Fossil SCM

Update the built-in SQLite to the latest 3.30.0 alpha, as an SQLite beta test.

drh 2019-09-04 15:41 UTC trunk
Commit f8823ae809f2fdc3a44407fbd6ea79ddb2aec88ae432fc8a7dfbcc65092ed6b7
3 files changed +188 -76 +4913 -3966 +56 -8
+188 -76
--- src/shell.c
+++ src/shell.c
@@ -9799,16 +9799,16 @@
97999799
sqlite3_result_error(context, "edit() cannot open temp file", -1);
98009800
goto edit_func_end;
98019801
}
98029802
sz = sqlite3_value_bytes(argv[0]);
98039803
if( bBin ){
9804
- x = fwrite(sqlite3_value_blob(argv[0]), 1, sz, f);
9804
+ x = fwrite(sqlite3_value_blob(argv[0]), 1, (size_t)sz, f);
98059805
}else{
98069806
const char *z = (const char*)sqlite3_value_text(argv[0]);
98079807
/* Remember whether or not the value originally contained \r\n */
98089808
if( z && strstr(z,"\r\n")!=0 ) hasCRNL = 1;
9809
- x = fwrite(sqlite3_value_text(argv[0]), 1, sz, f);
9809
+ x = fwrite(sqlite3_value_text(argv[0]), 1, (size_t)sz, f);
98109810
}
98119811
fclose(f);
98129812
f = 0;
98139813
if( x!=sz ){
98149814
sqlite3_result_error(context, "edit() could not write the whole file", -1);
@@ -9832,16 +9832,16 @@
98329832
goto edit_func_end;
98339833
}
98349834
fseek(f, 0, SEEK_END);
98359835
sz = ftell(f);
98369836
rewind(f);
9837
- p = sqlite3_malloc64( sz+(bBin==0) );
9837
+ p = sqlite3_malloc64( sz+1 );
98389838
if( p==0 ){
98399839
sqlite3_result_error_nomem(context);
98409840
goto edit_func_end;
98419841
}
9842
- x = fread(p, 1, sz, f);
9842
+ x = fread(p, 1, (size_t)sz, f);
98439843
fclose(f);
98449844
f = 0;
98459845
if( x!=sz ){
98469846
sqlite3_result_error(context, "could not read back the whole file", -1);
98479847
goto edit_func_end;
@@ -10309,11 +10309,12 @@
1030910309
int n = strlen30(p->sGraph.zPrefix);
1031010310
char *z;
1031110311
for(pRow = eqp_next_row(p, iEqpId, 0); pRow; pRow = pNext){
1031210312
pNext = eqp_next_row(p, iEqpId, pRow);
1031310313
z = pRow->zText;
10314
- utf8_printf(p->out, "%s%s%s\n", p->sGraph.zPrefix, pNext ? "|--" : "`--", z);
10314
+ utf8_printf(p->out, "%s%s%s\n", p->sGraph.zPrefix,
10315
+ pNext ? "|--" : "`--", z);
1031510316
if( n<(int)sizeof(p->sGraph.zPrefix)-7 ){
1031610317
memcpy(&p->sGraph.zPrefix[n], pNext ? "| " : " ", 4);
1031710318
eqp_render_level(p, pRow->iEqpId);
1031810319
p->sGraph.zPrefix[n] = 0;
1031910320
}
@@ -10500,11 +10501,11 @@
1050010501
z[j++] = c;
1050110502
}
1050210503
while( j>0 && IsSpace(z[j-1]) ){ j--; }
1050310504
z[j] = 0;
1050410505
if( strlen30(z)>=79 ){
10505
- for(i=j=0; (c = z[i])!=0; i++){ /* Copy changes from z[i] back to z[j] */
10506
+ for(i=j=0; (c = z[i])!=0; i++){ /* Copy from z[i] back to z[j] */
1050610507
if( c==cEnd ){
1050710508
cEnd = 0;
1050810509
}else if( c=='"' || c=='\'' || c=='`' ){
1050910510
cEnd = c;
1051010511
}else if( c=='[' ){
@@ -11079,11 +11080,11 @@
1107911080
raw_printf(pArg->out, "Sort Operations: %d\n", iCur);
1108011081
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
1108111082
raw_printf(pArg->out, "Autoindex Inserts: %d\n", iCur);
1108211083
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
1108311084
raw_printf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
11084
- iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_REPREPARE, bReset);
11085
+ iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_REPREPARE,bReset);
1108511086
raw_printf(pArg->out, "Reprepare operations: %d\n", iCur);
1108611087
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_RUN, bReset);
1108711088
raw_printf(pArg->out, "Number of times run: %d\n", iCur);
1108811089
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_MEMUSED, bReset);
1108911090
raw_printf(pArg->out, "Memory used by prepared stmt: %d\n", iCur);
@@ -12002,33 +12003,33 @@
1200212003
static const char *(azHelp[]) = {
1200312004
#if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
1200412005
".archive ... Manage SQL archives",
1200512006
" Each command must have exactly one of the following options:",
1200612007
" -c, --create Create a new archive",
12007
- " -u, --update Add files or update files with changed mtime",
12008
- " -i, --insert Like -u but always add even if mtime unchanged",
12008
+ " -u, --update Add or update files with changed mtime",
12009
+ " -i, --insert Like -u but always add even if unchanged",
1200912010
" -t, --list List contents of archive",
1201012011
" -x, --extract Extract files from archive",
1201112012
" Optional arguments:",
1201212013
" -v, --verbose Print each filename as it is processed",
12013
- " -f FILE, --file FILE Operate on archive FILE (default is current db)",
12014
- " -a FILE, --append FILE Operate on FILE opened using the apndvfs VFS",
12015
- " -C DIR, --directory DIR Change to directory DIR to read/extract files",
12014
+ " -f FILE, --file FILE Use archive FILE (default is current db)",
12015
+ " -a FILE, --append FILE Open FILE using the apndvfs VFS",
12016
+ " -C DIR, --directory DIR Read/extract files from directory DIR",
1201612017
" -n, --dryrun Show the SQL that would have occurred",
1201712018
" Examples:",
12018
- " .ar -cf archive.sar foo bar # Create archive.sar from files foo and bar",
12019
- " .ar -tf archive.sar # List members of archive.sar",
12020
- " .ar -xvf archive.sar # Verbosely extract files from archive.sar",
12019
+ " .ar -cf ARCHIVE foo bar # Create ARCHIVE from files foo and bar",
12020
+ " .ar -tf ARCHIVE # List members of ARCHIVE",
12021
+ " .ar -xvf ARCHIVE # Verbosely extract files from ARCHIVE",
1202112022
" See also:",
1202212023
" http://sqlite.org/cli.html#sqlar_archive_support",
1202312024
#endif
1202412025
#ifndef SQLITE_OMIT_AUTHORIZATION
1202512026
".auth ON|OFF Show authorizer callbacks",
1202612027
#endif
1202712028
".backup ?DB? FILE Backup DB (default \"main\") to FILE",
1202812029
" --append Use the appendvfs",
12029
- " --async Write to FILE without a journal and without fsync()",
12030
+ " --async Write to FILE without journal and fsync()",
1203012031
".bail on|off Stop after hitting an error. Default OFF",
1203112032
".binary on|off Turn binary output on or off. Default OFF",
1203212033
".cd DIRECTORY Change the working directory to DIRECTORY",
1203312034
".changes on|off Show number of rows changed by SQL",
1203412035
".check GLOB Fail if output since .testcase does not match",
@@ -12044,19 +12045,19 @@
1204412045
".echo on|off Turn command echo on or off",
1204512046
".eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN",
1204612047
" Other Modes:",
1204712048
#ifdef SQLITE_DEBUG
1204812049
" test Show raw EXPLAIN QUERY PLAN output",
12049
- " trace Like \"full\" but also enable \"PRAGMA vdbe_trace\"",
12050
+ " trace Like \"full\" but enable \"PRAGMA vdbe_trace\"",
1205012051
#endif
1205112052
" trigger Like \"full\" but also show trigger bytecode",
12052
- ".excel Display the output of next command in a spreadsheet",
12053
+ ".excel Display the output of next command in spreadsheet",
1205312054
".exit ?CODE? Exit this program with return-code CODE",
12054
- ".expert EXPERIMENTAL. Suggest indexes for specified queries",
12055
+ ".expert EXPERIMENTAL. Suggest indexes for queries",
1205512056
/* Because explain mode comes on automatically now, the ".explain" mode
12056
-** is removed from the help screen. It is still supported for legacy, however */
12057
-/*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic",*/
12057
+** is removed from the help screen. It is still supported for legacy, however */
12058
+/*".explain ?on|off|auto? Turn EXPLAIN output mode on or off",*/
1205812059
".filectrl CMD ... Run various sqlite3_file_control() operations",
1205912060
" Run \".filectrl\" with no arguments for details",
1206012061
".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
1206112062
".headers on|off Turn display of headers on or off",
1206212063
".help ?-all? ?PATTERN? Show help text for PATTERN",
@@ -12099,11 +12100,11 @@
1209912100
".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
1210012101
" Options:",
1210112102
" --append Use appendvfs to append database to the end of FILE",
1210212103
#ifdef SQLITE_ENABLE_DESERIALIZE
1210312104
" --deserialize Load into memory useing sqlite3_deserialize()",
12104
- " --hexdb Load the output of \"dbtotxt\" as an in-memory database",
12105
+ " --hexdb Load the output of \"dbtotxt\" as an in-memory db",
1210512106
" --maxsize N Maximum size for --hexdb or --deserialized database",
1210612107
#endif
1210712108
" --new Initialize FILE to an empty database",
1210812109
" --readonly Open FILE readonly",
1210912110
" --zip FILE is a ZIP archive",
@@ -12112,11 +12113,11 @@
1211212113
".parameter CMD ... Manage SQL parameter bindings",
1211312114
" clear Erase all bindings",
1211412115
" init Initialize the TEMP table that holds bindings",
1211512116
" list List the current parameter bindings",
1211612117
" set PARAMETER VALUE Given SQL parameter PARAMETER a value of VALUE",
12117
- " PARAMETER should start with '$', ':', '@', or '?'",
12118
+ " PARAMETER should start with one of: $ : @ ?",
1211812119
" unset PARAMETER Remove PARAMETER from the binding table",
1211912120
".print STRING... Print literal STRING",
1212012121
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
1212112122
".progress N Invoke progress handler after every N opcodes",
1212212123
" --limit N Interrupt after N progress callbacks",
@@ -12127,10 +12128,13 @@
1212712128
".prompt MAIN CONTINUE Replace the standard prompts",
1212812129
".quit Exit this program",
1212912130
".read FILE Read input from FILE",
1213012131
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
1213112132
".recover Recover as much data as possible from corrupt db.",
12133
+ " --freelist-corrupt Assume the freelist is corrupt",
12134
+ " --recovery-db NAME Store recovery metadata in database file NAME",
12135
+ " --lost-and-found TABLE Alternative name for the lost-and-found table",
1213212136
#endif
1213312137
".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
1213412138
".save FILE Write in-memory database into FILE",
1213512139
".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off",
1213612140
".schema ?PATTERN? Show the CREATE statements matching PATTERN",
@@ -12158,11 +12162,11 @@
1215812162
#endif
1215912163
".sha3sum ... Compute a SHA3 hash of database content",
1216012164
" Options:",
1216112165
" --schema Also hash the sqlite_master table",
1216212166
" --sha3-224 Use the sha3-224 algorithm",
12163
- " --sha3-256 Use the sha3-256 algorithm. This is the default.",
12167
+ " --sha3-256 Use the sha3-256 algorithm (default)",
1216412168
" --sha3-384 Use the sha3-384 algorithm",
1216512169
" --sha3-512 Use the sha3-512 algorithm",
1216612170
" Any other argument is a LIKE pattern for tables to hash",
1216712171
#ifndef SQLITE_NOHAVE_SYSTEM
1216812172
".shell CMD ARGS... Run CMD ARGS... in a system shell",
@@ -12192,10 +12196,14 @@
1219212196
" --stmt Trace statement execution (SQLITE_TRACE_STMT)",
1219312197
" --profile Profile statements (SQLITE_TRACE_PROFILE)",
1219412198
" --row Trace each row (SQLITE_TRACE_ROW)",
1219512199
" --close Trace connection close (SQLITE_TRACE_CLOSE)",
1219612200
#endif /* SQLITE_OMIT_TRACE */
12201
+#ifdef SQLITE_DEBUG
12202
+ ".unmodule NAME ... Unregister virtual table modules",
12203
+ " --allexcept Unregister everything except those named",
12204
+#endif
1219712205
".vfsinfo ?AUX? Information about the top-level VFS",
1219812206
".vfslist List all available VFSes",
1219912207
".vfsname ?AUX? Print the name of the VFS stack",
1220012208
".width NUM1 NUM2 ... Set column widths for \"column\" mode",
1220112209
" Negative values right-justify",
@@ -12434,10 +12442,12 @@
1243412442
nLine++;
1243512443
if( fgets(zLine, sizeof(zLine), in)==0 ) goto readHexDb_error;
1243612444
rc = sscanf(zLine, "| size %d pagesize %d", &n, &pgsz);
1243712445
if( rc!=2 ) goto readHexDb_error;
1243812446
if( n<0 ) goto readHexDb_error;
12447
+ if( pgsz<512 || pgsz>65536 || (pgsz&(pgsz-1))!=0 ) goto readHexDb_error;
12448
+ n = (n+pgsz-1)&~(pgsz-1); /* Round n up to the next multiple of pgsz */
1243912449
a = sqlite3_malloc( n ? n : 1 );
1244012450
if( a==0 ){
1244112451
utf8_printf(stderr, "Out of memory!\n");
1244212452
goto readHexDb_error;
1244312453
}
@@ -12517,10 +12527,27 @@
1251712527
+ ((sqlite3_int64)a[2]<< 8)
1251812528
+ ((sqlite3_int64)a[3]<< 0);
1251912529
sqlite3_result_int64(context, iVal);
1252012530
}
1252112531
}
12532
+
12533
+/*
12534
+** Scalar function "shell_idquote(X)" returns string X quoted as an identifier,
12535
+** using "..." with internal double-quote characters doubled.
12536
+*/
12537
+static void shellIdQuote(
12538
+ sqlite3_context *context,
12539
+ int argc,
12540
+ sqlite3_value **argv
12541
+){
12542
+ const char *zName = (const char*)sqlite3_value_text(argv[0]);
12543
+ UNUSED_PARAMETER(argc);
12544
+ if( zName ){
12545
+ char *z = sqlite3_mprintf("\"%w\"", zName);
12546
+ sqlite3_result_text(context, z, -1, sqlite3_free);
12547
+ }
12548
+}
1252212549
1252312550
/*
1252412551
** Scalar function "shell_escape_crnl" used by the .recover command.
1252512552
** The argument passed to this function is the output of built-in
1252612553
** function quote(). If the first character of the input is "'",
@@ -12694,10 +12721,12 @@
1269412721
shellPutsFunc, 0, 0);
1269512722
sqlite3_create_function(p->db, "shell_escape_crnl", 1, SQLITE_UTF8, 0,
1269612723
shellEscapeCrnl, 0, 0);
1269712724
sqlite3_create_function(p->db, "shell_int32", 2, SQLITE_UTF8, 0,
1269812725
shellInt32, 0, 0);
12726
+ sqlite3_create_function(p->db, "shell_idquote", 1, SQLITE_UTF8, 0,
12727
+ shellIdQuote, 0, 0);
1269912728
#ifndef SQLITE_NOHAVE_SYSTEM
1270012729
sqlite3_create_function(p->db, "edit", 1, SQLITE_UTF8, 0,
1270112730
editFunc, 0, 0);
1270212731
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
1270312732
editFunc, 0, 0);
@@ -14041,11 +14070,11 @@
1404114070
}
1404214071
}
1404314072
#endif /* !defined SQLITE_OMIT_VIRTUALTABLE */
1404414073
1404514074
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
14046
-/*********************************************************************************
14075
+/******************************************************************************
1404714076
** The ".archive" or ".ar" command.
1404814077
*/
1404914078
/*
1405014079
** Structure representing a single ".ar" command.
1405114080
*/
@@ -14239,11 +14268,12 @@
1423914268
if( i<(n-1) ){
1424014269
zArg = &z[i+1];
1424114270
i = n;
1424214271
}else{
1424314272
if( iArg>=(nArg-1) ){
14244
- return arErrorMsg(pAr, "option requires an argument: %c",z[i]);
14273
+ return arErrorMsg(pAr, "option requires an argument: %c",
14274
+ z[i]);
1424514275
}
1424614276
zArg = azArg[++iArg];
1424714277
}
1424814278
}
1424914279
if( arProcessSwitch(pAr, pOpt->eSwitch, zArg) ) return SQLITE_ERROR;
@@ -14627,14 +14657,14 @@
1462714657
1462814658
/*
1462914659
** Implementation of ".ar" dot command.
1463014660
*/
1463114661
static int arDotCommand(
14632
- ShellState *pState, /* Current shell tool state */
14633
- int fromCmdLine, /* True if -A command-line option, not .ar cmd */
14634
- char **azArg, /* Array of arguments passed to dot command */
14635
- int nArg /* Number of entries in azArg[] */
14662
+ ShellState *pState, /* Current shell tool state */
14663
+ int fromCmdLine, /* True if -A command-line option, not .ar cmd */
14664
+ char **azArg, /* Array of arguments passed to dot command */
14665
+ int nArg /* Number of entries in azArg[] */
1463614666
){
1463714667
ArCommand cmd;
1463814668
int rc;
1463914669
memset(&cmd, 0, sizeof(cmd));
1464014670
cmd.fromCmdLine = fromCmdLine;
@@ -14730,11 +14760,11 @@
1473014760
sqlite3_free(cmd.zSrcTable);
1473114761
1473214762
return rc;
1473314763
}
1473414764
/* End of the ".archive" or ".ar" command logic
14735
-**********************************************************************************/
14765
+*******************************************************************************/
1473614766
#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) */
1473714767
1473814768
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
1473914769
/*
1474014770
** If (*pRc) is not SQLITE_OK when this function is called, it is a no-op.
@@ -14871,10 +14901,14 @@
1487114901
int nSqlCol = 0;
1487214902
int bSqlIntkey = 0;
1487314903
sqlite3_stmt *pStmt = 0;
1487414904
1487514905
rc = sqlite3_open("", &dbtmp);
14906
+ if( rc==SQLITE_OK ){
14907
+ sqlite3_create_function(dbtmp, "shell_idquote", 1, SQLITE_UTF8, 0,
14908
+ shellIdQuote, 0, 0);
14909
+ }
1487614910
if( rc==SQLITE_OK ){
1487714911
rc = sqlite3_exec(dbtmp, "PRAGMA writable_schema = on", 0, 0, 0);
1487814912
}
1487914913
if( rc==SQLITE_OK ){
1488014914
rc = sqlite3_exec(dbtmp, zSql, 0, 0, 0);
@@ -14927,22 +14961,22 @@
1492714961
pTab->iPk = sqlite3_column_int(pPkFinder, 0);
1492814962
zPk = (const char*)sqlite3_column_text(pPkFinder, 1);
1492914963
}
1493014964
}
1493114965
14932
- pTab->zQuoted = shellMPrintf(&rc, "%Q", zName);
14966
+ pTab->zQuoted = shellMPrintf(&rc, "\"%w\"", zName);
1493314967
pTab->azlCol = (char**)shellMalloc(&rc, sizeof(char*) * (nSqlCol+1));
1493414968
pTab->nCol = nSqlCol;
1493514969
1493614970
if( bIntkey ){
14937
- pTab->azlCol[0] = shellMPrintf(&rc, "%Q", zPk);
14971
+ pTab->azlCol[0] = shellMPrintf(&rc, "\"%w\"", zPk);
1493814972
}else{
1493914973
pTab->azlCol[0] = shellMPrintf(&rc, "");
1494014974
}
1494114975
i = 1;
1494214976
shellPreparePrintf(dbtmp, &rc, &pStmt,
14943
- "SELECT %Q || group_concat(name, ', ') "
14977
+ "SELECT %Q || group_concat(shell_idquote(name), ', ') "
1494414978
" FILTER (WHERE cid!=%d) OVER (ORDER BY %s cid) "
1494514979
"FROM pragma_table_info(%Q)",
1494614980
bIntkey ? ", " : "", pTab->iPk,
1494714981
bIntkey ? "" : "(CASE WHEN pk=0 THEN 1000000 ELSE pk END), ",
1494814982
zName
@@ -15052,11 +15086,11 @@
1505215086
}
1505315087
shellFinalize(pRc, pTest);
1505415088
1505515089
pTab = (RecoverTable*)shellMalloc(pRc, sizeof(RecoverTable));
1505615090
if( pTab ){
15057
- pTab->zQuoted = shellMPrintf(pRc, "%Q", zTab);
15091
+ pTab->zQuoted = shellMPrintf(pRc, "\"%w\"", zTab);
1505815092
pTab->nCol = nCol;
1505915093
pTab->iPk = -2;
1506015094
if( nCol>0 ){
1506115095
pTab->azlCol = (char**)shellMalloc(pRc, sizeof(char*) * (nCol+1));
1506215096
if( pTab->azlCol ){
@@ -15118,22 +15152,20 @@
1511815152
if( n<=15 && memcmp("-lost-and-found", z, n)==0 && i<(nArg-1) ){
1511915153
i++;
1512015154
zLostAndFound = azArg[i];
1512115155
}
1512215156
else{
15123
- raw_printf(stderr, "unexpected option: %s\n", azArg[i]);
15124
- raw_printf(stderr, "options are:\n");
15125
- raw_printf(stderr, " --freelist-corrupt\n");
15126
- raw_printf(stderr, " --recovery-db DATABASE\n");
15127
- raw_printf(stderr, " --lost-and-found TABLE-NAME\n");
15157
+ utf8_printf(stderr, "unexpected option: %s\n", azArg[i]);
15158
+ showHelp(pState->out, azArg[0]);
1512815159
return 1;
1512915160
}
1513015161
}
1513115162
1513215163
shellExecPrintf(pState->db, &rc,
1513315164
/* Attach an in-memory database named 'recovery'. Create an indexed
1513415165
** cache of the sqlite_dbptr virtual table. */
15166
+ "PRAGMA writable_schema = on;"
1513515167
"ATTACH %Q AS recovery;"
1513615168
"DROP TABLE IF EXISTS recovery.dbptr;"
1513715169
"DROP TABLE IF EXISTS recovery.freelist;"
1513815170
"DROP TABLE IF EXISTS recovery.map;"
1513915171
"DROP TABLE IF EXISTS recovery.schema;"
@@ -15159,10 +15191,25 @@
1515915191
" FROM freelist WHERE n>=0"
1516015192
")"
1516115193
"REPLACE INTO recovery.freelist SELECT freepgno FROM freelist;"
1516215194
);
1516315195
}
15196
+
15197
+ /* If this is an auto-vacuum database, add all pointer-map pages to
15198
+ ** the freelist table. Do this regardless of whether or not
15199
+ ** --freelist-corrupt was specified. */
15200
+ shellExec(pState->db, &rc,
15201
+ "WITH ptrmap(pgno) AS ("
15202
+ " SELECT 2 WHERE shell_int32("
15203
+ " (SELECT data FROM sqlite_dbpage WHERE pgno=1), 13"
15204
+ " )"
15205
+ " UNION ALL "
15206
+ " SELECT pgno+1+(SELECT page_size FROM pragma_page_size)/5 AS pp "
15207
+ " FROM ptrmap WHERE pp<=(SELECT page_count FROM pragma_page_count)"
15208
+ ")"
15209
+ "REPLACE INTO recovery.freelist SELECT pgno FROM ptrmap"
15210
+ );
1516415211
1516515212
shellExec(pState->db, &rc,
1516615213
"CREATE TABLE recovery.dbptr("
1516715214
" pgno, child, PRIMARY KEY(child, pgno)"
1516815215
") WITHOUT ROWID;"
@@ -15208,11 +15255,11 @@
1520815255
" SELECT i, p.parent, "
1520915256
" (SELECT pgno FROM recovery.dbptr WHERE child=p.parent) FROM p"
1521015257
" )"
1521115258
" SELECT pgno FROM p WHERE (parent IS NULL OR pgno = orig)"
1521215259
") "
15213
- "FROM pages WHERE maxlen > 0 AND i NOT IN freelist;"
15260
+ "FROM pages WHERE maxlen IS NOT NULL AND i NOT IN freelist;"
1521415261
"UPDATE recovery.map AS o SET intkey = ("
1521515262
" SELECT substr(data, 1, 1)==X'0D' FROM sqlite_dbpage WHERE pgno=o.pgno"
1521615263
");"
1521715264
1521815265
/* Extract data from page 1 and any linked pages into table
@@ -15233,10 +15280,15 @@
1523315280
1523415281
/* Open a transaction, then print out all non-virtual, non-"sqlite_%"
1523515282
** CREATE TABLE statements that extracted from the existing schema. */
1523615283
if( rc==SQLITE_OK ){
1523715284
sqlite3_stmt *pStmt = 0;
15285
+ /* ".recover" might output content in an order which causes immediate
15286
+ ** foreign key constraints to be violated. So disable foreign-key
15287
+ ** constraint enforcement to prevent problems when running the output
15288
+ ** script. */
15289
+ raw_printf(pState->out, "PRAGMA foreign_keys=OFF;\n");
1523815290
raw_printf(pState->out, "BEGIN;\n");
1523915291
raw_printf(pState->out, "PRAGMA writable_schema = on;\n");
1524015292
shellPrepare(pState->db, &rc,
1524115293
"SELECT sql FROM recovery.schema "
1524215294
"WHERE type='table' AND sql LIKE 'create table%'", &pStmt
@@ -15265,10 +15317,11 @@
1526515317
shellPrepare(pState->db, &rc,
1526615318
"SELECT pgno FROM recovery.map WHERE root=?", &pPages
1526715319
);
1526815320
shellPrepare(pState->db, &rc,
1526915321
"SELECT max(field), group_concat(shell_escape_crnl(quote(value)), ', ')"
15322
+ ", min(field) "
1527015323
"FROM sqlite_dbdata WHERE pgno = ? AND field != ?"
1527115324
"GROUP BY cell", &pCells
1527215325
);
1527315326
1527415327
/* Loop through each root page. */
@@ -15283,10 +15336,11 @@
1528315336
int bIntkey = sqlite3_column_int(pLoop, 1);
1528415337
int nCol = sqlite3_column_int(pLoop, 2);
1528515338
int bNoop = 0;
1528615339
RecoverTable *pTab;
1528715340
15341
+ assert( bIntkey==0 || bIntkey==1 );
1528815342
pTab = recoverFindTable(pState, &rc, iRoot, bIntkey, nCol, &bNoop);
1528915343
if( bNoop || rc ) continue;
1529015344
if( pTab==0 ){
1529115345
if( pOrphan==0 ){
1529215346
pOrphan = recoverOrphanTable(pState, &rc, zLostAndFound, nOrphan);
@@ -15293,11 +15347,11 @@
1529315347
}
1529415348
pTab = pOrphan;
1529515349
if( pTab==0 ) break;
1529615350
}
1529715351
15298
- if( 0==sqlite3_stricmp(pTab->zQuoted, "'sqlite_sequence'") ){
15352
+ if( 0==sqlite3_stricmp(pTab->zQuoted, "\"sqlite_sequence\"") ){
1529915353
raw_printf(pState->out, "DELETE FROM sqlite_sequence;\n");
1530015354
}
1530115355
sqlite3_bind_int(pPages, 1, iRoot);
1530215356
sqlite3_bind_int(pCells, 2, pTab->iPk);
1530315357
@@ -15304,22 +15358,32 @@
1530415358
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pPages) ){
1530515359
int iPgno = sqlite3_column_int(pPages, 0);
1530615360
sqlite3_bind_int(pCells, 1, iPgno);
1530715361
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pCells) ){
1530815362
int nField = sqlite3_column_int(pCells, 0);
15363
+ int iMin = sqlite3_column_int(pCells, 2);
1530915364
const char *zVal = (const char*)sqlite3_column_text(pCells, 1);
15365
+
15366
+ RecoverTable *pTab2 = pTab;
15367
+ if( pTab!=pOrphan && (iMin<0)!=bIntkey ){
15368
+ if( pOrphan==0 ){
15369
+ pOrphan = recoverOrphanTable(pState, &rc, zLostAndFound, nOrphan);
15370
+ }
15371
+ pTab2 = pOrphan;
15372
+ if( pTab2==0 ) break;
15373
+ }
1531015374
1531115375
nField = nField+1;
15312
- if( pTab==pOrphan ){
15376
+ if( pTab2==pOrphan ){
1531315377
raw_printf(pState->out,
1531415378
"INSERT INTO %s VALUES(%d, %d, %d, %s%s%s);\n",
15315
- pTab->zQuoted, iRoot, iPgno, nField,
15316
- bIntkey ? "" : "NULL, ", zVal, pTab->azlCol[nField]
15379
+ pTab2->zQuoted, iRoot, iPgno, nField,
15380
+ iMin<0 ? "" : "NULL, ", zVal, pTab2->azlCol[nField]
1531715381
);
1531815382
}else{
1531915383
raw_printf(pState->out, "INSERT INTO %s(%s) VALUES( %s );\n",
15320
- pTab->zQuoted, pTab->azlCol[nField], zVal
15384
+ pTab2->zQuoted, pTab2->azlCol[nField], zVal
1532115385
);
1532215386
}
1532315387
}
1532415388
shellReset(&rc, pCells);
1532515389
}
@@ -15374,21 +15438,21 @@
1537415438
static int do_meta_command(char *zLine, ShellState *p){
1537515439
int h = 1;
1537615440
int nArg = 0;
1537715441
int n, c;
1537815442
int rc = 0;
15379
- char *azArg[50];
15443
+ char *azArg[52];
1538015444
1538115445
#ifndef SQLITE_OMIT_VIRTUALTABLE
1538215446
if( p->expert.pExpert ){
1538315447
expertFinish(p, 1, 0);
1538415448
}
1538515449
#endif
1538615450
1538715451
/* Parse the input line into tokens.
1538815452
*/
15389
- while( zLine[h] && nArg<ArraySize(azArg) ){
15453
+ while( zLine[h] && nArg<ArraySize(azArg)-1 ){
1539015454
while( IsSpace(zLine[h]) ){ h++; }
1539115455
if( zLine[h]==0 ) break;
1539215456
if( zLine[h]=='\'' || zLine[h]=='"' ){
1539315457
int delim = zLine[h++];
1539415458
azArg[nArg++] = &zLine[h];
@@ -15405,10 +15469,11 @@
1540515469
while( zLine[h] && !IsSpace(zLine[h]) ){ h++; }
1540615470
if( zLine[h] ) zLine[h++] = 0;
1540715471
resolve_backslashes(azArg[nArg-1]);
1540815472
}
1540915473
}
15474
+ azArg[nArg] = 0;
1541015475
1541115476
/* Process the input line.
1541215477
*/
1541315478
if( nArg==0 ) return 0; /* no tokens, no error */
1541415479
n = strlen30(azArg[0]);
@@ -15620,10 +15685,11 @@
1562015685
const char *zName;
1562115686
int op;
1562215687
} aDbConfig[] = {
1562315688
{ "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
1562415689
{ "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
15690
+ { "enable_view", SQLITE_DBCONFIG_ENABLE_VIEW },
1562515691
{ "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
1562615692
{ "load_extension", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
1562715693
{ "no_ckpt_on_close", SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
1562815694
{ "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
1562915695
{ "trigger_eqp", SQLITE_DBCONFIG_TRIGGER_EQP },
@@ -15993,12 +16059,10 @@
1599316059
sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_master'",
1599416060
callback, &data, &zErrMsg);
1599516061
data.cMode = data.mode = MODE_Insert;
1599616062
data.zDestTable = "sqlite_stat1";
1599716063
shell_exec(&data, "SELECT * FROM sqlite_stat1", &zErrMsg);
15998
- data.zDestTable = "sqlite_stat3";
15999
- shell_exec(&data, "SELECT * FROM sqlite_stat3", &zErrMsg);
1600016064
data.zDestTable = "sqlite_stat4";
1600116065
shell_exec(&data, "SELECT * FROM sqlite_stat4", &zErrMsg);
1600216066
raw_printf(p->out, "ANALYZE sqlite_master;\n");
1600316067
}
1600416068
}else
@@ -16944,15 +17008,16 @@
1694417008
appendText(&sSelect, " AS sname FROM ", 0);
1694517009
appendText(&sSelect, zDb, quoteChar(zDb));
1694617010
appendText(&sSelect, ".sqlite_master", 0);
1694717011
}
1694817012
sqlite3_finalize(pStmt);
16949
-#ifdef SQLITE_INTROSPECTION_PRAGMAS
17013
+#ifndef SQLITE_OMIT_INTROSPECTION_PRAGMAS
1695017014
if( zName ){
1695117015
appendText(&sSelect,
1695217016
" UNION ALL SELECT shell_module_schema(name),"
16953
- " 'table', name, name, name, 9e+99, 'main' FROM pragma_module_list", 0);
17017
+ " 'table', name, name, name, 9e+99, 'main' FROM pragma_module_list",
17018
+ 0);
1695417019
}
1695517020
#endif
1695617021
appendText(&sSelect, ") WHERE ", 0);
1695717022
if( zName ){
1695817023
char *zQarg = sqlite3_mprintf("%Q", zName);
@@ -17047,11 +17112,12 @@
1704717112
FILE *out = 0;
1704817113
if( nCmd!=2 ) goto session_syntax_error;
1704917114
if( pSession->p==0 ) goto session_not_open;
1705017115
out = fopen(azCmd[1], "wb");
1705117116
if( out==0 ){
17052
- utf8_printf(stderr, "ERROR: cannot open \"%s\" for writing\n", azCmd[1]);
17117
+ utf8_printf(stderr, "ERROR: cannot open \"%s\" for writing\n",
17118
+ azCmd[1]);
1705317119
}else{
1705417120
int szChng;
1705517121
void *pChng;
1705617122
if( azCmd[0][0]=='c' ){
1705717123
rc = sqlite3session_changeset(pSession->p, &szChng, &pChng);
@@ -17368,12 +17434,11 @@
1736817434
bDebug = 1;
1736917435
}else
1737017436
{
1737117437
utf8_printf(stderr, "Unknown option \"%s\" on \"%s\"\n",
1737217438
azArg[i], azArg[0]);
17373
- raw_printf(stderr, "Should be one of: --schema"
17374
- " --sha3-224 --sha3-256 --sha3-384 --sha3-512\n");
17439
+ showHelp(p->out, azArg[0]);
1737517440
rc = 1;
1737617441
goto meta_command_exit;
1737717442
}
1737817443
}else if( zLike ){
1737917444
raw_printf(stderr, "Usage: .sha3sum ?OPTIONS? ?LIKE-PATTERN?\n");
@@ -17415,12 +17480,11 @@
1741517480
appendText(&sQuery,"SELECT name,seq FROM sqlite_sequence"
1741617481
" ORDER BY name;", 0);
1741717482
}else if( strcmp(zTab, "sqlite_stat1")==0 ){
1741817483
appendText(&sQuery,"SELECT tbl,idx,stat FROM sqlite_stat1"
1741917484
" ORDER BY tbl,idx;", 0);
17420
- }else if( strcmp(zTab, "sqlite_stat3")==0
17421
- || strcmp(zTab, "sqlite_stat4")==0 ){
17485
+ }else if( strcmp(zTab, "sqlite_stat4")==0 ){
1742217486
appendText(&sQuery, "SELECT * FROM ", 0);
1742317487
appendText(&sQuery, zTab, 0);
1742417488
appendText(&sQuery, " ORDER BY tbl, idx, rowid;\n", 0);
1742517489
}
1742617490
appendText(&sSql, zSep, 0);
@@ -17648,29 +17712,30 @@
1764817712
static const struct {
1764917713
const char *zCtrlName; /* Name of a test-control option */
1765017714
int ctrlCode; /* Integer code for that option */
1765117715
const char *zUsage; /* Usage notes */
1765217716
} aCtrl[] = {
17653
- { "always", SQLITE_TESTCTRL_ALWAYS, "BOOLEAN" },
17654
- { "assert", SQLITE_TESTCTRL_ASSERT, "BOOLEAN" },
17655
- /*{ "benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, "" },*/
17656
- /*{ "bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, "" },*/
17657
- { "byteorder", SQLITE_TESTCTRL_BYTEORDER, "" },
17658
- /*{ "fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, "" }, */
17659
- { "imposter", SQLITE_TESTCTRL_IMPOSTER, "SCHEMA ON/OFF ROOTPAGE"},
17660
- { "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, "BOOLEAN" },
17661
- { "localtime_fault", SQLITE_TESTCTRL_LOCALTIME_FAULT,"BOOLEAN" },
17662
- { "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT, "BOOLEAN" },
17663
- { "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS, "DISABLE-MASK" },
17717
+ { "always", SQLITE_TESTCTRL_ALWAYS, "BOOLEAN" },
17718
+ { "assert", SQLITE_TESTCTRL_ASSERT, "BOOLEAN" },
17719
+ /*{ "benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, "" },*/
17720
+ /*{ "bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, "" },*/
17721
+ { "byteorder", SQLITE_TESTCTRL_BYTEORDER, "" },
17722
+ { "extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,"BOOLEAN" },
17723
+ /*{ "fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, "" },*/
17724
+ { "imposter", SQLITE_TESTCTRL_IMPOSTER, "SCHEMA ON/OFF ROOTPAGE"},
17725
+ { "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, "BOOLEAN" },
17726
+ { "localtime_fault", SQLITE_TESTCTRL_LOCALTIME_FAULT,"BOOLEAN" },
17727
+ { "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT, "BOOLEAN" },
17728
+ { "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS, "DISABLE-MASK" },
1766417729
#ifdef YYCOVERAGE
17665
- { "parser_coverage", SQLITE_TESTCTRL_PARSER_COVERAGE, "" },
17730
+ { "parser_coverage", SQLITE_TESTCTRL_PARSER_COVERAGE, "" },
1766617731
#endif
17667
- { "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE, "OFFSET " },
17668
- { "prng_reset", SQLITE_TESTCTRL_PRNG_RESET, "" },
17669
- { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE, "" },
17670
- { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, "" },
17671
- { "reserve", SQLITE_TESTCTRL_RESERVE, "BYTES-OF-RESERVE" },
17732
+ { "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE, "OFFSET " },
17733
+ { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE, "" },
17734
+ { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, "" },
17735
+ { "prng_seed", SQLITE_TESTCTRL_PRNG_SEED, "SEED ?db?" },
17736
+ { "reserve", SQLITE_TESTCTRL_RESERVE, "BYTES-OF-RESERVE"},
1767217737
};
1767317738
int testctrl = -1;
1767417739
int iCtrl = -1;
1767517740
int rc2 = 0; /* 0: usage. 1: %d 2: %x 3: no-output */
1767617741
int isOk = 0;
@@ -17746,10 +17811,31 @@
1774617811
unsigned int opt = (unsigned int)integerValue(azArg[2]);
1774717812
rc2 = sqlite3_test_control(testctrl, opt);
1774817813
isOk = 3;
1774917814
}
1775017815
break;
17816
+
17817
+ /* sqlite3_test_control(int, int, sqlite3*) */
17818
+ case SQLITE_TESTCTRL_PRNG_SEED:
17819
+ if( nArg==3 || nArg==4 ){
17820
+ int ii = (int)integerValue(azArg[2]);
17821
+ sqlite3 *db;
17822
+ if( ii==0 && strcmp(azArg[2],"random")==0 ){
17823
+ sqlite3_randomness(sizeof(ii),&ii);
17824
+ printf("-- random seed: %d\n", ii);
17825
+ }
17826
+ if( nArg==3 ){
17827
+ db = 0;
17828
+ }else{
17829
+ db = p->db;
17830
+ /* Make sure the schema has been loaded */
17831
+ sqlite3_table_column_metadata(db, 0, "x", 0, 0, 0, 0, 0, 0);
17832
+ }
17833
+ rc2 = sqlite3_test_control(testctrl, ii, db);
17834
+ isOk = 3;
17835
+ }
17836
+ break;
1775117837
1775217838
/* sqlite3_test_control(int, int) */
1775317839
case SQLITE_TESTCTRL_ASSERT:
1775417840
case SQLITE_TESTCTRL_ALWAYS:
1775517841
case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS:
@@ -17788,11 +17874,11 @@
1778817874
}
1778917875
#endif
1779017876
}
1779117877
}
1779217878
if( isOk==0 && iCtrl>=0 ){
17793
- utf8_printf(p->out, "Usage: .testctrl %s %s\n", zCmd, aCtrl[iCtrl].zUsage);
17879
+ utf8_printf(p->out, "Usage: .testctrl %s %s\n", zCmd,aCtrl[iCtrl].zUsage);
1779417880
rc = 1;
1779517881
}else if( isOk==1 ){
1779617882
raw_printf(p->out, "%d\n", rc2);
1779717883
}else if( isOk==2 ){
1779817884
raw_printf(p->out, "0x%08x\n", rc2);
@@ -17865,10 +17951,35 @@
1786517951
if( mType==0 ) mType = SQLITE_TRACE_STMT;
1786617952
sqlite3_trace_v2(p->db, mType, sql_trace_callback, p);
1786717953
}
1786817954
}else
1786917955
#endif /* !defined(SQLITE_OMIT_TRACE) */
17956
+
17957
+#ifdef SQLITE_DEBUG
17958
+ if( c=='u' && strncmp(azArg[0], "unmodule", n)==0 ){
17959
+ int ii;
17960
+ int lenOpt;
17961
+ char *zOpt;
17962
+ if( nArg<2 ){
17963
+ raw_printf(stderr, "Usage: .unmodule [--allexcept] NAME ...\n");
17964
+ rc = 1;
17965
+ goto meta_command_exit;
17966
+ }
17967
+ open_db(p, 0);
17968
+ zOpt = azArg[1];
17969
+ if( zOpt[0]=='-' && zOpt[1]=='-' && zOpt[2]!=0 ) zOpt++;
17970
+ lenOpt = (int)strlen(zOpt);
17971
+ if( lenOpt>=3 && strncmp(zOpt, "-allexcept",lenOpt)==0 ){
17972
+ assert( azArg[nArg]==0 );
17973
+ sqlite3_drop_modules(p->db, nArg>2 ? (const char**)(azArg+2) : 0);
17974
+ }else{
17975
+ for(ii=1; ii<nArg; ii++){
17976
+ sqlite3_create_module(p->db, azArg[ii], 0, 0);
17977
+ }
17978
+ }
17979
+ }else
17980
+#endif
1787017981
1787117982
#if SQLITE_USER_AUTHENTICATION
1787217983
if( c=='u' && strncmp(azArg[0], "user", n)==0 ){
1787317984
if( nArg<2 ){
1787417985
raw_printf(stderr, "Usage: .user SUBCOMMAND ...\n");
@@ -17880,11 +17991,12 @@
1788017991
if( nArg!=4 ){
1788117992
raw_printf(stderr, "Usage: .user login USER PASSWORD\n");
1788217993
rc = 1;
1788317994
goto meta_command_exit;
1788417995
}
17885
- rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3], strlen30(azArg[3]));
17996
+ rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3],
17997
+ strlen30(azArg[3]));
1788617998
if( rc ){
1788717999
utf8_printf(stderr, "Authentication failed for user %s\n", azArg[2]);
1788818000
rc = 1;
1788918001
}
1789018002
}else if( strcmp(azArg[1],"add")==0 ){
1789118003
--- src/shell.c
+++ src/shell.c
@@ -9799,16 +9799,16 @@
9799 sqlite3_result_error(context, "edit() cannot open temp file", -1);
9800 goto edit_func_end;
9801 }
9802 sz = sqlite3_value_bytes(argv[0]);
9803 if( bBin ){
9804 x = fwrite(sqlite3_value_blob(argv[0]), 1, sz, f);
9805 }else{
9806 const char *z = (const char*)sqlite3_value_text(argv[0]);
9807 /* Remember whether or not the value originally contained \r\n */
9808 if( z && strstr(z,"\r\n")!=0 ) hasCRNL = 1;
9809 x = fwrite(sqlite3_value_text(argv[0]), 1, sz, f);
9810 }
9811 fclose(f);
9812 f = 0;
9813 if( x!=sz ){
9814 sqlite3_result_error(context, "edit() could not write the whole file", -1);
@@ -9832,16 +9832,16 @@
9832 goto edit_func_end;
9833 }
9834 fseek(f, 0, SEEK_END);
9835 sz = ftell(f);
9836 rewind(f);
9837 p = sqlite3_malloc64( sz+(bBin==0) );
9838 if( p==0 ){
9839 sqlite3_result_error_nomem(context);
9840 goto edit_func_end;
9841 }
9842 x = fread(p, 1, sz, f);
9843 fclose(f);
9844 f = 0;
9845 if( x!=sz ){
9846 sqlite3_result_error(context, "could not read back the whole file", -1);
9847 goto edit_func_end;
@@ -10309,11 +10309,12 @@
10309 int n = strlen30(p->sGraph.zPrefix);
10310 char *z;
10311 for(pRow = eqp_next_row(p, iEqpId, 0); pRow; pRow = pNext){
10312 pNext = eqp_next_row(p, iEqpId, pRow);
10313 z = pRow->zText;
10314 utf8_printf(p->out, "%s%s%s\n", p->sGraph.zPrefix, pNext ? "|--" : "`--", z);
 
10315 if( n<(int)sizeof(p->sGraph.zPrefix)-7 ){
10316 memcpy(&p->sGraph.zPrefix[n], pNext ? "| " : " ", 4);
10317 eqp_render_level(p, pRow->iEqpId);
10318 p->sGraph.zPrefix[n] = 0;
10319 }
@@ -10500,11 +10501,11 @@
10500 z[j++] = c;
10501 }
10502 while( j>0 && IsSpace(z[j-1]) ){ j--; }
10503 z[j] = 0;
10504 if( strlen30(z)>=79 ){
10505 for(i=j=0; (c = z[i])!=0; i++){ /* Copy changes from z[i] back to z[j] */
10506 if( c==cEnd ){
10507 cEnd = 0;
10508 }else if( c=='"' || c=='\'' || c=='`' ){
10509 cEnd = c;
10510 }else if( c=='[' ){
@@ -11079,11 +11080,11 @@
11079 raw_printf(pArg->out, "Sort Operations: %d\n", iCur);
11080 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
11081 raw_printf(pArg->out, "Autoindex Inserts: %d\n", iCur);
11082 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
11083 raw_printf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
11084 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_REPREPARE, bReset);
11085 raw_printf(pArg->out, "Reprepare operations: %d\n", iCur);
11086 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_RUN, bReset);
11087 raw_printf(pArg->out, "Number of times run: %d\n", iCur);
11088 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_MEMUSED, bReset);
11089 raw_printf(pArg->out, "Memory used by prepared stmt: %d\n", iCur);
@@ -12002,33 +12003,33 @@
12002 static const char *(azHelp[]) = {
12003 #if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
12004 ".archive ... Manage SQL archives",
12005 " Each command must have exactly one of the following options:",
12006 " -c, --create Create a new archive",
12007 " -u, --update Add files or update files with changed mtime",
12008 " -i, --insert Like -u but always add even if mtime unchanged",
12009 " -t, --list List contents of archive",
12010 " -x, --extract Extract files from archive",
12011 " Optional arguments:",
12012 " -v, --verbose Print each filename as it is processed",
12013 " -f FILE, --file FILE Operate on archive FILE (default is current db)",
12014 " -a FILE, --append FILE Operate on FILE opened using the apndvfs VFS",
12015 " -C DIR, --directory DIR Change to directory DIR to read/extract files",
12016 " -n, --dryrun Show the SQL that would have occurred",
12017 " Examples:",
12018 " .ar -cf archive.sar foo bar # Create archive.sar from files foo and bar",
12019 " .ar -tf archive.sar # List members of archive.sar",
12020 " .ar -xvf archive.sar # Verbosely extract files from archive.sar",
12021 " See also:",
12022 " http://sqlite.org/cli.html#sqlar_archive_support",
12023 #endif
12024 #ifndef SQLITE_OMIT_AUTHORIZATION
12025 ".auth ON|OFF Show authorizer callbacks",
12026 #endif
12027 ".backup ?DB? FILE Backup DB (default \"main\") to FILE",
12028 " --append Use the appendvfs",
12029 " --async Write to FILE without a journal and without fsync()",
12030 ".bail on|off Stop after hitting an error. Default OFF",
12031 ".binary on|off Turn binary output on or off. Default OFF",
12032 ".cd DIRECTORY Change the working directory to DIRECTORY",
12033 ".changes on|off Show number of rows changed by SQL",
12034 ".check GLOB Fail if output since .testcase does not match",
@@ -12044,19 +12045,19 @@
12044 ".echo on|off Turn command echo on or off",
12045 ".eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN",
12046 " Other Modes:",
12047 #ifdef SQLITE_DEBUG
12048 " test Show raw EXPLAIN QUERY PLAN output",
12049 " trace Like \"full\" but also enable \"PRAGMA vdbe_trace\"",
12050 #endif
12051 " trigger Like \"full\" but also show trigger bytecode",
12052 ".excel Display the output of next command in a spreadsheet",
12053 ".exit ?CODE? Exit this program with return-code CODE",
12054 ".expert EXPERIMENTAL. Suggest indexes for specified queries",
12055 /* Because explain mode comes on automatically now, the ".explain" mode
12056 ** is removed from the help screen. It is still supported for legacy, however */
12057 /*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic",*/
12058 ".filectrl CMD ... Run various sqlite3_file_control() operations",
12059 " Run \".filectrl\" with no arguments for details",
12060 ".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
12061 ".headers on|off Turn display of headers on or off",
12062 ".help ?-all? ?PATTERN? Show help text for PATTERN",
@@ -12099,11 +12100,11 @@
12099 ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
12100 " Options:",
12101 " --append Use appendvfs to append database to the end of FILE",
12102 #ifdef SQLITE_ENABLE_DESERIALIZE
12103 " --deserialize Load into memory useing sqlite3_deserialize()",
12104 " --hexdb Load the output of \"dbtotxt\" as an in-memory database",
12105 " --maxsize N Maximum size for --hexdb or --deserialized database",
12106 #endif
12107 " --new Initialize FILE to an empty database",
12108 " --readonly Open FILE readonly",
12109 " --zip FILE is a ZIP archive",
@@ -12112,11 +12113,11 @@
12112 ".parameter CMD ... Manage SQL parameter bindings",
12113 " clear Erase all bindings",
12114 " init Initialize the TEMP table that holds bindings",
12115 " list List the current parameter bindings",
12116 " set PARAMETER VALUE Given SQL parameter PARAMETER a value of VALUE",
12117 " PARAMETER should start with '$', ':', '@', or '?'",
12118 " unset PARAMETER Remove PARAMETER from the binding table",
12119 ".print STRING... Print literal STRING",
12120 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
12121 ".progress N Invoke progress handler after every N opcodes",
12122 " --limit N Interrupt after N progress callbacks",
@@ -12127,10 +12128,13 @@
12127 ".prompt MAIN CONTINUE Replace the standard prompts",
12128 ".quit Exit this program",
12129 ".read FILE Read input from FILE",
12130 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
12131 ".recover Recover as much data as possible from corrupt db.",
 
 
 
12132 #endif
12133 ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
12134 ".save FILE Write in-memory database into FILE",
12135 ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off",
12136 ".schema ?PATTERN? Show the CREATE statements matching PATTERN",
@@ -12158,11 +12162,11 @@
12158 #endif
12159 ".sha3sum ... Compute a SHA3 hash of database content",
12160 " Options:",
12161 " --schema Also hash the sqlite_master table",
12162 " --sha3-224 Use the sha3-224 algorithm",
12163 " --sha3-256 Use the sha3-256 algorithm. This is the default.",
12164 " --sha3-384 Use the sha3-384 algorithm",
12165 " --sha3-512 Use the sha3-512 algorithm",
12166 " Any other argument is a LIKE pattern for tables to hash",
12167 #ifndef SQLITE_NOHAVE_SYSTEM
12168 ".shell CMD ARGS... Run CMD ARGS... in a system shell",
@@ -12192,10 +12196,14 @@
12192 " --stmt Trace statement execution (SQLITE_TRACE_STMT)",
12193 " --profile Profile statements (SQLITE_TRACE_PROFILE)",
12194 " --row Trace each row (SQLITE_TRACE_ROW)",
12195 " --close Trace connection close (SQLITE_TRACE_CLOSE)",
12196 #endif /* SQLITE_OMIT_TRACE */
 
 
 
 
12197 ".vfsinfo ?AUX? Information about the top-level VFS",
12198 ".vfslist List all available VFSes",
12199 ".vfsname ?AUX? Print the name of the VFS stack",
12200 ".width NUM1 NUM2 ... Set column widths for \"column\" mode",
12201 " Negative values right-justify",
@@ -12434,10 +12442,12 @@
12434 nLine++;
12435 if( fgets(zLine, sizeof(zLine), in)==0 ) goto readHexDb_error;
12436 rc = sscanf(zLine, "| size %d pagesize %d", &n, &pgsz);
12437 if( rc!=2 ) goto readHexDb_error;
12438 if( n<0 ) goto readHexDb_error;
 
 
12439 a = sqlite3_malloc( n ? n : 1 );
12440 if( a==0 ){
12441 utf8_printf(stderr, "Out of memory!\n");
12442 goto readHexDb_error;
12443 }
@@ -12517,10 +12527,27 @@
12517 + ((sqlite3_int64)a[2]<< 8)
12518 + ((sqlite3_int64)a[3]<< 0);
12519 sqlite3_result_int64(context, iVal);
12520 }
12521 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12522
12523 /*
12524 ** Scalar function "shell_escape_crnl" used by the .recover command.
12525 ** The argument passed to this function is the output of built-in
12526 ** function quote(). If the first character of the input is "'",
@@ -12694,10 +12721,12 @@
12694 shellPutsFunc, 0, 0);
12695 sqlite3_create_function(p->db, "shell_escape_crnl", 1, SQLITE_UTF8, 0,
12696 shellEscapeCrnl, 0, 0);
12697 sqlite3_create_function(p->db, "shell_int32", 2, SQLITE_UTF8, 0,
12698 shellInt32, 0, 0);
 
 
12699 #ifndef SQLITE_NOHAVE_SYSTEM
12700 sqlite3_create_function(p->db, "edit", 1, SQLITE_UTF8, 0,
12701 editFunc, 0, 0);
12702 sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
12703 editFunc, 0, 0);
@@ -14041,11 +14070,11 @@
14041 }
14042 }
14043 #endif /* !defined SQLITE_OMIT_VIRTUALTABLE */
14044
14045 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
14046 /*********************************************************************************
14047 ** The ".archive" or ".ar" command.
14048 */
14049 /*
14050 ** Structure representing a single ".ar" command.
14051 */
@@ -14239,11 +14268,12 @@
14239 if( i<(n-1) ){
14240 zArg = &z[i+1];
14241 i = n;
14242 }else{
14243 if( iArg>=(nArg-1) ){
14244 return arErrorMsg(pAr, "option requires an argument: %c",z[i]);
 
14245 }
14246 zArg = azArg[++iArg];
14247 }
14248 }
14249 if( arProcessSwitch(pAr, pOpt->eSwitch, zArg) ) return SQLITE_ERROR;
@@ -14627,14 +14657,14 @@
14627
14628 /*
14629 ** Implementation of ".ar" dot command.
14630 */
14631 static int arDotCommand(
14632 ShellState *pState, /* Current shell tool state */
14633 int fromCmdLine, /* True if -A command-line option, not .ar cmd */
14634 char **azArg, /* Array of arguments passed to dot command */
14635 int nArg /* Number of entries in azArg[] */
14636 ){
14637 ArCommand cmd;
14638 int rc;
14639 memset(&cmd, 0, sizeof(cmd));
14640 cmd.fromCmdLine = fromCmdLine;
@@ -14730,11 +14760,11 @@
14730 sqlite3_free(cmd.zSrcTable);
14731
14732 return rc;
14733 }
14734 /* End of the ".archive" or ".ar" command logic
14735 **********************************************************************************/
14736 #endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) */
14737
14738 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
14739 /*
14740 ** If (*pRc) is not SQLITE_OK when this function is called, it is a no-op.
@@ -14871,10 +14901,14 @@
14871 int nSqlCol = 0;
14872 int bSqlIntkey = 0;
14873 sqlite3_stmt *pStmt = 0;
14874
14875 rc = sqlite3_open("", &dbtmp);
 
 
 
 
14876 if( rc==SQLITE_OK ){
14877 rc = sqlite3_exec(dbtmp, "PRAGMA writable_schema = on", 0, 0, 0);
14878 }
14879 if( rc==SQLITE_OK ){
14880 rc = sqlite3_exec(dbtmp, zSql, 0, 0, 0);
@@ -14927,22 +14961,22 @@
14927 pTab->iPk = sqlite3_column_int(pPkFinder, 0);
14928 zPk = (const char*)sqlite3_column_text(pPkFinder, 1);
14929 }
14930 }
14931
14932 pTab->zQuoted = shellMPrintf(&rc, "%Q", zName);
14933 pTab->azlCol = (char**)shellMalloc(&rc, sizeof(char*) * (nSqlCol+1));
14934 pTab->nCol = nSqlCol;
14935
14936 if( bIntkey ){
14937 pTab->azlCol[0] = shellMPrintf(&rc, "%Q", zPk);
14938 }else{
14939 pTab->azlCol[0] = shellMPrintf(&rc, "");
14940 }
14941 i = 1;
14942 shellPreparePrintf(dbtmp, &rc, &pStmt,
14943 "SELECT %Q || group_concat(name, ', ') "
14944 " FILTER (WHERE cid!=%d) OVER (ORDER BY %s cid) "
14945 "FROM pragma_table_info(%Q)",
14946 bIntkey ? ", " : "", pTab->iPk,
14947 bIntkey ? "" : "(CASE WHEN pk=0 THEN 1000000 ELSE pk END), ",
14948 zName
@@ -15052,11 +15086,11 @@
15052 }
15053 shellFinalize(pRc, pTest);
15054
15055 pTab = (RecoverTable*)shellMalloc(pRc, sizeof(RecoverTable));
15056 if( pTab ){
15057 pTab->zQuoted = shellMPrintf(pRc, "%Q", zTab);
15058 pTab->nCol = nCol;
15059 pTab->iPk = -2;
15060 if( nCol>0 ){
15061 pTab->azlCol = (char**)shellMalloc(pRc, sizeof(char*) * (nCol+1));
15062 if( pTab->azlCol ){
@@ -15118,22 +15152,20 @@
15118 if( n<=15 && memcmp("-lost-and-found", z, n)==0 && i<(nArg-1) ){
15119 i++;
15120 zLostAndFound = azArg[i];
15121 }
15122 else{
15123 raw_printf(stderr, "unexpected option: %s\n", azArg[i]);
15124 raw_printf(stderr, "options are:\n");
15125 raw_printf(stderr, " --freelist-corrupt\n");
15126 raw_printf(stderr, " --recovery-db DATABASE\n");
15127 raw_printf(stderr, " --lost-and-found TABLE-NAME\n");
15128 return 1;
15129 }
15130 }
15131
15132 shellExecPrintf(pState->db, &rc,
15133 /* Attach an in-memory database named 'recovery'. Create an indexed
15134 ** cache of the sqlite_dbptr virtual table. */
 
15135 "ATTACH %Q AS recovery;"
15136 "DROP TABLE IF EXISTS recovery.dbptr;"
15137 "DROP TABLE IF EXISTS recovery.freelist;"
15138 "DROP TABLE IF EXISTS recovery.map;"
15139 "DROP TABLE IF EXISTS recovery.schema;"
@@ -15159,10 +15191,25 @@
15159 " FROM freelist WHERE n>=0"
15160 ")"
15161 "REPLACE INTO recovery.freelist SELECT freepgno FROM freelist;"
15162 );
15163 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15164
15165 shellExec(pState->db, &rc,
15166 "CREATE TABLE recovery.dbptr("
15167 " pgno, child, PRIMARY KEY(child, pgno)"
15168 ") WITHOUT ROWID;"
@@ -15208,11 +15255,11 @@
15208 " SELECT i, p.parent, "
15209 " (SELECT pgno FROM recovery.dbptr WHERE child=p.parent) FROM p"
15210 " )"
15211 " SELECT pgno FROM p WHERE (parent IS NULL OR pgno = orig)"
15212 ") "
15213 "FROM pages WHERE maxlen > 0 AND i NOT IN freelist;"
15214 "UPDATE recovery.map AS o SET intkey = ("
15215 " SELECT substr(data, 1, 1)==X'0D' FROM sqlite_dbpage WHERE pgno=o.pgno"
15216 ");"
15217
15218 /* Extract data from page 1 and any linked pages into table
@@ -15233,10 +15280,15 @@
15233
15234 /* Open a transaction, then print out all non-virtual, non-"sqlite_%"
15235 ** CREATE TABLE statements that extracted from the existing schema. */
15236 if( rc==SQLITE_OK ){
15237 sqlite3_stmt *pStmt = 0;
 
 
 
 
 
15238 raw_printf(pState->out, "BEGIN;\n");
15239 raw_printf(pState->out, "PRAGMA writable_schema = on;\n");
15240 shellPrepare(pState->db, &rc,
15241 "SELECT sql FROM recovery.schema "
15242 "WHERE type='table' AND sql LIKE 'create table%'", &pStmt
@@ -15265,10 +15317,11 @@
15265 shellPrepare(pState->db, &rc,
15266 "SELECT pgno FROM recovery.map WHERE root=?", &pPages
15267 );
15268 shellPrepare(pState->db, &rc,
15269 "SELECT max(field), group_concat(shell_escape_crnl(quote(value)), ', ')"
 
15270 "FROM sqlite_dbdata WHERE pgno = ? AND field != ?"
15271 "GROUP BY cell", &pCells
15272 );
15273
15274 /* Loop through each root page. */
@@ -15283,10 +15336,11 @@
15283 int bIntkey = sqlite3_column_int(pLoop, 1);
15284 int nCol = sqlite3_column_int(pLoop, 2);
15285 int bNoop = 0;
15286 RecoverTable *pTab;
15287
 
15288 pTab = recoverFindTable(pState, &rc, iRoot, bIntkey, nCol, &bNoop);
15289 if( bNoop || rc ) continue;
15290 if( pTab==0 ){
15291 if( pOrphan==0 ){
15292 pOrphan = recoverOrphanTable(pState, &rc, zLostAndFound, nOrphan);
@@ -15293,11 +15347,11 @@
15293 }
15294 pTab = pOrphan;
15295 if( pTab==0 ) break;
15296 }
15297
15298 if( 0==sqlite3_stricmp(pTab->zQuoted, "'sqlite_sequence'") ){
15299 raw_printf(pState->out, "DELETE FROM sqlite_sequence;\n");
15300 }
15301 sqlite3_bind_int(pPages, 1, iRoot);
15302 sqlite3_bind_int(pCells, 2, pTab->iPk);
15303
@@ -15304,22 +15358,32 @@
15304 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pPages) ){
15305 int iPgno = sqlite3_column_int(pPages, 0);
15306 sqlite3_bind_int(pCells, 1, iPgno);
15307 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pCells) ){
15308 int nField = sqlite3_column_int(pCells, 0);
 
15309 const char *zVal = (const char*)sqlite3_column_text(pCells, 1);
 
 
 
 
 
 
 
 
 
15310
15311 nField = nField+1;
15312 if( pTab==pOrphan ){
15313 raw_printf(pState->out,
15314 "INSERT INTO %s VALUES(%d, %d, %d, %s%s%s);\n",
15315 pTab->zQuoted, iRoot, iPgno, nField,
15316 bIntkey ? "" : "NULL, ", zVal, pTab->azlCol[nField]
15317 );
15318 }else{
15319 raw_printf(pState->out, "INSERT INTO %s(%s) VALUES( %s );\n",
15320 pTab->zQuoted, pTab->azlCol[nField], zVal
15321 );
15322 }
15323 }
15324 shellReset(&rc, pCells);
15325 }
@@ -15374,21 +15438,21 @@
15374 static int do_meta_command(char *zLine, ShellState *p){
15375 int h = 1;
15376 int nArg = 0;
15377 int n, c;
15378 int rc = 0;
15379 char *azArg[50];
15380
15381 #ifndef SQLITE_OMIT_VIRTUALTABLE
15382 if( p->expert.pExpert ){
15383 expertFinish(p, 1, 0);
15384 }
15385 #endif
15386
15387 /* Parse the input line into tokens.
15388 */
15389 while( zLine[h] && nArg<ArraySize(azArg) ){
15390 while( IsSpace(zLine[h]) ){ h++; }
15391 if( zLine[h]==0 ) break;
15392 if( zLine[h]=='\'' || zLine[h]=='"' ){
15393 int delim = zLine[h++];
15394 azArg[nArg++] = &zLine[h];
@@ -15405,10 +15469,11 @@
15405 while( zLine[h] && !IsSpace(zLine[h]) ){ h++; }
15406 if( zLine[h] ) zLine[h++] = 0;
15407 resolve_backslashes(azArg[nArg-1]);
15408 }
15409 }
 
15410
15411 /* Process the input line.
15412 */
15413 if( nArg==0 ) return 0; /* no tokens, no error */
15414 n = strlen30(azArg[0]);
@@ -15620,10 +15685,11 @@
15620 const char *zName;
15621 int op;
15622 } aDbConfig[] = {
15623 { "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
15624 { "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
 
15625 { "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
15626 { "load_extension", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
15627 { "no_ckpt_on_close", SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
15628 { "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
15629 { "trigger_eqp", SQLITE_DBCONFIG_TRIGGER_EQP },
@@ -15993,12 +16059,10 @@
15993 sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_master'",
15994 callback, &data, &zErrMsg);
15995 data.cMode = data.mode = MODE_Insert;
15996 data.zDestTable = "sqlite_stat1";
15997 shell_exec(&data, "SELECT * FROM sqlite_stat1", &zErrMsg);
15998 data.zDestTable = "sqlite_stat3";
15999 shell_exec(&data, "SELECT * FROM sqlite_stat3", &zErrMsg);
16000 data.zDestTable = "sqlite_stat4";
16001 shell_exec(&data, "SELECT * FROM sqlite_stat4", &zErrMsg);
16002 raw_printf(p->out, "ANALYZE sqlite_master;\n");
16003 }
16004 }else
@@ -16944,15 +17008,16 @@
16944 appendText(&sSelect, " AS sname FROM ", 0);
16945 appendText(&sSelect, zDb, quoteChar(zDb));
16946 appendText(&sSelect, ".sqlite_master", 0);
16947 }
16948 sqlite3_finalize(pStmt);
16949 #ifdef SQLITE_INTROSPECTION_PRAGMAS
16950 if( zName ){
16951 appendText(&sSelect,
16952 " UNION ALL SELECT shell_module_schema(name),"
16953 " 'table', name, name, name, 9e+99, 'main' FROM pragma_module_list", 0);
 
16954 }
16955 #endif
16956 appendText(&sSelect, ") WHERE ", 0);
16957 if( zName ){
16958 char *zQarg = sqlite3_mprintf("%Q", zName);
@@ -17047,11 +17112,12 @@
17047 FILE *out = 0;
17048 if( nCmd!=2 ) goto session_syntax_error;
17049 if( pSession->p==0 ) goto session_not_open;
17050 out = fopen(azCmd[1], "wb");
17051 if( out==0 ){
17052 utf8_printf(stderr, "ERROR: cannot open \"%s\" for writing\n", azCmd[1]);
 
17053 }else{
17054 int szChng;
17055 void *pChng;
17056 if( azCmd[0][0]=='c' ){
17057 rc = sqlite3session_changeset(pSession->p, &szChng, &pChng);
@@ -17368,12 +17434,11 @@
17368 bDebug = 1;
17369 }else
17370 {
17371 utf8_printf(stderr, "Unknown option \"%s\" on \"%s\"\n",
17372 azArg[i], azArg[0]);
17373 raw_printf(stderr, "Should be one of: --schema"
17374 " --sha3-224 --sha3-256 --sha3-384 --sha3-512\n");
17375 rc = 1;
17376 goto meta_command_exit;
17377 }
17378 }else if( zLike ){
17379 raw_printf(stderr, "Usage: .sha3sum ?OPTIONS? ?LIKE-PATTERN?\n");
@@ -17415,12 +17480,11 @@
17415 appendText(&sQuery,"SELECT name,seq FROM sqlite_sequence"
17416 " ORDER BY name;", 0);
17417 }else if( strcmp(zTab, "sqlite_stat1")==0 ){
17418 appendText(&sQuery,"SELECT tbl,idx,stat FROM sqlite_stat1"
17419 " ORDER BY tbl,idx;", 0);
17420 }else if( strcmp(zTab, "sqlite_stat3")==0
17421 || strcmp(zTab, "sqlite_stat4")==0 ){
17422 appendText(&sQuery, "SELECT * FROM ", 0);
17423 appendText(&sQuery, zTab, 0);
17424 appendText(&sQuery, " ORDER BY tbl, idx, rowid;\n", 0);
17425 }
17426 appendText(&sSql, zSep, 0);
@@ -17648,29 +17712,30 @@
17648 static const struct {
17649 const char *zCtrlName; /* Name of a test-control option */
17650 int ctrlCode; /* Integer code for that option */
17651 const char *zUsage; /* Usage notes */
17652 } aCtrl[] = {
17653 { "always", SQLITE_TESTCTRL_ALWAYS, "BOOLEAN" },
17654 { "assert", SQLITE_TESTCTRL_ASSERT, "BOOLEAN" },
17655 /*{ "benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, "" },*/
17656 /*{ "bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, "" },*/
17657 { "byteorder", SQLITE_TESTCTRL_BYTEORDER, "" },
17658 /*{ "fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, "" }, */
17659 { "imposter", SQLITE_TESTCTRL_IMPOSTER, "SCHEMA ON/OFF ROOTPAGE"},
17660 { "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, "BOOLEAN" },
17661 { "localtime_fault", SQLITE_TESTCTRL_LOCALTIME_FAULT,"BOOLEAN" },
17662 { "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT, "BOOLEAN" },
17663 { "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS, "DISABLE-MASK" },
 
17664 #ifdef YYCOVERAGE
17665 { "parser_coverage", SQLITE_TESTCTRL_PARSER_COVERAGE, "" },
17666 #endif
17667 { "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE, "OFFSET " },
17668 { "prng_reset", SQLITE_TESTCTRL_PRNG_RESET, "" },
17669 { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE, "" },
17670 { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, "" },
17671 { "reserve", SQLITE_TESTCTRL_RESERVE, "BYTES-OF-RESERVE" },
17672 };
17673 int testctrl = -1;
17674 int iCtrl = -1;
17675 int rc2 = 0; /* 0: usage. 1: %d 2: %x 3: no-output */
17676 int isOk = 0;
@@ -17746,10 +17811,31 @@
17746 unsigned int opt = (unsigned int)integerValue(azArg[2]);
17747 rc2 = sqlite3_test_control(testctrl, opt);
17748 isOk = 3;
17749 }
17750 break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17751
17752 /* sqlite3_test_control(int, int) */
17753 case SQLITE_TESTCTRL_ASSERT:
17754 case SQLITE_TESTCTRL_ALWAYS:
17755 case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS:
@@ -17788,11 +17874,11 @@
17788 }
17789 #endif
17790 }
17791 }
17792 if( isOk==0 && iCtrl>=0 ){
17793 utf8_printf(p->out, "Usage: .testctrl %s %s\n", zCmd, aCtrl[iCtrl].zUsage);
17794 rc = 1;
17795 }else if( isOk==1 ){
17796 raw_printf(p->out, "%d\n", rc2);
17797 }else if( isOk==2 ){
17798 raw_printf(p->out, "0x%08x\n", rc2);
@@ -17865,10 +17951,35 @@
17865 if( mType==0 ) mType = SQLITE_TRACE_STMT;
17866 sqlite3_trace_v2(p->db, mType, sql_trace_callback, p);
17867 }
17868 }else
17869 #endif /* !defined(SQLITE_OMIT_TRACE) */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17870
17871 #if SQLITE_USER_AUTHENTICATION
17872 if( c=='u' && strncmp(azArg[0], "user", n)==0 ){
17873 if( nArg<2 ){
17874 raw_printf(stderr, "Usage: .user SUBCOMMAND ...\n");
@@ -17880,11 +17991,12 @@
17880 if( nArg!=4 ){
17881 raw_printf(stderr, "Usage: .user login USER PASSWORD\n");
17882 rc = 1;
17883 goto meta_command_exit;
17884 }
17885 rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3], strlen30(azArg[3]));
 
17886 if( rc ){
17887 utf8_printf(stderr, "Authentication failed for user %s\n", azArg[2]);
17888 rc = 1;
17889 }
17890 }else if( strcmp(azArg[1],"add")==0 ){
17891
--- src/shell.c
+++ src/shell.c
@@ -9799,16 +9799,16 @@
9799 sqlite3_result_error(context, "edit() cannot open temp file", -1);
9800 goto edit_func_end;
9801 }
9802 sz = sqlite3_value_bytes(argv[0]);
9803 if( bBin ){
9804 x = fwrite(sqlite3_value_blob(argv[0]), 1, (size_t)sz, f);
9805 }else{
9806 const char *z = (const char*)sqlite3_value_text(argv[0]);
9807 /* Remember whether or not the value originally contained \r\n */
9808 if( z && strstr(z,"\r\n")!=0 ) hasCRNL = 1;
9809 x = fwrite(sqlite3_value_text(argv[0]), 1, (size_t)sz, f);
9810 }
9811 fclose(f);
9812 f = 0;
9813 if( x!=sz ){
9814 sqlite3_result_error(context, "edit() could not write the whole file", -1);
@@ -9832,16 +9832,16 @@
9832 goto edit_func_end;
9833 }
9834 fseek(f, 0, SEEK_END);
9835 sz = ftell(f);
9836 rewind(f);
9837 p = sqlite3_malloc64( sz+1 );
9838 if( p==0 ){
9839 sqlite3_result_error_nomem(context);
9840 goto edit_func_end;
9841 }
9842 x = fread(p, 1, (size_t)sz, f);
9843 fclose(f);
9844 f = 0;
9845 if( x!=sz ){
9846 sqlite3_result_error(context, "could not read back the whole file", -1);
9847 goto edit_func_end;
@@ -10309,11 +10309,12 @@
10309 int n = strlen30(p->sGraph.zPrefix);
10310 char *z;
10311 for(pRow = eqp_next_row(p, iEqpId, 0); pRow; pRow = pNext){
10312 pNext = eqp_next_row(p, iEqpId, pRow);
10313 z = pRow->zText;
10314 utf8_printf(p->out, "%s%s%s\n", p->sGraph.zPrefix,
10315 pNext ? "|--" : "`--", z);
10316 if( n<(int)sizeof(p->sGraph.zPrefix)-7 ){
10317 memcpy(&p->sGraph.zPrefix[n], pNext ? "| " : " ", 4);
10318 eqp_render_level(p, pRow->iEqpId);
10319 p->sGraph.zPrefix[n] = 0;
10320 }
@@ -10500,11 +10501,11 @@
10501 z[j++] = c;
10502 }
10503 while( j>0 && IsSpace(z[j-1]) ){ j--; }
10504 z[j] = 0;
10505 if( strlen30(z)>=79 ){
10506 for(i=j=0; (c = z[i])!=0; i++){ /* Copy from z[i] back to z[j] */
10507 if( c==cEnd ){
10508 cEnd = 0;
10509 }else if( c=='"' || c=='\'' || c=='`' ){
10510 cEnd = c;
10511 }else if( c=='[' ){
@@ -11079,11 +11080,11 @@
11080 raw_printf(pArg->out, "Sort Operations: %d\n", iCur);
11081 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
11082 raw_printf(pArg->out, "Autoindex Inserts: %d\n", iCur);
11083 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
11084 raw_printf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
11085 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_REPREPARE,bReset);
11086 raw_printf(pArg->out, "Reprepare operations: %d\n", iCur);
11087 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_RUN, bReset);
11088 raw_printf(pArg->out, "Number of times run: %d\n", iCur);
11089 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_MEMUSED, bReset);
11090 raw_printf(pArg->out, "Memory used by prepared stmt: %d\n", iCur);
@@ -12002,33 +12003,33 @@
12003 static const char *(azHelp[]) = {
12004 #if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
12005 ".archive ... Manage SQL archives",
12006 " Each command must have exactly one of the following options:",
12007 " -c, --create Create a new archive",
12008 " -u, --update Add or update files with changed mtime",
12009 " -i, --insert Like -u but always add even if unchanged",
12010 " -t, --list List contents of archive",
12011 " -x, --extract Extract files from archive",
12012 " Optional arguments:",
12013 " -v, --verbose Print each filename as it is processed",
12014 " -f FILE, --file FILE Use archive FILE (default is current db)",
12015 " -a FILE, --append FILE Open FILE using the apndvfs VFS",
12016 " -C DIR, --directory DIR Read/extract files from directory DIR",
12017 " -n, --dryrun Show the SQL that would have occurred",
12018 " Examples:",
12019 " .ar -cf ARCHIVE foo bar # Create ARCHIVE from files foo and bar",
12020 " .ar -tf ARCHIVE # List members of ARCHIVE",
12021 " .ar -xvf ARCHIVE # Verbosely extract files from ARCHIVE",
12022 " See also:",
12023 " http://sqlite.org/cli.html#sqlar_archive_support",
12024 #endif
12025 #ifndef SQLITE_OMIT_AUTHORIZATION
12026 ".auth ON|OFF Show authorizer callbacks",
12027 #endif
12028 ".backup ?DB? FILE Backup DB (default \"main\") to FILE",
12029 " --append Use the appendvfs",
12030 " --async Write to FILE without journal and fsync()",
12031 ".bail on|off Stop after hitting an error. Default OFF",
12032 ".binary on|off Turn binary output on or off. Default OFF",
12033 ".cd DIRECTORY Change the working directory to DIRECTORY",
12034 ".changes on|off Show number of rows changed by SQL",
12035 ".check GLOB Fail if output since .testcase does not match",
@@ -12044,19 +12045,19 @@
12045 ".echo on|off Turn command echo on or off",
12046 ".eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN",
12047 " Other Modes:",
12048 #ifdef SQLITE_DEBUG
12049 " test Show raw EXPLAIN QUERY PLAN output",
12050 " trace Like \"full\" but enable \"PRAGMA vdbe_trace\"",
12051 #endif
12052 " trigger Like \"full\" but also show trigger bytecode",
12053 ".excel Display the output of next command in spreadsheet",
12054 ".exit ?CODE? Exit this program with return-code CODE",
12055 ".expert EXPERIMENTAL. Suggest indexes for queries",
12056 /* Because explain mode comes on automatically now, the ".explain" mode
12057 ** is removed from the help screen. It is still supported for legacy, however */
12058 /*".explain ?on|off|auto? Turn EXPLAIN output mode on or off",*/
12059 ".filectrl CMD ... Run various sqlite3_file_control() operations",
12060 " Run \".filectrl\" with no arguments for details",
12061 ".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
12062 ".headers on|off Turn display of headers on or off",
12063 ".help ?-all? ?PATTERN? Show help text for PATTERN",
@@ -12099,11 +12100,11 @@
12100 ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
12101 " Options:",
12102 " --append Use appendvfs to append database to the end of FILE",
12103 #ifdef SQLITE_ENABLE_DESERIALIZE
12104 " --deserialize Load into memory useing sqlite3_deserialize()",
12105 " --hexdb Load the output of \"dbtotxt\" as an in-memory db",
12106 " --maxsize N Maximum size for --hexdb or --deserialized database",
12107 #endif
12108 " --new Initialize FILE to an empty database",
12109 " --readonly Open FILE readonly",
12110 " --zip FILE is a ZIP archive",
@@ -12112,11 +12113,11 @@
12113 ".parameter CMD ... Manage SQL parameter bindings",
12114 " clear Erase all bindings",
12115 " init Initialize the TEMP table that holds bindings",
12116 " list List the current parameter bindings",
12117 " set PARAMETER VALUE Given SQL parameter PARAMETER a value of VALUE",
12118 " PARAMETER should start with one of: $ : @ ?",
12119 " unset PARAMETER Remove PARAMETER from the binding table",
12120 ".print STRING... Print literal STRING",
12121 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
12122 ".progress N Invoke progress handler after every N opcodes",
12123 " --limit N Interrupt after N progress callbacks",
@@ -12127,10 +12128,13 @@
12128 ".prompt MAIN CONTINUE Replace the standard prompts",
12129 ".quit Exit this program",
12130 ".read FILE Read input from FILE",
12131 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
12132 ".recover Recover as much data as possible from corrupt db.",
12133 " --freelist-corrupt Assume the freelist is corrupt",
12134 " --recovery-db NAME Store recovery metadata in database file NAME",
12135 " --lost-and-found TABLE Alternative name for the lost-and-found table",
12136 #endif
12137 ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
12138 ".save FILE Write in-memory database into FILE",
12139 ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off",
12140 ".schema ?PATTERN? Show the CREATE statements matching PATTERN",
@@ -12158,11 +12162,11 @@
12162 #endif
12163 ".sha3sum ... Compute a SHA3 hash of database content",
12164 " Options:",
12165 " --schema Also hash the sqlite_master table",
12166 " --sha3-224 Use the sha3-224 algorithm",
12167 " --sha3-256 Use the sha3-256 algorithm (default)",
12168 " --sha3-384 Use the sha3-384 algorithm",
12169 " --sha3-512 Use the sha3-512 algorithm",
12170 " Any other argument is a LIKE pattern for tables to hash",
12171 #ifndef SQLITE_NOHAVE_SYSTEM
12172 ".shell CMD ARGS... Run CMD ARGS... in a system shell",
@@ -12192,10 +12196,14 @@
12196 " --stmt Trace statement execution (SQLITE_TRACE_STMT)",
12197 " --profile Profile statements (SQLITE_TRACE_PROFILE)",
12198 " --row Trace each row (SQLITE_TRACE_ROW)",
12199 " --close Trace connection close (SQLITE_TRACE_CLOSE)",
12200 #endif /* SQLITE_OMIT_TRACE */
12201 #ifdef SQLITE_DEBUG
12202 ".unmodule NAME ... Unregister virtual table modules",
12203 " --allexcept Unregister everything except those named",
12204 #endif
12205 ".vfsinfo ?AUX? Information about the top-level VFS",
12206 ".vfslist List all available VFSes",
12207 ".vfsname ?AUX? Print the name of the VFS stack",
12208 ".width NUM1 NUM2 ... Set column widths for \"column\" mode",
12209 " Negative values right-justify",
@@ -12434,10 +12442,12 @@
12442 nLine++;
12443 if( fgets(zLine, sizeof(zLine), in)==0 ) goto readHexDb_error;
12444 rc = sscanf(zLine, "| size %d pagesize %d", &n, &pgsz);
12445 if( rc!=2 ) goto readHexDb_error;
12446 if( n<0 ) goto readHexDb_error;
12447 if( pgsz<512 || pgsz>65536 || (pgsz&(pgsz-1))!=0 ) goto readHexDb_error;
12448 n = (n+pgsz-1)&~(pgsz-1); /* Round n up to the next multiple of pgsz */
12449 a = sqlite3_malloc( n ? n : 1 );
12450 if( a==0 ){
12451 utf8_printf(stderr, "Out of memory!\n");
12452 goto readHexDb_error;
12453 }
@@ -12517,10 +12527,27 @@
12527 + ((sqlite3_int64)a[2]<< 8)
12528 + ((sqlite3_int64)a[3]<< 0);
12529 sqlite3_result_int64(context, iVal);
12530 }
12531 }
12532
12533 /*
12534 ** Scalar function "shell_idquote(X)" returns string X quoted as an identifier,
12535 ** using "..." with internal double-quote characters doubled.
12536 */
12537 static void shellIdQuote(
12538 sqlite3_context *context,
12539 int argc,
12540 sqlite3_value **argv
12541 ){
12542 const char *zName = (const char*)sqlite3_value_text(argv[0]);
12543 UNUSED_PARAMETER(argc);
12544 if( zName ){
12545 char *z = sqlite3_mprintf("\"%w\"", zName);
12546 sqlite3_result_text(context, z, -1, sqlite3_free);
12547 }
12548 }
12549
12550 /*
12551 ** Scalar function "shell_escape_crnl" used by the .recover command.
12552 ** The argument passed to this function is the output of built-in
12553 ** function quote(). If the first character of the input is "'",
@@ -12694,10 +12721,12 @@
12721 shellPutsFunc, 0, 0);
12722 sqlite3_create_function(p->db, "shell_escape_crnl", 1, SQLITE_UTF8, 0,
12723 shellEscapeCrnl, 0, 0);
12724 sqlite3_create_function(p->db, "shell_int32", 2, SQLITE_UTF8, 0,
12725 shellInt32, 0, 0);
12726 sqlite3_create_function(p->db, "shell_idquote", 1, SQLITE_UTF8, 0,
12727 shellIdQuote, 0, 0);
12728 #ifndef SQLITE_NOHAVE_SYSTEM
12729 sqlite3_create_function(p->db, "edit", 1, SQLITE_UTF8, 0,
12730 editFunc, 0, 0);
12731 sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
12732 editFunc, 0, 0);
@@ -14041,11 +14070,11 @@
14070 }
14071 }
14072 #endif /* !defined SQLITE_OMIT_VIRTUALTABLE */
14073
14074 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
14075 /******************************************************************************
14076 ** The ".archive" or ".ar" command.
14077 */
14078 /*
14079 ** Structure representing a single ".ar" command.
14080 */
@@ -14239,11 +14268,12 @@
14268 if( i<(n-1) ){
14269 zArg = &z[i+1];
14270 i = n;
14271 }else{
14272 if( iArg>=(nArg-1) ){
14273 return arErrorMsg(pAr, "option requires an argument: %c",
14274 z[i]);
14275 }
14276 zArg = azArg[++iArg];
14277 }
14278 }
14279 if( arProcessSwitch(pAr, pOpt->eSwitch, zArg) ) return SQLITE_ERROR;
@@ -14627,14 +14657,14 @@
14657
14658 /*
14659 ** Implementation of ".ar" dot command.
14660 */
14661 static int arDotCommand(
14662 ShellState *pState, /* Current shell tool state */
14663 int fromCmdLine, /* True if -A command-line option, not .ar cmd */
14664 char **azArg, /* Array of arguments passed to dot command */
14665 int nArg /* Number of entries in azArg[] */
14666 ){
14667 ArCommand cmd;
14668 int rc;
14669 memset(&cmd, 0, sizeof(cmd));
14670 cmd.fromCmdLine = fromCmdLine;
@@ -14730,11 +14760,11 @@
14760 sqlite3_free(cmd.zSrcTable);
14761
14762 return rc;
14763 }
14764 /* End of the ".archive" or ".ar" command logic
14765 *******************************************************************************/
14766 #endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) */
14767
14768 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
14769 /*
14770 ** If (*pRc) is not SQLITE_OK when this function is called, it is a no-op.
@@ -14871,10 +14901,14 @@
14901 int nSqlCol = 0;
14902 int bSqlIntkey = 0;
14903 sqlite3_stmt *pStmt = 0;
14904
14905 rc = sqlite3_open("", &dbtmp);
14906 if( rc==SQLITE_OK ){
14907 sqlite3_create_function(dbtmp, "shell_idquote", 1, SQLITE_UTF8, 0,
14908 shellIdQuote, 0, 0);
14909 }
14910 if( rc==SQLITE_OK ){
14911 rc = sqlite3_exec(dbtmp, "PRAGMA writable_schema = on", 0, 0, 0);
14912 }
14913 if( rc==SQLITE_OK ){
14914 rc = sqlite3_exec(dbtmp, zSql, 0, 0, 0);
@@ -14927,22 +14961,22 @@
14961 pTab->iPk = sqlite3_column_int(pPkFinder, 0);
14962 zPk = (const char*)sqlite3_column_text(pPkFinder, 1);
14963 }
14964 }
14965
14966 pTab->zQuoted = shellMPrintf(&rc, "\"%w\"", zName);
14967 pTab->azlCol = (char**)shellMalloc(&rc, sizeof(char*) * (nSqlCol+1));
14968 pTab->nCol = nSqlCol;
14969
14970 if( bIntkey ){
14971 pTab->azlCol[0] = shellMPrintf(&rc, "\"%w\"", zPk);
14972 }else{
14973 pTab->azlCol[0] = shellMPrintf(&rc, "");
14974 }
14975 i = 1;
14976 shellPreparePrintf(dbtmp, &rc, &pStmt,
14977 "SELECT %Q || group_concat(shell_idquote(name), ', ') "
14978 " FILTER (WHERE cid!=%d) OVER (ORDER BY %s cid) "
14979 "FROM pragma_table_info(%Q)",
14980 bIntkey ? ", " : "", pTab->iPk,
14981 bIntkey ? "" : "(CASE WHEN pk=0 THEN 1000000 ELSE pk END), ",
14982 zName
@@ -15052,11 +15086,11 @@
15086 }
15087 shellFinalize(pRc, pTest);
15088
15089 pTab = (RecoverTable*)shellMalloc(pRc, sizeof(RecoverTable));
15090 if( pTab ){
15091 pTab->zQuoted = shellMPrintf(pRc, "\"%w\"", zTab);
15092 pTab->nCol = nCol;
15093 pTab->iPk = -2;
15094 if( nCol>0 ){
15095 pTab->azlCol = (char**)shellMalloc(pRc, sizeof(char*) * (nCol+1));
15096 if( pTab->azlCol ){
@@ -15118,22 +15152,20 @@
15152 if( n<=15 && memcmp("-lost-and-found", z, n)==0 && i<(nArg-1) ){
15153 i++;
15154 zLostAndFound = azArg[i];
15155 }
15156 else{
15157 utf8_printf(stderr, "unexpected option: %s\n", azArg[i]);
15158 showHelp(pState->out, azArg[0]);
 
 
 
15159 return 1;
15160 }
15161 }
15162
15163 shellExecPrintf(pState->db, &rc,
15164 /* Attach an in-memory database named 'recovery'. Create an indexed
15165 ** cache of the sqlite_dbptr virtual table. */
15166 "PRAGMA writable_schema = on;"
15167 "ATTACH %Q AS recovery;"
15168 "DROP TABLE IF EXISTS recovery.dbptr;"
15169 "DROP TABLE IF EXISTS recovery.freelist;"
15170 "DROP TABLE IF EXISTS recovery.map;"
15171 "DROP TABLE IF EXISTS recovery.schema;"
@@ -15159,10 +15191,25 @@
15191 " FROM freelist WHERE n>=0"
15192 ")"
15193 "REPLACE INTO recovery.freelist SELECT freepgno FROM freelist;"
15194 );
15195 }
15196
15197 /* If this is an auto-vacuum database, add all pointer-map pages to
15198 ** the freelist table. Do this regardless of whether or not
15199 ** --freelist-corrupt was specified. */
15200 shellExec(pState->db, &rc,
15201 "WITH ptrmap(pgno) AS ("
15202 " SELECT 2 WHERE shell_int32("
15203 " (SELECT data FROM sqlite_dbpage WHERE pgno=1), 13"
15204 " )"
15205 " UNION ALL "
15206 " SELECT pgno+1+(SELECT page_size FROM pragma_page_size)/5 AS pp "
15207 " FROM ptrmap WHERE pp<=(SELECT page_count FROM pragma_page_count)"
15208 ")"
15209 "REPLACE INTO recovery.freelist SELECT pgno FROM ptrmap"
15210 );
15211
15212 shellExec(pState->db, &rc,
15213 "CREATE TABLE recovery.dbptr("
15214 " pgno, child, PRIMARY KEY(child, pgno)"
15215 ") WITHOUT ROWID;"
@@ -15208,11 +15255,11 @@
15255 " SELECT i, p.parent, "
15256 " (SELECT pgno FROM recovery.dbptr WHERE child=p.parent) FROM p"
15257 " )"
15258 " SELECT pgno FROM p WHERE (parent IS NULL OR pgno = orig)"
15259 ") "
15260 "FROM pages WHERE maxlen IS NOT NULL AND i NOT IN freelist;"
15261 "UPDATE recovery.map AS o SET intkey = ("
15262 " SELECT substr(data, 1, 1)==X'0D' FROM sqlite_dbpage WHERE pgno=o.pgno"
15263 ");"
15264
15265 /* Extract data from page 1 and any linked pages into table
@@ -15233,10 +15280,15 @@
15280
15281 /* Open a transaction, then print out all non-virtual, non-"sqlite_%"
15282 ** CREATE TABLE statements that extracted from the existing schema. */
15283 if( rc==SQLITE_OK ){
15284 sqlite3_stmt *pStmt = 0;
15285 /* ".recover" might output content in an order which causes immediate
15286 ** foreign key constraints to be violated. So disable foreign-key
15287 ** constraint enforcement to prevent problems when running the output
15288 ** script. */
15289 raw_printf(pState->out, "PRAGMA foreign_keys=OFF;\n");
15290 raw_printf(pState->out, "BEGIN;\n");
15291 raw_printf(pState->out, "PRAGMA writable_schema = on;\n");
15292 shellPrepare(pState->db, &rc,
15293 "SELECT sql FROM recovery.schema "
15294 "WHERE type='table' AND sql LIKE 'create table%'", &pStmt
@@ -15265,10 +15317,11 @@
15317 shellPrepare(pState->db, &rc,
15318 "SELECT pgno FROM recovery.map WHERE root=?", &pPages
15319 );
15320 shellPrepare(pState->db, &rc,
15321 "SELECT max(field), group_concat(shell_escape_crnl(quote(value)), ', ')"
15322 ", min(field) "
15323 "FROM sqlite_dbdata WHERE pgno = ? AND field != ?"
15324 "GROUP BY cell", &pCells
15325 );
15326
15327 /* Loop through each root page. */
@@ -15283,10 +15336,11 @@
15336 int bIntkey = sqlite3_column_int(pLoop, 1);
15337 int nCol = sqlite3_column_int(pLoop, 2);
15338 int bNoop = 0;
15339 RecoverTable *pTab;
15340
15341 assert( bIntkey==0 || bIntkey==1 );
15342 pTab = recoverFindTable(pState, &rc, iRoot, bIntkey, nCol, &bNoop);
15343 if( bNoop || rc ) continue;
15344 if( pTab==0 ){
15345 if( pOrphan==0 ){
15346 pOrphan = recoverOrphanTable(pState, &rc, zLostAndFound, nOrphan);
@@ -15293,11 +15347,11 @@
15347 }
15348 pTab = pOrphan;
15349 if( pTab==0 ) break;
15350 }
15351
15352 if( 0==sqlite3_stricmp(pTab->zQuoted, "\"sqlite_sequence\"") ){
15353 raw_printf(pState->out, "DELETE FROM sqlite_sequence;\n");
15354 }
15355 sqlite3_bind_int(pPages, 1, iRoot);
15356 sqlite3_bind_int(pCells, 2, pTab->iPk);
15357
@@ -15304,22 +15358,32 @@
15358 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pPages) ){
15359 int iPgno = sqlite3_column_int(pPages, 0);
15360 sqlite3_bind_int(pCells, 1, iPgno);
15361 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pCells) ){
15362 int nField = sqlite3_column_int(pCells, 0);
15363 int iMin = sqlite3_column_int(pCells, 2);
15364 const char *zVal = (const char*)sqlite3_column_text(pCells, 1);
15365
15366 RecoverTable *pTab2 = pTab;
15367 if( pTab!=pOrphan && (iMin<0)!=bIntkey ){
15368 if( pOrphan==0 ){
15369 pOrphan = recoverOrphanTable(pState, &rc, zLostAndFound, nOrphan);
15370 }
15371 pTab2 = pOrphan;
15372 if( pTab2==0 ) break;
15373 }
15374
15375 nField = nField+1;
15376 if( pTab2==pOrphan ){
15377 raw_printf(pState->out,
15378 "INSERT INTO %s VALUES(%d, %d, %d, %s%s%s);\n",
15379 pTab2->zQuoted, iRoot, iPgno, nField,
15380 iMin<0 ? "" : "NULL, ", zVal, pTab2->azlCol[nField]
15381 );
15382 }else{
15383 raw_printf(pState->out, "INSERT INTO %s(%s) VALUES( %s );\n",
15384 pTab2->zQuoted, pTab2->azlCol[nField], zVal
15385 );
15386 }
15387 }
15388 shellReset(&rc, pCells);
15389 }
@@ -15374,21 +15438,21 @@
15438 static int do_meta_command(char *zLine, ShellState *p){
15439 int h = 1;
15440 int nArg = 0;
15441 int n, c;
15442 int rc = 0;
15443 char *azArg[52];
15444
15445 #ifndef SQLITE_OMIT_VIRTUALTABLE
15446 if( p->expert.pExpert ){
15447 expertFinish(p, 1, 0);
15448 }
15449 #endif
15450
15451 /* Parse the input line into tokens.
15452 */
15453 while( zLine[h] && nArg<ArraySize(azArg)-1 ){
15454 while( IsSpace(zLine[h]) ){ h++; }
15455 if( zLine[h]==0 ) break;
15456 if( zLine[h]=='\'' || zLine[h]=='"' ){
15457 int delim = zLine[h++];
15458 azArg[nArg++] = &zLine[h];
@@ -15405,10 +15469,11 @@
15469 while( zLine[h] && !IsSpace(zLine[h]) ){ h++; }
15470 if( zLine[h] ) zLine[h++] = 0;
15471 resolve_backslashes(azArg[nArg-1]);
15472 }
15473 }
15474 azArg[nArg] = 0;
15475
15476 /* Process the input line.
15477 */
15478 if( nArg==0 ) return 0; /* no tokens, no error */
15479 n = strlen30(azArg[0]);
@@ -15620,10 +15685,11 @@
15685 const char *zName;
15686 int op;
15687 } aDbConfig[] = {
15688 { "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
15689 { "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
15690 { "enable_view", SQLITE_DBCONFIG_ENABLE_VIEW },
15691 { "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
15692 { "load_extension", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
15693 { "no_ckpt_on_close", SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
15694 { "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
15695 { "trigger_eqp", SQLITE_DBCONFIG_TRIGGER_EQP },
@@ -15993,12 +16059,10 @@
16059 sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_master'",
16060 callback, &data, &zErrMsg);
16061 data.cMode = data.mode = MODE_Insert;
16062 data.zDestTable = "sqlite_stat1";
16063 shell_exec(&data, "SELECT * FROM sqlite_stat1", &zErrMsg);
 
 
16064 data.zDestTable = "sqlite_stat4";
16065 shell_exec(&data, "SELECT * FROM sqlite_stat4", &zErrMsg);
16066 raw_printf(p->out, "ANALYZE sqlite_master;\n");
16067 }
16068 }else
@@ -16944,15 +17008,16 @@
17008 appendText(&sSelect, " AS sname FROM ", 0);
17009 appendText(&sSelect, zDb, quoteChar(zDb));
17010 appendText(&sSelect, ".sqlite_master", 0);
17011 }
17012 sqlite3_finalize(pStmt);
17013 #ifndef SQLITE_OMIT_INTROSPECTION_PRAGMAS
17014 if( zName ){
17015 appendText(&sSelect,
17016 " UNION ALL SELECT shell_module_schema(name),"
17017 " 'table', name, name, name, 9e+99, 'main' FROM pragma_module_list",
17018 0);
17019 }
17020 #endif
17021 appendText(&sSelect, ") WHERE ", 0);
17022 if( zName ){
17023 char *zQarg = sqlite3_mprintf("%Q", zName);
@@ -17047,11 +17112,12 @@
17112 FILE *out = 0;
17113 if( nCmd!=2 ) goto session_syntax_error;
17114 if( pSession->p==0 ) goto session_not_open;
17115 out = fopen(azCmd[1], "wb");
17116 if( out==0 ){
17117 utf8_printf(stderr, "ERROR: cannot open \"%s\" for writing\n",
17118 azCmd[1]);
17119 }else{
17120 int szChng;
17121 void *pChng;
17122 if( azCmd[0][0]=='c' ){
17123 rc = sqlite3session_changeset(pSession->p, &szChng, &pChng);
@@ -17368,12 +17434,11 @@
17434 bDebug = 1;
17435 }else
17436 {
17437 utf8_printf(stderr, "Unknown option \"%s\" on \"%s\"\n",
17438 azArg[i], azArg[0]);
17439 showHelp(p->out, azArg[0]);
 
17440 rc = 1;
17441 goto meta_command_exit;
17442 }
17443 }else if( zLike ){
17444 raw_printf(stderr, "Usage: .sha3sum ?OPTIONS? ?LIKE-PATTERN?\n");
@@ -17415,12 +17480,11 @@
17480 appendText(&sQuery,"SELECT name,seq FROM sqlite_sequence"
17481 " ORDER BY name;", 0);
17482 }else if( strcmp(zTab, "sqlite_stat1")==0 ){
17483 appendText(&sQuery,"SELECT tbl,idx,stat FROM sqlite_stat1"
17484 " ORDER BY tbl,idx;", 0);
17485 }else if( strcmp(zTab, "sqlite_stat4")==0 ){
 
17486 appendText(&sQuery, "SELECT * FROM ", 0);
17487 appendText(&sQuery, zTab, 0);
17488 appendText(&sQuery, " ORDER BY tbl, idx, rowid;\n", 0);
17489 }
17490 appendText(&sSql, zSep, 0);
@@ -17648,29 +17712,30 @@
17712 static const struct {
17713 const char *zCtrlName; /* Name of a test-control option */
17714 int ctrlCode; /* Integer code for that option */
17715 const char *zUsage; /* Usage notes */
17716 } aCtrl[] = {
17717 { "always", SQLITE_TESTCTRL_ALWAYS, "BOOLEAN" },
17718 { "assert", SQLITE_TESTCTRL_ASSERT, "BOOLEAN" },
17719 /*{ "benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, "" },*/
17720 /*{ "bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, "" },*/
17721 { "byteorder", SQLITE_TESTCTRL_BYTEORDER, "" },
17722 { "extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,"BOOLEAN" },
17723 /*{ "fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, "" },*/
17724 { "imposter", SQLITE_TESTCTRL_IMPOSTER, "SCHEMA ON/OFF ROOTPAGE"},
17725 { "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, "BOOLEAN" },
17726 { "localtime_fault", SQLITE_TESTCTRL_LOCALTIME_FAULT,"BOOLEAN" },
17727 { "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT, "BOOLEAN" },
17728 { "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS, "DISABLE-MASK" },
17729 #ifdef YYCOVERAGE
17730 { "parser_coverage", SQLITE_TESTCTRL_PARSER_COVERAGE, "" },
17731 #endif
17732 { "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE, "OFFSET " },
17733 { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE, "" },
17734 { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, "" },
17735 { "prng_seed", SQLITE_TESTCTRL_PRNG_SEED, "SEED ?db?" },
17736 { "reserve", SQLITE_TESTCTRL_RESERVE, "BYTES-OF-RESERVE"},
17737 };
17738 int testctrl = -1;
17739 int iCtrl = -1;
17740 int rc2 = 0; /* 0: usage. 1: %d 2: %x 3: no-output */
17741 int isOk = 0;
@@ -17746,10 +17811,31 @@
17811 unsigned int opt = (unsigned int)integerValue(azArg[2]);
17812 rc2 = sqlite3_test_control(testctrl, opt);
17813 isOk = 3;
17814 }
17815 break;
17816
17817 /* sqlite3_test_control(int, int, sqlite3*) */
17818 case SQLITE_TESTCTRL_PRNG_SEED:
17819 if( nArg==3 || nArg==4 ){
17820 int ii = (int)integerValue(azArg[2]);
17821 sqlite3 *db;
17822 if( ii==0 && strcmp(azArg[2],"random")==0 ){
17823 sqlite3_randomness(sizeof(ii),&ii);
17824 printf("-- random seed: %d\n", ii);
17825 }
17826 if( nArg==3 ){
17827 db = 0;
17828 }else{
17829 db = p->db;
17830 /* Make sure the schema has been loaded */
17831 sqlite3_table_column_metadata(db, 0, "x", 0, 0, 0, 0, 0, 0);
17832 }
17833 rc2 = sqlite3_test_control(testctrl, ii, db);
17834 isOk = 3;
17835 }
17836 break;
17837
17838 /* sqlite3_test_control(int, int) */
17839 case SQLITE_TESTCTRL_ASSERT:
17840 case SQLITE_TESTCTRL_ALWAYS:
17841 case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS:
@@ -17788,11 +17874,11 @@
17874 }
17875 #endif
17876 }
17877 }
17878 if( isOk==0 && iCtrl>=0 ){
17879 utf8_printf(p->out, "Usage: .testctrl %s %s\n", zCmd,aCtrl[iCtrl].zUsage);
17880 rc = 1;
17881 }else if( isOk==1 ){
17882 raw_printf(p->out, "%d\n", rc2);
17883 }else if( isOk==2 ){
17884 raw_printf(p->out, "0x%08x\n", rc2);
@@ -17865,10 +17951,35 @@
17951 if( mType==0 ) mType = SQLITE_TRACE_STMT;
17952 sqlite3_trace_v2(p->db, mType, sql_trace_callback, p);
17953 }
17954 }else
17955 #endif /* !defined(SQLITE_OMIT_TRACE) */
17956
17957 #ifdef SQLITE_DEBUG
17958 if( c=='u' && strncmp(azArg[0], "unmodule", n)==0 ){
17959 int ii;
17960 int lenOpt;
17961 char *zOpt;
17962 if( nArg<2 ){
17963 raw_printf(stderr, "Usage: .unmodule [--allexcept] NAME ...\n");
17964 rc = 1;
17965 goto meta_command_exit;
17966 }
17967 open_db(p, 0);
17968 zOpt = azArg[1];
17969 if( zOpt[0]=='-' && zOpt[1]=='-' && zOpt[2]!=0 ) zOpt++;
17970 lenOpt = (int)strlen(zOpt);
17971 if( lenOpt>=3 && strncmp(zOpt, "-allexcept",lenOpt)==0 ){
17972 assert( azArg[nArg]==0 );
17973 sqlite3_drop_modules(p->db, nArg>2 ? (const char**)(azArg+2) : 0);
17974 }else{
17975 for(ii=1; ii<nArg; ii++){
17976 sqlite3_create_module(p->db, azArg[ii], 0, 0);
17977 }
17978 }
17979 }else
17980 #endif
17981
17982 #if SQLITE_USER_AUTHENTICATION
17983 if( c=='u' && strncmp(azArg[0], "user", n)==0 ){
17984 if( nArg<2 ){
17985 raw_printf(stderr, "Usage: .user SUBCOMMAND ...\n");
@@ -17880,11 +17991,12 @@
17991 if( nArg!=4 ){
17992 raw_printf(stderr, "Usage: .user login USER PASSWORD\n");
17993 rc = 1;
17994 goto meta_command_exit;
17995 }
17996 rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3],
17997 strlen30(azArg[3]));
17998 if( rc ){
17999 utf8_printf(stderr, "Authentication failed for user %s\n", azArg[2]);
18000 rc = 1;
18001 }
18002 }else if( strcmp(azArg[1],"add")==0 ){
18003
+4913 -3966
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.29.0. By combining all the individual C code files into this
3
+** version 3.30.0. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -329,12 +329,10 @@
329329
#if SQLITE_ENABLE_SQLLOG
330330
"ENABLE_SQLLOG",
331331
#endif
332332
#if defined(SQLITE_ENABLE_STAT4)
333333
"ENABLE_STAT4",
334
-#elif defined(SQLITE_ENABLE_STAT3)
335
- "ENABLE_STAT3",
336334
#endif
337335
#if SQLITE_ENABLE_STMTVTAB
338336
"ENABLE_STMTVTAB",
339337
#endif
340338
#if SQLITE_ENABLE_STMT_SCANSTATUS
@@ -1165,13 +1163,13 @@
11651163
**
11661164
** See also: [sqlite3_libversion()],
11671165
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11681166
** [sqlite_version()] and [sqlite_source_id()].
11691167
*/
1170
-#define SQLITE_VERSION "3.29.0"
1171
-#define SQLITE_VERSION_NUMBER 3029000
1172
-#define SQLITE_SOURCE_ID "2019-07-10 17:32:03 fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6"
1168
+#define SQLITE_VERSION "3.30.0"
1169
+#define SQLITE_VERSION_NUMBER 3030000
1170
+#define SQLITE_SOURCE_ID "2019-09-03 16:23:41 3044cf6917ea8324175fc91657e9a5978af9748f72e1914bc361753f0b2d897d"
11731171
11741172
/*
11751173
** CAPI3REF: Run-Time Library Version Numbers
11761174
** KEYWORDS: sqlite3_version sqlite3_sourceid
11771175
**
@@ -3135,10 +3133,21 @@
31353133
** The second parameter is a pointer to an integer into which
31363134
** is written 0 or 1 to indicate whether triggers are disabled or enabled
31373135
** following this call. The second parameter may be a NULL pointer, in
31383136
** which case the trigger setting is not reported back. </dd>
31393137
**
3138
+** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
3139
+** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
3140
+** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
3141
+** There should be two additional arguments.
3142
+** The first argument is an integer which is 0 to disable views,
3143
+** positive to enable views or negative to leave the setting unchanged.
3144
+** The second parameter is a pointer to an integer into which
3145
+** is written 0 or 1 to indicate whether views are disabled or enabled
3146
+** following this call. The second parameter may be a NULL pointer, in
3147
+** which case the view setting is not reported back. </dd>
3148
+**
31403149
** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
31413150
** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
31423151
** <dd> ^This option is used to enable or disable the
31433152
** [fts3_tokenizer()] function which is part of the
31443153
** [FTS3] full-text search engine extension.
@@ -3307,11 +3316,12 @@
33073316
#define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
33083317
#define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
33093318
#define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
33103319
#define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
33113320
#define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
3312
-#define SQLITE_DBCONFIG_MAX 1014 /* Largest DBCONFIG */
3321
+#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
3322
+#define SQLITE_DBCONFIG_MAX 1015 /* Largest DBCONFIG */
33133323
33143324
/*
33153325
** CAPI3REF: Enable Or Disable Extended Result Codes
33163326
** METHOD: sqlite3
33173327
**
@@ -4856,11 +4866,11 @@
48564866
** a schema change, on the first [sqlite3_step()] call following any change
48574867
** to the [sqlite3_bind_text | bindings] of that [parameter].
48584868
** ^The specific value of WHERE-clause [parameter] might influence the
48594869
** choice of query plan if the parameter is the left-hand side of a [LIKE]
48604870
** or [GLOB] operator or if the parameter is compared to an indexed column
4861
-** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
4871
+** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled.
48624872
** </li>
48634873
** </ol>
48644874
**
48654875
** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
48664876
** the extra prepFlags parameter, which is a bit array consisting of zero or
@@ -5890,10 +5900,13 @@
58905900
** the same inputs within a single SQL statement. Most SQL functions are
58915901
** deterministic. The built-in [random()] SQL function is an example of a
58925902
** function that is not deterministic. The SQLite query planner is able to
58935903
** perform additional optimizations on deterministic functions, so use
58945904
** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
5905
+** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY]
5906
+** flag, which if present prevents the function from being invoked from
5907
+** within VIEWs or TRIGGERs.
58955908
**
58965909
** ^(The fifth parameter is an arbitrary pointer. The implementation of the
58975910
** function can gain access to this pointer using [sqlite3_user_data()].)^
58985911
**
58995912
** ^The sixth, seventh and eighth parameters passed to the three
@@ -6007,12 +6020,20 @@
60076020
**
60086021
** These constants may be ORed together with the
60096022
** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
60106023
** to [sqlite3_create_function()], [sqlite3_create_function16()], or
60116024
** [sqlite3_create_function_v2()].
6025
+**
6026
+** The SQLITE_DETERMINISTIC flag means that the new function will always
6027
+** maps the same inputs into the same output. The abs() function is
6028
+** deterministic, for example, but randomblob() is not.
6029
+**
6030
+** The SQLITE_DIRECTONLY flag means that the function may only be invoked
6031
+** from top-level SQL, and cannot be used in VIEWs or TRIGGERs.
60126032
*/
6013
-#define SQLITE_DETERMINISTIC 0x800
6033
+#define SQLITE_DETERMINISTIC 0x000000800
6034
+#define SQLITE_DIRECTONLY 0x000080000
60146035
60156036
/*
60166037
** CAPI3REF: Deprecated Functions
60176038
** DEPRECATED
60186039
**
@@ -7654,10 +7675,16 @@
76547675
** no longer needs the pClientData pointer. ^The destructor will also
76557676
** be invoked if the call to sqlite3_create_module_v2() fails.
76567677
** ^The sqlite3_create_module()
76577678
** interface is equivalent to sqlite3_create_module_v2() with a NULL
76587679
** destructor.
7680
+**
7681
+** ^If the third parameter (the pointer to the sqlite3_module object) is
7682
+** NULL then no new module is create and any existing modules with the
7683
+** same name are dropped.
7684
+**
7685
+** See also: [sqlite3_drop_modules()]
76597686
*/
76607687
SQLITE_API int sqlite3_create_module(
76617688
sqlite3 *db, /* SQLite connection to register module with */
76627689
const char *zName, /* Name of the module */
76637690
const sqlite3_module *p, /* Methods for the module */
@@ -7668,10 +7695,27 @@
76687695
const char *zName, /* Name of the module */
76697696
const sqlite3_module *p, /* Methods for the module */
76707697
void *pClientData, /* Client data for xCreate/xConnect */
76717698
void(*xDestroy)(void*) /* Module destructor function */
76727699
);
7700
+
7701
+/*
7702
+** CAPI3REF: Remove Unnecessary Virtual Table Implementations
7703
+** METHOD: sqlite3
7704
+**
7705
+** ^The sqlite3_drop_modules(D,L) interface removes all virtual
7706
+** table modules from database connection D except those named on list L.
7707
+** The L parameter must be either NULL or a pointer to an array of pointers
7708
+** to strings where the array is terminated by a single NULL pointer.
7709
+** ^If the L parameter is NULL, then all virtual table modules are removed.
7710
+**
7711
+** See also: [sqlite3_create_module()]
7712
+*/
7713
+SQLITE_API int sqlite3_drop_modules(
7714
+ sqlite3 *db, /* Remove modules from this connection */
7715
+ const char **azKeep /* Except, do not remove the ones named here */
7716
+);
76737717
76747718
/*
76757719
** CAPI3REF: Virtual Table Instance Object
76767720
** KEYWORDS: sqlite3_vtab
76777721
**
@@ -8377,11 +8421,11 @@
83778421
** [sqlite3_test_control()] interface.
83788422
*/
83798423
#define SQLITE_TESTCTRL_FIRST 5
83808424
#define SQLITE_TESTCTRL_PRNG_SAVE 5
83818425
#define SQLITE_TESTCTRL_PRNG_RESTORE 6
8382
-#define SQLITE_TESTCTRL_PRNG_RESET 7
8426
+#define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */
83838427
#define SQLITE_TESTCTRL_BITVEC_TEST 8
83848428
#define SQLITE_TESTCTRL_FAULT_INSTALL 9
83858429
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
83868430
#define SQLITE_TESTCTRL_PENDING_BYTE 11
83878431
#define SQLITE_TESTCTRL_ASSERT 12
@@ -8400,11 +8444,13 @@
84008444
#define SQLITE_TESTCTRL_ISINIT 23
84018445
#define SQLITE_TESTCTRL_SORTER_MMAP 24
84028446
#define SQLITE_TESTCTRL_IMPOSTER 25
84038447
#define SQLITE_TESTCTRL_PARSER_COVERAGE 26
84048448
#define SQLITE_TESTCTRL_RESULT_INTREAL 27
8405
-#define SQLITE_TESTCTRL_LAST 27 /* Largest TESTCTRL */
8449
+#define SQLITE_TESTCTRL_PRNG_SEED 28
8450
+#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
8451
+#define SQLITE_TESTCTRL_LAST 29 /* Largest TESTCTRL */
84068452
84078453
/*
84088454
** CAPI3REF: SQL Keyword Checking
84098455
**
84108456
** These routines provide access to the set of SQL language keywords
@@ -13097,19 +13143,19 @@
1309713143
** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
1309813144
** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)).
1309913145
** So we have to define the macros in different ways depending on the
1310013146
** compiler.
1310113147
*/
13102
-#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
13148
+#if defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
13149
+# define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
13150
+# define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X))
13151
+#elif defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
1310313152
# define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
1310413153
# define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
1310513154
#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
1310613155
# define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
1310713156
# define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
13108
-#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
13109
-# define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
13110
-# define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X))
1311113157
#else /* Generates a warning - but it always works */
1311213158
# define SQLITE_INT_TO_PTR(X) ((void*)(X))
1311313159
# define SQLITE_PTR_TO_INT(X) ((int)(X))
1311413160
#endif
1311513161
@@ -13595,104 +13641,107 @@
1359513641
#define TK_TRIGGER 77
1359613642
#define TK_VACUUM 78
1359713643
#define TK_VIEW 79
1359813644
#define TK_VIRTUAL 80
1359913645
#define TK_WITH 81
13600
-#define TK_CURRENT 82
13601
-#define TK_FOLLOWING 83
13602
-#define TK_PARTITION 84
13603
-#define TK_PRECEDING 85
13604
-#define TK_RANGE 86
13605
-#define TK_UNBOUNDED 87
13606
-#define TK_EXCLUDE 88
13607
-#define TK_GROUPS 89
13608
-#define TK_OTHERS 90
13609
-#define TK_TIES 91
13610
-#define TK_REINDEX 92
13611
-#define TK_RENAME 93
13612
-#define TK_CTIME_KW 94
13613
-#define TK_ANY 95
13614
-#define TK_BITAND 96
13615
-#define TK_BITOR 97
13616
-#define TK_LSHIFT 98
13617
-#define TK_RSHIFT 99
13618
-#define TK_PLUS 100
13619
-#define TK_MINUS 101
13620
-#define TK_STAR 102
13621
-#define TK_SLASH 103
13622
-#define TK_REM 104
13623
-#define TK_CONCAT 105
13624
-#define TK_COLLATE 106
13625
-#define TK_BITNOT 107
13626
-#define TK_ON 108
13627
-#define TK_INDEXED 109
13628
-#define TK_STRING 110
13629
-#define TK_JOIN_KW 111
13630
-#define TK_CONSTRAINT 112
13631
-#define TK_DEFAULT 113
13632
-#define TK_NULL 114
13633
-#define TK_PRIMARY 115
13634
-#define TK_UNIQUE 116
13635
-#define TK_CHECK 117
13636
-#define TK_REFERENCES 118
13637
-#define TK_AUTOINCR 119
13638
-#define TK_INSERT 120
13639
-#define TK_DELETE 121
13640
-#define TK_UPDATE 122
13641
-#define TK_SET 123
13642
-#define TK_DEFERRABLE 124
13643
-#define TK_FOREIGN 125
13644
-#define TK_DROP 126
13645
-#define TK_UNION 127
13646
-#define TK_ALL 128
13647
-#define TK_EXCEPT 129
13648
-#define TK_INTERSECT 130
13649
-#define TK_SELECT 131
13650
-#define TK_VALUES 132
13651
-#define TK_DISTINCT 133
13652
-#define TK_DOT 134
13653
-#define TK_FROM 135
13654
-#define TK_JOIN 136
13655
-#define TK_USING 137
13656
-#define TK_ORDER 138
13657
-#define TK_GROUP 139
13658
-#define TK_HAVING 140
13659
-#define TK_LIMIT 141
13660
-#define TK_WHERE 142
13661
-#define TK_INTO 143
13662
-#define TK_NOTHING 144
13663
-#define TK_FLOAT 145
13664
-#define TK_BLOB 146
13665
-#define TK_INTEGER 147
13666
-#define TK_VARIABLE 148
13667
-#define TK_CASE 149
13668
-#define TK_WHEN 150
13669
-#define TK_THEN 151
13670
-#define TK_ELSE 152
13671
-#define TK_INDEX 153
13672
-#define TK_ALTER 154
13673
-#define TK_ADD 155
13674
-#define TK_WINDOW 156
13675
-#define TK_OVER 157
13676
-#define TK_FILTER 158
13677
-#define TK_TRUEFALSE 159
13678
-#define TK_ISNOT 160
13679
-#define TK_FUNCTION 161
13646
+#define TK_NULLS 82
13647
+#define TK_FIRST 83
13648
+#define TK_LAST 84
13649
+#define TK_CURRENT 85
13650
+#define TK_FOLLOWING 86
13651
+#define TK_PARTITION 87
13652
+#define TK_PRECEDING 88
13653
+#define TK_RANGE 89
13654
+#define TK_UNBOUNDED 90
13655
+#define TK_EXCLUDE 91
13656
+#define TK_GROUPS 92
13657
+#define TK_OTHERS 93
13658
+#define TK_TIES 94
13659
+#define TK_REINDEX 95
13660
+#define TK_RENAME 96
13661
+#define TK_CTIME_KW 97
13662
+#define TK_ANY 98
13663
+#define TK_BITAND 99
13664
+#define TK_BITOR 100
13665
+#define TK_LSHIFT 101
13666
+#define TK_RSHIFT 102
13667
+#define TK_PLUS 103
13668
+#define TK_MINUS 104
13669
+#define TK_STAR 105
13670
+#define TK_SLASH 106
13671
+#define TK_REM 107
13672
+#define TK_CONCAT 108
13673
+#define TK_COLLATE 109
13674
+#define TK_BITNOT 110
13675
+#define TK_ON 111
13676
+#define TK_INDEXED 112
13677
+#define TK_STRING 113
13678
+#define TK_JOIN_KW 114
13679
+#define TK_CONSTRAINT 115
13680
+#define TK_DEFAULT 116
13681
+#define TK_NULL 117
13682
+#define TK_PRIMARY 118
13683
+#define TK_UNIQUE 119
13684
+#define TK_CHECK 120
13685
+#define TK_REFERENCES 121
13686
+#define TK_AUTOINCR 122
13687
+#define TK_INSERT 123
13688
+#define TK_DELETE 124
13689
+#define TK_UPDATE 125
13690
+#define TK_SET 126
13691
+#define TK_DEFERRABLE 127
13692
+#define TK_FOREIGN 128
13693
+#define TK_DROP 129
13694
+#define TK_UNION 130
13695
+#define TK_ALL 131
13696
+#define TK_EXCEPT 132
13697
+#define TK_INTERSECT 133
13698
+#define TK_SELECT 134
13699
+#define TK_VALUES 135
13700
+#define TK_DISTINCT 136
13701
+#define TK_DOT 137
13702
+#define TK_FROM 138
13703
+#define TK_JOIN 139
13704
+#define TK_USING 140
13705
+#define TK_ORDER 141
13706
+#define TK_GROUP 142
13707
+#define TK_HAVING 143
13708
+#define TK_LIMIT 144
13709
+#define TK_WHERE 145
13710
+#define TK_INTO 146
13711
+#define TK_NOTHING 147
13712
+#define TK_FLOAT 148
13713
+#define TK_BLOB 149
13714
+#define TK_INTEGER 150
13715
+#define TK_VARIABLE 151
13716
+#define TK_CASE 152
13717
+#define TK_WHEN 153
13718
+#define TK_THEN 154
13719
+#define TK_ELSE 155
13720
+#define TK_INDEX 156
13721
+#define TK_ALTER 157
13722
+#define TK_ADD 158
13723
+#define TK_WINDOW 159
13724
+#define TK_OVER 160
13725
+#define TK_FILTER 161
1368013726
#define TK_COLUMN 162
1368113727
#define TK_AGG_FUNCTION 163
1368213728
#define TK_AGG_COLUMN 164
13683
-#define TK_UMINUS 165
13684
-#define TK_UPLUS 166
13685
-#define TK_TRUTH 167
13686
-#define TK_REGISTER 168
13687
-#define TK_VECTOR 169
13688
-#define TK_SELECT_COLUMN 170
13689
-#define TK_IF_NULL_ROW 171
13690
-#define TK_ASTERISK 172
13691
-#define TK_SPAN 173
13692
-#define TK_SPACE 174
13693
-#define TK_ILLEGAL 175
13729
+#define TK_TRUEFALSE 165
13730
+#define TK_ISNOT 166
13731
+#define TK_FUNCTION 167
13732
+#define TK_UMINUS 168
13733
+#define TK_UPLUS 169
13734
+#define TK_TRUTH 170
13735
+#define TK_REGISTER 171
13736
+#define TK_VECTOR 172
13737
+#define TK_SELECT_COLUMN 173
13738
+#define TK_IF_NULL_ROW 174
13739
+#define TK_ASTERISK 175
13740
+#define TK_SPAN 176
13741
+#define TK_SPACE 177
13742
+#define TK_ILLEGAL 178
1369413743
1369513744
/************** End of parse.h ***********************************************/
1369613745
/************** Continuing where we left off in sqliteInt.h ******************/
1369713746
#include <stdio.h>
1369813747
#include <stdlib.h>
@@ -14099,24 +14148,10 @@
1409914148
#if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE
1410014149
# undef SQLITE_DEFAULT_MMAP_SIZE
1410114150
# define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE
1410214151
#endif
1410314152
14104
-/*
14105
-** Only one of SQLITE_ENABLE_STAT3 or SQLITE_ENABLE_STAT4 can be defined.
14106
-** Priority is given to SQLITE_ENABLE_STAT4. If either are defined, also
14107
-** define SQLITE_ENABLE_STAT3_OR_STAT4
14108
-*/
14109
-#ifdef SQLITE_ENABLE_STAT4
14110
-# undef SQLITE_ENABLE_STAT3
14111
-# define SQLITE_ENABLE_STAT3_OR_STAT4 1
14112
-#elif SQLITE_ENABLE_STAT3
14113
-# define SQLITE_ENABLE_STAT3_OR_STAT4 1
14114
-#elif SQLITE_ENABLE_STAT3_OR_STAT4
14115
-# undef SQLITE_ENABLE_STAT3_OR_STAT4
14116
-#endif
14117
-
1411814153
/*
1411914154
** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not
1412014155
** the Select query generator tracing logic is turned on.
1412114156
*/
1412214157
#if defined(SQLITE_ENABLE_SELECTTRACE)
@@ -14982,28 +15017,28 @@
1498215017
#define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */
1498315018
#define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
1498415019
#define OP_Count 93 /* synopsis: r[P2]=count() */
1498515020
#define OP_ReadCookie 94
1498615021
#define OP_SetCookie 95
14987
-#define OP_BitAnd 96 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
14988
-#define OP_BitOr 97 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
14989
-#define OP_ShiftLeft 98 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
14990
-#define OP_ShiftRight 99 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
14991
-#define OP_Add 100 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
14992
-#define OP_Subtract 101 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
14993
-#define OP_Multiply 102 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
14994
-#define OP_Divide 103 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
14995
-#define OP_Remainder 104 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
14996
-#define OP_Concat 105 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
14997
-#define OP_ReopenIdx 106 /* synopsis: root=P2 iDb=P3 */
14998
-#define OP_BitNot 107 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
14999
-#define OP_OpenRead 108 /* synopsis: root=P2 iDb=P3 */
15000
-#define OP_OpenWrite 109 /* synopsis: root=P2 iDb=P3 */
15001
-#define OP_String8 110 /* same as TK_STRING, synopsis: r[P2]='P4' */
15002
-#define OP_OpenDup 111
15003
-#define OP_OpenAutoindex 112 /* synopsis: nColumn=P2 */
15004
-#define OP_OpenEphemeral 113 /* synopsis: nColumn=P2 */
15022
+#define OP_ReopenIdx 96 /* synopsis: root=P2 iDb=P3 */
15023
+#define OP_OpenRead 97 /* synopsis: root=P2 iDb=P3 */
15024
+#define OP_OpenWrite 98 /* synopsis: root=P2 iDb=P3 */
15025
+#define OP_BitAnd 99 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
15026
+#define OP_BitOr 100 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
15027
+#define OP_ShiftLeft 101 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
15028
+#define OP_ShiftRight 102 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
15029
+#define OP_Add 103 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
15030
+#define OP_Subtract 104 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
15031
+#define OP_Multiply 105 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
15032
+#define OP_Divide 106 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
15033
+#define OP_Remainder 107 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
15034
+#define OP_Concat 108 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
15035
+#define OP_OpenDup 109
15036
+#define OP_BitNot 110 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
15037
+#define OP_OpenAutoindex 111 /* synopsis: nColumn=P2 */
15038
+#define OP_OpenEphemeral 112 /* synopsis: nColumn=P2 */
15039
+#define OP_String8 113 /* same as TK_STRING, synopsis: r[P2]='P4' */
1500515040
#define OP_SorterOpen 114
1500615041
#define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
1500715042
#define OP_OpenPseudo 116 /* synopsis: P3 columns in r[P2] */
1500815043
#define OP_Close 117
1500915044
#define OP_ColumnsUsed 118
@@ -15031,14 +15066,14 @@
1503115066
#define OP_SqlExec 140
1503215067
#define OP_ParseSchema 141
1503315068
#define OP_LoadAnalysis 142
1503415069
#define OP_DropTable 143
1503515070
#define OP_DropIndex 144
15036
-#define OP_Real 145 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15037
-#define OP_DropTrigger 146
15038
-#define OP_IntegrityCk 147
15039
-#define OP_RowSetAdd 148 /* synopsis: rowset(P1)=r[P2] */
15071
+#define OP_DropTrigger 145
15072
+#define OP_IntegrityCk 146
15073
+#define OP_RowSetAdd 147 /* synopsis: rowset(P1)=r[P2] */
15074
+#define OP_Real 148 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
1504015075
#define OP_Param 149
1504115076
#define OP_FkCounter 150 /* synopsis: fkctr[P1]+=P2 */
1504215077
#define OP_MemMax 151 /* synopsis: r[P1]=max(r[P1],r[P2]) */
1504315078
#define OP_OffsetLimit 152 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
1504415079
#define OP_AggInverse 153 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
@@ -15083,17 +15118,17 @@
1508315118
/* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\
1508415119
/* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
1508515120
/* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
1508615121
/* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
1508715122
/* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
15088
-/* 96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
15089
-/* 104 */ 0x26, 0x26, 0x00, 0x12, 0x00, 0x00, 0x10, 0x00,\
15090
-/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15123
+/* 96 */ 0x00, 0x00, 0x00, 0x26, 0x26, 0x26, 0x26, 0x26,\
15124
+/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12, 0x00,\
15125
+/* 112 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
1509115126
/* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
1509215127
/* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
1509315128
/* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15094
-/* 144 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
15129
+/* 144 */ 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x04,\
1509515130
/* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
1509615131
/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
1509715132
/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,}
1509815133
1509915134
/* The sqlite3P2Values() routine is able to run faster if it knows
@@ -15159,14 +15194,14 @@
1515915194
SQLITE_PRIVATE void sqlite3ExplainBreakpoint(const char*,const char*);
1516015195
#else
1516115196
# define sqlite3ExplainBreakpoint(A,B) /*no-op*/
1516215197
#endif
1516315198
SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
15164
-SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8);
15165
-SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);
15166
-SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2);
15167
-SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3);
15199
+SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, int addr, u8);
15200
+SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1);
15201
+SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2);
15202
+SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3);
1516815203
SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5);
1516915204
SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);
1517015205
SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr);
1517115206
SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);
1517215207
SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);
@@ -16377,10 +16412,11 @@
1637716412
u8 iDb; /* Which db file is being initialized */
1637816413
u8 busy; /* TRUE if currently initializing */
1637916414
unsigned orphanTrigger : 1; /* Last statement is orphaned TEMP trigger */
1638016415
unsigned imposterTable : 1; /* Building an imposter table */
1638116416
unsigned reopenMemdb : 1; /* ATTACH is really a reopen using MemDB */
16417
+ char **azInit; /* "type", "name", and "tbl_name" columns */
1638216418
} init;
1638316419
int nVdbeActive; /* Number of VDBEs currently running */
1638416420
int nVdbeRead; /* Number of active VDBEs that read or write */
1638516421
int nVdbeWrite; /* Number of active VDBEs that read and write */
1638616422
int nVdbeExec; /* Number of nested calls to VdbeExec() */
@@ -16515,20 +16551,21 @@
1651516551
#define SQLITE_LegacyAlter 0x04000000 /* Legacy ALTER TABLE behaviour */
1651616552
#define SQLITE_NoSchemaError 0x08000000 /* Do not report schema parse errors*/
1651716553
#define SQLITE_Defensive 0x10000000 /* Input SQL is likely hostile */
1651816554
#define SQLITE_DqsDDL 0x20000000 /* dbl-quoted strings allowed in DDL*/
1651916555
#define SQLITE_DqsDML 0x40000000 /* dbl-quoted strings allowed in DML*/
16556
+#define SQLITE_EnableView 0x80000000 /* Enable the use of views */
1652016557
1652116558
/* Flags used only if debugging */
1652216559
#define HI(X) ((u64)(X)<<32)
1652316560
#ifdef SQLITE_DEBUG
16524
-#define SQLITE_SqlTrace HI(0x0001) /* Debug print SQL as it executes */
16525
-#define SQLITE_VdbeListing HI(0x0002) /* Debug listings of VDBE progs */
16526
-#define SQLITE_VdbeTrace HI(0x0004) /* True to trace VDBE execution */
16527
-#define SQLITE_VdbeAddopTrace HI(0x0008) /* Trace sqlite3VdbeAddOp() calls */
16528
-#define SQLITE_VdbeEQP HI(0x0010) /* Debug EXPLAIN QUERY PLAN */
16529
-#define SQLITE_ParserTrace HI(0x0020) /* PRAGMA parser_trace=ON */
16561
+#define SQLITE_SqlTrace HI(0x0100000) /* Debug print SQL as it executes */
16562
+#define SQLITE_VdbeListing HI(0x0200000) /* Debug listings of VDBE progs */
16563
+#define SQLITE_VdbeTrace HI(0x0400000) /* True to trace VDBE execution */
16564
+#define SQLITE_VdbeAddopTrace HI(0x0800000) /* Trace sqlite3VdbeAddOp() calls */
16565
+#define SQLITE_VdbeEQP HI(0x1000000) /* Debug EXPLAIN QUERY PLAN */
16566
+#define SQLITE_ParserTrace HI(0x2000000) /* PRAGMA parser_trace=ON */
1653016567
#endif
1653116568
1653216569
/*
1653316570
** Allowed values for sqlite3.mDbFlags
1653416571
*/
@@ -16552,12 +16589,12 @@
1655216589
#define SQLITE_OrderByIdxJoin 0x0040 /* ORDER BY of joins via index */
1655316590
#define SQLITE_Transitive 0x0080 /* Transitive constraints */
1655416591
#define SQLITE_OmitNoopJoin 0x0100 /* Omit unused tables in joins */
1655516592
#define SQLITE_CountOfView 0x0200 /* The count-of-view optimization */
1655616593
#define SQLITE_CursorHints 0x0400 /* Add OP_CursorHint opcodes */
16557
-#define SQLITE_Stat34 0x0800 /* Use STAT3 or STAT4 data */
16558
- /* TH3 expects the Stat34 ^^^^^^ value to be 0x0800. Don't change it */
16594
+#define SQLITE_Stat4 0x0800 /* Use STAT4 data */
16595
+ /* TH3 expects the Stat4 ^^^^^^ value to be 0x0800. Don't change it */
1655916596
#define SQLITE_PushDown 0x1000 /* The push-down optimization */
1656016597
#define SQLITE_SimplifyJoin 0x2000 /* Convert LEFT JOIN to JOIN */
1656116598
#define SQLITE_SkipScan 0x4000 /* Skip-scans */
1656216599
#define SQLITE_PropagateConst 0x8000 /* The constant propagation opt */
1656316600
#define SQLITE_AllOpts 0xffff /* All optimizations */
@@ -16641,10 +16678,11 @@
1664116678
** Value constraints (enforced via assert()):
1664216679
** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg
1664316680
** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG
1664416681
** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG
1664516682
** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API
16683
+** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API
1664616684
** SQLITE_FUNC_ENCMASK depends on SQLITE_UTF* macros in the API
1664716685
*/
1664816686
#define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
1664916687
#define SQLITE_FUNC_LIKE 0x0004 /* Candidate for the LIKE optimization */
1665016688
#define SQLITE_FUNC_CASE 0x0008 /* Case-sensitive LIKE-type function */
@@ -16661,10 +16699,11 @@
1666116699
** single query - might change over time */
1666216700
#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
1666316701
#define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */
1666416702
#define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */
1666516703
#define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */
16704
+#define SQLITE_FUNC_DIRECT 0x00080000 /* Not for use in TRIGGERs or VIEWs */
1666616705
1666716706
/*
1666816707
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
1666916708
** used to create the initializers for the FuncDef structures.
1667016709
**
@@ -16774,10 +16813,11 @@
1677416813
** hash table.
1677516814
*/
1677616815
struct Module {
1677716816
const sqlite3_module *pModule; /* Callback pointers */
1677816817
const char *zName; /* Name passed to create_module() */
16818
+ int nRefModule; /* Number of pointers to this object */
1677916819
void *pAux; /* pAux passed to create_module() */
1678016820
void (*xDestroy)(void *); /* Module destructor function */
1678116821
Table *pEpoTab; /* Eponymous table for this module */
1678216822
};
1678316823
@@ -16839,15 +16879,16 @@
1683916879
** used as the P4 operand, they will be more readable.
1684016880
**
1684116881
** Note also that the numeric types are grouped together so that testing
1684216882
** for a numeric type is a single comparison. And the BLOB type is first.
1684316883
*/
16844
-#define SQLITE_AFF_BLOB 'A'
16845
-#define SQLITE_AFF_TEXT 'B'
16846
-#define SQLITE_AFF_NUMERIC 'C'
16847
-#define SQLITE_AFF_INTEGER 'D'
16848
-#define SQLITE_AFF_REAL 'E'
16884
+#define SQLITE_AFF_NONE 0x40 /* '@' */
16885
+#define SQLITE_AFF_BLOB 0x41 /* 'A' */
16886
+#define SQLITE_AFF_TEXT 0x42 /* 'B' */
16887
+#define SQLITE_AFF_NUMERIC 0x43 /* 'C' */
16888
+#define SQLITE_AFF_INTEGER 0x44 /* 'D' */
16889
+#define SQLITE_AFF_REAL 0x45 /* 'E' */
1684916890
1685016891
#define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC)
1685116892
1685216893
/*
1685316894
** The SQLITE_AFF_MASK values masks off the significant bits of an
@@ -17111,13 +17152,16 @@
1711117152
u32 nRef; /* Number of references to this KeyInfo object */
1711217153
u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
1711317154
u16 nKeyField; /* Number of key columns in the index */
1711417155
u16 nAllField; /* Total columns, including key plus others */
1711517156
sqlite3 *db; /* The database connection */
17116
- u8 *aSortOrder; /* Sort order for each column. */
17157
+ u8 *aSortFlags; /* Sort order for each column. */
1711717158
CollSeq *aColl[1]; /* Collating sequence for each term of the key */
1711817159
};
17160
+
17161
+#define KEYINFO_ORDER_DESC 0x01
17162
+#define KEYINFO_ORDER_BIGNULL 0x02
1711917163
1712017164
/*
1712117165
** This object holds a record which has been parsed out into individual
1712217166
** fields, for the purposes of doing a comparison.
1712317167
**
@@ -17222,11 +17266,11 @@
1722217266
unsigned isCovering:1; /* True if this is a covering index */
1722317267
unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
1722417268
unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
1722517269
unsigned bNoQuery:1; /* Do not use this index to optimize queries */
1722617270
unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
17227
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
17271
+#ifdef SQLITE_ENABLE_STAT4
1722817272
int nSample; /* Number of elements in aSample[] */
1722917273
int nSampleCol; /* Size of IndexSample.anEq[] and so on */
1723017274
tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
1723117275
IndexSample *aSample; /* Samples of the left-most key */
1723217276
tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */
@@ -17254,11 +17298,11 @@
1725417298
*/
1725517299
#define XN_ROWID (-1) /* Indexed column is the rowid */
1725617300
#define XN_EXPR (-2) /* Indexed column is an expression */
1725717301
1725817302
/*
17259
-** Each sample stored in the sqlite_stat3 table is represented in memory
17303
+** Each sample stored in the sqlite_stat4 table is represented in memory
1726017304
** using a structure of this type. See documentation at the top of the
1726117305
** analyze.c source file for additional information.
1726217306
*/
1726317307
struct IndexSample {
1726417308
void *p; /* Pointer to sampled record */
@@ -17412,11 +17456,11 @@
1741217456
** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately
1741317457
** allocated, regardless of whether or not EP_Reduced is set.
1741417458
*/
1741517459
struct Expr {
1741617460
u8 op; /* Operation performed by this node */
17417
- char affinity; /* The affinity of the column or 0 if not a column */
17461
+ char affExpr; /* affinity, or RAISE type */
1741817462
u32 flags; /* Various flags. EP_* See below */
1741917463
union {
1742017464
char *zToken; /* Token value. Zero terminated and dequoted */
1742117465
int iValue; /* Non-negative integer value if EP_IntValue */
1742217466
} u;
@@ -17443,10 +17487,11 @@
1744317487
#endif
1744417488
int iTable; /* TK_COLUMN: cursor number of table holding column
1744517489
** TK_REGISTER: register number
1744617490
** TK_TRIGGER: 1 -> new, 0 -> old
1744717491
** EP_Unlikely: 134217728 times likelihood
17492
+ ** TK_SELECT_COLUMN: Number of columns on the LHS
1744817493
** TK_SELECT: 1st register of result vector */
1744917494
ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
1745017495
** TK_VARIABLE: variable number (always >= 1).
1745117496
** TK_SELECT_COLUMN: column of the result vector */
1745217497
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
@@ -17456,11 +17501,11 @@
1745617501
** TK_AGG_FUNCTION: nesting depth */
1745717502
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
1745817503
union {
1745917504
Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
1746017505
** for a column of an index on an expression */
17461
- Window *pWin; /* TK_FUNCTION: Window definition for the func */
17506
+ Window *pWin; /* EP_WinFunc: Window/Filter defn for a function */
1746217507
struct { /* TK_IN, TK_SELECT, and TK_EXISTS */
1746317508
int iAddr; /* Subroutine entry address */
1746417509
int regReturn; /* Register used to hold return address */
1746517510
} sub;
1746617511
} y;
@@ -17471,40 +17516,41 @@
1747117516
** Value restrictions:
1747217517
**
1747317518
** EP_Agg == NC_HasAgg == SF_HasAgg
1747417519
** EP_Win == NC_HasWin
1747517520
*/
17476
-#define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
17477
-#define EP_Distinct 0x000002 /* Aggregate function with DISTINCT keyword */
17478
-#define EP_HasFunc 0x000004 /* Contains one or more functions of any kind */
17479
-#define EP_FixedCol 0x000008 /* TK_Column with a known fixed value */
17480
-#define EP_Agg 0x000010 /* Contains one or more aggregate functions */
17481
-#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
17482
-#define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
17483
-#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
17484
-#define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
17485
-#define EP_Generic 0x000200 /* Ignore COLLATE or affinity on this tree */
17486
-#define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
17487
-#define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
17488
-#define EP_Skip 0x001000 /* Operator does not contribute to affinity */
17489
-#define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
17490
-#define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
17491
-#define EP_Win 0x008000 /* Contains window functions */
17492
-#define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */
17493
-#define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
17494
-#define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */
17495
-#define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
17496
-#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
17497
-#define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */
17498
-#define EP_Alias 0x400000 /* Is an alias for a result set column */
17499
-#define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
17500
-#define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
17501
-#define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */
17502
-#define EP_Quoted 0x4000000 /* TK_ID was originally quoted */
17503
-#define EP_Static 0x8000000 /* Held in memory not obtained from malloc() */
17504
-#define EP_IsTrue 0x10000000 /* Always has boolean value of TRUE */
17505
-#define EP_IsFalse 0x20000000 /* Always has boolean value of FALSE */
17521
+#define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
17522
+#define EP_Distinct 0x000002 /* Aggregate function with DISTINCT keyword */
17523
+#define EP_HasFunc 0x000004 /* Contains one or more functions of any kind */
17524
+#define EP_FixedCol 0x000008 /* TK_Column with a known fixed value */
17525
+#define EP_Agg 0x000010 /* Contains one or more aggregate functions */
17526
+#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
17527
+#define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
17528
+#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
17529
+#define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
17530
+ /* 0x000200 Available for reuse */
17531
+#define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
17532
+#define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
17533
+#define EP_Skip 0x001000 /* Operator does not contribute to affinity */
17534
+#define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
17535
+#define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
17536
+#define EP_Win 0x008000 /* Contains window functions */
17537
+#define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */
17538
+#define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
17539
+#define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */
17540
+#define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
17541
+#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
17542
+#define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */
17543
+#define EP_Alias 0x400000 /* Is an alias for a result set column */
17544
+#define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
17545
+#define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
17546
+#define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */
17547
+#define EP_Quoted 0x4000000 /* TK_ID was originally quoted */
17548
+#define EP_Static 0x8000000 /* Held in memory not obtained from malloc() */
17549
+#define EP_IsTrue 0x10000000 /* Always has boolean value of TRUE */
17550
+#define EP_IsFalse 0x20000000 /* Always has boolean value of FALSE */
17551
+#define EP_Indirect 0x40000000 /* Contained within a TRIGGER or a VIEW */
1750617552
1750717553
/*
1750817554
** The EP_Propagate mask is a set of properties that automatically propagate
1750917555
** upwards into parent nodes.
1751017556
*/
@@ -17543,10 +17589,18 @@
1754317589
/*
1754417590
** Flags passed to the sqlite3ExprDup() function. See the header comment
1754517591
** above sqlite3ExprDup() for details.
1754617592
*/
1754717593
#define EXPRDUP_REDUCE 0x0001 /* Used reduced-size Expr nodes */
17594
+
17595
+/*
17596
+** True if the expression passed as an argument was a function with
17597
+** an OVER() clause (a window function).
17598
+*/
17599
+#define IsWindowFunc(p) ( \
17600
+ ExprHasProperty((p), EP_WinFunc) && p->y.pWin->eFrmType!=TK_FILTER \
17601
+)
1754817602
1754917603
/*
1755017604
** A list of expressions. Each expression may optionally have a
1755117605
** name. An expr/name combination can be used in several ways, such
1755217606
** as the list of "expr AS ID" fields following a "SELECT" or in the
@@ -17566,15 +17620,16 @@
1756617620
int nExpr; /* Number of expressions on the list */
1756717621
struct ExprList_item { /* For each expression in the list */
1756817622
Expr *pExpr; /* The parse tree for this expression */
1756917623
char *zName; /* Token associated with this expression */
1757017624
char *zSpan; /* Original text of the expression */
17571
- u8 sortOrder; /* 1 for DESC or 0 for ASC */
17625
+ u8 sortFlags; /* Mask of KEYINFO_ORDER_* flags */
1757217626
unsigned done :1; /* A flag to indicate when processing is finished */
1757317627
unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
1757417628
unsigned reusable :1; /* Constant expression is reusable */
1757517629
unsigned bSorterRef :1; /* Defer evaluation until after sorting */
17630
+ unsigned bNulls: 1; /* True if explicit "NULLS FIRST/LAST" */
1757617631
union {
1757717632
struct {
1757817633
u16 iOrderByCol; /* For ORDER BY, column number in result set */
1757917634
u16 iAlias; /* Index into Parse.aAlias[] for zName */
1758017635
} x;
@@ -17861,10 +17916,11 @@
1786117916
#define SF_FixedLimit 0x04000 /* nSelectRow set by a constant LIMIT */
1786217917
#define SF_MaybeConvert 0x08000 /* Need convertCompoundSelectToSubquery() */
1786317918
#define SF_Converted 0x10000 /* By convertCompoundSelectToSubquery() */
1786417919
#define SF_IncludeHidden 0x20000 /* Include hidden columns in output */
1786517920
#define SF_ComplexResult 0x40000 /* Result contains subquery or function */
17921
+#define SF_WhereBegin 0x80000 /* Really a WhereBegin() call. Debug Only */
1786617922
1786717923
/*
1786817924
** The results of a SELECT can be distributed in several ways, as defined
1786917925
** by one of the following macros. The "SRT" prefix means "SELECT Result
1787017926
** Type".
@@ -18365,15 +18421,16 @@
1836518421
**
1836618422
** This structure also contains some state information.
1836718423
*/
1836818424
struct Sqlite3Config {
1836918425
int bMemstat; /* True to enable memory status */
18370
- int bCoreMutex; /* True to enable core mutexing */
18371
- int bFullMutex; /* True to enable full mutexing */
18372
- int bOpenUri; /* True to interpret filenames as URIs */
18373
- int bUseCis; /* Use covering indices for full-scans */
18374
- int bSmallMalloc; /* Avoid large memory allocations if true */
18426
+ u8 bCoreMutex; /* True to enable core mutexing */
18427
+ u8 bFullMutex; /* True to enable full mutexing */
18428
+ u8 bOpenUri; /* True to interpret filenames as URIs */
18429
+ u8 bUseCis; /* Use covering indices for full-scans */
18430
+ u8 bSmallMalloc; /* Avoid large memory allocations if true */
18431
+ u8 bExtraSchemaChecks; /* Verify type,name,tbl_name in schema */
1837518432
int mxStrlen; /* Maximum string length */
1837618433
int neverCorrupt; /* Database is always well-formed */
1837718434
int szLookaside; /* Default lookaside buffer size */
1837818435
int nLookaside; /* Default lookaside buffer count */
1837918436
int nStmtSpill; /* Stmt-journal spill-to-disk threshold */
@@ -18421,10 +18478,11 @@
1842118478
#endif
1842218479
int bLocaltimeFault; /* True to fail localtime() calls */
1842318480
int bInternalFunctions; /* Internal SQL functions are visible */
1842418481
int iOnceResetThreshold; /* When to reset OP_Once counters */
1842518482
u32 szSorterRef; /* Min size in bytes to use sorter-refs */
18483
+ unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */
1842618484
};
1842718485
1842818486
/*
1842918487
** This macro is used inside of assert() statements to indicate that
1843018488
** the assert is only valid on a well-formed database. Instead of:
@@ -18517,14 +18575,15 @@
1851718575
u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */
1851818576
};
1851918577
#endif /* SQLITE_DEBUG */
1852018578
1852118579
/*
18522
-** This object is used in various ways, all related to window functions
18580
+** This object is used in various ways, most (but not all) related to window
18581
+** functions.
1852318582
**
1852418583
** (1) A single instance of this structure is attached to the
18525
-** the Expr.pWin field for each window function in an expression tree.
18584
+** the Expr.y.pWin field for each window function in an expression tree.
1852618585
** This object holds the information contained in the OVER clause,
1852718586
** plus additional fields used during code generation.
1852818587
**
1852918588
** (2) All window functions in a single SELECT form a linked-list
1853018589
** attached to Select.pWin. The Window.pFunc and Window.pExpr
@@ -18531,10 +18590,14 @@
1853118590
** fields point back to the expression that is the window function.
1853218591
**
1853318592
** (3) The terms of the WINDOW clause of a SELECT are instances of this
1853418593
** object on a linked list attached to Select.pWinDefn.
1853518594
**
18595
+** (4) For an aggregate function with a FILTER clause, an instance
18596
+** of this object is stored in Expr.y.pWin with eFrmType set to
18597
+** TK_FILTER. In this case the only field used is Window.pFilter.
18598
+**
1853618599
** The uses (1) and (2) are really the same Window object that just happens
1853718600
** to be accessible in two different ways. Use case (3) are separate objects.
1853818601
*/
1853918602
struct Window {
1854018603
char *zName; /* Name of window (may be NULL) */
@@ -18546,10 +18609,11 @@
1854618609
u8 eEnd; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
1854718610
u8 bImplicitFrame; /* True if frame was implicitly specified */
1854818611
u8 eExclude; /* TK_NO, TK_CURRENT, TK_TIES, TK_GROUP, or 0 */
1854918612
Expr *pStart; /* Expression for "<expr> PRECEDING" */
1855018613
Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
18614
+ Window **ppThis; /* Pointer to this object in Select.pWin list */
1855118615
Window *pNextWin; /* Next window function belonging to this SELECT */
1855218616
Expr *pFilter; /* The FILTER expression */
1855318617
FuncDef *pFunc; /* The function */
1855418618
int iEphCsr; /* Partition buffer or Peer buffer */
1855518619
int regAccum;
@@ -18565,14 +18629,16 @@
1856518629
int regEndRowid;
1856618630
};
1856718631
1856818632
#ifndef SQLITE_OMIT_WINDOWFUNC
1856918633
SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3*, Window*);
18634
+SQLITE_PRIVATE void sqlite3WindowUnlinkFromSelect(Window*);
1857018635
SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p);
1857118636
SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, u8);
1857218637
SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*);
18573
-SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*);
18638
+SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin);
18639
+SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*, int);
1857418640
SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*);
1857518641
SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);
1857618642
SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*);
1857718643
SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*);
1857818644
SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*);
@@ -18840,11 +18906,11 @@
1884018906
SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
1884118907
SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
1884218908
SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
1884318909
SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
1884418910
SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
18845
-SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int);
18911
+SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int);
1884618912
SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
1884718913
SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
1884818914
SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
1884918915
SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
1885018916
SQLITE_PRIVATE int sqlite3IndexHasDuplicateRootPage(Index*);
@@ -18859,12 +18925,12 @@
1885918925
SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);
1886018926
SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);
1886118927
SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);
1886218928
SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
1886318929
SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
18864
-SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*);
18865
-SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
18930
+SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char);
18931
+SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char);
1886618932
SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
1886718933
SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
1886818934
SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);
1886918935
SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
1887018936
#if SQLITE_ENABLE_HIDDEN_COLUMNS
@@ -19161,11 +19227,11 @@
1916119227
SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst);
1916219228
#ifndef SQLITE_OMIT_VIRTUALTABLE
1916319229
SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double);
1916419230
#endif
1916519231
#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
19166
- defined(SQLITE_ENABLE_STAT3_OR_STAT4) || \
19232
+ defined(SQLITE_ENABLE_STAT4) || \
1916719233
defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
1916819234
SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst);
1916919235
#endif
1917019236
SQLITE_PRIVATE VList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int);
1917119237
SQLITE_PRIVATE const char *sqlite3VListNumToName(VList*,int);
@@ -19227,13 +19293,14 @@
1922719293
SQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, Expr *pExpr);
1922819294
SQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,Expr*,Expr*);
1922919295
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
1923019296
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
1923119297
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
19298
+SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr*);
1923219299
SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
1923319300
SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*);
19234
-SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);
19301
+SQLITE_PRIVATE int sqlite3CheckObjectName(Parse*, const char*,const char*,const char*);
1923519302
SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
1923619303
SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);
1923719304
SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);
1923819305
SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);
1923919306
SQLITE_PRIVATE int sqlite3AbsInt32(int);
@@ -19316,10 +19383,11 @@
1931619383
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);
1931719384
SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo*);
1931819385
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo*);
1931919386
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);
1932019387
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList(Parse*, ExprList*, int, int);
19388
+SQLITE_PRIVATE int sqlite3HasExplicitNulls(Parse*, ExprList*);
1932119389
1932219390
#ifdef SQLITE_DEBUG
1932319391
SQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo*);
1932419392
#endif
1932519393
SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
@@ -19348,12 +19416,11 @@
1934819416
SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse*, Expr*);
1934919417
#else
1935019418
# define sqlite3ExprCheckIN(x,y) SQLITE_OK
1935119419
#endif
1935219420
19353
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
19354
-SQLITE_PRIVATE void sqlite3AnalyzeFunctions(void);
19421
+#ifdef SQLITE_ENABLE_STAT4
1935519422
SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(
1935619423
Parse*,Index*,UnpackedRecord**,Expr*,int,int,int*);
1935719424
SQLITE_PRIVATE int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);
1935819425
SQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord*);
1935919426
SQLITE_PRIVATE int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);
@@ -19396,10 +19463,11 @@
1939619463
# define sqlite3VtabRollback(X)
1939719464
# define sqlite3VtabCommit(X)
1939819465
# define sqlite3VtabInSync(db) 0
1939919466
# define sqlite3VtabLock(X)
1940019467
# define sqlite3VtabUnlock(X)
19468
+# define sqlite3VtabModuleUnref(D,X)
1940119469
# define sqlite3VtabUnlockList(X)
1940219470
# define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK
1940319471
# define sqlite3GetVTable(X,Y) ((VTable*)0)
1940419472
#else
1940519473
SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table*);
@@ -19407,10 +19475,11 @@
1940719475
SQLITE_PRIVATE int sqlite3VtabSync(sqlite3 *db, Vdbe*);
1940819476
SQLITE_PRIVATE int sqlite3VtabRollback(sqlite3 *db);
1940919477
SQLITE_PRIVATE int sqlite3VtabCommit(sqlite3 *db);
1941019478
SQLITE_PRIVATE void sqlite3VtabLock(VTable *);
1941119479
SQLITE_PRIVATE void sqlite3VtabUnlock(VTable *);
19480
+SQLITE_PRIVATE void sqlite3VtabModuleUnref(sqlite3*,Module*);
1941219481
SQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3*);
1941319482
SQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *, int, int);
1941419483
SQLITE_PRIVATE void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*);
1941519484
SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3*, Table*);
1941619485
SQLITE_PRIVATE Module *sqlite3VtabCreateModule(
@@ -19874,10 +19943,11 @@
1987419943
1, /* bCoreMutex */
1987519944
SQLITE_THREADSAFE==1, /* bFullMutex */
1987619945
SQLITE_USE_URI, /* bOpenUri */
1987719946
SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */
1987819947
0, /* bSmallMalloc */
19948
+ 1, /* bExtraSchemaChecks */
1987919949
0x7ffffffe, /* mxStrlen */
1988019950
0, /* neverCorrupt */
1988119951
SQLITE_DEFAULT_LOOKASIDE, /* szLookaside, nLookaside */
1988219952
SQLITE_STMTJRNL_SPILL, /* nStmtSpill */
1988319953
{0,0,0,0,0,0,0,0}, /* m */
@@ -19920,10 +19990,11 @@
1992019990
#endif
1992119991
0, /* bLocaltimeFault */
1992219992
0, /* bInternalFunctions */
1992319993
0x7ffffffe, /* iOnceResetThreshold */
1992419994
SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
19995
+ 0, /* iPrngSeed */
1992519996
};
1992619997
1992719998
/*
1992819999
** Hash table for global functions - functions common to all
1992920000
** database connections. After initialization, this table is
@@ -20489,11 +20560,10 @@
2048920560
void sqliteVdbePopStack(Vdbe*,int);
2049020561
SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, int*);
2049120562
SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
2049220563
SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
2049320564
SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
20494
-SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int, u32*);
2049520565
SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
2049620566
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
2049720567
SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3*, AuxData**, int, int);
2049820568
2049920569
int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
@@ -22495,11 +22565,19 @@
2249522565
SQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *pVfs, void *pHandle){
2249622566
pVfs->xDlClose(pVfs, pHandle);
2249722567
}
2249822568
#endif /* SQLITE_OMIT_LOAD_EXTENSION */
2249922569
SQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
22500
- return pVfs->xRandomness(pVfs, nByte, zBufOut);
22570
+ if( sqlite3Config.iPrngSeed ){
22571
+ memset(zBufOut, 0, nByte);
22572
+ if( ALWAYS(nByte>(signed)sizeof(unsigned)) ) nByte = sizeof(unsigned int);
22573
+ memcpy(zBufOut, &sqlite3Config.iPrngSeed, nByte);
22574
+ return SQLITE_OK;
22575
+ }else{
22576
+ return pVfs->xRandomness(pVfs, nByte, zBufOut);
22577
+ }
22578
+
2250122579
}
2250222580
SQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){
2250322581
return pVfs->xSleep(pVfs, nMicro);
2250422582
}
2250522583
SQLITE_PRIVATE int sqlite3OsGetLastError(sqlite3_vfs *pVfs){
@@ -28776,17 +28854,21 @@
2877628854
sqlite3TreeViewWith(pView, p->pWith, 1);
2877728855
cnt = 1;
2877828856
sqlite3TreeViewPush(pView, 1);
2877928857
}
2878028858
do{
28781
- sqlite3TreeViewLine(pView,
28782
- "SELECT%s%s (%u/%p) selFlags=0x%x nSelectRow=%d",
28783
- ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
28784
- ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""),
28785
- p->selId, p, p->selFlags,
28786
- (int)p->nSelectRow
28787
- );
28859
+ if( p->selFlags & SF_WhereBegin ){
28860
+ sqlite3TreeViewLine(pView, "sqlite3WhereBegin()");
28861
+ }else{
28862
+ sqlite3TreeViewLine(pView,
28863
+ "SELECT%s%s (%u/%p) selFlags=0x%x nSelectRow=%d",
28864
+ ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
28865
+ ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""),
28866
+ p->selId, p, p->selFlags,
28867
+ (int)p->nSelectRow
28868
+ );
28869
+ }
2878828870
if( cnt++ ) sqlite3TreeViewPop(pView);
2878928871
if( p->pPrior ){
2879028872
n = 1000;
2879128873
}else{
2879228874
n = 0;
@@ -28799,11 +28881,14 @@
2879928881
#ifndef SQLITE_OMIT_WINDOWFUNC
2880028882
if( p->pWin ) n++;
2880128883
if( p->pWinDefn ) n++;
2880228884
#endif
2880328885
}
28804
- sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, "result-set");
28886
+ if( p->pEList ){
28887
+ sqlite3TreeViewExprList(pView, p->pEList, n>0, "result-set");
28888
+ }
28889
+ n--;
2880528890
#ifndef SQLITE_OMIT_WINDOWFUNC
2880628891
if( p->pWin ){
2880728892
Window *pX;
2880828893
pView = sqlite3TreeViewPush(pView, (n--)>0);
2880928894
sqlite3TreeViewLine(pView, "window-functions");
@@ -28995,16 +29080,18 @@
2899529080
if( pExpr==0 ){
2899629081
sqlite3TreeViewLine(pView, "nil");
2899729082
sqlite3TreeViewPop(pView);
2899829083
return;
2899929084
}
29000
- if( pExpr->flags ){
29085
+ if( pExpr->flags || pExpr->affExpr ){
2900129086
if( ExprHasProperty(pExpr, EP_FromJoin) ){
29002
- sqlite3_snprintf(sizeof(zFlgs),zFlgs," flags=0x%x iRJT=%d",
29003
- pExpr->flags, pExpr->iRightJoinTable);
29087
+ sqlite3_snprintf(sizeof(zFlgs),zFlgs," fg.af=%x.%c iRJT=%d",
29088
+ pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n',
29089
+ pExpr->iRightJoinTable);
2900429090
}else{
29005
- sqlite3_snprintf(sizeof(zFlgs),zFlgs," flags=0x%x",pExpr->flags);
29091
+ sqlite3_snprintf(sizeof(zFlgs),zFlgs," fg.af=%x.%c",
29092
+ pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n');
2900629093
}
2900729094
}else{
2900829095
zFlgs[0] = 0;
2900929096
}
2901029097
switch( pExpr->op ){
@@ -29148,14 +29235,14 @@
2914829235
#else
2914929236
pWin = 0;
2915029237
#endif
2915129238
}
2915229239
if( pExpr->op==TK_AGG_FUNCTION ){
29153
- sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q",
29154
- pExpr->op2, pExpr->u.zToken);
29240
+ sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s",
29241
+ pExpr->op2, pExpr->u.zToken, zFlgs);
2915529242
}else{
29156
- sqlite3TreeViewLine(pView, "FUNCTION %Q", pExpr->u.zToken);
29243
+ sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs);
2915729244
}
2915829245
if( pFarg ){
2915929246
sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);
2916029247
}
2916129248
#ifndef SQLITE_OMIT_WINDOWFUNC
@@ -29228,11 +29315,11 @@
2922829315
break;
2922929316
}
2923029317
#ifndef SQLITE_OMIT_TRIGGER
2923129318
case TK_RAISE: {
2923229319
const char *zType = "unk";
29233
- switch( pExpr->affinity ){
29320
+ switch( pExpr->affExpr ){
2923429321
case OE_Rollback: zType = "rollback"; break;
2923529322
case OE_Abort: zType = "abort"; break;
2923629323
case OE_Fail: zType = "fail"; break;
2923729324
case OE_Ignore: zType = "ignore"; break;
2923829325
}
@@ -29269,11 +29356,11 @@
2926929356
sqlite3TreeViewLine(pView, "%s%s", zBinOp, zFlgs);
2927029357
sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
2927129358
sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
2927229359
}else if( zUniOp ){
2927329360
sqlite3TreeViewLine(pView, "%s%s", zUniOp, zFlgs);
29274
- sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
29361
+ sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
2927529362
}
2927629363
sqlite3TreeViewPop(pView);
2927729364
}
2927829365
2927929366
@@ -31777,11 +31864,11 @@
3177731864
return e*10;
3177831865
}
3177931866
#endif /* SQLITE_OMIT_VIRTUALTABLE */
3178031867
3178131868
#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
31782
- defined(SQLITE_ENABLE_STAT3_OR_STAT4) || \
31869
+ defined(SQLITE_ENABLE_STAT4) || \
3178331870
defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
3178431871
/*
3178531872
** Convert a LogEst into an integer.
3178631873
**
3178731874
** Note that this routine is only used when one or more of various
@@ -31795,11 +31882,11 @@
3179531882
else if( n>=1 ) n -= 1;
3179631883
#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
3179731884
defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
3179831885
if( x>60 ) return (u64)LARGEST_INT64;
3179931886
#else
31800
- /* If only SQLITE_ENABLE_STAT3_OR_STAT4 is on, then the largest input
31887
+ /* If only SQLITE_ENABLE_STAT4 is on, then the largest input
3180131888
** possible to this routine is 310, resulting in a maximum x of 31 */
3180231889
assert( x<=60 );
3180331890
#endif
3180431891
return x>=3 ? (n+8)<<(x-3) : (n+8)>>(3-x);
3180531892
}
@@ -32288,28 +32375,28 @@
3228832375
/* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
3228932376
/* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
3229032377
/* 93 */ "Count" OpHelp("r[P2]=count()"),
3229132378
/* 94 */ "ReadCookie" OpHelp(""),
3229232379
/* 95 */ "SetCookie" OpHelp(""),
32293
- /* 96 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32294
- /* 97 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32295
- /* 98 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32296
- /* 99 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32297
- /* 100 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32298
- /* 101 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32299
- /* 102 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32300
- /* 103 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32301
- /* 104 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32302
- /* 105 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32303
- /* 106 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32304
- /* 107 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32305
- /* 108 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32306
- /* 109 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32307
- /* 110 */ "String8" OpHelp("r[P2]='P4'"),
32308
- /* 111 */ "OpenDup" OpHelp(""),
32309
- /* 112 */ "OpenAutoindex" OpHelp("nColumn=P2"),
32310
- /* 113 */ "OpenEphemeral" OpHelp("nColumn=P2"),
32380
+ /* 96 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32381
+ /* 97 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32382
+ /* 98 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32383
+ /* 99 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32384
+ /* 100 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32385
+ /* 101 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32386
+ /* 102 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32387
+ /* 103 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32388
+ /* 104 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32389
+ /* 105 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32390
+ /* 106 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32391
+ /* 107 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32392
+ /* 108 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32393
+ /* 109 */ "OpenDup" OpHelp(""),
32394
+ /* 110 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32395
+ /* 111 */ "OpenAutoindex" OpHelp("nColumn=P2"),
32396
+ /* 112 */ "OpenEphemeral" OpHelp("nColumn=P2"),
32397
+ /* 113 */ "String8" OpHelp("r[P2]='P4'"),
3231132398
/* 114 */ "SorterOpen" OpHelp(""),
3231232399
/* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
3231332400
/* 116 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
3231432401
/* 117 */ "Close" OpHelp(""),
3231532402
/* 118 */ "ColumnsUsed" OpHelp(""),
@@ -32337,14 +32424,14 @@
3233732424
/* 140 */ "SqlExec" OpHelp(""),
3233832425
/* 141 */ "ParseSchema" OpHelp(""),
3233932426
/* 142 */ "LoadAnalysis" OpHelp(""),
3234032427
/* 143 */ "DropTable" OpHelp(""),
3234132428
/* 144 */ "DropIndex" OpHelp(""),
32342
- /* 145 */ "Real" OpHelp("r[P2]=P4"),
32343
- /* 146 */ "DropTrigger" OpHelp(""),
32344
- /* 147 */ "IntegrityCk" OpHelp(""),
32345
- /* 148 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
32429
+ /* 145 */ "DropTrigger" OpHelp(""),
32430
+ /* 146 */ "IntegrityCk" OpHelp(""),
32431
+ /* 147 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
32432
+ /* 148 */ "Real" OpHelp("r[P2]=P4"),
3234632433
/* 149 */ "Param" OpHelp(""),
3234732434
/* 150 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
3234832435
/* 151 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
3234932436
/* 152 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
3235032437
/* 153 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
@@ -33093,17 +33180,18 @@
3309333180
#define osLstat ((int(*)(const char*,struct stat*))aSyscall[27].pCurrent)
3309433181
3309533182
#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
3309633183
# ifdef __ANDROID__
3309733184
{ "ioctl", (sqlite3_syscall_ptr)(int(*)(int, int, ...))ioctl, 0 },
33185
+#define osIoctl ((int(*)(int,int,...))aSyscall[28].pCurrent)
3309833186
# else
3309933187
{ "ioctl", (sqlite3_syscall_ptr)ioctl, 0 },
33188
+#define osIoctl ((int(*)(int,unsigned long,...))aSyscall[28].pCurrent)
3310033189
# endif
3310133190
#else
3310233191
{ "ioctl", (sqlite3_syscall_ptr)0, 0 },
3310333192
#endif
33104
-#define osIoctl ((int(*)(int,int,...))aSyscall[28].pCurrent)
3310533193
3310633194
}; /* End of the overrideable system calls */
3310733195
3310833196
3310933197
/*
@@ -38341,10 +38429,11 @@
3834138429
}
3834238430
if( pInode ){
3834338431
UnixUnusedFd **pp;
3834438432
assert( sqlite3_mutex_notheld(pInode->pLockMutex) );
3834538433
sqlite3_mutex_enter(pInode->pLockMutex);
38434
+ flags &= (SQLITE_OPEN_READONLY|SQLITE_OPEN_READWRITE);
3834638435
for(pp=&pInode->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
3834738436
pUnused = *pp;
3834838437
if( pUnused ){
3834938438
*pp = pUnused->pNext;
3835038439
}
@@ -38644,11 +38733,12 @@
3864438733
*pOutFlags = flags;
3864538734
}
3864638735
3864738736
if( p->pPreallocatedUnused ){
3864838737
p->pPreallocatedUnused->fd = fd;
38649
- p->pPreallocatedUnused->flags = flags;
38738
+ p->pPreallocatedUnused->flags =
38739
+ flags & (SQLITE_OPEN_READONLY|SQLITE_OPEN_READWRITE);
3865038740
}
3865138741
3865238742
if( isDelete ){
3865338743
#if OS_VXWORKS
3865438744
zPath = zName;
@@ -40175,11 +40265,11 @@
4017540265
}
4017640266
default: {
4017740267
assert( 0 ); /* The call assures that only valid opcodes are sent */
4017840268
}
4017940269
}
40180
- /*NOTREACHED*/
40270
+ /*NOTREACHED*/ assert(0);
4018140271
return SQLITE_ERROR;
4018240272
}
4018340273
4018440274
/*
4018540275
** Within this division (the proxying locking implementation) the procedures
@@ -44860,10 +44950,11 @@
4486044950
4486144951
if( !pShm ){
4486244952
rc = winOpenSharedMemory(pDbFd);
4486344953
if( rc!=SQLITE_OK ) return rc;
4486444954
pShm = pDbFd->pShm;
44955
+ assert( pShm!=0 );
4486544956
}
4486644957
pShmNode = pShm->pShmNode;
4486744958
4486844959
sqlite3_mutex_enter(pShmNode->mutex);
4486944960
if( pShmNode->isUnlocked ){
@@ -45162,10 +45253,11 @@
4516245253
osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
4516345254
return rc;
4516445255
}
4516545256
}
4516645257
if( pFd->mmapSize >= iOff+nAmt ){
45258
+ assert( pFd->pMapRegion!=0 );
4516745259
*pp = &((u8 *)pFd->pMapRegion)[iOff];
4516845260
pFd->nFetchOut++;
4516945261
}
4517045262
}
4517145263
#endif
@@ -48083,10 +48175,11 @@
4808348175
if( sqlite3GlobalConfig.pcache2.xInit==0 ){
4808448176
/* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the
4808548177
** built-in default page cache is used instead of the application defined
4808648178
** page cache. */
4808748179
sqlite3PCacheSetDefault();
48180
+ assert( sqlite3GlobalConfig.pcache2.xInit!=0 );
4808848181
}
4808948182
return sqlite3GlobalConfig.pcache2.xInit(sqlite3GlobalConfig.pcache2.pArg);
4809048183
}
4809148184
SQLITE_PRIVATE void sqlite3PcacheShutdown(void){
4809248185
if( sqlite3GlobalConfig.pcache2.xShutdown ){
@@ -49129,10 +49222,11 @@
4912949222
PgHdr1 *p = 0;
4913049223
void *pPg;
4913149224
4913249225
assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
4913349226
if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){
49227
+ assert( pCache->pFree!=0 );
4913449228
p = pCache->pFree;
4913549229
pCache->pFree = p->pNext;
4913649230
p->pNext = 0;
4913749231
}else{
4913849232
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
@@ -61855,10 +61949,11 @@
6185561949
while( iOffset<w.iSyncPoint ){
6185661950
rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);
6185761951
if( rc ) return rc;
6185861952
iOffset += szFrame;
6185961953
nExtra++;
61954
+ assert( pLast!=0 );
6186061955
}
6186161956
}
6186261957
if( bSync ){
6186361958
assert( rc==SQLITE_OK );
6186461959
rc = sqlite3OsSync(w.pFd, WAL_SYNC_FLAGS(sync_flags));
@@ -61887,10 +61982,11 @@
6188761982
for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){
6188861983
if( (p->flags & PGHDR_WAL_APPEND)==0 ) continue;
6188961984
iFrame++;
6189061985
rc = walIndexAppend(pWal, iFrame, p->pgno);
6189161986
}
61987
+ assert( pLast!=0 || nExtra==0 );
6189261988
while( rc==SQLITE_OK && nExtra>0 ){
6189361989
iFrame++;
6189461990
nExtra--;
6189561991
rc = walIndexAppend(pWal, iFrame, pLast->pgno);
6189661992
}
@@ -64898,13 +64994,16 @@
6489864994
testcase( gap+1==top );
6489964995
testcase( gap==top );
6490064996
if( (data[hdr+2] || data[hdr+1]) && gap+2<=top ){
6490164997
u8 *pSpace = pageFindSlot(pPage, nByte, &rc);
6490264998
if( pSpace ){
64903
- assert( pSpace>=data && (pSpace - data)<65536 );
64904
- *pIdx = (int)(pSpace - data);
64905
- return SQLITE_OK;
64999
+ assert( pSpace+nByte<=data+pPage->pBt->usableSize );
65000
+ if( (*pIdx = (int)(pSpace-data))<=gap ){
65001
+ return SQLITE_CORRUPT_PAGE(pPage);
65002
+ }else{
65003
+ return SQLITE_OK;
65004
+ }
6490665005
}else if( rc ){
6490765006
return rc;
6490865007
}
6490965008
}
6491065009
@@ -68127,10 +68226,11 @@
6812768226
u8 aSave[4];
6812868227
u8 *aWrite = &pBuf[-4];
6812968228
assert( aWrite>=pBufStart ); /* due to (6) */
6813068229
memcpy(aSave, aWrite, 4);
6813168230
rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));
68231
+ if( rc && nextPage>pBt->nPage ) rc = SQLITE_CORRUPT_BKPT;
6813268232
nextPage = get4byte(aWrite);
6813368233
memcpy(aWrite, aSave, 4);
6813468234
}else
6813568235
#endif
6813668236
@@ -69915,16 +70015,11 @@
6991570015
assert( MX_CELL(pPage->pBt)<=10921 );
6991670016
assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );
6991770017
assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
6991870018
assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
6991970019
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
69920
- /* The cell should normally be sized correctly. However, when moving a
69921
- ** malformed cell from a leaf page to an interior page, if the cell size
69922
- ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size
69923
- ** might be less than 8 (leaf-size + pointer) on the interior node. Hence
69924
- ** the term after the || in the following assert(). */
69925
- assert( sz==pPage->xCellSize(pPage, pCell) || (sz==8 && iChild>0) );
70020
+ assert( sz==pPage->xCellSize(pPage, pCell) || CORRUPT_DB );
6992670021
assert( pPage->nFree>=0 );
6992770022
if( pPage->nOverflow || sz+2>pPage->nFree ){
6992870023
if( pTemp ){
6992970024
memcpy(pTemp, pCell, sz);
6993070025
pCell = pTemp;
@@ -70152,11 +70247,11 @@
7015270247
int k; /* Current slot in pCArray->apEnd[] */
7015370248
u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */
7015470249
7015570250
assert( i<iEnd );
7015670251
j = get2byte(&aData[hdr+5]);
70157
- if( NEVER(j>(u32)usableSize) ){ j = 0; }
70252
+ if( j>(u32)usableSize ){ j = 0; }
7015870253
memcpy(&pTmp[j], &aData[j], usableSize - j);
7015970254
7016070255
for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
7016170256
pSrcEnd = pCArray->apEnd[k];
7016270257
@@ -70244,11 +70339,12 @@
7024470339
for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
7024570340
pEnd = pCArray->apEnd[k];
7024670341
while( 1 /*Exit by break*/ ){
7024770342
int sz, rc;
7024870343
u8 *pSlot;
70249
- sz = cachedCellSize(pCArray, i);
70344
+ assert( pCArray->szCell[i]!=0 );
70345
+ sz = pCArray->szCell[i];
7025070346
if( (aData[1]==0 && aData[2]==0) || (pSlot = pageFindSlot(pPg,sz,&rc))==0 ){
7025170347
if( (pData - pBegin)<sz ) return 1;
7025270348
pData -= sz;
7025370349
pSlot = pData;
7025470350
}
@@ -70405,10 +70501,11 @@
7040570501
pCellptr = &pPg->aCellIdx[iCell * 2];
7040670502
if( nCell>iCell ){
7040770503
memmove(&pCellptr[2], pCellptr, (nCell - iCell) * 2);
7040870504
}
7040970505
nCell++;
70506
+ cachedCellSize(pCArray, iCell+iNew);
7041070507
if( pageInsertArray(
7041170508
pPg, pBegin, &pData, pCellptr,
7041270509
iCell+iNew, 1, pCArray
7041370510
) ) goto editpage_fail;
7041470511
}
@@ -70927,11 +71024,11 @@
7092771024
** long be able to find the cells if a pointer to each cell is not saved
7092871025
** first.
7092971026
*/
7093071027
memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*(limit+pOld->nOverflow));
7093171028
if( pOld->nOverflow>0 ){
70932
- if( limit<pOld->aiOvfl[0] ){
71029
+ if( NEVER(limit<pOld->aiOvfl[0]) ){
7093371030
rc = SQLITE_CORRUPT_BKPT;
7093471031
goto balance_cleanup;
7093571032
}
7093671033
limit = pOld->aiOvfl[0];
7093771034
for(j=0; j<limit; j++){
@@ -71213,10 +71310,12 @@
7121371310
nNew>=5 ? apNew[4]->pgno : 0, nNew>=5 ? szNew[4] : 0,
7121471311
nNew>=5 ? cntNew[4] - cntNew[3] - !leafData : 0
7121571312
));
7121671313
7121771314
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
71315
+ assert( nNew>=1 && nNew<=ArraySize(apNew) );
71316
+ assert( apNew[nNew-1]!=0 );
7121871317
put4byte(pRight, apNew[nNew-1]->pgno);
7121971318
7122071319
/* If the sibling pages are not leaves, ensure that the right-child pointer
7122171320
** of the right-most new sibling page is set to the value that was
7122271321
** originally in the same field of the right-most old sibling page. */
@@ -71558,15 +71657,17 @@
7155871657
7155971658
VVA_ONLY( int balance_quick_called = 0 );
7156071659
VVA_ONLY( int balance_deeper_called = 0 );
7156171660
7156271661
do {
71563
- int iPage = pCur->iPage;
71662
+ int iPage;
7156471663
MemPage *pPage = pCur->pPage;
7156571664
7156671665
if( NEVER(pPage->nFree<0) && btreeComputeFreeSpace(pPage) ) break;
71567
- if( iPage==0 ){
71666
+ if( pPage->nOverflow==0 && pPage->nFree<=nMin ){
71667
+ break;
71668
+ }else if( (iPage = pCur->iPage)==0 ){
7156871669
if( pPage->nOverflow ){
7156971670
/* The root page of the b-tree is overfull. In this case call the
7157071671
** balance_deeper() function to create a new child for the root-page
7157171672
** and copy the current contents of the root-page to it. The
7157271673
** next iteration of the do-loop will balance the child page.
@@ -71583,12 +71684,10 @@
7158371684
assert( pCur->pPage->nOverflow );
7158471685
}
7158571686
}else{
7158671687
break;
7158771688
}
71588
- }else if( pPage->nOverflow==0 && pPage->nFree<=nMin ){
71589
- break;
7159071689
}else{
7159171690
MemPage * const pParent = pCur->apPage[iPage-1];
7159271691
int const iIdx = pCur->aiIdx[iPage-1];
7159371692
7159471693
rc = sqlite3PagerWrite(pParent->pDbPage);
@@ -71726,11 +71825,13 @@
7172671825
MemPage *pPage = pCur->pPage; /* Page being written */
7172771826
BtShared *pBt; /* Btree */
7172871827
Pgno ovflPgno; /* Next overflow page to write */
7172971828
u32 ovflPageSize; /* Size to write on overflow page */
7173071829
71731
- if( pCur->info.pPayload + pCur->info.nLocal > pPage->aDataEnd ){
71830
+ if( pCur->info.pPayload + pCur->info.nLocal > pPage->aDataEnd
71831
+ || pCur->info.pPayload < pPage->aData + pPage->cellOffset
71832
+ ){
7173271833
return SQLITE_CORRUPT_BKPT;
7173371834
}
7173471835
/* Overwrite the local portion first */
7173571836
rc = btreeOverwriteContent(pPage, pCur->info.pPayload, pX,
7173671837
0, pCur->info.nLocal);
@@ -71967,10 +72068,12 @@
7196772068
oldCell = findCell(pPage, idx);
7196872069
if( !pPage->leaf ){
7196972070
memcpy(newCell, oldCell, 4);
7197072071
}
7197172072
rc = clearCell(pPage, oldCell, &info);
72073
+ testcase( pCur->curFlags & BTCF_ValidOvfl );
72074
+ invalidateOverflowCache(pCur);
7197272075
if( info.nSize==szNew && info.nLocal==info.nPayload
7197372076
&& (!ISAUTOVACUUM || szNew<pPage->minLocal)
7197472077
){
7197572078
/* Overwrite the old cell with the new if they are the same size.
7197672079
** We could also try to do this if the old cell is smaller, then add
@@ -71980,11 +72083,16 @@
7198072083
**
7198172084
** This optimization cannot be used on an autovacuum database if the
7198272085
** new entry uses overflow pages, as the insertCell() call below is
7198372086
** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry. */
7198472087
assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */
71985
- if( oldCell+szNew > pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT;
72088
+ if( oldCell < pPage->aData+pPage->hdrOffset+10 ){
72089
+ return SQLITE_CORRUPT_BKPT;
72090
+ }
72091
+ if( oldCell+szNew > pPage->aDataEnd ){
72092
+ return SQLITE_CORRUPT_BKPT;
72093
+ }
7198672094
memcpy(oldCell, newCell, szNew);
7198772095
return SQLITE_OK;
7198872096
}
7198972097
dropCell(pPage, idx, info.nSize, &rc);
7199072098
if( rc ) goto end_insert;
@@ -74317,12 +74425,14 @@
7431774425
if( p->pDestDb ){
7431874426
p->pSrc->nBackup--;
7431974427
}
7432074428
if( p->isAttached ){
7432174429
pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));
74430
+ assert( pp!=0 );
7432274431
while( *pp!=p ){
7432374432
pp = &(*pp)->pNext;
74433
+ assert( pp!=0 );
7432474434
}
7432574435
*pp = p->pNext;
7432674436
}
7432774437
7432874438
/* If a transaction is still open on the Btree, roll it back. */
@@ -75804,11 +75914,11 @@
7580475914
** already been allocated, allocate the UnpackedRecord structure that
7580575915
** that function will return to its caller here. Then return a pointer to
7580675916
** an sqlite3_value within the UnpackedRecord.a[] array.
7580775917
*/
7580875918
static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){
75809
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
75919
+#ifdef SQLITE_ENABLE_STAT4
7581075920
if( p ){
7581175921
UnpackedRecord *pRec = p->ppRec[0];
7581275922
7581375923
if( pRec==0 ){
7581475924
Index *pIdx = p->pIdx; /* Index being probed */
@@ -75840,11 +75950,11 @@
7584075950
pRec->nField = p->iVal+1;
7584175951
return &pRec->aMem[p->iVal];
7584275952
}
7584375953
#else
7584475954
UNUSED_PARAMETER(p);
75845
-#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
75955
+#endif /* defined(SQLITE_ENABLE_STAT4) */
7584675956
return sqlite3ValueNew(db);
7584775957
}
7584875958
7584975959
/*
7585075960
** The expression object indicated by the second argument is guaranteed
@@ -75864,11 +75974,11 @@
7586475974
**
7586575975
** If the conditions above are not met, this function returns SQLITE_OK
7586675976
** and sets (*ppVal) to NULL. Or, if an error occurs, (*ppVal) is set to
7586775977
** NULL and an SQLite error code returned.
7586875978
*/
75869
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
75979
+#ifdef SQLITE_ENABLE_STAT4
7587075980
static int valueFromFunction(
7587175981
sqlite3 *db, /* The database connection */
7587275982
Expr *p, /* The expression to evaluate */
7587375983
u8 enc, /* Encoding to use */
7587475984
u8 aff, /* Affinity to use */
@@ -75947,11 +76057,11 @@
7594776057
*ppVal = pVal;
7594876058
return rc;
7594976059
}
7595076060
#else
7595176061
# define valueFromFunction(a,b,c,d,e,f) SQLITE_OK
75952
-#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
76062
+#endif /* defined(SQLITE_ENABLE_STAT4) */
7595376063
7595476064
/*
7595576065
** Extract a value from the supplied expression in the manner described
7595676066
** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object
7595776067
** using valueNew().
@@ -75976,11 +76086,11 @@
7597676086
const char *zNeg = "";
7597776087
int rc = SQLITE_OK;
7597876088
7597976089
assert( pExpr!=0 );
7598076090
while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft;
75981
-#if defined(SQLITE_ENABLE_STAT3_OR_STAT4)
76091
+#if defined(SQLITE_ENABLE_STAT4)
7598276092
if( op==TK_REGISTER ) op = pExpr->op2;
7598376093
#else
7598476094
if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
7598576095
#endif
7598676096
@@ -76069,11 +76179,11 @@
7606976179
assert( zVal[nVal]=='\'' );
7607076180
sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
7607176181
0, SQLITE_DYNAMIC);
7607276182
}
7607376183
#endif
76074
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
76184
+#ifdef SQLITE_ENABLE_STAT4
7607576185
else if( op==TK_FUNCTION && pCtx!=0 ){
7607676186
rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
7607776187
}
7607876188
#endif
7607976189
else if( op==TK_TRUEFALSE ){
@@ -76086,17 +76196,17 @@
7608676196
7608776197
*ppVal = pVal;
7608876198
return rc;
7608976199
7609076200
no_mem:
76091
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
76201
+#ifdef SQLITE_ENABLE_STAT4
7609276202
if( pCtx==0 || pCtx->pParse->nErr==0 )
7609376203
#endif
7609476204
sqlite3OomFault(db);
7609576205
sqlite3DbFree(db, zVal);
7609676206
assert( *ppVal==0 );
76097
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
76207
+#ifdef SQLITE_ENABLE_STAT4
7609876208
if( pCtx==0 ) sqlite3ValueFree(pVal);
7609976209
#else
7610076210
assert( pCtx==0 ); sqlite3ValueFree(pVal);
7610176211
#endif
7610276212
return SQLITE_NOMEM_BKPT;
@@ -76120,60 +76230,11 @@
7612076230
sqlite3_value **ppVal /* Write the new value here */
7612176231
){
7612276232
return pExpr ? valueFromExpr(db, pExpr, enc, affinity, ppVal, 0) : 0;
7612376233
}
7612476234
76125
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
76126
-/*
76127
-** The implementation of the sqlite_record() function. This function accepts
76128
-** a single argument of any type. The return value is a formatted database
76129
-** record (a blob) containing the argument value.
76130
-**
76131
-** This is used to convert the value stored in the 'sample' column of the
76132
-** sqlite_stat3 table to the record format SQLite uses internally.
76133
-*/
76134
-static void recordFunc(
76135
- sqlite3_context *context,
76136
- int argc,
76137
- sqlite3_value **argv
76138
-){
76139
- const int file_format = 1;
76140
- u32 iSerial; /* Serial type */
76141
- int nSerial; /* Bytes of space for iSerial as varint */
76142
- u32 nVal; /* Bytes of space required for argv[0] */
76143
- int nRet;
76144
- sqlite3 *db;
76145
- u8 *aRet;
76146
-
76147
- UNUSED_PARAMETER( argc );
76148
- iSerial = sqlite3VdbeSerialType(argv[0], file_format, &nVal);
76149
- nSerial = sqlite3VarintLen(iSerial);
76150
- db = sqlite3_context_db_handle(context);
76151
-
76152
- nRet = 1 + nSerial + nVal;
76153
- aRet = sqlite3DbMallocRawNN(db, nRet);
76154
- if( aRet==0 ){
76155
- sqlite3_result_error_nomem(context);
76156
- }else{
76157
- aRet[0] = nSerial+1;
76158
- putVarint32(&aRet[1], iSerial);
76159
- sqlite3VdbeSerialPut(&aRet[1+nSerial], argv[0], iSerial);
76160
- sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT);
76161
- sqlite3DbFreeNN(db, aRet);
76162
- }
76163
-}
76164
-
76165
-/*
76166
-** Register built-in functions used to help read ANALYZE data.
76167
-*/
76168
-SQLITE_PRIVATE void sqlite3AnalyzeFunctions(void){
76169
- static FuncDef aAnalyzeTableFuncs[] = {
76170
- FUNCTION(sqlite_record, 1, 0, 0, recordFunc),
76171
- };
76172
- sqlite3InsertBuiltinFuncs(aAnalyzeTableFuncs, ArraySize(aAnalyzeTableFuncs));
76173
-}
76174
-
76235
+#ifdef SQLITE_ENABLE_STAT4
7617576236
/*
7617676237
** Attempt to extract a value from pExpr and use it to construct *ppVal.
7617776238
**
7617876239
** If pAlloc is not NULL, then an UnpackedRecord object is created for
7617976240
** pAlloc if one does not exist and the new value is added to the
@@ -77413,20 +77474,20 @@
7741377474
7741477475
/*
7741577476
** Change the value of the opcode, or P1, P2, P3, or P5 operands
7741677477
** for a specific instruction.
7741777478
*/
77418
-SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe *p, u32 addr, u8 iNewOpcode){
77479
+SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe *p, int addr, u8 iNewOpcode){
7741977480
sqlite3VdbeGetOp(p,addr)->opcode = iNewOpcode;
7742077481
}
77421
-SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe *p, u32 addr, int val){
77482
+SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe *p, int addr, int val){
7742277483
sqlite3VdbeGetOp(p,addr)->p1 = val;
7742377484
}
77424
-SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe *p, u32 addr, int val){
77485
+SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe *p, int addr, int val){
7742577486
sqlite3VdbeGetOp(p,addr)->p2 = val;
7742677487
}
77427
-SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe *p, u32 addr, int val){
77488
+SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe *p, int addr, int val){
7742877489
sqlite3VdbeGetOp(p,addr)->p3 = val;
7742977490
}
7743077491
SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe *p, u16 p5){
7743177492
assert( p->nOp>0 || p->db->mallocFailed );
7743277493
if( p->nOp>0 ) p->aOp[p->nOp-1].p5 = p5;
@@ -77929,18 +77990,20 @@
7792977990
sqlite3StrAccumInit(&x, 0, zTemp, nTemp, 0);
7793077991
switch( pOp->p4type ){
7793177992
case P4_KEYINFO: {
7793277993
int j;
7793377994
KeyInfo *pKeyInfo = pOp->p4.pKeyInfo;
77934
- assert( pKeyInfo->aSortOrder!=0 );
77995
+ assert( pKeyInfo->aSortFlags!=0 );
7793577996
sqlite3_str_appendf(&x, "k(%d", pKeyInfo->nKeyField);
7793677997
for(j=0; j<pKeyInfo->nKeyField; j++){
7793777998
CollSeq *pColl = pKeyInfo->aColl[j];
7793877999
const char *zColl = pColl ? pColl->zName : "";
7793978000
if( strcmp(zColl, "BINARY")==0 ) zColl = "B";
77940
- sqlite3_str_appendf(&x, ",%s%s",
77941
- pKeyInfo->aSortOrder[j] ? "-" : "", zColl);
78001
+ sqlite3_str_appendf(&x, ",%s%s%s",
78002
+ (pKeyInfo->aSortFlags[j] & KEYINFO_ORDER_DESC) ? "-" : "",
78003
+ (pKeyInfo->aSortFlags[j] & KEYINFO_ORDER_BIGNULL)? "N." : "",
78004
+ zColl);
7794278005
}
7794378006
sqlite3_str_append(&x, ")", 1);
7794478007
break;
7794578008
}
7794678009
#ifdef SQLITE_ENABLE_CURSOR_HINTS
@@ -78343,12 +78406,15 @@
7834378406
}else{
7834478407
/* We are currently listing subprograms. Figure out which one and
7834578408
** pick up the appropriate opcode. */
7834678409
int j;
7834778410
i -= p->nOp;
78411
+ assert( apSub!=0 );
78412
+ assert( nSub>0 );
7834878413
for(j=0; i>=apSub[j]->nOp; j++){
7834978414
i -= apSub[j]->nOp;
78415
+ assert( i<apSub[j]->nOp || j+1<nSub );
7835078416
}
7835178417
pOp = &apSub[j]->aOp[i];
7835278418
}
7835378419
7835478420
/* When an OP_Program opcode is encounter (the only opcode that has
@@ -79866,14 +79932,21 @@
7986679932
**
7986779933
** The 8 and 9 types were added in 3.3.0, file format 4. Prior versions
7986879934
** of SQLite will not understand those serial types.
7986979935
*/
7987079936
79937
+#if 0 /* Inlined into the OP_MakeRecord opcode */
7987179938
/*
7987279939
** Return the serial-type for the value stored in pMem.
7987379940
**
7987479941
** This routine might convert a large MEM_IntReal value into MEM_Real.
79942
+**
79943
+** 2019-07-11: The primary user of this subroutine was the OP_MakeRecord
79944
+** opcode in the byte-code engine. But by moving this routine in-line, we
79945
+** can omit some redundant tests and make that opcode a lot faster. So
79946
+** this routine is now only used by the STAT3 logic and STAT3 support has
79947
+** ended. The code is kept here for historical reference only.
7987579948
*/
7987679949
SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format, u32 *pLen){
7987779950
int flags = pMem->flags;
7987879951
u32 n;
7987979952
@@ -79930,10 +80003,11 @@
7993080003
n += pMem->u.nZero;
7993180004
}
7993280005
*pLen = n;
7993380006
return ((n*2) + 12 + ((flags&MEM_Str)!=0));
7993480007
}
80008
+#endif /* inlined into OP_MakeRecord */
7993580009
7993680010
/*
7993780011
** The sizes for serial types less than 128
7993880012
*/
7993980013
static const u8 sqlite3SmallTypeSizes[] = {
@@ -80238,11 +80312,11 @@
8023880312
int nByte; /* Number of bytes required for *p */
8023980313
nByte = ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1);
8024080314
p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte);
8024180315
if( !p ) return 0;
8024280316
p->aMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))];
80243
- assert( pKeyInfo->aSortOrder!=0 );
80317
+ assert( pKeyInfo->aSortFlags!=0 );
8024480318
p->pKeyInfo = pKeyInfo;
8024580319
p->nField = pKeyInfo->nKeyField + 1;
8024680320
return p;
8024780321
}
8024880322
@@ -80337,11 +80411,11 @@
8033780411
8033880412
idx1 = getVarint32(aKey1, szHdr1);
8033980413
if( szHdr1>98307 ) return SQLITE_CORRUPT;
8034080414
d1 = szHdr1;
8034180415
assert( pKeyInfo->nAllField>=pPKey2->nField || CORRUPT_DB );
80342
- assert( pKeyInfo->aSortOrder!=0 );
80416
+ assert( pKeyInfo->aSortFlags!=0 );
8034380417
assert( pKeyInfo->nKeyField>0 );
8034480418
assert( idx1<=szHdr1 || CORRUPT_DB );
8034580419
do{
8034680420
u32 serial_type1;
8034780421
@@ -80368,11 +80442,16 @@
8036880442
*/
8036980443
rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
8037080444
pKeyInfo->nAllField>i ? pKeyInfo->aColl[i] : 0);
8037180445
if( rc!=0 ){
8037280446
assert( mem1.szMalloc==0 ); /* See comment below */
80373
- if( pKeyInfo->aSortOrder[i] ){
80447
+ if( (pKeyInfo->aSortFlags[i] & KEYINFO_ORDER_BIGNULL)
80448
+ && ((mem1.flags & MEM_Null) || (pPKey2->aMem[i].flags & MEM_Null))
80449
+ ){
80450
+ rc = -rc;
80451
+ }
80452
+ if( pKeyInfo->aSortFlags[i] & KEYINFO_ORDER_DESC ){
8037480453
rc = -rc; /* Invert the result for DESC sort order. */
8037580454
}
8037680455
goto debugCompareEnd;
8037780456
}
8037880457
i++;
@@ -80744,11 +80823,11 @@
8074480823
}
8074580824
8074680825
VVA_ONLY( mem1.szMalloc = 0; ) /* Only needed by assert() statements */
8074780826
assert( pPKey2->pKeyInfo->nAllField>=pPKey2->nField
8074880827
|| CORRUPT_DB );
80749
- assert( pPKey2->pKeyInfo->aSortOrder!=0 );
80828
+ assert( pPKey2->pKeyInfo->aSortFlags!=0 );
8075080829
assert( pPKey2->pKeyInfo->nKeyField>0 );
8075180830
assert( idx1<=szHdr1 || CORRUPT_DB );
8075280831
do{
8075380832
u32 serial_type;
8075480833
@@ -80867,12 +80946,18 @@
8086780946
serial_type = aKey1[idx1];
8086880947
rc = (serial_type!=0);
8086980948
}
8087080949
8087180950
if( rc!=0 ){
80872
- if( pPKey2->pKeyInfo->aSortOrder[i] ){
80873
- rc = -rc;
80951
+ int sortFlags = pPKey2->pKeyInfo->aSortFlags[i];
80952
+ if( sortFlags ){
80953
+ if( (sortFlags & KEYINFO_ORDER_BIGNULL)==0
80954
+ || ((sortFlags & KEYINFO_ORDER_DESC)
80955
+ !=(serial_type==0 || (pRhs->flags&MEM_Null)))
80956
+ ){
80957
+ rc = -rc;
80958
+ }
8087480959
}
8087580960
assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );
8087680961
assert( mem1.szMalloc==0 ); /* See comment below */
8087780962
return rc;
8087880963
}
@@ -81036,11 +81121,15 @@
8103681121
return 0; /* Corruption */
8103781122
}
8103881123
nCmp = MIN( pPKey2->aMem[0].n, nStr );
8103981124
res = memcmp(&aKey1[szHdr], pPKey2->aMem[0].z, nCmp);
8104081125
81041
- if( res==0 ){
81126
+ if( res>0 ){
81127
+ res = pPKey2->r2;
81128
+ }else if( res<0 ){
81129
+ res = pPKey2->r1;
81130
+ }else{
8104281131
res = nStr - pPKey2->aMem[0].n;
8104381132
if( res==0 ){
8104481133
if( pPKey2->nField>1 ){
8104581134
res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
8104681135
}else{
@@ -81050,14 +81139,10 @@
8105081139
}else if( res>0 ){
8105181140
res = pPKey2->r2;
8105281141
}else{
8105381142
res = pPKey2->r1;
8105481143
}
81055
- }else if( res>0 ){
81056
- res = pPKey2->r2;
81057
- }else{
81058
- res = pPKey2->r1;
8105981144
}
8106081145
}
8106181146
8106281147
assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, res)
8106381148
|| CORRUPT_DB
@@ -81085,11 +81170,14 @@
8108581170
** The easiest way to enforce this limit is to consider only records with
8108681171
** 13 fields or less. If the first field is an integer, the maximum legal
8108781172
** header size is (12*5 + 1 + 1) bytes. */
8108881173
if( p->pKeyInfo->nAllField<=13 ){
8108981174
int flags = p->aMem[0].flags;
81090
- if( p->pKeyInfo->aSortOrder[0] ){
81175
+ if( p->pKeyInfo->aSortFlags[0] ){
81176
+ if( p->pKeyInfo->aSortFlags[0] & KEYINFO_ORDER_BIGNULL ){
81177
+ return sqlite3VdbeRecordCompare;
81178
+ }
8109181179
p->r1 = 1;
8109281180
p->r2 = -1;
8109381181
}else{
8109481182
p->r1 = -1;
8109581183
p->r2 = 1;
@@ -81334,11 +81422,11 @@
8133481422
** throw an error if it is given inputs that would make it non-deterministic.
8133581423
** This routine is invoked by date/time functions that use non-deterministic
8133681424
** features such as 'now'.
8133781425
*/
8133881426
SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){
81339
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
81427
+#ifdef SQLITE_ENABLE_STAT4
8134081428
if( pCtx->pVdbe==0 ) return 1;
8134181429
#endif
8134281430
if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){
8134381431
sqlite3_result_error(pCtx,
8134481432
"non-deterministic function in index expression or CHECK constraint",
@@ -81431,11 +81519,11 @@
8143181519
preupdate.op = op;
8143281520
preupdate.iNewReg = iReg;
8143381521
preupdate.keyinfo.db = db;
8143481522
preupdate.keyinfo.enc = ENC(db);
8143581523
preupdate.keyinfo.nKeyField = pTab->nCol;
81436
- preupdate.keyinfo.aSortOrder = (u8*)&fakeSortOrder;
81524
+ preupdate.keyinfo.aSortFlags = (u8*)&fakeSortOrder;
8143781525
preupdate.iKey1 = iKey1;
8143881526
preupdate.iKey2 = iKey2;
8143981527
preupdate.pTab = pTab;
8144081528
8144181529
db->pPreUpdate = &preupdate;
@@ -82300,11 +82388,11 @@
8230082388
** of the amount of time that elapses between invocations. In other words,
8230182389
** the time returned is always the time of the first call.
8230282390
*/
8230382391
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
8230482392
int rc;
82305
-#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
82393
+#ifndef SQLITE_ENABLE_STAT4
8230682394
sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;
8230782395
assert( p->pVdbe!=0 );
8230882396
#else
8230982397
sqlite3_int64 iTime = 0;
8231082398
sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
@@ -82365,11 +82453,11 @@
8236582453
*/
8236682454
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
8236782455
AuxData *pAuxData;
8236882456
8236982457
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
82370
-#if SQLITE_ENABLE_STAT3_OR_STAT4
82458
+#if SQLITE_ENABLE_STAT4
8237182459
if( pCtx->pVdbe==0 ) return 0;
8237282460
#else
8237382461
assert( pCtx->pVdbe!=0 );
8237482462
#endif
8237582463
for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){
@@ -82399,11 +82487,11 @@
8239982487
){
8240082488
AuxData *pAuxData;
8240182489
Vdbe *pVdbe = pCtx->pVdbe;
8240282490
8240382491
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
82404
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
82492
+#ifdef SQLITE_ENABLE_STAT4
8240582493
if( pVdbe==0 ) goto failed;
8240682494
#else
8240782495
assert( pVdbe!=0 );
8240882496
#endif
8240982497
@@ -84051,10 +84139,11 @@
8405184139
**
8405284140
** SQLITE_AFF_TEXT:
8405384141
** Convert pRec to a text representation.
8405484142
**
8405584143
** SQLITE_AFF_BLOB:
84144
+** SQLITE_AFF_NONE:
8405684145
** No-op. pRec is unchanged.
8405784146
*/
8405884147
static void applyAffinity(
8405984148
Mem *pRec, /* The value to apply affinity to */
8406084149
char affinity, /* The affinity to be applied */
@@ -84192,15 +84281,16 @@
8419284281
c = 's';
8419384282
}
8419484283
*(zCsr++) = c;
8419584284
sqlite3_snprintf(100, zCsr, "%d[", pMem->n);
8419684285
zCsr += sqlite3Strlen30(zCsr);
84197
- for(i=0; i<16 && i<pMem->n; i++){
84286
+ for(i=0; i<25 && i<pMem->n; i++){
8419884287
sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
8419984288
zCsr += sqlite3Strlen30(zCsr);
8420084289
}
84201
- for(i=0; i<16 && i<pMem->n; i++){
84290
+ *zCsr++ = '|';
84291
+ for(i=0; i<25 && i<pMem->n; i++){
8420284292
char z = pMem->z[i];
8420384293
if( z<32 || z>126 ) *zCsr++ = '.';
8420484294
else *zCsr++ = z;
8420584295
}
8420684296
*(zCsr++) = ']';
@@ -84226,11 +84316,11 @@
8422684316
}
8422784317
k = 2;
8422884318
sqlite3_snprintf(100, &zBuf[k], "%d", pMem->n);
8422984319
k += sqlite3Strlen30(&zBuf[k]);
8423084320
zBuf[k++] = '[';
84231
- for(j=0; j<15 && j<pMem->n; j++){
84321
+ for(j=0; j<25 && j<pMem->n; j++){
8423284322
u8 c = pMem->z[j];
8423384323
if( c>=0x20 && c<0x7f ){
8423484324
zBuf[k++] = c;
8423584325
}else{
8423684326
zBuf[k++] = '.';
@@ -85628,10 +85718,11 @@
8562885718
pIn1 = &aMem[pOp->p1];
8562985719
if( pIn1->flags & (MEM_Int|MEM_IntReal) ){
8563085720
testcase( pIn1->flags & MEM_Int );
8563185721
testcase( pIn1->flags & MEM_IntReal );
8563285722
sqlite3VdbeMemRealify(pIn1);
85723
+ REGISTER_TRACE(pOp->p1, pIn1);
8563385724
}
8563485725
break;
8563585726
}
8563685727
#endif
8563785728
@@ -86023,13 +86114,18 @@
8602386114
assert( memIsValid(&aMem[p2+idx]) );
8602486115
REGISTER_TRACE(p1+idx, &aMem[p1+idx]);
8602586116
REGISTER_TRACE(p2+idx, &aMem[p2+idx]);
8602686117
assert( i<pKeyInfo->nKeyField );
8602786118
pColl = pKeyInfo->aColl[i];
86028
- bRev = pKeyInfo->aSortOrder[i];
86119
+ bRev = (pKeyInfo->aSortFlags[i] & KEYINFO_ORDER_DESC);
8602986120
iCompare = sqlite3MemCompare(&aMem[p1+idx], &aMem[p2+idx], pColl);
8603086121
if( iCompare ){
86122
+ if( (pKeyInfo->aSortFlags[i] & KEYINFO_ORDER_BIGNULL)
86123
+ && ((aMem[p1+idx].flags & MEM_Null) || (aMem[p2+idx].flags & MEM_Null))
86124
+ ){
86125
+ iCompare = -iCompare;
86126
+ }
8603186127
if( bRev ) iCompare = -iCompare;
8603286128
break;
8603386129
}
8603486130
}
8603586131
break;
@@ -86316,15 +86412,10 @@
8631686412
**
8631786413
** If the record contains fewer than P2 fields, then extract a NULL. Or,
8631886414
** if the P4 argument is a P4_MEM use the value of the P4 argument as
8631986415
** the result.
8632086416
**
86321
-** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
86322
-** then the cache of the cursor is reset prior to extracting the column.
86323
-** The first OP_Column against a pseudo-table after the value of the content
86324
-** register has changed should have this bit set.
86325
-**
8632686417
** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 then
8632786418
** the result is guaranteed to only be used as the argument of a length()
8632886419
** or typeof() function, respectively. The loading of large blobs can be
8632986420
** skipped for length() and all content loading can be skipped for typeof().
8633086421
*/
@@ -86609,19 +86700,31 @@
8660986700
zAffinity = pOp->p4.z;
8661086701
assert( zAffinity!=0 );
8661186702
assert( pOp->p2>0 );
8661286703
assert( zAffinity[pOp->p2]==0 );
8661386704
pIn1 = &aMem[pOp->p1];
86614
- while( 1 /*edit-by-break*/ ){
86705
+ while( 1 /*exit-by-break*/ ){
8661586706
assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] );
8661686707
assert( memIsValid(pIn1) );
8661786708
applyAffinity(pIn1, zAffinity[0], encoding);
8661886709
if( zAffinity[0]==SQLITE_AFF_REAL && (pIn1->flags & MEM_Int)!=0 ){
86619
- /* When applying REAL affinity, if the result is still MEM_Int,
86620
- ** indicate that REAL is actually desired */
86621
- pIn1->flags |= MEM_IntReal;
86622
- pIn1->flags &= ~MEM_Int;
86710
+ /* When applying REAL affinity, if the result is still an MEM_Int
86711
+ ** that will fit in 6 bytes, then change the type to MEM_IntReal
86712
+ ** so that we keep the high-resolution integer value but know that
86713
+ ** the type really wants to be REAL. */
86714
+ testcase( pIn1->u.i==140737488355328LL );
86715
+ testcase( pIn1->u.i==140737488355327LL );
86716
+ testcase( pIn1->u.i==-140737488355328LL );
86717
+ testcase( pIn1->u.i==-140737488355329LL );
86718
+ if( pIn1->u.i<=140737488355327LL && pIn1->u.i>=-140737488355328LL ){
86719
+ pIn1->flags |= MEM_IntReal;
86720
+ pIn1->flags &= ~MEM_Int;
86721
+ }else{
86722
+ pIn1->u.r = (double)pIn1->u.i;
86723
+ pIn1->flags |= MEM_Real;
86724
+ pIn1->flags &= ~MEM_Int;
86725
+ }
8662386726
}
8662486727
REGISTER_TRACE((int)(pIn1-aMem), pIn1);
8662586728
zAffinity++;
8662686729
if( zAffinity[0]==0 ) break;
8662786730
pIn1++;
@@ -86724,38 +86827,124 @@
8672486827
}
8672586828
}
8672686829
#endif
8672786830
8672886831
/* Loop through the elements that will make up the record to figure
86729
- ** out how much space is required for the new record.
86832
+ ** out how much space is required for the new record. After this loop,
86833
+ ** the Mem.uTemp field of each term should hold the serial-type that will
86834
+ ** be used for that term in the generated record:
86835
+ **
86836
+ ** Mem.uTemp value type
86837
+ ** --------------- ---------------
86838
+ ** 0 NULL
86839
+ ** 1 1-byte signed integer
86840
+ ** 2 2-byte signed integer
86841
+ ** 3 3-byte signed integer
86842
+ ** 4 4-byte signed integer
86843
+ ** 5 6-byte signed integer
86844
+ ** 6 8-byte signed integer
86845
+ ** 7 IEEE float
86846
+ ** 8 Integer constant 0
86847
+ ** 9 Integer constant 1
86848
+ ** 10,11 reserved for expansion
86849
+ ** N>=12 and even BLOB
86850
+ ** N>=13 and odd text
86851
+ **
86852
+ ** The following additional values are computed:
86853
+ ** nHdr Number of bytes needed for the record header
86854
+ ** nData Number of bytes of data space needed for the record
86855
+ ** nZero Zero bytes at the end of the record
8673086856
*/
8673186857
pRec = pLast;
8673286858
do{
8673386859
assert( memIsValid(pRec) );
86734
- serial_type = sqlite3VdbeSerialType(pRec, file_format, &len);
86735
- if( pRec->flags & MEM_Zero ){
86736
- if( serial_type==0 ){
86860
+ if( pRec->flags & MEM_Null ){
86861
+ if( pRec->flags & MEM_Zero ){
8673786862
/* Values with MEM_Null and MEM_Zero are created by xColumn virtual
8673886863
** table methods that never invoke sqlite3_result_xxxxx() while
8673986864
** computing an unchanging column value in an UPDATE statement.
8674086865
** Give such values a special internal-use-only serial-type of 10
8674186866
** so that they can be passed through to xUpdate and have
8674286867
** a true sqlite3_value_nochange(). */
8674386868
assert( pOp->p5==OPFLAG_NOCHNG_MAGIC || CORRUPT_DB );
86744
- serial_type = 10;
86745
- }else if( nData ){
86746
- if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem;
86869
+ pRec->uTemp = 10;
8674786870
}else{
86748
- nZero += pRec->u.nZero;
86749
- len -= pRec->u.nZero;
86750
- }
86751
- }
86752
- nData += len;
86753
- testcase( serial_type==127 );
86754
- testcase( serial_type==128 );
86755
- nHdr += serial_type<=127 ? 1 : sqlite3VarintLen(serial_type);
86756
- pRec->uTemp = serial_type;
86871
+ pRec->uTemp = 0;
86872
+ }
86873
+ nHdr++;
86874
+ }else if( pRec->flags & (MEM_Int|MEM_IntReal) ){
86875
+ /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */
86876
+ i64 i = pRec->u.i;
86877
+ u64 uu;
86878
+ testcase( pRec->flags & MEM_Int );
86879
+ testcase( pRec->flags & MEM_IntReal );
86880
+ if( i<0 ){
86881
+ uu = ~i;
86882
+ }else{
86883
+ uu = i;
86884
+ }
86885
+ nHdr++;
86886
+ testcase( uu==127 ); testcase( uu==128 );
86887
+ testcase( uu==32767 ); testcase( uu==32768 );
86888
+ testcase( uu==8388607 ); testcase( uu==8388608 );
86889
+ testcase( uu==2147483647 ); testcase( uu==2147483648 );
86890
+ testcase( uu==140737488355327LL ); testcase( uu==140737488355328LL );
86891
+ if( uu<=127 ){
86892
+ if( (i&1)==i && file_format>=4 ){
86893
+ pRec->uTemp = 8+(u32)uu;
86894
+ }else{
86895
+ nData++;
86896
+ pRec->uTemp = 1;
86897
+ }
86898
+ }else if( uu<=32767 ){
86899
+ nData += 2;
86900
+ pRec->uTemp = 2;
86901
+ }else if( uu<=8388607 ){
86902
+ nData += 3;
86903
+ pRec->uTemp = 3;
86904
+ }else if( uu<=2147483647 ){
86905
+ nData += 4;
86906
+ pRec->uTemp = 4;
86907
+ }else if( uu<=140737488355327LL ){
86908
+ nData += 6;
86909
+ pRec->uTemp = 5;
86910
+ }else{
86911
+ nData += 8;
86912
+ if( pRec->flags & MEM_IntReal ){
86913
+ /* If the value is IntReal and is going to take up 8 bytes to store
86914
+ ** as an integer, then we might as well make it an 8-byte floating
86915
+ ** point value */
86916
+ pRec->u.r = (double)pRec->u.i;
86917
+ pRec->flags &= ~MEM_IntReal;
86918
+ pRec->flags |= MEM_Real;
86919
+ pRec->uTemp = 7;
86920
+ }else{
86921
+ pRec->uTemp = 6;
86922
+ }
86923
+ }
86924
+ }else if( pRec->flags & MEM_Real ){
86925
+ nHdr++;
86926
+ nData += 8;
86927
+ pRec->uTemp = 7;
86928
+ }else{
86929
+ assert( db->mallocFailed || pRec->flags&(MEM_Str|MEM_Blob) );
86930
+ assert( pRec->n>=0 );
86931
+ len = (u32)pRec->n;
86932
+ serial_type = (len*2) + 12 + ((pRec->flags & MEM_Str)!=0);
86933
+ if( pRec->flags & MEM_Zero ){
86934
+ serial_type += pRec->u.nZero*2;
86935
+ if( nData ){
86936
+ if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem;
86937
+ len += pRec->u.nZero;
86938
+ }else{
86939
+ nZero += pRec->u.nZero;
86940
+ }
86941
+ }
86942
+ nData += len;
86943
+ nHdr += sqlite3VarintLen(serial_type);
86944
+ pRec->uTemp = serial_type;
86945
+ }
8675786946
if( pRec==pData0 ) break;
8675886947
pRec--;
8675986948
}while(1);
8676086949
8676186950
/* EVIDENCE-OF: R-22564-11647 The header begins with a single varint
@@ -87087,11 +87276,11 @@
8708787276
"cannot commit - no transaction is active"));
8708887277
8708987278
rc = SQLITE_ERROR;
8709087279
goto abort_due_to_error;
8709187280
}
87092
- break;
87281
+ /*NOTREACHED*/ assert(0);
8709387282
}
8709487283
8709587284
/* Opcode: Transaction P1 P2 P3 P4 P5
8709687285
**
8709787286
** Begin a transaction on database P1 if a transaction is not already
@@ -87825,30 +88014,34 @@
8782588014
#endif
8782688015
8782788016
pC->deferredMoveto = 0;
8782888017
pC->cacheStatus = CACHE_STALE;
8782988018
if( pC->isTable ){
88019
+ u16 flags3, newType;
8783088020
/* The BTREE_SEEK_EQ flag is only set on index cursors */
8783188021
assert( sqlite3BtreeCursorHasHint(pC->uc.pCursor, BTREE_SEEK_EQ)==0
8783288022
|| CORRUPT_DB );
8783388023
8783488024
/* The input value in P3 might be of any type: integer, real, string,
8783588025
** blob, or NULL. But it needs to be an integer before we can do
8783688026
** the seek, so convert it. */
8783788027
pIn3 = &aMem[pOp->p3];
87838
- if( (pIn3->flags & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Str))==MEM_Str ){
88028
+ flags3 = pIn3->flags;
88029
+ if( (flags3 & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Str))==MEM_Str ){
8783988030
applyNumericAffinity(pIn3, 0);
8784088031
}
87841
- iKey = sqlite3VdbeIntValue(pIn3);
88032
+ iKey = sqlite3VdbeIntValue(pIn3); /* Get the integer key value */
88033
+ newType = pIn3->flags; /* Record the type after applying numeric affinity */
88034
+ pIn3->flags = flags3; /* But convert the type back to its original */
8784288035
8784388036
/* If the P3 value could not be converted into an integer without
8784488037
** loss of information, then special processing is required... */
87845
- if( (pIn3->flags & (MEM_Int|MEM_IntReal))==0 ){
87846
- if( (pIn3->flags & MEM_Real)==0 ){
87847
- if( (pIn3->flags & MEM_Null) || oc>=OP_SeekGE ){
87848
- VdbeBranchTaken(1,2); goto jump_to_p2;
87849
- break;
88038
+ if( (newType & (MEM_Int|MEM_IntReal))==0 ){
88039
+ if( (newType & MEM_Real)==0 ){
88040
+ if( (newType & MEM_Null) || oc>=OP_SeekGE ){
88041
+ VdbeBranchTaken(1,2);
88042
+ goto jump_to_p2;
8785088043
}else{
8785188044
rc = sqlite3BtreeLast(pC->uc.pCursor, &res);
8785288045
if( rc!=SQLITE_OK ) goto abort_due_to_error;
8785388046
goto seek_not_found;
8785488047
}
@@ -89138,15 +89331,16 @@
8913889331
8913989332
/* The Next opcode is only used after SeekGT, SeekGE, Rewind, and Found.
8914089333
** The Prev opcode is only used after SeekLT, SeekLE, and Last. */
8914189334
assert( pOp->opcode!=OP_Next
8914289335
|| pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
89143
- || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
89144
- || pC->seekOp==OP_NullRow|| pC->seekOp==OP_SeekRowid);
89336
+ || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
89337
+ || pC->seekOp==OP_NullRow|| pC->seekOp==OP_SeekRowid
89338
+ || pC->seekOp==OP_IfNoHope);
8914589339
assert( pOp->opcode!=OP_Prev
8914689340
|| pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
89147
- || pC->seekOp==OP_Last
89341
+ || pC->seekOp==OP_Last || pC->seekOp==OP_IfNoHope
8914889342
|| pC->seekOp==OP_NullRow);
8914989343
8915089344
rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
8915189345
next_tail:
8915289346
pC->cacheStatus = CACHE_STALE;
@@ -89661,11 +89855,11 @@
8966189855
initData.db = db;
8966289856
initData.iDb = iDb;
8966389857
initData.pzErrMsg = &p->zErrMsg;
8966489858
initData.mInitFlags = 0;
8966589859
zSql = sqlite3MPrintf(db,
89666
- "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid",
89860
+ "SELECT*FROM\"%w\".%s WHERE %s ORDER BY rowid",
8966789861
db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);
8966889862
if( zSql==0 ){
8966989863
rc = SQLITE_NOMEM_BKPT;
8967089864
}else{
8967189865
assert( db->init.busy==0 );
@@ -91868,15 +92062,16 @@
9186892062
Incrblob *p = (Incrblob *)pBlob;
9186992063
int rc;
9187092064
sqlite3 *db;
9187192065
9187292066
if( p ){
92067
+ sqlite3_stmt *pStmt = p->pStmt;
9187392068
db = p->db;
9187492069
sqlite3_mutex_enter(db->mutex);
91875
- rc = sqlite3_finalize(p->pStmt);
9187692070
sqlite3DbFree(db, p);
9187792071
sqlite3_mutex_leave(db->mutex);
92072
+ rc = sqlite3_finalize(pStmt);
9187892073
}else{
9187992074
rc = SQLITE_OK;
9188092075
}
9188192076
return rc;
9188292077
}
@@ -92852,11 +93047,12 @@
9285293047
res = vdbeSorterCompareTail(
9285393048
pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2
9285493049
);
9285593050
}
9285693051
}else{
92857
- if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){
93052
+ assert( !(pTask->pSorter->pKeyInfo->aSortFlags[0]&KEYINFO_ORDER_BIGNULL) );
93053
+ if( pTask->pSorter->pKeyInfo->aSortFlags[0] ){
9285893054
res = res * -1;
9285993055
}
9286093056
}
9286193057
9286293058
return res;
@@ -92920,11 +93116,12 @@
9292093116
if( pTask->pSorter->pKeyInfo->nKeyField>1 ){
9292193117
res = vdbeSorterCompareTail(
9292293118
pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2
9292393119
);
9292493120
}
92925
- }else if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){
93121
+ }else if( pTask->pSorter->pKeyInfo->aSortFlags[0] ){
93122
+ assert( !(pTask->pSorter->pKeyInfo->aSortFlags[0]&KEYINFO_ORDER_BIGNULL) );
9292693123
res = res * -1;
9292793124
}
9292893125
9292993126
return res;
9293093127
}
@@ -93035,10 +93232,11 @@
9303593232
}
9303693233
}
9303793234
9303893235
if( pKeyInfo->nAllField<13
9303993236
&& (pKeyInfo->aColl[0]==0 || pKeyInfo->aColl[0]==db->pDfltColl)
93237
+ && (pKeyInfo->aSortFlags[0] & KEYINFO_ORDER_BIGNULL)==0
9304093238
){
9304193239
pSorter->typeMask = SORTER_TYPE_INTEGER | SORTER_TYPE_TEXT;
9304293240
}
9304393241
}
9304493242
@@ -93751,17 +93949,20 @@
9375193949
if( i==nWorker ){
9375293950
/* Use the foreground thread for this operation */
9375393951
rc = vdbeSorterListToPMA(&pSorter->aTask[nWorker], &pSorter->list);
9375493952
}else{
9375593953
/* Launch a background thread for this operation */
93756
- u8 *aMem = pTask->list.aMemory;
93757
- void *pCtx = (void*)pTask;
93954
+ u8 *aMem;
93955
+ void *pCtx;
9375893956
93957
+ assert( pTask!=0 );
9375993958
assert( pTask->pThread==0 && pTask->bDone==0 );
9376093959
assert( pTask->list.pList==0 );
9376193960
assert( pTask->list.aMemory==0 || pSorter->list.aMemory!=0 );
9376293961
93962
+ aMem = pTask->list.aMemory;
93963
+ pCtx = (void*)pTask;
9376393964
pSorter->iPrev = (u8)(pTask - pSorter->aTask);
9376493965
pTask->list = pSorter->list;
9376593966
pSorter->list.pList = 0;
9376693967
pSorter->list.szPMA = 0;
9376793968
if( aMem ){
@@ -94881,18 +95082,13 @@
9488195082
u8 *zOut = zBuf;
9488295083
int nRead = iAmt;
9488395084
int iChunkOffset;
9488495085
FileChunk *pChunk;
9488595086
94886
-#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \
94887
- || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
9488895087
if( (iAmt+iOfst)>p->endpoint.iOffset ){
9488995088
return SQLITE_IOERR_SHORT_READ;
9489095089
}
94891
-#endif
94892
-
94893
- assert( (iAmt+iOfst)<=p->endpoint.iOffset );
9489495090
assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 );
9489595091
if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
9489695092
sqlite3_int64 iOff = 0;
9489795093
for(pChunk=p->pFirst;
9489895094
ALWAYS(pChunk) && (iOff+p->nChunkSize)<=iOfst;
@@ -95247,13 +95443,26 @@
9524795443
** as the second argument.
9524895444
*/
9524995445
static int walkWindowList(Walker *pWalker, Window *pList){
9525095446
Window *pWin;
9525195447
for(pWin=pList; pWin; pWin=pWin->pNextWin){
95252
- if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
95253
- if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
95254
- if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
95448
+ int rc;
95449
+ rc = sqlite3WalkExprList(pWalker, pWin->pOrderBy);
95450
+ if( rc ) return WRC_Abort;
95451
+ rc = sqlite3WalkExprList(pWalker, pWin->pPartition);
95452
+ if( rc ) return WRC_Abort;
95453
+ rc = sqlite3WalkExpr(pWalker, pWin->pFilter);
95454
+ if( rc ) return WRC_Abort;
95455
+
95456
+ /* The next two are purely for calls to sqlite3RenameExprUnmap()
95457
+ ** within sqlite3WindowOffsetExpr(). Because of constraints imposed
95458
+ ** by sqlite3WindowOffsetExpr(), they can never fail. The results do
95459
+ ** not matter anyhow. */
95460
+ rc = sqlite3WalkExpr(pWalker, pWin->pStart);
95461
+ if( NEVER(rc) ) return WRC_Abort;
95462
+ rc = sqlite3WalkExpr(pWalker, pWin->pEnd);
95463
+ if( NEVER(rc) ) return WRC_Abort;
9525595464
}
9525695465
return WRC_Continue;
9525795466
}
9525895467
#endif
9525995468
@@ -95285,22 +95494,26 @@
9528595494
if( rc ) return rc & WRC_Abort;
9528695495
if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){
9528795496
if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
9528895497
assert( pExpr->x.pList==0 || pExpr->pRight==0 );
9528995498
if( pExpr->pRight ){
95499
+ assert( !ExprHasProperty(pExpr, EP_WinFunc) );
9529095500
pExpr = pExpr->pRight;
9529195501
continue;
9529295502
}else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
95503
+ assert( !ExprHasProperty(pExpr, EP_WinFunc) );
9529395504
if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
95294
- }else if( pExpr->x.pList ){
95295
- if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
95296
- }
95505
+ }else{
95506
+ if( pExpr->x.pList ){
95507
+ if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
95508
+ }
9529795509
#ifndef SQLITE_OMIT_WINDOWFUNC
95298
- if( ExprHasProperty(pExpr, EP_WinFunc) ){
95299
- if( walkWindowList(pWalker, pExpr->y.pWin) ) return WRC_Abort;
95510
+ if( ExprHasProperty(pExpr, EP_WinFunc) ){
95511
+ if( walkWindowList(pWalker, pExpr->y.pWin) ) return WRC_Abort;
95512
+ }
95513
+#endif
9530095514
}
95301
-#endif
9530295515
}
9530395516
break;
9530495517
}
9530595518
return WRC_Continue;
9530695519
}
@@ -95338,12 +95551,13 @@
9533895551
if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;
9533995552
#if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE)
9534095553
{
9534195554
Parse *pParse = pWalker->pParse;
9534295555
if( pParse && IN_RENAME_OBJECT ){
95556
+ /* The following may return WRC_Abort if there are unresolvable
95557
+ ** symbols (e.g. a table that does not exist) in a window definition. */
9534395558
int rc = walkWindowList(pWalker, p->pWinDefn);
95344
- assert( rc==WRC_Continue );
9534595559
return rc;
9534695560
}
9534795561
}
9534895562
#endif
9534995563
return WRC_Continue;
@@ -95796,11 +96010,11 @@
9579696010
}else
9579796011
#endif /* SQLITE_OMIT_UPSERT */
9579896012
{
9579996013
#ifndef SQLITE_OMIT_TRIGGER
9580096014
if( iCol<0 ){
95801
- pExpr->affinity = SQLITE_AFF_INTEGER;
96015
+ pExpr->affExpr = SQLITE_AFF_INTEGER;
9580296016
}else if( pExpr->iTable==0 ){
9580396017
testcase( iCol==31 );
9580496018
testcase( iCol==32 );
9580596019
pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
9580696020
}else{
@@ -95828,11 +96042,11 @@
9582896042
&& sqlite3IsRowid(zCol)
9582996043
&& VisibleRowid(pMatch->pTab)
9583096044
){
9583196045
cnt = 1;
9583296046
pExpr->iColumn = -1;
95833
- pExpr->affinity = SQLITE_AFF_INTEGER;
96047
+ pExpr->affExpr = SQLITE_AFF_INTEGER;
9583496048
}
9583596049
9583696050
/*
9583796051
** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z
9583896052
** might refer to an result-set alias. This happens, for example, when
@@ -96104,11 +96318,11 @@
9610496318
assert( HasRowid(pItem->pTab) && pItem->pTab->pSelect==0 );
9610596319
pExpr->op = TK_COLUMN;
9610696320
pExpr->y.pTab = pItem->pTab;
9610796321
pExpr->iTable = pItem->iCursor;
9610896322
pExpr->iColumn = -1;
96109
- pExpr->affinity = SQLITE_AFF_INTEGER;
96323
+ pExpr->affExpr = SQLITE_AFF_INTEGER;
9611096324
break;
9611196325
}
9611296326
#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)
9611396327
&& !defined(SQLITE_OMIT_SUBQUERY) */
9611496328
@@ -96164,11 +96378,13 @@
9616496378
int nId; /* Number of characters in function name */
9616596379
const char *zId; /* The function name. */
9616696380
FuncDef *pDef; /* Information about the function */
9616796381
u8 enc = ENC(pParse->db); /* The database encoding */
9616896382
int savedAllowFlags = (pNC->ncFlags & (NC_AllowAgg | NC_AllowWin));
96169
-
96383
+#ifndef SQLITE_OMIT_WINDOWFUNC
96384
+ Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0);
96385
+#endif
9617096386
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
9617196387
zId = pExpr->u.zToken;
9617296388
nId = sqlite3Strlen30(zId);
9617396389
pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);
9617496390
if( pDef==0 ){
@@ -96236,31 +96452,40 @@
9623696452
){
9623796453
/* Internal-use-only functions are disallowed unless the
9623896454
** SQL is being compiled using sqlite3NestedParse() */
9623996455
no_such_func = 1;
9624096456
pDef = 0;
96457
+ }else
96458
+ if( (pDef->funcFlags & SQLITE_FUNC_DIRECT)!=0
96459
+ && ExprHasProperty(pExpr, EP_Indirect)
96460
+ && !IN_RENAME_OBJECT
96461
+ ){
96462
+ /* Functions tagged with SQLITE_DIRECTONLY may not be used
96463
+ ** inside of triggers and views */
96464
+ sqlite3ErrorMsg(pParse, "%s() prohibited in triggers and views",
96465
+ pDef->zName);
9624196466
}
9624296467
}
9624396468
9624496469
if( 0==IN_RENAME_OBJECT ){
9624596470
#ifndef SQLITE_OMIT_WINDOWFUNC
9624696471
assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
9624796472
|| (pDef->xValue==0 && pDef->xInverse==0)
9624896473
|| (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
9624996474
);
96250
- if( pDef && pDef->xValue==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
96475
+ if( pDef && pDef->xValue==0 && pWin ){
9625196476
sqlite3ErrorMsg(pParse,
9625296477
"%.*s() may not be used as a window function", nId, zId
9625396478
);
9625496479
pNC->nErr++;
9625596480
}else if(
9625696481
(is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
96257
- || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pExpr->y.pWin)
96258
- || (is_agg && pExpr->y.pWin && (pNC->ncFlags & NC_AllowWin)==0)
96482
+ || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pWin)
96483
+ || (is_agg && pWin && (pNC->ncFlags & NC_AllowWin)==0)
9625996484
){
9626096485
const char *zType;
96261
- if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->y.pWin ){
96486
+ if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pWin ){
9626296487
zType = "window";
9626396488
}else{
9626496489
zType = "aggregate";
9626596490
}
9626696491
sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
@@ -96284,51 +96509,66 @@
9628496509
}else if( wrong_num_args ){
9628596510
sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
9628696511
nId, zId);
9628796512
pNC->nErr++;
9628896513
}
96514
+#ifndef SQLITE_OMIT_WINDOWFUNC
96515
+ else if( is_agg==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
96516
+ sqlite3ErrorMsg(pParse,
96517
+ "FILTER may not be used with non-aggregate %.*s()",
96518
+ nId, zId
96519
+ );
96520
+ pNC->nErr++;
96521
+ }
96522
+#endif
9628996523
if( is_agg ){
9629096524
/* Window functions may not be arguments of aggregate functions.
9629196525
** Or arguments of other window functions. But aggregate functions
9629296526
** may be arguments for window functions. */
9629396527
#ifndef SQLITE_OMIT_WINDOWFUNC
96294
- pNC->ncFlags &= ~(NC_AllowWin | (!pExpr->y.pWin ? NC_AllowAgg : 0));
96528
+ pNC->ncFlags &= ~(NC_AllowWin | (!pWin ? NC_AllowAgg : 0));
9629596529
#else
9629696530
pNC->ncFlags &= ~NC_AllowAgg;
9629796531
#endif
9629896532
}
9629996533
}
96534
+#ifndef SQLITE_OMIT_WINDOWFUNC
96535
+ else if( ExprHasProperty(pExpr, EP_WinFunc) ){
96536
+ is_agg = 1;
96537
+ }
96538
+#endif
9630096539
sqlite3WalkExprList(pWalker, pList);
9630196540
if( is_agg ){
9630296541
#ifndef SQLITE_OMIT_WINDOWFUNC
96303
- if( pExpr->y.pWin ){
96542
+ if( pWin ){
9630496543
Select *pSel = pNC->pWinSelect;
96544
+ assert( pWin==pExpr->y.pWin );
9630596545
if( IN_RENAME_OBJECT==0 ){
96306
- sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef);
96307
- }
96308
- sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition);
96309
- sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy);
96310
- sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter);
96311
- if( 0==pSel->pWin
96312
- || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin)
96313
- ){
96314
- pExpr->y.pWin->pNextWin = pSel->pWin;
96315
- pSel->pWin = pExpr->y.pWin;
96316
- }
96546
+ sqlite3WindowUpdate(pParse, pSel->pWinDefn, pWin, pDef);
96547
+ }
96548
+ sqlite3WalkExprList(pWalker, pWin->pPartition);
96549
+ sqlite3WalkExprList(pWalker, pWin->pOrderBy);
96550
+ sqlite3WalkExpr(pWalker, pWin->pFilter);
96551
+ sqlite3WindowLink(pSel, pWin);
9631796552
pNC->ncFlags |= NC_HasWin;
9631896553
}else
9631996554
#endif /* SQLITE_OMIT_WINDOWFUNC */
9632096555
{
9632196556
NameContext *pNC2 = pNC;
9632296557
pExpr->op = TK_AGG_FUNCTION;
9632396558
pExpr->op2 = 0;
96559
+#ifndef SQLITE_OMIT_WINDOWFUNC
96560
+ if( ExprHasProperty(pExpr, EP_WinFunc) ){
96561
+ sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter);
96562
+ }
96563
+#endif
9632496564
while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){
9632596565
pExpr->op2++;
9632696566
pNC2 = pNC2->pNext;
9632796567
}
96328
- assert( pDef!=0 );
96329
- if( pNC2 ){
96568
+ assert( pDef!=0 || IN_RENAME_OBJECT );
96569
+ if( pNC2 && pDef ){
9633096570
assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
9633196571
testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
9633296572
pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
9633396573
9633496574
}
@@ -96362,11 +96602,11 @@
9636296602
notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
9636396603
break;
9636496604
}
9636596605
case TK_IS:
9636696606
case TK_ISNOT: {
96367
- Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);
96607
+ Expr *pRight = sqlite3ExprSkipCollateAndLikely(pExpr->pRight);
9636896608
assert( !ExprHasProperty(pExpr, EP_Reduced) );
9636996609
/* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE",
9637096610
** and "x IS NOT FALSE". */
9637196611
if( pRight->op==TK_ID ){
9637296612
int rc = resolveExprStep(pWalker, pRight);
@@ -96573,11 +96813,11 @@
9657396813
assert( pEList!=0 );
9657496814
for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
9657596815
int iCol = -1;
9657696816
Expr *pE, *pDup;
9657796817
if( pItem->done ) continue;
96578
- pE = sqlite3ExprSkipCollate(pItem->pExpr);
96818
+ pE = sqlite3ExprSkipCollateAndLikely(pItem->pExpr);
9657996819
if( sqlite3ExprIsInteger(pE, &iCol) ){
9658096820
if( iCol<=0 || iCol>pEList->nExpr ){
9658196821
resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr);
9658296822
return 1;
9658396823
}
@@ -96667,11 +96907,11 @@
9666796907
int i;
9666896908
sqlite3 *db = pParse->db;
9666996909
ExprList *pEList;
9667096910
struct ExprList_item *pItem;
9667196911
96672
- if( pOrderBy==0 || pParse->db->mallocFailed ) return 0;
96912
+ if( pOrderBy==0 || pParse->db->mallocFailed || IN_RENAME_OBJECT ) return 0;
9667396913
if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){
9667496914
sqlite3ErrorMsg(pParse, "too many terms in %s BY clause", zType);
9667596915
return 1;
9667696916
}
9667796917
pEList = pSelect->pEList;
@@ -96689,39 +96929,37 @@
9668996929
return 0;
9669096930
}
9669196931
9669296932
#ifndef SQLITE_OMIT_WINDOWFUNC
9669396933
/*
96694
-** Walker callback for resolveRemoveWindows().
96934
+** Walker callback for windowRemoveExprFromSelect().
9669596935
*/
9669696936
static int resolveRemoveWindowsCb(Walker *pWalker, Expr *pExpr){
96937
+ UNUSED_PARAMETER(pWalker);
9669796938
if( ExprHasProperty(pExpr, EP_WinFunc) ){
96698
- Window **pp;
96699
- for(pp=&pWalker->u.pSelect->pWin; *pp; pp=&(*pp)->pNextWin){
96700
- if( *pp==pExpr->y.pWin ){
96701
- *pp = (*pp)->pNextWin;
96702
- break;
96703
- }
96704
- }
96939
+ Window *pWin = pExpr->y.pWin;
96940
+ sqlite3WindowUnlinkFromSelect(pWin);
9670596941
}
9670696942
return WRC_Continue;
9670796943
}
9670896944
9670996945
/*
9671096946
** Remove any Window objects owned by the expression pExpr from the
9671196947
** Select.pWin list of Select object pSelect.
9671296948
*/
96713
-static void resolveRemoveWindows(Select *pSelect, Expr *pExpr){
96714
- Walker sWalker;
96715
- memset(&sWalker, 0, sizeof(Walker));
96716
- sWalker.xExprCallback = resolveRemoveWindowsCb;
96717
- sWalker.u.pSelect = pSelect;
96718
- sqlite3WalkExpr(&sWalker, pExpr);
96949
+static void windowRemoveExprFromSelect(Select *pSelect, Expr *pExpr){
96950
+ if( pSelect->pWin ){
96951
+ Walker sWalker;
96952
+ memset(&sWalker, 0, sizeof(Walker));
96953
+ sWalker.xExprCallback = resolveRemoveWindowsCb;
96954
+ sWalker.u.pSelect = pSelect;
96955
+ sqlite3WalkExpr(&sWalker, pExpr);
96956
+ }
9671996957
}
9672096958
#else
96721
-# define resolveRemoveWindows(x,y)
96722
-#endif
96959
+# define windowRemoveExprFromSelect(a, b)
96960
+#endif /* SQLITE_OMIT_WINDOWFUNC */
9672396961
9672496962
/*
9672596963
** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.
9672696964
** The Name context of the SELECT statement is pNC. zType is either
9672796965
** "ORDER" or "GROUP" depending on which type of clause pOrderBy is.
@@ -96754,11 +96992,11 @@
9675496992
if( pOrderBy==0 ) return 0;
9675596993
nResult = pSelect->pEList->nExpr;
9675696994
pParse = pNC->pParse;
9675796995
for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
9675896996
Expr *pE = pItem->pExpr;
96759
- Expr *pE2 = sqlite3ExprSkipCollate(pE);
96997
+ Expr *pE2 = sqlite3ExprSkipCollateAndLikely(pE);
9676096998
if( zType[0]!='G' ){
9676196999
iCol = resolveAsName(pParse, pSelect->pEList, pE2);
9676297000
if( iCol>0 ){
9676397001
/* If an AS-name match is found, mark this ORDER BY column as being
9676497002
** a copy of the iCol-th result-set column. The subsequent call to
@@ -96788,11 +97026,11 @@
9678897026
for(j=0; j<pSelect->pEList->nExpr; j++){
9678997027
if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
9679097028
/* Since this expresion is being changed into a reference
9679197029
** to an identical expression in the result set, remove all Window
9679297030
** objects belonging to the expression from the Select.pWin list. */
96793
- resolveRemoveWindows(pSelect, pE);
97031
+ windowRemoveExprFromSelect(pSelect, pE);
9679497032
pItem->u.x.iOrderByCol = j+1;
9679597033
}
9679697034
}
9679797035
}
9679897036
return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -97256,11 +97494,10 @@
9725697494
** SELECT a AS b FROM t1 WHERE b;
9725797495
** SELECT * FROM t1 WHERE (select a from t1);
9725897496
*/
9725997497
SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){
9726097498
int op;
97261
- if( pExpr->flags & EP_Generic ) return 0;
9726297499
while( ExprHasProperty(pExpr, EP_Skip) ){
9726397500
assert( pExpr->op==TK_COLLATE );
9726497501
pExpr = pExpr->pLeft;
9726597502
assert( pExpr!=0 );
9726697503
}
@@ -97283,11 +97520,11 @@
9728397520
assert( pExpr->pLeft->flags&EP_xIsSelect );
9728497521
return sqlite3ExprAffinity(
9728597522
pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
9728697523
);
9728797524
}
97288
- return pExpr->affinity;
97525
+ return pExpr->affExpr;
9728997526
}
9729097527
9729197528
/*
9729297529
** Set the collating sequence for expression pExpr to be the collating
9729397530
** sequence named by pToken. Return a pointer to a new Expr node that
@@ -97318,14 +97555,26 @@
9731897555
sqlite3TokenInit(&s, (char*)zC);
9731997556
return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0);
9732097557
}
9732197558
9732297559
/*
97323
-** Skip over any TK_COLLATE operators and any unlikely()
97324
-** or likelihood() function at the root of an expression.
97560
+** Skip over any TK_COLLATE operators.
9732597561
*/
9732697562
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){
97563
+ while( pExpr && ExprHasProperty(pExpr, EP_Skip) ){
97564
+ assert( pExpr->op==TK_COLLATE );
97565
+ pExpr = pExpr->pLeft;
97566
+ }
97567
+ return pExpr;
97568
+}
97569
+
97570
+/*
97571
+** Skip over any TK_COLLATE operators and/or any unlikely()
97572
+** or likelihood() or likely() functions at the root of an
97573
+** expression.
97574
+*/
97575
+SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr *pExpr){
9732797576
while( pExpr && ExprHasProperty(pExpr, EP_Skip|EP_Unlikely) ){
9732897577
if( ExprHasProperty(pExpr, EP_Unlikely) ){
9732997578
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
9733097579
assert( pExpr->x.pList->nExpr>0 );
9733197580
assert( pExpr->op==TK_FUNCTION );
@@ -97356,11 +97605,10 @@
9735697605
sqlite3 *db = pParse->db;
9735797606
CollSeq *pColl = 0;
9735897607
Expr *p = pExpr;
9735997608
while( p ){
9736097609
int op = p->op;
97361
- if( p->flags & EP_Generic ) break;
9736297610
if( op==TK_REGISTER ) op = p->op2;
9736397611
if( (op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_TRIGGER)
9736497612
&& p->y.pTab!=0
9736597613
){
9736697614
/* op==TK_REGISTER && p->y.pTab!=0 happens when pExpr was originally
@@ -97442,28 +97690,23 @@
9744297690
** type affinity of the other operand. This routine returns the
9744397691
** type affinity that should be used for the comparison operator.
9744497692
*/
9744597693
SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2){
9744697694
char aff1 = sqlite3ExprAffinity(pExpr);
97447
- if( aff1 && aff2 ){
97695
+ if( aff1>SQLITE_AFF_NONE && aff2>SQLITE_AFF_NONE ){
9744897696
/* Both sides of the comparison are columns. If one has numeric
9744997697
** affinity, use that. Otherwise use no affinity.
9745097698
*/
9745197699
if( sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2) ){
9745297700
return SQLITE_AFF_NUMERIC;
9745397701
}else{
9745497702
return SQLITE_AFF_BLOB;
9745597703
}
97456
- }else if( !aff1 && !aff2 ){
97457
- /* Neither side of the comparison is a column. Compare the
97458
- ** results directly.
97459
- */
97460
- return SQLITE_AFF_BLOB;
9746197704
}else{
9746297705
/* One side is a column, the other is not. Use the columns affinity. */
97463
- assert( aff1==0 || aff2==0 );
97464
- return (aff1 + aff2);
97706
+ assert( aff1<=SQLITE_AFF_NONE || aff2<=SQLITE_AFF_NONE );
97707
+ return (aff1<=SQLITE_AFF_NONE ? aff2 : aff1) | SQLITE_AFF_NONE;
9746597708
}
9746697709
}
9746797710
9746897711
/*
9746997712
** pExpr is a comparison operator. Return the type affinity that should
@@ -97492,18 +97735,17 @@
9749297735
** if the index with affinity idx_affinity may be used to implement
9749397736
** the comparison in pExpr.
9749497737
*/
9749597738
SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){
9749697739
char aff = comparisonAffinity(pExpr);
97497
- switch( aff ){
97498
- case SQLITE_AFF_BLOB:
97499
- return 1;
97500
- case SQLITE_AFF_TEXT:
97501
- return idx_affinity==SQLITE_AFF_TEXT;
97502
- default:
97503
- return sqlite3IsNumericAffinity(idx_affinity);
97504
- }
97740
+ if( aff<SQLITE_AFF_TEXT ){
97741
+ return 1;
97742
+ }
97743
+ if( aff==SQLITE_AFF_TEXT ){
97744
+ return idx_affinity==SQLITE_AFF_TEXT;
97745
+ }
97746
+ return sqlite3IsNumericAffinity(idx_affinity);
9750597747
}
9750697748
9750797749
/*
9750897750
** Return the P5 value that should be used for a binary comparison
9750997751
** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2.
@@ -98252,19 +98494,22 @@
9825298494
if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){
9825398495
/* The Expr.x union is never used at the same time as Expr.pRight */
9825498496
assert( p->x.pList==0 || p->pRight==0 );
9825598497
if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);
9825698498
if( p->pRight ){
98499
+ assert( !ExprHasProperty(p, EP_WinFunc) );
9825798500
sqlite3ExprDeleteNN(db, p->pRight);
9825898501
}else if( ExprHasProperty(p, EP_xIsSelect) ){
98502
+ assert( !ExprHasProperty(p, EP_WinFunc) );
9825998503
sqlite3SelectDelete(db, p->x.pSelect);
9826098504
}else{
9826198505
sqlite3ExprListDelete(db, p->x.pList);
98262
- }
98263
- if( ExprHasProperty(p, EP_WinFunc) ){
98264
- assert( p->op==TK_FUNCTION );
98265
- sqlite3WindowDelete(db, p->y.pWin);
98506
+#ifndef SQLITE_OMIT_WINDOWFUNC
98507
+ if( ExprHasProperty(p, EP_WinFunc) ){
98508
+ sqlite3WindowDelete(db, p->y.pWin);
98509
+ }
98510
+#endif
9826698511
}
9826798512
}
9826898513
if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
9826998514
if( !ExprHasProperty(p, EP_Static) ){
9827098515
sqlite3DbFreeNN(db, p);
@@ -98295,20 +98540,10 @@
9829598540
if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE;
9829698541
if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE;
9829798542
return EXPR_FULLSIZE;
9829898543
}
9829998544
98300
-/*
98301
-** Copy the complete content of an Expr node, taking care not to read
98302
-** past the end of the structure for a reduced-size version of the source
98303
-** Expr.
98304
-*/
98305
-static void exprNodeCopy(Expr *pDest, Expr *pSrc){
98306
- memset(pDest, 0, sizeof(Expr));
98307
- memcpy(pDest, pSrc, exprStructSize(pSrc));
98308
-}
98309
-
9831098545
/*
9831198546
** The dupedExpr*Size() routines each return the number of bytes required
9831298547
** to store a copy of an expression or expression tree. They differ in
9831398548
** how much of the tree is measured.
9831498549
**
@@ -98544,14 +98779,17 @@
9854498779
** gatherSelectWindowsCallback() are used to scan all the expressions
9854598780
** an a newly duplicated SELECT statement and gather all of the Window
9854698781
** objects found there, assembling them onto the linked list at Select->pWin.
9854798782
*/
9854898783
static int gatherSelectWindowsCallback(Walker *pWalker, Expr *pExpr){
98549
- if( pExpr->op==TK_FUNCTION && pExpr->y.pWin!=0 ){
98550
- assert( ExprHasProperty(pExpr, EP_WinFunc) );
98551
- pExpr->y.pWin->pNextWin = pWalker->u.pSelect->pWin;
98552
- pWalker->u.pSelect->pWin = pExpr->y.pWin;
98784
+ if( pExpr->op==TK_FUNCTION && ExprHasProperty(pExpr, EP_WinFunc) ){
98785
+ Select *pSelect = pWalker->u.pSelect;
98786
+ Window *pWin = pExpr->y.pWin;
98787
+ assert( pWin );
98788
+ assert( IsWindowFunc(pExpr) );
98789
+ assert( pWin->ppThis==0 );
98790
+ sqlite3WindowLink(pSelect, pWin);
9855398791
}
9855498792
return WRC_Continue;
9855598793
}
9855698794
static int gatherSelectWindowsSelectCallback(Walker *pWalker, Select *p){
9855798795
return p==pWalker->u.pSelect ? WRC_Continue : WRC_Prune;
@@ -98621,12 +98859,13 @@
9862198859
pNewExpr->pLeft = pPriorSelectCol;
9862298860
}
9862398861
}
9862498862
pItem->zName = sqlite3DbStrDup(db, pOldItem->zName);
9862598863
pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan);
98626
- pItem->sortOrder = pOldItem->sortOrder;
98864
+ pItem->sortFlags = pOldItem->sortFlags;
9862798865
pItem->done = 0;
98866
+ pItem->bNulls = pOldItem->bNulls;
9862898867
pItem->bSpanIsTab = pOldItem->bSpanIsTab;
9862998868
pItem->bSorterRef = pOldItem->bSorterRef;
9863098869
pItem->u = pOldItem->u;
9863198870
}
9863298871
return pNew;
@@ -98733,11 +98972,11 @@
9873398972
pNew->nSelectRow = p->nSelectRow;
9873498973
pNew->pWith = withDup(db, p->pWith);
9873598974
#ifndef SQLITE_OMIT_WINDOWFUNC
9873698975
pNew->pWin = 0;
9873798976
pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
98738
- if( p->pWin ) gatherSelectWindows(pNew);
98977
+ if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew);
9873998978
#endif
9874098979
pNew->selId = p->selId;
9874198980
*pp = pNew;
9874298981
pp = &pNew->pPrior;
9874398982
pNext = pNew;
@@ -98842,10 +99081,14 @@
9884299081
goto vector_append_error;
9884399082
}
9884499083
9884599084
for(i=0; i<pColumns->nId; i++){
9884699085
Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);
99086
+ assert( pSubExpr!=0 || db->mallocFailed );
99087
+ assert( pSubExpr==0 || pSubExpr->iTable==0 );
99088
+ if( pSubExpr==0 ) continue;
99089
+ pSubExpr->iTable = pColumns->nId;
9884799090
pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);
9884899091
if( pList ){
9884999092
assert( pList->nExpr==iFirst+i+1 );
9885099093
pList->a[pList->nExpr-1].zName = pColumns->a[i].zName;
9885199094
pColumns->a[i].zName = 0;
@@ -98874,19 +99117,38 @@
9887499117
}
9887599118
9887699119
/*
9887799120
** Set the sort order for the last element on the given ExprList.
9887899121
*/
98879
-SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder){
99122
+SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder, int eNulls){
99123
+ struct ExprList_item *pItem;
9888099124
if( p==0 ) return;
98881
- assert( SQLITE_SO_UNDEFINED<0 && SQLITE_SO_ASC>=0 && SQLITE_SO_DESC>0 );
9888299125
assert( p->nExpr>0 );
98883
- if( iSortOrder<0 ){
98884
- assert( p->a[p->nExpr-1].sortOrder==SQLITE_SO_ASC );
98885
- return;
99126
+
99127
+ assert( SQLITE_SO_UNDEFINED<0 && SQLITE_SO_ASC==0 && SQLITE_SO_DESC>0 );
99128
+ assert( iSortOrder==SQLITE_SO_UNDEFINED
99129
+ || iSortOrder==SQLITE_SO_ASC
99130
+ || iSortOrder==SQLITE_SO_DESC
99131
+ );
99132
+ assert( eNulls==SQLITE_SO_UNDEFINED
99133
+ || eNulls==SQLITE_SO_ASC
99134
+ || eNulls==SQLITE_SO_DESC
99135
+ );
99136
+
99137
+ pItem = &p->a[p->nExpr-1];
99138
+ assert( pItem->bNulls==0 );
99139
+ if( iSortOrder==SQLITE_SO_UNDEFINED ){
99140
+ iSortOrder = SQLITE_SO_ASC;
9888699141
}
98887
- p->a[p->nExpr-1].sortOrder = (u8)iSortOrder;
99142
+ pItem->sortFlags = (u8)iSortOrder;
99143
+
99144
+ if( eNulls!=SQLITE_SO_UNDEFINED ){
99145
+ pItem->bNulls = 1;
99146
+ if( iSortOrder!=eNulls ){
99147
+ pItem->sortFlags |= KEYINFO_ORDER_BIGNULL;
99148
+ }
99149
+ }
9888899150
}
9888999151
9889099152
/*
9889199153
** Set the ExprList.a[].zName element of the most recently added item
9889299154
** on the expression list.
@@ -99381,31 +99643,34 @@
9938199643
** is harmless. A false positive, however, can result in the wrong
9938299644
** answer.
9938399645
*/
9938499646
SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr *p, char aff){
9938599647
u8 op;
99648
+ int unaryMinus = 0;
9938699649
if( aff==SQLITE_AFF_BLOB ) return 1;
99387
- while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }
99650
+ while( p->op==TK_UPLUS || p->op==TK_UMINUS ){
99651
+ if( p->op==TK_UMINUS ) unaryMinus = 1;
99652
+ p = p->pLeft;
99653
+ }
9938899654
op = p->op;
9938999655
if( op==TK_REGISTER ) op = p->op2;
9939099656
switch( op ){
9939199657
case TK_INTEGER: {
99392
- return aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC;
99658
+ return aff>=SQLITE_AFF_NUMERIC;
9939399659
}
9939499660
case TK_FLOAT: {
99395
- return aff==SQLITE_AFF_REAL || aff==SQLITE_AFF_NUMERIC;
99661
+ return aff>=SQLITE_AFF_NUMERIC;
9939699662
}
9939799663
case TK_STRING: {
99398
- return aff==SQLITE_AFF_TEXT;
99664
+ return !unaryMinus && aff==SQLITE_AFF_TEXT;
9939999665
}
9940099666
case TK_BLOB: {
99401
- return 1;
99667
+ return !unaryMinus;
9940299668
}
9940399669
case TK_COLUMN: {
9940499670
assert( p->iTable>=0 ); /* p cannot be part of a CHECK constraint */
99405
- return p->iColumn<0
99406
- && (aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC);
99671
+ return aff>=SQLITE_AFF_NUMERIC && p->iColumn<0;
9940799672
}
9940899673
default: {
9940999674
return 0;
9941099675
}
9941199676
}
@@ -99584,11 +99849,11 @@
9958499849
** then aiMap[] is populated with {2, 0, 1}.
9958599850
*/
9958699851
#ifndef SQLITE_OMIT_SUBQUERY
9958799852
SQLITE_PRIVATE int sqlite3FindInIndex(
9958899853
Parse *pParse, /* Parsing context */
99589
- Expr *pX, /* The right-hand side (RHS) of the IN operator */
99854
+ Expr *pX, /* The IN expression */
9959099855
u32 inFlags, /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */
9959199856
int *prRhsHasNull, /* Register holding NULL status. See notes */
9959299857
int *aiMap, /* Mapping from Index fields to RHS fields */
9959399858
int *piTab /* OUT: index to use */
9959499859
){
@@ -100009,13 +100274,13 @@
100009100274
*/
100010100275
char affinity; /* Affinity of the LHS of the IN */
100011100276
int i;
100012100277
ExprList *pList = pExpr->x.pList;
100013100278
struct ExprList_item *pItem;
100014
- int r1, r2, r3;
100279
+ int r1, r2;
100015100280
affinity = sqlite3ExprAffinity(pLeft);
100016
- if( !affinity ){
100281
+ if( affinity<=SQLITE_AFF_NONE ){
100017100282
affinity = SQLITE_AFF_BLOB;
100018100283
}
100019100284
if( pKeyInfo ){
100020100285
assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
100021100286
pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
@@ -100037,13 +100302,13 @@
100037100302
ExprClearProperty(pExpr, EP_Subrtn);
100038100303
addrOnce = 0;
100039100304
}
100040100305
100041100306
/* Evaluate the expression and insert it into the temp table */
100042
- r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);
100043
- sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);
100044
- sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r3, 1);
100307
+ sqlite3ExprCode(pParse, pE2, r1);
100308
+ sqlite3VdbeAddOp4(v, OP_MakeRecord, r1, 1, r2, &affinity, 1);
100309
+ sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r1, 1);
100045100310
}
100046100311
sqlite3ReleaseTempReg(pParse, r1);
100047100312
sqlite3ReleaseTempReg(pParse, r2);
100048100313
}
100049100314
if( pKeyInfo ){
@@ -100065,11 +100330,11 @@
100065100330
** (SELECT a FROM b) -- subquery
100066100331
** EXISTS (SELECT a FROM b) -- EXISTS subquery
100067100332
**
100068100333
** The pExpr parameter is the SELECT or EXISTS operator to be coded.
100069100334
**
100070
-** The register that holds the result. For a multi-column SELECT,
100335
+** Return the register that holds the result. For a multi-column SELECT,
100071100336
** the result is stored in a contiguous array of registers and the
100072100337
** return value is the register of the left-most result column.
100073100338
** Return 0 if an error occurs.
100074100339
*/
100075100340
#ifndef SQLITE_OMIT_SUBQUERY
@@ -100309,17 +100574,25 @@
100309100574
CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
100310100575
int labelOk = sqlite3VdbeMakeLabel(pParse);
100311100576
int r2, regToFree;
100312100577
int regCkNull = 0;
100313100578
int ii;
100579
+ int bLhsReal; /* True if the LHS of the IN has REAL affinity */
100314100580
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
100315100581
if( destIfNull!=destIfFalse ){
100316100582
regCkNull = sqlite3GetTempReg(pParse);
100317100583
sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull);
100318100584
}
100585
+ bLhsReal = sqlite3ExprAffinity(pExpr->pLeft)==SQLITE_AFF_REAL;
100319100586
for(ii=0; ii<pList->nExpr; ii++){
100320
- r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);
100587
+ if( bLhsReal ){
100588
+ r2 = regToFree = sqlite3GetTempReg(pParse);
100589
+ sqlite3ExprCode(pParse, pList->a[ii].pExpr, r2);
100590
+ sqlite3VdbeAddOp4(v, OP_Affinity, r2, 1, 0, "E", P4_STATIC);
100591
+ }else{
100592
+ r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);
100593
+ }
100321100594
if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
100322100595
sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);
100323100596
}
100324100597
if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){
100325100598
sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2,
@@ -100600,11 +100873,11 @@
100600100873
** Convert a scalar expression node to a TK_REGISTER referencing
100601100874
** register iReg. The caller must ensure that iReg already contains
100602100875
** the correct value for the expression.
100603100876
*/
100604100877
static void exprToRegister(Expr *pExpr, int iReg){
100605
- Expr *p = sqlite3ExprSkipCollate(pExpr);
100878
+ Expr *p = sqlite3ExprSkipCollateAndLikely(pExpr);
100606100879
p->op2 = p->op;
100607100880
p->op = TK_REGISTER;
100608100881
p->iTable = iReg;
100609100882
ExprClearProperty(p, EP_Skip);
100610100883
}
@@ -100701,11 +100974,11 @@
100701100974
** datatype by applying the Affinity of the table column to the
100702100975
** constant.
100703100976
*/
100704100977
int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
100705100978
int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
100706
- if( aff!=SQLITE_AFF_BLOB ){
100979
+ if( aff>SQLITE_AFF_BLOB ){
100707100980
static const char zAff[] = "B\000C\000D\000E";
100708100981
assert( SQLITE_AFF_BLOB=='A' );
100709100982
assert( SQLITE_AFF_TEXT=='B' );
100710100983
if( iReg!=target ){
100711100984
sqlite3VdbeAddOp2(v, OP_SCopy, iReg, target);
@@ -100717,11 +100990,23 @@
100717100990
return iReg;
100718100991
}
100719100992
if( iTab<0 ){
100720100993
if( pParse->iSelfTab<0 ){
100721100994
/* Generating CHECK constraints or inserting into partial index */
100722
- return pExpr->iColumn - pParse->iSelfTab;
100995
+ assert( pExpr->y.pTab!=0 );
100996
+ assert( pExpr->iColumn>=XN_ROWID );
100997
+ assert( pExpr->iColumn<pExpr->y.pTab->nCol );
100998
+ if( pExpr->iColumn>=0
100999
+ && pExpr->y.pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL
101000
+ ){
101001
+ sqlite3VdbeAddOp2(v, OP_SCopy, pExpr->iColumn - pParse->iSelfTab,
101002
+ target);
101003
+ sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
101004
+ return target;
101005
+ }else{
101006
+ return pExpr->iColumn - pParse->iSelfTab;
101007
+ }
100723101008
}else{
100724101009
/* Coding an expression that is part of an index where column names
100725101010
** in the index refer to the table to which the index belongs */
100726101011
iTab = pParse->iSelfTab - 1;
100727101012
}
@@ -101004,11 +101289,11 @@
101004101289
const char *azAff[] = { "blob", "text", "numeric", "integer", "real" };
101005101290
char aff;
101006101291
assert( nFarg==1 );
101007101292
aff = sqlite3ExprAffinity(pFarg->a[0].pExpr);
101008101293
sqlite3VdbeLoadString(v, target,
101009
- aff ? azAff[aff-SQLITE_AFF_BLOB] : "none");
101294
+ (aff<=SQLITE_AFF_NONE) ? "none" : azAff[aff-SQLITE_AFF_BLOB]);
101010101295
return target;
101011101296
}
101012101297
#endif
101013101298
101014101299
for(i=0; i<nFarg; i++){
@@ -101112,12 +101397,12 @@
101112101397
int n;
101113101398
if( pExpr->pLeft->iTable==0 ){
101114101399
pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
101115101400
}
101116101401
assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );
101117
- if( pExpr->iTable
101118
- && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
101402
+ if( pExpr->iTable!=0
101403
+ && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
101119101404
){
101120101405
sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
101121101406
pExpr->iTable, n);
101122101407
}
101123101408
return pExpr->pLeft->iTable + pExpr->iColumn;
@@ -101216,14 +101501,27 @@
101216101501
case TK_VECTOR: {
101217101502
sqlite3ErrorMsg(pParse, "row value misused");
101218101503
break;
101219101504
}
101220101505
101506
+ /* TK_IF_NULL_ROW Expr nodes are inserted ahead of expressions
101507
+ ** that derive from the right-hand table of a LEFT JOIN. The
101508
+ ** Expr.iTable value is the table number for the right-hand table.
101509
+ ** The expression is only evaluated if that table is not currently
101510
+ ** on a LEFT JOIN NULL row.
101511
+ */
101221101512
case TK_IF_NULL_ROW: {
101222101513
int addrINR;
101514
+ u8 okConstFactor = pParse->okConstFactor;
101223101515
addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable);
101516
+ /* Temporarily disable factoring of constant expressions, since
101517
+ ** even though expressions may appear to be constant, they are not
101518
+ ** really constant because they originate from the right-hand side
101519
+ ** of a LEFT JOIN. */
101520
+ pParse->okConstFactor = 0;
101224101521
inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
101522
+ pParse->okConstFactor = okConstFactor;
101225101523
sqlite3VdbeJumpHere(v, addrINR);
101226101524
sqlite3VdbeChangeP3(v, addrINR, inReg);
101227101525
break;
101228101526
}
101229101527
@@ -101256,25 +101554,31 @@
101256101554
ExprList *pEList; /* List of WHEN terms */
101257101555
struct ExprList_item *aListelem; /* Array of WHEN terms */
101258101556
Expr opCompare; /* The X==Ei expression */
101259101557
Expr *pX; /* The X expression */
101260101558
Expr *pTest = 0; /* X==Ei (form A) or just Ei (form B) */
101559
+ Expr *pDel = 0;
101560
+ sqlite3 *db = pParse->db;
101261101561
101262101562
assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
101263101563
assert(pExpr->x.pList->nExpr > 0);
101264101564
pEList = pExpr->x.pList;
101265101565
aListelem = pEList->a;
101266101566
nExpr = pEList->nExpr;
101267101567
endLabel = sqlite3VdbeMakeLabel(pParse);
101268101568
if( (pX = pExpr->pLeft)!=0 ){
101269
- exprNodeCopy(&tempX, pX);
101569
+ pDel = sqlite3ExprDup(db, pX, 0);
101570
+ if( db->mallocFailed ){
101571
+ sqlite3ExprDelete(db, pDel);
101572
+ break;
101573
+ }
101270101574
testcase( pX->op==TK_COLUMN );
101271
- exprToRegister(&tempX, exprCodeVector(pParse, &tempX, &regFree1));
101575
+ exprToRegister(pDel, exprCodeVector(pParse, pDel, &regFree1));
101272101576
testcase( regFree1==0 );
101273101577
memset(&opCompare, 0, sizeof(opCompare));
101274101578
opCompare.op = TK_EQ;
101275
- opCompare.pLeft = &tempX;
101579
+ opCompare.pLeft = pDel;
101276101580
pTest = &opCompare;
101277101581
/* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
101278101582
** The value in regFree1 might get SCopy-ed into the file result.
101279101583
** So make sure that the regFree1 register is not reused for other
101280101584
** purposes and possibly overwritten. */
@@ -101298,36 +101602,37 @@
101298101602
if( (nExpr&1)!=0 ){
101299101603
sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);
101300101604
}else{
101301101605
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
101302101606
}
101607
+ sqlite3ExprDelete(db, pDel);
101303101608
sqlite3VdbeResolveLabel(v, endLabel);
101304101609
break;
101305101610
}
101306101611
#ifndef SQLITE_OMIT_TRIGGER
101307101612
case TK_RAISE: {
101308
- assert( pExpr->affinity==OE_Rollback
101309
- || pExpr->affinity==OE_Abort
101310
- || pExpr->affinity==OE_Fail
101311
- || pExpr->affinity==OE_Ignore
101613
+ assert( pExpr->affExpr==OE_Rollback
101614
+ || pExpr->affExpr==OE_Abort
101615
+ || pExpr->affExpr==OE_Fail
101616
+ || pExpr->affExpr==OE_Ignore
101312101617
);
101313101618
if( !pParse->pTriggerTab ){
101314101619
sqlite3ErrorMsg(pParse,
101315101620
"RAISE() may only be used within a trigger-program");
101316101621
return 0;
101317101622
}
101318
- if( pExpr->affinity==OE_Abort ){
101623
+ if( pExpr->affExpr==OE_Abort ){
101319101624
sqlite3MayAbort(pParse);
101320101625
}
101321101626
assert( !ExprHasProperty(pExpr, EP_IntValue) );
101322
- if( pExpr->affinity==OE_Ignore ){
101627
+ if( pExpr->affExpr==OE_Ignore ){
101323101628
sqlite3VdbeAddOp4(
101324101629
v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);
101325101630
VdbeCoverage(v);
101326101631
}else{
101327101632
sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER,
101328
- pExpr->affinity, pExpr->u.zToken, 0, 0);
101633
+ pExpr->affExpr, pExpr->u.zToken, 0, 0);
101329101634
}
101330101635
101331101636
break;
101332101637
}
101333101638
#endif
@@ -101388,11 +101693,11 @@
101388101693
** code to fill the register in the initialization section of the
101389101694
** VDBE program, in order to factor it out of the evaluation loop.
101390101695
*/
101391101696
SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){
101392101697
int r2;
101393
- pExpr = sqlite3ExprSkipCollate(pExpr);
101698
+ pExpr = sqlite3ExprSkipCollateAndLikely(pExpr);
101394101699
if( ConstFactorOk(pParse)
101395101700
&& pExpr->op!=TK_REGISTER
101396101701
&& sqlite3ExprIsConstantNotJoin(pExpr)
101397101702
){
101398101703
*pReg = 0;
@@ -101579,44 +101884,48 @@
101579101884
Expr *pExpr, /* The BETWEEN expression */
101580101885
int dest, /* Jump destination or storage location */
101581101886
void (*xJump)(Parse*,Expr*,int,int), /* Action to take */
101582101887
int jumpIfNull /* Take the jump if the BETWEEN is NULL */
101583101888
){
101584
- Expr exprAnd; /* The AND operator in x>=y AND x<=z */
101889
+ Expr exprAnd; /* The AND operator in x>=y AND x<=z */
101585101890
Expr compLeft; /* The x>=y term */
101586101891
Expr compRight; /* The x<=z term */
101587
- Expr exprX; /* The x subexpression */
101588101892
int regFree1 = 0; /* Temporary use register */
101893
+ Expr *pDel = 0;
101894
+ sqlite3 *db = pParse->db;
101589101895
101590101896
memset(&compLeft, 0, sizeof(Expr));
101591101897
memset(&compRight, 0, sizeof(Expr));
101592101898
memset(&exprAnd, 0, sizeof(Expr));
101593101899
101594101900
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
101595
- exprNodeCopy(&exprX, pExpr->pLeft);
101596
- exprAnd.op = TK_AND;
101597
- exprAnd.pLeft = &compLeft;
101598
- exprAnd.pRight = &compRight;
101599
- compLeft.op = TK_GE;
101600
- compLeft.pLeft = &exprX;
101601
- compLeft.pRight = pExpr->x.pList->a[0].pExpr;
101602
- compRight.op = TK_LE;
101603
- compRight.pLeft = &exprX;
101604
- compRight.pRight = pExpr->x.pList->a[1].pExpr;
101605
- exprToRegister(&exprX, exprCodeVector(pParse, &exprX, &regFree1));
101606
- if( xJump ){
101607
- xJump(pParse, &exprAnd, dest, jumpIfNull);
101608
- }else{
101609
- /* Mark the expression is being from the ON or USING clause of a join
101610
- ** so that the sqlite3ExprCodeTarget() routine will not attempt to move
101611
- ** it into the Parse.pConstExpr list. We should use a new bit for this,
101612
- ** for clarity, but we are out of bits in the Expr.flags field so we
101613
- ** have to reuse the EP_FromJoin bit. Bummer. */
101614
- exprX.flags |= EP_FromJoin;
101615
- sqlite3ExprCodeTarget(pParse, &exprAnd, dest);
101616
- }
101617
- sqlite3ReleaseTempReg(pParse, regFree1);
101901
+ pDel = sqlite3ExprDup(db, pExpr->pLeft, 0);
101902
+ if( db->mallocFailed==0 ){
101903
+ exprAnd.op = TK_AND;
101904
+ exprAnd.pLeft = &compLeft;
101905
+ exprAnd.pRight = &compRight;
101906
+ compLeft.op = TK_GE;
101907
+ compLeft.pLeft = pDel;
101908
+ compLeft.pRight = pExpr->x.pList->a[0].pExpr;
101909
+ compRight.op = TK_LE;
101910
+ compRight.pLeft = pDel;
101911
+ compRight.pRight = pExpr->x.pList->a[1].pExpr;
101912
+ exprToRegister(pDel, exprCodeVector(pParse, pDel, &regFree1));
101913
+ if( xJump ){
101914
+ xJump(pParse, &exprAnd, dest, jumpIfNull);
101915
+ }else{
101916
+ /* Mark the expression is being from the ON or USING clause of a join
101917
+ ** so that the sqlite3ExprCodeTarget() routine will not attempt to move
101918
+ ** it into the Parse.pConstExpr list. We should use a new bit for this,
101919
+ ** for clarity, but we are out of bits in the Expr.flags field so we
101920
+ ** have to reuse the EP_FromJoin bit. Bummer. */
101921
+ pDel->flags |= EP_FromJoin;
101922
+ sqlite3ExprCodeTarget(pParse, &exprAnd, dest);
101923
+ }
101924
+ sqlite3ReleaseTempReg(pParse, regFree1);
101925
+ }
101926
+ sqlite3ExprDelete(db, pDel);
101618101927
101619101928
/* Ensure adequate test coverage */
101620101929
testcase( xJump==sqlite3ExprIfTrue && jumpIfNull==0 && regFree1==0 );
101621101930
testcase( xJump==sqlite3ExprIfTrue && jumpIfNull==0 && regFree1!=0 );
101622101931
testcase( xJump==sqlite3ExprIfTrue && jumpIfNull!=0 && regFree1==0 );
@@ -102051,24 +102360,21 @@
102051102360
return 1;
102052102361
}
102053102362
return 2;
102054102363
}
102055102364
if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
102056
- if( pA->op==TK_FUNCTION ){
102365
+ if( pA->op==TK_FUNCTION || pA->op==TK_AGG_FUNCTION ){
102057102366
if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
102058102367
#ifndef SQLITE_OMIT_WINDOWFUNC
102059
- /* Justification for the assert():
102060
- ** window functions have p->op==TK_FUNCTION but aggregate functions
102061
- ** have p->op==TK_AGG_FUNCTION. So any comparison between an aggregate
102062
- ** function and a window function should have failed before reaching
102063
- ** this point. And, it is not possible to have a window function and
102064
- ** a scalar function with the same name and number of arguments. So
102065
- ** if we reach this point, either A and B both window functions or
102066
- ** neither are a window functions. */
102067
- assert( ExprHasProperty(pA,EP_WinFunc)==ExprHasProperty(pB,EP_WinFunc) );
102368
+ assert( pA->op==pB->op );
102369
+ if( ExprHasProperty(pA,EP_WinFunc)!=ExprHasProperty(pB,EP_WinFunc) ){
102370
+ return 2;
102371
+ }
102068102372
if( ExprHasProperty(pA,EP_WinFunc) ){
102069
- if( sqlite3WindowCompare(pParse,pA->y.pWin,pB->y.pWin)!=0 ) return 2;
102373
+ if( sqlite3WindowCompare(pParse, pA->y.pWin, pB->y.pWin, 1)!=0 ){
102374
+ return 2;
102375
+ }
102070102376
}
102071102377
#endif
102072102378
}else if( pA->op==TK_NULL ){
102073102379
return 0;
102074102380
}else if( pA->op==TK_COLLATE ){
@@ -102118,11 +102424,11 @@
102118102424
if( pA==0 || pB==0 ) return 1;
102119102425
if( pA->nExpr!=pB->nExpr ) return 1;
102120102426
for(i=0; i<pA->nExpr; i++){
102121102427
Expr *pExprA = pA->a[i].pExpr;
102122102428
Expr *pExprB = pB->a[i].pExpr;
102123
- if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
102429
+ if( pA->a[i].sortFlags!=pB->a[i].sortFlags ) return 1;
102124102430
if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1;
102125102431
}
102126102432
return 0;
102127102433
}
102128102434
@@ -102130,78 +102436,85 @@
102130102436
** Like sqlite3ExprCompare() except COLLATE operators at the top-level
102131102437
** are ignored.
102132102438
*/
102133102439
SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
102134102440
return sqlite3ExprCompare(0,
102135
- sqlite3ExprSkipCollate(pA),
102136
- sqlite3ExprSkipCollate(pB),
102441
+ sqlite3ExprSkipCollateAndLikely(pA),
102442
+ sqlite3ExprSkipCollateAndLikely(pB),
102137102443
iTab);
102138102444
}
102139102445
102140102446
/*
102141102447
** Return non-zero if Expr p can only be true if pNN is not NULL.
102448
+**
102449
+** Or if seenNot is true, return non-zero if Expr p can only be
102450
+** non-NULL if pNN is not NULL
102142102451
*/
102143102452
static int exprImpliesNotNull(
102144102453
Parse *pParse, /* Parsing context */
102145102454
Expr *p, /* The expression to be checked */
102146102455
Expr *pNN, /* The expression that is NOT NULL */
102147102456
int iTab, /* Table being evaluated */
102148
- int seenNot /* True if p is an operand of NOT */
102457
+ int seenNot /* Return true only if p can be any non-NULL value */
102149102458
){
102150102459
assert( p );
102151102460
assert( pNN );
102152
- if( sqlite3ExprCompare(pParse, p, pNN, iTab)==0 ) return 1;
102461
+ if( sqlite3ExprCompare(pParse, p, pNN, iTab)==0 ){
102462
+ return pNN->op!=TK_NULL;
102463
+ }
102153102464
switch( p->op ){
102154102465
case TK_IN: {
102155102466
if( seenNot && ExprHasProperty(p, EP_xIsSelect) ) return 0;
102156102467
assert( ExprHasProperty(p,EP_xIsSelect)
102157102468
|| (p->x.pList!=0 && p->x.pList->nExpr>0) );
102158
- return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
102469
+ return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
102159102470
}
102160102471
case TK_BETWEEN: {
102161102472
ExprList *pList = p->x.pList;
102162102473
assert( pList!=0 );
102163102474
assert( pList->nExpr==2 );
102164102475
if( seenNot ) return 0;
102165
- if( exprImpliesNotNull(pParse, pList->a[0].pExpr, pNN, iTab, seenNot)
102166
- || exprImpliesNotNull(pParse, pList->a[1].pExpr, pNN, iTab, seenNot)
102476
+ if( exprImpliesNotNull(pParse, pList->a[0].pExpr, pNN, iTab, 1)
102477
+ || exprImpliesNotNull(pParse, pList->a[1].pExpr, pNN, iTab, 1)
102167102478
){
102168102479
return 1;
102169102480
}
102170
- return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
102481
+ return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
102171102482
}
102172102483
case TK_EQ:
102173102484
case TK_NE:
102174102485
case TK_LT:
102175102486
case TK_LE:
102176102487
case TK_GT:
102177102488
case TK_GE:
102178102489
case TK_PLUS:
102179102490
case TK_MINUS:
102491
+ case TK_BITOR:
102492
+ case TK_LSHIFT:
102493
+ case TK_RSHIFT:
102494
+ case TK_CONCAT:
102495
+ seenNot = 1;
102496
+ /* Fall thru */
102180102497
case TK_STAR:
102181102498
case TK_REM:
102182102499
case TK_BITAND:
102183
- case TK_BITOR:
102184
- case TK_SLASH:
102185
- case TK_LSHIFT:
102186
- case TK_RSHIFT:
102187
- case TK_CONCAT: {
102500
+ case TK_SLASH: {
102188102501
if( exprImpliesNotNull(pParse, p->pRight, pNN, iTab, seenNot) ) return 1;
102189102502
/* Fall thru into the next case */
102190102503
}
102191102504
case TK_SPAN:
102192102505
case TK_COLLATE:
102193
- case TK_BITNOT:
102194102506
case TK_UPLUS:
102195102507
case TK_UMINUS: {
102196102508
return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
102197102509
}
102198102510
case TK_TRUTH: {
102199102511
if( seenNot ) return 0;
102200102512
if( p->op2!=TK_IS ) return 0;
102201
- return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
102513
+ return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
102202102514
}
102515
+ case TK_BITNOT:
102203102516
case TK_NOT: {
102204102517
return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
102205102518
}
102206102519
}
102207102520
return 0;
@@ -102263,20 +102576,18 @@
102263102576
testcase( pExpr->op==TK_AGG_COLUMN );
102264102577
testcase( pExpr->op==TK_AGG_FUNCTION );
102265102578
if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;
102266102579
switch( pExpr->op ){
102267102580
case TK_ISNOT:
102268
- case TK_NOT:
102269102581
case TK_ISNULL:
102270102582
case TK_NOTNULL:
102271102583
case TK_IS:
102272102584
case TK_OR:
102273102585
case TK_CASE:
102274102586
case TK_IN:
102275102587
case TK_FUNCTION:
102276102588
testcase( pExpr->op==TK_ISNOT );
102277
- testcase( pExpr->op==TK_NOT );
102278102589
testcase( pExpr->op==TK_ISNULL );
102279102590
testcase( pExpr->op==TK_NOTNULL );
102280102591
testcase( pExpr->op==TK_IS );
102281102592
testcase( pExpr->op==TK_OR );
102282102593
testcase( pExpr->op==TK_CASE );
@@ -102288,10 +102599,22 @@
102288102599
pWalker->eCode = 1;
102289102600
return WRC_Abort;
102290102601
}
102291102602
return WRC_Prune;
102292102603
102604
+ case TK_AND:
102605
+ if( sqlite3ExprImpliesNonNullRow(pExpr->pLeft, pWalker->u.iCur)
102606
+ && sqlite3ExprImpliesNonNullRow(pExpr->pRight, pWalker->u.iCur)
102607
+ ){
102608
+ pWalker->eCode = 1;
102609
+ }
102610
+ return WRC_Prune;
102611
+
102612
+ case TK_BETWEEN:
102613
+ sqlite3WalkExpr(pWalker, pExpr->pLeft);
102614
+ return WRC_Prune;
102615
+
102293102616
/* Virtual tables are allowed to use constraints like x=NULL. So
102294102617
** a term of the form x=y does not prove that y is not null if x
102295102618
** is the column of a virtual table */
102296102619
case TK_EQ:
102297102620
case TK_NE:
@@ -102308,10 +102631,11 @@
102308102631
if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->y.pTab))
102309102632
|| (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->y.pTab))
102310102633
){
102311102634
return WRC_Prune;
102312102635
}
102636
+
102313102637
default:
102314102638
return WRC_Continue;
102315102639
}
102316102640
}
102317102641
@@ -102337,11 +102661,11 @@
102337102661
** be non-NULL, then the LEFT JOIN can be safely converted into an
102338102662
** ordinary join.
102339102663
*/
102340102664
SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){
102341102665
Walker w;
102342
- p = sqlite3ExprSkipCollate(p);
102666
+ p = sqlite3ExprSkipCollateAndLikely(p);
102343102667
while( p ){
102344102668
if( p->op==TK_NOTNULL ){
102345102669
p = p->pLeft;
102346102670
}else if( p->op==TK_AND ){
102347102671
if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1;
@@ -102443,11 +102767,14 @@
102443102767
for(i=0; i<nSrc; i++){
102444102768
if( pExpr->iTable==pSrc->a[i].iCursor ) break;
102445102769
}
102446102770
if( i<nSrc ){
102447102771
p->nThis++;
102448
- }else{
102772
+ }else if( nSrc==0 || pExpr->iTable<pSrc->a[0].iCursor ){
102773
+ /* In a well-formed parse tree (no name resolution errors),
102774
+ ** TK_COLUMN nodes with smaller Expr.iTable values are in an
102775
+ ** outer context. Those are the only ones to count as "other" */
102449102776
p->nOther++;
102450102777
}
102451102778
}
102452102779
return WRC_Continue;
102453102780
}
@@ -102460,12 +102787,13 @@
102460102787
*/
102461102788
SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){
102462102789
Walker w;
102463102790
struct SrcCount cnt;
102464102791
assert( pExpr->op==TK_AGG_FUNCTION );
102792
+ memset(&w, 0, sizeof(w));
102465102793
w.xExprCallback = exprSrcCount;
102466
- w.xSelectCallback = 0;
102794
+ w.xSelectCallback = sqlite3SelectWalkNoop;
102467102795
w.u.pSrcCount = &cnt;
102468102796
cnt.pSrc = pSrcList;
102469102797
cnt.nThis = 0;
102470102798
cnt.nOther = 0;
102471102799
sqlite3WalkExprList(&w, pExpr->x.pList);
@@ -102899,12 +103227,12 @@
102899103227
** that the table is being renamed to.
102900103228
*/
102901103229
if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){
102902103230
goto exit_rename_table;
102903103231
}
102904
- if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto
102905
- exit_rename_table;
103232
+ if( SQLITE_OK!=sqlite3CheckObjectName(pParse,zName,"table",zName) ){
103233
+ goto exit_rename_table;
102906103234
}
102907103235
102908103236
#ifndef SQLITE_OMIT_VIEW
102909103237
if( pTab->pSelect ){
102910103238
sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName);
@@ -104461,17 +104789,17 @@
104461104789
** Additional tables might be added in future releases of SQLite.
104462104790
** The sqlite_stat2 table is not created or used unless the SQLite version
104463104791
** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled
104464104792
** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated.
104465104793
** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
104466
-** created and used by SQLite versions 3.7.9 and later and with
104794
+** created and used by SQLite versions 3.7.9 through 3.29.0 when
104467104795
** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
104468
-** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
104469
-** version of sqlite_stat3 and is only available when compiled with
104470
-** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later. It is
104471
-** not possible to enable both STAT3 and STAT4 at the same time. If they
104472
-** are both enabled, then STAT4 takes precedence.
104796
+** is a superset of sqlite_stat2 and is also now deprecated. The
104797
+** sqlite_stat4 is an enhanced version of sqlite_stat3 and is only
104798
+** available when compiled with SQLITE_ENABLE_STAT4 and in SQLite
104799
+** versions 3.8.1 and later. STAT4 is the only variant that is still
104800
+** supported.
104473104801
**
104474104802
** For most applications, sqlite_stat1 provides all the statistics required
104475104803
** for the query planner to make good choices.
104476104804
**
104477104805
** Format of sqlite_stat1:
@@ -104578,21 +104906,15 @@
104578104906
#ifndef SQLITE_OMIT_ANALYZE
104579104907
/* #include "sqliteInt.h" */
104580104908
104581104909
#if defined(SQLITE_ENABLE_STAT4)
104582104910
# define IsStat4 1
104583
-# define IsStat3 0
104584
-#elif defined(SQLITE_ENABLE_STAT3)
104585
-# define IsStat4 0
104586
-# define IsStat3 1
104587104911
#else
104588104912
# define IsStat4 0
104589
-# define IsStat3 0
104590104913
# undef SQLITE_STAT4_SAMPLES
104591104914
# define SQLITE_STAT4_SAMPLES 1
104592104915
#endif
104593
-#define IsStat34 (IsStat3+IsStat4) /* 1 for STAT3 or STAT4. 0 otherwise */
104594104916
104595104917
/*
104596104918
** This routine generates code that opens the sqlite_statN tables.
104597104919
** The sqlite_stat1 table is always relevant. sqlite_stat2 is now
104598104920
** obsolete. sqlite_stat3 and sqlite_stat4 are only opened when
@@ -104617,18 +104939,14 @@
104617104939
const char *zCols;
104618104940
} aTable[] = {
104619104941
{ "sqlite_stat1", "tbl,idx,stat" },
104620104942
#if defined(SQLITE_ENABLE_STAT4)
104621104943
{ "sqlite_stat4", "tbl,idx,neq,nlt,ndlt,sample" },
104622
- { "sqlite_stat3", 0 },
104623
-#elif defined(SQLITE_ENABLE_STAT3)
104624
- { "sqlite_stat3", "tbl,idx,neq,nlt,ndlt,sample" },
104625
- { "sqlite_stat4", 0 },
104626104944
#else
104627
- { "sqlite_stat3", 0 },
104628104945
{ "sqlite_stat4", 0 },
104629104946
#endif
104947
+ { "sqlite_stat3", 0 },
104630104948
};
104631104949
int i;
104632104950
sqlite3 *db = pParse->db;
104633104951
Db *pDb;
104634104952
Vdbe *v = sqlite3GetVdbe(pParse);
@@ -104705,11 +105023,11 @@
104705105023
typedef struct Stat4Accum Stat4Accum;
104706105024
typedef struct Stat4Sample Stat4Sample;
104707105025
struct Stat4Sample {
104708105026
tRowcnt *anEq; /* sqlite_stat4.nEq */
104709105027
tRowcnt *anDLt; /* sqlite_stat4.nDLt */
104710
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105028
+#ifdef SQLITE_ENABLE_STAT4
104711105029
tRowcnt *anLt; /* sqlite_stat4.nLt */
104712105030
union {
104713105031
i64 iRowid; /* Rowid in main table of the key */
104714105032
u8 *aRowid; /* Key for WITHOUT ROWID tables */
104715105033
} u;
@@ -104736,11 +105054,11 @@
104736105054
sqlite3 *db; /* Database connection, for malloc() */
104737105055
};
104738105056
104739105057
/* Reclaim memory used by a Stat4Sample
104740105058
*/
104741
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105059
+#ifdef SQLITE_ENABLE_STAT4
104742105060
static void sampleClear(sqlite3 *db, Stat4Sample *p){
104743105061
assert( db!=0 );
104744105062
if( p->nRowid ){
104745105063
sqlite3DbFree(db, p->u.aRowid);
104746105064
p->nRowid = 0;
@@ -104748,11 +105066,11 @@
104748105066
}
104749105067
#endif
104750105068
104751105069
/* Initialize the BLOB value of a ROWID
104752105070
*/
104753
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105071
+#ifdef SQLITE_ENABLE_STAT4
104754105072
static void sampleSetRowid(sqlite3 *db, Stat4Sample *p, int n, const u8 *pData){
104755105073
assert( db!=0 );
104756105074
if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);
104757105075
p->u.aRowid = sqlite3DbMallocRawNN(db, n);
104758105076
if( p->u.aRowid ){
@@ -104764,11 +105082,11 @@
104764105082
}
104765105083
#endif
104766105084
104767105085
/* Initialize the INTEGER value of a ROWID.
104768105086
*/
104769
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105087
+#ifdef SQLITE_ENABLE_STAT4
104770105088
static void sampleSetRowidInt64(sqlite3 *db, Stat4Sample *p, i64 iRowid){
104771105089
assert( db!=0 );
104772105090
if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);
104773105091
p->nRowid = 0;
104774105092
p->u.iRowid = iRowid;
@@ -104777,11 +105095,11 @@
104777105095
104778105096
104779105097
/*
104780105098
** Copy the contents of object (*pFrom) into (*pTo).
104781105099
*/
104782
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105100
+#ifdef SQLITE_ENABLE_STAT4
104783105101
static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
104784105102
pTo->isPSample = pFrom->isPSample;
104785105103
pTo->iCol = pFrom->iCol;
104786105104
pTo->iHash = pFrom->iHash;
104787105105
memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);
@@ -104798,11 +105116,11 @@
104798105116
/*
104799105117
** Reclaim all memory of a Stat4Accum structure.
104800105118
*/
104801105119
static void stat4Destructor(void *pOld){
104802105120
Stat4Accum *p = (Stat4Accum*)pOld;
104803
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105121
+#ifdef SQLITE_ENABLE_STAT4
104804105122
int i;
104805105123
for(i=0; i<p->nCol; i++) sampleClear(p->db, p->aBest+i);
104806105124
for(i=0; i<p->mxSample; i++) sampleClear(p->db, p->a+i);
104807105125
sampleClear(p->db, &p->current);
104808105126
#endif
@@ -104818,11 +105136,11 @@
104818105136
**
104819105137
** Note 1: In the special case of the covering index that implements a
104820105138
** WITHOUT ROWID table, N is the number of PRIMARY KEY columns, not the
104821105139
** total number of columns in the table.
104822105140
**
104823
-** Note 2: C is only used for STAT3 and STAT4.
105141
+** Note 2: C is only used for STAT4.
104824105142
**
104825105143
** For indexes on ordinary rowid tables, N==K+1. But for indexes on
104826105144
** WITHOUT ROWID tables, N=K+P where P is the number of columns in the
104827105145
** PRIMARY KEY of the table. The covering index that implements the
104828105146
** original WITHOUT ROWID table as N==K as a special case.
@@ -104841,11 +105159,11 @@
104841105159
int nCol; /* Number of columns in index being sampled */
104842105160
int nKeyCol; /* Number of key columns */
104843105161
int nColUp; /* nCol rounded up for alignment */
104844105162
int n; /* Bytes of space to allocate */
104845105163
sqlite3 *db; /* Database connection */
104846
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105164
+#ifdef SQLITE_ENABLE_STAT4
104847105165
int mxSample = SQLITE_STAT4_SAMPLES;
104848105166
#endif
104849105167
104850105168
/* Decode the three function arguments */
104851105169
UNUSED_PARAMETER(argc);
@@ -104858,11 +105176,11 @@
104858105176
104859105177
/* Allocate the space required for the Stat4Accum object */
104860105178
n = sizeof(*p)
104861105179
+ sizeof(tRowcnt)*nColUp /* Stat4Accum.anEq */
104862105180
+ sizeof(tRowcnt)*nColUp /* Stat4Accum.anDLt */
104863
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105181
+#ifdef SQLITE_ENABLE_STAT4
104864105182
+ sizeof(tRowcnt)*nColUp /* Stat4Accum.anLt */
104865105183
+ sizeof(Stat4Sample)*(nCol+mxSample) /* Stat4Accum.aBest[], a[] */
104866105184
+ sizeof(tRowcnt)*3*nColUp*(nCol+mxSample)
104867105185
#endif
104868105186
;
@@ -104878,11 +105196,11 @@
104878105196
p->nCol = nCol;
104879105197
p->nKeyCol = nKeyCol;
104880105198
p->current.anDLt = (tRowcnt*)&p[1];
104881105199
p->current.anEq = &p->current.anDLt[nColUp];
104882105200
104883
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105201
+#ifdef SQLITE_ENABLE_STAT4
104884105202
{
104885105203
u8 *pSpace; /* Allocated space not yet assigned */
104886105204
int i; /* Used to iterate through p->aSample[] */
104887105205
104888105206
p->iGet = -1;
@@ -104913,11 +105231,11 @@
104913105231
** (given by the 3rd parameter) is never used and can be any positive
104914105232
** value. */
104915105233
sqlite3_result_blob(context, p, sizeof(*p), stat4Destructor);
104916105234
}
104917105235
static const FuncDef statInitFuncdef = {
104918
- 2+IsStat34, /* nArg */
105236
+ 2+IsStat4, /* nArg */
104919105237
SQLITE_UTF8, /* funcFlags */
104920105238
0, /* pUserData */
104921105239
0, /* pNext */
104922105240
statInit, /* xSFunc */
104923105241
0, /* xFinalize */
@@ -104953,11 +105271,11 @@
104953105271
if( pNew->iHash>pOld->iHash ) return 1;
104954105272
return 0;
104955105273
}
104956105274
#endif
104957105275
104958
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105276
+#ifdef SQLITE_ENABLE_STAT4
104959105277
/*
104960105278
** Return true if pNew is to be preferred over pOld.
104961105279
**
104962105280
** This function assumes that for each argument sample, the contents of
104963105281
** the anEq[] array from pSample->anEq[pSample->iCol] onwards are valid.
@@ -104972,19 +105290,15 @@
104972105290
104973105291
assert( pOld->isPSample==0 && pNew->isPSample==0 );
104974105292
assert( IsStat4 || (pNew->iCol==0 && pOld->iCol==0) );
104975105293
104976105294
if( (nEqNew>nEqOld) ) return 1;
104977
-#ifdef SQLITE_ENABLE_STAT4
104978105295
if( nEqNew==nEqOld ){
104979105296
if( pNew->iCol<pOld->iCol ) return 1;
104980105297
return (pNew->iCol==pOld->iCol && sampleIsBetterPost(pAccum, pNew, pOld));
104981105298
}
104982105299
return 0;
104983
-#else
104984
- return (nEqNew==nEqOld && pNew->iHash>pOld->iHash);
104985
-#endif
104986105300
}
104987105301
104988105302
/*
104989105303
** Copy the contents of sample *pNew into the p->a[] array. If necessary,
104990105304
** remove the least desirable sample from p->a[] to make room.
@@ -104993,11 +105307,10 @@
104993105307
Stat4Sample *pSample = 0;
104994105308
int i;
104995105309
104996105310
assert( IsStat4 || nEqZero==0 );
104997105311
104998
-#ifdef SQLITE_ENABLE_STAT4
104999105312
/* Stat4Accum.nMaxEqZero is set to the maximum number of leading 0
105000105313
** values in the anEq[] array of any sample in Stat4Accum.a[]. In
105001105314
** other words, if nMaxEqZero is n, then it is guaranteed that there
105002105315
** are no samples with Stat4Sample.anEq[m]==0 for (m>=n). */
105003105316
if( nEqZero>p->nMaxEqZero ){
@@ -105027,11 +105340,10 @@
105027105340
pUpgrade->iCol = pNew->iCol;
105028105341
pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol];
105029105342
goto find_new_min;
105030105343
}
105031105344
}
105032
-#endif
105033105345
105034105346
/* If necessary, remove sample iMin to make room for the new sample. */
105035105347
if( p->nSample>=p->mxSample ){
105036105348
Stat4Sample *pMin = &p->a[p->iMin];
105037105349
tRowcnt *anEq = pMin->anEq;
@@ -105048,26 +105360,22 @@
105048105360
}
105049105361
105050105362
/* The "rows less-than" for the rowid column must be greater than that
105051105363
** for the last sample in the p->a[] array. Otherwise, the samples would
105052105364
** be out of order. */
105053
-#ifdef SQLITE_ENABLE_STAT4
105054105365
assert( p->nSample==0
105055105366
|| pNew->anLt[p->nCol-1] > p->a[p->nSample-1].anLt[p->nCol-1] );
105056
-#endif
105057105367
105058105368
/* Insert the new sample */
105059105369
pSample = &p->a[p->nSample];
105060105370
sampleCopy(p, pSample, pNew);
105061105371
p->nSample++;
105062105372
105063105373
/* Zero the first nEqZero entries in the anEq[] array. */
105064105374
memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero);
105065105375
105066
-#ifdef SQLITE_ENABLE_STAT4
105067
- find_new_min:
105068
-#endif
105376
+find_new_min:
105069105377
if( p->nSample>=p->mxSample ){
105070105378
int iMin = -1;
105071105379
for(i=0; i<p->mxSample; i++){
105072105380
if( p->a[i].isPSample ) continue;
105073105381
if( iMin<0 || sampleIsBetter(p, &p->a[iMin], &p->a[i]) ){
@@ -105076,11 +105384,11 @@
105076105384
}
105077105385
assert( iMin>=0 );
105078105386
p->iMin = iMin;
105079105387
}
105080105388
}
105081
-#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
105389
+#endif /* SQLITE_ENABLE_STAT4 */
105082105390
105083105391
/*
105084105392
** Field iChng of the index being scanned has changed. So at this point
105085105393
** p->current contains a sample that reflects the previous row of the
105086105394
** index. The value of anEq[iChng] and subsequent anEq[] elements are
@@ -105117,32 +105425,11 @@
105117105425
}
105118105426
p->nMaxEqZero = iChng;
105119105427
}
105120105428
#endif
105121105429
105122
-#if defined(SQLITE_ENABLE_STAT3) && !defined(SQLITE_ENABLE_STAT4)
105123
- if( iChng==0 ){
105124
- tRowcnt nLt = p->current.anLt[0];
105125
- tRowcnt nEq = p->current.anEq[0];
105126
-
105127
- /* Check if this is to be a periodic sample. If so, add it. */
105128
- if( (nLt/p->nPSample)!=(nLt+nEq)/p->nPSample ){
105129
- p->current.isPSample = 1;
105130
- sampleInsert(p, &p->current, 0);
105131
- p->current.isPSample = 0;
105132
- }else
105133
-
105134
- /* Or if it is a non-periodic sample. Add it in this case too. */
105135
- if( p->nSample<p->mxSample
105136
- || sampleIsBetter(p, &p->current, &p->a[p->iMin])
105137
- ){
105138
- sampleInsert(p, &p->current, 0);
105139
- }
105140
- }
105141
-#endif
105142
-
105143
-#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
105430
+#ifndef SQLITE_ENABLE_STAT4
105144105431
UNUSED_PARAMETER( p );
105145105432
UNUSED_PARAMETER( iChng );
105146105433
#endif
105147105434
}
105148105435
@@ -105158,11 +105445,11 @@
105158105445
** This SQL function always returns NULL. It's purpose it to accumulate
105159105446
** statistical data and/or samples in the Stat4Accum object about the
105160105447
** index being analyzed. The stat_get() SQL function will later be used to
105161105448
** extract relevant information for constructing the sqlite_statN tables.
105162105449
**
105163
-** The R parameter is only used for STAT3 and STAT4
105450
+** The R parameter is only used for STAT4
105164105451
*/
105165105452
static void statPush(
105166105453
sqlite3_context *context,
105167105454
int argc,
105168105455
sqlite3_value **argv
@@ -105190,18 +105477,18 @@
105190105477
for(i=0; i<iChng; i++){
105191105478
p->current.anEq[i]++;
105192105479
}
105193105480
for(i=iChng; i<p->nCol; i++){
105194105481
p->current.anDLt[i]++;
105195
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105482
+#ifdef SQLITE_ENABLE_STAT4
105196105483
p->current.anLt[i] += p->current.anEq[i];
105197105484
#endif
105198105485
p->current.anEq[i] = 1;
105199105486
}
105200105487
}
105201105488
p->nRow++;
105202
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105489
+#ifdef SQLITE_ENABLE_STAT4
105203105490
if( sqlite3_value_type(argv[2])==SQLITE_INTEGER ){
105204105491
sampleSetRowidInt64(p->db, &p->current, sqlite3_value_int64(argv[2]));
105205105492
}else{
105206105493
sampleSetRowid(p->db, &p->current, sqlite3_value_bytes(argv[2]),
105207105494
sqlite3_value_blob(argv[2]));
@@ -105230,11 +105517,11 @@
105230105517
}
105231105518
}
105232105519
#endif
105233105520
}
105234105521
static const FuncDef statPushFuncdef = {
105235
- 2+IsStat34, /* nArg */
105522
+ 2+IsStat4, /* nArg */
105236105523
SQLITE_UTF8, /* funcFlags */
105237105524
0, /* pUserData */
105238105525
0, /* pNext */
105239105526
statPush, /* xSFunc */
105240105527
0, /* xFinalize */
@@ -105261,11 +105548,11 @@
105261105548
** inserted as part of a manually constructed bytecode program. (See
105262105549
** the callStatGet() routine below.) It is guaranteed that the P
105263105550
** parameter will always be a poiner to a Stat4Accum object, never a
105264105551
** NULL.
105265105552
**
105266
-** If neither STAT3 nor STAT4 are enabled, then J is always
105553
+** If STAT4 is not enabled, then J is always
105267105554
** STAT_GET_STAT1 and is hence omitted and this routine becomes
105268105555
** a one-parameter function, stat_get(P), that always returns the
105269105556
** stat1 table entry information.
105270105557
*/
105271105558
static void statGet(
@@ -105272,12 +105559,12 @@
105272105559
sqlite3_context *context,
105273105560
int argc,
105274105561
sqlite3_value **argv
105275105562
){
105276105563
Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);
105277
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105278
- /* STAT3 and STAT4 have a parameter on this routine. */
105564
+#ifdef SQLITE_ENABLE_STAT4
105565
+ /* STAT4 has a parameter on this routine. */
105279105566
int eCall = sqlite3_value_int(argv[1]);
105280105567
assert( argc==2 );
105281105568
assert( eCall==STAT_GET_STAT1 || eCall==STAT_GET_NEQ
105282105569
|| eCall==STAT_GET_ROWID || eCall==STAT_GET_NLT
105283105570
|| eCall==STAT_GET_NDLT
@@ -105328,11 +105615,11 @@
105328105615
}
105329105616
assert( z[0]=='\0' && z>zRet );
105330105617
105331105618
sqlite3_result_text(context, zRet, -1, sqlite3_free);
105332105619
}
105333
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105620
+#ifdef SQLITE_ENABLE_STAT4
105334105621
else if( eCall==STAT_GET_ROWID ){
105335105622
if( p->iGet<0 ){
105336105623
samplePushPrevious(p, 0);
105337105624
p->iGet = 0;
105338105625
}
@@ -105357,13 +105644,11 @@
105357105644
p->iGet++;
105358105645
break;
105359105646
}
105360105647
}
105361105648
105362
- if( IsStat3 ){
105363
- sqlite3_result_int64(context, (i64)aCnt[0]);
105364
- }else{
105649
+ {
105365105650
char *zRet = sqlite3MallocZero(p->nCol * 25);
105366105651
if( zRet==0 ){
105367105652
sqlite3_result_error_nomem(context);
105368105653
}else{
105369105654
int i;
@@ -105376,17 +105661,17 @@
105376105661
z[-1] = '\0';
105377105662
sqlite3_result_text(context, zRet, -1, sqlite3_free);
105378105663
}
105379105664
}
105380105665
}
105381
-#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
105666
+#endif /* SQLITE_ENABLE_STAT4 */
105382105667
#ifndef SQLITE_DEBUG
105383105668
UNUSED_PARAMETER( argc );
105384105669
#endif
105385105670
}
105386105671
static const FuncDef statGetFuncdef = {
105387
- 1+IsStat34, /* nArg */
105672
+ 1+IsStat4, /* nArg */
105388105673
SQLITE_UTF8, /* funcFlags */
105389105674
0, /* pUserData */
105390105675
0, /* pNext */
105391105676
statGet, /* xSFunc */
105392105677
0, /* xFinalize */
@@ -105395,20 +105680,20 @@
105395105680
{0}
105396105681
};
105397105682
105398105683
static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
105399105684
assert( regOut!=regStat4 && regOut!=regStat4+1 );
105400
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105685
+#ifdef SQLITE_ENABLE_STAT4
105401105686
sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
105402105687
#elif SQLITE_DEBUG
105403105688
assert( iParam==STAT_GET_STAT1 );
105404105689
#else
105405105690
UNUSED_PARAMETER( iParam );
105406105691
#endif
105407105692
sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4, regOut,
105408105693
(char*)&statGetFuncdef, P4_FUNCDEF);
105409
- sqlite3VdbeChangeP5(v, 1 + IsStat34);
105694
+ sqlite3VdbeChangeP5(v, 1 + IsStat4);
105410105695
}
105411105696
105412105697
/*
105413105698
** Generate code to do an analysis of all indices associated with
105414105699
** a single table.
@@ -105431,11 +105716,11 @@
105431105716
int iDb; /* Index of database containing pTab */
105432105717
u8 needTableCnt = 1; /* True to count the table */
105433105718
int regNewRowid = iMem++; /* Rowid for the inserted record */
105434105719
int regStat4 = iMem++; /* Register to hold Stat4Accum object */
105435105720
int regChng = iMem++; /* Index of changed index field */
105436
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105721
+#ifdef SQLITE_ENABLE_STAT4
105437105722
int regRowid = iMem++; /* Rowid argument passed to stat_push() */
105438105723
#endif
105439105724
int regTemp = iMem++; /* Temporary use register */
105440105725
int regTabname = iMem++; /* Register containing table name */
105441105726
int regIdxname = iMem++; /* Register containing index name */
@@ -105565,20 +105850,20 @@
105565105850
** (or for a WITHOUT ROWID table, the number of PK columns),
105566105851
** (2) the number of columns in the key without the rowid/pk
105567105852
** (3) the number of rows in the index,
105568105853
**
105569105854
**
105570
- ** The third argument is only used for STAT3 and STAT4
105855
+ ** The third argument is only used for STAT4
105571105856
*/
105572
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105857
+#ifdef SQLITE_ENABLE_STAT4
105573105858
sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+3);
105574105859
#endif
105575105860
sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1);
105576105861
sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);
105577105862
sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4+1, regStat4,
105578105863
(char*)&statInitFuncdef, P4_FUNCDEF);
105579
- sqlite3VdbeChangeP5(v, 2+IsStat34);
105864
+ sqlite3VdbeChangeP5(v, 2+IsStat4);
105580105865
105581105866
/* Implementation of the following:
105582105867
**
105583105868
** Rewind csr
105584105869
** if eof(csr) goto end_of_scan;
@@ -105645,16 +105930,16 @@
105645105930
sqlite3DbFree(db, aGotoChng);
105646105931
}
105647105932
105648105933
/*
105649105934
** chng_addr_N:
105650
- ** regRowid = idx(rowid) // STAT34 only
105651
- ** stat_push(P, regChng, regRowid) // 3rd parameter STAT34 only
105935
+ ** regRowid = idx(rowid) // STAT4 only
105936
+ ** stat_push(P, regChng, regRowid) // 3rd parameter STAT4 only
105652105937
** Next csr
105653105938
** if !eof(csr) goto next_row;
105654105939
*/
105655
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105940
+#ifdef SQLITE_ENABLE_STAT4
105656105941
assert( regRowid==(regStat4+2) );
105657105942
if( HasRowid(pTab) ){
105658105943
sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, regRowid);
105659105944
}else{
105660105945
Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
@@ -105671,11 +105956,11 @@
105671105956
}
105672105957
#endif
105673105958
assert( regChng==(regStat4+1) );
105674105959
sqlite3VdbeAddOp4(v, OP_Function0, 1, regStat4, regTemp,
105675105960
(char*)&statPushFuncdef, P4_FUNCDEF);
105676
- sqlite3VdbeChangeP5(v, 2+IsStat34);
105961
+ sqlite3VdbeChangeP5(v, 2+IsStat4);
105677105962
sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, addrNextRow); VdbeCoverage(v);
105678105963
105679105964
/* Add the entry to the stat1 table. */
105680105965
callStatGet(v, regStat4, STAT_GET_STAT1, regStat1);
105681105966
assert( "BBB"[0]==SQLITE_AFF_TEXT );
@@ -105685,12 +105970,12 @@
105685105970
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
105686105971
sqlite3VdbeChangeP4(v, -1, (char*)pStat1, P4_TABLE);
105687105972
#endif
105688105973
sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
105689105974
105690
- /* Add the entries to the stat3 or stat4 table. */
105691
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105975
+ /* Add the entries to the stat4 table. */
105976
+#ifdef SQLITE_ENABLE_STAT4
105692105977
{
105693105978
int regEq = regStat1;
105694105979
int regLt = regStat1+1;
105695105980
int regDLt = regStat1+2;
105696105981
int regSample = regStat1+3;
@@ -105709,25 +105994,21 @@
105709105994
callStatGet(v, regStat4, STAT_GET_NEQ, regEq);
105710105995
callStatGet(v, regStat4, STAT_GET_NLT, regLt);
105711105996
callStatGet(v, regStat4, STAT_GET_NDLT, regDLt);
105712105997
sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);
105713105998
VdbeCoverage(v);
105714
-#ifdef SQLITE_ENABLE_STAT3
105715
- sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, 0, regSample);
105716
-#else
105717105999
for(i=0; i<nCol; i++){
105718106000
sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
105719106001
}
105720106002
sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol, regSample);
105721
-#endif
105722106003
sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp);
105723106004
sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid);
105724106005
sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regTemp, regNewRowid);
105725106006
sqlite3VdbeAddOp2(v, OP_Goto, 1, addrNext); /* P1==1 for end-of-loop */
105726106007
sqlite3VdbeJumpHere(v, addrIsNull);
105727106008
}
105728
-#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
106009
+#endif /* SQLITE_ENABLE_STAT4 */
105729106010
105730106011
/* End of analysis */
105731106012
sqlite3VdbeJumpHere(v, addrRewind);
105732106013
}
105733106014
@@ -105898,11 +106179,11 @@
105898106179
char *z = zIntArray;
105899106180
int c;
105900106181
int i;
105901106182
tRowcnt v;
105902106183
105903
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
106184
+#ifdef SQLITE_ENABLE_STAT4
105904106185
if( z==0 ) z = "";
105905106186
#else
105906106187
assert( z!=0 );
105907106188
#endif
105908106189
for(i=0; *z && i<nOut; i++){
@@ -105909,11 +106190,11 @@
105909106190
v = 0;
105910106191
while( (c=z[0])>='0' && c<='9' ){
105911106192
v = v*10 + c - '0';
105912106193
z++;
105913106194
}
105914
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
106195
+#ifdef SQLITE_ENABLE_STAT4
105915106196
if( aOut ) aOut[i] = v;
105916106197
if( aLog ) aLog[i] = sqlite3LogEst(v);
105917106198
#else
105918106199
assert( aOut==0 );
105919106200
UNUSED_PARAMETER(aOut);
@@ -105920,11 +106201,11 @@
105920106201
assert( aLog!=0 );
105921106202
aLog[i] = sqlite3LogEst(v);
105922106203
#endif
105923106204
if( *z==' ' ) z++;
105924106205
}
105925
-#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
106206
+#ifndef SQLITE_ENABLE_STAT4
105926106207
assert( pIndex!=0 ); {
105927106208
#else
105928106209
if( pIndex ){
105929106210
#endif
105930106211
pIndex->bUnordered = 0;
@@ -105931,11 +106212,13 @@
105931106212
pIndex->noSkipScan = 0;
105932106213
while( z[0] ){
105933106214
if( sqlite3_strglob("unordered*", z)==0 ){
105934106215
pIndex->bUnordered = 1;
105935106216
}else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){
105936
- pIndex->szIdxRow = sqlite3LogEst(sqlite3Atoi(z+3));
106217
+ int sz = sqlite3Atoi(z+3);
106218
+ if( sz<2 ) sz = 2;
106219
+ pIndex->szIdxRow = sqlite3LogEst(sz);
105937106220
}else if( sqlite3_strglob("noskipscan*", z)==0 ){
105938106221
pIndex->noSkipScan = 1;
105939106222
}
105940106223
#ifdef SQLITE_ENABLE_COSTMULT
105941106224
else if( sqlite3_strglob("costmult=[0-9]*",z)==0 ){
@@ -105985,11 +106268,11 @@
105985106268
z = argv[2];
105986106269
105987106270
if( pIndex ){
105988106271
tRowcnt *aiRowEst = 0;
105989106272
int nCol = pIndex->nKeyCol+1;
105990
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
106273
+#ifdef SQLITE_ENABLE_STAT4
105991106274
/* Index.aiRowEst may already be set here if there are duplicate
105992106275
** sqlite_stat1 entries for this index. In that case just clobber
105993106276
** the old data with the new instead of allocating a new array. */
105994106277
if( pIndex->aiRowEst==0 ){
105995106278
pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(sizeof(tRowcnt) * nCol);
@@ -106021,11 +106304,11 @@
106021106304
/*
106022106305
** If the Index.aSample variable is not NULL, delete the aSample[] array
106023106306
** and its contents.
106024106307
*/
106025106308
SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){
106026
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
106309
+#ifdef SQLITE_ENABLE_STAT4
106027106310
if( pIdx->aSample ){
106028106311
int j;
106029106312
for(j=0; j<pIdx->nSample; j++){
106030106313
IndexSample *p = &pIdx->aSample[j];
106031106314
sqlite3DbFree(db, p->p);
@@ -106037,14 +106320,14 @@
106037106320
pIdx->aSample = 0;
106038106321
}
106039106322
#else
106040106323
UNUSED_PARAMETER(db);
106041106324
UNUSED_PARAMETER(pIdx);
106042
-#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
106325
+#endif /* SQLITE_ENABLE_STAT4 */
106043106326
}
106044106327
106045
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
106328
+#ifdef SQLITE_ENABLE_STAT4
106046106329
/*
106047106330
** Populate the pIdx->aAvgEq[] array based on the samples currently
106048106331
** stored in pIdx->aSample[].
106049106332
*/
106050106333
static void initAvgEq(Index *pIdx){
@@ -106118,25 +106401,23 @@
106118106401
}
106119106402
return pIdx;
106120106403
}
106121106404
106122106405
/*
106123
-** Load the content from either the sqlite_stat4 or sqlite_stat3 table
106406
+** Load the content from either the sqlite_stat4
106124106407
** into the relevant Index.aSample[] arrays.
106125106408
**
106126106409
** Arguments zSql1 and zSql2 must point to SQL statements that return
106127
-** data equivalent to the following (statements are different for stat3,
106128
-** see the caller of this function for details):
106410
+** data equivalent to the following:
106129106411
**
106130106412
** zSql1: SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx
106131106413
** zSql2: SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4
106132106414
**
106133106415
** where %Q is replaced with the database name before the SQL is executed.
106134106416
*/
106135106417
static int loadStatTbl(
106136106418
sqlite3 *db, /* Database handle */
106137
- int bStat3, /* Assume single column records only */
106138106419
const char *zSql1, /* SQL statement 1 (see above) */
106139106420
const char *zSql2, /* SQL statement 2 (see above) */
106140106421
const char *zDb /* Database name (e.g. "main") */
106141106422
){
106142106423
int rc; /* Result codes from subroutines */
@@ -106166,21 +106447,17 @@
106166106447
106167106448
zIndex = (char *)sqlite3_column_text(pStmt, 0);
106168106449
if( zIndex==0 ) continue;
106169106450
nSample = sqlite3_column_int(pStmt, 1);
106170106451
pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
106171
- assert( pIdx==0 || bStat3 || pIdx->nSample==0 );
106172
- /* Index.nSample is non-zero at this point if data has already been
106173
- ** loaded from the stat4 table. In this case ignore stat3 data. */
106174
- if( pIdx==0 || pIdx->nSample ) continue;
106175
- if( bStat3==0 ){
106176
- assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );
106177
- if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
106178
- nIdxCol = pIdx->nKeyCol;
106179
- }else{
106180
- nIdxCol = pIdx->nColumn;
106181
- }
106452
+ assert( pIdx==0 || pIdx->nSample==0 );
106453
+ if( pIdx==0 ) continue;
106454
+ assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );
106455
+ if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
106456
+ nIdxCol = pIdx->nKeyCol;
106457
+ }else{
106458
+ nIdxCol = pIdx->nColumn;
106182106459
}
106183106460
pIdx->nSampleCol = nIdxCol;
106184106461
nByte = sizeof(IndexSample) * nSample;
106185106462
nByte += sizeof(tRowcnt) * nIdxCol * 3 * nSample;
106186106463
nByte += nIdxCol * sizeof(tRowcnt); /* Space for Index.aAvgEq[] */
@@ -106218,13 +106495,12 @@
106218106495
zIndex = (char *)sqlite3_column_text(pStmt, 0);
106219106496
if( zIndex==0 ) continue;
106220106497
pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
106221106498
if( pIdx==0 ) continue;
106222106499
/* This next condition is true if data has already been loaded from
106223
- ** the sqlite_stat4 table. In this case ignore stat3 data. */
106500
+ ** the sqlite_stat4 table. */
106224106501
nCol = pIdx->nSampleCol;
106225
- if( bStat3 && nCol>1 ) continue;
106226106502
if( pIdx!=pPrevIdx ){
106227106503
initAvgEq(pPrevIdx);
106228106504
pPrevIdx = pIdx;
106229106505
}
106230106506
pSample = &pIdx->aSample[pIdx->nSample];
@@ -106253,49 +106529,40 @@
106253106529
if( rc==SQLITE_OK ) initAvgEq(pPrevIdx);
106254106530
return rc;
106255106531
}
106256106532
106257106533
/*
106258
-** Load content from the sqlite_stat4 and sqlite_stat3 tables into
106534
+** Load content from the sqlite_stat4 table into
106259106535
** the Index.aSample[] arrays of all indices.
106260106536
*/
106261106537
static int loadStat4(sqlite3 *db, const char *zDb){
106262106538
int rc = SQLITE_OK; /* Result codes from subroutines */
106263106539
106264106540
assert( db->lookaside.bDisable );
106265106541
if( sqlite3FindTable(db, "sqlite_stat4", zDb) ){
106266
- rc = loadStatTbl(db, 0,
106542
+ rc = loadStatTbl(db,
106267106543
"SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx",
106268106544
"SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4",
106269106545
zDb
106270106546
);
106271106547
}
106272
-
106273
- if( rc==SQLITE_OK && sqlite3FindTable(db, "sqlite_stat3", zDb) ){
106274
- rc = loadStatTbl(db, 1,
106275
- "SELECT idx,count(*) FROM %Q.sqlite_stat3 GROUP BY idx",
106276
- "SELECT idx,neq,nlt,ndlt,sqlite_record(sample) FROM %Q.sqlite_stat3",
106277
- zDb
106278
- );
106279
- }
106280
-
106281106548
return rc;
106282106549
}
106283
-#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
106550
+#endif /* SQLITE_ENABLE_STAT4 */
106284106551
106285106552
/*
106286
-** Load the content of the sqlite_stat1 and sqlite_stat3/4 tables. The
106553
+** Load the content of the sqlite_stat1 and sqlite_stat4 tables. The
106287106554
** contents of sqlite_stat1 are used to populate the Index.aiRowEst[]
106288
-** arrays. The contents of sqlite_stat3/4 are used to populate the
106555
+** arrays. The contents of sqlite_stat4 are used to populate the
106289106556
** Index.aSample[] arrays.
106290106557
**
106291106558
** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
106292
-** is returned. In this case, even if SQLITE_ENABLE_STAT3/4 was defined
106293
-** during compilation and the sqlite_stat3/4 table is present, no data is
106559
+** is returned. In this case, even if SQLITE_ENABLE_STAT4 was defined
106560
+** during compilation and the sqlite_stat4 table is present, no data is
106294106561
** read from it.
106295106562
**
106296
-** If SQLITE_ENABLE_STAT3/4 was defined during compilation and the
106563
+** If SQLITE_ENABLE_STAT4 was defined during compilation and the
106297106564
** sqlite_stat4 table is not present in the database, SQLITE_ERROR is
106298106565
** returned. However, in this case, data is read from the sqlite_stat1
106299106566
** table (if it is present) before returning.
106300106567
**
106301106568
** If an OOM error occurs, this function always sets db->mallocFailed.
@@ -106319,11 +106586,11 @@
106319106586
pTab->tabFlags &= ~TF_HasStat1;
106320106587
}
106321106588
for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
106322106589
Index *pIdx = sqliteHashData(i);
106323106590
pIdx->hasStat1 = 0;
106324
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
106591
+#ifdef SQLITE_ENABLE_STAT4
106325106592
sqlite3DeleteIndexSamples(db, pIdx);
106326106593
pIdx->aSample = 0;
106327106594
#endif
106328106595
}
106329106596
@@ -106347,11 +106614,11 @@
106347106614
Index *pIdx = sqliteHashData(i);
106348106615
if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
106349106616
}
106350106617
106351106618
/* Load the statistics from the sqlite_stat4 table. */
106352
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
106619
+#ifdef SQLITE_ENABLE_STAT4
106353106620
if( rc==SQLITE_OK ){
106354106621
db->lookaside.bDisable++;
106355106622
rc = loadStat4(db, sInfo.zDatabase);
106356106623
db->lookaside.bDisable--;
106357106624
}
@@ -106672,10 +106939,11 @@
106672106939
){
106673106940
const char *zName = (const char *)sqlite3_value_text(argv[0]);
106674106941
sqlite3 *db = sqlite3_context_db_handle(context);
106675106942
int i;
106676106943
Db *pDb = 0;
106944
+ HashElem *pEntry;
106677106945
char zErr[128];
106678106946
106679106947
UNUSED_PARAMETER(NotUsed);
106680106948
106681106949
if( zName==0 ) zName = "";
@@ -106695,10 +106963,22 @@
106695106963
}
106696106964
if( sqlite3BtreeIsInReadTrans(pDb->pBt) || sqlite3BtreeIsInBackup(pDb->pBt) ){
106697106965
sqlite3_snprintf(sizeof(zErr),zErr, "database %s is locked", zName);
106698106966
goto detach_error;
106699106967
}
106968
+
106969
+ /* If any TEMP triggers reference the schema being detached, move those
106970
+ ** triggers to reference the TEMP schema itself. */
106971
+ assert( db->aDb[1].pSchema );
106972
+ pEntry = sqliteHashFirst(&db->aDb[1].pSchema->trigHash);
106973
+ while( pEntry ){
106974
+ Trigger *pTrig = (Trigger*)sqliteHashData(pEntry);
106975
+ if( pTrig->pTabSchema==pDb->pSchema ){
106976
+ pTrig->pTabSchema = pTrig->pSchema;
106977
+ }
106978
+ pEntry = sqliteHashNext(pEntry);
106979
+ }
106700106980
106701106981
sqlite3BtreeClose(pDb->pBt);
106702106982
pDb->pBt = 0;
106703106983
pDb->pSchema = 0;
106704106984
sqlite3CollapseDatabaseArray(db);
@@ -106933,10 +107213,11 @@
106933107213
SQLITE_PRIVATE int sqlite3FixExpr(
106934107214
DbFixer *pFix, /* Context of the fixation */
106935107215
Expr *pExpr /* The expression to be fixed to one database */
106936107216
){
106937107217
while( pExpr ){
107218
+ ExprSetProperty(pExpr, EP_Indirect);
106938107219
if( pExpr->op==TK_VARIABLE ){
106939107220
if( pFix->pParse->db->init.busy ){
106940107221
pExpr->op = TK_NULL;
106941107222
}else{
106942107223
sqlite3ErrorMsg(pFix->pParse, "%s cannot use variables", pFix->zType);
@@ -107085,11 +107366,11 @@
107085107366
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
107086107367
#endif
107087107368
sqlite3_mutex_enter(db->mutex);
107088107369
db->xAuth = (sqlite3_xauth)xAuth;
107089107370
db->pAuthArg = pArg;
107090
- sqlite3ExpirePreparedStatements(db, 0);
107371
+ if( db->xAuth ) sqlite3ExpirePreparedStatements(db, 1);
107091107372
sqlite3_mutex_leave(db->mutex);
107092107373
return SQLITE_OK;
107093107374
}
107094107375
107095107376
/*
@@ -107739,11 +108020,11 @@
107739108020
#endif
107740108021
sqlite3ExprDelete(db, p->pPartIdxWhere);
107741108022
sqlite3ExprListDelete(db, p->aColExpr);
107742108023
sqlite3DbFree(db, p->zColAff);
107743108024
if( p->isResized ) sqlite3DbFree(db, (void *)p->azColl);
107744
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
108025
+#ifdef SQLITE_ENABLE_STAT4
107745108026
sqlite3_free(p->aiRowEst);
107746108027
#endif
107747108028
sqlite3DbFree(db, p);
107748108029
}
107749108030
@@ -108112,17 +108393,44 @@
108112108393
** This routine is used to check if the UTF-8 string zName is a legal
108113108394
** unqualified name for a new schema object (table, index, view or
108114108395
** trigger). All names are legal except those that begin with the string
108115108396
** "sqlite_" (in upper, lower or mixed case). This portion of the namespace
108116108397
** is reserved for internal use.
108398
+**
108399
+** When parsing the sqlite_master table, this routine also checks to
108400
+** make sure the "type", "name", and "tbl_name" columns are consistent
108401
+** with the SQL.
108117108402
*/
108118
-SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *pParse, const char *zName){
108119
- if( !pParse->db->init.busy && pParse->nested==0
108120
- && sqlite3WritableSchema(pParse->db)==0
108121
- && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
108122
- sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName);
108123
- return SQLITE_ERROR;
108403
+SQLITE_PRIVATE int sqlite3CheckObjectName(
108404
+ Parse *pParse, /* Parsing context */
108405
+ const char *zName, /* Name of the object to check */
108406
+ const char *zType, /* Type of this object */
108407
+ const char *zTblName /* Parent table name for triggers and indexes */
108408
+){
108409
+ sqlite3 *db = pParse->db;
108410
+ if( sqlite3WritableSchema(db) || db->init.imposterTable ){
108411
+ /* Skip these error checks for writable_schema=ON */
108412
+ return SQLITE_OK;
108413
+ }
108414
+ if( db->init.busy ){
108415
+ if( sqlite3_stricmp(zType, db->init.azInit[0])
108416
+ || sqlite3_stricmp(zName, db->init.azInit[1])
108417
+ || sqlite3_stricmp(zTblName, db->init.azInit[2])
108418
+ ){
108419
+ if( sqlite3Config.bExtraSchemaChecks ){
108420
+ sqlite3ErrorMsg(pParse, ""); /* corruptSchema() will supply the error */
108421
+ return SQLITE_ERROR;
108422
+ }
108423
+ }
108424
+ }else{
108425
+ if( pParse->nested==0
108426
+ && 0==sqlite3StrNICmp(zName, "sqlite_", 7)
108427
+ ){
108428
+ sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s",
108429
+ zName);
108430
+ return SQLITE_ERROR;
108431
+ }
108124108432
}
108125108433
return SQLITE_OK;
108126108434
}
108127108435
108128108436
/*
@@ -108199,11 +108507,11 @@
108199108507
sqlite3RenameTokenMap(pParse, (void*)zName, pName);
108200108508
}
108201108509
}
108202108510
pParse->sNameToken = *pName;
108203108511
if( zName==0 ) return;
108204
- if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
108512
+ if( sqlite3CheckObjectName(pParse, zName, isView?"view":"table", zName) ){
108205108513
goto begin_table_error;
108206108514
}
108207108515
if( db->init.iDb==1 ) isTemp = 1;
108208108516
#ifndef SQLITE_OMIT_AUTHORIZATION
108209108517
assert( isTemp==0 || isTemp==1 );
@@ -108699,11 +109007,11 @@
108699109007
}
108700109008
pTab->iPKey = iCol;
108701109009
pTab->keyConf = (u8)onError;
108702109010
assert( autoInc==0 || autoInc==1 );
108703109011
pTab->tabFlags |= autoInc*TF_Autoincrement;
108704
- if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder;
109012
+ if( pList ) pParse->iPkSortOrder = pList->a[0].sortFlags;
108705109013
}else if( autoInc ){
108706109014
#ifndef SQLITE_OMIT_AUTOINCREMENT
108707109015
sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
108708109016
"INTEGER PRIMARY KEY");
108709109017
#endif
@@ -109114,10 +109422,11 @@
109114109422
*/
109115109423
static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
109116109424
Index *pIdx;
109117109425
Index *pPk;
109118109426
int nPk;
109427
+ int nExtra;
109119109428
int i, j;
109120109429
sqlite3 *db = pParse->db;
109121109430
Vdbe *v = pParse->pVdbe;
109122109431
109123109432
/* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)
@@ -109149,17 +109458,18 @@
109149109458
sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
109150109459
if( pList==0 ) return;
109151109460
if( IN_RENAME_OBJECT ){
109152109461
sqlite3RenameTokenRemap(pParse, pList->a[0].pExpr, &pTab->iPKey);
109153109462
}
109154
- pList->a[0].sortOrder = pParse->iPkSortOrder;
109463
+ pList->a[0].sortFlags = pParse->iPkSortOrder;
109155109464
assert( pParse->pNewTable==pTab );
109156109465
pTab->iPKey = -1;
109157109466
sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
109158109467
SQLITE_IDXTYPE_PRIMARYKEY);
109159109468
if( db->mallocFailed || pParse->nErr ) return;
109160109469
pPk = sqlite3PrimaryKeyIndex(pTab);
109470
+ assert( pPk->nKeyCol==1 );
109161109471
}else{
109162109472
pPk = sqlite3PrimaryKeyIndex(pTab);
109163109473
assert( pPk!=0 );
109164109474
109165109475
/*
@@ -109170,19 +109480,21 @@
109170109480
for(i=j=1; i<pPk->nKeyCol; i++){
109171109481
if( isDupColumn(pPk, j, pPk, i) ){
109172109482
pPk->nColumn--;
109173109483
}else{
109174109484
testcase( hasColumn(pPk->aiColumn, j, pPk->aiColumn[i]) );
109485
+ pPk->azColl[j] = pPk->azColl[i];
109486
+ pPk->aSortOrder[j] = pPk->aSortOrder[i];
109175109487
pPk->aiColumn[j++] = pPk->aiColumn[i];
109176109488
}
109177109489
}
109178109490
pPk->nKeyCol = j;
109179109491
}
109180109492
assert( pPk!=0 );
109181109493
pPk->isCovering = 1;
109182109494
if( !db->init.imposterTable ) pPk->uniqNotNull = 1;
109183
- nPk = pPk->nKeyCol;
109495
+ nPk = pPk->nColumn = pPk->nKeyCol;
109184109496
109185109497
/* Bypass the creation of the PRIMARY KEY btree and the sqlite_master
109186109498
** table entry. This is only required if currently generating VDBE
109187109499
** code for a CREATE TABLE (not when parsing one as part of reading
109188109500
** a database schema). */
@@ -109228,25 +109540,25 @@
109228109540
assert( pIdx->nColumn>=j );
109229109541
}
109230109542
109231109543
/* Add all table columns to the PRIMARY KEY index
109232109544
*/
109233
- if( nPk<pTab->nCol ){
109234
- if( resizeIndexObject(db, pPk, pTab->nCol) ) return;
109235
- for(i=0, j=nPk; i<pTab->nCol; i++){
109236
- if( !hasColumn(pPk->aiColumn, j, i) ){
109237
- assert( j<pPk->nColumn );
109238
- pPk->aiColumn[j] = i;
109239
- pPk->azColl[j] = sqlite3StrBINARY;
109240
- j++;
109241
- }
109242
- }
109243
- assert( pPk->nColumn==j );
109244
- assert( pTab->nCol==j );
109245
- }else{
109246
- pPk->nColumn = pTab->nCol;
109247
- }
109545
+ nExtra = 0;
109546
+ for(i=0; i<pTab->nCol; i++){
109547
+ if( !hasColumn(pPk->aiColumn, nPk, i) ) nExtra++;
109548
+ }
109549
+ if( resizeIndexObject(db, pPk, nPk+nExtra) ) return;
109550
+ for(i=0, j=nPk; i<pTab->nCol; i++){
109551
+ if( !hasColumn(pPk->aiColumn, j, i) ){
109552
+ assert( j<pPk->nColumn );
109553
+ pPk->aiColumn[j] = i;
109554
+ pPk->azColl[j] = sqlite3StrBINARY;
109555
+ j++;
109556
+ }
109557
+ }
109558
+ assert( pPk->nColumn==j );
109559
+ assert( pTab->nCol<=j );
109248109560
recomputeColumnsNotIndexed(pPk);
109249109561
}
109250109562
109251109563
#ifndef SQLITE_OMIT_VIRTUALTABLE
109252109564
/*
@@ -109439,11 +109751,11 @@
109439109751
sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);
109440109752
pParse->nTab = 2;
109441109753
addrTop = sqlite3VdbeCurrentAddr(v) + 1;
109442109754
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
109443109755
if( pParse->nErr ) return;
109444
- pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect);
109756
+ pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect, SQLITE_AFF_BLOB);
109445109757
if( pSelTab==0 ) return;
109446109758
assert( p->aCol==0 );
109447109759
p->nCol = pSelTab->nCol;
109448109760
p->aCol = pSelTab->aCol;
109449109761
pSelTab->nCol = 0;
@@ -109703,14 +110015,14 @@
109703110015
pTable->nCol = -1;
109704110016
db->lookaside.bDisable++;
109705110017
#ifndef SQLITE_OMIT_AUTHORIZATION
109706110018
xAuth = db->xAuth;
109707110019
db->xAuth = 0;
109708
- pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
110020
+ pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE);
109709110021
db->xAuth = xAuth;
109710110022
#else
109711
- pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
110023
+ pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE);
109712110024
#endif
109713110025
pParse->nTab = n;
109714110026
if( pTable->pCheck ){
109715110027
/* CREATE VIEW name(arglist) AS ...
109716110028
** The names of the columns in the table are taken from
@@ -109722,11 +110034,12 @@
109722110034
&pTable->nCol, &pTable->aCol);
109723110035
if( db->mallocFailed==0
109724110036
&& pParse->nErr==0
109725110037
&& pTable->nCol==pSel->pEList->nExpr
109726110038
){
109727
- sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel);
110039
+ sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel,
110040
+ SQLITE_AFF_NONE);
109728110041
}
109729110042
}else if( pSelTab ){
109730110043
/* CREATE VIEW name AS... without an argument list. Construct
109731110044
** the column names from the SELECT statement that defines the view.
109732110045
*/
@@ -110403,10 +110716,31 @@
110403110716
p->nKeyCol = nCol - 1;
110404110717
*ppExtra = ((char*)p) + nByte;
110405110718
}
110406110719
return p;
110407110720
}
110721
+
110722
+/*
110723
+** If expression list pList contains an expression that was parsed with
110724
+** an explicit "NULLS FIRST" or "NULLS LAST" clause, leave an error in
110725
+** pParse and return non-zero. Otherwise, return zero.
110726
+*/
110727
+SQLITE_PRIVATE int sqlite3HasExplicitNulls(Parse *pParse, ExprList *pList){
110728
+ if( pList ){
110729
+ int i;
110730
+ for(i=0; i<pList->nExpr; i++){
110731
+ if( pList->a[i].bNulls ){
110732
+ u8 sf = pList->a[i].sortFlags;
110733
+ sqlite3ErrorMsg(pParse, "unsupported use of NULLS %s",
110734
+ (sf==0 || sf==3) ? "FIRST" : "LAST"
110735
+ );
110736
+ return 1;
110737
+ }
110738
+ }
110739
+ }
110740
+ return 0;
110741
+}
110408110742
110409110743
/*
110410110744
** Create a new index for an SQL table. pName1.pName2 is the name of the index
110411110745
** and pTblList is the name of the table that is to be indexed. Both will
110412110746
** be NULL for a primary key or an index that is created to satisfy a
@@ -110454,10 +110788,13 @@
110454110788
if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
110455110789
goto exit_create_index;
110456110790
}
110457110791
if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
110458110792
goto exit_create_index;
110793
+ }
110794
+ if( sqlite3HasExplicitNulls(pParse, pList) ){
110795
+ goto exit_create_index;
110459110796
}
110460110797
110461110798
/*
110462110799
** Find the table that is to be indexed. Return early if not found.
110463110800
*/
@@ -110553,11 +110890,11 @@
110553110890
*/
110554110891
if( pName ){
110555110892
zName = sqlite3NameFromToken(db, pName);
110556110893
if( zName==0 ) goto exit_create_index;
110557110894
assert( pName->z!=0 );
110558
- if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
110895
+ if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName,"index",pTab->zName) ){
110559110896
goto exit_create_index;
110560110897
}
110561110898
if( !IN_RENAME_OBJECT ){
110562110899
if( !db->init.busy ){
110563110900
if( sqlite3FindTable(db, zName, 0)!=0 ){
@@ -110619,11 +110956,11 @@
110619110956
sqlite3TokenInit(&prevCol, pCol->zName);
110620110957
pList = sqlite3ExprListAppend(pParse, 0,
110621110958
sqlite3ExprAlloc(db, TK_ID, &prevCol, 0));
110622110959
if( pList==0 ) goto exit_create_index;
110623110960
assert( pList->nExpr==1 );
110624
- sqlite3ExprListSetSortOrder(pList, sortOrder);
110961
+ sqlite3ExprListSetSortOrder(pList, sortOrder, SQLITE_SO_UNDEFINED);
110625110962
}else{
110626110963
sqlite3ExprListCheckLength(pParse, pList, "index");
110627110964
if( pParse->nErr ) goto exit_create_index;
110628110965
}
110629110966
@@ -110737,11 +111074,11 @@
110737111074
if( !zColl ) zColl = sqlite3StrBINARY;
110738111075
if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){
110739111076
goto exit_create_index;
110740111077
}
110741111078
pIndex->azColl[i] = zColl;
110742
- requestedSortOrder = pListItem->sortOrder & sortOrderMask;
111079
+ requestedSortOrder = pListItem->sortFlags & sortOrderMask;
110743111080
pIndex->aSortOrder[i] = (u8)requestedSortOrder;
110744111081
}
110745111082
110746111083
/* Append the table key to the end of the index. For WITHOUT ROWID
110747111084
** tables (when pPk!=0) this will be the declared PRIMARY KEY. For
@@ -110912,10 +111249,11 @@
110912111249
sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY);
110913111250
110914111251
/* Gather the complete text of the CREATE INDEX statement into
110915111252
** the zStmt variable
110916111253
*/
111254
+ assert( pName!=0 || pStart==0 );
110917111255
if( pStart ){
110918111256
int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
110919111257
if( pName->z[n-1]==';' ) n--;
110920111258
/* A named index with an explicit CREATE INDEX statement */
110921111259
zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
@@ -111954,11 +112292,12 @@
111954112292
assert( sqlite3KeyInfoIsWriteable(pKey) );
111955112293
for(i=0; i<nCol; i++){
111956112294
const char *zColl = pIdx->azColl[i];
111957112295
pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
111958112296
sqlite3LocateCollSeq(pParse, zColl);
111959
- pKey->aSortOrder[i] = pIdx->aSortOrder[i];
112297
+ pKey->aSortFlags[i] = pIdx->aSortOrder[i];
112298
+ assert( 0==(pKey->aSortFlags[i] & KEYINFO_ORDER_BIGNULL) );
111960112299
}
111961112300
if( pParse->nErr ){
111962112301
assert( pParse->rc==SQLITE_ERROR_MISSING_COLLSEQ );
111963112302
if( pIdx->bNoQuery==0 ){
111964112303
/* Deactivate the index because it contains an unknown collating
@@ -115493,13 +115832,10 @@
115493115832
};
115494115833
#ifndef SQLITE_OMIT_ALTERTABLE
115495115834
sqlite3AlterFunctions();
115496115835
#endif
115497115836
sqlite3WindowFunctions();
115498
-#if defined(SQLITE_ENABLE_STAT3) || defined(SQLITE_ENABLE_STAT4)
115499
- sqlite3AnalyzeFunctions();
115500
-#endif
115501115837
sqlite3RegisterDateTimeFunctions();
115502115838
sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));
115503115839
115504115840
#if 0 /* Enable to print out how the built-in functions are hashed */
115505115841
{
@@ -115998,17 +116334,17 @@
115998116334
pExpr = sqlite3Expr(db, TK_REGISTER, 0);
115999116335
if( pExpr ){
116000116336
if( iCol>=0 && iCol!=pTab->iPKey ){
116001116337
pCol = &pTab->aCol[iCol];
116002116338
pExpr->iTable = regBase + iCol + 1;
116003
- pExpr->affinity = pCol->affinity;
116339
+ pExpr->affExpr = pCol->affinity;
116004116340
zColl = pCol->zColl;
116005116341
if( zColl==0 ) zColl = db->pDfltColl->zName;
116006116342
pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl);
116007116343
}else{
116008116344
pExpr->iTable = regBase;
116009
- pExpr->affinity = SQLITE_AFF_INTEGER;
116345
+ pExpr->affExpr = SQLITE_AFF_INTEGER;
116010116346
}
116011116347
}
116012116348
return pExpr;
116013116349
}
116014116350
@@ -116807,11 +117143,11 @@
116807117143
116808117144
tFrom.z = zFrom;
116809117145
tFrom.n = nFrom;
116810117146
pRaise = sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed");
116811117147
if( pRaise ){
116812
- pRaise->affinity = OE_Abort;
117148
+ pRaise->affExpr = OE_Abort;
116813117149
}
116814117150
pSelect = sqlite3SelectNew(pParse,
116815117151
sqlite3ExprListAppend(pParse, 0, pRaise),
116816117152
sqlite3SrcListAppend(pParse, 0, &tFrom, 0),
116817117153
pWhere,
@@ -116852,10 +117188,11 @@
116852117188
if( db->mallocFailed==1 ){
116853117189
fkTriggerDelete(db, pTrigger);
116854117190
return 0;
116855117191
}
116856117192
assert( pStep!=0 );
117193
+ assert( pTrigger!=0 );
116857117194
116858117195
switch( action ){
116859117196
case OE_Restrict:
116860117197
pStep->op = TK_SELECT;
116861117198
break;
@@ -117042,22 +117379,23 @@
117042117379
sqlite3OomFault(db);
117043117380
return 0;
117044117381
}
117045117382
for(n=0; n<pIdx->nColumn; n++){
117046117383
i16 x = pIdx->aiColumn[n];
117384
+ char aff;
117047117385
if( x>=0 ){
117048
- pIdx->zColAff[n] = pTab->aCol[x].affinity;
117386
+ aff = pTab->aCol[x].affinity;
117049117387
}else if( x==XN_ROWID ){
117050
- pIdx->zColAff[n] = SQLITE_AFF_INTEGER;
117388
+ aff = SQLITE_AFF_INTEGER;
117051117389
}else{
117052
- char aff;
117053117390
assert( x==XN_EXPR );
117054117391
assert( pIdx->aColExpr!=0 );
117055117392
aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);
117056
- if( aff==0 ) aff = SQLITE_AFF_BLOB;
117057
- pIdx->zColAff[n] = aff;
117058117393
}
117394
+ if( aff<SQLITE_AFF_BLOB ) aff = SQLITE_AFF_BLOB;
117395
+ if( aff>SQLITE_AFF_NUMERIC) aff = SQLITE_AFF_NUMERIC;
117396
+ pIdx->zColAff[n] = aff;
117059117397
}
117060117398
pIdx->zColAff[n] = 0;
117061117399
}
117062117400
117063117401
return pIdx->zColAff;
@@ -117093,15 +117431,16 @@
117093117431
sqlite3OomFault(db);
117094117432
return;
117095117433
}
117096117434
117097117435
for(i=0; i<pTab->nCol; i++){
117436
+ assert( pTab->aCol[i].affinity!=0 );
117098117437
zColAff[i] = pTab->aCol[i].affinity;
117099117438
}
117100117439
do{
117101117440
zColAff[i--] = 0;
117102
- }while( i>=0 && zColAff[i]==SQLITE_AFF_BLOB );
117441
+ }while( i>=0 && zColAff[i]<=SQLITE_AFF_BLOB );
117103117442
pTab->zColAff = zColAff;
117104117443
}
117105117444
assert( zColAff!=0 );
117106117445
i = sqlite3Strlen30NN(zColAff);
117107117446
if( i ){
@@ -117785,10 +118124,13 @@
117785118124
if( pUpsert ){
117786118125
if( IsVirtual(pTab) ){
117787118126
sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"",
117788118127
pTab->zName);
117789118128
goto insert_cleanup;
118129
+ }
118130
+ if( sqlite3HasExplicitNulls(pParse, pUpsert->pUpsertTarget) ){
118131
+ goto insert_cleanup;
117790118132
}
117791118133
pTabList->a[0].iCursor = iDataCur;
117792118134
pUpsert->pUpsertSrc = pTabList;
117793118135
pUpsert->regData = regData;
117794118136
pUpsert->iDataCur = iDataCur;
@@ -119899,10 +120241,12 @@
119899120241
/* Version 3.26.0 and later */
119900120242
const char *(*normalized_sql)(sqlite3_stmt*);
119901120243
/* Version 3.28.0 and later */
119902120244
int (*stmt_isexplain)(sqlite3_stmt*);
119903120245
int (*value_frombind)(sqlite3_value*);
120246
+ /* Version 3.30.0 and later */
120247
+ int (*drop_modules)(sqlite3*,const char**);
119904120248
};
119905120249
119906120250
/*
119907120251
** This is the function signature used for all extension entry points. It
119908120252
** is also defined in the file "loadext.c".
@@ -120191,10 +120535,12 @@
120191120535
/* Version 3.26.0 and later */
120192120536
#define sqlite3_normalized_sql sqlite3_api->normalized_sql
120193120537
/* Version 3.28.0 and later */
120194120538
#define sqlite3_stmt_isexplain sqlite3_api->isexplain
120195120539
#define sqlite3_value_frombind sqlite3_api->frombind
120540
+/* Version 3.30.0 and later */
120541
+#define sqlite3_drop_modules sqlite3_api->drop_modules
120196120542
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
120197120543
120198120544
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
120199120545
/* This case when the file really is being compiled as a loadable
120200120546
** extension */
@@ -120656,11 +121002,13 @@
120656121002
#else
120657121003
0,
120658121004
#endif
120659121005
/* Version 3.28.0 and later */
120660121006
sqlite3_stmt_isexplain,
120661
- sqlite3_value_frombind
121007
+ sqlite3_value_frombind,
121008
+ /* Version 3.30.0 and later */
121009
+ sqlite3_drop_modules,
120662121010
};
120663121011
120664121012
/*
120665121013
** Attempt to load an SQLite extension library contained in the file
120666121014
** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -121369,11 +121717,11 @@
121369121717
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121370121718
/* ColNames: */ 0, 0,
121371121719
/* iArg: */ SQLITE_FullFSync },
121372121720
#endif
121373121721
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
121374
-#if defined(SQLITE_INTROSPECTION_PRAGMAS)
121722
+#if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
121375121723
{/* zName: */ "function_list",
121376121724
/* ePragTyp: */ PragTyp_FUNCTION_LIST,
121377121725
/* ePragFlg: */ PragFlg_Result0,
121378121726
/* ColNames: */ 41, 2,
121379121727
/* iArg: */ 0 },
@@ -121493,11 +121841,11 @@
121493121841
/* ColNames: */ 0, 0,
121494121842
/* iArg: */ 0 },
121495121843
#endif
121496121844
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
121497121845
#if !defined(SQLITE_OMIT_VIRTUALTABLE)
121498
-#if defined(SQLITE_INTROSPECTION_PRAGMAS)
121846
+#if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
121499121847
{/* zName: */ "module_list",
121500121848
/* ePragTyp: */ PragTyp_MODULE_LIST,
121501121849
/* ePragFlg: */ PragFlg_Result0,
121502121850
/* ColNames: */ 9, 1,
121503121851
/* iArg: */ 0 },
@@ -121528,11 +121876,11 @@
121528121876
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121529121877
/* ColNames: */ 0, 0,
121530121878
/* iArg: */ SQLITE_ParserTrace },
121531121879
#endif
121532121880
#endif
121533
-#if defined(SQLITE_INTROSPECTION_PRAGMAS)
121881
+#if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
121534121882
{/* zName: */ "pragma_list",
121535121883
/* ePragTyp: */ PragTyp_PRAGMA_LIST,
121536121884
/* ePragFlg: */ PragFlg_Result0,
121537121885
/* ColNames: */ 9, 1,
121538121886
/* iArg: */ 0 },
@@ -121726,11 +122074,11 @@
121726122074
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121727122075
/* ColNames: */ 0, 0,
121728122076
/* iArg: */ SQLITE_WriteSchema|SQLITE_NoSchemaError },
121729122077
#endif
121730122078
};
121731
-/* Number of pragmas: 62 on by default, 81 total. */
122079
+/* Number of pragmas: 65 on by default, 81 total. */
121732122080
121733122081
/************** End of pragma.h **********************************************/
121734122082
/************** Continuing where we left off in pragma.c *********************/
121735122083
121736122084
/*
@@ -122858,10 +123206,19 @@
122858123206
122859123207
case PragTyp_INDEX_INFO: if( zRight ){
122860123208
Index *pIdx;
122861123209
Table *pTab;
122862123210
pIdx = sqlite3FindIndex(db, zRight, zDb);
123211
+ if( pIdx==0 ){
123212
+ /* If there is no index named zRight, check to see if there is a
123213
+ ** WITHOUT ROWID table named zRight, and if there is, show the
123214
+ ** structure of the PRIMARY KEY index for that table. */
123215
+ pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);
123216
+ if( pTab && !HasRowid(pTab) ){
123217
+ pIdx = sqlite3PrimaryKeyIndex(pTab);
123218
+ }
123219
+ }
122863123220
if( pIdx ){
122864123221
int iIdxDb = sqlite3SchemaToIndex(db, pIdx->pSchema);
122865123222
int i;
122866123223
int mx;
122867123224
if( pPragma->iArg ){
@@ -122937,11 +123294,11 @@
122937123294
sqlite3VdbeMultiLoad(v, 1, "is", i++, pColl->zName);
122938123295
}
122939123296
}
122940123297
break;
122941123298
122942
-#ifdef SQLITE_INTROSPECTION_PRAGMAS
123299
+#ifndef SQLITE_OMIT_INTROSPECTION_PRAGMAS
122943123300
case PragTyp_FUNCTION_LIST: {
122944123301
int i;
122945123302
HashElem *j;
122946123303
FuncDef *p;
122947123304
pParse->nMem = 2;
@@ -124272,35 +124629,37 @@
124272124629
** database. See sqlite3Init() below for additional information.
124273124630
** This routine is also called from the OP_ParseSchema opcode of the VDBE.
124274124631
**
124275124632
** Each callback contains the following information:
124276124633
**
124277
-** argv[0] = name of thing being created
124278
-** argv[1] = root page number for table or index. 0 for trigger or view.
124279
-** argv[2] = SQL text for the CREATE statement.
124634
+** argv[0] = type of object: "table", "index", "trigger", or "view".
124635
+** argv[1] = name of thing being created
124636
+** argv[2] = associated table if an index or trigger
124637
+** argv[3] = root page number for table or index. 0 for trigger or view.
124638
+** argv[4] = SQL text for the CREATE statement.
124280124639
**
124281124640
*/
124282124641
SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){
124283124642
InitData *pData = (InitData*)pInit;
124284124643
sqlite3 *db = pData->db;
124285124644
int iDb = pData->iDb;
124286124645
124287
- assert( argc==3 );
124646
+ assert( argc==5 );
124288124647
UNUSED_PARAMETER2(NotUsed, argc);
124289124648
assert( sqlite3_mutex_held(db->mutex) );
124290124649
DbClearProperty(db, iDb, DB_Empty);
124291124650
pData->nInitRow++;
124292124651
if( db->mallocFailed ){
124293
- corruptSchema(pData, argv[0], 0);
124652
+ corruptSchema(pData, argv[1], 0);
124294124653
return 1;
124295124654
}
124296124655
124297124656
assert( iDb>=0 && iDb<db->nDb );
124298124657
if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */
124299
- if( argv[1]==0 ){
124300
- corruptSchema(pData, argv[0], 0);
124301
- }else if( sqlite3_strnicmp(argv[2],"create ",7)==0 ){
124658
+ if( argv[3]==0 ){
124659
+ corruptSchema(pData, argv[1], 0);
124660
+ }else if( sqlite3_strnicmp(argv[4],"create ",7)==0 ){
124302124661
/* Call the parser to process a CREATE TABLE, INDEX or VIEW.
124303124662
** But because db->init.busy is set to 1, no VDBE code is generated
124304124663
** or executed. All the parser does is build the internal data
124305124664
** structures that describe the table, index, or view.
124306124665
*/
@@ -124309,47 +124668,48 @@
124309124668
sqlite3_stmt *pStmt;
124310124669
TESTONLY(int rcp); /* Return code from sqlite3_prepare() */
124311124670
124312124671
assert( db->init.busy );
124313124672
db->init.iDb = iDb;
124314
- db->init.newTnum = sqlite3Atoi(argv[1]);
124673
+ db->init.newTnum = sqlite3Atoi(argv[3]);
124315124674
db->init.orphanTrigger = 0;
124316
- TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);
124675
+ db->init.azInit = argv;
124676
+ TESTONLY(rcp = ) sqlite3_prepare(db, argv[4], -1, &pStmt, 0);
124317124677
rc = db->errCode;
124318124678
assert( (rc&0xFF)==(rcp&0xFF) );
124319124679
db->init.iDb = saved_iDb;
124320124680
/* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */
124321124681
if( SQLITE_OK!=rc ){
124322124682
if( db->init.orphanTrigger ){
124323124683
assert( iDb==1 );
124324124684
}else{
124325
- pData->rc = rc;
124685
+ if( rc > pData->rc ) pData->rc = rc;
124326124686
if( rc==SQLITE_NOMEM ){
124327124687
sqlite3OomFault(db);
124328124688
}else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){
124329
- corruptSchema(pData, argv[0], sqlite3_errmsg(db));
124689
+ corruptSchema(pData, argv[1], sqlite3_errmsg(db));
124330124690
}
124331124691
}
124332124692
}
124333124693
sqlite3_finalize(pStmt);
124334
- }else if( argv[0]==0 || (argv[2]!=0 && argv[2][0]!=0) ){
124335
- corruptSchema(pData, argv[0], 0);
124694
+ }else if( argv[1]==0 || (argv[4]!=0 && argv[4][0]!=0) ){
124695
+ corruptSchema(pData, argv[1], 0);
124336124696
}else{
124337124697
/* If the SQL column is blank it means this is an index that
124338124698
** was created to be the PRIMARY KEY or to fulfill a UNIQUE
124339124699
** constraint for a CREATE TABLE. The index should have already
124340124700
** been created when we processed the CREATE TABLE. All we have
124341124701
** to do here is record the root page number for that index.
124342124702
*/
124343124703
Index *pIndex;
124344
- pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zDbSName);
124704
+ pIndex = sqlite3FindIndex(db, argv[1], db->aDb[iDb].zDbSName);
124345124705
if( pIndex==0
124346
- || sqlite3GetInt32(argv[1],&pIndex->tnum)==0
124706
+ || sqlite3GetInt32(argv[3],&pIndex->tnum)==0
124347124707
|| pIndex->tnum<2
124348124708
|| sqlite3IndexHasDuplicateRootPage(pIndex)
124349124709
){
124350
- corruptSchema(pData, argv[0], pIndex?"invalid rootpage":"orphan index");
124710
+ corruptSchema(pData, argv[1], pIndex?"invalid rootpage":"orphan index");
124351124711
}
124352124712
}
124353124713
return 0;
124354124714
}
124355124715
@@ -124366,11 +124726,11 @@
124366124726
int i;
124367124727
#ifndef SQLITE_OMIT_DEPRECATED
124368124728
int size;
124369124729
#endif
124370124730
Db *pDb;
124371
- char const *azArg[4];
124731
+ char const *azArg[6];
124372124732
int meta[5];
124373124733
InitData initData;
124374124734
const char *zMasterName;
124375124735
int openedTransaction = 0;
124376124736
@@ -124385,22 +124745,24 @@
124385124745
/* Construct the in-memory representation schema tables (sqlite_master or
124386124746
** sqlite_temp_master) by invoking the parser directly. The appropriate
124387124747
** table name will be inserted automatically by the parser so we can just
124388124748
** use the abbreviation "x" here. The parser will also automatically tag
124389124749
** the schema table as read-only. */
124390
- azArg[0] = zMasterName = SCHEMA_TABLE(iDb);
124391
- azArg[1] = "1";
124392
- azArg[2] = "CREATE TABLE x(type text,name text,tbl_name text,"
124750
+ azArg[0] = "table";
124751
+ azArg[1] = zMasterName = SCHEMA_TABLE(iDb);
124752
+ azArg[2] = azArg[1];
124753
+ azArg[3] = "1";
124754
+ azArg[4] = "CREATE TABLE x(type text,name text,tbl_name text,"
124393124755
"rootpage int,sql text)";
124394
- azArg[3] = 0;
124756
+ azArg[5] = 0;
124395124757
initData.db = db;
124396124758
initData.iDb = iDb;
124397124759
initData.rc = SQLITE_OK;
124398124760
initData.pzErrMsg = pzErrMsg;
124399124761
initData.mInitFlags = mFlags;
124400124762
initData.nInitRow = 0;
124401
- sqlite3InitCallback(&initData, 3, (char **)azArg, 0);
124763
+ sqlite3InitCallback(&initData, 5, (char **)azArg, 0);
124402124764
if( initData.rc ){
124403124765
rc = initData.rc;
124404124766
goto error_out;
124405124767
}
124406124768
@@ -124522,11 +124884,11 @@
124522124884
*/
124523124885
assert( db->init.busy );
124524124886
{
124525124887
char *zSql;
124526124888
zSql = sqlite3MPrintf(db,
124527
- "SELECT name, rootpage, sql FROM \"%w\".%s ORDER BY rowid",
124889
+ "SELECT*FROM\"%w\".%s ORDER BY rowid",
124528124890
db->aDb[iDb].zDbSName, zMasterName);
124529124891
#ifndef SQLITE_OMIT_AUTHORIZATION
124530124892
{
124531124893
sqlite3_xauth xAuth;
124532124894
xAuth = db->xAuth;
@@ -124843,11 +125205,14 @@
124843125205
*pzTail = sParse.zTail;
124844125206
}
124845125207
rc = sParse.rc;
124846125208
124847125209
#ifndef SQLITE_OMIT_EXPLAIN
124848
- if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){
125210
+ /* Justification for the ALWAYS(): The only way for rc to be SQLITE_OK and
125211
+ ** sParse.pVdbe to be NULL is if the input SQL is an empty string, but in
125212
+ ** that case, sParse.explain will be false. */
125213
+ if( sParse.explain && rc==SQLITE_OK && ALWAYS(sParse.pVdbe) ){
124849125214
static const char * const azColName[] = {
124850125215
"addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment",
124851125216
"id", "parent", "notused", "detail"
124852125217
};
124853125218
int iFirst, mx;
@@ -124868,12 +125233,12 @@
124868125233
#endif
124869125234
124870125235
if( db->init.busy==0 ){
124871125236
sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);
124872125237
}
124873
- if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){
124874
- sqlite3VdbeFinalize(sParse.pVdbe);
125238
+ if( rc!=SQLITE_OK || db->mallocFailed ){
125239
+ if( sParse.pVdbe ) sqlite3VdbeFinalize(sParse.pVdbe);
124875125240
assert(!(*ppStmt));
124876125241
}else{
124877125242
*ppStmt = (sqlite3_stmt*)sParse.pVdbe;
124878125243
}
124879125244
@@ -125242,10 +125607,11 @@
125242125607
if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){
125243125608
sqlite3WindowListDelete(db, p->pWinDefn);
125244125609
}
125245125610
#endif
125246125611
if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);
125612
+ assert( p->pWin==0 );
125247125613
if( bFree ) sqlite3DbFreeNN(db, p);
125248125614
p = pPrior;
125249125615
bFree = 1;
125250125616
}
125251125617
}
@@ -125803,11 +126169,11 @@
125803126169
sqlite3VdbeAddOp3(v, OP_Compare, regPrevKey, regBase, pSort->nOBSat);
125804126170
pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);
125805126171
if( pParse->db->mallocFailed ) return;
125806126172
pOp->p2 = nKey + nData;
125807126173
pKI = pOp->p4.pKeyInfo;
125808
- memset(pKI->aSortOrder, 0, pKI->nKeyField); /* Makes OP_Jump testable */
126174
+ memset(pKI->aSortFlags, 0, pKI->nKeyField); /* Makes OP_Jump testable */
125809126175
sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
125810126176
testcase( pKI->nAllField > pKI->nKeyField+2 );
125811126177
pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat,
125812126178
pKI->nAllField-pKI->nKeyField-1);
125813126179
addrJmp = sqlite3VdbeCurrentAddr(v);
@@ -126414,11 +126780,11 @@
126414126780
*/
126415126781
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
126416126782
int nExtra = (N+X)*(sizeof(CollSeq*)+1) - sizeof(CollSeq*);
126417126783
KeyInfo *p = sqlite3DbMallocRawNN(db, sizeof(KeyInfo) + nExtra);
126418126784
if( p ){
126419
- p->aSortOrder = (u8*)&p->aColl[N+X];
126785
+ p->aSortFlags = (u8*)&p->aColl[N+X];
126420126786
p->nKeyField = (u16)N;
126421126787
p->nAllField = (u16)(N+X);
126422126788
p->enc = ENC(db);
126423126789
p->db = db;
126424126790
p->nRef = 1;
@@ -126491,11 +126857,11 @@
126491126857
pInfo = sqlite3KeyInfoAlloc(db, nExpr-iStart, nExtra+1);
126492126858
if( pInfo ){
126493126859
assert( sqlite3KeyInfoIsWriteable(pInfo) );
126494126860
for(i=iStart, pItem=pList->a+iStart; i<nExpr; i++, pItem++){
126495126861
pInfo->aColl[i-iStart] = sqlite3ExprNNCollSeq(pParse, pItem->pExpr);
126496
- pInfo->aSortOrder[i-iStart] = pItem->sortOrder;
126862
+ pInfo->aSortFlags[i-iStart] = pItem->sortFlags;
126497126863
}
126498126864
}
126499126865
return pInfo;
126500126866
}
126501126867
@@ -126783,12 +127149,10 @@
126783127149
char const *zOrigCol = 0;
126784127150
#endif
126785127151
126786127152
assert( pExpr!=0 );
126787127153
assert( pNC->pSrcList!=0 );
126788
- assert( pExpr->op!=TK_AGG_COLUMN ); /* This routine runes before aggregates
126789
- ** are processed */
126790127154
switch( pExpr->op ){
126791127155
case TK_COLUMN: {
126792127156
/* The expression is a column. Locate the table the column is being
126793127157
** extracted from in NameContext.pSrcList. This table may be real
126794127158
** database table or a subquery.
@@ -127101,16 +127465,15 @@
127101127465
/* Get an appropriate name for the column
127102127466
*/
127103127467
if( (zName = pEList->a[i].zName)!=0 ){
127104127468
/* If the column contains an "AS <name>" phrase, use <name> as the name */
127105127469
}else{
127106
- Expr *pColExpr = sqlite3ExprSkipCollate(pEList->a[i].pExpr);
127470
+ Expr *pColExpr = sqlite3ExprSkipCollateAndLikely(pEList->a[i].pExpr);
127107127471
while( pColExpr->op==TK_DOT ){
127108127472
pColExpr = pColExpr->pRight;
127109127473
assert( pColExpr!=0 );
127110127474
}
127111
- assert( pColExpr->op!=TK_AGG_COLUMN );
127112127475
if( pColExpr->op==TK_COLUMN ){
127113127476
/* For columns use the column name name */
127114127477
int iCol = pColExpr->iColumn;
127115127478
Table *pTab = pColExpr->y.pTab;
127116127479
assert( pTab!=0 );
@@ -127174,11 +127537,12 @@
127174127537
** statement be resolved.
127175127538
*/
127176127539
SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(
127177127540
Parse *pParse, /* Parsing contexts */
127178127541
Table *pTab, /* Add column type information to this table */
127179
- Select *pSelect /* SELECT used to determine types and collations */
127542
+ Select *pSelect, /* SELECT used to determine types and collations */
127543
+ char aff /* Default affinity for columns */
127180127544
){
127181127545
sqlite3 *db = pParse->db;
127182127546
NameContext sNC;
127183127547
Column *pCol;
127184127548
CollSeq *pColl;
@@ -127207,11 +127571,11 @@
127207127571
if( pCol->zName ){
127208127572
memcpy(&pCol->zName[n+1], zType, m+1);
127209127573
pCol->colFlags |= COLFLAG_HASTYPE;
127210127574
}
127211127575
}
127212
- if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_BLOB;
127576
+ if( pCol->affinity<=SQLITE_AFF_NONE ) pCol->affinity = aff;
127213127577
pColl = sqlite3ExprCollSeq(pParse, p);
127214127578
if( pColl && pCol->zColl==0 ){
127215127579
pCol->zColl = sqlite3DbStrDup(db, pColl->zName);
127216127580
}
127217127581
}
@@ -127220,11 +127584,11 @@
127220127584
127221127585
/*
127222127586
** Given a SELECT statement, generate a Table structure that describes
127223127587
** the result set of that SELECT.
127224127588
*/
127225
-SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
127589
+SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect, char aff){
127226127590
Table *pTab;
127227127591
sqlite3 *db = pParse->db;
127228127592
u64 savedFlags;
127229127593
127230127594
savedFlags = db->flags;
@@ -127240,11 +127604,11 @@
127240127604
}
127241127605
pTab->nTabRef = 1;
127242127606
pTab->zName = 0;
127243127607
pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
127244127608
sqlite3ColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);
127245
- sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSelect);
127609
+ sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSelect, aff);
127246127610
pTab->iPKey = -1;
127247127611
if( db->mallocFailed ){
127248127612
sqlite3DeleteTable(db, pTab);
127249127613
return 0;
127250127614
}
@@ -127394,11 +127758,11 @@
127394127758
pOrderBy->a[i].pExpr =
127395127759
sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);
127396127760
}
127397127761
assert( sqlite3KeyInfoIsWriteable(pRet) );
127398127762
pRet->aColl[i] = pColl;
127399
- pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder;
127763
+ pRet->aSortFlags[i] = pOrderBy->a[i].sortFlags;
127400127764
}
127401127765
}
127402127766
127403127767
return pRet;
127404127768
}
@@ -128105,15 +128469,18 @@
128105128469
break;
128106128470
}
128107128471
128108128472
/* If this is a scalar select that is part of an expression, then
128109128473
** store the results in the appropriate memory cell and break out
128110
- ** of the scan loop.
128474
+ ** of the scan loop. Note that the select might return multiple columns
128475
+ ** if it is the RHS of a row-value IN operator.
128111128476
*/
128112128477
case SRT_Mem: {
128113
- assert( pIn->nSdst==1 || pParse->nErr>0 ); testcase( pIn->nSdst!=1 );
128114
- sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);
128478
+ if( pParse->nErr==0 ){
128479
+ testcase( pIn->nSdst>1 );
128480
+ sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, pIn->nSdst);
128481
+ }
128115128482
/* The LIMIT clause will jump out of the loop for us */
128116128483
break;
128117128484
}
128118128485
#endif /* #ifndef SQLITE_OMIT_SUBQUERY */
128119128486
@@ -128366,11 +128733,11 @@
128366128733
pKeyDup = sqlite3KeyInfoAlloc(db, nExpr, 1);
128367128734
if( pKeyDup ){
128368128735
assert( sqlite3KeyInfoIsWriteable(pKeyDup) );
128369128736
for(i=0; i<nExpr; i++){
128370128737
pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
128371
- pKeyDup->aSortOrder[i] = 0;
128738
+ pKeyDup->aSortFlags[i] = 0;
128372128739
}
128373128740
}
128374128741
}
128375128742
128376128743
/* Separate the left and the right query from one another
@@ -129089,10 +129456,11 @@
129089129456
** elements we are now copying in.
129090129457
*/
129091129458
for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){
129092129459
int nSubSrc;
129093129460
u8 jointype = 0;
129461
+ assert( pSub!=0 );
129094129462
pSubSrc = pSub->pSrc; /* FROM clause of subquery */
129095129463
nSubSrc = pSubSrc->nSrc; /* Number of terms in subquery FROM clause */
129096129464
pSrc = pParent->pSrc; /* FROM clause of the outer query */
129097129465
129098129466
if( pSrc ){
@@ -129539,28 +129907,31 @@
129539129907
static u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){
129540129908
int eRet = WHERE_ORDERBY_NORMAL; /* Return value */
129541129909
ExprList *pEList = pFunc->x.pList; /* Arguments to agg function */
129542129910
const char *zFunc; /* Name of aggregate function pFunc */
129543129911
ExprList *pOrderBy;
129544
- u8 sortOrder;
129912
+ u8 sortFlags;
129545129913
129546129914
assert( *ppMinMax==0 );
129547129915
assert( pFunc->op==TK_AGG_FUNCTION );
129548
- if( pEList==0 || pEList->nExpr!=1 ) return eRet;
129916
+ assert( !IsWindowFunc(pFunc) );
129917
+ if( pEList==0 || pEList->nExpr!=1 || ExprHasProperty(pFunc, EP_WinFunc) ){
129918
+ return eRet;
129919
+ }
129549129920
zFunc = pFunc->u.zToken;
129550129921
if( sqlite3StrICmp(zFunc, "min")==0 ){
129551129922
eRet = WHERE_ORDERBY_MIN;
129552
- sortOrder = SQLITE_SO_ASC;
129923
+ sortFlags = KEYINFO_ORDER_BIGNULL;
129553129924
}else if( sqlite3StrICmp(zFunc, "max")==0 ){
129554129925
eRet = WHERE_ORDERBY_MAX;
129555
- sortOrder = SQLITE_SO_DESC;
129926
+ sortFlags = KEYINFO_ORDER_DESC;
129556129927
}else{
129557129928
return eRet;
129558129929
}
129559129930
*ppMinMax = pOrderBy = sqlite3ExprListDup(db, pEList, 0);
129560129931
assert( pOrderBy!=0 || db->mallocFailed );
129561
- if( pOrderBy ) pOrderBy->a[0].sortOrder = sortOrder;
129932
+ if( pOrderBy ) pOrderBy->a[0].sortFlags = sortFlags;
129562129933
return eRet;
129563129934
}
129564129935
129565129936
/*
129566129937
** The select statement passed as the first argument is an aggregate query.
@@ -129590,11 +129961,11 @@
129590129961
129591129962
if( IsVirtual(pTab) ) return 0;
129592129963
if( pExpr->op!=TK_AGG_FUNCTION ) return 0;
129593129964
if( NEVER(pAggInfo->nFunc==0) ) return 0;
129594129965
if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0;
129595
- if( pExpr->flags&EP_Distinct ) return 0;
129966
+ if( ExprHasProperty(pExpr, EP_Distinct|EP_WinFunc) ) return 0;
129596129967
129597129968
return pTab;
129598129969
}
129599129970
129600129971
/*
@@ -130037,10 +130408,14 @@
130037130408
if( IsVirtual(pTab) || pTab->pSelect ){
130038130409
i16 nCol;
130039130410
u8 eCodeOrig = pWalker->eCode;
130040130411
if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;
130041130412
assert( pFrom->pSelect==0 );
130413
+ if( pTab->pSelect && (db->flags & SQLITE_EnableView)==0 ){
130414
+ sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited",
130415
+ pTab->zName);
130416
+ }
130042130417
pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);
130043130418
nCol = pTab->nCol;
130044130419
pTab->nCol = -1;
130045130420
pWalker->eCode = 1; /* Turn on Select.selId renumbering */
130046130421
sqlite3WalkSelect(pWalker, pFrom->pSelect);
@@ -130330,11 +130705,12 @@
130330130705
if( (pTab->tabFlags & TF_Ephemeral)!=0 ){
130331130706
/* A sub-query in the FROM clause of a SELECT */
130332130707
Select *pSel = pFrom->pSelect;
130333130708
if( pSel ){
130334130709
while( pSel->pPrior ) pSel = pSel->pPrior;
130335
- sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSel);
130710
+ sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSel,
130711
+ SQLITE_AFF_NONE);
130336130712
}
130337130713
}
130338130714
}
130339130715
}
130340130716
#endif
@@ -130470,20 +130846,28 @@
130470130846
int nArg;
130471130847
int addrNext = 0;
130472130848
int regAgg;
130473130849
ExprList *pList = pF->pExpr->x.pList;
130474130850
assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
130851
+ assert( !IsWindowFunc(pF->pExpr) );
130852
+ if( ExprHasProperty(pF->pExpr, EP_WinFunc) ){
130853
+ Expr *pFilter = pF->pExpr->y.pWin->pFilter;
130854
+ addrNext = sqlite3VdbeMakeLabel(pParse);
130855
+ sqlite3ExprIfFalse(pParse, pFilter, addrNext, SQLITE_JUMPIFNULL);
130856
+ }
130475130857
if( pList ){
130476130858
nArg = pList->nExpr;
130477130859
regAgg = sqlite3GetTempRange(pParse, nArg);
130478130860
sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP);
130479130861
}else{
130480130862
nArg = 0;
130481130863
regAgg = 0;
130482130864
}
130483130865
if( pF->iDistinct>=0 ){
130484
- addrNext = sqlite3VdbeMakeLabel(pParse);
130866
+ if( addrNext==0 ){
130867
+ addrNext = sqlite3VdbeMakeLabel(pParse);
130868
+ }
130485130869
testcase( nArg==0 ); /* Error condition */
130486130870
testcase( nArg>1 ); /* Also an error */
130487130871
codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);
130488130872
}
130489130873
if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
@@ -130982,11 +131366,11 @@
130982131366
** "" column. The original design was for the fake column name to be a NULL,
130983131367
** which would be unambiguous. But legacy authorization callbacks might
130984131368
** assume the column name is non-NULL and segfault. The use of an empty
130985131369
** string for the fake column name seems safer.
130986131370
*/
130987
- if( pItem->colUsed==0 ){
131371
+ if( pItem->colUsed==0 && pItem->zName!=0 ){
130988131372
sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase);
130989131373
}
130990131374
130991131375
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
130992131376
/* Generate code for all sub-queries in the FROM clause
@@ -130996,12 +131380,19 @@
130996131380
130997131381
/* The code for a subquery should only be generated once, though it is
130998131382
** technically harmless for it to be generated multiple times. The
130999131383
** following assert() will detect if something changes to cause
131000131384
** the same subquery to be coded multiple times, as a signal to the
131001
- ** developers to try to optimize the situation. */
131002
- assert( pItem->addrFillSub==0 );
131385
+ ** developers to try to optimize the situation.
131386
+ **
131387
+ ** Update 2019-07-24:
131388
+ ** See ticket https://sqlite.org/src/tktview/c52b09c7f38903b1311cec40.
131389
+ ** The dbsqlfuzz fuzzer found a case where the same subquery gets
131390
+ ** coded twice. So this assert() now becomes a testcase(). It should
131391
+ ** be very rare, though.
131392
+ */
131393
+ testcase( pItem->addrFillSub!=0 );
131003131394
131004131395
/* Increment Parse.nHeight by the height of the largest expression
131005131396
** tree referred to by this, the parent select. The child select
131006131397
** may contain expression trees of at most
131007131398
** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit
@@ -131071,11 +131462,11 @@
131071131462
int topAddr;
131072131463
int onceAddr = 0;
131073131464
int retAddr;
131074131465
struct SrcList_item *pPrior;
131075131466
131076
- assert( pItem->addrFillSub==0 );
131467
+ testcase( pItem->addrFillSub==0 ); /* Ticket c52b09c7f38903b1311 */
131077131468
pItem->regReturn = ++pParse->nMem;
131078131469
topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn);
131079131470
pItem->addrFillSub = topAddr+1;
131080131471
if( pItem->fg.isCorrelated==0 ){
131081131472
/* If the subquery is not correlated and if we are not inside of
@@ -131362,13 +131753,20 @@
131362131753
minMaxFlag = minMaxQuery(db, sAggInfo.aFunc[0].pExpr, &pMinMaxOrderBy);
131363131754
}else{
131364131755
minMaxFlag = WHERE_ORDERBY_NORMAL;
131365131756
}
131366131757
for(i=0; i<sAggInfo.nFunc; i++){
131367
- assert( !ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect) );
131758
+ Expr *pExpr = sAggInfo.aFunc[i].pExpr;
131759
+ assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
131368131760
sNC.ncFlags |= NC_InAggFunc;
131369
- sqlite3ExprAnalyzeAggList(&sNC, sAggInfo.aFunc[i].pExpr->x.pList);
131761
+ sqlite3ExprAnalyzeAggList(&sNC, pExpr->x.pList);
131762
+#ifndef SQLITE_OMIT_WINDOWFUNC
131763
+ assert( !IsWindowFunc(pExpr) );
131764
+ if( ExprHasProperty(pExpr, EP_WinFunc) ){
131765
+ sqlite3ExprAnalyzeAggregates(&sNC, pExpr->y.pWin->pFilter);
131766
+ }
131767
+#endif
131370131768
sNC.ncFlags &= ~NC_InAggFunc;
131371131769
}
131372131770
sAggInfo.mxReg = pParse->nMem;
131373131771
if( db->mallocFailed ) goto select_end;
131374131772
#if SELECTTRACE_ENABLED
@@ -132153,11 +132551,15 @@
132153132551
}
132154132552
132155132553
/* Check that the trigger name is not reserved and that no trigger of the
132156132554
** specified name exists */
132157132555
zName = sqlite3NameFromToken(db, pName);
132158
- if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
132556
+ if( zName==0 ){
132557
+ assert( db->mallocFailed );
132558
+ goto trigger_cleanup;
132559
+ }
132560
+ if( sqlite3CheckObjectName(pParse, zName, "trigger", pTab->zName) ){
132159132561
goto trigger_cleanup;
132160132562
}
132161132563
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
132162132564
if( !IN_RENAME_OBJECT ){
132163132565
if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),zName) ){
@@ -132316,10 +132718,11 @@
132316132718
132317132719
if( db->init.busy ){
132318132720
Trigger *pLink = pTrig;
132319132721
Hash *pHash = &db->aDb[iDb].pSchema->trigHash;
132320132722
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
132723
+ assert( pLink!=0 );
132321132724
pTrig = sqlite3HashInsert(pHash, zName, pTrig);
132322132725
if( pTrig ){
132323132726
sqlite3OomFault(db);
132324132727
}else if( pLink->pSchema==pLink->pTabSchema ){
132325132728
Table *pTab;
@@ -132434,10 +132837,13 @@
132434132837
pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
132435132838
}
132436132839
pTriggerStep->pIdList = pColumn;
132437132840
pTriggerStep->pUpsert = pUpsert;
132438132841
pTriggerStep->orconf = orconf;
132842
+ if( pUpsert ){
132843
+ sqlite3HasExplicitNulls(pParse, pUpsert->pUpsertTarget);
132844
+ }
132439132845
}else{
132440132846
testcase( pColumn );
132441132847
sqlite3IdListDelete(db, pColumn);
132442132848
testcase( pUpsert );
132443132849
sqlite3UpsertDelete(db, pUpsert);
@@ -132589,14 +132995,13 @@
132589132995
int iDb;
132590132996
132591132997
iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema);
132592132998
assert( iDb>=0 && iDb<db->nDb );
132593132999
pTable = tableOfTrigger(pTrigger);
132594
- assert( pTable );
132595
- assert( pTable->pSchema==pTrigger->pSchema || iDb==1 );
133000
+ assert( (pTable && pTable->pSchema==pTrigger->pSchema) || iDb==1 );
132596133001
#ifndef SQLITE_OMIT_AUTHORIZATION
132597
- {
133002
+ if( pTable ){
132598133003
int code = SQLITE_DROP_TRIGGER;
132599133004
const char *zDb = db->aDb[iDb].zDbSName;
132600133005
const char *zTab = SCHEMA_TABLE(iDb);
132601133006
if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;
132602133007
if( sqlite3AuthCheck(pParse, code, pTrigger->zName, pTable->zName, zDb) ||
@@ -132606,11 +133011,10 @@
132606133011
}
132607133012
#endif
132608133013
132609133014
/* Generate code to destroy the database record of the trigger.
132610133015
*/
132611
- assert( pTable!=0 );
132612133016
if( (v = sqlite3GetVdbe(pParse))!=0 ){
132613133017
sqlite3NestedParse(pParse,
132614133018
"DELETE FROM %Q.%s WHERE name=%Q AND type='trigger'",
132615133019
db->aDb[iDb].zDbSName, MASTER_NAME, pTrigger->zName
132616133020
);
@@ -132630,13 +133034,15 @@
132630133034
pHash = &(db->aDb[iDb].pSchema->trigHash);
132631133035
pTrigger = sqlite3HashInsert(pHash, zName, 0);
132632133036
if( ALWAYS(pTrigger) ){
132633133037
if( pTrigger->pSchema==pTrigger->pTabSchema ){
132634133038
Table *pTab = tableOfTrigger(pTrigger);
132635
- Trigger **pp;
132636
- for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext));
132637
- *pp = (*pp)->pNext;
133039
+ if( pTab ){
133040
+ Trigger **pp;
133041
+ for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext));
133042
+ *pp = (*pp)->pNext;
133043
+ }
132638133044
}
132639133045
sqlite3DeleteTrigger(db, pTrigger);
132640133046
db->mDbFlags |= DBFLAG_SchemaChange;
132641133047
}
132642133048
}
@@ -133880,32 +134286,34 @@
133880134286
}
133881134287
}
133882134288
}
133883134289
133884134290
if( !isView ){
133885
- int addr1 = 0; /* Address of jump instruction */
133886
-
133887134291
/* Do constraint checks. */
133888134292
assert( regOldRowid>0 );
133889134293
sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
133890134294
regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace,
133891134295
aXRef, 0);
134296
+
134297
+ /* If REPLACE conflict handling may have been used, or if the PK of the
134298
+ ** row is changing, then the GenerateConstraintChecks() above may have
134299
+ ** moved cursor iDataCur. Reseek it. */
134300
+ if( bReplace || chngKey ){
134301
+ if( pPk ){
134302
+ sqlite3VdbeAddOp4Int(v, OP_NotFound,iDataCur,labelContinue,regKey,nKey);
134303
+ }else{
134304
+ sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue,regOldRowid);
134305
+ }
134306
+ VdbeCoverageNeverTaken(v);
134307
+ }
133892134308
133893134309
/* Do FK constraint checks. */
133894134310
if( hasFK ){
133895134311
sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);
133896134312
}
133897134313
133898134314
/* Delete the index entries associated with the current record. */
133899
- if( bReplace || chngKey ){
133900
- if( pPk ){
133901
- addr1 = sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, 0, regKey, nKey);
133902
- }else{
133903
- addr1 = sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, 0, regOldRowid);
133904
- }
133905
- VdbeCoverageNeverTaken(v);
133906
- }
133907134315
sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, aRegIdx, -1);
133908134316
133909134317
/* If changing the rowid value, or if there are foreign key constraints
133910134318
** to process, delete the old record. Otherwise, add a noop OP_Delete
133911134319
** to invoke the pre-update hook.
@@ -133931,13 +134339,10 @@
133931134339
#else
133932134340
if( hasFK>1 || chngKey ){
133933134341
sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0);
133934134342
}
133935134343
#endif
133936
- if( bReplace || chngKey ){
133937
- sqlite3VdbeJumpHere(v, addr1);
133938
- }
133939134344
133940134345
if( hasFK ){
133941134346
sqlite3FkCheck(pParse, pTab, 0, regNewRowid, aXRef, chngKey);
133942134347
}
133943134348
@@ -134372,10 +134777,11 @@
134372134777
){
134373134778
Vdbe *v = pParse->pVdbe;
134374134779
sqlite3 *db = pParse->db;
134375134780
SrcList *pSrc; /* FROM clause for the UPDATE */
134376134781
int iDataCur;
134782
+ int i;
134377134783
134378134784
assert( v!=0 );
134379134785
assert( pUpsert!=0 );
134380134786
VdbeNoopComment((v, "Begin DO UPDATE of UPSERT"));
134381134787
iDataCur = pUpsert->iDataCur;
@@ -134388,11 +134794,10 @@
134388134794
sqlite3ReleaseTempReg(pParse, regRowid);
134389134795
}else{
134390134796
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
134391134797
int nPk = pPk->nKeyCol;
134392134798
int iPk = pParse->nMem+1;
134393
- int i;
134394134799
pParse->nMem += nPk;
134395134800
for(i=0; i<nPk; i++){
134396134801
int k;
134397134802
assert( pPk->aiColumn[i]>=0 );
134398134803
k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
@@ -134409,10 +134814,16 @@
134409134814
}
134410134815
}
134411134816
/* pUpsert does not own pUpsertSrc - the outer INSERT statement does. So
134412134817
** we have to make a copy before passing it down into sqlite3Update() */
134413134818
pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
134819
+ /* excluded.* columns of type REAL need to be converted to a hard real */
134820
+ for(i=0; i<pTab->nCol; i++){
134821
+ if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){
134822
+ sqlite3VdbeAddOp1(v, OP_RealAffinity, pUpsert->regData+i);
134823
+ }
134824
+ }
134414134825
sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet,
134415134826
pUpsert->pUpsertWhere, OE_Abort, 0, 0, pUpsert);
134416134827
pUpsert->pUpsertSet = 0; /* Will have been deleted by sqlite3Update() */
134417134828
pUpsert->pUpsertWhere = 0; /* Will have been deleted by sqlite3Update() */
134418134829
VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
@@ -134872,38 +135283,52 @@
134872135283
134873135284
/*
134874135285
** Construct and install a Module object for a virtual table. When this
134875135286
** routine is called, it is guaranteed that all appropriate locks are held
134876135287
** and the module is not already part of the connection.
135288
+**
135289
+** If there already exists a module with zName, replace it with the new one.
135290
+** If pModule==0, then delete the module zName if it exists.
134877135291
*/
134878135292
SQLITE_PRIVATE Module *sqlite3VtabCreateModule(
134879135293
sqlite3 *db, /* Database in which module is registered */
134880135294
const char *zName, /* Name assigned to this module */
134881135295
const sqlite3_module *pModule, /* The definition of the module */
134882135296
void *pAux, /* Context pointer for xCreate/xConnect */
134883135297
void (*xDestroy)(void *) /* Module destructor function */
134884135298
){
134885135299
Module *pMod;
134886
- int nName = sqlite3Strlen30(zName);
134887
- pMod = (Module *)sqlite3Malloc(sizeof(Module) + nName + 1);
134888
- if( pMod==0 ){
134889
- sqlite3OomFault(db);
135300
+ Module *pDel;
135301
+ char *zCopy;
135302
+ if( pModule==0 ){
135303
+ zCopy = (char*)zName;
135304
+ pMod = 0;
134890135305
}else{
134891
- Module *pDel;
134892
- char *zCopy = (char *)(&pMod[1]);
135306
+ int nName = sqlite3Strlen30(zName);
135307
+ pMod = (Module *)sqlite3Malloc(sizeof(Module) + nName + 1);
135308
+ if( pMod==0 ){
135309
+ sqlite3OomFault(db);
135310
+ return 0;
135311
+ }
135312
+ zCopy = (char *)(&pMod[1]);
134893135313
memcpy(zCopy, zName, nName+1);
134894135314
pMod->zName = zCopy;
134895135315
pMod->pModule = pModule;
134896135316
pMod->pAux = pAux;
134897135317
pMod->xDestroy = xDestroy;
134898135318
pMod->pEpoTab = 0;
134899
- pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,(void*)pMod);
134900
- assert( pDel==0 || pDel==pMod );
134901
- if( pDel ){
135319
+ pMod->nRefModule = 1;
135320
+ }
135321
+ pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,(void*)pMod);
135322
+ if( pDel ){
135323
+ if( pDel==pMod ){
134902135324
sqlite3OomFault(db);
134903135325
sqlite3DbFree(db, pDel);
134904135326
pMod = 0;
135327
+ }else{
135328
+ sqlite3VtabEponymousTableClear(db, pDel);
135329
+ sqlite3VtabModuleUnref(db, pDel);
134905135330
}
134906135331
}
134907135332
return pMod;
134908135333
}
134909135334
@@ -134920,15 +135345,11 @@
134920135345
void (*xDestroy)(void *) /* Module destructor function */
134921135346
){
134922135347
int rc = SQLITE_OK;
134923135348
134924135349
sqlite3_mutex_enter(db->mutex);
134925
- if( sqlite3HashFind(&db->aModule, zName) ){
134926
- rc = SQLITE_MISUSE_BKPT;
134927
- }else{
134928
- (void)sqlite3VtabCreateModule(db, zName, pModule, pAux, xDestroy);
134929
- }
135350
+ (void)sqlite3VtabCreateModule(db, zName, pModule, pAux, xDestroy);
134930135351
rc = sqlite3ApiExit(db, rc);
134931135352
if( rc!=SQLITE_OK && xDestroy ) xDestroy(pAux);
134932135353
sqlite3_mutex_leave(db->mutex);
134933135354
return rc;
134934135355
}
@@ -134962,10 +135383,48 @@
134962135383
#ifdef SQLITE_ENABLE_API_ARMOR
134963135384
if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;
134964135385
#endif
134965135386
return createModule(db, zName, pModule, pAux, xDestroy);
134966135387
}
135388
+
135389
+/*
135390
+** External API to drop all virtual-table modules, except those named
135391
+** on the azNames list.
135392
+*/
135393
+SQLITE_API int sqlite3_drop_modules(sqlite3 *db, const char** azNames){
135394
+ HashElem *pThis, *pNext;
135395
+#ifdef SQLITE_ENABLE_API_ARMOR
135396
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
135397
+#endif
135398
+ for(pThis=sqliteHashFirst(&db->aModule); pThis; pThis=pNext){
135399
+ Module *pMod = (Module*)sqliteHashData(pThis);
135400
+ pNext = sqliteHashNext(pThis);
135401
+ if( azNames ){
135402
+ int ii;
135403
+ for(ii=0; azNames[ii]!=0 && strcmp(azNames[ii],pMod->zName)!=0; ii++){}
135404
+ if( azNames[ii]!=0 ) continue;
135405
+ }
135406
+ createModule(db, pMod->zName, 0, 0, 0);
135407
+ }
135408
+ return SQLITE_OK;
135409
+}
135410
+
135411
+/*
135412
+** Decrement the reference count on a Module object. Destroy the
135413
+** module when the reference count reaches zero.
135414
+*/
135415
+SQLITE_PRIVATE void sqlite3VtabModuleUnref(sqlite3 *db, Module *pMod){
135416
+ assert( pMod->nRefModule>0 );
135417
+ pMod->nRefModule--;
135418
+ if( pMod->nRefModule==0 ){
135419
+ if( pMod->xDestroy ){
135420
+ pMod->xDestroy(pMod->pAux);
135421
+ }
135422
+ assert( pMod->pEpoTab==0 );
135423
+ sqlite3DbFree(db, pMod);
135424
+ }
135425
+}
134967135426
134968135427
/*
134969135428
** Lock the virtual table so that it cannot be disconnected.
134970135429
** Locks nest. Every lock should have a corresponding unlock.
134971135430
** If an unlock is omitted, resources leaks will occur.
@@ -135002,10 +135461,11 @@
135002135461
assert( db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_ZOMBIE );
135003135462
135004135463
pVTab->nRef--;
135005135464
if( pVTab->nRef==0 ){
135006135465
sqlite3_vtab *p = pVTab->pVtab;
135466
+ sqlite3VtabModuleUnref(pVTab->db, pVTab->pMod);
135007135467
if( p ){
135008135468
p->pModule->xDisconnect(p);
135009135469
}
135010135470
sqlite3DbFree(db, pVTab);
135011135471
}
@@ -135406,10 +135866,11 @@
135406135866
}else if( ALWAYS(pVTable->pVtab) ){
135407135867
/* Justification of ALWAYS(): A correct vtab constructor must allocate
135408135868
** the sqlite3_vtab object if successful. */
135409135869
memset(pVTable->pVtab, 0, sizeof(pVTable->pVtab[0]));
135410135870
pVTable->pVtab->pModule = pMod->pModule;
135871
+ pMod->nRefModule++;
135411135872
pVTable->nRef = 1;
135412135873
if( sCtx.bDeclared==0 ){
135413135874
const char *zFormat = "vtable constructor did not declare schema: %s";
135414135875
*pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
135415135876
sqlite3VtabUnlock(pVTable);
@@ -136190,17 +136651,19 @@
136190136651
int addrNxt; /* Jump here to start the next IN combination */
136191136652
int addrSkip; /* Jump here for next iteration of skip-scan */
136192136653
int addrCont; /* Jump here to continue with the next loop cycle */
136193136654
int addrFirst; /* First instruction of interior of the loop */
136194136655
int addrBody; /* Beginning of the body of this loop */
136656
+ int regBignull; /* big-null flag reg. True if a NULL-scan is needed */
136657
+ int addrBignull; /* Jump here for next part of big-null scan */
136195136658
#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS
136196136659
u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */
136197136660
int addrLikeRep; /* LIKE range processing address */
136198136661
#endif
136199136662
u8 iFrom; /* Which entry in the FROM clause */
136200136663
u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
136201
- int p1, p2; /* Operands of the opcode used to ends the loop */
136664
+ int p1, p2; /* Operands of the opcode used to end the loop */
136202136665
union { /* Information that depends on pWLoop->wsFlags */
136203136666
struct {
136204136667
int nIn; /* Number of entries in aInLoop[] */
136205136668
struct InLoop {
136206136669
int iCur; /* The VDBE cursor used by this IN operator */
@@ -136247,11 +136710,11 @@
136247136710
union {
136248136711
struct { /* Information for internal btree tables */
136249136712
u16 nEq; /* Number of equality constraints */
136250136713
u16 nBtm; /* Size of BTM vector */
136251136714
u16 nTop; /* Size of TOP vector */
136252
- u16 nIdxCol; /* Index column used for ORDER BY */
136715
+ u16 nDistinctCol; /* Index columns used to sort for DISTINCT */
136253136716
Index *pIndex; /* Index used, or NULL */
136254136717
} btree;
136255136718
struct { /* Information for virtual tables */
136256136719
int idxNum; /* Index number */
136257136720
u8 needFree; /* True if sqlite3_free(idxStr) is needed */
@@ -136398,20 +136861,21 @@
136398136861
#define TERM_CODED 0x04 /* This term is already coded */
136399136862
#define TERM_COPIED 0x08 /* Has a child */
136400136863
#define TERM_ORINFO 0x10 /* Need to free the WhereTerm.u.pOrInfo object */
136401136864
#define TERM_ANDINFO 0x20 /* Need to free the WhereTerm.u.pAndInfo obj */
136402136865
#define TERM_OR_OK 0x40 /* Used during OR-clause processing */
136403
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
136866
+#ifdef SQLITE_ENABLE_STAT4
136404136867
# define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */
136405136868
#else
136406
-# define TERM_VNULL 0x00 /* Disabled if not using stat3 */
136869
+# define TERM_VNULL 0x00 /* Disabled if not using stat4 */
136407136870
#endif
136408136871
#define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
136409136872
#define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
136410136873
#define TERM_LIKE 0x400 /* The original LIKE operator */
136411136874
#define TERM_IS 0x800 /* Term.pExpr is an IS operator */
136412136875
#define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
136876
+#define TERM_NOPARTIDX 0x2000 /* Not for use to enable a partial index */
136413136877
136414136878
/*
136415136879
** An instance of the WhereScan object is used as an iterator for locating
136416136880
** terms in the WHERE clause that are useful to the query planner.
136417136881
*/
@@ -136518,11 +136982,11 @@
136518136982
WhereInfo *pWInfo; /* Information about this WHERE */
136519136983
WhereClause *pWC; /* WHERE clause terms */
136520136984
ExprList *pOrderBy; /* ORDER BY clause */
136521136985
WhereLoop *pNew; /* Template WhereLoop */
136522136986
WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
136523
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
136987
+#ifdef SQLITE_ENABLE_STAT4
136524136988
UnpackedRecord *pRec; /* Probe for stat4 (if required) */
136525136989
int nRecValid; /* Number of valid fields currently in pRec */
136526136990
#endif
136527136991
unsigned int bldFlags; /* SQLITE_BLDF_* flags */
136528136992
unsigned int iPlanLimit; /* Search limiter */
@@ -136705,10 +137169,11 @@
136705137169
#define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
136706137170
#define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
136707137171
#define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
136708137172
#define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
136709137173
#define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
137174
+#define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
136710137175
136711137176
#endif /* !defined(SQLITE_WHEREINT_H) */
136712137177
136713137178
/************** End of whereInt.h ********************************************/
136714137179
/************** Continuing where we left off in wherecode.c ******************/
@@ -137009,13 +137474,13 @@
137009137474
137010137475
/*
137011137476
** Code an OP_Affinity opcode to apply the column affinity string zAff
137012137477
** to the n registers starting at base.
137013137478
**
137014
-** As an optimization, SQLITE_AFF_BLOB entries (which are no-ops) at the
137015
-** beginning and end of zAff are ignored. If all entries in zAff are
137016
-** SQLITE_AFF_BLOB, then no code gets generated.
137479
+** As an optimization, SQLITE_AFF_BLOB and SQLITE_AFF_NONE entries (which
137480
+** are no-ops) at the beginning and end of zAff are ignored. If all entries
137481
+** in zAff are SQLITE_AFF_BLOB or SQLITE_AFF_NONE, then no code gets generated.
137017137482
**
137018137483
** This routine makes its own copy of zAff so that the caller is free
137019137484
** to modify zAff after this routine returns.
137020137485
*/
137021137486
static void codeApplyAffinity(Parse *pParse, int base, int n, char *zAff){
@@ -137024,19 +137489,20 @@
137024137489
assert( pParse->db->mallocFailed );
137025137490
return;
137026137491
}
137027137492
assert( v!=0 );
137028137493
137029
- /* Adjust base and n to skip over SQLITE_AFF_BLOB entries at the beginning
137030
- ** and end of the affinity string.
137494
+ /* Adjust base and n to skip over SQLITE_AFF_BLOB and SQLITE_AFF_NONE
137495
+ ** entries at the beginning and end of the affinity string.
137031137496
*/
137032
- while( n>0 && zAff[0]==SQLITE_AFF_BLOB ){
137497
+ assert( SQLITE_AFF_NONE<SQLITE_AFF_BLOB );
137498
+ while( n>0 && zAff[0]<=SQLITE_AFF_BLOB ){
137033137499
n--;
137034137500
base++;
137035137501
zAff++;
137036137502
}
137037
- while( n>1 && zAff[n-1]==SQLITE_AFF_BLOB ){
137503
+ while( n>1 && zAff[n-1]<=SQLITE_AFF_BLOB ){
137038137504
n--;
137039137505
}
137040137506
137041137507
/* Code the OP_Affinity opcode if there is anything left to do. */
137042137508
if( n>0 ){
@@ -137807,10 +138273,11 @@
137807138273
** that contains the value of pExpr.
137808138274
*/
137809138275
static int whereIndexExprTransNode(Walker *p, Expr *pExpr){
137810138276
IdxExprTrans *pX = p->u.pIdxTrans;
137811138277
if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
138278
+ pExpr->affExpr = sqlite3ExprAffinity(pExpr);
137812138279
pExpr->op = TK_COLUMN;
137813138280
pExpr->iTable = pX->iIdxCur;
137814138281
pExpr->iColumn = pX->iIdxCol;
137815138282
pExpr->y.pTab = 0;
137816138283
return WRC_Prune;
@@ -138239,36 +138706,16 @@
138239138706
char *zStartAff; /* Affinity for start of range constraint */
138240138707
char *zEndAff = 0; /* Affinity for end of range constraint */
138241138708
u8 bSeekPastNull = 0; /* True to seek past initial nulls */
138242138709
u8 bStopAtNull = 0; /* Add condition to terminate at NULLs */
138243138710
int omitTable; /* True if we use the index only */
138244
-
138711
+ int regBignull = 0; /* big-null flag register */
138245138712
138246138713
pIdx = pLoop->u.btree.pIndex;
138247138714
iIdxCur = pLevel->iIdxCur;
138248138715
assert( nEq>=pLoop->nSkip );
138249138716
138250
- /* If this loop satisfies a sort order (pOrderBy) request that
138251
- ** was passed to this function to implement a "SELECT min(x) ..."
138252
- ** query, then the caller will only allow the loop to run for
138253
- ** a single iteration. This means that the first row returned
138254
- ** should not have a NULL value stored in 'x'. If column 'x' is
138255
- ** the first one after the nEq equality constraints in the index,
138256
- ** this requires some special handling.
138257
- */
138258
- assert( pWInfo->pOrderBy==0
138259
- || pWInfo->pOrderBy->nExpr==1
138260
- || (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0 );
138261
- if( (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)!=0
138262
- && pWInfo->nOBSat>0
138263
- && (pIdx->nKeyCol>nEq)
138264
- ){
138265
- assert( pLoop->nSkip==0 );
138266
- bSeekPastNull = 1;
138267
- nExtraReg = 1;
138268
- }
138269
-
138270138717
/* Find any inequality constraint terms for the start and end
138271138718
** of the range.
138272138719
*/
138273138720
j = nEq;
138274138721
if( pLoop->wsFlags & WHERE_BTM_LIMIT ){
@@ -138304,10 +138751,29 @@
138304138751
bSeekPastNull = 1;
138305138752
}
138306138753
}
138307138754
}
138308138755
assert( pRangeEnd==0 || (pRangeEnd->wtFlags & TERM_VNULL)==0 );
138756
+
138757
+ /* If the WHERE_BIGNULL_SORT flag is set, then index column nEq uses
138758
+ ** a non-default "big-null" sort (either ASC NULLS LAST or DESC NULLS
138759
+ ** FIRST). In both cases separate ordered scans are made of those
138760
+ ** index entries for which the column is null and for those for which
138761
+ ** it is not. For an ASC sort, the non-NULL entries are scanned first.
138762
+ ** For DESC, NULL entries are scanned first.
138763
+ */
138764
+ if( (pLoop->wsFlags & (WHERE_TOP_LIMIT|WHERE_BTM_LIMIT))==0
138765
+ && (pLoop->wsFlags & WHERE_BIGNULL_SORT)!=0
138766
+ ){
138767
+ assert( bSeekPastNull==0 && nExtraReg==0 && nBtm==0 && nTop==0 );
138768
+ assert( pRangeEnd==0 && pRangeStart==0 );
138769
+ assert( pLoop->nSkip==0 );
138770
+ nExtraReg = 1;
138771
+ bSeekPastNull = 1;
138772
+ pLevel->regBignull = regBignull = ++pParse->nMem;
138773
+ pLevel->addrBignull = sqlite3VdbeMakeLabel(pParse);
138774
+ }
138309138775
138310138776
/* If we are doing a reverse order scan on an ascending index, or
138311138777
** a forward order scan on a descending index, interchange the
138312138778
** start and end terms (pRangeStart and pRangeEnd).
138313138779
*/
@@ -138327,11 +138793,11 @@
138327138793
regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
138328138794
assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );
138329138795
if( zStartAff && nTop ){
138330138796
zEndAff = sqlite3DbStrDup(db, &zStartAff[nEq]);
138331138797
}
138332
- addrNxt = pLevel->addrNxt;
138798
+ addrNxt = (regBignull ? pLevel->addrBignull : pLevel->addrNxt);
138333138799
138334138800
testcase( pRangeStart && (pRangeStart->eOperator & WO_LE)!=0 );
138335138801
testcase( pRangeStart && (pRangeStart->eOperator & WO_GE)!=0 );
138336138802
testcase( pRangeEnd && (pRangeEnd->eOperator & WO_LE)!=0 );
138337138803
testcase( pRangeEnd && (pRangeEnd->eOperator & WO_GE)!=0 );
@@ -138361,14 +138827,18 @@
138361138827
}else{
138362138828
startEq = 1;
138363138829
}
138364138830
bSeekPastNull = 0;
138365138831
}else if( bSeekPastNull ){
138366
- sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
138367
- nConstraint++;
138368138832
startEq = 0;
138833
+ sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
138834
+ start_constraints = 1;
138835
+ nConstraint++;
138836
+ }else if( regBignull ){
138837
+ sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
138369138838
start_constraints = 1;
138839
+ nConstraint++;
138370138840
}
138371138841
codeApplyAffinity(pParse, regBase, nConstraint - bSeekPastNull, zStartAff);
138372138842
if( pLoop->nSkip>0 && nConstraint==pLoop->nSkip ){
138373138843
/* The skip-scan logic inside the call to codeAllEqualityConstraints()
138374138844
** above has already left the cursor sitting on the correct row,
@@ -138375,10 +138845,15 @@
138375138845
** so no further seeking is needed */
138376138846
}else{
138377138847
if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
138378138848
sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur);
138379138849
}
138850
+ if( regBignull ){
138851
+ sqlite3VdbeAddOp2(v, OP_Integer, 1, regBignull);
138852
+ VdbeComment((v, "NULL-scan pass ctr"));
138853
+ }
138854
+
138380138855
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
138381138856
assert( op!=0 );
138382138857
sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
138383138858
VdbeCoverage(v);
138384138859
VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind );
@@ -138385,10 +138860,27 @@
138385138860
VdbeCoverageIf(v, op==OP_Last); testcase( op==OP_Last );
138386138861
VdbeCoverageIf(v, op==OP_SeekGT); testcase( op==OP_SeekGT );
138387138862
VdbeCoverageIf(v, op==OP_SeekGE); testcase( op==OP_SeekGE );
138388138863
VdbeCoverageIf(v, op==OP_SeekLE); testcase( op==OP_SeekLE );
138389138864
VdbeCoverageIf(v, op==OP_SeekLT); testcase( op==OP_SeekLT );
138865
+
138866
+ assert( bSeekPastNull==0 || bStopAtNull==0 );
138867
+ if( regBignull ){
138868
+ assert( bSeekPastNull==1 || bStopAtNull==1 );
138869
+ assert( bSeekPastNull==!bStopAtNull );
138870
+ assert( bStopAtNull==startEq );
138871
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2);
138872
+ op = aStartOp[(nConstraint>1)*4 + 2 + bRev];
138873
+ sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase,
138874
+ nConstraint-startEq);
138875
+ VdbeCoverage(v);
138876
+ VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind );
138877
+ VdbeCoverageIf(v, op==OP_Last); testcase( op==OP_Last );
138878
+ VdbeCoverageIf(v, op==OP_SeekGE); testcase( op==OP_SeekGE );
138879
+ VdbeCoverageIf(v, op==OP_SeekLE); testcase( op==OP_SeekLE );
138880
+ assert( op==OP_Rewind || op==OP_Last || op==OP_SeekGE || op==OP_SeekLE);
138881
+ }
138390138882
}
138391138883
138392138884
/* Load the value for the inequality constraint at the end of the
138393138885
** range (if any).
138394138886
*/
@@ -138416,12 +138908,14 @@
138416138908
disableTerm(pLevel, pRangeEnd);
138417138909
}else{
138418138910
endEq = 1;
138419138911
}
138420138912
}else if( bStopAtNull ){
138421
- sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
138422
- endEq = 0;
138913
+ if( regBignull==0 ){
138914
+ sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
138915
+ endEq = 0;
138916
+ }
138423138917
nConstraint++;
138424138918
}
138425138919
sqlite3DbFree(db, zStartAff);
138426138920
sqlite3DbFree(db, zEndAff);
138427138921
@@ -138428,12 +138922,35 @@
138428138922
/* Top of the loop body */
138429138923
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
138430138924
138431138925
/* Check if the index cursor is past the end of the range. */
138432138926
if( nConstraint ){
138927
+ if( regBignull ){
138928
+ /* Except, skip the end-of-range check while doing the NULL-scan */
138929
+ sqlite3VdbeAddOp2(v, OP_IfNot, regBignull, sqlite3VdbeCurrentAddr(v)+3);
138930
+ VdbeComment((v, "If NULL-scan 2nd pass"));
138931
+ VdbeCoverage(v);
138932
+ }
138433138933
op = aEndOp[bRev*2 + endEq];
138434138934
sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
138935
+ testcase( op==OP_IdxGT ); VdbeCoverageIf(v, op==OP_IdxGT );
138936
+ testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE );
138937
+ testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
138938
+ testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
138939
+ }
138940
+ if( regBignull ){
138941
+ /* During a NULL-scan, check to see if we have reached the end of
138942
+ ** the NULLs */
138943
+ assert( bSeekPastNull==!bStopAtNull );
138944
+ assert( bSeekPastNull+bStopAtNull==1 );
138945
+ assert( nConstraint+bSeekPastNull>0 );
138946
+ sqlite3VdbeAddOp2(v, OP_If, regBignull, sqlite3VdbeCurrentAddr(v)+2);
138947
+ VdbeComment((v, "If NULL-scan 1st pass"));
138948
+ VdbeCoverage(v);
138949
+ op = aEndOp[bRev*2 + bSeekPastNull];
138950
+ sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase,
138951
+ nConstraint+bSeekPastNull);
138435138952
testcase( op==OP_IdxGT ); VdbeCoverageIf(v, op==OP_IdxGT );
138436138953
testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE );
138437138954
testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
138438138955
testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
138439138956
}
@@ -139061,11 +139578,11 @@
139061139578
if( p && ExprHasProperty(p, EP_Unlikely) ){
139062139579
pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;
139063139580
}else{
139064139581
pTerm->truthProb = 1;
139065139582
}
139066
- pTerm->pExpr = sqlite3ExprSkipCollate(p);
139583
+ pTerm->pExpr = sqlite3ExprSkipCollateAndLikely(p);
139067139584
pTerm->wtFlags = wtFlags;
139068139585
pTerm->pWC = pWC;
139069139586
pTerm->iParent = -1;
139070139587
memset(&pTerm->eOperator, 0,
139071139588
sizeof(WhereTerm) - offsetof(WhereTerm,eOperator));
@@ -139094,26 +139611,34 @@
139094139611
** that the collating sequence does not change. For example:
139095139612
** "Y collate NOCASE op X" becomes "X op Y" because any collation sequence on
139096139613
** the left hand side of a comparison overrides any collation sequence
139097139614
** attached to the right. For the same reason the EP_Collate flag
139098139615
** is not commuted.
139616
+**
139617
+** The return value is extra flags that are added to the WhereTerm object
139618
+** after it is commuted. The only extra flag ever added is TERM_NOPARTIDX
139619
+** which prevents the term from being used to enable a partial index if
139620
+** COLLATE changes have been made.
139099139621
*/
139100
-static void exprCommute(Parse *pParse, Expr *pExpr){
139622
+static u16 exprCommute(Parse *pParse, Expr *pExpr){
139101139623
u16 expRight = (pExpr->pRight->flags & EP_Collate);
139102139624
u16 expLeft = (pExpr->pLeft->flags & EP_Collate);
139625
+ u16 wtFlags = 0;
139103139626
assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );
139104139627
if( expRight==expLeft ){
139105139628
/* Either X and Y both have COLLATE operator or neither do */
139106139629
if( expRight ){
139107139630
/* Both X and Y have COLLATE operators. Make sure X is always
139108139631
** used by clearing the EP_Collate flag from Y. */
139109139632
pExpr->pRight->flags &= ~EP_Collate;
139633
+ wtFlags |= TERM_NOPARTIDX;
139110139634
}else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){
139111139635
/* Neither X nor Y have COLLATE operators, but X has a non-default
139112139636
** collating sequence. So add the EP_Collate marker on X to cause
139113139637
** it to be searched first. */
139114139638
pExpr->pLeft->flags |= EP_Collate;
139639
+ wtFlags |= TERM_NOPARTIDX;
139115139640
}
139116139641
}
139117139642
SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
139118139643
if( pExpr->op>=TK_GT ){
139119139644
assert( TK_LT==TK_GT+2 );
@@ -139121,10 +139646,11 @@
139121139646
assert( TK_GT>TK_EQ );
139122139647
assert( TK_GT<TK_LE );
139123139648
assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );
139124139649
pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;
139125139650
}
139651
+ return wtFlags;
139126139652
}
139127139653
139128139654
/*
139129139655
** Translate from TK_xx operator to WO_xx bitmask.
139130139656
*/
@@ -140117,11 +140643,11 @@
140117140643
}
140118140644
}else{
140119140645
pDup = pExpr;
140120140646
pNew = pTerm;
140121140647
}
140122
- exprCommute(pParse, pDup);
140648
+ pNew->wtFlags |= exprCommute(pParse, pDup);
140123140649
pNew->leftCursor = aiCurCol[0];
140124140650
pNew->u.leftColumn = aiCurCol[1];
140125140651
testcase( (prereqLeft | extraRight) != prereqLeft );
140126140652
pNew->prereqRight = prereqLeft | extraRight;
140127140653
pNew->prereqAll = prereqAll;
@@ -140358,12 +140884,12 @@
140358140884
exprAnalyze(pSrc, pWC, idxNew);
140359140885
markTermAsChild(pWC, idxNew, idxTerm);
140360140886
}
140361140887
}
140362140888
140363
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
140364
- /* When sqlite_stat3 histogram data is available an operator of the
140889
+#ifdef SQLITE_ENABLE_STAT4
140890
+ /* When sqlite_stat4 histogram data is available an operator of the
140365140891
** form "x IS NOT NULL" can sometimes be evaluated more efficiently
140366140892
** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
140367140893
** virtual term of that form.
140368140894
**
140369140895
** Note that the virtual term must be tagged with TERM_VNULL.
@@ -140370,11 +140896,11 @@
140370140896
*/
140371140897
if( pExpr->op==TK_NOTNULL
140372140898
&& pExpr->pLeft->op==TK_COLUMN
140373140899
&& pExpr->pLeft->iColumn>=0
140374140900
&& !ExprHasProperty(pExpr, EP_FromJoin)
140375
- && OptimizationEnabled(db, SQLITE_Stat34)
140901
+ && OptimizationEnabled(db, SQLITE_Stat4)
140376140902
){
140377140903
Expr *pNewExpr;
140378140904
Expr *pLeft = pExpr->pLeft;
140379140905
int idxNew;
140380140906
WhereTerm *pNewTerm;
@@ -140395,11 +140921,11 @@
140395140921
pTerm = &pWC->a[idxTerm];
140396140922
pTerm->wtFlags |= TERM_COPIED;
140397140923
pNewTerm->prereqAll = pTerm->prereqAll;
140398140924
}
140399140925
}
140400
-#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
140926
+#endif /* SQLITE_ENABLE_STAT4 */
140401140927
140402140928
/* Prevent ON clause terms of a LEFT JOIN from being used to drive
140403140929
** an index for tables to the left of the join.
140404140930
*/
140405140931
testcase( pTerm!=&pWC->a[idxTerm] );
@@ -140428,11 +140954,11 @@
140428140954
** In the previous sentence and in the diagram, "slot[]" refers to
140429140955
** the WhereClause.a[] array. The slot[] array grows as needed to contain
140430140956
** all terms of the WHERE clause.
140431140957
*/
140432140958
SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause *pWC, Expr *pExpr, u8 op){
140433
- Expr *pE2 = sqlite3ExprSkipCollate(pExpr);
140959
+ Expr *pE2 = sqlite3ExprSkipCollateAndLikely(pExpr);
140434140960
pWC->op = op;
140435140961
if( pE2==0 ) return;
140436140962
if( pE2->op!=op ){
140437140963
whereClauseInsert(pWC, pExpr, 0);
140438140964
}else{
@@ -140843,11 +141369,12 @@
140843141369
pScan->pIdxExpr,iCur)==0)
140844141370
&& (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
140845141371
){
140846141372
if( (pTerm->eOperator & WO_EQUIV)!=0
140847141373
&& pScan->nEquiv<ArraySize(pScan->aiCur)
140848
- && (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN
141374
+ && (pX = sqlite3ExprSkipCollateAndLikely(pTerm->pExpr->pRight))->op
141375
+ ==TK_COLUMN
140849141376
){
140850141377
int j;
140851141378
for(j=0; j<pScan->nEquiv; j++){
140852141379
if( pScan->aiCur[j]==pX->iTable
140853141380
&& pScan->aiColumn[j]==pX->iColumn ){
@@ -141039,11 +141566,11 @@
141039141566
){
141040141567
int i;
141041141568
const char *zColl = pIdx->azColl[iCol];
141042141569
141043141570
for(i=0; i<pList->nExpr; i++){
141044
- Expr *p = sqlite3ExprSkipCollate(pList->a[i].pExpr);
141571
+ Expr *p = sqlite3ExprSkipCollateAndLikely(pList->a[i].pExpr);
141045141572
if( p->op==TK_COLUMN
141046141573
&& p->iColumn==pIdx->aiColumn[iCol]
141047141574
&& p->iTable==iBase
141048141575
){
141049141576
CollSeq *pColl = sqlite3ExprNNCollSeq(pParse, pList->a[i].pExpr);
@@ -141103,11 +141630,11 @@
141103141630
/* If any of the expressions is an IPK column on table iBase, then return
141104141631
** true. Note: The (p->iTable==iBase) part of this test may be false if the
141105141632
** current SELECT is a correlated sub-query.
141106141633
*/
141107141634
for(i=0; i<pDistinct->nExpr; i++){
141108
- Expr *p = sqlite3ExprSkipCollate(pDistinct->a[i].pExpr);
141635
+ Expr *p = sqlite3ExprSkipCollateAndLikely(pDistinct->a[i].pExpr);
141109141636
if( p->op==TK_COLUMN && p->iTable==iBase && p->iColumn<0 ) return 1;
141110141637
}
141111141638
141112141639
/* Loop through all indices on the table, checking each to see if it makes
141113141640
** the DISTINCT qualifier redundant. It does so if:
@@ -141523,10 +142050,11 @@
141523142050
if( pOrderBy ){
141524142051
int n = pOrderBy->nExpr;
141525142052
for(i=0; i<n; i++){
141526142053
Expr *pExpr = pOrderBy->a[i].pExpr;
141527142054
if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;
142055
+ if( pOrderBy->a[i].sortFlags & KEYINFO_ORDER_BIGNULL ) break;
141528142056
}
141529142057
if( i==n){
141530142058
nOrderBy = n;
141531142059
}
141532142060
}
@@ -141621,11 +142149,11 @@
141621142149
j++;
141622142150
}
141623142151
for(i=0; i<nOrderBy; i++){
141624142152
Expr *pExpr = pOrderBy->a[i].pExpr;
141625142153
pIdxOrderBy[i].iColumn = pExpr->iColumn;
141626
- pIdxOrderBy[i].desc = pOrderBy->a[i].sortOrder;
142154
+ pIdxOrderBy[i].desc = pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC;
141627142155
}
141628142156
141629142157
*pmNoOmit = mNoOmit;
141630142158
return pIdxInfo;
141631142159
}
@@ -141667,11 +142195,11 @@
141667142195
pVtab->zErrMsg = 0;
141668142196
return rc;
141669142197
}
141670142198
#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */
141671142199
141672
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
142200
+#ifdef SQLITE_ENABLE_STAT4
141673142201
/*
141674142202
** Estimate the location of a particular key among all keys in an
141675142203
** index. Store the results in aStat as follows:
141676142204
**
141677142205
** aStat[0] Est. number of rows less than pRec
@@ -141860,11 +142388,11 @@
141860142388
141861142389
/* Restore the pRec->nField value before returning. */
141862142390
pRec->nField = nField;
141863142391
return i;
141864142392
}
141865
-#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
142393
+#endif /* SQLITE_ENABLE_STAT4 */
141866142394
141867142395
/*
141868142396
** If it is not NULL, pTerm is a term that provides an upper or lower
141869142397
** bound on a range scan. Without considering pTerm, it is estimated
141870142398
** that the scan will visit nNew rows. This function returns the number
@@ -141886,25 +142414,26 @@
141886142414
}
141887142415
return nRet;
141888142416
}
141889142417
141890142418
141891
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
142419
+#ifdef SQLITE_ENABLE_STAT4
141892142420
/*
141893142421
** Return the affinity for a single column of an index.
141894142422
*/
141895142423
SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){
141896142424
assert( iCol>=0 && iCol<pIdx->nColumn );
141897142425
if( !pIdx->zColAff ){
141898142426
if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;
141899142427
}
142428
+ assert( pIdx->zColAff[iCol]!=0 );
141900142429
return pIdx->zColAff[iCol];
141901142430
}
141902142431
#endif
141903142432
141904142433
141905
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
142434
+#ifdef SQLITE_ENABLE_STAT4
141906142435
/*
141907142436
** This function is called to estimate the number of rows visited by a
141908142437
** range-scan on a skip-scan index. For example:
141909142438
**
141910142439
** CREATE INDEX i1 ON t1(a, b, c);
@@ -142006,11 +142535,11 @@
142006142535
sqlite3ValueFree(p2);
142007142536
sqlite3ValueFree(pVal);
142008142537
142009142538
return rc;
142010142539
}
142011
-#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
142540
+#endif /* SQLITE_ENABLE_STAT4 */
142012142541
142013142542
/*
142014142543
** This function is used to estimate the number of rows that will be visited
142015142544
** by scanning an index for a range of values. The range may have an upper
142016142545
** bound, a lower bound, or both. The WHERE clause terms that set the upper
@@ -142059,16 +142588,16 @@
142059142588
){
142060142589
int rc = SQLITE_OK;
142061142590
int nOut = pLoop->nOut;
142062142591
LogEst nNew;
142063142592
142064
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
142593
+#ifdef SQLITE_ENABLE_STAT4
142065142594
Index *p = pLoop->u.btree.pIndex;
142066142595
int nEq = pLoop->u.btree.nEq;
142067142596
142068
- if( p->nSample>0 && nEq<p->nSampleCol
142069
- && OptimizationEnabled(pParse->db, SQLITE_Stat34)
142597
+ if( p->nSample>0 && ALWAYS(nEq<p->nSampleCol)
142598
+ && OptimizationEnabled(pParse->db, SQLITE_Stat4)
142070142599
){
142071142600
if( nEq==pBuilder->nRecValid ){
142072142601
UnpackedRecord *pRec = pBuilder->pRec;
142073142602
tRowcnt a[2];
142074142603
int nBtm = pLoop->u.btree.nBtm;
@@ -142162,11 +142691,11 @@
142162142691
if( iUpper>iLower ){
142163142692
nNew = sqlite3LogEst(iUpper - iLower);
142164142693
/* TUNING: If both iUpper and iLower are derived from the same
142165142694
** sample, then assume they are 4x more selective. This brings
142166142695
** the estimated selectivity more in line with what it would be
142167
- ** if estimated without the use of STAT3/4 tables. */
142696
+ ** if estimated without the use of STAT4 tables. */
142168142697
if( iLwrIdx==iUprIdx ) nNew -= 20; assert( 20==sqlite3LogEst(4) );
142169142698
}else{
142170142699
nNew = 10; assert( 10==sqlite3LogEst(2) );
142171142700
}
142172142701
if( nNew<nOut ){
@@ -142211,16 +142740,16 @@
142211142740
#endif
142212142741
pLoop->nOut = (LogEst)nOut;
142213142742
return rc;
142214142743
}
142215142744
142216
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
142745
+#ifdef SQLITE_ENABLE_STAT4
142217142746
/*
142218142747
** Estimate the number of rows that will be returned based on
142219142748
** an equality constraint x=VALUE and where that VALUE occurs in
142220142749
** the histogram data. This only works when x is the left-most
142221
-** column of an index and sqlite_stat3 histogram data is available
142750
+** column of an index and sqlite_stat4 histogram data is available
142222142751
** for that index. When pExpr==NULL that means the constraint is
142223142752
** "x IS NULL" instead of "x=VALUE".
142224142753
**
142225142754
** Write the estimated row count into *pnRow and return SQLITE_OK.
142226142755
** If unable to make an estimate, leave *pnRow unchanged and return
@@ -142274,13 +142803,13 @@
142274142803
p->zName, nEq-1, (int)a[1]));
142275142804
*pnRow = a[1];
142276142805
142277142806
return rc;
142278142807
}
142279
-#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
142808
+#endif /* SQLITE_ENABLE_STAT4 */
142280142809
142281
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
142810
+#ifdef SQLITE_ENABLE_STAT4
142282142811
/*
142283142812
** Estimate the number of rows that will be returned based on
142284142813
** an IN constraint where the right-hand side of the IN operator
142285142814
** is a list of values. Example:
142286142815
**
@@ -142323,11 +142852,11 @@
142323142852
WHERETRACE(0x10,("IN row estimate: est=%d\n", nRowEst));
142324142853
}
142325142854
assert( pBuilder->nRecValid==nRecValid );
142326142855
return rc;
142327142856
}
142328
-#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
142857
+#endif /* SQLITE_ENABLE_STAT4 */
142329142858
142330142859
142331142860
#ifdef WHERETRACE_ENABLED
142332142861
/*
142333142862
** Print the content of a WhereTerm object
@@ -142860,10 +143389,11 @@
142860143389
int i, j, k;
142861143390
LogEst iReduce = 0; /* pLoop->nOut should not exceed nRow-iReduce */
142862143391
142863143392
assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
142864143393
for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){
143394
+ assert( pTerm!=0 );
142865143395
if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
142866143396
if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
142867143397
if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
142868143398
for(j=pLoop->nLTerm-1; j>=0; j--){
142869143399
pX = pLoop->aLTerm[j];
@@ -143043,11 +143573,11 @@
143043143573
for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
143044143574
u16 eOp = pTerm->eOperator; /* Shorthand for pTerm->eOperator */
143045143575
LogEst rCostIdx;
143046143576
LogEst nOutUnadjusted; /* nOut before IN() and WHERE adjustments */
143047143577
int nIn = 0;
143048
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
143578
+#ifdef SQLITE_ENABLE_STAT4
143049143579
int nRecValid = pBuilder->nRecValid;
143050143580
#endif
143051143581
if( (eOp==WO_ISNULL || (pTerm->wtFlags&TERM_VNULL)!=0)
143052143582
&& indexColumnNotNull(pProbe, saved_nEq)
143053143583
){
@@ -143104,12 +143634,10 @@
143104143634
if( pNew->aLTerm[i] && pNew->aLTerm[i]->pExpr==pExpr ) nIn = 0;
143105143635
}
143106143636
}else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
143107143637
/* "x IN (value, value, ...)" */
143108143638
nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
143109
- assert( nIn>0 ); /* RHS always has 2 or more terms... The parser
143110
- ** changes "x IN (?)" into "x=?". */
143111143639
}
143112143640
if( pProbe->hasStat1 ){
143113143641
LogEst M, logK, safetyMargin;
143114143642
/* Let:
143115143643
** N = the total number of rows in the table
@@ -143201,11 +143729,11 @@
143201143729
** values of nIn and nInMul. In other words, assuming that all
143202143730
** "x IN(...)" terms are replaced with "x = ?". This block updates
143203143731
** the value of pNew->nOut to account for pTerm (but not nIn/nInMul). */
143204143732
assert( pNew->nOut==saved_nOut );
143205143733
if( pNew->wsFlags & WHERE_COLUMN_RANGE ){
143206
- /* Adjust nOut using stat3/stat4 data. Or, if there is no stat3/stat4
143734
+ /* Adjust nOut using stat4 data. Or, if there is no stat4
143207143735
** data, using some other estimate. */
143208143736
whereRangeScanEst(pParse, pBuilder, pBtm, pTop, pNew);
143209143737
}else{
143210143738
int nEq = ++pNew->u.btree.nEq;
143211143739
assert( eOp & (WO_ISNULL|WO_EQ|WO_IN|WO_IS) );
@@ -143215,17 +143743,17 @@
143215143743
assert( (eOp & WO_IN) || nIn==0 );
143216143744
testcase( eOp & WO_IN );
143217143745
pNew->nOut += pTerm->truthProb;
143218143746
pNew->nOut -= nIn;
143219143747
}else{
143220
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
143748
+#ifdef SQLITE_ENABLE_STAT4
143221143749
tRowcnt nOut = 0;
143222143750
if( nInMul==0
143223143751
&& pProbe->nSample
143224143752
&& pNew->u.btree.nEq<=pProbe->nSampleCol
143225143753
&& ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))
143226
- && OptimizationEnabled(db, SQLITE_Stat34)
143754
+ && OptimizationEnabled(db, SQLITE_Stat4)
143227143755
){
143228143756
Expr *pExpr = pTerm->pExpr;
143229143757
if( (eOp & (WO_EQ|WO_ISNULL|WO_IS))!=0 ){
143230143758
testcase( eOp & WO_EQ );
143231143759
testcase( eOp & WO_IS );
@@ -143258,10 +143786,11 @@
143258143786
143259143787
/* Set rCostIdx to the cost of visiting selected rows in index. Add
143260143788
** it to pNew->rRun, which is currently set to the cost of the index
143261143789
** seek only. Then, if this is a non-covering index, add the cost of
143262143790
** visiting the rows in the main table. */
143791
+ assert( pSrc->pTab->szTabRow>0 );
143263143792
rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow;
143264143793
pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx);
143265143794
if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
143266143795
pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16);
143267143796
}
@@ -143283,11 +143812,11 @@
143283143812
&& pNew->u.btree.nEq<pProbe->nColumn
143284143813
){
143285143814
whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
143286143815
}
143287143816
pNew->nOut = saved_nOut;
143288
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
143817
+#ifdef SQLITE_ENABLE_STAT4
143289143818
pBuilder->nRecValid = nRecValid;
143290143819
#endif
143291143820
}
143292143821
pNew->prereq = saved_prereq;
143293143822
pNew->u.btree.nEq = saved_nEq;
@@ -143356,11 +143885,11 @@
143356143885
int ii, jj;
143357143886
143358143887
if( pIndex->bUnordered ) return 0;
143359143888
if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0;
143360143889
for(ii=0; ii<pOB->nExpr; ii++){
143361
- Expr *pExpr = sqlite3ExprSkipCollate(pOB->a[ii].pExpr);
143890
+ Expr *pExpr = sqlite3ExprSkipCollateAndLikely(pOB->a[ii].pExpr);
143362143891
if( pExpr->op==TK_COLUMN && pExpr->iTable==iCursor ){
143363143892
if( pExpr->iColumn<0 ) return 1;
143364143893
for(jj=0; jj<pIndex->nKeyCol; jj++){
143365143894
if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
143366143895
}
@@ -143387,11 +143916,13 @@
143387143916
if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;
143388143917
pWhere = pWhere->pRight;
143389143918
}
143390143919
if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
143391143920
for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
143392
- Expr *pExpr = pTerm->pExpr;
143921
+ Expr *pExpr;
143922
+ if( pTerm->wtFlags & TERM_NOPARTIDX ) continue;
143923
+ pExpr = pTerm->pExpr;
143393143924
if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
143394143925
&& sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
143395143926
){
143396143927
return 1;
143397143928
}
@@ -143656,11 +144187,11 @@
143656144187
** unique index is used (making the index functionally non-unique)
143657144188
** then the sqlite_stat1 data becomes important for scoring the
143658144189
** plan */
143659144190
pTab->tabFlags |= TF_StatsUsed;
143660144191
}
143661
-#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
144192
+#ifdef SQLITE_ENABLE_STAT4
143662144193
sqlite3Stat4ProbeFree(pBuilder->pRec);
143663144194
pBuilder->nRecValid = 0;
143664144195
pBuilder->pRec = 0;
143665144196
#endif
143666144197
}
@@ -144284,12 +144815,12 @@
144284144815
pLoop = pLast;
144285144816
}
144286144817
if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
144287144818
if( pLoop->u.vtab.isOrdered ) obSat = obDone;
144288144819
break;
144289
- }else{
144290
- pLoop->u.btree.nIdxCol = 0;
144820
+ }else if( wctrlFlags & WHERE_DISTINCTBY ){
144821
+ pLoop->u.btree.nDistinctCol = 0;
144291144822
}
144292144823
iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
144293144824
144294144825
/* Mark off any ORDER BY term X that is a column in the table of
144295144826
** the current loop for which there is term in the WHERE
@@ -144296,11 +144827,11 @@
144296144827
** clause of the form X IS NULL or X=? that reference only outer
144297144828
** loops.
144298144829
*/
144299144830
for(i=0; i<nOrderBy; i++){
144300144831
if( MASKBIT(i) & obSat ) continue;
144301
- pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
144832
+ pOBExpr = sqlite3ExprSkipCollateAndLikely(pOrderBy->a[i].pExpr);
144302144833
if( pOBExpr->op!=TK_COLUMN ) continue;
144303144834
if( pOBExpr->iTable!=iCur ) continue;
144304144835
pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
144305144836
~ready, eqOpMask, 0);
144306144837
if( pTerm==0 ) continue;
@@ -144333,11 +144864,12 @@
144333144864
nKeyCol = pIndex->nKeyCol;
144334144865
nColumn = pIndex->nColumn;
144335144866
assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) );
144336144867
assert( pIndex->aiColumn[nColumn-1]==XN_ROWID
144337144868
|| !HasRowid(pIndex->pTable));
144338
- isOrderDistinct = IsUniqueIndex(pIndex);
144869
+ isOrderDistinct = IsUniqueIndex(pIndex)
144870
+ && (pLoop->wsFlags & WHERE_SKIPSCAN)==0;
144339144871
}
144340144872
144341144873
/* Loop through all columns of the index and deal with the ones
144342144874
** that are not constrained by == or IN.
144343144875
*/
@@ -144351,19 +144883,25 @@
144351144883
);
144352144884
if( j<pLoop->u.btree.nEq && j>=pLoop->nSkip ){
144353144885
u16 eOp = pLoop->aLTerm[j]->eOperator;
144354144886
144355144887
/* Skip over == and IS and ISNULL terms. (Also skip IN terms when
144356
- ** doing WHERE_ORDERBY_LIMIT processing).
144888
+ ** doing WHERE_ORDERBY_LIMIT processing). Except, IS and ISNULL
144889
+ ** terms imply that the index is not UNIQUE NOT NULL in which case
144890
+ ** the loop need to be marked as not order-distinct because it can
144891
+ ** have repeated NULL rows.
144357144892
**
144358144893
** If the current term is a column of an ((?,?) IN (SELECT...))
144359144894
** expression for which the SELECT returns more than one column,
144360144895
** check that it is the only column used by this loop. Otherwise,
144361144896
** if it is one of two or more, none of the columns can be
144362
- ** considered to match an ORDER BY term. */
144897
+ ** considered to match an ORDER BY term.
144898
+ */
144363144899
if( (eOp & eqOpMask)!=0 ){
144364
- if( eOp & WO_ISNULL ){
144900
+ if( eOp & (WO_ISNULL|WO_IS) ){
144901
+ testcase( eOp & WO_ISNULL );
144902
+ testcase( eOp & WO_IS );
144365144903
testcase( isOrderDistinct );
144366144904
isOrderDistinct = 0;
144367144905
}
144368144906
continue;
144369144907
}else if( ALWAYS(eOp & WO_IN) ){
@@ -144385,11 +144923,11 @@
144385144923
/* Get the column number in the table (iColumn) and sort order
144386144924
** (revIdx) for the j-th column of the index.
144387144925
*/
144388144926
if( pIndex ){
144389144927
iColumn = pIndex->aiColumn[j];
144390
- revIdx = pIndex->aSortOrder[j];
144928
+ revIdx = pIndex->aSortOrder[j] & KEYINFO_ORDER_DESC;
144391144929
if( iColumn==pIndex->pTable->iPKey ) iColumn = XN_ROWID;
144392144930
}else{
144393144931
iColumn = XN_ROWID;
144394144932
revIdx = 0;
144395144933
}
@@ -144409,11 +144947,11 @@
144409144947
** of the index and mark that ORDER BY term off
144410144948
*/
144411144949
isMatch = 0;
144412144950
for(i=0; bOnce && i<nOrderBy; i++){
144413144951
if( MASKBIT(i) & obSat ) continue;
144414
- pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
144952
+ pOBExpr = sqlite3ExprSkipCollateAndLikely(pOrderBy->a[i].pExpr);
144415144953
testcase( wctrlFlags & WHERE_GROUPBY );
144416144954
testcase( wctrlFlags & WHERE_DISTINCTBY );
144417144955
if( (wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY))==0 ) bOnce = 0;
144418144956
if( iColumn>=XN_ROWID ){
144419144957
if( pOBExpr->op!=TK_COLUMN ) continue;
@@ -144427,24 +144965,35 @@
144427144965
}
144428144966
if( iColumn!=XN_ROWID ){
144429144967
pColl = sqlite3ExprNNCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
144430144968
if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ) continue;
144431144969
}
144432
- pLoop->u.btree.nIdxCol = j+1;
144970
+ if( wctrlFlags & WHERE_DISTINCTBY ){
144971
+ pLoop->u.btree.nDistinctCol = j+1;
144972
+ }
144433144973
isMatch = 1;
144434144974
break;
144435144975
}
144436144976
if( isMatch && (wctrlFlags & WHERE_GROUPBY)==0 ){
144437144977
/* Make sure the sort order is compatible in an ORDER BY clause.
144438144978
** Sort order is irrelevant for a GROUP BY clause. */
144439144979
if( revSet ){
144440
- if( (rev ^ revIdx)!=pOrderBy->a[i].sortOrder ) isMatch = 0;
144980
+ if( (rev ^ revIdx)!=(pOrderBy->a[i].sortFlags&KEYINFO_ORDER_DESC) ){
144981
+ isMatch = 0;
144982
+ }
144441144983
}else{
144442
- rev = revIdx ^ pOrderBy->a[i].sortOrder;
144984
+ rev = revIdx ^ (pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC);
144443144985
if( rev ) *pRevMask |= MASKBIT(iLoop);
144444144986
revSet = 1;
144445144987
}
144988
+ }
144989
+ if( isMatch && (pOrderBy->a[i].sortFlags & KEYINFO_ORDER_BIGNULL) ){
144990
+ if( j==pLoop->u.btree.nEq ){
144991
+ pLoop->wsFlags |= WHERE_BIGNULL_SORT;
144992
+ }else{
144993
+ isMatch = 0;
144994
+ }
144446144995
}
144447144996
if( isMatch ){
144448144997
if( iColumn==XN_ROWID ){
144449144998
testcase( distinctColumns==0 );
144450144999
distinctColumns = 1;
@@ -145355,10 +145904,20 @@
145355145904
sqlite3DebugPrintf("*** Optimizer Start *** (wctrlFlags: 0x%x",wctrlFlags);
145356145905
if( wctrlFlags & WHERE_USE_LIMIT ){
145357145906
sqlite3DebugPrintf(", limit: %d", iAuxArg);
145358145907
}
145359145908
sqlite3DebugPrintf(")\n");
145909
+ if( sqlite3WhereTrace & 0x100 ){
145910
+ Select sSelect;
145911
+ memset(&sSelect, 0, sizeof(sSelect));
145912
+ sSelect.selFlags = SF_WhereBegin;
145913
+ sSelect.pSrc = pTabList;
145914
+ sSelect.pWhere = pWhere;
145915
+ sSelect.pOrderBy = pOrderBy;
145916
+ sSelect.pEList = pResultSet;
145917
+ sqlite3TreeViewSelect(0, &sSelect, 0);
145918
+ }
145360145919
}
145361145920
if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
145362145921
sqlite3WhereClausePrint(sWLB.pWC);
145363145922
}
145364145923
#endif
@@ -145631,10 +146190,11 @@
145631146190
if( op ){
145632146191
sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);
145633146192
sqlite3VdbeSetP4KeyInfo(pParse, pIx);
145634146193
if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0
145635146194
&& (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0
146195
+ && (pLoop->wsFlags & WHERE_BIGNULL_SORT)==0
145636146196
&& (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0
145637146197
&& pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED
145638146198
){
145639146199
sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */
145640146200
}
@@ -145748,11 +146308,11 @@
145748146308
int n;
145749146309
if( pWInfo->eDistinct==WHERE_DISTINCT_ORDERED
145750146310
&& i==pWInfo->nLevel-1 /* Ticket [ef9318757b152e3] 2017-10-21 */
145751146311
&& (pLoop->wsFlags & WHERE_INDEXED)!=0
145752146312
&& (pIdx = pLoop->u.btree.pIndex)->hasStat1
145753
- && (n = pLoop->u.btree.nIdxCol)>0
146313
+ && (n = pLoop->u.btree.nDistinctCol)>0
145754146314
&& pIdx->aiRowLogEst[n]>=36
145755146315
){
145756146316
int r1 = pParse->nMem+1;
145757146317
int j, op;
145758146318
for(j=0; j<n; j++){
@@ -145772,10 +146332,15 @@
145772146332
sqlite3VdbeChangeP5(v, pLevel->p5);
145773146333
VdbeCoverage(v);
145774146334
VdbeCoverageIf(v, pLevel->op==OP_Next);
145775146335
VdbeCoverageIf(v, pLevel->op==OP_Prev);
145776146336
VdbeCoverageIf(v, pLevel->op==OP_VNext);
146337
+ if( pLevel->regBignull ){
146338
+ sqlite3VdbeResolveLabel(v, pLevel->addrBignull);
146339
+ sqlite3VdbeAddOp2(v, OP_DecrJumpZero, pLevel->regBignull, pLevel->p2-1);
146340
+ VdbeCoverage(v);
146341
+ }
145777146342
#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT
145778146343
if( addrSeek ) sqlite3VdbeJumpHere(v, addrSeek);
145779146344
#endif
145780146345
}else{
145781146346
sqlite3VdbeResolveLabel(v, pLevel->addrCont);
@@ -146711,10 +147276,12 @@
146711147276
** expression (*ppExpr) in place.
146712147277
*/
146713147278
static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){
146714147279
struct WindowRewrite *p = pWalker->u.pRewrite;
146715147280
Parse *pParse = pWalker->pParse;
147281
+ assert( p!=0 );
147282
+ assert( p->pWin!=0 );
146716147283
146717147284
/* If this function is being called from within a scalar sub-select
146718147285
** that used by the SELECT statement being processed, only process
146719147286
** TK_COLUMN expressions that refer to it (the outer SELECT). Do
146720147287
** not process aggregates or window functions at all, as they belong
@@ -146810,10 +147377,11 @@
146810147377
ExprList **ppSub /* IN/OUT: Sub-select expression-list */
146811147378
){
146812147379
Walker sWalker;
146813147380
WindowRewrite sRewrite;
146814147381
147382
+ assert( pWin!=0 );
146815147383
memset(&sWalker, 0, sizeof(Walker));
146816147384
memset(&sRewrite, 0, sizeof(WindowRewrite));
146817147385
146818147386
sRewrite.pSub = *ppSub;
146819147387
sRewrite.pWin = pWin;
@@ -146848,11 +147416,11 @@
146848147416
if( bIntToNull && pDup && pDup->op==TK_INTEGER ){
146849147417
pDup->op = TK_NULL;
146850147418
pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
146851147419
}
146852147420
pList = sqlite3ExprListAppend(pParse, pList, pDup);
146853
- if( pList ) pList->a[nInit+i].sortOrder = pAppend->a[i].sortOrder;
147421
+ if( pList ) pList->a[nInit+i].sortFlags = pAppend->a[i].sortFlags;
146854147422
}
146855147423
}
146856147424
return pList;
146857147425
}
146858147426
@@ -146894,15 +147462,18 @@
146894147462
/* Create the ORDER BY clause for the sub-select. This is the concatenation
146895147463
** of the window PARTITION and ORDER BY clauses. Then, if this makes it
146896147464
** redundant, remove the ORDER BY from the parent SELECT. */
146897147465
pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);
146898147466
pSort = exprListAppendList(pParse, pSort, pMWin->pOrderBy, 1);
146899
- if( pSort && p->pOrderBy ){
147467
+ if( pSort && p->pOrderBy && p->pOrderBy->nExpr<=pSort->nExpr ){
147468
+ int nSave = pSort->nExpr;
147469
+ pSort->nExpr = p->pOrderBy->nExpr;
146900147470
if( sqlite3ExprListCompare(pSort, p->pOrderBy, -1)==0 ){
146901147471
sqlite3ExprListDelete(db, p->pOrderBy);
146902147472
p->pOrderBy = 0;
146903147473
}
147474
+ pSort->nExpr = nSave;
146904147475
}
146905147476
146906147477
/* Assign a cursor number for the ephemeral table used to buffer rows.
146907147478
** The OpenEphemeral instruction is coded later, after it is known how
146908147479
** many columns the table will have. */
@@ -146954,11 +147525,11 @@
146954147525
if( p->pSrc ){
146955147526
Table *pTab2;
146956147527
p->pSrc->a[0].pSelect = pSub;
146957147528
sqlite3SrcListAssignCursors(pParse, p->pSrc);
146958147529
pSub->selFlags |= SF_Expanded;
146959
- pTab2 = sqlite3ResultSetOfSelect(pParse, pSub);
147530
+ pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
146960147531
if( pTab2==0 ){
146961147532
rc = SQLITE_NOMEM;
146962147533
}else{
146963147534
memcpy(pTab, pTab2, sizeof(Table));
146964147535
pTab->tabFlags |= TF_Ephemeral;
@@ -146976,16 +147547,29 @@
146976147547
sqlite3DbFree(db, pTab);
146977147548
}
146978147549
146979147550
return rc;
146980147551
}
147552
+
147553
+/*
147554
+** Unlink the Window object from the Select to which it is attached,
147555
+** if it is attached.
147556
+*/
147557
+SQLITE_PRIVATE void sqlite3WindowUnlinkFromSelect(Window *p){
147558
+ if( p->ppThis ){
147559
+ *p->ppThis = p->pNextWin;
147560
+ if( p->pNextWin ) p->pNextWin->ppThis = p->ppThis;
147561
+ p->ppThis = 0;
147562
+ }
147563
+}
146981147564
146982147565
/*
146983147566
** Free the Window object passed as the second argument.
146984147567
*/
146985147568
SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3 *db, Window *p){
146986147569
if( p ){
147570
+ sqlite3WindowUnlinkFromSelect(p);
146987147571
sqlite3ExprDelete(db, p->pFilter);
146988147572
sqlite3ExprListDelete(db, p->pPartition);
146989147573
sqlite3ExprListDelete(db, p->pOrderBy);
146990147574
sqlite3ExprDelete(db, p->pEnd);
146991147575
sqlite3ExprDelete(db, p->pStart);
@@ -147159,40 +147743,59 @@
147159147743
** Attach window object pWin to expression p.
147160147744
*/
147161147745
SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
147162147746
if( p ){
147163147747
assert( p->op==TK_FUNCTION );
147164
- /* This routine is only called for the parser. If pWin was not
147165
- ** allocated due to an OOM, then the parser would fail before ever
147166
- ** invoking this routine */
147167
- if( ALWAYS(pWin) ){
147168
- p->y.pWin = pWin;
147169
- ExprSetProperty(p, EP_WinFunc);
147170
- pWin->pOwner = p;
147171
- if( p->flags & EP_Distinct ){
147172
- sqlite3ErrorMsg(pParse,
147173
- "DISTINCT is not supported for window functions");
147174
- }
147748
+ assert( pWin );
147749
+ p->y.pWin = pWin;
147750
+ ExprSetProperty(p, EP_WinFunc);
147751
+ pWin->pOwner = p;
147752
+ if( (p->flags & EP_Distinct) && pWin->eFrmType!=TK_FILTER ){
147753
+ sqlite3ErrorMsg(pParse,
147754
+ "DISTINCT is not supported for window functions"
147755
+ );
147175147756
}
147176147757
}else{
147177147758
sqlite3WindowDelete(pParse->db, pWin);
147178147759
}
147179147760
}
147761
+
147762
+/*
147763
+** Possibly link window pWin into the list at pSel->pWin (window functions
147764
+** to be processed as part of SELECT statement pSel). The window is linked
147765
+** in if either (a) there are no other windows already linked to this
147766
+** SELECT, or (b) the windows already linked use a compatible window frame.
147767
+*/
147768
+SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin){
147769
+ if( 0==pSel->pWin
147770
+ || 0==sqlite3WindowCompare(0, pSel->pWin, pWin, 0)
147771
+ ){
147772
+ pWin->pNextWin = pSel->pWin;
147773
+ if( pSel->pWin ){
147774
+ pSel->pWin->ppThis = &pWin->pNextWin;
147775
+ }
147776
+ pSel->pWin = pWin;
147777
+ pWin->ppThis = &pSel->pWin;
147778
+ }
147779
+}
147180147780
147181147781
/*
147182147782
** Return 0 if the two window objects are identical, or non-zero otherwise.
147183147783
** Identical window objects can be processed in a single scan.
147184147784
*/
147185
-SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2){
147785
+SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, int bFilter){
147186147786
if( p1->eFrmType!=p2->eFrmType ) return 1;
147187147787
if( p1->eStart!=p2->eStart ) return 1;
147188147788
if( p1->eEnd!=p2->eEnd ) return 1;
147189147789
if( p1->eExclude!=p2->eExclude ) return 1;
147190147790
if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
147191147791
if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1;
147192147792
if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1;
147193147793
if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1;
147794
+ if( bFilter ){
147795
+ if( sqlite3ExprCompare(pParse, p1->pFilter, p2->pFilter, -1) ) return 1;
147796
+ }
147194147797
return 0;
147195147798
}
147196147799
147197147800
147198147801
/*
@@ -147240,12 +147843,12 @@
147240147843
KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0);
147241147844
pWin->csrApp = pParse->nTab++;
147242147845
pWin->regApp = pParse->nMem+1;
147243147846
pParse->nMem += 3;
147244147847
if( pKeyInfo && pWin->pFunc->zName[1]=='i' ){
147245
- assert( pKeyInfo->aSortOrder[0]==0 );
147246
- pKeyInfo->aSortOrder[0] = 1;
147848
+ assert( pKeyInfo->aSortFlags[0]==0 );
147849
+ pKeyInfo->aSortFlags[0] = KEYINFO_ORDER_DESC;
147247147850
}
147248147851
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2);
147249147852
sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);
147250147853
sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
147251147854
}
@@ -147360,10 +147963,12 @@
147360147963
FuncDef *pFunc = pWin->pFunc;
147361147964
int regArg;
147362147965
int nArg = windowArgCount(pWin);
147363147966
int i;
147364147967
147968
+ assert( bInverse==0 || pWin->eStart!=TK_UNBOUNDED );
147969
+
147365147970
for(i=0; i<nArg; i++){
147366147971
if( i!=1 || pFunc->zName!=nth_valueName ){
147367147972
sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
147368147973
}else{
147369147974
sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+i, reg+i);
@@ -147422,23 +148027,82 @@
147422148027
}
147423148028
}
147424148029
147425148030
typedef struct WindowCodeArg WindowCodeArg;
147426148031
typedef struct WindowCsrAndReg WindowCsrAndReg;
148032
+
148033
+/*
148034
+** See comments above struct WindowCodeArg.
148035
+*/
147427148036
struct WindowCsrAndReg {
147428
- int csr;
147429
- int reg;
148037
+ int csr; /* Cursor number */
148038
+ int reg; /* First in array of peer values */
147430148039
};
147431148040
148041
+/*
148042
+** A single instance of this structure is allocated on the stack by
148043
+** sqlite3WindowCodeStep() and a pointer to it passed to the various helper
148044
+** routines. This is to reduce the number of arguments required by each
148045
+** helper function.
148046
+**
148047
+** regArg:
148048
+** Each window function requires an accumulator register (just as an
148049
+** ordinary aggregate function does). This variable is set to the first
148050
+** in an array of accumulator registers - one for each window function
148051
+** in the WindowCodeArg.pMWin list.
148052
+**
148053
+** eDelete:
148054
+** The window functions implementation sometimes caches the input rows
148055
+** that it processes in a temporary table. If it is not zero, this
148056
+** variable indicates when rows may be removed from the temp table (in
148057
+** order to reduce memory requirements - it would always be safe just
148058
+** to leave them there). Possible values for eDelete are:
148059
+**
148060
+** WINDOW_RETURN_ROW:
148061
+** An input row can be discarded after it is returned to the caller.
148062
+**
148063
+** WINDOW_AGGINVERSE:
148064
+** An input row can be discarded after the window functions xInverse()
148065
+** callbacks have been invoked in it.
148066
+**
148067
+** WINDOW_AGGSTEP:
148068
+** An input row can be discarded after the window functions xStep()
148069
+** callbacks have been invoked in it.
148070
+**
148071
+** start,current,end
148072
+** Consider a window-frame similar to the following:
148073
+**
148074
+** (ORDER BY a, b GROUPS BETWEEN 2 PRECEDING AND 2 FOLLOWING)
148075
+**
148076
+** The windows functions implmentation caches the input rows in a temp
148077
+** table, sorted by "a, b" (it actually populates the cache lazily, and
148078
+** aggressively removes rows once they are no longer required, but that's
148079
+** a mere detail). It keeps three cursors open on the temp table. One
148080
+** (current) that points to the next row to return to the query engine
148081
+** once its window function values have been calculated. Another (end)
148082
+** points to the next row to call the xStep() method of each window function
148083
+** on (so that it is 2 groups ahead of current). And a third (start) that
148084
+** points to the next row to call the xInverse() method of each window
148085
+** function on.
148086
+**
148087
+** Each cursor (start, current and end) consists of a VDBE cursor
148088
+** (WindowCsrAndReg.csr) and an array of registers (starting at
148089
+** WindowCodeArg.reg) that always contains a copy of the peer values
148090
+** read from the corresponding cursor.
148091
+**
148092
+** Depending on the window-frame in question, all three cursors may not
148093
+** be required. In this case both WindowCodeArg.csr and reg are set to
148094
+** 0.
148095
+*/
147432148096
struct WindowCodeArg {
147433
- Parse *pParse;
147434
- Window *pMWin;
147435
- Vdbe *pVdbe;
147436
- int regGosub;
147437
- int addrGosub;
147438
- int regArg;
147439
- int eDelete;
148097
+ Parse *pParse; /* Parse context */
148098
+ Window *pMWin; /* First in list of functions being processed */
148099
+ Vdbe *pVdbe; /* VDBE object */
148100
+ int addrGosub; /* OP_Gosub to this address to return one row */
148101
+ int regGosub; /* Register used with OP_Gosub(addrGosub) */
148102
+ int regArg; /* First in array of accumulator registers */
148103
+ int eDelete; /* See above */
147440148104
147441148105
WindowCsrAndReg start;
147442148106
WindowCsrAndReg current;
147443148107
WindowCsrAndReg end;
147444148108
};
@@ -147530,12 +148194,14 @@
147530148194
147531148195
int nPeer;
147532148196
int lblNext;
147533148197
int lblBrk;
147534148198
int addrNext;
147535
- int csr = pMWin->csrApp;
148199
+ int csr;
147536148200
148201
+ assert( pMWin!=0 );
148202
+ csr = pMWin->csrApp;
147537148203
nPeer = (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
147538148204
147539148205
lblNext = sqlite3VdbeMakeLabel(pParse);
147540148206
lblBrk = sqlite3VdbeMakeLabel(pParse);
147541148207
@@ -147775,67 +148441,147 @@
147775148441
}
147776148442
147777148443
/*
147778148444
** This function is called as part of generating VM programs for RANGE
147779148445
** offset PRECEDING/FOLLOWING frame boundaries. Assuming "ASC" order for
147780
-** the ORDER BY term in the window, it generates code equivalent to:
148446
+** the ORDER BY term in the window, and that argument op is OP_Ge, it generates
148447
+** code equivalent to:
147781148448
**
147782148449
** if( csr1.peerVal + regVal >= csr2.peerVal ) goto lbl;
147783148450
**
147784
-** A special type of arithmetic is used such that if csr.peerVal is not
147785
-** a numeric type (real or integer), then the result of the addition is
147786
-** a copy of csr1.peerVal.
148451
+** The value of parameter op may also be OP_Gt or OP_Le. In these cases the
148452
+** operator in the above pseudo-code is replaced with ">" or "<=", respectively.
148453
+**
148454
+** If the sort-order for the ORDER BY term in the window is DESC, then the
148455
+** comparison is reversed. Instead of adding regVal to csr1.peerVal, it is
148456
+** subtracted. And the comparison operator is inverted to - ">=" becomes "<=",
148457
+** ">" becomes "<", and so on. So, with DESC sort order, if the argument op
148458
+** is OP_Ge, the generated code is equivalent to:
148459
+**
148460
+** if( csr1.peerVal - regVal <= csr2.peerVal ) goto lbl;
148461
+**
148462
+** A special type of arithmetic is used such that if csr1.peerVal is not
148463
+** a numeric type (real or integer), then the result of the addition addition
148464
+** or subtraction is a a copy of csr1.peerVal.
147787148465
*/
147788148466
static void windowCodeRangeTest(
147789148467
WindowCodeArg *p,
147790
- int op, /* OP_Ge or OP_Gt */
147791
- int csr1,
147792
- int regVal,
147793
- int csr2,
147794
- int lbl
148468
+ int op, /* OP_Ge, OP_Gt, or OP_Le */
148469
+ int csr1, /* Cursor number for cursor 1 */
148470
+ int regVal, /* Register containing non-negative number */
148471
+ int csr2, /* Cursor number for cursor 2 */
148472
+ int lbl /* Jump destination if condition is true */
147795148473
){
147796148474
Parse *pParse = p->pParse;
147797148475
Vdbe *v = sqlite3GetVdbe(pParse);
147798
- int reg1 = sqlite3GetTempReg(pParse);
147799
- int reg2 = sqlite3GetTempReg(pParse);
147800
- int arith = OP_Add;
147801
- int addrGe;
147802
-
147803
- int regString = ++pParse->nMem;
148476
+ ExprList *pOrderBy = p->pMWin->pOrderBy; /* ORDER BY clause for window */
148477
+ int reg1 = sqlite3GetTempReg(pParse); /* Reg. for csr1.peerVal+regVal */
148478
+ int reg2 = sqlite3GetTempReg(pParse); /* Reg. for csr2.peerVal */
148479
+ int regString = ++pParse->nMem; /* Reg. for constant value '' */
148480
+ int arith = OP_Add; /* OP_Add or OP_Subtract */
148481
+ int addrGe; /* Jump destination */
147804148482
147805148483
assert( op==OP_Ge || op==OP_Gt || op==OP_Le );
147806
- assert( p->pMWin->pOrderBy && p->pMWin->pOrderBy->nExpr==1 );
147807
- if( p->pMWin->pOrderBy->a[0].sortOrder ){
148484
+ assert( pOrderBy && pOrderBy->nExpr==1 );
148485
+ if( pOrderBy->a[0].sortFlags & KEYINFO_ORDER_DESC ){
147808148486
switch( op ){
147809148487
case OP_Ge: op = OP_Le; break;
147810148488
case OP_Gt: op = OP_Lt; break;
147811148489
default: assert( op==OP_Le ); op = OP_Ge; break;
147812148490
}
147813148491
arith = OP_Subtract;
147814148492
}
147815148493
148494
+ /* Read the peer-value from each cursor into a register */
147816148495
windowReadPeerValues(p, csr1, reg1);
147817148496
windowReadPeerValues(p, csr2, reg2);
147818148497
147819
- /* Check if the peer value for csr1 value is a text or blob by comparing
147820
- ** it to the smallest possible string - ''. If it is, jump over the
147821
- ** OP_Add or OP_Subtract operation and proceed directly to the comparison. */
148498
+ VdbeModuleComment((v, "CodeRangeTest: if( R%d %s R%d %s R%d ) goto lbl",
148499
+ reg1, (arith==OP_Add ? "+" : "-"), regVal,
148500
+ ((op==OP_Ge) ? ">=" : (op==OP_Le) ? "<=" : (op==OP_Gt) ? ">" : "<"), reg2
148501
+ ));
148502
+
148503
+ /* Register reg1 currently contains csr1.peerVal (the peer-value from csr1).
148504
+ ** This block adds (or subtracts for DESC) the numeric value in regVal
148505
+ ** from it. Or, if reg1 is not numeric (it is a NULL, a text value or a blob),
148506
+ ** then leave reg1 as it is. In pseudo-code, this is implemented as:
148507
+ **
148508
+ ** if( reg1>='' ) goto addrGe;
148509
+ ** reg1 = reg1 +/- regVal
148510
+ ** addrGe:
148511
+ **
148512
+ ** Since all strings and blobs are greater-than-or-equal-to an empty string,
148513
+ ** the add/subtract is skipped for these, as required. If reg1 is a NULL,
148514
+ ** then the arithmetic is performed, but since adding or subtracting from
148515
+ ** NULL is always NULL anyway, this case is handled as required too. */
147822148516
sqlite3VdbeAddOp4(v, OP_String8, 0, regString, 0, "", P4_STATIC);
147823148517
addrGe = sqlite3VdbeAddOp3(v, OP_Ge, regString, 0, reg1);
147824148518
VdbeCoverage(v);
147825148519
sqlite3VdbeAddOp3(v, arith, regVal, reg1, reg1);
147826148520
sqlite3VdbeJumpHere(v, addrGe);
148521
+
148522
+ /* If the BIGNULL flag is set for the ORDER BY, then it is required to
148523
+ ** consider NULL values to be larger than all other values, instead of
148524
+ ** the usual smaller. The VDBE opcodes OP_Ge and so on do not handle this
148525
+ ** (and adding that capability causes a performance regression), so
148526
+ ** instead if the BIGNULL flag is set then cases where either reg1 or
148527
+ ** reg2 are NULL are handled separately in the following block. The code
148528
+ ** generated is equivalent to:
148529
+ **
148530
+ ** if( reg1 IS NULL ){
148531
+ ** if( op==OP_Ge ) goto lbl;
148532
+ ** if( op==OP_Gt && reg2 IS NOT NULL ) goto lbl;
148533
+ ** if( op==OP_Le && reg2 IS NULL ) goto lbl;
148534
+ ** }else if( reg2 IS NULL ){
148535
+ ** if( op==OP_Le ) goto lbl;
148536
+ ** }
148537
+ **
148538
+ ** Additionally, if either reg1 or reg2 are NULL but the jump to lbl is
148539
+ ** not taken, control jumps over the comparison operator coded below this
148540
+ ** block. */
148541
+ if( pOrderBy->a[0].sortFlags & KEYINFO_ORDER_BIGNULL ){
148542
+ /* This block runs if reg1 contains a NULL. */
148543
+ int addr = sqlite3VdbeAddOp1(v, OP_NotNull, reg1); VdbeCoverage(v);
148544
+ switch( op ){
148545
+ case OP_Ge:
148546
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, lbl);
148547
+ break;
148548
+ case OP_Gt:
148549
+ sqlite3VdbeAddOp2(v, OP_NotNull, reg2, lbl);
148550
+ VdbeCoverage(v);
148551
+ break;
148552
+ case OP_Le:
148553
+ sqlite3VdbeAddOp2(v, OP_IsNull, reg2, lbl);
148554
+ VdbeCoverage(v);
148555
+ break;
148556
+ default: assert( op==OP_Lt ); /* no-op */ break;
148557
+ }
148558
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+3);
148559
+
148560
+ /* This block runs if reg1 is not NULL, but reg2 is. */
148561
+ sqlite3VdbeJumpHere(v, addr);
148562
+ sqlite3VdbeAddOp2(v, OP_IsNull, reg2, lbl); VdbeCoverage(v);
148563
+ if( op==OP_Gt || op==OP_Ge ){
148564
+ sqlite3VdbeChangeP2(v, -1, sqlite3VdbeCurrentAddr(v)+1);
148565
+ }
148566
+ }
148567
+
148568
+ /* Compare registers reg2 and reg1, taking the jump if required. Note that
148569
+ ** control skips over this test if the BIGNULL flag is set and either
148570
+ ** reg1 or reg2 contain a NULL value. */
147827148571
sqlite3VdbeAddOp3(v, op, reg2, lbl, reg1); VdbeCoverage(v);
147828148572
sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
148573
+
147829148574
assert( op==OP_Ge || op==OP_Gt || op==OP_Lt || op==OP_Le );
147830148575
testcase(op==OP_Ge); VdbeCoverageIf(v, op==OP_Ge);
147831148576
testcase(op==OP_Lt); VdbeCoverageIf(v, op==OP_Lt);
147832148577
testcase(op==OP_Le); VdbeCoverageIf(v, op==OP_Le);
147833148578
testcase(op==OP_Gt); VdbeCoverageIf(v, op==OP_Gt);
147834
-
147835148579
sqlite3ReleaseTempReg(pParse, reg1);
147836148580
sqlite3ReleaseTempReg(pParse, reg2);
148581
+
148582
+ VdbeModuleComment((v, "CodeRangeTest: end"));
147837148583
}
147838148584
147839148585
/*
147840148586
** Helper function for sqlite3WindowCodeStep(). Each call to this function
147841148587
** generates VM code for a single RETURN_ROW, AGGSTEP or AGGINVERSE
@@ -147980,10 +148726,11 @@
147980148726
pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
147981148727
pNew->eFrmType = p->eFrmType;
147982148728
pNew->eEnd = p->eEnd;
147983148729
pNew->eStart = p->eStart;
147984148730
pNew->eExclude = p->eExclude;
148731
+ pNew->regResult = p->regResult;
147985148732
pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);
147986148733
pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);
147987148734
pNew->pOwner = pOwner;
147988148735
}
147989148736
}
@@ -148786,10 +149533,11 @@
148786149533
** For a compound SELECT statement, make sure p->pPrior->pNext==p for
148787149534
** all elements in the list. And make sure list length does not exceed
148788149535
** SQLITE_LIMIT_COMPOUND_SELECT.
148789149536
*/
148790149537
static void parserDoubleLinkSelect(Parse *pParse, Select *p){
149538
+ assert( p!=0 );
148791149539
if( p->pPrior ){
148792149540
Select *pNext = 0, *pLoop;
148793149541
int mxSelect, cnt = 0;
148794149542
for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){
148795149543
pLoop->pNext = pNext;
@@ -148812,11 +149560,11 @@
148812149560
static Expr *tokenExpr(Parse *pParse, int op, Token t){
148813149561
Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);
148814149562
if( p ){
148815149563
/* memset(p, 0, sizeof(Expr)); */
148816149564
p->op = (u8)op;
148817
- p->affinity = 0;
149565
+ p->affExpr = 0;
148818149566
p->flags = EP_Leaf;
148819149567
p->iAgg = -1;
148820149568
p->pLeft = p->pRight = 0;
148821149569
p->x.pList = 0;
148822149570
p->pAggInfo = 0;
@@ -148939,32 +149687,32 @@
148939149687
#ifndef INTERFACE
148940149688
# define INTERFACE 1
148941149689
#endif
148942149690
/************* Begin control #defines *****************************************/
148943149691
#define YYCODETYPE unsigned short int
148944
-#define YYNOCODE 302
149692
+#define YYNOCODE 307
148945149693
#define YYACTIONTYPE unsigned short int
148946
-#define YYWILDCARD 95
149694
+#define YYWILDCARD 98
148947149695
#define sqlite3ParserTOKENTYPE Token
148948149696
typedef union {
148949149697
int yyinit;
148950149698
sqlite3ParserTOKENTYPE yy0;
148951
- TriggerStep* yy11;
148952
- IdList* yy76;
148953
- ExprList* yy94;
148954
- Upsert* yy95;
148955
- int yy100;
148956
- Expr* yy102;
148957
- struct {int value; int mask;} yy199;
148958
- u8 yy218;
148959
- With* yy243;
148960
- struct TrigEvent yy298;
148961
- Window* yy379;
148962
- struct FrameBound yy389;
148963
- Select* yy391;
148964
- SrcList* yy407;
148965
- const char* yy528;
149699
+ const char* yy8;
149700
+ Select* yy25;
149701
+ int yy32;
149702
+ Expr* yy46;
149703
+ struct FrameBound yy57;
149704
+ u8 yy118;
149705
+ ExprList* yy138;
149706
+ Upsert* yy288;
149707
+ With* yy297;
149708
+ IdList* yy406;
149709
+ Window* yy455;
149710
+ struct {int value; int mask;} yy495;
149711
+ TriggerStep* yy527;
149712
+ struct TrigEvent yy572;
149713
+ SrcList* yy609;
148966149714
} YYMINORTYPE;
148967149715
#ifndef YYSTACKDEPTH
148968149716
#define YYSTACKDEPTH 100
148969149717
#endif
148970149718
#define sqlite3ParserARG_SDECL
@@ -148976,21 +149724,21 @@
148976149724
#define sqlite3ParserCTX_PDECL ,Parse *pParse
148977149725
#define sqlite3ParserCTX_PARAM ,pParse
148978149726
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
148979149727
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
148980149728
#define YYFALLBACK 1
148981
-#define YYNSTATE 540
148982
-#define YYNRULE 376
148983
-#define YYNTOKEN 176
148984
-#define YY_MAX_SHIFT 539
148985
-#define YY_MIN_SHIFTREDUCE 783
148986
-#define YY_MAX_SHIFTREDUCE 1158
148987
-#define YY_ERROR_ACTION 1159
148988
-#define YY_ACCEPT_ACTION 1160
148989
-#define YY_NO_ACTION 1161
148990
-#define YY_MIN_REDUCE 1162
148991
-#define YY_MAX_REDUCE 1537
149729
+#define YYNSTATE 543
149730
+#define YYNRULE 381
149731
+#define YYNTOKEN 179
149732
+#define YY_MAX_SHIFT 542
149733
+#define YY_MIN_SHIFTREDUCE 790
149734
+#define YY_MAX_SHIFTREDUCE 1170
149735
+#define YY_ERROR_ACTION 1171
149736
+#define YY_ACCEPT_ACTION 1172
149737
+#define YY_NO_ACTION 1173
149738
+#define YY_MIN_REDUCE 1174
149739
+#define YY_MAX_REDUCE 1554
148992149740
/************* End control #defines *******************************************/
148993149741
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
148994149742
148995149743
/* Define the yytestcase() macro to be a no-op if is not already defined
148996149744
** otherwise.
@@ -149053,605 +149801,577 @@
149053149801
** yy_reduce_ofst[] For each state, the offset into yy_action for
149054149802
** shifting non-terminals after a reduce.
149055149803
** yy_default[] Default action for each state.
149056149804
**
149057149805
*********** Begin parsing tables **********************************************/
149058
-#define YY_ACTTAB_COUNT (2142)
149806
+#define YY_ACTTAB_COUNT (1913)
149059149807
static const YYACTIONTYPE yy_action[] = {
149060
- /* 0 */ 112, 109, 209, 112, 109, 209, 1160, 1, 1, 539,
149061
- /* 10 */ 2, 1164, 490, 1193, 1293, 534, 289, 1196, 134, 383,
149062
- /* 20 */ 1485, 1428, 1164, 1229, 1208, 1242, 1195, 289, 491, 134,
149063
- /* 30 */ 373, 915, 1229, 443, 16, 16, 1242, 70, 70, 916,
149064
- /* 40 */ 242, 1292, 296, 119, 120, 110, 1136, 1136, 981, 984,
149065
- /* 50 */ 974, 974, 117, 117, 118, 118, 118, 118, 264, 264,
149066
- /* 60 */ 190, 264, 264, 264, 264, 112, 109, 209, 362, 264,
149067
- /* 70 */ 264, 531, 376, 497, 531, 1134, 531, 1501, 239, 206,
149068
- /* 80 */ 338, 9, 531, 242, 219, 1203, 118, 118, 118, 118,
149069
- /* 90 */ 111, 439, 112, 109, 209, 219, 116, 116, 116, 116,
149070
- /* 100 */ 115, 115, 114, 114, 114, 113, 414, 115, 115, 114,
149071
- /* 110 */ 114, 114, 113, 414, 418, 12, 383, 400, 1134, 114,
149072
- /* 120 */ 114, 114, 113, 414, 1115, 418, 1134, 1392, 116, 116,
149073
- /* 130 */ 116, 116, 115, 115, 114, 114, 114, 113, 414, 961,
149074
- /* 140 */ 119, 120, 110, 1136, 1136, 981, 984, 974, 974, 117,
149075
- /* 150 */ 117, 118, 118, 118, 118, 952, 534, 414, 941, 951,
149076
- /* 160 */ 1481, 539, 2, 1164, 1505, 534, 160, 175, 289, 1134,
149077
- /* 170 */ 134, 434, 312, 297, 1115, 1116, 1117, 1242, 70, 70,
149078
- /* 180 */ 1089, 338, 1089, 118, 118, 118, 118, 42, 42, 448,
149079
- /* 190 */ 951, 951, 953, 116, 116, 116, 116, 115, 115, 114,
149080
- /* 200 */ 114, 114, 113, 414, 1115, 311, 264, 264, 82, 441,
149081
- /* 210 */ 264, 264, 190, 383, 284, 12, 288, 525, 407, 531,
149082
- /* 220 */ 96, 159, 458, 531, 371, 116, 116, 116, 116, 115,
149083
- /* 230 */ 115, 114, 114, 114, 113, 414, 219, 119, 120, 110,
149084
- /* 240 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
149085
- /* 250 */ 118, 118, 511, 1477, 1115, 1116, 1117, 113, 414, 534,
149086
- /* 260 */ 528, 528, 528, 121, 534, 1427, 418, 116, 116, 116,
149087
- /* 270 */ 116, 115, 115, 114, 114, 114, 113, 414, 1464, 351,
149088
- /* 280 */ 270, 42, 42, 383, 187, 1115, 70, 70, 533, 433,
149089
- /* 290 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
149090
- /* 300 */ 414, 534, 1339, 405, 159, 411, 410, 119, 120, 110,
149091
- /* 310 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
149092
- /* 320 */ 118, 118, 285, 42, 42, 349, 411, 410, 514, 479,
149093
- /* 330 */ 1458, 79, 1084, 6, 1140, 1115, 1116, 1117, 480, 1142,
149094
- /* 340 */ 501, 1115, 1084, 123, 238, 1084, 136, 1141, 1234, 1234,
149095
- /* 350 */ 1143, 383, 1143, 1115, 167, 426, 80, 447, 512, 1451,
149096
- /* 360 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
149097
- /* 370 */ 414, 1143, 1466, 1143, 350, 119, 120, 110, 1136, 1136,
149098
- /* 380 */ 981, 984, 974, 974, 117, 117, 118, 118, 118, 118,
149099
- /* 390 */ 402, 1115, 1116, 1117, 500, 534, 250, 267, 336, 474,
149100
- /* 400 */ 331, 473, 236, 1115, 1116, 1117, 231, 1115, 329, 471,
149101
- /* 410 */ 468, 467, 509, 1458, 1464, 505, 6, 70, 70, 466,
149102
- /* 420 */ 181, 380, 379, 534, 971, 971, 982, 985, 116, 116,
149103
- /* 430 */ 116, 116, 115, 115, 114, 114, 114, 113, 414, 1115,
149104
- /* 440 */ 412, 412, 412, 496, 1115, 69, 69, 235, 383, 288,
149105
- /* 450 */ 525, 273, 326, 516, 337, 458, 1084, 1115, 1116, 1117,
149106
- /* 460 */ 1232, 1232, 492, 160, 508, 441, 1084, 1067, 1531, 1084,
149107
- /* 470 */ 207, 1531, 119, 120, 110, 1136, 1136, 981, 984, 974,
149108
- /* 480 */ 974, 117, 117, 118, 118, 118, 118, 881, 534, 1115,
149109
- /* 490 */ 1116, 1117, 975, 534, 1115, 1116, 1117, 534, 421, 534,
149110
- /* 500 */ 141, 534, 176, 356, 517, 1119, 32, 511, 482, 388,
149111
- /* 510 */ 70, 70, 818, 288, 525, 70, 70, 441, 499, 50,
149112
- /* 520 */ 50, 70, 70, 70, 70, 116, 116, 116, 116, 115,
149113
- /* 530 */ 115, 114, 114, 114, 113, 414, 274, 264, 264, 1115,
149114
- /* 540 */ 1065, 264, 264, 1115, 355, 383, 409, 961, 1439, 822,
149115
- /* 550 */ 531, 516, 190, 419, 531, 483, 1119, 516, 337, 516,
149116
- /* 560 */ 518, 1115, 818, 952, 382, 458, 515, 951, 481, 119,
149117
- /* 570 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
149118
- /* 580 */ 118, 118, 118, 118, 1338, 278, 1045, 278, 275, 1115,
149119
- /* 590 */ 1116, 1117, 259, 1115, 1116, 1117, 534, 5, 951, 951,
149120
- /* 600 */ 953, 1046, 231, 3, 143, 471, 468, 467, 1391, 463,
149121
- /* 610 */ 1115, 1115, 1116, 1117, 1452, 466, 1047, 836, 70, 70,
149122
- /* 620 */ 480, 534, 116, 116, 116, 116, 115, 115, 114, 114,
149123
- /* 630 */ 114, 113, 414, 95, 1115, 287, 235, 856, 902, 420,
149124
- /* 640 */ 1115, 534, 383, 13, 13, 381, 815, 857, 472, 112,
149125
- /* 650 */ 109, 209, 1115, 337, 413, 309, 837, 394, 1436, 534,
149126
- /* 660 */ 1115, 1116, 1117, 54, 54, 291, 119, 120, 110, 1136,
149127
- /* 670 */ 1136, 981, 984, 974, 974, 117, 117, 118, 118, 118,
149128
- /* 680 */ 118, 13, 13, 1084, 1115, 1116, 1117, 901, 264, 264,
149129
- /* 690 */ 1115, 1116, 1117, 1084, 292, 399, 1084, 800, 388, 140,
149130
- /* 700 */ 295, 531, 1115, 1116, 1117, 403, 447, 532, 534, 870,
149131
- /* 710 */ 870, 534, 1240, 534, 329, 534, 1185, 389, 534, 116,
149132
- /* 720 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 414,
149133
- /* 730 */ 13, 13, 1024, 13, 13, 13, 13, 13, 13, 383,
149134
- /* 740 */ 13, 13, 424, 1100, 401, 264, 264, 277, 160, 184,
149135
- /* 750 */ 1182, 185, 1533, 369, 513, 484, 432, 487, 531, 424,
149136
- /* 760 */ 423, 1397, 941, 119, 120, 110, 1136, 1136, 981, 984,
149137
- /* 770 */ 974, 974, 117, 117, 118, 118, 118, 118, 1397, 1399,
149138
- /* 780 */ 425, 519, 392, 264, 264, 1029, 1029, 455, 264, 264,
149139
- /* 790 */ 264, 264, 1004, 304, 261, 1278, 531, 900, 288, 525,
149140
- /* 800 */ 310, 531, 493, 531, 1067, 1532, 458, 387, 1532, 311,
149141
- /* 810 */ 429, 299, 534, 107, 264, 264, 116, 116, 116, 116,
149142
- /* 820 */ 115, 115, 114, 114, 114, 113, 414, 531, 424, 1384,
149143
- /* 830 */ 507, 258, 258, 1246, 55, 55, 383, 1277, 265, 265,
149144
- /* 840 */ 962, 324, 434, 312, 531, 531, 506, 1397, 1026, 1241,
149145
- /* 850 */ 298, 531, 1026, 445, 301, 1095, 303, 534, 368, 1156,
149146
- /* 860 */ 119, 120, 110, 1136, 1136, 981, 984, 974, 974, 117,
149147
- /* 870 */ 117, 118, 118, 118, 118, 1045, 534, 1065, 534, 15,
149148
- /* 880 */ 15, 1084, 208, 1324, 453, 452, 534, 1324, 534, 449,
149149
- /* 890 */ 1046, 1084, 494, 458, 1084, 234, 233, 232, 44, 44,
149150
- /* 900 */ 56, 56, 319, 1095, 322, 1047, 534, 900, 57, 57,
149151
- /* 910 */ 58, 58, 534, 116, 116, 116, 116, 115, 115, 114,
149152
- /* 920 */ 114, 114, 113, 414, 534, 514, 522, 534, 59, 59,
149153
- /* 930 */ 302, 1157, 534, 383, 60, 60, 1237, 946, 788, 789,
149154
- /* 940 */ 790, 1459, 1456, 446, 6, 6, 61, 61, 1212, 45,
149155
- /* 950 */ 45, 534, 396, 383, 46, 46, 397, 119, 120, 110,
149156
- /* 960 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
149157
- /* 970 */ 118, 118, 428, 48, 48, 534, 392, 119, 120, 110,
149158
- /* 980 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
149159
- /* 990 */ 118, 118, 1324, 368, 1066, 447, 825, 49, 49, 534,
149160
- /* 1000 */ 458, 357, 534, 353, 534, 138, 534, 337, 1478, 478,
149161
- /* 1010 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
149162
- /* 1020 */ 414, 62, 62, 392, 63, 63, 64, 64, 14, 14,
149163
- /* 1030 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
149164
- /* 1040 */ 414, 534, 810, 317, 271, 534, 1457, 825, 534, 6,
149165
- /* 1050 */ 534, 1324, 534, 142, 534, 1442, 534, 212, 534, 1324,
149166
- /* 1060 */ 534, 398, 305, 65, 65, 534, 1157, 125, 125, 476,
149167
- /* 1070 */ 66, 66, 51, 51, 67, 67, 68, 68, 52, 52,
149168
- /* 1080 */ 147, 147, 148, 148, 534, 98, 534, 75, 75, 276,
149169
- /* 1090 */ 534, 272, 534, 810, 534, 876, 534, 527, 389, 534,
149170
- /* 1100 */ 875, 534, 1151, 202, 534, 383, 53, 53, 71, 71,
149171
- /* 1110 */ 288, 525, 126, 126, 72, 72, 127, 127, 128, 128,
149172
- /* 1120 */ 454, 124, 124, 146, 146, 383, 145, 145, 408, 119,
149173
- /* 1130 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
149174
- /* 1140 */ 118, 118, 118, 118, 534, 900, 534, 95, 534, 119,
149175
- /* 1150 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
149176
- /* 1160 */ 118, 118, 118, 118, 390, 161, 132, 132, 131, 131,
149177
- /* 1170 */ 129, 129, 534, 915, 534, 1455, 534, 1454, 6, 1416,
149178
- /* 1180 */ 6, 916, 116, 116, 116, 116, 115, 115, 114, 114,
149179
- /* 1190 */ 114, 113, 414, 1415, 130, 130, 74, 74, 76, 76,
149180
- /* 1200 */ 534, 30, 116, 116, 116, 116, 115, 115, 114, 114,
149181
- /* 1210 */ 114, 113, 414, 534, 263, 206, 534, 1133, 1504, 93,
149182
- /* 1220 */ 876, 845, 73, 73, 102, 875, 100, 139, 17, 38,
149183
- /* 1230 */ 208, 1062, 31, 450, 370, 43, 43, 101, 47, 47,
149184
- /* 1240 */ 827, 216, 436, 308, 943, 440, 95, 241, 241, 442,
149185
- /* 1250 */ 313, 464, 241, 95, 237, 900, 327, 383, 266, 95,
149186
- /* 1260 */ 835, 834, 193, 335, 938, 314, 1011, 435, 842, 843,
149187
- /* 1270 */ 955, 1007, 909, 334, 237, 241, 873, 383, 1023, 107,
149188
- /* 1280 */ 1023, 119, 120, 110, 1136, 1136, 981, 984, 974, 974,
149189
- /* 1290 */ 117, 117, 118, 118, 118, 118, 1022, 808, 1022, 1274,
149190
- /* 1300 */ 137, 119, 108, 110, 1136, 1136, 981, 984, 974, 974,
149191
- /* 1310 */ 117, 117, 118, 118, 118, 118, 874, 1011, 318, 107,
149192
- /* 1320 */ 321, 955, 323, 325, 1225, 1211, 197, 1210, 1209, 330,
149193
- /* 1330 */ 339, 1265, 340, 283, 116, 116, 116, 116, 115, 115,
149194
- /* 1340 */ 114, 114, 114, 113, 414, 1286, 1323, 1261, 1471, 1272,
149195
- /* 1350 */ 520, 218, 521, 1329, 116, 116, 116, 116, 115, 115,
149196
- /* 1360 */ 114, 114, 114, 113, 414, 1192, 1184, 1173, 1172, 1174,
149197
- /* 1370 */ 1494, 1488, 459, 256, 383, 1258, 342, 199, 367, 344,
149198
- /* 1380 */ 211, 195, 307, 444, 11, 346, 469, 333, 1308, 1316,
149199
- /* 1390 */ 375, 427, 203, 360, 383, 1388, 188, 1387, 189, 120,
149200
- /* 1400 */ 110, 1136, 1136, 981, 984, 974, 974, 117, 117, 118,
149201
- /* 1410 */ 118, 118, 118, 1208, 1151, 300, 348, 1491, 245, 1148,
149202
- /* 1420 */ 110, 1136, 1136, 981, 984, 974, 974, 117, 117, 118,
149203
- /* 1430 */ 118, 118, 118, 198, 1435, 1433, 524, 78, 391, 163,
149204
- /* 1440 */ 82, 1393, 438, 173, 81, 105, 526, 1313, 4, 35,
149205
- /* 1450 */ 157, 116, 116, 116, 116, 115, 115, 114, 114, 114,
149206
- /* 1460 */ 113, 414, 529, 165, 93, 430, 1305, 168, 169, 431,
149207
- /* 1470 */ 462, 116, 116, 116, 116, 115, 115, 114, 114, 114,
149208
- /* 1480 */ 113, 414, 170, 171, 221, 415, 372, 437, 1319, 177,
149209
- /* 1490 */ 374, 36, 451, 225, 1382, 87, 457, 523, 257, 1404,
149210
- /* 1500 */ 316, 105, 526, 227, 4, 182, 460, 160, 320, 228,
149211
- /* 1510 */ 377, 1175, 475, 229, 1228, 404, 1227, 1226, 529, 827,
149212
- /* 1520 */ 961, 1219, 378, 1200, 1199, 406, 103, 103, 1218, 332,
149213
- /* 1530 */ 8, 281, 1198, 104, 1503, 415, 536, 535, 486, 282,
149214
- /* 1540 */ 951, 415, 489, 495, 92, 244, 1269, 341, 243, 122,
149215
- /* 1550 */ 1270, 343, 514, 523, 1268, 1462, 10, 288, 525, 345,
149216
- /* 1560 */ 1461, 354, 99, 352, 503, 94, 1267, 347, 1251, 502,
149217
- /* 1570 */ 498, 951, 951, 953, 954, 27, 961, 1250, 194, 358,
149218
- /* 1580 */ 251, 359, 103, 103, 1181, 34, 537, 1110, 252, 104,
149219
- /* 1590 */ 254, 415, 536, 535, 255, 1368, 951, 1420, 286, 538,
149220
- /* 1600 */ 1170, 1165, 1421, 135, 1419, 1418, 149, 150, 279, 784,
149221
- /* 1610 */ 416, 196, 151, 290, 210, 200, 77, 385, 269, 386,
149222
- /* 1620 */ 133, 162, 935, 1021, 201, 1019, 153, 951, 951, 953,
149223
- /* 1630 */ 954, 27, 1480, 1104, 417, 164, 217, 268, 859, 166,
149224
- /* 1640 */ 306, 1035, 366, 366, 365, 253, 363, 220, 172, 797,
149225
- /* 1650 */ 939, 155, 105, 526, 393, 4, 395, 174, 156, 83,
149226
- /* 1660 */ 1038, 84, 213, 85, 294, 222, 86, 223, 1034, 529,
149227
- /* 1670 */ 144, 18, 293, 224, 315, 456, 241, 1027, 1145, 178,
149228
- /* 1680 */ 226, 179, 37, 799, 334, 461, 230, 465, 470, 838,
149229
- /* 1690 */ 180, 88, 415, 19, 280, 328, 20, 89, 90, 158,
149230
- /* 1700 */ 191, 477, 215, 1097, 523, 204, 192, 987, 91, 1070,
149231
- /* 1710 */ 152, 39, 485, 154, 1071, 503, 40, 488, 205, 260,
149232
- /* 1720 */ 504, 262, 105, 526, 214, 4, 908, 961, 183, 240,
149233
- /* 1730 */ 903, 107, 1086, 103, 103, 21, 22, 1088, 23, 529,
149234
- /* 1740 */ 104, 24, 415, 536, 535, 1090, 1093, 951, 1094, 25,
149235
- /* 1750 */ 1074, 33, 7, 26, 510, 1002, 247, 186, 384, 95,
149236
- /* 1760 */ 988, 986, 415, 288, 525, 990, 1044, 246, 1043, 991,
149237
- /* 1770 */ 28, 41, 530, 956, 523, 809, 106, 29, 951, 951,
149238
- /* 1780 */ 953, 954, 27, 869, 361, 503, 422, 248, 364, 1105,
149239
- /* 1790 */ 502, 249, 1161, 1496, 1495, 1161, 1161, 961, 1161, 1161,
149240
- /* 1800 */ 1161, 1161, 1161, 103, 103, 1161, 1161, 1161, 1161, 1161,
149241
- /* 1810 */ 104, 1161, 415, 536, 535, 1104, 417, 951, 1161, 268,
149242
- /* 1820 */ 1161, 1161, 1161, 1161, 366, 366, 365, 253, 363, 1161,
149243
- /* 1830 */ 1161, 797, 1161, 1161, 1161, 1161, 105, 526, 1161, 4,
149244
- /* 1840 */ 1161, 1161, 1161, 1161, 213, 1161, 294, 1161, 951, 951,
149245
- /* 1850 */ 953, 954, 27, 529, 293, 1161, 1161, 1161, 1161, 1161,
149246
- /* 1860 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
149247
- /* 1870 */ 1161, 1161, 1161, 1161, 1161, 1161, 415, 1161, 1161, 1161,
149248
- /* 1880 */ 1161, 1161, 1161, 1161, 215, 1161, 1161, 1161, 523, 1161,
149249
- /* 1890 */ 1161, 1161, 152, 1161, 1161, 154, 105, 526, 1161, 4,
149250
- /* 1900 */ 1161, 1161, 1161, 1161, 1161, 1161, 214, 1161, 1161, 1161,
149251
- /* 1910 */ 1161, 961, 1161, 529, 1161, 1161, 1161, 103, 103, 880,
149252
- /* 1920 */ 1161, 1161, 1161, 1161, 104, 1161, 415, 536, 535, 1161,
149253
- /* 1930 */ 1161, 951, 1161, 1161, 1161, 1161, 415, 1161, 1161, 1161,
149254
- /* 1940 */ 384, 1161, 1161, 1161, 1161, 288, 525, 1161, 523, 1161,
149255
- /* 1950 */ 1161, 1161, 1161, 1161, 1161, 1161, 97, 526, 1161, 4,
149256
- /* 1960 */ 1161, 1161, 951, 951, 953, 954, 27, 1161, 422, 1161,
149257
- /* 1970 */ 1161, 961, 1161, 529, 1161, 1161, 1161, 103, 103, 1161,
149258
- /* 1980 */ 1161, 1161, 1161, 1161, 104, 1161, 415, 536, 535, 1161,
149259
- /* 1990 */ 1161, 951, 268, 1161, 1161, 1161, 415, 366, 366, 365,
149260
- /* 2000 */ 253, 363, 1161, 1161, 797, 1161, 1161, 1161, 523, 1161,
149261
- /* 2010 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 213, 1161, 294,
149262
- /* 2020 */ 1161, 1161, 951, 951, 953, 954, 27, 293, 1161, 1161,
149263
- /* 2030 */ 1161, 961, 1161, 1161, 1161, 1161, 1161, 103, 103, 1161,
149264
- /* 2040 */ 1161, 1161, 1161, 1161, 104, 1161, 415, 536, 535, 1161,
149265
- /* 2050 */ 1161, 951, 1161, 1161, 1161, 1161, 1161, 215, 1161, 1161,
149266
- /* 2060 */ 1161, 1161, 1161, 1161, 1161, 152, 1161, 1161, 154, 1161,
149267
- /* 2070 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 214,
149268
- /* 2080 */ 1161, 1161, 951, 951, 953, 954, 27, 1161, 1161, 1161,
149269
- /* 2090 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
149270
- /* 2100 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
149271
- /* 2110 */ 1161, 1161, 1161, 384, 1161, 1161, 1161, 1161, 288, 525,
149272
- /* 2120 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
149273
- /* 2130 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
149274
- /* 2140 */ 1161, 422,
149808
+ /* 0 */ 537, 339, 537, 1241, 1220, 537, 12, 537, 112, 109,
149809
+ /* 10 */ 209, 537, 1241, 537, 1205, 462, 112, 109, 209, 386,
149810
+ /* 20 */ 338, 462, 42, 42, 42, 42, 445, 42, 42, 70,
149811
+ /* 30 */ 70, 922, 1208, 70, 70, 70, 70, 1443, 403, 923,
149812
+ /* 40 */ 531, 531, 531, 119, 120, 110, 1148, 1148, 991, 994,
149813
+ /* 50 */ 984, 984, 117, 117, 118, 118, 118, 118, 425, 386,
149814
+ /* 60 */ 1498, 542, 2, 1176, 1442, 519, 141, 1518, 289, 519,
149815
+ /* 70 */ 134, 519, 95, 259, 495, 1215, 189, 1254, 518, 494,
149816
+ /* 80 */ 484, 437, 296, 119, 120, 110, 1148, 1148, 991, 994,
149817
+ /* 90 */ 984, 984, 117, 117, 118, 118, 118, 118, 270, 116,
149818
+ /* 100 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
149819
+ /* 110 */ 264, 264, 264, 264, 423, 1479, 352, 1481, 123, 351,
149820
+ /* 120 */ 1479, 508, 1094, 534, 1034, 534, 1099, 386, 1099, 239,
149821
+ /* 130 */ 206, 112, 109, 209, 96, 1094, 376, 219, 1094, 116,
149822
+ /* 140 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
149823
+ /* 150 */ 480, 119, 120, 110, 1148, 1148, 991, 994, 984, 984,
149824
+ /* 160 */ 117, 117, 118, 118, 118, 118, 353, 422, 1407, 264,
149825
+ /* 170 */ 264, 114, 114, 114, 113, 418, 883, 121, 416, 416,
149826
+ /* 180 */ 416, 882, 534, 116, 116, 116, 116, 115, 115, 114,
149827
+ /* 190 */ 114, 114, 113, 418, 212, 415, 414, 386, 443, 383,
149828
+ /* 200 */ 382, 118, 118, 118, 118, 111, 177, 116, 116, 116,
149829
+ /* 210 */ 116, 115, 115, 114, 114, 114, 113, 418, 112, 109,
149830
+ /* 220 */ 209, 119, 120, 110, 1148, 1148, 991, 994, 984, 984,
149831
+ /* 230 */ 117, 117, 118, 118, 118, 118, 386, 438, 312, 1163,
149832
+ /* 240 */ 1155, 80, 1155, 1127, 514, 79, 116, 116, 116, 116,
149833
+ /* 250 */ 115, 115, 114, 114, 114, 113, 418, 514, 428, 418,
149834
+ /* 260 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
149835
+ /* 270 */ 117, 118, 118, 118, 118, 428, 427, 116, 116, 116,
149836
+ /* 280 */ 116, 115, 115, 114, 114, 114, 113, 418, 115, 115,
149837
+ /* 290 */ 114, 114, 114, 113, 418, 1127, 1127, 1128, 1129, 1094,
149838
+ /* 300 */ 258, 258, 192, 386, 408, 371, 1168, 326, 118, 118,
149839
+ /* 310 */ 118, 118, 1094, 534, 374, 1094, 116, 116, 116, 116,
149840
+ /* 320 */ 115, 115, 114, 114, 114, 113, 418, 119, 120, 110,
149841
+ /* 330 */ 1148, 1148, 991, 994, 984, 984, 117, 117, 118, 118,
149842
+ /* 340 */ 118, 118, 386, 354, 445, 428, 829, 238, 1127, 1128,
149843
+ /* 350 */ 1129, 515, 1466, 116, 116, 116, 116, 115, 115, 114,
149844
+ /* 360 */ 114, 114, 113, 418, 1127, 1467, 119, 120, 110, 1148,
149845
+ /* 370 */ 1148, 991, 994, 984, 984, 117, 117, 118, 118, 118,
149846
+ /* 380 */ 118, 1169, 82, 116, 116, 116, 116, 115, 115, 114,
149847
+ /* 390 */ 114, 114, 113, 418, 405, 112, 109, 209, 161, 445,
149848
+ /* 400 */ 250, 267, 336, 478, 331, 477, 236, 951, 1127, 386,
149849
+ /* 410 */ 888, 1521, 329, 822, 852, 162, 274, 1127, 1128, 1129,
149850
+ /* 420 */ 338, 169, 116, 116, 116, 116, 115, 115, 114, 114,
149851
+ /* 430 */ 114, 113, 418, 119, 120, 110, 1148, 1148, 991, 994,
149852
+ /* 440 */ 984, 984, 117, 117, 118, 118, 118, 118, 386, 438,
149853
+ /* 450 */ 312, 1502, 1112, 1176, 161, 288, 528, 311, 289, 883,
149854
+ /* 460 */ 134, 1127, 1128, 1129, 882, 537, 143, 1254, 288, 528,
149855
+ /* 470 */ 297, 275, 119, 120, 110, 1148, 1148, 991, 994, 984,
149856
+ /* 480 */ 984, 117, 117, 118, 118, 118, 118, 70, 70, 116,
149857
+ /* 490 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
149858
+ /* 500 */ 264, 264, 12, 264, 264, 395, 1127, 483, 1473, 1094,
149859
+ /* 510 */ 204, 482, 6, 534, 1258, 386, 534, 1474, 825, 972,
149860
+ /* 520 */ 504, 6, 1094, 500, 95, 1094, 534, 219, 116, 116,
149861
+ /* 530 */ 116, 116, 115, 115, 114, 114, 114, 113, 418, 119,
149862
+ /* 540 */ 120, 110, 1148, 1148, 991, 994, 984, 984, 117, 117,
149863
+ /* 550 */ 118, 118, 118, 118, 386, 1339, 971, 422, 956, 1127,
149864
+ /* 560 */ 1128, 1129, 231, 512, 1473, 475, 472, 471, 6, 113,
149865
+ /* 570 */ 418, 825, 962, 298, 503, 470, 961, 452, 119, 120,
149866
+ /* 580 */ 110, 1148, 1148, 991, 994, 984, 984, 117, 117, 118,
149867
+ /* 590 */ 118, 118, 118, 395, 537, 116, 116, 116, 116, 115,
149868
+ /* 600 */ 115, 114, 114, 114, 113, 418, 202, 961, 961, 963,
149869
+ /* 610 */ 231, 971, 1127, 475, 472, 471, 13, 13, 951, 1127,
149870
+ /* 620 */ 834, 386, 1207, 470, 399, 183, 447, 962, 462, 162,
149871
+ /* 630 */ 397, 961, 1246, 1246, 116, 116, 116, 116, 115, 115,
149872
+ /* 640 */ 114, 114, 114, 113, 418, 119, 120, 110, 1148, 1148,
149873
+ /* 650 */ 991, 994, 984, 984, 117, 117, 118, 118, 118, 118,
149874
+ /* 660 */ 386, 271, 961, 961, 963, 1127, 1128, 1129, 311, 433,
149875
+ /* 670 */ 299, 1406, 1127, 1128, 1129, 178, 1471, 138, 162, 32,
149876
+ /* 680 */ 6, 1127, 288, 528, 119, 120, 110, 1148, 1148, 991,
149877
+ /* 690 */ 994, 984, 984, 117, 117, 118, 118, 118, 118, 909,
149878
+ /* 700 */ 390, 116, 116, 116, 116, 115, 115, 114, 114, 114,
149879
+ /* 710 */ 113, 418, 1127, 429, 817, 537, 1127, 265, 265, 981,
149880
+ /* 720 */ 981, 992, 995, 324, 1055, 93, 520, 5, 338, 537,
149881
+ /* 730 */ 534, 288, 528, 1522, 1127, 1128, 1129, 70, 70, 1056,
149882
+ /* 740 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
149883
+ /* 750 */ 418, 70, 70, 1495, 1057, 537, 98, 1244, 1244, 264,
149884
+ /* 760 */ 264, 908, 371, 1076, 1127, 1127, 1128, 1129, 817, 1127,
149885
+ /* 770 */ 1128, 1129, 534, 519, 140, 863, 386, 13, 13, 456,
149886
+ /* 780 */ 192, 193, 521, 453, 319, 864, 322, 284, 365, 430,
149887
+ /* 790 */ 985, 402, 379, 1077, 1548, 101, 386, 1548, 3, 395,
149888
+ /* 800 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
149889
+ /* 810 */ 117, 118, 118, 118, 118, 386, 451, 1127, 1128, 1129,
149890
+ /* 820 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
149891
+ /* 830 */ 117, 118, 118, 118, 118, 1127, 1354, 1412, 1169, 119,
149892
+ /* 840 */ 108, 110, 1148, 1148, 991, 994, 984, 984, 117, 117,
149893
+ /* 850 */ 118, 118, 118, 118, 1412, 1414, 116, 116, 116, 116,
149894
+ /* 860 */ 115, 115, 114, 114, 114, 113, 418, 272, 535, 1075,
149895
+ /* 870 */ 877, 877, 337, 1492, 309, 462, 116, 116, 116, 116,
149896
+ /* 880 */ 115, 115, 114, 114, 114, 113, 418, 537, 1127, 1128,
149897
+ /* 890 */ 1129, 537, 360, 537, 356, 116, 116, 116, 116, 115,
149898
+ /* 900 */ 115, 114, 114, 114, 113, 418, 386, 264, 264, 13,
149899
+ /* 910 */ 13, 273, 1127, 13, 13, 13, 13, 304, 1253, 386,
149900
+ /* 920 */ 534, 1077, 1549, 404, 1412, 1549, 496, 277, 451, 186,
149901
+ /* 930 */ 1252, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
149902
+ /* 940 */ 117, 118, 118, 118, 118, 110, 1148, 1148, 991, 994,
149903
+ /* 950 */ 984, 984, 117, 117, 118, 118, 118, 118, 105, 529,
149904
+ /* 960 */ 537, 4, 1339, 264, 264, 1127, 1128, 1129, 1039, 1039,
149905
+ /* 970 */ 459, 795, 796, 797, 536, 532, 534, 242, 301, 807,
149906
+ /* 980 */ 303, 462, 69, 69, 451, 1353, 116, 116, 116, 116,
149907
+ /* 990 */ 115, 115, 114, 114, 114, 113, 418, 1075, 419, 116,
149908
+ /* 1000 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
149909
+ /* 1010 */ 526, 537, 1146, 192, 350, 105, 529, 537, 4, 497,
149910
+ /* 1020 */ 162, 337, 1492, 310, 1249, 385, 1550, 372, 9, 462,
149911
+ /* 1030 */ 242, 400, 532, 13, 13, 499, 971, 843, 436, 70,
149912
+ /* 1040 */ 70, 359, 103, 103, 8, 339, 278, 187, 278, 104,
149913
+ /* 1050 */ 1127, 419, 539, 538, 1339, 419, 961, 302, 1339, 1172,
149914
+ /* 1060 */ 1, 1, 542, 2, 1176, 1146, 1146, 526, 476, 289,
149915
+ /* 1070 */ 30, 134, 317, 288, 528, 285, 844, 1014, 1254, 276,
149916
+ /* 1080 */ 1472, 506, 410, 1194, 6, 207, 505, 961, 961, 963,
149917
+ /* 1090 */ 964, 27, 449, 971, 415, 414, 234, 233, 232, 103,
149918
+ /* 1100 */ 103, 31, 1152, 1127, 1128, 1129, 104, 1154, 419, 539,
149919
+ /* 1110 */ 538, 264, 264, 961, 1399, 1153, 264, 264, 1470, 1146,
149920
+ /* 1120 */ 537, 216, 6, 401, 534, 1197, 392, 458, 406, 534,
149921
+ /* 1130 */ 537, 485, 358, 537, 261, 537, 1339, 907, 219, 1155,
149922
+ /* 1140 */ 467, 1155, 50, 50, 961, 961, 963, 964, 27, 1497,
149923
+ /* 1150 */ 1116, 421, 70, 70, 268, 70, 70, 13, 13, 369,
149924
+ /* 1160 */ 369, 368, 253, 366, 264, 264, 804, 235, 422, 105,
149925
+ /* 1170 */ 529, 516, 4, 287, 487, 510, 493, 534, 486, 213,
149926
+ /* 1180 */ 1055, 294, 490, 384, 1127, 450, 532, 338, 413, 293,
149927
+ /* 1190 */ 522, 417, 335, 1036, 509, 1056, 107, 1036, 16, 16,
149928
+ /* 1200 */ 1469, 1094, 334, 1105, 6, 411, 1145, 264, 264, 419,
149929
+ /* 1210 */ 1057, 102, 511, 100, 1094, 264, 264, 1094, 922, 215,
149930
+ /* 1220 */ 534, 526, 907, 264, 264, 208, 923, 154, 534, 457,
149931
+ /* 1230 */ 156, 525, 391, 142, 218, 506, 534, 1127, 1128, 1129,
149932
+ /* 1240 */ 507, 139, 1131, 38, 214, 530, 392, 971, 329, 1454,
149933
+ /* 1250 */ 907, 1105, 537, 103, 103, 105, 529, 537, 4, 537,
149934
+ /* 1260 */ 104, 424, 419, 539, 538, 537, 502, 961, 517, 537,
149935
+ /* 1270 */ 1072, 537, 532, 373, 54, 54, 288, 528, 387, 55,
149936
+ /* 1280 */ 55, 15, 15, 288, 528, 17, 136, 44, 44, 1451,
149937
+ /* 1290 */ 537, 56, 56, 57, 57, 419, 1131, 291, 961, 961,
149938
+ /* 1300 */ 963, 964, 27, 393, 163, 537, 426, 526, 263, 206,
149939
+ /* 1310 */ 208, 517, 58, 58, 235, 440, 842, 841, 197, 105,
149940
+ /* 1320 */ 529, 506, 4, 1033, 439, 1033, 505, 59, 59, 308,
149941
+ /* 1330 */ 849, 850, 95, 971, 537, 907, 532, 948, 832, 103,
149942
+ /* 1340 */ 103, 105, 529, 537, 4, 1021, 104, 537, 419, 539,
149943
+ /* 1350 */ 538, 1116, 421, 961, 537, 268, 60, 60, 532, 419,
149944
+ /* 1360 */ 369, 369, 368, 253, 366, 61, 61, 804, 965, 45,
149945
+ /* 1370 */ 45, 526, 537, 1032, 1277, 1032, 46, 46, 537, 391,
149946
+ /* 1380 */ 213, 419, 294, 266, 961, 961, 963, 964, 27, 292,
149947
+ /* 1390 */ 293, 295, 832, 526, 48, 48, 1290, 971, 1289, 1021,
149948
+ /* 1400 */ 49, 49, 432, 103, 103, 887, 953, 537, 1457, 241,
149949
+ /* 1410 */ 104, 305, 419, 539, 538, 925, 926, 961, 444, 971,
149950
+ /* 1420 */ 215, 241, 965, 1224, 537, 103, 103, 1431, 154, 62,
149951
+ /* 1430 */ 62, 156, 104, 1430, 419, 539, 538, 97, 529, 961,
149952
+ /* 1440 */ 4, 537, 454, 537, 314, 214, 63, 63, 961, 961,
149953
+ /* 1450 */ 963, 964, 27, 537, 532, 446, 1286, 318, 241, 537,
149954
+ /* 1460 */ 321, 323, 325, 64, 64, 14, 14, 1237, 537, 1223,
149955
+ /* 1470 */ 961, 961, 963, 964, 27, 65, 65, 419, 537, 387,
149956
+ /* 1480 */ 537, 125, 125, 537, 288, 528, 537, 1486, 537, 526,
149957
+ /* 1490 */ 66, 66, 313, 524, 537, 95, 468, 1221, 1511, 237,
149958
+ /* 1500 */ 51, 51, 67, 67, 330, 68, 68, 426, 52, 52,
149959
+ /* 1510 */ 149, 149, 1222, 340, 341, 971, 150, 150, 1298, 463,
149960
+ /* 1520 */ 327, 103, 103, 95, 537, 1338, 1273, 537, 104, 537,
149961
+ /* 1530 */ 419, 539, 538, 1284, 537, 961, 268, 283, 523, 1344,
149962
+ /* 1540 */ 1204, 369, 369, 368, 253, 366, 75, 75, 804, 53,
149963
+ /* 1550 */ 53, 71, 71, 537, 1196, 537, 126, 126, 537, 1017,
149964
+ /* 1560 */ 537, 213, 237, 294, 537, 1185, 961, 961, 963, 964,
149965
+ /* 1570 */ 27, 293, 537, 1184, 537, 72, 72, 127, 127, 1186,
149966
+ /* 1580 */ 128, 128, 124, 124, 1505, 537, 148, 148, 537, 256,
149967
+ /* 1590 */ 195, 537, 1270, 537, 147, 147, 132, 132, 537, 11,
149968
+ /* 1600 */ 537, 215, 537, 199, 343, 345, 347, 131, 131, 154,
149969
+ /* 1610 */ 129, 129, 156, 130, 130, 74, 74, 537, 370, 1323,
149970
+ /* 1620 */ 76, 76, 73, 73, 43, 43, 214, 431, 211, 1331,
149971
+ /* 1630 */ 300, 916, 880, 815, 241, 107, 137, 307, 881, 47,
149972
+ /* 1640 */ 47, 107, 473, 378, 203, 448, 333, 1403, 1220, 1402,
149973
+ /* 1650 */ 349, 190, 527, 191, 363, 198, 1508, 1163, 245, 165,
149974
+ /* 1660 */ 387, 1450, 1448, 1160, 78, 288, 528, 1408, 81, 394,
149975
+ /* 1670 */ 82, 442, 175, 159, 167, 93, 1328, 35, 1320, 434,
149976
+ /* 1680 */ 170, 171, 172, 173, 435, 466, 221, 375, 426, 377,
149977
+ /* 1690 */ 1334, 179, 455, 441, 1397, 225, 87, 36, 461, 1419,
149978
+ /* 1700 */ 316, 257, 227, 184, 320, 464, 228, 479, 1187, 229,
149979
+ /* 1710 */ 380, 1240, 1239, 407, 1238, 1212, 834, 332, 1231, 381,
149980
+ /* 1720 */ 409, 1211, 204, 1210, 1491, 498, 1520, 1281, 92, 281,
149981
+ /* 1730 */ 1230, 489, 282, 492, 342, 243, 1282, 344, 244, 1280,
149982
+ /* 1740 */ 346, 412, 1279, 1477, 348, 122, 1476, 517, 10, 357,
149983
+ /* 1750 */ 286, 1305, 1304, 99, 1383, 94, 501, 251, 1193, 34,
149984
+ /* 1760 */ 1263, 355, 540, 194, 1262, 361, 362, 1122, 252, 254,
149985
+ /* 1770 */ 255, 388, 541, 1182, 1177, 151, 1435, 389, 1436, 1434,
149986
+ /* 1780 */ 1433, 791, 152, 135, 279, 200, 201, 420, 196, 77,
149987
+ /* 1790 */ 153, 290, 269, 210, 1031, 133, 1029, 945, 166, 155,
149988
+ /* 1800 */ 217, 168, 866, 306, 220, 1045, 174, 949, 157, 396,
149989
+ /* 1810 */ 83, 398, 176, 84, 85, 164, 86, 158, 1048, 222,
149990
+ /* 1820 */ 223, 1044, 144, 18, 224, 315, 1037, 180, 241, 460,
149991
+ /* 1830 */ 1157, 226, 181, 37, 806, 465, 334, 230, 328, 469,
149992
+ /* 1840 */ 182, 88, 474, 19, 20, 160, 89, 280, 145, 90,
149993
+ /* 1850 */ 481, 845, 1110, 146, 997, 205, 1080, 39, 91, 40,
149994
+ /* 1860 */ 488, 1081, 915, 491, 260, 262, 185, 910, 240, 107,
149995
+ /* 1870 */ 1100, 1096, 1098, 1104, 21, 1084, 33, 513, 247, 22,
149996
+ /* 1880 */ 23, 24, 1103, 25, 188, 95, 1012, 998, 996, 26,
149997
+ /* 1890 */ 1000, 1054, 7, 1053, 1001, 246, 28, 41, 533, 966,
149998
+ /* 1900 */ 816, 106, 29, 367, 248, 249, 1513, 1512, 364, 1117,
149999
+ /* 1910 */ 1173, 1173, 876,
149275150000
};
149276150001
static const YYCODETYPE yy_lookahead[] = {
149277
- /* 0 */ 260, 261, 262, 260, 261, 262, 176, 177, 178, 179,
149278
- /* 10 */ 180, 181, 184, 206, 209, 184, 186, 206, 188, 19,
149279
- /* 20 */ 179, 281, 181, 213, 214, 195, 206, 186, 195, 188,
149280
- /* 30 */ 195, 31, 222, 184, 206, 207, 195, 206, 207, 39,
149281
- /* 40 */ 24, 209, 184, 43, 44, 45, 46, 47, 48, 49,
149282
- /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 228, 229,
149283
- /* 60 */ 184, 228, 229, 228, 229, 260, 261, 262, 192, 228,
149284
- /* 70 */ 229, 241, 196, 242, 241, 59, 241, 205, 245, 246,
149285
- /* 80 */ 184, 22, 241, 24, 254, 213, 54, 55, 56, 57,
149286
- /* 90 */ 58, 256, 260, 261, 262, 254, 96, 97, 98, 99,
149287
- /* 100 */ 100, 101, 102, 103, 104, 105, 106, 100, 101, 102,
149288
- /* 110 */ 103, 104, 105, 106, 284, 203, 19, 221, 59, 102,
149289
- /* 120 */ 103, 104, 105, 106, 59, 284, 110, 269, 96, 97,
149290
- /* 130 */ 98, 99, 100, 101, 102, 103, 104, 105, 106, 94,
149291
- /* 140 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
149292
- /* 150 */ 53, 54, 55, 56, 57, 110, 184, 106, 73, 114,
149293
- /* 160 */ 178, 179, 180, 181, 219, 184, 81, 22, 186, 110,
149294
- /* 170 */ 188, 121, 122, 195, 109, 110, 111, 195, 206, 207,
149295
- /* 180 */ 83, 184, 85, 54, 55, 56, 57, 206, 207, 277,
149296
- /* 190 */ 145, 146, 147, 96, 97, 98, 99, 100, 101, 102,
149297
- /* 200 */ 103, 104, 105, 106, 59, 120, 228, 229, 143, 184,
149298
- /* 210 */ 228, 229, 184, 19, 242, 203, 131, 132, 221, 241,
149299
- /* 220 */ 26, 184, 184, 241, 196, 96, 97, 98, 99, 100,
149300
- /* 230 */ 101, 102, 103, 104, 105, 106, 254, 43, 44, 45,
149301
- /* 240 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
149302
- /* 250 */ 56, 57, 184, 184, 109, 110, 111, 105, 106, 184,
149303
- /* 260 */ 200, 201, 202, 69, 184, 227, 284, 96, 97, 98,
149304
- /* 270 */ 99, 100, 101, 102, 103, 104, 105, 106, 297, 298,
149305
- /* 280 */ 255, 206, 207, 19, 272, 59, 206, 207, 184, 277,
149306
- /* 290 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
149307
- /* 300 */ 106, 184, 259, 19, 184, 100, 101, 43, 44, 45,
149308
- /* 310 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
149309
- /* 320 */ 56, 57, 242, 206, 207, 184, 100, 101, 138, 292,
149310
- /* 330 */ 293, 67, 76, 296, 108, 109, 110, 111, 295, 113,
149311
- /* 340 */ 84, 59, 86, 22, 26, 89, 156, 121, 224, 225,
149312
- /* 350 */ 145, 19, 147, 59, 72, 256, 24, 184, 290, 291,
149313
- /* 360 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
149314
- /* 370 */ 106, 145, 297, 147, 299, 43, 44, 45, 46, 47,
149315
- /* 380 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
149316
- /* 390 */ 106, 109, 110, 111, 138, 184, 112, 113, 114, 115,
149317
- /* 400 */ 116, 117, 118, 109, 110, 111, 112, 59, 124, 115,
149318
- /* 410 */ 116, 117, 292, 293, 297, 298, 296, 206, 207, 125,
149319
- /* 420 */ 72, 100, 101, 184, 46, 47, 48, 49, 96, 97,
149320
- /* 430 */ 98, 99, 100, 101, 102, 103, 104, 105, 106, 59,
149321
- /* 440 */ 200, 201, 202, 184, 59, 206, 207, 46, 19, 131,
149322
- /* 450 */ 132, 278, 23, 242, 184, 184, 76, 109, 110, 111,
149323
- /* 460 */ 224, 225, 251, 81, 84, 184, 86, 22, 23, 89,
149324
- /* 470 */ 184, 26, 43, 44, 45, 46, 47, 48, 49, 50,
149325
- /* 480 */ 51, 52, 53, 54, 55, 56, 57, 102, 184, 109,
149326
- /* 490 */ 110, 111, 114, 184, 109, 110, 111, 184, 227, 184,
149327
- /* 500 */ 230, 184, 22, 264, 195, 59, 22, 184, 195, 108,
149328
- /* 510 */ 206, 207, 59, 131, 132, 206, 207, 184, 138, 206,
149329
- /* 520 */ 207, 206, 207, 206, 207, 96, 97, 98, 99, 100,
149330
- /* 530 */ 101, 102, 103, 104, 105, 106, 255, 228, 229, 59,
149331
- /* 540 */ 95, 228, 229, 59, 184, 19, 242, 94, 184, 23,
149332
- /* 550 */ 241, 242, 184, 282, 241, 242, 110, 242, 184, 242,
149333
- /* 560 */ 251, 59, 109, 110, 196, 184, 251, 114, 251, 43,
149334
- /* 570 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
149335
- /* 580 */ 54, 55, 56, 57, 259, 217, 12, 219, 255, 109,
149336
- /* 590 */ 110, 111, 203, 109, 110, 111, 184, 22, 145, 146,
149337
- /* 600 */ 147, 27, 112, 22, 230, 115, 116, 117, 227, 19,
149338
- /* 610 */ 59, 109, 110, 111, 291, 125, 42, 35, 206, 207,
149339
- /* 620 */ 295, 184, 96, 97, 98, 99, 100, 101, 102, 103,
149340
- /* 630 */ 104, 105, 106, 26, 59, 233, 46, 63, 136, 184,
149341
- /* 640 */ 59, 184, 19, 206, 207, 243, 23, 73, 66, 260,
149342
- /* 650 */ 261, 262, 59, 184, 242, 195, 74, 220, 184, 184,
149343
- /* 660 */ 109, 110, 111, 206, 207, 184, 43, 44, 45, 46,
149344
- /* 670 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
149345
- /* 680 */ 57, 206, 207, 76, 109, 110, 111, 136, 228, 229,
149346
- /* 690 */ 109, 110, 111, 86, 184, 220, 89, 21, 108, 230,
149347
- /* 700 */ 184, 241, 109, 110, 111, 123, 184, 127, 184, 129,
149348
- /* 710 */ 130, 184, 195, 184, 124, 184, 198, 199, 184, 96,
149349
- /* 720 */ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
149350
- /* 730 */ 206, 207, 11, 206, 207, 206, 207, 206, 207, 19,
149351
- /* 740 */ 206, 207, 184, 23, 220, 228, 229, 220, 81, 220,
149352
- /* 750 */ 195, 220, 287, 288, 220, 195, 80, 195, 241, 201,
149353
- /* 760 */ 202, 184, 73, 43, 44, 45, 46, 47, 48, 49,
149354
- /* 770 */ 50, 51, 52, 53, 54, 55, 56, 57, 201, 202,
149355
- /* 780 */ 113, 195, 184, 228, 229, 120, 121, 122, 228, 229,
149356
- /* 790 */ 228, 229, 116, 16, 23, 184, 241, 26, 131, 132,
149357
- /* 800 */ 278, 241, 19, 241, 22, 23, 184, 189, 26, 120,
149358
- /* 810 */ 121, 122, 184, 26, 228, 229, 96, 97, 98, 99,
149359
- /* 820 */ 100, 101, 102, 103, 104, 105, 106, 241, 270, 153,
149360
- /* 830 */ 66, 228, 229, 229, 206, 207, 19, 184, 228, 229,
149361
- /* 840 */ 23, 16, 121, 122, 241, 241, 82, 270, 29, 227,
149362
- /* 850 */ 252, 241, 33, 19, 77, 91, 79, 184, 22, 23,
149363
- /* 860 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
149364
- /* 870 */ 53, 54, 55, 56, 57, 12, 184, 95, 184, 206,
149365
- /* 880 */ 207, 76, 111, 184, 65, 267, 184, 184, 184, 271,
149366
- /* 890 */ 27, 86, 109, 184, 89, 120, 121, 122, 206, 207,
149367
- /* 900 */ 206, 207, 77, 139, 79, 42, 184, 136, 206, 207,
149368
- /* 910 */ 206, 207, 184, 96, 97, 98, 99, 100, 101, 102,
149369
- /* 920 */ 103, 104, 105, 106, 184, 138, 63, 184, 206, 207,
149370
- /* 930 */ 153, 95, 184, 19, 206, 207, 227, 23, 7, 8,
149371
- /* 940 */ 9, 293, 293, 109, 296, 296, 206, 207, 215, 206,
149372
- /* 950 */ 207, 184, 253, 19, 206, 207, 253, 43, 44, 45,
149373
- /* 960 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
149374
- /* 970 */ 56, 57, 184, 206, 207, 184, 184, 43, 44, 45,
149375
- /* 980 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
149376
- /* 990 */ 56, 57, 184, 22, 23, 184, 59, 206, 207, 184,
149377
- /* 1000 */ 184, 238, 184, 240, 184, 22, 184, 184, 157, 158,
149378
- /* 1010 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
149379
- /* 1020 */ 106, 206, 207, 184, 206, 207, 206, 207, 206, 207,
149380
- /* 1030 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
149381
- /* 1040 */ 106, 184, 59, 227, 252, 184, 293, 110, 184, 296,
149382
- /* 1050 */ 184, 184, 184, 230, 184, 184, 184, 15, 184, 184,
149383
- /* 1060 */ 184, 253, 184, 206, 207, 184, 95, 206, 207, 102,
149384
- /* 1070 */ 206, 207, 206, 207, 206, 207, 206, 207, 206, 207,
149385
- /* 1080 */ 206, 207, 206, 207, 184, 151, 184, 206, 207, 278,
149386
- /* 1090 */ 184, 252, 184, 110, 184, 128, 184, 198, 199, 184,
149387
- /* 1100 */ 133, 184, 60, 26, 184, 19, 206, 207, 206, 207,
149388
- /* 1110 */ 131, 132, 206, 207, 206, 207, 206, 207, 206, 207,
149389
- /* 1120 */ 253, 206, 207, 206, 207, 19, 206, 207, 253, 43,
149390
- /* 1130 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
149391
- /* 1140 */ 54, 55, 56, 57, 184, 26, 184, 26, 184, 43,
149392
- /* 1150 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
149393
- /* 1160 */ 54, 55, 56, 57, 285, 286, 206, 207, 206, 207,
149394
- /* 1170 */ 206, 207, 184, 31, 184, 293, 184, 293, 296, 184,
149395
- /* 1180 */ 296, 39, 96, 97, 98, 99, 100, 101, 102, 103,
149396
- /* 1190 */ 104, 105, 106, 184, 206, 207, 206, 207, 206, 207,
149397
- /* 1200 */ 184, 22, 96, 97, 98, 99, 100, 101, 102, 103,
149398
- /* 1210 */ 104, 105, 106, 184, 245, 246, 184, 26, 23, 142,
149399
- /* 1220 */ 128, 26, 206, 207, 150, 133, 152, 22, 22, 24,
149400
- /* 1230 */ 111, 23, 53, 184, 26, 206, 207, 151, 206, 207,
149401
- /* 1240 */ 119, 24, 122, 23, 23, 23, 26, 26, 26, 23,
149402
- /* 1250 */ 23, 23, 26, 26, 26, 136, 23, 19, 22, 26,
149403
- /* 1260 */ 113, 114, 24, 114, 144, 184, 59, 61, 7, 8,
149404
- /* 1270 */ 59, 23, 23, 124, 26, 26, 23, 19, 145, 26,
149405
- /* 1280 */ 147, 43, 44, 45, 46, 47, 48, 49, 50, 51,
149406
- /* 1290 */ 52, 53, 54, 55, 56, 57, 145, 23, 147, 184,
149407
- /* 1300 */ 26, 43, 44, 45, 46, 47, 48, 49, 50, 51,
149408
- /* 1310 */ 52, 53, 54, 55, 56, 57, 23, 110, 184, 26,
149409
- /* 1320 */ 184, 110, 184, 184, 184, 215, 135, 215, 184, 184,
149410
- /* 1330 */ 184, 247, 184, 244, 96, 97, 98, 99, 100, 101,
149411
- /* 1340 */ 102, 103, 104, 105, 106, 184, 184, 184, 301, 184,
149412
- /* 1350 */ 184, 134, 225, 184, 96, 97, 98, 99, 100, 101,
149413
- /* 1360 */ 102, 103, 104, 105, 106, 184, 184, 184, 184, 184,
149414
- /* 1370 */ 134, 184, 274, 273, 19, 244, 244, 204, 182, 244,
149415
- /* 1380 */ 283, 231, 279, 279, 232, 244, 210, 209, 235, 235,
149416
- /* 1390 */ 235, 248, 218, 234, 19, 209, 238, 209, 238, 44,
149417
- /* 1400 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
149418
- /* 1410 */ 55, 56, 57, 214, 60, 248, 248, 187, 134, 38,
149419
- /* 1420 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
149420
- /* 1430 */ 55, 56, 57, 232, 191, 191, 266, 280, 191, 283,
149421
- /* 1440 */ 143, 269, 108, 22, 280, 19, 20, 258, 22, 257,
149422
- /* 1450 */ 43, 96, 97, 98, 99, 100, 101, 102, 103, 104,
149423
- /* 1460 */ 105, 106, 36, 223, 142, 18, 235, 226, 226, 191,
149424
- /* 1470 */ 18, 96, 97, 98, 99, 100, 101, 102, 103, 104,
149425
- /* 1480 */ 105, 106, 226, 226, 190, 59, 235, 235, 223, 223,
149426
- /* 1490 */ 258, 257, 191, 190, 235, 150, 62, 71, 191, 276,
149427
- /* 1500 */ 275, 19, 20, 190, 22, 22, 211, 81, 191, 190,
149428
- /* 1510 */ 211, 191, 108, 190, 208, 64, 208, 208, 36, 119,
149429
- /* 1520 */ 94, 216, 211, 208, 210, 106, 100, 101, 216, 208,
149430
- /* 1530 */ 48, 268, 208, 107, 208, 109, 110, 111, 211, 268,
149431
- /* 1540 */ 114, 59, 211, 137, 108, 88, 250, 249, 191, 141,
149432
- /* 1550 */ 250, 249, 138, 71, 250, 300, 22, 131, 132, 249,
149433
- /* 1560 */ 300, 191, 150, 238, 82, 140, 250, 249, 239, 87,
149434
- /* 1570 */ 139, 145, 146, 147, 148, 149, 94, 239, 237, 236,
149435
- /* 1580 */ 25, 235, 100, 101, 194, 26, 193, 13, 185, 107,
149436
- /* 1590 */ 185, 109, 110, 111, 6, 263, 114, 203, 265, 183,
149437
- /* 1600 */ 183, 183, 203, 212, 203, 203, 197, 197, 212, 4,
149438
- /* 1610 */ 3, 22, 197, 155, 15, 204, 203, 289, 93, 289,
149439
- /* 1620 */ 16, 286, 132, 23, 204, 23, 123, 145, 146, 147,
149440
- /* 1630 */ 148, 149, 0, 1, 2, 143, 24, 5, 20, 135,
149441
- /* 1640 */ 16, 1, 10, 11, 12, 13, 14, 137, 135, 17,
149442
- /* 1650 */ 144, 123, 19, 20, 61, 22, 37, 143, 123, 53,
149443
- /* 1660 */ 109, 53, 30, 53, 32, 34, 53, 134, 1, 36,
149444
- /* 1670 */ 5, 22, 40, 108, 153, 41, 26, 68, 75, 68,
149445
- /* 1680 */ 134, 108, 24, 20, 124, 19, 118, 67, 67, 28,
149446
- /* 1690 */ 22, 22, 59, 22, 67, 23, 22, 22, 142, 37,
149447
- /* 1700 */ 23, 22, 70, 23, 71, 157, 23, 23, 26, 23,
149448
- /* 1710 */ 78, 22, 24, 81, 23, 82, 22, 24, 134, 23,
149449
- /* 1720 */ 87, 23, 19, 20, 92, 22, 109, 94, 22, 34,
149450
- /* 1730 */ 136, 26, 85, 100, 101, 34, 34, 83, 34, 36,
149451
- /* 1740 */ 107, 34, 109, 110, 111, 75, 90, 114, 75, 34,
149452
- /* 1750 */ 23, 22, 44, 34, 24, 23, 22, 26, 126, 26,
149453
- /* 1760 */ 23, 23, 59, 131, 132, 23, 23, 26, 23, 11,
149454
- /* 1770 */ 22, 22, 26, 23, 71, 23, 22, 22, 145, 146,
149455
- /* 1780 */ 147, 148, 149, 128, 23, 82, 154, 134, 15, 1,
149456
- /* 1790 */ 87, 134, 302, 134, 134, 302, 302, 94, 302, 302,
149457
- /* 1800 */ 302, 302, 302, 100, 101, 302, 302, 302, 302, 302,
149458
- /* 1810 */ 107, 302, 109, 110, 111, 1, 2, 114, 302, 5,
149459
- /* 1820 */ 302, 302, 302, 302, 10, 11, 12, 13, 14, 302,
149460
- /* 1830 */ 302, 17, 302, 302, 302, 302, 19, 20, 302, 22,
149461
- /* 1840 */ 302, 302, 302, 302, 30, 302, 32, 302, 145, 146,
149462
- /* 1850 */ 147, 148, 149, 36, 40, 302, 302, 302, 302, 302,
149463
- /* 1860 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149464
- /* 1870 */ 302, 302, 302, 302, 302, 302, 59, 302, 302, 302,
149465
- /* 1880 */ 302, 302, 302, 302, 70, 302, 302, 302, 71, 302,
149466
- /* 1890 */ 302, 302, 78, 302, 302, 81, 19, 20, 302, 22,
149467
- /* 1900 */ 302, 302, 302, 302, 302, 302, 92, 302, 302, 302,
149468
- /* 1910 */ 302, 94, 302, 36, 302, 302, 302, 100, 101, 102,
149469
- /* 1920 */ 302, 302, 302, 302, 107, 302, 109, 110, 111, 302,
149470
- /* 1930 */ 302, 114, 302, 302, 302, 302, 59, 302, 302, 302,
149471
- /* 1940 */ 126, 302, 302, 302, 302, 131, 132, 302, 71, 302,
149472
- /* 1950 */ 302, 302, 302, 302, 302, 302, 19, 20, 302, 22,
149473
- /* 1960 */ 302, 302, 145, 146, 147, 148, 149, 302, 154, 302,
149474
- /* 1970 */ 302, 94, 302, 36, 302, 302, 302, 100, 101, 302,
149475
- /* 1980 */ 302, 302, 302, 302, 107, 302, 109, 110, 111, 302,
149476
- /* 1990 */ 302, 114, 5, 302, 302, 302, 59, 10, 11, 12,
149477
- /* 2000 */ 13, 14, 302, 302, 17, 302, 302, 302, 71, 302,
149478
- /* 2010 */ 302, 302, 302, 302, 302, 302, 302, 30, 302, 32,
149479
- /* 2020 */ 302, 302, 145, 146, 147, 148, 149, 40, 302, 302,
149480
- /* 2030 */ 302, 94, 302, 302, 302, 302, 302, 100, 101, 302,
149481
- /* 2040 */ 302, 302, 302, 302, 107, 302, 109, 110, 111, 302,
149482
- /* 2050 */ 302, 114, 302, 302, 302, 302, 302, 70, 302, 302,
149483
- /* 2060 */ 302, 302, 302, 302, 302, 78, 302, 302, 81, 302,
149484
- /* 2070 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 92,
149485
- /* 2080 */ 302, 302, 145, 146, 147, 148, 149, 302, 302, 302,
149486
- /* 2090 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149487
- /* 2100 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149488
- /* 2110 */ 302, 302, 302, 126, 302, 302, 302, 302, 131, 132,
149489
- /* 2120 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149490
- /* 2130 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149491
- /* 2140 */ 302, 154, 302, 302, 302, 302, 302, 302, 302, 302,
149492
- /* 2150 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149493
- /* 2160 */ 302, 302, 302, 302, 302, 302, 302, 302, 302,
149494
-};
149495
-#define YY_SHIFT_COUNT (539)
150002
+ /* 0 */ 187, 187, 187, 216, 217, 187, 206, 187, 264, 265,
150003
+ /* 10 */ 266, 187, 225, 187, 209, 187, 264, 265, 266, 19,
150004
+ /* 20 */ 187, 187, 209, 210, 209, 210, 187, 209, 210, 209,
150005
+ /* 30 */ 210, 31, 209, 209, 210, 209, 210, 285, 224, 39,
150006
+ /* 40 */ 203, 204, 205, 43, 44, 45, 46, 47, 48, 49,
150007
+ /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 230, 19,
150008
+ /* 60 */ 181, 182, 183, 184, 230, 245, 233, 208, 189, 245,
150009
+ /* 70 */ 191, 245, 26, 206, 254, 216, 276, 198, 254, 198,
150010
+ /* 80 */ 254, 281, 187, 43, 44, 45, 46, 47, 48, 49,
150011
+ /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 259, 99,
150012
+ /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150013
+ /* 110 */ 231, 232, 231, 232, 286, 302, 303, 302, 22, 304,
150014
+ /* 120 */ 302, 303, 76, 244, 11, 244, 86, 19, 88, 248,
150015
+ /* 130 */ 249, 264, 265, 266, 26, 89, 198, 258, 92, 99,
150016
+ /* 140 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150017
+ /* 150 */ 105, 43, 44, 45, 46, 47, 48, 49, 50, 51,
150018
+ /* 160 */ 52, 53, 54, 55, 56, 57, 212, 288, 273, 231,
150019
+ /* 170 */ 232, 105, 106, 107, 108, 109, 131, 69, 203, 204,
150020
+ /* 180 */ 205, 136, 244, 99, 100, 101, 102, 103, 104, 105,
150021
+ /* 190 */ 106, 107, 108, 109, 15, 103, 104, 19, 260, 103,
150022
+ /* 200 */ 104, 54, 55, 56, 57, 58, 22, 99, 100, 101,
150023
+ /* 210 */ 102, 103, 104, 105, 106, 107, 108, 109, 264, 265,
150024
+ /* 220 */ 266, 43, 44, 45, 46, 47, 48, 49, 50, 51,
150025
+ /* 230 */ 52, 53, 54, 55, 56, 57, 19, 124, 125, 60,
150026
+ /* 240 */ 148, 24, 150, 59, 187, 67, 99, 100, 101, 102,
150027
+ /* 250 */ 103, 104, 105, 106, 107, 108, 109, 187, 187, 109,
150028
+ /* 260 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150029
+ /* 270 */ 53, 54, 55, 56, 57, 204, 205, 99, 100, 101,
150030
+ /* 280 */ 102, 103, 104, 105, 106, 107, 108, 109, 103, 104,
150031
+ /* 290 */ 105, 106, 107, 108, 109, 59, 112, 113, 114, 76,
150032
+ /* 300 */ 231, 232, 187, 19, 19, 22, 23, 23, 54, 55,
150033
+ /* 310 */ 56, 57, 89, 244, 199, 92, 99, 100, 101, 102,
150034
+ /* 320 */ 103, 104, 105, 106, 107, 108, 109, 43, 44, 45,
150035
+ /* 330 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
150036
+ /* 340 */ 56, 57, 19, 212, 187, 274, 23, 26, 112, 113,
150037
+ /* 350 */ 114, 294, 295, 99, 100, 101, 102, 103, 104, 105,
150038
+ /* 360 */ 106, 107, 108, 109, 59, 295, 43, 44, 45, 46,
150039
+ /* 370 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
150040
+ /* 380 */ 57, 98, 146, 99, 100, 101, 102, 103, 104, 105,
150041
+ /* 390 */ 106, 107, 108, 109, 109, 264, 265, 266, 187, 187,
150042
+ /* 400 */ 115, 116, 117, 118, 119, 120, 121, 73, 59, 19,
150043
+ /* 410 */ 105, 23, 127, 23, 26, 81, 259, 112, 113, 114,
150044
+ /* 420 */ 187, 72, 99, 100, 101, 102, 103, 104, 105, 106,
150045
+ /* 430 */ 107, 108, 109, 43, 44, 45, 46, 47, 48, 49,
150046
+ /* 440 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 124,
150047
+ /* 450 */ 125, 182, 23, 184, 187, 134, 135, 123, 189, 131,
150048
+ /* 460 */ 191, 112, 113, 114, 136, 187, 233, 198, 134, 135,
150049
+ /* 470 */ 198, 259, 43, 44, 45, 46, 47, 48, 49, 50,
150050
+ /* 480 */ 51, 52, 53, 54, 55, 56, 57, 209, 210, 99,
150051
+ /* 490 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150052
+ /* 500 */ 231, 232, 206, 231, 232, 187, 59, 296, 297, 76,
150053
+ /* 510 */ 160, 161, 301, 244, 232, 19, 244, 297, 59, 23,
150054
+ /* 520 */ 87, 301, 89, 245, 26, 92, 244, 258, 99, 100,
150055
+ /* 530 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 43,
150056
+ /* 540 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
150057
+ /* 550 */ 54, 55, 56, 57, 19, 187, 97, 288, 23, 112,
150058
+ /* 560 */ 113, 114, 115, 296, 297, 118, 119, 120, 301, 108,
150059
+ /* 570 */ 109, 112, 113, 255, 141, 128, 117, 281, 43, 44,
150060
+ /* 580 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
150061
+ /* 590 */ 55, 56, 57, 187, 187, 99, 100, 101, 102, 103,
150062
+ /* 600 */ 104, 105, 106, 107, 108, 109, 26, 148, 149, 150,
150063
+ /* 610 */ 115, 97, 59, 118, 119, 120, 209, 210, 73, 59,
150064
+ /* 620 */ 122, 19, 209, 128, 256, 72, 187, 113, 187, 81,
150065
+ /* 630 */ 223, 117, 227, 228, 99, 100, 101, 102, 103, 104,
150066
+ /* 640 */ 105, 106, 107, 108, 109, 43, 44, 45, 46, 47,
150067
+ /* 650 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
150068
+ /* 660 */ 19, 255, 148, 149, 150, 112, 113, 114, 123, 124,
150069
+ /* 670 */ 125, 230, 112, 113, 114, 22, 297, 22, 81, 22,
150070
+ /* 680 */ 301, 59, 134, 135, 43, 44, 45, 46, 47, 48,
150071
+ /* 690 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 139,
150072
+ /* 700 */ 192, 99, 100, 101, 102, 103, 104, 105, 106, 107,
150073
+ /* 710 */ 108, 109, 59, 116, 59, 187, 59, 231, 232, 46,
150074
+ /* 720 */ 47, 48, 49, 16, 12, 145, 198, 22, 187, 187,
150075
+ /* 730 */ 244, 134, 135, 222, 112, 113, 114, 209, 210, 27,
150076
+ /* 740 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
150077
+ /* 750 */ 109, 209, 210, 187, 42, 187, 154, 227, 228, 231,
150078
+ /* 760 */ 232, 139, 22, 23, 59, 112, 113, 114, 113, 112,
150079
+ /* 770 */ 113, 114, 244, 245, 233, 63, 19, 209, 210, 271,
150080
+ /* 780 */ 187, 24, 254, 275, 77, 73, 79, 245, 195, 260,
150081
+ /* 790 */ 117, 223, 199, 22, 23, 154, 19, 26, 22, 187,
150082
+ /* 800 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150083
+ /* 810 */ 53, 54, 55, 56, 57, 19, 187, 112, 113, 114,
150084
+ /* 820 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150085
+ /* 830 */ 53, 54, 55, 56, 57, 59, 263, 187, 98, 43,
150086
+ /* 840 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
150087
+ /* 850 */ 54, 55, 56, 57, 204, 205, 99, 100, 101, 102,
150088
+ /* 860 */ 103, 104, 105, 106, 107, 108, 109, 255, 130, 98,
150089
+ /* 870 */ 132, 133, 299, 300, 198, 187, 99, 100, 101, 102,
150090
+ /* 880 */ 103, 104, 105, 106, 107, 108, 109, 187, 112, 113,
150091
+ /* 890 */ 114, 187, 241, 187, 243, 99, 100, 101, 102, 103,
150092
+ /* 900 */ 104, 105, 106, 107, 108, 109, 19, 231, 232, 209,
150093
+ /* 910 */ 210, 282, 59, 209, 210, 209, 210, 16, 230, 19,
150094
+ /* 920 */ 244, 22, 23, 223, 274, 26, 19, 223, 187, 223,
150095
+ /* 930 */ 198, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150096
+ /* 940 */ 53, 54, 55, 56, 57, 45, 46, 47, 48, 49,
150097
+ /* 950 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 20,
150098
+ /* 960 */ 187, 22, 187, 231, 232, 112, 113, 114, 123, 124,
150099
+ /* 970 */ 125, 7, 8, 9, 187, 36, 244, 24, 77, 21,
150100
+ /* 980 */ 79, 187, 209, 210, 187, 263, 99, 100, 101, 102,
150101
+ /* 990 */ 103, 104, 105, 106, 107, 108, 109, 98, 59, 99,
150102
+ /* 1000 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150103
+ /* 1010 */ 71, 187, 59, 187, 187, 19, 20, 187, 22, 112,
150104
+ /* 1020 */ 81, 299, 300, 282, 230, 199, 291, 292, 22, 187,
150105
+ /* 1030 */ 24, 256, 36, 209, 210, 187, 97, 35, 80, 209,
150106
+ /* 1040 */ 210, 268, 103, 104, 48, 187, 220, 223, 222, 110,
150107
+ /* 1050 */ 59, 112, 113, 114, 187, 59, 117, 156, 187, 179,
150108
+ /* 1060 */ 180, 181, 182, 183, 184, 59, 113, 71, 66, 189,
150109
+ /* 1070 */ 22, 191, 230, 134, 135, 245, 74, 119, 198, 282,
150110
+ /* 1080 */ 297, 85, 224, 198, 301, 187, 90, 148, 149, 150,
150111
+ /* 1090 */ 151, 152, 19, 97, 103, 104, 123, 124, 125, 103,
150112
+ /* 1100 */ 104, 53, 111, 112, 113, 114, 110, 116, 112, 113,
150113
+ /* 1110 */ 114, 231, 232, 117, 156, 124, 231, 232, 297, 113,
150114
+ /* 1120 */ 187, 24, 301, 256, 244, 201, 202, 256, 126, 244,
150115
+ /* 1130 */ 187, 198, 187, 187, 23, 187, 187, 26, 258, 148,
150116
+ /* 1140 */ 19, 150, 209, 210, 148, 149, 150, 151, 152, 0,
150117
+ /* 1150 */ 1, 2, 209, 210, 5, 209, 210, 209, 210, 10,
150118
+ /* 1160 */ 11, 12, 13, 14, 231, 232, 17, 46, 288, 19,
150119
+ /* 1170 */ 20, 223, 22, 236, 198, 66, 187, 244, 245, 30,
150120
+ /* 1180 */ 12, 32, 198, 246, 59, 112, 36, 187, 245, 40,
150121
+ /* 1190 */ 198, 245, 117, 29, 85, 27, 26, 33, 209, 210,
150122
+ /* 1200 */ 297, 76, 127, 94, 301, 256, 26, 231, 232, 59,
150123
+ /* 1210 */ 42, 153, 87, 155, 89, 231, 232, 92, 31, 70,
150124
+ /* 1220 */ 244, 71, 26, 231, 232, 114, 39, 78, 244, 65,
150125
+ /* 1230 */ 81, 63, 111, 233, 137, 85, 244, 112, 113, 114,
150126
+ /* 1240 */ 90, 22, 59, 24, 95, 201, 202, 97, 127, 187,
150127
+ /* 1250 */ 139, 142, 187, 103, 104, 19, 20, 187, 22, 187,
150128
+ /* 1260 */ 110, 187, 112, 113, 114, 187, 141, 117, 141, 187,
150129
+ /* 1270 */ 23, 187, 36, 26, 209, 210, 134, 135, 129, 209,
150130
+ /* 1280 */ 210, 209, 210, 134, 135, 22, 159, 209, 210, 187,
150131
+ /* 1290 */ 187, 209, 210, 209, 210, 59, 113, 187, 148, 149,
150132
+ /* 1300 */ 150, 151, 152, 289, 290, 187, 157, 71, 248, 249,
150133
+ /* 1310 */ 114, 141, 209, 210, 46, 125, 116, 117, 138, 19,
150134
+ /* 1320 */ 20, 85, 22, 148, 61, 150, 90, 209, 210, 23,
150135
+ /* 1330 */ 7, 8, 26, 97, 187, 139, 36, 147, 59, 103,
150136
+ /* 1340 */ 104, 19, 20, 187, 22, 59, 110, 187, 112, 113,
150137
+ /* 1350 */ 114, 1, 2, 117, 187, 5, 209, 210, 36, 59,
150138
+ /* 1360 */ 10, 11, 12, 13, 14, 209, 210, 17, 59, 209,
150139
+ /* 1370 */ 210, 71, 187, 148, 250, 150, 209, 210, 187, 111,
150140
+ /* 1380 */ 30, 59, 32, 22, 148, 149, 150, 151, 152, 187,
150141
+ /* 1390 */ 40, 187, 113, 71, 209, 210, 187, 97, 187, 113,
150142
+ /* 1400 */ 209, 210, 187, 103, 104, 105, 23, 187, 187, 26,
150143
+ /* 1410 */ 110, 187, 112, 113, 114, 83, 84, 117, 23, 97,
150144
+ /* 1420 */ 70, 26, 113, 218, 187, 103, 104, 187, 78, 209,
150145
+ /* 1430 */ 210, 81, 110, 187, 112, 113, 114, 19, 20, 117,
150146
+ /* 1440 */ 22, 187, 187, 187, 187, 95, 209, 210, 148, 149,
150147
+ /* 1450 */ 150, 151, 152, 187, 36, 23, 187, 187, 26, 187,
150148
+ /* 1460 */ 187, 187, 187, 209, 210, 209, 210, 187, 187, 218,
150149
+ /* 1470 */ 148, 149, 150, 151, 152, 209, 210, 59, 187, 129,
150150
+ /* 1480 */ 187, 209, 210, 187, 134, 135, 187, 306, 187, 71,
150151
+ /* 1490 */ 209, 210, 23, 228, 187, 26, 23, 187, 137, 26,
150152
+ /* 1500 */ 209, 210, 209, 210, 187, 209, 210, 157, 209, 210,
150153
+ /* 1510 */ 209, 210, 218, 187, 187, 97, 209, 210, 187, 278,
150154
+ /* 1520 */ 23, 103, 104, 26, 187, 187, 187, 187, 110, 187,
150155
+ /* 1530 */ 112, 113, 114, 187, 187, 117, 5, 247, 187, 187,
150156
+ /* 1540 */ 187, 10, 11, 12, 13, 14, 209, 210, 17, 209,
150157
+ /* 1550 */ 210, 209, 210, 187, 187, 187, 209, 210, 187, 23,
150158
+ /* 1560 */ 187, 30, 26, 32, 187, 187, 148, 149, 150, 151,
150159
+ /* 1570 */ 152, 40, 187, 187, 187, 209, 210, 209, 210, 187,
150160
+ /* 1580 */ 209, 210, 209, 210, 187, 187, 209, 210, 187, 277,
150161
+ /* 1590 */ 234, 187, 247, 187, 209, 210, 209, 210, 187, 235,
150162
+ /* 1600 */ 187, 70, 187, 207, 247, 247, 247, 209, 210, 78,
150163
+ /* 1610 */ 209, 210, 81, 209, 210, 209, 210, 187, 185, 238,
150164
+ /* 1620 */ 209, 210, 209, 210, 209, 210, 95, 251, 287, 238,
150165
+ /* 1630 */ 251, 23, 23, 23, 26, 26, 26, 283, 23, 209,
150166
+ /* 1640 */ 210, 26, 213, 238, 221, 283, 212, 212, 217, 212,
150167
+ /* 1650 */ 251, 241, 270, 241, 237, 235, 190, 60, 137, 287,
150168
+ /* 1660 */ 129, 194, 194, 38, 284, 134, 135, 273, 284, 194,
150169
+ /* 1670 */ 146, 111, 22, 43, 226, 145, 262, 261, 238, 18,
150170
+ /* 1680 */ 229, 229, 229, 229, 194, 18, 193, 238, 157, 262,
150171
+ /* 1690 */ 226, 226, 194, 238, 238, 193, 153, 261, 62, 280,
150172
+ /* 1700 */ 279, 194, 193, 22, 194, 214, 193, 111, 194, 193,
150173
+ /* 1710 */ 214, 211, 211, 64, 211, 211, 122, 211, 219, 214,
150174
+ /* 1720 */ 109, 213, 160, 211, 300, 140, 211, 253, 111, 272,
150175
+ /* 1730 */ 219, 214, 272, 214, 252, 194, 253, 252, 91, 253,
150176
+ /* 1740 */ 252, 82, 253, 305, 252, 144, 305, 141, 22, 194,
150177
+ /* 1750 */ 269, 257, 257, 153, 267, 143, 142, 25, 197, 26,
150178
+ /* 1760 */ 242, 241, 196, 240, 242, 239, 238, 13, 188, 188,
150179
+ /* 1770 */ 6, 293, 186, 186, 186, 200, 206, 293, 206, 206,
150180
+ /* 1780 */ 206, 4, 200, 215, 215, 207, 207, 3, 22, 206,
150181
+ /* 1790 */ 200, 158, 96, 15, 23, 16, 23, 135, 146, 126,
150182
+ /* 1800 */ 24, 138, 20, 16, 140, 1, 138, 147, 126, 61,
150183
+ /* 1810 */ 53, 37, 146, 53, 53, 290, 53, 126, 112, 34,
150184
+ /* 1820 */ 137, 1, 5, 22, 111, 156, 68, 68, 26, 41,
150185
+ /* 1830 */ 75, 137, 111, 24, 20, 19, 127, 121, 23, 67,
150186
+ /* 1840 */ 22, 22, 67, 22, 22, 37, 22, 67, 23, 145,
150187
+ /* 1850 */ 22, 28, 23, 23, 23, 137, 23, 22, 26, 22,
150188
+ /* 1860 */ 24, 23, 112, 24, 23, 23, 22, 139, 34, 26,
150189
+ /* 1870 */ 75, 88, 86, 75, 34, 23, 22, 24, 22, 34,
150190
+ /* 1880 */ 34, 34, 93, 34, 26, 26, 23, 23, 23, 34,
150191
+ /* 1890 */ 23, 23, 44, 23, 11, 26, 22, 22, 26, 23,
150192
+ /* 1900 */ 23, 22, 22, 15, 137, 137, 137, 137, 23, 1,
150193
+ /* 1910 */ 307, 307, 131, 307, 307, 307, 307, 307, 307, 307,
150194
+ /* 1920 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150195
+ /* 1930 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150196
+ /* 1940 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150197
+ /* 1950 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150198
+ /* 1960 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150199
+ /* 1970 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150200
+ /* 1980 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150201
+ /* 1990 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150202
+ /* 2000 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150203
+ /* 2010 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150204
+ /* 2020 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150205
+ /* 2030 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150206
+ /* 2040 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150207
+ /* 2050 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150208
+ /* 2060 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150209
+ /* 2070 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150210
+ /* 2080 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150211
+ /* 2090 */ 307, 307,
150212
+};
150213
+#define YY_SHIFT_COUNT (542)
149496150214
#define YY_SHIFT_MIN (0)
149497
-#define YY_SHIFT_MAX (1987)
150215
+#define YY_SHIFT_MAX (1908)
149498150216
static const unsigned short int yy_shift_ofst[] = {
149499
- /* 0 */ 1814, 1632, 1987, 1426, 1426, 382, 1482, 1633, 1703, 1877,
149500
- /* 10 */ 1877, 1877, 85, 0, 0, 264, 1106, 1877, 1877, 1877,
149501
- /* 20 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
149502
- /* 30 */ 226, 226, 380, 380, 294, 667, 382, 382, 382, 382,
149503
- /* 40 */ 382, 382, 97, 194, 332, 429, 526, 623, 720, 817,
149504
- /* 50 */ 914, 934, 1086, 1238, 1106, 1106, 1106, 1106, 1106, 1106,
149505
- /* 60 */ 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106,
149506
- /* 70 */ 1106, 1106, 1258, 1106, 1355, 1375, 1375, 1817, 1877, 1877,
149507
- /* 80 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
149508
- /* 90 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
149509
- /* 100 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
149510
- /* 110 */ 1937, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
149511
- /* 120 */ 1877, 1877, 1877, 1877, 32, 129, 129, 129, 129, 129,
149512
- /* 130 */ 171, 7, 17, 593, 676, 590, 593, 205, 205, 593,
149513
- /* 140 */ 318, 318, 318, 318, 50, 152, 51, 2142, 2142, 284,
149514
- /* 150 */ 284, 284, 65, 145, 282, 145, 145, 574, 574, 256,
149515
- /* 160 */ 348, 445, 782, 593, 593, 593, 593, 593, 593, 593,
149516
- /* 170 */ 593, 593, 593, 593, 593, 593, 593, 593, 593, 593,
149517
- /* 180 */ 593, 593, 593, 593, 607, 607, 593, 721, 805, 805,
149518
- /* 190 */ 446, 851, 851, 446, 190, 979, 2142, 2142, 2142, 453,
149519
- /* 200 */ 45, 45, 480, 490, 484, 385, 575, 502, 551, 581,
149520
- /* 210 */ 593, 593, 593, 593, 593, 593, 593, 593, 593, 689,
149521
- /* 220 */ 593, 593, 593, 593, 593, 593, 593, 593, 593, 593,
149522
- /* 230 */ 593, 593, 582, 582, 582, 593, 593, 593, 593, 771,
149523
- /* 240 */ 593, 593, 593, 59, 764, 593, 593, 863, 593, 593,
149524
- /* 250 */ 593, 593, 593, 593, 593, 593, 665, 819, 580, 16,
149525
- /* 260 */ 16, 16, 16, 1119, 580, 580, 967, 321, 931, 1042,
149526
- /* 270 */ 1077, 783, 783, 834, 1077, 1077, 834, 1121, 1195, 401,
149527
- /* 280 */ 1142, 1142, 1142, 783, 787, 787, 1074, 1191, 1092, 1205,
149528
- /* 290 */ 1354, 1284, 1284, 1381, 1381, 1284, 1297, 1334, 1421, 1407,
149529
- /* 300 */ 1322, 1447, 1447, 1447, 1447, 1284, 1452, 1322, 1322, 1334,
149530
- /* 310 */ 1421, 1407, 1407, 1322, 1284, 1452, 1345, 1434, 1284, 1452,
149531
- /* 320 */ 1483, 1284, 1452, 1284, 1452, 1483, 1404, 1404, 1404, 1451,
149532
- /* 330 */ 1483, 1404, 1400, 1404, 1451, 1404, 1404, 1483, 1419, 1419,
149533
- /* 340 */ 1483, 1406, 1436, 1406, 1436, 1406, 1436, 1406, 1436, 1284,
149534
- /* 350 */ 1457, 1457, 1408, 1414, 1534, 1284, 1412, 1408, 1425, 1431,
149535
- /* 360 */ 1322, 1555, 1559, 1574, 1574, 1588, 1588, 1588, 2142, 2142,
149536
- /* 370 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
149537
- /* 380 */ 2142, 2142, 2142, 378, 777, 836, 971, 825, 775, 983,
149538
- /* 390 */ 1208, 1179, 1217, 1120, 1220, 1206, 1221, 1222, 1226, 1227,
149539
- /* 400 */ 1228, 1233, 937, 1147, 1261, 1149, 1207, 1248, 1249, 1253,
149540
- /* 410 */ 1133, 1151, 1274, 1293, 1211, 1236, 1605, 1607, 1589, 1458,
149541
- /* 420 */ 1599, 1525, 1604, 1600, 1602, 1490, 1492, 1503, 1612, 1504,
149542
- /* 430 */ 1618, 1510, 1624, 1640, 1513, 1506, 1528, 1593, 1619, 1514,
149543
- /* 440 */ 1606, 1608, 1610, 1613, 1535, 1551, 1631, 1533, 1667, 1665,
149544
- /* 450 */ 1649, 1565, 1521, 1609, 1650, 1611, 1603, 1634, 1546, 1573,
149545
- /* 460 */ 1658, 1663, 1666, 1560, 1568, 1668, 1620, 1669, 1671, 1672,
149546
- /* 470 */ 1674, 1621, 1661, 1675, 1627, 1662, 1677, 1556, 1679, 1680,
149547
- /* 480 */ 1548, 1683, 1684, 1682, 1686, 1689, 1688, 1691, 1694, 1693,
149548
- /* 490 */ 1584, 1696, 1698, 1617, 1695, 1706, 1594, 1705, 1701, 1702,
149549
- /* 500 */ 1704, 1707, 1647, 1670, 1654, 1708, 1673, 1656, 1715, 1727,
149550
- /* 510 */ 1729, 1730, 1731, 1733, 1719, 1732, 1705, 1737, 1738, 1742,
149551
- /* 520 */ 1743, 1741, 1745, 1734, 1758, 1748, 1749, 1750, 1752, 1754,
149552
- /* 530 */ 1755, 1746, 1655, 1653, 1657, 1659, 1660, 1761, 1773, 1788,
149553
-};
149554
-#define YY_REDUCE_COUNT (382)
149555
-#define YY_REDUCE_MIN (-260)
149556
-#define YY_REDUCE_MAX (1420)
150217
+ /* 0 */ 1350, 1149, 1531, 939, 939, 548, 996, 1150, 1236, 1322,
150218
+ /* 10 */ 1322, 1322, 334, 0, 0, 178, 777, 1322, 1322, 1322,
150219
+ /* 20 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150220
+ /* 30 */ 991, 991, 1125, 1125, 447, 597, 548, 548, 548, 548,
150221
+ /* 40 */ 548, 548, 40, 108, 217, 284, 323, 390, 429, 496,
150222
+ /* 50 */ 535, 602, 641, 757, 777, 777, 777, 777, 777, 777,
150223
+ /* 60 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777,
150224
+ /* 70 */ 777, 777, 796, 777, 887, 900, 900, 1300, 1322, 1322,
150225
+ /* 80 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150226
+ /* 90 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150227
+ /* 100 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150228
+ /* 110 */ 1418, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150229
+ /* 120 */ 1322, 1322, 1322, 1322, 147, 254, 254, 254, 254, 254,
150230
+ /* 130 */ 84, 185, 66, 853, 958, 1121, 853, 92, 92, 853,
150231
+ /* 140 */ 321, 321, 321, 321, 325, 350, 350, 461, 150, 1913,
150232
+ /* 150 */ 1913, 285, 285, 285, 236, 184, 349, 184, 184, 712,
150233
+ /* 160 */ 712, 433, 553, 771, 899, 853, 853, 853, 853, 853,
150234
+ /* 170 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 853,
150235
+ /* 180 */ 853, 853, 853, 853, 853, 853, 46, 46, 853, 113,
150236
+ /* 190 */ 223, 223, 1183, 1183, 1127, 1142, 1913, 1913, 1913, 459,
150237
+ /* 200 */ 514, 514, 653, 495, 657, 305, 705, 560, 622, 776,
150238
+ /* 210 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 545,
150239
+ /* 220 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 853,
150240
+ /* 230 */ 853, 853, 1002, 1002, 1002, 853, 853, 853, 853, 1111,
150241
+ /* 240 */ 853, 853, 853, 1006, 1109, 853, 853, 1168, 853, 853,
150242
+ /* 250 */ 853, 853, 853, 853, 853, 853, 845, 1164, 738, 953,
150243
+ /* 260 */ 953, 953, 953, 1196, 738, 738, 45, 96, 964, 179,
150244
+ /* 270 */ 580, 907, 907, 1073, 580, 580, 1073, 498, 388, 1268,
150245
+ /* 280 */ 1187, 1187, 1187, 907, 1170, 1170, 1058, 1180, 328, 1219,
150246
+ /* 290 */ 1597, 1521, 1521, 1625, 1625, 1521, 1524, 1560, 1650, 1630,
150247
+ /* 300 */ 1530, 1661, 1661, 1661, 1661, 1521, 1667, 1530, 1530, 1560,
150248
+ /* 310 */ 1650, 1630, 1630, 1530, 1521, 1667, 1543, 1636, 1521, 1667,
150249
+ /* 320 */ 1681, 1521, 1667, 1521, 1667, 1681, 1596, 1596, 1596, 1649,
150250
+ /* 330 */ 1681, 1596, 1594, 1596, 1649, 1596, 1596, 1562, 1681, 1611,
150251
+ /* 340 */ 1611, 1681, 1585, 1617, 1585, 1617, 1585, 1617, 1585, 1617,
150252
+ /* 350 */ 1521, 1647, 1647, 1659, 1659, 1601, 1606, 1726, 1521, 1600,
150253
+ /* 360 */ 1601, 1612, 1614, 1530, 1732, 1733, 1754, 1754, 1764, 1764,
150254
+ /* 370 */ 1764, 1913, 1913, 1913, 1913, 1913, 1913, 1913, 1913, 1913,
150255
+ /* 380 */ 1913, 1913, 1913, 1913, 1913, 1913, 673, 901, 283, 740,
150256
+ /* 390 */ 707, 973, 655, 1247, 1048, 1097, 1190, 1306, 1263, 1383,
150257
+ /* 400 */ 1395, 1432, 1469, 1473, 1497, 1279, 1200, 1323, 1075, 1286,
150258
+ /* 410 */ 1536, 1608, 1332, 1609, 1175, 1225, 1610, 1615, 1309, 1361,
150259
+ /* 420 */ 1777, 1784, 1766, 1633, 1778, 1696, 1779, 1771, 1773, 1662,
150260
+ /* 430 */ 1652, 1673, 1776, 1663, 1782, 1664, 1787, 1804, 1668, 1660,
150261
+ /* 440 */ 1682, 1748, 1774, 1666, 1757, 1760, 1761, 1763, 1691, 1706,
150262
+ /* 450 */ 1785, 1683, 1820, 1817, 1801, 1713, 1669, 1758, 1802, 1759,
150263
+ /* 460 */ 1755, 1788, 1694, 1721, 1809, 1814, 1816, 1709, 1716, 1818,
150264
+ /* 470 */ 1772, 1819, 1821, 1815, 1822, 1775, 1823, 1824, 1780, 1808,
150265
+ /* 480 */ 1825, 1704, 1828, 1829, 1830, 1831, 1832, 1833, 1835, 1836,
150266
+ /* 490 */ 1838, 1837, 1839, 1718, 1841, 1842, 1750, 1834, 1844, 1728,
150267
+ /* 500 */ 1843, 1840, 1845, 1846, 1847, 1783, 1795, 1786, 1848, 1798,
150268
+ /* 510 */ 1789, 1849, 1852, 1854, 1853, 1858, 1859, 1855, 1863, 1843,
150269
+ /* 520 */ 1864, 1865, 1867, 1868, 1869, 1870, 1856, 1883, 1874, 1875,
150270
+ /* 530 */ 1876, 1877, 1879, 1880, 1872, 1781, 1767, 1768, 1769, 1770,
150271
+ /* 540 */ 1885, 1888, 1908,
150272
+};
150273
+#define YY_REDUCE_COUNT (385)
150274
+#define YY_REDUCE_MIN (-256)
150275
+#define YY_REDUCE_MAX (1590)
149557150276
static const short yy_reduce_ofst[] = {
149558
- /* 0 */ -170, -18, -159, 309, 313, -167, -19, 75, 117, 211,
149559
- /* 10 */ 315, 317, -165, -195, -168, -260, 389, 437, 475, 524,
149560
- /* 20 */ 527, -169, 529, 531, -28, 80, 534, 239, 304, 412,
149561
- /* 30 */ 558, 577, 37, 120, 368, -22, 460, 517, 555, 560,
149562
- /* 40 */ 562, 586, -257, -257, -257, -257, -257, -257, -257, -257,
149563
- /* 50 */ -257, -257, -257, -257, -257, -257, -257, -257, -257, -257,
149564
- /* 60 */ -257, -257, -257, -257, -257, -257, -257, -257, -257, -257,
149565
- /* 70 */ -257, -257, -257, -257, -257, -257, -257, -172, 457, 628,
149566
- /* 80 */ 673, 692, 694, 702, 704, 722, 728, 740, 743, 748,
149567
- /* 90 */ 767, 791, 815, 818, 820, 822, 857, 861, 864, 866,
149568
- /* 100 */ 868, 870, 872, 874, 876, 881, 900, 902, 906, 908,
149569
- /* 110 */ 910, 912, 915, 917, 920, 960, 962, 964, 988, 990,
149570
- /* 120 */ 992, 1016, 1029, 1032, -257, -257, -257, -257, -257, -257,
149571
- /* 130 */ -257, -257, -257, 271, 618, -190, 68, 60, 240, -124,
149572
- /* 140 */ 603, 610, 603, 610, 12, -257, -257, -257, -257, -128,
149573
- /* 150 */ -128, -128, -142, 25, 270, 281, 333, 124, 236, 648,
149574
- /* 160 */ 374, 465, 465, 28, 598, 792, 839, 469, 38, 381,
149575
- /* 170 */ 622, 709, 173, 699, 522, 703, 808, 811, 867, 816,
149576
- /* 180 */ -104, 823, -3, 875, 649, 753, 323, -88, 882, 884,
149577
- /* 190 */ 518, 43, 325, 899, 763, 604, 879, 969, 402, -193,
149578
- /* 200 */ -189, -180, -151, -55, 69, 104, 141, 259, 286, 360,
149579
- /* 210 */ 364, 455, 474, 481, 510, 516, 611, 653, 788, 99,
149580
- /* 220 */ 871, 878, 995, 1009, 1049, 1081, 1115, 1134, 1136, 1138,
149581
- /* 230 */ 1139, 1140, 733, 1110, 1112, 1144, 1145, 1146, 1148, 1084,
149582
- /* 240 */ 1161, 1162, 1163, 1089, 1047, 1165, 1166, 1127, 1169, 104,
149583
- /* 250 */ 1181, 1182, 1183, 1184, 1185, 1187, 1098, 1100, 1150, 1131,
149584
- /* 260 */ 1132, 1135, 1141, 1084, 1150, 1150, 1152, 1173, 1196, 1097,
149585
- /* 270 */ 1153, 1143, 1167, 1103, 1154, 1155, 1104, 1176, 1174, 1199,
149586
- /* 280 */ 1178, 1186, 1188, 1168, 1158, 1160, 1170, 1159, 1201, 1230,
149587
- /* 290 */ 1156, 1243, 1244, 1157, 1164, 1247, 1172, 1189, 1192, 1240,
149588
- /* 300 */ 1231, 1241, 1242, 1256, 1257, 1278, 1294, 1251, 1252, 1232,
149589
- /* 310 */ 1234, 1265, 1266, 1259, 1301, 1303, 1223, 1225, 1307, 1313,
149590
- /* 320 */ 1295, 1317, 1319, 1320, 1323, 1299, 1306, 1308, 1309, 1305,
149591
- /* 330 */ 1311, 1315, 1314, 1321, 1312, 1324, 1326, 1327, 1263, 1271,
149592
- /* 340 */ 1331, 1296, 1298, 1300, 1302, 1304, 1310, 1316, 1318, 1357,
149593
- /* 350 */ 1255, 1260, 1329, 1325, 1332, 1370, 1333, 1338, 1341, 1343,
149594
- /* 360 */ 1346, 1390, 1393, 1403, 1405, 1416, 1417, 1418, 1328, 1330,
149595
- /* 370 */ 1335, 1409, 1394, 1399, 1401, 1402, 1410, 1391, 1396, 1411,
149596
- /* 380 */ 1420, 1413, 1415,
150277
+ /* 0 */ 880, -121, 269, 528, 933, -119, -187, -185, -182, -180,
150278
+ /* 10 */ -176, -174, -62, -46, 131, -248, -133, 407, 568, 700,
150279
+ /* 20 */ 704, 278, 706, 824, 542, 830, 948, 773, 943, 946,
150280
+ /* 30 */ 71, 650, 211, 267, 826, 272, 676, 732, 885, 976,
150281
+ /* 40 */ 984, 992, -256, -256, -256, -256, -256, -256, -256, -256,
150282
+ /* 50 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
150283
+ /* 60 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
150284
+ /* 70 */ -256, -256, -256, -256, -256, -256, -256, 989, 1065, 1070,
150285
+ /* 80 */ 1072, 1078, 1082, 1084, 1103, 1118, 1147, 1156, 1160, 1167,
150286
+ /* 90 */ 1185, 1191, 1220, 1237, 1254, 1256, 1266, 1272, 1281, 1291,
150287
+ /* 100 */ 1293, 1296, 1299, 1301, 1307, 1337, 1340, 1342, 1347, 1366,
150288
+ /* 110 */ 1368, 1371, 1373, 1377, 1385, 1387, 1398, 1401, 1404, 1406,
150289
+ /* 120 */ 1411, 1413, 1415, 1430, -256, -256, -256, -256, -256, -256,
150290
+ /* 130 */ -256, -256, -256, -172, 508, -213, 57, -163, -25, 593,
150291
+ /* 140 */ 69, 486, 69, 486, -200, 573, 722, -256, -256, -256,
150292
+ /* 150 */ -256, -141, -141, -141, -105, -161, -167, 157, 212, 405,
150293
+ /* 160 */ 530, 220, 233, 735, 735, 115, 318, 406, 612, 541,
150294
+ /* 170 */ -166, 441, 688, 794, 629, 368, 741, 775, 867, 797,
150295
+ /* 180 */ 871, 842, -186, 1000, 858, 949, 379, 783, 70, 296,
150296
+ /* 190 */ 821, 903, 924, 1044, 651, 282, 1014, 1060, 937, -195,
150297
+ /* 200 */ -177, 413, 439, 511, 566, 787, 827, 848, 898, 945,
150298
+ /* 210 */ 1062, 1074, 1102, 1110, 1202, 1204, 1209, 1211, 1215, 529,
150299
+ /* 220 */ 1221, 1224, 1240, 1246, 1255, 1257, 1269, 1270, 1273, 1274,
150300
+ /* 230 */ 1275, 1280, 1205, 1251, 1294, 1310, 1317, 1326, 1327, 1124,
150301
+ /* 240 */ 1331, 1338, 1339, 1290, 1181, 1346, 1351, 1265, 1352, 787,
150302
+ /* 250 */ 1353, 1367, 1378, 1386, 1392, 1397, 1241, 1312, 1356, 1345,
150303
+ /* 260 */ 1357, 1358, 1359, 1124, 1356, 1356, 1364, 1396, 1433, 1341,
150304
+ /* 270 */ 1381, 1376, 1379, 1354, 1391, 1405, 1362, 1429, 1423, 1431,
150305
+ /* 280 */ 1434, 1435, 1437, 1399, 1410, 1412, 1382, 1417, 1420, 1466,
150306
+ /* 290 */ 1372, 1467, 1468, 1380, 1384, 1475, 1394, 1414, 1416, 1448,
150307
+ /* 300 */ 1440, 1451, 1452, 1453, 1454, 1490, 1493, 1449, 1455, 1427,
150308
+ /* 310 */ 1436, 1464, 1465, 1456, 1498, 1502, 1419, 1421, 1507, 1509,
150309
+ /* 320 */ 1491, 1510, 1513, 1514, 1516, 1496, 1500, 1501, 1503, 1499,
150310
+ /* 330 */ 1505, 1504, 1508, 1506, 1511, 1512, 1515, 1424, 1517, 1457,
150311
+ /* 340 */ 1460, 1519, 1474, 1482, 1483, 1485, 1486, 1488, 1489, 1492,
150312
+ /* 350 */ 1541, 1438, 1441, 1494, 1495, 1518, 1520, 1487, 1555, 1481,
150313
+ /* 360 */ 1522, 1523, 1526, 1528, 1561, 1566, 1580, 1581, 1586, 1587,
150314
+ /* 370 */ 1588, 1478, 1484, 1525, 1575, 1570, 1572, 1573, 1574, 1582,
150315
+ /* 380 */ 1568, 1569, 1578, 1579, 1583, 1590,
149597150316
};
149598150317
static const YYACTIONTYPE yy_default[] = {
149599
- /* 0 */ 1537, 1537, 1537, 1377, 1159, 1266, 1159, 1159, 1159, 1377,
149600
- /* 10 */ 1377, 1377, 1159, 1296, 1296, 1430, 1190, 1159, 1159, 1159,
149601
- /* 20 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1376, 1159, 1159,
149602
- /* 30 */ 1159, 1159, 1460, 1460, 1159, 1159, 1159, 1159, 1159, 1159,
149603
- /* 40 */ 1159, 1159, 1159, 1302, 1159, 1159, 1159, 1159, 1159, 1378,
149604
- /* 50 */ 1379, 1159, 1159, 1159, 1429, 1431, 1394, 1312, 1311, 1310,
149605
- /* 60 */ 1309, 1412, 1283, 1307, 1300, 1304, 1372, 1373, 1371, 1375,
149606
- /* 70 */ 1379, 1378, 1159, 1303, 1343, 1357, 1342, 1159, 1159, 1159,
149607
- /* 80 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149608
- /* 90 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149609
- /* 100 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149610
- /* 110 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149611
- /* 120 */ 1159, 1159, 1159, 1159, 1351, 1356, 1362, 1355, 1352, 1345,
149612
- /* 130 */ 1344, 1346, 1347, 1159, 1180, 1230, 1159, 1159, 1159, 1159,
149613
- /* 140 */ 1448, 1447, 1159, 1159, 1190, 1348, 1349, 1359, 1358, 1437,
149614
- /* 150 */ 1493, 1492, 1395, 1159, 1159, 1159, 1159, 1159, 1159, 1460,
149615
- /* 160 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149616
- /* 170 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149617
- /* 180 */ 1159, 1159, 1159, 1159, 1460, 1460, 1159, 1190, 1460, 1460,
149618
- /* 190 */ 1186, 1337, 1336, 1186, 1290, 1159, 1443, 1266, 1257, 1159,
149619
- /* 200 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149620
- /* 210 */ 1159, 1159, 1159, 1434, 1432, 1159, 1159, 1159, 1159, 1159,
149621
- /* 220 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149622
- /* 230 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149623
- /* 240 */ 1159, 1159, 1159, 1262, 1159, 1159, 1159, 1159, 1159, 1159,
149624
- /* 250 */ 1159, 1159, 1159, 1159, 1159, 1487, 1159, 1407, 1244, 1262,
149625
- /* 260 */ 1262, 1262, 1262, 1264, 1245, 1243, 1256, 1191, 1166, 1529,
149626
- /* 270 */ 1306, 1285, 1285, 1526, 1306, 1306, 1526, 1205, 1507, 1202,
149627
- /* 280 */ 1296, 1296, 1296, 1285, 1290, 1290, 1374, 1263, 1256, 1159,
149628
- /* 290 */ 1529, 1271, 1271, 1528, 1528, 1271, 1395, 1315, 1321, 1233,
149629
- /* 300 */ 1306, 1239, 1239, 1239, 1239, 1271, 1177, 1306, 1306, 1315,
149630
- /* 310 */ 1321, 1233, 1233, 1306, 1271, 1177, 1411, 1523, 1271, 1177,
149631
- /* 320 */ 1385, 1271, 1177, 1271, 1177, 1385, 1231, 1231, 1231, 1220,
149632
- /* 330 */ 1385, 1231, 1205, 1231, 1220, 1231, 1231, 1385, 1389, 1389,
149633
- /* 340 */ 1385, 1289, 1284, 1289, 1284, 1289, 1284, 1289, 1284, 1271,
149634
- /* 350 */ 1470, 1470, 1301, 1290, 1380, 1271, 1159, 1301, 1299, 1297,
149635
- /* 360 */ 1306, 1183, 1223, 1490, 1490, 1486, 1486, 1486, 1534, 1534,
149636
- /* 370 */ 1443, 1502, 1190, 1190, 1190, 1190, 1502, 1207, 1207, 1191,
149637
- /* 380 */ 1191, 1190, 1502, 1159, 1159, 1159, 1159, 1159, 1159, 1497,
149638
- /* 390 */ 1159, 1396, 1275, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149639
- /* 400 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149640
- /* 410 */ 1159, 1159, 1159, 1159, 1159, 1326, 1159, 1162, 1440, 1159,
149641
- /* 420 */ 1159, 1438, 1159, 1159, 1159, 1159, 1159, 1159, 1276, 1159,
149642
- /* 430 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149643
- /* 440 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1525, 1159, 1159,
149644
- /* 450 */ 1159, 1159, 1159, 1159, 1410, 1409, 1159, 1159, 1273, 1159,
149645
- /* 460 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149646
- /* 470 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149647
- /* 480 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149648
- /* 490 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1298, 1159, 1159,
149649
- /* 500 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149650
- /* 510 */ 1159, 1159, 1475, 1291, 1159, 1159, 1516, 1159, 1159, 1159,
149651
- /* 520 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149652
- /* 530 */ 1159, 1511, 1247, 1328, 1159, 1327, 1331, 1159, 1171, 1159,
150318
+ /* 0 */ 1554, 1554, 1554, 1392, 1171, 1278, 1171, 1171, 1171, 1392,
150319
+ /* 10 */ 1392, 1392, 1171, 1308, 1308, 1445, 1202, 1171, 1171, 1171,
150320
+ /* 20 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1391, 1171, 1171,
150321
+ /* 30 */ 1171, 1171, 1475, 1475, 1171, 1171, 1171, 1171, 1171, 1171,
150322
+ /* 40 */ 1171, 1171, 1171, 1317, 1171, 1171, 1171, 1171, 1171, 1393,
150323
+ /* 50 */ 1394, 1171, 1171, 1171, 1444, 1446, 1409, 1327, 1326, 1325,
150324
+ /* 60 */ 1324, 1427, 1295, 1322, 1315, 1319, 1387, 1388, 1386, 1390,
150325
+ /* 70 */ 1394, 1393, 1171, 1318, 1358, 1372, 1357, 1171, 1171, 1171,
150326
+ /* 80 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150327
+ /* 90 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150328
+ /* 100 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150329
+ /* 110 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150330
+ /* 120 */ 1171, 1171, 1171, 1171, 1366, 1371, 1377, 1370, 1367, 1360,
150331
+ /* 130 */ 1359, 1361, 1362, 1171, 1192, 1242, 1171, 1171, 1171, 1171,
150332
+ /* 140 */ 1463, 1462, 1171, 1171, 1202, 1352, 1351, 1363, 1364, 1374,
150333
+ /* 150 */ 1373, 1452, 1510, 1509, 1410, 1171, 1171, 1171, 1171, 1171,
150334
+ /* 160 */ 1171, 1475, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150335
+ /* 170 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150336
+ /* 180 */ 1171, 1171, 1171, 1171, 1171, 1171, 1475, 1475, 1171, 1202,
150337
+ /* 190 */ 1475, 1475, 1198, 1198, 1302, 1171, 1458, 1278, 1269, 1171,
150338
+ /* 200 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150339
+ /* 210 */ 1171, 1171, 1171, 1449, 1447, 1171, 1171, 1171, 1171, 1171,
150340
+ /* 220 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150341
+ /* 230 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150342
+ /* 240 */ 1171, 1171, 1171, 1274, 1171, 1171, 1171, 1171, 1171, 1171,
150343
+ /* 250 */ 1171, 1171, 1171, 1171, 1171, 1504, 1171, 1422, 1256, 1274,
150344
+ /* 260 */ 1274, 1274, 1274, 1276, 1257, 1255, 1268, 1203, 1178, 1546,
150345
+ /* 270 */ 1321, 1297, 1297, 1543, 1321, 1321, 1543, 1217, 1524, 1214,
150346
+ /* 280 */ 1308, 1308, 1308, 1297, 1302, 1302, 1389, 1275, 1268, 1171,
150347
+ /* 290 */ 1546, 1283, 1283, 1545, 1545, 1283, 1410, 1330, 1336, 1245,
150348
+ /* 300 */ 1321, 1251, 1251, 1251, 1251, 1283, 1189, 1321, 1321, 1330,
150349
+ /* 310 */ 1336, 1245, 1245, 1321, 1283, 1189, 1426, 1540, 1283, 1189,
150350
+ /* 320 */ 1400, 1283, 1189, 1283, 1189, 1400, 1243, 1243, 1243, 1232,
150351
+ /* 330 */ 1400, 1243, 1217, 1243, 1232, 1243, 1243, 1493, 1400, 1404,
150352
+ /* 340 */ 1404, 1400, 1301, 1296, 1301, 1296, 1301, 1296, 1301, 1296,
150353
+ /* 350 */ 1283, 1485, 1485, 1311, 1311, 1316, 1302, 1395, 1283, 1171,
150354
+ /* 360 */ 1316, 1314, 1312, 1321, 1195, 1235, 1507, 1507, 1503, 1503,
150355
+ /* 370 */ 1503, 1551, 1551, 1458, 1519, 1202, 1202, 1202, 1202, 1519,
150356
+ /* 380 */ 1219, 1219, 1203, 1203, 1202, 1519, 1171, 1171, 1171, 1171,
150357
+ /* 390 */ 1171, 1171, 1514, 1171, 1411, 1287, 1171, 1171, 1171, 1171,
150358
+ /* 400 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150359
+ /* 410 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1341,
150360
+ /* 420 */ 1171, 1174, 1455, 1171, 1171, 1453, 1171, 1171, 1171, 1171,
150361
+ /* 430 */ 1171, 1171, 1288, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150362
+ /* 440 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150363
+ /* 450 */ 1171, 1542, 1171, 1171, 1171, 1171, 1171, 1171, 1425, 1424,
150364
+ /* 460 */ 1171, 1171, 1285, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150365
+ /* 470 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150366
+ /* 480 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150367
+ /* 490 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150368
+ /* 500 */ 1313, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150369
+ /* 510 */ 1171, 1171, 1171, 1171, 1171, 1490, 1303, 1171, 1171, 1533,
150370
+ /* 520 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150371
+ /* 530 */ 1171, 1171, 1171, 1171, 1528, 1259, 1343, 1171, 1342, 1346,
150372
+ /* 540 */ 1171, 1183, 1171,
149653150373
};
149654150374
/********** End of lemon-generated parsing tables *****************************/
149655150375
149656150376
/* The next table maps tokens (terminal symbols) into fallback tokens.
149657150377
** If a construct like the following:
@@ -149749,10 +150469,13 @@
149749150469
59, /* TRIGGER => ID */
149750150470
59, /* VACUUM => ID */
149751150471
59, /* VIEW => ID */
149752150472
59, /* VIRTUAL => ID */
149753150473
59, /* WITH => ID */
150474
+ 59, /* NULLS => ID */
150475
+ 59, /* FIRST => ID */
150476
+ 59, /* LAST => ID */
149754150477
59, /* CURRENT => ID */
149755150478
59, /* FOLLOWING => ID */
149756150479
59, /* PARTITION => ID */
149757150480
59, /* PRECEDING => ID */
149758150481
59, /* RANGE => ID */
@@ -149762,10 +150485,91 @@
149762150485
59, /* OTHERS => ID */
149763150486
59, /* TIES => ID */
149764150487
59, /* REINDEX => ID */
149765150488
59, /* RENAME => ID */
149766150489
59, /* CTIME_KW => ID */
150490
+ 0, /* ANY => nothing */
150491
+ 0, /* BITAND => nothing */
150492
+ 0, /* BITOR => nothing */
150493
+ 0, /* LSHIFT => nothing */
150494
+ 0, /* RSHIFT => nothing */
150495
+ 0, /* PLUS => nothing */
150496
+ 0, /* MINUS => nothing */
150497
+ 0, /* STAR => nothing */
150498
+ 0, /* SLASH => nothing */
150499
+ 0, /* REM => nothing */
150500
+ 0, /* CONCAT => nothing */
150501
+ 0, /* COLLATE => nothing */
150502
+ 0, /* BITNOT => nothing */
150503
+ 0, /* ON => nothing */
150504
+ 0, /* INDEXED => nothing */
150505
+ 0, /* STRING => nothing */
150506
+ 0, /* JOIN_KW => nothing */
150507
+ 0, /* CONSTRAINT => nothing */
150508
+ 0, /* DEFAULT => nothing */
150509
+ 0, /* NULL => nothing */
150510
+ 0, /* PRIMARY => nothing */
150511
+ 0, /* UNIQUE => nothing */
150512
+ 0, /* CHECK => nothing */
150513
+ 0, /* REFERENCES => nothing */
150514
+ 0, /* AUTOINCR => nothing */
150515
+ 0, /* INSERT => nothing */
150516
+ 0, /* DELETE => nothing */
150517
+ 0, /* UPDATE => nothing */
150518
+ 0, /* SET => nothing */
150519
+ 0, /* DEFERRABLE => nothing */
150520
+ 0, /* FOREIGN => nothing */
150521
+ 0, /* DROP => nothing */
150522
+ 0, /* UNION => nothing */
150523
+ 0, /* ALL => nothing */
150524
+ 0, /* EXCEPT => nothing */
150525
+ 0, /* INTERSECT => nothing */
150526
+ 0, /* SELECT => nothing */
150527
+ 0, /* VALUES => nothing */
150528
+ 0, /* DISTINCT => nothing */
150529
+ 0, /* DOT => nothing */
150530
+ 0, /* FROM => nothing */
150531
+ 0, /* JOIN => nothing */
150532
+ 0, /* USING => nothing */
150533
+ 0, /* ORDER => nothing */
150534
+ 0, /* GROUP => nothing */
150535
+ 0, /* HAVING => nothing */
150536
+ 0, /* LIMIT => nothing */
150537
+ 0, /* WHERE => nothing */
150538
+ 0, /* INTO => nothing */
150539
+ 0, /* NOTHING => nothing */
150540
+ 0, /* FLOAT => nothing */
150541
+ 0, /* BLOB => nothing */
150542
+ 0, /* INTEGER => nothing */
150543
+ 0, /* VARIABLE => nothing */
150544
+ 0, /* CASE => nothing */
150545
+ 0, /* WHEN => nothing */
150546
+ 0, /* THEN => nothing */
150547
+ 0, /* ELSE => nothing */
150548
+ 0, /* INDEX => nothing */
150549
+ 0, /* ALTER => nothing */
150550
+ 0, /* ADD => nothing */
150551
+ 0, /* WINDOW => nothing */
150552
+ 0, /* OVER => nothing */
150553
+ 0, /* FILTER => nothing */
150554
+ 0, /* COLUMN => nothing */
150555
+ 0, /* AGG_FUNCTION => nothing */
150556
+ 0, /* AGG_COLUMN => nothing */
150557
+ 0, /* TRUEFALSE => nothing */
150558
+ 0, /* ISNOT => nothing */
150559
+ 0, /* FUNCTION => nothing */
150560
+ 0, /* UMINUS => nothing */
150561
+ 0, /* UPLUS => nothing */
150562
+ 0, /* TRUTH => nothing */
150563
+ 0, /* REGISTER => nothing */
150564
+ 0, /* VECTOR => nothing */
150565
+ 0, /* SELECT_COLUMN => nothing */
150566
+ 0, /* IF_NULL_ROW => nothing */
150567
+ 0, /* ASTERISK => nothing */
150568
+ 0, /* SPAN => nothing */
150569
+ 0, /* SPACE => nothing */
150570
+ 0, /* ILLEGAL => nothing */
149767150571
};
149768150572
#endif /* YYFALLBACK */
149769150573
149770150574
/* The following structure represents a single element of the
149771150575
** parser's stack. Information stored includes:
@@ -149931,230 +150735,235 @@
149931150735
/* 77 */ "TRIGGER",
149932150736
/* 78 */ "VACUUM",
149933150737
/* 79 */ "VIEW",
149934150738
/* 80 */ "VIRTUAL",
149935150739
/* 81 */ "WITH",
149936
- /* 82 */ "CURRENT",
149937
- /* 83 */ "FOLLOWING",
149938
- /* 84 */ "PARTITION",
149939
- /* 85 */ "PRECEDING",
149940
- /* 86 */ "RANGE",
149941
- /* 87 */ "UNBOUNDED",
149942
- /* 88 */ "EXCLUDE",
149943
- /* 89 */ "GROUPS",
149944
- /* 90 */ "OTHERS",
149945
- /* 91 */ "TIES",
149946
- /* 92 */ "REINDEX",
149947
- /* 93 */ "RENAME",
149948
- /* 94 */ "CTIME_KW",
149949
- /* 95 */ "ANY",
149950
- /* 96 */ "BITAND",
149951
- /* 97 */ "BITOR",
149952
- /* 98 */ "LSHIFT",
149953
- /* 99 */ "RSHIFT",
149954
- /* 100 */ "PLUS",
149955
- /* 101 */ "MINUS",
149956
- /* 102 */ "STAR",
149957
- /* 103 */ "SLASH",
149958
- /* 104 */ "REM",
149959
- /* 105 */ "CONCAT",
149960
- /* 106 */ "COLLATE",
149961
- /* 107 */ "BITNOT",
149962
- /* 108 */ "ON",
149963
- /* 109 */ "INDEXED",
149964
- /* 110 */ "STRING",
149965
- /* 111 */ "JOIN_KW",
149966
- /* 112 */ "CONSTRAINT",
149967
- /* 113 */ "DEFAULT",
149968
- /* 114 */ "NULL",
149969
- /* 115 */ "PRIMARY",
149970
- /* 116 */ "UNIQUE",
149971
- /* 117 */ "CHECK",
149972
- /* 118 */ "REFERENCES",
149973
- /* 119 */ "AUTOINCR",
149974
- /* 120 */ "INSERT",
149975
- /* 121 */ "DELETE",
149976
- /* 122 */ "UPDATE",
149977
- /* 123 */ "SET",
149978
- /* 124 */ "DEFERRABLE",
149979
- /* 125 */ "FOREIGN",
149980
- /* 126 */ "DROP",
149981
- /* 127 */ "UNION",
149982
- /* 128 */ "ALL",
149983
- /* 129 */ "EXCEPT",
149984
- /* 130 */ "INTERSECT",
149985
- /* 131 */ "SELECT",
149986
- /* 132 */ "VALUES",
149987
- /* 133 */ "DISTINCT",
149988
- /* 134 */ "DOT",
149989
- /* 135 */ "FROM",
149990
- /* 136 */ "JOIN",
149991
- /* 137 */ "USING",
149992
- /* 138 */ "ORDER",
149993
- /* 139 */ "GROUP",
149994
- /* 140 */ "HAVING",
149995
- /* 141 */ "LIMIT",
149996
- /* 142 */ "WHERE",
149997
- /* 143 */ "INTO",
149998
- /* 144 */ "NOTHING",
149999
- /* 145 */ "FLOAT",
150000
- /* 146 */ "BLOB",
150001
- /* 147 */ "INTEGER",
150002
- /* 148 */ "VARIABLE",
150003
- /* 149 */ "CASE",
150004
- /* 150 */ "WHEN",
150005
- /* 151 */ "THEN",
150006
- /* 152 */ "ELSE",
150007
- /* 153 */ "INDEX",
150008
- /* 154 */ "ALTER",
150009
- /* 155 */ "ADD",
150010
- /* 156 */ "WINDOW",
150011
- /* 157 */ "OVER",
150012
- /* 158 */ "FILTER",
150013
- /* 159 */ "TRUEFALSE",
150014
- /* 160 */ "ISNOT",
150015
- /* 161 */ "FUNCTION",
150740
+ /* 82 */ "NULLS",
150741
+ /* 83 */ "FIRST",
150742
+ /* 84 */ "LAST",
150743
+ /* 85 */ "CURRENT",
150744
+ /* 86 */ "FOLLOWING",
150745
+ /* 87 */ "PARTITION",
150746
+ /* 88 */ "PRECEDING",
150747
+ /* 89 */ "RANGE",
150748
+ /* 90 */ "UNBOUNDED",
150749
+ /* 91 */ "EXCLUDE",
150750
+ /* 92 */ "GROUPS",
150751
+ /* 93 */ "OTHERS",
150752
+ /* 94 */ "TIES",
150753
+ /* 95 */ "REINDEX",
150754
+ /* 96 */ "RENAME",
150755
+ /* 97 */ "CTIME_KW",
150756
+ /* 98 */ "ANY",
150757
+ /* 99 */ "BITAND",
150758
+ /* 100 */ "BITOR",
150759
+ /* 101 */ "LSHIFT",
150760
+ /* 102 */ "RSHIFT",
150761
+ /* 103 */ "PLUS",
150762
+ /* 104 */ "MINUS",
150763
+ /* 105 */ "STAR",
150764
+ /* 106 */ "SLASH",
150765
+ /* 107 */ "REM",
150766
+ /* 108 */ "CONCAT",
150767
+ /* 109 */ "COLLATE",
150768
+ /* 110 */ "BITNOT",
150769
+ /* 111 */ "ON",
150770
+ /* 112 */ "INDEXED",
150771
+ /* 113 */ "STRING",
150772
+ /* 114 */ "JOIN_KW",
150773
+ /* 115 */ "CONSTRAINT",
150774
+ /* 116 */ "DEFAULT",
150775
+ /* 117 */ "NULL",
150776
+ /* 118 */ "PRIMARY",
150777
+ /* 119 */ "UNIQUE",
150778
+ /* 120 */ "CHECK",
150779
+ /* 121 */ "REFERENCES",
150780
+ /* 122 */ "AUTOINCR",
150781
+ /* 123 */ "INSERT",
150782
+ /* 124 */ "DELETE",
150783
+ /* 125 */ "UPDATE",
150784
+ /* 126 */ "SET",
150785
+ /* 127 */ "DEFERRABLE",
150786
+ /* 128 */ "FOREIGN",
150787
+ /* 129 */ "DROP",
150788
+ /* 130 */ "UNION",
150789
+ /* 131 */ "ALL",
150790
+ /* 132 */ "EXCEPT",
150791
+ /* 133 */ "INTERSECT",
150792
+ /* 134 */ "SELECT",
150793
+ /* 135 */ "VALUES",
150794
+ /* 136 */ "DISTINCT",
150795
+ /* 137 */ "DOT",
150796
+ /* 138 */ "FROM",
150797
+ /* 139 */ "JOIN",
150798
+ /* 140 */ "USING",
150799
+ /* 141 */ "ORDER",
150800
+ /* 142 */ "GROUP",
150801
+ /* 143 */ "HAVING",
150802
+ /* 144 */ "LIMIT",
150803
+ /* 145 */ "WHERE",
150804
+ /* 146 */ "INTO",
150805
+ /* 147 */ "NOTHING",
150806
+ /* 148 */ "FLOAT",
150807
+ /* 149 */ "BLOB",
150808
+ /* 150 */ "INTEGER",
150809
+ /* 151 */ "VARIABLE",
150810
+ /* 152 */ "CASE",
150811
+ /* 153 */ "WHEN",
150812
+ /* 154 */ "THEN",
150813
+ /* 155 */ "ELSE",
150814
+ /* 156 */ "INDEX",
150815
+ /* 157 */ "ALTER",
150816
+ /* 158 */ "ADD",
150817
+ /* 159 */ "WINDOW",
150818
+ /* 160 */ "OVER",
150819
+ /* 161 */ "FILTER",
150016150820
/* 162 */ "COLUMN",
150017150821
/* 163 */ "AGG_FUNCTION",
150018150822
/* 164 */ "AGG_COLUMN",
150019
- /* 165 */ "UMINUS",
150020
- /* 166 */ "UPLUS",
150021
- /* 167 */ "TRUTH",
150022
- /* 168 */ "REGISTER",
150023
- /* 169 */ "VECTOR",
150024
- /* 170 */ "SELECT_COLUMN",
150025
- /* 171 */ "IF_NULL_ROW",
150026
- /* 172 */ "ASTERISK",
150027
- /* 173 */ "SPAN",
150028
- /* 174 */ "SPACE",
150029
- /* 175 */ "ILLEGAL",
150030
- /* 176 */ "input",
150031
- /* 177 */ "cmdlist",
150032
- /* 178 */ "ecmd",
150033
- /* 179 */ "cmdx",
150034
- /* 180 */ "explain",
150035
- /* 181 */ "cmd",
150036
- /* 182 */ "transtype",
150037
- /* 183 */ "trans_opt",
150038
- /* 184 */ "nm",
150039
- /* 185 */ "savepoint_opt",
150040
- /* 186 */ "create_table",
150041
- /* 187 */ "create_table_args",
150042
- /* 188 */ "createkw",
150043
- /* 189 */ "temp",
150044
- /* 190 */ "ifnotexists",
150045
- /* 191 */ "dbnm",
150046
- /* 192 */ "columnlist",
150047
- /* 193 */ "conslist_opt",
150048
- /* 194 */ "table_options",
150049
- /* 195 */ "select",
150050
- /* 196 */ "columnname",
150051
- /* 197 */ "carglist",
150052
- /* 198 */ "typetoken",
150053
- /* 199 */ "typename",
150054
- /* 200 */ "signed",
150055
- /* 201 */ "plus_num",
150056
- /* 202 */ "minus_num",
150057
- /* 203 */ "scanpt",
150058
- /* 204 */ "scantok",
150059
- /* 205 */ "ccons",
150060
- /* 206 */ "term",
150061
- /* 207 */ "expr",
150062
- /* 208 */ "onconf",
150063
- /* 209 */ "sortorder",
150064
- /* 210 */ "autoinc",
150065
- /* 211 */ "eidlist_opt",
150066
- /* 212 */ "refargs",
150067
- /* 213 */ "defer_subclause",
150068
- /* 214 */ "refarg",
150069
- /* 215 */ "refact",
150070
- /* 216 */ "init_deferred_pred_opt",
150071
- /* 217 */ "conslist",
150072
- /* 218 */ "tconscomma",
150073
- /* 219 */ "tcons",
150074
- /* 220 */ "sortlist",
150075
- /* 221 */ "eidlist",
150076
- /* 222 */ "defer_subclause_opt",
150077
- /* 223 */ "orconf",
150078
- /* 224 */ "resolvetype",
150079
- /* 225 */ "raisetype",
150080
- /* 226 */ "ifexists",
150081
- /* 227 */ "fullname",
150082
- /* 228 */ "selectnowith",
150083
- /* 229 */ "oneselect",
150084
- /* 230 */ "wqlist",
150085
- /* 231 */ "multiselect_op",
150086
- /* 232 */ "distinct",
150087
- /* 233 */ "selcollist",
150088
- /* 234 */ "from",
150089
- /* 235 */ "where_opt",
150090
- /* 236 */ "groupby_opt",
150091
- /* 237 */ "having_opt",
150092
- /* 238 */ "orderby_opt",
150093
- /* 239 */ "limit_opt",
150094
- /* 240 */ "window_clause",
150095
- /* 241 */ "values",
150096
- /* 242 */ "nexprlist",
150097
- /* 243 */ "sclp",
150098
- /* 244 */ "as",
150099
- /* 245 */ "seltablist",
150100
- /* 246 */ "stl_prefix",
150101
- /* 247 */ "joinop",
150102
- /* 248 */ "indexed_opt",
150103
- /* 249 */ "on_opt",
150104
- /* 250 */ "using_opt",
150105
- /* 251 */ "exprlist",
150106
- /* 252 */ "xfullname",
150107
- /* 253 */ "idlist",
150108
- /* 254 */ "with",
150109
- /* 255 */ "setlist",
150110
- /* 256 */ "insert_cmd",
150111
- /* 257 */ "idlist_opt",
150112
- /* 258 */ "upsert",
150113
- /* 259 */ "over_clause",
150114
- /* 260 */ "likeop",
150115
- /* 261 */ "between_op",
150116
- /* 262 */ "in_op",
150117
- /* 263 */ "paren_exprlist",
150118
- /* 264 */ "case_operand",
150119
- /* 265 */ "case_exprlist",
150120
- /* 266 */ "case_else",
150121
- /* 267 */ "uniqueflag",
150122
- /* 268 */ "collate",
150123
- /* 269 */ "vinto",
150124
- /* 270 */ "nmnum",
150125
- /* 271 */ "trigger_decl",
150126
- /* 272 */ "trigger_cmd_list",
150127
- /* 273 */ "trigger_time",
150128
- /* 274 */ "trigger_event",
150129
- /* 275 */ "foreach_clause",
150130
- /* 276 */ "when_clause",
150131
- /* 277 */ "trigger_cmd",
150132
- /* 278 */ "trnm",
150133
- /* 279 */ "tridxby",
150134
- /* 280 */ "database_kw_opt",
150135
- /* 281 */ "key_opt",
150136
- /* 282 */ "add_column_fullname",
150137
- /* 283 */ "kwcolumn_opt",
150138
- /* 284 */ "create_vtab",
150139
- /* 285 */ "vtabarglist",
150140
- /* 286 */ "vtabarg",
150141
- /* 287 */ "vtabargtoken",
150142
- /* 288 */ "lp",
150143
- /* 289 */ "anylist",
150144
- /* 290 */ "windowdefn_list",
150145
- /* 291 */ "windowdefn",
150146
- /* 292 */ "window",
150147
- /* 293 */ "frame_opt",
150148
- /* 294 */ "part_opt",
150149
- /* 295 */ "filter_opt",
150150
- /* 296 */ "range_or_rows",
150151
- /* 297 */ "frame_bound",
150152
- /* 298 */ "frame_bound_s",
150153
- /* 299 */ "frame_bound_e",
150154
- /* 300 */ "frame_exclude_opt",
150155
- /* 301 */ "frame_exclude",
150823
+ /* 165 */ "TRUEFALSE",
150824
+ /* 166 */ "ISNOT",
150825
+ /* 167 */ "FUNCTION",
150826
+ /* 168 */ "UMINUS",
150827
+ /* 169 */ "UPLUS",
150828
+ /* 170 */ "TRUTH",
150829
+ /* 171 */ "REGISTER",
150830
+ /* 172 */ "VECTOR",
150831
+ /* 173 */ "SELECT_COLUMN",
150832
+ /* 174 */ "IF_NULL_ROW",
150833
+ /* 175 */ "ASTERISK",
150834
+ /* 176 */ "SPAN",
150835
+ /* 177 */ "SPACE",
150836
+ /* 178 */ "ILLEGAL",
150837
+ /* 179 */ "input",
150838
+ /* 180 */ "cmdlist",
150839
+ /* 181 */ "ecmd",
150840
+ /* 182 */ "cmdx",
150841
+ /* 183 */ "explain",
150842
+ /* 184 */ "cmd",
150843
+ /* 185 */ "transtype",
150844
+ /* 186 */ "trans_opt",
150845
+ /* 187 */ "nm",
150846
+ /* 188 */ "savepoint_opt",
150847
+ /* 189 */ "create_table",
150848
+ /* 190 */ "create_table_args",
150849
+ /* 191 */ "createkw",
150850
+ /* 192 */ "temp",
150851
+ /* 193 */ "ifnotexists",
150852
+ /* 194 */ "dbnm",
150853
+ /* 195 */ "columnlist",
150854
+ /* 196 */ "conslist_opt",
150855
+ /* 197 */ "table_options",
150856
+ /* 198 */ "select",
150857
+ /* 199 */ "columnname",
150858
+ /* 200 */ "carglist",
150859
+ /* 201 */ "typetoken",
150860
+ /* 202 */ "typename",
150861
+ /* 203 */ "signed",
150862
+ /* 204 */ "plus_num",
150863
+ /* 205 */ "minus_num",
150864
+ /* 206 */ "scanpt",
150865
+ /* 207 */ "scantok",
150866
+ /* 208 */ "ccons",
150867
+ /* 209 */ "term",
150868
+ /* 210 */ "expr",
150869
+ /* 211 */ "onconf",
150870
+ /* 212 */ "sortorder",
150871
+ /* 213 */ "autoinc",
150872
+ /* 214 */ "eidlist_opt",
150873
+ /* 215 */ "refargs",
150874
+ /* 216 */ "defer_subclause",
150875
+ /* 217 */ "refarg",
150876
+ /* 218 */ "refact",
150877
+ /* 219 */ "init_deferred_pred_opt",
150878
+ /* 220 */ "conslist",
150879
+ /* 221 */ "tconscomma",
150880
+ /* 222 */ "tcons",
150881
+ /* 223 */ "sortlist",
150882
+ /* 224 */ "eidlist",
150883
+ /* 225 */ "defer_subclause_opt",
150884
+ /* 226 */ "orconf",
150885
+ /* 227 */ "resolvetype",
150886
+ /* 228 */ "raisetype",
150887
+ /* 229 */ "ifexists",
150888
+ /* 230 */ "fullname",
150889
+ /* 231 */ "selectnowith",
150890
+ /* 232 */ "oneselect",
150891
+ /* 233 */ "wqlist",
150892
+ /* 234 */ "multiselect_op",
150893
+ /* 235 */ "distinct",
150894
+ /* 236 */ "selcollist",
150895
+ /* 237 */ "from",
150896
+ /* 238 */ "where_opt",
150897
+ /* 239 */ "groupby_opt",
150898
+ /* 240 */ "having_opt",
150899
+ /* 241 */ "orderby_opt",
150900
+ /* 242 */ "limit_opt",
150901
+ /* 243 */ "window_clause",
150902
+ /* 244 */ "values",
150903
+ /* 245 */ "nexprlist",
150904
+ /* 246 */ "sclp",
150905
+ /* 247 */ "as",
150906
+ /* 248 */ "seltablist",
150907
+ /* 249 */ "stl_prefix",
150908
+ /* 250 */ "joinop",
150909
+ /* 251 */ "indexed_opt",
150910
+ /* 252 */ "on_opt",
150911
+ /* 253 */ "using_opt",
150912
+ /* 254 */ "exprlist",
150913
+ /* 255 */ "xfullname",
150914
+ /* 256 */ "idlist",
150915
+ /* 257 */ "nulls",
150916
+ /* 258 */ "with",
150917
+ /* 259 */ "setlist",
150918
+ /* 260 */ "insert_cmd",
150919
+ /* 261 */ "idlist_opt",
150920
+ /* 262 */ "upsert",
150921
+ /* 263 */ "filter_over",
150922
+ /* 264 */ "likeop",
150923
+ /* 265 */ "between_op",
150924
+ /* 266 */ "in_op",
150925
+ /* 267 */ "paren_exprlist",
150926
+ /* 268 */ "case_operand",
150927
+ /* 269 */ "case_exprlist",
150928
+ /* 270 */ "case_else",
150929
+ /* 271 */ "uniqueflag",
150930
+ /* 272 */ "collate",
150931
+ /* 273 */ "vinto",
150932
+ /* 274 */ "nmnum",
150933
+ /* 275 */ "trigger_decl",
150934
+ /* 276 */ "trigger_cmd_list",
150935
+ /* 277 */ "trigger_time",
150936
+ /* 278 */ "trigger_event",
150937
+ /* 279 */ "foreach_clause",
150938
+ /* 280 */ "when_clause",
150939
+ /* 281 */ "trigger_cmd",
150940
+ /* 282 */ "trnm",
150941
+ /* 283 */ "tridxby",
150942
+ /* 284 */ "database_kw_opt",
150943
+ /* 285 */ "key_opt",
150944
+ /* 286 */ "add_column_fullname",
150945
+ /* 287 */ "kwcolumn_opt",
150946
+ /* 288 */ "create_vtab",
150947
+ /* 289 */ "vtabarglist",
150948
+ /* 290 */ "vtabarg",
150949
+ /* 291 */ "vtabargtoken",
150950
+ /* 292 */ "lp",
150951
+ /* 293 */ "anylist",
150952
+ /* 294 */ "windowdefn_list",
150953
+ /* 295 */ "windowdefn",
150954
+ /* 296 */ "window",
150955
+ /* 297 */ "frame_opt",
150956
+ /* 298 */ "part_opt",
150957
+ /* 299 */ "filter_clause",
150958
+ /* 300 */ "over_clause",
150959
+ /* 301 */ "range_or_rows",
150960
+ /* 302 */ "frame_bound",
150961
+ /* 303 */ "frame_bound_s",
150962
+ /* 304 */ "frame_bound_e",
150963
+ /* 305 */ "frame_exclude_opt",
150964
+ /* 306 */ "frame_exclude",
150156150965
};
150157150966
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
150158150967
150159150968
#ifndef NDEBUG
150160150969
/* For tracing reduce actions, the names of all rules are required.
@@ -150288,256 +151097,261 @@
150288151097
/* 125 */ "indexed_opt ::= NOT INDEXED",
150289151098
/* 126 */ "using_opt ::= USING LP idlist RP",
150290151099
/* 127 */ "using_opt ::=",
150291151100
/* 128 */ "orderby_opt ::=",
150292151101
/* 129 */ "orderby_opt ::= ORDER BY sortlist",
150293
- /* 130 */ "sortlist ::= sortlist COMMA expr sortorder",
150294
- /* 131 */ "sortlist ::= expr sortorder",
151102
+ /* 130 */ "sortlist ::= sortlist COMMA expr sortorder nulls",
151103
+ /* 131 */ "sortlist ::= expr sortorder nulls",
150295151104
/* 132 */ "sortorder ::= ASC",
150296151105
/* 133 */ "sortorder ::= DESC",
150297151106
/* 134 */ "sortorder ::=",
150298
- /* 135 */ "groupby_opt ::=",
150299
- /* 136 */ "groupby_opt ::= GROUP BY nexprlist",
150300
- /* 137 */ "having_opt ::=",
150301
- /* 138 */ "having_opt ::= HAVING expr",
150302
- /* 139 */ "limit_opt ::=",
150303
- /* 140 */ "limit_opt ::= LIMIT expr",
150304
- /* 141 */ "limit_opt ::= LIMIT expr OFFSET expr",
150305
- /* 142 */ "limit_opt ::= LIMIT expr COMMA expr",
150306
- /* 143 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
150307
- /* 144 */ "where_opt ::=",
150308
- /* 145 */ "where_opt ::= WHERE expr",
150309
- /* 146 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
150310
- /* 147 */ "setlist ::= setlist COMMA nm EQ expr",
150311
- /* 148 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
150312
- /* 149 */ "setlist ::= nm EQ expr",
150313
- /* 150 */ "setlist ::= LP idlist RP EQ expr",
150314
- /* 151 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
150315
- /* 152 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
150316
- /* 153 */ "upsert ::=",
150317
- /* 154 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
150318
- /* 155 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
150319
- /* 156 */ "upsert ::= ON CONFLICT DO NOTHING",
150320
- /* 157 */ "insert_cmd ::= INSERT orconf",
150321
- /* 158 */ "insert_cmd ::= REPLACE",
150322
- /* 159 */ "idlist_opt ::=",
150323
- /* 160 */ "idlist_opt ::= LP idlist RP",
150324
- /* 161 */ "idlist ::= idlist COMMA nm",
150325
- /* 162 */ "idlist ::= nm",
150326
- /* 163 */ "expr ::= LP expr RP",
150327
- /* 164 */ "expr ::= ID|INDEXED",
150328
- /* 165 */ "expr ::= JOIN_KW",
150329
- /* 166 */ "expr ::= nm DOT nm",
150330
- /* 167 */ "expr ::= nm DOT nm DOT nm",
150331
- /* 168 */ "term ::= NULL|FLOAT|BLOB",
150332
- /* 169 */ "term ::= STRING",
150333
- /* 170 */ "term ::= INTEGER",
150334
- /* 171 */ "expr ::= VARIABLE",
150335
- /* 172 */ "expr ::= expr COLLATE ID|STRING",
150336
- /* 173 */ "expr ::= CAST LP expr AS typetoken RP",
150337
- /* 174 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
150338
- /* 175 */ "expr ::= ID|INDEXED LP STAR RP",
150339
- /* 176 */ "expr ::= ID|INDEXED LP distinct exprlist RP over_clause",
150340
- /* 177 */ "expr ::= ID|INDEXED LP STAR RP over_clause",
150341
- /* 178 */ "term ::= CTIME_KW",
150342
- /* 179 */ "expr ::= LP nexprlist COMMA expr RP",
150343
- /* 180 */ "expr ::= expr AND expr",
150344
- /* 181 */ "expr ::= expr OR expr",
150345
- /* 182 */ "expr ::= expr LT|GT|GE|LE expr",
150346
- /* 183 */ "expr ::= expr EQ|NE expr",
150347
- /* 184 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
150348
- /* 185 */ "expr ::= expr PLUS|MINUS expr",
150349
- /* 186 */ "expr ::= expr STAR|SLASH|REM expr",
150350
- /* 187 */ "expr ::= expr CONCAT expr",
150351
- /* 188 */ "likeop ::= NOT LIKE_KW|MATCH",
150352
- /* 189 */ "expr ::= expr likeop expr",
150353
- /* 190 */ "expr ::= expr likeop expr ESCAPE expr",
150354
- /* 191 */ "expr ::= expr ISNULL|NOTNULL",
150355
- /* 192 */ "expr ::= expr NOT NULL",
150356
- /* 193 */ "expr ::= expr IS expr",
150357
- /* 194 */ "expr ::= expr IS NOT expr",
150358
- /* 195 */ "expr ::= NOT expr",
150359
- /* 196 */ "expr ::= BITNOT expr",
150360
- /* 197 */ "expr ::= PLUS|MINUS expr",
150361
- /* 198 */ "between_op ::= BETWEEN",
150362
- /* 199 */ "between_op ::= NOT BETWEEN",
150363
- /* 200 */ "expr ::= expr between_op expr AND expr",
150364
- /* 201 */ "in_op ::= IN",
150365
- /* 202 */ "in_op ::= NOT IN",
150366
- /* 203 */ "expr ::= expr in_op LP exprlist RP",
150367
- /* 204 */ "expr ::= LP select RP",
150368
- /* 205 */ "expr ::= expr in_op LP select RP",
150369
- /* 206 */ "expr ::= expr in_op nm dbnm paren_exprlist",
150370
- /* 207 */ "expr ::= EXISTS LP select RP",
150371
- /* 208 */ "expr ::= CASE case_operand case_exprlist case_else END",
150372
- /* 209 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
150373
- /* 210 */ "case_exprlist ::= WHEN expr THEN expr",
150374
- /* 211 */ "case_else ::= ELSE expr",
150375
- /* 212 */ "case_else ::=",
150376
- /* 213 */ "case_operand ::= expr",
150377
- /* 214 */ "case_operand ::=",
150378
- /* 215 */ "exprlist ::=",
150379
- /* 216 */ "nexprlist ::= nexprlist COMMA expr",
150380
- /* 217 */ "nexprlist ::= expr",
150381
- /* 218 */ "paren_exprlist ::=",
150382
- /* 219 */ "paren_exprlist ::= LP exprlist RP",
150383
- /* 220 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
150384
- /* 221 */ "uniqueflag ::= UNIQUE",
150385
- /* 222 */ "uniqueflag ::=",
150386
- /* 223 */ "eidlist_opt ::=",
150387
- /* 224 */ "eidlist_opt ::= LP eidlist RP",
150388
- /* 225 */ "eidlist ::= eidlist COMMA nm collate sortorder",
150389
- /* 226 */ "eidlist ::= nm collate sortorder",
150390
- /* 227 */ "collate ::=",
150391
- /* 228 */ "collate ::= COLLATE ID|STRING",
150392
- /* 229 */ "cmd ::= DROP INDEX ifexists fullname",
150393
- /* 230 */ "cmd ::= VACUUM vinto",
150394
- /* 231 */ "cmd ::= VACUUM nm vinto",
150395
- /* 232 */ "vinto ::= INTO expr",
150396
- /* 233 */ "vinto ::=",
150397
- /* 234 */ "cmd ::= PRAGMA nm dbnm",
150398
- /* 235 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
150399
- /* 236 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
150400
- /* 237 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
150401
- /* 238 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
150402
- /* 239 */ "plus_num ::= PLUS INTEGER|FLOAT",
150403
- /* 240 */ "minus_num ::= MINUS INTEGER|FLOAT",
150404
- /* 241 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
150405
- /* 242 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
150406
- /* 243 */ "trigger_time ::= BEFORE|AFTER",
150407
- /* 244 */ "trigger_time ::= INSTEAD OF",
150408
- /* 245 */ "trigger_time ::=",
150409
- /* 246 */ "trigger_event ::= DELETE|INSERT",
150410
- /* 247 */ "trigger_event ::= UPDATE",
150411
- /* 248 */ "trigger_event ::= UPDATE OF idlist",
150412
- /* 249 */ "when_clause ::=",
150413
- /* 250 */ "when_clause ::= WHEN expr",
150414
- /* 251 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
150415
- /* 252 */ "trigger_cmd_list ::= trigger_cmd SEMI",
150416
- /* 253 */ "trnm ::= nm DOT nm",
150417
- /* 254 */ "tridxby ::= INDEXED BY nm",
150418
- /* 255 */ "tridxby ::= NOT INDEXED",
150419
- /* 256 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
150420
- /* 257 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
150421
- /* 258 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
150422
- /* 259 */ "trigger_cmd ::= scanpt select scanpt",
150423
- /* 260 */ "expr ::= RAISE LP IGNORE RP",
150424
- /* 261 */ "expr ::= RAISE LP raisetype COMMA nm RP",
150425
- /* 262 */ "raisetype ::= ROLLBACK",
150426
- /* 263 */ "raisetype ::= ABORT",
150427
- /* 264 */ "raisetype ::= FAIL",
150428
- /* 265 */ "cmd ::= DROP TRIGGER ifexists fullname",
150429
- /* 266 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
150430
- /* 267 */ "cmd ::= DETACH database_kw_opt expr",
150431
- /* 268 */ "key_opt ::=",
150432
- /* 269 */ "key_opt ::= KEY expr",
150433
- /* 270 */ "cmd ::= REINDEX",
150434
- /* 271 */ "cmd ::= REINDEX nm dbnm",
150435
- /* 272 */ "cmd ::= ANALYZE",
150436
- /* 273 */ "cmd ::= ANALYZE nm dbnm",
150437
- /* 274 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
150438
- /* 275 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
150439
- /* 276 */ "add_column_fullname ::= fullname",
150440
- /* 277 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
150441
- /* 278 */ "cmd ::= create_vtab",
150442
- /* 279 */ "cmd ::= create_vtab LP vtabarglist RP",
150443
- /* 280 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
150444
- /* 281 */ "vtabarg ::=",
150445
- /* 282 */ "vtabargtoken ::= ANY",
150446
- /* 283 */ "vtabargtoken ::= lp anylist RP",
150447
- /* 284 */ "lp ::= LP",
150448
- /* 285 */ "with ::= WITH wqlist",
150449
- /* 286 */ "with ::= WITH RECURSIVE wqlist",
150450
- /* 287 */ "wqlist ::= nm eidlist_opt AS LP select RP",
150451
- /* 288 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
150452
- /* 289 */ "windowdefn_list ::= windowdefn",
150453
- /* 290 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
150454
- /* 291 */ "windowdefn ::= nm AS LP window RP",
150455
- /* 292 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
150456
- /* 293 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
150457
- /* 294 */ "window ::= ORDER BY sortlist frame_opt",
150458
- /* 295 */ "window ::= nm ORDER BY sortlist frame_opt",
150459
- /* 296 */ "window ::= frame_opt",
150460
- /* 297 */ "window ::= nm frame_opt",
150461
- /* 298 */ "frame_opt ::=",
150462
- /* 299 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
150463
- /* 300 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
150464
- /* 301 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
150465
- /* 302 */ "frame_bound_s ::= frame_bound",
150466
- /* 303 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
150467
- /* 304 */ "frame_bound_e ::= frame_bound",
150468
- /* 305 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
150469
- /* 306 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
150470
- /* 307 */ "frame_bound ::= CURRENT ROW",
150471
- /* 308 */ "frame_exclude_opt ::=",
150472
- /* 309 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
150473
- /* 310 */ "frame_exclude ::= NO OTHERS",
150474
- /* 311 */ "frame_exclude ::= CURRENT ROW",
150475
- /* 312 */ "frame_exclude ::= GROUP|TIES",
150476
- /* 313 */ "window_clause ::= WINDOW windowdefn_list",
150477
- /* 314 */ "over_clause ::= filter_opt OVER LP window RP",
150478
- /* 315 */ "over_clause ::= filter_opt OVER nm",
150479
- /* 316 */ "filter_opt ::=",
150480
- /* 317 */ "filter_opt ::= FILTER LP WHERE expr RP",
150481
- /* 318 */ "input ::= cmdlist",
150482
- /* 319 */ "cmdlist ::= cmdlist ecmd",
150483
- /* 320 */ "cmdlist ::= ecmd",
150484
- /* 321 */ "ecmd ::= SEMI",
150485
- /* 322 */ "ecmd ::= cmdx SEMI",
150486
- /* 323 */ "ecmd ::= explain cmdx",
150487
- /* 324 */ "trans_opt ::=",
150488
- /* 325 */ "trans_opt ::= TRANSACTION",
150489
- /* 326 */ "trans_opt ::= TRANSACTION nm",
150490
- /* 327 */ "savepoint_opt ::= SAVEPOINT",
150491
- /* 328 */ "savepoint_opt ::=",
150492
- /* 329 */ "cmd ::= create_table create_table_args",
150493
- /* 330 */ "columnlist ::= columnlist COMMA columnname carglist",
150494
- /* 331 */ "columnlist ::= columnname carglist",
150495
- /* 332 */ "nm ::= ID|INDEXED",
150496
- /* 333 */ "nm ::= STRING",
150497
- /* 334 */ "nm ::= JOIN_KW",
150498
- /* 335 */ "typetoken ::= typename",
150499
- /* 336 */ "typename ::= ID|STRING",
150500
- /* 337 */ "signed ::= plus_num",
150501
- /* 338 */ "signed ::= minus_num",
150502
- /* 339 */ "carglist ::= carglist ccons",
150503
- /* 340 */ "carglist ::=",
150504
- /* 341 */ "ccons ::= NULL onconf",
150505
- /* 342 */ "conslist_opt ::= COMMA conslist",
150506
- /* 343 */ "conslist ::= conslist tconscomma tcons",
150507
- /* 344 */ "conslist ::= tcons",
150508
- /* 345 */ "tconscomma ::=",
150509
- /* 346 */ "defer_subclause_opt ::= defer_subclause",
150510
- /* 347 */ "resolvetype ::= raisetype",
150511
- /* 348 */ "selectnowith ::= oneselect",
150512
- /* 349 */ "oneselect ::= values",
150513
- /* 350 */ "sclp ::= selcollist COMMA",
150514
- /* 351 */ "as ::= ID|STRING",
150515
- /* 352 */ "expr ::= term",
150516
- /* 353 */ "likeop ::= LIKE_KW|MATCH",
150517
- /* 354 */ "exprlist ::= nexprlist",
150518
- /* 355 */ "nmnum ::= plus_num",
150519
- /* 356 */ "nmnum ::= nm",
150520
- /* 357 */ "nmnum ::= ON",
150521
- /* 358 */ "nmnum ::= DELETE",
150522
- /* 359 */ "nmnum ::= DEFAULT",
150523
- /* 360 */ "plus_num ::= INTEGER|FLOAT",
150524
- /* 361 */ "foreach_clause ::=",
150525
- /* 362 */ "foreach_clause ::= FOR EACH ROW",
150526
- /* 363 */ "trnm ::= nm",
150527
- /* 364 */ "tridxby ::=",
150528
- /* 365 */ "database_kw_opt ::= DATABASE",
150529
- /* 366 */ "database_kw_opt ::=",
150530
- /* 367 */ "kwcolumn_opt ::=",
150531
- /* 368 */ "kwcolumn_opt ::= COLUMNKW",
150532
- /* 369 */ "vtabarglist ::= vtabarg",
150533
- /* 370 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
150534
- /* 371 */ "vtabarg ::= vtabarg vtabargtoken",
150535
- /* 372 */ "anylist ::=",
150536
- /* 373 */ "anylist ::= anylist LP anylist RP",
150537
- /* 374 */ "anylist ::= anylist ANY",
150538
- /* 375 */ "with ::=",
151107
+ /* 135 */ "nulls ::= NULLS FIRST",
151108
+ /* 136 */ "nulls ::= NULLS LAST",
151109
+ /* 137 */ "nulls ::=",
151110
+ /* 138 */ "groupby_opt ::=",
151111
+ /* 139 */ "groupby_opt ::= GROUP BY nexprlist",
151112
+ /* 140 */ "having_opt ::=",
151113
+ /* 141 */ "having_opt ::= HAVING expr",
151114
+ /* 142 */ "limit_opt ::=",
151115
+ /* 143 */ "limit_opt ::= LIMIT expr",
151116
+ /* 144 */ "limit_opt ::= LIMIT expr OFFSET expr",
151117
+ /* 145 */ "limit_opt ::= LIMIT expr COMMA expr",
151118
+ /* 146 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
151119
+ /* 147 */ "where_opt ::=",
151120
+ /* 148 */ "where_opt ::= WHERE expr",
151121
+ /* 149 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
151122
+ /* 150 */ "setlist ::= setlist COMMA nm EQ expr",
151123
+ /* 151 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
151124
+ /* 152 */ "setlist ::= nm EQ expr",
151125
+ /* 153 */ "setlist ::= LP idlist RP EQ expr",
151126
+ /* 154 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
151127
+ /* 155 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
151128
+ /* 156 */ "upsert ::=",
151129
+ /* 157 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
151130
+ /* 158 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
151131
+ /* 159 */ "upsert ::= ON CONFLICT DO NOTHING",
151132
+ /* 160 */ "insert_cmd ::= INSERT orconf",
151133
+ /* 161 */ "insert_cmd ::= REPLACE",
151134
+ /* 162 */ "idlist_opt ::=",
151135
+ /* 163 */ "idlist_opt ::= LP idlist RP",
151136
+ /* 164 */ "idlist ::= idlist COMMA nm",
151137
+ /* 165 */ "idlist ::= nm",
151138
+ /* 166 */ "expr ::= LP expr RP",
151139
+ /* 167 */ "expr ::= ID|INDEXED",
151140
+ /* 168 */ "expr ::= JOIN_KW",
151141
+ /* 169 */ "expr ::= nm DOT nm",
151142
+ /* 170 */ "expr ::= nm DOT nm DOT nm",
151143
+ /* 171 */ "term ::= NULL|FLOAT|BLOB",
151144
+ /* 172 */ "term ::= STRING",
151145
+ /* 173 */ "term ::= INTEGER",
151146
+ /* 174 */ "expr ::= VARIABLE",
151147
+ /* 175 */ "expr ::= expr COLLATE ID|STRING",
151148
+ /* 176 */ "expr ::= CAST LP expr AS typetoken RP",
151149
+ /* 177 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
151150
+ /* 178 */ "expr ::= ID|INDEXED LP STAR RP",
151151
+ /* 179 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over",
151152
+ /* 180 */ "expr ::= ID|INDEXED LP STAR RP filter_over",
151153
+ /* 181 */ "term ::= CTIME_KW",
151154
+ /* 182 */ "expr ::= LP nexprlist COMMA expr RP",
151155
+ /* 183 */ "expr ::= expr AND expr",
151156
+ /* 184 */ "expr ::= expr OR expr",
151157
+ /* 185 */ "expr ::= expr LT|GT|GE|LE expr",
151158
+ /* 186 */ "expr ::= expr EQ|NE expr",
151159
+ /* 187 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
151160
+ /* 188 */ "expr ::= expr PLUS|MINUS expr",
151161
+ /* 189 */ "expr ::= expr STAR|SLASH|REM expr",
151162
+ /* 190 */ "expr ::= expr CONCAT expr",
151163
+ /* 191 */ "likeop ::= NOT LIKE_KW|MATCH",
151164
+ /* 192 */ "expr ::= expr likeop expr",
151165
+ /* 193 */ "expr ::= expr likeop expr ESCAPE expr",
151166
+ /* 194 */ "expr ::= expr ISNULL|NOTNULL",
151167
+ /* 195 */ "expr ::= expr NOT NULL",
151168
+ /* 196 */ "expr ::= expr IS expr",
151169
+ /* 197 */ "expr ::= expr IS NOT expr",
151170
+ /* 198 */ "expr ::= NOT expr",
151171
+ /* 199 */ "expr ::= BITNOT expr",
151172
+ /* 200 */ "expr ::= PLUS|MINUS expr",
151173
+ /* 201 */ "between_op ::= BETWEEN",
151174
+ /* 202 */ "between_op ::= NOT BETWEEN",
151175
+ /* 203 */ "expr ::= expr between_op expr AND expr",
151176
+ /* 204 */ "in_op ::= IN",
151177
+ /* 205 */ "in_op ::= NOT IN",
151178
+ /* 206 */ "expr ::= expr in_op LP exprlist RP",
151179
+ /* 207 */ "expr ::= LP select RP",
151180
+ /* 208 */ "expr ::= expr in_op LP select RP",
151181
+ /* 209 */ "expr ::= expr in_op nm dbnm paren_exprlist",
151182
+ /* 210 */ "expr ::= EXISTS LP select RP",
151183
+ /* 211 */ "expr ::= CASE case_operand case_exprlist case_else END",
151184
+ /* 212 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
151185
+ /* 213 */ "case_exprlist ::= WHEN expr THEN expr",
151186
+ /* 214 */ "case_else ::= ELSE expr",
151187
+ /* 215 */ "case_else ::=",
151188
+ /* 216 */ "case_operand ::= expr",
151189
+ /* 217 */ "case_operand ::=",
151190
+ /* 218 */ "exprlist ::=",
151191
+ /* 219 */ "nexprlist ::= nexprlist COMMA expr",
151192
+ /* 220 */ "nexprlist ::= expr",
151193
+ /* 221 */ "paren_exprlist ::=",
151194
+ /* 222 */ "paren_exprlist ::= LP exprlist RP",
151195
+ /* 223 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
151196
+ /* 224 */ "uniqueflag ::= UNIQUE",
151197
+ /* 225 */ "uniqueflag ::=",
151198
+ /* 226 */ "eidlist_opt ::=",
151199
+ /* 227 */ "eidlist_opt ::= LP eidlist RP",
151200
+ /* 228 */ "eidlist ::= eidlist COMMA nm collate sortorder",
151201
+ /* 229 */ "eidlist ::= nm collate sortorder",
151202
+ /* 230 */ "collate ::=",
151203
+ /* 231 */ "collate ::= COLLATE ID|STRING",
151204
+ /* 232 */ "cmd ::= DROP INDEX ifexists fullname",
151205
+ /* 233 */ "cmd ::= VACUUM vinto",
151206
+ /* 234 */ "cmd ::= VACUUM nm vinto",
151207
+ /* 235 */ "vinto ::= INTO expr",
151208
+ /* 236 */ "vinto ::=",
151209
+ /* 237 */ "cmd ::= PRAGMA nm dbnm",
151210
+ /* 238 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
151211
+ /* 239 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
151212
+ /* 240 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
151213
+ /* 241 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
151214
+ /* 242 */ "plus_num ::= PLUS INTEGER|FLOAT",
151215
+ /* 243 */ "minus_num ::= MINUS INTEGER|FLOAT",
151216
+ /* 244 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
151217
+ /* 245 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
151218
+ /* 246 */ "trigger_time ::= BEFORE|AFTER",
151219
+ /* 247 */ "trigger_time ::= INSTEAD OF",
151220
+ /* 248 */ "trigger_time ::=",
151221
+ /* 249 */ "trigger_event ::= DELETE|INSERT",
151222
+ /* 250 */ "trigger_event ::= UPDATE",
151223
+ /* 251 */ "trigger_event ::= UPDATE OF idlist",
151224
+ /* 252 */ "when_clause ::=",
151225
+ /* 253 */ "when_clause ::= WHEN expr",
151226
+ /* 254 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
151227
+ /* 255 */ "trigger_cmd_list ::= trigger_cmd SEMI",
151228
+ /* 256 */ "trnm ::= nm DOT nm",
151229
+ /* 257 */ "tridxby ::= INDEXED BY nm",
151230
+ /* 258 */ "tridxby ::= NOT INDEXED",
151231
+ /* 259 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
151232
+ /* 260 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
151233
+ /* 261 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
151234
+ /* 262 */ "trigger_cmd ::= scanpt select scanpt",
151235
+ /* 263 */ "expr ::= RAISE LP IGNORE RP",
151236
+ /* 264 */ "expr ::= RAISE LP raisetype COMMA nm RP",
151237
+ /* 265 */ "raisetype ::= ROLLBACK",
151238
+ /* 266 */ "raisetype ::= ABORT",
151239
+ /* 267 */ "raisetype ::= FAIL",
151240
+ /* 268 */ "cmd ::= DROP TRIGGER ifexists fullname",
151241
+ /* 269 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
151242
+ /* 270 */ "cmd ::= DETACH database_kw_opt expr",
151243
+ /* 271 */ "key_opt ::=",
151244
+ /* 272 */ "key_opt ::= KEY expr",
151245
+ /* 273 */ "cmd ::= REINDEX",
151246
+ /* 274 */ "cmd ::= REINDEX nm dbnm",
151247
+ /* 275 */ "cmd ::= ANALYZE",
151248
+ /* 276 */ "cmd ::= ANALYZE nm dbnm",
151249
+ /* 277 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
151250
+ /* 278 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
151251
+ /* 279 */ "add_column_fullname ::= fullname",
151252
+ /* 280 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
151253
+ /* 281 */ "cmd ::= create_vtab",
151254
+ /* 282 */ "cmd ::= create_vtab LP vtabarglist RP",
151255
+ /* 283 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
151256
+ /* 284 */ "vtabarg ::=",
151257
+ /* 285 */ "vtabargtoken ::= ANY",
151258
+ /* 286 */ "vtabargtoken ::= lp anylist RP",
151259
+ /* 287 */ "lp ::= LP",
151260
+ /* 288 */ "with ::= WITH wqlist",
151261
+ /* 289 */ "with ::= WITH RECURSIVE wqlist",
151262
+ /* 290 */ "wqlist ::= nm eidlist_opt AS LP select RP",
151263
+ /* 291 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
151264
+ /* 292 */ "windowdefn_list ::= windowdefn",
151265
+ /* 293 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
151266
+ /* 294 */ "windowdefn ::= nm AS LP window RP",
151267
+ /* 295 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
151268
+ /* 296 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
151269
+ /* 297 */ "window ::= ORDER BY sortlist frame_opt",
151270
+ /* 298 */ "window ::= nm ORDER BY sortlist frame_opt",
151271
+ /* 299 */ "window ::= frame_opt",
151272
+ /* 300 */ "window ::= nm frame_opt",
151273
+ /* 301 */ "frame_opt ::=",
151274
+ /* 302 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
151275
+ /* 303 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
151276
+ /* 304 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
151277
+ /* 305 */ "frame_bound_s ::= frame_bound",
151278
+ /* 306 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
151279
+ /* 307 */ "frame_bound_e ::= frame_bound",
151280
+ /* 308 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
151281
+ /* 309 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
151282
+ /* 310 */ "frame_bound ::= CURRENT ROW",
151283
+ /* 311 */ "frame_exclude_opt ::=",
151284
+ /* 312 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
151285
+ /* 313 */ "frame_exclude ::= NO OTHERS",
151286
+ /* 314 */ "frame_exclude ::= CURRENT ROW",
151287
+ /* 315 */ "frame_exclude ::= GROUP|TIES",
151288
+ /* 316 */ "window_clause ::= WINDOW windowdefn_list",
151289
+ /* 317 */ "filter_over ::= filter_clause over_clause",
151290
+ /* 318 */ "filter_over ::= over_clause",
151291
+ /* 319 */ "filter_over ::= filter_clause",
151292
+ /* 320 */ "over_clause ::= OVER LP window RP",
151293
+ /* 321 */ "over_clause ::= OVER nm",
151294
+ /* 322 */ "filter_clause ::= FILTER LP WHERE expr RP",
151295
+ /* 323 */ "input ::= cmdlist",
151296
+ /* 324 */ "cmdlist ::= cmdlist ecmd",
151297
+ /* 325 */ "cmdlist ::= ecmd",
151298
+ /* 326 */ "ecmd ::= SEMI",
151299
+ /* 327 */ "ecmd ::= cmdx SEMI",
151300
+ /* 328 */ "ecmd ::= explain cmdx",
151301
+ /* 329 */ "trans_opt ::=",
151302
+ /* 330 */ "trans_opt ::= TRANSACTION",
151303
+ /* 331 */ "trans_opt ::= TRANSACTION nm",
151304
+ /* 332 */ "savepoint_opt ::= SAVEPOINT",
151305
+ /* 333 */ "savepoint_opt ::=",
151306
+ /* 334 */ "cmd ::= create_table create_table_args",
151307
+ /* 335 */ "columnlist ::= columnlist COMMA columnname carglist",
151308
+ /* 336 */ "columnlist ::= columnname carglist",
151309
+ /* 337 */ "nm ::= ID|INDEXED",
151310
+ /* 338 */ "nm ::= STRING",
151311
+ /* 339 */ "nm ::= JOIN_KW",
151312
+ /* 340 */ "typetoken ::= typename",
151313
+ /* 341 */ "typename ::= ID|STRING",
151314
+ /* 342 */ "signed ::= plus_num",
151315
+ /* 343 */ "signed ::= minus_num",
151316
+ /* 344 */ "carglist ::= carglist ccons",
151317
+ /* 345 */ "carglist ::=",
151318
+ /* 346 */ "ccons ::= NULL onconf",
151319
+ /* 347 */ "conslist_opt ::= COMMA conslist",
151320
+ /* 348 */ "conslist ::= conslist tconscomma tcons",
151321
+ /* 349 */ "conslist ::= tcons",
151322
+ /* 350 */ "tconscomma ::=",
151323
+ /* 351 */ "defer_subclause_opt ::= defer_subclause",
151324
+ /* 352 */ "resolvetype ::= raisetype",
151325
+ /* 353 */ "selectnowith ::= oneselect",
151326
+ /* 354 */ "oneselect ::= values",
151327
+ /* 355 */ "sclp ::= selcollist COMMA",
151328
+ /* 356 */ "as ::= ID|STRING",
151329
+ /* 357 */ "expr ::= term",
151330
+ /* 358 */ "likeop ::= LIKE_KW|MATCH",
151331
+ /* 359 */ "exprlist ::= nexprlist",
151332
+ /* 360 */ "nmnum ::= plus_num",
151333
+ /* 361 */ "nmnum ::= nm",
151334
+ /* 362 */ "nmnum ::= ON",
151335
+ /* 363 */ "nmnum ::= DELETE",
151336
+ /* 364 */ "nmnum ::= DEFAULT",
151337
+ /* 365 */ "plus_num ::= INTEGER|FLOAT",
151338
+ /* 366 */ "foreach_clause ::=",
151339
+ /* 367 */ "foreach_clause ::= FOR EACH ROW",
151340
+ /* 368 */ "trnm ::= nm",
151341
+ /* 369 */ "tridxby ::=",
151342
+ /* 370 */ "database_kw_opt ::= DATABASE",
151343
+ /* 371 */ "database_kw_opt ::=",
151344
+ /* 372 */ "kwcolumn_opt ::=",
151345
+ /* 373 */ "kwcolumn_opt ::= COLUMNKW",
151346
+ /* 374 */ "vtabarglist ::= vtabarg",
151347
+ /* 375 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
151348
+ /* 376 */ "vtabarg ::= vtabarg vtabargtoken",
151349
+ /* 377 */ "anylist ::=",
151350
+ /* 378 */ "anylist ::= anylist LP anylist RP",
151351
+ /* 379 */ "anylist ::= anylist ANY",
151352
+ /* 380 */ "with ::=",
150539151353
};
150540151354
#endif /* NDEBUG */
150541151355
150542151356
150543151357
#if YYSTACKDEPTH<=0
@@ -150659,101 +151473,102 @@
150659151473
** Note: during a reduce, the only symbols destroyed are those
150660151474
** which appear on the RHS of the rule, but which are *not* used
150661151475
** inside the C code.
150662151476
*/
150663151477
/********* Begin destructor definitions ***************************************/
150664
- case 195: /* select */
150665
- case 228: /* selectnowith */
150666
- case 229: /* oneselect */
150667
- case 241: /* values */
150668
-{
150669
-sqlite3SelectDelete(pParse->db, (yypminor->yy391));
150670
-}
150671
- break;
150672
- case 206: /* term */
150673
- case 207: /* expr */
150674
- case 235: /* where_opt */
150675
- case 237: /* having_opt */
150676
- case 249: /* on_opt */
150677
- case 264: /* case_operand */
150678
- case 266: /* case_else */
150679
- case 269: /* vinto */
150680
- case 276: /* when_clause */
150681
- case 281: /* key_opt */
150682
- case 295: /* filter_opt */
150683
-{
150684
-sqlite3ExprDelete(pParse->db, (yypminor->yy102));
150685
-}
150686
- break;
150687
- case 211: /* eidlist_opt */
150688
- case 220: /* sortlist */
150689
- case 221: /* eidlist */
150690
- case 233: /* selcollist */
150691
- case 236: /* groupby_opt */
150692
- case 238: /* orderby_opt */
150693
- case 242: /* nexprlist */
150694
- case 243: /* sclp */
150695
- case 251: /* exprlist */
150696
- case 255: /* setlist */
150697
- case 263: /* paren_exprlist */
150698
- case 265: /* case_exprlist */
150699
- case 294: /* part_opt */
150700
-{
150701
-sqlite3ExprListDelete(pParse->db, (yypminor->yy94));
150702
-}
150703
- break;
150704
- case 227: /* fullname */
150705
- case 234: /* from */
150706
- case 245: /* seltablist */
150707
- case 246: /* stl_prefix */
150708
- case 252: /* xfullname */
150709
-{
150710
-sqlite3SrcListDelete(pParse->db, (yypminor->yy407));
150711
-}
150712
- break;
150713
- case 230: /* wqlist */
150714
-{
150715
-sqlite3WithDelete(pParse->db, (yypminor->yy243));
150716
-}
150717
- break;
150718
- case 240: /* window_clause */
150719
- case 290: /* windowdefn_list */
150720
-{
150721
-sqlite3WindowListDelete(pParse->db, (yypminor->yy379));
150722
-}
150723
- break;
150724
- case 250: /* using_opt */
150725
- case 253: /* idlist */
150726
- case 257: /* idlist_opt */
150727
-{
150728
-sqlite3IdListDelete(pParse->db, (yypminor->yy76));
150729
-}
150730
- break;
150731
- case 259: /* over_clause */
150732
- case 291: /* windowdefn */
150733
- case 292: /* window */
150734
- case 293: /* frame_opt */
150735
-{
150736
-sqlite3WindowDelete(pParse->db, (yypminor->yy379));
150737
-}
150738
- break;
150739
- case 272: /* trigger_cmd_list */
150740
- case 277: /* trigger_cmd */
150741
-{
150742
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy11));
150743
-}
150744
- break;
150745
- case 274: /* trigger_event */
150746
-{
150747
-sqlite3IdListDelete(pParse->db, (yypminor->yy298).b);
150748
-}
150749
- break;
150750
- case 297: /* frame_bound */
150751
- case 298: /* frame_bound_s */
150752
- case 299: /* frame_bound_e */
150753
-{
150754
-sqlite3ExprDelete(pParse->db, (yypminor->yy389).pExpr);
151478
+ case 198: /* select */
151479
+ case 231: /* selectnowith */
151480
+ case 232: /* oneselect */
151481
+ case 244: /* values */
151482
+{
151483
+sqlite3SelectDelete(pParse->db, (yypminor->yy25));
151484
+}
151485
+ break;
151486
+ case 209: /* term */
151487
+ case 210: /* expr */
151488
+ case 238: /* where_opt */
151489
+ case 240: /* having_opt */
151490
+ case 252: /* on_opt */
151491
+ case 268: /* case_operand */
151492
+ case 270: /* case_else */
151493
+ case 273: /* vinto */
151494
+ case 280: /* when_clause */
151495
+ case 285: /* key_opt */
151496
+ case 299: /* filter_clause */
151497
+{
151498
+sqlite3ExprDelete(pParse->db, (yypminor->yy46));
151499
+}
151500
+ break;
151501
+ case 214: /* eidlist_opt */
151502
+ case 223: /* sortlist */
151503
+ case 224: /* eidlist */
151504
+ case 236: /* selcollist */
151505
+ case 239: /* groupby_opt */
151506
+ case 241: /* orderby_opt */
151507
+ case 245: /* nexprlist */
151508
+ case 246: /* sclp */
151509
+ case 254: /* exprlist */
151510
+ case 259: /* setlist */
151511
+ case 267: /* paren_exprlist */
151512
+ case 269: /* case_exprlist */
151513
+ case 298: /* part_opt */
151514
+{
151515
+sqlite3ExprListDelete(pParse->db, (yypminor->yy138));
151516
+}
151517
+ break;
151518
+ case 230: /* fullname */
151519
+ case 237: /* from */
151520
+ case 248: /* seltablist */
151521
+ case 249: /* stl_prefix */
151522
+ case 255: /* xfullname */
151523
+{
151524
+sqlite3SrcListDelete(pParse->db, (yypminor->yy609));
151525
+}
151526
+ break;
151527
+ case 233: /* wqlist */
151528
+{
151529
+sqlite3WithDelete(pParse->db, (yypminor->yy297));
151530
+}
151531
+ break;
151532
+ case 243: /* window_clause */
151533
+ case 294: /* windowdefn_list */
151534
+{
151535
+sqlite3WindowListDelete(pParse->db, (yypminor->yy455));
151536
+}
151537
+ break;
151538
+ case 253: /* using_opt */
151539
+ case 256: /* idlist */
151540
+ case 261: /* idlist_opt */
151541
+{
151542
+sqlite3IdListDelete(pParse->db, (yypminor->yy406));
151543
+}
151544
+ break;
151545
+ case 263: /* filter_over */
151546
+ case 295: /* windowdefn */
151547
+ case 296: /* window */
151548
+ case 297: /* frame_opt */
151549
+ case 300: /* over_clause */
151550
+{
151551
+sqlite3WindowDelete(pParse->db, (yypminor->yy455));
151552
+}
151553
+ break;
151554
+ case 276: /* trigger_cmd_list */
151555
+ case 281: /* trigger_cmd */
151556
+{
151557
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy527));
151558
+}
151559
+ break;
151560
+ case 278: /* trigger_event */
151561
+{
151562
+sqlite3IdListDelete(pParse->db, (yypminor->yy572).b);
151563
+}
151564
+ break;
151565
+ case 302: /* frame_bound */
151566
+ case 303: /* frame_bound_s */
151567
+ case 304: /* frame_bound_e */
151568
+{
151569
+sqlite3ExprDelete(pParse->db, (yypminor->yy57).pExpr);
150755151570
}
150756151571
break;
150757151572
/********* End destructor definitions *****************************************/
150758151573
default: break; /* If no destructor action specified: do nothing */
150759151574
}
@@ -150875,19 +151690,22 @@
150875151690
yycoverage[stateno][iLookAhead] = 1;
150876151691
#endif
150877151692
do{
150878151693
i = yy_shift_ofst[stateno];
150879151694
assert( i>=0 );
150880
- /* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */
151695
+ assert( i<=YY_ACTTAB_COUNT );
151696
+ assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD );
150881151697
assert( iLookAhead!=YYNOCODE );
150882151698
assert( iLookAhead < YYNTOKEN );
150883151699
i += iLookAhead;
150884
- if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){
151700
+ assert( i<(int)YY_NLOOKAHEAD );
151701
+ if( yy_lookahead[i]!=iLookAhead ){
150885151702
#ifdef YYFALLBACK
150886151703
YYCODETYPE iFallback; /* Fallback token */
150887
- if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
150888
- && (iFallback = yyFallback[iLookAhead])!=0 ){
151704
+ assert( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) );
151705
+ iFallback = yyFallback[iLookAhead];
151706
+ if( iFallback!=0 ){
150889151707
#ifndef NDEBUG
150890151708
if( yyTraceFILE ){
150891151709
fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
150892151710
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
150893151711
}
@@ -150898,20 +151716,12 @@
150898151716
}
150899151717
#endif
150900151718
#ifdef YYWILDCARD
150901151719
{
150902151720
int j = i - iLookAhead + YYWILDCARD;
150903
- if(
150904
-#if YY_SHIFT_MIN+YYWILDCARD<0
150905
- j>=0 &&
150906
-#endif
150907
-#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
150908
- j<YY_ACTTAB_COUNT &&
150909
-#endif
150910
- j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) &&
150911
- yy_lookahead[j]==YYWILDCARD && iLookAhead>0
150912
- ){
151721
+ assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) );
151722
+ if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){
150913151723
#ifndef NDEBUG
150914151724
if( yyTraceFILE ){
150915151725
fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
150916151726
yyTracePrompt, yyTokenName[iLookAhead],
150917151727
yyTokenName[YYWILDCARD]);
@@ -150921,10 +151731,11 @@
150921151731
}
150922151732
}
150923151733
#endif /* YYWILDCARD */
150924151734
return yy_default[stateno];
150925151735
}else{
151736
+ assert( i>=0 && i<sizeof(yy_action)/sizeof(yy_action[0]) );
150926151737
return yy_action[i];
150927151738
}
150928151739
}while(1);
150929151740
}
150930151741
@@ -151044,386 +151855,391 @@
151044151855
}
151045151856
151046151857
/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
151047151858
** of that rule */
151048151859
static const YYCODETYPE yyRuleInfoLhs[] = {
151049
- 180, /* (0) explain ::= EXPLAIN */
151050
- 180, /* (1) explain ::= EXPLAIN QUERY PLAN */
151051
- 179, /* (2) cmdx ::= cmd */
151052
- 181, /* (3) cmd ::= BEGIN transtype trans_opt */
151053
- 182, /* (4) transtype ::= */
151054
- 182, /* (5) transtype ::= DEFERRED */
151055
- 182, /* (6) transtype ::= IMMEDIATE */
151056
- 182, /* (7) transtype ::= EXCLUSIVE */
151057
- 181, /* (8) cmd ::= COMMIT|END trans_opt */
151058
- 181, /* (9) cmd ::= ROLLBACK trans_opt */
151059
- 181, /* (10) cmd ::= SAVEPOINT nm */
151060
- 181, /* (11) cmd ::= RELEASE savepoint_opt nm */
151061
- 181, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
151062
- 186, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
151063
- 188, /* (14) createkw ::= CREATE */
151064
- 190, /* (15) ifnotexists ::= */
151065
- 190, /* (16) ifnotexists ::= IF NOT EXISTS */
151066
- 189, /* (17) temp ::= TEMP */
151067
- 189, /* (18) temp ::= */
151068
- 187, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
151069
- 187, /* (20) create_table_args ::= AS select */
151070
- 194, /* (21) table_options ::= */
151071
- 194, /* (22) table_options ::= WITHOUT nm */
151072
- 196, /* (23) columnname ::= nm typetoken */
151073
- 198, /* (24) typetoken ::= */
151074
- 198, /* (25) typetoken ::= typename LP signed RP */
151075
- 198, /* (26) typetoken ::= typename LP signed COMMA signed RP */
151076
- 199, /* (27) typename ::= typename ID|STRING */
151077
- 203, /* (28) scanpt ::= */
151078
- 204, /* (29) scantok ::= */
151079
- 205, /* (30) ccons ::= CONSTRAINT nm */
151080
- 205, /* (31) ccons ::= DEFAULT scantok term */
151081
- 205, /* (32) ccons ::= DEFAULT LP expr RP */
151082
- 205, /* (33) ccons ::= DEFAULT PLUS scantok term */
151083
- 205, /* (34) ccons ::= DEFAULT MINUS scantok term */
151084
- 205, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
151085
- 205, /* (36) ccons ::= NOT NULL onconf */
151086
- 205, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
151087
- 205, /* (38) ccons ::= UNIQUE onconf */
151088
- 205, /* (39) ccons ::= CHECK LP expr RP */
151089
- 205, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
151090
- 205, /* (41) ccons ::= defer_subclause */
151091
- 205, /* (42) ccons ::= COLLATE ID|STRING */
151092
- 210, /* (43) autoinc ::= */
151093
- 210, /* (44) autoinc ::= AUTOINCR */
151094
- 212, /* (45) refargs ::= */
151095
- 212, /* (46) refargs ::= refargs refarg */
151096
- 214, /* (47) refarg ::= MATCH nm */
151097
- 214, /* (48) refarg ::= ON INSERT refact */
151098
- 214, /* (49) refarg ::= ON DELETE refact */
151099
- 214, /* (50) refarg ::= ON UPDATE refact */
151100
- 215, /* (51) refact ::= SET NULL */
151101
- 215, /* (52) refact ::= SET DEFAULT */
151102
- 215, /* (53) refact ::= CASCADE */
151103
- 215, /* (54) refact ::= RESTRICT */
151104
- 215, /* (55) refact ::= NO ACTION */
151105
- 213, /* (56) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
151106
- 213, /* (57) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
151107
- 216, /* (58) init_deferred_pred_opt ::= */
151108
- 216, /* (59) init_deferred_pred_opt ::= INITIALLY DEFERRED */
151109
- 216, /* (60) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
151110
- 193, /* (61) conslist_opt ::= */
151111
- 218, /* (62) tconscomma ::= COMMA */
151112
- 219, /* (63) tcons ::= CONSTRAINT nm */
151113
- 219, /* (64) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
151114
- 219, /* (65) tcons ::= UNIQUE LP sortlist RP onconf */
151115
- 219, /* (66) tcons ::= CHECK LP expr RP onconf */
151116
- 219, /* (67) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
151117
- 222, /* (68) defer_subclause_opt ::= */
151118
- 208, /* (69) onconf ::= */
151119
- 208, /* (70) onconf ::= ON CONFLICT resolvetype */
151120
- 223, /* (71) orconf ::= */
151121
- 223, /* (72) orconf ::= OR resolvetype */
151122
- 224, /* (73) resolvetype ::= IGNORE */
151123
- 224, /* (74) resolvetype ::= REPLACE */
151124
- 181, /* (75) cmd ::= DROP TABLE ifexists fullname */
151125
- 226, /* (76) ifexists ::= IF EXISTS */
151126
- 226, /* (77) ifexists ::= */
151127
- 181, /* (78) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
151128
- 181, /* (79) cmd ::= DROP VIEW ifexists fullname */
151129
- 181, /* (80) cmd ::= select */
151130
- 195, /* (81) select ::= WITH wqlist selectnowith */
151131
- 195, /* (82) select ::= WITH RECURSIVE wqlist selectnowith */
151132
- 195, /* (83) select ::= selectnowith */
151133
- 228, /* (84) selectnowith ::= selectnowith multiselect_op oneselect */
151134
- 231, /* (85) multiselect_op ::= UNION */
151135
- 231, /* (86) multiselect_op ::= UNION ALL */
151136
- 231, /* (87) multiselect_op ::= EXCEPT|INTERSECT */
151137
- 229, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
151138
- 229, /* (89) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
151139
- 241, /* (90) values ::= VALUES LP nexprlist RP */
151140
- 241, /* (91) values ::= values COMMA LP nexprlist RP */
151141
- 232, /* (92) distinct ::= DISTINCT */
151142
- 232, /* (93) distinct ::= ALL */
151143
- 232, /* (94) distinct ::= */
151144
- 243, /* (95) sclp ::= */
151145
- 233, /* (96) selcollist ::= sclp scanpt expr scanpt as */
151146
- 233, /* (97) selcollist ::= sclp scanpt STAR */
151147
- 233, /* (98) selcollist ::= sclp scanpt nm DOT STAR */
151148
- 244, /* (99) as ::= AS nm */
151149
- 244, /* (100) as ::= */
151150
- 234, /* (101) from ::= */
151151
- 234, /* (102) from ::= FROM seltablist */
151152
- 246, /* (103) stl_prefix ::= seltablist joinop */
151153
- 246, /* (104) stl_prefix ::= */
151154
- 245, /* (105) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
151155
- 245, /* (106) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
151156
- 245, /* (107) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
151157
- 245, /* (108) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
151158
- 191, /* (109) dbnm ::= */
151159
- 191, /* (110) dbnm ::= DOT nm */
151160
- 227, /* (111) fullname ::= nm */
151161
- 227, /* (112) fullname ::= nm DOT nm */
151162
- 252, /* (113) xfullname ::= nm */
151163
- 252, /* (114) xfullname ::= nm DOT nm */
151164
- 252, /* (115) xfullname ::= nm DOT nm AS nm */
151165
- 252, /* (116) xfullname ::= nm AS nm */
151166
- 247, /* (117) joinop ::= COMMA|JOIN */
151167
- 247, /* (118) joinop ::= JOIN_KW JOIN */
151168
- 247, /* (119) joinop ::= JOIN_KW nm JOIN */
151169
- 247, /* (120) joinop ::= JOIN_KW nm nm JOIN */
151170
- 249, /* (121) on_opt ::= ON expr */
151171
- 249, /* (122) on_opt ::= */
151172
- 248, /* (123) indexed_opt ::= */
151173
- 248, /* (124) indexed_opt ::= INDEXED BY nm */
151174
- 248, /* (125) indexed_opt ::= NOT INDEXED */
151175
- 250, /* (126) using_opt ::= USING LP idlist RP */
151176
- 250, /* (127) using_opt ::= */
151177
- 238, /* (128) orderby_opt ::= */
151178
- 238, /* (129) orderby_opt ::= ORDER BY sortlist */
151179
- 220, /* (130) sortlist ::= sortlist COMMA expr sortorder */
151180
- 220, /* (131) sortlist ::= expr sortorder */
151181
- 209, /* (132) sortorder ::= ASC */
151182
- 209, /* (133) sortorder ::= DESC */
151183
- 209, /* (134) sortorder ::= */
151184
- 236, /* (135) groupby_opt ::= */
151185
- 236, /* (136) groupby_opt ::= GROUP BY nexprlist */
151186
- 237, /* (137) having_opt ::= */
151187
- 237, /* (138) having_opt ::= HAVING expr */
151188
- 239, /* (139) limit_opt ::= */
151189
- 239, /* (140) limit_opt ::= LIMIT expr */
151190
- 239, /* (141) limit_opt ::= LIMIT expr OFFSET expr */
151191
- 239, /* (142) limit_opt ::= LIMIT expr COMMA expr */
151192
- 181, /* (143) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
151193
- 235, /* (144) where_opt ::= */
151194
- 235, /* (145) where_opt ::= WHERE expr */
151195
- 181, /* (146) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
151196
- 255, /* (147) setlist ::= setlist COMMA nm EQ expr */
151197
- 255, /* (148) setlist ::= setlist COMMA LP idlist RP EQ expr */
151198
- 255, /* (149) setlist ::= nm EQ expr */
151199
- 255, /* (150) setlist ::= LP idlist RP EQ expr */
151200
- 181, /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
151201
- 181, /* (152) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
151202
- 258, /* (153) upsert ::= */
151203
- 258, /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
151204
- 258, /* (155) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
151205
- 258, /* (156) upsert ::= ON CONFLICT DO NOTHING */
151206
- 256, /* (157) insert_cmd ::= INSERT orconf */
151207
- 256, /* (158) insert_cmd ::= REPLACE */
151208
- 257, /* (159) idlist_opt ::= */
151209
- 257, /* (160) idlist_opt ::= LP idlist RP */
151210
- 253, /* (161) idlist ::= idlist COMMA nm */
151211
- 253, /* (162) idlist ::= nm */
151212
- 207, /* (163) expr ::= LP expr RP */
151213
- 207, /* (164) expr ::= ID|INDEXED */
151214
- 207, /* (165) expr ::= JOIN_KW */
151215
- 207, /* (166) expr ::= nm DOT nm */
151216
- 207, /* (167) expr ::= nm DOT nm DOT nm */
151217
- 206, /* (168) term ::= NULL|FLOAT|BLOB */
151218
- 206, /* (169) term ::= STRING */
151219
- 206, /* (170) term ::= INTEGER */
151220
- 207, /* (171) expr ::= VARIABLE */
151221
- 207, /* (172) expr ::= expr COLLATE ID|STRING */
151222
- 207, /* (173) expr ::= CAST LP expr AS typetoken RP */
151223
- 207, /* (174) expr ::= ID|INDEXED LP distinct exprlist RP */
151224
- 207, /* (175) expr ::= ID|INDEXED LP STAR RP */
151225
- 207, /* (176) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
151226
- 207, /* (177) expr ::= ID|INDEXED LP STAR RP over_clause */
151227
- 206, /* (178) term ::= CTIME_KW */
151228
- 207, /* (179) expr ::= LP nexprlist COMMA expr RP */
151229
- 207, /* (180) expr ::= expr AND expr */
151230
- 207, /* (181) expr ::= expr OR expr */
151231
- 207, /* (182) expr ::= expr LT|GT|GE|LE expr */
151232
- 207, /* (183) expr ::= expr EQ|NE expr */
151233
- 207, /* (184) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
151234
- 207, /* (185) expr ::= expr PLUS|MINUS expr */
151235
- 207, /* (186) expr ::= expr STAR|SLASH|REM expr */
151236
- 207, /* (187) expr ::= expr CONCAT expr */
151237
- 260, /* (188) likeop ::= NOT LIKE_KW|MATCH */
151238
- 207, /* (189) expr ::= expr likeop expr */
151239
- 207, /* (190) expr ::= expr likeop expr ESCAPE expr */
151240
- 207, /* (191) expr ::= expr ISNULL|NOTNULL */
151241
- 207, /* (192) expr ::= expr NOT NULL */
151242
- 207, /* (193) expr ::= expr IS expr */
151243
- 207, /* (194) expr ::= expr IS NOT expr */
151244
- 207, /* (195) expr ::= NOT expr */
151245
- 207, /* (196) expr ::= BITNOT expr */
151246
- 207, /* (197) expr ::= PLUS|MINUS expr */
151247
- 261, /* (198) between_op ::= BETWEEN */
151248
- 261, /* (199) between_op ::= NOT BETWEEN */
151249
- 207, /* (200) expr ::= expr between_op expr AND expr */
151250
- 262, /* (201) in_op ::= IN */
151251
- 262, /* (202) in_op ::= NOT IN */
151252
- 207, /* (203) expr ::= expr in_op LP exprlist RP */
151253
- 207, /* (204) expr ::= LP select RP */
151254
- 207, /* (205) expr ::= expr in_op LP select RP */
151255
- 207, /* (206) expr ::= expr in_op nm dbnm paren_exprlist */
151256
- 207, /* (207) expr ::= EXISTS LP select RP */
151257
- 207, /* (208) expr ::= CASE case_operand case_exprlist case_else END */
151258
- 265, /* (209) case_exprlist ::= case_exprlist WHEN expr THEN expr */
151259
- 265, /* (210) case_exprlist ::= WHEN expr THEN expr */
151260
- 266, /* (211) case_else ::= ELSE expr */
151261
- 266, /* (212) case_else ::= */
151262
- 264, /* (213) case_operand ::= expr */
151263
- 264, /* (214) case_operand ::= */
151264
- 251, /* (215) exprlist ::= */
151265
- 242, /* (216) nexprlist ::= nexprlist COMMA expr */
151266
- 242, /* (217) nexprlist ::= expr */
151267
- 263, /* (218) paren_exprlist ::= */
151268
- 263, /* (219) paren_exprlist ::= LP exprlist RP */
151269
- 181, /* (220) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
151270
- 267, /* (221) uniqueflag ::= UNIQUE */
151271
- 267, /* (222) uniqueflag ::= */
151272
- 211, /* (223) eidlist_opt ::= */
151273
- 211, /* (224) eidlist_opt ::= LP eidlist RP */
151274
- 221, /* (225) eidlist ::= eidlist COMMA nm collate sortorder */
151275
- 221, /* (226) eidlist ::= nm collate sortorder */
151276
- 268, /* (227) collate ::= */
151277
- 268, /* (228) collate ::= COLLATE ID|STRING */
151278
- 181, /* (229) cmd ::= DROP INDEX ifexists fullname */
151279
- 181, /* (230) cmd ::= VACUUM vinto */
151280
- 181, /* (231) cmd ::= VACUUM nm vinto */
151281
- 269, /* (232) vinto ::= INTO expr */
151282
- 269, /* (233) vinto ::= */
151283
- 181, /* (234) cmd ::= PRAGMA nm dbnm */
151284
- 181, /* (235) cmd ::= PRAGMA nm dbnm EQ nmnum */
151285
- 181, /* (236) cmd ::= PRAGMA nm dbnm LP nmnum RP */
151286
- 181, /* (237) cmd ::= PRAGMA nm dbnm EQ minus_num */
151287
- 181, /* (238) cmd ::= PRAGMA nm dbnm LP minus_num RP */
151288
- 201, /* (239) plus_num ::= PLUS INTEGER|FLOAT */
151289
- 202, /* (240) minus_num ::= MINUS INTEGER|FLOAT */
151290
- 181, /* (241) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
151291
- 271, /* (242) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
151292
- 273, /* (243) trigger_time ::= BEFORE|AFTER */
151293
- 273, /* (244) trigger_time ::= INSTEAD OF */
151294
- 273, /* (245) trigger_time ::= */
151295
- 274, /* (246) trigger_event ::= DELETE|INSERT */
151296
- 274, /* (247) trigger_event ::= UPDATE */
151297
- 274, /* (248) trigger_event ::= UPDATE OF idlist */
151298
- 276, /* (249) when_clause ::= */
151299
- 276, /* (250) when_clause ::= WHEN expr */
151300
- 272, /* (251) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
151301
- 272, /* (252) trigger_cmd_list ::= trigger_cmd SEMI */
151302
- 278, /* (253) trnm ::= nm DOT nm */
151303
- 279, /* (254) tridxby ::= INDEXED BY nm */
151304
- 279, /* (255) tridxby ::= NOT INDEXED */
151305
- 277, /* (256) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
151306
- 277, /* (257) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
151307
- 277, /* (258) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
151308
- 277, /* (259) trigger_cmd ::= scanpt select scanpt */
151309
- 207, /* (260) expr ::= RAISE LP IGNORE RP */
151310
- 207, /* (261) expr ::= RAISE LP raisetype COMMA nm RP */
151311
- 225, /* (262) raisetype ::= ROLLBACK */
151312
- 225, /* (263) raisetype ::= ABORT */
151313
- 225, /* (264) raisetype ::= FAIL */
151314
- 181, /* (265) cmd ::= DROP TRIGGER ifexists fullname */
151315
- 181, /* (266) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
151316
- 181, /* (267) cmd ::= DETACH database_kw_opt expr */
151317
- 281, /* (268) key_opt ::= */
151318
- 281, /* (269) key_opt ::= KEY expr */
151319
- 181, /* (270) cmd ::= REINDEX */
151320
- 181, /* (271) cmd ::= REINDEX nm dbnm */
151321
- 181, /* (272) cmd ::= ANALYZE */
151322
- 181, /* (273) cmd ::= ANALYZE nm dbnm */
151323
- 181, /* (274) cmd ::= ALTER TABLE fullname RENAME TO nm */
151324
- 181, /* (275) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
151325
- 282, /* (276) add_column_fullname ::= fullname */
151326
- 181, /* (277) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
151327
- 181, /* (278) cmd ::= create_vtab */
151328
- 181, /* (279) cmd ::= create_vtab LP vtabarglist RP */
151329
- 284, /* (280) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
151330
- 286, /* (281) vtabarg ::= */
151331
- 287, /* (282) vtabargtoken ::= ANY */
151332
- 287, /* (283) vtabargtoken ::= lp anylist RP */
151333
- 288, /* (284) lp ::= LP */
151334
- 254, /* (285) with ::= WITH wqlist */
151335
- 254, /* (286) with ::= WITH RECURSIVE wqlist */
151336
- 230, /* (287) wqlist ::= nm eidlist_opt AS LP select RP */
151337
- 230, /* (288) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
151338
- 290, /* (289) windowdefn_list ::= windowdefn */
151339
- 290, /* (290) windowdefn_list ::= windowdefn_list COMMA windowdefn */
151340
- 291, /* (291) windowdefn ::= nm AS LP window RP */
151341
- 292, /* (292) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
151342
- 292, /* (293) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
151343
- 292, /* (294) window ::= ORDER BY sortlist frame_opt */
151344
- 292, /* (295) window ::= nm ORDER BY sortlist frame_opt */
151345
- 292, /* (296) window ::= frame_opt */
151346
- 292, /* (297) window ::= nm frame_opt */
151347
- 293, /* (298) frame_opt ::= */
151348
- 293, /* (299) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
151349
- 293, /* (300) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
151350
- 296, /* (301) range_or_rows ::= RANGE|ROWS|GROUPS */
151351
- 298, /* (302) frame_bound_s ::= frame_bound */
151352
- 298, /* (303) frame_bound_s ::= UNBOUNDED PRECEDING */
151353
- 299, /* (304) frame_bound_e ::= frame_bound */
151354
- 299, /* (305) frame_bound_e ::= UNBOUNDED FOLLOWING */
151355
- 297, /* (306) frame_bound ::= expr PRECEDING|FOLLOWING */
151356
- 297, /* (307) frame_bound ::= CURRENT ROW */
151357
- 300, /* (308) frame_exclude_opt ::= */
151358
- 300, /* (309) frame_exclude_opt ::= EXCLUDE frame_exclude */
151359
- 301, /* (310) frame_exclude ::= NO OTHERS */
151360
- 301, /* (311) frame_exclude ::= CURRENT ROW */
151361
- 301, /* (312) frame_exclude ::= GROUP|TIES */
151362
- 240, /* (313) window_clause ::= WINDOW windowdefn_list */
151363
- 259, /* (314) over_clause ::= filter_opt OVER LP window RP */
151364
- 259, /* (315) over_clause ::= filter_opt OVER nm */
151365
- 295, /* (316) filter_opt ::= */
151366
- 295, /* (317) filter_opt ::= FILTER LP WHERE expr RP */
151367
- 176, /* (318) input ::= cmdlist */
151368
- 177, /* (319) cmdlist ::= cmdlist ecmd */
151369
- 177, /* (320) cmdlist ::= ecmd */
151370
- 178, /* (321) ecmd ::= SEMI */
151371
- 178, /* (322) ecmd ::= cmdx SEMI */
151372
- 178, /* (323) ecmd ::= explain cmdx */
151373
- 183, /* (324) trans_opt ::= */
151374
- 183, /* (325) trans_opt ::= TRANSACTION */
151375
- 183, /* (326) trans_opt ::= TRANSACTION nm */
151376
- 185, /* (327) savepoint_opt ::= SAVEPOINT */
151377
- 185, /* (328) savepoint_opt ::= */
151378
- 181, /* (329) cmd ::= create_table create_table_args */
151379
- 192, /* (330) columnlist ::= columnlist COMMA columnname carglist */
151380
- 192, /* (331) columnlist ::= columnname carglist */
151381
- 184, /* (332) nm ::= ID|INDEXED */
151382
- 184, /* (333) nm ::= STRING */
151383
- 184, /* (334) nm ::= JOIN_KW */
151384
- 198, /* (335) typetoken ::= typename */
151385
- 199, /* (336) typename ::= ID|STRING */
151386
- 200, /* (337) signed ::= plus_num */
151387
- 200, /* (338) signed ::= minus_num */
151388
- 197, /* (339) carglist ::= carglist ccons */
151389
- 197, /* (340) carglist ::= */
151390
- 205, /* (341) ccons ::= NULL onconf */
151391
- 193, /* (342) conslist_opt ::= COMMA conslist */
151392
- 217, /* (343) conslist ::= conslist tconscomma tcons */
151393
- 217, /* (344) conslist ::= tcons */
151394
- 218, /* (345) tconscomma ::= */
151395
- 222, /* (346) defer_subclause_opt ::= defer_subclause */
151396
- 224, /* (347) resolvetype ::= raisetype */
151397
- 228, /* (348) selectnowith ::= oneselect */
151398
- 229, /* (349) oneselect ::= values */
151399
- 243, /* (350) sclp ::= selcollist COMMA */
151400
- 244, /* (351) as ::= ID|STRING */
151401
- 207, /* (352) expr ::= term */
151402
- 260, /* (353) likeop ::= LIKE_KW|MATCH */
151403
- 251, /* (354) exprlist ::= nexprlist */
151404
- 270, /* (355) nmnum ::= plus_num */
151405
- 270, /* (356) nmnum ::= nm */
151406
- 270, /* (357) nmnum ::= ON */
151407
- 270, /* (358) nmnum ::= DELETE */
151408
- 270, /* (359) nmnum ::= DEFAULT */
151409
- 201, /* (360) plus_num ::= INTEGER|FLOAT */
151410
- 275, /* (361) foreach_clause ::= */
151411
- 275, /* (362) foreach_clause ::= FOR EACH ROW */
151412
- 278, /* (363) trnm ::= nm */
151413
- 279, /* (364) tridxby ::= */
151414
- 280, /* (365) database_kw_opt ::= DATABASE */
151415
- 280, /* (366) database_kw_opt ::= */
151416
- 283, /* (367) kwcolumn_opt ::= */
151417
- 283, /* (368) kwcolumn_opt ::= COLUMNKW */
151418
- 285, /* (369) vtabarglist ::= vtabarg */
151419
- 285, /* (370) vtabarglist ::= vtabarglist COMMA vtabarg */
151420
- 286, /* (371) vtabarg ::= vtabarg vtabargtoken */
151421
- 289, /* (372) anylist ::= */
151422
- 289, /* (373) anylist ::= anylist LP anylist RP */
151423
- 289, /* (374) anylist ::= anylist ANY */
151424
- 254, /* (375) with ::= */
151860
+ 183, /* (0) explain ::= EXPLAIN */
151861
+ 183, /* (1) explain ::= EXPLAIN QUERY PLAN */
151862
+ 182, /* (2) cmdx ::= cmd */
151863
+ 184, /* (3) cmd ::= BEGIN transtype trans_opt */
151864
+ 185, /* (4) transtype ::= */
151865
+ 185, /* (5) transtype ::= DEFERRED */
151866
+ 185, /* (6) transtype ::= IMMEDIATE */
151867
+ 185, /* (7) transtype ::= EXCLUSIVE */
151868
+ 184, /* (8) cmd ::= COMMIT|END trans_opt */
151869
+ 184, /* (9) cmd ::= ROLLBACK trans_opt */
151870
+ 184, /* (10) cmd ::= SAVEPOINT nm */
151871
+ 184, /* (11) cmd ::= RELEASE savepoint_opt nm */
151872
+ 184, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
151873
+ 189, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
151874
+ 191, /* (14) createkw ::= CREATE */
151875
+ 193, /* (15) ifnotexists ::= */
151876
+ 193, /* (16) ifnotexists ::= IF NOT EXISTS */
151877
+ 192, /* (17) temp ::= TEMP */
151878
+ 192, /* (18) temp ::= */
151879
+ 190, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
151880
+ 190, /* (20) create_table_args ::= AS select */
151881
+ 197, /* (21) table_options ::= */
151882
+ 197, /* (22) table_options ::= WITHOUT nm */
151883
+ 199, /* (23) columnname ::= nm typetoken */
151884
+ 201, /* (24) typetoken ::= */
151885
+ 201, /* (25) typetoken ::= typename LP signed RP */
151886
+ 201, /* (26) typetoken ::= typename LP signed COMMA signed RP */
151887
+ 202, /* (27) typename ::= typename ID|STRING */
151888
+ 206, /* (28) scanpt ::= */
151889
+ 207, /* (29) scantok ::= */
151890
+ 208, /* (30) ccons ::= CONSTRAINT nm */
151891
+ 208, /* (31) ccons ::= DEFAULT scantok term */
151892
+ 208, /* (32) ccons ::= DEFAULT LP expr RP */
151893
+ 208, /* (33) ccons ::= DEFAULT PLUS scantok term */
151894
+ 208, /* (34) ccons ::= DEFAULT MINUS scantok term */
151895
+ 208, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
151896
+ 208, /* (36) ccons ::= NOT NULL onconf */
151897
+ 208, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
151898
+ 208, /* (38) ccons ::= UNIQUE onconf */
151899
+ 208, /* (39) ccons ::= CHECK LP expr RP */
151900
+ 208, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
151901
+ 208, /* (41) ccons ::= defer_subclause */
151902
+ 208, /* (42) ccons ::= COLLATE ID|STRING */
151903
+ 213, /* (43) autoinc ::= */
151904
+ 213, /* (44) autoinc ::= AUTOINCR */
151905
+ 215, /* (45) refargs ::= */
151906
+ 215, /* (46) refargs ::= refargs refarg */
151907
+ 217, /* (47) refarg ::= MATCH nm */
151908
+ 217, /* (48) refarg ::= ON INSERT refact */
151909
+ 217, /* (49) refarg ::= ON DELETE refact */
151910
+ 217, /* (50) refarg ::= ON UPDATE refact */
151911
+ 218, /* (51) refact ::= SET NULL */
151912
+ 218, /* (52) refact ::= SET DEFAULT */
151913
+ 218, /* (53) refact ::= CASCADE */
151914
+ 218, /* (54) refact ::= RESTRICT */
151915
+ 218, /* (55) refact ::= NO ACTION */
151916
+ 216, /* (56) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
151917
+ 216, /* (57) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
151918
+ 219, /* (58) init_deferred_pred_opt ::= */
151919
+ 219, /* (59) init_deferred_pred_opt ::= INITIALLY DEFERRED */
151920
+ 219, /* (60) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
151921
+ 196, /* (61) conslist_opt ::= */
151922
+ 221, /* (62) tconscomma ::= COMMA */
151923
+ 222, /* (63) tcons ::= CONSTRAINT nm */
151924
+ 222, /* (64) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
151925
+ 222, /* (65) tcons ::= UNIQUE LP sortlist RP onconf */
151926
+ 222, /* (66) tcons ::= CHECK LP expr RP onconf */
151927
+ 222, /* (67) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
151928
+ 225, /* (68) defer_subclause_opt ::= */
151929
+ 211, /* (69) onconf ::= */
151930
+ 211, /* (70) onconf ::= ON CONFLICT resolvetype */
151931
+ 226, /* (71) orconf ::= */
151932
+ 226, /* (72) orconf ::= OR resolvetype */
151933
+ 227, /* (73) resolvetype ::= IGNORE */
151934
+ 227, /* (74) resolvetype ::= REPLACE */
151935
+ 184, /* (75) cmd ::= DROP TABLE ifexists fullname */
151936
+ 229, /* (76) ifexists ::= IF EXISTS */
151937
+ 229, /* (77) ifexists ::= */
151938
+ 184, /* (78) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
151939
+ 184, /* (79) cmd ::= DROP VIEW ifexists fullname */
151940
+ 184, /* (80) cmd ::= select */
151941
+ 198, /* (81) select ::= WITH wqlist selectnowith */
151942
+ 198, /* (82) select ::= WITH RECURSIVE wqlist selectnowith */
151943
+ 198, /* (83) select ::= selectnowith */
151944
+ 231, /* (84) selectnowith ::= selectnowith multiselect_op oneselect */
151945
+ 234, /* (85) multiselect_op ::= UNION */
151946
+ 234, /* (86) multiselect_op ::= UNION ALL */
151947
+ 234, /* (87) multiselect_op ::= EXCEPT|INTERSECT */
151948
+ 232, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
151949
+ 232, /* (89) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
151950
+ 244, /* (90) values ::= VALUES LP nexprlist RP */
151951
+ 244, /* (91) values ::= values COMMA LP nexprlist RP */
151952
+ 235, /* (92) distinct ::= DISTINCT */
151953
+ 235, /* (93) distinct ::= ALL */
151954
+ 235, /* (94) distinct ::= */
151955
+ 246, /* (95) sclp ::= */
151956
+ 236, /* (96) selcollist ::= sclp scanpt expr scanpt as */
151957
+ 236, /* (97) selcollist ::= sclp scanpt STAR */
151958
+ 236, /* (98) selcollist ::= sclp scanpt nm DOT STAR */
151959
+ 247, /* (99) as ::= AS nm */
151960
+ 247, /* (100) as ::= */
151961
+ 237, /* (101) from ::= */
151962
+ 237, /* (102) from ::= FROM seltablist */
151963
+ 249, /* (103) stl_prefix ::= seltablist joinop */
151964
+ 249, /* (104) stl_prefix ::= */
151965
+ 248, /* (105) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
151966
+ 248, /* (106) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
151967
+ 248, /* (107) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
151968
+ 248, /* (108) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
151969
+ 194, /* (109) dbnm ::= */
151970
+ 194, /* (110) dbnm ::= DOT nm */
151971
+ 230, /* (111) fullname ::= nm */
151972
+ 230, /* (112) fullname ::= nm DOT nm */
151973
+ 255, /* (113) xfullname ::= nm */
151974
+ 255, /* (114) xfullname ::= nm DOT nm */
151975
+ 255, /* (115) xfullname ::= nm DOT nm AS nm */
151976
+ 255, /* (116) xfullname ::= nm AS nm */
151977
+ 250, /* (117) joinop ::= COMMA|JOIN */
151978
+ 250, /* (118) joinop ::= JOIN_KW JOIN */
151979
+ 250, /* (119) joinop ::= JOIN_KW nm JOIN */
151980
+ 250, /* (120) joinop ::= JOIN_KW nm nm JOIN */
151981
+ 252, /* (121) on_opt ::= ON expr */
151982
+ 252, /* (122) on_opt ::= */
151983
+ 251, /* (123) indexed_opt ::= */
151984
+ 251, /* (124) indexed_opt ::= INDEXED BY nm */
151985
+ 251, /* (125) indexed_opt ::= NOT INDEXED */
151986
+ 253, /* (126) using_opt ::= USING LP idlist RP */
151987
+ 253, /* (127) using_opt ::= */
151988
+ 241, /* (128) orderby_opt ::= */
151989
+ 241, /* (129) orderby_opt ::= ORDER BY sortlist */
151990
+ 223, /* (130) sortlist ::= sortlist COMMA expr sortorder nulls */
151991
+ 223, /* (131) sortlist ::= expr sortorder nulls */
151992
+ 212, /* (132) sortorder ::= ASC */
151993
+ 212, /* (133) sortorder ::= DESC */
151994
+ 212, /* (134) sortorder ::= */
151995
+ 257, /* (135) nulls ::= NULLS FIRST */
151996
+ 257, /* (136) nulls ::= NULLS LAST */
151997
+ 257, /* (137) nulls ::= */
151998
+ 239, /* (138) groupby_opt ::= */
151999
+ 239, /* (139) groupby_opt ::= GROUP BY nexprlist */
152000
+ 240, /* (140) having_opt ::= */
152001
+ 240, /* (141) having_opt ::= HAVING expr */
152002
+ 242, /* (142) limit_opt ::= */
152003
+ 242, /* (143) limit_opt ::= LIMIT expr */
152004
+ 242, /* (144) limit_opt ::= LIMIT expr OFFSET expr */
152005
+ 242, /* (145) limit_opt ::= LIMIT expr COMMA expr */
152006
+ 184, /* (146) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
152007
+ 238, /* (147) where_opt ::= */
152008
+ 238, /* (148) where_opt ::= WHERE expr */
152009
+ 184, /* (149) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
152010
+ 259, /* (150) setlist ::= setlist COMMA nm EQ expr */
152011
+ 259, /* (151) setlist ::= setlist COMMA LP idlist RP EQ expr */
152012
+ 259, /* (152) setlist ::= nm EQ expr */
152013
+ 259, /* (153) setlist ::= LP idlist RP EQ expr */
152014
+ 184, /* (154) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
152015
+ 184, /* (155) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
152016
+ 262, /* (156) upsert ::= */
152017
+ 262, /* (157) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
152018
+ 262, /* (158) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
152019
+ 262, /* (159) upsert ::= ON CONFLICT DO NOTHING */
152020
+ 260, /* (160) insert_cmd ::= INSERT orconf */
152021
+ 260, /* (161) insert_cmd ::= REPLACE */
152022
+ 261, /* (162) idlist_opt ::= */
152023
+ 261, /* (163) idlist_opt ::= LP idlist RP */
152024
+ 256, /* (164) idlist ::= idlist COMMA nm */
152025
+ 256, /* (165) idlist ::= nm */
152026
+ 210, /* (166) expr ::= LP expr RP */
152027
+ 210, /* (167) expr ::= ID|INDEXED */
152028
+ 210, /* (168) expr ::= JOIN_KW */
152029
+ 210, /* (169) expr ::= nm DOT nm */
152030
+ 210, /* (170) expr ::= nm DOT nm DOT nm */
152031
+ 209, /* (171) term ::= NULL|FLOAT|BLOB */
152032
+ 209, /* (172) term ::= STRING */
152033
+ 209, /* (173) term ::= INTEGER */
152034
+ 210, /* (174) expr ::= VARIABLE */
152035
+ 210, /* (175) expr ::= expr COLLATE ID|STRING */
152036
+ 210, /* (176) expr ::= CAST LP expr AS typetoken RP */
152037
+ 210, /* (177) expr ::= ID|INDEXED LP distinct exprlist RP */
152038
+ 210, /* (178) expr ::= ID|INDEXED LP STAR RP */
152039
+ 210, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
152040
+ 210, /* (180) expr ::= ID|INDEXED LP STAR RP filter_over */
152041
+ 209, /* (181) term ::= CTIME_KW */
152042
+ 210, /* (182) expr ::= LP nexprlist COMMA expr RP */
152043
+ 210, /* (183) expr ::= expr AND expr */
152044
+ 210, /* (184) expr ::= expr OR expr */
152045
+ 210, /* (185) expr ::= expr LT|GT|GE|LE expr */
152046
+ 210, /* (186) expr ::= expr EQ|NE expr */
152047
+ 210, /* (187) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
152048
+ 210, /* (188) expr ::= expr PLUS|MINUS expr */
152049
+ 210, /* (189) expr ::= expr STAR|SLASH|REM expr */
152050
+ 210, /* (190) expr ::= expr CONCAT expr */
152051
+ 264, /* (191) likeop ::= NOT LIKE_KW|MATCH */
152052
+ 210, /* (192) expr ::= expr likeop expr */
152053
+ 210, /* (193) expr ::= expr likeop expr ESCAPE expr */
152054
+ 210, /* (194) expr ::= expr ISNULL|NOTNULL */
152055
+ 210, /* (195) expr ::= expr NOT NULL */
152056
+ 210, /* (196) expr ::= expr IS expr */
152057
+ 210, /* (197) expr ::= expr IS NOT expr */
152058
+ 210, /* (198) expr ::= NOT expr */
152059
+ 210, /* (199) expr ::= BITNOT expr */
152060
+ 210, /* (200) expr ::= PLUS|MINUS expr */
152061
+ 265, /* (201) between_op ::= BETWEEN */
152062
+ 265, /* (202) between_op ::= NOT BETWEEN */
152063
+ 210, /* (203) expr ::= expr between_op expr AND expr */
152064
+ 266, /* (204) in_op ::= IN */
152065
+ 266, /* (205) in_op ::= NOT IN */
152066
+ 210, /* (206) expr ::= expr in_op LP exprlist RP */
152067
+ 210, /* (207) expr ::= LP select RP */
152068
+ 210, /* (208) expr ::= expr in_op LP select RP */
152069
+ 210, /* (209) expr ::= expr in_op nm dbnm paren_exprlist */
152070
+ 210, /* (210) expr ::= EXISTS LP select RP */
152071
+ 210, /* (211) expr ::= CASE case_operand case_exprlist case_else END */
152072
+ 269, /* (212) case_exprlist ::= case_exprlist WHEN expr THEN expr */
152073
+ 269, /* (213) case_exprlist ::= WHEN expr THEN expr */
152074
+ 270, /* (214) case_else ::= ELSE expr */
152075
+ 270, /* (215) case_else ::= */
152076
+ 268, /* (216) case_operand ::= expr */
152077
+ 268, /* (217) case_operand ::= */
152078
+ 254, /* (218) exprlist ::= */
152079
+ 245, /* (219) nexprlist ::= nexprlist COMMA expr */
152080
+ 245, /* (220) nexprlist ::= expr */
152081
+ 267, /* (221) paren_exprlist ::= */
152082
+ 267, /* (222) paren_exprlist ::= LP exprlist RP */
152083
+ 184, /* (223) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
152084
+ 271, /* (224) uniqueflag ::= UNIQUE */
152085
+ 271, /* (225) uniqueflag ::= */
152086
+ 214, /* (226) eidlist_opt ::= */
152087
+ 214, /* (227) eidlist_opt ::= LP eidlist RP */
152088
+ 224, /* (228) eidlist ::= eidlist COMMA nm collate sortorder */
152089
+ 224, /* (229) eidlist ::= nm collate sortorder */
152090
+ 272, /* (230) collate ::= */
152091
+ 272, /* (231) collate ::= COLLATE ID|STRING */
152092
+ 184, /* (232) cmd ::= DROP INDEX ifexists fullname */
152093
+ 184, /* (233) cmd ::= VACUUM vinto */
152094
+ 184, /* (234) cmd ::= VACUUM nm vinto */
152095
+ 273, /* (235) vinto ::= INTO expr */
152096
+ 273, /* (236) vinto ::= */
152097
+ 184, /* (237) cmd ::= PRAGMA nm dbnm */
152098
+ 184, /* (238) cmd ::= PRAGMA nm dbnm EQ nmnum */
152099
+ 184, /* (239) cmd ::= PRAGMA nm dbnm LP nmnum RP */
152100
+ 184, /* (240) cmd ::= PRAGMA nm dbnm EQ minus_num */
152101
+ 184, /* (241) cmd ::= PRAGMA nm dbnm LP minus_num RP */
152102
+ 204, /* (242) plus_num ::= PLUS INTEGER|FLOAT */
152103
+ 205, /* (243) minus_num ::= MINUS INTEGER|FLOAT */
152104
+ 184, /* (244) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
152105
+ 275, /* (245) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
152106
+ 277, /* (246) trigger_time ::= BEFORE|AFTER */
152107
+ 277, /* (247) trigger_time ::= INSTEAD OF */
152108
+ 277, /* (248) trigger_time ::= */
152109
+ 278, /* (249) trigger_event ::= DELETE|INSERT */
152110
+ 278, /* (250) trigger_event ::= UPDATE */
152111
+ 278, /* (251) trigger_event ::= UPDATE OF idlist */
152112
+ 280, /* (252) when_clause ::= */
152113
+ 280, /* (253) when_clause ::= WHEN expr */
152114
+ 276, /* (254) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
152115
+ 276, /* (255) trigger_cmd_list ::= trigger_cmd SEMI */
152116
+ 282, /* (256) trnm ::= nm DOT nm */
152117
+ 283, /* (257) tridxby ::= INDEXED BY nm */
152118
+ 283, /* (258) tridxby ::= NOT INDEXED */
152119
+ 281, /* (259) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
152120
+ 281, /* (260) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
152121
+ 281, /* (261) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
152122
+ 281, /* (262) trigger_cmd ::= scanpt select scanpt */
152123
+ 210, /* (263) expr ::= RAISE LP IGNORE RP */
152124
+ 210, /* (264) expr ::= RAISE LP raisetype COMMA nm RP */
152125
+ 228, /* (265) raisetype ::= ROLLBACK */
152126
+ 228, /* (266) raisetype ::= ABORT */
152127
+ 228, /* (267) raisetype ::= FAIL */
152128
+ 184, /* (268) cmd ::= DROP TRIGGER ifexists fullname */
152129
+ 184, /* (269) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
152130
+ 184, /* (270) cmd ::= DETACH database_kw_opt expr */
152131
+ 285, /* (271) key_opt ::= */
152132
+ 285, /* (272) key_opt ::= KEY expr */
152133
+ 184, /* (273) cmd ::= REINDEX */
152134
+ 184, /* (274) cmd ::= REINDEX nm dbnm */
152135
+ 184, /* (275) cmd ::= ANALYZE */
152136
+ 184, /* (276) cmd ::= ANALYZE nm dbnm */
152137
+ 184, /* (277) cmd ::= ALTER TABLE fullname RENAME TO nm */
152138
+ 184, /* (278) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
152139
+ 286, /* (279) add_column_fullname ::= fullname */
152140
+ 184, /* (280) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
152141
+ 184, /* (281) cmd ::= create_vtab */
152142
+ 184, /* (282) cmd ::= create_vtab LP vtabarglist RP */
152143
+ 288, /* (283) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
152144
+ 290, /* (284) vtabarg ::= */
152145
+ 291, /* (285) vtabargtoken ::= ANY */
152146
+ 291, /* (286) vtabargtoken ::= lp anylist RP */
152147
+ 292, /* (287) lp ::= LP */
152148
+ 258, /* (288) with ::= WITH wqlist */
152149
+ 258, /* (289) with ::= WITH RECURSIVE wqlist */
152150
+ 233, /* (290) wqlist ::= nm eidlist_opt AS LP select RP */
152151
+ 233, /* (291) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
152152
+ 294, /* (292) windowdefn_list ::= windowdefn */
152153
+ 294, /* (293) windowdefn_list ::= windowdefn_list COMMA windowdefn */
152154
+ 295, /* (294) windowdefn ::= nm AS LP window RP */
152155
+ 296, /* (295) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
152156
+ 296, /* (296) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
152157
+ 296, /* (297) window ::= ORDER BY sortlist frame_opt */
152158
+ 296, /* (298) window ::= nm ORDER BY sortlist frame_opt */
152159
+ 296, /* (299) window ::= frame_opt */
152160
+ 296, /* (300) window ::= nm frame_opt */
152161
+ 297, /* (301) frame_opt ::= */
152162
+ 297, /* (302) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
152163
+ 297, /* (303) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
152164
+ 301, /* (304) range_or_rows ::= RANGE|ROWS|GROUPS */
152165
+ 303, /* (305) frame_bound_s ::= frame_bound */
152166
+ 303, /* (306) frame_bound_s ::= UNBOUNDED PRECEDING */
152167
+ 304, /* (307) frame_bound_e ::= frame_bound */
152168
+ 304, /* (308) frame_bound_e ::= UNBOUNDED FOLLOWING */
152169
+ 302, /* (309) frame_bound ::= expr PRECEDING|FOLLOWING */
152170
+ 302, /* (310) frame_bound ::= CURRENT ROW */
152171
+ 305, /* (311) frame_exclude_opt ::= */
152172
+ 305, /* (312) frame_exclude_opt ::= EXCLUDE frame_exclude */
152173
+ 306, /* (313) frame_exclude ::= NO OTHERS */
152174
+ 306, /* (314) frame_exclude ::= CURRENT ROW */
152175
+ 306, /* (315) frame_exclude ::= GROUP|TIES */
152176
+ 243, /* (316) window_clause ::= WINDOW windowdefn_list */
152177
+ 263, /* (317) filter_over ::= filter_clause over_clause */
152178
+ 263, /* (318) filter_over ::= over_clause */
152179
+ 263, /* (319) filter_over ::= filter_clause */
152180
+ 300, /* (320) over_clause ::= OVER LP window RP */
152181
+ 300, /* (321) over_clause ::= OVER nm */
152182
+ 299, /* (322) filter_clause ::= FILTER LP WHERE expr RP */
152183
+ 179, /* (323) input ::= cmdlist */
152184
+ 180, /* (324) cmdlist ::= cmdlist ecmd */
152185
+ 180, /* (325) cmdlist ::= ecmd */
152186
+ 181, /* (326) ecmd ::= SEMI */
152187
+ 181, /* (327) ecmd ::= cmdx SEMI */
152188
+ 181, /* (328) ecmd ::= explain cmdx */
152189
+ 186, /* (329) trans_opt ::= */
152190
+ 186, /* (330) trans_opt ::= TRANSACTION */
152191
+ 186, /* (331) trans_opt ::= TRANSACTION nm */
152192
+ 188, /* (332) savepoint_opt ::= SAVEPOINT */
152193
+ 188, /* (333) savepoint_opt ::= */
152194
+ 184, /* (334) cmd ::= create_table create_table_args */
152195
+ 195, /* (335) columnlist ::= columnlist COMMA columnname carglist */
152196
+ 195, /* (336) columnlist ::= columnname carglist */
152197
+ 187, /* (337) nm ::= ID|INDEXED */
152198
+ 187, /* (338) nm ::= STRING */
152199
+ 187, /* (339) nm ::= JOIN_KW */
152200
+ 201, /* (340) typetoken ::= typename */
152201
+ 202, /* (341) typename ::= ID|STRING */
152202
+ 203, /* (342) signed ::= plus_num */
152203
+ 203, /* (343) signed ::= minus_num */
152204
+ 200, /* (344) carglist ::= carglist ccons */
152205
+ 200, /* (345) carglist ::= */
152206
+ 208, /* (346) ccons ::= NULL onconf */
152207
+ 196, /* (347) conslist_opt ::= COMMA conslist */
152208
+ 220, /* (348) conslist ::= conslist tconscomma tcons */
152209
+ 220, /* (349) conslist ::= tcons */
152210
+ 221, /* (350) tconscomma ::= */
152211
+ 225, /* (351) defer_subclause_opt ::= defer_subclause */
152212
+ 227, /* (352) resolvetype ::= raisetype */
152213
+ 231, /* (353) selectnowith ::= oneselect */
152214
+ 232, /* (354) oneselect ::= values */
152215
+ 246, /* (355) sclp ::= selcollist COMMA */
152216
+ 247, /* (356) as ::= ID|STRING */
152217
+ 210, /* (357) expr ::= term */
152218
+ 264, /* (358) likeop ::= LIKE_KW|MATCH */
152219
+ 254, /* (359) exprlist ::= nexprlist */
152220
+ 274, /* (360) nmnum ::= plus_num */
152221
+ 274, /* (361) nmnum ::= nm */
152222
+ 274, /* (362) nmnum ::= ON */
152223
+ 274, /* (363) nmnum ::= DELETE */
152224
+ 274, /* (364) nmnum ::= DEFAULT */
152225
+ 204, /* (365) plus_num ::= INTEGER|FLOAT */
152226
+ 279, /* (366) foreach_clause ::= */
152227
+ 279, /* (367) foreach_clause ::= FOR EACH ROW */
152228
+ 282, /* (368) trnm ::= nm */
152229
+ 283, /* (369) tridxby ::= */
152230
+ 284, /* (370) database_kw_opt ::= DATABASE */
152231
+ 284, /* (371) database_kw_opt ::= */
152232
+ 287, /* (372) kwcolumn_opt ::= */
152233
+ 287, /* (373) kwcolumn_opt ::= COLUMNKW */
152234
+ 289, /* (374) vtabarglist ::= vtabarg */
152235
+ 289, /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */
152236
+ 290, /* (376) vtabarg ::= vtabarg vtabargtoken */
152237
+ 293, /* (377) anylist ::= */
152238
+ 293, /* (378) anylist ::= anylist LP anylist RP */
152239
+ 293, /* (379) anylist ::= anylist ANY */
152240
+ 258, /* (380) with ::= */
151425152241
};
151426152242
151427152243
/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
151428152244
** of symbols on the right-hand side of that rule. */
151429152245
static const signed char yyRuleInfoNRhs[] = {
@@ -151555,256 +152371,261 @@
151555152371
-2, /* (125) indexed_opt ::= NOT INDEXED */
151556152372
-4, /* (126) using_opt ::= USING LP idlist RP */
151557152373
0, /* (127) using_opt ::= */
151558152374
0, /* (128) orderby_opt ::= */
151559152375
-3, /* (129) orderby_opt ::= ORDER BY sortlist */
151560
- -4, /* (130) sortlist ::= sortlist COMMA expr sortorder */
151561
- -2, /* (131) sortlist ::= expr sortorder */
152376
+ -5, /* (130) sortlist ::= sortlist COMMA expr sortorder nulls */
152377
+ -3, /* (131) sortlist ::= expr sortorder nulls */
151562152378
-1, /* (132) sortorder ::= ASC */
151563152379
-1, /* (133) sortorder ::= DESC */
151564152380
0, /* (134) sortorder ::= */
151565
- 0, /* (135) groupby_opt ::= */
151566
- -3, /* (136) groupby_opt ::= GROUP BY nexprlist */
151567
- 0, /* (137) having_opt ::= */
151568
- -2, /* (138) having_opt ::= HAVING expr */
151569
- 0, /* (139) limit_opt ::= */
151570
- -2, /* (140) limit_opt ::= LIMIT expr */
151571
- -4, /* (141) limit_opt ::= LIMIT expr OFFSET expr */
151572
- -4, /* (142) limit_opt ::= LIMIT expr COMMA expr */
151573
- -6, /* (143) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
151574
- 0, /* (144) where_opt ::= */
151575
- -2, /* (145) where_opt ::= WHERE expr */
151576
- -8, /* (146) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
151577
- -5, /* (147) setlist ::= setlist COMMA nm EQ expr */
151578
- -7, /* (148) setlist ::= setlist COMMA LP idlist RP EQ expr */
151579
- -3, /* (149) setlist ::= nm EQ expr */
151580
- -5, /* (150) setlist ::= LP idlist RP EQ expr */
151581
- -7, /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
151582
- -7, /* (152) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
151583
- 0, /* (153) upsert ::= */
151584
- -11, /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
151585
- -8, /* (155) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
151586
- -4, /* (156) upsert ::= ON CONFLICT DO NOTHING */
151587
- -2, /* (157) insert_cmd ::= INSERT orconf */
151588
- -1, /* (158) insert_cmd ::= REPLACE */
151589
- 0, /* (159) idlist_opt ::= */
151590
- -3, /* (160) idlist_opt ::= LP idlist RP */
151591
- -3, /* (161) idlist ::= idlist COMMA nm */
151592
- -1, /* (162) idlist ::= nm */
151593
- -3, /* (163) expr ::= LP expr RP */
151594
- -1, /* (164) expr ::= ID|INDEXED */
151595
- -1, /* (165) expr ::= JOIN_KW */
151596
- -3, /* (166) expr ::= nm DOT nm */
151597
- -5, /* (167) expr ::= nm DOT nm DOT nm */
151598
- -1, /* (168) term ::= NULL|FLOAT|BLOB */
151599
- -1, /* (169) term ::= STRING */
151600
- -1, /* (170) term ::= INTEGER */
151601
- -1, /* (171) expr ::= VARIABLE */
151602
- -3, /* (172) expr ::= expr COLLATE ID|STRING */
151603
- -6, /* (173) expr ::= CAST LP expr AS typetoken RP */
151604
- -5, /* (174) expr ::= ID|INDEXED LP distinct exprlist RP */
151605
- -4, /* (175) expr ::= ID|INDEXED LP STAR RP */
151606
- -6, /* (176) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
151607
- -5, /* (177) expr ::= ID|INDEXED LP STAR RP over_clause */
151608
- -1, /* (178) term ::= CTIME_KW */
151609
- -5, /* (179) expr ::= LP nexprlist COMMA expr RP */
151610
- -3, /* (180) expr ::= expr AND expr */
151611
- -3, /* (181) expr ::= expr OR expr */
151612
- -3, /* (182) expr ::= expr LT|GT|GE|LE expr */
151613
- -3, /* (183) expr ::= expr EQ|NE expr */
151614
- -3, /* (184) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
151615
- -3, /* (185) expr ::= expr PLUS|MINUS expr */
151616
- -3, /* (186) expr ::= expr STAR|SLASH|REM expr */
151617
- -3, /* (187) expr ::= expr CONCAT expr */
151618
- -2, /* (188) likeop ::= NOT LIKE_KW|MATCH */
151619
- -3, /* (189) expr ::= expr likeop expr */
151620
- -5, /* (190) expr ::= expr likeop expr ESCAPE expr */
151621
- -2, /* (191) expr ::= expr ISNULL|NOTNULL */
151622
- -3, /* (192) expr ::= expr NOT NULL */
151623
- -3, /* (193) expr ::= expr IS expr */
151624
- -4, /* (194) expr ::= expr IS NOT expr */
151625
- -2, /* (195) expr ::= NOT expr */
151626
- -2, /* (196) expr ::= BITNOT expr */
151627
- -2, /* (197) expr ::= PLUS|MINUS expr */
151628
- -1, /* (198) between_op ::= BETWEEN */
151629
- -2, /* (199) between_op ::= NOT BETWEEN */
151630
- -5, /* (200) expr ::= expr between_op expr AND expr */
151631
- -1, /* (201) in_op ::= IN */
151632
- -2, /* (202) in_op ::= NOT IN */
151633
- -5, /* (203) expr ::= expr in_op LP exprlist RP */
151634
- -3, /* (204) expr ::= LP select RP */
151635
- -5, /* (205) expr ::= expr in_op LP select RP */
151636
- -5, /* (206) expr ::= expr in_op nm dbnm paren_exprlist */
151637
- -4, /* (207) expr ::= EXISTS LP select RP */
151638
- -5, /* (208) expr ::= CASE case_operand case_exprlist case_else END */
151639
- -5, /* (209) case_exprlist ::= case_exprlist WHEN expr THEN expr */
151640
- -4, /* (210) case_exprlist ::= WHEN expr THEN expr */
151641
- -2, /* (211) case_else ::= ELSE expr */
151642
- 0, /* (212) case_else ::= */
151643
- -1, /* (213) case_operand ::= expr */
151644
- 0, /* (214) case_operand ::= */
151645
- 0, /* (215) exprlist ::= */
151646
- -3, /* (216) nexprlist ::= nexprlist COMMA expr */
151647
- -1, /* (217) nexprlist ::= expr */
151648
- 0, /* (218) paren_exprlist ::= */
151649
- -3, /* (219) paren_exprlist ::= LP exprlist RP */
151650
- -12, /* (220) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
151651
- -1, /* (221) uniqueflag ::= UNIQUE */
151652
- 0, /* (222) uniqueflag ::= */
151653
- 0, /* (223) eidlist_opt ::= */
151654
- -3, /* (224) eidlist_opt ::= LP eidlist RP */
151655
- -5, /* (225) eidlist ::= eidlist COMMA nm collate sortorder */
151656
- -3, /* (226) eidlist ::= nm collate sortorder */
151657
- 0, /* (227) collate ::= */
151658
- -2, /* (228) collate ::= COLLATE ID|STRING */
151659
- -4, /* (229) cmd ::= DROP INDEX ifexists fullname */
151660
- -2, /* (230) cmd ::= VACUUM vinto */
151661
- -3, /* (231) cmd ::= VACUUM nm vinto */
151662
- -2, /* (232) vinto ::= INTO expr */
151663
- 0, /* (233) vinto ::= */
151664
- -3, /* (234) cmd ::= PRAGMA nm dbnm */
151665
- -5, /* (235) cmd ::= PRAGMA nm dbnm EQ nmnum */
151666
- -6, /* (236) cmd ::= PRAGMA nm dbnm LP nmnum RP */
151667
- -5, /* (237) cmd ::= PRAGMA nm dbnm EQ minus_num */
151668
- -6, /* (238) cmd ::= PRAGMA nm dbnm LP minus_num RP */
151669
- -2, /* (239) plus_num ::= PLUS INTEGER|FLOAT */
151670
- -2, /* (240) minus_num ::= MINUS INTEGER|FLOAT */
151671
- -5, /* (241) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
151672
- -11, /* (242) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
151673
- -1, /* (243) trigger_time ::= BEFORE|AFTER */
151674
- -2, /* (244) trigger_time ::= INSTEAD OF */
151675
- 0, /* (245) trigger_time ::= */
151676
- -1, /* (246) trigger_event ::= DELETE|INSERT */
151677
- -1, /* (247) trigger_event ::= UPDATE */
151678
- -3, /* (248) trigger_event ::= UPDATE OF idlist */
151679
- 0, /* (249) when_clause ::= */
151680
- -2, /* (250) when_clause ::= WHEN expr */
151681
- -3, /* (251) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
151682
- -2, /* (252) trigger_cmd_list ::= trigger_cmd SEMI */
151683
- -3, /* (253) trnm ::= nm DOT nm */
151684
- -3, /* (254) tridxby ::= INDEXED BY nm */
151685
- -2, /* (255) tridxby ::= NOT INDEXED */
151686
- -8, /* (256) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
151687
- -8, /* (257) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
151688
- -6, /* (258) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
151689
- -3, /* (259) trigger_cmd ::= scanpt select scanpt */
151690
- -4, /* (260) expr ::= RAISE LP IGNORE RP */
151691
- -6, /* (261) expr ::= RAISE LP raisetype COMMA nm RP */
151692
- -1, /* (262) raisetype ::= ROLLBACK */
151693
- -1, /* (263) raisetype ::= ABORT */
151694
- -1, /* (264) raisetype ::= FAIL */
151695
- -4, /* (265) cmd ::= DROP TRIGGER ifexists fullname */
151696
- -6, /* (266) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
151697
- -3, /* (267) cmd ::= DETACH database_kw_opt expr */
151698
- 0, /* (268) key_opt ::= */
151699
- -2, /* (269) key_opt ::= KEY expr */
151700
- -1, /* (270) cmd ::= REINDEX */
151701
- -3, /* (271) cmd ::= REINDEX nm dbnm */
151702
- -1, /* (272) cmd ::= ANALYZE */
151703
- -3, /* (273) cmd ::= ANALYZE nm dbnm */
151704
- -6, /* (274) cmd ::= ALTER TABLE fullname RENAME TO nm */
151705
- -7, /* (275) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
151706
- -1, /* (276) add_column_fullname ::= fullname */
151707
- -8, /* (277) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
151708
- -1, /* (278) cmd ::= create_vtab */
151709
- -4, /* (279) cmd ::= create_vtab LP vtabarglist RP */
151710
- -8, /* (280) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
151711
- 0, /* (281) vtabarg ::= */
151712
- -1, /* (282) vtabargtoken ::= ANY */
151713
- -3, /* (283) vtabargtoken ::= lp anylist RP */
151714
- -1, /* (284) lp ::= LP */
151715
- -2, /* (285) with ::= WITH wqlist */
151716
- -3, /* (286) with ::= WITH RECURSIVE wqlist */
151717
- -6, /* (287) wqlist ::= nm eidlist_opt AS LP select RP */
151718
- -8, /* (288) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
151719
- -1, /* (289) windowdefn_list ::= windowdefn */
151720
- -3, /* (290) windowdefn_list ::= windowdefn_list COMMA windowdefn */
151721
- -5, /* (291) windowdefn ::= nm AS LP window RP */
151722
- -5, /* (292) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
151723
- -6, /* (293) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
151724
- -4, /* (294) window ::= ORDER BY sortlist frame_opt */
151725
- -5, /* (295) window ::= nm ORDER BY sortlist frame_opt */
151726
- -1, /* (296) window ::= frame_opt */
151727
- -2, /* (297) window ::= nm frame_opt */
151728
- 0, /* (298) frame_opt ::= */
151729
- -3, /* (299) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
151730
- -6, /* (300) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
151731
- -1, /* (301) range_or_rows ::= RANGE|ROWS|GROUPS */
151732
- -1, /* (302) frame_bound_s ::= frame_bound */
151733
- -2, /* (303) frame_bound_s ::= UNBOUNDED PRECEDING */
151734
- -1, /* (304) frame_bound_e ::= frame_bound */
151735
- -2, /* (305) frame_bound_e ::= UNBOUNDED FOLLOWING */
151736
- -2, /* (306) frame_bound ::= expr PRECEDING|FOLLOWING */
151737
- -2, /* (307) frame_bound ::= CURRENT ROW */
151738
- 0, /* (308) frame_exclude_opt ::= */
151739
- -2, /* (309) frame_exclude_opt ::= EXCLUDE frame_exclude */
151740
- -2, /* (310) frame_exclude ::= NO OTHERS */
151741
- -2, /* (311) frame_exclude ::= CURRENT ROW */
151742
- -1, /* (312) frame_exclude ::= GROUP|TIES */
151743
- -2, /* (313) window_clause ::= WINDOW windowdefn_list */
151744
- -5, /* (314) over_clause ::= filter_opt OVER LP window RP */
151745
- -3, /* (315) over_clause ::= filter_opt OVER nm */
151746
- 0, /* (316) filter_opt ::= */
151747
- -5, /* (317) filter_opt ::= FILTER LP WHERE expr RP */
151748
- -1, /* (318) input ::= cmdlist */
151749
- -2, /* (319) cmdlist ::= cmdlist ecmd */
151750
- -1, /* (320) cmdlist ::= ecmd */
151751
- -1, /* (321) ecmd ::= SEMI */
151752
- -2, /* (322) ecmd ::= cmdx SEMI */
151753
- -2, /* (323) ecmd ::= explain cmdx */
151754
- 0, /* (324) trans_opt ::= */
151755
- -1, /* (325) trans_opt ::= TRANSACTION */
151756
- -2, /* (326) trans_opt ::= TRANSACTION nm */
151757
- -1, /* (327) savepoint_opt ::= SAVEPOINT */
151758
- 0, /* (328) savepoint_opt ::= */
151759
- -2, /* (329) cmd ::= create_table create_table_args */
151760
- -4, /* (330) columnlist ::= columnlist COMMA columnname carglist */
151761
- -2, /* (331) columnlist ::= columnname carglist */
151762
- -1, /* (332) nm ::= ID|INDEXED */
151763
- -1, /* (333) nm ::= STRING */
151764
- -1, /* (334) nm ::= JOIN_KW */
151765
- -1, /* (335) typetoken ::= typename */
151766
- -1, /* (336) typename ::= ID|STRING */
151767
- -1, /* (337) signed ::= plus_num */
151768
- -1, /* (338) signed ::= minus_num */
151769
- -2, /* (339) carglist ::= carglist ccons */
151770
- 0, /* (340) carglist ::= */
151771
- -2, /* (341) ccons ::= NULL onconf */
151772
- -2, /* (342) conslist_opt ::= COMMA conslist */
151773
- -3, /* (343) conslist ::= conslist tconscomma tcons */
151774
- -1, /* (344) conslist ::= tcons */
151775
- 0, /* (345) tconscomma ::= */
151776
- -1, /* (346) defer_subclause_opt ::= defer_subclause */
151777
- -1, /* (347) resolvetype ::= raisetype */
151778
- -1, /* (348) selectnowith ::= oneselect */
151779
- -1, /* (349) oneselect ::= values */
151780
- -2, /* (350) sclp ::= selcollist COMMA */
151781
- -1, /* (351) as ::= ID|STRING */
151782
- -1, /* (352) expr ::= term */
151783
- -1, /* (353) likeop ::= LIKE_KW|MATCH */
151784
- -1, /* (354) exprlist ::= nexprlist */
151785
- -1, /* (355) nmnum ::= plus_num */
151786
- -1, /* (356) nmnum ::= nm */
151787
- -1, /* (357) nmnum ::= ON */
151788
- -1, /* (358) nmnum ::= DELETE */
151789
- -1, /* (359) nmnum ::= DEFAULT */
151790
- -1, /* (360) plus_num ::= INTEGER|FLOAT */
151791
- 0, /* (361) foreach_clause ::= */
151792
- -3, /* (362) foreach_clause ::= FOR EACH ROW */
151793
- -1, /* (363) trnm ::= nm */
151794
- 0, /* (364) tridxby ::= */
151795
- -1, /* (365) database_kw_opt ::= DATABASE */
151796
- 0, /* (366) database_kw_opt ::= */
151797
- 0, /* (367) kwcolumn_opt ::= */
151798
- -1, /* (368) kwcolumn_opt ::= COLUMNKW */
151799
- -1, /* (369) vtabarglist ::= vtabarg */
151800
- -3, /* (370) vtabarglist ::= vtabarglist COMMA vtabarg */
151801
- -2, /* (371) vtabarg ::= vtabarg vtabargtoken */
151802
- 0, /* (372) anylist ::= */
151803
- -4, /* (373) anylist ::= anylist LP anylist RP */
151804
- -2, /* (374) anylist ::= anylist ANY */
151805
- 0, /* (375) with ::= */
152381
+ -2, /* (135) nulls ::= NULLS FIRST */
152382
+ -2, /* (136) nulls ::= NULLS LAST */
152383
+ 0, /* (137) nulls ::= */
152384
+ 0, /* (138) groupby_opt ::= */
152385
+ -3, /* (139) groupby_opt ::= GROUP BY nexprlist */
152386
+ 0, /* (140) having_opt ::= */
152387
+ -2, /* (141) having_opt ::= HAVING expr */
152388
+ 0, /* (142) limit_opt ::= */
152389
+ -2, /* (143) limit_opt ::= LIMIT expr */
152390
+ -4, /* (144) limit_opt ::= LIMIT expr OFFSET expr */
152391
+ -4, /* (145) limit_opt ::= LIMIT expr COMMA expr */
152392
+ -6, /* (146) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
152393
+ 0, /* (147) where_opt ::= */
152394
+ -2, /* (148) where_opt ::= WHERE expr */
152395
+ -8, /* (149) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
152396
+ -5, /* (150) setlist ::= setlist COMMA nm EQ expr */
152397
+ -7, /* (151) setlist ::= setlist COMMA LP idlist RP EQ expr */
152398
+ -3, /* (152) setlist ::= nm EQ expr */
152399
+ -5, /* (153) setlist ::= LP idlist RP EQ expr */
152400
+ -7, /* (154) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
152401
+ -7, /* (155) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
152402
+ 0, /* (156) upsert ::= */
152403
+ -11, /* (157) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
152404
+ -8, /* (158) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
152405
+ -4, /* (159) upsert ::= ON CONFLICT DO NOTHING */
152406
+ -2, /* (160) insert_cmd ::= INSERT orconf */
152407
+ -1, /* (161) insert_cmd ::= REPLACE */
152408
+ 0, /* (162) idlist_opt ::= */
152409
+ -3, /* (163) idlist_opt ::= LP idlist RP */
152410
+ -3, /* (164) idlist ::= idlist COMMA nm */
152411
+ -1, /* (165) idlist ::= nm */
152412
+ -3, /* (166) expr ::= LP expr RP */
152413
+ -1, /* (167) expr ::= ID|INDEXED */
152414
+ -1, /* (168) expr ::= JOIN_KW */
152415
+ -3, /* (169) expr ::= nm DOT nm */
152416
+ -5, /* (170) expr ::= nm DOT nm DOT nm */
152417
+ -1, /* (171) term ::= NULL|FLOAT|BLOB */
152418
+ -1, /* (172) term ::= STRING */
152419
+ -1, /* (173) term ::= INTEGER */
152420
+ -1, /* (174) expr ::= VARIABLE */
152421
+ -3, /* (175) expr ::= expr COLLATE ID|STRING */
152422
+ -6, /* (176) expr ::= CAST LP expr AS typetoken RP */
152423
+ -5, /* (177) expr ::= ID|INDEXED LP distinct exprlist RP */
152424
+ -4, /* (178) expr ::= ID|INDEXED LP STAR RP */
152425
+ -6, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
152426
+ -5, /* (180) expr ::= ID|INDEXED LP STAR RP filter_over */
152427
+ -1, /* (181) term ::= CTIME_KW */
152428
+ -5, /* (182) expr ::= LP nexprlist COMMA expr RP */
152429
+ -3, /* (183) expr ::= expr AND expr */
152430
+ -3, /* (184) expr ::= expr OR expr */
152431
+ -3, /* (185) expr ::= expr LT|GT|GE|LE expr */
152432
+ -3, /* (186) expr ::= expr EQ|NE expr */
152433
+ -3, /* (187) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
152434
+ -3, /* (188) expr ::= expr PLUS|MINUS expr */
152435
+ -3, /* (189) expr ::= expr STAR|SLASH|REM expr */
152436
+ -3, /* (190) expr ::= expr CONCAT expr */
152437
+ -2, /* (191) likeop ::= NOT LIKE_KW|MATCH */
152438
+ -3, /* (192) expr ::= expr likeop expr */
152439
+ -5, /* (193) expr ::= expr likeop expr ESCAPE expr */
152440
+ -2, /* (194) expr ::= expr ISNULL|NOTNULL */
152441
+ -3, /* (195) expr ::= expr NOT NULL */
152442
+ -3, /* (196) expr ::= expr IS expr */
152443
+ -4, /* (197) expr ::= expr IS NOT expr */
152444
+ -2, /* (198) expr ::= NOT expr */
152445
+ -2, /* (199) expr ::= BITNOT expr */
152446
+ -2, /* (200) expr ::= PLUS|MINUS expr */
152447
+ -1, /* (201) between_op ::= BETWEEN */
152448
+ -2, /* (202) between_op ::= NOT BETWEEN */
152449
+ -5, /* (203) expr ::= expr between_op expr AND expr */
152450
+ -1, /* (204) in_op ::= IN */
152451
+ -2, /* (205) in_op ::= NOT IN */
152452
+ -5, /* (206) expr ::= expr in_op LP exprlist RP */
152453
+ -3, /* (207) expr ::= LP select RP */
152454
+ -5, /* (208) expr ::= expr in_op LP select RP */
152455
+ -5, /* (209) expr ::= expr in_op nm dbnm paren_exprlist */
152456
+ -4, /* (210) expr ::= EXISTS LP select RP */
152457
+ -5, /* (211) expr ::= CASE case_operand case_exprlist case_else END */
152458
+ -5, /* (212) case_exprlist ::= case_exprlist WHEN expr THEN expr */
152459
+ -4, /* (213) case_exprlist ::= WHEN expr THEN expr */
152460
+ -2, /* (214) case_else ::= ELSE expr */
152461
+ 0, /* (215) case_else ::= */
152462
+ -1, /* (216) case_operand ::= expr */
152463
+ 0, /* (217) case_operand ::= */
152464
+ 0, /* (218) exprlist ::= */
152465
+ -3, /* (219) nexprlist ::= nexprlist COMMA expr */
152466
+ -1, /* (220) nexprlist ::= expr */
152467
+ 0, /* (221) paren_exprlist ::= */
152468
+ -3, /* (222) paren_exprlist ::= LP exprlist RP */
152469
+ -12, /* (223) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
152470
+ -1, /* (224) uniqueflag ::= UNIQUE */
152471
+ 0, /* (225) uniqueflag ::= */
152472
+ 0, /* (226) eidlist_opt ::= */
152473
+ -3, /* (227) eidlist_opt ::= LP eidlist RP */
152474
+ -5, /* (228) eidlist ::= eidlist COMMA nm collate sortorder */
152475
+ -3, /* (229) eidlist ::= nm collate sortorder */
152476
+ 0, /* (230) collate ::= */
152477
+ -2, /* (231) collate ::= COLLATE ID|STRING */
152478
+ -4, /* (232) cmd ::= DROP INDEX ifexists fullname */
152479
+ -2, /* (233) cmd ::= VACUUM vinto */
152480
+ -3, /* (234) cmd ::= VACUUM nm vinto */
152481
+ -2, /* (235) vinto ::= INTO expr */
152482
+ 0, /* (236) vinto ::= */
152483
+ -3, /* (237) cmd ::= PRAGMA nm dbnm */
152484
+ -5, /* (238) cmd ::= PRAGMA nm dbnm EQ nmnum */
152485
+ -6, /* (239) cmd ::= PRAGMA nm dbnm LP nmnum RP */
152486
+ -5, /* (240) cmd ::= PRAGMA nm dbnm EQ minus_num */
152487
+ -6, /* (241) cmd ::= PRAGMA nm dbnm LP minus_num RP */
152488
+ -2, /* (242) plus_num ::= PLUS INTEGER|FLOAT */
152489
+ -2, /* (243) minus_num ::= MINUS INTEGER|FLOAT */
152490
+ -5, /* (244) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
152491
+ -11, /* (245) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
152492
+ -1, /* (246) trigger_time ::= BEFORE|AFTER */
152493
+ -2, /* (247) trigger_time ::= INSTEAD OF */
152494
+ 0, /* (248) trigger_time ::= */
152495
+ -1, /* (249) trigger_event ::= DELETE|INSERT */
152496
+ -1, /* (250) trigger_event ::= UPDATE */
152497
+ -3, /* (251) trigger_event ::= UPDATE OF idlist */
152498
+ 0, /* (252) when_clause ::= */
152499
+ -2, /* (253) when_clause ::= WHEN expr */
152500
+ -3, /* (254) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
152501
+ -2, /* (255) trigger_cmd_list ::= trigger_cmd SEMI */
152502
+ -3, /* (256) trnm ::= nm DOT nm */
152503
+ -3, /* (257) tridxby ::= INDEXED BY nm */
152504
+ -2, /* (258) tridxby ::= NOT INDEXED */
152505
+ -8, /* (259) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
152506
+ -8, /* (260) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
152507
+ -6, /* (261) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
152508
+ -3, /* (262) trigger_cmd ::= scanpt select scanpt */
152509
+ -4, /* (263) expr ::= RAISE LP IGNORE RP */
152510
+ -6, /* (264) expr ::= RAISE LP raisetype COMMA nm RP */
152511
+ -1, /* (265) raisetype ::= ROLLBACK */
152512
+ -1, /* (266) raisetype ::= ABORT */
152513
+ -1, /* (267) raisetype ::= FAIL */
152514
+ -4, /* (268) cmd ::= DROP TRIGGER ifexists fullname */
152515
+ -6, /* (269) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
152516
+ -3, /* (270) cmd ::= DETACH database_kw_opt expr */
152517
+ 0, /* (271) key_opt ::= */
152518
+ -2, /* (272) key_opt ::= KEY expr */
152519
+ -1, /* (273) cmd ::= REINDEX */
152520
+ -3, /* (274) cmd ::= REINDEX nm dbnm */
152521
+ -1, /* (275) cmd ::= ANALYZE */
152522
+ -3, /* (276) cmd ::= ANALYZE nm dbnm */
152523
+ -6, /* (277) cmd ::= ALTER TABLE fullname RENAME TO nm */
152524
+ -7, /* (278) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
152525
+ -1, /* (279) add_column_fullname ::= fullname */
152526
+ -8, /* (280) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
152527
+ -1, /* (281) cmd ::= create_vtab */
152528
+ -4, /* (282) cmd ::= create_vtab LP vtabarglist RP */
152529
+ -8, /* (283) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
152530
+ 0, /* (284) vtabarg ::= */
152531
+ -1, /* (285) vtabargtoken ::= ANY */
152532
+ -3, /* (286) vtabargtoken ::= lp anylist RP */
152533
+ -1, /* (287) lp ::= LP */
152534
+ -2, /* (288) with ::= WITH wqlist */
152535
+ -3, /* (289) with ::= WITH RECURSIVE wqlist */
152536
+ -6, /* (290) wqlist ::= nm eidlist_opt AS LP select RP */
152537
+ -8, /* (291) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
152538
+ -1, /* (292) windowdefn_list ::= windowdefn */
152539
+ -3, /* (293) windowdefn_list ::= windowdefn_list COMMA windowdefn */
152540
+ -5, /* (294) windowdefn ::= nm AS LP window RP */
152541
+ -5, /* (295) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
152542
+ -6, /* (296) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
152543
+ -4, /* (297) window ::= ORDER BY sortlist frame_opt */
152544
+ -5, /* (298) window ::= nm ORDER BY sortlist frame_opt */
152545
+ -1, /* (299) window ::= frame_opt */
152546
+ -2, /* (300) window ::= nm frame_opt */
152547
+ 0, /* (301) frame_opt ::= */
152548
+ -3, /* (302) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
152549
+ -6, /* (303) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
152550
+ -1, /* (304) range_or_rows ::= RANGE|ROWS|GROUPS */
152551
+ -1, /* (305) frame_bound_s ::= frame_bound */
152552
+ -2, /* (306) frame_bound_s ::= UNBOUNDED PRECEDING */
152553
+ -1, /* (307) frame_bound_e ::= frame_bound */
152554
+ -2, /* (308) frame_bound_e ::= UNBOUNDED FOLLOWING */
152555
+ -2, /* (309) frame_bound ::= expr PRECEDING|FOLLOWING */
152556
+ -2, /* (310) frame_bound ::= CURRENT ROW */
152557
+ 0, /* (311) frame_exclude_opt ::= */
152558
+ -2, /* (312) frame_exclude_opt ::= EXCLUDE frame_exclude */
152559
+ -2, /* (313) frame_exclude ::= NO OTHERS */
152560
+ -2, /* (314) frame_exclude ::= CURRENT ROW */
152561
+ -1, /* (315) frame_exclude ::= GROUP|TIES */
152562
+ -2, /* (316) window_clause ::= WINDOW windowdefn_list */
152563
+ -2, /* (317) filter_over ::= filter_clause over_clause */
152564
+ -1, /* (318) filter_over ::= over_clause */
152565
+ -1, /* (319) filter_over ::= filter_clause */
152566
+ -4, /* (320) over_clause ::= OVER LP window RP */
152567
+ -2, /* (321) over_clause ::= OVER nm */
152568
+ -5, /* (322) filter_clause ::= FILTER LP WHERE expr RP */
152569
+ -1, /* (323) input ::= cmdlist */
152570
+ -2, /* (324) cmdlist ::= cmdlist ecmd */
152571
+ -1, /* (325) cmdlist ::= ecmd */
152572
+ -1, /* (326) ecmd ::= SEMI */
152573
+ -2, /* (327) ecmd ::= cmdx SEMI */
152574
+ -2, /* (328) ecmd ::= explain cmdx */
152575
+ 0, /* (329) trans_opt ::= */
152576
+ -1, /* (330) trans_opt ::= TRANSACTION */
152577
+ -2, /* (331) trans_opt ::= TRANSACTION nm */
152578
+ -1, /* (332) savepoint_opt ::= SAVEPOINT */
152579
+ 0, /* (333) savepoint_opt ::= */
152580
+ -2, /* (334) cmd ::= create_table create_table_args */
152581
+ -4, /* (335) columnlist ::= columnlist COMMA columnname carglist */
152582
+ -2, /* (336) columnlist ::= columnname carglist */
152583
+ -1, /* (337) nm ::= ID|INDEXED */
152584
+ -1, /* (338) nm ::= STRING */
152585
+ -1, /* (339) nm ::= JOIN_KW */
152586
+ -1, /* (340) typetoken ::= typename */
152587
+ -1, /* (341) typename ::= ID|STRING */
152588
+ -1, /* (342) signed ::= plus_num */
152589
+ -1, /* (343) signed ::= minus_num */
152590
+ -2, /* (344) carglist ::= carglist ccons */
152591
+ 0, /* (345) carglist ::= */
152592
+ -2, /* (346) ccons ::= NULL onconf */
152593
+ -2, /* (347) conslist_opt ::= COMMA conslist */
152594
+ -3, /* (348) conslist ::= conslist tconscomma tcons */
152595
+ -1, /* (349) conslist ::= tcons */
152596
+ 0, /* (350) tconscomma ::= */
152597
+ -1, /* (351) defer_subclause_opt ::= defer_subclause */
152598
+ -1, /* (352) resolvetype ::= raisetype */
152599
+ -1, /* (353) selectnowith ::= oneselect */
152600
+ -1, /* (354) oneselect ::= values */
152601
+ -2, /* (355) sclp ::= selcollist COMMA */
152602
+ -1, /* (356) as ::= ID|STRING */
152603
+ -1, /* (357) expr ::= term */
152604
+ -1, /* (358) likeop ::= LIKE_KW|MATCH */
152605
+ -1, /* (359) exprlist ::= nexprlist */
152606
+ -1, /* (360) nmnum ::= plus_num */
152607
+ -1, /* (361) nmnum ::= nm */
152608
+ -1, /* (362) nmnum ::= ON */
152609
+ -1, /* (363) nmnum ::= DELETE */
152610
+ -1, /* (364) nmnum ::= DEFAULT */
152611
+ -1, /* (365) plus_num ::= INTEGER|FLOAT */
152612
+ 0, /* (366) foreach_clause ::= */
152613
+ -3, /* (367) foreach_clause ::= FOR EACH ROW */
152614
+ -1, /* (368) trnm ::= nm */
152615
+ 0, /* (369) tridxby ::= */
152616
+ -1, /* (370) database_kw_opt ::= DATABASE */
152617
+ 0, /* (371) database_kw_opt ::= */
152618
+ 0, /* (372) kwcolumn_opt ::= */
152619
+ -1, /* (373) kwcolumn_opt ::= COLUMNKW */
152620
+ -1, /* (374) vtabarglist ::= vtabarg */
152621
+ -3, /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */
152622
+ -2, /* (376) vtabarg ::= vtabarg vtabargtoken */
152623
+ 0, /* (377) anylist ::= */
152624
+ -4, /* (378) anylist ::= anylist LP anylist RP */
152625
+ -2, /* (379) anylist ::= anylist ANY */
152626
+ 0, /* (380) with ::= */
151806152627
};
151807152628
151808152629
static void yy_accept(yyParser*); /* Forward Declaration */
151809152630
151810152631
/*
@@ -151897,20 +152718,20 @@
151897152718
break;
151898152719
case 2: /* cmdx ::= cmd */
151899152720
{ sqlite3FinishCoding(pParse); }
151900152721
break;
151901152722
case 3: /* cmd ::= BEGIN transtype trans_opt */
151902
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy100);}
152723
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy32);}
151903152724
break;
151904152725
case 4: /* transtype ::= */
151905
-{yymsp[1].minor.yy100 = TK_DEFERRED;}
152726
+{yymsp[1].minor.yy32 = TK_DEFERRED;}
151906152727
break;
151907152728
case 5: /* transtype ::= DEFERRED */
151908152729
case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
151909152730
case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
151910
- case 301: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==301);
151911
-{yymsp[0].minor.yy100 = yymsp[0].major; /*A-overwrites-X*/}
152731
+ case 304: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==304);
152732
+{yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-X*/}
151912152733
break;
151913152734
case 8: /* cmd ::= COMMIT|END trans_opt */
151914152735
case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
151915152736
{sqlite3EndTransaction(pParse,yymsp[-1].major);}
151916152737
break;
@@ -151929,11 +152750,11 @@
151929152750
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
151930152751
}
151931152752
break;
151932152753
case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
151933152754
{
151934
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy100,0,0,yymsp[-2].minor.yy100);
152755
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy32,0,0,yymsp[-2].minor.yy32);
151935152756
}
151936152757
break;
151937152758
case 14: /* createkw ::= CREATE */
151938152759
{disableLookaside(pParse);}
151939152760
break;
@@ -151943,37 +152764,37 @@
151943152764
case 43: /* autoinc ::= */ yytestcase(yyruleno==43);
151944152765
case 58: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==58);
151945152766
case 68: /* defer_subclause_opt ::= */ yytestcase(yyruleno==68);
151946152767
case 77: /* ifexists ::= */ yytestcase(yyruleno==77);
151947152768
case 94: /* distinct ::= */ yytestcase(yyruleno==94);
151948
- case 227: /* collate ::= */ yytestcase(yyruleno==227);
151949
-{yymsp[1].minor.yy100 = 0;}
152769
+ case 230: /* collate ::= */ yytestcase(yyruleno==230);
152770
+{yymsp[1].minor.yy32 = 0;}
151950152771
break;
151951152772
case 16: /* ifnotexists ::= IF NOT EXISTS */
151952
-{yymsp[-2].minor.yy100 = 1;}
152773
+{yymsp[-2].minor.yy32 = 1;}
151953152774
break;
151954152775
case 17: /* temp ::= TEMP */
151955152776
case 44: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==44);
151956
-{yymsp[0].minor.yy100 = 1;}
152777
+{yymsp[0].minor.yy32 = 1;}
151957152778
break;
151958152779
case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
151959152780
{
151960
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy100,0);
152781
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy32,0);
151961152782
}
151962152783
break;
151963152784
case 20: /* create_table_args ::= AS select */
151964152785
{
151965
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy391);
151966
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy391);
152786
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy25);
152787
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy25);
151967152788
}
151968152789
break;
151969152790
case 22: /* table_options ::= WITHOUT nm */
151970152791
{
151971152792
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
151972
- yymsp[-1].minor.yy100 = TF_WithoutRowid | TF_NoVisibleRowid;
152793
+ yymsp[-1].minor.yy32 = TF_WithoutRowid | TF_NoVisibleRowid;
151973152794
}else{
151974
- yymsp[-1].minor.yy100 = 0;
152795
+ yymsp[-1].minor.yy32 = 0;
151975152796
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
151976152797
}
151977152798
}
151978152799
break;
151979152800
case 23: /* columnname ::= nm typetoken */
@@ -151998,11 +152819,11 @@
151998152819
{yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
151999152820
break;
152000152821
case 28: /* scanpt ::= */
152001152822
{
152002152823
assert( yyLookahead!=YYNOCODE );
152003
- yymsp[1].minor.yy528 = yyLookaheadToken.z;
152824
+ yymsp[1].minor.yy8 = yyLookaheadToken.z;
152004152825
}
152005152826
break;
152006152827
case 29: /* scantok ::= */
152007152828
{
152008152829
assert( yyLookahead!=YYNOCODE );
@@ -152012,21 +152833,21 @@
152012152833
case 30: /* ccons ::= CONSTRAINT nm */
152013152834
case 63: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==63);
152014152835
{pParse->constraintName = yymsp[0].minor.yy0;}
152015152836
break;
152016152837
case 31: /* ccons ::= DEFAULT scantok term */
152017
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy102,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
152838
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy46,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
152018152839
break;
152019152840
case 32: /* ccons ::= DEFAULT LP expr RP */
152020
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy102,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
152841
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy46,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
152021152842
break;
152022152843
case 33: /* ccons ::= DEFAULT PLUS scantok term */
152023
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy102,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
152844
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy46,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
152024152845
break;
152025152846
case 34: /* ccons ::= DEFAULT MINUS scantok term */
152026152847
{
152027
- Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy102, 0);
152848
+ Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy46, 0);
152028152849
sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
152029152850
}
152030152851
break;
152031152852
case 35: /* ccons ::= DEFAULT scantok ID|INDEXED */
152032152853
{
@@ -152037,319 +152858,319 @@
152037152858
}
152038152859
sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
152039152860
}
152040152861
break;
152041152862
case 36: /* ccons ::= NOT NULL onconf */
152042
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy100);}
152863
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy32);}
152043152864
break;
152044152865
case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
152045
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy100,yymsp[0].minor.yy100,yymsp[-2].minor.yy100);}
152866
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy32,yymsp[0].minor.yy32,yymsp[-2].minor.yy32);}
152046152867
break;
152047152868
case 38: /* ccons ::= UNIQUE onconf */
152048
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy100,0,0,0,0,
152869
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy32,0,0,0,0,
152049152870
SQLITE_IDXTYPE_UNIQUE);}
152050152871
break;
152051152872
case 39: /* ccons ::= CHECK LP expr RP */
152052
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy102);}
152873
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy46);}
152053152874
break;
152054152875
case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */
152055
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy94,yymsp[0].minor.yy100);}
152876
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy138,yymsp[0].minor.yy32);}
152056152877
break;
152057152878
case 41: /* ccons ::= defer_subclause */
152058
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy100);}
152879
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy32);}
152059152880
break;
152060152881
case 42: /* ccons ::= COLLATE ID|STRING */
152061152882
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
152062152883
break;
152063152884
case 45: /* refargs ::= */
152064
-{ yymsp[1].minor.yy100 = OE_None*0x0101; /* EV: R-19803-45884 */}
152885
+{ yymsp[1].minor.yy32 = OE_None*0x0101; /* EV: R-19803-45884 */}
152065152886
break;
152066152887
case 46: /* refargs ::= refargs refarg */
152067
-{ yymsp[-1].minor.yy100 = (yymsp[-1].minor.yy100 & ~yymsp[0].minor.yy199.mask) | yymsp[0].minor.yy199.value; }
152888
+{ yymsp[-1].minor.yy32 = (yymsp[-1].minor.yy32 & ~yymsp[0].minor.yy495.mask) | yymsp[0].minor.yy495.value; }
152068152889
break;
152069152890
case 47: /* refarg ::= MATCH nm */
152070
-{ yymsp[-1].minor.yy199.value = 0; yymsp[-1].minor.yy199.mask = 0x000000; }
152891
+{ yymsp[-1].minor.yy495.value = 0; yymsp[-1].minor.yy495.mask = 0x000000; }
152071152892
break;
152072152893
case 48: /* refarg ::= ON INSERT refact */
152073
-{ yymsp[-2].minor.yy199.value = 0; yymsp[-2].minor.yy199.mask = 0x000000; }
152894
+{ yymsp[-2].minor.yy495.value = 0; yymsp[-2].minor.yy495.mask = 0x000000; }
152074152895
break;
152075152896
case 49: /* refarg ::= ON DELETE refact */
152076
-{ yymsp[-2].minor.yy199.value = yymsp[0].minor.yy100; yymsp[-2].minor.yy199.mask = 0x0000ff; }
152897
+{ yymsp[-2].minor.yy495.value = yymsp[0].minor.yy32; yymsp[-2].minor.yy495.mask = 0x0000ff; }
152077152898
break;
152078152899
case 50: /* refarg ::= ON UPDATE refact */
152079
-{ yymsp[-2].minor.yy199.value = yymsp[0].minor.yy100<<8; yymsp[-2].minor.yy199.mask = 0x00ff00; }
152900
+{ yymsp[-2].minor.yy495.value = yymsp[0].minor.yy32<<8; yymsp[-2].minor.yy495.mask = 0x00ff00; }
152080152901
break;
152081152902
case 51: /* refact ::= SET NULL */
152082
-{ yymsp[-1].minor.yy100 = OE_SetNull; /* EV: R-33326-45252 */}
152903
+{ yymsp[-1].minor.yy32 = OE_SetNull; /* EV: R-33326-45252 */}
152083152904
break;
152084152905
case 52: /* refact ::= SET DEFAULT */
152085
-{ yymsp[-1].minor.yy100 = OE_SetDflt; /* EV: R-33326-45252 */}
152906
+{ yymsp[-1].minor.yy32 = OE_SetDflt; /* EV: R-33326-45252 */}
152086152907
break;
152087152908
case 53: /* refact ::= CASCADE */
152088
-{ yymsp[0].minor.yy100 = OE_Cascade; /* EV: R-33326-45252 */}
152909
+{ yymsp[0].minor.yy32 = OE_Cascade; /* EV: R-33326-45252 */}
152089152910
break;
152090152911
case 54: /* refact ::= RESTRICT */
152091
-{ yymsp[0].minor.yy100 = OE_Restrict; /* EV: R-33326-45252 */}
152912
+{ yymsp[0].minor.yy32 = OE_Restrict; /* EV: R-33326-45252 */}
152092152913
break;
152093152914
case 55: /* refact ::= NO ACTION */
152094
-{ yymsp[-1].minor.yy100 = OE_None; /* EV: R-33326-45252 */}
152915
+{ yymsp[-1].minor.yy32 = OE_None; /* EV: R-33326-45252 */}
152095152916
break;
152096152917
case 56: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
152097
-{yymsp[-2].minor.yy100 = 0;}
152918
+{yymsp[-2].minor.yy32 = 0;}
152098152919
break;
152099152920
case 57: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
152100152921
case 72: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==72);
152101
- case 157: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==157);
152102
-{yymsp[-1].minor.yy100 = yymsp[0].minor.yy100;}
152922
+ case 160: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==160);
152923
+{yymsp[-1].minor.yy32 = yymsp[0].minor.yy32;}
152103152924
break;
152104152925
case 59: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
152105152926
case 76: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==76);
152106
- case 199: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==199);
152107
- case 202: /* in_op ::= NOT IN */ yytestcase(yyruleno==202);
152108
- case 228: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==228);
152109
-{yymsp[-1].minor.yy100 = 1;}
152927
+ case 202: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==202);
152928
+ case 205: /* in_op ::= NOT IN */ yytestcase(yyruleno==205);
152929
+ case 231: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==231);
152930
+{yymsp[-1].minor.yy32 = 1;}
152110152931
break;
152111152932
case 60: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
152112
-{yymsp[-1].minor.yy100 = 0;}
152933
+{yymsp[-1].minor.yy32 = 0;}
152113152934
break;
152114152935
case 62: /* tconscomma ::= COMMA */
152115152936
{pParse->constraintName.n = 0;}
152116152937
break;
152117152938
case 64: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
152118
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy94,yymsp[0].minor.yy100,yymsp[-2].minor.yy100,0);}
152939
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy138,yymsp[0].minor.yy32,yymsp[-2].minor.yy32,0);}
152119152940
break;
152120152941
case 65: /* tcons ::= UNIQUE LP sortlist RP onconf */
152121
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy94,yymsp[0].minor.yy100,0,0,0,0,
152942
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy138,yymsp[0].minor.yy32,0,0,0,0,
152122152943
SQLITE_IDXTYPE_UNIQUE);}
152123152944
break;
152124152945
case 66: /* tcons ::= CHECK LP expr RP onconf */
152125
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy102);}
152946
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy46);}
152126152947
break;
152127152948
case 67: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
152128152949
{
152129
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy94, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy94, yymsp[-1].minor.yy100);
152130
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy100);
152950
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy138, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy138, yymsp[-1].minor.yy32);
152951
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy32);
152131152952
}
152132152953
break;
152133152954
case 69: /* onconf ::= */
152134152955
case 71: /* orconf ::= */ yytestcase(yyruleno==71);
152135
-{yymsp[1].minor.yy100 = OE_Default;}
152956
+{yymsp[1].minor.yy32 = OE_Default;}
152136152957
break;
152137152958
case 70: /* onconf ::= ON CONFLICT resolvetype */
152138
-{yymsp[-2].minor.yy100 = yymsp[0].minor.yy100;}
152959
+{yymsp[-2].minor.yy32 = yymsp[0].minor.yy32;}
152139152960
break;
152140152961
case 73: /* resolvetype ::= IGNORE */
152141
-{yymsp[0].minor.yy100 = OE_Ignore;}
152962
+{yymsp[0].minor.yy32 = OE_Ignore;}
152142152963
break;
152143152964
case 74: /* resolvetype ::= REPLACE */
152144
- case 158: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==158);
152145
-{yymsp[0].minor.yy100 = OE_Replace;}
152965
+ case 161: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==161);
152966
+{yymsp[0].minor.yy32 = OE_Replace;}
152146152967
break;
152147152968
case 75: /* cmd ::= DROP TABLE ifexists fullname */
152148152969
{
152149
- sqlite3DropTable(pParse, yymsp[0].minor.yy407, 0, yymsp[-1].minor.yy100);
152970
+ sqlite3DropTable(pParse, yymsp[0].minor.yy609, 0, yymsp[-1].minor.yy32);
152150152971
}
152151152972
break;
152152152973
case 78: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
152153152974
{
152154
- sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy94, yymsp[0].minor.yy391, yymsp[-7].minor.yy100, yymsp[-5].minor.yy100);
152975
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy138, yymsp[0].minor.yy25, yymsp[-7].minor.yy32, yymsp[-5].minor.yy32);
152155152976
}
152156152977
break;
152157152978
case 79: /* cmd ::= DROP VIEW ifexists fullname */
152158152979
{
152159
- sqlite3DropTable(pParse, yymsp[0].minor.yy407, 1, yymsp[-1].minor.yy100);
152980
+ sqlite3DropTable(pParse, yymsp[0].minor.yy609, 1, yymsp[-1].minor.yy32);
152160152981
}
152161152982
break;
152162152983
case 80: /* cmd ::= select */
152163152984
{
152164152985
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
152165
- sqlite3Select(pParse, yymsp[0].minor.yy391, &dest);
152166
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy391);
152986
+ sqlite3Select(pParse, yymsp[0].minor.yy25, &dest);
152987
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy25);
152167152988
}
152168152989
break;
152169152990
case 81: /* select ::= WITH wqlist selectnowith */
152170152991
{
152171
- Select *p = yymsp[0].minor.yy391;
152992
+ Select *p = yymsp[0].minor.yy25;
152172152993
if( p ){
152173
- p->pWith = yymsp[-1].minor.yy243;
152994
+ p->pWith = yymsp[-1].minor.yy297;
152174152995
parserDoubleLinkSelect(pParse, p);
152175152996
}else{
152176
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy243);
152997
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy297);
152177152998
}
152178
- yymsp[-2].minor.yy391 = p;
152999
+ yymsp[-2].minor.yy25 = p;
152179153000
}
152180153001
break;
152181153002
case 82: /* select ::= WITH RECURSIVE wqlist selectnowith */
152182153003
{
152183
- Select *p = yymsp[0].minor.yy391;
153004
+ Select *p = yymsp[0].minor.yy25;
152184153005
if( p ){
152185
- p->pWith = yymsp[-1].minor.yy243;
153006
+ p->pWith = yymsp[-1].minor.yy297;
152186153007
parserDoubleLinkSelect(pParse, p);
152187153008
}else{
152188
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy243);
153009
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy297);
152189153010
}
152190
- yymsp[-3].minor.yy391 = p;
153011
+ yymsp[-3].minor.yy25 = p;
152191153012
}
152192153013
break;
152193153014
case 83: /* select ::= selectnowith */
152194153015
{
152195
- Select *p = yymsp[0].minor.yy391;
153016
+ Select *p = yymsp[0].minor.yy25;
152196153017
if( p ){
152197153018
parserDoubleLinkSelect(pParse, p);
152198153019
}
152199
- yymsp[0].minor.yy391 = p; /*A-overwrites-X*/
153020
+ yymsp[0].minor.yy25 = p; /*A-overwrites-X*/
152200153021
}
152201153022
break;
152202153023
case 84: /* selectnowith ::= selectnowith multiselect_op oneselect */
152203153024
{
152204
- Select *pRhs = yymsp[0].minor.yy391;
152205
- Select *pLhs = yymsp[-2].minor.yy391;
153025
+ Select *pRhs = yymsp[0].minor.yy25;
153026
+ Select *pLhs = yymsp[-2].minor.yy25;
152206153027
if( pRhs && pRhs->pPrior ){
152207153028
SrcList *pFrom;
152208153029
Token x;
152209153030
x.n = 0;
152210153031
parserDoubleLinkSelect(pParse, pRhs);
152211153032
pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
152212153033
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
152213153034
}
152214153035
if( pRhs ){
152215
- pRhs->op = (u8)yymsp[-1].minor.yy100;
153036
+ pRhs->op = (u8)yymsp[-1].minor.yy32;
152216153037
pRhs->pPrior = pLhs;
152217153038
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
152218153039
pRhs->selFlags &= ~SF_MultiValue;
152219
- if( yymsp[-1].minor.yy100!=TK_ALL ) pParse->hasCompound = 1;
153040
+ if( yymsp[-1].minor.yy32!=TK_ALL ) pParse->hasCompound = 1;
152220153041
}else{
152221153042
sqlite3SelectDelete(pParse->db, pLhs);
152222153043
}
152223
- yymsp[-2].minor.yy391 = pRhs;
153044
+ yymsp[-2].minor.yy25 = pRhs;
152224153045
}
152225153046
break;
152226153047
case 85: /* multiselect_op ::= UNION */
152227153048
case 87: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==87);
152228
-{yymsp[0].minor.yy100 = yymsp[0].major; /*A-overwrites-OP*/}
153049
+{yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-OP*/}
152229153050
break;
152230153051
case 86: /* multiselect_op ::= UNION ALL */
152231
-{yymsp[-1].minor.yy100 = TK_ALL;}
153052
+{yymsp[-1].minor.yy32 = TK_ALL;}
152232153053
break;
152233153054
case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
152234153055
{
152235
- yymsp[-8].minor.yy391 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy94,yymsp[-5].minor.yy407,yymsp[-4].minor.yy102,yymsp[-3].minor.yy94,yymsp[-2].minor.yy102,yymsp[-1].minor.yy94,yymsp[-7].minor.yy100,yymsp[0].minor.yy102);
153056
+ yymsp[-8].minor.yy25 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy138,yymsp[-5].minor.yy609,yymsp[-4].minor.yy46,yymsp[-3].minor.yy138,yymsp[-2].minor.yy46,yymsp[-1].minor.yy138,yymsp[-7].minor.yy32,yymsp[0].minor.yy46);
152236153057
}
152237153058
break;
152238153059
case 89: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
152239153060
{
152240
- yymsp[-9].minor.yy391 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy94,yymsp[-6].minor.yy407,yymsp[-5].minor.yy102,yymsp[-4].minor.yy94,yymsp[-3].minor.yy102,yymsp[-1].minor.yy94,yymsp[-8].minor.yy100,yymsp[0].minor.yy102);
152241
- if( yymsp[-9].minor.yy391 ){
152242
- yymsp[-9].minor.yy391->pWinDefn = yymsp[-2].minor.yy379;
153061
+ yymsp[-9].minor.yy25 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy138,yymsp[-6].minor.yy609,yymsp[-5].minor.yy46,yymsp[-4].minor.yy138,yymsp[-3].minor.yy46,yymsp[-1].minor.yy138,yymsp[-8].minor.yy32,yymsp[0].minor.yy46);
153062
+ if( yymsp[-9].minor.yy25 ){
153063
+ yymsp[-9].minor.yy25->pWinDefn = yymsp[-2].minor.yy455;
152243153064
}else{
152244
- sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy379);
153065
+ sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy455);
152245153066
}
152246153067
}
152247153068
break;
152248153069
case 90: /* values ::= VALUES LP nexprlist RP */
152249153070
{
152250
- yymsp[-3].minor.yy391 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy94,0,0,0,0,0,SF_Values,0);
153071
+ yymsp[-3].minor.yy25 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy138,0,0,0,0,0,SF_Values,0);
152251153072
}
152252153073
break;
152253153074
case 91: /* values ::= values COMMA LP nexprlist RP */
152254153075
{
152255
- Select *pRight, *pLeft = yymsp[-4].minor.yy391;
152256
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy94,0,0,0,0,0,SF_Values|SF_MultiValue,0);
153076
+ Select *pRight, *pLeft = yymsp[-4].minor.yy25;
153077
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy138,0,0,0,0,0,SF_Values|SF_MultiValue,0);
152257153078
if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
152258153079
if( pRight ){
152259153080
pRight->op = TK_ALL;
152260153081
pRight->pPrior = pLeft;
152261
- yymsp[-4].minor.yy391 = pRight;
153082
+ yymsp[-4].minor.yy25 = pRight;
152262153083
}else{
152263
- yymsp[-4].minor.yy391 = pLeft;
153084
+ yymsp[-4].minor.yy25 = pLeft;
152264153085
}
152265153086
}
152266153087
break;
152267153088
case 92: /* distinct ::= DISTINCT */
152268
-{yymsp[0].minor.yy100 = SF_Distinct;}
153089
+{yymsp[0].minor.yy32 = SF_Distinct;}
152269153090
break;
152270153091
case 93: /* distinct ::= ALL */
152271
-{yymsp[0].minor.yy100 = SF_All;}
153092
+{yymsp[0].minor.yy32 = SF_All;}
152272153093
break;
152273153094
case 95: /* sclp ::= */
152274153095
case 128: /* orderby_opt ::= */ yytestcase(yyruleno==128);
152275
- case 135: /* groupby_opt ::= */ yytestcase(yyruleno==135);
152276
- case 215: /* exprlist ::= */ yytestcase(yyruleno==215);
152277
- case 218: /* paren_exprlist ::= */ yytestcase(yyruleno==218);
152278
- case 223: /* eidlist_opt ::= */ yytestcase(yyruleno==223);
152279
-{yymsp[1].minor.yy94 = 0;}
153096
+ case 138: /* groupby_opt ::= */ yytestcase(yyruleno==138);
153097
+ case 218: /* exprlist ::= */ yytestcase(yyruleno==218);
153098
+ case 221: /* paren_exprlist ::= */ yytestcase(yyruleno==221);
153099
+ case 226: /* eidlist_opt ::= */ yytestcase(yyruleno==226);
153100
+{yymsp[1].minor.yy138 = 0;}
152280153101
break;
152281153102
case 96: /* selcollist ::= sclp scanpt expr scanpt as */
152282153103
{
152283
- yymsp[-4].minor.yy94 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy94, yymsp[-2].minor.yy102);
152284
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy94, &yymsp[0].minor.yy0, 1);
152285
- sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy94,yymsp[-3].minor.yy528,yymsp[-1].minor.yy528);
153104
+ yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy138, yymsp[-2].minor.yy46);
153105
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy138, &yymsp[0].minor.yy0, 1);
153106
+ sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy138,yymsp[-3].minor.yy8,yymsp[-1].minor.yy8);
152286153107
}
152287153108
break;
152288153109
case 97: /* selcollist ::= sclp scanpt STAR */
152289153110
{
152290153111
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
152291
- yymsp[-2].minor.yy94 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy94, p);
153112
+ yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy138, p);
152292153113
}
152293153114
break;
152294153115
case 98: /* selcollist ::= sclp scanpt nm DOT STAR */
152295153116
{
152296153117
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
152297153118
Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
152298153119
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
152299
- yymsp[-4].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy94, pDot);
153120
+ yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, pDot);
152300153121
}
152301153122
break;
152302153123
case 99: /* as ::= AS nm */
152303153124
case 110: /* dbnm ::= DOT nm */ yytestcase(yyruleno==110);
152304
- case 239: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==239);
152305
- case 240: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==240);
153125
+ case 242: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==242);
153126
+ case 243: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==243);
152306153127
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
152307153128
break;
152308153129
case 101: /* from ::= */
152309
-{yymsp[1].minor.yy407 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy407));}
153130
+{yymsp[1].minor.yy609 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy609));}
152310153131
break;
152311153132
case 102: /* from ::= FROM seltablist */
152312153133
{
152313
- yymsp[-1].minor.yy407 = yymsp[0].minor.yy407;
152314
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy407);
153134
+ yymsp[-1].minor.yy609 = yymsp[0].minor.yy609;
153135
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy609);
152315153136
}
152316153137
break;
152317153138
case 103: /* stl_prefix ::= seltablist joinop */
152318153139
{
152319
- if( ALWAYS(yymsp[-1].minor.yy407 && yymsp[-1].minor.yy407->nSrc>0) ) yymsp[-1].minor.yy407->a[yymsp[-1].minor.yy407->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy100;
153140
+ if( ALWAYS(yymsp[-1].minor.yy609 && yymsp[-1].minor.yy609->nSrc>0) ) yymsp[-1].minor.yy609->a[yymsp[-1].minor.yy609->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy32;
152320153141
}
152321153142
break;
152322153143
case 104: /* stl_prefix ::= */
152323
-{yymsp[1].minor.yy407 = 0;}
153144
+{yymsp[1].minor.yy609 = 0;}
152324153145
break;
152325153146
case 105: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
152326153147
{
152327
- yymsp[-6].minor.yy407 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy407,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy102,yymsp[0].minor.yy76);
152328
- sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy407, &yymsp[-2].minor.yy0);
153148
+ yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy46,yymsp[0].minor.yy406);
153149
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy609, &yymsp[-2].minor.yy0);
152329153150
}
152330153151
break;
152331153152
case 106: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
152332153153
{
152333
- yymsp[-8].minor.yy407 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy407,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy102,yymsp[0].minor.yy76);
152334
- sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy407, yymsp[-4].minor.yy94);
153154
+ yymsp[-8].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy609,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy46,yymsp[0].minor.yy406);
153155
+ sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy609, yymsp[-4].minor.yy138);
152335153156
}
152336153157
break;
152337153158
case 107: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
152338153159
{
152339
- yymsp[-6].minor.yy407 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy407,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy391,yymsp[-1].minor.yy102,yymsp[0].minor.yy76);
153160
+ yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy25,yymsp[-1].minor.yy46,yymsp[0].minor.yy406);
152340153161
}
152341153162
break;
152342153163
case 108: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
152343153164
{
152344
- if( yymsp[-6].minor.yy407==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy102==0 && yymsp[0].minor.yy76==0 ){
152345
- yymsp[-6].minor.yy407 = yymsp[-4].minor.yy407;
152346
- }else if( yymsp[-4].minor.yy407->nSrc==1 ){
152347
- yymsp[-6].minor.yy407 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy407,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy102,yymsp[0].minor.yy76);
152348
- if( yymsp[-6].minor.yy407 ){
152349
- struct SrcList_item *pNew = &yymsp[-6].minor.yy407->a[yymsp[-6].minor.yy407->nSrc-1];
152350
- struct SrcList_item *pOld = yymsp[-4].minor.yy407->a;
153165
+ if( yymsp[-6].minor.yy609==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy46==0 && yymsp[0].minor.yy406==0 ){
153166
+ yymsp[-6].minor.yy609 = yymsp[-4].minor.yy609;
153167
+ }else if( yymsp[-4].minor.yy609->nSrc==1 ){
153168
+ yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy46,yymsp[0].minor.yy406);
153169
+ if( yymsp[-6].minor.yy609 ){
153170
+ struct SrcList_item *pNew = &yymsp[-6].minor.yy609->a[yymsp[-6].minor.yy609->nSrc-1];
153171
+ struct SrcList_item *pOld = yymsp[-4].minor.yy609->a;
152351153172
pNew->zName = pOld->zName;
152352153173
pNew->zDatabase = pOld->zDatabase;
152353153174
pNew->pSelect = pOld->pSelect;
152354153175
if( pOld->fg.isTabFunc ){
152355153176
pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -152358,953 +153179,946 @@
152358153179
pNew->fg.isTabFunc = 1;
152359153180
}
152360153181
pOld->zName = pOld->zDatabase = 0;
152361153182
pOld->pSelect = 0;
152362153183
}
152363
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy407);
153184
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy609);
152364153185
}else{
152365153186
Select *pSubquery;
152366
- sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy407);
152367
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy407,0,0,0,0,SF_NestedFrom,0);
152368
- yymsp[-6].minor.yy407 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy407,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy102,yymsp[0].minor.yy76);
153187
+ sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy609);
153188
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy609,0,0,0,0,SF_NestedFrom,0);
153189
+ yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy46,yymsp[0].minor.yy406);
152369153190
}
152370153191
}
152371153192
break;
152372153193
case 109: /* dbnm ::= */
152373153194
case 123: /* indexed_opt ::= */ yytestcase(yyruleno==123);
152374153195
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
152375153196
break;
152376153197
case 111: /* fullname ::= nm */
152377153198
{
152378
- yylhsminor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
152379
- if( IN_RENAME_OBJECT && yylhsminor.yy407 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy407->a[0].zName, &yymsp[0].minor.yy0);
153199
+ yylhsminor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
153200
+ if( IN_RENAME_OBJECT && yylhsminor.yy609 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy609->a[0].zName, &yymsp[0].minor.yy0);
152380153201
}
152381
- yymsp[0].minor.yy407 = yylhsminor.yy407;
153202
+ yymsp[0].minor.yy609 = yylhsminor.yy609;
152382153203
break;
152383153204
case 112: /* fullname ::= nm DOT nm */
152384153205
{
152385
- yylhsminor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
152386
- if( IN_RENAME_OBJECT && yylhsminor.yy407 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy407->a[0].zName, &yymsp[0].minor.yy0);
153206
+ yylhsminor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
153207
+ if( IN_RENAME_OBJECT && yylhsminor.yy609 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy609->a[0].zName, &yymsp[0].minor.yy0);
152387153208
}
152388
- yymsp[-2].minor.yy407 = yylhsminor.yy407;
153209
+ yymsp[-2].minor.yy609 = yylhsminor.yy609;
152389153210
break;
152390153211
case 113: /* xfullname ::= nm */
152391
-{yymsp[0].minor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
153212
+{yymsp[0].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
152392153213
break;
152393153214
case 114: /* xfullname ::= nm DOT nm */
152394
-{yymsp[-2].minor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
153215
+{yymsp[-2].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
152395153216
break;
152396153217
case 115: /* xfullname ::= nm DOT nm AS nm */
152397153218
{
152398
- yymsp[-4].minor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
152399
- if( yymsp[-4].minor.yy407 ) yymsp[-4].minor.yy407->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
153219
+ yymsp[-4].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
153220
+ if( yymsp[-4].minor.yy609 ) yymsp[-4].minor.yy609->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
152400153221
}
152401153222
break;
152402153223
case 116: /* xfullname ::= nm AS nm */
152403153224
{
152404
- yymsp[-2].minor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
152405
- if( yymsp[-2].minor.yy407 ) yymsp[-2].minor.yy407->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
153225
+ yymsp[-2].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
153226
+ if( yymsp[-2].minor.yy609 ) yymsp[-2].minor.yy609->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
152406153227
}
152407153228
break;
152408153229
case 117: /* joinop ::= COMMA|JOIN */
152409
-{ yymsp[0].minor.yy100 = JT_INNER; }
153230
+{ yymsp[0].minor.yy32 = JT_INNER; }
152410153231
break;
152411153232
case 118: /* joinop ::= JOIN_KW JOIN */
152412
-{yymsp[-1].minor.yy100 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
153233
+{yymsp[-1].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
152413153234
break;
152414153235
case 119: /* joinop ::= JOIN_KW nm JOIN */
152415
-{yymsp[-2].minor.yy100 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
153236
+{yymsp[-2].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
152416153237
break;
152417153238
case 120: /* joinop ::= JOIN_KW nm nm JOIN */
152418
-{yymsp[-3].minor.yy100 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
153239
+{yymsp[-3].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
152419153240
break;
152420153241
case 121: /* on_opt ::= ON expr */
152421
- case 138: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==138);
152422
- case 145: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==145);
152423
- case 211: /* case_else ::= ELSE expr */ yytestcase(yyruleno==211);
152424
- case 232: /* vinto ::= INTO expr */ yytestcase(yyruleno==232);
152425
-{yymsp[-1].minor.yy102 = yymsp[0].minor.yy102;}
153242
+ case 141: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==141);
153243
+ case 148: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==148);
153244
+ case 214: /* case_else ::= ELSE expr */ yytestcase(yyruleno==214);
153245
+ case 235: /* vinto ::= INTO expr */ yytestcase(yyruleno==235);
153246
+{yymsp[-1].minor.yy46 = yymsp[0].minor.yy46;}
152426153247
break;
152427153248
case 122: /* on_opt ::= */
152428
- case 137: /* having_opt ::= */ yytestcase(yyruleno==137);
152429
- case 139: /* limit_opt ::= */ yytestcase(yyruleno==139);
152430
- case 144: /* where_opt ::= */ yytestcase(yyruleno==144);
152431
- case 212: /* case_else ::= */ yytestcase(yyruleno==212);
152432
- case 214: /* case_operand ::= */ yytestcase(yyruleno==214);
152433
- case 233: /* vinto ::= */ yytestcase(yyruleno==233);
152434
-{yymsp[1].minor.yy102 = 0;}
153249
+ case 140: /* having_opt ::= */ yytestcase(yyruleno==140);
153250
+ case 142: /* limit_opt ::= */ yytestcase(yyruleno==142);
153251
+ case 147: /* where_opt ::= */ yytestcase(yyruleno==147);
153252
+ case 215: /* case_else ::= */ yytestcase(yyruleno==215);
153253
+ case 217: /* case_operand ::= */ yytestcase(yyruleno==217);
153254
+ case 236: /* vinto ::= */ yytestcase(yyruleno==236);
153255
+{yymsp[1].minor.yy46 = 0;}
152435153256
break;
152436153257
case 124: /* indexed_opt ::= INDEXED BY nm */
152437153258
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
152438153259
break;
152439153260
case 125: /* indexed_opt ::= NOT INDEXED */
152440153261
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
152441153262
break;
152442153263
case 126: /* using_opt ::= USING LP idlist RP */
152443
-{yymsp[-3].minor.yy76 = yymsp[-1].minor.yy76;}
153264
+{yymsp[-3].minor.yy406 = yymsp[-1].minor.yy406;}
152444153265
break;
152445153266
case 127: /* using_opt ::= */
152446
- case 159: /* idlist_opt ::= */ yytestcase(yyruleno==159);
152447
-{yymsp[1].minor.yy76 = 0;}
153267
+ case 162: /* idlist_opt ::= */ yytestcase(yyruleno==162);
153268
+{yymsp[1].minor.yy406 = 0;}
152448153269
break;
152449153270
case 129: /* orderby_opt ::= ORDER BY sortlist */
152450
- case 136: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==136);
152451
-{yymsp[-2].minor.yy94 = yymsp[0].minor.yy94;}
153271
+ case 139: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==139);
153272
+{yymsp[-2].minor.yy138 = yymsp[0].minor.yy138;}
152452153273
break;
152453
- case 130: /* sortlist ::= sortlist COMMA expr sortorder */
153274
+ case 130: /* sortlist ::= sortlist COMMA expr sortorder nulls */
152454153275
{
152455
- yymsp[-3].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy94,yymsp[-1].minor.yy102);
152456
- sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy94,yymsp[0].minor.yy100);
153276
+ yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138,yymsp[-2].minor.yy46);
153277
+ sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy138,yymsp[-1].minor.yy32,yymsp[0].minor.yy32);
152457153278
}
152458153279
break;
152459
- case 131: /* sortlist ::= expr sortorder */
153280
+ case 131: /* sortlist ::= expr sortorder nulls */
152460153281
{
152461
- yymsp[-1].minor.yy94 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy102); /*A-overwrites-Y*/
152462
- sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy94,yymsp[0].minor.yy100);
153282
+ yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy46); /*A-overwrites-Y*/
153283
+ sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy138,yymsp[-1].minor.yy32,yymsp[0].minor.yy32);
152463153284
}
152464153285
break;
152465153286
case 132: /* sortorder ::= ASC */
152466
-{yymsp[0].minor.yy100 = SQLITE_SO_ASC;}
153287
+{yymsp[0].minor.yy32 = SQLITE_SO_ASC;}
152467153288
break;
152468153289
case 133: /* sortorder ::= DESC */
152469
-{yymsp[0].minor.yy100 = SQLITE_SO_DESC;}
153290
+{yymsp[0].minor.yy32 = SQLITE_SO_DESC;}
152470153291
break;
152471153292
case 134: /* sortorder ::= */
152472
-{yymsp[1].minor.yy100 = SQLITE_SO_UNDEFINED;}
152473
- break;
152474
- case 140: /* limit_opt ::= LIMIT expr */
152475
-{yymsp[-1].minor.yy102 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy102,0);}
152476
- break;
152477
- case 141: /* limit_opt ::= LIMIT expr OFFSET expr */
152478
-{yymsp[-3].minor.yy102 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy102,yymsp[0].minor.yy102);}
152479
- break;
152480
- case 142: /* limit_opt ::= LIMIT expr COMMA expr */
152481
-{yymsp[-3].minor.yy102 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy102,yymsp[-2].minor.yy102);}
152482
- break;
152483
- case 143: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
152484
-{
152485
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy407, &yymsp[-1].minor.yy0);
152486
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy407,yymsp[0].minor.yy102,0,0);
152487
-}
152488
- break;
152489
- case 146: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
152490
-{
152491
- sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy407, &yymsp[-3].minor.yy0);
152492
- sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy94,"set list");
152493
- sqlite3Update(pParse,yymsp[-4].minor.yy407,yymsp[-1].minor.yy94,yymsp[0].minor.yy102,yymsp[-5].minor.yy100,0,0,0);
152494
-}
152495
- break;
152496
- case 147: /* setlist ::= setlist COMMA nm EQ expr */
152497
-{
152498
- yymsp[-4].minor.yy94 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy94, yymsp[0].minor.yy102);
152499
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy94, &yymsp[-2].minor.yy0, 1);
152500
-}
152501
- break;
152502
- case 148: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
152503
-{
152504
- yymsp[-6].minor.yy94 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy94, yymsp[-3].minor.yy76, yymsp[0].minor.yy102);
152505
-}
152506
- break;
152507
- case 149: /* setlist ::= nm EQ expr */
152508
-{
152509
- yylhsminor.yy94 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy102);
152510
- sqlite3ExprListSetName(pParse, yylhsminor.yy94, &yymsp[-2].minor.yy0, 1);
152511
-}
152512
- yymsp[-2].minor.yy94 = yylhsminor.yy94;
152513
- break;
152514
- case 150: /* setlist ::= LP idlist RP EQ expr */
152515
-{
152516
- yymsp[-4].minor.yy94 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy76, yymsp[0].minor.yy102);
152517
-}
152518
- break;
152519
- case 151: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
152520
-{
152521
- sqlite3Insert(pParse, yymsp[-3].minor.yy407, yymsp[-1].minor.yy391, yymsp[-2].minor.yy76, yymsp[-5].minor.yy100, yymsp[0].minor.yy95);
152522
-}
152523
- break;
152524
- case 152: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
152525
-{
152526
- sqlite3Insert(pParse, yymsp[-3].minor.yy407, 0, yymsp[-2].minor.yy76, yymsp[-5].minor.yy100, 0);
152527
-}
152528
- break;
152529
- case 153: /* upsert ::= */
152530
-{ yymsp[1].minor.yy95 = 0; }
152531
- break;
152532
- case 154: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
152533
-{ yymsp[-10].minor.yy95 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy94,yymsp[-5].minor.yy102,yymsp[-1].minor.yy94,yymsp[0].minor.yy102);}
152534
- break;
152535
- case 155: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
152536
-{ yymsp[-7].minor.yy95 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy94,yymsp[-2].minor.yy102,0,0); }
152537
- break;
152538
- case 156: /* upsert ::= ON CONFLICT DO NOTHING */
152539
-{ yymsp[-3].minor.yy95 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
152540
- break;
152541
- case 160: /* idlist_opt ::= LP idlist RP */
152542
-{yymsp[-2].minor.yy76 = yymsp[-1].minor.yy76;}
152543
- break;
152544
- case 161: /* idlist ::= idlist COMMA nm */
152545
-{yymsp[-2].minor.yy76 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy76,&yymsp[0].minor.yy0);}
152546
- break;
152547
- case 162: /* idlist ::= nm */
152548
-{yymsp[0].minor.yy76 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
152549
- break;
152550
- case 163: /* expr ::= LP expr RP */
152551
-{yymsp[-2].minor.yy102 = yymsp[-1].minor.yy102;}
152552
- break;
152553
- case 164: /* expr ::= ID|INDEXED */
152554
- case 165: /* expr ::= JOIN_KW */ yytestcase(yyruleno==165);
152555
-{yymsp[0].minor.yy102=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
152556
- break;
152557
- case 166: /* expr ::= nm DOT nm */
153293
+ case 137: /* nulls ::= */ yytestcase(yyruleno==137);
153294
+{yymsp[1].minor.yy32 = SQLITE_SO_UNDEFINED;}
153295
+ break;
153296
+ case 135: /* nulls ::= NULLS FIRST */
153297
+{yymsp[-1].minor.yy32 = SQLITE_SO_ASC;}
153298
+ break;
153299
+ case 136: /* nulls ::= NULLS LAST */
153300
+{yymsp[-1].minor.yy32 = SQLITE_SO_DESC;}
153301
+ break;
153302
+ case 143: /* limit_opt ::= LIMIT expr */
153303
+{yymsp[-1].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy46,0);}
153304
+ break;
153305
+ case 144: /* limit_opt ::= LIMIT expr OFFSET expr */
153306
+{yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153307
+ break;
153308
+ case 145: /* limit_opt ::= LIMIT expr COMMA expr */
153309
+{yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy46,yymsp[-2].minor.yy46);}
153310
+ break;
153311
+ case 146: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
153312
+{
153313
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy609, &yymsp[-1].minor.yy0);
153314
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy609,yymsp[0].minor.yy46,0,0);
153315
+}
153316
+ break;
153317
+ case 149: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
153318
+{
153319
+ sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy609, &yymsp[-3].minor.yy0);
153320
+ sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy138,"set list");
153321
+ sqlite3Update(pParse,yymsp[-4].minor.yy609,yymsp[-1].minor.yy138,yymsp[0].minor.yy46,yymsp[-5].minor.yy32,0,0,0);
153322
+}
153323
+ break;
153324
+ case 150: /* setlist ::= setlist COMMA nm EQ expr */
153325
+{
153326
+ yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy138, yymsp[0].minor.yy46);
153327
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy138, &yymsp[-2].minor.yy0, 1);
153328
+}
153329
+ break;
153330
+ case 151: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
153331
+{
153332
+ yymsp[-6].minor.yy138 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy138, yymsp[-3].minor.yy406, yymsp[0].minor.yy46);
153333
+}
153334
+ break;
153335
+ case 152: /* setlist ::= nm EQ expr */
153336
+{
153337
+ yylhsminor.yy138 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy46);
153338
+ sqlite3ExprListSetName(pParse, yylhsminor.yy138, &yymsp[-2].minor.yy0, 1);
153339
+}
153340
+ yymsp[-2].minor.yy138 = yylhsminor.yy138;
153341
+ break;
153342
+ case 153: /* setlist ::= LP idlist RP EQ expr */
153343
+{
153344
+ yymsp[-4].minor.yy138 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy406, yymsp[0].minor.yy46);
153345
+}
153346
+ break;
153347
+ case 154: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
153348
+{
153349
+ sqlite3Insert(pParse, yymsp[-3].minor.yy609, yymsp[-1].minor.yy25, yymsp[-2].minor.yy406, yymsp[-5].minor.yy32, yymsp[0].minor.yy288);
153350
+}
153351
+ break;
153352
+ case 155: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
153353
+{
153354
+ sqlite3Insert(pParse, yymsp[-3].minor.yy609, 0, yymsp[-2].minor.yy406, yymsp[-5].minor.yy32, 0);
153355
+}
153356
+ break;
153357
+ case 156: /* upsert ::= */
153358
+{ yymsp[1].minor.yy288 = 0; }
153359
+ break;
153360
+ case 157: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
153361
+{ yymsp[-10].minor.yy288 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy138,yymsp[-5].minor.yy46,yymsp[-1].minor.yy138,yymsp[0].minor.yy46);}
153362
+ break;
153363
+ case 158: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
153364
+{ yymsp[-7].minor.yy288 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy138,yymsp[-2].minor.yy46,0,0); }
153365
+ break;
153366
+ case 159: /* upsert ::= ON CONFLICT DO NOTHING */
153367
+{ yymsp[-3].minor.yy288 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
153368
+ break;
153369
+ case 163: /* idlist_opt ::= LP idlist RP */
153370
+{yymsp[-2].minor.yy406 = yymsp[-1].minor.yy406;}
153371
+ break;
153372
+ case 164: /* idlist ::= idlist COMMA nm */
153373
+{yymsp[-2].minor.yy406 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy406,&yymsp[0].minor.yy0);}
153374
+ break;
153375
+ case 165: /* idlist ::= nm */
153376
+{yymsp[0].minor.yy406 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
153377
+ break;
153378
+ case 166: /* expr ::= LP expr RP */
153379
+{yymsp[-2].minor.yy46 = yymsp[-1].minor.yy46;}
153380
+ break;
153381
+ case 167: /* expr ::= ID|INDEXED */
153382
+ case 168: /* expr ::= JOIN_KW */ yytestcase(yyruleno==168);
153383
+{yymsp[0].minor.yy46=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
153384
+ break;
153385
+ case 169: /* expr ::= nm DOT nm */
152558153386
{
152559153387
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
152560153388
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
152561153389
if( IN_RENAME_OBJECT ){
152562153390
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
152563153391
sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
152564153392
}
152565
- yylhsminor.yy102 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
153393
+ yylhsminor.yy46 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
152566153394
}
152567
- yymsp[-2].minor.yy102 = yylhsminor.yy102;
153395
+ yymsp[-2].minor.yy46 = yylhsminor.yy46;
152568153396
break;
152569
- case 167: /* expr ::= nm DOT nm DOT nm */
153397
+ case 170: /* expr ::= nm DOT nm DOT nm */
152570153398
{
152571153399
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
152572153400
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
152573153401
Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
152574153402
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
152575153403
if( IN_RENAME_OBJECT ){
152576153404
sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
152577153405
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
152578153406
}
152579
- yylhsminor.yy102 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
152580
-}
152581
- yymsp[-4].minor.yy102 = yylhsminor.yy102;
152582
- break;
152583
- case 168: /* term ::= NULL|FLOAT|BLOB */
152584
- case 169: /* term ::= STRING */ yytestcase(yyruleno==169);
152585
-{yymsp[0].minor.yy102=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
152586
- break;
152587
- case 170: /* term ::= INTEGER */
152588
-{
152589
- yylhsminor.yy102 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
152590
-}
152591
- yymsp[0].minor.yy102 = yylhsminor.yy102;
152592
- break;
152593
- case 171: /* expr ::= VARIABLE */
153407
+ yylhsminor.yy46 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
153408
+}
153409
+ yymsp[-4].minor.yy46 = yylhsminor.yy46;
153410
+ break;
153411
+ case 171: /* term ::= NULL|FLOAT|BLOB */
153412
+ case 172: /* term ::= STRING */ yytestcase(yyruleno==172);
153413
+{yymsp[0].minor.yy46=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
153414
+ break;
153415
+ case 173: /* term ::= INTEGER */
153416
+{
153417
+ yylhsminor.yy46 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
153418
+}
153419
+ yymsp[0].minor.yy46 = yylhsminor.yy46;
153420
+ break;
153421
+ case 174: /* expr ::= VARIABLE */
152594153422
{
152595153423
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
152596153424
u32 n = yymsp[0].minor.yy0.n;
152597
- yymsp[0].minor.yy102 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
152598
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy102, n);
153425
+ yymsp[0].minor.yy46 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
153426
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy46, n);
152599153427
}else{
152600153428
/* When doing a nested parse, one can include terms in an expression
152601153429
** that look like this: #1 #2 ... These terms refer to registers
152602153430
** in the virtual machine. #N is the N-th register. */
152603153431
Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
152604153432
assert( t.n>=2 );
152605153433
if( pParse->nested==0 ){
152606153434
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
152607
- yymsp[0].minor.yy102 = 0;
152608
- }else{
152609
- yymsp[0].minor.yy102 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
152610
- if( yymsp[0].minor.yy102 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy102->iTable);
152611
- }
152612
- }
152613
-}
152614
- break;
152615
- case 172: /* expr ::= expr COLLATE ID|STRING */
152616
-{
152617
- yymsp[-2].minor.yy102 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy102, &yymsp[0].minor.yy0, 1);
152618
-}
152619
- break;
152620
- case 173: /* expr ::= CAST LP expr AS typetoken RP */
152621
-{
152622
- yymsp[-5].minor.yy102 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
152623
- sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy102, yymsp[-3].minor.yy102, 0);
152624
-}
152625
- break;
152626
- case 174: /* expr ::= ID|INDEXED LP distinct exprlist RP */
152627
-{
152628
- yylhsminor.yy102 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy94, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy100);
152629
-}
152630
- yymsp[-4].minor.yy102 = yylhsminor.yy102;
152631
- break;
152632
- case 175: /* expr ::= ID|INDEXED LP STAR RP */
152633
-{
152634
- yylhsminor.yy102 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
152635
-}
152636
- yymsp[-3].minor.yy102 = yylhsminor.yy102;
152637
- break;
152638
- case 176: /* expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
152639
-{
152640
- yylhsminor.yy102 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy94, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy100);
152641
- sqlite3WindowAttach(pParse, yylhsminor.yy102, yymsp[0].minor.yy379);
152642
-}
152643
- yymsp[-5].minor.yy102 = yylhsminor.yy102;
152644
- break;
152645
- case 177: /* expr ::= ID|INDEXED LP STAR RP over_clause */
152646
-{
152647
- yylhsminor.yy102 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
152648
- sqlite3WindowAttach(pParse, yylhsminor.yy102, yymsp[0].minor.yy379);
152649
-}
152650
- yymsp[-4].minor.yy102 = yylhsminor.yy102;
152651
- break;
152652
- case 178: /* term ::= CTIME_KW */
152653
-{
152654
- yylhsminor.yy102 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
152655
-}
152656
- yymsp[0].minor.yy102 = yylhsminor.yy102;
152657
- break;
152658
- case 179: /* expr ::= LP nexprlist COMMA expr RP */
152659
-{
152660
- ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy94, yymsp[-1].minor.yy102);
152661
- yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
152662
- if( yymsp[-4].minor.yy102 ){
152663
- yymsp[-4].minor.yy102->x.pList = pList;
153435
+ yymsp[0].minor.yy46 = 0;
153436
+ }else{
153437
+ yymsp[0].minor.yy46 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
153438
+ if( yymsp[0].minor.yy46 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy46->iTable);
153439
+ }
153440
+ }
153441
+}
153442
+ break;
153443
+ case 175: /* expr ::= expr COLLATE ID|STRING */
153444
+{
153445
+ yymsp[-2].minor.yy46 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy46, &yymsp[0].minor.yy0, 1);
153446
+}
153447
+ break;
153448
+ case 176: /* expr ::= CAST LP expr AS typetoken RP */
153449
+{
153450
+ yymsp[-5].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
153451
+ sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy46, yymsp[-3].minor.yy46, 0);
153452
+}
153453
+ break;
153454
+ case 177: /* expr ::= ID|INDEXED LP distinct exprlist RP */
153455
+{
153456
+ yylhsminor.yy46 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy138, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy32);
153457
+}
153458
+ yymsp[-4].minor.yy46 = yylhsminor.yy46;
153459
+ break;
153460
+ case 178: /* expr ::= ID|INDEXED LP STAR RP */
153461
+{
153462
+ yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
153463
+}
153464
+ yymsp[-3].minor.yy46 = yylhsminor.yy46;
153465
+ break;
153466
+ case 179: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
153467
+{
153468
+ yylhsminor.yy46 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy138, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy32);
153469
+ sqlite3WindowAttach(pParse, yylhsminor.yy46, yymsp[0].minor.yy455);
153470
+}
153471
+ yymsp[-5].minor.yy46 = yylhsminor.yy46;
153472
+ break;
153473
+ case 180: /* expr ::= ID|INDEXED LP STAR RP filter_over */
153474
+{
153475
+ yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
153476
+ sqlite3WindowAttach(pParse, yylhsminor.yy46, yymsp[0].minor.yy455);
153477
+}
153478
+ yymsp[-4].minor.yy46 = yylhsminor.yy46;
153479
+ break;
153480
+ case 181: /* term ::= CTIME_KW */
153481
+{
153482
+ yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
153483
+}
153484
+ yymsp[0].minor.yy46 = yylhsminor.yy46;
153485
+ break;
153486
+ case 182: /* expr ::= LP nexprlist COMMA expr RP */
153487
+{
153488
+ ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy138, yymsp[-1].minor.yy46);
153489
+ yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
153490
+ if( yymsp[-4].minor.yy46 ){
153491
+ yymsp[-4].minor.yy46->x.pList = pList;
152664153492
}else{
152665153493
sqlite3ExprListDelete(pParse->db, pList);
152666153494
}
152667153495
}
152668153496
break;
152669
- case 180: /* expr ::= expr AND expr */
152670
-{yymsp[-2].minor.yy102=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy102,yymsp[0].minor.yy102);}
152671
- break;
152672
- case 181: /* expr ::= expr OR expr */
152673
- case 182: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==182);
152674
- case 183: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==183);
152675
- case 184: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==184);
152676
- case 185: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==185);
152677
- case 186: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==186);
152678
- case 187: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==187);
152679
-{yymsp[-2].minor.yy102=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy102,yymsp[0].minor.yy102);}
152680
- break;
152681
- case 188: /* likeop ::= NOT LIKE_KW|MATCH */
153497
+ case 183: /* expr ::= expr AND expr */
153498
+{yymsp[-2].minor.yy46=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153499
+ break;
153500
+ case 184: /* expr ::= expr OR expr */
153501
+ case 185: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==185);
153502
+ case 186: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==186);
153503
+ case 187: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==187);
153504
+ case 188: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==188);
153505
+ case 189: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==189);
153506
+ case 190: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==190);
153507
+{yymsp[-2].minor.yy46=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153508
+ break;
153509
+ case 191: /* likeop ::= NOT LIKE_KW|MATCH */
152682153510
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
152683153511
break;
152684
- case 189: /* expr ::= expr likeop expr */
153512
+ case 192: /* expr ::= expr likeop expr */
152685153513
{
152686153514
ExprList *pList;
152687153515
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
152688153516
yymsp[-1].minor.yy0.n &= 0x7fffffff;
152689
- pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy102);
152690
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy102);
152691
- yymsp[-2].minor.yy102 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
152692
- if( bNot ) yymsp[-2].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy102, 0);
152693
- if( yymsp[-2].minor.yy102 ) yymsp[-2].minor.yy102->flags |= EP_InfixFunc;
153517
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy46);
153518
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy46);
153519
+ yymsp[-2].minor.yy46 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
153520
+ if( bNot ) yymsp[-2].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy46, 0);
153521
+ if( yymsp[-2].minor.yy46 ) yymsp[-2].minor.yy46->flags |= EP_InfixFunc;
152694153522
}
152695153523
break;
152696
- case 190: /* expr ::= expr likeop expr ESCAPE expr */
153524
+ case 193: /* expr ::= expr likeop expr ESCAPE expr */
152697153525
{
152698153526
ExprList *pList;
152699153527
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
152700153528
yymsp[-3].minor.yy0.n &= 0x7fffffff;
152701
- pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy102);
152702
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy102);
152703
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy102);
152704
- yymsp[-4].minor.yy102 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
152705
- if( bNot ) yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy102, 0);
152706
- if( yymsp[-4].minor.yy102 ) yymsp[-4].minor.yy102->flags |= EP_InfixFunc;
152707
-}
152708
- break;
152709
- case 191: /* expr ::= expr ISNULL|NOTNULL */
152710
-{yymsp[-1].minor.yy102 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy102,0);}
152711
- break;
152712
- case 192: /* expr ::= expr NOT NULL */
152713
-{yymsp[-2].minor.yy102 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy102,0);}
152714
- break;
152715
- case 193: /* expr ::= expr IS expr */
152716
-{
152717
- yymsp[-2].minor.yy102 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy102,yymsp[0].minor.yy102);
152718
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy102, yymsp[-2].minor.yy102, TK_ISNULL);
152719
-}
152720
- break;
152721
- case 194: /* expr ::= expr IS NOT expr */
152722
-{
152723
- yymsp[-3].minor.yy102 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy102,yymsp[0].minor.yy102);
152724
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy102, yymsp[-3].minor.yy102, TK_NOTNULL);
152725
-}
152726
- break;
152727
- case 195: /* expr ::= NOT expr */
152728
- case 196: /* expr ::= BITNOT expr */ yytestcase(yyruleno==196);
152729
-{yymsp[-1].minor.yy102 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy102, 0);/*A-overwrites-B*/}
152730
- break;
152731
- case 197: /* expr ::= PLUS|MINUS expr */
152732
-{
152733
- yymsp[-1].minor.yy102 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy102, 0);
153529
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153530
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy46);
153531
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy46);
153532
+ yymsp[-4].minor.yy46 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
153533
+ if( bNot ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153534
+ if( yymsp[-4].minor.yy46 ) yymsp[-4].minor.yy46->flags |= EP_InfixFunc;
153535
+}
153536
+ break;
153537
+ case 194: /* expr ::= expr ISNULL|NOTNULL */
153538
+{yymsp[-1].minor.yy46 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy46,0);}
153539
+ break;
153540
+ case 195: /* expr ::= expr NOT NULL */
153541
+{yymsp[-2].minor.yy46 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy46,0);}
153542
+ break;
153543
+ case 196: /* expr ::= expr IS expr */
153544
+{
153545
+ yymsp[-2].minor.yy46 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);
153546
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy46, yymsp[-2].minor.yy46, TK_ISNULL);
153547
+}
153548
+ break;
153549
+ case 197: /* expr ::= expr IS NOT expr */
153550
+{
153551
+ yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy46,yymsp[0].minor.yy46);
153552
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy46, yymsp[-3].minor.yy46, TK_NOTNULL);
153553
+}
153554
+ break;
153555
+ case 198: /* expr ::= NOT expr */
153556
+ case 199: /* expr ::= BITNOT expr */ yytestcase(yyruleno==199);
153557
+{yymsp[-1].minor.yy46 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy46, 0);/*A-overwrites-B*/}
153558
+ break;
153559
+ case 200: /* expr ::= PLUS|MINUS expr */
153560
+{
153561
+ yymsp[-1].minor.yy46 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy46, 0);
152734153562
/*A-overwrites-B*/
152735153563
}
152736153564
break;
152737
- case 198: /* between_op ::= BETWEEN */
152738
- case 201: /* in_op ::= IN */ yytestcase(yyruleno==201);
152739
-{yymsp[0].minor.yy100 = 0;}
152740
- break;
152741
- case 200: /* expr ::= expr between_op expr AND expr */
152742
-{
152743
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy102);
152744
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy102);
152745
- yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy102, 0);
152746
- if( yymsp[-4].minor.yy102 ){
152747
- yymsp[-4].minor.yy102->x.pList = pList;
153565
+ case 201: /* between_op ::= BETWEEN */
153566
+ case 204: /* in_op ::= IN */ yytestcase(yyruleno==204);
153567
+{yymsp[0].minor.yy32 = 0;}
153568
+ break;
153569
+ case 203: /* expr ::= expr between_op expr AND expr */
153570
+{
153571
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153572
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy46);
153573
+ yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy46, 0);
153574
+ if( yymsp[-4].minor.yy46 ){
153575
+ yymsp[-4].minor.yy46->x.pList = pList;
152748153576
}else{
152749153577
sqlite3ExprListDelete(pParse->db, pList);
152750153578
}
152751
- if( yymsp[-3].minor.yy100 ) yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy102, 0);
153579
+ if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
152752153580
}
152753153581
break;
152754
- case 203: /* expr ::= expr in_op LP exprlist RP */
153582
+ case 206: /* expr ::= expr in_op LP exprlist RP */
152755153583
{
152756
- if( yymsp[-1].minor.yy94==0 ){
153584
+ if( yymsp[-1].minor.yy138==0 ){
152757153585
/* Expressions of the form
152758153586
**
152759153587
** expr1 IN ()
152760153588
** expr1 NOT IN ()
152761153589
**
152762153590
** simplify to constants 0 (false) and 1 (true), respectively,
152763153591
** regardless of the value of expr1.
152764153592
*/
152765
- sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy102);
152766
- yymsp[-4].minor.yy102 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy100],1);
152767
- }else if( yymsp[-1].minor.yy94->nExpr==1 ){
152768
- /* Expressions of the form:
152769
- **
152770
- ** expr1 IN (?1)
152771
- ** expr1 NOT IN (?2)
152772
- **
152773
- ** with exactly one value on the RHS can be simplified to something
152774
- ** like this:
152775
- **
152776
- ** expr1 == ?1
152777
- ** expr1 <> ?2
152778
- **
152779
- ** But, the RHS of the == or <> is marked with the EP_Generic flag
152780
- ** so that it may not contribute to the computation of comparison
152781
- ** affinity or the collating sequence to use for comparison. Otherwise,
152782
- ** the semantics would be subtly different from IN or NOT IN.
152783
- */
152784
- Expr *pRHS = yymsp[-1].minor.yy94->a[0].pExpr;
152785
- yymsp[-1].minor.yy94->a[0].pExpr = 0;
152786
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy94);
152787
- /* pRHS cannot be NULL because a malloc error would have been detected
152788
- ** before now and control would have never reached this point */
152789
- if( ALWAYS(pRHS) ){
152790
- pRHS->flags &= ~EP_Collate;
152791
- pRHS->flags |= EP_Generic;
152792
- }
152793
- yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, yymsp[-3].minor.yy100 ? TK_NE : TK_EQ, yymsp[-4].minor.yy102, pRHS);
152794
- }else{
152795
- yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy102, 0);
152796
- if( yymsp[-4].minor.yy102 ){
152797
- yymsp[-4].minor.yy102->x.pList = yymsp[-1].minor.yy94;
152798
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy102);
152799
- }else{
152800
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy94);
152801
- }
152802
- if( yymsp[-3].minor.yy100 ) yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy102, 0);
152803
- }
152804
- }
152805
- break;
152806
- case 204: /* expr ::= LP select RP */
152807
-{
152808
- yymsp[-2].minor.yy102 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
152809
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy102, yymsp[-1].minor.yy391);
152810
- }
152811
- break;
152812
- case 205: /* expr ::= expr in_op LP select RP */
152813
-{
152814
- yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy102, 0);
152815
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy102, yymsp[-1].minor.yy391);
152816
- if( yymsp[-3].minor.yy100 ) yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy102, 0);
152817
- }
152818
- break;
152819
- case 206: /* expr ::= expr in_op nm dbnm paren_exprlist */
153593
+ sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy46);
153594
+ yymsp[-4].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy32],1);
153595
+ }else{
153596
+ yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153597
+ if( yymsp[-4].minor.yy46 ){
153598
+ yymsp[-4].minor.yy46->x.pList = yymsp[-1].minor.yy138;
153599
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy46);
153600
+ }else{
153601
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy138);
153602
+ }
153603
+ if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153604
+ }
153605
+ }
153606
+ break;
153607
+ case 207: /* expr ::= LP select RP */
153608
+{
153609
+ yymsp[-2].minor.yy46 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
153610
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy46, yymsp[-1].minor.yy25);
153611
+ }
153612
+ break;
153613
+ case 208: /* expr ::= expr in_op LP select RP */
153614
+{
153615
+ yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153616
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy46, yymsp[-1].minor.yy25);
153617
+ if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153618
+ }
153619
+ break;
153620
+ case 209: /* expr ::= expr in_op nm dbnm paren_exprlist */
152820153621
{
152821153622
SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
152822153623
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
152823
- if( yymsp[0].minor.yy94 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy94);
152824
- yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy102, 0);
152825
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy102, pSelect);
152826
- if( yymsp[-3].minor.yy100 ) yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy102, 0);
153624
+ if( yymsp[0].minor.yy138 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy138);
153625
+ yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153626
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy46, pSelect);
153627
+ if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
152827153628
}
152828153629
break;
152829
- case 207: /* expr ::= EXISTS LP select RP */
153630
+ case 210: /* expr ::= EXISTS LP select RP */
152830153631
{
152831153632
Expr *p;
152832
- p = yymsp[-3].minor.yy102 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
152833
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy391);
152834
- }
152835
- break;
152836
- case 208: /* expr ::= CASE case_operand case_exprlist case_else END */
152837
-{
152838
- yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy102, 0);
152839
- if( yymsp[-4].minor.yy102 ){
152840
- yymsp[-4].minor.yy102->x.pList = yymsp[-1].minor.yy102 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy94,yymsp[-1].minor.yy102) : yymsp[-2].minor.yy94;
152841
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy102);
152842
- }else{
152843
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy94);
152844
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy102);
152845
- }
152846
-}
152847
- break;
152848
- case 209: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
152849
-{
152850
- yymsp[-4].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy94, yymsp[-2].minor.yy102);
152851
- yymsp[-4].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy94, yymsp[0].minor.yy102);
152852
-}
152853
- break;
152854
- case 210: /* case_exprlist ::= WHEN expr THEN expr */
152855
-{
152856
- yymsp[-3].minor.yy94 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy102);
152857
- yymsp[-3].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy94, yymsp[0].minor.yy102);
152858
-}
152859
- break;
152860
- case 213: /* case_operand ::= expr */
152861
-{yymsp[0].minor.yy102 = yymsp[0].minor.yy102; /*A-overwrites-X*/}
152862
- break;
152863
- case 216: /* nexprlist ::= nexprlist COMMA expr */
152864
-{yymsp[-2].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy94,yymsp[0].minor.yy102);}
152865
- break;
152866
- case 217: /* nexprlist ::= expr */
152867
-{yymsp[0].minor.yy94 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy102); /*A-overwrites-Y*/}
152868
- break;
152869
- case 219: /* paren_exprlist ::= LP exprlist RP */
152870
- case 224: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==224);
152871
-{yymsp[-2].minor.yy94 = yymsp[-1].minor.yy94;}
152872
- break;
152873
- case 220: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
153633
+ p = yymsp[-3].minor.yy46 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
153634
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy25);
153635
+ }
153636
+ break;
153637
+ case 211: /* expr ::= CASE case_operand case_exprlist case_else END */
153638
+{
153639
+ yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy46, 0);
153640
+ if( yymsp[-4].minor.yy46 ){
153641
+ yymsp[-4].minor.yy46->x.pList = yymsp[-1].minor.yy46 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy138,yymsp[-1].minor.yy46) : yymsp[-2].minor.yy138;
153642
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy46);
153643
+ }else{
153644
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy138);
153645
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy46);
153646
+ }
153647
+}
153648
+ break;
153649
+ case 212: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
153650
+{
153651
+ yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, yymsp[-2].minor.yy46);
153652
+ yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, yymsp[0].minor.yy46);
153653
+}
153654
+ break;
153655
+ case 213: /* case_exprlist ::= WHEN expr THEN expr */
153656
+{
153657
+ yymsp[-3].minor.yy138 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153658
+ yymsp[-3].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy138, yymsp[0].minor.yy46);
153659
+}
153660
+ break;
153661
+ case 216: /* case_operand ::= expr */
153662
+{yymsp[0].minor.yy46 = yymsp[0].minor.yy46; /*A-overwrites-X*/}
153663
+ break;
153664
+ case 219: /* nexprlist ::= nexprlist COMMA expr */
153665
+{yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy138,yymsp[0].minor.yy46);}
153666
+ break;
153667
+ case 220: /* nexprlist ::= expr */
153668
+{yymsp[0].minor.yy138 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy46); /*A-overwrites-Y*/}
153669
+ break;
153670
+ case 222: /* paren_exprlist ::= LP exprlist RP */
153671
+ case 227: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==227);
153672
+{yymsp[-2].minor.yy138 = yymsp[-1].minor.yy138;}
153673
+ break;
153674
+ case 223: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
152874153675
{
152875153676
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
152876
- sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy94, yymsp[-10].minor.yy100,
152877
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy102, SQLITE_SO_ASC, yymsp[-8].minor.yy100, SQLITE_IDXTYPE_APPDEF);
153677
+ sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy138, yymsp[-10].minor.yy32,
153678
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy46, SQLITE_SO_ASC, yymsp[-8].minor.yy32, SQLITE_IDXTYPE_APPDEF);
152878153679
if( IN_RENAME_OBJECT && pParse->pNewIndex ){
152879153680
sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
152880153681
}
152881153682
}
152882153683
break;
152883
- case 221: /* uniqueflag ::= UNIQUE */
152884
- case 263: /* raisetype ::= ABORT */ yytestcase(yyruleno==263);
152885
-{yymsp[0].minor.yy100 = OE_Abort;}
152886
- break;
152887
- case 222: /* uniqueflag ::= */
152888
-{yymsp[1].minor.yy100 = OE_None;}
152889
- break;
152890
- case 225: /* eidlist ::= eidlist COMMA nm collate sortorder */
152891
-{
152892
- yymsp[-4].minor.yy94 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy94, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy100, yymsp[0].minor.yy100);
152893
-}
152894
- break;
152895
- case 226: /* eidlist ::= nm collate sortorder */
152896
-{
152897
- yymsp[-2].minor.yy94 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy100, yymsp[0].minor.yy100); /*A-overwrites-Y*/
152898
-}
152899
- break;
152900
- case 229: /* cmd ::= DROP INDEX ifexists fullname */
152901
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy407, yymsp[-1].minor.yy100);}
152902
- break;
152903
- case 230: /* cmd ::= VACUUM vinto */
152904
-{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy102);}
152905
- break;
152906
- case 231: /* cmd ::= VACUUM nm vinto */
152907
-{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy102);}
152908
- break;
152909
- case 234: /* cmd ::= PRAGMA nm dbnm */
153684
+ case 224: /* uniqueflag ::= UNIQUE */
153685
+ case 266: /* raisetype ::= ABORT */ yytestcase(yyruleno==266);
153686
+{yymsp[0].minor.yy32 = OE_Abort;}
153687
+ break;
153688
+ case 225: /* uniqueflag ::= */
153689
+{yymsp[1].minor.yy32 = OE_None;}
153690
+ break;
153691
+ case 228: /* eidlist ::= eidlist COMMA nm collate sortorder */
153692
+{
153693
+ yymsp[-4].minor.yy138 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy138, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy32, yymsp[0].minor.yy32);
153694
+}
153695
+ break;
153696
+ case 229: /* eidlist ::= nm collate sortorder */
153697
+{
153698
+ yymsp[-2].minor.yy138 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy32, yymsp[0].minor.yy32); /*A-overwrites-Y*/
153699
+}
153700
+ break;
153701
+ case 232: /* cmd ::= DROP INDEX ifexists fullname */
153702
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy609, yymsp[-1].minor.yy32);}
153703
+ break;
153704
+ case 233: /* cmd ::= VACUUM vinto */
153705
+{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy46);}
153706
+ break;
153707
+ case 234: /* cmd ::= VACUUM nm vinto */
153708
+{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy46);}
153709
+ break;
153710
+ case 237: /* cmd ::= PRAGMA nm dbnm */
152910153711
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
152911153712
break;
152912
- case 235: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
153713
+ case 238: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
152913153714
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
152914153715
break;
152915
- case 236: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
153716
+ case 239: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
152916153717
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
152917153718
break;
152918
- case 237: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
153719
+ case 240: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
152919153720
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
152920153721
break;
152921
- case 238: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
153722
+ case 241: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
152922153723
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
152923153724
break;
152924
- case 241: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
153725
+ case 244: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
152925153726
{
152926153727
Token all;
152927153728
all.z = yymsp[-3].minor.yy0.z;
152928153729
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
152929
- sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy11, &all);
153730
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy527, &all);
152930153731
}
152931153732
break;
152932
- case 242: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
153733
+ case 245: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
152933153734
{
152934
- sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy100, yymsp[-4].minor.yy298.a, yymsp[-4].minor.yy298.b, yymsp[-2].minor.yy407, yymsp[0].minor.yy102, yymsp[-10].minor.yy100, yymsp[-8].minor.yy100);
153735
+ sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy32, yymsp[-4].minor.yy572.a, yymsp[-4].minor.yy572.b, yymsp[-2].minor.yy609, yymsp[0].minor.yy46, yymsp[-10].minor.yy32, yymsp[-8].minor.yy32);
152935153736
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
152936153737
}
152937153738
break;
152938
- case 243: /* trigger_time ::= BEFORE|AFTER */
152939
-{ yymsp[0].minor.yy100 = yymsp[0].major; /*A-overwrites-X*/ }
152940
- break;
152941
- case 244: /* trigger_time ::= INSTEAD OF */
152942
-{ yymsp[-1].minor.yy100 = TK_INSTEAD;}
152943
- break;
152944
- case 245: /* trigger_time ::= */
152945
-{ yymsp[1].minor.yy100 = TK_BEFORE; }
152946
- break;
152947
- case 246: /* trigger_event ::= DELETE|INSERT */
152948
- case 247: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==247);
152949
-{yymsp[0].minor.yy298.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy298.b = 0;}
152950
- break;
152951
- case 248: /* trigger_event ::= UPDATE OF idlist */
152952
-{yymsp[-2].minor.yy298.a = TK_UPDATE; yymsp[-2].minor.yy298.b = yymsp[0].minor.yy76;}
152953
- break;
152954
- case 249: /* when_clause ::= */
152955
- case 268: /* key_opt ::= */ yytestcase(yyruleno==268);
152956
- case 316: /* filter_opt ::= */ yytestcase(yyruleno==316);
152957
-{ yymsp[1].minor.yy102 = 0; }
152958
- break;
152959
- case 250: /* when_clause ::= WHEN expr */
152960
- case 269: /* key_opt ::= KEY expr */ yytestcase(yyruleno==269);
152961
-{ yymsp[-1].minor.yy102 = yymsp[0].minor.yy102; }
152962
- break;
152963
- case 251: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
152964
-{
152965
- assert( yymsp[-2].minor.yy11!=0 );
152966
- yymsp[-2].minor.yy11->pLast->pNext = yymsp[-1].minor.yy11;
152967
- yymsp[-2].minor.yy11->pLast = yymsp[-1].minor.yy11;
152968
-}
152969
- break;
152970
- case 252: /* trigger_cmd_list ::= trigger_cmd SEMI */
152971
-{
152972
- assert( yymsp[-1].minor.yy11!=0 );
152973
- yymsp[-1].minor.yy11->pLast = yymsp[-1].minor.yy11;
152974
-}
152975
- break;
152976
- case 253: /* trnm ::= nm DOT nm */
153739
+ case 246: /* trigger_time ::= BEFORE|AFTER */
153740
+{ yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-X*/ }
153741
+ break;
153742
+ case 247: /* trigger_time ::= INSTEAD OF */
153743
+{ yymsp[-1].minor.yy32 = TK_INSTEAD;}
153744
+ break;
153745
+ case 248: /* trigger_time ::= */
153746
+{ yymsp[1].minor.yy32 = TK_BEFORE; }
153747
+ break;
153748
+ case 249: /* trigger_event ::= DELETE|INSERT */
153749
+ case 250: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==250);
153750
+{yymsp[0].minor.yy572.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy572.b = 0;}
153751
+ break;
153752
+ case 251: /* trigger_event ::= UPDATE OF idlist */
153753
+{yymsp[-2].minor.yy572.a = TK_UPDATE; yymsp[-2].minor.yy572.b = yymsp[0].minor.yy406;}
153754
+ break;
153755
+ case 252: /* when_clause ::= */
153756
+ case 271: /* key_opt ::= */ yytestcase(yyruleno==271);
153757
+{ yymsp[1].minor.yy46 = 0; }
153758
+ break;
153759
+ case 253: /* when_clause ::= WHEN expr */
153760
+ case 272: /* key_opt ::= KEY expr */ yytestcase(yyruleno==272);
153761
+{ yymsp[-1].minor.yy46 = yymsp[0].minor.yy46; }
153762
+ break;
153763
+ case 254: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
153764
+{
153765
+ assert( yymsp[-2].minor.yy527!=0 );
153766
+ yymsp[-2].minor.yy527->pLast->pNext = yymsp[-1].minor.yy527;
153767
+ yymsp[-2].minor.yy527->pLast = yymsp[-1].minor.yy527;
153768
+}
153769
+ break;
153770
+ case 255: /* trigger_cmd_list ::= trigger_cmd SEMI */
153771
+{
153772
+ assert( yymsp[-1].minor.yy527!=0 );
153773
+ yymsp[-1].minor.yy527->pLast = yymsp[-1].minor.yy527;
153774
+}
153775
+ break;
153776
+ case 256: /* trnm ::= nm DOT nm */
152977153777
{
152978153778
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
152979153779
sqlite3ErrorMsg(pParse,
152980153780
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
152981153781
"statements within triggers");
152982153782
}
152983153783
break;
152984
- case 254: /* tridxby ::= INDEXED BY nm */
153784
+ case 257: /* tridxby ::= INDEXED BY nm */
152985153785
{
152986153786
sqlite3ErrorMsg(pParse,
152987153787
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
152988153788
"within triggers");
152989153789
}
152990153790
break;
152991
- case 255: /* tridxby ::= NOT INDEXED */
153791
+ case 258: /* tridxby ::= NOT INDEXED */
152992153792
{
152993153793
sqlite3ErrorMsg(pParse,
152994153794
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
152995153795
"within triggers");
152996153796
}
152997153797
break;
152998
- case 256: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
152999
-{yylhsminor.yy11 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy94, yymsp[-1].minor.yy102, yymsp[-6].minor.yy100, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy528);}
153000
- yymsp[-7].minor.yy11 = yylhsminor.yy11;
153001
- break;
153002
- case 257: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
153003
-{
153004
- yylhsminor.yy11 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy76,yymsp[-2].minor.yy391,yymsp[-6].minor.yy100,yymsp[-1].minor.yy95,yymsp[-7].minor.yy528,yymsp[0].minor.yy528);/*yylhsminor.yy11-overwrites-yymsp[-6].minor.yy100*/
153005
-}
153006
- yymsp[-7].minor.yy11 = yylhsminor.yy11;
153007
- break;
153008
- case 258: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
153009
-{yylhsminor.yy11 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy102, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy528);}
153010
- yymsp[-5].minor.yy11 = yylhsminor.yy11;
153011
- break;
153012
- case 259: /* trigger_cmd ::= scanpt select scanpt */
153013
-{yylhsminor.yy11 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy391, yymsp[-2].minor.yy528, yymsp[0].minor.yy528); /*yylhsminor.yy11-overwrites-yymsp[-1].minor.yy391*/}
153014
- yymsp[-2].minor.yy11 = yylhsminor.yy11;
153015
- break;
153016
- case 260: /* expr ::= RAISE LP IGNORE RP */
153017
-{
153018
- yymsp[-3].minor.yy102 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
153019
- if( yymsp[-3].minor.yy102 ){
153020
- yymsp[-3].minor.yy102->affinity = OE_Ignore;
153021
- }
153022
-}
153023
- break;
153024
- case 261: /* expr ::= RAISE LP raisetype COMMA nm RP */
153025
-{
153026
- yymsp[-5].minor.yy102 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
153027
- if( yymsp[-5].minor.yy102 ) {
153028
- yymsp[-5].minor.yy102->affinity = (char)yymsp[-3].minor.yy100;
153029
- }
153030
-}
153031
- break;
153032
- case 262: /* raisetype ::= ROLLBACK */
153033
-{yymsp[0].minor.yy100 = OE_Rollback;}
153034
- break;
153035
- case 264: /* raisetype ::= FAIL */
153036
-{yymsp[0].minor.yy100 = OE_Fail;}
153037
- break;
153038
- case 265: /* cmd ::= DROP TRIGGER ifexists fullname */
153039
-{
153040
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy407,yymsp[-1].minor.yy100);
153041
-}
153042
- break;
153043
- case 266: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
153044
-{
153045
- sqlite3Attach(pParse, yymsp[-3].minor.yy102, yymsp[-1].minor.yy102, yymsp[0].minor.yy102);
153046
-}
153047
- break;
153048
- case 267: /* cmd ::= DETACH database_kw_opt expr */
153049
-{
153050
- sqlite3Detach(pParse, yymsp[0].minor.yy102);
153051
-}
153052
- break;
153053
- case 270: /* cmd ::= REINDEX */
153798
+ case 259: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
153799
+{yylhsminor.yy527 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy138, yymsp[-1].minor.yy46, yymsp[-6].minor.yy32, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy8);}
153800
+ yymsp[-7].minor.yy527 = yylhsminor.yy527;
153801
+ break;
153802
+ case 260: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
153803
+{
153804
+ yylhsminor.yy527 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy406,yymsp[-2].minor.yy25,yymsp[-6].minor.yy32,yymsp[-1].minor.yy288,yymsp[-7].minor.yy8,yymsp[0].minor.yy8);/*yylhsminor.yy527-overwrites-yymsp[-6].minor.yy32*/
153805
+}
153806
+ yymsp[-7].minor.yy527 = yylhsminor.yy527;
153807
+ break;
153808
+ case 261: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
153809
+{yylhsminor.yy527 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy46, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy8);}
153810
+ yymsp[-5].minor.yy527 = yylhsminor.yy527;
153811
+ break;
153812
+ case 262: /* trigger_cmd ::= scanpt select scanpt */
153813
+{yylhsminor.yy527 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy25, yymsp[-2].minor.yy8, yymsp[0].minor.yy8); /*yylhsminor.yy527-overwrites-yymsp[-1].minor.yy25*/}
153814
+ yymsp[-2].minor.yy527 = yylhsminor.yy527;
153815
+ break;
153816
+ case 263: /* expr ::= RAISE LP IGNORE RP */
153817
+{
153818
+ yymsp[-3].minor.yy46 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
153819
+ if( yymsp[-3].minor.yy46 ){
153820
+ yymsp[-3].minor.yy46->affExpr = OE_Ignore;
153821
+ }
153822
+}
153823
+ break;
153824
+ case 264: /* expr ::= RAISE LP raisetype COMMA nm RP */
153825
+{
153826
+ yymsp[-5].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
153827
+ if( yymsp[-5].minor.yy46 ) {
153828
+ yymsp[-5].minor.yy46->affExpr = (char)yymsp[-3].minor.yy32;
153829
+ }
153830
+}
153831
+ break;
153832
+ case 265: /* raisetype ::= ROLLBACK */
153833
+{yymsp[0].minor.yy32 = OE_Rollback;}
153834
+ break;
153835
+ case 267: /* raisetype ::= FAIL */
153836
+{yymsp[0].minor.yy32 = OE_Fail;}
153837
+ break;
153838
+ case 268: /* cmd ::= DROP TRIGGER ifexists fullname */
153839
+{
153840
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy609,yymsp[-1].minor.yy32);
153841
+}
153842
+ break;
153843
+ case 269: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
153844
+{
153845
+ sqlite3Attach(pParse, yymsp[-3].minor.yy46, yymsp[-1].minor.yy46, yymsp[0].minor.yy46);
153846
+}
153847
+ break;
153848
+ case 270: /* cmd ::= DETACH database_kw_opt expr */
153849
+{
153850
+ sqlite3Detach(pParse, yymsp[0].minor.yy46);
153851
+}
153852
+ break;
153853
+ case 273: /* cmd ::= REINDEX */
153054153854
{sqlite3Reindex(pParse, 0, 0);}
153055153855
break;
153056
- case 271: /* cmd ::= REINDEX nm dbnm */
153856
+ case 274: /* cmd ::= REINDEX nm dbnm */
153057153857
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
153058153858
break;
153059
- case 272: /* cmd ::= ANALYZE */
153859
+ case 275: /* cmd ::= ANALYZE */
153060153860
{sqlite3Analyze(pParse, 0, 0);}
153061153861
break;
153062
- case 273: /* cmd ::= ANALYZE nm dbnm */
153862
+ case 276: /* cmd ::= ANALYZE nm dbnm */
153063153863
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
153064153864
break;
153065
- case 274: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
153865
+ case 277: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
153066153866
{
153067
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy407,&yymsp[0].minor.yy0);
153867
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy609,&yymsp[0].minor.yy0);
153068153868
}
153069153869
break;
153070
- case 275: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
153870
+ case 278: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
153071153871
{
153072153872
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
153073153873
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
153074153874
}
153075153875
break;
153076
- case 276: /* add_column_fullname ::= fullname */
153876
+ case 279: /* add_column_fullname ::= fullname */
153077153877
{
153078153878
disableLookaside(pParse);
153079
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy407);
153080
-}
153081
- break;
153082
- case 277: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
153083
-{
153084
- sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy407, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
153085
-}
153086
- break;
153087
- case 278: /* cmd ::= create_vtab */
153879
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy609);
153880
+}
153881
+ break;
153882
+ case 280: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
153883
+{
153884
+ sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy609, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
153885
+}
153886
+ break;
153887
+ case 281: /* cmd ::= create_vtab */
153088153888
{sqlite3VtabFinishParse(pParse,0);}
153089153889
break;
153090
- case 279: /* cmd ::= create_vtab LP vtabarglist RP */
153890
+ case 282: /* cmd ::= create_vtab LP vtabarglist RP */
153091153891
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
153092153892
break;
153093
- case 280: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
153893
+ case 283: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
153094153894
{
153095
- sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy100);
153895
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy32);
153096153896
}
153097153897
break;
153098
- case 281: /* vtabarg ::= */
153898
+ case 284: /* vtabarg ::= */
153099153899
{sqlite3VtabArgInit(pParse);}
153100153900
break;
153101
- case 282: /* vtabargtoken ::= ANY */
153102
- case 283: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==283);
153103
- case 284: /* lp ::= LP */ yytestcase(yyruleno==284);
153901
+ case 285: /* vtabargtoken ::= ANY */
153902
+ case 286: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==286);
153903
+ case 287: /* lp ::= LP */ yytestcase(yyruleno==287);
153104153904
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
153105153905
break;
153106
- case 285: /* with ::= WITH wqlist */
153107
- case 286: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==286);
153108
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy243, 1); }
153109
- break;
153110
- case 287: /* wqlist ::= nm eidlist_opt AS LP select RP */
153111
-{
153112
- yymsp[-5].minor.yy243 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy94, yymsp[-1].minor.yy391); /*A-overwrites-X*/
153113
-}
153114
- break;
153115
- case 288: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
153116
-{
153117
- yymsp[-7].minor.yy243 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy243, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy94, yymsp[-1].minor.yy391);
153118
-}
153119
- break;
153120
- case 289: /* windowdefn_list ::= windowdefn */
153121
-{ yylhsminor.yy379 = yymsp[0].minor.yy379; }
153122
- yymsp[0].minor.yy379 = yylhsminor.yy379;
153123
- break;
153124
- case 290: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
153125
-{
153126
- assert( yymsp[0].minor.yy379!=0 );
153127
- sqlite3WindowChain(pParse, yymsp[0].minor.yy379, yymsp[-2].minor.yy379);
153128
- yymsp[0].minor.yy379->pNextWin = yymsp[-2].minor.yy379;
153129
- yylhsminor.yy379 = yymsp[0].minor.yy379;
153130
-}
153131
- yymsp[-2].minor.yy379 = yylhsminor.yy379;
153132
- break;
153133
- case 291: /* windowdefn ::= nm AS LP window RP */
153134
-{
153135
- if( ALWAYS(yymsp[-1].minor.yy379) ){
153136
- yymsp[-1].minor.yy379->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
153137
- }
153138
- yylhsminor.yy379 = yymsp[-1].minor.yy379;
153139
-}
153140
- yymsp[-4].minor.yy379 = yylhsminor.yy379;
153141
- break;
153142
- case 292: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
153143
-{
153144
- yymsp[-4].minor.yy379 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy379, yymsp[-2].minor.yy94, yymsp[-1].minor.yy94, 0);
153145
-}
153146
- break;
153147
- case 293: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
153148
-{
153149
- yylhsminor.yy379 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy379, yymsp[-2].minor.yy94, yymsp[-1].minor.yy94, &yymsp[-5].minor.yy0);
153150
-}
153151
- yymsp[-5].minor.yy379 = yylhsminor.yy379;
153152
- break;
153153
- case 294: /* window ::= ORDER BY sortlist frame_opt */
153154
-{
153155
- yymsp[-3].minor.yy379 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy379, 0, yymsp[-1].minor.yy94, 0);
153156
-}
153157
- break;
153158
- case 295: /* window ::= nm ORDER BY sortlist frame_opt */
153159
-{
153160
- yylhsminor.yy379 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy379, 0, yymsp[-1].minor.yy94, &yymsp[-4].minor.yy0);
153161
-}
153162
- yymsp[-4].minor.yy379 = yylhsminor.yy379;
153163
- break;
153164
- case 296: /* window ::= frame_opt */
153165
-{
153166
- yylhsminor.yy379 = yymsp[0].minor.yy379;
153167
-}
153168
- yymsp[0].minor.yy379 = yylhsminor.yy379;
153169
- break;
153170
- case 297: /* window ::= nm frame_opt */
153171
-{
153172
- yylhsminor.yy379 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy379, 0, 0, &yymsp[-1].minor.yy0);
153173
-}
153174
- yymsp[-1].minor.yy379 = yylhsminor.yy379;
153175
- break;
153176
- case 298: /* frame_opt ::= */
153177
-{
153178
- yymsp[1].minor.yy379 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
153179
-}
153180
- break;
153181
- case 299: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
153182
-{
153183
- yylhsminor.yy379 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy100, yymsp[-1].minor.yy389.eType, yymsp[-1].minor.yy389.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy218);
153184
-}
153185
- yymsp[-2].minor.yy379 = yylhsminor.yy379;
153186
- break;
153187
- case 300: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
153188
-{
153189
- yylhsminor.yy379 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy100, yymsp[-3].minor.yy389.eType, yymsp[-3].minor.yy389.pExpr, yymsp[-1].minor.yy389.eType, yymsp[-1].minor.yy389.pExpr, yymsp[0].minor.yy218);
153190
-}
153191
- yymsp[-5].minor.yy379 = yylhsminor.yy379;
153192
- break;
153193
- case 302: /* frame_bound_s ::= frame_bound */
153194
- case 304: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==304);
153195
-{yylhsminor.yy389 = yymsp[0].minor.yy389;}
153196
- yymsp[0].minor.yy389 = yylhsminor.yy389;
153197
- break;
153198
- case 303: /* frame_bound_s ::= UNBOUNDED PRECEDING */
153199
- case 305: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==305);
153200
- case 307: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==307);
153201
-{yylhsminor.yy389.eType = yymsp[-1].major; yylhsminor.yy389.pExpr = 0;}
153202
- yymsp[-1].minor.yy389 = yylhsminor.yy389;
153203
- break;
153204
- case 306: /* frame_bound ::= expr PRECEDING|FOLLOWING */
153205
-{yylhsminor.yy389.eType = yymsp[0].major; yylhsminor.yy389.pExpr = yymsp[-1].minor.yy102;}
153206
- yymsp[-1].minor.yy389 = yylhsminor.yy389;
153207
- break;
153208
- case 308: /* frame_exclude_opt ::= */
153209
-{yymsp[1].minor.yy218 = 0;}
153210
- break;
153211
- case 309: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
153212
-{yymsp[-1].minor.yy218 = yymsp[0].minor.yy218;}
153213
- break;
153214
- case 310: /* frame_exclude ::= NO OTHERS */
153215
- case 311: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==311);
153216
-{yymsp[-1].minor.yy218 = yymsp[-1].major; /*A-overwrites-X*/}
153217
- break;
153218
- case 312: /* frame_exclude ::= GROUP|TIES */
153219
-{yymsp[0].minor.yy218 = yymsp[0].major; /*A-overwrites-X*/}
153220
- break;
153221
- case 313: /* window_clause ::= WINDOW windowdefn_list */
153222
-{ yymsp[-1].minor.yy379 = yymsp[0].minor.yy379; }
153223
- break;
153224
- case 314: /* over_clause ::= filter_opt OVER LP window RP */
153225
-{
153226
- yylhsminor.yy379 = yymsp[-1].minor.yy379;
153227
- assert( yylhsminor.yy379!=0 );
153228
- yylhsminor.yy379->pFilter = yymsp[-4].minor.yy102;
153229
-}
153230
- yymsp[-4].minor.yy379 = yylhsminor.yy379;
153231
- break;
153232
- case 315: /* over_clause ::= filter_opt OVER nm */
153233
-{
153234
- yylhsminor.yy379 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
153235
- if( yylhsminor.yy379 ){
153236
- yylhsminor.yy379->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
153237
- yylhsminor.yy379->pFilter = yymsp[-2].minor.yy102;
153238
- }else{
153239
- sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy102);
153240
- }
153241
-}
153242
- yymsp[-2].minor.yy379 = yylhsminor.yy379;
153243
- break;
153244
- case 317: /* filter_opt ::= FILTER LP WHERE expr RP */
153245
-{ yymsp[-4].minor.yy102 = yymsp[-1].minor.yy102; }
153906
+ case 288: /* with ::= WITH wqlist */
153907
+ case 289: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==289);
153908
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy297, 1); }
153909
+ break;
153910
+ case 290: /* wqlist ::= nm eidlist_opt AS LP select RP */
153911
+{
153912
+ yymsp[-5].minor.yy297 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy138, yymsp[-1].minor.yy25); /*A-overwrites-X*/
153913
+}
153914
+ break;
153915
+ case 291: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
153916
+{
153917
+ yymsp[-7].minor.yy297 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy297, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy138, yymsp[-1].minor.yy25);
153918
+}
153919
+ break;
153920
+ case 292: /* windowdefn_list ::= windowdefn */
153921
+{ yylhsminor.yy455 = yymsp[0].minor.yy455; }
153922
+ yymsp[0].minor.yy455 = yylhsminor.yy455;
153923
+ break;
153924
+ case 293: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
153925
+{
153926
+ assert( yymsp[0].minor.yy455!=0 );
153927
+ sqlite3WindowChain(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy455);
153928
+ yymsp[0].minor.yy455->pNextWin = yymsp[-2].minor.yy455;
153929
+ yylhsminor.yy455 = yymsp[0].minor.yy455;
153930
+}
153931
+ yymsp[-2].minor.yy455 = yylhsminor.yy455;
153932
+ break;
153933
+ case 294: /* windowdefn ::= nm AS LP window RP */
153934
+{
153935
+ if( ALWAYS(yymsp[-1].minor.yy455) ){
153936
+ yymsp[-1].minor.yy455->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
153937
+ }
153938
+ yylhsminor.yy455 = yymsp[-1].minor.yy455;
153939
+}
153940
+ yymsp[-4].minor.yy455 = yylhsminor.yy455;
153941
+ break;
153942
+ case 295: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
153943
+{
153944
+ yymsp[-4].minor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy138, yymsp[-1].minor.yy138, 0);
153945
+}
153946
+ break;
153947
+ case 296: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
153948
+{
153949
+ yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy138, yymsp[-1].minor.yy138, &yymsp[-5].minor.yy0);
153950
+}
153951
+ yymsp[-5].minor.yy455 = yylhsminor.yy455;
153952
+ break;
153953
+ case 297: /* window ::= ORDER BY sortlist frame_opt */
153954
+{
153955
+ yymsp[-3].minor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, yymsp[-1].minor.yy138, 0);
153956
+}
153957
+ break;
153958
+ case 298: /* window ::= nm ORDER BY sortlist frame_opt */
153959
+{
153960
+ yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, yymsp[-1].minor.yy138, &yymsp[-4].minor.yy0);
153961
+}
153962
+ yymsp[-4].minor.yy455 = yylhsminor.yy455;
153963
+ break;
153964
+ case 299: /* window ::= frame_opt */
153965
+ case 318: /* filter_over ::= over_clause */ yytestcase(yyruleno==318);
153966
+{
153967
+ yylhsminor.yy455 = yymsp[0].minor.yy455;
153968
+}
153969
+ yymsp[0].minor.yy455 = yylhsminor.yy455;
153970
+ break;
153971
+ case 300: /* window ::= nm frame_opt */
153972
+{
153973
+ yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, 0, &yymsp[-1].minor.yy0);
153974
+}
153975
+ yymsp[-1].minor.yy455 = yylhsminor.yy455;
153976
+ break;
153977
+ case 301: /* frame_opt ::= */
153978
+{
153979
+ yymsp[1].minor.yy455 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
153980
+}
153981
+ break;
153982
+ case 302: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
153983
+{
153984
+ yylhsminor.yy455 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy32, yymsp[-1].minor.yy57.eType, yymsp[-1].minor.yy57.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy118);
153985
+}
153986
+ yymsp[-2].minor.yy455 = yylhsminor.yy455;
153987
+ break;
153988
+ case 303: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
153989
+{
153990
+ yylhsminor.yy455 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy32, yymsp[-3].minor.yy57.eType, yymsp[-3].minor.yy57.pExpr, yymsp[-1].minor.yy57.eType, yymsp[-1].minor.yy57.pExpr, yymsp[0].minor.yy118);
153991
+}
153992
+ yymsp[-5].minor.yy455 = yylhsminor.yy455;
153993
+ break;
153994
+ case 305: /* frame_bound_s ::= frame_bound */
153995
+ case 307: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==307);
153996
+{yylhsminor.yy57 = yymsp[0].minor.yy57;}
153997
+ yymsp[0].minor.yy57 = yylhsminor.yy57;
153998
+ break;
153999
+ case 306: /* frame_bound_s ::= UNBOUNDED PRECEDING */
154000
+ case 308: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==308);
154001
+ case 310: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==310);
154002
+{yylhsminor.yy57.eType = yymsp[-1].major; yylhsminor.yy57.pExpr = 0;}
154003
+ yymsp[-1].minor.yy57 = yylhsminor.yy57;
154004
+ break;
154005
+ case 309: /* frame_bound ::= expr PRECEDING|FOLLOWING */
154006
+{yylhsminor.yy57.eType = yymsp[0].major; yylhsminor.yy57.pExpr = yymsp[-1].minor.yy46;}
154007
+ yymsp[-1].minor.yy57 = yylhsminor.yy57;
154008
+ break;
154009
+ case 311: /* frame_exclude_opt ::= */
154010
+{yymsp[1].minor.yy118 = 0;}
154011
+ break;
154012
+ case 312: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
154013
+{yymsp[-1].minor.yy118 = yymsp[0].minor.yy118;}
154014
+ break;
154015
+ case 313: /* frame_exclude ::= NO OTHERS */
154016
+ case 314: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==314);
154017
+{yymsp[-1].minor.yy118 = yymsp[-1].major; /*A-overwrites-X*/}
154018
+ break;
154019
+ case 315: /* frame_exclude ::= GROUP|TIES */
154020
+{yymsp[0].minor.yy118 = yymsp[0].major; /*A-overwrites-X*/}
154021
+ break;
154022
+ case 316: /* window_clause ::= WINDOW windowdefn_list */
154023
+{ yymsp[-1].minor.yy455 = yymsp[0].minor.yy455; }
154024
+ break;
154025
+ case 317: /* filter_over ::= filter_clause over_clause */
154026
+{
154027
+ yymsp[0].minor.yy455->pFilter = yymsp[-1].minor.yy46;
154028
+ yylhsminor.yy455 = yymsp[0].minor.yy455;
154029
+}
154030
+ yymsp[-1].minor.yy455 = yylhsminor.yy455;
154031
+ break;
154032
+ case 319: /* filter_over ::= filter_clause */
154033
+{
154034
+ yylhsminor.yy455 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
154035
+ if( yylhsminor.yy455 ){
154036
+ yylhsminor.yy455->eFrmType = TK_FILTER;
154037
+ yylhsminor.yy455->pFilter = yymsp[0].minor.yy46;
154038
+ }else{
154039
+ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy46);
154040
+ }
154041
+}
154042
+ yymsp[0].minor.yy455 = yylhsminor.yy455;
154043
+ break;
154044
+ case 320: /* over_clause ::= OVER LP window RP */
154045
+{
154046
+ yymsp[-3].minor.yy455 = yymsp[-1].minor.yy455;
154047
+ assert( yymsp[-3].minor.yy455!=0 );
154048
+}
154049
+ break;
154050
+ case 321: /* over_clause ::= OVER nm */
154051
+{
154052
+ yymsp[-1].minor.yy455 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
154053
+ if( yymsp[-1].minor.yy455 ){
154054
+ yymsp[-1].minor.yy455->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
154055
+ }
154056
+}
154057
+ break;
154058
+ case 322: /* filter_clause ::= FILTER LP WHERE expr RP */
154059
+{ yymsp[-4].minor.yy46 = yymsp[-1].minor.yy46; }
153246154060
break;
153247154061
default:
153248
- /* (318) input ::= cmdlist */ yytestcase(yyruleno==318);
153249
- /* (319) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==319);
153250
- /* (320) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=320);
153251
- /* (321) ecmd ::= SEMI */ yytestcase(yyruleno==321);
153252
- /* (322) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==322);
153253
- /* (323) ecmd ::= explain cmdx */ yytestcase(yyruleno==323);
153254
- /* (324) trans_opt ::= */ yytestcase(yyruleno==324);
153255
- /* (325) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==325);
153256
- /* (326) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==326);
153257
- /* (327) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==327);
153258
- /* (328) savepoint_opt ::= */ yytestcase(yyruleno==328);
153259
- /* (329) cmd ::= create_table create_table_args */ yytestcase(yyruleno==329);
153260
- /* (330) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==330);
153261
- /* (331) columnlist ::= columnname carglist */ yytestcase(yyruleno==331);
153262
- /* (332) nm ::= ID|INDEXED */ yytestcase(yyruleno==332);
153263
- /* (333) nm ::= STRING */ yytestcase(yyruleno==333);
153264
- /* (334) nm ::= JOIN_KW */ yytestcase(yyruleno==334);
153265
- /* (335) typetoken ::= typename */ yytestcase(yyruleno==335);
153266
- /* (336) typename ::= ID|STRING */ yytestcase(yyruleno==336);
153267
- /* (337) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=337);
153268
- /* (338) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=338);
153269
- /* (339) carglist ::= carglist ccons */ yytestcase(yyruleno==339);
153270
- /* (340) carglist ::= */ yytestcase(yyruleno==340);
153271
- /* (341) ccons ::= NULL onconf */ yytestcase(yyruleno==341);
153272
- /* (342) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==342);
153273
- /* (343) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==343);
153274
- /* (344) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=344);
153275
- /* (345) tconscomma ::= */ yytestcase(yyruleno==345);
153276
- /* (346) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=346);
153277
- /* (347) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=347);
153278
- /* (348) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=348);
153279
- /* (349) oneselect ::= values */ yytestcase(yyruleno==349);
153280
- /* (350) sclp ::= selcollist COMMA */ yytestcase(yyruleno==350);
153281
- /* (351) as ::= ID|STRING */ yytestcase(yyruleno==351);
153282
- /* (352) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=352);
153283
- /* (353) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==353);
153284
- /* (354) exprlist ::= nexprlist */ yytestcase(yyruleno==354);
153285
- /* (355) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=355);
153286
- /* (356) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=356);
153287
- /* (357) nmnum ::= ON */ yytestcase(yyruleno==357);
153288
- /* (358) nmnum ::= DELETE */ yytestcase(yyruleno==358);
153289
- /* (359) nmnum ::= DEFAULT */ yytestcase(yyruleno==359);
153290
- /* (360) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==360);
153291
- /* (361) foreach_clause ::= */ yytestcase(yyruleno==361);
153292
- /* (362) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==362);
153293
- /* (363) trnm ::= nm */ yytestcase(yyruleno==363);
153294
- /* (364) tridxby ::= */ yytestcase(yyruleno==364);
153295
- /* (365) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==365);
153296
- /* (366) database_kw_opt ::= */ yytestcase(yyruleno==366);
153297
- /* (367) kwcolumn_opt ::= */ yytestcase(yyruleno==367);
153298
- /* (368) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==368);
153299
- /* (369) vtabarglist ::= vtabarg */ yytestcase(yyruleno==369);
153300
- /* (370) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==370);
153301
- /* (371) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==371);
153302
- /* (372) anylist ::= */ yytestcase(yyruleno==372);
153303
- /* (373) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==373);
153304
- /* (374) anylist ::= anylist ANY */ yytestcase(yyruleno==374);
153305
- /* (375) with ::= */ yytestcase(yyruleno==375);
154062
+ /* (323) input ::= cmdlist */ yytestcase(yyruleno==323);
154063
+ /* (324) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==324);
154064
+ /* (325) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=325);
154065
+ /* (326) ecmd ::= SEMI */ yytestcase(yyruleno==326);
154066
+ /* (327) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==327);
154067
+ /* (328) ecmd ::= explain cmdx */ yytestcase(yyruleno==328);
154068
+ /* (329) trans_opt ::= */ yytestcase(yyruleno==329);
154069
+ /* (330) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==330);
154070
+ /* (331) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==331);
154071
+ /* (332) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==332);
154072
+ /* (333) savepoint_opt ::= */ yytestcase(yyruleno==333);
154073
+ /* (334) cmd ::= create_table create_table_args */ yytestcase(yyruleno==334);
154074
+ /* (335) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==335);
154075
+ /* (336) columnlist ::= columnname carglist */ yytestcase(yyruleno==336);
154076
+ /* (337) nm ::= ID|INDEXED */ yytestcase(yyruleno==337);
154077
+ /* (338) nm ::= STRING */ yytestcase(yyruleno==338);
154078
+ /* (339) nm ::= JOIN_KW */ yytestcase(yyruleno==339);
154079
+ /* (340) typetoken ::= typename */ yytestcase(yyruleno==340);
154080
+ /* (341) typename ::= ID|STRING */ yytestcase(yyruleno==341);
154081
+ /* (342) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=342);
154082
+ /* (343) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=343);
154083
+ /* (344) carglist ::= carglist ccons */ yytestcase(yyruleno==344);
154084
+ /* (345) carglist ::= */ yytestcase(yyruleno==345);
154085
+ /* (346) ccons ::= NULL onconf */ yytestcase(yyruleno==346);
154086
+ /* (347) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==347);
154087
+ /* (348) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==348);
154088
+ /* (349) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=349);
154089
+ /* (350) tconscomma ::= */ yytestcase(yyruleno==350);
154090
+ /* (351) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=351);
154091
+ /* (352) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=352);
154092
+ /* (353) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=353);
154093
+ /* (354) oneselect ::= values */ yytestcase(yyruleno==354);
154094
+ /* (355) sclp ::= selcollist COMMA */ yytestcase(yyruleno==355);
154095
+ /* (356) as ::= ID|STRING */ yytestcase(yyruleno==356);
154096
+ /* (357) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=357);
154097
+ /* (358) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==358);
154098
+ /* (359) exprlist ::= nexprlist */ yytestcase(yyruleno==359);
154099
+ /* (360) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=360);
154100
+ /* (361) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=361);
154101
+ /* (362) nmnum ::= ON */ yytestcase(yyruleno==362);
154102
+ /* (363) nmnum ::= DELETE */ yytestcase(yyruleno==363);
154103
+ /* (364) nmnum ::= DEFAULT */ yytestcase(yyruleno==364);
154104
+ /* (365) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==365);
154105
+ /* (366) foreach_clause ::= */ yytestcase(yyruleno==366);
154106
+ /* (367) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==367);
154107
+ /* (368) trnm ::= nm */ yytestcase(yyruleno==368);
154108
+ /* (369) tridxby ::= */ yytestcase(yyruleno==369);
154109
+ /* (370) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==370);
154110
+ /* (371) database_kw_opt ::= */ yytestcase(yyruleno==371);
154111
+ /* (372) kwcolumn_opt ::= */ yytestcase(yyruleno==372);
154112
+ /* (373) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==373);
154113
+ /* (374) vtabarglist ::= vtabarg */ yytestcase(yyruleno==374);
154114
+ /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==375);
154115
+ /* (376) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==376);
154116
+ /* (377) anylist ::= */ yytestcase(yyruleno==377);
154117
+ /* (378) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==378);
154118
+ /* (379) anylist ::= anylist ANY */ yytestcase(yyruleno==379);
154119
+ /* (380) with ::= */ yytestcase(yyruleno==380);
153306154120
break;
153307154121
/********** End reduce actions ************************************************/
153308154122
};
153309154123
assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
153310154124
yygoto = yyRuleInfoLhs[yyruleno];
@@ -153592,13 +154406,12 @@
153592154406
** Return the fallback token corresponding to canonical token iToken, or
153593154407
** 0 if iToken has no fallback.
153594154408
*/
153595154409
SQLITE_PRIVATE int sqlite3ParserFallback(int iToken){
153596154410
#ifdef YYFALLBACK
153597
- if( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ){
153598
- return yyFallback[iToken];
153599
- }
154411
+ assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) );
154412
+ return yyFallback[iToken];
153600154413
#else
153601154414
(void)iToken;
153602154415
#endif
153603154416
return 0;
153604154417
}
@@ -153763,148 +154576,150 @@
153763154576
** might be implemented more directly using a hand-written hash table.
153764154577
** But by using this automatically generated code, the size of the code
153765154578
** is substantially reduced. This is important for embedded applications
153766154579
** on platforms with limited memory.
153767154580
*/
153768
-/* Hash score: 214 */
153769
-/* zKWText[] encodes 950 bytes of keyword text in 629 bytes */
154581
+/* Hash score: 221 */
154582
+/* zKWText[] encodes 967 bytes of keyword text in 638 bytes */
153770154583
/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
153771
-/* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYCONSTRAINTERSECTIES */
153772
-/* AVEPOINTOFFSETRANSACTIONATURALTERAISEXCEPTRIGGEREFERENCES */
153773
-/* UNIQUERYWITHOUTERELEASEXCLUSIVEXISTSATTACHAVINGLOBEGINNERANGE */
153774
-/* BETWEENOTHINGROUPSCASCADETACHCASECOLLATECREATECURRENT_DATE */
153775
-/* IMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTUPDATEVALUES */
153776
-/* VIRTUALIMITWHENOTNULLWHERECURSIVEAFTERENAMEANDEFAULT */
154584
+/* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYISNULLSAVEPOINTERSECT */
154585
+/* IESNOTNULLIKEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTS */
154586
+/* CONSTRAINTOFFSETRIGGEREFERENCESUNIQUERYWITHOUTERELEASEATTACH */
154587
+/* AVINGLOBEGINNERANGEBETWEENOTHINGROUPSCASCADETACHCASECOLLATE */
154588
+/* CREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORT */
154589
+/* UPDATEVALUESVIRTUALASTWHENWHERECURSIVEAFTERENAMEANDEFAULT */
153777154590
/* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */
153778
-/* ARTITIONDEFERREDISTINCTDROPRECEDINGFAILFILTEREPLACEFOLLOWING */
153779
-/* FROMFULLIFISNULLORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */
154591
+/* ARTITIONDEFERREDISTINCTDROPRECEDINGFAILIMITFILTEREPLACEFIRST */
154592
+/* FOLLOWINGFROMFULLIFORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */
153780154593
/* UNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBYINITIALLYPRIMARY */
153781
-static const char zKWText[628] = {
154594
+static const char zKWText[637] = {
153782154595
'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
153783154596
'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
153784154597
'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
153785154598
'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
153786154599
'E','R','R','A','B','L','E','L','S','E','X','C','L','U','D','E','L','E',
153787
- 'T','E','M','P','O','R','A','R','Y','C','O','N','S','T','R','A','I','N',
153788
- 'T','E','R','S','E','C','T','I','E','S','A','V','E','P','O','I','N','T',
153789
- 'O','F','F','S','E','T','R','A','N','S','A','C','T','I','O','N','A','T',
153790
- 'U','R','A','L','T','E','R','A','I','S','E','X','C','E','P','T','R','I',
153791
- 'G','G','E','R','E','F','E','R','E','N','C','E','S','U','N','I','Q','U',
153792
- 'E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S','E',
153793
- 'X','C','L','U','S','I','V','E','X','I','S','T','S','A','T','T','A','C',
153794
- 'H','A','V','I','N','G','L','O','B','E','G','I','N','N','E','R','A','N',
153795
- 'G','E','B','E','T','W','E','E','N','O','T','H','I','N','G','R','O','U',
153796
- 'P','S','C','A','S','C','A','D','E','T','A','C','H','C','A','S','E','C',
153797
- 'O','L','L','A','T','E','C','R','E','A','T','E','C','U','R','R','E','N',
153798
- 'T','_','D','A','T','E','I','M','M','E','D','I','A','T','E','J','O','I',
153799
- 'N','S','E','R','T','L','I','K','E','M','A','T','C','H','P','L','A','N',
153800
- 'A','L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','U','P','D',
153801
- 'A','T','E','V','A','L','U','E','S','V','I','R','T','U','A','L','I','M',
153802
- 'I','T','W','H','E','N','O','T','N','U','L','L','W','H','E','R','E','C',
153803
- 'U','R','S','I','V','E','A','F','T','E','R','E','N','A','M','E','A','N',
153804
- 'D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E','M','E',
153805
- 'N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M','I','T',
153806
- 'C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R','R','E',
153807
- 'N','T','_','T','I','M','E','S','T','A','M','P','A','R','T','I','T','I',
153808
- 'O','N','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
153809
- 'R','O','P','R','E','C','E','D','I','N','G','F','A','I','L','F','I','L',
153810
- 'T','E','R','E','P','L','A','C','E','F','O','L','L','O','W','I','N','G',
153811
- 'F','R','O','M','F','U','L','L','I','F','I','S','N','U','L','L','O','R',
153812
- 'D','E','R','E','S','T','R','I','C','T','O','T','H','E','R','S','O','V',
153813
- 'E','R','I','G','H','T','R','O','L','L','B','A','C','K','R','O','W','S',
153814
- 'U','N','B','O','U','N','D','E','D','U','N','I','O','N','U','S','I','N',
153815
- 'G','V','A','C','U','U','M','V','I','E','W','I','N','D','O','W','B','Y',
153816
- 'I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R','Y',
154600
+ 'T','E','M','P','O','R','A','R','Y','I','S','N','U','L','L','S','A','V',
154601
+ 'E','P','O','I','N','T','E','R','S','E','C','T','I','E','S','N','O','T',
154602
+ 'N','U','L','L','I','K','E','X','C','E','P','T','R','A','N','S','A','C',
154603
+ 'T','I','O','N','A','T','U','R','A','L','T','E','R','A','I','S','E','X',
154604
+ 'C','L','U','S','I','V','E','X','I','S','T','S','C','O','N','S','T','R',
154605
+ 'A','I','N','T','O','F','F','S','E','T','R','I','G','G','E','R','E','F',
154606
+ 'E','R','E','N','C','E','S','U','N','I','Q','U','E','R','Y','W','I','T',
154607
+ 'H','O','U','T','E','R','E','L','E','A','S','E','A','T','T','A','C','H',
154608
+ 'A','V','I','N','G','L','O','B','E','G','I','N','N','E','R','A','N','G',
154609
+ 'E','B','E','T','W','E','E','N','O','T','H','I','N','G','R','O','U','P',
154610
+ 'S','C','A','S','C','A','D','E','T','A','C','H','C','A','S','E','C','O',
154611
+ 'L','L','A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T',
154612
+ '_','D','A','T','E','I','M','M','E','D','I','A','T','E','J','O','I','N',
154613
+ 'S','E','R','T','M','A','T','C','H','P','L','A','N','A','L','Y','Z','E',
154614
+ 'P','R','A','G','M','A','B','O','R','T','U','P','D','A','T','E','V','A',
154615
+ 'L','U','E','S','V','I','R','T','U','A','L','A','S','T','W','H','E','N',
154616
+ 'W','H','E','R','E','C','U','R','S','I','V','E','A','F','T','E','R','E',
154617
+ 'N','A','M','E','A','N','D','E','F','A','U','L','T','A','U','T','O','I',
154618
+ 'N','C','R','E','M','E','N','T','C','A','S','T','C','O','L','U','M','N',
154619
+ 'C','O','M','M','I','T','C','O','N','F','L','I','C','T','C','R','O','S',
154620
+ 'S','C','U','R','R','E','N','T','_','T','I','M','E','S','T','A','M','P',
154621
+ 'A','R','T','I','T','I','O','N','D','E','F','E','R','R','E','D','I','S',
154622
+ 'T','I','N','C','T','D','R','O','P','R','E','C','E','D','I','N','G','F',
154623
+ 'A','I','L','I','M','I','T','F','I','L','T','E','R','E','P','L','A','C',
154624
+ 'E','F','I','R','S','T','F','O','L','L','O','W','I','N','G','F','R','O',
154625
+ 'M','F','U','L','L','I','F','O','R','D','E','R','E','S','T','R','I','C',
154626
+ 'T','O','T','H','E','R','S','O','V','E','R','I','G','H','T','R','O','L',
154627
+ 'L','B','A','C','K','R','O','W','S','U','N','B','O','U','N','D','E','D',
154628
+ 'U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M','V','I',
154629
+ 'E','W','I','N','D','O','W','B','Y','I','N','I','T','I','A','L','L','Y',
154630
+ 'P','R','I','M','A','R','Y',
153817154631
};
153818154632
/* aKWHash[i] is the hash value for the i-th keyword */
153819154633
static const unsigned char aKWHash[127] = {
153820
- 75, 111, 127, 73, 108, 29, 0, 0, 83, 0, 77, 63, 0,
153821
- 37, 33, 78, 15, 0, 126, 86, 57, 120, 128, 19, 0, 0,
153822
- 133, 0, 131, 123, 0, 22, 98, 0, 9, 0, 0, 117, 71,
153823
- 0, 69, 6, 0, 49, 95, 140, 0, 129, 106, 0, 0, 54,
153824
- 0, 109, 24, 0, 17, 0, 134, 56, 23, 26, 5, 58, 135,
153825
- 101, 0, 0, 139, 112, 62, 138, 59, 115, 65, 0, 96, 0,
153826
- 105, 45, 0, 104, 0, 0, 0, 100, 97, 102, 107, 119, 14,
153827
- 31, 118, 0, 81, 0, 136, 116, 137, 61, 124, 132, 80, 121,
153828
- 88, 30, 85, 0, 0, 99, 35, 125, 122, 0, 130, 0, 0,
153829
- 41, 0, 91, 89, 90, 0, 20, 87, 113, 82,
154634
+ 82, 113, 130, 80, 110, 29, 0, 0, 89, 0, 83, 70, 0,
154635
+ 53, 35, 84, 15, 0, 129, 92, 64, 124, 131, 19, 0, 0,
154636
+ 136, 0, 134, 126, 0, 22, 100, 0, 9, 0, 0, 121, 78,
154637
+ 0, 76, 6, 0, 58, 97, 143, 0, 132, 108, 0, 0, 48,
154638
+ 0, 111, 24, 0, 17, 0, 137, 63, 23, 26, 5, 65, 138,
154639
+ 103, 120, 0, 142, 114, 69, 141, 66, 118, 72, 0, 98, 0,
154640
+ 107, 41, 0, 106, 0, 0, 0, 102, 99, 104, 109, 123, 14,
154641
+ 50, 122, 0, 87, 0, 139, 119, 140, 68, 127, 135, 86, 81,
154642
+ 37, 91, 117, 0, 0, 101, 51, 128, 125, 0, 133, 0, 0,
154643
+ 44, 0, 93, 67, 39, 0, 20, 45, 115, 88,
153830154644
};
153831154645
/* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
153832154646
** then the i-th keyword has no more hash collisions. Otherwise,
153833154647
** the next keyword with the same hash is aKWHash[i]-1. */
153834
-static const unsigned char aKWNext[140] = {
154648
+static const unsigned char aKWNext[143] = {
153835154649
0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
153836154650
0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
153837
- 0, 0, 0, 21, 0, 0, 12, 0, 0, 0, 0, 0, 0,
153838
- 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
153839
- 51, 28, 0, 0, 38, 0, 0, 0, 44, 0, 0, 0, 3,
153840
- 0, 0, 67, 1, 66, 0, 0, 0, 36, 0, 47, 0, 0,
153841
- 0, 0, 0, 48, 50, 76, 0, 0, 42, 0, 60, 0, 0,
153842
- 0, 43, 0, 16, 55, 10, 0, 0, 0, 0, 0, 0, 0,
153843
- 11, 72, 93, 0, 0, 8, 0, 110, 0, 103, 40, 53, 70,
153844
- 0, 114, 0, 74, 52, 0, 0, 92, 39, 46, 0, 68, 32,
153845
- 84, 0, 34, 27, 25, 18, 94, 0, 64, 79,
154651
+ 0, 0, 0, 21, 0, 0, 0, 0, 12, 0, 0, 0, 0,
154652
+ 0, 0, 0, 7, 0, 36, 0, 0, 28, 0, 0, 0, 31,
154653
+ 0, 0, 0, 40, 0, 0, 0, 0, 0, 60, 0, 54, 0,
154654
+ 0, 38, 47, 0, 0, 0, 3, 0, 0, 74, 1, 73, 0,
154655
+ 0, 0, 52, 0, 0, 0, 0, 0, 0, 57, 59, 56, 30,
154656
+ 0, 0, 0, 46, 0, 16, 49, 10, 0, 0, 0, 0, 0,
154657
+ 0, 0, 11, 79, 95, 0, 0, 8, 0, 112, 0, 105, 0,
154658
+ 43, 62, 0, 77, 0, 116, 0, 61, 0, 0, 94, 42, 55,
154659
+ 0, 75, 34, 90, 32, 33, 27, 25, 18, 96, 0, 71, 85,
153846154660
};
153847154661
/* aKWLen[i] is the length (in bytes) of the i-th keyword */
153848
-static const unsigned char aKWLen[140] = {
154662
+static const unsigned char aKWLen[143] = {
153849154663
7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
153850154664
7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7,
153851
- 6, 9, 4, 2, 10, 9, 4, 9, 4, 6, 2, 3, 11,
153852
- 6, 2, 7, 5, 5, 6, 7, 10, 6, 5, 7, 4, 5,
153853
- 7, 9, 6, 6, 6, 4, 5, 5, 5, 7, 7, 6, 5,
153854
- 7, 3, 6, 4, 7, 6, 12, 9, 4, 6, 4, 5, 4,
153855
- 7, 6, 5, 6, 6, 7, 5, 4, 7, 3, 2, 4, 5,
153856
- 9, 5, 6, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5,
153857
- 17, 12, 7, 9, 8, 8, 2, 4, 9, 4, 6, 7, 9,
153858
- 4, 4, 2, 6, 5, 8, 6, 4, 5, 8, 4, 3, 9,
153859
- 5, 5, 6, 4, 6, 2, 2, 9, 3, 7,
154665
+ 6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4,
154666
+ 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 10, 4, 6,
154667
+ 2, 3, 7, 10, 6, 5, 7, 4, 5, 7, 6, 6, 4,
154668
+ 5, 5, 5, 7, 7, 6, 5, 7, 3, 6, 4, 7, 6,
154669
+ 12, 9, 4, 6, 5, 4, 7, 6, 5, 6, 6, 7, 4,
154670
+ 4, 5, 9, 5, 6, 3, 7, 13, 2, 2, 4, 6, 6,
154671
+ 8, 5, 17, 12, 7, 9, 8, 8, 2, 4, 9, 4, 5,
154672
+ 6, 7, 5, 9, 4, 4, 2, 5, 8, 6, 4, 5, 8,
154673
+ 4, 3, 9, 5, 5, 6, 4, 6, 2, 2, 9, 3, 7,
153860154674
};
153861154675
/* aKWOffset[i] is the index into zKWText[] of the start of
153862154676
** the text for the i-th keyword. */
153863
-static const unsigned short int aKWOffset[140] = {
154677
+static const unsigned short int aKWOffset[143] = {
153864154678
0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
153865154679
36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
153866
- 86, 90, 90, 94, 99, 106, 114, 117, 123, 126, 126, 129, 131,
153867
- 136, 140, 141, 146, 150, 154, 159, 165, 175, 178, 183, 183, 187,
153868
- 191, 197, 205, 211, 216, 221, 224, 227, 231, 236, 242, 248, 248,
153869
- 254, 255, 259, 265, 269, 276, 282, 294, 303, 305, 311, 315, 320,
153870
- 322, 329, 334, 339, 345, 351, 357, 362, 365, 365, 365, 368, 372,
153871
- 375, 384, 388, 394, 396, 403, 405, 407, 416, 420, 426, 432, 440,
153872
- 445, 445, 445, 461, 470, 477, 478, 485, 488, 497, 501, 506, 513,
153873
- 522, 526, 530, 532, 538, 542, 550, 556, 559, 564, 572, 572, 576,
153874
- 585, 590, 595, 601, 604, 607, 610, 612, 617, 621,
154680
+ 86, 90, 90, 94, 99, 101, 105, 111, 119, 123, 123, 123, 126,
154681
+ 129, 132, 137, 142, 146, 147, 152, 156, 160, 168, 174, 181, 184,
154682
+ 184, 187, 189, 195, 205, 208, 213, 213, 217, 221, 228, 233, 238,
154683
+ 241, 244, 248, 253, 259, 265, 265, 271, 272, 276, 282, 286, 293,
154684
+ 299, 311, 320, 322, 328, 333, 335, 342, 347, 352, 358, 364, 370,
154685
+ 374, 378, 381, 390, 394, 400, 402, 409, 411, 413, 422, 426, 432,
154686
+ 438, 446, 451, 451, 451, 467, 476, 483, 484, 491, 494, 503, 506,
154687
+ 511, 516, 523, 528, 537, 541, 545, 547, 551, 559, 565, 568, 573,
154688
+ 581, 581, 585, 594, 599, 604, 610, 613, 616, 619, 621, 626, 630,
153875154689
};
153876154690
/* aKWCode[i] is the parser symbol code for the i-th keyword */
153877
-static const unsigned char aKWCode[140] = {
154691
+static const unsigned char aKWCode[143] = {
153878154692
TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
153879154693
TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
153880154694
TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
153881154695
TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
153882154696
TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
153883154697
TK_EXCLUDE, TK_DELETE, TK_TEMP, TK_TEMP, TK_OR,
153884
- TK_CONSTRAINT, TK_INTERSECT, TK_TIES, TK_SAVEPOINT, TK_INTO,
153885
- TK_OFFSET, TK_OF, TK_SET, TK_TRANSACTION,TK_ACTION,
153886
- TK_ON, TK_JOIN_KW, TK_ALTER, TK_RAISE, TK_EXCEPT,
153887
- TK_TRIGGER, TK_REFERENCES, TK_UNIQUE, TK_QUERY, TK_WITHOUT,
153888
- TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_EXCLUSIVE, TK_EXISTS,
153889
- TK_ATTACH, TK_HAVING, TK_LIKE_KW, TK_BEGIN, TK_JOIN_KW,
153890
- TK_RANGE, TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP,
153891
- TK_CASCADE, TK_ASC, TK_DETACH, TK_CASE, TK_COLLATE,
153892
- TK_CREATE, TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT,
153893
- TK_LIKE_KW, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA,
153894
- TK_ABORT, TK_UPDATE, TK_VALUES, TK_VIRTUAL, TK_LIMIT,
153895
- TK_WHEN, TK_NOTNULL, TK_NOT, TK_NO, TK_NULL,
153896
- TK_WHERE, TK_RECURSIVE, TK_AFTER, TK_RENAME, TK_AND,
153897
- TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
153898
- TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW,
153899
- TK_CTIME_KW, TK_CURRENT, TK_PARTITION, TK_DEFERRED, TK_DISTINCT,
153900
- TK_IS, TK_DROP, TK_PRECEDING, TK_FAIL, TK_FILTER,
153901
- TK_REPLACE, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_IF,
153902
- TK_ISNULL, TK_ORDER, TK_RESTRICT, TK_OTHERS, TK_OVER,
153903
- TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNBOUNDED,
153904
- TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_WINDOW,
153905
- TK_DO, TK_BY, TK_INITIALLY, TK_ALL, TK_PRIMARY,
154698
+ TK_ISNULL, TK_NULLS, TK_SAVEPOINT, TK_INTERSECT, TK_TIES,
154699
+ TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
154700
+ TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
154701
+ TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_CONSTRAINT,
154702
+ TK_INTO, TK_OFFSET, TK_OF, TK_SET, TK_TRIGGER,
154703
+ TK_REFERENCES, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
154704
+ TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_LIKE_KW,
154705
+ TK_BEGIN, TK_JOIN_KW, TK_RANGE, TK_BETWEEN, TK_NOTHING,
154706
+ TK_GROUPS, TK_GROUP, TK_CASCADE, TK_ASC, TK_DETACH,
154707
+ TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_IMMEDIATE,
154708
+ TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE,
154709
+ TK_PRAGMA, TK_ABORT, TK_UPDATE, TK_VALUES, TK_VIRTUAL,
154710
+ TK_LAST, TK_WHEN, TK_WHERE, TK_RECURSIVE, TK_AFTER,
154711
+ TK_RENAME, TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO,
154712
+ TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT,
154713
+ TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT, TK_PARTITION,
154714
+ TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP, TK_PRECEDING,
154715
+ TK_FAIL, TK_LIMIT, TK_FILTER, TK_REPLACE, TK_FIRST,
154716
+ TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_IF, TK_ORDER,
154717
+ TK_RESTRICT, TK_OTHERS, TK_OVER, TK_JOIN_KW, TK_ROLLBACK,
154718
+ TK_ROWS, TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING,
154719
+ TK_VACUUM, TK_VIEW, TK_WINDOW, TK_DO, TK_BY,
154720
+ TK_INITIALLY, TK_ALL, TK_PRIMARY,
153906154721
};
153907154722
/* Check to see if z[0..n-1] is a keyword. If it is, write the
153908154723
** parser symbol code for that keyword into *pType. Always
153909154724
** return the integer n (the length of the token). */
153910154725
static int keywordCode(const char *z, int n, int *pType){
@@ -153951,120 +154766,123 @@
153951154766
testcase( i==25 ); /* EXCLUDE */
153952154767
testcase( i==26 ); /* DELETE */
153953154768
testcase( i==27 ); /* TEMPORARY */
153954154769
testcase( i==28 ); /* TEMP */
153955154770
testcase( i==29 ); /* OR */
153956
- testcase( i==30 ); /* CONSTRAINT */
153957
- testcase( i==31 ); /* INTERSECT */
153958
- testcase( i==32 ); /* TIES */
153959
- testcase( i==33 ); /* SAVEPOINT */
153960
- testcase( i==34 ); /* INTO */
153961
- testcase( i==35 ); /* OFFSET */
153962
- testcase( i==36 ); /* OF */
153963
- testcase( i==37 ); /* SET */
153964
- testcase( i==38 ); /* TRANSACTION */
153965
- testcase( i==39 ); /* ACTION */
153966
- testcase( i==40 ); /* ON */
153967
- testcase( i==41 ); /* NATURAL */
153968
- testcase( i==42 ); /* ALTER */
153969
- testcase( i==43 ); /* RAISE */
153970
- testcase( i==44 ); /* EXCEPT */
153971
- testcase( i==45 ); /* TRIGGER */
153972
- testcase( i==46 ); /* REFERENCES */
153973
- testcase( i==47 ); /* UNIQUE */
153974
- testcase( i==48 ); /* QUERY */
153975
- testcase( i==49 ); /* WITHOUT */
153976
- testcase( i==50 ); /* WITH */
153977
- testcase( i==51 ); /* OUTER */
153978
- testcase( i==52 ); /* RELEASE */
153979
- testcase( i==53 ); /* EXCLUSIVE */
153980
- testcase( i==54 ); /* EXISTS */
153981
- testcase( i==55 ); /* ATTACH */
153982
- testcase( i==56 ); /* HAVING */
153983
- testcase( i==57 ); /* GLOB */
153984
- testcase( i==58 ); /* BEGIN */
153985
- testcase( i==59 ); /* INNER */
153986
- testcase( i==60 ); /* RANGE */
153987
- testcase( i==61 ); /* BETWEEN */
153988
- testcase( i==62 ); /* NOTHING */
153989
- testcase( i==63 ); /* GROUPS */
153990
- testcase( i==64 ); /* GROUP */
153991
- testcase( i==65 ); /* CASCADE */
153992
- testcase( i==66 ); /* ASC */
153993
- testcase( i==67 ); /* DETACH */
153994
- testcase( i==68 ); /* CASE */
153995
- testcase( i==69 ); /* COLLATE */
153996
- testcase( i==70 ); /* CREATE */
153997
- testcase( i==71 ); /* CURRENT_DATE */
153998
- testcase( i==72 ); /* IMMEDIATE */
153999
- testcase( i==73 ); /* JOIN */
154000
- testcase( i==74 ); /* INSERT */
154001
- testcase( i==75 ); /* LIKE */
154002
- testcase( i==76 ); /* MATCH */
154003
- testcase( i==77 ); /* PLAN */
154004
- testcase( i==78 ); /* ANALYZE */
154005
- testcase( i==79 ); /* PRAGMA */
154006
- testcase( i==80 ); /* ABORT */
154007
- testcase( i==81 ); /* UPDATE */
154008
- testcase( i==82 ); /* VALUES */
154009
- testcase( i==83 ); /* VIRTUAL */
154010
- testcase( i==84 ); /* LIMIT */
154011
- testcase( i==85 ); /* WHEN */
154012
- testcase( i==86 ); /* NOTNULL */
154013
- testcase( i==87 ); /* NOT */
154014
- testcase( i==88 ); /* NO */
154015
- testcase( i==89 ); /* NULL */
154016
- testcase( i==90 ); /* WHERE */
154017
- testcase( i==91 ); /* RECURSIVE */
154018
- testcase( i==92 ); /* AFTER */
154019
- testcase( i==93 ); /* RENAME */
154020
- testcase( i==94 ); /* AND */
154021
- testcase( i==95 ); /* DEFAULT */
154022
- testcase( i==96 ); /* AUTOINCREMENT */
154023
- testcase( i==97 ); /* TO */
154024
- testcase( i==98 ); /* IN */
154025
- testcase( i==99 ); /* CAST */
154026
- testcase( i==100 ); /* COLUMN */
154027
- testcase( i==101 ); /* COMMIT */
154028
- testcase( i==102 ); /* CONFLICT */
154029
- testcase( i==103 ); /* CROSS */
154030
- testcase( i==104 ); /* CURRENT_TIMESTAMP */
154031
- testcase( i==105 ); /* CURRENT_TIME */
154032
- testcase( i==106 ); /* CURRENT */
154033
- testcase( i==107 ); /* PARTITION */
154034
- testcase( i==108 ); /* DEFERRED */
154035
- testcase( i==109 ); /* DISTINCT */
154036
- testcase( i==110 ); /* IS */
154037
- testcase( i==111 ); /* DROP */
154038
- testcase( i==112 ); /* PRECEDING */
154039
- testcase( i==113 ); /* FAIL */
154040
- testcase( i==114 ); /* FILTER */
154041
- testcase( i==115 ); /* REPLACE */
154042
- testcase( i==116 ); /* FOLLOWING */
154043
- testcase( i==117 ); /* FROM */
154044
- testcase( i==118 ); /* FULL */
154045
- testcase( i==119 ); /* IF */
154046
- testcase( i==120 ); /* ISNULL */
154047
- testcase( i==121 ); /* ORDER */
154048
- testcase( i==122 ); /* RESTRICT */
154049
- testcase( i==123 ); /* OTHERS */
154050
- testcase( i==124 ); /* OVER */
154051
- testcase( i==125 ); /* RIGHT */
154052
- testcase( i==126 ); /* ROLLBACK */
154053
- testcase( i==127 ); /* ROWS */
154054
- testcase( i==128 ); /* ROW */
154055
- testcase( i==129 ); /* UNBOUNDED */
154056
- testcase( i==130 ); /* UNION */
154057
- testcase( i==131 ); /* USING */
154058
- testcase( i==132 ); /* VACUUM */
154059
- testcase( i==133 ); /* VIEW */
154060
- testcase( i==134 ); /* WINDOW */
154061
- testcase( i==135 ); /* DO */
154062
- testcase( i==136 ); /* BY */
154063
- testcase( i==137 ); /* INITIALLY */
154064
- testcase( i==138 ); /* ALL */
154065
- testcase( i==139 ); /* PRIMARY */
154771
+ testcase( i==30 ); /* ISNULL */
154772
+ testcase( i==31 ); /* NULLS */
154773
+ testcase( i==32 ); /* SAVEPOINT */
154774
+ testcase( i==33 ); /* INTERSECT */
154775
+ testcase( i==34 ); /* TIES */
154776
+ testcase( i==35 ); /* NOTNULL */
154777
+ testcase( i==36 ); /* NOT */
154778
+ testcase( i==37 ); /* NO */
154779
+ testcase( i==38 ); /* NULL */
154780
+ testcase( i==39 ); /* LIKE */
154781
+ testcase( i==40 ); /* EXCEPT */
154782
+ testcase( i==41 ); /* TRANSACTION */
154783
+ testcase( i==42 ); /* ACTION */
154784
+ testcase( i==43 ); /* ON */
154785
+ testcase( i==44 ); /* NATURAL */
154786
+ testcase( i==45 ); /* ALTER */
154787
+ testcase( i==46 ); /* RAISE */
154788
+ testcase( i==47 ); /* EXCLUSIVE */
154789
+ testcase( i==48 ); /* EXISTS */
154790
+ testcase( i==49 ); /* CONSTRAINT */
154791
+ testcase( i==50 ); /* INTO */
154792
+ testcase( i==51 ); /* OFFSET */
154793
+ testcase( i==52 ); /* OF */
154794
+ testcase( i==53 ); /* SET */
154795
+ testcase( i==54 ); /* TRIGGER */
154796
+ testcase( i==55 ); /* REFERENCES */
154797
+ testcase( i==56 ); /* UNIQUE */
154798
+ testcase( i==57 ); /* QUERY */
154799
+ testcase( i==58 ); /* WITHOUT */
154800
+ testcase( i==59 ); /* WITH */
154801
+ testcase( i==60 ); /* OUTER */
154802
+ testcase( i==61 ); /* RELEASE */
154803
+ testcase( i==62 ); /* ATTACH */
154804
+ testcase( i==63 ); /* HAVING */
154805
+ testcase( i==64 ); /* GLOB */
154806
+ testcase( i==65 ); /* BEGIN */
154807
+ testcase( i==66 ); /* INNER */
154808
+ testcase( i==67 ); /* RANGE */
154809
+ testcase( i==68 ); /* BETWEEN */
154810
+ testcase( i==69 ); /* NOTHING */
154811
+ testcase( i==70 ); /* GROUPS */
154812
+ testcase( i==71 ); /* GROUP */
154813
+ testcase( i==72 ); /* CASCADE */
154814
+ testcase( i==73 ); /* ASC */
154815
+ testcase( i==74 ); /* DETACH */
154816
+ testcase( i==75 ); /* CASE */
154817
+ testcase( i==76 ); /* COLLATE */
154818
+ testcase( i==77 ); /* CREATE */
154819
+ testcase( i==78 ); /* CURRENT_DATE */
154820
+ testcase( i==79 ); /* IMMEDIATE */
154821
+ testcase( i==80 ); /* JOIN */
154822
+ testcase( i==81 ); /* INSERT */
154823
+ testcase( i==82 ); /* MATCH */
154824
+ testcase( i==83 ); /* PLAN */
154825
+ testcase( i==84 ); /* ANALYZE */
154826
+ testcase( i==85 ); /* PRAGMA */
154827
+ testcase( i==86 ); /* ABORT */
154828
+ testcase( i==87 ); /* UPDATE */
154829
+ testcase( i==88 ); /* VALUES */
154830
+ testcase( i==89 ); /* VIRTUAL */
154831
+ testcase( i==90 ); /* LAST */
154832
+ testcase( i==91 ); /* WHEN */
154833
+ testcase( i==92 ); /* WHERE */
154834
+ testcase( i==93 ); /* RECURSIVE */
154835
+ testcase( i==94 ); /* AFTER */
154836
+ testcase( i==95 ); /* RENAME */
154837
+ testcase( i==96 ); /* AND */
154838
+ testcase( i==97 ); /* DEFAULT */
154839
+ testcase( i==98 ); /* AUTOINCREMENT */
154840
+ testcase( i==99 ); /* TO */
154841
+ testcase( i==100 ); /* IN */
154842
+ testcase( i==101 ); /* CAST */
154843
+ testcase( i==102 ); /* COLUMN */
154844
+ testcase( i==103 ); /* COMMIT */
154845
+ testcase( i==104 ); /* CONFLICT */
154846
+ testcase( i==105 ); /* CROSS */
154847
+ testcase( i==106 ); /* CURRENT_TIMESTAMP */
154848
+ testcase( i==107 ); /* CURRENT_TIME */
154849
+ testcase( i==108 ); /* CURRENT */
154850
+ testcase( i==109 ); /* PARTITION */
154851
+ testcase( i==110 ); /* DEFERRED */
154852
+ testcase( i==111 ); /* DISTINCT */
154853
+ testcase( i==112 ); /* IS */
154854
+ testcase( i==113 ); /* DROP */
154855
+ testcase( i==114 ); /* PRECEDING */
154856
+ testcase( i==115 ); /* FAIL */
154857
+ testcase( i==116 ); /* LIMIT */
154858
+ testcase( i==117 ); /* FILTER */
154859
+ testcase( i==118 ); /* REPLACE */
154860
+ testcase( i==119 ); /* FIRST */
154861
+ testcase( i==120 ); /* FOLLOWING */
154862
+ testcase( i==121 ); /* FROM */
154863
+ testcase( i==122 ); /* FULL */
154864
+ testcase( i==123 ); /* IF */
154865
+ testcase( i==124 ); /* ORDER */
154866
+ testcase( i==125 ); /* RESTRICT */
154867
+ testcase( i==126 ); /* OTHERS */
154868
+ testcase( i==127 ); /* OVER */
154869
+ testcase( i==128 ); /* RIGHT */
154870
+ testcase( i==129 ); /* ROLLBACK */
154871
+ testcase( i==130 ); /* ROWS */
154872
+ testcase( i==131 ); /* ROW */
154873
+ testcase( i==132 ); /* UNBOUNDED */
154874
+ testcase( i==133 ); /* UNION */
154875
+ testcase( i==134 ); /* USING */
154876
+ testcase( i==135 ); /* VACUUM */
154877
+ testcase( i==136 ); /* VIEW */
154878
+ testcase( i==137 ); /* WINDOW */
154879
+ testcase( i==138 ); /* DO */
154880
+ testcase( i==139 ); /* BY */
154881
+ testcase( i==140 ); /* INITIALLY */
154882
+ testcase( i==141 ); /* ALL */
154883
+ testcase( i==142 ); /* PRIMARY */
154066154884
*pType = aKWCode[i];
154067154885
break;
154068154886
}
154069154887
}
154070154888
return n;
@@ -154072,11 +154890,11 @@
154072154890
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
154073154891
int id = TK_ID;
154074154892
keywordCode((char*)z, n, &id);
154075154893
return id;
154076154894
}
154077
-#define SQLITE_N_KEYWORD 140
154895
+#define SQLITE_N_KEYWORD 143
154078154896
SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
154079154897
if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
154080154898
*pzName = zKWText + aKWOffset[i];
154081154899
*pnName = aKWLen[i];
154082154900
return SQLITE_OK;
@@ -156033,10 +156851,11 @@
156033156851
int op; /* The opcode */
156034156852
u32 mask; /* Mask of the bit in sqlite3.flags to set/clear */
156035156853
} aFlagOp[] = {
156036156854
{ SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
156037156855
{ SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
156856
+ { SQLITE_DBCONFIG_ENABLE_VIEW, SQLITE_EnableView },
156038156857
{ SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
156039156858
{ SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
156040156859
{ SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
156041156860
{ SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
156042156861
{ SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP },
@@ -156432,15 +157251,12 @@
156432157251
}
156433157252
sqlite3HashClear(&db->aCollSeq);
156434157253
#ifndef SQLITE_OMIT_VIRTUALTABLE
156435157254
for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){
156436157255
Module *pMod = (Module *)sqliteHashData(i);
156437
- if( pMod->xDestroy ){
156438
- pMod->xDestroy(pMod->pAux);
156439
- }
156440157256
sqlite3VtabEponymousTableClear(db, pMod);
156441
- sqlite3DbFree(db, pMod);
157257
+ sqlite3VtabModuleUnref(db, pMod);
156442157258
}
156443157259
sqlite3HashClear(&db->aModule);
156444157260
#endif
156445157261
156446157262
sqlite3Error(db, SQLITE_OK); /* Deallocates any cached error strings. */
@@ -156917,11 +157733,12 @@
156917157733
){
156918157734
return SQLITE_MISUSE_BKPT;
156919157735
}
156920157736
156921157737
assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
156922
- extraFlags = enc & SQLITE_DETERMINISTIC;
157738
+ assert( SQLITE_FUNC_DIRECT==SQLITE_DIRECTONLY );
157739
+ extraFlags = enc & (SQLITE_DETERMINISTIC|SQLITE_DIRECTONLY);
156923157740
enc &= (SQLITE_FUNC_ENCMASK|SQLITE_ANY);
156924157741
156925157742
#ifndef SQLITE_OMIT_UTF16
156926157743
/* If SQLITE_UTF16 is specified as the encoding type, transform this
156927157744
** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
@@ -156980,10 +157797,11 @@
156980157797
pDestructor->nRef++;
156981157798
}
156982157799
p->u.pDestructor = pDestructor;
156983157800
p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags;
156984157801
testcase( p->funcFlags & SQLITE_DETERMINISTIC );
157802
+ testcase( p->funcFlags & SQLITE_DIRECTONLY );
156985157803
p->xSFunc = xSFunc ? xSFunc : xStep;
156986157804
p->xFinalize = xFinal;
156987157805
p->xValue = xValue;
156988157806
p->xInverse = xInverse;
156989157807
p->pUserData = pUserData;
@@ -158272,10 +159090,11 @@
158272159090
db->szMmap = sqlite3GlobalConfig.szMmap;
158273159091
db->nextPagesize = 0;
158274159092
db->nMaxSorterMmap = 0x7FFFFFFF;
158275159093
db->flags |= SQLITE_ShortColNames
158276159094
| SQLITE_EnableTrigger
159095
+ | SQLITE_EnableView
158277159096
| SQLITE_CacheSpill
158278159097
158279159098
/* The SQLITE_DQS compile-time option determines the default settings
158280159099
** for SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML.
158281159100
**
@@ -159021,16 +159840,37 @@
159021159840
case SQLITE_TESTCTRL_PRNG_RESTORE: {
159022159841
sqlite3PrngRestoreState();
159023159842
break;
159024159843
}
159025159844
159026
- /*
159027
- ** Reset the PRNG back to its uninitialized state. The next call
159028
- ** to sqlite3_randomness() will reseed the PRNG using a single call
159029
- ** to the xRandomness method of the default VFS.
159845
+ /* sqlite3_test_control(SQLITE_TESTCTRL_PRNG_SEED, int x, sqlite3 *db);
159846
+ **
159847
+ ** Control the seed for the pseudo-random number generator (PRNG) that
159848
+ ** is built into SQLite. Cases:
159849
+ **
159850
+ ** x!=0 && db!=0 Seed the PRNG to the current value of the
159851
+ ** schema cookie in the main database for db, or
159852
+ ** x if the schema cookie is zero. This case
159853
+ ** is convenient to use with database fuzzers
159854
+ ** as it allows the fuzzer some control over the
159855
+ ** the PRNG seed.
159856
+ **
159857
+ ** x!=0 && db==0 Seed the PRNG to the value of x.
159858
+ **
159859
+ ** x==0 && db==0 Revert to default behavior of using the
159860
+ ** xRandomness method on the primary VFS.
159861
+ **
159862
+ ** This test-control also resets the PRNG so that the new seed will
159863
+ ** be used for the next call to sqlite3_randomness().
159030159864
*/
159031
- case SQLITE_TESTCTRL_PRNG_RESET: {
159865
+ case SQLITE_TESTCTRL_PRNG_SEED: {
159866
+ int x = va_arg(ap, int);
159867
+ int y;
159868
+ sqlite3 *db = va_arg(ap, sqlite3*);
159869
+ assert( db==0 || db->aDb[0].pSchema!=0 );
159870
+ if( db && (y = db->aDb[0].pSchema->schema_cookie)!=0 ){ x = y; }
159871
+ sqlite3Config.iPrngSeed = x;
159032159872
sqlite3_randomness(0,0);
159033159873
break;
159034159874
}
159035159875
159036159876
/*
@@ -159238,10 +160078,21 @@
159238160078
*/
159239160079
case SQLITE_TESTCTRL_NEVER_CORRUPT: {
159240160080
sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int);
159241160081
break;
159242160082
}
160083
+
160084
+ /* sqlite3_test_control(SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS, int);
160085
+ **
160086
+ ** Set or clear a flag that causes SQLite to verify that type, name,
160087
+ ** and tbl_name fields of the sqlite_master table. This is normally
160088
+ ** on, but it is sometimes useful to turn it off for testing.
160089
+ */
160090
+ case SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS: {
160091
+ sqlite3GlobalConfig.bExtraSchemaChecks = va_arg(ap, int);
160092
+ break;
160093
+ }
159243160094
159244160095
/* Set the threshold at which OP_Once counters reset back to zero.
159245160096
** By default this is 0x7ffffffe (over 2 billion), but that value is
159246160097
** too big to test in a reasonable amount of time, so this control is
159247160098
** provided to set a small and easily reachable reset value.
@@ -174941,10 +175792,11 @@
174941175792
blobGrowBuffer(pPrev, nTerm, &rc);
174942175793
if( rc!=SQLITE_OK ) return rc;
174943175794
174944175795
nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);
174945175796
nSuffix = nTerm - nPrefix;
175797
+ if( nSuffix<=0 ) return FTS_CORRUPT_VTAB;
174946175798
memcpy(pPrev->a, zTerm, nTerm);
174947175799
pPrev->n = nTerm;
174948175800
174949175801
if( bFirst==0 ){
174950175802
pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);
@@ -177161,14 +178013,14 @@
177161178013
char *pCsr = pPhrase->pTail;
177162178014
int iCsr = pPhrase->iTail;
177163178015
177164178016
while( iCsr<(iStart+pIter->nSnippet) && iCsr>=iStart ){
177165178017
int j;
177166
- u64 mPhrase = (u64)1 << i;
178018
+ u64 mPhrase = (u64)1 << (i%64);
177167178019
u64 mPos = (u64)1 << (iCsr - iStart);
177168178020
assert( iCsr>=iStart && (iCsr - iStart)<=64 );
177169
- assert( i>=0 && i<=64 );
178021
+ assert( i>=0 );
177170178022
if( (mCover|mCovered)&mPhrase ){
177171178023
iScore++;
177172178024
}else{
177173178025
iScore += 1000;
177174178026
}
@@ -180325,10 +181177,11 @@
180325181177
){
180326181178
u32 i, j, nKey;
180327181179
const char *zKey;
180328181180
JsonNode *pRoot = &pParse->aNode[iRoot];
180329181181
if( zPath[0]==0 ) return pRoot;
181182
+ if( pRoot->jnFlags & JNODE_REPLACE ) return 0;
180330181183
if( zPath[0]=='.' ){
180331181184
if( pRoot->eType!=JSON_OBJECT ) return 0;
180332181185
zPath++;
180333181186
if( zPath[0]=='"' ){
180334181187
zKey = zPath + 1;
@@ -182455,18 +183308,20 @@
182455183308
182456183309
/* Check if the requested node is already in the hash table. If so,
182457183310
** increase its reference count and return it.
182458183311
*/
182459183312
if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
182460
- assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
182461183313
if( pParent && !pNode->pParent ){
182462183314
if( nodeInParentChain(pNode, pParent) ){
182463183315
RTREE_IS_CORRUPT(pRtree);
182464183316
return SQLITE_CORRUPT_VTAB;
182465183317
}
182466183318
pParent->nRef++;
182467183319
pNode->pParent = pParent;
183320
+ }else if( pParent && pNode->pParent && pParent!=pNode->pParent ){
183321
+ RTREE_IS_CORRUPT(pRtree);
183322
+ return SQLITE_CORRUPT_VTAB;
182468183323
}
182469183324
pNode->nRef++;
182470183325
*ppNode = pNode;
182471183326
return SQLITE_OK;
182472183327
}
@@ -183350,17 +184205,18 @@
183350184205
int eInt;
183351184206
RtreeSearchPoint x;
183352184207
183353184208
eInt = pRtree->eCoordType==RTREE_COORD_INT32;
183354184209
while( (p = rtreeSearchPointFirst(pCur))!=0 && p->iLevel>0 ){
184210
+ u8 *pCellData;
183355184211
pNode = rtreeNodeOfFirstSearchPoint(pCur, &rc);
183356184212
if( rc ) return rc;
183357184213
nCell = NCELL(pNode);
183358184214
assert( nCell<200 );
184215
+ pCellData = pNode->zData + (4+pRtree->nBytesPerCell*p->iCell);
183359184216
while( p->iCell<nCell ){
183360184217
sqlite3_rtree_dbl rScore = (sqlite3_rtree_dbl)-1;
183361
- u8 *pCellData = pNode->zData + (4+pRtree->nBytesPerCell*p->iCell);
183362184218
eWithin = FULLY_WITHIN;
183363184219
for(ii=0; ii<nConstraint; ii++){
183364184220
RtreeConstraint *pConstraint = pCur->aConstraint + ii;
183365184221
if( pConstraint->op>=RTREE_MATCH ){
183366184222
rc = rtreeCallbackConstraint(pConstraint, eInt, pCellData, p,
@@ -183369,17 +184225,27 @@
183369184225
}else if( p->iLevel==1 ){
183370184226
rtreeLeafConstraint(pConstraint, eInt, pCellData, &eWithin);
183371184227
}else{
183372184228
rtreeNonleafConstraint(pConstraint, eInt, pCellData, &eWithin);
183373184229
}
183374
- if( eWithin==NOT_WITHIN ) break;
184230
+ if( eWithin==NOT_WITHIN ){
184231
+ p->iCell++;
184232
+ pCellData += pRtree->nBytesPerCell;
184233
+ break;
184234
+ }
183375184235
}
183376
- p->iCell++;
183377184236
if( eWithin==NOT_WITHIN ) continue;
184237
+ p->iCell++;
183378184238
x.iLevel = p->iLevel - 1;
183379184239
if( x.iLevel ){
183380184240
x.id = readInt64(pCellData);
184241
+ for(ii=0; ii<pCur->nPoint; ii++){
184242
+ if( pCur->aPoint[ii].id==x.id ){
184243
+ RTREE_IS_CORRUPT(pRtree);
184244
+ return SQLITE_CORRUPT_VTAB;
184245
+ }
184246
+ }
183381184247
x.iCell = 0;
183382184248
}else{
183383184249
x.id = p->id;
183384184250
x.iCell = p->iCell - 1;
183385184251
}
@@ -189683,10 +190549,11 @@
189683190549
"CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)"
189684190550
189685190551
typedef struct RbuFrame RbuFrame;
189686190552
typedef struct RbuObjIter RbuObjIter;
189687190553
typedef struct RbuState RbuState;
190554
+typedef struct RbuSpan RbuSpan;
189688190555
typedef struct rbu_vfs rbu_vfs;
189689190556
typedef struct rbu_file rbu_file;
189690190557
typedef struct RbuUpdateStmt RbuUpdateStmt;
189691190558
189692190559
#if !defined(SQLITE_AMALGAMATION)
@@ -189726,10 +190593,15 @@
189726190593
struct RbuUpdateStmt {
189727190594
char *zMask; /* Copy of update mask used with pUpdate */
189728190595
sqlite3_stmt *pUpdate; /* Last update statement (or NULL) */
189729190596
RbuUpdateStmt *pNext;
189730190597
};
190598
+
190599
+struct RbuSpan {
190600
+ const char *zSpan;
190601
+ int nSpan;
190602
+};
189731190603
189732190604
/*
189733190605
** An iterator of this type is used to iterate through all objects in
189734190606
** the target database that require updating. For each such table, the
189735190607
** iterator visits, in order:
@@ -189776,10 +190648,13 @@
189776190648
int nCol; /* Number of columns in current object */
189777190649
sqlite3_stmt *pSelect; /* Source data */
189778190650
sqlite3_stmt *pInsert; /* Statement for INSERT operations */
189779190651
sqlite3_stmt *pDelete; /* Statement for DELETE ops */
189780190652
sqlite3_stmt *pTmpInsert; /* Insert into rbu_tmp_$zDataTbl */
190653
+ int nIdxCol;
190654
+ RbuSpan *aIdxCol;
190655
+ char *zIdxSql;
189781190656
189782190657
/* Last UPDATE used (for PK b-tree updates only), or NULL. */
189783190658
RbuUpdateStmt *pRbuUpdate;
189784190659
};
189785190660
@@ -190310,17 +191185,22 @@
190310191185
RbuUpdateStmt *pTmp = pUp->pNext;
190311191186
sqlite3_finalize(pUp->pUpdate);
190312191187
sqlite3_free(pUp);
190313191188
pUp = pTmp;
190314191189
}
191190
+ sqlite3_free(pIter->aIdxCol);
191191
+ sqlite3_free(pIter->zIdxSql);
190315191192
190316191193
pIter->pSelect = 0;
190317191194
pIter->pInsert = 0;
190318191195
pIter->pDelete = 0;
190319191196
pIter->pRbuUpdate = 0;
190320191197
pIter->pTmpInsert = 0;
190321191198
pIter->nCol = 0;
191199
+ pIter->nIdxCol = 0;
191200
+ pIter->aIdxCol = 0;
191201
+ pIter->zIdxSql = 0;
190322191202
}
190323191203
190324191204
/*
190325191205
** Clean up any resources allocated as part of the iterator object passed
190326191206
** as the only argument.
@@ -190431,12 +191311,12 @@
190431191311
assert( argc==1 || argc==2 );
190432191312
190433191313
zIn = (const char*)sqlite3_value_text(argv[0]);
190434191314
if( zIn ){
190435191315
if( rbuIsVacuum(p) ){
190436
- assert( argc==2 );
190437
- if( 0==sqlite3_value_int(argv[1]) ){
191316
+ assert( argc==2 || argc==1 );
191317
+ if( argc==1 || 0==sqlite3_value_int(argv[1]) ){
190438191318
sqlite3_result_text(pCtx, zIn, -1, SQLITE_STATIC);
190439191319
}
190440191320
}else{
190441191321
if( strlen(zIn)>4 && memcmp("data", zIn, 4)==0 ){
190442191322
int i;
@@ -190590,18 +191470,19 @@
190590191470
** if the allocation succeeds, (*pRc) is left unchanged.
190591191471
*/
190592191472
static char *rbuStrndup(const char *zStr, int *pRc){
190593191473
char *zRet = 0;
190594191474
190595
- assert( *pRc==SQLITE_OK );
190596
- if( zStr ){
190597
- size_t nCopy = strlen(zStr) + 1;
190598
- zRet = (char*)sqlite3_malloc64(nCopy);
190599
- if( zRet ){
190600
- memcpy(zRet, zStr, nCopy);
190601
- }else{
190602
- *pRc = SQLITE_NOMEM;
191475
+ if( *pRc==SQLITE_OK ){
191476
+ if( zStr ){
191477
+ size_t nCopy = strlen(zStr) + 1;
191478
+ zRet = (char*)sqlite3_malloc64(nCopy);
191479
+ if( zRet ){
191480
+ memcpy(zRet, zStr, nCopy);
191481
+ }else{
191482
+ *pRc = SQLITE_NOMEM;
191483
+ }
190603191484
}
190604191485
}
190605191486
190606191487
return zRet;
190607191488
}
@@ -190769,10 +191650,13 @@
190769191650
sqlite3_mprintf("PRAGMA main.index_xinfo = %Q", zIdx)
190770191651
);
190771191652
while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){
190772191653
int iCid = sqlite3_column_int(pXInfo, 1);
190773191654
if( iCid>=0 ) pIter->abIndexed[iCid] = 1;
191655
+ if( iCid==-2 ){
191656
+ memset(pIter->abIndexed, 0x01, sizeof(u8)*pIter->nTblCol);
191657
+ }
190774191658
}
190775191659
rbuFinalize(p, pXInfo);
190776191660
bIndex = 1;
190777191661
pIter->nIndex++;
190778191662
}
@@ -191180,33 +192064,41 @@
191180192064
191181192065
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){
191182192066
int iCid = sqlite3_column_int(pXInfo, 1);
191183192067
int bDesc = sqlite3_column_int(pXInfo, 3);
191184192068
const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4);
191185
- const char *zCol;
192069
+ const char *zCol = 0;
191186192070
const char *zType;
191187192071
191188
- if( iCid<0 ){
191189
- /* An integer primary key. If the table has an explicit IPK, use
191190
- ** its name. Otherwise, use "rbu_rowid". */
191191
- if( pIter->eType==RBU_PK_IPK ){
191192
- int i;
191193
- for(i=0; pIter->abTblPk[i]==0; i++);
191194
- assert( i<pIter->nTblCol );
191195
- zCol = pIter->azTblCol[i];
191196
- }else if( rbuIsVacuum(p) ){
191197
- zCol = "_rowid_";
191198
- }else{
191199
- zCol = "rbu_rowid";
191200
- }
191201
- zType = "INTEGER";
191202
- }else{
191203
- zCol = pIter->azTblCol[iCid];
191204
- zType = pIter->azTblType[iCid];
191205
- }
191206
-
191207
- zRet = sqlite3_mprintf("%z%s\"%w\" COLLATE %Q", zRet, zCom, zCol, zCollate);
192072
+ if( iCid==-2 ){
192073
+ int iSeq = sqlite3_column_int(pXInfo, 0);
192074
+ zRet = sqlite3_mprintf("%z%s(%.*s) COLLATE %Q", zRet, zCom,
192075
+ pIter->aIdxCol[iSeq].nSpan, pIter->aIdxCol[iSeq].zSpan, zCollate
192076
+ );
192077
+ zType = "";
192078
+ }else {
192079
+ if( iCid<0 ){
192080
+ /* An integer primary key. If the table has an explicit IPK, use
192081
+ ** its name. Otherwise, use "rbu_rowid". */
192082
+ if( pIter->eType==RBU_PK_IPK ){
192083
+ int i;
192084
+ for(i=0; pIter->abTblPk[i]==0; i++);
192085
+ assert( i<pIter->nTblCol );
192086
+ zCol = pIter->azTblCol[i];
192087
+ }else if( rbuIsVacuum(p) ){
192088
+ zCol = "_rowid_";
192089
+ }else{
192090
+ zCol = "rbu_rowid";
192091
+ }
192092
+ zType = "INTEGER";
192093
+ }else{
192094
+ zCol = pIter->azTblCol[iCid];
192095
+ zType = pIter->azTblType[iCid];
192096
+ }
192097
+ zRet = sqlite3_mprintf("%z%s\"%w\" COLLATE %Q", zRet, zCom,zCol,zCollate);
192098
+ }
192099
+
191208192100
if( pIter->bUnique==0 || sqlite3_column_int(pXInfo, 5) ){
191209192101
const char *zOrder = (bDesc ? " DESC" : "");
191210192102
zImpPK = sqlite3_mprintf("%z%s\"rbu_imp_%d%w\"%s",
191211192103
zImpPK, zCom, nBind, zCol, zOrder
191212192104
);
@@ -191682,34 +192574,65 @@
191682192574
static char *rbuObjIterGetIndexWhere(sqlite3rbu *p, RbuObjIter *pIter){
191683192575
sqlite3_stmt *pStmt = 0;
191684192576
int rc = p->rc;
191685192577
char *zRet = 0;
191686192578
192579
+ assert( pIter->zIdxSql==0 && pIter->nIdxCol==0 && pIter->aIdxCol==0 );
192580
+
191687192581
if( rc==SQLITE_OK ){
191688192582
rc = prepareAndCollectError(p->dbMain, &pStmt, &p->zErrmsg,
191689192583
"SELECT trim(sql) FROM sqlite_master WHERE type='index' AND name=?"
191690192584
);
191691192585
}
191692192586
if( rc==SQLITE_OK ){
191693192587
int rc2;
191694192588
rc = sqlite3_bind_text(pStmt, 1, pIter->zIdx, -1, SQLITE_STATIC);
191695192589
if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
191696
- const char *zSql = (const char*)sqlite3_column_text(pStmt, 0);
192590
+ char *zSql = (char*)sqlite3_column_text(pStmt, 0);
192591
+ if( zSql ){
192592
+ pIter->zIdxSql = zSql = rbuStrndup(zSql, &rc);
192593
+ }
191697192594
if( zSql ){
191698192595
int nParen = 0; /* Number of open parenthesis */
191699192596
int i;
192597
+ int iIdxCol = 0;
192598
+ int nIdxAlloc = 0;
191700192599
for(i=0; zSql[i]; i++){
191701192600
char c = zSql[i];
192601
+
192602
+ /* If necessary, grow the pIter->aIdxCol[] array */
192603
+ if( iIdxCol==nIdxAlloc ){
192604
+ RbuSpan *aIdxCol = (RbuSpan*)sqlite3_realloc(
192605
+ pIter->aIdxCol, (nIdxAlloc+16)*sizeof(RbuSpan)
192606
+ );
192607
+ if( aIdxCol==0 ){
192608
+ rc = SQLITE_NOMEM;
192609
+ break;
192610
+ }
192611
+ pIter->aIdxCol = aIdxCol;
192612
+ nIdxAlloc += 16;
192613
+ }
192614
+
191702192615
if( c=='(' ){
192616
+ if( nParen==0 ){
192617
+ assert( iIdxCol==0 );
192618
+ pIter->aIdxCol[0].zSpan = &zSql[i+1];
192619
+ }
191703192620
nParen++;
191704192621
}
191705192622
else if( c==')' ){
191706192623
nParen--;
191707192624
if( nParen==0 ){
192625
+ int nSpan = &zSql[i] - pIter->aIdxCol[iIdxCol].zSpan;
192626
+ pIter->aIdxCol[iIdxCol++].nSpan = nSpan;
191708192627
i++;
191709192628
break;
191710192629
}
192630
+ }else if( c==',' && nParen==1 ){
192631
+ int nSpan = &zSql[i] - pIter->aIdxCol[iIdxCol].zSpan;
192632
+ pIter->aIdxCol[iIdxCol++].nSpan = nSpan;
192633
+ pIter->aIdxCol[iIdxCol].zSpan = &zSql[i+1];
191711192634
}else if( c=='"' || c=='\'' || c=='`' ){
191712192635
for(i++; 1; i++){
191713192636
if( zSql[i]==c ){
191714192637
if( zSql[i+1]!=c ) break;
191715192638
i++;
@@ -191717,15 +192640,23 @@
191717192640
}
191718192641
}else if( c=='[' ){
191719192642
for(i++; 1; i++){
191720192643
if( zSql[i]==']' ) break;
191721192644
}
192645
+ }else if( c=='-' && zSql[i+1]=='-' ){
192646
+ for(i=i+2; zSql[i] && zSql[i]!='\n'; i++);
192647
+ if( zSql[i]=='\0' ) break;
192648
+ }else if( c=='/' && zSql[i+1]=='*' ){
192649
+ for(i=i+2; zSql[i] && (zSql[i]!='*' || zSql[i+1]!='/'); i++);
192650
+ if( zSql[i]=='\0' ) break;
192651
+ i++;
191722192652
}
191723192653
}
191724192654
if( zSql[i] ){
191725192655
zRet = rbuStrndup(&zSql[i], &rc);
191726192656
}
192657
+ pIter->nIdxCol = iIdxCol;
191727192658
}
191728192659
}
191729192660
191730192661
rc2 = sqlite3_finalize(pStmt);
191731192662
if( rc==SQLITE_OK ) rc = rc2;
@@ -191766,15 +192697,15 @@
191766192697
char *zBind = 0;
191767192698
char *zPart = 0;
191768192699
int nBind = 0;
191769192700
191770192701
assert( pIter->eType!=RBU_PK_VTAB );
192702
+ zPart = rbuObjIterGetIndexWhere(p, pIter);
191771192703
zCollist = rbuObjIterGetIndexCols(
191772192704
p, pIter, &zImposterCols, &zImposterPK, &zWhere, &nBind
191773192705
);
191774192706
zBind = rbuObjIterGetBindlist(p, nBind);
191775
- zPart = rbuObjIterGetIndexWhere(p, pIter);
191776192707
191777192708
/* Create the imposter table used to write to this index. */
191778192709
sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, "main", 0, 1);
191779192710
sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, "main", 1,tnum);
191780192711
rbuMPrintfExec(p, p->dbMain,
@@ -193296,14 +194227,15 @@
193296194227
){
193297194228
sqlite3rbu *p = (sqlite3rbu*)sqlite3_user_data(pCtx);
193298194229
sqlite3_stmt *pStmt = 0;
193299194230
char *zErrmsg = 0;
193300194231
int rc;
194232
+ sqlite3 *db = (rbuIsVacuum(p) ? p->dbRbu : p->dbMain);
193301194233
193302194234
assert( nVal==1 );
193303194235
193304
- rc = prepareFreeAndCollectError(p->dbMain, &pStmt, &zErrmsg,
194236
+ rc = prepareFreeAndCollectError(db, &pStmt, &zErrmsg,
193305194237
sqlite3_mprintf("SELECT count(*) FROM sqlite_master "
193306194238
"WHERE type='index' AND tbl_name = %Q", sqlite3_value_text(apVal[0]))
193307194239
);
193308194240
if( rc!=SQLITE_OK ){
193309194241
sqlite3_result_error(pCtx, zErrmsg, -1);
@@ -193314,11 +194246,11 @@
193314194246
}
193315194247
rc = sqlite3_finalize(pStmt);
193316194248
if( rc==SQLITE_OK ){
193317194249
sqlite3_result_int(pCtx, nIndex);
193318194250
}else{
193319
- sqlite3_result_error(pCtx, sqlite3_errmsg(p->dbMain), -1);
194251
+ sqlite3_result_error(pCtx, sqlite3_errmsg(db), -1);
193320194252
}
193321194253
}
193322194254
193323194255
sqlite3_free(zErrmsg);
193324194256
}
@@ -197757,11 +198689,11 @@
197757198689
if( *pRc==SQLITE_OK && (size_t)(p->nAlloc-p->nBuf)<nByte ){
197758198690
u8 *aNew;
197759198691
i64 nNew = p->nAlloc ? p->nAlloc : 128;
197760198692
do {
197761198693
nNew = nNew*2;
197762
- }while( (nNew-p->nBuf)<nByte );
198694
+ }while( (size_t)(nNew-p->nBuf)<nByte );
197763198695
197764198696
aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);
197765198697
if( 0==aNew ){
197766198698
*pRc = SQLITE_NOMEM;
197767198699
}else{
@@ -202158,10 +203090,11 @@
202158203090
int bColumnsize; /* "columnsize=" option value (dflt==1) */
202159203091
int eDetail; /* FTS5_DETAIL_XXX value */
202160203092
char *zContentExprlist;
202161203093
Fts5Tokenizer *pTok;
202162203094
fts5_tokenizer *pTokApi;
203095
+ int bLock; /* True when table is preparing statement */
202163203096
202164203097
/* Values loaded from the %_config table */
202165203098
int iCookie; /* Incremented when %_config is modified */
202166203099
int pgsz; /* Approximate page size used in %_data */
202167203100
int nAutomerge; /* 'automerge' setting */
@@ -203525,19 +204458,22 @@
203525204458
fts5yycoverage[stateno][iLookAhead] = 1;
203526204459
#endif
203527204460
do{
203528204461
i = fts5yy_shift_ofst[stateno];
203529204462
assert( i>=0 );
203530
- /* assert( i+fts5YYNFTS5TOKEN<=(int)fts5YY_NLOOKAHEAD ); */
204463
+ assert( i<=fts5YY_ACTTAB_COUNT );
204464
+ assert( i+fts5YYNFTS5TOKEN<=(int)fts5YY_NLOOKAHEAD );
203531204465
assert( iLookAhead!=fts5YYNOCODE );
203532204466
assert( iLookAhead < fts5YYNFTS5TOKEN );
203533204467
i += iLookAhead;
203534
- if( i>=fts5YY_NLOOKAHEAD || fts5yy_lookahead[i]!=iLookAhead ){
204468
+ assert( i<(int)fts5YY_NLOOKAHEAD );
204469
+ if( fts5yy_lookahead[i]!=iLookAhead ){
203535204470
#ifdef fts5YYFALLBACK
203536204471
fts5YYCODETYPE iFallback; /* Fallback token */
203537
- if( iLookAhead<sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])
203538
- && (iFallback = fts5yyFallback[iLookAhead])!=0 ){
204472
+ assert( iLookAhead<sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0]) );
204473
+ iFallback = fts5yyFallback[iLookAhead];
204474
+ if( iFallback!=0 ){
203539204475
#ifndef NDEBUG
203540204476
if( fts5yyTraceFILE ){
203541204477
fprintf(fts5yyTraceFILE, "%sFALLBACK %s => %s\n",
203542204478
fts5yyTracePrompt, fts5yyTokenName[iLookAhead], fts5yyTokenName[iFallback]);
203543204479
}
@@ -203548,20 +204484,12 @@
203548204484
}
203549204485
#endif
203550204486
#ifdef fts5YYWILDCARD
203551204487
{
203552204488
int j = i - iLookAhead + fts5YYWILDCARD;
203553
- if(
203554
-#if fts5YY_SHIFT_MIN+fts5YYWILDCARD<0
203555
- j>=0 &&
203556
-#endif
203557
-#if fts5YY_SHIFT_MAX+fts5YYWILDCARD>=fts5YY_ACTTAB_COUNT
203558
- j<fts5YY_ACTTAB_COUNT &&
203559
-#endif
203560
- j<(int)(sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0])) &&
203561
- fts5yy_lookahead[j]==fts5YYWILDCARD && iLookAhead>0
203562
- ){
204489
+ assert( j<(int)(sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0])) );
204490
+ if( fts5yy_lookahead[j]==fts5YYWILDCARD && iLookAhead>0 ){
203563204491
#ifndef NDEBUG
203564204492
if( fts5yyTraceFILE ){
203565204493
fprintf(fts5yyTraceFILE, "%sWILDCARD %s => %s\n",
203566204494
fts5yyTracePrompt, fts5yyTokenName[iLookAhead],
203567204495
fts5yyTokenName[fts5YYWILDCARD]);
@@ -203571,10 +204499,11 @@
203571204499
}
203572204500
}
203573204501
#endif /* fts5YYWILDCARD */
203574204502
return fts5yy_default[stateno];
203575204503
}else{
204504
+ assert( i>=0 && i<sizeof(fts5yy_action)/sizeof(fts5yy_action[0]) );
203576204505
return fts5yy_action[i];
203577204506
}
203578204507
}while(1);
203579204508
}
203580204509
@@ -204271,13 +205200,12 @@
204271205200
** Return the fallback token corresponding to canonical token iToken, or
204272205201
** 0 if iToken has no fallback.
204273205202
*/
204274205203
static int sqlite3Fts5ParserFallback(int iToken){
204275205204
#ifdef fts5YYFALLBACK
204276
- if( iToken<(int)(sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])) ){
204277
- return fts5yyFallback[iToken];
204278
- }
205205
+ assert( iToken<(int)(sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])) );
205206
+ return fts5yyFallback[iToken];
204279205207
#else
204280205208
(void)iToken;
204281205209
#endif
204282205210
return 0;
204283205211
}
@@ -210470,10 +211398,11 @@
210470211398
sqlite3_free(pRet);
210471211399
pRet = 0;
210472211400
}else{
210473211401
/* TODO1: Fix this */
210474211402
pRet->p[nByte] = 0x00;
211403
+ pRet->p[nByte+1] = 0x00;
210475211404
pRet->szLeaf = fts5GetU16(&pRet->p[2]);
210476211405
}
210477211406
}
210478211407
p->rc = rc;
210479211408
p->nRead++;
@@ -214776,13 +215705,16 @@
214776215705
214777215706
i64 iPrev = 0;
214778215707
Fts5PoslistWriter writer;
214779215708
memset(&writer, 0, sizeof(writer));
214780215709
215710
+ /* See the earlier comment in this function for an explanation of why
215711
+ ** corrupt input position lists might cause the output to consume
215712
+ ** at most 20 bytes of unexpected space. */
214781215713
fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);
214782215714
fts5BufferZero(&tmp);
214783
- sqlite3Fts5BufferSize(&p->rc, &tmp, i1.nPoslist + i2.nPoslist);
215715
+ sqlite3Fts5BufferSize(&p->rc, &tmp, i1.nPoslist + i2.nPoslist + 10 + 10);
214784215716
if( p->rc ) break;
214785215717
214786215718
sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);
214787215719
sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);
214788215720
assert_nc( iPos1>=0 && iPos2>=0 );
@@ -214826,10 +215758,16 @@
214826215758
if( nCopy>0 ){
214827215759
fts5BufferSafeAppendBlob(&tmp, aCopy, nCopy);
214828215760
}
214829215761
214830215762
/* WRITEPOSLISTSIZE */
215763
+ assert_nc( tmp.n<=i1.nPoslist+i2.nPoslist );
215764
+ assert( tmp.n<=i1.nPoslist+i2.nPoslist+10+10 );
215765
+ if( tmp.n>i1.nPoslist+i2.nPoslist ){
215766
+ if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT;
215767
+ break;
215768
+ }
214831215769
fts5BufferSafeAppendVarint(&out, tmp.n * 2);
214832215770
fts5BufferSafeAppendBlob(&out, tmp.p, tmp.n);
214833215771
fts5DoclistIterNext(&i1);
214834215772
fts5DoclistIterNext(&i2);
214835215773
assert_nc( out.n<=(p1->n+p2->n+9) );
@@ -216897,10 +217835,17 @@
216897217835
assert( SQLITE_INDEX_CONSTRAINT_EQ<SQLITE_INDEX_CONSTRAINT_MATCH );
216898217836
assert( SQLITE_INDEX_CONSTRAINT_GT<SQLITE_INDEX_CONSTRAINT_MATCH );
216899217837
assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH );
216900217838
assert( SQLITE_INDEX_CONSTRAINT_GE<SQLITE_INDEX_CONSTRAINT_MATCH );
216901217839
assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH );
217840
+
217841
+ if( pConfig->bLock ){
217842
+ pTab->base.zErrMsg = sqlite3_mprintf(
217843
+ "recursively defined fts5 content table"
217844
+ );
217845
+ return SQLITE_ERROR;
217846
+ }
216902217847
216903217848
/* Set idxFlags flags for all WHERE clause terms that will be used. */
216904217849
for(i=0; i<pInfo->nConstraint; i++){
216905217850
struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];
216906217851
int iCol = p->iColumn;
@@ -217287,11 +218232,11 @@
217287218232
** And since the statement required here reads from this very virtual
217288218233
** table, saving it creates a circular reference.
217289218234
**
217290218235
** If SQLite a built-in statement cache, this wouldn't be a problem. */
217291218236
rc = fts5PrepareStatement(&pSorter->pStmt, pConfig,
217292
- "SELECT rowid, rank FROM %Q.%Q ORDER BY %s(%s%s%s) %s",
218237
+ "SELECT rowid, rank FROM %Q.%Q ORDER BY %s(\"%w\"%s%s) %s",
217293218238
pConfig->zDb, pConfig->zName, zRank, pConfig->zName,
217294218239
(zRankArgs ? ", " : ""),
217295218240
(zRankArgs ? zRankArgs : ""),
217296218241
bDesc ? "DESC" : "ASC"
217297218242
);
@@ -217343,14 +218288,14 @@
217343218288
for(n=0; z[n] && z[n]!=' '; n++);
217344218289
217345218290
assert( pTab->p.base.zErrMsg==0 );
217346218291
pCsr->ePlan = FTS5_PLAN_SPECIAL;
217347218292
217348
- if( 0==sqlite3_strnicmp("reads", z, n) ){
218293
+ if( n==5 && 0==sqlite3_strnicmp("reads", z, n) ){
217349218294
pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->p.pIndex);
217350218295
}
217351
- else if( 0==sqlite3_strnicmp("id", z, n) ){
218296
+ else if( n==2 && 0==sqlite3_strnicmp("id", z, n) ){
217352218297
pCsr->iSpecial = pCsr->iCsrId;
217353218298
}
217354218299
else{
217355218300
/* An unrecognized directive. Return an error message. */
217356218301
pTab->p.base.zErrMsg = sqlite3_mprintf("unknown special query: %.*s", n, z);
@@ -218594,11 +219539,11 @@
218594219539
assert( argc>=1 );
218595219540
pAux = (Fts5Auxiliary*)sqlite3_user_data(context);
218596219541
iCsrId = sqlite3_value_int64(argv[0]);
218597219542
218598219543
pCsr = fts5CursorFromCsrid(pAux->pGlobal, iCsrId);
218599
- if( pCsr==0 ){
219544
+ if( pCsr==0 || pCsr->ePlan==0 ){
218600219545
char *zErr = sqlite3_mprintf("no such cursor: %lld", iCsrId);
218601219546
sqlite3_result_error(context, zErr, -1);
218602219547
sqlite3_free(zErr);
218603219548
}else{
218604219549
fts5ApiInvoke(pAux, pCsr, context, argc-1, &argv[1]);
@@ -219010,11 +219955,11 @@
219010219955
int nArg, /* Number of args */
219011219956
sqlite3_value **apUnused /* Function arguments */
219012219957
){
219013219958
assert( nArg==0 );
219014219959
UNUSED_PARAM2(nArg, apUnused);
219015
- sqlite3_result_text(pCtx, "fts5: 2019-07-10 17:32:03 fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6", -1, SQLITE_TRANSIENT);
219960
+ sqlite3_result_text(pCtx, "fts5: 2019-09-03 16:23:41 3044cf6917ea8324175fc91657e9a5978af9748f72e1914bc361753f0b2d897d", -1, SQLITE_TRANSIENT);
219016219961
}
219017219962
219018219963
/*
219019219964
** Return true if zName is the extension on one of the shadow tables used
219020219965
** by this module.
@@ -219282,11 +220227,13 @@
219282220227
if( zSql==0 ){
219283220228
rc = SQLITE_NOMEM;
219284220229
}else{
219285220230
int f = SQLITE_PREPARE_PERSISTENT;
219286220231
if( eStmt>FTS5_STMT_LOOKUP ) f |= SQLITE_PREPARE_NO_VTAB;
220232
+ p->pConfig->bLock++;
219287220233
rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);
220234
+ p->pConfig->bLock--;
219288220235
sqlite3_free(zSql);
219289220236
if( rc!=SQLITE_OK && pzErrMsg ){
219290220237
*pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
219291220238
}
219292220239
}
@@ -223776,12 +224723,12 @@
223776224723
}
223777224724
#endif /* SQLITE_CORE */
223778224725
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
223779224726
223780224727
/************** End of stmt.c ************************************************/
223781
-#if __LINE__!=223781
224728
+#if __LINE__!=224728
223782224729
#undef SQLITE_SOURCE_ID
223783
-#define SQLITE_SOURCE_ID "2019-07-10 17:32:03 fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88alt2"
224730
+#define SQLITE_SOURCE_ID "2019-09-03 16:23:41 3044cf6917ea8324175fc91657e9a5978af9748f72e1914bc361753f0b2dalt2"
223784224731
#endif
223785224732
/* Return the source-id for this library */
223786224733
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
223787224734
/************************** End of sqlite3.c ******************************/
223788224735
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.29.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -329,12 +329,10 @@
329 #if SQLITE_ENABLE_SQLLOG
330 "ENABLE_SQLLOG",
331 #endif
332 #if defined(SQLITE_ENABLE_STAT4)
333 "ENABLE_STAT4",
334 #elif defined(SQLITE_ENABLE_STAT3)
335 "ENABLE_STAT3",
336 #endif
337 #if SQLITE_ENABLE_STMTVTAB
338 "ENABLE_STMTVTAB",
339 #endif
340 #if SQLITE_ENABLE_STMT_SCANSTATUS
@@ -1165,13 +1163,13 @@
1165 **
1166 ** See also: [sqlite3_libversion()],
1167 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1168 ** [sqlite_version()] and [sqlite_source_id()].
1169 */
1170 #define SQLITE_VERSION "3.29.0"
1171 #define SQLITE_VERSION_NUMBER 3029000
1172 #define SQLITE_SOURCE_ID "2019-07-10 17:32:03 fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6"
1173
1174 /*
1175 ** CAPI3REF: Run-Time Library Version Numbers
1176 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1177 **
@@ -3135,10 +3133,21 @@
3135 ** The second parameter is a pointer to an integer into which
3136 ** is written 0 or 1 to indicate whether triggers are disabled or enabled
3137 ** following this call. The second parameter may be a NULL pointer, in
3138 ** which case the trigger setting is not reported back. </dd>
3139 **
 
 
 
 
 
 
 
 
 
 
 
3140 ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
3141 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
3142 ** <dd> ^This option is used to enable or disable the
3143 ** [fts3_tokenizer()] function which is part of the
3144 ** [FTS3] full-text search engine extension.
@@ -3307,11 +3316,12 @@
3307 #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
3308 #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
3309 #define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
3310 #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
3311 #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
3312 #define SQLITE_DBCONFIG_MAX 1014 /* Largest DBCONFIG */
 
3313
3314 /*
3315 ** CAPI3REF: Enable Or Disable Extended Result Codes
3316 ** METHOD: sqlite3
3317 **
@@ -4856,11 +4866,11 @@
4856 ** a schema change, on the first [sqlite3_step()] call following any change
4857 ** to the [sqlite3_bind_text | bindings] of that [parameter].
4858 ** ^The specific value of WHERE-clause [parameter] might influence the
4859 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
4860 ** or [GLOB] operator or if the parameter is compared to an indexed column
4861 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
4862 ** </li>
4863 ** </ol>
4864 **
4865 ** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
4866 ** the extra prepFlags parameter, which is a bit array consisting of zero or
@@ -5890,10 +5900,13 @@
5890 ** the same inputs within a single SQL statement. Most SQL functions are
5891 ** deterministic. The built-in [random()] SQL function is an example of a
5892 ** function that is not deterministic. The SQLite query planner is able to
5893 ** perform additional optimizations on deterministic functions, so use
5894 ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
 
 
 
5895 **
5896 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
5897 ** function can gain access to this pointer using [sqlite3_user_data()].)^
5898 **
5899 ** ^The sixth, seventh and eighth parameters passed to the three
@@ -6007,12 +6020,20 @@
6007 **
6008 ** These constants may be ORed together with the
6009 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
6010 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or
6011 ** [sqlite3_create_function_v2()].
 
 
 
 
 
 
 
6012 */
6013 #define SQLITE_DETERMINISTIC 0x800
 
6014
6015 /*
6016 ** CAPI3REF: Deprecated Functions
6017 ** DEPRECATED
6018 **
@@ -7654,10 +7675,16 @@
7654 ** no longer needs the pClientData pointer. ^The destructor will also
7655 ** be invoked if the call to sqlite3_create_module_v2() fails.
7656 ** ^The sqlite3_create_module()
7657 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
7658 ** destructor.
 
 
 
 
 
 
7659 */
7660 SQLITE_API int sqlite3_create_module(
7661 sqlite3 *db, /* SQLite connection to register module with */
7662 const char *zName, /* Name of the module */
7663 const sqlite3_module *p, /* Methods for the module */
@@ -7668,10 +7695,27 @@
7668 const char *zName, /* Name of the module */
7669 const sqlite3_module *p, /* Methods for the module */
7670 void *pClientData, /* Client data for xCreate/xConnect */
7671 void(*xDestroy)(void*) /* Module destructor function */
7672 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7673
7674 /*
7675 ** CAPI3REF: Virtual Table Instance Object
7676 ** KEYWORDS: sqlite3_vtab
7677 **
@@ -8377,11 +8421,11 @@
8377 ** [sqlite3_test_control()] interface.
8378 */
8379 #define SQLITE_TESTCTRL_FIRST 5
8380 #define SQLITE_TESTCTRL_PRNG_SAVE 5
8381 #define SQLITE_TESTCTRL_PRNG_RESTORE 6
8382 #define SQLITE_TESTCTRL_PRNG_RESET 7
8383 #define SQLITE_TESTCTRL_BITVEC_TEST 8
8384 #define SQLITE_TESTCTRL_FAULT_INSTALL 9
8385 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
8386 #define SQLITE_TESTCTRL_PENDING_BYTE 11
8387 #define SQLITE_TESTCTRL_ASSERT 12
@@ -8400,11 +8444,13 @@
8400 #define SQLITE_TESTCTRL_ISINIT 23
8401 #define SQLITE_TESTCTRL_SORTER_MMAP 24
8402 #define SQLITE_TESTCTRL_IMPOSTER 25
8403 #define SQLITE_TESTCTRL_PARSER_COVERAGE 26
8404 #define SQLITE_TESTCTRL_RESULT_INTREAL 27
8405 #define SQLITE_TESTCTRL_LAST 27 /* Largest TESTCTRL */
 
 
8406
8407 /*
8408 ** CAPI3REF: SQL Keyword Checking
8409 **
8410 ** These routines provide access to the set of SQL language keywords
@@ -13097,19 +13143,19 @@
13097 ** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
13098 ** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)).
13099 ** So we have to define the macros in different ways depending on the
13100 ** compiler.
13101 */
13102 #if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
 
 
 
13103 # define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
13104 # define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
13105 #elif !defined(__GNUC__) /* Works for compilers other than LLVM */
13106 # define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
13107 # define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
13108 #elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
13109 # define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
13110 # define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X))
13111 #else /* Generates a warning - but it always works */
13112 # define SQLITE_INT_TO_PTR(X) ((void*)(X))
13113 # define SQLITE_PTR_TO_INT(X) ((int)(X))
13114 #endif
13115
@@ -13595,104 +13641,107 @@
13595 #define TK_TRIGGER 77
13596 #define TK_VACUUM 78
13597 #define TK_VIEW 79
13598 #define TK_VIRTUAL 80
13599 #define TK_WITH 81
13600 #define TK_CURRENT 82
13601 #define TK_FOLLOWING 83
13602 #define TK_PARTITION 84
13603 #define TK_PRECEDING 85
13604 #define TK_RANGE 86
13605 #define TK_UNBOUNDED 87
13606 #define TK_EXCLUDE 88
13607 #define TK_GROUPS 89
13608 #define TK_OTHERS 90
13609 #define TK_TIES 91
13610 #define TK_REINDEX 92
13611 #define TK_RENAME 93
13612 #define TK_CTIME_KW 94
13613 #define TK_ANY 95
13614 #define TK_BITAND 96
13615 #define TK_BITOR 97
13616 #define TK_LSHIFT 98
13617 #define TK_RSHIFT 99
13618 #define TK_PLUS 100
13619 #define TK_MINUS 101
13620 #define TK_STAR 102
13621 #define TK_SLASH 103
13622 #define TK_REM 104
13623 #define TK_CONCAT 105
13624 #define TK_COLLATE 106
13625 #define TK_BITNOT 107
13626 #define TK_ON 108
13627 #define TK_INDEXED 109
13628 #define TK_STRING 110
13629 #define TK_JOIN_KW 111
13630 #define TK_CONSTRAINT 112
13631 #define TK_DEFAULT 113
13632 #define TK_NULL 114
13633 #define TK_PRIMARY 115
13634 #define TK_UNIQUE 116
13635 #define TK_CHECK 117
13636 #define TK_REFERENCES 118
13637 #define TK_AUTOINCR 119
13638 #define TK_INSERT 120
13639 #define TK_DELETE 121
13640 #define TK_UPDATE 122
13641 #define TK_SET 123
13642 #define TK_DEFERRABLE 124
13643 #define TK_FOREIGN 125
13644 #define TK_DROP 126
13645 #define TK_UNION 127
13646 #define TK_ALL 128
13647 #define TK_EXCEPT 129
13648 #define TK_INTERSECT 130
13649 #define TK_SELECT 131
13650 #define TK_VALUES 132
13651 #define TK_DISTINCT 133
13652 #define TK_DOT 134
13653 #define TK_FROM 135
13654 #define TK_JOIN 136
13655 #define TK_USING 137
13656 #define TK_ORDER 138
13657 #define TK_GROUP 139
13658 #define TK_HAVING 140
13659 #define TK_LIMIT 141
13660 #define TK_WHERE 142
13661 #define TK_INTO 143
13662 #define TK_NOTHING 144
13663 #define TK_FLOAT 145
13664 #define TK_BLOB 146
13665 #define TK_INTEGER 147
13666 #define TK_VARIABLE 148
13667 #define TK_CASE 149
13668 #define TK_WHEN 150
13669 #define TK_THEN 151
13670 #define TK_ELSE 152
13671 #define TK_INDEX 153
13672 #define TK_ALTER 154
13673 #define TK_ADD 155
13674 #define TK_WINDOW 156
13675 #define TK_OVER 157
13676 #define TK_FILTER 158
13677 #define TK_TRUEFALSE 159
13678 #define TK_ISNOT 160
13679 #define TK_FUNCTION 161
13680 #define TK_COLUMN 162
13681 #define TK_AGG_FUNCTION 163
13682 #define TK_AGG_COLUMN 164
13683 #define TK_UMINUS 165
13684 #define TK_UPLUS 166
13685 #define TK_TRUTH 167
13686 #define TK_REGISTER 168
13687 #define TK_VECTOR 169
13688 #define TK_SELECT_COLUMN 170
13689 #define TK_IF_NULL_ROW 171
13690 #define TK_ASTERISK 172
13691 #define TK_SPAN 173
13692 #define TK_SPACE 174
13693 #define TK_ILLEGAL 175
 
 
 
13694
13695 /************** End of parse.h ***********************************************/
13696 /************** Continuing where we left off in sqliteInt.h ******************/
13697 #include <stdio.h>
13698 #include <stdlib.h>
@@ -14099,24 +14148,10 @@
14099 #if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE
14100 # undef SQLITE_DEFAULT_MMAP_SIZE
14101 # define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE
14102 #endif
14103
14104 /*
14105 ** Only one of SQLITE_ENABLE_STAT3 or SQLITE_ENABLE_STAT4 can be defined.
14106 ** Priority is given to SQLITE_ENABLE_STAT4. If either are defined, also
14107 ** define SQLITE_ENABLE_STAT3_OR_STAT4
14108 */
14109 #ifdef SQLITE_ENABLE_STAT4
14110 # undef SQLITE_ENABLE_STAT3
14111 # define SQLITE_ENABLE_STAT3_OR_STAT4 1
14112 #elif SQLITE_ENABLE_STAT3
14113 # define SQLITE_ENABLE_STAT3_OR_STAT4 1
14114 #elif SQLITE_ENABLE_STAT3_OR_STAT4
14115 # undef SQLITE_ENABLE_STAT3_OR_STAT4
14116 #endif
14117
14118 /*
14119 ** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not
14120 ** the Select query generator tracing logic is turned on.
14121 */
14122 #if defined(SQLITE_ENABLE_SELECTTRACE)
@@ -14982,28 +15017,28 @@
14982 #define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */
14983 #define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
14984 #define OP_Count 93 /* synopsis: r[P2]=count() */
14985 #define OP_ReadCookie 94
14986 #define OP_SetCookie 95
14987 #define OP_BitAnd 96 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
14988 #define OP_BitOr 97 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
14989 #define OP_ShiftLeft 98 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
14990 #define OP_ShiftRight 99 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
14991 #define OP_Add 100 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
14992 #define OP_Subtract 101 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
14993 #define OP_Multiply 102 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
14994 #define OP_Divide 103 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
14995 #define OP_Remainder 104 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
14996 #define OP_Concat 105 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
14997 #define OP_ReopenIdx 106 /* synopsis: root=P2 iDb=P3 */
14998 #define OP_BitNot 107 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
14999 #define OP_OpenRead 108 /* synopsis: root=P2 iDb=P3 */
15000 #define OP_OpenWrite 109 /* synopsis: root=P2 iDb=P3 */
15001 #define OP_String8 110 /* same as TK_STRING, synopsis: r[P2]='P4' */
15002 #define OP_OpenDup 111
15003 #define OP_OpenAutoindex 112 /* synopsis: nColumn=P2 */
15004 #define OP_OpenEphemeral 113 /* synopsis: nColumn=P2 */
15005 #define OP_SorterOpen 114
15006 #define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15007 #define OP_OpenPseudo 116 /* synopsis: P3 columns in r[P2] */
15008 #define OP_Close 117
15009 #define OP_ColumnsUsed 118
@@ -15031,14 +15066,14 @@
15031 #define OP_SqlExec 140
15032 #define OP_ParseSchema 141
15033 #define OP_LoadAnalysis 142
15034 #define OP_DropTable 143
15035 #define OP_DropIndex 144
15036 #define OP_Real 145 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15037 #define OP_DropTrigger 146
15038 #define OP_IntegrityCk 147
15039 #define OP_RowSetAdd 148 /* synopsis: rowset(P1)=r[P2] */
15040 #define OP_Param 149
15041 #define OP_FkCounter 150 /* synopsis: fkctr[P1]+=P2 */
15042 #define OP_MemMax 151 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15043 #define OP_OffsetLimit 152 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15044 #define OP_AggInverse 153 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
@@ -15083,17 +15118,17 @@
15083 /* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\
15084 /* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
15085 /* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
15086 /* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
15087 /* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
15088 /* 96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
15089 /* 104 */ 0x26, 0x26, 0x00, 0x12, 0x00, 0x00, 0x10, 0x00,\
15090 /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15091 /* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15092 /* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
15093 /* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15094 /* 144 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
15095 /* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15096 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
15097 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,}
15098
15099 /* The sqlite3P2Values() routine is able to run faster if it knows
@@ -15159,14 +15194,14 @@
15159 SQLITE_PRIVATE void sqlite3ExplainBreakpoint(const char*,const char*);
15160 #else
15161 # define sqlite3ExplainBreakpoint(A,B) /*no-op*/
15162 #endif
15163 SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
15164 SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8);
15165 SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);
15166 SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2);
15167 SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3);
15168 SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5);
15169 SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);
15170 SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr);
15171 SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);
15172 SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);
@@ -16377,10 +16412,11 @@
16377 u8 iDb; /* Which db file is being initialized */
16378 u8 busy; /* TRUE if currently initializing */
16379 unsigned orphanTrigger : 1; /* Last statement is orphaned TEMP trigger */
16380 unsigned imposterTable : 1; /* Building an imposter table */
16381 unsigned reopenMemdb : 1; /* ATTACH is really a reopen using MemDB */
 
16382 } init;
16383 int nVdbeActive; /* Number of VDBEs currently running */
16384 int nVdbeRead; /* Number of active VDBEs that read or write */
16385 int nVdbeWrite; /* Number of active VDBEs that read and write */
16386 int nVdbeExec; /* Number of nested calls to VdbeExec() */
@@ -16515,20 +16551,21 @@
16515 #define SQLITE_LegacyAlter 0x04000000 /* Legacy ALTER TABLE behaviour */
16516 #define SQLITE_NoSchemaError 0x08000000 /* Do not report schema parse errors*/
16517 #define SQLITE_Defensive 0x10000000 /* Input SQL is likely hostile */
16518 #define SQLITE_DqsDDL 0x20000000 /* dbl-quoted strings allowed in DDL*/
16519 #define SQLITE_DqsDML 0x40000000 /* dbl-quoted strings allowed in DML*/
 
16520
16521 /* Flags used only if debugging */
16522 #define HI(X) ((u64)(X)<<32)
16523 #ifdef SQLITE_DEBUG
16524 #define SQLITE_SqlTrace HI(0x0001) /* Debug print SQL as it executes */
16525 #define SQLITE_VdbeListing HI(0x0002) /* Debug listings of VDBE progs */
16526 #define SQLITE_VdbeTrace HI(0x0004) /* True to trace VDBE execution */
16527 #define SQLITE_VdbeAddopTrace HI(0x0008) /* Trace sqlite3VdbeAddOp() calls */
16528 #define SQLITE_VdbeEQP HI(0x0010) /* Debug EXPLAIN QUERY PLAN */
16529 #define SQLITE_ParserTrace HI(0x0020) /* PRAGMA parser_trace=ON */
16530 #endif
16531
16532 /*
16533 ** Allowed values for sqlite3.mDbFlags
16534 */
@@ -16552,12 +16589,12 @@
16552 #define SQLITE_OrderByIdxJoin 0x0040 /* ORDER BY of joins via index */
16553 #define SQLITE_Transitive 0x0080 /* Transitive constraints */
16554 #define SQLITE_OmitNoopJoin 0x0100 /* Omit unused tables in joins */
16555 #define SQLITE_CountOfView 0x0200 /* The count-of-view optimization */
16556 #define SQLITE_CursorHints 0x0400 /* Add OP_CursorHint opcodes */
16557 #define SQLITE_Stat34 0x0800 /* Use STAT3 or STAT4 data */
16558 /* TH3 expects the Stat34 ^^^^^^ value to be 0x0800. Don't change it */
16559 #define SQLITE_PushDown 0x1000 /* The push-down optimization */
16560 #define SQLITE_SimplifyJoin 0x2000 /* Convert LEFT JOIN to JOIN */
16561 #define SQLITE_SkipScan 0x4000 /* Skip-scans */
16562 #define SQLITE_PropagateConst 0x8000 /* The constant propagation opt */
16563 #define SQLITE_AllOpts 0xffff /* All optimizations */
@@ -16641,10 +16678,11 @@
16641 ** Value constraints (enforced via assert()):
16642 ** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg
16643 ** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG
16644 ** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG
16645 ** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API
 
16646 ** SQLITE_FUNC_ENCMASK depends on SQLITE_UTF* macros in the API
16647 */
16648 #define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
16649 #define SQLITE_FUNC_LIKE 0x0004 /* Candidate for the LIKE optimization */
16650 #define SQLITE_FUNC_CASE 0x0008 /* Case-sensitive LIKE-type function */
@@ -16661,10 +16699,11 @@
16661 ** single query - might change over time */
16662 #define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
16663 #define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */
16664 #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */
16665 #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */
 
16666
16667 /*
16668 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
16669 ** used to create the initializers for the FuncDef structures.
16670 **
@@ -16774,10 +16813,11 @@
16774 ** hash table.
16775 */
16776 struct Module {
16777 const sqlite3_module *pModule; /* Callback pointers */
16778 const char *zName; /* Name passed to create_module() */
 
16779 void *pAux; /* pAux passed to create_module() */
16780 void (*xDestroy)(void *); /* Module destructor function */
16781 Table *pEpoTab; /* Eponymous table for this module */
16782 };
16783
@@ -16839,15 +16879,16 @@
16839 ** used as the P4 operand, they will be more readable.
16840 **
16841 ** Note also that the numeric types are grouped together so that testing
16842 ** for a numeric type is a single comparison. And the BLOB type is first.
16843 */
16844 #define SQLITE_AFF_BLOB 'A'
16845 #define SQLITE_AFF_TEXT 'B'
16846 #define SQLITE_AFF_NUMERIC 'C'
16847 #define SQLITE_AFF_INTEGER 'D'
16848 #define SQLITE_AFF_REAL 'E'
 
16849
16850 #define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC)
16851
16852 /*
16853 ** The SQLITE_AFF_MASK values masks off the significant bits of an
@@ -17111,13 +17152,16 @@
17111 u32 nRef; /* Number of references to this KeyInfo object */
17112 u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
17113 u16 nKeyField; /* Number of key columns in the index */
17114 u16 nAllField; /* Total columns, including key plus others */
17115 sqlite3 *db; /* The database connection */
17116 u8 *aSortOrder; /* Sort order for each column. */
17117 CollSeq *aColl[1]; /* Collating sequence for each term of the key */
17118 };
 
 
 
17119
17120 /*
17121 ** This object holds a record which has been parsed out into individual
17122 ** fields, for the purposes of doing a comparison.
17123 **
@@ -17222,11 +17266,11 @@
17222 unsigned isCovering:1; /* True if this is a covering index */
17223 unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
17224 unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
17225 unsigned bNoQuery:1; /* Do not use this index to optimize queries */
17226 unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
17227 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
17228 int nSample; /* Number of elements in aSample[] */
17229 int nSampleCol; /* Size of IndexSample.anEq[] and so on */
17230 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
17231 IndexSample *aSample; /* Samples of the left-most key */
17232 tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */
@@ -17254,11 +17298,11 @@
17254 */
17255 #define XN_ROWID (-1) /* Indexed column is the rowid */
17256 #define XN_EXPR (-2) /* Indexed column is an expression */
17257
17258 /*
17259 ** Each sample stored in the sqlite_stat3 table is represented in memory
17260 ** using a structure of this type. See documentation at the top of the
17261 ** analyze.c source file for additional information.
17262 */
17263 struct IndexSample {
17264 void *p; /* Pointer to sampled record */
@@ -17412,11 +17456,11 @@
17412 ** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately
17413 ** allocated, regardless of whether or not EP_Reduced is set.
17414 */
17415 struct Expr {
17416 u8 op; /* Operation performed by this node */
17417 char affinity; /* The affinity of the column or 0 if not a column */
17418 u32 flags; /* Various flags. EP_* See below */
17419 union {
17420 char *zToken; /* Token value. Zero terminated and dequoted */
17421 int iValue; /* Non-negative integer value if EP_IntValue */
17422 } u;
@@ -17443,10 +17487,11 @@
17443 #endif
17444 int iTable; /* TK_COLUMN: cursor number of table holding column
17445 ** TK_REGISTER: register number
17446 ** TK_TRIGGER: 1 -> new, 0 -> old
17447 ** EP_Unlikely: 134217728 times likelihood
 
17448 ** TK_SELECT: 1st register of result vector */
17449 ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
17450 ** TK_VARIABLE: variable number (always >= 1).
17451 ** TK_SELECT_COLUMN: column of the result vector */
17452 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
@@ -17456,11 +17501,11 @@
17456 ** TK_AGG_FUNCTION: nesting depth */
17457 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
17458 union {
17459 Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
17460 ** for a column of an index on an expression */
17461 Window *pWin; /* TK_FUNCTION: Window definition for the func */
17462 struct { /* TK_IN, TK_SELECT, and TK_EXISTS */
17463 int iAddr; /* Subroutine entry address */
17464 int regReturn; /* Register used to hold return address */
17465 } sub;
17466 } y;
@@ -17471,40 +17516,41 @@
17471 ** Value restrictions:
17472 **
17473 ** EP_Agg == NC_HasAgg == SF_HasAgg
17474 ** EP_Win == NC_HasWin
17475 */
17476 #define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
17477 #define EP_Distinct 0x000002 /* Aggregate function with DISTINCT keyword */
17478 #define EP_HasFunc 0x000004 /* Contains one or more functions of any kind */
17479 #define EP_FixedCol 0x000008 /* TK_Column with a known fixed value */
17480 #define EP_Agg 0x000010 /* Contains one or more aggregate functions */
17481 #define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
17482 #define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
17483 #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
17484 #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
17485 #define EP_Generic 0x000200 /* Ignore COLLATE or affinity on this tree */
17486 #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
17487 #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
17488 #define EP_Skip 0x001000 /* Operator does not contribute to affinity */
17489 #define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
17490 #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
17491 #define EP_Win 0x008000 /* Contains window functions */
17492 #define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */
17493 #define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
17494 #define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */
17495 #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
17496 #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
17497 #define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */
17498 #define EP_Alias 0x400000 /* Is an alias for a result set column */
17499 #define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
17500 #define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
17501 #define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */
17502 #define EP_Quoted 0x4000000 /* TK_ID was originally quoted */
17503 #define EP_Static 0x8000000 /* Held in memory not obtained from malloc() */
17504 #define EP_IsTrue 0x10000000 /* Always has boolean value of TRUE */
17505 #define EP_IsFalse 0x20000000 /* Always has boolean value of FALSE */
 
17506
17507 /*
17508 ** The EP_Propagate mask is a set of properties that automatically propagate
17509 ** upwards into parent nodes.
17510 */
@@ -17543,10 +17589,18 @@
17543 /*
17544 ** Flags passed to the sqlite3ExprDup() function. See the header comment
17545 ** above sqlite3ExprDup() for details.
17546 */
17547 #define EXPRDUP_REDUCE 0x0001 /* Used reduced-size Expr nodes */
 
 
 
 
 
 
 
 
17548
17549 /*
17550 ** A list of expressions. Each expression may optionally have a
17551 ** name. An expr/name combination can be used in several ways, such
17552 ** as the list of "expr AS ID" fields following a "SELECT" or in the
@@ -17566,15 +17620,16 @@
17566 int nExpr; /* Number of expressions on the list */
17567 struct ExprList_item { /* For each expression in the list */
17568 Expr *pExpr; /* The parse tree for this expression */
17569 char *zName; /* Token associated with this expression */
17570 char *zSpan; /* Original text of the expression */
17571 u8 sortOrder; /* 1 for DESC or 0 for ASC */
17572 unsigned done :1; /* A flag to indicate when processing is finished */
17573 unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
17574 unsigned reusable :1; /* Constant expression is reusable */
17575 unsigned bSorterRef :1; /* Defer evaluation until after sorting */
 
17576 union {
17577 struct {
17578 u16 iOrderByCol; /* For ORDER BY, column number in result set */
17579 u16 iAlias; /* Index into Parse.aAlias[] for zName */
17580 } x;
@@ -17861,10 +17916,11 @@
17861 #define SF_FixedLimit 0x04000 /* nSelectRow set by a constant LIMIT */
17862 #define SF_MaybeConvert 0x08000 /* Need convertCompoundSelectToSubquery() */
17863 #define SF_Converted 0x10000 /* By convertCompoundSelectToSubquery() */
17864 #define SF_IncludeHidden 0x20000 /* Include hidden columns in output */
17865 #define SF_ComplexResult 0x40000 /* Result contains subquery or function */
 
17866
17867 /*
17868 ** The results of a SELECT can be distributed in several ways, as defined
17869 ** by one of the following macros. The "SRT" prefix means "SELECT Result
17870 ** Type".
@@ -18365,15 +18421,16 @@
18365 **
18366 ** This structure also contains some state information.
18367 */
18368 struct Sqlite3Config {
18369 int bMemstat; /* True to enable memory status */
18370 int bCoreMutex; /* True to enable core mutexing */
18371 int bFullMutex; /* True to enable full mutexing */
18372 int bOpenUri; /* True to interpret filenames as URIs */
18373 int bUseCis; /* Use covering indices for full-scans */
18374 int bSmallMalloc; /* Avoid large memory allocations if true */
 
18375 int mxStrlen; /* Maximum string length */
18376 int neverCorrupt; /* Database is always well-formed */
18377 int szLookaside; /* Default lookaside buffer size */
18378 int nLookaside; /* Default lookaside buffer count */
18379 int nStmtSpill; /* Stmt-journal spill-to-disk threshold */
@@ -18421,10 +18478,11 @@
18421 #endif
18422 int bLocaltimeFault; /* True to fail localtime() calls */
18423 int bInternalFunctions; /* Internal SQL functions are visible */
18424 int iOnceResetThreshold; /* When to reset OP_Once counters */
18425 u32 szSorterRef; /* Min size in bytes to use sorter-refs */
 
18426 };
18427
18428 /*
18429 ** This macro is used inside of assert() statements to indicate that
18430 ** the assert is only valid on a well-formed database. Instead of:
@@ -18517,14 +18575,15 @@
18517 u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */
18518 };
18519 #endif /* SQLITE_DEBUG */
18520
18521 /*
18522 ** This object is used in various ways, all related to window functions
 
18523 **
18524 ** (1) A single instance of this structure is attached to the
18525 ** the Expr.pWin field for each window function in an expression tree.
18526 ** This object holds the information contained in the OVER clause,
18527 ** plus additional fields used during code generation.
18528 **
18529 ** (2) All window functions in a single SELECT form a linked-list
18530 ** attached to Select.pWin. The Window.pFunc and Window.pExpr
@@ -18531,10 +18590,14 @@
18531 ** fields point back to the expression that is the window function.
18532 **
18533 ** (3) The terms of the WINDOW clause of a SELECT are instances of this
18534 ** object on a linked list attached to Select.pWinDefn.
18535 **
 
 
 
 
18536 ** The uses (1) and (2) are really the same Window object that just happens
18537 ** to be accessible in two different ways. Use case (3) are separate objects.
18538 */
18539 struct Window {
18540 char *zName; /* Name of window (may be NULL) */
@@ -18546,10 +18609,11 @@
18546 u8 eEnd; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
18547 u8 bImplicitFrame; /* True if frame was implicitly specified */
18548 u8 eExclude; /* TK_NO, TK_CURRENT, TK_TIES, TK_GROUP, or 0 */
18549 Expr *pStart; /* Expression for "<expr> PRECEDING" */
18550 Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
 
18551 Window *pNextWin; /* Next window function belonging to this SELECT */
18552 Expr *pFilter; /* The FILTER expression */
18553 FuncDef *pFunc; /* The function */
18554 int iEphCsr; /* Partition buffer or Peer buffer */
18555 int regAccum;
@@ -18565,14 +18629,16 @@
18565 int regEndRowid;
18566 };
18567
18568 #ifndef SQLITE_OMIT_WINDOWFUNC
18569 SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3*, Window*);
 
18570 SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p);
18571 SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, u8);
18572 SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*);
18573 SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*);
 
18574 SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*);
18575 SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);
18576 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*);
18577 SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*);
18578 SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*);
@@ -18840,11 +18906,11 @@
18840 SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
18841 SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
18842 SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
18843 SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
18844 SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
18845 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int);
18846 SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
18847 SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
18848 SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
18849 SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
18850 SQLITE_PRIVATE int sqlite3IndexHasDuplicateRootPage(Index*);
@@ -18859,12 +18925,12 @@
18859 SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);
18860 SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);
18861 SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);
18862 SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
18863 SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
18864 SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*);
18865 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
18866 SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
18867 SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
18868 SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);
18869 SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
18870 #if SQLITE_ENABLE_HIDDEN_COLUMNS
@@ -19161,11 +19227,11 @@
19161 SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst);
19162 #ifndef SQLITE_OMIT_VIRTUALTABLE
19163 SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double);
19164 #endif
19165 #if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
19166 defined(SQLITE_ENABLE_STAT3_OR_STAT4) || \
19167 defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
19168 SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst);
19169 #endif
19170 SQLITE_PRIVATE VList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int);
19171 SQLITE_PRIVATE const char *sqlite3VListNumToName(VList*,int);
@@ -19227,13 +19293,14 @@
19227 SQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, Expr *pExpr);
19228 SQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,Expr*,Expr*);
19229 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
19230 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
19231 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
 
19232 SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
19233 SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*);
19234 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);
19235 SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
19236 SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);
19237 SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);
19238 SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);
19239 SQLITE_PRIVATE int sqlite3AbsInt32(int);
@@ -19316,10 +19383,11 @@
19316 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);
19317 SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo*);
19318 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo*);
19319 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);
19320 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList(Parse*, ExprList*, int, int);
 
19321
19322 #ifdef SQLITE_DEBUG
19323 SQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo*);
19324 #endif
19325 SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
@@ -19348,12 +19416,11 @@
19348 SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse*, Expr*);
19349 #else
19350 # define sqlite3ExprCheckIN(x,y) SQLITE_OK
19351 #endif
19352
19353 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
19354 SQLITE_PRIVATE void sqlite3AnalyzeFunctions(void);
19355 SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(
19356 Parse*,Index*,UnpackedRecord**,Expr*,int,int,int*);
19357 SQLITE_PRIVATE int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);
19358 SQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord*);
19359 SQLITE_PRIVATE int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);
@@ -19396,10 +19463,11 @@
19396 # define sqlite3VtabRollback(X)
19397 # define sqlite3VtabCommit(X)
19398 # define sqlite3VtabInSync(db) 0
19399 # define sqlite3VtabLock(X)
19400 # define sqlite3VtabUnlock(X)
 
19401 # define sqlite3VtabUnlockList(X)
19402 # define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK
19403 # define sqlite3GetVTable(X,Y) ((VTable*)0)
19404 #else
19405 SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table*);
@@ -19407,10 +19475,11 @@
19407 SQLITE_PRIVATE int sqlite3VtabSync(sqlite3 *db, Vdbe*);
19408 SQLITE_PRIVATE int sqlite3VtabRollback(sqlite3 *db);
19409 SQLITE_PRIVATE int sqlite3VtabCommit(sqlite3 *db);
19410 SQLITE_PRIVATE void sqlite3VtabLock(VTable *);
19411 SQLITE_PRIVATE void sqlite3VtabUnlock(VTable *);
 
19412 SQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3*);
19413 SQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *, int, int);
19414 SQLITE_PRIVATE void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*);
19415 SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3*, Table*);
19416 SQLITE_PRIVATE Module *sqlite3VtabCreateModule(
@@ -19874,10 +19943,11 @@
19874 1, /* bCoreMutex */
19875 SQLITE_THREADSAFE==1, /* bFullMutex */
19876 SQLITE_USE_URI, /* bOpenUri */
19877 SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */
19878 0, /* bSmallMalloc */
 
19879 0x7ffffffe, /* mxStrlen */
19880 0, /* neverCorrupt */
19881 SQLITE_DEFAULT_LOOKASIDE, /* szLookaside, nLookaside */
19882 SQLITE_STMTJRNL_SPILL, /* nStmtSpill */
19883 {0,0,0,0,0,0,0,0}, /* m */
@@ -19920,10 +19990,11 @@
19920 #endif
19921 0, /* bLocaltimeFault */
19922 0, /* bInternalFunctions */
19923 0x7ffffffe, /* iOnceResetThreshold */
19924 SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
 
19925 };
19926
19927 /*
19928 ** Hash table for global functions - functions common to all
19929 ** database connections. After initialization, this table is
@@ -20489,11 +20560,10 @@
20489 void sqliteVdbePopStack(Vdbe*,int);
20490 SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, int*);
20491 SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
20492 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
20493 SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
20494 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int, u32*);
20495 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
20496 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
20497 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3*, AuxData**, int, int);
20498
20499 int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
@@ -22495,11 +22565,19 @@
22495 SQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *pVfs, void *pHandle){
22496 pVfs->xDlClose(pVfs, pHandle);
22497 }
22498 #endif /* SQLITE_OMIT_LOAD_EXTENSION */
22499 SQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
22500 return pVfs->xRandomness(pVfs, nByte, zBufOut);
 
 
 
 
 
 
 
 
22501 }
22502 SQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){
22503 return pVfs->xSleep(pVfs, nMicro);
22504 }
22505 SQLITE_PRIVATE int sqlite3OsGetLastError(sqlite3_vfs *pVfs){
@@ -28776,17 +28854,21 @@
28776 sqlite3TreeViewWith(pView, p->pWith, 1);
28777 cnt = 1;
28778 sqlite3TreeViewPush(pView, 1);
28779 }
28780 do{
28781 sqlite3TreeViewLine(pView,
28782 "SELECT%s%s (%u/%p) selFlags=0x%x nSelectRow=%d",
28783 ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
28784 ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""),
28785 p->selId, p, p->selFlags,
28786 (int)p->nSelectRow
28787 );
 
 
 
 
28788 if( cnt++ ) sqlite3TreeViewPop(pView);
28789 if( p->pPrior ){
28790 n = 1000;
28791 }else{
28792 n = 0;
@@ -28799,11 +28881,14 @@
28799 #ifndef SQLITE_OMIT_WINDOWFUNC
28800 if( p->pWin ) n++;
28801 if( p->pWinDefn ) n++;
28802 #endif
28803 }
28804 sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, "result-set");
 
 
 
28805 #ifndef SQLITE_OMIT_WINDOWFUNC
28806 if( p->pWin ){
28807 Window *pX;
28808 pView = sqlite3TreeViewPush(pView, (n--)>0);
28809 sqlite3TreeViewLine(pView, "window-functions");
@@ -28995,16 +29080,18 @@
28995 if( pExpr==0 ){
28996 sqlite3TreeViewLine(pView, "nil");
28997 sqlite3TreeViewPop(pView);
28998 return;
28999 }
29000 if( pExpr->flags ){
29001 if( ExprHasProperty(pExpr, EP_FromJoin) ){
29002 sqlite3_snprintf(sizeof(zFlgs),zFlgs," flags=0x%x iRJT=%d",
29003 pExpr->flags, pExpr->iRightJoinTable);
 
29004 }else{
29005 sqlite3_snprintf(sizeof(zFlgs),zFlgs," flags=0x%x",pExpr->flags);
 
29006 }
29007 }else{
29008 zFlgs[0] = 0;
29009 }
29010 switch( pExpr->op ){
@@ -29148,14 +29235,14 @@
29148 #else
29149 pWin = 0;
29150 #endif
29151 }
29152 if( pExpr->op==TK_AGG_FUNCTION ){
29153 sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q",
29154 pExpr->op2, pExpr->u.zToken);
29155 }else{
29156 sqlite3TreeViewLine(pView, "FUNCTION %Q", pExpr->u.zToken);
29157 }
29158 if( pFarg ){
29159 sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);
29160 }
29161 #ifndef SQLITE_OMIT_WINDOWFUNC
@@ -29228,11 +29315,11 @@
29228 break;
29229 }
29230 #ifndef SQLITE_OMIT_TRIGGER
29231 case TK_RAISE: {
29232 const char *zType = "unk";
29233 switch( pExpr->affinity ){
29234 case OE_Rollback: zType = "rollback"; break;
29235 case OE_Abort: zType = "abort"; break;
29236 case OE_Fail: zType = "fail"; break;
29237 case OE_Ignore: zType = "ignore"; break;
29238 }
@@ -29269,11 +29356,11 @@
29269 sqlite3TreeViewLine(pView, "%s%s", zBinOp, zFlgs);
29270 sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
29271 sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
29272 }else if( zUniOp ){
29273 sqlite3TreeViewLine(pView, "%s%s", zUniOp, zFlgs);
29274 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
29275 }
29276 sqlite3TreeViewPop(pView);
29277 }
29278
29279
@@ -31777,11 +31864,11 @@
31777 return e*10;
31778 }
31779 #endif /* SQLITE_OMIT_VIRTUALTABLE */
31780
31781 #if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
31782 defined(SQLITE_ENABLE_STAT3_OR_STAT4) || \
31783 defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
31784 /*
31785 ** Convert a LogEst into an integer.
31786 **
31787 ** Note that this routine is only used when one or more of various
@@ -31795,11 +31882,11 @@
31795 else if( n>=1 ) n -= 1;
31796 #if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
31797 defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
31798 if( x>60 ) return (u64)LARGEST_INT64;
31799 #else
31800 /* If only SQLITE_ENABLE_STAT3_OR_STAT4 is on, then the largest input
31801 ** possible to this routine is 310, resulting in a maximum x of 31 */
31802 assert( x<=60 );
31803 #endif
31804 return x>=3 ? (n+8)<<(x-3) : (n+8)>>(3-x);
31805 }
@@ -32288,28 +32375,28 @@
32288 /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
32289 /* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
32290 /* 93 */ "Count" OpHelp("r[P2]=count()"),
32291 /* 94 */ "ReadCookie" OpHelp(""),
32292 /* 95 */ "SetCookie" OpHelp(""),
32293 /* 96 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32294 /* 97 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32295 /* 98 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32296 /* 99 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32297 /* 100 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32298 /* 101 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32299 /* 102 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32300 /* 103 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32301 /* 104 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32302 /* 105 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32303 /* 106 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32304 /* 107 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32305 /* 108 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32306 /* 109 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32307 /* 110 */ "String8" OpHelp("r[P2]='P4'"),
32308 /* 111 */ "OpenDup" OpHelp(""),
32309 /* 112 */ "OpenAutoindex" OpHelp("nColumn=P2"),
32310 /* 113 */ "OpenEphemeral" OpHelp("nColumn=P2"),
32311 /* 114 */ "SorterOpen" OpHelp(""),
32312 /* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
32313 /* 116 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
32314 /* 117 */ "Close" OpHelp(""),
32315 /* 118 */ "ColumnsUsed" OpHelp(""),
@@ -32337,14 +32424,14 @@
32337 /* 140 */ "SqlExec" OpHelp(""),
32338 /* 141 */ "ParseSchema" OpHelp(""),
32339 /* 142 */ "LoadAnalysis" OpHelp(""),
32340 /* 143 */ "DropTable" OpHelp(""),
32341 /* 144 */ "DropIndex" OpHelp(""),
32342 /* 145 */ "Real" OpHelp("r[P2]=P4"),
32343 /* 146 */ "DropTrigger" OpHelp(""),
32344 /* 147 */ "IntegrityCk" OpHelp(""),
32345 /* 148 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
32346 /* 149 */ "Param" OpHelp(""),
32347 /* 150 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
32348 /* 151 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
32349 /* 152 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
32350 /* 153 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
@@ -33093,17 +33180,18 @@
33093 #define osLstat ((int(*)(const char*,struct stat*))aSyscall[27].pCurrent)
33094
33095 #if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
33096 # ifdef __ANDROID__
33097 { "ioctl", (sqlite3_syscall_ptr)(int(*)(int, int, ...))ioctl, 0 },
 
33098 # else
33099 { "ioctl", (sqlite3_syscall_ptr)ioctl, 0 },
 
33100 # endif
33101 #else
33102 { "ioctl", (sqlite3_syscall_ptr)0, 0 },
33103 #endif
33104 #define osIoctl ((int(*)(int,int,...))aSyscall[28].pCurrent)
33105
33106 }; /* End of the overrideable system calls */
33107
33108
33109 /*
@@ -38341,10 +38429,11 @@
38341 }
38342 if( pInode ){
38343 UnixUnusedFd **pp;
38344 assert( sqlite3_mutex_notheld(pInode->pLockMutex) );
38345 sqlite3_mutex_enter(pInode->pLockMutex);
 
38346 for(pp=&pInode->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
38347 pUnused = *pp;
38348 if( pUnused ){
38349 *pp = pUnused->pNext;
38350 }
@@ -38644,11 +38733,12 @@
38644 *pOutFlags = flags;
38645 }
38646
38647 if( p->pPreallocatedUnused ){
38648 p->pPreallocatedUnused->fd = fd;
38649 p->pPreallocatedUnused->flags = flags;
 
38650 }
38651
38652 if( isDelete ){
38653 #if OS_VXWORKS
38654 zPath = zName;
@@ -40175,11 +40265,11 @@
40175 }
40176 default: {
40177 assert( 0 ); /* The call assures that only valid opcodes are sent */
40178 }
40179 }
40180 /*NOTREACHED*/
40181 return SQLITE_ERROR;
40182 }
40183
40184 /*
40185 ** Within this division (the proxying locking implementation) the procedures
@@ -44860,10 +44950,11 @@
44860
44861 if( !pShm ){
44862 rc = winOpenSharedMemory(pDbFd);
44863 if( rc!=SQLITE_OK ) return rc;
44864 pShm = pDbFd->pShm;
 
44865 }
44866 pShmNode = pShm->pShmNode;
44867
44868 sqlite3_mutex_enter(pShmNode->mutex);
44869 if( pShmNode->isUnlocked ){
@@ -45162,10 +45253,11 @@
45162 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
45163 return rc;
45164 }
45165 }
45166 if( pFd->mmapSize >= iOff+nAmt ){
 
45167 *pp = &((u8 *)pFd->pMapRegion)[iOff];
45168 pFd->nFetchOut++;
45169 }
45170 }
45171 #endif
@@ -48083,10 +48175,11 @@
48083 if( sqlite3GlobalConfig.pcache2.xInit==0 ){
48084 /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the
48085 ** built-in default page cache is used instead of the application defined
48086 ** page cache. */
48087 sqlite3PCacheSetDefault();
 
48088 }
48089 return sqlite3GlobalConfig.pcache2.xInit(sqlite3GlobalConfig.pcache2.pArg);
48090 }
48091 SQLITE_PRIVATE void sqlite3PcacheShutdown(void){
48092 if( sqlite3GlobalConfig.pcache2.xShutdown ){
@@ -49129,10 +49222,11 @@
49129 PgHdr1 *p = 0;
49130 void *pPg;
49131
49132 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
49133 if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){
 
49134 p = pCache->pFree;
49135 pCache->pFree = p->pNext;
49136 p->pNext = 0;
49137 }else{
49138 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
@@ -61855,10 +61949,11 @@
61855 while( iOffset<w.iSyncPoint ){
61856 rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);
61857 if( rc ) return rc;
61858 iOffset += szFrame;
61859 nExtra++;
 
61860 }
61861 }
61862 if( bSync ){
61863 assert( rc==SQLITE_OK );
61864 rc = sqlite3OsSync(w.pFd, WAL_SYNC_FLAGS(sync_flags));
@@ -61887,10 +61982,11 @@
61887 for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){
61888 if( (p->flags & PGHDR_WAL_APPEND)==0 ) continue;
61889 iFrame++;
61890 rc = walIndexAppend(pWal, iFrame, p->pgno);
61891 }
 
61892 while( rc==SQLITE_OK && nExtra>0 ){
61893 iFrame++;
61894 nExtra--;
61895 rc = walIndexAppend(pWal, iFrame, pLast->pgno);
61896 }
@@ -64898,13 +64994,16 @@
64898 testcase( gap+1==top );
64899 testcase( gap==top );
64900 if( (data[hdr+2] || data[hdr+1]) && gap+2<=top ){
64901 u8 *pSpace = pageFindSlot(pPage, nByte, &rc);
64902 if( pSpace ){
64903 assert( pSpace>=data && (pSpace - data)<65536 );
64904 *pIdx = (int)(pSpace - data);
64905 return SQLITE_OK;
 
 
 
64906 }else if( rc ){
64907 return rc;
64908 }
64909 }
64910
@@ -68127,10 +68226,11 @@
68127 u8 aSave[4];
68128 u8 *aWrite = &pBuf[-4];
68129 assert( aWrite>=pBufStart ); /* due to (6) */
68130 memcpy(aSave, aWrite, 4);
68131 rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));
 
68132 nextPage = get4byte(aWrite);
68133 memcpy(aWrite, aSave, 4);
68134 }else
68135 #endif
68136
@@ -69915,16 +70015,11 @@
69915 assert( MX_CELL(pPage->pBt)<=10921 );
69916 assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );
69917 assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
69918 assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
69919 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
69920 /* The cell should normally be sized correctly. However, when moving a
69921 ** malformed cell from a leaf page to an interior page, if the cell size
69922 ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size
69923 ** might be less than 8 (leaf-size + pointer) on the interior node. Hence
69924 ** the term after the || in the following assert(). */
69925 assert( sz==pPage->xCellSize(pPage, pCell) || (sz==8 && iChild>0) );
69926 assert( pPage->nFree>=0 );
69927 if( pPage->nOverflow || sz+2>pPage->nFree ){
69928 if( pTemp ){
69929 memcpy(pTemp, pCell, sz);
69930 pCell = pTemp;
@@ -70152,11 +70247,11 @@
70152 int k; /* Current slot in pCArray->apEnd[] */
70153 u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */
70154
70155 assert( i<iEnd );
70156 j = get2byte(&aData[hdr+5]);
70157 if( NEVER(j>(u32)usableSize) ){ j = 0; }
70158 memcpy(&pTmp[j], &aData[j], usableSize - j);
70159
70160 for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
70161 pSrcEnd = pCArray->apEnd[k];
70162
@@ -70244,11 +70339,12 @@
70244 for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
70245 pEnd = pCArray->apEnd[k];
70246 while( 1 /*Exit by break*/ ){
70247 int sz, rc;
70248 u8 *pSlot;
70249 sz = cachedCellSize(pCArray, i);
 
70250 if( (aData[1]==0 && aData[2]==0) || (pSlot = pageFindSlot(pPg,sz,&rc))==0 ){
70251 if( (pData - pBegin)<sz ) return 1;
70252 pData -= sz;
70253 pSlot = pData;
70254 }
@@ -70405,10 +70501,11 @@
70405 pCellptr = &pPg->aCellIdx[iCell * 2];
70406 if( nCell>iCell ){
70407 memmove(&pCellptr[2], pCellptr, (nCell - iCell) * 2);
70408 }
70409 nCell++;
 
70410 if( pageInsertArray(
70411 pPg, pBegin, &pData, pCellptr,
70412 iCell+iNew, 1, pCArray
70413 ) ) goto editpage_fail;
70414 }
@@ -70927,11 +71024,11 @@
70927 ** long be able to find the cells if a pointer to each cell is not saved
70928 ** first.
70929 */
70930 memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*(limit+pOld->nOverflow));
70931 if( pOld->nOverflow>0 ){
70932 if( limit<pOld->aiOvfl[0] ){
70933 rc = SQLITE_CORRUPT_BKPT;
70934 goto balance_cleanup;
70935 }
70936 limit = pOld->aiOvfl[0];
70937 for(j=0; j<limit; j++){
@@ -71213,10 +71310,12 @@
71213 nNew>=5 ? apNew[4]->pgno : 0, nNew>=5 ? szNew[4] : 0,
71214 nNew>=5 ? cntNew[4] - cntNew[3] - !leafData : 0
71215 ));
71216
71217 assert( sqlite3PagerIswriteable(pParent->pDbPage) );
 
 
71218 put4byte(pRight, apNew[nNew-1]->pgno);
71219
71220 /* If the sibling pages are not leaves, ensure that the right-child pointer
71221 ** of the right-most new sibling page is set to the value that was
71222 ** originally in the same field of the right-most old sibling page. */
@@ -71558,15 +71657,17 @@
71558
71559 VVA_ONLY( int balance_quick_called = 0 );
71560 VVA_ONLY( int balance_deeper_called = 0 );
71561
71562 do {
71563 int iPage = pCur->iPage;
71564 MemPage *pPage = pCur->pPage;
71565
71566 if( NEVER(pPage->nFree<0) && btreeComputeFreeSpace(pPage) ) break;
71567 if( iPage==0 ){
 
 
71568 if( pPage->nOverflow ){
71569 /* The root page of the b-tree is overfull. In this case call the
71570 ** balance_deeper() function to create a new child for the root-page
71571 ** and copy the current contents of the root-page to it. The
71572 ** next iteration of the do-loop will balance the child page.
@@ -71583,12 +71684,10 @@
71583 assert( pCur->pPage->nOverflow );
71584 }
71585 }else{
71586 break;
71587 }
71588 }else if( pPage->nOverflow==0 && pPage->nFree<=nMin ){
71589 break;
71590 }else{
71591 MemPage * const pParent = pCur->apPage[iPage-1];
71592 int const iIdx = pCur->aiIdx[iPage-1];
71593
71594 rc = sqlite3PagerWrite(pParent->pDbPage);
@@ -71726,11 +71825,13 @@
71726 MemPage *pPage = pCur->pPage; /* Page being written */
71727 BtShared *pBt; /* Btree */
71728 Pgno ovflPgno; /* Next overflow page to write */
71729 u32 ovflPageSize; /* Size to write on overflow page */
71730
71731 if( pCur->info.pPayload + pCur->info.nLocal > pPage->aDataEnd ){
 
 
71732 return SQLITE_CORRUPT_BKPT;
71733 }
71734 /* Overwrite the local portion first */
71735 rc = btreeOverwriteContent(pPage, pCur->info.pPayload, pX,
71736 0, pCur->info.nLocal);
@@ -71967,10 +72068,12 @@
71967 oldCell = findCell(pPage, idx);
71968 if( !pPage->leaf ){
71969 memcpy(newCell, oldCell, 4);
71970 }
71971 rc = clearCell(pPage, oldCell, &info);
 
 
71972 if( info.nSize==szNew && info.nLocal==info.nPayload
71973 && (!ISAUTOVACUUM || szNew<pPage->minLocal)
71974 ){
71975 /* Overwrite the old cell with the new if they are the same size.
71976 ** We could also try to do this if the old cell is smaller, then add
@@ -71980,11 +72083,16 @@
71980 **
71981 ** This optimization cannot be used on an autovacuum database if the
71982 ** new entry uses overflow pages, as the insertCell() call below is
71983 ** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry. */
71984 assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */
71985 if( oldCell+szNew > pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT;
 
 
 
 
 
71986 memcpy(oldCell, newCell, szNew);
71987 return SQLITE_OK;
71988 }
71989 dropCell(pPage, idx, info.nSize, &rc);
71990 if( rc ) goto end_insert;
@@ -74317,12 +74425,14 @@
74317 if( p->pDestDb ){
74318 p->pSrc->nBackup--;
74319 }
74320 if( p->isAttached ){
74321 pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));
 
74322 while( *pp!=p ){
74323 pp = &(*pp)->pNext;
 
74324 }
74325 *pp = p->pNext;
74326 }
74327
74328 /* If a transaction is still open on the Btree, roll it back. */
@@ -75804,11 +75914,11 @@
75804 ** already been allocated, allocate the UnpackedRecord structure that
75805 ** that function will return to its caller here. Then return a pointer to
75806 ** an sqlite3_value within the UnpackedRecord.a[] array.
75807 */
75808 static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){
75809 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
75810 if( p ){
75811 UnpackedRecord *pRec = p->ppRec[0];
75812
75813 if( pRec==0 ){
75814 Index *pIdx = p->pIdx; /* Index being probed */
@@ -75840,11 +75950,11 @@
75840 pRec->nField = p->iVal+1;
75841 return &pRec->aMem[p->iVal];
75842 }
75843 #else
75844 UNUSED_PARAMETER(p);
75845 #endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
75846 return sqlite3ValueNew(db);
75847 }
75848
75849 /*
75850 ** The expression object indicated by the second argument is guaranteed
@@ -75864,11 +75974,11 @@
75864 **
75865 ** If the conditions above are not met, this function returns SQLITE_OK
75866 ** and sets (*ppVal) to NULL. Or, if an error occurs, (*ppVal) is set to
75867 ** NULL and an SQLite error code returned.
75868 */
75869 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
75870 static int valueFromFunction(
75871 sqlite3 *db, /* The database connection */
75872 Expr *p, /* The expression to evaluate */
75873 u8 enc, /* Encoding to use */
75874 u8 aff, /* Affinity to use */
@@ -75947,11 +76057,11 @@
75947 *ppVal = pVal;
75948 return rc;
75949 }
75950 #else
75951 # define valueFromFunction(a,b,c,d,e,f) SQLITE_OK
75952 #endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
75953
75954 /*
75955 ** Extract a value from the supplied expression in the manner described
75956 ** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object
75957 ** using valueNew().
@@ -75976,11 +76086,11 @@
75976 const char *zNeg = "";
75977 int rc = SQLITE_OK;
75978
75979 assert( pExpr!=0 );
75980 while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft;
75981 #if defined(SQLITE_ENABLE_STAT3_OR_STAT4)
75982 if( op==TK_REGISTER ) op = pExpr->op2;
75983 #else
75984 if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
75985 #endif
75986
@@ -76069,11 +76179,11 @@
76069 assert( zVal[nVal]=='\'' );
76070 sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
76071 0, SQLITE_DYNAMIC);
76072 }
76073 #endif
76074 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
76075 else if( op==TK_FUNCTION && pCtx!=0 ){
76076 rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
76077 }
76078 #endif
76079 else if( op==TK_TRUEFALSE ){
@@ -76086,17 +76196,17 @@
76086
76087 *ppVal = pVal;
76088 return rc;
76089
76090 no_mem:
76091 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
76092 if( pCtx==0 || pCtx->pParse->nErr==0 )
76093 #endif
76094 sqlite3OomFault(db);
76095 sqlite3DbFree(db, zVal);
76096 assert( *ppVal==0 );
76097 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
76098 if( pCtx==0 ) sqlite3ValueFree(pVal);
76099 #else
76100 assert( pCtx==0 ); sqlite3ValueFree(pVal);
76101 #endif
76102 return SQLITE_NOMEM_BKPT;
@@ -76120,60 +76230,11 @@
76120 sqlite3_value **ppVal /* Write the new value here */
76121 ){
76122 return pExpr ? valueFromExpr(db, pExpr, enc, affinity, ppVal, 0) : 0;
76123 }
76124
76125 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
76126 /*
76127 ** The implementation of the sqlite_record() function. This function accepts
76128 ** a single argument of any type. The return value is a formatted database
76129 ** record (a blob) containing the argument value.
76130 **
76131 ** This is used to convert the value stored in the 'sample' column of the
76132 ** sqlite_stat3 table to the record format SQLite uses internally.
76133 */
76134 static void recordFunc(
76135 sqlite3_context *context,
76136 int argc,
76137 sqlite3_value **argv
76138 ){
76139 const int file_format = 1;
76140 u32 iSerial; /* Serial type */
76141 int nSerial; /* Bytes of space for iSerial as varint */
76142 u32 nVal; /* Bytes of space required for argv[0] */
76143 int nRet;
76144 sqlite3 *db;
76145 u8 *aRet;
76146
76147 UNUSED_PARAMETER( argc );
76148 iSerial = sqlite3VdbeSerialType(argv[0], file_format, &nVal);
76149 nSerial = sqlite3VarintLen(iSerial);
76150 db = sqlite3_context_db_handle(context);
76151
76152 nRet = 1 + nSerial + nVal;
76153 aRet = sqlite3DbMallocRawNN(db, nRet);
76154 if( aRet==0 ){
76155 sqlite3_result_error_nomem(context);
76156 }else{
76157 aRet[0] = nSerial+1;
76158 putVarint32(&aRet[1], iSerial);
76159 sqlite3VdbeSerialPut(&aRet[1+nSerial], argv[0], iSerial);
76160 sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT);
76161 sqlite3DbFreeNN(db, aRet);
76162 }
76163 }
76164
76165 /*
76166 ** Register built-in functions used to help read ANALYZE data.
76167 */
76168 SQLITE_PRIVATE void sqlite3AnalyzeFunctions(void){
76169 static FuncDef aAnalyzeTableFuncs[] = {
76170 FUNCTION(sqlite_record, 1, 0, 0, recordFunc),
76171 };
76172 sqlite3InsertBuiltinFuncs(aAnalyzeTableFuncs, ArraySize(aAnalyzeTableFuncs));
76173 }
76174
76175 /*
76176 ** Attempt to extract a value from pExpr and use it to construct *ppVal.
76177 **
76178 ** If pAlloc is not NULL, then an UnpackedRecord object is created for
76179 ** pAlloc if one does not exist and the new value is added to the
@@ -77413,20 +77474,20 @@
77413
77414 /*
77415 ** Change the value of the opcode, or P1, P2, P3, or P5 operands
77416 ** for a specific instruction.
77417 */
77418 SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe *p, u32 addr, u8 iNewOpcode){
77419 sqlite3VdbeGetOp(p,addr)->opcode = iNewOpcode;
77420 }
77421 SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe *p, u32 addr, int val){
77422 sqlite3VdbeGetOp(p,addr)->p1 = val;
77423 }
77424 SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe *p, u32 addr, int val){
77425 sqlite3VdbeGetOp(p,addr)->p2 = val;
77426 }
77427 SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe *p, u32 addr, int val){
77428 sqlite3VdbeGetOp(p,addr)->p3 = val;
77429 }
77430 SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe *p, u16 p5){
77431 assert( p->nOp>0 || p->db->mallocFailed );
77432 if( p->nOp>0 ) p->aOp[p->nOp-1].p5 = p5;
@@ -77929,18 +77990,20 @@
77929 sqlite3StrAccumInit(&x, 0, zTemp, nTemp, 0);
77930 switch( pOp->p4type ){
77931 case P4_KEYINFO: {
77932 int j;
77933 KeyInfo *pKeyInfo = pOp->p4.pKeyInfo;
77934 assert( pKeyInfo->aSortOrder!=0 );
77935 sqlite3_str_appendf(&x, "k(%d", pKeyInfo->nKeyField);
77936 for(j=0; j<pKeyInfo->nKeyField; j++){
77937 CollSeq *pColl = pKeyInfo->aColl[j];
77938 const char *zColl = pColl ? pColl->zName : "";
77939 if( strcmp(zColl, "BINARY")==0 ) zColl = "B";
77940 sqlite3_str_appendf(&x, ",%s%s",
77941 pKeyInfo->aSortOrder[j] ? "-" : "", zColl);
 
 
77942 }
77943 sqlite3_str_append(&x, ")", 1);
77944 break;
77945 }
77946 #ifdef SQLITE_ENABLE_CURSOR_HINTS
@@ -78343,12 +78406,15 @@
78343 }else{
78344 /* We are currently listing subprograms. Figure out which one and
78345 ** pick up the appropriate opcode. */
78346 int j;
78347 i -= p->nOp;
 
 
78348 for(j=0; i>=apSub[j]->nOp; j++){
78349 i -= apSub[j]->nOp;
 
78350 }
78351 pOp = &apSub[j]->aOp[i];
78352 }
78353
78354 /* When an OP_Program opcode is encounter (the only opcode that has
@@ -79866,14 +79932,21 @@
79866 **
79867 ** The 8 and 9 types were added in 3.3.0, file format 4. Prior versions
79868 ** of SQLite will not understand those serial types.
79869 */
79870
 
79871 /*
79872 ** Return the serial-type for the value stored in pMem.
79873 **
79874 ** This routine might convert a large MEM_IntReal value into MEM_Real.
 
 
 
 
 
 
79875 */
79876 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format, u32 *pLen){
79877 int flags = pMem->flags;
79878 u32 n;
79879
@@ -79930,10 +80003,11 @@
79930 n += pMem->u.nZero;
79931 }
79932 *pLen = n;
79933 return ((n*2) + 12 + ((flags&MEM_Str)!=0));
79934 }
 
79935
79936 /*
79937 ** The sizes for serial types less than 128
79938 */
79939 static const u8 sqlite3SmallTypeSizes[] = {
@@ -80238,11 +80312,11 @@
80238 int nByte; /* Number of bytes required for *p */
80239 nByte = ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1);
80240 p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte);
80241 if( !p ) return 0;
80242 p->aMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))];
80243 assert( pKeyInfo->aSortOrder!=0 );
80244 p->pKeyInfo = pKeyInfo;
80245 p->nField = pKeyInfo->nKeyField + 1;
80246 return p;
80247 }
80248
@@ -80337,11 +80411,11 @@
80337
80338 idx1 = getVarint32(aKey1, szHdr1);
80339 if( szHdr1>98307 ) return SQLITE_CORRUPT;
80340 d1 = szHdr1;
80341 assert( pKeyInfo->nAllField>=pPKey2->nField || CORRUPT_DB );
80342 assert( pKeyInfo->aSortOrder!=0 );
80343 assert( pKeyInfo->nKeyField>0 );
80344 assert( idx1<=szHdr1 || CORRUPT_DB );
80345 do{
80346 u32 serial_type1;
80347
@@ -80368,11 +80442,16 @@
80368 */
80369 rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
80370 pKeyInfo->nAllField>i ? pKeyInfo->aColl[i] : 0);
80371 if( rc!=0 ){
80372 assert( mem1.szMalloc==0 ); /* See comment below */
80373 if( pKeyInfo->aSortOrder[i] ){
 
 
 
 
 
80374 rc = -rc; /* Invert the result for DESC sort order. */
80375 }
80376 goto debugCompareEnd;
80377 }
80378 i++;
@@ -80744,11 +80823,11 @@
80744 }
80745
80746 VVA_ONLY( mem1.szMalloc = 0; ) /* Only needed by assert() statements */
80747 assert( pPKey2->pKeyInfo->nAllField>=pPKey2->nField
80748 || CORRUPT_DB );
80749 assert( pPKey2->pKeyInfo->aSortOrder!=0 );
80750 assert( pPKey2->pKeyInfo->nKeyField>0 );
80751 assert( idx1<=szHdr1 || CORRUPT_DB );
80752 do{
80753 u32 serial_type;
80754
@@ -80867,12 +80946,18 @@
80867 serial_type = aKey1[idx1];
80868 rc = (serial_type!=0);
80869 }
80870
80871 if( rc!=0 ){
80872 if( pPKey2->pKeyInfo->aSortOrder[i] ){
80873 rc = -rc;
 
 
 
 
 
 
80874 }
80875 assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );
80876 assert( mem1.szMalloc==0 ); /* See comment below */
80877 return rc;
80878 }
@@ -81036,11 +81121,15 @@
81036 return 0; /* Corruption */
81037 }
81038 nCmp = MIN( pPKey2->aMem[0].n, nStr );
81039 res = memcmp(&aKey1[szHdr], pPKey2->aMem[0].z, nCmp);
81040
81041 if( res==0 ){
 
 
 
 
81042 res = nStr - pPKey2->aMem[0].n;
81043 if( res==0 ){
81044 if( pPKey2->nField>1 ){
81045 res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
81046 }else{
@@ -81050,14 +81139,10 @@
81050 }else if( res>0 ){
81051 res = pPKey2->r2;
81052 }else{
81053 res = pPKey2->r1;
81054 }
81055 }else if( res>0 ){
81056 res = pPKey2->r2;
81057 }else{
81058 res = pPKey2->r1;
81059 }
81060 }
81061
81062 assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, res)
81063 || CORRUPT_DB
@@ -81085,11 +81170,14 @@
81085 ** The easiest way to enforce this limit is to consider only records with
81086 ** 13 fields or less. If the first field is an integer, the maximum legal
81087 ** header size is (12*5 + 1 + 1) bytes. */
81088 if( p->pKeyInfo->nAllField<=13 ){
81089 int flags = p->aMem[0].flags;
81090 if( p->pKeyInfo->aSortOrder[0] ){
 
 
 
81091 p->r1 = 1;
81092 p->r2 = -1;
81093 }else{
81094 p->r1 = -1;
81095 p->r2 = 1;
@@ -81334,11 +81422,11 @@
81334 ** throw an error if it is given inputs that would make it non-deterministic.
81335 ** This routine is invoked by date/time functions that use non-deterministic
81336 ** features such as 'now'.
81337 */
81338 SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){
81339 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
81340 if( pCtx->pVdbe==0 ) return 1;
81341 #endif
81342 if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){
81343 sqlite3_result_error(pCtx,
81344 "non-deterministic function in index expression or CHECK constraint",
@@ -81431,11 +81519,11 @@
81431 preupdate.op = op;
81432 preupdate.iNewReg = iReg;
81433 preupdate.keyinfo.db = db;
81434 preupdate.keyinfo.enc = ENC(db);
81435 preupdate.keyinfo.nKeyField = pTab->nCol;
81436 preupdate.keyinfo.aSortOrder = (u8*)&fakeSortOrder;
81437 preupdate.iKey1 = iKey1;
81438 preupdate.iKey2 = iKey2;
81439 preupdate.pTab = pTab;
81440
81441 db->pPreUpdate = &preupdate;
@@ -82300,11 +82388,11 @@
82300 ** of the amount of time that elapses between invocations. In other words,
82301 ** the time returned is always the time of the first call.
82302 */
82303 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
82304 int rc;
82305 #ifndef SQLITE_ENABLE_STAT3_OR_STAT4
82306 sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;
82307 assert( p->pVdbe!=0 );
82308 #else
82309 sqlite3_int64 iTime = 0;
82310 sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
@@ -82365,11 +82453,11 @@
82365 */
82366 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
82367 AuxData *pAuxData;
82368
82369 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
82370 #if SQLITE_ENABLE_STAT3_OR_STAT4
82371 if( pCtx->pVdbe==0 ) return 0;
82372 #else
82373 assert( pCtx->pVdbe!=0 );
82374 #endif
82375 for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){
@@ -82399,11 +82487,11 @@
82399 ){
82400 AuxData *pAuxData;
82401 Vdbe *pVdbe = pCtx->pVdbe;
82402
82403 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
82404 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
82405 if( pVdbe==0 ) goto failed;
82406 #else
82407 assert( pVdbe!=0 );
82408 #endif
82409
@@ -84051,10 +84139,11 @@
84051 **
84052 ** SQLITE_AFF_TEXT:
84053 ** Convert pRec to a text representation.
84054 **
84055 ** SQLITE_AFF_BLOB:
 
84056 ** No-op. pRec is unchanged.
84057 */
84058 static void applyAffinity(
84059 Mem *pRec, /* The value to apply affinity to */
84060 char affinity, /* The affinity to be applied */
@@ -84192,15 +84281,16 @@
84192 c = 's';
84193 }
84194 *(zCsr++) = c;
84195 sqlite3_snprintf(100, zCsr, "%d[", pMem->n);
84196 zCsr += sqlite3Strlen30(zCsr);
84197 for(i=0; i<16 && i<pMem->n; i++){
84198 sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
84199 zCsr += sqlite3Strlen30(zCsr);
84200 }
84201 for(i=0; i<16 && i<pMem->n; i++){
 
84202 char z = pMem->z[i];
84203 if( z<32 || z>126 ) *zCsr++ = '.';
84204 else *zCsr++ = z;
84205 }
84206 *(zCsr++) = ']';
@@ -84226,11 +84316,11 @@
84226 }
84227 k = 2;
84228 sqlite3_snprintf(100, &zBuf[k], "%d", pMem->n);
84229 k += sqlite3Strlen30(&zBuf[k]);
84230 zBuf[k++] = '[';
84231 for(j=0; j<15 && j<pMem->n; j++){
84232 u8 c = pMem->z[j];
84233 if( c>=0x20 && c<0x7f ){
84234 zBuf[k++] = c;
84235 }else{
84236 zBuf[k++] = '.';
@@ -85628,10 +85718,11 @@
85628 pIn1 = &aMem[pOp->p1];
85629 if( pIn1->flags & (MEM_Int|MEM_IntReal) ){
85630 testcase( pIn1->flags & MEM_Int );
85631 testcase( pIn1->flags & MEM_IntReal );
85632 sqlite3VdbeMemRealify(pIn1);
 
85633 }
85634 break;
85635 }
85636 #endif
85637
@@ -86023,13 +86114,18 @@
86023 assert( memIsValid(&aMem[p2+idx]) );
86024 REGISTER_TRACE(p1+idx, &aMem[p1+idx]);
86025 REGISTER_TRACE(p2+idx, &aMem[p2+idx]);
86026 assert( i<pKeyInfo->nKeyField );
86027 pColl = pKeyInfo->aColl[i];
86028 bRev = pKeyInfo->aSortOrder[i];
86029 iCompare = sqlite3MemCompare(&aMem[p1+idx], &aMem[p2+idx], pColl);
86030 if( iCompare ){
 
 
 
 
 
86031 if( bRev ) iCompare = -iCompare;
86032 break;
86033 }
86034 }
86035 break;
@@ -86316,15 +86412,10 @@
86316 **
86317 ** If the record contains fewer than P2 fields, then extract a NULL. Or,
86318 ** if the P4 argument is a P4_MEM use the value of the P4 argument as
86319 ** the result.
86320 **
86321 ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
86322 ** then the cache of the cursor is reset prior to extracting the column.
86323 ** The first OP_Column against a pseudo-table after the value of the content
86324 ** register has changed should have this bit set.
86325 **
86326 ** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 then
86327 ** the result is guaranteed to only be used as the argument of a length()
86328 ** or typeof() function, respectively. The loading of large blobs can be
86329 ** skipped for length() and all content loading can be skipped for typeof().
86330 */
@@ -86609,19 +86700,31 @@
86609 zAffinity = pOp->p4.z;
86610 assert( zAffinity!=0 );
86611 assert( pOp->p2>0 );
86612 assert( zAffinity[pOp->p2]==0 );
86613 pIn1 = &aMem[pOp->p1];
86614 while( 1 /*edit-by-break*/ ){
86615 assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] );
86616 assert( memIsValid(pIn1) );
86617 applyAffinity(pIn1, zAffinity[0], encoding);
86618 if( zAffinity[0]==SQLITE_AFF_REAL && (pIn1->flags & MEM_Int)!=0 ){
86619 /* When applying REAL affinity, if the result is still MEM_Int,
86620 ** indicate that REAL is actually desired */
86621 pIn1->flags |= MEM_IntReal;
86622 pIn1->flags &= ~MEM_Int;
 
 
 
 
 
 
 
 
 
 
 
 
86623 }
86624 REGISTER_TRACE((int)(pIn1-aMem), pIn1);
86625 zAffinity++;
86626 if( zAffinity[0]==0 ) break;
86627 pIn1++;
@@ -86724,38 +86827,124 @@
86724 }
86725 }
86726 #endif
86727
86728 /* Loop through the elements that will make up the record to figure
86729 ** out how much space is required for the new record.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86730 */
86731 pRec = pLast;
86732 do{
86733 assert( memIsValid(pRec) );
86734 serial_type = sqlite3VdbeSerialType(pRec, file_format, &len);
86735 if( pRec->flags & MEM_Zero ){
86736 if( serial_type==0 ){
86737 /* Values with MEM_Null and MEM_Zero are created by xColumn virtual
86738 ** table methods that never invoke sqlite3_result_xxxxx() while
86739 ** computing an unchanging column value in an UPDATE statement.
86740 ** Give such values a special internal-use-only serial-type of 10
86741 ** so that they can be passed through to xUpdate and have
86742 ** a true sqlite3_value_nochange(). */
86743 assert( pOp->p5==OPFLAG_NOCHNG_MAGIC || CORRUPT_DB );
86744 serial_type = 10;
86745 }else if( nData ){
86746 if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem;
86747 }else{
86748 nZero += pRec->u.nZero;
86749 len -= pRec->u.nZero;
86750 }
86751 }
86752 nData += len;
86753 testcase( serial_type==127 );
86754 testcase( serial_type==128 );
86755 nHdr += serial_type<=127 ? 1 : sqlite3VarintLen(serial_type);
86756 pRec->uTemp = serial_type;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86757 if( pRec==pData0 ) break;
86758 pRec--;
86759 }while(1);
86760
86761 /* EVIDENCE-OF: R-22564-11647 The header begins with a single varint
@@ -87087,11 +87276,11 @@
87087 "cannot commit - no transaction is active"));
87088
87089 rc = SQLITE_ERROR;
87090 goto abort_due_to_error;
87091 }
87092 break;
87093 }
87094
87095 /* Opcode: Transaction P1 P2 P3 P4 P5
87096 **
87097 ** Begin a transaction on database P1 if a transaction is not already
@@ -87825,30 +88014,34 @@
87825 #endif
87826
87827 pC->deferredMoveto = 0;
87828 pC->cacheStatus = CACHE_STALE;
87829 if( pC->isTable ){
 
87830 /* The BTREE_SEEK_EQ flag is only set on index cursors */
87831 assert( sqlite3BtreeCursorHasHint(pC->uc.pCursor, BTREE_SEEK_EQ)==0
87832 || CORRUPT_DB );
87833
87834 /* The input value in P3 might be of any type: integer, real, string,
87835 ** blob, or NULL. But it needs to be an integer before we can do
87836 ** the seek, so convert it. */
87837 pIn3 = &aMem[pOp->p3];
87838 if( (pIn3->flags & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Str))==MEM_Str ){
 
87839 applyNumericAffinity(pIn3, 0);
87840 }
87841 iKey = sqlite3VdbeIntValue(pIn3);
 
 
87842
87843 /* If the P3 value could not be converted into an integer without
87844 ** loss of information, then special processing is required... */
87845 if( (pIn3->flags & (MEM_Int|MEM_IntReal))==0 ){
87846 if( (pIn3->flags & MEM_Real)==0 ){
87847 if( (pIn3->flags & MEM_Null) || oc>=OP_SeekGE ){
87848 VdbeBranchTaken(1,2); goto jump_to_p2;
87849 break;
87850 }else{
87851 rc = sqlite3BtreeLast(pC->uc.pCursor, &res);
87852 if( rc!=SQLITE_OK ) goto abort_due_to_error;
87853 goto seek_not_found;
87854 }
@@ -89138,15 +89331,16 @@
89138
89139 /* The Next opcode is only used after SeekGT, SeekGE, Rewind, and Found.
89140 ** The Prev opcode is only used after SeekLT, SeekLE, and Last. */
89141 assert( pOp->opcode!=OP_Next
89142 || pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
89143 || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
89144 || pC->seekOp==OP_NullRow|| pC->seekOp==OP_SeekRowid);
 
89145 assert( pOp->opcode!=OP_Prev
89146 || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
89147 || pC->seekOp==OP_Last
89148 || pC->seekOp==OP_NullRow);
89149
89150 rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
89151 next_tail:
89152 pC->cacheStatus = CACHE_STALE;
@@ -89661,11 +89855,11 @@
89661 initData.db = db;
89662 initData.iDb = iDb;
89663 initData.pzErrMsg = &p->zErrMsg;
89664 initData.mInitFlags = 0;
89665 zSql = sqlite3MPrintf(db,
89666 "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid",
89667 db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);
89668 if( zSql==0 ){
89669 rc = SQLITE_NOMEM_BKPT;
89670 }else{
89671 assert( db->init.busy==0 );
@@ -91868,15 +92062,16 @@
91868 Incrblob *p = (Incrblob *)pBlob;
91869 int rc;
91870 sqlite3 *db;
91871
91872 if( p ){
 
91873 db = p->db;
91874 sqlite3_mutex_enter(db->mutex);
91875 rc = sqlite3_finalize(p->pStmt);
91876 sqlite3DbFree(db, p);
91877 sqlite3_mutex_leave(db->mutex);
 
91878 }else{
91879 rc = SQLITE_OK;
91880 }
91881 return rc;
91882 }
@@ -92852,11 +93047,12 @@
92852 res = vdbeSorterCompareTail(
92853 pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2
92854 );
92855 }
92856 }else{
92857 if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){
 
92858 res = res * -1;
92859 }
92860 }
92861
92862 return res;
@@ -92920,11 +93116,12 @@
92920 if( pTask->pSorter->pKeyInfo->nKeyField>1 ){
92921 res = vdbeSorterCompareTail(
92922 pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2
92923 );
92924 }
92925 }else if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){
 
92926 res = res * -1;
92927 }
92928
92929 return res;
92930 }
@@ -93035,10 +93232,11 @@
93035 }
93036 }
93037
93038 if( pKeyInfo->nAllField<13
93039 && (pKeyInfo->aColl[0]==0 || pKeyInfo->aColl[0]==db->pDfltColl)
 
93040 ){
93041 pSorter->typeMask = SORTER_TYPE_INTEGER | SORTER_TYPE_TEXT;
93042 }
93043 }
93044
@@ -93751,17 +93949,20 @@
93751 if( i==nWorker ){
93752 /* Use the foreground thread for this operation */
93753 rc = vdbeSorterListToPMA(&pSorter->aTask[nWorker], &pSorter->list);
93754 }else{
93755 /* Launch a background thread for this operation */
93756 u8 *aMem = pTask->list.aMemory;
93757 void *pCtx = (void*)pTask;
93758
 
93759 assert( pTask->pThread==0 && pTask->bDone==0 );
93760 assert( pTask->list.pList==0 );
93761 assert( pTask->list.aMemory==0 || pSorter->list.aMemory!=0 );
93762
 
 
93763 pSorter->iPrev = (u8)(pTask - pSorter->aTask);
93764 pTask->list = pSorter->list;
93765 pSorter->list.pList = 0;
93766 pSorter->list.szPMA = 0;
93767 if( aMem ){
@@ -94881,18 +95082,13 @@
94881 u8 *zOut = zBuf;
94882 int nRead = iAmt;
94883 int iChunkOffset;
94884 FileChunk *pChunk;
94885
94886 #if defined(SQLITE_ENABLE_ATOMIC_WRITE) \
94887 || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
94888 if( (iAmt+iOfst)>p->endpoint.iOffset ){
94889 return SQLITE_IOERR_SHORT_READ;
94890 }
94891 #endif
94892
94893 assert( (iAmt+iOfst)<=p->endpoint.iOffset );
94894 assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 );
94895 if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
94896 sqlite3_int64 iOff = 0;
94897 for(pChunk=p->pFirst;
94898 ALWAYS(pChunk) && (iOff+p->nChunkSize)<=iOfst;
@@ -95247,13 +95443,26 @@
95247 ** as the second argument.
95248 */
95249 static int walkWindowList(Walker *pWalker, Window *pList){
95250 Window *pWin;
95251 for(pWin=pList; pWin; pWin=pWin->pNextWin){
95252 if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
95253 if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
95254 if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
 
 
 
 
 
 
 
 
 
 
 
 
 
95255 }
95256 return WRC_Continue;
95257 }
95258 #endif
95259
@@ -95285,22 +95494,26 @@
95285 if( rc ) return rc & WRC_Abort;
95286 if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){
95287 if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
95288 assert( pExpr->x.pList==0 || pExpr->pRight==0 );
95289 if( pExpr->pRight ){
 
95290 pExpr = pExpr->pRight;
95291 continue;
95292 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
 
95293 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
95294 }else if( pExpr->x.pList ){
95295 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
95296 }
 
95297 #ifndef SQLITE_OMIT_WINDOWFUNC
95298 if( ExprHasProperty(pExpr, EP_WinFunc) ){
95299 if( walkWindowList(pWalker, pExpr->y.pWin) ) return WRC_Abort;
 
 
95300 }
95301 #endif
95302 }
95303 break;
95304 }
95305 return WRC_Continue;
95306 }
@@ -95338,12 +95551,13 @@
95338 if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;
95339 #if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE)
95340 {
95341 Parse *pParse = pWalker->pParse;
95342 if( pParse && IN_RENAME_OBJECT ){
 
 
95343 int rc = walkWindowList(pWalker, p->pWinDefn);
95344 assert( rc==WRC_Continue );
95345 return rc;
95346 }
95347 }
95348 #endif
95349 return WRC_Continue;
@@ -95796,11 +96010,11 @@
95796 }else
95797 #endif /* SQLITE_OMIT_UPSERT */
95798 {
95799 #ifndef SQLITE_OMIT_TRIGGER
95800 if( iCol<0 ){
95801 pExpr->affinity = SQLITE_AFF_INTEGER;
95802 }else if( pExpr->iTable==0 ){
95803 testcase( iCol==31 );
95804 testcase( iCol==32 );
95805 pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
95806 }else{
@@ -95828,11 +96042,11 @@
95828 && sqlite3IsRowid(zCol)
95829 && VisibleRowid(pMatch->pTab)
95830 ){
95831 cnt = 1;
95832 pExpr->iColumn = -1;
95833 pExpr->affinity = SQLITE_AFF_INTEGER;
95834 }
95835
95836 /*
95837 ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z
95838 ** might refer to an result-set alias. This happens, for example, when
@@ -96104,11 +96318,11 @@
96104 assert( HasRowid(pItem->pTab) && pItem->pTab->pSelect==0 );
96105 pExpr->op = TK_COLUMN;
96106 pExpr->y.pTab = pItem->pTab;
96107 pExpr->iTable = pItem->iCursor;
96108 pExpr->iColumn = -1;
96109 pExpr->affinity = SQLITE_AFF_INTEGER;
96110 break;
96111 }
96112 #endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)
96113 && !defined(SQLITE_OMIT_SUBQUERY) */
96114
@@ -96164,11 +96378,13 @@
96164 int nId; /* Number of characters in function name */
96165 const char *zId; /* The function name. */
96166 FuncDef *pDef; /* Information about the function */
96167 u8 enc = ENC(pParse->db); /* The database encoding */
96168 int savedAllowFlags = (pNC->ncFlags & (NC_AllowAgg | NC_AllowWin));
96169
 
 
96170 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
96171 zId = pExpr->u.zToken;
96172 nId = sqlite3Strlen30(zId);
96173 pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);
96174 if( pDef==0 ){
@@ -96236,31 +96452,40 @@
96236 ){
96237 /* Internal-use-only functions are disallowed unless the
96238 ** SQL is being compiled using sqlite3NestedParse() */
96239 no_such_func = 1;
96240 pDef = 0;
 
 
 
 
 
 
 
 
 
96241 }
96242 }
96243
96244 if( 0==IN_RENAME_OBJECT ){
96245 #ifndef SQLITE_OMIT_WINDOWFUNC
96246 assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
96247 || (pDef->xValue==0 && pDef->xInverse==0)
96248 || (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
96249 );
96250 if( pDef && pDef->xValue==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
96251 sqlite3ErrorMsg(pParse,
96252 "%.*s() may not be used as a window function", nId, zId
96253 );
96254 pNC->nErr++;
96255 }else if(
96256 (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
96257 || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pExpr->y.pWin)
96258 || (is_agg && pExpr->y.pWin && (pNC->ncFlags & NC_AllowWin)==0)
96259 ){
96260 const char *zType;
96261 if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->y.pWin ){
96262 zType = "window";
96263 }else{
96264 zType = "aggregate";
96265 }
96266 sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
@@ -96284,51 +96509,66 @@
96284 }else if( wrong_num_args ){
96285 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
96286 nId, zId);
96287 pNC->nErr++;
96288 }
 
 
 
 
 
 
 
 
 
96289 if( is_agg ){
96290 /* Window functions may not be arguments of aggregate functions.
96291 ** Or arguments of other window functions. But aggregate functions
96292 ** may be arguments for window functions. */
96293 #ifndef SQLITE_OMIT_WINDOWFUNC
96294 pNC->ncFlags &= ~(NC_AllowWin | (!pExpr->y.pWin ? NC_AllowAgg : 0));
96295 #else
96296 pNC->ncFlags &= ~NC_AllowAgg;
96297 #endif
96298 }
96299 }
 
 
 
 
 
96300 sqlite3WalkExprList(pWalker, pList);
96301 if( is_agg ){
96302 #ifndef SQLITE_OMIT_WINDOWFUNC
96303 if( pExpr->y.pWin ){
96304 Select *pSel = pNC->pWinSelect;
 
96305 if( IN_RENAME_OBJECT==0 ){
96306 sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef);
96307 }
96308 sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition);
96309 sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy);
96310 sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter);
96311 if( 0==pSel->pWin
96312 || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin)
96313 ){
96314 pExpr->y.pWin->pNextWin = pSel->pWin;
96315 pSel->pWin = pExpr->y.pWin;
96316 }
96317 pNC->ncFlags |= NC_HasWin;
96318 }else
96319 #endif /* SQLITE_OMIT_WINDOWFUNC */
96320 {
96321 NameContext *pNC2 = pNC;
96322 pExpr->op = TK_AGG_FUNCTION;
96323 pExpr->op2 = 0;
 
 
 
 
 
96324 while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){
96325 pExpr->op2++;
96326 pNC2 = pNC2->pNext;
96327 }
96328 assert( pDef!=0 );
96329 if( pNC2 ){
96330 assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
96331 testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
96332 pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
96333
96334 }
@@ -96362,11 +96602,11 @@
96362 notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
96363 break;
96364 }
96365 case TK_IS:
96366 case TK_ISNOT: {
96367 Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);
96368 assert( !ExprHasProperty(pExpr, EP_Reduced) );
96369 /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE",
96370 ** and "x IS NOT FALSE". */
96371 if( pRight->op==TK_ID ){
96372 int rc = resolveExprStep(pWalker, pRight);
@@ -96573,11 +96813,11 @@
96573 assert( pEList!=0 );
96574 for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
96575 int iCol = -1;
96576 Expr *pE, *pDup;
96577 if( pItem->done ) continue;
96578 pE = sqlite3ExprSkipCollate(pItem->pExpr);
96579 if( sqlite3ExprIsInteger(pE, &iCol) ){
96580 if( iCol<=0 || iCol>pEList->nExpr ){
96581 resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr);
96582 return 1;
96583 }
@@ -96667,11 +96907,11 @@
96667 int i;
96668 sqlite3 *db = pParse->db;
96669 ExprList *pEList;
96670 struct ExprList_item *pItem;
96671
96672 if( pOrderBy==0 || pParse->db->mallocFailed ) return 0;
96673 if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){
96674 sqlite3ErrorMsg(pParse, "too many terms in %s BY clause", zType);
96675 return 1;
96676 }
96677 pEList = pSelect->pEList;
@@ -96689,39 +96929,37 @@
96689 return 0;
96690 }
96691
96692 #ifndef SQLITE_OMIT_WINDOWFUNC
96693 /*
96694 ** Walker callback for resolveRemoveWindows().
96695 */
96696 static int resolveRemoveWindowsCb(Walker *pWalker, Expr *pExpr){
 
96697 if( ExprHasProperty(pExpr, EP_WinFunc) ){
96698 Window **pp;
96699 for(pp=&pWalker->u.pSelect->pWin; *pp; pp=&(*pp)->pNextWin){
96700 if( *pp==pExpr->y.pWin ){
96701 *pp = (*pp)->pNextWin;
96702 break;
96703 }
96704 }
96705 }
96706 return WRC_Continue;
96707 }
96708
96709 /*
96710 ** Remove any Window objects owned by the expression pExpr from the
96711 ** Select.pWin list of Select object pSelect.
96712 */
96713 static void resolveRemoveWindows(Select *pSelect, Expr *pExpr){
96714 Walker sWalker;
96715 memset(&sWalker, 0, sizeof(Walker));
96716 sWalker.xExprCallback = resolveRemoveWindowsCb;
96717 sWalker.u.pSelect = pSelect;
96718 sqlite3WalkExpr(&sWalker, pExpr);
 
 
96719 }
96720 #else
96721 # define resolveRemoveWindows(x,y)
96722 #endif
96723
96724 /*
96725 ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.
96726 ** The Name context of the SELECT statement is pNC. zType is either
96727 ** "ORDER" or "GROUP" depending on which type of clause pOrderBy is.
@@ -96754,11 +96992,11 @@
96754 if( pOrderBy==0 ) return 0;
96755 nResult = pSelect->pEList->nExpr;
96756 pParse = pNC->pParse;
96757 for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
96758 Expr *pE = pItem->pExpr;
96759 Expr *pE2 = sqlite3ExprSkipCollate(pE);
96760 if( zType[0]!='G' ){
96761 iCol = resolveAsName(pParse, pSelect->pEList, pE2);
96762 if( iCol>0 ){
96763 /* If an AS-name match is found, mark this ORDER BY column as being
96764 ** a copy of the iCol-th result-set column. The subsequent call to
@@ -96788,11 +97026,11 @@
96788 for(j=0; j<pSelect->pEList->nExpr; j++){
96789 if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
96790 /* Since this expresion is being changed into a reference
96791 ** to an identical expression in the result set, remove all Window
96792 ** objects belonging to the expression from the Select.pWin list. */
96793 resolveRemoveWindows(pSelect, pE);
96794 pItem->u.x.iOrderByCol = j+1;
96795 }
96796 }
96797 }
96798 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -97256,11 +97494,10 @@
97256 ** SELECT a AS b FROM t1 WHERE b;
97257 ** SELECT * FROM t1 WHERE (select a from t1);
97258 */
97259 SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){
97260 int op;
97261 if( pExpr->flags & EP_Generic ) return 0;
97262 while( ExprHasProperty(pExpr, EP_Skip) ){
97263 assert( pExpr->op==TK_COLLATE );
97264 pExpr = pExpr->pLeft;
97265 assert( pExpr!=0 );
97266 }
@@ -97283,11 +97520,11 @@
97283 assert( pExpr->pLeft->flags&EP_xIsSelect );
97284 return sqlite3ExprAffinity(
97285 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
97286 );
97287 }
97288 return pExpr->affinity;
97289 }
97290
97291 /*
97292 ** Set the collating sequence for expression pExpr to be the collating
97293 ** sequence named by pToken. Return a pointer to a new Expr node that
@@ -97318,14 +97555,26 @@
97318 sqlite3TokenInit(&s, (char*)zC);
97319 return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0);
97320 }
97321
97322 /*
97323 ** Skip over any TK_COLLATE operators and any unlikely()
97324 ** or likelihood() function at the root of an expression.
97325 */
97326 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){
 
 
 
 
 
 
 
 
 
 
 
 
 
97327 while( pExpr && ExprHasProperty(pExpr, EP_Skip|EP_Unlikely) ){
97328 if( ExprHasProperty(pExpr, EP_Unlikely) ){
97329 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
97330 assert( pExpr->x.pList->nExpr>0 );
97331 assert( pExpr->op==TK_FUNCTION );
@@ -97356,11 +97605,10 @@
97356 sqlite3 *db = pParse->db;
97357 CollSeq *pColl = 0;
97358 Expr *p = pExpr;
97359 while( p ){
97360 int op = p->op;
97361 if( p->flags & EP_Generic ) break;
97362 if( op==TK_REGISTER ) op = p->op2;
97363 if( (op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_TRIGGER)
97364 && p->y.pTab!=0
97365 ){
97366 /* op==TK_REGISTER && p->y.pTab!=0 happens when pExpr was originally
@@ -97442,28 +97690,23 @@
97442 ** type affinity of the other operand. This routine returns the
97443 ** type affinity that should be used for the comparison operator.
97444 */
97445 SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2){
97446 char aff1 = sqlite3ExprAffinity(pExpr);
97447 if( aff1 && aff2 ){
97448 /* Both sides of the comparison are columns. If one has numeric
97449 ** affinity, use that. Otherwise use no affinity.
97450 */
97451 if( sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2) ){
97452 return SQLITE_AFF_NUMERIC;
97453 }else{
97454 return SQLITE_AFF_BLOB;
97455 }
97456 }else if( !aff1 && !aff2 ){
97457 /* Neither side of the comparison is a column. Compare the
97458 ** results directly.
97459 */
97460 return SQLITE_AFF_BLOB;
97461 }else{
97462 /* One side is a column, the other is not. Use the columns affinity. */
97463 assert( aff1==0 || aff2==0 );
97464 return (aff1 + aff2);
97465 }
97466 }
97467
97468 /*
97469 ** pExpr is a comparison operator. Return the type affinity that should
@@ -97492,18 +97735,17 @@
97492 ** if the index with affinity idx_affinity may be used to implement
97493 ** the comparison in pExpr.
97494 */
97495 SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){
97496 char aff = comparisonAffinity(pExpr);
97497 switch( aff ){
97498 case SQLITE_AFF_BLOB:
97499 return 1;
97500 case SQLITE_AFF_TEXT:
97501 return idx_affinity==SQLITE_AFF_TEXT;
97502 default:
97503 return sqlite3IsNumericAffinity(idx_affinity);
97504 }
97505 }
97506
97507 /*
97508 ** Return the P5 value that should be used for a binary comparison
97509 ** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2.
@@ -98252,19 +98494,22 @@
98252 if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){
98253 /* The Expr.x union is never used at the same time as Expr.pRight */
98254 assert( p->x.pList==0 || p->pRight==0 );
98255 if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);
98256 if( p->pRight ){
 
98257 sqlite3ExprDeleteNN(db, p->pRight);
98258 }else if( ExprHasProperty(p, EP_xIsSelect) ){
 
98259 sqlite3SelectDelete(db, p->x.pSelect);
98260 }else{
98261 sqlite3ExprListDelete(db, p->x.pList);
98262 }
98263 if( ExprHasProperty(p, EP_WinFunc) ){
98264 assert( p->op==TK_FUNCTION );
98265 sqlite3WindowDelete(db, p->y.pWin);
 
98266 }
98267 }
98268 if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
98269 if( !ExprHasProperty(p, EP_Static) ){
98270 sqlite3DbFreeNN(db, p);
@@ -98295,20 +98540,10 @@
98295 if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE;
98296 if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE;
98297 return EXPR_FULLSIZE;
98298 }
98299
98300 /*
98301 ** Copy the complete content of an Expr node, taking care not to read
98302 ** past the end of the structure for a reduced-size version of the source
98303 ** Expr.
98304 */
98305 static void exprNodeCopy(Expr *pDest, Expr *pSrc){
98306 memset(pDest, 0, sizeof(Expr));
98307 memcpy(pDest, pSrc, exprStructSize(pSrc));
98308 }
98309
98310 /*
98311 ** The dupedExpr*Size() routines each return the number of bytes required
98312 ** to store a copy of an expression or expression tree. They differ in
98313 ** how much of the tree is measured.
98314 **
@@ -98544,14 +98779,17 @@
98544 ** gatherSelectWindowsCallback() are used to scan all the expressions
98545 ** an a newly duplicated SELECT statement and gather all of the Window
98546 ** objects found there, assembling them onto the linked list at Select->pWin.
98547 */
98548 static int gatherSelectWindowsCallback(Walker *pWalker, Expr *pExpr){
98549 if( pExpr->op==TK_FUNCTION && pExpr->y.pWin!=0 ){
98550 assert( ExprHasProperty(pExpr, EP_WinFunc) );
98551 pExpr->y.pWin->pNextWin = pWalker->u.pSelect->pWin;
98552 pWalker->u.pSelect->pWin = pExpr->y.pWin;
 
 
 
98553 }
98554 return WRC_Continue;
98555 }
98556 static int gatherSelectWindowsSelectCallback(Walker *pWalker, Select *p){
98557 return p==pWalker->u.pSelect ? WRC_Continue : WRC_Prune;
@@ -98621,12 +98859,13 @@
98621 pNewExpr->pLeft = pPriorSelectCol;
98622 }
98623 }
98624 pItem->zName = sqlite3DbStrDup(db, pOldItem->zName);
98625 pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan);
98626 pItem->sortOrder = pOldItem->sortOrder;
98627 pItem->done = 0;
 
98628 pItem->bSpanIsTab = pOldItem->bSpanIsTab;
98629 pItem->bSorterRef = pOldItem->bSorterRef;
98630 pItem->u = pOldItem->u;
98631 }
98632 return pNew;
@@ -98733,11 +98972,11 @@
98733 pNew->nSelectRow = p->nSelectRow;
98734 pNew->pWith = withDup(db, p->pWith);
98735 #ifndef SQLITE_OMIT_WINDOWFUNC
98736 pNew->pWin = 0;
98737 pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
98738 if( p->pWin ) gatherSelectWindows(pNew);
98739 #endif
98740 pNew->selId = p->selId;
98741 *pp = pNew;
98742 pp = &pNew->pPrior;
98743 pNext = pNew;
@@ -98842,10 +99081,14 @@
98842 goto vector_append_error;
98843 }
98844
98845 for(i=0; i<pColumns->nId; i++){
98846 Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);
 
 
 
 
98847 pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);
98848 if( pList ){
98849 assert( pList->nExpr==iFirst+i+1 );
98850 pList->a[pList->nExpr-1].zName = pColumns->a[i].zName;
98851 pColumns->a[i].zName = 0;
@@ -98874,19 +99117,38 @@
98874 }
98875
98876 /*
98877 ** Set the sort order for the last element on the given ExprList.
98878 */
98879 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder){
 
98880 if( p==0 ) return;
98881 assert( SQLITE_SO_UNDEFINED<0 && SQLITE_SO_ASC>=0 && SQLITE_SO_DESC>0 );
98882 assert( p->nExpr>0 );
98883 if( iSortOrder<0 ){
98884 assert( p->a[p->nExpr-1].sortOrder==SQLITE_SO_ASC );
98885 return;
 
 
 
 
 
 
 
 
 
 
 
 
98886 }
98887 p->a[p->nExpr-1].sortOrder = (u8)iSortOrder;
 
 
 
 
 
 
 
98888 }
98889
98890 /*
98891 ** Set the ExprList.a[].zName element of the most recently added item
98892 ** on the expression list.
@@ -99381,31 +99643,34 @@
99381 ** is harmless. A false positive, however, can result in the wrong
99382 ** answer.
99383 */
99384 SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr *p, char aff){
99385 u8 op;
 
99386 if( aff==SQLITE_AFF_BLOB ) return 1;
99387 while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }
 
 
 
99388 op = p->op;
99389 if( op==TK_REGISTER ) op = p->op2;
99390 switch( op ){
99391 case TK_INTEGER: {
99392 return aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC;
99393 }
99394 case TK_FLOAT: {
99395 return aff==SQLITE_AFF_REAL || aff==SQLITE_AFF_NUMERIC;
99396 }
99397 case TK_STRING: {
99398 return aff==SQLITE_AFF_TEXT;
99399 }
99400 case TK_BLOB: {
99401 return 1;
99402 }
99403 case TK_COLUMN: {
99404 assert( p->iTable>=0 ); /* p cannot be part of a CHECK constraint */
99405 return p->iColumn<0
99406 && (aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC);
99407 }
99408 default: {
99409 return 0;
99410 }
99411 }
@@ -99584,11 +99849,11 @@
99584 ** then aiMap[] is populated with {2, 0, 1}.
99585 */
99586 #ifndef SQLITE_OMIT_SUBQUERY
99587 SQLITE_PRIVATE int sqlite3FindInIndex(
99588 Parse *pParse, /* Parsing context */
99589 Expr *pX, /* The right-hand side (RHS) of the IN operator */
99590 u32 inFlags, /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */
99591 int *prRhsHasNull, /* Register holding NULL status. See notes */
99592 int *aiMap, /* Mapping from Index fields to RHS fields */
99593 int *piTab /* OUT: index to use */
99594 ){
@@ -100009,13 +100274,13 @@
100009 */
100010 char affinity; /* Affinity of the LHS of the IN */
100011 int i;
100012 ExprList *pList = pExpr->x.pList;
100013 struct ExprList_item *pItem;
100014 int r1, r2, r3;
100015 affinity = sqlite3ExprAffinity(pLeft);
100016 if( !affinity ){
100017 affinity = SQLITE_AFF_BLOB;
100018 }
100019 if( pKeyInfo ){
100020 assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
100021 pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
@@ -100037,13 +100302,13 @@
100037 ExprClearProperty(pExpr, EP_Subrtn);
100038 addrOnce = 0;
100039 }
100040
100041 /* Evaluate the expression and insert it into the temp table */
100042 r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);
100043 sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);
100044 sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r3, 1);
100045 }
100046 sqlite3ReleaseTempReg(pParse, r1);
100047 sqlite3ReleaseTempReg(pParse, r2);
100048 }
100049 if( pKeyInfo ){
@@ -100065,11 +100330,11 @@
100065 ** (SELECT a FROM b) -- subquery
100066 ** EXISTS (SELECT a FROM b) -- EXISTS subquery
100067 **
100068 ** The pExpr parameter is the SELECT or EXISTS operator to be coded.
100069 **
100070 ** The register that holds the result. For a multi-column SELECT,
100071 ** the result is stored in a contiguous array of registers and the
100072 ** return value is the register of the left-most result column.
100073 ** Return 0 if an error occurs.
100074 */
100075 #ifndef SQLITE_OMIT_SUBQUERY
@@ -100309,17 +100574,25 @@
100309 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
100310 int labelOk = sqlite3VdbeMakeLabel(pParse);
100311 int r2, regToFree;
100312 int regCkNull = 0;
100313 int ii;
 
100314 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
100315 if( destIfNull!=destIfFalse ){
100316 regCkNull = sqlite3GetTempReg(pParse);
100317 sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull);
100318 }
 
100319 for(ii=0; ii<pList->nExpr; ii++){
100320 r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);
 
 
 
 
 
 
100321 if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
100322 sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);
100323 }
100324 if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){
100325 sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2,
@@ -100600,11 +100873,11 @@
100600 ** Convert a scalar expression node to a TK_REGISTER referencing
100601 ** register iReg. The caller must ensure that iReg already contains
100602 ** the correct value for the expression.
100603 */
100604 static void exprToRegister(Expr *pExpr, int iReg){
100605 Expr *p = sqlite3ExprSkipCollate(pExpr);
100606 p->op2 = p->op;
100607 p->op = TK_REGISTER;
100608 p->iTable = iReg;
100609 ExprClearProperty(p, EP_Skip);
100610 }
@@ -100701,11 +100974,11 @@
100701 ** datatype by applying the Affinity of the table column to the
100702 ** constant.
100703 */
100704 int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
100705 int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
100706 if( aff!=SQLITE_AFF_BLOB ){
100707 static const char zAff[] = "B\000C\000D\000E";
100708 assert( SQLITE_AFF_BLOB=='A' );
100709 assert( SQLITE_AFF_TEXT=='B' );
100710 if( iReg!=target ){
100711 sqlite3VdbeAddOp2(v, OP_SCopy, iReg, target);
@@ -100717,11 +100990,23 @@
100717 return iReg;
100718 }
100719 if( iTab<0 ){
100720 if( pParse->iSelfTab<0 ){
100721 /* Generating CHECK constraints or inserting into partial index */
100722 return pExpr->iColumn - pParse->iSelfTab;
 
 
 
 
 
 
 
 
 
 
 
 
100723 }else{
100724 /* Coding an expression that is part of an index where column names
100725 ** in the index refer to the table to which the index belongs */
100726 iTab = pParse->iSelfTab - 1;
100727 }
@@ -101004,11 +101289,11 @@
101004 const char *azAff[] = { "blob", "text", "numeric", "integer", "real" };
101005 char aff;
101006 assert( nFarg==1 );
101007 aff = sqlite3ExprAffinity(pFarg->a[0].pExpr);
101008 sqlite3VdbeLoadString(v, target,
101009 aff ? azAff[aff-SQLITE_AFF_BLOB] : "none");
101010 return target;
101011 }
101012 #endif
101013
101014 for(i=0; i<nFarg; i++){
@@ -101112,12 +101397,12 @@
101112 int n;
101113 if( pExpr->pLeft->iTable==0 ){
101114 pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
101115 }
101116 assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );
101117 if( pExpr->iTable
101118 && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
101119 ){
101120 sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
101121 pExpr->iTable, n);
101122 }
101123 return pExpr->pLeft->iTable + pExpr->iColumn;
@@ -101216,14 +101501,27 @@
101216 case TK_VECTOR: {
101217 sqlite3ErrorMsg(pParse, "row value misused");
101218 break;
101219 }
101220
 
 
 
 
 
 
101221 case TK_IF_NULL_ROW: {
101222 int addrINR;
 
101223 addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable);
 
 
 
 
 
101224 inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
 
101225 sqlite3VdbeJumpHere(v, addrINR);
101226 sqlite3VdbeChangeP3(v, addrINR, inReg);
101227 break;
101228 }
101229
@@ -101256,25 +101554,31 @@
101256 ExprList *pEList; /* List of WHEN terms */
101257 struct ExprList_item *aListelem; /* Array of WHEN terms */
101258 Expr opCompare; /* The X==Ei expression */
101259 Expr *pX; /* The X expression */
101260 Expr *pTest = 0; /* X==Ei (form A) or just Ei (form B) */
 
 
101261
101262 assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
101263 assert(pExpr->x.pList->nExpr > 0);
101264 pEList = pExpr->x.pList;
101265 aListelem = pEList->a;
101266 nExpr = pEList->nExpr;
101267 endLabel = sqlite3VdbeMakeLabel(pParse);
101268 if( (pX = pExpr->pLeft)!=0 ){
101269 exprNodeCopy(&tempX, pX);
 
 
 
 
101270 testcase( pX->op==TK_COLUMN );
101271 exprToRegister(&tempX, exprCodeVector(pParse, &tempX, &regFree1));
101272 testcase( regFree1==0 );
101273 memset(&opCompare, 0, sizeof(opCompare));
101274 opCompare.op = TK_EQ;
101275 opCompare.pLeft = &tempX;
101276 pTest = &opCompare;
101277 /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
101278 ** The value in regFree1 might get SCopy-ed into the file result.
101279 ** So make sure that the regFree1 register is not reused for other
101280 ** purposes and possibly overwritten. */
@@ -101298,36 +101602,37 @@
101298 if( (nExpr&1)!=0 ){
101299 sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);
101300 }else{
101301 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
101302 }
 
101303 sqlite3VdbeResolveLabel(v, endLabel);
101304 break;
101305 }
101306 #ifndef SQLITE_OMIT_TRIGGER
101307 case TK_RAISE: {
101308 assert( pExpr->affinity==OE_Rollback
101309 || pExpr->affinity==OE_Abort
101310 || pExpr->affinity==OE_Fail
101311 || pExpr->affinity==OE_Ignore
101312 );
101313 if( !pParse->pTriggerTab ){
101314 sqlite3ErrorMsg(pParse,
101315 "RAISE() may only be used within a trigger-program");
101316 return 0;
101317 }
101318 if( pExpr->affinity==OE_Abort ){
101319 sqlite3MayAbort(pParse);
101320 }
101321 assert( !ExprHasProperty(pExpr, EP_IntValue) );
101322 if( pExpr->affinity==OE_Ignore ){
101323 sqlite3VdbeAddOp4(
101324 v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);
101325 VdbeCoverage(v);
101326 }else{
101327 sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER,
101328 pExpr->affinity, pExpr->u.zToken, 0, 0);
101329 }
101330
101331 break;
101332 }
101333 #endif
@@ -101388,11 +101693,11 @@
101388 ** code to fill the register in the initialization section of the
101389 ** VDBE program, in order to factor it out of the evaluation loop.
101390 */
101391 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){
101392 int r2;
101393 pExpr = sqlite3ExprSkipCollate(pExpr);
101394 if( ConstFactorOk(pParse)
101395 && pExpr->op!=TK_REGISTER
101396 && sqlite3ExprIsConstantNotJoin(pExpr)
101397 ){
101398 *pReg = 0;
@@ -101579,44 +101884,48 @@
101579 Expr *pExpr, /* The BETWEEN expression */
101580 int dest, /* Jump destination or storage location */
101581 void (*xJump)(Parse*,Expr*,int,int), /* Action to take */
101582 int jumpIfNull /* Take the jump if the BETWEEN is NULL */
101583 ){
101584 Expr exprAnd; /* The AND operator in x>=y AND x<=z */
101585 Expr compLeft; /* The x>=y term */
101586 Expr compRight; /* The x<=z term */
101587 Expr exprX; /* The x subexpression */
101588 int regFree1 = 0; /* Temporary use register */
 
 
101589
101590 memset(&compLeft, 0, sizeof(Expr));
101591 memset(&compRight, 0, sizeof(Expr));
101592 memset(&exprAnd, 0, sizeof(Expr));
101593
101594 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
101595 exprNodeCopy(&exprX, pExpr->pLeft);
101596 exprAnd.op = TK_AND;
101597 exprAnd.pLeft = &compLeft;
101598 exprAnd.pRight = &compRight;
101599 compLeft.op = TK_GE;
101600 compLeft.pLeft = &exprX;
101601 compLeft.pRight = pExpr->x.pList->a[0].pExpr;
101602 compRight.op = TK_LE;
101603 compRight.pLeft = &exprX;
101604 compRight.pRight = pExpr->x.pList->a[1].pExpr;
101605 exprToRegister(&exprX, exprCodeVector(pParse, &exprX, &regFree1));
101606 if( xJump ){
101607 xJump(pParse, &exprAnd, dest, jumpIfNull);
101608 }else{
101609 /* Mark the expression is being from the ON or USING clause of a join
101610 ** so that the sqlite3ExprCodeTarget() routine will not attempt to move
101611 ** it into the Parse.pConstExpr list. We should use a new bit for this,
101612 ** for clarity, but we are out of bits in the Expr.flags field so we
101613 ** have to reuse the EP_FromJoin bit. Bummer. */
101614 exprX.flags |= EP_FromJoin;
101615 sqlite3ExprCodeTarget(pParse, &exprAnd, dest);
101616 }
101617 sqlite3ReleaseTempReg(pParse, regFree1);
 
 
 
101618
101619 /* Ensure adequate test coverage */
101620 testcase( xJump==sqlite3ExprIfTrue && jumpIfNull==0 && regFree1==0 );
101621 testcase( xJump==sqlite3ExprIfTrue && jumpIfNull==0 && regFree1!=0 );
101622 testcase( xJump==sqlite3ExprIfTrue && jumpIfNull!=0 && regFree1==0 );
@@ -102051,24 +102360,21 @@
102051 return 1;
102052 }
102053 return 2;
102054 }
102055 if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
102056 if( pA->op==TK_FUNCTION ){
102057 if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
102058 #ifndef SQLITE_OMIT_WINDOWFUNC
102059 /* Justification for the assert():
102060 ** window functions have p->op==TK_FUNCTION but aggregate functions
102061 ** have p->op==TK_AGG_FUNCTION. So any comparison between an aggregate
102062 ** function and a window function should have failed before reaching
102063 ** this point. And, it is not possible to have a window function and
102064 ** a scalar function with the same name and number of arguments. So
102065 ** if we reach this point, either A and B both window functions or
102066 ** neither are a window functions. */
102067 assert( ExprHasProperty(pA,EP_WinFunc)==ExprHasProperty(pB,EP_WinFunc) );
102068 if( ExprHasProperty(pA,EP_WinFunc) ){
102069 if( sqlite3WindowCompare(pParse,pA->y.pWin,pB->y.pWin)!=0 ) return 2;
 
 
102070 }
102071 #endif
102072 }else if( pA->op==TK_NULL ){
102073 return 0;
102074 }else if( pA->op==TK_COLLATE ){
@@ -102118,11 +102424,11 @@
102118 if( pA==0 || pB==0 ) return 1;
102119 if( pA->nExpr!=pB->nExpr ) return 1;
102120 for(i=0; i<pA->nExpr; i++){
102121 Expr *pExprA = pA->a[i].pExpr;
102122 Expr *pExprB = pB->a[i].pExpr;
102123 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
102124 if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1;
102125 }
102126 return 0;
102127 }
102128
@@ -102130,78 +102436,85 @@
102130 ** Like sqlite3ExprCompare() except COLLATE operators at the top-level
102131 ** are ignored.
102132 */
102133 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
102134 return sqlite3ExprCompare(0,
102135 sqlite3ExprSkipCollate(pA),
102136 sqlite3ExprSkipCollate(pB),
102137 iTab);
102138 }
102139
102140 /*
102141 ** Return non-zero if Expr p can only be true if pNN is not NULL.
 
 
 
102142 */
102143 static int exprImpliesNotNull(
102144 Parse *pParse, /* Parsing context */
102145 Expr *p, /* The expression to be checked */
102146 Expr *pNN, /* The expression that is NOT NULL */
102147 int iTab, /* Table being evaluated */
102148 int seenNot /* True if p is an operand of NOT */
102149 ){
102150 assert( p );
102151 assert( pNN );
102152 if( sqlite3ExprCompare(pParse, p, pNN, iTab)==0 ) return 1;
 
 
102153 switch( p->op ){
102154 case TK_IN: {
102155 if( seenNot && ExprHasProperty(p, EP_xIsSelect) ) return 0;
102156 assert( ExprHasProperty(p,EP_xIsSelect)
102157 || (p->x.pList!=0 && p->x.pList->nExpr>0) );
102158 return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
102159 }
102160 case TK_BETWEEN: {
102161 ExprList *pList = p->x.pList;
102162 assert( pList!=0 );
102163 assert( pList->nExpr==2 );
102164 if( seenNot ) return 0;
102165 if( exprImpliesNotNull(pParse, pList->a[0].pExpr, pNN, iTab, seenNot)
102166 || exprImpliesNotNull(pParse, pList->a[1].pExpr, pNN, iTab, seenNot)
102167 ){
102168 return 1;
102169 }
102170 return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
102171 }
102172 case TK_EQ:
102173 case TK_NE:
102174 case TK_LT:
102175 case TK_LE:
102176 case TK_GT:
102177 case TK_GE:
102178 case TK_PLUS:
102179 case TK_MINUS:
 
 
 
 
 
 
102180 case TK_STAR:
102181 case TK_REM:
102182 case TK_BITAND:
102183 case TK_BITOR:
102184 case TK_SLASH:
102185 case TK_LSHIFT:
102186 case TK_RSHIFT:
102187 case TK_CONCAT: {
102188 if( exprImpliesNotNull(pParse, p->pRight, pNN, iTab, seenNot) ) return 1;
102189 /* Fall thru into the next case */
102190 }
102191 case TK_SPAN:
102192 case TK_COLLATE:
102193 case TK_BITNOT:
102194 case TK_UPLUS:
102195 case TK_UMINUS: {
102196 return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
102197 }
102198 case TK_TRUTH: {
102199 if( seenNot ) return 0;
102200 if( p->op2!=TK_IS ) return 0;
102201 return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
102202 }
 
102203 case TK_NOT: {
102204 return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
102205 }
102206 }
102207 return 0;
@@ -102263,20 +102576,18 @@
102263 testcase( pExpr->op==TK_AGG_COLUMN );
102264 testcase( pExpr->op==TK_AGG_FUNCTION );
102265 if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;
102266 switch( pExpr->op ){
102267 case TK_ISNOT:
102268 case TK_NOT:
102269 case TK_ISNULL:
102270 case TK_NOTNULL:
102271 case TK_IS:
102272 case TK_OR:
102273 case TK_CASE:
102274 case TK_IN:
102275 case TK_FUNCTION:
102276 testcase( pExpr->op==TK_ISNOT );
102277 testcase( pExpr->op==TK_NOT );
102278 testcase( pExpr->op==TK_ISNULL );
102279 testcase( pExpr->op==TK_NOTNULL );
102280 testcase( pExpr->op==TK_IS );
102281 testcase( pExpr->op==TK_OR );
102282 testcase( pExpr->op==TK_CASE );
@@ -102288,10 +102599,22 @@
102288 pWalker->eCode = 1;
102289 return WRC_Abort;
102290 }
102291 return WRC_Prune;
102292
 
 
 
 
 
 
 
 
 
 
 
 
102293 /* Virtual tables are allowed to use constraints like x=NULL. So
102294 ** a term of the form x=y does not prove that y is not null if x
102295 ** is the column of a virtual table */
102296 case TK_EQ:
102297 case TK_NE:
@@ -102308,10 +102631,11 @@
102308 if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->y.pTab))
102309 || (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->y.pTab))
102310 ){
102311 return WRC_Prune;
102312 }
 
102313 default:
102314 return WRC_Continue;
102315 }
102316 }
102317
@@ -102337,11 +102661,11 @@
102337 ** be non-NULL, then the LEFT JOIN can be safely converted into an
102338 ** ordinary join.
102339 */
102340 SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){
102341 Walker w;
102342 p = sqlite3ExprSkipCollate(p);
102343 while( p ){
102344 if( p->op==TK_NOTNULL ){
102345 p = p->pLeft;
102346 }else if( p->op==TK_AND ){
102347 if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1;
@@ -102443,11 +102767,14 @@
102443 for(i=0; i<nSrc; i++){
102444 if( pExpr->iTable==pSrc->a[i].iCursor ) break;
102445 }
102446 if( i<nSrc ){
102447 p->nThis++;
102448 }else{
 
 
 
102449 p->nOther++;
102450 }
102451 }
102452 return WRC_Continue;
102453 }
@@ -102460,12 +102787,13 @@
102460 */
102461 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){
102462 Walker w;
102463 struct SrcCount cnt;
102464 assert( pExpr->op==TK_AGG_FUNCTION );
 
102465 w.xExprCallback = exprSrcCount;
102466 w.xSelectCallback = 0;
102467 w.u.pSrcCount = &cnt;
102468 cnt.pSrc = pSrcList;
102469 cnt.nThis = 0;
102470 cnt.nOther = 0;
102471 sqlite3WalkExprList(&w, pExpr->x.pList);
@@ -102899,12 +103227,12 @@
102899 ** that the table is being renamed to.
102900 */
102901 if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){
102902 goto exit_rename_table;
102903 }
102904 if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto
102905 exit_rename_table;
102906 }
102907
102908 #ifndef SQLITE_OMIT_VIEW
102909 if( pTab->pSelect ){
102910 sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName);
@@ -104461,17 +104789,17 @@
104461 ** Additional tables might be added in future releases of SQLite.
104462 ** The sqlite_stat2 table is not created or used unless the SQLite version
104463 ** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled
104464 ** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated.
104465 ** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
104466 ** created and used by SQLite versions 3.7.9 and later and with
104467 ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
104468 ** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
104469 ** version of sqlite_stat3 and is only available when compiled with
104470 ** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later. It is
104471 ** not possible to enable both STAT3 and STAT4 at the same time. If they
104472 ** are both enabled, then STAT4 takes precedence.
104473 **
104474 ** For most applications, sqlite_stat1 provides all the statistics required
104475 ** for the query planner to make good choices.
104476 **
104477 ** Format of sqlite_stat1:
@@ -104578,21 +104906,15 @@
104578 #ifndef SQLITE_OMIT_ANALYZE
104579 /* #include "sqliteInt.h" */
104580
104581 #if defined(SQLITE_ENABLE_STAT4)
104582 # define IsStat4 1
104583 # define IsStat3 0
104584 #elif defined(SQLITE_ENABLE_STAT3)
104585 # define IsStat4 0
104586 # define IsStat3 1
104587 #else
104588 # define IsStat4 0
104589 # define IsStat3 0
104590 # undef SQLITE_STAT4_SAMPLES
104591 # define SQLITE_STAT4_SAMPLES 1
104592 #endif
104593 #define IsStat34 (IsStat3+IsStat4) /* 1 for STAT3 or STAT4. 0 otherwise */
104594
104595 /*
104596 ** This routine generates code that opens the sqlite_statN tables.
104597 ** The sqlite_stat1 table is always relevant. sqlite_stat2 is now
104598 ** obsolete. sqlite_stat3 and sqlite_stat4 are only opened when
@@ -104617,18 +104939,14 @@
104617 const char *zCols;
104618 } aTable[] = {
104619 { "sqlite_stat1", "tbl,idx,stat" },
104620 #if defined(SQLITE_ENABLE_STAT4)
104621 { "sqlite_stat4", "tbl,idx,neq,nlt,ndlt,sample" },
104622 { "sqlite_stat3", 0 },
104623 #elif defined(SQLITE_ENABLE_STAT3)
104624 { "sqlite_stat3", "tbl,idx,neq,nlt,ndlt,sample" },
104625 { "sqlite_stat4", 0 },
104626 #else
104627 { "sqlite_stat3", 0 },
104628 { "sqlite_stat4", 0 },
104629 #endif
 
104630 };
104631 int i;
104632 sqlite3 *db = pParse->db;
104633 Db *pDb;
104634 Vdbe *v = sqlite3GetVdbe(pParse);
@@ -104705,11 +105023,11 @@
104705 typedef struct Stat4Accum Stat4Accum;
104706 typedef struct Stat4Sample Stat4Sample;
104707 struct Stat4Sample {
104708 tRowcnt *anEq; /* sqlite_stat4.nEq */
104709 tRowcnt *anDLt; /* sqlite_stat4.nDLt */
104710 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
104711 tRowcnt *anLt; /* sqlite_stat4.nLt */
104712 union {
104713 i64 iRowid; /* Rowid in main table of the key */
104714 u8 *aRowid; /* Key for WITHOUT ROWID tables */
104715 } u;
@@ -104736,11 +105054,11 @@
104736 sqlite3 *db; /* Database connection, for malloc() */
104737 };
104738
104739 /* Reclaim memory used by a Stat4Sample
104740 */
104741 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
104742 static void sampleClear(sqlite3 *db, Stat4Sample *p){
104743 assert( db!=0 );
104744 if( p->nRowid ){
104745 sqlite3DbFree(db, p->u.aRowid);
104746 p->nRowid = 0;
@@ -104748,11 +105066,11 @@
104748 }
104749 #endif
104750
104751 /* Initialize the BLOB value of a ROWID
104752 */
104753 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
104754 static void sampleSetRowid(sqlite3 *db, Stat4Sample *p, int n, const u8 *pData){
104755 assert( db!=0 );
104756 if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);
104757 p->u.aRowid = sqlite3DbMallocRawNN(db, n);
104758 if( p->u.aRowid ){
@@ -104764,11 +105082,11 @@
104764 }
104765 #endif
104766
104767 /* Initialize the INTEGER value of a ROWID.
104768 */
104769 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
104770 static void sampleSetRowidInt64(sqlite3 *db, Stat4Sample *p, i64 iRowid){
104771 assert( db!=0 );
104772 if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);
104773 p->nRowid = 0;
104774 p->u.iRowid = iRowid;
@@ -104777,11 +105095,11 @@
104777
104778
104779 /*
104780 ** Copy the contents of object (*pFrom) into (*pTo).
104781 */
104782 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
104783 static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
104784 pTo->isPSample = pFrom->isPSample;
104785 pTo->iCol = pFrom->iCol;
104786 pTo->iHash = pFrom->iHash;
104787 memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);
@@ -104798,11 +105116,11 @@
104798 /*
104799 ** Reclaim all memory of a Stat4Accum structure.
104800 */
104801 static void stat4Destructor(void *pOld){
104802 Stat4Accum *p = (Stat4Accum*)pOld;
104803 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
104804 int i;
104805 for(i=0; i<p->nCol; i++) sampleClear(p->db, p->aBest+i);
104806 for(i=0; i<p->mxSample; i++) sampleClear(p->db, p->a+i);
104807 sampleClear(p->db, &p->current);
104808 #endif
@@ -104818,11 +105136,11 @@
104818 **
104819 ** Note 1: In the special case of the covering index that implements a
104820 ** WITHOUT ROWID table, N is the number of PRIMARY KEY columns, not the
104821 ** total number of columns in the table.
104822 **
104823 ** Note 2: C is only used for STAT3 and STAT4.
104824 **
104825 ** For indexes on ordinary rowid tables, N==K+1. But for indexes on
104826 ** WITHOUT ROWID tables, N=K+P where P is the number of columns in the
104827 ** PRIMARY KEY of the table. The covering index that implements the
104828 ** original WITHOUT ROWID table as N==K as a special case.
@@ -104841,11 +105159,11 @@
104841 int nCol; /* Number of columns in index being sampled */
104842 int nKeyCol; /* Number of key columns */
104843 int nColUp; /* nCol rounded up for alignment */
104844 int n; /* Bytes of space to allocate */
104845 sqlite3 *db; /* Database connection */
104846 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
104847 int mxSample = SQLITE_STAT4_SAMPLES;
104848 #endif
104849
104850 /* Decode the three function arguments */
104851 UNUSED_PARAMETER(argc);
@@ -104858,11 +105176,11 @@
104858
104859 /* Allocate the space required for the Stat4Accum object */
104860 n = sizeof(*p)
104861 + sizeof(tRowcnt)*nColUp /* Stat4Accum.anEq */
104862 + sizeof(tRowcnt)*nColUp /* Stat4Accum.anDLt */
104863 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
104864 + sizeof(tRowcnt)*nColUp /* Stat4Accum.anLt */
104865 + sizeof(Stat4Sample)*(nCol+mxSample) /* Stat4Accum.aBest[], a[] */
104866 + sizeof(tRowcnt)*3*nColUp*(nCol+mxSample)
104867 #endif
104868 ;
@@ -104878,11 +105196,11 @@
104878 p->nCol = nCol;
104879 p->nKeyCol = nKeyCol;
104880 p->current.anDLt = (tRowcnt*)&p[1];
104881 p->current.anEq = &p->current.anDLt[nColUp];
104882
104883 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
104884 {
104885 u8 *pSpace; /* Allocated space not yet assigned */
104886 int i; /* Used to iterate through p->aSample[] */
104887
104888 p->iGet = -1;
@@ -104913,11 +105231,11 @@
104913 ** (given by the 3rd parameter) is never used and can be any positive
104914 ** value. */
104915 sqlite3_result_blob(context, p, sizeof(*p), stat4Destructor);
104916 }
104917 static const FuncDef statInitFuncdef = {
104918 2+IsStat34, /* nArg */
104919 SQLITE_UTF8, /* funcFlags */
104920 0, /* pUserData */
104921 0, /* pNext */
104922 statInit, /* xSFunc */
104923 0, /* xFinalize */
@@ -104953,11 +105271,11 @@
104953 if( pNew->iHash>pOld->iHash ) return 1;
104954 return 0;
104955 }
104956 #endif
104957
104958 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
104959 /*
104960 ** Return true if pNew is to be preferred over pOld.
104961 **
104962 ** This function assumes that for each argument sample, the contents of
104963 ** the anEq[] array from pSample->anEq[pSample->iCol] onwards are valid.
@@ -104972,19 +105290,15 @@
104972
104973 assert( pOld->isPSample==0 && pNew->isPSample==0 );
104974 assert( IsStat4 || (pNew->iCol==0 && pOld->iCol==0) );
104975
104976 if( (nEqNew>nEqOld) ) return 1;
104977 #ifdef SQLITE_ENABLE_STAT4
104978 if( nEqNew==nEqOld ){
104979 if( pNew->iCol<pOld->iCol ) return 1;
104980 return (pNew->iCol==pOld->iCol && sampleIsBetterPost(pAccum, pNew, pOld));
104981 }
104982 return 0;
104983 #else
104984 return (nEqNew==nEqOld && pNew->iHash>pOld->iHash);
104985 #endif
104986 }
104987
104988 /*
104989 ** Copy the contents of sample *pNew into the p->a[] array. If necessary,
104990 ** remove the least desirable sample from p->a[] to make room.
@@ -104993,11 +105307,10 @@
104993 Stat4Sample *pSample = 0;
104994 int i;
104995
104996 assert( IsStat4 || nEqZero==0 );
104997
104998 #ifdef SQLITE_ENABLE_STAT4
104999 /* Stat4Accum.nMaxEqZero is set to the maximum number of leading 0
105000 ** values in the anEq[] array of any sample in Stat4Accum.a[]. In
105001 ** other words, if nMaxEqZero is n, then it is guaranteed that there
105002 ** are no samples with Stat4Sample.anEq[m]==0 for (m>=n). */
105003 if( nEqZero>p->nMaxEqZero ){
@@ -105027,11 +105340,10 @@
105027 pUpgrade->iCol = pNew->iCol;
105028 pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol];
105029 goto find_new_min;
105030 }
105031 }
105032 #endif
105033
105034 /* If necessary, remove sample iMin to make room for the new sample. */
105035 if( p->nSample>=p->mxSample ){
105036 Stat4Sample *pMin = &p->a[p->iMin];
105037 tRowcnt *anEq = pMin->anEq;
@@ -105048,26 +105360,22 @@
105048 }
105049
105050 /* The "rows less-than" for the rowid column must be greater than that
105051 ** for the last sample in the p->a[] array. Otherwise, the samples would
105052 ** be out of order. */
105053 #ifdef SQLITE_ENABLE_STAT4
105054 assert( p->nSample==0
105055 || pNew->anLt[p->nCol-1] > p->a[p->nSample-1].anLt[p->nCol-1] );
105056 #endif
105057
105058 /* Insert the new sample */
105059 pSample = &p->a[p->nSample];
105060 sampleCopy(p, pSample, pNew);
105061 p->nSample++;
105062
105063 /* Zero the first nEqZero entries in the anEq[] array. */
105064 memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero);
105065
105066 #ifdef SQLITE_ENABLE_STAT4
105067 find_new_min:
105068 #endif
105069 if( p->nSample>=p->mxSample ){
105070 int iMin = -1;
105071 for(i=0; i<p->mxSample; i++){
105072 if( p->a[i].isPSample ) continue;
105073 if( iMin<0 || sampleIsBetter(p, &p->a[iMin], &p->a[i]) ){
@@ -105076,11 +105384,11 @@
105076 }
105077 assert( iMin>=0 );
105078 p->iMin = iMin;
105079 }
105080 }
105081 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
105082
105083 /*
105084 ** Field iChng of the index being scanned has changed. So at this point
105085 ** p->current contains a sample that reflects the previous row of the
105086 ** index. The value of anEq[iChng] and subsequent anEq[] elements are
@@ -105117,32 +105425,11 @@
105117 }
105118 p->nMaxEqZero = iChng;
105119 }
105120 #endif
105121
105122 #if defined(SQLITE_ENABLE_STAT3) && !defined(SQLITE_ENABLE_STAT4)
105123 if( iChng==0 ){
105124 tRowcnt nLt = p->current.anLt[0];
105125 tRowcnt nEq = p->current.anEq[0];
105126
105127 /* Check if this is to be a periodic sample. If so, add it. */
105128 if( (nLt/p->nPSample)!=(nLt+nEq)/p->nPSample ){
105129 p->current.isPSample = 1;
105130 sampleInsert(p, &p->current, 0);
105131 p->current.isPSample = 0;
105132 }else
105133
105134 /* Or if it is a non-periodic sample. Add it in this case too. */
105135 if( p->nSample<p->mxSample
105136 || sampleIsBetter(p, &p->current, &p->a[p->iMin])
105137 ){
105138 sampleInsert(p, &p->current, 0);
105139 }
105140 }
105141 #endif
105142
105143 #ifndef SQLITE_ENABLE_STAT3_OR_STAT4
105144 UNUSED_PARAMETER( p );
105145 UNUSED_PARAMETER( iChng );
105146 #endif
105147 }
105148
@@ -105158,11 +105445,11 @@
105158 ** This SQL function always returns NULL. It's purpose it to accumulate
105159 ** statistical data and/or samples in the Stat4Accum object about the
105160 ** index being analyzed. The stat_get() SQL function will later be used to
105161 ** extract relevant information for constructing the sqlite_statN tables.
105162 **
105163 ** The R parameter is only used for STAT3 and STAT4
105164 */
105165 static void statPush(
105166 sqlite3_context *context,
105167 int argc,
105168 sqlite3_value **argv
@@ -105190,18 +105477,18 @@
105190 for(i=0; i<iChng; i++){
105191 p->current.anEq[i]++;
105192 }
105193 for(i=iChng; i<p->nCol; i++){
105194 p->current.anDLt[i]++;
105195 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105196 p->current.anLt[i] += p->current.anEq[i];
105197 #endif
105198 p->current.anEq[i] = 1;
105199 }
105200 }
105201 p->nRow++;
105202 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105203 if( sqlite3_value_type(argv[2])==SQLITE_INTEGER ){
105204 sampleSetRowidInt64(p->db, &p->current, sqlite3_value_int64(argv[2]));
105205 }else{
105206 sampleSetRowid(p->db, &p->current, sqlite3_value_bytes(argv[2]),
105207 sqlite3_value_blob(argv[2]));
@@ -105230,11 +105517,11 @@
105230 }
105231 }
105232 #endif
105233 }
105234 static const FuncDef statPushFuncdef = {
105235 2+IsStat34, /* nArg */
105236 SQLITE_UTF8, /* funcFlags */
105237 0, /* pUserData */
105238 0, /* pNext */
105239 statPush, /* xSFunc */
105240 0, /* xFinalize */
@@ -105261,11 +105548,11 @@
105261 ** inserted as part of a manually constructed bytecode program. (See
105262 ** the callStatGet() routine below.) It is guaranteed that the P
105263 ** parameter will always be a poiner to a Stat4Accum object, never a
105264 ** NULL.
105265 **
105266 ** If neither STAT3 nor STAT4 are enabled, then J is always
105267 ** STAT_GET_STAT1 and is hence omitted and this routine becomes
105268 ** a one-parameter function, stat_get(P), that always returns the
105269 ** stat1 table entry information.
105270 */
105271 static void statGet(
@@ -105272,12 +105559,12 @@
105272 sqlite3_context *context,
105273 int argc,
105274 sqlite3_value **argv
105275 ){
105276 Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);
105277 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105278 /* STAT3 and STAT4 have a parameter on this routine. */
105279 int eCall = sqlite3_value_int(argv[1]);
105280 assert( argc==2 );
105281 assert( eCall==STAT_GET_STAT1 || eCall==STAT_GET_NEQ
105282 || eCall==STAT_GET_ROWID || eCall==STAT_GET_NLT
105283 || eCall==STAT_GET_NDLT
@@ -105328,11 +105615,11 @@
105328 }
105329 assert( z[0]=='\0' && z>zRet );
105330
105331 sqlite3_result_text(context, zRet, -1, sqlite3_free);
105332 }
105333 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105334 else if( eCall==STAT_GET_ROWID ){
105335 if( p->iGet<0 ){
105336 samplePushPrevious(p, 0);
105337 p->iGet = 0;
105338 }
@@ -105357,13 +105644,11 @@
105357 p->iGet++;
105358 break;
105359 }
105360 }
105361
105362 if( IsStat3 ){
105363 sqlite3_result_int64(context, (i64)aCnt[0]);
105364 }else{
105365 char *zRet = sqlite3MallocZero(p->nCol * 25);
105366 if( zRet==0 ){
105367 sqlite3_result_error_nomem(context);
105368 }else{
105369 int i;
@@ -105376,17 +105661,17 @@
105376 z[-1] = '\0';
105377 sqlite3_result_text(context, zRet, -1, sqlite3_free);
105378 }
105379 }
105380 }
105381 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
105382 #ifndef SQLITE_DEBUG
105383 UNUSED_PARAMETER( argc );
105384 #endif
105385 }
105386 static const FuncDef statGetFuncdef = {
105387 1+IsStat34, /* nArg */
105388 SQLITE_UTF8, /* funcFlags */
105389 0, /* pUserData */
105390 0, /* pNext */
105391 statGet, /* xSFunc */
105392 0, /* xFinalize */
@@ -105395,20 +105680,20 @@
105395 {0}
105396 };
105397
105398 static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
105399 assert( regOut!=regStat4 && regOut!=regStat4+1 );
105400 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105401 sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
105402 #elif SQLITE_DEBUG
105403 assert( iParam==STAT_GET_STAT1 );
105404 #else
105405 UNUSED_PARAMETER( iParam );
105406 #endif
105407 sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4, regOut,
105408 (char*)&statGetFuncdef, P4_FUNCDEF);
105409 sqlite3VdbeChangeP5(v, 1 + IsStat34);
105410 }
105411
105412 /*
105413 ** Generate code to do an analysis of all indices associated with
105414 ** a single table.
@@ -105431,11 +105716,11 @@
105431 int iDb; /* Index of database containing pTab */
105432 u8 needTableCnt = 1; /* True to count the table */
105433 int regNewRowid = iMem++; /* Rowid for the inserted record */
105434 int regStat4 = iMem++; /* Register to hold Stat4Accum object */
105435 int regChng = iMem++; /* Index of changed index field */
105436 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105437 int regRowid = iMem++; /* Rowid argument passed to stat_push() */
105438 #endif
105439 int regTemp = iMem++; /* Temporary use register */
105440 int regTabname = iMem++; /* Register containing table name */
105441 int regIdxname = iMem++; /* Register containing index name */
@@ -105565,20 +105850,20 @@
105565 ** (or for a WITHOUT ROWID table, the number of PK columns),
105566 ** (2) the number of columns in the key without the rowid/pk
105567 ** (3) the number of rows in the index,
105568 **
105569 **
105570 ** The third argument is only used for STAT3 and STAT4
105571 */
105572 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105573 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+3);
105574 #endif
105575 sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1);
105576 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);
105577 sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4+1, regStat4,
105578 (char*)&statInitFuncdef, P4_FUNCDEF);
105579 sqlite3VdbeChangeP5(v, 2+IsStat34);
105580
105581 /* Implementation of the following:
105582 **
105583 ** Rewind csr
105584 ** if eof(csr) goto end_of_scan;
@@ -105645,16 +105930,16 @@
105645 sqlite3DbFree(db, aGotoChng);
105646 }
105647
105648 /*
105649 ** chng_addr_N:
105650 ** regRowid = idx(rowid) // STAT34 only
105651 ** stat_push(P, regChng, regRowid) // 3rd parameter STAT34 only
105652 ** Next csr
105653 ** if !eof(csr) goto next_row;
105654 */
105655 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105656 assert( regRowid==(regStat4+2) );
105657 if( HasRowid(pTab) ){
105658 sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, regRowid);
105659 }else{
105660 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
@@ -105671,11 +105956,11 @@
105671 }
105672 #endif
105673 assert( regChng==(regStat4+1) );
105674 sqlite3VdbeAddOp4(v, OP_Function0, 1, regStat4, regTemp,
105675 (char*)&statPushFuncdef, P4_FUNCDEF);
105676 sqlite3VdbeChangeP5(v, 2+IsStat34);
105677 sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, addrNextRow); VdbeCoverage(v);
105678
105679 /* Add the entry to the stat1 table. */
105680 callStatGet(v, regStat4, STAT_GET_STAT1, regStat1);
105681 assert( "BBB"[0]==SQLITE_AFF_TEXT );
@@ -105685,12 +105970,12 @@
105685 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
105686 sqlite3VdbeChangeP4(v, -1, (char*)pStat1, P4_TABLE);
105687 #endif
105688 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
105689
105690 /* Add the entries to the stat3 or stat4 table. */
105691 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105692 {
105693 int regEq = regStat1;
105694 int regLt = regStat1+1;
105695 int regDLt = regStat1+2;
105696 int regSample = regStat1+3;
@@ -105709,25 +105994,21 @@
105709 callStatGet(v, regStat4, STAT_GET_NEQ, regEq);
105710 callStatGet(v, regStat4, STAT_GET_NLT, regLt);
105711 callStatGet(v, regStat4, STAT_GET_NDLT, regDLt);
105712 sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);
105713 VdbeCoverage(v);
105714 #ifdef SQLITE_ENABLE_STAT3
105715 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, 0, regSample);
105716 #else
105717 for(i=0; i<nCol; i++){
105718 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
105719 }
105720 sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol, regSample);
105721 #endif
105722 sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp);
105723 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid);
105724 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regTemp, regNewRowid);
105725 sqlite3VdbeAddOp2(v, OP_Goto, 1, addrNext); /* P1==1 for end-of-loop */
105726 sqlite3VdbeJumpHere(v, addrIsNull);
105727 }
105728 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
105729
105730 /* End of analysis */
105731 sqlite3VdbeJumpHere(v, addrRewind);
105732 }
105733
@@ -105898,11 +106179,11 @@
105898 char *z = zIntArray;
105899 int c;
105900 int i;
105901 tRowcnt v;
105902
105903 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105904 if( z==0 ) z = "";
105905 #else
105906 assert( z!=0 );
105907 #endif
105908 for(i=0; *z && i<nOut; i++){
@@ -105909,11 +106190,11 @@
105909 v = 0;
105910 while( (c=z[0])>='0' && c<='9' ){
105911 v = v*10 + c - '0';
105912 z++;
105913 }
105914 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105915 if( aOut ) aOut[i] = v;
105916 if( aLog ) aLog[i] = sqlite3LogEst(v);
105917 #else
105918 assert( aOut==0 );
105919 UNUSED_PARAMETER(aOut);
@@ -105920,11 +106201,11 @@
105920 assert( aLog!=0 );
105921 aLog[i] = sqlite3LogEst(v);
105922 #endif
105923 if( *z==' ' ) z++;
105924 }
105925 #ifndef SQLITE_ENABLE_STAT3_OR_STAT4
105926 assert( pIndex!=0 ); {
105927 #else
105928 if( pIndex ){
105929 #endif
105930 pIndex->bUnordered = 0;
@@ -105931,11 +106212,13 @@
105931 pIndex->noSkipScan = 0;
105932 while( z[0] ){
105933 if( sqlite3_strglob("unordered*", z)==0 ){
105934 pIndex->bUnordered = 1;
105935 }else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){
105936 pIndex->szIdxRow = sqlite3LogEst(sqlite3Atoi(z+3));
 
 
105937 }else if( sqlite3_strglob("noskipscan*", z)==0 ){
105938 pIndex->noSkipScan = 1;
105939 }
105940 #ifdef SQLITE_ENABLE_COSTMULT
105941 else if( sqlite3_strglob("costmult=[0-9]*",z)==0 ){
@@ -105985,11 +106268,11 @@
105985 z = argv[2];
105986
105987 if( pIndex ){
105988 tRowcnt *aiRowEst = 0;
105989 int nCol = pIndex->nKeyCol+1;
105990 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
105991 /* Index.aiRowEst may already be set here if there are duplicate
105992 ** sqlite_stat1 entries for this index. In that case just clobber
105993 ** the old data with the new instead of allocating a new array. */
105994 if( pIndex->aiRowEst==0 ){
105995 pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(sizeof(tRowcnt) * nCol);
@@ -106021,11 +106304,11 @@
106021 /*
106022 ** If the Index.aSample variable is not NULL, delete the aSample[] array
106023 ** and its contents.
106024 */
106025 SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){
106026 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
106027 if( pIdx->aSample ){
106028 int j;
106029 for(j=0; j<pIdx->nSample; j++){
106030 IndexSample *p = &pIdx->aSample[j];
106031 sqlite3DbFree(db, p->p);
@@ -106037,14 +106320,14 @@
106037 pIdx->aSample = 0;
106038 }
106039 #else
106040 UNUSED_PARAMETER(db);
106041 UNUSED_PARAMETER(pIdx);
106042 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
106043 }
106044
106045 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
106046 /*
106047 ** Populate the pIdx->aAvgEq[] array based on the samples currently
106048 ** stored in pIdx->aSample[].
106049 */
106050 static void initAvgEq(Index *pIdx){
@@ -106118,25 +106401,23 @@
106118 }
106119 return pIdx;
106120 }
106121
106122 /*
106123 ** Load the content from either the sqlite_stat4 or sqlite_stat3 table
106124 ** into the relevant Index.aSample[] arrays.
106125 **
106126 ** Arguments zSql1 and zSql2 must point to SQL statements that return
106127 ** data equivalent to the following (statements are different for stat3,
106128 ** see the caller of this function for details):
106129 **
106130 ** zSql1: SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx
106131 ** zSql2: SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4
106132 **
106133 ** where %Q is replaced with the database name before the SQL is executed.
106134 */
106135 static int loadStatTbl(
106136 sqlite3 *db, /* Database handle */
106137 int bStat3, /* Assume single column records only */
106138 const char *zSql1, /* SQL statement 1 (see above) */
106139 const char *zSql2, /* SQL statement 2 (see above) */
106140 const char *zDb /* Database name (e.g. "main") */
106141 ){
106142 int rc; /* Result codes from subroutines */
@@ -106166,21 +106447,17 @@
106166
106167 zIndex = (char *)sqlite3_column_text(pStmt, 0);
106168 if( zIndex==0 ) continue;
106169 nSample = sqlite3_column_int(pStmt, 1);
106170 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
106171 assert( pIdx==0 || bStat3 || pIdx->nSample==0 );
106172 /* Index.nSample is non-zero at this point if data has already been
106173 ** loaded from the stat4 table. In this case ignore stat3 data. */
106174 if( pIdx==0 || pIdx->nSample ) continue;
106175 if( bStat3==0 ){
106176 assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );
106177 if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
106178 nIdxCol = pIdx->nKeyCol;
106179 }else{
106180 nIdxCol = pIdx->nColumn;
106181 }
106182 }
106183 pIdx->nSampleCol = nIdxCol;
106184 nByte = sizeof(IndexSample) * nSample;
106185 nByte += sizeof(tRowcnt) * nIdxCol * 3 * nSample;
106186 nByte += nIdxCol * sizeof(tRowcnt); /* Space for Index.aAvgEq[] */
@@ -106218,13 +106495,12 @@
106218 zIndex = (char *)sqlite3_column_text(pStmt, 0);
106219 if( zIndex==0 ) continue;
106220 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
106221 if( pIdx==0 ) continue;
106222 /* This next condition is true if data has already been loaded from
106223 ** the sqlite_stat4 table. In this case ignore stat3 data. */
106224 nCol = pIdx->nSampleCol;
106225 if( bStat3 && nCol>1 ) continue;
106226 if( pIdx!=pPrevIdx ){
106227 initAvgEq(pPrevIdx);
106228 pPrevIdx = pIdx;
106229 }
106230 pSample = &pIdx->aSample[pIdx->nSample];
@@ -106253,49 +106529,40 @@
106253 if( rc==SQLITE_OK ) initAvgEq(pPrevIdx);
106254 return rc;
106255 }
106256
106257 /*
106258 ** Load content from the sqlite_stat4 and sqlite_stat3 tables into
106259 ** the Index.aSample[] arrays of all indices.
106260 */
106261 static int loadStat4(sqlite3 *db, const char *zDb){
106262 int rc = SQLITE_OK; /* Result codes from subroutines */
106263
106264 assert( db->lookaside.bDisable );
106265 if( sqlite3FindTable(db, "sqlite_stat4", zDb) ){
106266 rc = loadStatTbl(db, 0,
106267 "SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx",
106268 "SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4",
106269 zDb
106270 );
106271 }
106272
106273 if( rc==SQLITE_OK && sqlite3FindTable(db, "sqlite_stat3", zDb) ){
106274 rc = loadStatTbl(db, 1,
106275 "SELECT idx,count(*) FROM %Q.sqlite_stat3 GROUP BY idx",
106276 "SELECT idx,neq,nlt,ndlt,sqlite_record(sample) FROM %Q.sqlite_stat3",
106277 zDb
106278 );
106279 }
106280
106281 return rc;
106282 }
106283 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
106284
106285 /*
106286 ** Load the content of the sqlite_stat1 and sqlite_stat3/4 tables. The
106287 ** contents of sqlite_stat1 are used to populate the Index.aiRowEst[]
106288 ** arrays. The contents of sqlite_stat3/4 are used to populate the
106289 ** Index.aSample[] arrays.
106290 **
106291 ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
106292 ** is returned. In this case, even if SQLITE_ENABLE_STAT3/4 was defined
106293 ** during compilation and the sqlite_stat3/4 table is present, no data is
106294 ** read from it.
106295 **
106296 ** If SQLITE_ENABLE_STAT3/4 was defined during compilation and the
106297 ** sqlite_stat4 table is not present in the database, SQLITE_ERROR is
106298 ** returned. However, in this case, data is read from the sqlite_stat1
106299 ** table (if it is present) before returning.
106300 **
106301 ** If an OOM error occurs, this function always sets db->mallocFailed.
@@ -106319,11 +106586,11 @@
106319 pTab->tabFlags &= ~TF_HasStat1;
106320 }
106321 for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
106322 Index *pIdx = sqliteHashData(i);
106323 pIdx->hasStat1 = 0;
106324 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
106325 sqlite3DeleteIndexSamples(db, pIdx);
106326 pIdx->aSample = 0;
106327 #endif
106328 }
106329
@@ -106347,11 +106614,11 @@
106347 Index *pIdx = sqliteHashData(i);
106348 if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
106349 }
106350
106351 /* Load the statistics from the sqlite_stat4 table. */
106352 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
106353 if( rc==SQLITE_OK ){
106354 db->lookaside.bDisable++;
106355 rc = loadStat4(db, sInfo.zDatabase);
106356 db->lookaside.bDisable--;
106357 }
@@ -106672,10 +106939,11 @@
106672 ){
106673 const char *zName = (const char *)sqlite3_value_text(argv[0]);
106674 sqlite3 *db = sqlite3_context_db_handle(context);
106675 int i;
106676 Db *pDb = 0;
 
106677 char zErr[128];
106678
106679 UNUSED_PARAMETER(NotUsed);
106680
106681 if( zName==0 ) zName = "";
@@ -106695,10 +106963,22 @@
106695 }
106696 if( sqlite3BtreeIsInReadTrans(pDb->pBt) || sqlite3BtreeIsInBackup(pDb->pBt) ){
106697 sqlite3_snprintf(sizeof(zErr),zErr, "database %s is locked", zName);
106698 goto detach_error;
106699 }
 
 
 
 
 
 
 
 
 
 
 
 
106700
106701 sqlite3BtreeClose(pDb->pBt);
106702 pDb->pBt = 0;
106703 pDb->pSchema = 0;
106704 sqlite3CollapseDatabaseArray(db);
@@ -106933,10 +107213,11 @@
106933 SQLITE_PRIVATE int sqlite3FixExpr(
106934 DbFixer *pFix, /* Context of the fixation */
106935 Expr *pExpr /* The expression to be fixed to one database */
106936 ){
106937 while( pExpr ){
 
106938 if( pExpr->op==TK_VARIABLE ){
106939 if( pFix->pParse->db->init.busy ){
106940 pExpr->op = TK_NULL;
106941 }else{
106942 sqlite3ErrorMsg(pFix->pParse, "%s cannot use variables", pFix->zType);
@@ -107085,11 +107366,11 @@
107085 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
107086 #endif
107087 sqlite3_mutex_enter(db->mutex);
107088 db->xAuth = (sqlite3_xauth)xAuth;
107089 db->pAuthArg = pArg;
107090 sqlite3ExpirePreparedStatements(db, 0);
107091 sqlite3_mutex_leave(db->mutex);
107092 return SQLITE_OK;
107093 }
107094
107095 /*
@@ -107739,11 +108020,11 @@
107739 #endif
107740 sqlite3ExprDelete(db, p->pPartIdxWhere);
107741 sqlite3ExprListDelete(db, p->aColExpr);
107742 sqlite3DbFree(db, p->zColAff);
107743 if( p->isResized ) sqlite3DbFree(db, (void *)p->azColl);
107744 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
107745 sqlite3_free(p->aiRowEst);
107746 #endif
107747 sqlite3DbFree(db, p);
107748 }
107749
@@ -108112,17 +108393,44 @@
108112 ** This routine is used to check if the UTF-8 string zName is a legal
108113 ** unqualified name for a new schema object (table, index, view or
108114 ** trigger). All names are legal except those that begin with the string
108115 ** "sqlite_" (in upper, lower or mixed case). This portion of the namespace
108116 ** is reserved for internal use.
 
 
 
 
108117 */
108118 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *pParse, const char *zName){
108119 if( !pParse->db->init.busy && pParse->nested==0
108120 && sqlite3WritableSchema(pParse->db)==0
108121 && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
108122 sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName);
108123 return SQLITE_ERROR;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108124 }
108125 return SQLITE_OK;
108126 }
108127
108128 /*
@@ -108199,11 +108507,11 @@
108199 sqlite3RenameTokenMap(pParse, (void*)zName, pName);
108200 }
108201 }
108202 pParse->sNameToken = *pName;
108203 if( zName==0 ) return;
108204 if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
108205 goto begin_table_error;
108206 }
108207 if( db->init.iDb==1 ) isTemp = 1;
108208 #ifndef SQLITE_OMIT_AUTHORIZATION
108209 assert( isTemp==0 || isTemp==1 );
@@ -108699,11 +109007,11 @@
108699 }
108700 pTab->iPKey = iCol;
108701 pTab->keyConf = (u8)onError;
108702 assert( autoInc==0 || autoInc==1 );
108703 pTab->tabFlags |= autoInc*TF_Autoincrement;
108704 if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder;
108705 }else if( autoInc ){
108706 #ifndef SQLITE_OMIT_AUTOINCREMENT
108707 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
108708 "INTEGER PRIMARY KEY");
108709 #endif
@@ -109114,10 +109422,11 @@
109114 */
109115 static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
109116 Index *pIdx;
109117 Index *pPk;
109118 int nPk;
 
109119 int i, j;
109120 sqlite3 *db = pParse->db;
109121 Vdbe *v = pParse->pVdbe;
109122
109123 /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)
@@ -109149,17 +109458,18 @@
109149 sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
109150 if( pList==0 ) return;
109151 if( IN_RENAME_OBJECT ){
109152 sqlite3RenameTokenRemap(pParse, pList->a[0].pExpr, &pTab->iPKey);
109153 }
109154 pList->a[0].sortOrder = pParse->iPkSortOrder;
109155 assert( pParse->pNewTable==pTab );
109156 pTab->iPKey = -1;
109157 sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
109158 SQLITE_IDXTYPE_PRIMARYKEY);
109159 if( db->mallocFailed || pParse->nErr ) return;
109160 pPk = sqlite3PrimaryKeyIndex(pTab);
 
109161 }else{
109162 pPk = sqlite3PrimaryKeyIndex(pTab);
109163 assert( pPk!=0 );
109164
109165 /*
@@ -109170,19 +109480,21 @@
109170 for(i=j=1; i<pPk->nKeyCol; i++){
109171 if( isDupColumn(pPk, j, pPk, i) ){
109172 pPk->nColumn--;
109173 }else{
109174 testcase( hasColumn(pPk->aiColumn, j, pPk->aiColumn[i]) );
 
 
109175 pPk->aiColumn[j++] = pPk->aiColumn[i];
109176 }
109177 }
109178 pPk->nKeyCol = j;
109179 }
109180 assert( pPk!=0 );
109181 pPk->isCovering = 1;
109182 if( !db->init.imposterTable ) pPk->uniqNotNull = 1;
109183 nPk = pPk->nKeyCol;
109184
109185 /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master
109186 ** table entry. This is only required if currently generating VDBE
109187 ** code for a CREATE TABLE (not when parsing one as part of reading
109188 ** a database schema). */
@@ -109228,25 +109540,25 @@
109228 assert( pIdx->nColumn>=j );
109229 }
109230
109231 /* Add all table columns to the PRIMARY KEY index
109232 */
109233 if( nPk<pTab->nCol ){
109234 if( resizeIndexObject(db, pPk, pTab->nCol) ) return;
109235 for(i=0, j=nPk; i<pTab->nCol; i++){
109236 if( !hasColumn(pPk->aiColumn, j, i) ){
109237 assert( j<pPk->nColumn );
109238 pPk->aiColumn[j] = i;
109239 pPk->azColl[j] = sqlite3StrBINARY;
109240 j++;
109241 }
109242 }
109243 assert( pPk->nColumn==j );
109244 assert( pTab->nCol==j );
109245 }else{
109246 pPk->nColumn = pTab->nCol;
109247 }
109248 recomputeColumnsNotIndexed(pPk);
109249 }
109250
109251 #ifndef SQLITE_OMIT_VIRTUALTABLE
109252 /*
@@ -109439,11 +109751,11 @@
109439 sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);
109440 pParse->nTab = 2;
109441 addrTop = sqlite3VdbeCurrentAddr(v) + 1;
109442 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
109443 if( pParse->nErr ) return;
109444 pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect);
109445 if( pSelTab==0 ) return;
109446 assert( p->aCol==0 );
109447 p->nCol = pSelTab->nCol;
109448 p->aCol = pSelTab->aCol;
109449 pSelTab->nCol = 0;
@@ -109703,14 +110015,14 @@
109703 pTable->nCol = -1;
109704 db->lookaside.bDisable++;
109705 #ifndef SQLITE_OMIT_AUTHORIZATION
109706 xAuth = db->xAuth;
109707 db->xAuth = 0;
109708 pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
109709 db->xAuth = xAuth;
109710 #else
109711 pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
109712 #endif
109713 pParse->nTab = n;
109714 if( pTable->pCheck ){
109715 /* CREATE VIEW name(arglist) AS ...
109716 ** The names of the columns in the table are taken from
@@ -109722,11 +110034,12 @@
109722 &pTable->nCol, &pTable->aCol);
109723 if( db->mallocFailed==0
109724 && pParse->nErr==0
109725 && pTable->nCol==pSel->pEList->nExpr
109726 ){
109727 sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel);
 
109728 }
109729 }else if( pSelTab ){
109730 /* CREATE VIEW name AS... without an argument list. Construct
109731 ** the column names from the SELECT statement that defines the view.
109732 */
@@ -110403,10 +110716,31 @@
110403 p->nKeyCol = nCol - 1;
110404 *ppExtra = ((char*)p) + nByte;
110405 }
110406 return p;
110407 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110408
110409 /*
110410 ** Create a new index for an SQL table. pName1.pName2 is the name of the index
110411 ** and pTblList is the name of the table that is to be indexed. Both will
110412 ** be NULL for a primary key or an index that is created to satisfy a
@@ -110454,10 +110788,13 @@
110454 if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
110455 goto exit_create_index;
110456 }
110457 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
110458 goto exit_create_index;
 
 
 
110459 }
110460
110461 /*
110462 ** Find the table that is to be indexed. Return early if not found.
110463 */
@@ -110553,11 +110890,11 @@
110553 */
110554 if( pName ){
110555 zName = sqlite3NameFromToken(db, pName);
110556 if( zName==0 ) goto exit_create_index;
110557 assert( pName->z!=0 );
110558 if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
110559 goto exit_create_index;
110560 }
110561 if( !IN_RENAME_OBJECT ){
110562 if( !db->init.busy ){
110563 if( sqlite3FindTable(db, zName, 0)!=0 ){
@@ -110619,11 +110956,11 @@
110619 sqlite3TokenInit(&prevCol, pCol->zName);
110620 pList = sqlite3ExprListAppend(pParse, 0,
110621 sqlite3ExprAlloc(db, TK_ID, &prevCol, 0));
110622 if( pList==0 ) goto exit_create_index;
110623 assert( pList->nExpr==1 );
110624 sqlite3ExprListSetSortOrder(pList, sortOrder);
110625 }else{
110626 sqlite3ExprListCheckLength(pParse, pList, "index");
110627 if( pParse->nErr ) goto exit_create_index;
110628 }
110629
@@ -110737,11 +111074,11 @@
110737 if( !zColl ) zColl = sqlite3StrBINARY;
110738 if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){
110739 goto exit_create_index;
110740 }
110741 pIndex->azColl[i] = zColl;
110742 requestedSortOrder = pListItem->sortOrder & sortOrderMask;
110743 pIndex->aSortOrder[i] = (u8)requestedSortOrder;
110744 }
110745
110746 /* Append the table key to the end of the index. For WITHOUT ROWID
110747 ** tables (when pPk!=0) this will be the declared PRIMARY KEY. For
@@ -110912,10 +111249,11 @@
110912 sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY);
110913
110914 /* Gather the complete text of the CREATE INDEX statement into
110915 ** the zStmt variable
110916 */
 
110917 if( pStart ){
110918 int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
110919 if( pName->z[n-1]==';' ) n--;
110920 /* A named index with an explicit CREATE INDEX statement */
110921 zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
@@ -111954,11 +112292,12 @@
111954 assert( sqlite3KeyInfoIsWriteable(pKey) );
111955 for(i=0; i<nCol; i++){
111956 const char *zColl = pIdx->azColl[i];
111957 pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
111958 sqlite3LocateCollSeq(pParse, zColl);
111959 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
 
111960 }
111961 if( pParse->nErr ){
111962 assert( pParse->rc==SQLITE_ERROR_MISSING_COLLSEQ );
111963 if( pIdx->bNoQuery==0 ){
111964 /* Deactivate the index because it contains an unknown collating
@@ -115493,13 +115832,10 @@
115493 };
115494 #ifndef SQLITE_OMIT_ALTERTABLE
115495 sqlite3AlterFunctions();
115496 #endif
115497 sqlite3WindowFunctions();
115498 #if defined(SQLITE_ENABLE_STAT3) || defined(SQLITE_ENABLE_STAT4)
115499 sqlite3AnalyzeFunctions();
115500 #endif
115501 sqlite3RegisterDateTimeFunctions();
115502 sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));
115503
115504 #if 0 /* Enable to print out how the built-in functions are hashed */
115505 {
@@ -115998,17 +116334,17 @@
115998 pExpr = sqlite3Expr(db, TK_REGISTER, 0);
115999 if( pExpr ){
116000 if( iCol>=0 && iCol!=pTab->iPKey ){
116001 pCol = &pTab->aCol[iCol];
116002 pExpr->iTable = regBase + iCol + 1;
116003 pExpr->affinity = pCol->affinity;
116004 zColl = pCol->zColl;
116005 if( zColl==0 ) zColl = db->pDfltColl->zName;
116006 pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl);
116007 }else{
116008 pExpr->iTable = regBase;
116009 pExpr->affinity = SQLITE_AFF_INTEGER;
116010 }
116011 }
116012 return pExpr;
116013 }
116014
@@ -116807,11 +117143,11 @@
116807
116808 tFrom.z = zFrom;
116809 tFrom.n = nFrom;
116810 pRaise = sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed");
116811 if( pRaise ){
116812 pRaise->affinity = OE_Abort;
116813 }
116814 pSelect = sqlite3SelectNew(pParse,
116815 sqlite3ExprListAppend(pParse, 0, pRaise),
116816 sqlite3SrcListAppend(pParse, 0, &tFrom, 0),
116817 pWhere,
@@ -116852,10 +117188,11 @@
116852 if( db->mallocFailed==1 ){
116853 fkTriggerDelete(db, pTrigger);
116854 return 0;
116855 }
116856 assert( pStep!=0 );
 
116857
116858 switch( action ){
116859 case OE_Restrict:
116860 pStep->op = TK_SELECT;
116861 break;
@@ -117042,22 +117379,23 @@
117042 sqlite3OomFault(db);
117043 return 0;
117044 }
117045 for(n=0; n<pIdx->nColumn; n++){
117046 i16 x = pIdx->aiColumn[n];
 
117047 if( x>=0 ){
117048 pIdx->zColAff[n] = pTab->aCol[x].affinity;
117049 }else if( x==XN_ROWID ){
117050 pIdx->zColAff[n] = SQLITE_AFF_INTEGER;
117051 }else{
117052 char aff;
117053 assert( x==XN_EXPR );
117054 assert( pIdx->aColExpr!=0 );
117055 aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);
117056 if( aff==0 ) aff = SQLITE_AFF_BLOB;
117057 pIdx->zColAff[n] = aff;
117058 }
 
 
 
117059 }
117060 pIdx->zColAff[n] = 0;
117061 }
117062
117063 return pIdx->zColAff;
@@ -117093,15 +117431,16 @@
117093 sqlite3OomFault(db);
117094 return;
117095 }
117096
117097 for(i=0; i<pTab->nCol; i++){
 
117098 zColAff[i] = pTab->aCol[i].affinity;
117099 }
117100 do{
117101 zColAff[i--] = 0;
117102 }while( i>=0 && zColAff[i]==SQLITE_AFF_BLOB );
117103 pTab->zColAff = zColAff;
117104 }
117105 assert( zColAff!=0 );
117106 i = sqlite3Strlen30NN(zColAff);
117107 if( i ){
@@ -117785,10 +118124,13 @@
117785 if( pUpsert ){
117786 if( IsVirtual(pTab) ){
117787 sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"",
117788 pTab->zName);
117789 goto insert_cleanup;
 
 
 
117790 }
117791 pTabList->a[0].iCursor = iDataCur;
117792 pUpsert->pUpsertSrc = pTabList;
117793 pUpsert->regData = regData;
117794 pUpsert->iDataCur = iDataCur;
@@ -119899,10 +120241,12 @@
119899 /* Version 3.26.0 and later */
119900 const char *(*normalized_sql)(sqlite3_stmt*);
119901 /* Version 3.28.0 and later */
119902 int (*stmt_isexplain)(sqlite3_stmt*);
119903 int (*value_frombind)(sqlite3_value*);
 
 
119904 };
119905
119906 /*
119907 ** This is the function signature used for all extension entry points. It
119908 ** is also defined in the file "loadext.c".
@@ -120191,10 +120535,12 @@
120191 /* Version 3.26.0 and later */
120192 #define sqlite3_normalized_sql sqlite3_api->normalized_sql
120193 /* Version 3.28.0 and later */
120194 #define sqlite3_stmt_isexplain sqlite3_api->isexplain
120195 #define sqlite3_value_frombind sqlite3_api->frombind
 
 
120196 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
120197
120198 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
120199 /* This case when the file really is being compiled as a loadable
120200 ** extension */
@@ -120656,11 +121002,13 @@
120656 #else
120657 0,
120658 #endif
120659 /* Version 3.28.0 and later */
120660 sqlite3_stmt_isexplain,
120661 sqlite3_value_frombind
 
 
120662 };
120663
120664 /*
120665 ** Attempt to load an SQLite extension library contained in the file
120666 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -121369,11 +121717,11 @@
121369 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121370 /* ColNames: */ 0, 0,
121371 /* iArg: */ SQLITE_FullFSync },
121372 #endif
121373 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
121374 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
121375 {/* zName: */ "function_list",
121376 /* ePragTyp: */ PragTyp_FUNCTION_LIST,
121377 /* ePragFlg: */ PragFlg_Result0,
121378 /* ColNames: */ 41, 2,
121379 /* iArg: */ 0 },
@@ -121493,11 +121841,11 @@
121493 /* ColNames: */ 0, 0,
121494 /* iArg: */ 0 },
121495 #endif
121496 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
121497 #if !defined(SQLITE_OMIT_VIRTUALTABLE)
121498 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
121499 {/* zName: */ "module_list",
121500 /* ePragTyp: */ PragTyp_MODULE_LIST,
121501 /* ePragFlg: */ PragFlg_Result0,
121502 /* ColNames: */ 9, 1,
121503 /* iArg: */ 0 },
@@ -121528,11 +121876,11 @@
121528 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121529 /* ColNames: */ 0, 0,
121530 /* iArg: */ SQLITE_ParserTrace },
121531 #endif
121532 #endif
121533 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
121534 {/* zName: */ "pragma_list",
121535 /* ePragTyp: */ PragTyp_PRAGMA_LIST,
121536 /* ePragFlg: */ PragFlg_Result0,
121537 /* ColNames: */ 9, 1,
121538 /* iArg: */ 0 },
@@ -121726,11 +122074,11 @@
121726 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121727 /* ColNames: */ 0, 0,
121728 /* iArg: */ SQLITE_WriteSchema|SQLITE_NoSchemaError },
121729 #endif
121730 };
121731 /* Number of pragmas: 62 on by default, 81 total. */
121732
121733 /************** End of pragma.h **********************************************/
121734 /************** Continuing where we left off in pragma.c *********************/
121735
121736 /*
@@ -122858,10 +123206,19 @@
122858
122859 case PragTyp_INDEX_INFO: if( zRight ){
122860 Index *pIdx;
122861 Table *pTab;
122862 pIdx = sqlite3FindIndex(db, zRight, zDb);
 
 
 
 
 
 
 
 
 
122863 if( pIdx ){
122864 int iIdxDb = sqlite3SchemaToIndex(db, pIdx->pSchema);
122865 int i;
122866 int mx;
122867 if( pPragma->iArg ){
@@ -122937,11 +123294,11 @@
122937 sqlite3VdbeMultiLoad(v, 1, "is", i++, pColl->zName);
122938 }
122939 }
122940 break;
122941
122942 #ifdef SQLITE_INTROSPECTION_PRAGMAS
122943 case PragTyp_FUNCTION_LIST: {
122944 int i;
122945 HashElem *j;
122946 FuncDef *p;
122947 pParse->nMem = 2;
@@ -124272,35 +124629,37 @@
124272 ** database. See sqlite3Init() below for additional information.
124273 ** This routine is also called from the OP_ParseSchema opcode of the VDBE.
124274 **
124275 ** Each callback contains the following information:
124276 **
124277 ** argv[0] = name of thing being created
124278 ** argv[1] = root page number for table or index. 0 for trigger or view.
124279 ** argv[2] = SQL text for the CREATE statement.
 
 
124280 **
124281 */
124282 SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){
124283 InitData *pData = (InitData*)pInit;
124284 sqlite3 *db = pData->db;
124285 int iDb = pData->iDb;
124286
124287 assert( argc==3 );
124288 UNUSED_PARAMETER2(NotUsed, argc);
124289 assert( sqlite3_mutex_held(db->mutex) );
124290 DbClearProperty(db, iDb, DB_Empty);
124291 pData->nInitRow++;
124292 if( db->mallocFailed ){
124293 corruptSchema(pData, argv[0], 0);
124294 return 1;
124295 }
124296
124297 assert( iDb>=0 && iDb<db->nDb );
124298 if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */
124299 if( argv[1]==0 ){
124300 corruptSchema(pData, argv[0], 0);
124301 }else if( sqlite3_strnicmp(argv[2],"create ",7)==0 ){
124302 /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
124303 ** But because db->init.busy is set to 1, no VDBE code is generated
124304 ** or executed. All the parser does is build the internal data
124305 ** structures that describe the table, index, or view.
124306 */
@@ -124309,47 +124668,48 @@
124309 sqlite3_stmt *pStmt;
124310 TESTONLY(int rcp); /* Return code from sqlite3_prepare() */
124311
124312 assert( db->init.busy );
124313 db->init.iDb = iDb;
124314 db->init.newTnum = sqlite3Atoi(argv[1]);
124315 db->init.orphanTrigger = 0;
124316 TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);
 
124317 rc = db->errCode;
124318 assert( (rc&0xFF)==(rcp&0xFF) );
124319 db->init.iDb = saved_iDb;
124320 /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */
124321 if( SQLITE_OK!=rc ){
124322 if( db->init.orphanTrigger ){
124323 assert( iDb==1 );
124324 }else{
124325 pData->rc = rc;
124326 if( rc==SQLITE_NOMEM ){
124327 sqlite3OomFault(db);
124328 }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){
124329 corruptSchema(pData, argv[0], sqlite3_errmsg(db));
124330 }
124331 }
124332 }
124333 sqlite3_finalize(pStmt);
124334 }else if( argv[0]==0 || (argv[2]!=0 && argv[2][0]!=0) ){
124335 corruptSchema(pData, argv[0], 0);
124336 }else{
124337 /* If the SQL column is blank it means this is an index that
124338 ** was created to be the PRIMARY KEY or to fulfill a UNIQUE
124339 ** constraint for a CREATE TABLE. The index should have already
124340 ** been created when we processed the CREATE TABLE. All we have
124341 ** to do here is record the root page number for that index.
124342 */
124343 Index *pIndex;
124344 pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zDbSName);
124345 if( pIndex==0
124346 || sqlite3GetInt32(argv[1],&pIndex->tnum)==0
124347 || pIndex->tnum<2
124348 || sqlite3IndexHasDuplicateRootPage(pIndex)
124349 ){
124350 corruptSchema(pData, argv[0], pIndex?"invalid rootpage":"orphan index");
124351 }
124352 }
124353 return 0;
124354 }
124355
@@ -124366,11 +124726,11 @@
124366 int i;
124367 #ifndef SQLITE_OMIT_DEPRECATED
124368 int size;
124369 #endif
124370 Db *pDb;
124371 char const *azArg[4];
124372 int meta[5];
124373 InitData initData;
124374 const char *zMasterName;
124375 int openedTransaction = 0;
124376
@@ -124385,22 +124745,24 @@
124385 /* Construct the in-memory representation schema tables (sqlite_master or
124386 ** sqlite_temp_master) by invoking the parser directly. The appropriate
124387 ** table name will be inserted automatically by the parser so we can just
124388 ** use the abbreviation "x" here. The parser will also automatically tag
124389 ** the schema table as read-only. */
124390 azArg[0] = zMasterName = SCHEMA_TABLE(iDb);
124391 azArg[1] = "1";
124392 azArg[2] = "CREATE TABLE x(type text,name text,tbl_name text,"
 
 
124393 "rootpage int,sql text)";
124394 azArg[3] = 0;
124395 initData.db = db;
124396 initData.iDb = iDb;
124397 initData.rc = SQLITE_OK;
124398 initData.pzErrMsg = pzErrMsg;
124399 initData.mInitFlags = mFlags;
124400 initData.nInitRow = 0;
124401 sqlite3InitCallback(&initData, 3, (char **)azArg, 0);
124402 if( initData.rc ){
124403 rc = initData.rc;
124404 goto error_out;
124405 }
124406
@@ -124522,11 +124884,11 @@
124522 */
124523 assert( db->init.busy );
124524 {
124525 char *zSql;
124526 zSql = sqlite3MPrintf(db,
124527 "SELECT name, rootpage, sql FROM \"%w\".%s ORDER BY rowid",
124528 db->aDb[iDb].zDbSName, zMasterName);
124529 #ifndef SQLITE_OMIT_AUTHORIZATION
124530 {
124531 sqlite3_xauth xAuth;
124532 xAuth = db->xAuth;
@@ -124843,11 +125205,14 @@
124843 *pzTail = sParse.zTail;
124844 }
124845 rc = sParse.rc;
124846
124847 #ifndef SQLITE_OMIT_EXPLAIN
124848 if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){
 
 
 
124849 static const char * const azColName[] = {
124850 "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment",
124851 "id", "parent", "notused", "detail"
124852 };
124853 int iFirst, mx;
@@ -124868,12 +125233,12 @@
124868 #endif
124869
124870 if( db->init.busy==0 ){
124871 sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);
124872 }
124873 if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){
124874 sqlite3VdbeFinalize(sParse.pVdbe);
124875 assert(!(*ppStmt));
124876 }else{
124877 *ppStmt = (sqlite3_stmt*)sParse.pVdbe;
124878 }
124879
@@ -125242,10 +125607,11 @@
125242 if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){
125243 sqlite3WindowListDelete(db, p->pWinDefn);
125244 }
125245 #endif
125246 if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);
 
125247 if( bFree ) sqlite3DbFreeNN(db, p);
125248 p = pPrior;
125249 bFree = 1;
125250 }
125251 }
@@ -125803,11 +126169,11 @@
125803 sqlite3VdbeAddOp3(v, OP_Compare, regPrevKey, regBase, pSort->nOBSat);
125804 pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);
125805 if( pParse->db->mallocFailed ) return;
125806 pOp->p2 = nKey + nData;
125807 pKI = pOp->p4.pKeyInfo;
125808 memset(pKI->aSortOrder, 0, pKI->nKeyField); /* Makes OP_Jump testable */
125809 sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
125810 testcase( pKI->nAllField > pKI->nKeyField+2 );
125811 pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat,
125812 pKI->nAllField-pKI->nKeyField-1);
125813 addrJmp = sqlite3VdbeCurrentAddr(v);
@@ -126414,11 +126780,11 @@
126414 */
126415 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
126416 int nExtra = (N+X)*(sizeof(CollSeq*)+1) - sizeof(CollSeq*);
126417 KeyInfo *p = sqlite3DbMallocRawNN(db, sizeof(KeyInfo) + nExtra);
126418 if( p ){
126419 p->aSortOrder = (u8*)&p->aColl[N+X];
126420 p->nKeyField = (u16)N;
126421 p->nAllField = (u16)(N+X);
126422 p->enc = ENC(db);
126423 p->db = db;
126424 p->nRef = 1;
@@ -126491,11 +126857,11 @@
126491 pInfo = sqlite3KeyInfoAlloc(db, nExpr-iStart, nExtra+1);
126492 if( pInfo ){
126493 assert( sqlite3KeyInfoIsWriteable(pInfo) );
126494 for(i=iStart, pItem=pList->a+iStart; i<nExpr; i++, pItem++){
126495 pInfo->aColl[i-iStart] = sqlite3ExprNNCollSeq(pParse, pItem->pExpr);
126496 pInfo->aSortOrder[i-iStart] = pItem->sortOrder;
126497 }
126498 }
126499 return pInfo;
126500 }
126501
@@ -126783,12 +127149,10 @@
126783 char const *zOrigCol = 0;
126784 #endif
126785
126786 assert( pExpr!=0 );
126787 assert( pNC->pSrcList!=0 );
126788 assert( pExpr->op!=TK_AGG_COLUMN ); /* This routine runes before aggregates
126789 ** are processed */
126790 switch( pExpr->op ){
126791 case TK_COLUMN: {
126792 /* The expression is a column. Locate the table the column is being
126793 ** extracted from in NameContext.pSrcList. This table may be real
126794 ** database table or a subquery.
@@ -127101,16 +127465,15 @@
127101 /* Get an appropriate name for the column
127102 */
127103 if( (zName = pEList->a[i].zName)!=0 ){
127104 /* If the column contains an "AS <name>" phrase, use <name> as the name */
127105 }else{
127106 Expr *pColExpr = sqlite3ExprSkipCollate(pEList->a[i].pExpr);
127107 while( pColExpr->op==TK_DOT ){
127108 pColExpr = pColExpr->pRight;
127109 assert( pColExpr!=0 );
127110 }
127111 assert( pColExpr->op!=TK_AGG_COLUMN );
127112 if( pColExpr->op==TK_COLUMN ){
127113 /* For columns use the column name name */
127114 int iCol = pColExpr->iColumn;
127115 Table *pTab = pColExpr->y.pTab;
127116 assert( pTab!=0 );
@@ -127174,11 +127537,12 @@
127174 ** statement be resolved.
127175 */
127176 SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(
127177 Parse *pParse, /* Parsing contexts */
127178 Table *pTab, /* Add column type information to this table */
127179 Select *pSelect /* SELECT used to determine types and collations */
 
127180 ){
127181 sqlite3 *db = pParse->db;
127182 NameContext sNC;
127183 Column *pCol;
127184 CollSeq *pColl;
@@ -127207,11 +127571,11 @@
127207 if( pCol->zName ){
127208 memcpy(&pCol->zName[n+1], zType, m+1);
127209 pCol->colFlags |= COLFLAG_HASTYPE;
127210 }
127211 }
127212 if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_BLOB;
127213 pColl = sqlite3ExprCollSeq(pParse, p);
127214 if( pColl && pCol->zColl==0 ){
127215 pCol->zColl = sqlite3DbStrDup(db, pColl->zName);
127216 }
127217 }
@@ -127220,11 +127584,11 @@
127220
127221 /*
127222 ** Given a SELECT statement, generate a Table structure that describes
127223 ** the result set of that SELECT.
127224 */
127225 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
127226 Table *pTab;
127227 sqlite3 *db = pParse->db;
127228 u64 savedFlags;
127229
127230 savedFlags = db->flags;
@@ -127240,11 +127604,11 @@
127240 }
127241 pTab->nTabRef = 1;
127242 pTab->zName = 0;
127243 pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
127244 sqlite3ColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);
127245 sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSelect);
127246 pTab->iPKey = -1;
127247 if( db->mallocFailed ){
127248 sqlite3DeleteTable(db, pTab);
127249 return 0;
127250 }
@@ -127394,11 +127758,11 @@
127394 pOrderBy->a[i].pExpr =
127395 sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);
127396 }
127397 assert( sqlite3KeyInfoIsWriteable(pRet) );
127398 pRet->aColl[i] = pColl;
127399 pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder;
127400 }
127401 }
127402
127403 return pRet;
127404 }
@@ -128105,15 +128469,18 @@
128105 break;
128106 }
128107
128108 /* If this is a scalar select that is part of an expression, then
128109 ** store the results in the appropriate memory cell and break out
128110 ** of the scan loop.
 
128111 */
128112 case SRT_Mem: {
128113 assert( pIn->nSdst==1 || pParse->nErr>0 ); testcase( pIn->nSdst!=1 );
128114 sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);
 
 
128115 /* The LIMIT clause will jump out of the loop for us */
128116 break;
128117 }
128118 #endif /* #ifndef SQLITE_OMIT_SUBQUERY */
128119
@@ -128366,11 +128733,11 @@
128366 pKeyDup = sqlite3KeyInfoAlloc(db, nExpr, 1);
128367 if( pKeyDup ){
128368 assert( sqlite3KeyInfoIsWriteable(pKeyDup) );
128369 for(i=0; i<nExpr; i++){
128370 pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
128371 pKeyDup->aSortOrder[i] = 0;
128372 }
128373 }
128374 }
128375
128376 /* Separate the left and the right query from one another
@@ -129089,10 +129456,11 @@
129089 ** elements we are now copying in.
129090 */
129091 for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){
129092 int nSubSrc;
129093 u8 jointype = 0;
 
129094 pSubSrc = pSub->pSrc; /* FROM clause of subquery */
129095 nSubSrc = pSubSrc->nSrc; /* Number of terms in subquery FROM clause */
129096 pSrc = pParent->pSrc; /* FROM clause of the outer query */
129097
129098 if( pSrc ){
@@ -129539,28 +129907,31 @@
129539 static u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){
129540 int eRet = WHERE_ORDERBY_NORMAL; /* Return value */
129541 ExprList *pEList = pFunc->x.pList; /* Arguments to agg function */
129542 const char *zFunc; /* Name of aggregate function pFunc */
129543 ExprList *pOrderBy;
129544 u8 sortOrder;
129545
129546 assert( *ppMinMax==0 );
129547 assert( pFunc->op==TK_AGG_FUNCTION );
129548 if( pEList==0 || pEList->nExpr!=1 ) return eRet;
 
 
 
129549 zFunc = pFunc->u.zToken;
129550 if( sqlite3StrICmp(zFunc, "min")==0 ){
129551 eRet = WHERE_ORDERBY_MIN;
129552 sortOrder = SQLITE_SO_ASC;
129553 }else if( sqlite3StrICmp(zFunc, "max")==0 ){
129554 eRet = WHERE_ORDERBY_MAX;
129555 sortOrder = SQLITE_SO_DESC;
129556 }else{
129557 return eRet;
129558 }
129559 *ppMinMax = pOrderBy = sqlite3ExprListDup(db, pEList, 0);
129560 assert( pOrderBy!=0 || db->mallocFailed );
129561 if( pOrderBy ) pOrderBy->a[0].sortOrder = sortOrder;
129562 return eRet;
129563 }
129564
129565 /*
129566 ** The select statement passed as the first argument is an aggregate query.
@@ -129590,11 +129961,11 @@
129590
129591 if( IsVirtual(pTab) ) return 0;
129592 if( pExpr->op!=TK_AGG_FUNCTION ) return 0;
129593 if( NEVER(pAggInfo->nFunc==0) ) return 0;
129594 if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0;
129595 if( pExpr->flags&EP_Distinct ) return 0;
129596
129597 return pTab;
129598 }
129599
129600 /*
@@ -130037,10 +130408,14 @@
130037 if( IsVirtual(pTab) || pTab->pSelect ){
130038 i16 nCol;
130039 u8 eCodeOrig = pWalker->eCode;
130040 if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;
130041 assert( pFrom->pSelect==0 );
 
 
 
 
130042 pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);
130043 nCol = pTab->nCol;
130044 pTab->nCol = -1;
130045 pWalker->eCode = 1; /* Turn on Select.selId renumbering */
130046 sqlite3WalkSelect(pWalker, pFrom->pSelect);
@@ -130330,11 +130705,12 @@
130330 if( (pTab->tabFlags & TF_Ephemeral)!=0 ){
130331 /* A sub-query in the FROM clause of a SELECT */
130332 Select *pSel = pFrom->pSelect;
130333 if( pSel ){
130334 while( pSel->pPrior ) pSel = pSel->pPrior;
130335 sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSel);
 
130336 }
130337 }
130338 }
130339 }
130340 #endif
@@ -130470,20 +130846,28 @@
130470 int nArg;
130471 int addrNext = 0;
130472 int regAgg;
130473 ExprList *pList = pF->pExpr->x.pList;
130474 assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
 
 
 
 
 
 
130475 if( pList ){
130476 nArg = pList->nExpr;
130477 regAgg = sqlite3GetTempRange(pParse, nArg);
130478 sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP);
130479 }else{
130480 nArg = 0;
130481 regAgg = 0;
130482 }
130483 if( pF->iDistinct>=0 ){
130484 addrNext = sqlite3VdbeMakeLabel(pParse);
 
 
130485 testcase( nArg==0 ); /* Error condition */
130486 testcase( nArg>1 ); /* Also an error */
130487 codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);
130488 }
130489 if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
@@ -130982,11 +131366,11 @@
130982 ** "" column. The original design was for the fake column name to be a NULL,
130983 ** which would be unambiguous. But legacy authorization callbacks might
130984 ** assume the column name is non-NULL and segfault. The use of an empty
130985 ** string for the fake column name seems safer.
130986 */
130987 if( pItem->colUsed==0 ){
130988 sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase);
130989 }
130990
130991 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
130992 /* Generate code for all sub-queries in the FROM clause
@@ -130996,12 +131380,19 @@
130996
130997 /* The code for a subquery should only be generated once, though it is
130998 ** technically harmless for it to be generated multiple times. The
130999 ** following assert() will detect if something changes to cause
131000 ** the same subquery to be coded multiple times, as a signal to the
131001 ** developers to try to optimize the situation. */
131002 assert( pItem->addrFillSub==0 );
 
 
 
 
 
 
 
131003
131004 /* Increment Parse.nHeight by the height of the largest expression
131005 ** tree referred to by this, the parent select. The child select
131006 ** may contain expression trees of at most
131007 ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit
@@ -131071,11 +131462,11 @@
131071 int topAddr;
131072 int onceAddr = 0;
131073 int retAddr;
131074 struct SrcList_item *pPrior;
131075
131076 assert( pItem->addrFillSub==0 );
131077 pItem->regReturn = ++pParse->nMem;
131078 topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn);
131079 pItem->addrFillSub = topAddr+1;
131080 if( pItem->fg.isCorrelated==0 ){
131081 /* If the subquery is not correlated and if we are not inside of
@@ -131362,13 +131753,20 @@
131362 minMaxFlag = minMaxQuery(db, sAggInfo.aFunc[0].pExpr, &pMinMaxOrderBy);
131363 }else{
131364 minMaxFlag = WHERE_ORDERBY_NORMAL;
131365 }
131366 for(i=0; i<sAggInfo.nFunc; i++){
131367 assert( !ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect) );
 
131368 sNC.ncFlags |= NC_InAggFunc;
131369 sqlite3ExprAnalyzeAggList(&sNC, sAggInfo.aFunc[i].pExpr->x.pList);
 
 
 
 
 
 
131370 sNC.ncFlags &= ~NC_InAggFunc;
131371 }
131372 sAggInfo.mxReg = pParse->nMem;
131373 if( db->mallocFailed ) goto select_end;
131374 #if SELECTTRACE_ENABLED
@@ -132153,11 +132551,15 @@
132153 }
132154
132155 /* Check that the trigger name is not reserved and that no trigger of the
132156 ** specified name exists */
132157 zName = sqlite3NameFromToken(db, pName);
132158 if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
 
 
 
 
132159 goto trigger_cleanup;
132160 }
132161 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
132162 if( !IN_RENAME_OBJECT ){
132163 if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),zName) ){
@@ -132316,10 +132718,11 @@
132316
132317 if( db->init.busy ){
132318 Trigger *pLink = pTrig;
132319 Hash *pHash = &db->aDb[iDb].pSchema->trigHash;
132320 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
 
132321 pTrig = sqlite3HashInsert(pHash, zName, pTrig);
132322 if( pTrig ){
132323 sqlite3OomFault(db);
132324 }else if( pLink->pSchema==pLink->pTabSchema ){
132325 Table *pTab;
@@ -132434,10 +132837,13 @@
132434 pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
132435 }
132436 pTriggerStep->pIdList = pColumn;
132437 pTriggerStep->pUpsert = pUpsert;
132438 pTriggerStep->orconf = orconf;
 
 
 
132439 }else{
132440 testcase( pColumn );
132441 sqlite3IdListDelete(db, pColumn);
132442 testcase( pUpsert );
132443 sqlite3UpsertDelete(db, pUpsert);
@@ -132589,14 +132995,13 @@
132589 int iDb;
132590
132591 iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema);
132592 assert( iDb>=0 && iDb<db->nDb );
132593 pTable = tableOfTrigger(pTrigger);
132594 assert( pTable );
132595 assert( pTable->pSchema==pTrigger->pSchema || iDb==1 );
132596 #ifndef SQLITE_OMIT_AUTHORIZATION
132597 {
132598 int code = SQLITE_DROP_TRIGGER;
132599 const char *zDb = db->aDb[iDb].zDbSName;
132600 const char *zTab = SCHEMA_TABLE(iDb);
132601 if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;
132602 if( sqlite3AuthCheck(pParse, code, pTrigger->zName, pTable->zName, zDb) ||
@@ -132606,11 +133011,10 @@
132606 }
132607 #endif
132608
132609 /* Generate code to destroy the database record of the trigger.
132610 */
132611 assert( pTable!=0 );
132612 if( (v = sqlite3GetVdbe(pParse))!=0 ){
132613 sqlite3NestedParse(pParse,
132614 "DELETE FROM %Q.%s WHERE name=%Q AND type='trigger'",
132615 db->aDb[iDb].zDbSName, MASTER_NAME, pTrigger->zName
132616 );
@@ -132630,13 +133034,15 @@
132630 pHash = &(db->aDb[iDb].pSchema->trigHash);
132631 pTrigger = sqlite3HashInsert(pHash, zName, 0);
132632 if( ALWAYS(pTrigger) ){
132633 if( pTrigger->pSchema==pTrigger->pTabSchema ){
132634 Table *pTab = tableOfTrigger(pTrigger);
132635 Trigger **pp;
132636 for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext));
132637 *pp = (*pp)->pNext;
 
 
132638 }
132639 sqlite3DeleteTrigger(db, pTrigger);
132640 db->mDbFlags |= DBFLAG_SchemaChange;
132641 }
132642 }
@@ -133880,32 +134286,34 @@
133880 }
133881 }
133882 }
133883
133884 if( !isView ){
133885 int addr1 = 0; /* Address of jump instruction */
133886
133887 /* Do constraint checks. */
133888 assert( regOldRowid>0 );
133889 sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
133890 regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace,
133891 aXRef, 0);
 
 
 
 
 
 
 
 
 
 
 
 
133892
133893 /* Do FK constraint checks. */
133894 if( hasFK ){
133895 sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);
133896 }
133897
133898 /* Delete the index entries associated with the current record. */
133899 if( bReplace || chngKey ){
133900 if( pPk ){
133901 addr1 = sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, 0, regKey, nKey);
133902 }else{
133903 addr1 = sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, 0, regOldRowid);
133904 }
133905 VdbeCoverageNeverTaken(v);
133906 }
133907 sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, aRegIdx, -1);
133908
133909 /* If changing the rowid value, or if there are foreign key constraints
133910 ** to process, delete the old record. Otherwise, add a noop OP_Delete
133911 ** to invoke the pre-update hook.
@@ -133931,13 +134339,10 @@
133931 #else
133932 if( hasFK>1 || chngKey ){
133933 sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0);
133934 }
133935 #endif
133936 if( bReplace || chngKey ){
133937 sqlite3VdbeJumpHere(v, addr1);
133938 }
133939
133940 if( hasFK ){
133941 sqlite3FkCheck(pParse, pTab, 0, regNewRowid, aXRef, chngKey);
133942 }
133943
@@ -134372,10 +134777,11 @@
134372 ){
134373 Vdbe *v = pParse->pVdbe;
134374 sqlite3 *db = pParse->db;
134375 SrcList *pSrc; /* FROM clause for the UPDATE */
134376 int iDataCur;
 
134377
134378 assert( v!=0 );
134379 assert( pUpsert!=0 );
134380 VdbeNoopComment((v, "Begin DO UPDATE of UPSERT"));
134381 iDataCur = pUpsert->iDataCur;
@@ -134388,11 +134794,10 @@
134388 sqlite3ReleaseTempReg(pParse, regRowid);
134389 }else{
134390 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
134391 int nPk = pPk->nKeyCol;
134392 int iPk = pParse->nMem+1;
134393 int i;
134394 pParse->nMem += nPk;
134395 for(i=0; i<nPk; i++){
134396 int k;
134397 assert( pPk->aiColumn[i]>=0 );
134398 k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
@@ -134409,10 +134814,16 @@
134409 }
134410 }
134411 /* pUpsert does not own pUpsertSrc - the outer INSERT statement does. So
134412 ** we have to make a copy before passing it down into sqlite3Update() */
134413 pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
 
 
 
 
 
 
134414 sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet,
134415 pUpsert->pUpsertWhere, OE_Abort, 0, 0, pUpsert);
134416 pUpsert->pUpsertSet = 0; /* Will have been deleted by sqlite3Update() */
134417 pUpsert->pUpsertWhere = 0; /* Will have been deleted by sqlite3Update() */
134418 VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
@@ -134872,38 +135283,52 @@
134872
134873 /*
134874 ** Construct and install a Module object for a virtual table. When this
134875 ** routine is called, it is guaranteed that all appropriate locks are held
134876 ** and the module is not already part of the connection.
 
 
 
134877 */
134878 SQLITE_PRIVATE Module *sqlite3VtabCreateModule(
134879 sqlite3 *db, /* Database in which module is registered */
134880 const char *zName, /* Name assigned to this module */
134881 const sqlite3_module *pModule, /* The definition of the module */
134882 void *pAux, /* Context pointer for xCreate/xConnect */
134883 void (*xDestroy)(void *) /* Module destructor function */
134884 ){
134885 Module *pMod;
134886 int nName = sqlite3Strlen30(zName);
134887 pMod = (Module *)sqlite3Malloc(sizeof(Module) + nName + 1);
134888 if( pMod==0 ){
134889 sqlite3OomFault(db);
 
134890 }else{
134891 Module *pDel;
134892 char *zCopy = (char *)(&pMod[1]);
 
 
 
 
 
134893 memcpy(zCopy, zName, nName+1);
134894 pMod->zName = zCopy;
134895 pMod->pModule = pModule;
134896 pMod->pAux = pAux;
134897 pMod->xDestroy = xDestroy;
134898 pMod->pEpoTab = 0;
134899 pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,(void*)pMod);
134900 assert( pDel==0 || pDel==pMod );
134901 if( pDel ){
 
 
134902 sqlite3OomFault(db);
134903 sqlite3DbFree(db, pDel);
134904 pMod = 0;
 
 
 
134905 }
134906 }
134907 return pMod;
134908 }
134909
@@ -134920,15 +135345,11 @@
134920 void (*xDestroy)(void *) /* Module destructor function */
134921 ){
134922 int rc = SQLITE_OK;
134923
134924 sqlite3_mutex_enter(db->mutex);
134925 if( sqlite3HashFind(&db->aModule, zName) ){
134926 rc = SQLITE_MISUSE_BKPT;
134927 }else{
134928 (void)sqlite3VtabCreateModule(db, zName, pModule, pAux, xDestroy);
134929 }
134930 rc = sqlite3ApiExit(db, rc);
134931 if( rc!=SQLITE_OK && xDestroy ) xDestroy(pAux);
134932 sqlite3_mutex_leave(db->mutex);
134933 return rc;
134934 }
@@ -134962,10 +135383,48 @@
134962 #ifdef SQLITE_ENABLE_API_ARMOR
134963 if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;
134964 #endif
134965 return createModule(db, zName, pModule, pAux, xDestroy);
134966 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134967
134968 /*
134969 ** Lock the virtual table so that it cannot be disconnected.
134970 ** Locks nest. Every lock should have a corresponding unlock.
134971 ** If an unlock is omitted, resources leaks will occur.
@@ -135002,10 +135461,11 @@
135002 assert( db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_ZOMBIE );
135003
135004 pVTab->nRef--;
135005 if( pVTab->nRef==0 ){
135006 sqlite3_vtab *p = pVTab->pVtab;
 
135007 if( p ){
135008 p->pModule->xDisconnect(p);
135009 }
135010 sqlite3DbFree(db, pVTab);
135011 }
@@ -135406,10 +135866,11 @@
135406 }else if( ALWAYS(pVTable->pVtab) ){
135407 /* Justification of ALWAYS(): A correct vtab constructor must allocate
135408 ** the sqlite3_vtab object if successful. */
135409 memset(pVTable->pVtab, 0, sizeof(pVTable->pVtab[0]));
135410 pVTable->pVtab->pModule = pMod->pModule;
 
135411 pVTable->nRef = 1;
135412 if( sCtx.bDeclared==0 ){
135413 const char *zFormat = "vtable constructor did not declare schema: %s";
135414 *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
135415 sqlite3VtabUnlock(pVTable);
@@ -136190,17 +136651,19 @@
136190 int addrNxt; /* Jump here to start the next IN combination */
136191 int addrSkip; /* Jump here for next iteration of skip-scan */
136192 int addrCont; /* Jump here to continue with the next loop cycle */
136193 int addrFirst; /* First instruction of interior of the loop */
136194 int addrBody; /* Beginning of the body of this loop */
 
 
136195 #ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS
136196 u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */
136197 int addrLikeRep; /* LIKE range processing address */
136198 #endif
136199 u8 iFrom; /* Which entry in the FROM clause */
136200 u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
136201 int p1, p2; /* Operands of the opcode used to ends the loop */
136202 union { /* Information that depends on pWLoop->wsFlags */
136203 struct {
136204 int nIn; /* Number of entries in aInLoop[] */
136205 struct InLoop {
136206 int iCur; /* The VDBE cursor used by this IN operator */
@@ -136247,11 +136710,11 @@
136247 union {
136248 struct { /* Information for internal btree tables */
136249 u16 nEq; /* Number of equality constraints */
136250 u16 nBtm; /* Size of BTM vector */
136251 u16 nTop; /* Size of TOP vector */
136252 u16 nIdxCol; /* Index column used for ORDER BY */
136253 Index *pIndex; /* Index used, or NULL */
136254 } btree;
136255 struct { /* Information for virtual tables */
136256 int idxNum; /* Index number */
136257 u8 needFree; /* True if sqlite3_free(idxStr) is needed */
@@ -136398,20 +136861,21 @@
136398 #define TERM_CODED 0x04 /* This term is already coded */
136399 #define TERM_COPIED 0x08 /* Has a child */
136400 #define TERM_ORINFO 0x10 /* Need to free the WhereTerm.u.pOrInfo object */
136401 #define TERM_ANDINFO 0x20 /* Need to free the WhereTerm.u.pAndInfo obj */
136402 #define TERM_OR_OK 0x40 /* Used during OR-clause processing */
136403 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
136404 # define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */
136405 #else
136406 # define TERM_VNULL 0x00 /* Disabled if not using stat3 */
136407 #endif
136408 #define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
136409 #define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
136410 #define TERM_LIKE 0x400 /* The original LIKE operator */
136411 #define TERM_IS 0x800 /* Term.pExpr is an IS operator */
136412 #define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
 
136413
136414 /*
136415 ** An instance of the WhereScan object is used as an iterator for locating
136416 ** terms in the WHERE clause that are useful to the query planner.
136417 */
@@ -136518,11 +136982,11 @@
136518 WhereInfo *pWInfo; /* Information about this WHERE */
136519 WhereClause *pWC; /* WHERE clause terms */
136520 ExprList *pOrderBy; /* ORDER BY clause */
136521 WhereLoop *pNew; /* Template WhereLoop */
136522 WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
136523 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
136524 UnpackedRecord *pRec; /* Probe for stat4 (if required) */
136525 int nRecValid; /* Number of valid fields currently in pRec */
136526 #endif
136527 unsigned int bldFlags; /* SQLITE_BLDF_* flags */
136528 unsigned int iPlanLimit; /* Search limiter */
@@ -136705,10 +137169,11 @@
136705 #define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
136706 #define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
136707 #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
136708 #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
136709 #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
 
136710
136711 #endif /* !defined(SQLITE_WHEREINT_H) */
136712
136713 /************** End of whereInt.h ********************************************/
136714 /************** Continuing where we left off in wherecode.c ******************/
@@ -137009,13 +137474,13 @@
137009
137010 /*
137011 ** Code an OP_Affinity opcode to apply the column affinity string zAff
137012 ** to the n registers starting at base.
137013 **
137014 ** As an optimization, SQLITE_AFF_BLOB entries (which are no-ops) at the
137015 ** beginning and end of zAff are ignored. If all entries in zAff are
137016 ** SQLITE_AFF_BLOB, then no code gets generated.
137017 **
137018 ** This routine makes its own copy of zAff so that the caller is free
137019 ** to modify zAff after this routine returns.
137020 */
137021 static void codeApplyAffinity(Parse *pParse, int base, int n, char *zAff){
@@ -137024,19 +137489,20 @@
137024 assert( pParse->db->mallocFailed );
137025 return;
137026 }
137027 assert( v!=0 );
137028
137029 /* Adjust base and n to skip over SQLITE_AFF_BLOB entries at the beginning
137030 ** and end of the affinity string.
137031 */
137032 while( n>0 && zAff[0]==SQLITE_AFF_BLOB ){
 
137033 n--;
137034 base++;
137035 zAff++;
137036 }
137037 while( n>1 && zAff[n-1]==SQLITE_AFF_BLOB ){
137038 n--;
137039 }
137040
137041 /* Code the OP_Affinity opcode if there is anything left to do. */
137042 if( n>0 ){
@@ -137807,10 +138273,11 @@
137807 ** that contains the value of pExpr.
137808 */
137809 static int whereIndexExprTransNode(Walker *p, Expr *pExpr){
137810 IdxExprTrans *pX = p->u.pIdxTrans;
137811 if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
 
137812 pExpr->op = TK_COLUMN;
137813 pExpr->iTable = pX->iIdxCur;
137814 pExpr->iColumn = pX->iIdxCol;
137815 pExpr->y.pTab = 0;
137816 return WRC_Prune;
@@ -138239,36 +138706,16 @@
138239 char *zStartAff; /* Affinity for start of range constraint */
138240 char *zEndAff = 0; /* Affinity for end of range constraint */
138241 u8 bSeekPastNull = 0; /* True to seek past initial nulls */
138242 u8 bStopAtNull = 0; /* Add condition to terminate at NULLs */
138243 int omitTable; /* True if we use the index only */
138244
138245
138246 pIdx = pLoop->u.btree.pIndex;
138247 iIdxCur = pLevel->iIdxCur;
138248 assert( nEq>=pLoop->nSkip );
138249
138250 /* If this loop satisfies a sort order (pOrderBy) request that
138251 ** was passed to this function to implement a "SELECT min(x) ..."
138252 ** query, then the caller will only allow the loop to run for
138253 ** a single iteration. This means that the first row returned
138254 ** should not have a NULL value stored in 'x'. If column 'x' is
138255 ** the first one after the nEq equality constraints in the index,
138256 ** this requires some special handling.
138257 */
138258 assert( pWInfo->pOrderBy==0
138259 || pWInfo->pOrderBy->nExpr==1
138260 || (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0 );
138261 if( (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)!=0
138262 && pWInfo->nOBSat>0
138263 && (pIdx->nKeyCol>nEq)
138264 ){
138265 assert( pLoop->nSkip==0 );
138266 bSeekPastNull = 1;
138267 nExtraReg = 1;
138268 }
138269
138270 /* Find any inequality constraint terms for the start and end
138271 ** of the range.
138272 */
138273 j = nEq;
138274 if( pLoop->wsFlags & WHERE_BTM_LIMIT ){
@@ -138304,10 +138751,29 @@
138304 bSeekPastNull = 1;
138305 }
138306 }
138307 }
138308 assert( pRangeEnd==0 || (pRangeEnd->wtFlags & TERM_VNULL)==0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138309
138310 /* If we are doing a reverse order scan on an ascending index, or
138311 ** a forward order scan on a descending index, interchange the
138312 ** start and end terms (pRangeStart and pRangeEnd).
138313 */
@@ -138327,11 +138793,11 @@
138327 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
138328 assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );
138329 if( zStartAff && nTop ){
138330 zEndAff = sqlite3DbStrDup(db, &zStartAff[nEq]);
138331 }
138332 addrNxt = pLevel->addrNxt;
138333
138334 testcase( pRangeStart && (pRangeStart->eOperator & WO_LE)!=0 );
138335 testcase( pRangeStart && (pRangeStart->eOperator & WO_GE)!=0 );
138336 testcase( pRangeEnd && (pRangeEnd->eOperator & WO_LE)!=0 );
138337 testcase( pRangeEnd && (pRangeEnd->eOperator & WO_GE)!=0 );
@@ -138361,14 +138827,18 @@
138361 }else{
138362 startEq = 1;
138363 }
138364 bSeekPastNull = 0;
138365 }else if( bSeekPastNull ){
138366 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
138367 nConstraint++;
138368 startEq = 0;
 
 
 
 
 
138369 start_constraints = 1;
 
138370 }
138371 codeApplyAffinity(pParse, regBase, nConstraint - bSeekPastNull, zStartAff);
138372 if( pLoop->nSkip>0 && nConstraint==pLoop->nSkip ){
138373 /* The skip-scan logic inside the call to codeAllEqualityConstraints()
138374 ** above has already left the cursor sitting on the correct row,
@@ -138375,10 +138845,15 @@
138375 ** so no further seeking is needed */
138376 }else{
138377 if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
138378 sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur);
138379 }
 
 
 
 
 
138380 op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
138381 assert( op!=0 );
138382 sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
138383 VdbeCoverage(v);
138384 VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind );
@@ -138385,10 +138860,27 @@
138385 VdbeCoverageIf(v, op==OP_Last); testcase( op==OP_Last );
138386 VdbeCoverageIf(v, op==OP_SeekGT); testcase( op==OP_SeekGT );
138387 VdbeCoverageIf(v, op==OP_SeekGE); testcase( op==OP_SeekGE );
138388 VdbeCoverageIf(v, op==OP_SeekLE); testcase( op==OP_SeekLE );
138389 VdbeCoverageIf(v, op==OP_SeekLT); testcase( op==OP_SeekLT );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138390 }
138391
138392 /* Load the value for the inequality constraint at the end of the
138393 ** range (if any).
138394 */
@@ -138416,12 +138908,14 @@
138416 disableTerm(pLevel, pRangeEnd);
138417 }else{
138418 endEq = 1;
138419 }
138420 }else if( bStopAtNull ){
138421 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
138422 endEq = 0;
 
 
138423 nConstraint++;
138424 }
138425 sqlite3DbFree(db, zStartAff);
138426 sqlite3DbFree(db, zEndAff);
138427
@@ -138428,12 +138922,35 @@
138428 /* Top of the loop body */
138429 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
138430
138431 /* Check if the index cursor is past the end of the range. */
138432 if( nConstraint ){
 
 
 
 
 
 
138433 op = aEndOp[bRev*2 + endEq];
138434 sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138435 testcase( op==OP_IdxGT ); VdbeCoverageIf(v, op==OP_IdxGT );
138436 testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE );
138437 testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
138438 testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
138439 }
@@ -139061,11 +139578,11 @@
139061 if( p && ExprHasProperty(p, EP_Unlikely) ){
139062 pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;
139063 }else{
139064 pTerm->truthProb = 1;
139065 }
139066 pTerm->pExpr = sqlite3ExprSkipCollate(p);
139067 pTerm->wtFlags = wtFlags;
139068 pTerm->pWC = pWC;
139069 pTerm->iParent = -1;
139070 memset(&pTerm->eOperator, 0,
139071 sizeof(WhereTerm) - offsetof(WhereTerm,eOperator));
@@ -139094,26 +139611,34 @@
139094 ** that the collating sequence does not change. For example:
139095 ** "Y collate NOCASE op X" becomes "X op Y" because any collation sequence on
139096 ** the left hand side of a comparison overrides any collation sequence
139097 ** attached to the right. For the same reason the EP_Collate flag
139098 ** is not commuted.
 
 
 
 
 
139099 */
139100 static void exprCommute(Parse *pParse, Expr *pExpr){
139101 u16 expRight = (pExpr->pRight->flags & EP_Collate);
139102 u16 expLeft = (pExpr->pLeft->flags & EP_Collate);
 
139103 assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );
139104 if( expRight==expLeft ){
139105 /* Either X and Y both have COLLATE operator or neither do */
139106 if( expRight ){
139107 /* Both X and Y have COLLATE operators. Make sure X is always
139108 ** used by clearing the EP_Collate flag from Y. */
139109 pExpr->pRight->flags &= ~EP_Collate;
 
139110 }else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){
139111 /* Neither X nor Y have COLLATE operators, but X has a non-default
139112 ** collating sequence. So add the EP_Collate marker on X to cause
139113 ** it to be searched first. */
139114 pExpr->pLeft->flags |= EP_Collate;
 
139115 }
139116 }
139117 SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
139118 if( pExpr->op>=TK_GT ){
139119 assert( TK_LT==TK_GT+2 );
@@ -139121,10 +139646,11 @@
139121 assert( TK_GT>TK_EQ );
139122 assert( TK_GT<TK_LE );
139123 assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );
139124 pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;
139125 }
 
139126 }
139127
139128 /*
139129 ** Translate from TK_xx operator to WO_xx bitmask.
139130 */
@@ -140117,11 +140643,11 @@
140117 }
140118 }else{
140119 pDup = pExpr;
140120 pNew = pTerm;
140121 }
140122 exprCommute(pParse, pDup);
140123 pNew->leftCursor = aiCurCol[0];
140124 pNew->u.leftColumn = aiCurCol[1];
140125 testcase( (prereqLeft | extraRight) != prereqLeft );
140126 pNew->prereqRight = prereqLeft | extraRight;
140127 pNew->prereqAll = prereqAll;
@@ -140358,12 +140884,12 @@
140358 exprAnalyze(pSrc, pWC, idxNew);
140359 markTermAsChild(pWC, idxNew, idxTerm);
140360 }
140361 }
140362
140363 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
140364 /* When sqlite_stat3 histogram data is available an operator of the
140365 ** form "x IS NOT NULL" can sometimes be evaluated more efficiently
140366 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
140367 ** virtual term of that form.
140368 **
140369 ** Note that the virtual term must be tagged with TERM_VNULL.
@@ -140370,11 +140896,11 @@
140370 */
140371 if( pExpr->op==TK_NOTNULL
140372 && pExpr->pLeft->op==TK_COLUMN
140373 && pExpr->pLeft->iColumn>=0
140374 && !ExprHasProperty(pExpr, EP_FromJoin)
140375 && OptimizationEnabled(db, SQLITE_Stat34)
140376 ){
140377 Expr *pNewExpr;
140378 Expr *pLeft = pExpr->pLeft;
140379 int idxNew;
140380 WhereTerm *pNewTerm;
@@ -140395,11 +140921,11 @@
140395 pTerm = &pWC->a[idxTerm];
140396 pTerm->wtFlags |= TERM_COPIED;
140397 pNewTerm->prereqAll = pTerm->prereqAll;
140398 }
140399 }
140400 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
140401
140402 /* Prevent ON clause terms of a LEFT JOIN from being used to drive
140403 ** an index for tables to the left of the join.
140404 */
140405 testcase( pTerm!=&pWC->a[idxTerm] );
@@ -140428,11 +140954,11 @@
140428 ** In the previous sentence and in the diagram, "slot[]" refers to
140429 ** the WhereClause.a[] array. The slot[] array grows as needed to contain
140430 ** all terms of the WHERE clause.
140431 */
140432 SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause *pWC, Expr *pExpr, u8 op){
140433 Expr *pE2 = sqlite3ExprSkipCollate(pExpr);
140434 pWC->op = op;
140435 if( pE2==0 ) return;
140436 if( pE2->op!=op ){
140437 whereClauseInsert(pWC, pExpr, 0);
140438 }else{
@@ -140843,11 +141369,12 @@
140843 pScan->pIdxExpr,iCur)==0)
140844 && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
140845 ){
140846 if( (pTerm->eOperator & WO_EQUIV)!=0
140847 && pScan->nEquiv<ArraySize(pScan->aiCur)
140848 && (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN
 
140849 ){
140850 int j;
140851 for(j=0; j<pScan->nEquiv; j++){
140852 if( pScan->aiCur[j]==pX->iTable
140853 && pScan->aiColumn[j]==pX->iColumn ){
@@ -141039,11 +141566,11 @@
141039 ){
141040 int i;
141041 const char *zColl = pIdx->azColl[iCol];
141042
141043 for(i=0; i<pList->nExpr; i++){
141044 Expr *p = sqlite3ExprSkipCollate(pList->a[i].pExpr);
141045 if( p->op==TK_COLUMN
141046 && p->iColumn==pIdx->aiColumn[iCol]
141047 && p->iTable==iBase
141048 ){
141049 CollSeq *pColl = sqlite3ExprNNCollSeq(pParse, pList->a[i].pExpr);
@@ -141103,11 +141630,11 @@
141103 /* If any of the expressions is an IPK column on table iBase, then return
141104 ** true. Note: The (p->iTable==iBase) part of this test may be false if the
141105 ** current SELECT is a correlated sub-query.
141106 */
141107 for(i=0; i<pDistinct->nExpr; i++){
141108 Expr *p = sqlite3ExprSkipCollate(pDistinct->a[i].pExpr);
141109 if( p->op==TK_COLUMN && p->iTable==iBase && p->iColumn<0 ) return 1;
141110 }
141111
141112 /* Loop through all indices on the table, checking each to see if it makes
141113 ** the DISTINCT qualifier redundant. It does so if:
@@ -141523,10 +142050,11 @@
141523 if( pOrderBy ){
141524 int n = pOrderBy->nExpr;
141525 for(i=0; i<n; i++){
141526 Expr *pExpr = pOrderBy->a[i].pExpr;
141527 if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;
 
141528 }
141529 if( i==n){
141530 nOrderBy = n;
141531 }
141532 }
@@ -141621,11 +142149,11 @@
141621 j++;
141622 }
141623 for(i=0; i<nOrderBy; i++){
141624 Expr *pExpr = pOrderBy->a[i].pExpr;
141625 pIdxOrderBy[i].iColumn = pExpr->iColumn;
141626 pIdxOrderBy[i].desc = pOrderBy->a[i].sortOrder;
141627 }
141628
141629 *pmNoOmit = mNoOmit;
141630 return pIdxInfo;
141631 }
@@ -141667,11 +142195,11 @@
141667 pVtab->zErrMsg = 0;
141668 return rc;
141669 }
141670 #endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */
141671
141672 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
141673 /*
141674 ** Estimate the location of a particular key among all keys in an
141675 ** index. Store the results in aStat as follows:
141676 **
141677 ** aStat[0] Est. number of rows less than pRec
@@ -141860,11 +142388,11 @@
141860
141861 /* Restore the pRec->nField value before returning. */
141862 pRec->nField = nField;
141863 return i;
141864 }
141865 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
141866
141867 /*
141868 ** If it is not NULL, pTerm is a term that provides an upper or lower
141869 ** bound on a range scan. Without considering pTerm, it is estimated
141870 ** that the scan will visit nNew rows. This function returns the number
@@ -141886,25 +142414,26 @@
141886 }
141887 return nRet;
141888 }
141889
141890
141891 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
141892 /*
141893 ** Return the affinity for a single column of an index.
141894 */
141895 SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){
141896 assert( iCol>=0 && iCol<pIdx->nColumn );
141897 if( !pIdx->zColAff ){
141898 if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;
141899 }
 
141900 return pIdx->zColAff[iCol];
141901 }
141902 #endif
141903
141904
141905 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
141906 /*
141907 ** This function is called to estimate the number of rows visited by a
141908 ** range-scan on a skip-scan index. For example:
141909 **
141910 ** CREATE INDEX i1 ON t1(a, b, c);
@@ -142006,11 +142535,11 @@
142006 sqlite3ValueFree(p2);
142007 sqlite3ValueFree(pVal);
142008
142009 return rc;
142010 }
142011 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
142012
142013 /*
142014 ** This function is used to estimate the number of rows that will be visited
142015 ** by scanning an index for a range of values. The range may have an upper
142016 ** bound, a lower bound, or both. The WHERE clause terms that set the upper
@@ -142059,16 +142588,16 @@
142059 ){
142060 int rc = SQLITE_OK;
142061 int nOut = pLoop->nOut;
142062 LogEst nNew;
142063
142064 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
142065 Index *p = pLoop->u.btree.pIndex;
142066 int nEq = pLoop->u.btree.nEq;
142067
142068 if( p->nSample>0 && nEq<p->nSampleCol
142069 && OptimizationEnabled(pParse->db, SQLITE_Stat34)
142070 ){
142071 if( nEq==pBuilder->nRecValid ){
142072 UnpackedRecord *pRec = pBuilder->pRec;
142073 tRowcnt a[2];
142074 int nBtm = pLoop->u.btree.nBtm;
@@ -142162,11 +142691,11 @@
142162 if( iUpper>iLower ){
142163 nNew = sqlite3LogEst(iUpper - iLower);
142164 /* TUNING: If both iUpper and iLower are derived from the same
142165 ** sample, then assume they are 4x more selective. This brings
142166 ** the estimated selectivity more in line with what it would be
142167 ** if estimated without the use of STAT3/4 tables. */
142168 if( iLwrIdx==iUprIdx ) nNew -= 20; assert( 20==sqlite3LogEst(4) );
142169 }else{
142170 nNew = 10; assert( 10==sqlite3LogEst(2) );
142171 }
142172 if( nNew<nOut ){
@@ -142211,16 +142740,16 @@
142211 #endif
142212 pLoop->nOut = (LogEst)nOut;
142213 return rc;
142214 }
142215
142216 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
142217 /*
142218 ** Estimate the number of rows that will be returned based on
142219 ** an equality constraint x=VALUE and where that VALUE occurs in
142220 ** the histogram data. This only works when x is the left-most
142221 ** column of an index and sqlite_stat3 histogram data is available
142222 ** for that index. When pExpr==NULL that means the constraint is
142223 ** "x IS NULL" instead of "x=VALUE".
142224 **
142225 ** Write the estimated row count into *pnRow and return SQLITE_OK.
142226 ** If unable to make an estimate, leave *pnRow unchanged and return
@@ -142274,13 +142803,13 @@
142274 p->zName, nEq-1, (int)a[1]));
142275 *pnRow = a[1];
142276
142277 return rc;
142278 }
142279 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
142280
142281 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
142282 /*
142283 ** Estimate the number of rows that will be returned based on
142284 ** an IN constraint where the right-hand side of the IN operator
142285 ** is a list of values. Example:
142286 **
@@ -142323,11 +142852,11 @@
142323 WHERETRACE(0x10,("IN row estimate: est=%d\n", nRowEst));
142324 }
142325 assert( pBuilder->nRecValid==nRecValid );
142326 return rc;
142327 }
142328 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
142329
142330
142331 #ifdef WHERETRACE_ENABLED
142332 /*
142333 ** Print the content of a WhereTerm object
@@ -142860,10 +143389,11 @@
142860 int i, j, k;
142861 LogEst iReduce = 0; /* pLoop->nOut should not exceed nRow-iReduce */
142862
142863 assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
142864 for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){
 
142865 if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
142866 if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
142867 if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
142868 for(j=pLoop->nLTerm-1; j>=0; j--){
142869 pX = pLoop->aLTerm[j];
@@ -143043,11 +143573,11 @@
143043 for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
143044 u16 eOp = pTerm->eOperator; /* Shorthand for pTerm->eOperator */
143045 LogEst rCostIdx;
143046 LogEst nOutUnadjusted; /* nOut before IN() and WHERE adjustments */
143047 int nIn = 0;
143048 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
143049 int nRecValid = pBuilder->nRecValid;
143050 #endif
143051 if( (eOp==WO_ISNULL || (pTerm->wtFlags&TERM_VNULL)!=0)
143052 && indexColumnNotNull(pProbe, saved_nEq)
143053 ){
@@ -143104,12 +143634,10 @@
143104 if( pNew->aLTerm[i] && pNew->aLTerm[i]->pExpr==pExpr ) nIn = 0;
143105 }
143106 }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
143107 /* "x IN (value, value, ...)" */
143108 nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
143109 assert( nIn>0 ); /* RHS always has 2 or more terms... The parser
143110 ** changes "x IN (?)" into "x=?". */
143111 }
143112 if( pProbe->hasStat1 ){
143113 LogEst M, logK, safetyMargin;
143114 /* Let:
143115 ** N = the total number of rows in the table
@@ -143201,11 +143729,11 @@
143201 ** values of nIn and nInMul. In other words, assuming that all
143202 ** "x IN(...)" terms are replaced with "x = ?". This block updates
143203 ** the value of pNew->nOut to account for pTerm (but not nIn/nInMul). */
143204 assert( pNew->nOut==saved_nOut );
143205 if( pNew->wsFlags & WHERE_COLUMN_RANGE ){
143206 /* Adjust nOut using stat3/stat4 data. Or, if there is no stat3/stat4
143207 ** data, using some other estimate. */
143208 whereRangeScanEst(pParse, pBuilder, pBtm, pTop, pNew);
143209 }else{
143210 int nEq = ++pNew->u.btree.nEq;
143211 assert( eOp & (WO_ISNULL|WO_EQ|WO_IN|WO_IS) );
@@ -143215,17 +143743,17 @@
143215 assert( (eOp & WO_IN) || nIn==0 );
143216 testcase( eOp & WO_IN );
143217 pNew->nOut += pTerm->truthProb;
143218 pNew->nOut -= nIn;
143219 }else{
143220 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
143221 tRowcnt nOut = 0;
143222 if( nInMul==0
143223 && pProbe->nSample
143224 && pNew->u.btree.nEq<=pProbe->nSampleCol
143225 && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))
143226 && OptimizationEnabled(db, SQLITE_Stat34)
143227 ){
143228 Expr *pExpr = pTerm->pExpr;
143229 if( (eOp & (WO_EQ|WO_ISNULL|WO_IS))!=0 ){
143230 testcase( eOp & WO_EQ );
143231 testcase( eOp & WO_IS );
@@ -143258,10 +143786,11 @@
143258
143259 /* Set rCostIdx to the cost of visiting selected rows in index. Add
143260 ** it to pNew->rRun, which is currently set to the cost of the index
143261 ** seek only. Then, if this is a non-covering index, add the cost of
143262 ** visiting the rows in the main table. */
 
143263 rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow;
143264 pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx);
143265 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
143266 pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16);
143267 }
@@ -143283,11 +143812,11 @@
143283 && pNew->u.btree.nEq<pProbe->nColumn
143284 ){
143285 whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
143286 }
143287 pNew->nOut = saved_nOut;
143288 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
143289 pBuilder->nRecValid = nRecValid;
143290 #endif
143291 }
143292 pNew->prereq = saved_prereq;
143293 pNew->u.btree.nEq = saved_nEq;
@@ -143356,11 +143885,11 @@
143356 int ii, jj;
143357
143358 if( pIndex->bUnordered ) return 0;
143359 if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0;
143360 for(ii=0; ii<pOB->nExpr; ii++){
143361 Expr *pExpr = sqlite3ExprSkipCollate(pOB->a[ii].pExpr);
143362 if( pExpr->op==TK_COLUMN && pExpr->iTable==iCursor ){
143363 if( pExpr->iColumn<0 ) return 1;
143364 for(jj=0; jj<pIndex->nKeyCol; jj++){
143365 if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
143366 }
@@ -143387,11 +143916,13 @@
143387 if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;
143388 pWhere = pWhere->pRight;
143389 }
143390 if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
143391 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
143392 Expr *pExpr = pTerm->pExpr;
 
 
143393 if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
143394 && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
143395 ){
143396 return 1;
143397 }
@@ -143656,11 +144187,11 @@
143656 ** unique index is used (making the index functionally non-unique)
143657 ** then the sqlite_stat1 data becomes important for scoring the
143658 ** plan */
143659 pTab->tabFlags |= TF_StatsUsed;
143660 }
143661 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
143662 sqlite3Stat4ProbeFree(pBuilder->pRec);
143663 pBuilder->nRecValid = 0;
143664 pBuilder->pRec = 0;
143665 #endif
143666 }
@@ -144284,12 +144815,12 @@
144284 pLoop = pLast;
144285 }
144286 if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
144287 if( pLoop->u.vtab.isOrdered ) obSat = obDone;
144288 break;
144289 }else{
144290 pLoop->u.btree.nIdxCol = 0;
144291 }
144292 iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
144293
144294 /* Mark off any ORDER BY term X that is a column in the table of
144295 ** the current loop for which there is term in the WHERE
@@ -144296,11 +144827,11 @@
144296 ** clause of the form X IS NULL or X=? that reference only outer
144297 ** loops.
144298 */
144299 for(i=0; i<nOrderBy; i++){
144300 if( MASKBIT(i) & obSat ) continue;
144301 pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
144302 if( pOBExpr->op!=TK_COLUMN ) continue;
144303 if( pOBExpr->iTable!=iCur ) continue;
144304 pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
144305 ~ready, eqOpMask, 0);
144306 if( pTerm==0 ) continue;
@@ -144333,11 +144864,12 @@
144333 nKeyCol = pIndex->nKeyCol;
144334 nColumn = pIndex->nColumn;
144335 assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) );
144336 assert( pIndex->aiColumn[nColumn-1]==XN_ROWID
144337 || !HasRowid(pIndex->pTable));
144338 isOrderDistinct = IsUniqueIndex(pIndex);
 
144339 }
144340
144341 /* Loop through all columns of the index and deal with the ones
144342 ** that are not constrained by == or IN.
144343 */
@@ -144351,19 +144883,25 @@
144351 );
144352 if( j<pLoop->u.btree.nEq && j>=pLoop->nSkip ){
144353 u16 eOp = pLoop->aLTerm[j]->eOperator;
144354
144355 /* Skip over == and IS and ISNULL terms. (Also skip IN terms when
144356 ** doing WHERE_ORDERBY_LIMIT processing).
 
 
 
144357 **
144358 ** If the current term is a column of an ((?,?) IN (SELECT...))
144359 ** expression for which the SELECT returns more than one column,
144360 ** check that it is the only column used by this loop. Otherwise,
144361 ** if it is one of two or more, none of the columns can be
144362 ** considered to match an ORDER BY term. */
 
144363 if( (eOp & eqOpMask)!=0 ){
144364 if( eOp & WO_ISNULL ){
 
 
144365 testcase( isOrderDistinct );
144366 isOrderDistinct = 0;
144367 }
144368 continue;
144369 }else if( ALWAYS(eOp & WO_IN) ){
@@ -144385,11 +144923,11 @@
144385 /* Get the column number in the table (iColumn) and sort order
144386 ** (revIdx) for the j-th column of the index.
144387 */
144388 if( pIndex ){
144389 iColumn = pIndex->aiColumn[j];
144390 revIdx = pIndex->aSortOrder[j];
144391 if( iColumn==pIndex->pTable->iPKey ) iColumn = XN_ROWID;
144392 }else{
144393 iColumn = XN_ROWID;
144394 revIdx = 0;
144395 }
@@ -144409,11 +144947,11 @@
144409 ** of the index and mark that ORDER BY term off
144410 */
144411 isMatch = 0;
144412 for(i=0; bOnce && i<nOrderBy; i++){
144413 if( MASKBIT(i) & obSat ) continue;
144414 pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
144415 testcase( wctrlFlags & WHERE_GROUPBY );
144416 testcase( wctrlFlags & WHERE_DISTINCTBY );
144417 if( (wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY))==0 ) bOnce = 0;
144418 if( iColumn>=XN_ROWID ){
144419 if( pOBExpr->op!=TK_COLUMN ) continue;
@@ -144427,24 +144965,35 @@
144427 }
144428 if( iColumn!=XN_ROWID ){
144429 pColl = sqlite3ExprNNCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
144430 if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ) continue;
144431 }
144432 pLoop->u.btree.nIdxCol = j+1;
 
 
144433 isMatch = 1;
144434 break;
144435 }
144436 if( isMatch && (wctrlFlags & WHERE_GROUPBY)==0 ){
144437 /* Make sure the sort order is compatible in an ORDER BY clause.
144438 ** Sort order is irrelevant for a GROUP BY clause. */
144439 if( revSet ){
144440 if( (rev ^ revIdx)!=pOrderBy->a[i].sortOrder ) isMatch = 0;
 
 
144441 }else{
144442 rev = revIdx ^ pOrderBy->a[i].sortOrder;
144443 if( rev ) *pRevMask |= MASKBIT(iLoop);
144444 revSet = 1;
144445 }
 
 
 
 
 
 
 
144446 }
144447 if( isMatch ){
144448 if( iColumn==XN_ROWID ){
144449 testcase( distinctColumns==0 );
144450 distinctColumns = 1;
@@ -145355,10 +145904,20 @@
145355 sqlite3DebugPrintf("*** Optimizer Start *** (wctrlFlags: 0x%x",wctrlFlags);
145356 if( wctrlFlags & WHERE_USE_LIMIT ){
145357 sqlite3DebugPrintf(", limit: %d", iAuxArg);
145358 }
145359 sqlite3DebugPrintf(")\n");
 
 
 
 
 
 
 
 
 
 
145360 }
145361 if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
145362 sqlite3WhereClausePrint(sWLB.pWC);
145363 }
145364 #endif
@@ -145631,10 +146190,11 @@
145631 if( op ){
145632 sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);
145633 sqlite3VdbeSetP4KeyInfo(pParse, pIx);
145634 if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0
145635 && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0
 
145636 && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0
145637 && pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED
145638 ){
145639 sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */
145640 }
@@ -145748,11 +146308,11 @@
145748 int n;
145749 if( pWInfo->eDistinct==WHERE_DISTINCT_ORDERED
145750 && i==pWInfo->nLevel-1 /* Ticket [ef9318757b152e3] 2017-10-21 */
145751 && (pLoop->wsFlags & WHERE_INDEXED)!=0
145752 && (pIdx = pLoop->u.btree.pIndex)->hasStat1
145753 && (n = pLoop->u.btree.nIdxCol)>0
145754 && pIdx->aiRowLogEst[n]>=36
145755 ){
145756 int r1 = pParse->nMem+1;
145757 int j, op;
145758 for(j=0; j<n; j++){
@@ -145772,10 +146332,15 @@
145772 sqlite3VdbeChangeP5(v, pLevel->p5);
145773 VdbeCoverage(v);
145774 VdbeCoverageIf(v, pLevel->op==OP_Next);
145775 VdbeCoverageIf(v, pLevel->op==OP_Prev);
145776 VdbeCoverageIf(v, pLevel->op==OP_VNext);
 
 
 
 
 
145777 #ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT
145778 if( addrSeek ) sqlite3VdbeJumpHere(v, addrSeek);
145779 #endif
145780 }else{
145781 sqlite3VdbeResolveLabel(v, pLevel->addrCont);
@@ -146711,10 +147276,12 @@
146711 ** expression (*ppExpr) in place.
146712 */
146713 static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){
146714 struct WindowRewrite *p = pWalker->u.pRewrite;
146715 Parse *pParse = pWalker->pParse;
 
 
146716
146717 /* If this function is being called from within a scalar sub-select
146718 ** that used by the SELECT statement being processed, only process
146719 ** TK_COLUMN expressions that refer to it (the outer SELECT). Do
146720 ** not process aggregates or window functions at all, as they belong
@@ -146810,10 +147377,11 @@
146810 ExprList **ppSub /* IN/OUT: Sub-select expression-list */
146811 ){
146812 Walker sWalker;
146813 WindowRewrite sRewrite;
146814
 
146815 memset(&sWalker, 0, sizeof(Walker));
146816 memset(&sRewrite, 0, sizeof(WindowRewrite));
146817
146818 sRewrite.pSub = *ppSub;
146819 sRewrite.pWin = pWin;
@@ -146848,11 +147416,11 @@
146848 if( bIntToNull && pDup && pDup->op==TK_INTEGER ){
146849 pDup->op = TK_NULL;
146850 pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
146851 }
146852 pList = sqlite3ExprListAppend(pParse, pList, pDup);
146853 if( pList ) pList->a[nInit+i].sortOrder = pAppend->a[i].sortOrder;
146854 }
146855 }
146856 return pList;
146857 }
146858
@@ -146894,15 +147462,18 @@
146894 /* Create the ORDER BY clause for the sub-select. This is the concatenation
146895 ** of the window PARTITION and ORDER BY clauses. Then, if this makes it
146896 ** redundant, remove the ORDER BY from the parent SELECT. */
146897 pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);
146898 pSort = exprListAppendList(pParse, pSort, pMWin->pOrderBy, 1);
146899 if( pSort && p->pOrderBy ){
 
 
146900 if( sqlite3ExprListCompare(pSort, p->pOrderBy, -1)==0 ){
146901 sqlite3ExprListDelete(db, p->pOrderBy);
146902 p->pOrderBy = 0;
146903 }
 
146904 }
146905
146906 /* Assign a cursor number for the ephemeral table used to buffer rows.
146907 ** The OpenEphemeral instruction is coded later, after it is known how
146908 ** many columns the table will have. */
@@ -146954,11 +147525,11 @@
146954 if( p->pSrc ){
146955 Table *pTab2;
146956 p->pSrc->a[0].pSelect = pSub;
146957 sqlite3SrcListAssignCursors(pParse, p->pSrc);
146958 pSub->selFlags |= SF_Expanded;
146959 pTab2 = sqlite3ResultSetOfSelect(pParse, pSub);
146960 if( pTab2==0 ){
146961 rc = SQLITE_NOMEM;
146962 }else{
146963 memcpy(pTab, pTab2, sizeof(Table));
146964 pTab->tabFlags |= TF_Ephemeral;
@@ -146976,16 +147547,29 @@
146976 sqlite3DbFree(db, pTab);
146977 }
146978
146979 return rc;
146980 }
 
 
 
 
 
 
 
 
 
 
 
 
146981
146982 /*
146983 ** Free the Window object passed as the second argument.
146984 */
146985 SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3 *db, Window *p){
146986 if( p ){
 
146987 sqlite3ExprDelete(db, p->pFilter);
146988 sqlite3ExprListDelete(db, p->pPartition);
146989 sqlite3ExprListDelete(db, p->pOrderBy);
146990 sqlite3ExprDelete(db, p->pEnd);
146991 sqlite3ExprDelete(db, p->pStart);
@@ -147159,40 +147743,59 @@
147159 ** Attach window object pWin to expression p.
147160 */
147161 SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
147162 if( p ){
147163 assert( p->op==TK_FUNCTION );
147164 /* This routine is only called for the parser. If pWin was not
147165 ** allocated due to an OOM, then the parser would fail before ever
147166 ** invoking this routine */
147167 if( ALWAYS(pWin) ){
147168 p->y.pWin = pWin;
147169 ExprSetProperty(p, EP_WinFunc);
147170 pWin->pOwner = p;
147171 if( p->flags & EP_Distinct ){
147172 sqlite3ErrorMsg(pParse,
147173 "DISTINCT is not supported for window functions");
147174 }
147175 }
147176 }else{
147177 sqlite3WindowDelete(pParse->db, pWin);
147178 }
147179 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147180
147181 /*
147182 ** Return 0 if the two window objects are identical, or non-zero otherwise.
147183 ** Identical window objects can be processed in a single scan.
147184 */
147185 SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2){
147186 if( p1->eFrmType!=p2->eFrmType ) return 1;
147187 if( p1->eStart!=p2->eStart ) return 1;
147188 if( p1->eEnd!=p2->eEnd ) return 1;
147189 if( p1->eExclude!=p2->eExclude ) return 1;
147190 if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
147191 if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1;
147192 if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1;
147193 if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1;
 
 
 
147194 return 0;
147195 }
147196
147197
147198 /*
@@ -147240,12 +147843,12 @@
147240 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0);
147241 pWin->csrApp = pParse->nTab++;
147242 pWin->regApp = pParse->nMem+1;
147243 pParse->nMem += 3;
147244 if( pKeyInfo && pWin->pFunc->zName[1]=='i' ){
147245 assert( pKeyInfo->aSortOrder[0]==0 );
147246 pKeyInfo->aSortOrder[0] = 1;
147247 }
147248 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2);
147249 sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);
147250 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
147251 }
@@ -147360,10 +147963,12 @@
147360 FuncDef *pFunc = pWin->pFunc;
147361 int regArg;
147362 int nArg = windowArgCount(pWin);
147363 int i;
147364
 
 
147365 for(i=0; i<nArg; i++){
147366 if( i!=1 || pFunc->zName!=nth_valueName ){
147367 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
147368 }else{
147369 sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+i, reg+i);
@@ -147422,23 +148027,82 @@
147422 }
147423 }
147424
147425 typedef struct WindowCodeArg WindowCodeArg;
147426 typedef struct WindowCsrAndReg WindowCsrAndReg;
 
 
 
 
147427 struct WindowCsrAndReg {
147428 int csr;
147429 int reg;
147430 };
147431
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147432 struct WindowCodeArg {
147433 Parse *pParse;
147434 Window *pMWin;
147435 Vdbe *pVdbe;
147436 int regGosub;
147437 int addrGosub;
147438 int regArg;
147439 int eDelete;
147440
147441 WindowCsrAndReg start;
147442 WindowCsrAndReg current;
147443 WindowCsrAndReg end;
147444 };
@@ -147530,12 +148194,14 @@
147530
147531 int nPeer;
147532 int lblNext;
147533 int lblBrk;
147534 int addrNext;
147535 int csr = pMWin->csrApp;
147536
 
 
147537 nPeer = (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
147538
147539 lblNext = sqlite3VdbeMakeLabel(pParse);
147540 lblBrk = sqlite3VdbeMakeLabel(pParse);
147541
@@ -147775,67 +148441,147 @@
147775 }
147776
147777 /*
147778 ** This function is called as part of generating VM programs for RANGE
147779 ** offset PRECEDING/FOLLOWING frame boundaries. Assuming "ASC" order for
147780 ** the ORDER BY term in the window, it generates code equivalent to:
 
147781 **
147782 ** if( csr1.peerVal + regVal >= csr2.peerVal ) goto lbl;
147783 **
147784 ** A special type of arithmetic is used such that if csr.peerVal is not
147785 ** a numeric type (real or integer), then the result of the addition is
147786 ** a copy of csr1.peerVal.
 
 
 
 
 
 
 
 
 
 
 
147787 */
147788 static void windowCodeRangeTest(
147789 WindowCodeArg *p,
147790 int op, /* OP_Ge or OP_Gt */
147791 int csr1,
147792 int regVal,
147793 int csr2,
147794 int lbl
147795 ){
147796 Parse *pParse = p->pParse;
147797 Vdbe *v = sqlite3GetVdbe(pParse);
147798 int reg1 = sqlite3GetTempReg(pParse);
147799 int reg2 = sqlite3GetTempReg(pParse);
147800 int arith = OP_Add;
147801 int addrGe;
147802
147803 int regString = ++pParse->nMem;
147804
147805 assert( op==OP_Ge || op==OP_Gt || op==OP_Le );
147806 assert( p->pMWin->pOrderBy && p->pMWin->pOrderBy->nExpr==1 );
147807 if( p->pMWin->pOrderBy->a[0].sortOrder ){
147808 switch( op ){
147809 case OP_Ge: op = OP_Le; break;
147810 case OP_Gt: op = OP_Lt; break;
147811 default: assert( op==OP_Le ); op = OP_Ge; break;
147812 }
147813 arith = OP_Subtract;
147814 }
147815
 
147816 windowReadPeerValues(p, csr1, reg1);
147817 windowReadPeerValues(p, csr2, reg2);
147818
147819 /* Check if the peer value for csr1 value is a text or blob by comparing
147820 ** it to the smallest possible string - ''. If it is, jump over the
147821 ** OP_Add or OP_Subtract operation and proceed directly to the comparison. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147822 sqlite3VdbeAddOp4(v, OP_String8, 0, regString, 0, "", P4_STATIC);
147823 addrGe = sqlite3VdbeAddOp3(v, OP_Ge, regString, 0, reg1);
147824 VdbeCoverage(v);
147825 sqlite3VdbeAddOp3(v, arith, regVal, reg1, reg1);
147826 sqlite3VdbeJumpHere(v, addrGe);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147827 sqlite3VdbeAddOp3(v, op, reg2, lbl, reg1); VdbeCoverage(v);
147828 sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
 
147829 assert( op==OP_Ge || op==OP_Gt || op==OP_Lt || op==OP_Le );
147830 testcase(op==OP_Ge); VdbeCoverageIf(v, op==OP_Ge);
147831 testcase(op==OP_Lt); VdbeCoverageIf(v, op==OP_Lt);
147832 testcase(op==OP_Le); VdbeCoverageIf(v, op==OP_Le);
147833 testcase(op==OP_Gt); VdbeCoverageIf(v, op==OP_Gt);
147834
147835 sqlite3ReleaseTempReg(pParse, reg1);
147836 sqlite3ReleaseTempReg(pParse, reg2);
 
 
147837 }
147838
147839 /*
147840 ** Helper function for sqlite3WindowCodeStep(). Each call to this function
147841 ** generates VM code for a single RETURN_ROW, AGGSTEP or AGGINVERSE
@@ -147980,10 +148726,11 @@
147980 pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
147981 pNew->eFrmType = p->eFrmType;
147982 pNew->eEnd = p->eEnd;
147983 pNew->eStart = p->eStart;
147984 pNew->eExclude = p->eExclude;
 
147985 pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);
147986 pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);
147987 pNew->pOwner = pOwner;
147988 }
147989 }
@@ -148786,10 +149533,11 @@
148786 ** For a compound SELECT statement, make sure p->pPrior->pNext==p for
148787 ** all elements in the list. And make sure list length does not exceed
148788 ** SQLITE_LIMIT_COMPOUND_SELECT.
148789 */
148790 static void parserDoubleLinkSelect(Parse *pParse, Select *p){
 
148791 if( p->pPrior ){
148792 Select *pNext = 0, *pLoop;
148793 int mxSelect, cnt = 0;
148794 for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){
148795 pLoop->pNext = pNext;
@@ -148812,11 +149560,11 @@
148812 static Expr *tokenExpr(Parse *pParse, int op, Token t){
148813 Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);
148814 if( p ){
148815 /* memset(p, 0, sizeof(Expr)); */
148816 p->op = (u8)op;
148817 p->affinity = 0;
148818 p->flags = EP_Leaf;
148819 p->iAgg = -1;
148820 p->pLeft = p->pRight = 0;
148821 p->x.pList = 0;
148822 p->pAggInfo = 0;
@@ -148939,32 +149687,32 @@
148939 #ifndef INTERFACE
148940 # define INTERFACE 1
148941 #endif
148942 /************* Begin control #defines *****************************************/
148943 #define YYCODETYPE unsigned short int
148944 #define YYNOCODE 302
148945 #define YYACTIONTYPE unsigned short int
148946 #define YYWILDCARD 95
148947 #define sqlite3ParserTOKENTYPE Token
148948 typedef union {
148949 int yyinit;
148950 sqlite3ParserTOKENTYPE yy0;
148951 TriggerStep* yy11;
148952 IdList* yy76;
148953 ExprList* yy94;
148954 Upsert* yy95;
148955 int yy100;
148956 Expr* yy102;
148957 struct {int value; int mask;} yy199;
148958 u8 yy218;
148959 With* yy243;
148960 struct TrigEvent yy298;
148961 Window* yy379;
148962 struct FrameBound yy389;
148963 Select* yy391;
148964 SrcList* yy407;
148965 const char* yy528;
148966 } YYMINORTYPE;
148967 #ifndef YYSTACKDEPTH
148968 #define YYSTACKDEPTH 100
148969 #endif
148970 #define sqlite3ParserARG_SDECL
@@ -148976,21 +149724,21 @@
148976 #define sqlite3ParserCTX_PDECL ,Parse *pParse
148977 #define sqlite3ParserCTX_PARAM ,pParse
148978 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
148979 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
148980 #define YYFALLBACK 1
148981 #define YYNSTATE 540
148982 #define YYNRULE 376
148983 #define YYNTOKEN 176
148984 #define YY_MAX_SHIFT 539
148985 #define YY_MIN_SHIFTREDUCE 783
148986 #define YY_MAX_SHIFTREDUCE 1158
148987 #define YY_ERROR_ACTION 1159
148988 #define YY_ACCEPT_ACTION 1160
148989 #define YY_NO_ACTION 1161
148990 #define YY_MIN_REDUCE 1162
148991 #define YY_MAX_REDUCE 1537
148992 /************* End control #defines *******************************************/
148993 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
148994
148995 /* Define the yytestcase() macro to be a no-op if is not already defined
148996 ** otherwise.
@@ -149053,605 +149801,577 @@
149053 ** yy_reduce_ofst[] For each state, the offset into yy_action for
149054 ** shifting non-terminals after a reduce.
149055 ** yy_default[] Default action for each state.
149056 **
149057 *********** Begin parsing tables **********************************************/
149058 #define YY_ACTTAB_COUNT (2142)
149059 static const YYACTIONTYPE yy_action[] = {
149060 /* 0 */ 112, 109, 209, 112, 109, 209, 1160, 1, 1, 539,
149061 /* 10 */ 2, 1164, 490, 1193, 1293, 534, 289, 1196, 134, 383,
149062 /* 20 */ 1485, 1428, 1164, 1229, 1208, 1242, 1195, 289, 491, 134,
149063 /* 30 */ 373, 915, 1229, 443, 16, 16, 1242, 70, 70, 916,
149064 /* 40 */ 242, 1292, 296, 119, 120, 110, 1136, 1136, 981, 984,
149065 /* 50 */ 974, 974, 117, 117, 118, 118, 118, 118, 264, 264,
149066 /* 60 */ 190, 264, 264, 264, 264, 112, 109, 209, 362, 264,
149067 /* 70 */ 264, 531, 376, 497, 531, 1134, 531, 1501, 239, 206,
149068 /* 80 */ 338, 9, 531, 242, 219, 1203, 118, 118, 118, 118,
149069 /* 90 */ 111, 439, 112, 109, 209, 219, 116, 116, 116, 116,
149070 /* 100 */ 115, 115, 114, 114, 114, 113, 414, 115, 115, 114,
149071 /* 110 */ 114, 114, 113, 414, 418, 12, 383, 400, 1134, 114,
149072 /* 120 */ 114, 114, 113, 414, 1115, 418, 1134, 1392, 116, 116,
149073 /* 130 */ 116, 116, 115, 115, 114, 114, 114, 113, 414, 961,
149074 /* 140 */ 119, 120, 110, 1136, 1136, 981, 984, 974, 974, 117,
149075 /* 150 */ 117, 118, 118, 118, 118, 952, 534, 414, 941, 951,
149076 /* 160 */ 1481, 539, 2, 1164, 1505, 534, 160, 175, 289, 1134,
149077 /* 170 */ 134, 434, 312, 297, 1115, 1116, 1117, 1242, 70, 70,
149078 /* 180 */ 1089, 338, 1089, 118, 118, 118, 118, 42, 42, 448,
149079 /* 190 */ 951, 951, 953, 116, 116, 116, 116, 115, 115, 114,
149080 /* 200 */ 114, 114, 113, 414, 1115, 311, 264, 264, 82, 441,
149081 /* 210 */ 264, 264, 190, 383, 284, 12, 288, 525, 407, 531,
149082 /* 220 */ 96, 159, 458, 531, 371, 116, 116, 116, 116, 115,
149083 /* 230 */ 115, 114, 114, 114, 113, 414, 219, 119, 120, 110,
149084 /* 240 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
149085 /* 250 */ 118, 118, 511, 1477, 1115, 1116, 1117, 113, 414, 534,
149086 /* 260 */ 528, 528, 528, 121, 534, 1427, 418, 116, 116, 116,
149087 /* 270 */ 116, 115, 115, 114, 114, 114, 113, 414, 1464, 351,
149088 /* 280 */ 270, 42, 42, 383, 187, 1115, 70, 70, 533, 433,
149089 /* 290 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
149090 /* 300 */ 414, 534, 1339, 405, 159, 411, 410, 119, 120, 110,
149091 /* 310 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
149092 /* 320 */ 118, 118, 285, 42, 42, 349, 411, 410, 514, 479,
149093 /* 330 */ 1458, 79, 1084, 6, 1140, 1115, 1116, 1117, 480, 1142,
149094 /* 340 */ 501, 1115, 1084, 123, 238, 1084, 136, 1141, 1234, 1234,
149095 /* 350 */ 1143, 383, 1143, 1115, 167, 426, 80, 447, 512, 1451,
149096 /* 360 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
149097 /* 370 */ 414, 1143, 1466, 1143, 350, 119, 120, 110, 1136, 1136,
149098 /* 380 */ 981, 984, 974, 974, 117, 117, 118, 118, 118, 118,
149099 /* 390 */ 402, 1115, 1116, 1117, 500, 534, 250, 267, 336, 474,
149100 /* 400 */ 331, 473, 236, 1115, 1116, 1117, 231, 1115, 329, 471,
149101 /* 410 */ 468, 467, 509, 1458, 1464, 505, 6, 70, 70, 466,
149102 /* 420 */ 181, 380, 379, 534, 971, 971, 982, 985, 116, 116,
149103 /* 430 */ 116, 116, 115, 115, 114, 114, 114, 113, 414, 1115,
149104 /* 440 */ 412, 412, 412, 496, 1115, 69, 69, 235, 383, 288,
149105 /* 450 */ 525, 273, 326, 516, 337, 458, 1084, 1115, 1116, 1117,
149106 /* 460 */ 1232, 1232, 492, 160, 508, 441, 1084, 1067, 1531, 1084,
149107 /* 470 */ 207, 1531, 119, 120, 110, 1136, 1136, 981, 984, 974,
149108 /* 480 */ 974, 117, 117, 118, 118, 118, 118, 881, 534, 1115,
149109 /* 490 */ 1116, 1117, 975, 534, 1115, 1116, 1117, 534, 421, 534,
149110 /* 500 */ 141, 534, 176, 356, 517, 1119, 32, 511, 482, 388,
149111 /* 510 */ 70, 70, 818, 288, 525, 70, 70, 441, 499, 50,
149112 /* 520 */ 50, 70, 70, 70, 70, 116, 116, 116, 116, 115,
149113 /* 530 */ 115, 114, 114, 114, 113, 414, 274, 264, 264, 1115,
149114 /* 540 */ 1065, 264, 264, 1115, 355, 383, 409, 961, 1439, 822,
149115 /* 550 */ 531, 516, 190, 419, 531, 483, 1119, 516, 337, 516,
149116 /* 560 */ 518, 1115, 818, 952, 382, 458, 515, 951, 481, 119,
149117 /* 570 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
149118 /* 580 */ 118, 118, 118, 118, 1338, 278, 1045, 278, 275, 1115,
149119 /* 590 */ 1116, 1117, 259, 1115, 1116, 1117, 534, 5, 951, 951,
149120 /* 600 */ 953, 1046, 231, 3, 143, 471, 468, 467, 1391, 463,
149121 /* 610 */ 1115, 1115, 1116, 1117, 1452, 466, 1047, 836, 70, 70,
149122 /* 620 */ 480, 534, 116, 116, 116, 116, 115, 115, 114, 114,
149123 /* 630 */ 114, 113, 414, 95, 1115, 287, 235, 856, 902, 420,
149124 /* 640 */ 1115, 534, 383, 13, 13, 381, 815, 857, 472, 112,
149125 /* 650 */ 109, 209, 1115, 337, 413, 309, 837, 394, 1436, 534,
149126 /* 660 */ 1115, 1116, 1117, 54, 54, 291, 119, 120, 110, 1136,
149127 /* 670 */ 1136, 981, 984, 974, 974, 117, 117, 118, 118, 118,
149128 /* 680 */ 118, 13, 13, 1084, 1115, 1116, 1117, 901, 264, 264,
149129 /* 690 */ 1115, 1116, 1117, 1084, 292, 399, 1084, 800, 388, 140,
149130 /* 700 */ 295, 531, 1115, 1116, 1117, 403, 447, 532, 534, 870,
149131 /* 710 */ 870, 534, 1240, 534, 329, 534, 1185, 389, 534, 116,
149132 /* 720 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 414,
149133 /* 730 */ 13, 13, 1024, 13, 13, 13, 13, 13, 13, 383,
149134 /* 740 */ 13, 13, 424, 1100, 401, 264, 264, 277, 160, 184,
149135 /* 750 */ 1182, 185, 1533, 369, 513, 484, 432, 487, 531, 424,
149136 /* 760 */ 423, 1397, 941, 119, 120, 110, 1136, 1136, 981, 984,
149137 /* 770 */ 974, 974, 117, 117, 118, 118, 118, 118, 1397, 1399,
149138 /* 780 */ 425, 519, 392, 264, 264, 1029, 1029, 455, 264, 264,
149139 /* 790 */ 264, 264, 1004, 304, 261, 1278, 531, 900, 288, 525,
149140 /* 800 */ 310, 531, 493, 531, 1067, 1532, 458, 387, 1532, 311,
149141 /* 810 */ 429, 299, 534, 107, 264, 264, 116, 116, 116, 116,
149142 /* 820 */ 115, 115, 114, 114, 114, 113, 414, 531, 424, 1384,
149143 /* 830 */ 507, 258, 258, 1246, 55, 55, 383, 1277, 265, 265,
149144 /* 840 */ 962, 324, 434, 312, 531, 531, 506, 1397, 1026, 1241,
149145 /* 850 */ 298, 531, 1026, 445, 301, 1095, 303, 534, 368, 1156,
149146 /* 860 */ 119, 120, 110, 1136, 1136, 981, 984, 974, 974, 117,
149147 /* 870 */ 117, 118, 118, 118, 118, 1045, 534, 1065, 534, 15,
149148 /* 880 */ 15, 1084, 208, 1324, 453, 452, 534, 1324, 534, 449,
149149 /* 890 */ 1046, 1084, 494, 458, 1084, 234, 233, 232, 44, 44,
149150 /* 900 */ 56, 56, 319, 1095, 322, 1047, 534, 900, 57, 57,
149151 /* 910 */ 58, 58, 534, 116, 116, 116, 116, 115, 115, 114,
149152 /* 920 */ 114, 114, 113, 414, 534, 514, 522, 534, 59, 59,
149153 /* 930 */ 302, 1157, 534, 383, 60, 60, 1237, 946, 788, 789,
149154 /* 940 */ 790, 1459, 1456, 446, 6, 6, 61, 61, 1212, 45,
149155 /* 950 */ 45, 534, 396, 383, 46, 46, 397, 119, 120, 110,
149156 /* 960 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
149157 /* 970 */ 118, 118, 428, 48, 48, 534, 392, 119, 120, 110,
149158 /* 980 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
149159 /* 990 */ 118, 118, 1324, 368, 1066, 447, 825, 49, 49, 534,
149160 /* 1000 */ 458, 357, 534, 353, 534, 138, 534, 337, 1478, 478,
149161 /* 1010 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
149162 /* 1020 */ 414, 62, 62, 392, 63, 63, 64, 64, 14, 14,
149163 /* 1030 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
149164 /* 1040 */ 414, 534, 810, 317, 271, 534, 1457, 825, 534, 6,
149165 /* 1050 */ 534, 1324, 534, 142, 534, 1442, 534, 212, 534, 1324,
149166 /* 1060 */ 534, 398, 305, 65, 65, 534, 1157, 125, 125, 476,
149167 /* 1070 */ 66, 66, 51, 51, 67, 67, 68, 68, 52, 52,
149168 /* 1080 */ 147, 147, 148, 148, 534, 98, 534, 75, 75, 276,
149169 /* 1090 */ 534, 272, 534, 810, 534, 876, 534, 527, 389, 534,
149170 /* 1100 */ 875, 534, 1151, 202, 534, 383, 53, 53, 71, 71,
149171 /* 1110 */ 288, 525, 126, 126, 72, 72, 127, 127, 128, 128,
149172 /* 1120 */ 454, 124, 124, 146, 146, 383, 145, 145, 408, 119,
149173 /* 1130 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
149174 /* 1140 */ 118, 118, 118, 118, 534, 900, 534, 95, 534, 119,
149175 /* 1150 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
149176 /* 1160 */ 118, 118, 118, 118, 390, 161, 132, 132, 131, 131,
149177 /* 1170 */ 129, 129, 534, 915, 534, 1455, 534, 1454, 6, 1416,
149178 /* 1180 */ 6, 916, 116, 116, 116, 116, 115, 115, 114, 114,
149179 /* 1190 */ 114, 113, 414, 1415, 130, 130, 74, 74, 76, 76,
149180 /* 1200 */ 534, 30, 116, 116, 116, 116, 115, 115, 114, 114,
149181 /* 1210 */ 114, 113, 414, 534, 263, 206, 534, 1133, 1504, 93,
149182 /* 1220 */ 876, 845, 73, 73, 102, 875, 100, 139, 17, 38,
149183 /* 1230 */ 208, 1062, 31, 450, 370, 43, 43, 101, 47, 47,
149184 /* 1240 */ 827, 216, 436, 308, 943, 440, 95, 241, 241, 442,
149185 /* 1250 */ 313, 464, 241, 95, 237, 900, 327, 383, 266, 95,
149186 /* 1260 */ 835, 834, 193, 335, 938, 314, 1011, 435, 842, 843,
149187 /* 1270 */ 955, 1007, 909, 334, 237, 241, 873, 383, 1023, 107,
149188 /* 1280 */ 1023, 119, 120, 110, 1136, 1136, 981, 984, 974, 974,
149189 /* 1290 */ 117, 117, 118, 118, 118, 118, 1022, 808, 1022, 1274,
149190 /* 1300 */ 137, 119, 108, 110, 1136, 1136, 981, 984, 974, 974,
149191 /* 1310 */ 117, 117, 118, 118, 118, 118, 874, 1011, 318, 107,
149192 /* 1320 */ 321, 955, 323, 325, 1225, 1211, 197, 1210, 1209, 330,
149193 /* 1330 */ 339, 1265, 340, 283, 116, 116, 116, 116, 115, 115,
149194 /* 1340 */ 114, 114, 114, 113, 414, 1286, 1323, 1261, 1471, 1272,
149195 /* 1350 */ 520, 218, 521, 1329, 116, 116, 116, 116, 115, 115,
149196 /* 1360 */ 114, 114, 114, 113, 414, 1192, 1184, 1173, 1172, 1174,
149197 /* 1370 */ 1494, 1488, 459, 256, 383, 1258, 342, 199, 367, 344,
149198 /* 1380 */ 211, 195, 307, 444, 11, 346, 469, 333, 1308, 1316,
149199 /* 1390 */ 375, 427, 203, 360, 383, 1388, 188, 1387, 189, 120,
149200 /* 1400 */ 110, 1136, 1136, 981, 984, 974, 974, 117, 117, 118,
149201 /* 1410 */ 118, 118, 118, 1208, 1151, 300, 348, 1491, 245, 1148,
149202 /* 1420 */ 110, 1136, 1136, 981, 984, 974, 974, 117, 117, 118,
149203 /* 1430 */ 118, 118, 118, 198, 1435, 1433, 524, 78, 391, 163,
149204 /* 1440 */ 82, 1393, 438, 173, 81, 105, 526, 1313, 4, 35,
149205 /* 1450 */ 157, 116, 116, 116, 116, 115, 115, 114, 114, 114,
149206 /* 1460 */ 113, 414, 529, 165, 93, 430, 1305, 168, 169, 431,
149207 /* 1470 */ 462, 116, 116, 116, 116, 115, 115, 114, 114, 114,
149208 /* 1480 */ 113, 414, 170, 171, 221, 415, 372, 437, 1319, 177,
149209 /* 1490 */ 374, 36, 451, 225, 1382, 87, 457, 523, 257, 1404,
149210 /* 1500 */ 316, 105, 526, 227, 4, 182, 460, 160, 320, 228,
149211 /* 1510 */ 377, 1175, 475, 229, 1228, 404, 1227, 1226, 529, 827,
149212 /* 1520 */ 961, 1219, 378, 1200, 1199, 406, 103, 103, 1218, 332,
149213 /* 1530 */ 8, 281, 1198, 104, 1503, 415, 536, 535, 486, 282,
149214 /* 1540 */ 951, 415, 489, 495, 92, 244, 1269, 341, 243, 122,
149215 /* 1550 */ 1270, 343, 514, 523, 1268, 1462, 10, 288, 525, 345,
149216 /* 1560 */ 1461, 354, 99, 352, 503, 94, 1267, 347, 1251, 502,
149217 /* 1570 */ 498, 951, 951, 953, 954, 27, 961, 1250, 194, 358,
149218 /* 1580 */ 251, 359, 103, 103, 1181, 34, 537, 1110, 252, 104,
149219 /* 1590 */ 254, 415, 536, 535, 255, 1368, 951, 1420, 286, 538,
149220 /* 1600 */ 1170, 1165, 1421, 135, 1419, 1418, 149, 150, 279, 784,
149221 /* 1610 */ 416, 196, 151, 290, 210, 200, 77, 385, 269, 386,
149222 /* 1620 */ 133, 162, 935, 1021, 201, 1019, 153, 951, 951, 953,
149223 /* 1630 */ 954, 27, 1480, 1104, 417, 164, 217, 268, 859, 166,
149224 /* 1640 */ 306, 1035, 366, 366, 365, 253, 363, 220, 172, 797,
149225 /* 1650 */ 939, 155, 105, 526, 393, 4, 395, 174, 156, 83,
149226 /* 1660 */ 1038, 84, 213, 85, 294, 222, 86, 223, 1034, 529,
149227 /* 1670 */ 144, 18, 293, 224, 315, 456, 241, 1027, 1145, 178,
149228 /* 1680 */ 226, 179, 37, 799, 334, 461, 230, 465, 470, 838,
149229 /* 1690 */ 180, 88, 415, 19, 280, 328, 20, 89, 90, 158,
149230 /* 1700 */ 191, 477, 215, 1097, 523, 204, 192, 987, 91, 1070,
149231 /* 1710 */ 152, 39, 485, 154, 1071, 503, 40, 488, 205, 260,
149232 /* 1720 */ 504, 262, 105, 526, 214, 4, 908, 961, 183, 240,
149233 /* 1730 */ 903, 107, 1086, 103, 103, 21, 22, 1088, 23, 529,
149234 /* 1740 */ 104, 24, 415, 536, 535, 1090, 1093, 951, 1094, 25,
149235 /* 1750 */ 1074, 33, 7, 26, 510, 1002, 247, 186, 384, 95,
149236 /* 1760 */ 988, 986, 415, 288, 525, 990, 1044, 246, 1043, 991,
149237 /* 1770 */ 28, 41, 530, 956, 523, 809, 106, 29, 951, 951,
149238 /* 1780 */ 953, 954, 27, 869, 361, 503, 422, 248, 364, 1105,
149239 /* 1790 */ 502, 249, 1161, 1496, 1495, 1161, 1161, 961, 1161, 1161,
149240 /* 1800 */ 1161, 1161, 1161, 103, 103, 1161, 1161, 1161, 1161, 1161,
149241 /* 1810 */ 104, 1161, 415, 536, 535, 1104, 417, 951, 1161, 268,
149242 /* 1820 */ 1161, 1161, 1161, 1161, 366, 366, 365, 253, 363, 1161,
149243 /* 1830 */ 1161, 797, 1161, 1161, 1161, 1161, 105, 526, 1161, 4,
149244 /* 1840 */ 1161, 1161, 1161, 1161, 213, 1161, 294, 1161, 951, 951,
149245 /* 1850 */ 953, 954, 27, 529, 293, 1161, 1161, 1161, 1161, 1161,
149246 /* 1860 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
149247 /* 1870 */ 1161, 1161, 1161, 1161, 1161, 1161, 415, 1161, 1161, 1161,
149248 /* 1880 */ 1161, 1161, 1161, 1161, 215, 1161, 1161, 1161, 523, 1161,
149249 /* 1890 */ 1161, 1161, 152, 1161, 1161, 154, 105, 526, 1161, 4,
149250 /* 1900 */ 1161, 1161, 1161, 1161, 1161, 1161, 214, 1161, 1161, 1161,
149251 /* 1910 */ 1161, 961, 1161, 529, 1161, 1161, 1161, 103, 103, 880,
149252 /* 1920 */ 1161, 1161, 1161, 1161, 104, 1161, 415, 536, 535, 1161,
149253 /* 1930 */ 1161, 951, 1161, 1161, 1161, 1161, 415, 1161, 1161, 1161,
149254 /* 1940 */ 384, 1161, 1161, 1161, 1161, 288, 525, 1161, 523, 1161,
149255 /* 1950 */ 1161, 1161, 1161, 1161, 1161, 1161, 97, 526, 1161, 4,
149256 /* 1960 */ 1161, 1161, 951, 951, 953, 954, 27, 1161, 422, 1161,
149257 /* 1970 */ 1161, 961, 1161, 529, 1161, 1161, 1161, 103, 103, 1161,
149258 /* 1980 */ 1161, 1161, 1161, 1161, 104, 1161, 415, 536, 535, 1161,
149259 /* 1990 */ 1161, 951, 268, 1161, 1161, 1161, 415, 366, 366, 365,
149260 /* 2000 */ 253, 363, 1161, 1161, 797, 1161, 1161, 1161, 523, 1161,
149261 /* 2010 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 213, 1161, 294,
149262 /* 2020 */ 1161, 1161, 951, 951, 953, 954, 27, 293, 1161, 1161,
149263 /* 2030 */ 1161, 961, 1161, 1161, 1161, 1161, 1161, 103, 103, 1161,
149264 /* 2040 */ 1161, 1161, 1161, 1161, 104, 1161, 415, 536, 535, 1161,
149265 /* 2050 */ 1161, 951, 1161, 1161, 1161, 1161, 1161, 215, 1161, 1161,
149266 /* 2060 */ 1161, 1161, 1161, 1161, 1161, 152, 1161, 1161, 154, 1161,
149267 /* 2070 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 214,
149268 /* 2080 */ 1161, 1161, 951, 951, 953, 954, 27, 1161, 1161, 1161,
149269 /* 2090 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
149270 /* 2100 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
149271 /* 2110 */ 1161, 1161, 1161, 384, 1161, 1161, 1161, 1161, 288, 525,
149272 /* 2120 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
149273 /* 2130 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
149274 /* 2140 */ 1161, 422,
149275 };
149276 static const YYCODETYPE yy_lookahead[] = {
149277 /* 0 */ 260, 261, 262, 260, 261, 262, 176, 177, 178, 179,
149278 /* 10 */ 180, 181, 184, 206, 209, 184, 186, 206, 188, 19,
149279 /* 20 */ 179, 281, 181, 213, 214, 195, 206, 186, 195, 188,
149280 /* 30 */ 195, 31, 222, 184, 206, 207, 195, 206, 207, 39,
149281 /* 40 */ 24, 209, 184, 43, 44, 45, 46, 47, 48, 49,
149282 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 228, 229,
149283 /* 60 */ 184, 228, 229, 228, 229, 260, 261, 262, 192, 228,
149284 /* 70 */ 229, 241, 196, 242, 241, 59, 241, 205, 245, 246,
149285 /* 80 */ 184, 22, 241, 24, 254, 213, 54, 55, 56, 57,
149286 /* 90 */ 58, 256, 260, 261, 262, 254, 96, 97, 98, 99,
149287 /* 100 */ 100, 101, 102, 103, 104, 105, 106, 100, 101, 102,
149288 /* 110 */ 103, 104, 105, 106, 284, 203, 19, 221, 59, 102,
149289 /* 120 */ 103, 104, 105, 106, 59, 284, 110, 269, 96, 97,
149290 /* 130 */ 98, 99, 100, 101, 102, 103, 104, 105, 106, 94,
149291 /* 140 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
149292 /* 150 */ 53, 54, 55, 56, 57, 110, 184, 106, 73, 114,
149293 /* 160 */ 178, 179, 180, 181, 219, 184, 81, 22, 186, 110,
149294 /* 170 */ 188, 121, 122, 195, 109, 110, 111, 195, 206, 207,
149295 /* 180 */ 83, 184, 85, 54, 55, 56, 57, 206, 207, 277,
149296 /* 190 */ 145, 146, 147, 96, 97, 98, 99, 100, 101, 102,
149297 /* 200 */ 103, 104, 105, 106, 59, 120, 228, 229, 143, 184,
149298 /* 210 */ 228, 229, 184, 19, 242, 203, 131, 132, 221, 241,
149299 /* 220 */ 26, 184, 184, 241, 196, 96, 97, 98, 99, 100,
149300 /* 230 */ 101, 102, 103, 104, 105, 106, 254, 43, 44, 45,
149301 /* 240 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
149302 /* 250 */ 56, 57, 184, 184, 109, 110, 111, 105, 106, 184,
149303 /* 260 */ 200, 201, 202, 69, 184, 227, 284, 96, 97, 98,
149304 /* 270 */ 99, 100, 101, 102, 103, 104, 105, 106, 297, 298,
149305 /* 280 */ 255, 206, 207, 19, 272, 59, 206, 207, 184, 277,
149306 /* 290 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
149307 /* 300 */ 106, 184, 259, 19, 184, 100, 101, 43, 44, 45,
149308 /* 310 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
149309 /* 320 */ 56, 57, 242, 206, 207, 184, 100, 101, 138, 292,
149310 /* 330 */ 293, 67, 76, 296, 108, 109, 110, 111, 295, 113,
149311 /* 340 */ 84, 59, 86, 22, 26, 89, 156, 121, 224, 225,
149312 /* 350 */ 145, 19, 147, 59, 72, 256, 24, 184, 290, 291,
149313 /* 360 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
149314 /* 370 */ 106, 145, 297, 147, 299, 43, 44, 45, 46, 47,
149315 /* 380 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
149316 /* 390 */ 106, 109, 110, 111, 138, 184, 112, 113, 114, 115,
149317 /* 400 */ 116, 117, 118, 109, 110, 111, 112, 59, 124, 115,
149318 /* 410 */ 116, 117, 292, 293, 297, 298, 296, 206, 207, 125,
149319 /* 420 */ 72, 100, 101, 184, 46, 47, 48, 49, 96, 97,
149320 /* 430 */ 98, 99, 100, 101, 102, 103, 104, 105, 106, 59,
149321 /* 440 */ 200, 201, 202, 184, 59, 206, 207, 46, 19, 131,
149322 /* 450 */ 132, 278, 23, 242, 184, 184, 76, 109, 110, 111,
149323 /* 460 */ 224, 225, 251, 81, 84, 184, 86, 22, 23, 89,
149324 /* 470 */ 184, 26, 43, 44, 45, 46, 47, 48, 49, 50,
149325 /* 480 */ 51, 52, 53, 54, 55, 56, 57, 102, 184, 109,
149326 /* 490 */ 110, 111, 114, 184, 109, 110, 111, 184, 227, 184,
149327 /* 500 */ 230, 184, 22, 264, 195, 59, 22, 184, 195, 108,
149328 /* 510 */ 206, 207, 59, 131, 132, 206, 207, 184, 138, 206,
149329 /* 520 */ 207, 206, 207, 206, 207, 96, 97, 98, 99, 100,
149330 /* 530 */ 101, 102, 103, 104, 105, 106, 255, 228, 229, 59,
149331 /* 540 */ 95, 228, 229, 59, 184, 19, 242, 94, 184, 23,
149332 /* 550 */ 241, 242, 184, 282, 241, 242, 110, 242, 184, 242,
149333 /* 560 */ 251, 59, 109, 110, 196, 184, 251, 114, 251, 43,
149334 /* 570 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
149335 /* 580 */ 54, 55, 56, 57, 259, 217, 12, 219, 255, 109,
149336 /* 590 */ 110, 111, 203, 109, 110, 111, 184, 22, 145, 146,
149337 /* 600 */ 147, 27, 112, 22, 230, 115, 116, 117, 227, 19,
149338 /* 610 */ 59, 109, 110, 111, 291, 125, 42, 35, 206, 207,
149339 /* 620 */ 295, 184, 96, 97, 98, 99, 100, 101, 102, 103,
149340 /* 630 */ 104, 105, 106, 26, 59, 233, 46, 63, 136, 184,
149341 /* 640 */ 59, 184, 19, 206, 207, 243, 23, 73, 66, 260,
149342 /* 650 */ 261, 262, 59, 184, 242, 195, 74, 220, 184, 184,
149343 /* 660 */ 109, 110, 111, 206, 207, 184, 43, 44, 45, 46,
149344 /* 670 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
149345 /* 680 */ 57, 206, 207, 76, 109, 110, 111, 136, 228, 229,
149346 /* 690 */ 109, 110, 111, 86, 184, 220, 89, 21, 108, 230,
149347 /* 700 */ 184, 241, 109, 110, 111, 123, 184, 127, 184, 129,
149348 /* 710 */ 130, 184, 195, 184, 124, 184, 198, 199, 184, 96,
149349 /* 720 */ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
149350 /* 730 */ 206, 207, 11, 206, 207, 206, 207, 206, 207, 19,
149351 /* 740 */ 206, 207, 184, 23, 220, 228, 229, 220, 81, 220,
149352 /* 750 */ 195, 220, 287, 288, 220, 195, 80, 195, 241, 201,
149353 /* 760 */ 202, 184, 73, 43, 44, 45, 46, 47, 48, 49,
149354 /* 770 */ 50, 51, 52, 53, 54, 55, 56, 57, 201, 202,
149355 /* 780 */ 113, 195, 184, 228, 229, 120, 121, 122, 228, 229,
149356 /* 790 */ 228, 229, 116, 16, 23, 184, 241, 26, 131, 132,
149357 /* 800 */ 278, 241, 19, 241, 22, 23, 184, 189, 26, 120,
149358 /* 810 */ 121, 122, 184, 26, 228, 229, 96, 97, 98, 99,
149359 /* 820 */ 100, 101, 102, 103, 104, 105, 106, 241, 270, 153,
149360 /* 830 */ 66, 228, 229, 229, 206, 207, 19, 184, 228, 229,
149361 /* 840 */ 23, 16, 121, 122, 241, 241, 82, 270, 29, 227,
149362 /* 850 */ 252, 241, 33, 19, 77, 91, 79, 184, 22, 23,
149363 /* 860 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
149364 /* 870 */ 53, 54, 55, 56, 57, 12, 184, 95, 184, 206,
149365 /* 880 */ 207, 76, 111, 184, 65, 267, 184, 184, 184, 271,
149366 /* 890 */ 27, 86, 109, 184, 89, 120, 121, 122, 206, 207,
149367 /* 900 */ 206, 207, 77, 139, 79, 42, 184, 136, 206, 207,
149368 /* 910 */ 206, 207, 184, 96, 97, 98, 99, 100, 101, 102,
149369 /* 920 */ 103, 104, 105, 106, 184, 138, 63, 184, 206, 207,
149370 /* 930 */ 153, 95, 184, 19, 206, 207, 227, 23, 7, 8,
149371 /* 940 */ 9, 293, 293, 109, 296, 296, 206, 207, 215, 206,
149372 /* 950 */ 207, 184, 253, 19, 206, 207, 253, 43, 44, 45,
149373 /* 960 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
149374 /* 970 */ 56, 57, 184, 206, 207, 184, 184, 43, 44, 45,
149375 /* 980 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
149376 /* 990 */ 56, 57, 184, 22, 23, 184, 59, 206, 207, 184,
149377 /* 1000 */ 184, 238, 184, 240, 184, 22, 184, 184, 157, 158,
149378 /* 1010 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
149379 /* 1020 */ 106, 206, 207, 184, 206, 207, 206, 207, 206, 207,
149380 /* 1030 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
149381 /* 1040 */ 106, 184, 59, 227, 252, 184, 293, 110, 184, 296,
149382 /* 1050 */ 184, 184, 184, 230, 184, 184, 184, 15, 184, 184,
149383 /* 1060 */ 184, 253, 184, 206, 207, 184, 95, 206, 207, 102,
149384 /* 1070 */ 206, 207, 206, 207, 206, 207, 206, 207, 206, 207,
149385 /* 1080 */ 206, 207, 206, 207, 184, 151, 184, 206, 207, 278,
149386 /* 1090 */ 184, 252, 184, 110, 184, 128, 184, 198, 199, 184,
149387 /* 1100 */ 133, 184, 60, 26, 184, 19, 206, 207, 206, 207,
149388 /* 1110 */ 131, 132, 206, 207, 206, 207, 206, 207, 206, 207,
149389 /* 1120 */ 253, 206, 207, 206, 207, 19, 206, 207, 253, 43,
149390 /* 1130 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
149391 /* 1140 */ 54, 55, 56, 57, 184, 26, 184, 26, 184, 43,
149392 /* 1150 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
149393 /* 1160 */ 54, 55, 56, 57, 285, 286, 206, 207, 206, 207,
149394 /* 1170 */ 206, 207, 184, 31, 184, 293, 184, 293, 296, 184,
149395 /* 1180 */ 296, 39, 96, 97, 98, 99, 100, 101, 102, 103,
149396 /* 1190 */ 104, 105, 106, 184, 206, 207, 206, 207, 206, 207,
149397 /* 1200 */ 184, 22, 96, 97, 98, 99, 100, 101, 102, 103,
149398 /* 1210 */ 104, 105, 106, 184, 245, 246, 184, 26, 23, 142,
149399 /* 1220 */ 128, 26, 206, 207, 150, 133, 152, 22, 22, 24,
149400 /* 1230 */ 111, 23, 53, 184, 26, 206, 207, 151, 206, 207,
149401 /* 1240 */ 119, 24, 122, 23, 23, 23, 26, 26, 26, 23,
149402 /* 1250 */ 23, 23, 26, 26, 26, 136, 23, 19, 22, 26,
149403 /* 1260 */ 113, 114, 24, 114, 144, 184, 59, 61, 7, 8,
149404 /* 1270 */ 59, 23, 23, 124, 26, 26, 23, 19, 145, 26,
149405 /* 1280 */ 147, 43, 44, 45, 46, 47, 48, 49, 50, 51,
149406 /* 1290 */ 52, 53, 54, 55, 56, 57, 145, 23, 147, 184,
149407 /* 1300 */ 26, 43, 44, 45, 46, 47, 48, 49, 50, 51,
149408 /* 1310 */ 52, 53, 54, 55, 56, 57, 23, 110, 184, 26,
149409 /* 1320 */ 184, 110, 184, 184, 184, 215, 135, 215, 184, 184,
149410 /* 1330 */ 184, 247, 184, 244, 96, 97, 98, 99, 100, 101,
149411 /* 1340 */ 102, 103, 104, 105, 106, 184, 184, 184, 301, 184,
149412 /* 1350 */ 184, 134, 225, 184, 96, 97, 98, 99, 100, 101,
149413 /* 1360 */ 102, 103, 104, 105, 106, 184, 184, 184, 184, 184,
149414 /* 1370 */ 134, 184, 274, 273, 19, 244, 244, 204, 182, 244,
149415 /* 1380 */ 283, 231, 279, 279, 232, 244, 210, 209, 235, 235,
149416 /* 1390 */ 235, 248, 218, 234, 19, 209, 238, 209, 238, 44,
149417 /* 1400 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
149418 /* 1410 */ 55, 56, 57, 214, 60, 248, 248, 187, 134, 38,
149419 /* 1420 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
149420 /* 1430 */ 55, 56, 57, 232, 191, 191, 266, 280, 191, 283,
149421 /* 1440 */ 143, 269, 108, 22, 280, 19, 20, 258, 22, 257,
149422 /* 1450 */ 43, 96, 97, 98, 99, 100, 101, 102, 103, 104,
149423 /* 1460 */ 105, 106, 36, 223, 142, 18, 235, 226, 226, 191,
149424 /* 1470 */ 18, 96, 97, 98, 99, 100, 101, 102, 103, 104,
149425 /* 1480 */ 105, 106, 226, 226, 190, 59, 235, 235, 223, 223,
149426 /* 1490 */ 258, 257, 191, 190, 235, 150, 62, 71, 191, 276,
149427 /* 1500 */ 275, 19, 20, 190, 22, 22, 211, 81, 191, 190,
149428 /* 1510 */ 211, 191, 108, 190, 208, 64, 208, 208, 36, 119,
149429 /* 1520 */ 94, 216, 211, 208, 210, 106, 100, 101, 216, 208,
149430 /* 1530 */ 48, 268, 208, 107, 208, 109, 110, 111, 211, 268,
149431 /* 1540 */ 114, 59, 211, 137, 108, 88, 250, 249, 191, 141,
149432 /* 1550 */ 250, 249, 138, 71, 250, 300, 22, 131, 132, 249,
149433 /* 1560 */ 300, 191, 150, 238, 82, 140, 250, 249, 239, 87,
149434 /* 1570 */ 139, 145, 146, 147, 148, 149, 94, 239, 237, 236,
149435 /* 1580 */ 25, 235, 100, 101, 194, 26, 193, 13, 185, 107,
149436 /* 1590 */ 185, 109, 110, 111, 6, 263, 114, 203, 265, 183,
149437 /* 1600 */ 183, 183, 203, 212, 203, 203, 197, 197, 212, 4,
149438 /* 1610 */ 3, 22, 197, 155, 15, 204, 203, 289, 93, 289,
149439 /* 1620 */ 16, 286, 132, 23, 204, 23, 123, 145, 146, 147,
149440 /* 1630 */ 148, 149, 0, 1, 2, 143, 24, 5, 20, 135,
149441 /* 1640 */ 16, 1, 10, 11, 12, 13, 14, 137, 135, 17,
149442 /* 1650 */ 144, 123, 19, 20, 61, 22, 37, 143, 123, 53,
149443 /* 1660 */ 109, 53, 30, 53, 32, 34, 53, 134, 1, 36,
149444 /* 1670 */ 5, 22, 40, 108, 153, 41, 26, 68, 75, 68,
149445 /* 1680 */ 134, 108, 24, 20, 124, 19, 118, 67, 67, 28,
149446 /* 1690 */ 22, 22, 59, 22, 67, 23, 22, 22, 142, 37,
149447 /* 1700 */ 23, 22, 70, 23, 71, 157, 23, 23, 26, 23,
149448 /* 1710 */ 78, 22, 24, 81, 23, 82, 22, 24, 134, 23,
149449 /* 1720 */ 87, 23, 19, 20, 92, 22, 109, 94, 22, 34,
149450 /* 1730 */ 136, 26, 85, 100, 101, 34, 34, 83, 34, 36,
149451 /* 1740 */ 107, 34, 109, 110, 111, 75, 90, 114, 75, 34,
149452 /* 1750 */ 23, 22, 44, 34, 24, 23, 22, 26, 126, 26,
149453 /* 1760 */ 23, 23, 59, 131, 132, 23, 23, 26, 23, 11,
149454 /* 1770 */ 22, 22, 26, 23, 71, 23, 22, 22, 145, 146,
149455 /* 1780 */ 147, 148, 149, 128, 23, 82, 154, 134, 15, 1,
149456 /* 1790 */ 87, 134, 302, 134, 134, 302, 302, 94, 302, 302,
149457 /* 1800 */ 302, 302, 302, 100, 101, 302, 302, 302, 302, 302,
149458 /* 1810 */ 107, 302, 109, 110, 111, 1, 2, 114, 302, 5,
149459 /* 1820 */ 302, 302, 302, 302, 10, 11, 12, 13, 14, 302,
149460 /* 1830 */ 302, 17, 302, 302, 302, 302, 19, 20, 302, 22,
149461 /* 1840 */ 302, 302, 302, 302, 30, 302, 32, 302, 145, 146,
149462 /* 1850 */ 147, 148, 149, 36, 40, 302, 302, 302, 302, 302,
149463 /* 1860 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149464 /* 1870 */ 302, 302, 302, 302, 302, 302, 59, 302, 302, 302,
149465 /* 1880 */ 302, 302, 302, 302, 70, 302, 302, 302, 71, 302,
149466 /* 1890 */ 302, 302, 78, 302, 302, 81, 19, 20, 302, 22,
149467 /* 1900 */ 302, 302, 302, 302, 302, 302, 92, 302, 302, 302,
149468 /* 1910 */ 302, 94, 302, 36, 302, 302, 302, 100, 101, 102,
149469 /* 1920 */ 302, 302, 302, 302, 107, 302, 109, 110, 111, 302,
149470 /* 1930 */ 302, 114, 302, 302, 302, 302, 59, 302, 302, 302,
149471 /* 1940 */ 126, 302, 302, 302, 302, 131, 132, 302, 71, 302,
149472 /* 1950 */ 302, 302, 302, 302, 302, 302, 19, 20, 302, 22,
149473 /* 1960 */ 302, 302, 145, 146, 147, 148, 149, 302, 154, 302,
149474 /* 1970 */ 302, 94, 302, 36, 302, 302, 302, 100, 101, 302,
149475 /* 1980 */ 302, 302, 302, 302, 107, 302, 109, 110, 111, 302,
149476 /* 1990 */ 302, 114, 5, 302, 302, 302, 59, 10, 11, 12,
149477 /* 2000 */ 13, 14, 302, 302, 17, 302, 302, 302, 71, 302,
149478 /* 2010 */ 302, 302, 302, 302, 302, 302, 302, 30, 302, 32,
149479 /* 2020 */ 302, 302, 145, 146, 147, 148, 149, 40, 302, 302,
149480 /* 2030 */ 302, 94, 302, 302, 302, 302, 302, 100, 101, 302,
149481 /* 2040 */ 302, 302, 302, 302, 107, 302, 109, 110, 111, 302,
149482 /* 2050 */ 302, 114, 302, 302, 302, 302, 302, 70, 302, 302,
149483 /* 2060 */ 302, 302, 302, 302, 302, 78, 302, 302, 81, 302,
149484 /* 2070 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 92,
149485 /* 2080 */ 302, 302, 145, 146, 147, 148, 149, 302, 302, 302,
149486 /* 2090 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149487 /* 2100 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149488 /* 2110 */ 302, 302, 302, 126, 302, 302, 302, 302, 131, 132,
149489 /* 2120 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149490 /* 2130 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149491 /* 2140 */ 302, 154, 302, 302, 302, 302, 302, 302, 302, 302,
149492 /* 2150 */ 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
149493 /* 2160 */ 302, 302, 302, 302, 302, 302, 302, 302, 302,
149494 };
149495 #define YY_SHIFT_COUNT (539)
149496 #define YY_SHIFT_MIN (0)
149497 #define YY_SHIFT_MAX (1987)
149498 static const unsigned short int yy_shift_ofst[] = {
149499 /* 0 */ 1814, 1632, 1987, 1426, 1426, 382, 1482, 1633, 1703, 1877,
149500 /* 10 */ 1877, 1877, 85, 0, 0, 264, 1106, 1877, 1877, 1877,
149501 /* 20 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
149502 /* 30 */ 226, 226, 380, 380, 294, 667, 382, 382, 382, 382,
149503 /* 40 */ 382, 382, 97, 194, 332, 429, 526, 623, 720, 817,
149504 /* 50 */ 914, 934, 1086, 1238, 1106, 1106, 1106, 1106, 1106, 1106,
149505 /* 60 */ 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106,
149506 /* 70 */ 1106, 1106, 1258, 1106, 1355, 1375, 1375, 1817, 1877, 1877,
149507 /* 80 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
149508 /* 90 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
149509 /* 100 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
149510 /* 110 */ 1937, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
149511 /* 120 */ 1877, 1877, 1877, 1877, 32, 129, 129, 129, 129, 129,
149512 /* 130 */ 171, 7, 17, 593, 676, 590, 593, 205, 205, 593,
149513 /* 140 */ 318, 318, 318, 318, 50, 152, 51, 2142, 2142, 284,
149514 /* 150 */ 284, 284, 65, 145, 282, 145, 145, 574, 574, 256,
149515 /* 160 */ 348, 445, 782, 593, 593, 593, 593, 593, 593, 593,
149516 /* 170 */ 593, 593, 593, 593, 593, 593, 593, 593, 593, 593,
149517 /* 180 */ 593, 593, 593, 593, 607, 607, 593, 721, 805, 805,
149518 /* 190 */ 446, 851, 851, 446, 190, 979, 2142, 2142, 2142, 453,
149519 /* 200 */ 45, 45, 480, 490, 484, 385, 575, 502, 551, 581,
149520 /* 210 */ 593, 593, 593, 593, 593, 593, 593, 593, 593, 689,
149521 /* 220 */ 593, 593, 593, 593, 593, 593, 593, 593, 593, 593,
149522 /* 230 */ 593, 593, 582, 582, 582, 593, 593, 593, 593, 771,
149523 /* 240 */ 593, 593, 593, 59, 764, 593, 593, 863, 593, 593,
149524 /* 250 */ 593, 593, 593, 593, 593, 593, 665, 819, 580, 16,
149525 /* 260 */ 16, 16, 16, 1119, 580, 580, 967, 321, 931, 1042,
149526 /* 270 */ 1077, 783, 783, 834, 1077, 1077, 834, 1121, 1195, 401,
149527 /* 280 */ 1142, 1142, 1142, 783, 787, 787, 1074, 1191, 1092, 1205,
149528 /* 290 */ 1354, 1284, 1284, 1381, 1381, 1284, 1297, 1334, 1421, 1407,
149529 /* 300 */ 1322, 1447, 1447, 1447, 1447, 1284, 1452, 1322, 1322, 1334,
149530 /* 310 */ 1421, 1407, 1407, 1322, 1284, 1452, 1345, 1434, 1284, 1452,
149531 /* 320 */ 1483, 1284, 1452, 1284, 1452, 1483, 1404, 1404, 1404, 1451,
149532 /* 330 */ 1483, 1404, 1400, 1404, 1451, 1404, 1404, 1483, 1419, 1419,
149533 /* 340 */ 1483, 1406, 1436, 1406, 1436, 1406, 1436, 1406, 1436, 1284,
149534 /* 350 */ 1457, 1457, 1408, 1414, 1534, 1284, 1412, 1408, 1425, 1431,
149535 /* 360 */ 1322, 1555, 1559, 1574, 1574, 1588, 1588, 1588, 2142, 2142,
149536 /* 370 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
149537 /* 380 */ 2142, 2142, 2142, 378, 777, 836, 971, 825, 775, 983,
149538 /* 390 */ 1208, 1179, 1217, 1120, 1220, 1206, 1221, 1222, 1226, 1227,
149539 /* 400 */ 1228, 1233, 937, 1147, 1261, 1149, 1207, 1248, 1249, 1253,
149540 /* 410 */ 1133, 1151, 1274, 1293, 1211, 1236, 1605, 1607, 1589, 1458,
149541 /* 420 */ 1599, 1525, 1604, 1600, 1602, 1490, 1492, 1503, 1612, 1504,
149542 /* 430 */ 1618, 1510, 1624, 1640, 1513, 1506, 1528, 1593, 1619, 1514,
149543 /* 440 */ 1606, 1608, 1610, 1613, 1535, 1551, 1631, 1533, 1667, 1665,
149544 /* 450 */ 1649, 1565, 1521, 1609, 1650, 1611, 1603, 1634, 1546, 1573,
149545 /* 460 */ 1658, 1663, 1666, 1560, 1568, 1668, 1620, 1669, 1671, 1672,
149546 /* 470 */ 1674, 1621, 1661, 1675, 1627, 1662, 1677, 1556, 1679, 1680,
149547 /* 480 */ 1548, 1683, 1684, 1682, 1686, 1689, 1688, 1691, 1694, 1693,
149548 /* 490 */ 1584, 1696, 1698, 1617, 1695, 1706, 1594, 1705, 1701, 1702,
149549 /* 500 */ 1704, 1707, 1647, 1670, 1654, 1708, 1673, 1656, 1715, 1727,
149550 /* 510 */ 1729, 1730, 1731, 1733, 1719, 1732, 1705, 1737, 1738, 1742,
149551 /* 520 */ 1743, 1741, 1745, 1734, 1758, 1748, 1749, 1750, 1752, 1754,
149552 /* 530 */ 1755, 1746, 1655, 1653, 1657, 1659, 1660, 1761, 1773, 1788,
149553 };
149554 #define YY_REDUCE_COUNT (382)
149555 #define YY_REDUCE_MIN (-260)
149556 #define YY_REDUCE_MAX (1420)
 
149557 static const short yy_reduce_ofst[] = {
149558 /* 0 */ -170, -18, -159, 309, 313, -167, -19, 75, 117, 211,
149559 /* 10 */ 315, 317, -165, -195, -168, -260, 389, 437, 475, 524,
149560 /* 20 */ 527, -169, 529, 531, -28, 80, 534, 239, 304, 412,
149561 /* 30 */ 558, 577, 37, 120, 368, -22, 460, 517, 555, 560,
149562 /* 40 */ 562, 586, -257, -257, -257, -257, -257, -257, -257, -257,
149563 /* 50 */ -257, -257, -257, -257, -257, -257, -257, -257, -257, -257,
149564 /* 60 */ -257, -257, -257, -257, -257, -257, -257, -257, -257, -257,
149565 /* 70 */ -257, -257, -257, -257, -257, -257, -257, -172, 457, 628,
149566 /* 80 */ 673, 692, 694, 702, 704, 722, 728, 740, 743, 748,
149567 /* 90 */ 767, 791, 815, 818, 820, 822, 857, 861, 864, 866,
149568 /* 100 */ 868, 870, 872, 874, 876, 881, 900, 902, 906, 908,
149569 /* 110 */ 910, 912, 915, 917, 920, 960, 962, 964, 988, 990,
149570 /* 120 */ 992, 1016, 1029, 1032, -257, -257, -257, -257, -257, -257,
149571 /* 130 */ -257, -257, -257, 271, 618, -190, 68, 60, 240, -124,
149572 /* 140 */ 603, 610, 603, 610, 12, -257, -257, -257, -257, -128,
149573 /* 150 */ -128, -128, -142, 25, 270, 281, 333, 124, 236, 648,
149574 /* 160 */ 374, 465, 465, 28, 598, 792, 839, 469, 38, 381,
149575 /* 170 */ 622, 709, 173, 699, 522, 703, 808, 811, 867, 816,
149576 /* 180 */ -104, 823, -3, 875, 649, 753, 323, -88, 882, 884,
149577 /* 190 */ 518, 43, 325, 899, 763, 604, 879, 969, 402, -193,
149578 /* 200 */ -189, -180, -151, -55, 69, 104, 141, 259, 286, 360,
149579 /* 210 */ 364, 455, 474, 481, 510, 516, 611, 653, 788, 99,
149580 /* 220 */ 871, 878, 995, 1009, 1049, 1081, 1115, 1134, 1136, 1138,
149581 /* 230 */ 1139, 1140, 733, 1110, 1112, 1144, 1145, 1146, 1148, 1084,
149582 /* 240 */ 1161, 1162, 1163, 1089, 1047, 1165, 1166, 1127, 1169, 104,
149583 /* 250 */ 1181, 1182, 1183, 1184, 1185, 1187, 1098, 1100, 1150, 1131,
149584 /* 260 */ 1132, 1135, 1141, 1084, 1150, 1150, 1152, 1173, 1196, 1097,
149585 /* 270 */ 1153, 1143, 1167, 1103, 1154, 1155, 1104, 1176, 1174, 1199,
149586 /* 280 */ 1178, 1186, 1188, 1168, 1158, 1160, 1170, 1159, 1201, 1230,
149587 /* 290 */ 1156, 1243, 1244, 1157, 1164, 1247, 1172, 1189, 1192, 1240,
149588 /* 300 */ 1231, 1241, 1242, 1256, 1257, 1278, 1294, 1251, 1252, 1232,
149589 /* 310 */ 1234, 1265, 1266, 1259, 1301, 1303, 1223, 1225, 1307, 1313,
149590 /* 320 */ 1295, 1317, 1319, 1320, 1323, 1299, 1306, 1308, 1309, 1305,
149591 /* 330 */ 1311, 1315, 1314, 1321, 1312, 1324, 1326, 1327, 1263, 1271,
149592 /* 340 */ 1331, 1296, 1298, 1300, 1302, 1304, 1310, 1316, 1318, 1357,
149593 /* 350 */ 1255, 1260, 1329, 1325, 1332, 1370, 1333, 1338, 1341, 1343,
149594 /* 360 */ 1346, 1390, 1393, 1403, 1405, 1416, 1417, 1418, 1328, 1330,
149595 /* 370 */ 1335, 1409, 1394, 1399, 1401, 1402, 1410, 1391, 1396, 1411,
149596 /* 380 */ 1420, 1413, 1415,
149597 };
149598 static const YYACTIONTYPE yy_default[] = {
149599 /* 0 */ 1537, 1537, 1537, 1377, 1159, 1266, 1159, 1159, 1159, 1377,
149600 /* 10 */ 1377, 1377, 1159, 1296, 1296, 1430, 1190, 1159, 1159, 1159,
149601 /* 20 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1376, 1159, 1159,
149602 /* 30 */ 1159, 1159, 1460, 1460, 1159, 1159, 1159, 1159, 1159, 1159,
149603 /* 40 */ 1159, 1159, 1159, 1302, 1159, 1159, 1159, 1159, 1159, 1378,
149604 /* 50 */ 1379, 1159, 1159, 1159, 1429, 1431, 1394, 1312, 1311, 1310,
149605 /* 60 */ 1309, 1412, 1283, 1307, 1300, 1304, 1372, 1373, 1371, 1375,
149606 /* 70 */ 1379, 1378, 1159, 1303, 1343, 1357, 1342, 1159, 1159, 1159,
149607 /* 80 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149608 /* 90 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149609 /* 100 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149610 /* 110 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149611 /* 120 */ 1159, 1159, 1159, 1159, 1351, 1356, 1362, 1355, 1352, 1345,
149612 /* 130 */ 1344, 1346, 1347, 1159, 1180, 1230, 1159, 1159, 1159, 1159,
149613 /* 140 */ 1448, 1447, 1159, 1159, 1190, 1348, 1349, 1359, 1358, 1437,
149614 /* 150 */ 1493, 1492, 1395, 1159, 1159, 1159, 1159, 1159, 1159, 1460,
149615 /* 160 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149616 /* 170 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149617 /* 180 */ 1159, 1159, 1159, 1159, 1460, 1460, 1159, 1190, 1460, 1460,
149618 /* 190 */ 1186, 1337, 1336, 1186, 1290, 1159, 1443, 1266, 1257, 1159,
149619 /* 200 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149620 /* 210 */ 1159, 1159, 1159, 1434, 1432, 1159, 1159, 1159, 1159, 1159,
149621 /* 220 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149622 /* 230 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149623 /* 240 */ 1159, 1159, 1159, 1262, 1159, 1159, 1159, 1159, 1159, 1159,
149624 /* 250 */ 1159, 1159, 1159, 1159, 1159, 1487, 1159, 1407, 1244, 1262,
149625 /* 260 */ 1262, 1262, 1262, 1264, 1245, 1243, 1256, 1191, 1166, 1529,
149626 /* 270 */ 1306, 1285, 1285, 1526, 1306, 1306, 1526, 1205, 1507, 1202,
149627 /* 280 */ 1296, 1296, 1296, 1285, 1290, 1290, 1374, 1263, 1256, 1159,
149628 /* 290 */ 1529, 1271, 1271, 1528, 1528, 1271, 1395, 1315, 1321, 1233,
149629 /* 300 */ 1306, 1239, 1239, 1239, 1239, 1271, 1177, 1306, 1306, 1315,
149630 /* 310 */ 1321, 1233, 1233, 1306, 1271, 1177, 1411, 1523, 1271, 1177,
149631 /* 320 */ 1385, 1271, 1177, 1271, 1177, 1385, 1231, 1231, 1231, 1220,
149632 /* 330 */ 1385, 1231, 1205, 1231, 1220, 1231, 1231, 1385, 1389, 1389,
149633 /* 340 */ 1385, 1289, 1284, 1289, 1284, 1289, 1284, 1289, 1284, 1271,
149634 /* 350 */ 1470, 1470, 1301, 1290, 1380, 1271, 1159, 1301, 1299, 1297,
149635 /* 360 */ 1306, 1183, 1223, 1490, 1490, 1486, 1486, 1486, 1534, 1534,
149636 /* 370 */ 1443, 1502, 1190, 1190, 1190, 1190, 1502, 1207, 1207, 1191,
149637 /* 380 */ 1191, 1190, 1502, 1159, 1159, 1159, 1159, 1159, 1159, 1497,
149638 /* 390 */ 1159, 1396, 1275, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149639 /* 400 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149640 /* 410 */ 1159, 1159, 1159, 1159, 1159, 1326, 1159, 1162, 1440, 1159,
149641 /* 420 */ 1159, 1438, 1159, 1159, 1159, 1159, 1159, 1159, 1276, 1159,
149642 /* 430 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149643 /* 440 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1525, 1159, 1159,
149644 /* 450 */ 1159, 1159, 1159, 1159, 1410, 1409, 1159, 1159, 1273, 1159,
149645 /* 460 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149646 /* 470 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149647 /* 480 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149648 /* 490 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1298, 1159, 1159,
149649 /* 500 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149650 /* 510 */ 1159, 1159, 1475, 1291, 1159, 1159, 1516, 1159, 1159, 1159,
149651 /* 520 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149652 /* 530 */ 1159, 1511, 1247, 1328, 1159, 1327, 1331, 1159, 1171, 1159,
 
149653 };
149654 /********** End of lemon-generated parsing tables *****************************/
149655
149656 /* The next table maps tokens (terminal symbols) into fallback tokens.
149657 ** If a construct like the following:
@@ -149749,10 +150469,13 @@
149749 59, /* TRIGGER => ID */
149750 59, /* VACUUM => ID */
149751 59, /* VIEW => ID */
149752 59, /* VIRTUAL => ID */
149753 59, /* WITH => ID */
 
 
 
149754 59, /* CURRENT => ID */
149755 59, /* FOLLOWING => ID */
149756 59, /* PARTITION => ID */
149757 59, /* PRECEDING => ID */
149758 59, /* RANGE => ID */
@@ -149762,10 +150485,91 @@
149762 59, /* OTHERS => ID */
149763 59, /* TIES => ID */
149764 59, /* REINDEX => ID */
149765 59, /* RENAME => ID */
149766 59, /* CTIME_KW => ID */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149767 };
149768 #endif /* YYFALLBACK */
149769
149770 /* The following structure represents a single element of the
149771 ** parser's stack. Information stored includes:
@@ -149931,230 +150735,235 @@
149931 /* 77 */ "TRIGGER",
149932 /* 78 */ "VACUUM",
149933 /* 79 */ "VIEW",
149934 /* 80 */ "VIRTUAL",
149935 /* 81 */ "WITH",
149936 /* 82 */ "CURRENT",
149937 /* 83 */ "FOLLOWING",
149938 /* 84 */ "PARTITION",
149939 /* 85 */ "PRECEDING",
149940 /* 86 */ "RANGE",
149941 /* 87 */ "UNBOUNDED",
149942 /* 88 */ "EXCLUDE",
149943 /* 89 */ "GROUPS",
149944 /* 90 */ "OTHERS",
149945 /* 91 */ "TIES",
149946 /* 92 */ "REINDEX",
149947 /* 93 */ "RENAME",
149948 /* 94 */ "CTIME_KW",
149949 /* 95 */ "ANY",
149950 /* 96 */ "BITAND",
149951 /* 97 */ "BITOR",
149952 /* 98 */ "LSHIFT",
149953 /* 99 */ "RSHIFT",
149954 /* 100 */ "PLUS",
149955 /* 101 */ "MINUS",
149956 /* 102 */ "STAR",
149957 /* 103 */ "SLASH",
149958 /* 104 */ "REM",
149959 /* 105 */ "CONCAT",
149960 /* 106 */ "COLLATE",
149961 /* 107 */ "BITNOT",
149962 /* 108 */ "ON",
149963 /* 109 */ "INDEXED",
149964 /* 110 */ "STRING",
149965 /* 111 */ "JOIN_KW",
149966 /* 112 */ "CONSTRAINT",
149967 /* 113 */ "DEFAULT",
149968 /* 114 */ "NULL",
149969 /* 115 */ "PRIMARY",
149970 /* 116 */ "UNIQUE",
149971 /* 117 */ "CHECK",
149972 /* 118 */ "REFERENCES",
149973 /* 119 */ "AUTOINCR",
149974 /* 120 */ "INSERT",
149975 /* 121 */ "DELETE",
149976 /* 122 */ "UPDATE",
149977 /* 123 */ "SET",
149978 /* 124 */ "DEFERRABLE",
149979 /* 125 */ "FOREIGN",
149980 /* 126 */ "DROP",
149981 /* 127 */ "UNION",
149982 /* 128 */ "ALL",
149983 /* 129 */ "EXCEPT",
149984 /* 130 */ "INTERSECT",
149985 /* 131 */ "SELECT",
149986 /* 132 */ "VALUES",
149987 /* 133 */ "DISTINCT",
149988 /* 134 */ "DOT",
149989 /* 135 */ "FROM",
149990 /* 136 */ "JOIN",
149991 /* 137 */ "USING",
149992 /* 138 */ "ORDER",
149993 /* 139 */ "GROUP",
149994 /* 140 */ "HAVING",
149995 /* 141 */ "LIMIT",
149996 /* 142 */ "WHERE",
149997 /* 143 */ "INTO",
149998 /* 144 */ "NOTHING",
149999 /* 145 */ "FLOAT",
150000 /* 146 */ "BLOB",
150001 /* 147 */ "INTEGER",
150002 /* 148 */ "VARIABLE",
150003 /* 149 */ "CASE",
150004 /* 150 */ "WHEN",
150005 /* 151 */ "THEN",
150006 /* 152 */ "ELSE",
150007 /* 153 */ "INDEX",
150008 /* 154 */ "ALTER",
150009 /* 155 */ "ADD",
150010 /* 156 */ "WINDOW",
150011 /* 157 */ "OVER",
150012 /* 158 */ "FILTER",
150013 /* 159 */ "TRUEFALSE",
150014 /* 160 */ "ISNOT",
150015 /* 161 */ "FUNCTION",
150016 /* 162 */ "COLUMN",
150017 /* 163 */ "AGG_FUNCTION",
150018 /* 164 */ "AGG_COLUMN",
150019 /* 165 */ "UMINUS",
150020 /* 166 */ "UPLUS",
150021 /* 167 */ "TRUTH",
150022 /* 168 */ "REGISTER",
150023 /* 169 */ "VECTOR",
150024 /* 170 */ "SELECT_COLUMN",
150025 /* 171 */ "IF_NULL_ROW",
150026 /* 172 */ "ASTERISK",
150027 /* 173 */ "SPAN",
150028 /* 174 */ "SPACE",
150029 /* 175 */ "ILLEGAL",
150030 /* 176 */ "input",
150031 /* 177 */ "cmdlist",
150032 /* 178 */ "ecmd",
150033 /* 179 */ "cmdx",
150034 /* 180 */ "explain",
150035 /* 181 */ "cmd",
150036 /* 182 */ "transtype",
150037 /* 183 */ "trans_opt",
150038 /* 184 */ "nm",
150039 /* 185 */ "savepoint_opt",
150040 /* 186 */ "create_table",
150041 /* 187 */ "create_table_args",
150042 /* 188 */ "createkw",
150043 /* 189 */ "temp",
150044 /* 190 */ "ifnotexists",
150045 /* 191 */ "dbnm",
150046 /* 192 */ "columnlist",
150047 /* 193 */ "conslist_opt",
150048 /* 194 */ "table_options",
150049 /* 195 */ "select",
150050 /* 196 */ "columnname",
150051 /* 197 */ "carglist",
150052 /* 198 */ "typetoken",
150053 /* 199 */ "typename",
150054 /* 200 */ "signed",
150055 /* 201 */ "plus_num",
150056 /* 202 */ "minus_num",
150057 /* 203 */ "scanpt",
150058 /* 204 */ "scantok",
150059 /* 205 */ "ccons",
150060 /* 206 */ "term",
150061 /* 207 */ "expr",
150062 /* 208 */ "onconf",
150063 /* 209 */ "sortorder",
150064 /* 210 */ "autoinc",
150065 /* 211 */ "eidlist_opt",
150066 /* 212 */ "refargs",
150067 /* 213 */ "defer_subclause",
150068 /* 214 */ "refarg",
150069 /* 215 */ "refact",
150070 /* 216 */ "init_deferred_pred_opt",
150071 /* 217 */ "conslist",
150072 /* 218 */ "tconscomma",
150073 /* 219 */ "tcons",
150074 /* 220 */ "sortlist",
150075 /* 221 */ "eidlist",
150076 /* 222 */ "defer_subclause_opt",
150077 /* 223 */ "orconf",
150078 /* 224 */ "resolvetype",
150079 /* 225 */ "raisetype",
150080 /* 226 */ "ifexists",
150081 /* 227 */ "fullname",
150082 /* 228 */ "selectnowith",
150083 /* 229 */ "oneselect",
150084 /* 230 */ "wqlist",
150085 /* 231 */ "multiselect_op",
150086 /* 232 */ "distinct",
150087 /* 233 */ "selcollist",
150088 /* 234 */ "from",
150089 /* 235 */ "where_opt",
150090 /* 236 */ "groupby_opt",
150091 /* 237 */ "having_opt",
150092 /* 238 */ "orderby_opt",
150093 /* 239 */ "limit_opt",
150094 /* 240 */ "window_clause",
150095 /* 241 */ "values",
150096 /* 242 */ "nexprlist",
150097 /* 243 */ "sclp",
150098 /* 244 */ "as",
150099 /* 245 */ "seltablist",
150100 /* 246 */ "stl_prefix",
150101 /* 247 */ "joinop",
150102 /* 248 */ "indexed_opt",
150103 /* 249 */ "on_opt",
150104 /* 250 */ "using_opt",
150105 /* 251 */ "exprlist",
150106 /* 252 */ "xfullname",
150107 /* 253 */ "idlist",
150108 /* 254 */ "with",
150109 /* 255 */ "setlist",
150110 /* 256 */ "insert_cmd",
150111 /* 257 */ "idlist_opt",
150112 /* 258 */ "upsert",
150113 /* 259 */ "over_clause",
150114 /* 260 */ "likeop",
150115 /* 261 */ "between_op",
150116 /* 262 */ "in_op",
150117 /* 263 */ "paren_exprlist",
150118 /* 264 */ "case_operand",
150119 /* 265 */ "case_exprlist",
150120 /* 266 */ "case_else",
150121 /* 267 */ "uniqueflag",
150122 /* 268 */ "collate",
150123 /* 269 */ "vinto",
150124 /* 270 */ "nmnum",
150125 /* 271 */ "trigger_decl",
150126 /* 272 */ "trigger_cmd_list",
150127 /* 273 */ "trigger_time",
150128 /* 274 */ "trigger_event",
150129 /* 275 */ "foreach_clause",
150130 /* 276 */ "when_clause",
150131 /* 277 */ "trigger_cmd",
150132 /* 278 */ "trnm",
150133 /* 279 */ "tridxby",
150134 /* 280 */ "database_kw_opt",
150135 /* 281 */ "key_opt",
150136 /* 282 */ "add_column_fullname",
150137 /* 283 */ "kwcolumn_opt",
150138 /* 284 */ "create_vtab",
150139 /* 285 */ "vtabarglist",
150140 /* 286 */ "vtabarg",
150141 /* 287 */ "vtabargtoken",
150142 /* 288 */ "lp",
150143 /* 289 */ "anylist",
150144 /* 290 */ "windowdefn_list",
150145 /* 291 */ "windowdefn",
150146 /* 292 */ "window",
150147 /* 293 */ "frame_opt",
150148 /* 294 */ "part_opt",
150149 /* 295 */ "filter_opt",
150150 /* 296 */ "range_or_rows",
150151 /* 297 */ "frame_bound",
150152 /* 298 */ "frame_bound_s",
150153 /* 299 */ "frame_bound_e",
150154 /* 300 */ "frame_exclude_opt",
150155 /* 301 */ "frame_exclude",
 
 
 
 
 
150156 };
150157 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
150158
150159 #ifndef NDEBUG
150160 /* For tracing reduce actions, the names of all rules are required.
@@ -150288,256 +151097,261 @@
150288 /* 125 */ "indexed_opt ::= NOT INDEXED",
150289 /* 126 */ "using_opt ::= USING LP idlist RP",
150290 /* 127 */ "using_opt ::=",
150291 /* 128 */ "orderby_opt ::=",
150292 /* 129 */ "orderby_opt ::= ORDER BY sortlist",
150293 /* 130 */ "sortlist ::= sortlist COMMA expr sortorder",
150294 /* 131 */ "sortlist ::= expr sortorder",
150295 /* 132 */ "sortorder ::= ASC",
150296 /* 133 */ "sortorder ::= DESC",
150297 /* 134 */ "sortorder ::=",
150298 /* 135 */ "groupby_opt ::=",
150299 /* 136 */ "groupby_opt ::= GROUP BY nexprlist",
150300 /* 137 */ "having_opt ::=",
150301 /* 138 */ "having_opt ::= HAVING expr",
150302 /* 139 */ "limit_opt ::=",
150303 /* 140 */ "limit_opt ::= LIMIT expr",
150304 /* 141 */ "limit_opt ::= LIMIT expr OFFSET expr",
150305 /* 142 */ "limit_opt ::= LIMIT expr COMMA expr",
150306 /* 143 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
150307 /* 144 */ "where_opt ::=",
150308 /* 145 */ "where_opt ::= WHERE expr",
150309 /* 146 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
150310 /* 147 */ "setlist ::= setlist COMMA nm EQ expr",
150311 /* 148 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
150312 /* 149 */ "setlist ::= nm EQ expr",
150313 /* 150 */ "setlist ::= LP idlist RP EQ expr",
150314 /* 151 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
150315 /* 152 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
150316 /* 153 */ "upsert ::=",
150317 /* 154 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
150318 /* 155 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
150319 /* 156 */ "upsert ::= ON CONFLICT DO NOTHING",
150320 /* 157 */ "insert_cmd ::= INSERT orconf",
150321 /* 158 */ "insert_cmd ::= REPLACE",
150322 /* 159 */ "idlist_opt ::=",
150323 /* 160 */ "idlist_opt ::= LP idlist RP",
150324 /* 161 */ "idlist ::= idlist COMMA nm",
150325 /* 162 */ "idlist ::= nm",
150326 /* 163 */ "expr ::= LP expr RP",
150327 /* 164 */ "expr ::= ID|INDEXED",
150328 /* 165 */ "expr ::= JOIN_KW",
150329 /* 166 */ "expr ::= nm DOT nm",
150330 /* 167 */ "expr ::= nm DOT nm DOT nm",
150331 /* 168 */ "term ::= NULL|FLOAT|BLOB",
150332 /* 169 */ "term ::= STRING",
150333 /* 170 */ "term ::= INTEGER",
150334 /* 171 */ "expr ::= VARIABLE",
150335 /* 172 */ "expr ::= expr COLLATE ID|STRING",
150336 /* 173 */ "expr ::= CAST LP expr AS typetoken RP",
150337 /* 174 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
150338 /* 175 */ "expr ::= ID|INDEXED LP STAR RP",
150339 /* 176 */ "expr ::= ID|INDEXED LP distinct exprlist RP over_clause",
150340 /* 177 */ "expr ::= ID|INDEXED LP STAR RP over_clause",
150341 /* 178 */ "term ::= CTIME_KW",
150342 /* 179 */ "expr ::= LP nexprlist COMMA expr RP",
150343 /* 180 */ "expr ::= expr AND expr",
150344 /* 181 */ "expr ::= expr OR expr",
150345 /* 182 */ "expr ::= expr LT|GT|GE|LE expr",
150346 /* 183 */ "expr ::= expr EQ|NE expr",
150347 /* 184 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
150348 /* 185 */ "expr ::= expr PLUS|MINUS expr",
150349 /* 186 */ "expr ::= expr STAR|SLASH|REM expr",
150350 /* 187 */ "expr ::= expr CONCAT expr",
150351 /* 188 */ "likeop ::= NOT LIKE_KW|MATCH",
150352 /* 189 */ "expr ::= expr likeop expr",
150353 /* 190 */ "expr ::= expr likeop expr ESCAPE expr",
150354 /* 191 */ "expr ::= expr ISNULL|NOTNULL",
150355 /* 192 */ "expr ::= expr NOT NULL",
150356 /* 193 */ "expr ::= expr IS expr",
150357 /* 194 */ "expr ::= expr IS NOT expr",
150358 /* 195 */ "expr ::= NOT expr",
150359 /* 196 */ "expr ::= BITNOT expr",
150360 /* 197 */ "expr ::= PLUS|MINUS expr",
150361 /* 198 */ "between_op ::= BETWEEN",
150362 /* 199 */ "between_op ::= NOT BETWEEN",
150363 /* 200 */ "expr ::= expr between_op expr AND expr",
150364 /* 201 */ "in_op ::= IN",
150365 /* 202 */ "in_op ::= NOT IN",
150366 /* 203 */ "expr ::= expr in_op LP exprlist RP",
150367 /* 204 */ "expr ::= LP select RP",
150368 /* 205 */ "expr ::= expr in_op LP select RP",
150369 /* 206 */ "expr ::= expr in_op nm dbnm paren_exprlist",
150370 /* 207 */ "expr ::= EXISTS LP select RP",
150371 /* 208 */ "expr ::= CASE case_operand case_exprlist case_else END",
150372 /* 209 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
150373 /* 210 */ "case_exprlist ::= WHEN expr THEN expr",
150374 /* 211 */ "case_else ::= ELSE expr",
150375 /* 212 */ "case_else ::=",
150376 /* 213 */ "case_operand ::= expr",
150377 /* 214 */ "case_operand ::=",
150378 /* 215 */ "exprlist ::=",
150379 /* 216 */ "nexprlist ::= nexprlist COMMA expr",
150380 /* 217 */ "nexprlist ::= expr",
150381 /* 218 */ "paren_exprlist ::=",
150382 /* 219 */ "paren_exprlist ::= LP exprlist RP",
150383 /* 220 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
150384 /* 221 */ "uniqueflag ::= UNIQUE",
150385 /* 222 */ "uniqueflag ::=",
150386 /* 223 */ "eidlist_opt ::=",
150387 /* 224 */ "eidlist_opt ::= LP eidlist RP",
150388 /* 225 */ "eidlist ::= eidlist COMMA nm collate sortorder",
150389 /* 226 */ "eidlist ::= nm collate sortorder",
150390 /* 227 */ "collate ::=",
150391 /* 228 */ "collate ::= COLLATE ID|STRING",
150392 /* 229 */ "cmd ::= DROP INDEX ifexists fullname",
150393 /* 230 */ "cmd ::= VACUUM vinto",
150394 /* 231 */ "cmd ::= VACUUM nm vinto",
150395 /* 232 */ "vinto ::= INTO expr",
150396 /* 233 */ "vinto ::=",
150397 /* 234 */ "cmd ::= PRAGMA nm dbnm",
150398 /* 235 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
150399 /* 236 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
150400 /* 237 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
150401 /* 238 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
150402 /* 239 */ "plus_num ::= PLUS INTEGER|FLOAT",
150403 /* 240 */ "minus_num ::= MINUS INTEGER|FLOAT",
150404 /* 241 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
150405 /* 242 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
150406 /* 243 */ "trigger_time ::= BEFORE|AFTER",
150407 /* 244 */ "trigger_time ::= INSTEAD OF",
150408 /* 245 */ "trigger_time ::=",
150409 /* 246 */ "trigger_event ::= DELETE|INSERT",
150410 /* 247 */ "trigger_event ::= UPDATE",
150411 /* 248 */ "trigger_event ::= UPDATE OF idlist",
150412 /* 249 */ "when_clause ::=",
150413 /* 250 */ "when_clause ::= WHEN expr",
150414 /* 251 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
150415 /* 252 */ "trigger_cmd_list ::= trigger_cmd SEMI",
150416 /* 253 */ "trnm ::= nm DOT nm",
150417 /* 254 */ "tridxby ::= INDEXED BY nm",
150418 /* 255 */ "tridxby ::= NOT INDEXED",
150419 /* 256 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
150420 /* 257 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
150421 /* 258 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
150422 /* 259 */ "trigger_cmd ::= scanpt select scanpt",
150423 /* 260 */ "expr ::= RAISE LP IGNORE RP",
150424 /* 261 */ "expr ::= RAISE LP raisetype COMMA nm RP",
150425 /* 262 */ "raisetype ::= ROLLBACK",
150426 /* 263 */ "raisetype ::= ABORT",
150427 /* 264 */ "raisetype ::= FAIL",
150428 /* 265 */ "cmd ::= DROP TRIGGER ifexists fullname",
150429 /* 266 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
150430 /* 267 */ "cmd ::= DETACH database_kw_opt expr",
150431 /* 268 */ "key_opt ::=",
150432 /* 269 */ "key_opt ::= KEY expr",
150433 /* 270 */ "cmd ::= REINDEX",
150434 /* 271 */ "cmd ::= REINDEX nm dbnm",
150435 /* 272 */ "cmd ::= ANALYZE",
150436 /* 273 */ "cmd ::= ANALYZE nm dbnm",
150437 /* 274 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
150438 /* 275 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
150439 /* 276 */ "add_column_fullname ::= fullname",
150440 /* 277 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
150441 /* 278 */ "cmd ::= create_vtab",
150442 /* 279 */ "cmd ::= create_vtab LP vtabarglist RP",
150443 /* 280 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
150444 /* 281 */ "vtabarg ::=",
150445 /* 282 */ "vtabargtoken ::= ANY",
150446 /* 283 */ "vtabargtoken ::= lp anylist RP",
150447 /* 284 */ "lp ::= LP",
150448 /* 285 */ "with ::= WITH wqlist",
150449 /* 286 */ "with ::= WITH RECURSIVE wqlist",
150450 /* 287 */ "wqlist ::= nm eidlist_opt AS LP select RP",
150451 /* 288 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
150452 /* 289 */ "windowdefn_list ::= windowdefn",
150453 /* 290 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
150454 /* 291 */ "windowdefn ::= nm AS LP window RP",
150455 /* 292 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
150456 /* 293 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
150457 /* 294 */ "window ::= ORDER BY sortlist frame_opt",
150458 /* 295 */ "window ::= nm ORDER BY sortlist frame_opt",
150459 /* 296 */ "window ::= frame_opt",
150460 /* 297 */ "window ::= nm frame_opt",
150461 /* 298 */ "frame_opt ::=",
150462 /* 299 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
150463 /* 300 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
150464 /* 301 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
150465 /* 302 */ "frame_bound_s ::= frame_bound",
150466 /* 303 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
150467 /* 304 */ "frame_bound_e ::= frame_bound",
150468 /* 305 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
150469 /* 306 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
150470 /* 307 */ "frame_bound ::= CURRENT ROW",
150471 /* 308 */ "frame_exclude_opt ::=",
150472 /* 309 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
150473 /* 310 */ "frame_exclude ::= NO OTHERS",
150474 /* 311 */ "frame_exclude ::= CURRENT ROW",
150475 /* 312 */ "frame_exclude ::= GROUP|TIES",
150476 /* 313 */ "window_clause ::= WINDOW windowdefn_list",
150477 /* 314 */ "over_clause ::= filter_opt OVER LP window RP",
150478 /* 315 */ "over_clause ::= filter_opt OVER nm",
150479 /* 316 */ "filter_opt ::=",
150480 /* 317 */ "filter_opt ::= FILTER LP WHERE expr RP",
150481 /* 318 */ "input ::= cmdlist",
150482 /* 319 */ "cmdlist ::= cmdlist ecmd",
150483 /* 320 */ "cmdlist ::= ecmd",
150484 /* 321 */ "ecmd ::= SEMI",
150485 /* 322 */ "ecmd ::= cmdx SEMI",
150486 /* 323 */ "ecmd ::= explain cmdx",
150487 /* 324 */ "trans_opt ::=",
150488 /* 325 */ "trans_opt ::= TRANSACTION",
150489 /* 326 */ "trans_opt ::= TRANSACTION nm",
150490 /* 327 */ "savepoint_opt ::= SAVEPOINT",
150491 /* 328 */ "savepoint_opt ::=",
150492 /* 329 */ "cmd ::= create_table create_table_args",
150493 /* 330 */ "columnlist ::= columnlist COMMA columnname carglist",
150494 /* 331 */ "columnlist ::= columnname carglist",
150495 /* 332 */ "nm ::= ID|INDEXED",
150496 /* 333 */ "nm ::= STRING",
150497 /* 334 */ "nm ::= JOIN_KW",
150498 /* 335 */ "typetoken ::= typename",
150499 /* 336 */ "typename ::= ID|STRING",
150500 /* 337 */ "signed ::= plus_num",
150501 /* 338 */ "signed ::= minus_num",
150502 /* 339 */ "carglist ::= carglist ccons",
150503 /* 340 */ "carglist ::=",
150504 /* 341 */ "ccons ::= NULL onconf",
150505 /* 342 */ "conslist_opt ::= COMMA conslist",
150506 /* 343 */ "conslist ::= conslist tconscomma tcons",
150507 /* 344 */ "conslist ::= tcons",
150508 /* 345 */ "tconscomma ::=",
150509 /* 346 */ "defer_subclause_opt ::= defer_subclause",
150510 /* 347 */ "resolvetype ::= raisetype",
150511 /* 348 */ "selectnowith ::= oneselect",
150512 /* 349 */ "oneselect ::= values",
150513 /* 350 */ "sclp ::= selcollist COMMA",
150514 /* 351 */ "as ::= ID|STRING",
150515 /* 352 */ "expr ::= term",
150516 /* 353 */ "likeop ::= LIKE_KW|MATCH",
150517 /* 354 */ "exprlist ::= nexprlist",
150518 /* 355 */ "nmnum ::= plus_num",
150519 /* 356 */ "nmnum ::= nm",
150520 /* 357 */ "nmnum ::= ON",
150521 /* 358 */ "nmnum ::= DELETE",
150522 /* 359 */ "nmnum ::= DEFAULT",
150523 /* 360 */ "plus_num ::= INTEGER|FLOAT",
150524 /* 361 */ "foreach_clause ::=",
150525 /* 362 */ "foreach_clause ::= FOR EACH ROW",
150526 /* 363 */ "trnm ::= nm",
150527 /* 364 */ "tridxby ::=",
150528 /* 365 */ "database_kw_opt ::= DATABASE",
150529 /* 366 */ "database_kw_opt ::=",
150530 /* 367 */ "kwcolumn_opt ::=",
150531 /* 368 */ "kwcolumn_opt ::= COLUMNKW",
150532 /* 369 */ "vtabarglist ::= vtabarg",
150533 /* 370 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
150534 /* 371 */ "vtabarg ::= vtabarg vtabargtoken",
150535 /* 372 */ "anylist ::=",
150536 /* 373 */ "anylist ::= anylist LP anylist RP",
150537 /* 374 */ "anylist ::= anylist ANY",
150538 /* 375 */ "with ::=",
 
 
 
 
 
150539 };
150540 #endif /* NDEBUG */
150541
150542
150543 #if YYSTACKDEPTH<=0
@@ -150659,101 +151473,102 @@
150659 ** Note: during a reduce, the only symbols destroyed are those
150660 ** which appear on the RHS of the rule, but which are *not* used
150661 ** inside the C code.
150662 */
150663 /********* Begin destructor definitions ***************************************/
150664 case 195: /* select */
150665 case 228: /* selectnowith */
150666 case 229: /* oneselect */
150667 case 241: /* values */
150668 {
150669 sqlite3SelectDelete(pParse->db, (yypminor->yy391));
150670 }
150671 break;
150672 case 206: /* term */
150673 case 207: /* expr */
150674 case 235: /* where_opt */
150675 case 237: /* having_opt */
150676 case 249: /* on_opt */
150677 case 264: /* case_operand */
150678 case 266: /* case_else */
150679 case 269: /* vinto */
150680 case 276: /* when_clause */
150681 case 281: /* key_opt */
150682 case 295: /* filter_opt */
150683 {
150684 sqlite3ExprDelete(pParse->db, (yypminor->yy102));
150685 }
150686 break;
150687 case 211: /* eidlist_opt */
150688 case 220: /* sortlist */
150689 case 221: /* eidlist */
150690 case 233: /* selcollist */
150691 case 236: /* groupby_opt */
150692 case 238: /* orderby_opt */
150693 case 242: /* nexprlist */
150694 case 243: /* sclp */
150695 case 251: /* exprlist */
150696 case 255: /* setlist */
150697 case 263: /* paren_exprlist */
150698 case 265: /* case_exprlist */
150699 case 294: /* part_opt */
150700 {
150701 sqlite3ExprListDelete(pParse->db, (yypminor->yy94));
150702 }
150703 break;
150704 case 227: /* fullname */
150705 case 234: /* from */
150706 case 245: /* seltablist */
150707 case 246: /* stl_prefix */
150708 case 252: /* xfullname */
150709 {
150710 sqlite3SrcListDelete(pParse->db, (yypminor->yy407));
150711 }
150712 break;
150713 case 230: /* wqlist */
150714 {
150715 sqlite3WithDelete(pParse->db, (yypminor->yy243));
150716 }
150717 break;
150718 case 240: /* window_clause */
150719 case 290: /* windowdefn_list */
150720 {
150721 sqlite3WindowListDelete(pParse->db, (yypminor->yy379));
150722 }
150723 break;
150724 case 250: /* using_opt */
150725 case 253: /* idlist */
150726 case 257: /* idlist_opt */
150727 {
150728 sqlite3IdListDelete(pParse->db, (yypminor->yy76));
150729 }
150730 break;
150731 case 259: /* over_clause */
150732 case 291: /* windowdefn */
150733 case 292: /* window */
150734 case 293: /* frame_opt */
150735 {
150736 sqlite3WindowDelete(pParse->db, (yypminor->yy379));
150737 }
150738 break;
150739 case 272: /* trigger_cmd_list */
150740 case 277: /* trigger_cmd */
150741 {
150742 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy11));
150743 }
150744 break;
150745 case 274: /* trigger_event */
150746 {
150747 sqlite3IdListDelete(pParse->db, (yypminor->yy298).b);
150748 }
150749 break;
150750 case 297: /* frame_bound */
150751 case 298: /* frame_bound_s */
150752 case 299: /* frame_bound_e */
150753 {
150754 sqlite3ExprDelete(pParse->db, (yypminor->yy389).pExpr);
 
150755 }
150756 break;
150757 /********* End destructor definitions *****************************************/
150758 default: break; /* If no destructor action specified: do nothing */
150759 }
@@ -150875,19 +151690,22 @@
150875 yycoverage[stateno][iLookAhead] = 1;
150876 #endif
150877 do{
150878 i = yy_shift_ofst[stateno];
150879 assert( i>=0 );
150880 /* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */
 
150881 assert( iLookAhead!=YYNOCODE );
150882 assert( iLookAhead < YYNTOKEN );
150883 i += iLookAhead;
150884 if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){
 
150885 #ifdef YYFALLBACK
150886 YYCODETYPE iFallback; /* Fallback token */
150887 if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
150888 && (iFallback = yyFallback[iLookAhead])!=0 ){
 
150889 #ifndef NDEBUG
150890 if( yyTraceFILE ){
150891 fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
150892 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
150893 }
@@ -150898,20 +151716,12 @@
150898 }
150899 #endif
150900 #ifdef YYWILDCARD
150901 {
150902 int j = i - iLookAhead + YYWILDCARD;
150903 if(
150904 #if YY_SHIFT_MIN+YYWILDCARD<0
150905 j>=0 &&
150906 #endif
150907 #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
150908 j<YY_ACTTAB_COUNT &&
150909 #endif
150910 j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) &&
150911 yy_lookahead[j]==YYWILDCARD && iLookAhead>0
150912 ){
150913 #ifndef NDEBUG
150914 if( yyTraceFILE ){
150915 fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
150916 yyTracePrompt, yyTokenName[iLookAhead],
150917 yyTokenName[YYWILDCARD]);
@@ -150921,10 +151731,11 @@
150921 }
150922 }
150923 #endif /* YYWILDCARD */
150924 return yy_default[stateno];
150925 }else{
 
150926 return yy_action[i];
150927 }
150928 }while(1);
150929 }
150930
@@ -151044,386 +151855,391 @@
151044 }
151045
151046 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
151047 ** of that rule */
151048 static const YYCODETYPE yyRuleInfoLhs[] = {
151049 180, /* (0) explain ::= EXPLAIN */
151050 180, /* (1) explain ::= EXPLAIN QUERY PLAN */
151051 179, /* (2) cmdx ::= cmd */
151052 181, /* (3) cmd ::= BEGIN transtype trans_opt */
151053 182, /* (4) transtype ::= */
151054 182, /* (5) transtype ::= DEFERRED */
151055 182, /* (6) transtype ::= IMMEDIATE */
151056 182, /* (7) transtype ::= EXCLUSIVE */
151057 181, /* (8) cmd ::= COMMIT|END trans_opt */
151058 181, /* (9) cmd ::= ROLLBACK trans_opt */
151059 181, /* (10) cmd ::= SAVEPOINT nm */
151060 181, /* (11) cmd ::= RELEASE savepoint_opt nm */
151061 181, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
151062 186, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
151063 188, /* (14) createkw ::= CREATE */
151064 190, /* (15) ifnotexists ::= */
151065 190, /* (16) ifnotexists ::= IF NOT EXISTS */
151066 189, /* (17) temp ::= TEMP */
151067 189, /* (18) temp ::= */
151068 187, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
151069 187, /* (20) create_table_args ::= AS select */
151070 194, /* (21) table_options ::= */
151071 194, /* (22) table_options ::= WITHOUT nm */
151072 196, /* (23) columnname ::= nm typetoken */
151073 198, /* (24) typetoken ::= */
151074 198, /* (25) typetoken ::= typename LP signed RP */
151075 198, /* (26) typetoken ::= typename LP signed COMMA signed RP */
151076 199, /* (27) typename ::= typename ID|STRING */
151077 203, /* (28) scanpt ::= */
151078 204, /* (29) scantok ::= */
151079 205, /* (30) ccons ::= CONSTRAINT nm */
151080 205, /* (31) ccons ::= DEFAULT scantok term */
151081 205, /* (32) ccons ::= DEFAULT LP expr RP */
151082 205, /* (33) ccons ::= DEFAULT PLUS scantok term */
151083 205, /* (34) ccons ::= DEFAULT MINUS scantok term */
151084 205, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
151085 205, /* (36) ccons ::= NOT NULL onconf */
151086 205, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
151087 205, /* (38) ccons ::= UNIQUE onconf */
151088 205, /* (39) ccons ::= CHECK LP expr RP */
151089 205, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
151090 205, /* (41) ccons ::= defer_subclause */
151091 205, /* (42) ccons ::= COLLATE ID|STRING */
151092 210, /* (43) autoinc ::= */
151093 210, /* (44) autoinc ::= AUTOINCR */
151094 212, /* (45) refargs ::= */
151095 212, /* (46) refargs ::= refargs refarg */
151096 214, /* (47) refarg ::= MATCH nm */
151097 214, /* (48) refarg ::= ON INSERT refact */
151098 214, /* (49) refarg ::= ON DELETE refact */
151099 214, /* (50) refarg ::= ON UPDATE refact */
151100 215, /* (51) refact ::= SET NULL */
151101 215, /* (52) refact ::= SET DEFAULT */
151102 215, /* (53) refact ::= CASCADE */
151103 215, /* (54) refact ::= RESTRICT */
151104 215, /* (55) refact ::= NO ACTION */
151105 213, /* (56) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
151106 213, /* (57) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
151107 216, /* (58) init_deferred_pred_opt ::= */
151108 216, /* (59) init_deferred_pred_opt ::= INITIALLY DEFERRED */
151109 216, /* (60) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
151110 193, /* (61) conslist_opt ::= */
151111 218, /* (62) tconscomma ::= COMMA */
151112 219, /* (63) tcons ::= CONSTRAINT nm */
151113 219, /* (64) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
151114 219, /* (65) tcons ::= UNIQUE LP sortlist RP onconf */
151115 219, /* (66) tcons ::= CHECK LP expr RP onconf */
151116 219, /* (67) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
151117 222, /* (68) defer_subclause_opt ::= */
151118 208, /* (69) onconf ::= */
151119 208, /* (70) onconf ::= ON CONFLICT resolvetype */
151120 223, /* (71) orconf ::= */
151121 223, /* (72) orconf ::= OR resolvetype */
151122 224, /* (73) resolvetype ::= IGNORE */
151123 224, /* (74) resolvetype ::= REPLACE */
151124 181, /* (75) cmd ::= DROP TABLE ifexists fullname */
151125 226, /* (76) ifexists ::= IF EXISTS */
151126 226, /* (77) ifexists ::= */
151127 181, /* (78) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
151128 181, /* (79) cmd ::= DROP VIEW ifexists fullname */
151129 181, /* (80) cmd ::= select */
151130 195, /* (81) select ::= WITH wqlist selectnowith */
151131 195, /* (82) select ::= WITH RECURSIVE wqlist selectnowith */
151132 195, /* (83) select ::= selectnowith */
151133 228, /* (84) selectnowith ::= selectnowith multiselect_op oneselect */
151134 231, /* (85) multiselect_op ::= UNION */
151135 231, /* (86) multiselect_op ::= UNION ALL */
151136 231, /* (87) multiselect_op ::= EXCEPT|INTERSECT */
151137 229, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
151138 229, /* (89) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
151139 241, /* (90) values ::= VALUES LP nexprlist RP */
151140 241, /* (91) values ::= values COMMA LP nexprlist RP */
151141 232, /* (92) distinct ::= DISTINCT */
151142 232, /* (93) distinct ::= ALL */
151143 232, /* (94) distinct ::= */
151144 243, /* (95) sclp ::= */
151145 233, /* (96) selcollist ::= sclp scanpt expr scanpt as */
151146 233, /* (97) selcollist ::= sclp scanpt STAR */
151147 233, /* (98) selcollist ::= sclp scanpt nm DOT STAR */
151148 244, /* (99) as ::= AS nm */
151149 244, /* (100) as ::= */
151150 234, /* (101) from ::= */
151151 234, /* (102) from ::= FROM seltablist */
151152 246, /* (103) stl_prefix ::= seltablist joinop */
151153 246, /* (104) stl_prefix ::= */
151154 245, /* (105) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
151155 245, /* (106) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
151156 245, /* (107) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
151157 245, /* (108) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
151158 191, /* (109) dbnm ::= */
151159 191, /* (110) dbnm ::= DOT nm */
151160 227, /* (111) fullname ::= nm */
151161 227, /* (112) fullname ::= nm DOT nm */
151162 252, /* (113) xfullname ::= nm */
151163 252, /* (114) xfullname ::= nm DOT nm */
151164 252, /* (115) xfullname ::= nm DOT nm AS nm */
151165 252, /* (116) xfullname ::= nm AS nm */
151166 247, /* (117) joinop ::= COMMA|JOIN */
151167 247, /* (118) joinop ::= JOIN_KW JOIN */
151168 247, /* (119) joinop ::= JOIN_KW nm JOIN */
151169 247, /* (120) joinop ::= JOIN_KW nm nm JOIN */
151170 249, /* (121) on_opt ::= ON expr */
151171 249, /* (122) on_opt ::= */
151172 248, /* (123) indexed_opt ::= */
151173 248, /* (124) indexed_opt ::= INDEXED BY nm */
151174 248, /* (125) indexed_opt ::= NOT INDEXED */
151175 250, /* (126) using_opt ::= USING LP idlist RP */
151176 250, /* (127) using_opt ::= */
151177 238, /* (128) orderby_opt ::= */
151178 238, /* (129) orderby_opt ::= ORDER BY sortlist */
151179 220, /* (130) sortlist ::= sortlist COMMA expr sortorder */
151180 220, /* (131) sortlist ::= expr sortorder */
151181 209, /* (132) sortorder ::= ASC */
151182 209, /* (133) sortorder ::= DESC */
151183 209, /* (134) sortorder ::= */
151184 236, /* (135) groupby_opt ::= */
151185 236, /* (136) groupby_opt ::= GROUP BY nexprlist */
151186 237, /* (137) having_opt ::= */
151187 237, /* (138) having_opt ::= HAVING expr */
151188 239, /* (139) limit_opt ::= */
151189 239, /* (140) limit_opt ::= LIMIT expr */
151190 239, /* (141) limit_opt ::= LIMIT expr OFFSET expr */
151191 239, /* (142) limit_opt ::= LIMIT expr COMMA expr */
151192 181, /* (143) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
151193 235, /* (144) where_opt ::= */
151194 235, /* (145) where_opt ::= WHERE expr */
151195 181, /* (146) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
151196 255, /* (147) setlist ::= setlist COMMA nm EQ expr */
151197 255, /* (148) setlist ::= setlist COMMA LP idlist RP EQ expr */
151198 255, /* (149) setlist ::= nm EQ expr */
151199 255, /* (150) setlist ::= LP idlist RP EQ expr */
151200 181, /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
151201 181, /* (152) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
151202 258, /* (153) upsert ::= */
151203 258, /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
151204 258, /* (155) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
151205 258, /* (156) upsert ::= ON CONFLICT DO NOTHING */
151206 256, /* (157) insert_cmd ::= INSERT orconf */
151207 256, /* (158) insert_cmd ::= REPLACE */
151208 257, /* (159) idlist_opt ::= */
151209 257, /* (160) idlist_opt ::= LP idlist RP */
151210 253, /* (161) idlist ::= idlist COMMA nm */
151211 253, /* (162) idlist ::= nm */
151212 207, /* (163) expr ::= LP expr RP */
151213 207, /* (164) expr ::= ID|INDEXED */
151214 207, /* (165) expr ::= JOIN_KW */
151215 207, /* (166) expr ::= nm DOT nm */
151216 207, /* (167) expr ::= nm DOT nm DOT nm */
151217 206, /* (168) term ::= NULL|FLOAT|BLOB */
151218 206, /* (169) term ::= STRING */
151219 206, /* (170) term ::= INTEGER */
151220 207, /* (171) expr ::= VARIABLE */
151221 207, /* (172) expr ::= expr COLLATE ID|STRING */
151222 207, /* (173) expr ::= CAST LP expr AS typetoken RP */
151223 207, /* (174) expr ::= ID|INDEXED LP distinct exprlist RP */
151224 207, /* (175) expr ::= ID|INDEXED LP STAR RP */
151225 207, /* (176) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
151226 207, /* (177) expr ::= ID|INDEXED LP STAR RP over_clause */
151227 206, /* (178) term ::= CTIME_KW */
151228 207, /* (179) expr ::= LP nexprlist COMMA expr RP */
151229 207, /* (180) expr ::= expr AND expr */
151230 207, /* (181) expr ::= expr OR expr */
151231 207, /* (182) expr ::= expr LT|GT|GE|LE expr */
151232 207, /* (183) expr ::= expr EQ|NE expr */
151233 207, /* (184) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
151234 207, /* (185) expr ::= expr PLUS|MINUS expr */
151235 207, /* (186) expr ::= expr STAR|SLASH|REM expr */
151236 207, /* (187) expr ::= expr CONCAT expr */
151237 260, /* (188) likeop ::= NOT LIKE_KW|MATCH */
151238 207, /* (189) expr ::= expr likeop expr */
151239 207, /* (190) expr ::= expr likeop expr ESCAPE expr */
151240 207, /* (191) expr ::= expr ISNULL|NOTNULL */
151241 207, /* (192) expr ::= expr NOT NULL */
151242 207, /* (193) expr ::= expr IS expr */
151243 207, /* (194) expr ::= expr IS NOT expr */
151244 207, /* (195) expr ::= NOT expr */
151245 207, /* (196) expr ::= BITNOT expr */
151246 207, /* (197) expr ::= PLUS|MINUS expr */
151247 261, /* (198) between_op ::= BETWEEN */
151248 261, /* (199) between_op ::= NOT BETWEEN */
151249 207, /* (200) expr ::= expr between_op expr AND expr */
151250 262, /* (201) in_op ::= IN */
151251 262, /* (202) in_op ::= NOT IN */
151252 207, /* (203) expr ::= expr in_op LP exprlist RP */
151253 207, /* (204) expr ::= LP select RP */
151254 207, /* (205) expr ::= expr in_op LP select RP */
151255 207, /* (206) expr ::= expr in_op nm dbnm paren_exprlist */
151256 207, /* (207) expr ::= EXISTS LP select RP */
151257 207, /* (208) expr ::= CASE case_operand case_exprlist case_else END */
151258 265, /* (209) case_exprlist ::= case_exprlist WHEN expr THEN expr */
151259 265, /* (210) case_exprlist ::= WHEN expr THEN expr */
151260 266, /* (211) case_else ::= ELSE expr */
151261 266, /* (212) case_else ::= */
151262 264, /* (213) case_operand ::= expr */
151263 264, /* (214) case_operand ::= */
151264 251, /* (215) exprlist ::= */
151265 242, /* (216) nexprlist ::= nexprlist COMMA expr */
151266 242, /* (217) nexprlist ::= expr */
151267 263, /* (218) paren_exprlist ::= */
151268 263, /* (219) paren_exprlist ::= LP exprlist RP */
151269 181, /* (220) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
151270 267, /* (221) uniqueflag ::= UNIQUE */
151271 267, /* (222) uniqueflag ::= */
151272 211, /* (223) eidlist_opt ::= */
151273 211, /* (224) eidlist_opt ::= LP eidlist RP */
151274 221, /* (225) eidlist ::= eidlist COMMA nm collate sortorder */
151275 221, /* (226) eidlist ::= nm collate sortorder */
151276 268, /* (227) collate ::= */
151277 268, /* (228) collate ::= COLLATE ID|STRING */
151278 181, /* (229) cmd ::= DROP INDEX ifexists fullname */
151279 181, /* (230) cmd ::= VACUUM vinto */
151280 181, /* (231) cmd ::= VACUUM nm vinto */
151281 269, /* (232) vinto ::= INTO expr */
151282 269, /* (233) vinto ::= */
151283 181, /* (234) cmd ::= PRAGMA nm dbnm */
151284 181, /* (235) cmd ::= PRAGMA nm dbnm EQ nmnum */
151285 181, /* (236) cmd ::= PRAGMA nm dbnm LP nmnum RP */
151286 181, /* (237) cmd ::= PRAGMA nm dbnm EQ minus_num */
151287 181, /* (238) cmd ::= PRAGMA nm dbnm LP minus_num RP */
151288 201, /* (239) plus_num ::= PLUS INTEGER|FLOAT */
151289 202, /* (240) minus_num ::= MINUS INTEGER|FLOAT */
151290 181, /* (241) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
151291 271, /* (242) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
151292 273, /* (243) trigger_time ::= BEFORE|AFTER */
151293 273, /* (244) trigger_time ::= INSTEAD OF */
151294 273, /* (245) trigger_time ::= */
151295 274, /* (246) trigger_event ::= DELETE|INSERT */
151296 274, /* (247) trigger_event ::= UPDATE */
151297 274, /* (248) trigger_event ::= UPDATE OF idlist */
151298 276, /* (249) when_clause ::= */
151299 276, /* (250) when_clause ::= WHEN expr */
151300 272, /* (251) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
151301 272, /* (252) trigger_cmd_list ::= trigger_cmd SEMI */
151302 278, /* (253) trnm ::= nm DOT nm */
151303 279, /* (254) tridxby ::= INDEXED BY nm */
151304 279, /* (255) tridxby ::= NOT INDEXED */
151305 277, /* (256) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
151306 277, /* (257) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
151307 277, /* (258) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
151308 277, /* (259) trigger_cmd ::= scanpt select scanpt */
151309 207, /* (260) expr ::= RAISE LP IGNORE RP */
151310 207, /* (261) expr ::= RAISE LP raisetype COMMA nm RP */
151311 225, /* (262) raisetype ::= ROLLBACK */
151312 225, /* (263) raisetype ::= ABORT */
151313 225, /* (264) raisetype ::= FAIL */
151314 181, /* (265) cmd ::= DROP TRIGGER ifexists fullname */
151315 181, /* (266) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
151316 181, /* (267) cmd ::= DETACH database_kw_opt expr */
151317 281, /* (268) key_opt ::= */
151318 281, /* (269) key_opt ::= KEY expr */
151319 181, /* (270) cmd ::= REINDEX */
151320 181, /* (271) cmd ::= REINDEX nm dbnm */
151321 181, /* (272) cmd ::= ANALYZE */
151322 181, /* (273) cmd ::= ANALYZE nm dbnm */
151323 181, /* (274) cmd ::= ALTER TABLE fullname RENAME TO nm */
151324 181, /* (275) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
151325 282, /* (276) add_column_fullname ::= fullname */
151326 181, /* (277) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
151327 181, /* (278) cmd ::= create_vtab */
151328 181, /* (279) cmd ::= create_vtab LP vtabarglist RP */
151329 284, /* (280) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
151330 286, /* (281) vtabarg ::= */
151331 287, /* (282) vtabargtoken ::= ANY */
151332 287, /* (283) vtabargtoken ::= lp anylist RP */
151333 288, /* (284) lp ::= LP */
151334 254, /* (285) with ::= WITH wqlist */
151335 254, /* (286) with ::= WITH RECURSIVE wqlist */
151336 230, /* (287) wqlist ::= nm eidlist_opt AS LP select RP */
151337 230, /* (288) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
151338 290, /* (289) windowdefn_list ::= windowdefn */
151339 290, /* (290) windowdefn_list ::= windowdefn_list COMMA windowdefn */
151340 291, /* (291) windowdefn ::= nm AS LP window RP */
151341 292, /* (292) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
151342 292, /* (293) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
151343 292, /* (294) window ::= ORDER BY sortlist frame_opt */
151344 292, /* (295) window ::= nm ORDER BY sortlist frame_opt */
151345 292, /* (296) window ::= frame_opt */
151346 292, /* (297) window ::= nm frame_opt */
151347 293, /* (298) frame_opt ::= */
151348 293, /* (299) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
151349 293, /* (300) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
151350 296, /* (301) range_or_rows ::= RANGE|ROWS|GROUPS */
151351 298, /* (302) frame_bound_s ::= frame_bound */
151352 298, /* (303) frame_bound_s ::= UNBOUNDED PRECEDING */
151353 299, /* (304) frame_bound_e ::= frame_bound */
151354 299, /* (305) frame_bound_e ::= UNBOUNDED FOLLOWING */
151355 297, /* (306) frame_bound ::= expr PRECEDING|FOLLOWING */
151356 297, /* (307) frame_bound ::= CURRENT ROW */
151357 300, /* (308) frame_exclude_opt ::= */
151358 300, /* (309) frame_exclude_opt ::= EXCLUDE frame_exclude */
151359 301, /* (310) frame_exclude ::= NO OTHERS */
151360 301, /* (311) frame_exclude ::= CURRENT ROW */
151361 301, /* (312) frame_exclude ::= GROUP|TIES */
151362 240, /* (313) window_clause ::= WINDOW windowdefn_list */
151363 259, /* (314) over_clause ::= filter_opt OVER LP window RP */
151364 259, /* (315) over_clause ::= filter_opt OVER nm */
151365 295, /* (316) filter_opt ::= */
151366 295, /* (317) filter_opt ::= FILTER LP WHERE expr RP */
151367 176, /* (318) input ::= cmdlist */
151368 177, /* (319) cmdlist ::= cmdlist ecmd */
151369 177, /* (320) cmdlist ::= ecmd */
151370 178, /* (321) ecmd ::= SEMI */
151371 178, /* (322) ecmd ::= cmdx SEMI */
151372 178, /* (323) ecmd ::= explain cmdx */
151373 183, /* (324) trans_opt ::= */
151374 183, /* (325) trans_opt ::= TRANSACTION */
151375 183, /* (326) trans_opt ::= TRANSACTION nm */
151376 185, /* (327) savepoint_opt ::= SAVEPOINT */
151377 185, /* (328) savepoint_opt ::= */
151378 181, /* (329) cmd ::= create_table create_table_args */
151379 192, /* (330) columnlist ::= columnlist COMMA columnname carglist */
151380 192, /* (331) columnlist ::= columnname carglist */
151381 184, /* (332) nm ::= ID|INDEXED */
151382 184, /* (333) nm ::= STRING */
151383 184, /* (334) nm ::= JOIN_KW */
151384 198, /* (335) typetoken ::= typename */
151385 199, /* (336) typename ::= ID|STRING */
151386 200, /* (337) signed ::= plus_num */
151387 200, /* (338) signed ::= minus_num */
151388 197, /* (339) carglist ::= carglist ccons */
151389 197, /* (340) carglist ::= */
151390 205, /* (341) ccons ::= NULL onconf */
151391 193, /* (342) conslist_opt ::= COMMA conslist */
151392 217, /* (343) conslist ::= conslist tconscomma tcons */
151393 217, /* (344) conslist ::= tcons */
151394 218, /* (345) tconscomma ::= */
151395 222, /* (346) defer_subclause_opt ::= defer_subclause */
151396 224, /* (347) resolvetype ::= raisetype */
151397 228, /* (348) selectnowith ::= oneselect */
151398 229, /* (349) oneselect ::= values */
151399 243, /* (350) sclp ::= selcollist COMMA */
151400 244, /* (351) as ::= ID|STRING */
151401 207, /* (352) expr ::= term */
151402 260, /* (353) likeop ::= LIKE_KW|MATCH */
151403 251, /* (354) exprlist ::= nexprlist */
151404 270, /* (355) nmnum ::= plus_num */
151405 270, /* (356) nmnum ::= nm */
151406 270, /* (357) nmnum ::= ON */
151407 270, /* (358) nmnum ::= DELETE */
151408 270, /* (359) nmnum ::= DEFAULT */
151409 201, /* (360) plus_num ::= INTEGER|FLOAT */
151410 275, /* (361) foreach_clause ::= */
151411 275, /* (362) foreach_clause ::= FOR EACH ROW */
151412 278, /* (363) trnm ::= nm */
151413 279, /* (364) tridxby ::= */
151414 280, /* (365) database_kw_opt ::= DATABASE */
151415 280, /* (366) database_kw_opt ::= */
151416 283, /* (367) kwcolumn_opt ::= */
151417 283, /* (368) kwcolumn_opt ::= COLUMNKW */
151418 285, /* (369) vtabarglist ::= vtabarg */
151419 285, /* (370) vtabarglist ::= vtabarglist COMMA vtabarg */
151420 286, /* (371) vtabarg ::= vtabarg vtabargtoken */
151421 289, /* (372) anylist ::= */
151422 289, /* (373) anylist ::= anylist LP anylist RP */
151423 289, /* (374) anylist ::= anylist ANY */
151424 254, /* (375) with ::= */
 
 
 
 
 
151425 };
151426
151427 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
151428 ** of symbols on the right-hand side of that rule. */
151429 static const signed char yyRuleInfoNRhs[] = {
@@ -151555,256 +152371,261 @@
151555 -2, /* (125) indexed_opt ::= NOT INDEXED */
151556 -4, /* (126) using_opt ::= USING LP idlist RP */
151557 0, /* (127) using_opt ::= */
151558 0, /* (128) orderby_opt ::= */
151559 -3, /* (129) orderby_opt ::= ORDER BY sortlist */
151560 -4, /* (130) sortlist ::= sortlist COMMA expr sortorder */
151561 -2, /* (131) sortlist ::= expr sortorder */
151562 -1, /* (132) sortorder ::= ASC */
151563 -1, /* (133) sortorder ::= DESC */
151564 0, /* (134) sortorder ::= */
151565 0, /* (135) groupby_opt ::= */
151566 -3, /* (136) groupby_opt ::= GROUP BY nexprlist */
151567 0, /* (137) having_opt ::= */
151568 -2, /* (138) having_opt ::= HAVING expr */
151569 0, /* (139) limit_opt ::= */
151570 -2, /* (140) limit_opt ::= LIMIT expr */
151571 -4, /* (141) limit_opt ::= LIMIT expr OFFSET expr */
151572 -4, /* (142) limit_opt ::= LIMIT expr COMMA expr */
151573 -6, /* (143) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
151574 0, /* (144) where_opt ::= */
151575 -2, /* (145) where_opt ::= WHERE expr */
151576 -8, /* (146) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
151577 -5, /* (147) setlist ::= setlist COMMA nm EQ expr */
151578 -7, /* (148) setlist ::= setlist COMMA LP idlist RP EQ expr */
151579 -3, /* (149) setlist ::= nm EQ expr */
151580 -5, /* (150) setlist ::= LP idlist RP EQ expr */
151581 -7, /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
151582 -7, /* (152) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
151583 0, /* (153) upsert ::= */
151584 -11, /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
151585 -8, /* (155) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
151586 -4, /* (156) upsert ::= ON CONFLICT DO NOTHING */
151587 -2, /* (157) insert_cmd ::= INSERT orconf */
151588 -1, /* (158) insert_cmd ::= REPLACE */
151589 0, /* (159) idlist_opt ::= */
151590 -3, /* (160) idlist_opt ::= LP idlist RP */
151591 -3, /* (161) idlist ::= idlist COMMA nm */
151592 -1, /* (162) idlist ::= nm */
151593 -3, /* (163) expr ::= LP expr RP */
151594 -1, /* (164) expr ::= ID|INDEXED */
151595 -1, /* (165) expr ::= JOIN_KW */
151596 -3, /* (166) expr ::= nm DOT nm */
151597 -5, /* (167) expr ::= nm DOT nm DOT nm */
151598 -1, /* (168) term ::= NULL|FLOAT|BLOB */
151599 -1, /* (169) term ::= STRING */
151600 -1, /* (170) term ::= INTEGER */
151601 -1, /* (171) expr ::= VARIABLE */
151602 -3, /* (172) expr ::= expr COLLATE ID|STRING */
151603 -6, /* (173) expr ::= CAST LP expr AS typetoken RP */
151604 -5, /* (174) expr ::= ID|INDEXED LP distinct exprlist RP */
151605 -4, /* (175) expr ::= ID|INDEXED LP STAR RP */
151606 -6, /* (176) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
151607 -5, /* (177) expr ::= ID|INDEXED LP STAR RP over_clause */
151608 -1, /* (178) term ::= CTIME_KW */
151609 -5, /* (179) expr ::= LP nexprlist COMMA expr RP */
151610 -3, /* (180) expr ::= expr AND expr */
151611 -3, /* (181) expr ::= expr OR expr */
151612 -3, /* (182) expr ::= expr LT|GT|GE|LE expr */
151613 -3, /* (183) expr ::= expr EQ|NE expr */
151614 -3, /* (184) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
151615 -3, /* (185) expr ::= expr PLUS|MINUS expr */
151616 -3, /* (186) expr ::= expr STAR|SLASH|REM expr */
151617 -3, /* (187) expr ::= expr CONCAT expr */
151618 -2, /* (188) likeop ::= NOT LIKE_KW|MATCH */
151619 -3, /* (189) expr ::= expr likeop expr */
151620 -5, /* (190) expr ::= expr likeop expr ESCAPE expr */
151621 -2, /* (191) expr ::= expr ISNULL|NOTNULL */
151622 -3, /* (192) expr ::= expr NOT NULL */
151623 -3, /* (193) expr ::= expr IS expr */
151624 -4, /* (194) expr ::= expr IS NOT expr */
151625 -2, /* (195) expr ::= NOT expr */
151626 -2, /* (196) expr ::= BITNOT expr */
151627 -2, /* (197) expr ::= PLUS|MINUS expr */
151628 -1, /* (198) between_op ::= BETWEEN */
151629 -2, /* (199) between_op ::= NOT BETWEEN */
151630 -5, /* (200) expr ::= expr between_op expr AND expr */
151631 -1, /* (201) in_op ::= IN */
151632 -2, /* (202) in_op ::= NOT IN */
151633 -5, /* (203) expr ::= expr in_op LP exprlist RP */
151634 -3, /* (204) expr ::= LP select RP */
151635 -5, /* (205) expr ::= expr in_op LP select RP */
151636 -5, /* (206) expr ::= expr in_op nm dbnm paren_exprlist */
151637 -4, /* (207) expr ::= EXISTS LP select RP */
151638 -5, /* (208) expr ::= CASE case_operand case_exprlist case_else END */
151639 -5, /* (209) case_exprlist ::= case_exprlist WHEN expr THEN expr */
151640 -4, /* (210) case_exprlist ::= WHEN expr THEN expr */
151641 -2, /* (211) case_else ::= ELSE expr */
151642 0, /* (212) case_else ::= */
151643 -1, /* (213) case_operand ::= expr */
151644 0, /* (214) case_operand ::= */
151645 0, /* (215) exprlist ::= */
151646 -3, /* (216) nexprlist ::= nexprlist COMMA expr */
151647 -1, /* (217) nexprlist ::= expr */
151648 0, /* (218) paren_exprlist ::= */
151649 -3, /* (219) paren_exprlist ::= LP exprlist RP */
151650 -12, /* (220) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
151651 -1, /* (221) uniqueflag ::= UNIQUE */
151652 0, /* (222) uniqueflag ::= */
151653 0, /* (223) eidlist_opt ::= */
151654 -3, /* (224) eidlist_opt ::= LP eidlist RP */
151655 -5, /* (225) eidlist ::= eidlist COMMA nm collate sortorder */
151656 -3, /* (226) eidlist ::= nm collate sortorder */
151657 0, /* (227) collate ::= */
151658 -2, /* (228) collate ::= COLLATE ID|STRING */
151659 -4, /* (229) cmd ::= DROP INDEX ifexists fullname */
151660 -2, /* (230) cmd ::= VACUUM vinto */
151661 -3, /* (231) cmd ::= VACUUM nm vinto */
151662 -2, /* (232) vinto ::= INTO expr */
151663 0, /* (233) vinto ::= */
151664 -3, /* (234) cmd ::= PRAGMA nm dbnm */
151665 -5, /* (235) cmd ::= PRAGMA nm dbnm EQ nmnum */
151666 -6, /* (236) cmd ::= PRAGMA nm dbnm LP nmnum RP */
151667 -5, /* (237) cmd ::= PRAGMA nm dbnm EQ minus_num */
151668 -6, /* (238) cmd ::= PRAGMA nm dbnm LP minus_num RP */
151669 -2, /* (239) plus_num ::= PLUS INTEGER|FLOAT */
151670 -2, /* (240) minus_num ::= MINUS INTEGER|FLOAT */
151671 -5, /* (241) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
151672 -11, /* (242) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
151673 -1, /* (243) trigger_time ::= BEFORE|AFTER */
151674 -2, /* (244) trigger_time ::= INSTEAD OF */
151675 0, /* (245) trigger_time ::= */
151676 -1, /* (246) trigger_event ::= DELETE|INSERT */
151677 -1, /* (247) trigger_event ::= UPDATE */
151678 -3, /* (248) trigger_event ::= UPDATE OF idlist */
151679 0, /* (249) when_clause ::= */
151680 -2, /* (250) when_clause ::= WHEN expr */
151681 -3, /* (251) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
151682 -2, /* (252) trigger_cmd_list ::= trigger_cmd SEMI */
151683 -3, /* (253) trnm ::= nm DOT nm */
151684 -3, /* (254) tridxby ::= INDEXED BY nm */
151685 -2, /* (255) tridxby ::= NOT INDEXED */
151686 -8, /* (256) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
151687 -8, /* (257) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
151688 -6, /* (258) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
151689 -3, /* (259) trigger_cmd ::= scanpt select scanpt */
151690 -4, /* (260) expr ::= RAISE LP IGNORE RP */
151691 -6, /* (261) expr ::= RAISE LP raisetype COMMA nm RP */
151692 -1, /* (262) raisetype ::= ROLLBACK */
151693 -1, /* (263) raisetype ::= ABORT */
151694 -1, /* (264) raisetype ::= FAIL */
151695 -4, /* (265) cmd ::= DROP TRIGGER ifexists fullname */
151696 -6, /* (266) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
151697 -3, /* (267) cmd ::= DETACH database_kw_opt expr */
151698 0, /* (268) key_opt ::= */
151699 -2, /* (269) key_opt ::= KEY expr */
151700 -1, /* (270) cmd ::= REINDEX */
151701 -3, /* (271) cmd ::= REINDEX nm dbnm */
151702 -1, /* (272) cmd ::= ANALYZE */
151703 -3, /* (273) cmd ::= ANALYZE nm dbnm */
151704 -6, /* (274) cmd ::= ALTER TABLE fullname RENAME TO nm */
151705 -7, /* (275) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
151706 -1, /* (276) add_column_fullname ::= fullname */
151707 -8, /* (277) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
151708 -1, /* (278) cmd ::= create_vtab */
151709 -4, /* (279) cmd ::= create_vtab LP vtabarglist RP */
151710 -8, /* (280) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
151711 0, /* (281) vtabarg ::= */
151712 -1, /* (282) vtabargtoken ::= ANY */
151713 -3, /* (283) vtabargtoken ::= lp anylist RP */
151714 -1, /* (284) lp ::= LP */
151715 -2, /* (285) with ::= WITH wqlist */
151716 -3, /* (286) with ::= WITH RECURSIVE wqlist */
151717 -6, /* (287) wqlist ::= nm eidlist_opt AS LP select RP */
151718 -8, /* (288) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
151719 -1, /* (289) windowdefn_list ::= windowdefn */
151720 -3, /* (290) windowdefn_list ::= windowdefn_list COMMA windowdefn */
151721 -5, /* (291) windowdefn ::= nm AS LP window RP */
151722 -5, /* (292) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
151723 -6, /* (293) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
151724 -4, /* (294) window ::= ORDER BY sortlist frame_opt */
151725 -5, /* (295) window ::= nm ORDER BY sortlist frame_opt */
151726 -1, /* (296) window ::= frame_opt */
151727 -2, /* (297) window ::= nm frame_opt */
151728 0, /* (298) frame_opt ::= */
151729 -3, /* (299) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
151730 -6, /* (300) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
151731 -1, /* (301) range_or_rows ::= RANGE|ROWS|GROUPS */
151732 -1, /* (302) frame_bound_s ::= frame_bound */
151733 -2, /* (303) frame_bound_s ::= UNBOUNDED PRECEDING */
151734 -1, /* (304) frame_bound_e ::= frame_bound */
151735 -2, /* (305) frame_bound_e ::= UNBOUNDED FOLLOWING */
151736 -2, /* (306) frame_bound ::= expr PRECEDING|FOLLOWING */
151737 -2, /* (307) frame_bound ::= CURRENT ROW */
151738 0, /* (308) frame_exclude_opt ::= */
151739 -2, /* (309) frame_exclude_opt ::= EXCLUDE frame_exclude */
151740 -2, /* (310) frame_exclude ::= NO OTHERS */
151741 -2, /* (311) frame_exclude ::= CURRENT ROW */
151742 -1, /* (312) frame_exclude ::= GROUP|TIES */
151743 -2, /* (313) window_clause ::= WINDOW windowdefn_list */
151744 -5, /* (314) over_clause ::= filter_opt OVER LP window RP */
151745 -3, /* (315) over_clause ::= filter_opt OVER nm */
151746 0, /* (316) filter_opt ::= */
151747 -5, /* (317) filter_opt ::= FILTER LP WHERE expr RP */
151748 -1, /* (318) input ::= cmdlist */
151749 -2, /* (319) cmdlist ::= cmdlist ecmd */
151750 -1, /* (320) cmdlist ::= ecmd */
151751 -1, /* (321) ecmd ::= SEMI */
151752 -2, /* (322) ecmd ::= cmdx SEMI */
151753 -2, /* (323) ecmd ::= explain cmdx */
151754 0, /* (324) trans_opt ::= */
151755 -1, /* (325) trans_opt ::= TRANSACTION */
151756 -2, /* (326) trans_opt ::= TRANSACTION nm */
151757 -1, /* (327) savepoint_opt ::= SAVEPOINT */
151758 0, /* (328) savepoint_opt ::= */
151759 -2, /* (329) cmd ::= create_table create_table_args */
151760 -4, /* (330) columnlist ::= columnlist COMMA columnname carglist */
151761 -2, /* (331) columnlist ::= columnname carglist */
151762 -1, /* (332) nm ::= ID|INDEXED */
151763 -1, /* (333) nm ::= STRING */
151764 -1, /* (334) nm ::= JOIN_KW */
151765 -1, /* (335) typetoken ::= typename */
151766 -1, /* (336) typename ::= ID|STRING */
151767 -1, /* (337) signed ::= plus_num */
151768 -1, /* (338) signed ::= minus_num */
151769 -2, /* (339) carglist ::= carglist ccons */
151770 0, /* (340) carglist ::= */
151771 -2, /* (341) ccons ::= NULL onconf */
151772 -2, /* (342) conslist_opt ::= COMMA conslist */
151773 -3, /* (343) conslist ::= conslist tconscomma tcons */
151774 -1, /* (344) conslist ::= tcons */
151775 0, /* (345) tconscomma ::= */
151776 -1, /* (346) defer_subclause_opt ::= defer_subclause */
151777 -1, /* (347) resolvetype ::= raisetype */
151778 -1, /* (348) selectnowith ::= oneselect */
151779 -1, /* (349) oneselect ::= values */
151780 -2, /* (350) sclp ::= selcollist COMMA */
151781 -1, /* (351) as ::= ID|STRING */
151782 -1, /* (352) expr ::= term */
151783 -1, /* (353) likeop ::= LIKE_KW|MATCH */
151784 -1, /* (354) exprlist ::= nexprlist */
151785 -1, /* (355) nmnum ::= plus_num */
151786 -1, /* (356) nmnum ::= nm */
151787 -1, /* (357) nmnum ::= ON */
151788 -1, /* (358) nmnum ::= DELETE */
151789 -1, /* (359) nmnum ::= DEFAULT */
151790 -1, /* (360) plus_num ::= INTEGER|FLOAT */
151791 0, /* (361) foreach_clause ::= */
151792 -3, /* (362) foreach_clause ::= FOR EACH ROW */
151793 -1, /* (363) trnm ::= nm */
151794 0, /* (364) tridxby ::= */
151795 -1, /* (365) database_kw_opt ::= DATABASE */
151796 0, /* (366) database_kw_opt ::= */
151797 0, /* (367) kwcolumn_opt ::= */
151798 -1, /* (368) kwcolumn_opt ::= COLUMNKW */
151799 -1, /* (369) vtabarglist ::= vtabarg */
151800 -3, /* (370) vtabarglist ::= vtabarglist COMMA vtabarg */
151801 -2, /* (371) vtabarg ::= vtabarg vtabargtoken */
151802 0, /* (372) anylist ::= */
151803 -4, /* (373) anylist ::= anylist LP anylist RP */
151804 -2, /* (374) anylist ::= anylist ANY */
151805 0, /* (375) with ::= */
 
 
 
 
 
151806 };
151807
151808 static void yy_accept(yyParser*); /* Forward Declaration */
151809
151810 /*
@@ -151897,20 +152718,20 @@
151897 break;
151898 case 2: /* cmdx ::= cmd */
151899 { sqlite3FinishCoding(pParse); }
151900 break;
151901 case 3: /* cmd ::= BEGIN transtype trans_opt */
151902 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy100);}
151903 break;
151904 case 4: /* transtype ::= */
151905 {yymsp[1].minor.yy100 = TK_DEFERRED;}
151906 break;
151907 case 5: /* transtype ::= DEFERRED */
151908 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
151909 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
151910 case 301: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==301);
151911 {yymsp[0].minor.yy100 = yymsp[0].major; /*A-overwrites-X*/}
151912 break;
151913 case 8: /* cmd ::= COMMIT|END trans_opt */
151914 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
151915 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
151916 break;
@@ -151929,11 +152750,11 @@
151929 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
151930 }
151931 break;
151932 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
151933 {
151934 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy100,0,0,yymsp[-2].minor.yy100);
151935 }
151936 break;
151937 case 14: /* createkw ::= CREATE */
151938 {disableLookaside(pParse);}
151939 break;
@@ -151943,37 +152764,37 @@
151943 case 43: /* autoinc ::= */ yytestcase(yyruleno==43);
151944 case 58: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==58);
151945 case 68: /* defer_subclause_opt ::= */ yytestcase(yyruleno==68);
151946 case 77: /* ifexists ::= */ yytestcase(yyruleno==77);
151947 case 94: /* distinct ::= */ yytestcase(yyruleno==94);
151948 case 227: /* collate ::= */ yytestcase(yyruleno==227);
151949 {yymsp[1].minor.yy100 = 0;}
151950 break;
151951 case 16: /* ifnotexists ::= IF NOT EXISTS */
151952 {yymsp[-2].minor.yy100 = 1;}
151953 break;
151954 case 17: /* temp ::= TEMP */
151955 case 44: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==44);
151956 {yymsp[0].minor.yy100 = 1;}
151957 break;
151958 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
151959 {
151960 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy100,0);
151961 }
151962 break;
151963 case 20: /* create_table_args ::= AS select */
151964 {
151965 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy391);
151966 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy391);
151967 }
151968 break;
151969 case 22: /* table_options ::= WITHOUT nm */
151970 {
151971 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
151972 yymsp[-1].minor.yy100 = TF_WithoutRowid | TF_NoVisibleRowid;
151973 }else{
151974 yymsp[-1].minor.yy100 = 0;
151975 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
151976 }
151977 }
151978 break;
151979 case 23: /* columnname ::= nm typetoken */
@@ -151998,11 +152819,11 @@
151998 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
151999 break;
152000 case 28: /* scanpt ::= */
152001 {
152002 assert( yyLookahead!=YYNOCODE );
152003 yymsp[1].minor.yy528 = yyLookaheadToken.z;
152004 }
152005 break;
152006 case 29: /* scantok ::= */
152007 {
152008 assert( yyLookahead!=YYNOCODE );
@@ -152012,21 +152833,21 @@
152012 case 30: /* ccons ::= CONSTRAINT nm */
152013 case 63: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==63);
152014 {pParse->constraintName = yymsp[0].minor.yy0;}
152015 break;
152016 case 31: /* ccons ::= DEFAULT scantok term */
152017 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy102,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
152018 break;
152019 case 32: /* ccons ::= DEFAULT LP expr RP */
152020 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy102,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
152021 break;
152022 case 33: /* ccons ::= DEFAULT PLUS scantok term */
152023 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy102,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
152024 break;
152025 case 34: /* ccons ::= DEFAULT MINUS scantok term */
152026 {
152027 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy102, 0);
152028 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
152029 }
152030 break;
152031 case 35: /* ccons ::= DEFAULT scantok ID|INDEXED */
152032 {
@@ -152037,319 +152858,319 @@
152037 }
152038 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
152039 }
152040 break;
152041 case 36: /* ccons ::= NOT NULL onconf */
152042 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy100);}
152043 break;
152044 case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
152045 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy100,yymsp[0].minor.yy100,yymsp[-2].minor.yy100);}
152046 break;
152047 case 38: /* ccons ::= UNIQUE onconf */
152048 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy100,0,0,0,0,
152049 SQLITE_IDXTYPE_UNIQUE);}
152050 break;
152051 case 39: /* ccons ::= CHECK LP expr RP */
152052 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy102);}
152053 break;
152054 case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */
152055 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy94,yymsp[0].minor.yy100);}
152056 break;
152057 case 41: /* ccons ::= defer_subclause */
152058 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy100);}
152059 break;
152060 case 42: /* ccons ::= COLLATE ID|STRING */
152061 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
152062 break;
152063 case 45: /* refargs ::= */
152064 { yymsp[1].minor.yy100 = OE_None*0x0101; /* EV: R-19803-45884 */}
152065 break;
152066 case 46: /* refargs ::= refargs refarg */
152067 { yymsp[-1].minor.yy100 = (yymsp[-1].minor.yy100 & ~yymsp[0].minor.yy199.mask) | yymsp[0].minor.yy199.value; }
152068 break;
152069 case 47: /* refarg ::= MATCH nm */
152070 { yymsp[-1].minor.yy199.value = 0; yymsp[-1].minor.yy199.mask = 0x000000; }
152071 break;
152072 case 48: /* refarg ::= ON INSERT refact */
152073 { yymsp[-2].minor.yy199.value = 0; yymsp[-2].minor.yy199.mask = 0x000000; }
152074 break;
152075 case 49: /* refarg ::= ON DELETE refact */
152076 { yymsp[-2].minor.yy199.value = yymsp[0].minor.yy100; yymsp[-2].minor.yy199.mask = 0x0000ff; }
152077 break;
152078 case 50: /* refarg ::= ON UPDATE refact */
152079 { yymsp[-2].minor.yy199.value = yymsp[0].minor.yy100<<8; yymsp[-2].minor.yy199.mask = 0x00ff00; }
152080 break;
152081 case 51: /* refact ::= SET NULL */
152082 { yymsp[-1].minor.yy100 = OE_SetNull; /* EV: R-33326-45252 */}
152083 break;
152084 case 52: /* refact ::= SET DEFAULT */
152085 { yymsp[-1].minor.yy100 = OE_SetDflt; /* EV: R-33326-45252 */}
152086 break;
152087 case 53: /* refact ::= CASCADE */
152088 { yymsp[0].minor.yy100 = OE_Cascade; /* EV: R-33326-45252 */}
152089 break;
152090 case 54: /* refact ::= RESTRICT */
152091 { yymsp[0].minor.yy100 = OE_Restrict; /* EV: R-33326-45252 */}
152092 break;
152093 case 55: /* refact ::= NO ACTION */
152094 { yymsp[-1].minor.yy100 = OE_None; /* EV: R-33326-45252 */}
152095 break;
152096 case 56: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
152097 {yymsp[-2].minor.yy100 = 0;}
152098 break;
152099 case 57: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
152100 case 72: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==72);
152101 case 157: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==157);
152102 {yymsp[-1].minor.yy100 = yymsp[0].minor.yy100;}
152103 break;
152104 case 59: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
152105 case 76: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==76);
152106 case 199: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==199);
152107 case 202: /* in_op ::= NOT IN */ yytestcase(yyruleno==202);
152108 case 228: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==228);
152109 {yymsp[-1].minor.yy100 = 1;}
152110 break;
152111 case 60: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
152112 {yymsp[-1].minor.yy100 = 0;}
152113 break;
152114 case 62: /* tconscomma ::= COMMA */
152115 {pParse->constraintName.n = 0;}
152116 break;
152117 case 64: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
152118 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy94,yymsp[0].minor.yy100,yymsp[-2].minor.yy100,0);}
152119 break;
152120 case 65: /* tcons ::= UNIQUE LP sortlist RP onconf */
152121 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy94,yymsp[0].minor.yy100,0,0,0,0,
152122 SQLITE_IDXTYPE_UNIQUE);}
152123 break;
152124 case 66: /* tcons ::= CHECK LP expr RP onconf */
152125 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy102);}
152126 break;
152127 case 67: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
152128 {
152129 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy94, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy94, yymsp[-1].minor.yy100);
152130 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy100);
152131 }
152132 break;
152133 case 69: /* onconf ::= */
152134 case 71: /* orconf ::= */ yytestcase(yyruleno==71);
152135 {yymsp[1].minor.yy100 = OE_Default;}
152136 break;
152137 case 70: /* onconf ::= ON CONFLICT resolvetype */
152138 {yymsp[-2].minor.yy100 = yymsp[0].minor.yy100;}
152139 break;
152140 case 73: /* resolvetype ::= IGNORE */
152141 {yymsp[0].minor.yy100 = OE_Ignore;}
152142 break;
152143 case 74: /* resolvetype ::= REPLACE */
152144 case 158: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==158);
152145 {yymsp[0].minor.yy100 = OE_Replace;}
152146 break;
152147 case 75: /* cmd ::= DROP TABLE ifexists fullname */
152148 {
152149 sqlite3DropTable(pParse, yymsp[0].minor.yy407, 0, yymsp[-1].minor.yy100);
152150 }
152151 break;
152152 case 78: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
152153 {
152154 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy94, yymsp[0].minor.yy391, yymsp[-7].minor.yy100, yymsp[-5].minor.yy100);
152155 }
152156 break;
152157 case 79: /* cmd ::= DROP VIEW ifexists fullname */
152158 {
152159 sqlite3DropTable(pParse, yymsp[0].minor.yy407, 1, yymsp[-1].minor.yy100);
152160 }
152161 break;
152162 case 80: /* cmd ::= select */
152163 {
152164 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
152165 sqlite3Select(pParse, yymsp[0].minor.yy391, &dest);
152166 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy391);
152167 }
152168 break;
152169 case 81: /* select ::= WITH wqlist selectnowith */
152170 {
152171 Select *p = yymsp[0].minor.yy391;
152172 if( p ){
152173 p->pWith = yymsp[-1].minor.yy243;
152174 parserDoubleLinkSelect(pParse, p);
152175 }else{
152176 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy243);
152177 }
152178 yymsp[-2].minor.yy391 = p;
152179 }
152180 break;
152181 case 82: /* select ::= WITH RECURSIVE wqlist selectnowith */
152182 {
152183 Select *p = yymsp[0].minor.yy391;
152184 if( p ){
152185 p->pWith = yymsp[-1].minor.yy243;
152186 parserDoubleLinkSelect(pParse, p);
152187 }else{
152188 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy243);
152189 }
152190 yymsp[-3].minor.yy391 = p;
152191 }
152192 break;
152193 case 83: /* select ::= selectnowith */
152194 {
152195 Select *p = yymsp[0].minor.yy391;
152196 if( p ){
152197 parserDoubleLinkSelect(pParse, p);
152198 }
152199 yymsp[0].minor.yy391 = p; /*A-overwrites-X*/
152200 }
152201 break;
152202 case 84: /* selectnowith ::= selectnowith multiselect_op oneselect */
152203 {
152204 Select *pRhs = yymsp[0].minor.yy391;
152205 Select *pLhs = yymsp[-2].minor.yy391;
152206 if( pRhs && pRhs->pPrior ){
152207 SrcList *pFrom;
152208 Token x;
152209 x.n = 0;
152210 parserDoubleLinkSelect(pParse, pRhs);
152211 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
152212 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
152213 }
152214 if( pRhs ){
152215 pRhs->op = (u8)yymsp[-1].minor.yy100;
152216 pRhs->pPrior = pLhs;
152217 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
152218 pRhs->selFlags &= ~SF_MultiValue;
152219 if( yymsp[-1].minor.yy100!=TK_ALL ) pParse->hasCompound = 1;
152220 }else{
152221 sqlite3SelectDelete(pParse->db, pLhs);
152222 }
152223 yymsp[-2].minor.yy391 = pRhs;
152224 }
152225 break;
152226 case 85: /* multiselect_op ::= UNION */
152227 case 87: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==87);
152228 {yymsp[0].minor.yy100 = yymsp[0].major; /*A-overwrites-OP*/}
152229 break;
152230 case 86: /* multiselect_op ::= UNION ALL */
152231 {yymsp[-1].minor.yy100 = TK_ALL;}
152232 break;
152233 case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
152234 {
152235 yymsp[-8].minor.yy391 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy94,yymsp[-5].minor.yy407,yymsp[-4].minor.yy102,yymsp[-3].minor.yy94,yymsp[-2].minor.yy102,yymsp[-1].minor.yy94,yymsp[-7].minor.yy100,yymsp[0].minor.yy102);
152236 }
152237 break;
152238 case 89: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
152239 {
152240 yymsp[-9].minor.yy391 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy94,yymsp[-6].minor.yy407,yymsp[-5].minor.yy102,yymsp[-4].minor.yy94,yymsp[-3].minor.yy102,yymsp[-1].minor.yy94,yymsp[-8].minor.yy100,yymsp[0].minor.yy102);
152241 if( yymsp[-9].minor.yy391 ){
152242 yymsp[-9].minor.yy391->pWinDefn = yymsp[-2].minor.yy379;
152243 }else{
152244 sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy379);
152245 }
152246 }
152247 break;
152248 case 90: /* values ::= VALUES LP nexprlist RP */
152249 {
152250 yymsp[-3].minor.yy391 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy94,0,0,0,0,0,SF_Values,0);
152251 }
152252 break;
152253 case 91: /* values ::= values COMMA LP nexprlist RP */
152254 {
152255 Select *pRight, *pLeft = yymsp[-4].minor.yy391;
152256 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy94,0,0,0,0,0,SF_Values|SF_MultiValue,0);
152257 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
152258 if( pRight ){
152259 pRight->op = TK_ALL;
152260 pRight->pPrior = pLeft;
152261 yymsp[-4].minor.yy391 = pRight;
152262 }else{
152263 yymsp[-4].minor.yy391 = pLeft;
152264 }
152265 }
152266 break;
152267 case 92: /* distinct ::= DISTINCT */
152268 {yymsp[0].minor.yy100 = SF_Distinct;}
152269 break;
152270 case 93: /* distinct ::= ALL */
152271 {yymsp[0].minor.yy100 = SF_All;}
152272 break;
152273 case 95: /* sclp ::= */
152274 case 128: /* orderby_opt ::= */ yytestcase(yyruleno==128);
152275 case 135: /* groupby_opt ::= */ yytestcase(yyruleno==135);
152276 case 215: /* exprlist ::= */ yytestcase(yyruleno==215);
152277 case 218: /* paren_exprlist ::= */ yytestcase(yyruleno==218);
152278 case 223: /* eidlist_opt ::= */ yytestcase(yyruleno==223);
152279 {yymsp[1].minor.yy94 = 0;}
152280 break;
152281 case 96: /* selcollist ::= sclp scanpt expr scanpt as */
152282 {
152283 yymsp[-4].minor.yy94 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy94, yymsp[-2].minor.yy102);
152284 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy94, &yymsp[0].minor.yy0, 1);
152285 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy94,yymsp[-3].minor.yy528,yymsp[-1].minor.yy528);
152286 }
152287 break;
152288 case 97: /* selcollist ::= sclp scanpt STAR */
152289 {
152290 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
152291 yymsp[-2].minor.yy94 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy94, p);
152292 }
152293 break;
152294 case 98: /* selcollist ::= sclp scanpt nm DOT STAR */
152295 {
152296 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
152297 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
152298 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
152299 yymsp[-4].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy94, pDot);
152300 }
152301 break;
152302 case 99: /* as ::= AS nm */
152303 case 110: /* dbnm ::= DOT nm */ yytestcase(yyruleno==110);
152304 case 239: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==239);
152305 case 240: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==240);
152306 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
152307 break;
152308 case 101: /* from ::= */
152309 {yymsp[1].minor.yy407 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy407));}
152310 break;
152311 case 102: /* from ::= FROM seltablist */
152312 {
152313 yymsp[-1].minor.yy407 = yymsp[0].minor.yy407;
152314 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy407);
152315 }
152316 break;
152317 case 103: /* stl_prefix ::= seltablist joinop */
152318 {
152319 if( ALWAYS(yymsp[-1].minor.yy407 && yymsp[-1].minor.yy407->nSrc>0) ) yymsp[-1].minor.yy407->a[yymsp[-1].minor.yy407->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy100;
152320 }
152321 break;
152322 case 104: /* stl_prefix ::= */
152323 {yymsp[1].minor.yy407 = 0;}
152324 break;
152325 case 105: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
152326 {
152327 yymsp[-6].minor.yy407 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy407,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy102,yymsp[0].minor.yy76);
152328 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy407, &yymsp[-2].minor.yy0);
152329 }
152330 break;
152331 case 106: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
152332 {
152333 yymsp[-8].minor.yy407 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy407,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy102,yymsp[0].minor.yy76);
152334 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy407, yymsp[-4].minor.yy94);
152335 }
152336 break;
152337 case 107: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
152338 {
152339 yymsp[-6].minor.yy407 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy407,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy391,yymsp[-1].minor.yy102,yymsp[0].minor.yy76);
152340 }
152341 break;
152342 case 108: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
152343 {
152344 if( yymsp[-6].minor.yy407==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy102==0 && yymsp[0].minor.yy76==0 ){
152345 yymsp[-6].minor.yy407 = yymsp[-4].minor.yy407;
152346 }else if( yymsp[-4].minor.yy407->nSrc==1 ){
152347 yymsp[-6].minor.yy407 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy407,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy102,yymsp[0].minor.yy76);
152348 if( yymsp[-6].minor.yy407 ){
152349 struct SrcList_item *pNew = &yymsp[-6].minor.yy407->a[yymsp[-6].minor.yy407->nSrc-1];
152350 struct SrcList_item *pOld = yymsp[-4].minor.yy407->a;
152351 pNew->zName = pOld->zName;
152352 pNew->zDatabase = pOld->zDatabase;
152353 pNew->pSelect = pOld->pSelect;
152354 if( pOld->fg.isTabFunc ){
152355 pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -152358,953 +153179,946 @@
152358 pNew->fg.isTabFunc = 1;
152359 }
152360 pOld->zName = pOld->zDatabase = 0;
152361 pOld->pSelect = 0;
152362 }
152363 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy407);
152364 }else{
152365 Select *pSubquery;
152366 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy407);
152367 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy407,0,0,0,0,SF_NestedFrom,0);
152368 yymsp[-6].minor.yy407 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy407,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy102,yymsp[0].minor.yy76);
152369 }
152370 }
152371 break;
152372 case 109: /* dbnm ::= */
152373 case 123: /* indexed_opt ::= */ yytestcase(yyruleno==123);
152374 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
152375 break;
152376 case 111: /* fullname ::= nm */
152377 {
152378 yylhsminor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
152379 if( IN_RENAME_OBJECT && yylhsminor.yy407 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy407->a[0].zName, &yymsp[0].minor.yy0);
152380 }
152381 yymsp[0].minor.yy407 = yylhsminor.yy407;
152382 break;
152383 case 112: /* fullname ::= nm DOT nm */
152384 {
152385 yylhsminor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
152386 if( IN_RENAME_OBJECT && yylhsminor.yy407 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy407->a[0].zName, &yymsp[0].minor.yy0);
152387 }
152388 yymsp[-2].minor.yy407 = yylhsminor.yy407;
152389 break;
152390 case 113: /* xfullname ::= nm */
152391 {yymsp[0].minor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
152392 break;
152393 case 114: /* xfullname ::= nm DOT nm */
152394 {yymsp[-2].minor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
152395 break;
152396 case 115: /* xfullname ::= nm DOT nm AS nm */
152397 {
152398 yymsp[-4].minor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
152399 if( yymsp[-4].minor.yy407 ) yymsp[-4].minor.yy407->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
152400 }
152401 break;
152402 case 116: /* xfullname ::= nm AS nm */
152403 {
152404 yymsp[-2].minor.yy407 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
152405 if( yymsp[-2].minor.yy407 ) yymsp[-2].minor.yy407->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
152406 }
152407 break;
152408 case 117: /* joinop ::= COMMA|JOIN */
152409 { yymsp[0].minor.yy100 = JT_INNER; }
152410 break;
152411 case 118: /* joinop ::= JOIN_KW JOIN */
152412 {yymsp[-1].minor.yy100 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
152413 break;
152414 case 119: /* joinop ::= JOIN_KW nm JOIN */
152415 {yymsp[-2].minor.yy100 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
152416 break;
152417 case 120: /* joinop ::= JOIN_KW nm nm JOIN */
152418 {yymsp[-3].minor.yy100 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
152419 break;
152420 case 121: /* on_opt ::= ON expr */
152421 case 138: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==138);
152422 case 145: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==145);
152423 case 211: /* case_else ::= ELSE expr */ yytestcase(yyruleno==211);
152424 case 232: /* vinto ::= INTO expr */ yytestcase(yyruleno==232);
152425 {yymsp[-1].minor.yy102 = yymsp[0].minor.yy102;}
152426 break;
152427 case 122: /* on_opt ::= */
152428 case 137: /* having_opt ::= */ yytestcase(yyruleno==137);
152429 case 139: /* limit_opt ::= */ yytestcase(yyruleno==139);
152430 case 144: /* where_opt ::= */ yytestcase(yyruleno==144);
152431 case 212: /* case_else ::= */ yytestcase(yyruleno==212);
152432 case 214: /* case_operand ::= */ yytestcase(yyruleno==214);
152433 case 233: /* vinto ::= */ yytestcase(yyruleno==233);
152434 {yymsp[1].minor.yy102 = 0;}
152435 break;
152436 case 124: /* indexed_opt ::= INDEXED BY nm */
152437 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
152438 break;
152439 case 125: /* indexed_opt ::= NOT INDEXED */
152440 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
152441 break;
152442 case 126: /* using_opt ::= USING LP idlist RP */
152443 {yymsp[-3].minor.yy76 = yymsp[-1].minor.yy76;}
152444 break;
152445 case 127: /* using_opt ::= */
152446 case 159: /* idlist_opt ::= */ yytestcase(yyruleno==159);
152447 {yymsp[1].minor.yy76 = 0;}
152448 break;
152449 case 129: /* orderby_opt ::= ORDER BY sortlist */
152450 case 136: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==136);
152451 {yymsp[-2].minor.yy94 = yymsp[0].minor.yy94;}
152452 break;
152453 case 130: /* sortlist ::= sortlist COMMA expr sortorder */
152454 {
152455 yymsp[-3].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy94,yymsp[-1].minor.yy102);
152456 sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy94,yymsp[0].minor.yy100);
152457 }
152458 break;
152459 case 131: /* sortlist ::= expr sortorder */
152460 {
152461 yymsp[-1].minor.yy94 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy102); /*A-overwrites-Y*/
152462 sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy94,yymsp[0].minor.yy100);
152463 }
152464 break;
152465 case 132: /* sortorder ::= ASC */
152466 {yymsp[0].minor.yy100 = SQLITE_SO_ASC;}
152467 break;
152468 case 133: /* sortorder ::= DESC */
152469 {yymsp[0].minor.yy100 = SQLITE_SO_DESC;}
152470 break;
152471 case 134: /* sortorder ::= */
152472 {yymsp[1].minor.yy100 = SQLITE_SO_UNDEFINED;}
152473 break;
152474 case 140: /* limit_opt ::= LIMIT expr */
152475 {yymsp[-1].minor.yy102 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy102,0);}
152476 break;
152477 case 141: /* limit_opt ::= LIMIT expr OFFSET expr */
152478 {yymsp[-3].minor.yy102 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy102,yymsp[0].minor.yy102);}
152479 break;
152480 case 142: /* limit_opt ::= LIMIT expr COMMA expr */
152481 {yymsp[-3].minor.yy102 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy102,yymsp[-2].minor.yy102);}
152482 break;
152483 case 143: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
152484 {
152485 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy407, &yymsp[-1].minor.yy0);
152486 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy407,yymsp[0].minor.yy102,0,0);
152487 }
152488 break;
152489 case 146: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
152490 {
152491 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy407, &yymsp[-3].minor.yy0);
152492 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy94,"set list");
152493 sqlite3Update(pParse,yymsp[-4].minor.yy407,yymsp[-1].minor.yy94,yymsp[0].minor.yy102,yymsp[-5].minor.yy100,0,0,0);
152494 }
152495 break;
152496 case 147: /* setlist ::= setlist COMMA nm EQ expr */
152497 {
152498 yymsp[-4].minor.yy94 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy94, yymsp[0].minor.yy102);
152499 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy94, &yymsp[-2].minor.yy0, 1);
152500 }
152501 break;
152502 case 148: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
152503 {
152504 yymsp[-6].minor.yy94 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy94, yymsp[-3].minor.yy76, yymsp[0].minor.yy102);
152505 }
152506 break;
152507 case 149: /* setlist ::= nm EQ expr */
152508 {
152509 yylhsminor.yy94 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy102);
152510 sqlite3ExprListSetName(pParse, yylhsminor.yy94, &yymsp[-2].minor.yy0, 1);
152511 }
152512 yymsp[-2].minor.yy94 = yylhsminor.yy94;
152513 break;
152514 case 150: /* setlist ::= LP idlist RP EQ expr */
152515 {
152516 yymsp[-4].minor.yy94 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy76, yymsp[0].minor.yy102);
152517 }
152518 break;
152519 case 151: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
152520 {
152521 sqlite3Insert(pParse, yymsp[-3].minor.yy407, yymsp[-1].minor.yy391, yymsp[-2].minor.yy76, yymsp[-5].minor.yy100, yymsp[0].minor.yy95);
152522 }
152523 break;
152524 case 152: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
152525 {
152526 sqlite3Insert(pParse, yymsp[-3].minor.yy407, 0, yymsp[-2].minor.yy76, yymsp[-5].minor.yy100, 0);
152527 }
152528 break;
152529 case 153: /* upsert ::= */
152530 { yymsp[1].minor.yy95 = 0; }
152531 break;
152532 case 154: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
152533 { yymsp[-10].minor.yy95 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy94,yymsp[-5].minor.yy102,yymsp[-1].minor.yy94,yymsp[0].minor.yy102);}
152534 break;
152535 case 155: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
152536 { yymsp[-7].minor.yy95 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy94,yymsp[-2].minor.yy102,0,0); }
152537 break;
152538 case 156: /* upsert ::= ON CONFLICT DO NOTHING */
152539 { yymsp[-3].minor.yy95 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
152540 break;
152541 case 160: /* idlist_opt ::= LP idlist RP */
152542 {yymsp[-2].minor.yy76 = yymsp[-1].minor.yy76;}
152543 break;
152544 case 161: /* idlist ::= idlist COMMA nm */
152545 {yymsp[-2].minor.yy76 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy76,&yymsp[0].minor.yy0);}
152546 break;
152547 case 162: /* idlist ::= nm */
152548 {yymsp[0].minor.yy76 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
152549 break;
152550 case 163: /* expr ::= LP expr RP */
152551 {yymsp[-2].minor.yy102 = yymsp[-1].minor.yy102;}
152552 break;
152553 case 164: /* expr ::= ID|INDEXED */
152554 case 165: /* expr ::= JOIN_KW */ yytestcase(yyruleno==165);
152555 {yymsp[0].minor.yy102=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
152556 break;
152557 case 166: /* expr ::= nm DOT nm */
 
 
 
 
 
 
 
152558 {
152559 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
152560 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
152561 if( IN_RENAME_OBJECT ){
152562 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
152563 sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
152564 }
152565 yylhsminor.yy102 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
152566 }
152567 yymsp[-2].minor.yy102 = yylhsminor.yy102;
152568 break;
152569 case 167: /* expr ::= nm DOT nm DOT nm */
152570 {
152571 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
152572 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
152573 Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
152574 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
152575 if( IN_RENAME_OBJECT ){
152576 sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
152577 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
152578 }
152579 yylhsminor.yy102 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
152580 }
152581 yymsp[-4].minor.yy102 = yylhsminor.yy102;
152582 break;
152583 case 168: /* term ::= NULL|FLOAT|BLOB */
152584 case 169: /* term ::= STRING */ yytestcase(yyruleno==169);
152585 {yymsp[0].minor.yy102=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
152586 break;
152587 case 170: /* term ::= INTEGER */
152588 {
152589 yylhsminor.yy102 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
152590 }
152591 yymsp[0].minor.yy102 = yylhsminor.yy102;
152592 break;
152593 case 171: /* expr ::= VARIABLE */
152594 {
152595 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
152596 u32 n = yymsp[0].minor.yy0.n;
152597 yymsp[0].minor.yy102 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
152598 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy102, n);
152599 }else{
152600 /* When doing a nested parse, one can include terms in an expression
152601 ** that look like this: #1 #2 ... These terms refer to registers
152602 ** in the virtual machine. #N is the N-th register. */
152603 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
152604 assert( t.n>=2 );
152605 if( pParse->nested==0 ){
152606 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
152607 yymsp[0].minor.yy102 = 0;
152608 }else{
152609 yymsp[0].minor.yy102 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
152610 if( yymsp[0].minor.yy102 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy102->iTable);
152611 }
152612 }
152613 }
152614 break;
152615 case 172: /* expr ::= expr COLLATE ID|STRING */
152616 {
152617 yymsp[-2].minor.yy102 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy102, &yymsp[0].minor.yy0, 1);
152618 }
152619 break;
152620 case 173: /* expr ::= CAST LP expr AS typetoken RP */
152621 {
152622 yymsp[-5].minor.yy102 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
152623 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy102, yymsp[-3].minor.yy102, 0);
152624 }
152625 break;
152626 case 174: /* expr ::= ID|INDEXED LP distinct exprlist RP */
152627 {
152628 yylhsminor.yy102 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy94, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy100);
152629 }
152630 yymsp[-4].minor.yy102 = yylhsminor.yy102;
152631 break;
152632 case 175: /* expr ::= ID|INDEXED LP STAR RP */
152633 {
152634 yylhsminor.yy102 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
152635 }
152636 yymsp[-3].minor.yy102 = yylhsminor.yy102;
152637 break;
152638 case 176: /* expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
152639 {
152640 yylhsminor.yy102 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy94, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy100);
152641 sqlite3WindowAttach(pParse, yylhsminor.yy102, yymsp[0].minor.yy379);
152642 }
152643 yymsp[-5].minor.yy102 = yylhsminor.yy102;
152644 break;
152645 case 177: /* expr ::= ID|INDEXED LP STAR RP over_clause */
152646 {
152647 yylhsminor.yy102 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
152648 sqlite3WindowAttach(pParse, yylhsminor.yy102, yymsp[0].minor.yy379);
152649 }
152650 yymsp[-4].minor.yy102 = yylhsminor.yy102;
152651 break;
152652 case 178: /* term ::= CTIME_KW */
152653 {
152654 yylhsminor.yy102 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
152655 }
152656 yymsp[0].minor.yy102 = yylhsminor.yy102;
152657 break;
152658 case 179: /* expr ::= LP nexprlist COMMA expr RP */
152659 {
152660 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy94, yymsp[-1].minor.yy102);
152661 yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
152662 if( yymsp[-4].minor.yy102 ){
152663 yymsp[-4].minor.yy102->x.pList = pList;
152664 }else{
152665 sqlite3ExprListDelete(pParse->db, pList);
152666 }
152667 }
152668 break;
152669 case 180: /* expr ::= expr AND expr */
152670 {yymsp[-2].minor.yy102=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy102,yymsp[0].minor.yy102);}
152671 break;
152672 case 181: /* expr ::= expr OR expr */
152673 case 182: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==182);
152674 case 183: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==183);
152675 case 184: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==184);
152676 case 185: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==185);
152677 case 186: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==186);
152678 case 187: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==187);
152679 {yymsp[-2].minor.yy102=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy102,yymsp[0].minor.yy102);}
152680 break;
152681 case 188: /* likeop ::= NOT LIKE_KW|MATCH */
152682 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
152683 break;
152684 case 189: /* expr ::= expr likeop expr */
152685 {
152686 ExprList *pList;
152687 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
152688 yymsp[-1].minor.yy0.n &= 0x7fffffff;
152689 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy102);
152690 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy102);
152691 yymsp[-2].minor.yy102 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
152692 if( bNot ) yymsp[-2].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy102, 0);
152693 if( yymsp[-2].minor.yy102 ) yymsp[-2].minor.yy102->flags |= EP_InfixFunc;
152694 }
152695 break;
152696 case 190: /* expr ::= expr likeop expr ESCAPE expr */
152697 {
152698 ExprList *pList;
152699 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
152700 yymsp[-3].minor.yy0.n &= 0x7fffffff;
152701 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy102);
152702 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy102);
152703 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy102);
152704 yymsp[-4].minor.yy102 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
152705 if( bNot ) yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy102, 0);
152706 if( yymsp[-4].minor.yy102 ) yymsp[-4].minor.yy102->flags |= EP_InfixFunc;
152707 }
152708 break;
152709 case 191: /* expr ::= expr ISNULL|NOTNULL */
152710 {yymsp[-1].minor.yy102 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy102,0);}
152711 break;
152712 case 192: /* expr ::= expr NOT NULL */
152713 {yymsp[-2].minor.yy102 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy102,0);}
152714 break;
152715 case 193: /* expr ::= expr IS expr */
152716 {
152717 yymsp[-2].minor.yy102 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy102,yymsp[0].minor.yy102);
152718 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy102, yymsp[-2].minor.yy102, TK_ISNULL);
152719 }
152720 break;
152721 case 194: /* expr ::= expr IS NOT expr */
152722 {
152723 yymsp[-3].minor.yy102 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy102,yymsp[0].minor.yy102);
152724 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy102, yymsp[-3].minor.yy102, TK_NOTNULL);
152725 }
152726 break;
152727 case 195: /* expr ::= NOT expr */
152728 case 196: /* expr ::= BITNOT expr */ yytestcase(yyruleno==196);
152729 {yymsp[-1].minor.yy102 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy102, 0);/*A-overwrites-B*/}
152730 break;
152731 case 197: /* expr ::= PLUS|MINUS expr */
152732 {
152733 yymsp[-1].minor.yy102 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy102, 0);
152734 /*A-overwrites-B*/
152735 }
152736 break;
152737 case 198: /* between_op ::= BETWEEN */
152738 case 201: /* in_op ::= IN */ yytestcase(yyruleno==201);
152739 {yymsp[0].minor.yy100 = 0;}
152740 break;
152741 case 200: /* expr ::= expr between_op expr AND expr */
152742 {
152743 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy102);
152744 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy102);
152745 yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy102, 0);
152746 if( yymsp[-4].minor.yy102 ){
152747 yymsp[-4].minor.yy102->x.pList = pList;
152748 }else{
152749 sqlite3ExprListDelete(pParse->db, pList);
152750 }
152751 if( yymsp[-3].minor.yy100 ) yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy102, 0);
152752 }
152753 break;
152754 case 203: /* expr ::= expr in_op LP exprlist RP */
152755 {
152756 if( yymsp[-1].minor.yy94==0 ){
152757 /* Expressions of the form
152758 **
152759 ** expr1 IN ()
152760 ** expr1 NOT IN ()
152761 **
152762 ** simplify to constants 0 (false) and 1 (true), respectively,
152763 ** regardless of the value of expr1.
152764 */
152765 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy102);
152766 yymsp[-4].minor.yy102 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy100],1);
152767 }else if( yymsp[-1].minor.yy94->nExpr==1 ){
152768 /* Expressions of the form:
152769 **
152770 ** expr1 IN (?1)
152771 ** expr1 NOT IN (?2)
152772 **
152773 ** with exactly one value on the RHS can be simplified to something
152774 ** like this:
152775 **
152776 ** expr1 == ?1
152777 ** expr1 <> ?2
152778 **
152779 ** But, the RHS of the == or <> is marked with the EP_Generic flag
152780 ** so that it may not contribute to the computation of comparison
152781 ** affinity or the collating sequence to use for comparison. Otherwise,
152782 ** the semantics would be subtly different from IN or NOT IN.
152783 */
152784 Expr *pRHS = yymsp[-1].minor.yy94->a[0].pExpr;
152785 yymsp[-1].minor.yy94->a[0].pExpr = 0;
152786 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy94);
152787 /* pRHS cannot be NULL because a malloc error would have been detected
152788 ** before now and control would have never reached this point */
152789 if( ALWAYS(pRHS) ){
152790 pRHS->flags &= ~EP_Collate;
152791 pRHS->flags |= EP_Generic;
152792 }
152793 yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, yymsp[-3].minor.yy100 ? TK_NE : TK_EQ, yymsp[-4].minor.yy102, pRHS);
152794 }else{
152795 yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy102, 0);
152796 if( yymsp[-4].minor.yy102 ){
152797 yymsp[-4].minor.yy102->x.pList = yymsp[-1].minor.yy94;
152798 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy102);
152799 }else{
152800 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy94);
152801 }
152802 if( yymsp[-3].minor.yy100 ) yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy102, 0);
152803 }
152804 }
152805 break;
152806 case 204: /* expr ::= LP select RP */
152807 {
152808 yymsp[-2].minor.yy102 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
152809 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy102, yymsp[-1].minor.yy391);
152810 }
152811 break;
152812 case 205: /* expr ::= expr in_op LP select RP */
152813 {
152814 yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy102, 0);
152815 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy102, yymsp[-1].minor.yy391);
152816 if( yymsp[-3].minor.yy100 ) yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy102, 0);
152817 }
152818 break;
152819 case 206: /* expr ::= expr in_op nm dbnm paren_exprlist */
152820 {
152821 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
152822 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
152823 if( yymsp[0].minor.yy94 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy94);
152824 yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy102, 0);
152825 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy102, pSelect);
152826 if( yymsp[-3].minor.yy100 ) yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy102, 0);
152827 }
152828 break;
152829 case 207: /* expr ::= EXISTS LP select RP */
152830 {
152831 Expr *p;
152832 p = yymsp[-3].minor.yy102 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
152833 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy391);
152834 }
152835 break;
152836 case 208: /* expr ::= CASE case_operand case_exprlist case_else END */
152837 {
152838 yymsp[-4].minor.yy102 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy102, 0);
152839 if( yymsp[-4].minor.yy102 ){
152840 yymsp[-4].minor.yy102->x.pList = yymsp[-1].minor.yy102 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy94,yymsp[-1].minor.yy102) : yymsp[-2].minor.yy94;
152841 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy102);
152842 }else{
152843 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy94);
152844 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy102);
152845 }
152846 }
152847 break;
152848 case 209: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
152849 {
152850 yymsp[-4].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy94, yymsp[-2].minor.yy102);
152851 yymsp[-4].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy94, yymsp[0].minor.yy102);
152852 }
152853 break;
152854 case 210: /* case_exprlist ::= WHEN expr THEN expr */
152855 {
152856 yymsp[-3].minor.yy94 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy102);
152857 yymsp[-3].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy94, yymsp[0].minor.yy102);
152858 }
152859 break;
152860 case 213: /* case_operand ::= expr */
152861 {yymsp[0].minor.yy102 = yymsp[0].minor.yy102; /*A-overwrites-X*/}
152862 break;
152863 case 216: /* nexprlist ::= nexprlist COMMA expr */
152864 {yymsp[-2].minor.yy94 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy94,yymsp[0].minor.yy102);}
152865 break;
152866 case 217: /* nexprlist ::= expr */
152867 {yymsp[0].minor.yy94 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy102); /*A-overwrites-Y*/}
152868 break;
152869 case 219: /* paren_exprlist ::= LP exprlist RP */
152870 case 224: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==224);
152871 {yymsp[-2].minor.yy94 = yymsp[-1].minor.yy94;}
152872 break;
152873 case 220: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
152874 {
152875 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
152876 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy94, yymsp[-10].minor.yy100,
152877 &yymsp[-11].minor.yy0, yymsp[0].minor.yy102, SQLITE_SO_ASC, yymsp[-8].minor.yy100, SQLITE_IDXTYPE_APPDEF);
152878 if( IN_RENAME_OBJECT && pParse->pNewIndex ){
152879 sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
152880 }
152881 }
152882 break;
152883 case 221: /* uniqueflag ::= UNIQUE */
152884 case 263: /* raisetype ::= ABORT */ yytestcase(yyruleno==263);
152885 {yymsp[0].minor.yy100 = OE_Abort;}
152886 break;
152887 case 222: /* uniqueflag ::= */
152888 {yymsp[1].minor.yy100 = OE_None;}
152889 break;
152890 case 225: /* eidlist ::= eidlist COMMA nm collate sortorder */
152891 {
152892 yymsp[-4].minor.yy94 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy94, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy100, yymsp[0].minor.yy100);
152893 }
152894 break;
152895 case 226: /* eidlist ::= nm collate sortorder */
152896 {
152897 yymsp[-2].minor.yy94 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy100, yymsp[0].minor.yy100); /*A-overwrites-Y*/
152898 }
152899 break;
152900 case 229: /* cmd ::= DROP INDEX ifexists fullname */
152901 {sqlite3DropIndex(pParse, yymsp[0].minor.yy407, yymsp[-1].minor.yy100);}
152902 break;
152903 case 230: /* cmd ::= VACUUM vinto */
152904 {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy102);}
152905 break;
152906 case 231: /* cmd ::= VACUUM nm vinto */
152907 {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy102);}
152908 break;
152909 case 234: /* cmd ::= PRAGMA nm dbnm */
152910 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
152911 break;
152912 case 235: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
152913 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
152914 break;
152915 case 236: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
152916 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
152917 break;
152918 case 237: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
152919 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
152920 break;
152921 case 238: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
152922 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
152923 break;
152924 case 241: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
152925 {
152926 Token all;
152927 all.z = yymsp[-3].minor.yy0.z;
152928 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
152929 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy11, &all);
152930 }
152931 break;
152932 case 242: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
152933 {
152934 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy100, yymsp[-4].minor.yy298.a, yymsp[-4].minor.yy298.b, yymsp[-2].minor.yy407, yymsp[0].minor.yy102, yymsp[-10].minor.yy100, yymsp[-8].minor.yy100);
152935 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
152936 }
152937 break;
152938 case 243: /* trigger_time ::= BEFORE|AFTER */
152939 { yymsp[0].minor.yy100 = yymsp[0].major; /*A-overwrites-X*/ }
152940 break;
152941 case 244: /* trigger_time ::= INSTEAD OF */
152942 { yymsp[-1].minor.yy100 = TK_INSTEAD;}
152943 break;
152944 case 245: /* trigger_time ::= */
152945 { yymsp[1].minor.yy100 = TK_BEFORE; }
152946 break;
152947 case 246: /* trigger_event ::= DELETE|INSERT */
152948 case 247: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==247);
152949 {yymsp[0].minor.yy298.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy298.b = 0;}
152950 break;
152951 case 248: /* trigger_event ::= UPDATE OF idlist */
152952 {yymsp[-2].minor.yy298.a = TK_UPDATE; yymsp[-2].minor.yy298.b = yymsp[0].minor.yy76;}
152953 break;
152954 case 249: /* when_clause ::= */
152955 case 268: /* key_opt ::= */ yytestcase(yyruleno==268);
152956 case 316: /* filter_opt ::= */ yytestcase(yyruleno==316);
152957 { yymsp[1].minor.yy102 = 0; }
152958 break;
152959 case 250: /* when_clause ::= WHEN expr */
152960 case 269: /* key_opt ::= KEY expr */ yytestcase(yyruleno==269);
152961 { yymsp[-1].minor.yy102 = yymsp[0].minor.yy102; }
152962 break;
152963 case 251: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
152964 {
152965 assert( yymsp[-2].minor.yy11!=0 );
152966 yymsp[-2].minor.yy11->pLast->pNext = yymsp[-1].minor.yy11;
152967 yymsp[-2].minor.yy11->pLast = yymsp[-1].minor.yy11;
152968 }
152969 break;
152970 case 252: /* trigger_cmd_list ::= trigger_cmd SEMI */
152971 {
152972 assert( yymsp[-1].minor.yy11!=0 );
152973 yymsp[-1].minor.yy11->pLast = yymsp[-1].minor.yy11;
152974 }
152975 break;
152976 case 253: /* trnm ::= nm DOT nm */
152977 {
152978 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
152979 sqlite3ErrorMsg(pParse,
152980 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
152981 "statements within triggers");
152982 }
152983 break;
152984 case 254: /* tridxby ::= INDEXED BY nm */
152985 {
152986 sqlite3ErrorMsg(pParse,
152987 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
152988 "within triggers");
152989 }
152990 break;
152991 case 255: /* tridxby ::= NOT INDEXED */
152992 {
152993 sqlite3ErrorMsg(pParse,
152994 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
152995 "within triggers");
152996 }
152997 break;
152998 case 256: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
152999 {yylhsminor.yy11 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy94, yymsp[-1].minor.yy102, yymsp[-6].minor.yy100, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy528);}
153000 yymsp[-7].minor.yy11 = yylhsminor.yy11;
153001 break;
153002 case 257: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
153003 {
153004 yylhsminor.yy11 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy76,yymsp[-2].minor.yy391,yymsp[-6].minor.yy100,yymsp[-1].minor.yy95,yymsp[-7].minor.yy528,yymsp[0].minor.yy528);/*yylhsminor.yy11-overwrites-yymsp[-6].minor.yy100*/
153005 }
153006 yymsp[-7].minor.yy11 = yylhsminor.yy11;
153007 break;
153008 case 258: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
153009 {yylhsminor.yy11 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy102, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy528);}
153010 yymsp[-5].minor.yy11 = yylhsminor.yy11;
153011 break;
153012 case 259: /* trigger_cmd ::= scanpt select scanpt */
153013 {yylhsminor.yy11 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy391, yymsp[-2].minor.yy528, yymsp[0].minor.yy528); /*yylhsminor.yy11-overwrites-yymsp[-1].minor.yy391*/}
153014 yymsp[-2].minor.yy11 = yylhsminor.yy11;
153015 break;
153016 case 260: /* expr ::= RAISE LP IGNORE RP */
153017 {
153018 yymsp[-3].minor.yy102 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
153019 if( yymsp[-3].minor.yy102 ){
153020 yymsp[-3].minor.yy102->affinity = OE_Ignore;
153021 }
153022 }
153023 break;
153024 case 261: /* expr ::= RAISE LP raisetype COMMA nm RP */
153025 {
153026 yymsp[-5].minor.yy102 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
153027 if( yymsp[-5].minor.yy102 ) {
153028 yymsp[-5].minor.yy102->affinity = (char)yymsp[-3].minor.yy100;
153029 }
153030 }
153031 break;
153032 case 262: /* raisetype ::= ROLLBACK */
153033 {yymsp[0].minor.yy100 = OE_Rollback;}
153034 break;
153035 case 264: /* raisetype ::= FAIL */
153036 {yymsp[0].minor.yy100 = OE_Fail;}
153037 break;
153038 case 265: /* cmd ::= DROP TRIGGER ifexists fullname */
153039 {
153040 sqlite3DropTrigger(pParse,yymsp[0].minor.yy407,yymsp[-1].minor.yy100);
153041 }
153042 break;
153043 case 266: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
153044 {
153045 sqlite3Attach(pParse, yymsp[-3].minor.yy102, yymsp[-1].minor.yy102, yymsp[0].minor.yy102);
153046 }
153047 break;
153048 case 267: /* cmd ::= DETACH database_kw_opt expr */
153049 {
153050 sqlite3Detach(pParse, yymsp[0].minor.yy102);
153051 }
153052 break;
153053 case 270: /* cmd ::= REINDEX */
153054 {sqlite3Reindex(pParse, 0, 0);}
153055 break;
153056 case 271: /* cmd ::= REINDEX nm dbnm */
153057 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
153058 break;
153059 case 272: /* cmd ::= ANALYZE */
153060 {sqlite3Analyze(pParse, 0, 0);}
153061 break;
153062 case 273: /* cmd ::= ANALYZE nm dbnm */
153063 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
153064 break;
153065 case 274: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
153066 {
153067 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy407,&yymsp[0].minor.yy0);
153068 }
153069 break;
153070 case 275: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
153071 {
153072 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
153073 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
153074 }
153075 break;
153076 case 276: /* add_column_fullname ::= fullname */
153077 {
153078 disableLookaside(pParse);
153079 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy407);
153080 }
153081 break;
153082 case 277: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
153083 {
153084 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy407, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
153085 }
153086 break;
153087 case 278: /* cmd ::= create_vtab */
153088 {sqlite3VtabFinishParse(pParse,0);}
153089 break;
153090 case 279: /* cmd ::= create_vtab LP vtabarglist RP */
153091 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
153092 break;
153093 case 280: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
153094 {
153095 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy100);
153096 }
153097 break;
153098 case 281: /* vtabarg ::= */
153099 {sqlite3VtabArgInit(pParse);}
153100 break;
153101 case 282: /* vtabargtoken ::= ANY */
153102 case 283: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==283);
153103 case 284: /* lp ::= LP */ yytestcase(yyruleno==284);
153104 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
153105 break;
153106 case 285: /* with ::= WITH wqlist */
153107 case 286: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==286);
153108 { sqlite3WithPush(pParse, yymsp[0].minor.yy243, 1); }
153109 break;
153110 case 287: /* wqlist ::= nm eidlist_opt AS LP select RP */
153111 {
153112 yymsp[-5].minor.yy243 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy94, yymsp[-1].minor.yy391); /*A-overwrites-X*/
153113 }
153114 break;
153115 case 288: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
153116 {
153117 yymsp[-7].minor.yy243 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy243, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy94, yymsp[-1].minor.yy391);
153118 }
153119 break;
153120 case 289: /* windowdefn_list ::= windowdefn */
153121 { yylhsminor.yy379 = yymsp[0].minor.yy379; }
153122 yymsp[0].minor.yy379 = yylhsminor.yy379;
153123 break;
153124 case 290: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
153125 {
153126 assert( yymsp[0].minor.yy379!=0 );
153127 sqlite3WindowChain(pParse, yymsp[0].minor.yy379, yymsp[-2].minor.yy379);
153128 yymsp[0].minor.yy379->pNextWin = yymsp[-2].minor.yy379;
153129 yylhsminor.yy379 = yymsp[0].minor.yy379;
153130 }
153131 yymsp[-2].minor.yy379 = yylhsminor.yy379;
153132 break;
153133 case 291: /* windowdefn ::= nm AS LP window RP */
153134 {
153135 if( ALWAYS(yymsp[-1].minor.yy379) ){
153136 yymsp[-1].minor.yy379->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
153137 }
153138 yylhsminor.yy379 = yymsp[-1].minor.yy379;
153139 }
153140 yymsp[-4].minor.yy379 = yylhsminor.yy379;
153141 break;
153142 case 292: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
153143 {
153144 yymsp[-4].minor.yy379 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy379, yymsp[-2].minor.yy94, yymsp[-1].minor.yy94, 0);
153145 }
153146 break;
153147 case 293: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
153148 {
153149 yylhsminor.yy379 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy379, yymsp[-2].minor.yy94, yymsp[-1].minor.yy94, &yymsp[-5].minor.yy0);
153150 }
153151 yymsp[-5].minor.yy379 = yylhsminor.yy379;
153152 break;
153153 case 294: /* window ::= ORDER BY sortlist frame_opt */
153154 {
153155 yymsp[-3].minor.yy379 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy379, 0, yymsp[-1].minor.yy94, 0);
153156 }
153157 break;
153158 case 295: /* window ::= nm ORDER BY sortlist frame_opt */
153159 {
153160 yylhsminor.yy379 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy379, 0, yymsp[-1].minor.yy94, &yymsp[-4].minor.yy0);
153161 }
153162 yymsp[-4].minor.yy379 = yylhsminor.yy379;
153163 break;
153164 case 296: /* window ::= frame_opt */
153165 {
153166 yylhsminor.yy379 = yymsp[0].minor.yy379;
153167 }
153168 yymsp[0].minor.yy379 = yylhsminor.yy379;
153169 break;
153170 case 297: /* window ::= nm frame_opt */
153171 {
153172 yylhsminor.yy379 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy379, 0, 0, &yymsp[-1].minor.yy0);
153173 }
153174 yymsp[-1].minor.yy379 = yylhsminor.yy379;
153175 break;
153176 case 298: /* frame_opt ::= */
153177 {
153178 yymsp[1].minor.yy379 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
153179 }
153180 break;
153181 case 299: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
153182 {
153183 yylhsminor.yy379 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy100, yymsp[-1].minor.yy389.eType, yymsp[-1].minor.yy389.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy218);
153184 }
153185 yymsp[-2].minor.yy379 = yylhsminor.yy379;
153186 break;
153187 case 300: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
153188 {
153189 yylhsminor.yy379 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy100, yymsp[-3].minor.yy389.eType, yymsp[-3].minor.yy389.pExpr, yymsp[-1].minor.yy389.eType, yymsp[-1].minor.yy389.pExpr, yymsp[0].minor.yy218);
153190 }
153191 yymsp[-5].minor.yy379 = yylhsminor.yy379;
153192 break;
153193 case 302: /* frame_bound_s ::= frame_bound */
153194 case 304: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==304);
153195 {yylhsminor.yy389 = yymsp[0].minor.yy389;}
153196 yymsp[0].minor.yy389 = yylhsminor.yy389;
153197 break;
153198 case 303: /* frame_bound_s ::= UNBOUNDED PRECEDING */
153199 case 305: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==305);
153200 case 307: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==307);
153201 {yylhsminor.yy389.eType = yymsp[-1].major; yylhsminor.yy389.pExpr = 0;}
153202 yymsp[-1].minor.yy389 = yylhsminor.yy389;
153203 break;
153204 case 306: /* frame_bound ::= expr PRECEDING|FOLLOWING */
153205 {yylhsminor.yy389.eType = yymsp[0].major; yylhsminor.yy389.pExpr = yymsp[-1].minor.yy102;}
153206 yymsp[-1].minor.yy389 = yylhsminor.yy389;
153207 break;
153208 case 308: /* frame_exclude_opt ::= */
153209 {yymsp[1].minor.yy218 = 0;}
153210 break;
153211 case 309: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
153212 {yymsp[-1].minor.yy218 = yymsp[0].minor.yy218;}
153213 break;
153214 case 310: /* frame_exclude ::= NO OTHERS */
153215 case 311: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==311);
153216 {yymsp[-1].minor.yy218 = yymsp[-1].major; /*A-overwrites-X*/}
153217 break;
153218 case 312: /* frame_exclude ::= GROUP|TIES */
153219 {yymsp[0].minor.yy218 = yymsp[0].major; /*A-overwrites-X*/}
153220 break;
153221 case 313: /* window_clause ::= WINDOW windowdefn_list */
153222 { yymsp[-1].minor.yy379 = yymsp[0].minor.yy379; }
153223 break;
153224 case 314: /* over_clause ::= filter_opt OVER LP window RP */
153225 {
153226 yylhsminor.yy379 = yymsp[-1].minor.yy379;
153227 assert( yylhsminor.yy379!=0 );
153228 yylhsminor.yy379->pFilter = yymsp[-4].minor.yy102;
153229 }
153230 yymsp[-4].minor.yy379 = yylhsminor.yy379;
153231 break;
153232 case 315: /* over_clause ::= filter_opt OVER nm */
153233 {
153234 yylhsminor.yy379 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
153235 if( yylhsminor.yy379 ){
153236 yylhsminor.yy379->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
153237 yylhsminor.yy379->pFilter = yymsp[-2].minor.yy102;
153238 }else{
153239 sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy102);
153240 }
153241 }
153242 yymsp[-2].minor.yy379 = yylhsminor.yy379;
153243 break;
153244 case 317: /* filter_opt ::= FILTER LP WHERE expr RP */
153245 { yymsp[-4].minor.yy102 = yymsp[-1].minor.yy102; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153246 break;
153247 default:
153248 /* (318) input ::= cmdlist */ yytestcase(yyruleno==318);
153249 /* (319) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==319);
153250 /* (320) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=320);
153251 /* (321) ecmd ::= SEMI */ yytestcase(yyruleno==321);
153252 /* (322) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==322);
153253 /* (323) ecmd ::= explain cmdx */ yytestcase(yyruleno==323);
153254 /* (324) trans_opt ::= */ yytestcase(yyruleno==324);
153255 /* (325) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==325);
153256 /* (326) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==326);
153257 /* (327) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==327);
153258 /* (328) savepoint_opt ::= */ yytestcase(yyruleno==328);
153259 /* (329) cmd ::= create_table create_table_args */ yytestcase(yyruleno==329);
153260 /* (330) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==330);
153261 /* (331) columnlist ::= columnname carglist */ yytestcase(yyruleno==331);
153262 /* (332) nm ::= ID|INDEXED */ yytestcase(yyruleno==332);
153263 /* (333) nm ::= STRING */ yytestcase(yyruleno==333);
153264 /* (334) nm ::= JOIN_KW */ yytestcase(yyruleno==334);
153265 /* (335) typetoken ::= typename */ yytestcase(yyruleno==335);
153266 /* (336) typename ::= ID|STRING */ yytestcase(yyruleno==336);
153267 /* (337) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=337);
153268 /* (338) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=338);
153269 /* (339) carglist ::= carglist ccons */ yytestcase(yyruleno==339);
153270 /* (340) carglist ::= */ yytestcase(yyruleno==340);
153271 /* (341) ccons ::= NULL onconf */ yytestcase(yyruleno==341);
153272 /* (342) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==342);
153273 /* (343) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==343);
153274 /* (344) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=344);
153275 /* (345) tconscomma ::= */ yytestcase(yyruleno==345);
153276 /* (346) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=346);
153277 /* (347) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=347);
153278 /* (348) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=348);
153279 /* (349) oneselect ::= values */ yytestcase(yyruleno==349);
153280 /* (350) sclp ::= selcollist COMMA */ yytestcase(yyruleno==350);
153281 /* (351) as ::= ID|STRING */ yytestcase(yyruleno==351);
153282 /* (352) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=352);
153283 /* (353) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==353);
153284 /* (354) exprlist ::= nexprlist */ yytestcase(yyruleno==354);
153285 /* (355) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=355);
153286 /* (356) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=356);
153287 /* (357) nmnum ::= ON */ yytestcase(yyruleno==357);
153288 /* (358) nmnum ::= DELETE */ yytestcase(yyruleno==358);
153289 /* (359) nmnum ::= DEFAULT */ yytestcase(yyruleno==359);
153290 /* (360) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==360);
153291 /* (361) foreach_clause ::= */ yytestcase(yyruleno==361);
153292 /* (362) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==362);
153293 /* (363) trnm ::= nm */ yytestcase(yyruleno==363);
153294 /* (364) tridxby ::= */ yytestcase(yyruleno==364);
153295 /* (365) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==365);
153296 /* (366) database_kw_opt ::= */ yytestcase(yyruleno==366);
153297 /* (367) kwcolumn_opt ::= */ yytestcase(yyruleno==367);
153298 /* (368) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==368);
153299 /* (369) vtabarglist ::= vtabarg */ yytestcase(yyruleno==369);
153300 /* (370) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==370);
153301 /* (371) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==371);
153302 /* (372) anylist ::= */ yytestcase(yyruleno==372);
153303 /* (373) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==373);
153304 /* (374) anylist ::= anylist ANY */ yytestcase(yyruleno==374);
153305 /* (375) with ::= */ yytestcase(yyruleno==375);
153306 break;
153307 /********** End reduce actions ************************************************/
153308 };
153309 assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
153310 yygoto = yyRuleInfoLhs[yyruleno];
@@ -153592,13 +154406,12 @@
153592 ** Return the fallback token corresponding to canonical token iToken, or
153593 ** 0 if iToken has no fallback.
153594 */
153595 SQLITE_PRIVATE int sqlite3ParserFallback(int iToken){
153596 #ifdef YYFALLBACK
153597 if( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ){
153598 return yyFallback[iToken];
153599 }
153600 #else
153601 (void)iToken;
153602 #endif
153603 return 0;
153604 }
@@ -153763,148 +154576,150 @@
153763 ** might be implemented more directly using a hand-written hash table.
153764 ** But by using this automatically generated code, the size of the code
153765 ** is substantially reduced. This is important for embedded applications
153766 ** on platforms with limited memory.
153767 */
153768 /* Hash score: 214 */
153769 /* zKWText[] encodes 950 bytes of keyword text in 629 bytes */
153770 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
153771 /* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYCONSTRAINTERSECTIES */
153772 /* AVEPOINTOFFSETRANSACTIONATURALTERAISEXCEPTRIGGEREFERENCES */
153773 /* UNIQUERYWITHOUTERELEASEXCLUSIVEXISTSATTACHAVINGLOBEGINNERANGE */
153774 /* BETWEENOTHINGROUPSCASCADETACHCASECOLLATECREATECURRENT_DATE */
153775 /* IMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTUPDATEVALUES */
153776 /* VIRTUALIMITWHENOTNULLWHERECURSIVEAFTERENAMEANDEFAULT */
153777 /* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */
153778 /* ARTITIONDEFERREDISTINCTDROPRECEDINGFAILFILTEREPLACEFOLLOWING */
153779 /* FROMFULLIFISNULLORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */
153780 /* UNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBYINITIALLYPRIMARY */
153781 static const char zKWText[628] = {
153782 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
153783 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
153784 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
153785 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
153786 'E','R','R','A','B','L','E','L','S','E','X','C','L','U','D','E','L','E',
153787 'T','E','M','P','O','R','A','R','Y','C','O','N','S','T','R','A','I','N',
153788 'T','E','R','S','E','C','T','I','E','S','A','V','E','P','O','I','N','T',
153789 'O','F','F','S','E','T','R','A','N','S','A','C','T','I','O','N','A','T',
153790 'U','R','A','L','T','E','R','A','I','S','E','X','C','E','P','T','R','I',
153791 'G','G','E','R','E','F','E','R','E','N','C','E','S','U','N','I','Q','U',
153792 'E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S','E',
153793 'X','C','L','U','S','I','V','E','X','I','S','T','S','A','T','T','A','C',
153794 'H','A','V','I','N','G','L','O','B','E','G','I','N','N','E','R','A','N',
153795 'G','E','B','E','T','W','E','E','N','O','T','H','I','N','G','R','O','U',
153796 'P','S','C','A','S','C','A','D','E','T','A','C','H','C','A','S','E','C',
153797 'O','L','L','A','T','E','C','R','E','A','T','E','C','U','R','R','E','N',
153798 'T','_','D','A','T','E','I','M','M','E','D','I','A','T','E','J','O','I',
153799 'N','S','E','R','T','L','I','K','E','M','A','T','C','H','P','L','A','N',
153800 'A','L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','U','P','D',
153801 'A','T','E','V','A','L','U','E','S','V','I','R','T','U','A','L','I','M',
153802 'I','T','W','H','E','N','O','T','N','U','L','L','W','H','E','R','E','C',
153803 'U','R','S','I','V','E','A','F','T','E','R','E','N','A','M','E','A','N',
153804 'D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E','M','E',
153805 'N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M','I','T',
153806 'C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R','R','E',
153807 'N','T','_','T','I','M','E','S','T','A','M','P','A','R','T','I','T','I',
153808 'O','N','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
153809 'R','O','P','R','E','C','E','D','I','N','G','F','A','I','L','F','I','L',
153810 'T','E','R','E','P','L','A','C','E','F','O','L','L','O','W','I','N','G',
153811 'F','R','O','M','F','U','L','L','I','F','I','S','N','U','L','L','O','R',
153812 'D','E','R','E','S','T','R','I','C','T','O','T','H','E','R','S','O','V',
153813 'E','R','I','G','H','T','R','O','L','L','B','A','C','K','R','O','W','S',
153814 'U','N','B','O','U','N','D','E','D','U','N','I','O','N','U','S','I','N',
153815 'G','V','A','C','U','U','M','V','I','E','W','I','N','D','O','W','B','Y',
153816 'I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R','Y',
 
153817 };
153818 /* aKWHash[i] is the hash value for the i-th keyword */
153819 static const unsigned char aKWHash[127] = {
153820 75, 111, 127, 73, 108, 29, 0, 0, 83, 0, 77, 63, 0,
153821 37, 33, 78, 15, 0, 126, 86, 57, 120, 128, 19, 0, 0,
153822 133, 0, 131, 123, 0, 22, 98, 0, 9, 0, 0, 117, 71,
153823 0, 69, 6, 0, 49, 95, 140, 0, 129, 106, 0, 0, 54,
153824 0, 109, 24, 0, 17, 0, 134, 56, 23, 26, 5, 58, 135,
153825 101, 0, 0, 139, 112, 62, 138, 59, 115, 65, 0, 96, 0,
153826 105, 45, 0, 104, 0, 0, 0, 100, 97, 102, 107, 119, 14,
153827 31, 118, 0, 81, 0, 136, 116, 137, 61, 124, 132, 80, 121,
153828 88, 30, 85, 0, 0, 99, 35, 125, 122, 0, 130, 0, 0,
153829 41, 0, 91, 89, 90, 0, 20, 87, 113, 82,
153830 };
153831 /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
153832 ** then the i-th keyword has no more hash collisions. Otherwise,
153833 ** the next keyword with the same hash is aKWHash[i]-1. */
153834 static const unsigned char aKWNext[140] = {
153835 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
153836 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
153837 0, 0, 0, 21, 0, 0, 12, 0, 0, 0, 0, 0, 0,
153838 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
153839 51, 28, 0, 0, 38, 0, 0, 0, 44, 0, 0, 0, 3,
153840 0, 0, 67, 1, 66, 0, 0, 0, 36, 0, 47, 0, 0,
153841 0, 0, 0, 48, 50, 76, 0, 0, 42, 0, 60, 0, 0,
153842 0, 43, 0, 16, 55, 10, 0, 0, 0, 0, 0, 0, 0,
153843 11, 72, 93, 0, 0, 8, 0, 110, 0, 103, 40, 53, 70,
153844 0, 114, 0, 74, 52, 0, 0, 92, 39, 46, 0, 68, 32,
153845 84, 0, 34, 27, 25, 18, 94, 0, 64, 79,
153846 };
153847 /* aKWLen[i] is the length (in bytes) of the i-th keyword */
153848 static const unsigned char aKWLen[140] = {
153849 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
153850 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7,
153851 6, 9, 4, 2, 10, 9, 4, 9, 4, 6, 2, 3, 11,
153852 6, 2, 7, 5, 5, 6, 7, 10, 6, 5, 7, 4, 5,
153853 7, 9, 6, 6, 6, 4, 5, 5, 5, 7, 7, 6, 5,
153854 7, 3, 6, 4, 7, 6, 12, 9, 4, 6, 4, 5, 4,
153855 7, 6, 5, 6, 6, 7, 5, 4, 7, 3, 2, 4, 5,
153856 9, 5, 6, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5,
153857 17, 12, 7, 9, 8, 8, 2, 4, 9, 4, 6, 7, 9,
153858 4, 4, 2, 6, 5, 8, 6, 4, 5, 8, 4, 3, 9,
153859 5, 5, 6, 4, 6, 2, 2, 9, 3, 7,
153860 };
153861 /* aKWOffset[i] is the index into zKWText[] of the start of
153862 ** the text for the i-th keyword. */
153863 static const unsigned short int aKWOffset[140] = {
153864 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
153865 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
153866 86, 90, 90, 94, 99, 106, 114, 117, 123, 126, 126, 129, 131,
153867 136, 140, 141, 146, 150, 154, 159, 165, 175, 178, 183, 183, 187,
153868 191, 197, 205, 211, 216, 221, 224, 227, 231, 236, 242, 248, 248,
153869 254, 255, 259, 265, 269, 276, 282, 294, 303, 305, 311, 315, 320,
153870 322, 329, 334, 339, 345, 351, 357, 362, 365, 365, 365, 368, 372,
153871 375, 384, 388, 394, 396, 403, 405, 407, 416, 420, 426, 432, 440,
153872 445, 445, 445, 461, 470, 477, 478, 485, 488, 497, 501, 506, 513,
153873 522, 526, 530, 532, 538, 542, 550, 556, 559, 564, 572, 572, 576,
153874 585, 590, 595, 601, 604, 607, 610, 612, 617, 621,
153875 };
153876 /* aKWCode[i] is the parser symbol code for the i-th keyword */
153877 static const unsigned char aKWCode[140] = {
153878 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
153879 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
153880 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
153881 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
153882 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
153883 TK_EXCLUDE, TK_DELETE, TK_TEMP, TK_TEMP, TK_OR,
153884 TK_CONSTRAINT, TK_INTERSECT, TK_TIES, TK_SAVEPOINT, TK_INTO,
153885 TK_OFFSET, TK_OF, TK_SET, TK_TRANSACTION,TK_ACTION,
153886 TK_ON, TK_JOIN_KW, TK_ALTER, TK_RAISE, TK_EXCEPT,
153887 TK_TRIGGER, TK_REFERENCES, TK_UNIQUE, TK_QUERY, TK_WITHOUT,
153888 TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_EXCLUSIVE, TK_EXISTS,
153889 TK_ATTACH, TK_HAVING, TK_LIKE_KW, TK_BEGIN, TK_JOIN_KW,
153890 TK_RANGE, TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP,
153891 TK_CASCADE, TK_ASC, TK_DETACH, TK_CASE, TK_COLLATE,
153892 TK_CREATE, TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT,
153893 TK_LIKE_KW, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA,
153894 TK_ABORT, TK_UPDATE, TK_VALUES, TK_VIRTUAL, TK_LIMIT,
153895 TK_WHEN, TK_NOTNULL, TK_NOT, TK_NO, TK_NULL,
153896 TK_WHERE, TK_RECURSIVE, TK_AFTER, TK_RENAME, TK_AND,
153897 TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
153898 TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW,
153899 TK_CTIME_KW, TK_CURRENT, TK_PARTITION, TK_DEFERRED, TK_DISTINCT,
153900 TK_IS, TK_DROP, TK_PRECEDING, TK_FAIL, TK_FILTER,
153901 TK_REPLACE, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_IF,
153902 TK_ISNULL, TK_ORDER, TK_RESTRICT, TK_OTHERS, TK_OVER,
153903 TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNBOUNDED,
153904 TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_WINDOW,
153905 TK_DO, TK_BY, TK_INITIALLY, TK_ALL, TK_PRIMARY,
 
153906 };
153907 /* Check to see if z[0..n-1] is a keyword. If it is, write the
153908 ** parser symbol code for that keyword into *pType. Always
153909 ** return the integer n (the length of the token). */
153910 static int keywordCode(const char *z, int n, int *pType){
@@ -153951,120 +154766,123 @@
153951 testcase( i==25 ); /* EXCLUDE */
153952 testcase( i==26 ); /* DELETE */
153953 testcase( i==27 ); /* TEMPORARY */
153954 testcase( i==28 ); /* TEMP */
153955 testcase( i==29 ); /* OR */
153956 testcase( i==30 ); /* CONSTRAINT */
153957 testcase( i==31 ); /* INTERSECT */
153958 testcase( i==32 ); /* TIES */
153959 testcase( i==33 ); /* SAVEPOINT */
153960 testcase( i==34 ); /* INTO */
153961 testcase( i==35 ); /* OFFSET */
153962 testcase( i==36 ); /* OF */
153963 testcase( i==37 ); /* SET */
153964 testcase( i==38 ); /* TRANSACTION */
153965 testcase( i==39 ); /* ACTION */
153966 testcase( i==40 ); /* ON */
153967 testcase( i==41 ); /* NATURAL */
153968 testcase( i==42 ); /* ALTER */
153969 testcase( i==43 ); /* RAISE */
153970 testcase( i==44 ); /* EXCEPT */
153971 testcase( i==45 ); /* TRIGGER */
153972 testcase( i==46 ); /* REFERENCES */
153973 testcase( i==47 ); /* UNIQUE */
153974 testcase( i==48 ); /* QUERY */
153975 testcase( i==49 ); /* WITHOUT */
153976 testcase( i==50 ); /* WITH */
153977 testcase( i==51 ); /* OUTER */
153978 testcase( i==52 ); /* RELEASE */
153979 testcase( i==53 ); /* EXCLUSIVE */
153980 testcase( i==54 ); /* EXISTS */
153981 testcase( i==55 ); /* ATTACH */
153982 testcase( i==56 ); /* HAVING */
153983 testcase( i==57 ); /* GLOB */
153984 testcase( i==58 ); /* BEGIN */
153985 testcase( i==59 ); /* INNER */
153986 testcase( i==60 ); /* RANGE */
153987 testcase( i==61 ); /* BETWEEN */
153988 testcase( i==62 ); /* NOTHING */
153989 testcase( i==63 ); /* GROUPS */
153990 testcase( i==64 ); /* GROUP */
153991 testcase( i==65 ); /* CASCADE */
153992 testcase( i==66 ); /* ASC */
153993 testcase( i==67 ); /* DETACH */
153994 testcase( i==68 ); /* CASE */
153995 testcase( i==69 ); /* COLLATE */
153996 testcase( i==70 ); /* CREATE */
153997 testcase( i==71 ); /* CURRENT_DATE */
153998 testcase( i==72 ); /* IMMEDIATE */
153999 testcase( i==73 ); /* JOIN */
154000 testcase( i==74 ); /* INSERT */
154001 testcase( i==75 ); /* LIKE */
154002 testcase( i==76 ); /* MATCH */
154003 testcase( i==77 ); /* PLAN */
154004 testcase( i==78 ); /* ANALYZE */
154005 testcase( i==79 ); /* PRAGMA */
154006 testcase( i==80 ); /* ABORT */
154007 testcase( i==81 ); /* UPDATE */
154008 testcase( i==82 ); /* VALUES */
154009 testcase( i==83 ); /* VIRTUAL */
154010 testcase( i==84 ); /* LIMIT */
154011 testcase( i==85 ); /* WHEN */
154012 testcase( i==86 ); /* NOTNULL */
154013 testcase( i==87 ); /* NOT */
154014 testcase( i==88 ); /* NO */
154015 testcase( i==89 ); /* NULL */
154016 testcase( i==90 ); /* WHERE */
154017 testcase( i==91 ); /* RECURSIVE */
154018 testcase( i==92 ); /* AFTER */
154019 testcase( i==93 ); /* RENAME */
154020 testcase( i==94 ); /* AND */
154021 testcase( i==95 ); /* DEFAULT */
154022 testcase( i==96 ); /* AUTOINCREMENT */
154023 testcase( i==97 ); /* TO */
154024 testcase( i==98 ); /* IN */
154025 testcase( i==99 ); /* CAST */
154026 testcase( i==100 ); /* COLUMN */
154027 testcase( i==101 ); /* COMMIT */
154028 testcase( i==102 ); /* CONFLICT */
154029 testcase( i==103 ); /* CROSS */
154030 testcase( i==104 ); /* CURRENT_TIMESTAMP */
154031 testcase( i==105 ); /* CURRENT_TIME */
154032 testcase( i==106 ); /* CURRENT */
154033 testcase( i==107 ); /* PARTITION */
154034 testcase( i==108 ); /* DEFERRED */
154035 testcase( i==109 ); /* DISTINCT */
154036 testcase( i==110 ); /* IS */
154037 testcase( i==111 ); /* DROP */
154038 testcase( i==112 ); /* PRECEDING */
154039 testcase( i==113 ); /* FAIL */
154040 testcase( i==114 ); /* FILTER */
154041 testcase( i==115 ); /* REPLACE */
154042 testcase( i==116 ); /* FOLLOWING */
154043 testcase( i==117 ); /* FROM */
154044 testcase( i==118 ); /* FULL */
154045 testcase( i==119 ); /* IF */
154046 testcase( i==120 ); /* ISNULL */
154047 testcase( i==121 ); /* ORDER */
154048 testcase( i==122 ); /* RESTRICT */
154049 testcase( i==123 ); /* OTHERS */
154050 testcase( i==124 ); /* OVER */
154051 testcase( i==125 ); /* RIGHT */
154052 testcase( i==126 ); /* ROLLBACK */
154053 testcase( i==127 ); /* ROWS */
154054 testcase( i==128 ); /* ROW */
154055 testcase( i==129 ); /* UNBOUNDED */
154056 testcase( i==130 ); /* UNION */
154057 testcase( i==131 ); /* USING */
154058 testcase( i==132 ); /* VACUUM */
154059 testcase( i==133 ); /* VIEW */
154060 testcase( i==134 ); /* WINDOW */
154061 testcase( i==135 ); /* DO */
154062 testcase( i==136 ); /* BY */
154063 testcase( i==137 ); /* INITIALLY */
154064 testcase( i==138 ); /* ALL */
154065 testcase( i==139 ); /* PRIMARY */
 
 
 
154066 *pType = aKWCode[i];
154067 break;
154068 }
154069 }
154070 return n;
@@ -154072,11 +154890,11 @@
154072 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
154073 int id = TK_ID;
154074 keywordCode((char*)z, n, &id);
154075 return id;
154076 }
154077 #define SQLITE_N_KEYWORD 140
154078 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
154079 if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
154080 *pzName = zKWText + aKWOffset[i];
154081 *pnName = aKWLen[i];
154082 return SQLITE_OK;
@@ -156033,10 +156851,11 @@
156033 int op; /* The opcode */
156034 u32 mask; /* Mask of the bit in sqlite3.flags to set/clear */
156035 } aFlagOp[] = {
156036 { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
156037 { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
 
156038 { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
156039 { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
156040 { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
156041 { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
156042 { SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP },
@@ -156432,15 +157251,12 @@
156432 }
156433 sqlite3HashClear(&db->aCollSeq);
156434 #ifndef SQLITE_OMIT_VIRTUALTABLE
156435 for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){
156436 Module *pMod = (Module *)sqliteHashData(i);
156437 if( pMod->xDestroy ){
156438 pMod->xDestroy(pMod->pAux);
156439 }
156440 sqlite3VtabEponymousTableClear(db, pMod);
156441 sqlite3DbFree(db, pMod);
156442 }
156443 sqlite3HashClear(&db->aModule);
156444 #endif
156445
156446 sqlite3Error(db, SQLITE_OK); /* Deallocates any cached error strings. */
@@ -156917,11 +157733,12 @@
156917 ){
156918 return SQLITE_MISUSE_BKPT;
156919 }
156920
156921 assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
156922 extraFlags = enc & SQLITE_DETERMINISTIC;
 
156923 enc &= (SQLITE_FUNC_ENCMASK|SQLITE_ANY);
156924
156925 #ifndef SQLITE_OMIT_UTF16
156926 /* If SQLITE_UTF16 is specified as the encoding type, transform this
156927 ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
@@ -156980,10 +157797,11 @@
156980 pDestructor->nRef++;
156981 }
156982 p->u.pDestructor = pDestructor;
156983 p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags;
156984 testcase( p->funcFlags & SQLITE_DETERMINISTIC );
 
156985 p->xSFunc = xSFunc ? xSFunc : xStep;
156986 p->xFinalize = xFinal;
156987 p->xValue = xValue;
156988 p->xInverse = xInverse;
156989 p->pUserData = pUserData;
@@ -158272,10 +159090,11 @@
158272 db->szMmap = sqlite3GlobalConfig.szMmap;
158273 db->nextPagesize = 0;
158274 db->nMaxSorterMmap = 0x7FFFFFFF;
158275 db->flags |= SQLITE_ShortColNames
158276 | SQLITE_EnableTrigger
 
158277 | SQLITE_CacheSpill
158278
158279 /* The SQLITE_DQS compile-time option determines the default settings
158280 ** for SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML.
158281 **
@@ -159021,16 +159840,37 @@
159021 case SQLITE_TESTCTRL_PRNG_RESTORE: {
159022 sqlite3PrngRestoreState();
159023 break;
159024 }
159025
159026 /*
159027 ** Reset the PRNG back to its uninitialized state. The next call
159028 ** to sqlite3_randomness() will reseed the PRNG using a single call
159029 ** to the xRandomness method of the default VFS.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159030 */
159031 case SQLITE_TESTCTRL_PRNG_RESET: {
 
 
 
 
 
 
159032 sqlite3_randomness(0,0);
159033 break;
159034 }
159035
159036 /*
@@ -159238,10 +160078,21 @@
159238 */
159239 case SQLITE_TESTCTRL_NEVER_CORRUPT: {
159240 sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int);
159241 break;
159242 }
 
 
 
 
 
 
 
 
 
 
 
159243
159244 /* Set the threshold at which OP_Once counters reset back to zero.
159245 ** By default this is 0x7ffffffe (over 2 billion), but that value is
159246 ** too big to test in a reasonable amount of time, so this control is
159247 ** provided to set a small and easily reachable reset value.
@@ -174941,10 +175792,11 @@
174941 blobGrowBuffer(pPrev, nTerm, &rc);
174942 if( rc!=SQLITE_OK ) return rc;
174943
174944 nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);
174945 nSuffix = nTerm - nPrefix;
 
174946 memcpy(pPrev->a, zTerm, nTerm);
174947 pPrev->n = nTerm;
174948
174949 if( bFirst==0 ){
174950 pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);
@@ -177161,14 +178013,14 @@
177161 char *pCsr = pPhrase->pTail;
177162 int iCsr = pPhrase->iTail;
177163
177164 while( iCsr<(iStart+pIter->nSnippet) && iCsr>=iStart ){
177165 int j;
177166 u64 mPhrase = (u64)1 << i;
177167 u64 mPos = (u64)1 << (iCsr - iStart);
177168 assert( iCsr>=iStart && (iCsr - iStart)<=64 );
177169 assert( i>=0 && i<=64 );
177170 if( (mCover|mCovered)&mPhrase ){
177171 iScore++;
177172 }else{
177173 iScore += 1000;
177174 }
@@ -180325,10 +181177,11 @@
180325 ){
180326 u32 i, j, nKey;
180327 const char *zKey;
180328 JsonNode *pRoot = &pParse->aNode[iRoot];
180329 if( zPath[0]==0 ) return pRoot;
 
180330 if( zPath[0]=='.' ){
180331 if( pRoot->eType!=JSON_OBJECT ) return 0;
180332 zPath++;
180333 if( zPath[0]=='"' ){
180334 zKey = zPath + 1;
@@ -182455,18 +183308,20 @@
182455
182456 /* Check if the requested node is already in the hash table. If so,
182457 ** increase its reference count and return it.
182458 */
182459 if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
182460 assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
182461 if( pParent && !pNode->pParent ){
182462 if( nodeInParentChain(pNode, pParent) ){
182463 RTREE_IS_CORRUPT(pRtree);
182464 return SQLITE_CORRUPT_VTAB;
182465 }
182466 pParent->nRef++;
182467 pNode->pParent = pParent;
 
 
 
182468 }
182469 pNode->nRef++;
182470 *ppNode = pNode;
182471 return SQLITE_OK;
182472 }
@@ -183350,17 +184205,18 @@
183350 int eInt;
183351 RtreeSearchPoint x;
183352
183353 eInt = pRtree->eCoordType==RTREE_COORD_INT32;
183354 while( (p = rtreeSearchPointFirst(pCur))!=0 && p->iLevel>0 ){
 
183355 pNode = rtreeNodeOfFirstSearchPoint(pCur, &rc);
183356 if( rc ) return rc;
183357 nCell = NCELL(pNode);
183358 assert( nCell<200 );
 
183359 while( p->iCell<nCell ){
183360 sqlite3_rtree_dbl rScore = (sqlite3_rtree_dbl)-1;
183361 u8 *pCellData = pNode->zData + (4+pRtree->nBytesPerCell*p->iCell);
183362 eWithin = FULLY_WITHIN;
183363 for(ii=0; ii<nConstraint; ii++){
183364 RtreeConstraint *pConstraint = pCur->aConstraint + ii;
183365 if( pConstraint->op>=RTREE_MATCH ){
183366 rc = rtreeCallbackConstraint(pConstraint, eInt, pCellData, p,
@@ -183369,17 +184225,27 @@
183369 }else if( p->iLevel==1 ){
183370 rtreeLeafConstraint(pConstraint, eInt, pCellData, &eWithin);
183371 }else{
183372 rtreeNonleafConstraint(pConstraint, eInt, pCellData, &eWithin);
183373 }
183374 if( eWithin==NOT_WITHIN ) break;
 
 
 
 
183375 }
183376 p->iCell++;
183377 if( eWithin==NOT_WITHIN ) continue;
 
183378 x.iLevel = p->iLevel - 1;
183379 if( x.iLevel ){
183380 x.id = readInt64(pCellData);
 
 
 
 
 
 
183381 x.iCell = 0;
183382 }else{
183383 x.id = p->id;
183384 x.iCell = p->iCell - 1;
183385 }
@@ -189683,10 +190549,11 @@
189683 "CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)"
189684
189685 typedef struct RbuFrame RbuFrame;
189686 typedef struct RbuObjIter RbuObjIter;
189687 typedef struct RbuState RbuState;
 
189688 typedef struct rbu_vfs rbu_vfs;
189689 typedef struct rbu_file rbu_file;
189690 typedef struct RbuUpdateStmt RbuUpdateStmt;
189691
189692 #if !defined(SQLITE_AMALGAMATION)
@@ -189726,10 +190593,15 @@
189726 struct RbuUpdateStmt {
189727 char *zMask; /* Copy of update mask used with pUpdate */
189728 sqlite3_stmt *pUpdate; /* Last update statement (or NULL) */
189729 RbuUpdateStmt *pNext;
189730 };
 
 
 
 
 
189731
189732 /*
189733 ** An iterator of this type is used to iterate through all objects in
189734 ** the target database that require updating. For each such table, the
189735 ** iterator visits, in order:
@@ -189776,10 +190648,13 @@
189776 int nCol; /* Number of columns in current object */
189777 sqlite3_stmt *pSelect; /* Source data */
189778 sqlite3_stmt *pInsert; /* Statement for INSERT operations */
189779 sqlite3_stmt *pDelete; /* Statement for DELETE ops */
189780 sqlite3_stmt *pTmpInsert; /* Insert into rbu_tmp_$zDataTbl */
 
 
 
189781
189782 /* Last UPDATE used (for PK b-tree updates only), or NULL. */
189783 RbuUpdateStmt *pRbuUpdate;
189784 };
189785
@@ -190310,17 +191185,22 @@
190310 RbuUpdateStmt *pTmp = pUp->pNext;
190311 sqlite3_finalize(pUp->pUpdate);
190312 sqlite3_free(pUp);
190313 pUp = pTmp;
190314 }
 
 
190315
190316 pIter->pSelect = 0;
190317 pIter->pInsert = 0;
190318 pIter->pDelete = 0;
190319 pIter->pRbuUpdate = 0;
190320 pIter->pTmpInsert = 0;
190321 pIter->nCol = 0;
 
 
 
190322 }
190323
190324 /*
190325 ** Clean up any resources allocated as part of the iterator object passed
190326 ** as the only argument.
@@ -190431,12 +191311,12 @@
190431 assert( argc==1 || argc==2 );
190432
190433 zIn = (const char*)sqlite3_value_text(argv[0]);
190434 if( zIn ){
190435 if( rbuIsVacuum(p) ){
190436 assert( argc==2 );
190437 if( 0==sqlite3_value_int(argv[1]) ){
190438 sqlite3_result_text(pCtx, zIn, -1, SQLITE_STATIC);
190439 }
190440 }else{
190441 if( strlen(zIn)>4 && memcmp("data", zIn, 4)==0 ){
190442 int i;
@@ -190590,18 +191470,19 @@
190590 ** if the allocation succeeds, (*pRc) is left unchanged.
190591 */
190592 static char *rbuStrndup(const char *zStr, int *pRc){
190593 char *zRet = 0;
190594
190595 assert( *pRc==SQLITE_OK );
190596 if( zStr ){
190597 size_t nCopy = strlen(zStr) + 1;
190598 zRet = (char*)sqlite3_malloc64(nCopy);
190599 if( zRet ){
190600 memcpy(zRet, zStr, nCopy);
190601 }else{
190602 *pRc = SQLITE_NOMEM;
 
190603 }
190604 }
190605
190606 return zRet;
190607 }
@@ -190769,10 +191650,13 @@
190769 sqlite3_mprintf("PRAGMA main.index_xinfo = %Q", zIdx)
190770 );
190771 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){
190772 int iCid = sqlite3_column_int(pXInfo, 1);
190773 if( iCid>=0 ) pIter->abIndexed[iCid] = 1;
 
 
 
190774 }
190775 rbuFinalize(p, pXInfo);
190776 bIndex = 1;
190777 pIter->nIndex++;
190778 }
@@ -191180,33 +192064,41 @@
191180
191181 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){
191182 int iCid = sqlite3_column_int(pXInfo, 1);
191183 int bDesc = sqlite3_column_int(pXInfo, 3);
191184 const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4);
191185 const char *zCol;
191186 const char *zType;
191187
191188 if( iCid<0 ){
191189 /* An integer primary key. If the table has an explicit IPK, use
191190 ** its name. Otherwise, use "rbu_rowid". */
191191 if( pIter->eType==RBU_PK_IPK ){
191192 int i;
191193 for(i=0; pIter->abTblPk[i]==0; i++);
191194 assert( i<pIter->nTblCol );
191195 zCol = pIter->azTblCol[i];
191196 }else if( rbuIsVacuum(p) ){
191197 zCol = "_rowid_";
191198 }else{
191199 zCol = "rbu_rowid";
191200 }
191201 zType = "INTEGER";
191202 }else{
191203 zCol = pIter->azTblCol[iCid];
191204 zType = pIter->azTblType[iCid];
191205 }
191206
191207 zRet = sqlite3_mprintf("%z%s\"%w\" COLLATE %Q", zRet, zCom, zCol, zCollate);
 
 
 
 
 
 
 
 
191208 if( pIter->bUnique==0 || sqlite3_column_int(pXInfo, 5) ){
191209 const char *zOrder = (bDesc ? " DESC" : "");
191210 zImpPK = sqlite3_mprintf("%z%s\"rbu_imp_%d%w\"%s",
191211 zImpPK, zCom, nBind, zCol, zOrder
191212 );
@@ -191682,34 +192574,65 @@
191682 static char *rbuObjIterGetIndexWhere(sqlite3rbu *p, RbuObjIter *pIter){
191683 sqlite3_stmt *pStmt = 0;
191684 int rc = p->rc;
191685 char *zRet = 0;
191686
 
 
191687 if( rc==SQLITE_OK ){
191688 rc = prepareAndCollectError(p->dbMain, &pStmt, &p->zErrmsg,
191689 "SELECT trim(sql) FROM sqlite_master WHERE type='index' AND name=?"
191690 );
191691 }
191692 if( rc==SQLITE_OK ){
191693 int rc2;
191694 rc = sqlite3_bind_text(pStmt, 1, pIter->zIdx, -1, SQLITE_STATIC);
191695 if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
191696 const char *zSql = (const char*)sqlite3_column_text(pStmt, 0);
 
 
 
191697 if( zSql ){
191698 int nParen = 0; /* Number of open parenthesis */
191699 int i;
 
 
191700 for(i=0; zSql[i]; i++){
191701 char c = zSql[i];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191702 if( c=='(' ){
 
 
 
 
191703 nParen++;
191704 }
191705 else if( c==')' ){
191706 nParen--;
191707 if( nParen==0 ){
 
 
191708 i++;
191709 break;
191710 }
 
 
 
 
191711 }else if( c=='"' || c=='\'' || c=='`' ){
191712 for(i++; 1; i++){
191713 if( zSql[i]==c ){
191714 if( zSql[i+1]!=c ) break;
191715 i++;
@@ -191717,15 +192640,23 @@
191717 }
191718 }else if( c=='[' ){
191719 for(i++; 1; i++){
191720 if( zSql[i]==']' ) break;
191721 }
 
 
 
 
 
 
 
191722 }
191723 }
191724 if( zSql[i] ){
191725 zRet = rbuStrndup(&zSql[i], &rc);
191726 }
 
191727 }
191728 }
191729
191730 rc2 = sqlite3_finalize(pStmt);
191731 if( rc==SQLITE_OK ) rc = rc2;
@@ -191766,15 +192697,15 @@
191766 char *zBind = 0;
191767 char *zPart = 0;
191768 int nBind = 0;
191769
191770 assert( pIter->eType!=RBU_PK_VTAB );
 
191771 zCollist = rbuObjIterGetIndexCols(
191772 p, pIter, &zImposterCols, &zImposterPK, &zWhere, &nBind
191773 );
191774 zBind = rbuObjIterGetBindlist(p, nBind);
191775 zPart = rbuObjIterGetIndexWhere(p, pIter);
191776
191777 /* Create the imposter table used to write to this index. */
191778 sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, "main", 0, 1);
191779 sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, "main", 1,tnum);
191780 rbuMPrintfExec(p, p->dbMain,
@@ -193296,14 +194227,15 @@
193296 ){
193297 sqlite3rbu *p = (sqlite3rbu*)sqlite3_user_data(pCtx);
193298 sqlite3_stmt *pStmt = 0;
193299 char *zErrmsg = 0;
193300 int rc;
 
193301
193302 assert( nVal==1 );
193303
193304 rc = prepareFreeAndCollectError(p->dbMain, &pStmt, &zErrmsg,
193305 sqlite3_mprintf("SELECT count(*) FROM sqlite_master "
193306 "WHERE type='index' AND tbl_name = %Q", sqlite3_value_text(apVal[0]))
193307 );
193308 if( rc!=SQLITE_OK ){
193309 sqlite3_result_error(pCtx, zErrmsg, -1);
@@ -193314,11 +194246,11 @@
193314 }
193315 rc = sqlite3_finalize(pStmt);
193316 if( rc==SQLITE_OK ){
193317 sqlite3_result_int(pCtx, nIndex);
193318 }else{
193319 sqlite3_result_error(pCtx, sqlite3_errmsg(p->dbMain), -1);
193320 }
193321 }
193322
193323 sqlite3_free(zErrmsg);
193324 }
@@ -197757,11 +198689,11 @@
197757 if( *pRc==SQLITE_OK && (size_t)(p->nAlloc-p->nBuf)<nByte ){
197758 u8 *aNew;
197759 i64 nNew = p->nAlloc ? p->nAlloc : 128;
197760 do {
197761 nNew = nNew*2;
197762 }while( (nNew-p->nBuf)<nByte );
197763
197764 aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);
197765 if( 0==aNew ){
197766 *pRc = SQLITE_NOMEM;
197767 }else{
@@ -202158,10 +203090,11 @@
202158 int bColumnsize; /* "columnsize=" option value (dflt==1) */
202159 int eDetail; /* FTS5_DETAIL_XXX value */
202160 char *zContentExprlist;
202161 Fts5Tokenizer *pTok;
202162 fts5_tokenizer *pTokApi;
 
202163
202164 /* Values loaded from the %_config table */
202165 int iCookie; /* Incremented when %_config is modified */
202166 int pgsz; /* Approximate page size used in %_data */
202167 int nAutomerge; /* 'automerge' setting */
@@ -203525,19 +204458,22 @@
203525 fts5yycoverage[stateno][iLookAhead] = 1;
203526 #endif
203527 do{
203528 i = fts5yy_shift_ofst[stateno];
203529 assert( i>=0 );
203530 /* assert( i+fts5YYNFTS5TOKEN<=(int)fts5YY_NLOOKAHEAD ); */
 
203531 assert( iLookAhead!=fts5YYNOCODE );
203532 assert( iLookAhead < fts5YYNFTS5TOKEN );
203533 i += iLookAhead;
203534 if( i>=fts5YY_NLOOKAHEAD || fts5yy_lookahead[i]!=iLookAhead ){
 
203535 #ifdef fts5YYFALLBACK
203536 fts5YYCODETYPE iFallback; /* Fallback token */
203537 if( iLookAhead<sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])
203538 && (iFallback = fts5yyFallback[iLookAhead])!=0 ){
 
203539 #ifndef NDEBUG
203540 if( fts5yyTraceFILE ){
203541 fprintf(fts5yyTraceFILE, "%sFALLBACK %s => %s\n",
203542 fts5yyTracePrompt, fts5yyTokenName[iLookAhead], fts5yyTokenName[iFallback]);
203543 }
@@ -203548,20 +204484,12 @@
203548 }
203549 #endif
203550 #ifdef fts5YYWILDCARD
203551 {
203552 int j = i - iLookAhead + fts5YYWILDCARD;
203553 if(
203554 #if fts5YY_SHIFT_MIN+fts5YYWILDCARD<0
203555 j>=0 &&
203556 #endif
203557 #if fts5YY_SHIFT_MAX+fts5YYWILDCARD>=fts5YY_ACTTAB_COUNT
203558 j<fts5YY_ACTTAB_COUNT &&
203559 #endif
203560 j<(int)(sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0])) &&
203561 fts5yy_lookahead[j]==fts5YYWILDCARD && iLookAhead>0
203562 ){
203563 #ifndef NDEBUG
203564 if( fts5yyTraceFILE ){
203565 fprintf(fts5yyTraceFILE, "%sWILDCARD %s => %s\n",
203566 fts5yyTracePrompt, fts5yyTokenName[iLookAhead],
203567 fts5yyTokenName[fts5YYWILDCARD]);
@@ -203571,10 +204499,11 @@
203571 }
203572 }
203573 #endif /* fts5YYWILDCARD */
203574 return fts5yy_default[stateno];
203575 }else{
 
203576 return fts5yy_action[i];
203577 }
203578 }while(1);
203579 }
203580
@@ -204271,13 +205200,12 @@
204271 ** Return the fallback token corresponding to canonical token iToken, or
204272 ** 0 if iToken has no fallback.
204273 */
204274 static int sqlite3Fts5ParserFallback(int iToken){
204275 #ifdef fts5YYFALLBACK
204276 if( iToken<(int)(sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])) ){
204277 return fts5yyFallback[iToken];
204278 }
204279 #else
204280 (void)iToken;
204281 #endif
204282 return 0;
204283 }
@@ -210470,10 +211398,11 @@
210470 sqlite3_free(pRet);
210471 pRet = 0;
210472 }else{
210473 /* TODO1: Fix this */
210474 pRet->p[nByte] = 0x00;
 
210475 pRet->szLeaf = fts5GetU16(&pRet->p[2]);
210476 }
210477 }
210478 p->rc = rc;
210479 p->nRead++;
@@ -214776,13 +215705,16 @@
214776
214777 i64 iPrev = 0;
214778 Fts5PoslistWriter writer;
214779 memset(&writer, 0, sizeof(writer));
214780
 
 
 
214781 fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);
214782 fts5BufferZero(&tmp);
214783 sqlite3Fts5BufferSize(&p->rc, &tmp, i1.nPoslist + i2.nPoslist);
214784 if( p->rc ) break;
214785
214786 sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);
214787 sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);
214788 assert_nc( iPos1>=0 && iPos2>=0 );
@@ -214826,10 +215758,16 @@
214826 if( nCopy>0 ){
214827 fts5BufferSafeAppendBlob(&tmp, aCopy, nCopy);
214828 }
214829
214830 /* WRITEPOSLISTSIZE */
 
 
 
 
 
 
214831 fts5BufferSafeAppendVarint(&out, tmp.n * 2);
214832 fts5BufferSafeAppendBlob(&out, tmp.p, tmp.n);
214833 fts5DoclistIterNext(&i1);
214834 fts5DoclistIterNext(&i2);
214835 assert_nc( out.n<=(p1->n+p2->n+9) );
@@ -216897,10 +217835,17 @@
216897 assert( SQLITE_INDEX_CONSTRAINT_EQ<SQLITE_INDEX_CONSTRAINT_MATCH );
216898 assert( SQLITE_INDEX_CONSTRAINT_GT<SQLITE_INDEX_CONSTRAINT_MATCH );
216899 assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH );
216900 assert( SQLITE_INDEX_CONSTRAINT_GE<SQLITE_INDEX_CONSTRAINT_MATCH );
216901 assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH );
 
 
 
 
 
 
 
216902
216903 /* Set idxFlags flags for all WHERE clause terms that will be used. */
216904 for(i=0; i<pInfo->nConstraint; i++){
216905 struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];
216906 int iCol = p->iColumn;
@@ -217287,11 +218232,11 @@
217287 ** And since the statement required here reads from this very virtual
217288 ** table, saving it creates a circular reference.
217289 **
217290 ** If SQLite a built-in statement cache, this wouldn't be a problem. */
217291 rc = fts5PrepareStatement(&pSorter->pStmt, pConfig,
217292 "SELECT rowid, rank FROM %Q.%Q ORDER BY %s(%s%s%s) %s",
217293 pConfig->zDb, pConfig->zName, zRank, pConfig->zName,
217294 (zRankArgs ? ", " : ""),
217295 (zRankArgs ? zRankArgs : ""),
217296 bDesc ? "DESC" : "ASC"
217297 );
@@ -217343,14 +218288,14 @@
217343 for(n=0; z[n] && z[n]!=' '; n++);
217344
217345 assert( pTab->p.base.zErrMsg==0 );
217346 pCsr->ePlan = FTS5_PLAN_SPECIAL;
217347
217348 if( 0==sqlite3_strnicmp("reads", z, n) ){
217349 pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->p.pIndex);
217350 }
217351 else if( 0==sqlite3_strnicmp("id", z, n) ){
217352 pCsr->iSpecial = pCsr->iCsrId;
217353 }
217354 else{
217355 /* An unrecognized directive. Return an error message. */
217356 pTab->p.base.zErrMsg = sqlite3_mprintf("unknown special query: %.*s", n, z);
@@ -218594,11 +219539,11 @@
218594 assert( argc>=1 );
218595 pAux = (Fts5Auxiliary*)sqlite3_user_data(context);
218596 iCsrId = sqlite3_value_int64(argv[0]);
218597
218598 pCsr = fts5CursorFromCsrid(pAux->pGlobal, iCsrId);
218599 if( pCsr==0 ){
218600 char *zErr = sqlite3_mprintf("no such cursor: %lld", iCsrId);
218601 sqlite3_result_error(context, zErr, -1);
218602 sqlite3_free(zErr);
218603 }else{
218604 fts5ApiInvoke(pAux, pCsr, context, argc-1, &argv[1]);
@@ -219010,11 +219955,11 @@
219010 int nArg, /* Number of args */
219011 sqlite3_value **apUnused /* Function arguments */
219012 ){
219013 assert( nArg==0 );
219014 UNUSED_PARAM2(nArg, apUnused);
219015 sqlite3_result_text(pCtx, "fts5: 2019-07-10 17:32:03 fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6", -1, SQLITE_TRANSIENT);
219016 }
219017
219018 /*
219019 ** Return true if zName is the extension on one of the shadow tables used
219020 ** by this module.
@@ -219282,11 +220227,13 @@
219282 if( zSql==0 ){
219283 rc = SQLITE_NOMEM;
219284 }else{
219285 int f = SQLITE_PREPARE_PERSISTENT;
219286 if( eStmt>FTS5_STMT_LOOKUP ) f |= SQLITE_PREPARE_NO_VTAB;
 
219287 rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);
 
219288 sqlite3_free(zSql);
219289 if( rc!=SQLITE_OK && pzErrMsg ){
219290 *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
219291 }
219292 }
@@ -223776,12 +224723,12 @@
223776 }
223777 #endif /* SQLITE_CORE */
223778 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
223779
223780 /************** End of stmt.c ************************************************/
223781 #if __LINE__!=223781
223782 #undef SQLITE_SOURCE_ID
223783 #define SQLITE_SOURCE_ID "2019-07-10 17:32:03 fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88alt2"
223784 #endif
223785 /* Return the source-id for this library */
223786 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
223787 /************************** End of sqlite3.c ******************************/
223788
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.30.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -329,12 +329,10 @@
329 #if SQLITE_ENABLE_SQLLOG
330 "ENABLE_SQLLOG",
331 #endif
332 #if defined(SQLITE_ENABLE_STAT4)
333 "ENABLE_STAT4",
 
 
334 #endif
335 #if SQLITE_ENABLE_STMTVTAB
336 "ENABLE_STMTVTAB",
337 #endif
338 #if SQLITE_ENABLE_STMT_SCANSTATUS
@@ -1165,13 +1163,13 @@
1163 **
1164 ** See also: [sqlite3_libversion()],
1165 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1166 ** [sqlite_version()] and [sqlite_source_id()].
1167 */
1168 #define SQLITE_VERSION "3.30.0"
1169 #define SQLITE_VERSION_NUMBER 3030000
1170 #define SQLITE_SOURCE_ID "2019-09-03 16:23:41 3044cf6917ea8324175fc91657e9a5978af9748f72e1914bc361753f0b2d897d"
1171
1172 /*
1173 ** CAPI3REF: Run-Time Library Version Numbers
1174 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1175 **
@@ -3135,10 +3133,21 @@
3133 ** The second parameter is a pointer to an integer into which
3134 ** is written 0 or 1 to indicate whether triggers are disabled or enabled
3135 ** following this call. The second parameter may be a NULL pointer, in
3136 ** which case the trigger setting is not reported back. </dd>
3137 **
3138 ** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
3139 ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
3140 ** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
3141 ** There should be two additional arguments.
3142 ** The first argument is an integer which is 0 to disable views,
3143 ** positive to enable views or negative to leave the setting unchanged.
3144 ** The second parameter is a pointer to an integer into which
3145 ** is written 0 or 1 to indicate whether views are disabled or enabled
3146 ** following this call. The second parameter may be a NULL pointer, in
3147 ** which case the view setting is not reported back. </dd>
3148 **
3149 ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
3150 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
3151 ** <dd> ^This option is used to enable or disable the
3152 ** [fts3_tokenizer()] function which is part of the
3153 ** [FTS3] full-text search engine extension.
@@ -3307,11 +3316,12 @@
3316 #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
3317 #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
3318 #define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
3319 #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
3320 #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
3321 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
3322 #define SQLITE_DBCONFIG_MAX 1015 /* Largest DBCONFIG */
3323
3324 /*
3325 ** CAPI3REF: Enable Or Disable Extended Result Codes
3326 ** METHOD: sqlite3
3327 **
@@ -4856,11 +4866,11 @@
4866 ** a schema change, on the first [sqlite3_step()] call following any change
4867 ** to the [sqlite3_bind_text | bindings] of that [parameter].
4868 ** ^The specific value of WHERE-clause [parameter] might influence the
4869 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
4870 ** or [GLOB] operator or if the parameter is compared to an indexed column
4871 ** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled.
4872 ** </li>
4873 ** </ol>
4874 **
4875 ** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
4876 ** the extra prepFlags parameter, which is a bit array consisting of zero or
@@ -5890,10 +5900,13 @@
5900 ** the same inputs within a single SQL statement. Most SQL functions are
5901 ** deterministic. The built-in [random()] SQL function is an example of a
5902 ** function that is not deterministic. The SQLite query planner is able to
5903 ** perform additional optimizations on deterministic functions, so use
5904 ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
5905 ** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY]
5906 ** flag, which if present prevents the function from being invoked from
5907 ** within VIEWs or TRIGGERs.
5908 **
5909 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
5910 ** function can gain access to this pointer using [sqlite3_user_data()].)^
5911 **
5912 ** ^The sixth, seventh and eighth parameters passed to the three
@@ -6007,12 +6020,20 @@
6020 **
6021 ** These constants may be ORed together with the
6022 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
6023 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or
6024 ** [sqlite3_create_function_v2()].
6025 **
6026 ** The SQLITE_DETERMINISTIC flag means that the new function will always
6027 ** maps the same inputs into the same output. The abs() function is
6028 ** deterministic, for example, but randomblob() is not.
6029 **
6030 ** The SQLITE_DIRECTONLY flag means that the function may only be invoked
6031 ** from top-level SQL, and cannot be used in VIEWs or TRIGGERs.
6032 */
6033 #define SQLITE_DETERMINISTIC 0x000000800
6034 #define SQLITE_DIRECTONLY 0x000080000
6035
6036 /*
6037 ** CAPI3REF: Deprecated Functions
6038 ** DEPRECATED
6039 **
@@ -7654,10 +7675,16 @@
7675 ** no longer needs the pClientData pointer. ^The destructor will also
7676 ** be invoked if the call to sqlite3_create_module_v2() fails.
7677 ** ^The sqlite3_create_module()
7678 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
7679 ** destructor.
7680 **
7681 ** ^If the third parameter (the pointer to the sqlite3_module object) is
7682 ** NULL then no new module is create and any existing modules with the
7683 ** same name are dropped.
7684 **
7685 ** See also: [sqlite3_drop_modules()]
7686 */
7687 SQLITE_API int sqlite3_create_module(
7688 sqlite3 *db, /* SQLite connection to register module with */
7689 const char *zName, /* Name of the module */
7690 const sqlite3_module *p, /* Methods for the module */
@@ -7668,10 +7695,27 @@
7695 const char *zName, /* Name of the module */
7696 const sqlite3_module *p, /* Methods for the module */
7697 void *pClientData, /* Client data for xCreate/xConnect */
7698 void(*xDestroy)(void*) /* Module destructor function */
7699 );
7700
7701 /*
7702 ** CAPI3REF: Remove Unnecessary Virtual Table Implementations
7703 ** METHOD: sqlite3
7704 **
7705 ** ^The sqlite3_drop_modules(D,L) interface removes all virtual
7706 ** table modules from database connection D except those named on list L.
7707 ** The L parameter must be either NULL or a pointer to an array of pointers
7708 ** to strings where the array is terminated by a single NULL pointer.
7709 ** ^If the L parameter is NULL, then all virtual table modules are removed.
7710 **
7711 ** See also: [sqlite3_create_module()]
7712 */
7713 SQLITE_API int sqlite3_drop_modules(
7714 sqlite3 *db, /* Remove modules from this connection */
7715 const char **azKeep /* Except, do not remove the ones named here */
7716 );
7717
7718 /*
7719 ** CAPI3REF: Virtual Table Instance Object
7720 ** KEYWORDS: sqlite3_vtab
7721 **
@@ -8377,11 +8421,11 @@
8421 ** [sqlite3_test_control()] interface.
8422 */
8423 #define SQLITE_TESTCTRL_FIRST 5
8424 #define SQLITE_TESTCTRL_PRNG_SAVE 5
8425 #define SQLITE_TESTCTRL_PRNG_RESTORE 6
8426 #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */
8427 #define SQLITE_TESTCTRL_BITVEC_TEST 8
8428 #define SQLITE_TESTCTRL_FAULT_INSTALL 9
8429 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
8430 #define SQLITE_TESTCTRL_PENDING_BYTE 11
8431 #define SQLITE_TESTCTRL_ASSERT 12
@@ -8400,11 +8444,13 @@
8444 #define SQLITE_TESTCTRL_ISINIT 23
8445 #define SQLITE_TESTCTRL_SORTER_MMAP 24
8446 #define SQLITE_TESTCTRL_IMPOSTER 25
8447 #define SQLITE_TESTCTRL_PARSER_COVERAGE 26
8448 #define SQLITE_TESTCTRL_RESULT_INTREAL 27
8449 #define SQLITE_TESTCTRL_PRNG_SEED 28
8450 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
8451 #define SQLITE_TESTCTRL_LAST 29 /* Largest TESTCTRL */
8452
8453 /*
8454 ** CAPI3REF: SQL Keyword Checking
8455 **
8456 ** These routines provide access to the set of SQL language keywords
@@ -13097,19 +13143,19 @@
13143 ** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
13144 ** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)).
13145 ** So we have to define the macros in different ways depending on the
13146 ** compiler.
13147 */
13148 #if defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
13149 # define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
13150 # define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X))
13151 #elif defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
13152 # define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
13153 # define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
13154 #elif !defined(__GNUC__) /* Works for compilers other than LLVM */
13155 # define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
13156 # define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
 
 
 
13157 #else /* Generates a warning - but it always works */
13158 # define SQLITE_INT_TO_PTR(X) ((void*)(X))
13159 # define SQLITE_PTR_TO_INT(X) ((int)(X))
13160 #endif
13161
@@ -13595,104 +13641,107 @@
13641 #define TK_TRIGGER 77
13642 #define TK_VACUUM 78
13643 #define TK_VIEW 79
13644 #define TK_VIRTUAL 80
13645 #define TK_WITH 81
13646 #define TK_NULLS 82
13647 #define TK_FIRST 83
13648 #define TK_LAST 84
13649 #define TK_CURRENT 85
13650 #define TK_FOLLOWING 86
13651 #define TK_PARTITION 87
13652 #define TK_PRECEDING 88
13653 #define TK_RANGE 89
13654 #define TK_UNBOUNDED 90
13655 #define TK_EXCLUDE 91
13656 #define TK_GROUPS 92
13657 #define TK_OTHERS 93
13658 #define TK_TIES 94
13659 #define TK_REINDEX 95
13660 #define TK_RENAME 96
13661 #define TK_CTIME_KW 97
13662 #define TK_ANY 98
13663 #define TK_BITAND 99
13664 #define TK_BITOR 100
13665 #define TK_LSHIFT 101
13666 #define TK_RSHIFT 102
13667 #define TK_PLUS 103
13668 #define TK_MINUS 104
13669 #define TK_STAR 105
13670 #define TK_SLASH 106
13671 #define TK_REM 107
13672 #define TK_CONCAT 108
13673 #define TK_COLLATE 109
13674 #define TK_BITNOT 110
13675 #define TK_ON 111
13676 #define TK_INDEXED 112
13677 #define TK_STRING 113
13678 #define TK_JOIN_KW 114
13679 #define TK_CONSTRAINT 115
13680 #define TK_DEFAULT 116
13681 #define TK_NULL 117
13682 #define TK_PRIMARY 118
13683 #define TK_UNIQUE 119
13684 #define TK_CHECK 120
13685 #define TK_REFERENCES 121
13686 #define TK_AUTOINCR 122
13687 #define TK_INSERT 123
13688 #define TK_DELETE 124
13689 #define TK_UPDATE 125
13690 #define TK_SET 126
13691 #define TK_DEFERRABLE 127
13692 #define TK_FOREIGN 128
13693 #define TK_DROP 129
13694 #define TK_UNION 130
13695 #define TK_ALL 131
13696 #define TK_EXCEPT 132
13697 #define TK_INTERSECT 133
13698 #define TK_SELECT 134
13699 #define TK_VALUES 135
13700 #define TK_DISTINCT 136
13701 #define TK_DOT 137
13702 #define TK_FROM 138
13703 #define TK_JOIN 139
13704 #define TK_USING 140
13705 #define TK_ORDER 141
13706 #define TK_GROUP 142
13707 #define TK_HAVING 143
13708 #define TK_LIMIT 144
13709 #define TK_WHERE 145
13710 #define TK_INTO 146
13711 #define TK_NOTHING 147
13712 #define TK_FLOAT 148
13713 #define TK_BLOB 149
13714 #define TK_INTEGER 150
13715 #define TK_VARIABLE 151
13716 #define TK_CASE 152
13717 #define TK_WHEN 153
13718 #define TK_THEN 154
13719 #define TK_ELSE 155
13720 #define TK_INDEX 156
13721 #define TK_ALTER 157
13722 #define TK_ADD 158
13723 #define TK_WINDOW 159
13724 #define TK_OVER 160
13725 #define TK_FILTER 161
13726 #define TK_COLUMN 162
13727 #define TK_AGG_FUNCTION 163
13728 #define TK_AGG_COLUMN 164
13729 #define TK_TRUEFALSE 165
13730 #define TK_ISNOT 166
13731 #define TK_FUNCTION 167
13732 #define TK_UMINUS 168
13733 #define TK_UPLUS 169
13734 #define TK_TRUTH 170
13735 #define TK_REGISTER 171
13736 #define TK_VECTOR 172
13737 #define TK_SELECT_COLUMN 173
13738 #define TK_IF_NULL_ROW 174
13739 #define TK_ASTERISK 175
13740 #define TK_SPAN 176
13741 #define TK_SPACE 177
13742 #define TK_ILLEGAL 178
13743
13744 /************** End of parse.h ***********************************************/
13745 /************** Continuing where we left off in sqliteInt.h ******************/
13746 #include <stdio.h>
13747 #include <stdlib.h>
@@ -14099,24 +14148,10 @@
14148 #if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE
14149 # undef SQLITE_DEFAULT_MMAP_SIZE
14150 # define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE
14151 #endif
14152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14153 /*
14154 ** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not
14155 ** the Select query generator tracing logic is turned on.
14156 */
14157 #if defined(SQLITE_ENABLE_SELECTTRACE)
@@ -14982,28 +15017,28 @@
15017 #define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */
15018 #define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
15019 #define OP_Count 93 /* synopsis: r[P2]=count() */
15020 #define OP_ReadCookie 94
15021 #define OP_SetCookie 95
15022 #define OP_ReopenIdx 96 /* synopsis: root=P2 iDb=P3 */
15023 #define OP_OpenRead 97 /* synopsis: root=P2 iDb=P3 */
15024 #define OP_OpenWrite 98 /* synopsis: root=P2 iDb=P3 */
15025 #define OP_BitAnd 99 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
15026 #define OP_BitOr 100 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
15027 #define OP_ShiftLeft 101 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
15028 #define OP_ShiftRight 102 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
15029 #define OP_Add 103 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
15030 #define OP_Subtract 104 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
15031 #define OP_Multiply 105 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
15032 #define OP_Divide 106 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
15033 #define OP_Remainder 107 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
15034 #define OP_Concat 108 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
15035 #define OP_OpenDup 109
15036 #define OP_BitNot 110 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
15037 #define OP_OpenAutoindex 111 /* synopsis: nColumn=P2 */
15038 #define OP_OpenEphemeral 112 /* synopsis: nColumn=P2 */
15039 #define OP_String8 113 /* same as TK_STRING, synopsis: r[P2]='P4' */
15040 #define OP_SorterOpen 114
15041 #define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15042 #define OP_OpenPseudo 116 /* synopsis: P3 columns in r[P2] */
15043 #define OP_Close 117
15044 #define OP_ColumnsUsed 118
@@ -15031,14 +15066,14 @@
15066 #define OP_SqlExec 140
15067 #define OP_ParseSchema 141
15068 #define OP_LoadAnalysis 142
15069 #define OP_DropTable 143
15070 #define OP_DropIndex 144
15071 #define OP_DropTrigger 145
15072 #define OP_IntegrityCk 146
15073 #define OP_RowSetAdd 147 /* synopsis: rowset(P1)=r[P2] */
15074 #define OP_Real 148 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15075 #define OP_Param 149
15076 #define OP_FkCounter 150 /* synopsis: fkctr[P1]+=P2 */
15077 #define OP_MemMax 151 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15078 #define OP_OffsetLimit 152 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15079 #define OP_AggInverse 153 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
@@ -15083,17 +15118,17 @@
15118 /* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\
15119 /* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
15120 /* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
15121 /* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
15122 /* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
15123 /* 96 */ 0x00, 0x00, 0x00, 0x26, 0x26, 0x26, 0x26, 0x26,\
15124 /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12, 0x00,\
15125 /* 112 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15126 /* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15127 /* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
15128 /* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15129 /* 144 */ 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x04,\
15130 /* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15131 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
15132 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,}
15133
15134 /* The sqlite3P2Values() routine is able to run faster if it knows
@@ -15159,14 +15194,14 @@
15194 SQLITE_PRIVATE void sqlite3ExplainBreakpoint(const char*,const char*);
15195 #else
15196 # define sqlite3ExplainBreakpoint(A,B) /*no-op*/
15197 #endif
15198 SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
15199 SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, int addr, u8);
15200 SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1);
15201 SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2);
15202 SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3);
15203 SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5);
15204 SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);
15205 SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr);
15206 SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);
15207 SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);
@@ -16377,10 +16412,11 @@
16412 u8 iDb; /* Which db file is being initialized */
16413 u8 busy; /* TRUE if currently initializing */
16414 unsigned orphanTrigger : 1; /* Last statement is orphaned TEMP trigger */
16415 unsigned imposterTable : 1; /* Building an imposter table */
16416 unsigned reopenMemdb : 1; /* ATTACH is really a reopen using MemDB */
16417 char **azInit; /* "type", "name", and "tbl_name" columns */
16418 } init;
16419 int nVdbeActive; /* Number of VDBEs currently running */
16420 int nVdbeRead; /* Number of active VDBEs that read or write */
16421 int nVdbeWrite; /* Number of active VDBEs that read and write */
16422 int nVdbeExec; /* Number of nested calls to VdbeExec() */
@@ -16515,20 +16551,21 @@
16551 #define SQLITE_LegacyAlter 0x04000000 /* Legacy ALTER TABLE behaviour */
16552 #define SQLITE_NoSchemaError 0x08000000 /* Do not report schema parse errors*/
16553 #define SQLITE_Defensive 0x10000000 /* Input SQL is likely hostile */
16554 #define SQLITE_DqsDDL 0x20000000 /* dbl-quoted strings allowed in DDL*/
16555 #define SQLITE_DqsDML 0x40000000 /* dbl-quoted strings allowed in DML*/
16556 #define SQLITE_EnableView 0x80000000 /* Enable the use of views */
16557
16558 /* Flags used only if debugging */
16559 #define HI(X) ((u64)(X)<<32)
16560 #ifdef SQLITE_DEBUG
16561 #define SQLITE_SqlTrace HI(0x0100000) /* Debug print SQL as it executes */
16562 #define SQLITE_VdbeListing HI(0x0200000) /* Debug listings of VDBE progs */
16563 #define SQLITE_VdbeTrace HI(0x0400000) /* True to trace VDBE execution */
16564 #define SQLITE_VdbeAddopTrace HI(0x0800000) /* Trace sqlite3VdbeAddOp() calls */
16565 #define SQLITE_VdbeEQP HI(0x1000000) /* Debug EXPLAIN QUERY PLAN */
16566 #define SQLITE_ParserTrace HI(0x2000000) /* PRAGMA parser_trace=ON */
16567 #endif
16568
16569 /*
16570 ** Allowed values for sqlite3.mDbFlags
16571 */
@@ -16552,12 +16589,12 @@
16589 #define SQLITE_OrderByIdxJoin 0x0040 /* ORDER BY of joins via index */
16590 #define SQLITE_Transitive 0x0080 /* Transitive constraints */
16591 #define SQLITE_OmitNoopJoin 0x0100 /* Omit unused tables in joins */
16592 #define SQLITE_CountOfView 0x0200 /* The count-of-view optimization */
16593 #define SQLITE_CursorHints 0x0400 /* Add OP_CursorHint opcodes */
16594 #define SQLITE_Stat4 0x0800 /* Use STAT4 data */
16595 /* TH3 expects the Stat4 ^^^^^^ value to be 0x0800. Don't change it */
16596 #define SQLITE_PushDown 0x1000 /* The push-down optimization */
16597 #define SQLITE_SimplifyJoin 0x2000 /* Convert LEFT JOIN to JOIN */
16598 #define SQLITE_SkipScan 0x4000 /* Skip-scans */
16599 #define SQLITE_PropagateConst 0x8000 /* The constant propagation opt */
16600 #define SQLITE_AllOpts 0xffff /* All optimizations */
@@ -16641,10 +16678,11 @@
16678 ** Value constraints (enforced via assert()):
16679 ** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg
16680 ** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG
16681 ** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG
16682 ** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API
16683 ** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API
16684 ** SQLITE_FUNC_ENCMASK depends on SQLITE_UTF* macros in the API
16685 */
16686 #define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
16687 #define SQLITE_FUNC_LIKE 0x0004 /* Candidate for the LIKE optimization */
16688 #define SQLITE_FUNC_CASE 0x0008 /* Case-sensitive LIKE-type function */
@@ -16661,10 +16699,11 @@
16699 ** single query - might change over time */
16700 #define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
16701 #define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */
16702 #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */
16703 #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */
16704 #define SQLITE_FUNC_DIRECT 0x00080000 /* Not for use in TRIGGERs or VIEWs */
16705
16706 /*
16707 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
16708 ** used to create the initializers for the FuncDef structures.
16709 **
@@ -16774,10 +16813,11 @@
16813 ** hash table.
16814 */
16815 struct Module {
16816 const sqlite3_module *pModule; /* Callback pointers */
16817 const char *zName; /* Name passed to create_module() */
16818 int nRefModule; /* Number of pointers to this object */
16819 void *pAux; /* pAux passed to create_module() */
16820 void (*xDestroy)(void *); /* Module destructor function */
16821 Table *pEpoTab; /* Eponymous table for this module */
16822 };
16823
@@ -16839,15 +16879,16 @@
16879 ** used as the P4 operand, they will be more readable.
16880 **
16881 ** Note also that the numeric types are grouped together so that testing
16882 ** for a numeric type is a single comparison. And the BLOB type is first.
16883 */
16884 #define SQLITE_AFF_NONE 0x40 /* '@' */
16885 #define SQLITE_AFF_BLOB 0x41 /* 'A' */
16886 #define SQLITE_AFF_TEXT 0x42 /* 'B' */
16887 #define SQLITE_AFF_NUMERIC 0x43 /* 'C' */
16888 #define SQLITE_AFF_INTEGER 0x44 /* 'D' */
16889 #define SQLITE_AFF_REAL 0x45 /* 'E' */
16890
16891 #define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC)
16892
16893 /*
16894 ** The SQLITE_AFF_MASK values masks off the significant bits of an
@@ -17111,13 +17152,16 @@
17152 u32 nRef; /* Number of references to this KeyInfo object */
17153 u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
17154 u16 nKeyField; /* Number of key columns in the index */
17155 u16 nAllField; /* Total columns, including key plus others */
17156 sqlite3 *db; /* The database connection */
17157 u8 *aSortFlags; /* Sort order for each column. */
17158 CollSeq *aColl[1]; /* Collating sequence for each term of the key */
17159 };
17160
17161 #define KEYINFO_ORDER_DESC 0x01
17162 #define KEYINFO_ORDER_BIGNULL 0x02
17163
17164 /*
17165 ** This object holds a record which has been parsed out into individual
17166 ** fields, for the purposes of doing a comparison.
17167 **
@@ -17222,11 +17266,11 @@
17266 unsigned isCovering:1; /* True if this is a covering index */
17267 unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
17268 unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
17269 unsigned bNoQuery:1; /* Do not use this index to optimize queries */
17270 unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
17271 #ifdef SQLITE_ENABLE_STAT4
17272 int nSample; /* Number of elements in aSample[] */
17273 int nSampleCol; /* Size of IndexSample.anEq[] and so on */
17274 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
17275 IndexSample *aSample; /* Samples of the left-most key */
17276 tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */
@@ -17254,11 +17298,11 @@
17298 */
17299 #define XN_ROWID (-1) /* Indexed column is the rowid */
17300 #define XN_EXPR (-2) /* Indexed column is an expression */
17301
17302 /*
17303 ** Each sample stored in the sqlite_stat4 table is represented in memory
17304 ** using a structure of this type. See documentation at the top of the
17305 ** analyze.c source file for additional information.
17306 */
17307 struct IndexSample {
17308 void *p; /* Pointer to sampled record */
@@ -17412,11 +17456,11 @@
17456 ** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately
17457 ** allocated, regardless of whether or not EP_Reduced is set.
17458 */
17459 struct Expr {
17460 u8 op; /* Operation performed by this node */
17461 char affExpr; /* affinity, or RAISE type */
17462 u32 flags; /* Various flags. EP_* See below */
17463 union {
17464 char *zToken; /* Token value. Zero terminated and dequoted */
17465 int iValue; /* Non-negative integer value if EP_IntValue */
17466 } u;
@@ -17443,10 +17487,11 @@
17487 #endif
17488 int iTable; /* TK_COLUMN: cursor number of table holding column
17489 ** TK_REGISTER: register number
17490 ** TK_TRIGGER: 1 -> new, 0 -> old
17491 ** EP_Unlikely: 134217728 times likelihood
17492 ** TK_SELECT_COLUMN: Number of columns on the LHS
17493 ** TK_SELECT: 1st register of result vector */
17494 ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
17495 ** TK_VARIABLE: variable number (always >= 1).
17496 ** TK_SELECT_COLUMN: column of the result vector */
17497 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
@@ -17456,11 +17501,11 @@
17501 ** TK_AGG_FUNCTION: nesting depth */
17502 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
17503 union {
17504 Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
17505 ** for a column of an index on an expression */
17506 Window *pWin; /* EP_WinFunc: Window/Filter defn for a function */
17507 struct { /* TK_IN, TK_SELECT, and TK_EXISTS */
17508 int iAddr; /* Subroutine entry address */
17509 int regReturn; /* Register used to hold return address */
17510 } sub;
17511 } y;
@@ -17471,40 +17516,41 @@
17516 ** Value restrictions:
17517 **
17518 ** EP_Agg == NC_HasAgg == SF_HasAgg
17519 ** EP_Win == NC_HasWin
17520 */
17521 #define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
17522 #define EP_Distinct 0x000002 /* Aggregate function with DISTINCT keyword */
17523 #define EP_HasFunc 0x000004 /* Contains one or more functions of any kind */
17524 #define EP_FixedCol 0x000008 /* TK_Column with a known fixed value */
17525 #define EP_Agg 0x000010 /* Contains one or more aggregate functions */
17526 #define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
17527 #define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
17528 #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
17529 #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
17530 /* 0x000200 Available for reuse */
17531 #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
17532 #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
17533 #define EP_Skip 0x001000 /* Operator does not contribute to affinity */
17534 #define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
17535 #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
17536 #define EP_Win 0x008000 /* Contains window functions */
17537 #define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */
17538 #define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
17539 #define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */
17540 #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
17541 #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
17542 #define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */
17543 #define EP_Alias 0x400000 /* Is an alias for a result set column */
17544 #define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
17545 #define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
17546 #define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */
17547 #define EP_Quoted 0x4000000 /* TK_ID was originally quoted */
17548 #define EP_Static 0x8000000 /* Held in memory not obtained from malloc() */
17549 #define EP_IsTrue 0x10000000 /* Always has boolean value of TRUE */
17550 #define EP_IsFalse 0x20000000 /* Always has boolean value of FALSE */
17551 #define EP_Indirect 0x40000000 /* Contained within a TRIGGER or a VIEW */
17552
17553 /*
17554 ** The EP_Propagate mask is a set of properties that automatically propagate
17555 ** upwards into parent nodes.
17556 */
@@ -17543,10 +17589,18 @@
17589 /*
17590 ** Flags passed to the sqlite3ExprDup() function. See the header comment
17591 ** above sqlite3ExprDup() for details.
17592 */
17593 #define EXPRDUP_REDUCE 0x0001 /* Used reduced-size Expr nodes */
17594
17595 /*
17596 ** True if the expression passed as an argument was a function with
17597 ** an OVER() clause (a window function).
17598 */
17599 #define IsWindowFunc(p) ( \
17600 ExprHasProperty((p), EP_WinFunc) && p->y.pWin->eFrmType!=TK_FILTER \
17601 )
17602
17603 /*
17604 ** A list of expressions. Each expression may optionally have a
17605 ** name. An expr/name combination can be used in several ways, such
17606 ** as the list of "expr AS ID" fields following a "SELECT" or in the
@@ -17566,15 +17620,16 @@
17620 int nExpr; /* Number of expressions on the list */
17621 struct ExprList_item { /* For each expression in the list */
17622 Expr *pExpr; /* The parse tree for this expression */
17623 char *zName; /* Token associated with this expression */
17624 char *zSpan; /* Original text of the expression */
17625 u8 sortFlags; /* Mask of KEYINFO_ORDER_* flags */
17626 unsigned done :1; /* A flag to indicate when processing is finished */
17627 unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
17628 unsigned reusable :1; /* Constant expression is reusable */
17629 unsigned bSorterRef :1; /* Defer evaluation until after sorting */
17630 unsigned bNulls: 1; /* True if explicit "NULLS FIRST/LAST" */
17631 union {
17632 struct {
17633 u16 iOrderByCol; /* For ORDER BY, column number in result set */
17634 u16 iAlias; /* Index into Parse.aAlias[] for zName */
17635 } x;
@@ -17861,10 +17916,11 @@
17916 #define SF_FixedLimit 0x04000 /* nSelectRow set by a constant LIMIT */
17917 #define SF_MaybeConvert 0x08000 /* Need convertCompoundSelectToSubquery() */
17918 #define SF_Converted 0x10000 /* By convertCompoundSelectToSubquery() */
17919 #define SF_IncludeHidden 0x20000 /* Include hidden columns in output */
17920 #define SF_ComplexResult 0x40000 /* Result contains subquery or function */
17921 #define SF_WhereBegin 0x80000 /* Really a WhereBegin() call. Debug Only */
17922
17923 /*
17924 ** The results of a SELECT can be distributed in several ways, as defined
17925 ** by one of the following macros. The "SRT" prefix means "SELECT Result
17926 ** Type".
@@ -18365,15 +18421,16 @@
18421 **
18422 ** This structure also contains some state information.
18423 */
18424 struct Sqlite3Config {
18425 int bMemstat; /* True to enable memory status */
18426 u8 bCoreMutex; /* True to enable core mutexing */
18427 u8 bFullMutex; /* True to enable full mutexing */
18428 u8 bOpenUri; /* True to interpret filenames as URIs */
18429 u8 bUseCis; /* Use covering indices for full-scans */
18430 u8 bSmallMalloc; /* Avoid large memory allocations if true */
18431 u8 bExtraSchemaChecks; /* Verify type,name,tbl_name in schema */
18432 int mxStrlen; /* Maximum string length */
18433 int neverCorrupt; /* Database is always well-formed */
18434 int szLookaside; /* Default lookaside buffer size */
18435 int nLookaside; /* Default lookaside buffer count */
18436 int nStmtSpill; /* Stmt-journal spill-to-disk threshold */
@@ -18421,10 +18478,11 @@
18478 #endif
18479 int bLocaltimeFault; /* True to fail localtime() calls */
18480 int bInternalFunctions; /* Internal SQL functions are visible */
18481 int iOnceResetThreshold; /* When to reset OP_Once counters */
18482 u32 szSorterRef; /* Min size in bytes to use sorter-refs */
18483 unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */
18484 };
18485
18486 /*
18487 ** This macro is used inside of assert() statements to indicate that
18488 ** the assert is only valid on a well-formed database. Instead of:
@@ -18517,14 +18575,15 @@
18575 u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */
18576 };
18577 #endif /* SQLITE_DEBUG */
18578
18579 /*
18580 ** This object is used in various ways, most (but not all) related to window
18581 ** functions.
18582 **
18583 ** (1) A single instance of this structure is attached to the
18584 ** the Expr.y.pWin field for each window function in an expression tree.
18585 ** This object holds the information contained in the OVER clause,
18586 ** plus additional fields used during code generation.
18587 **
18588 ** (2) All window functions in a single SELECT form a linked-list
18589 ** attached to Select.pWin. The Window.pFunc and Window.pExpr
@@ -18531,10 +18590,14 @@
18590 ** fields point back to the expression that is the window function.
18591 **
18592 ** (3) The terms of the WINDOW clause of a SELECT are instances of this
18593 ** object on a linked list attached to Select.pWinDefn.
18594 **
18595 ** (4) For an aggregate function with a FILTER clause, an instance
18596 ** of this object is stored in Expr.y.pWin with eFrmType set to
18597 ** TK_FILTER. In this case the only field used is Window.pFilter.
18598 **
18599 ** The uses (1) and (2) are really the same Window object that just happens
18600 ** to be accessible in two different ways. Use case (3) are separate objects.
18601 */
18602 struct Window {
18603 char *zName; /* Name of window (may be NULL) */
@@ -18546,10 +18609,11 @@
18609 u8 eEnd; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
18610 u8 bImplicitFrame; /* True if frame was implicitly specified */
18611 u8 eExclude; /* TK_NO, TK_CURRENT, TK_TIES, TK_GROUP, or 0 */
18612 Expr *pStart; /* Expression for "<expr> PRECEDING" */
18613 Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
18614 Window **ppThis; /* Pointer to this object in Select.pWin list */
18615 Window *pNextWin; /* Next window function belonging to this SELECT */
18616 Expr *pFilter; /* The FILTER expression */
18617 FuncDef *pFunc; /* The function */
18618 int iEphCsr; /* Partition buffer or Peer buffer */
18619 int regAccum;
@@ -18565,14 +18629,16 @@
18629 int regEndRowid;
18630 };
18631
18632 #ifndef SQLITE_OMIT_WINDOWFUNC
18633 SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3*, Window*);
18634 SQLITE_PRIVATE void sqlite3WindowUnlinkFromSelect(Window*);
18635 SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p);
18636 SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, u8);
18637 SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*);
18638 SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin);
18639 SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*, int);
18640 SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*);
18641 SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);
18642 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*);
18643 SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*);
18644 SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*);
@@ -18840,11 +18906,11 @@
18906 SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
18907 SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
18908 SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
18909 SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
18910 SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
18911 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int);
18912 SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
18913 SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
18914 SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
18915 SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
18916 SQLITE_PRIVATE int sqlite3IndexHasDuplicateRootPage(Index*);
@@ -18859,12 +18925,12 @@
18925 SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);
18926 SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);
18927 SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);
18928 SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
18929 SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
18930 SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char);
18931 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char);
18932 SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
18933 SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
18934 SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);
18935 SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
18936 #if SQLITE_ENABLE_HIDDEN_COLUMNS
@@ -19161,11 +19227,11 @@
19227 SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst);
19228 #ifndef SQLITE_OMIT_VIRTUALTABLE
19229 SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double);
19230 #endif
19231 #if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
19232 defined(SQLITE_ENABLE_STAT4) || \
19233 defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
19234 SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst);
19235 #endif
19236 SQLITE_PRIVATE VList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int);
19237 SQLITE_PRIVATE const char *sqlite3VListNumToName(VList*,int);
@@ -19227,13 +19293,14 @@
19293 SQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, Expr *pExpr);
19294 SQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,Expr*,Expr*);
19295 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
19296 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
19297 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
19298 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr*);
19299 SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
19300 SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*);
19301 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse*, const char*,const char*,const char*);
19302 SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
19303 SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);
19304 SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);
19305 SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);
19306 SQLITE_PRIVATE int sqlite3AbsInt32(int);
@@ -19316,10 +19383,11 @@
19383 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);
19384 SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo*);
19385 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo*);
19386 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);
19387 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList(Parse*, ExprList*, int, int);
19388 SQLITE_PRIVATE int sqlite3HasExplicitNulls(Parse*, ExprList*);
19389
19390 #ifdef SQLITE_DEBUG
19391 SQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo*);
19392 #endif
19393 SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
@@ -19348,12 +19416,11 @@
19416 SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse*, Expr*);
19417 #else
19418 # define sqlite3ExprCheckIN(x,y) SQLITE_OK
19419 #endif
19420
19421 #ifdef SQLITE_ENABLE_STAT4
 
19422 SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(
19423 Parse*,Index*,UnpackedRecord**,Expr*,int,int,int*);
19424 SQLITE_PRIVATE int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);
19425 SQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord*);
19426 SQLITE_PRIVATE int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);
@@ -19396,10 +19463,11 @@
19463 # define sqlite3VtabRollback(X)
19464 # define sqlite3VtabCommit(X)
19465 # define sqlite3VtabInSync(db) 0
19466 # define sqlite3VtabLock(X)
19467 # define sqlite3VtabUnlock(X)
19468 # define sqlite3VtabModuleUnref(D,X)
19469 # define sqlite3VtabUnlockList(X)
19470 # define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK
19471 # define sqlite3GetVTable(X,Y) ((VTable*)0)
19472 #else
19473 SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table*);
@@ -19407,10 +19475,11 @@
19475 SQLITE_PRIVATE int sqlite3VtabSync(sqlite3 *db, Vdbe*);
19476 SQLITE_PRIVATE int sqlite3VtabRollback(sqlite3 *db);
19477 SQLITE_PRIVATE int sqlite3VtabCommit(sqlite3 *db);
19478 SQLITE_PRIVATE void sqlite3VtabLock(VTable *);
19479 SQLITE_PRIVATE void sqlite3VtabUnlock(VTable *);
19480 SQLITE_PRIVATE void sqlite3VtabModuleUnref(sqlite3*,Module*);
19481 SQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3*);
19482 SQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *, int, int);
19483 SQLITE_PRIVATE void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*);
19484 SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3*, Table*);
19485 SQLITE_PRIVATE Module *sqlite3VtabCreateModule(
@@ -19874,10 +19943,11 @@
19943 1, /* bCoreMutex */
19944 SQLITE_THREADSAFE==1, /* bFullMutex */
19945 SQLITE_USE_URI, /* bOpenUri */
19946 SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */
19947 0, /* bSmallMalloc */
19948 1, /* bExtraSchemaChecks */
19949 0x7ffffffe, /* mxStrlen */
19950 0, /* neverCorrupt */
19951 SQLITE_DEFAULT_LOOKASIDE, /* szLookaside, nLookaside */
19952 SQLITE_STMTJRNL_SPILL, /* nStmtSpill */
19953 {0,0,0,0,0,0,0,0}, /* m */
@@ -19920,10 +19990,11 @@
19990 #endif
19991 0, /* bLocaltimeFault */
19992 0, /* bInternalFunctions */
19993 0x7ffffffe, /* iOnceResetThreshold */
19994 SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
19995 0, /* iPrngSeed */
19996 };
19997
19998 /*
19999 ** Hash table for global functions - functions common to all
20000 ** database connections. After initialization, this table is
@@ -20489,11 +20560,10 @@
20560 void sqliteVdbePopStack(Vdbe*,int);
20561 SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, int*);
20562 SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
20563 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
20564 SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
 
20565 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
20566 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
20567 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3*, AuxData**, int, int);
20568
20569 int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
@@ -22495,11 +22565,19 @@
22565 SQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *pVfs, void *pHandle){
22566 pVfs->xDlClose(pVfs, pHandle);
22567 }
22568 #endif /* SQLITE_OMIT_LOAD_EXTENSION */
22569 SQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
22570 if( sqlite3Config.iPrngSeed ){
22571 memset(zBufOut, 0, nByte);
22572 if( ALWAYS(nByte>(signed)sizeof(unsigned)) ) nByte = sizeof(unsigned int);
22573 memcpy(zBufOut, &sqlite3Config.iPrngSeed, nByte);
22574 return SQLITE_OK;
22575 }else{
22576 return pVfs->xRandomness(pVfs, nByte, zBufOut);
22577 }
22578
22579 }
22580 SQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){
22581 return pVfs->xSleep(pVfs, nMicro);
22582 }
22583 SQLITE_PRIVATE int sqlite3OsGetLastError(sqlite3_vfs *pVfs){
@@ -28776,17 +28854,21 @@
28854 sqlite3TreeViewWith(pView, p->pWith, 1);
28855 cnt = 1;
28856 sqlite3TreeViewPush(pView, 1);
28857 }
28858 do{
28859 if( p->selFlags & SF_WhereBegin ){
28860 sqlite3TreeViewLine(pView, "sqlite3WhereBegin()");
28861 }else{
28862 sqlite3TreeViewLine(pView,
28863 "SELECT%s%s (%u/%p) selFlags=0x%x nSelectRow=%d",
28864 ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
28865 ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""),
28866 p->selId, p, p->selFlags,
28867 (int)p->nSelectRow
28868 );
28869 }
28870 if( cnt++ ) sqlite3TreeViewPop(pView);
28871 if( p->pPrior ){
28872 n = 1000;
28873 }else{
28874 n = 0;
@@ -28799,11 +28881,14 @@
28881 #ifndef SQLITE_OMIT_WINDOWFUNC
28882 if( p->pWin ) n++;
28883 if( p->pWinDefn ) n++;
28884 #endif
28885 }
28886 if( p->pEList ){
28887 sqlite3TreeViewExprList(pView, p->pEList, n>0, "result-set");
28888 }
28889 n--;
28890 #ifndef SQLITE_OMIT_WINDOWFUNC
28891 if( p->pWin ){
28892 Window *pX;
28893 pView = sqlite3TreeViewPush(pView, (n--)>0);
28894 sqlite3TreeViewLine(pView, "window-functions");
@@ -28995,16 +29080,18 @@
29080 if( pExpr==0 ){
29081 sqlite3TreeViewLine(pView, "nil");
29082 sqlite3TreeViewPop(pView);
29083 return;
29084 }
29085 if( pExpr->flags || pExpr->affExpr ){
29086 if( ExprHasProperty(pExpr, EP_FromJoin) ){
29087 sqlite3_snprintf(sizeof(zFlgs),zFlgs," fg.af=%x.%c iRJT=%d",
29088 pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n',
29089 pExpr->iRightJoinTable);
29090 }else{
29091 sqlite3_snprintf(sizeof(zFlgs),zFlgs," fg.af=%x.%c",
29092 pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n');
29093 }
29094 }else{
29095 zFlgs[0] = 0;
29096 }
29097 switch( pExpr->op ){
@@ -29148,14 +29235,14 @@
29235 #else
29236 pWin = 0;
29237 #endif
29238 }
29239 if( pExpr->op==TK_AGG_FUNCTION ){
29240 sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s",
29241 pExpr->op2, pExpr->u.zToken, zFlgs);
29242 }else{
29243 sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs);
29244 }
29245 if( pFarg ){
29246 sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);
29247 }
29248 #ifndef SQLITE_OMIT_WINDOWFUNC
@@ -29228,11 +29315,11 @@
29315 break;
29316 }
29317 #ifndef SQLITE_OMIT_TRIGGER
29318 case TK_RAISE: {
29319 const char *zType = "unk";
29320 switch( pExpr->affExpr ){
29321 case OE_Rollback: zType = "rollback"; break;
29322 case OE_Abort: zType = "abort"; break;
29323 case OE_Fail: zType = "fail"; break;
29324 case OE_Ignore: zType = "ignore"; break;
29325 }
@@ -29269,11 +29356,11 @@
29356 sqlite3TreeViewLine(pView, "%s%s", zBinOp, zFlgs);
29357 sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
29358 sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
29359 }else if( zUniOp ){
29360 sqlite3TreeViewLine(pView, "%s%s", zUniOp, zFlgs);
29361 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
29362 }
29363 sqlite3TreeViewPop(pView);
29364 }
29365
29366
@@ -31777,11 +31864,11 @@
31864 return e*10;
31865 }
31866 #endif /* SQLITE_OMIT_VIRTUALTABLE */
31867
31868 #if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
31869 defined(SQLITE_ENABLE_STAT4) || \
31870 defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
31871 /*
31872 ** Convert a LogEst into an integer.
31873 **
31874 ** Note that this routine is only used when one or more of various
@@ -31795,11 +31882,11 @@
31882 else if( n>=1 ) n -= 1;
31883 #if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
31884 defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
31885 if( x>60 ) return (u64)LARGEST_INT64;
31886 #else
31887 /* If only SQLITE_ENABLE_STAT4 is on, then the largest input
31888 ** possible to this routine is 310, resulting in a maximum x of 31 */
31889 assert( x<=60 );
31890 #endif
31891 return x>=3 ? (n+8)<<(x-3) : (n+8)>>(3-x);
31892 }
@@ -32288,28 +32375,28 @@
32375 /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
32376 /* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
32377 /* 93 */ "Count" OpHelp("r[P2]=count()"),
32378 /* 94 */ "ReadCookie" OpHelp(""),
32379 /* 95 */ "SetCookie" OpHelp(""),
32380 /* 96 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32381 /* 97 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32382 /* 98 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32383 /* 99 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32384 /* 100 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32385 /* 101 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32386 /* 102 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32387 /* 103 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32388 /* 104 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32389 /* 105 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32390 /* 106 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32391 /* 107 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32392 /* 108 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32393 /* 109 */ "OpenDup" OpHelp(""),
32394 /* 110 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32395 /* 111 */ "OpenAutoindex" OpHelp("nColumn=P2"),
32396 /* 112 */ "OpenEphemeral" OpHelp("nColumn=P2"),
32397 /* 113 */ "String8" OpHelp("r[P2]='P4'"),
32398 /* 114 */ "SorterOpen" OpHelp(""),
32399 /* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
32400 /* 116 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
32401 /* 117 */ "Close" OpHelp(""),
32402 /* 118 */ "ColumnsUsed" OpHelp(""),
@@ -32337,14 +32424,14 @@
32424 /* 140 */ "SqlExec" OpHelp(""),
32425 /* 141 */ "ParseSchema" OpHelp(""),
32426 /* 142 */ "LoadAnalysis" OpHelp(""),
32427 /* 143 */ "DropTable" OpHelp(""),
32428 /* 144 */ "DropIndex" OpHelp(""),
32429 /* 145 */ "DropTrigger" OpHelp(""),
32430 /* 146 */ "IntegrityCk" OpHelp(""),
32431 /* 147 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
32432 /* 148 */ "Real" OpHelp("r[P2]=P4"),
32433 /* 149 */ "Param" OpHelp(""),
32434 /* 150 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
32435 /* 151 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
32436 /* 152 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
32437 /* 153 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
@@ -33093,17 +33180,18 @@
33180 #define osLstat ((int(*)(const char*,struct stat*))aSyscall[27].pCurrent)
33181
33182 #if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
33183 # ifdef __ANDROID__
33184 { "ioctl", (sqlite3_syscall_ptr)(int(*)(int, int, ...))ioctl, 0 },
33185 #define osIoctl ((int(*)(int,int,...))aSyscall[28].pCurrent)
33186 # else
33187 { "ioctl", (sqlite3_syscall_ptr)ioctl, 0 },
33188 #define osIoctl ((int(*)(int,unsigned long,...))aSyscall[28].pCurrent)
33189 # endif
33190 #else
33191 { "ioctl", (sqlite3_syscall_ptr)0, 0 },
33192 #endif
 
33193
33194 }; /* End of the overrideable system calls */
33195
33196
33197 /*
@@ -38341,10 +38429,11 @@
38429 }
38430 if( pInode ){
38431 UnixUnusedFd **pp;
38432 assert( sqlite3_mutex_notheld(pInode->pLockMutex) );
38433 sqlite3_mutex_enter(pInode->pLockMutex);
38434 flags &= (SQLITE_OPEN_READONLY|SQLITE_OPEN_READWRITE);
38435 for(pp=&pInode->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
38436 pUnused = *pp;
38437 if( pUnused ){
38438 *pp = pUnused->pNext;
38439 }
@@ -38644,11 +38733,12 @@
38733 *pOutFlags = flags;
38734 }
38735
38736 if( p->pPreallocatedUnused ){
38737 p->pPreallocatedUnused->fd = fd;
38738 p->pPreallocatedUnused->flags =
38739 flags & (SQLITE_OPEN_READONLY|SQLITE_OPEN_READWRITE);
38740 }
38741
38742 if( isDelete ){
38743 #if OS_VXWORKS
38744 zPath = zName;
@@ -40175,11 +40265,11 @@
40265 }
40266 default: {
40267 assert( 0 ); /* The call assures that only valid opcodes are sent */
40268 }
40269 }
40270 /*NOTREACHED*/ assert(0);
40271 return SQLITE_ERROR;
40272 }
40273
40274 /*
40275 ** Within this division (the proxying locking implementation) the procedures
@@ -44860,10 +44950,11 @@
44950
44951 if( !pShm ){
44952 rc = winOpenSharedMemory(pDbFd);
44953 if( rc!=SQLITE_OK ) return rc;
44954 pShm = pDbFd->pShm;
44955 assert( pShm!=0 );
44956 }
44957 pShmNode = pShm->pShmNode;
44958
44959 sqlite3_mutex_enter(pShmNode->mutex);
44960 if( pShmNode->isUnlocked ){
@@ -45162,10 +45253,11 @@
45253 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
45254 return rc;
45255 }
45256 }
45257 if( pFd->mmapSize >= iOff+nAmt ){
45258 assert( pFd->pMapRegion!=0 );
45259 *pp = &((u8 *)pFd->pMapRegion)[iOff];
45260 pFd->nFetchOut++;
45261 }
45262 }
45263 #endif
@@ -48083,10 +48175,11 @@
48175 if( sqlite3GlobalConfig.pcache2.xInit==0 ){
48176 /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the
48177 ** built-in default page cache is used instead of the application defined
48178 ** page cache. */
48179 sqlite3PCacheSetDefault();
48180 assert( sqlite3GlobalConfig.pcache2.xInit!=0 );
48181 }
48182 return sqlite3GlobalConfig.pcache2.xInit(sqlite3GlobalConfig.pcache2.pArg);
48183 }
48184 SQLITE_PRIVATE void sqlite3PcacheShutdown(void){
48185 if( sqlite3GlobalConfig.pcache2.xShutdown ){
@@ -49129,10 +49222,11 @@
49222 PgHdr1 *p = 0;
49223 void *pPg;
49224
49225 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
49226 if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){
49227 assert( pCache->pFree!=0 );
49228 p = pCache->pFree;
49229 pCache->pFree = p->pNext;
49230 p->pNext = 0;
49231 }else{
49232 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
@@ -61855,10 +61949,11 @@
61949 while( iOffset<w.iSyncPoint ){
61950 rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);
61951 if( rc ) return rc;
61952 iOffset += szFrame;
61953 nExtra++;
61954 assert( pLast!=0 );
61955 }
61956 }
61957 if( bSync ){
61958 assert( rc==SQLITE_OK );
61959 rc = sqlite3OsSync(w.pFd, WAL_SYNC_FLAGS(sync_flags));
@@ -61887,10 +61982,11 @@
61982 for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){
61983 if( (p->flags & PGHDR_WAL_APPEND)==0 ) continue;
61984 iFrame++;
61985 rc = walIndexAppend(pWal, iFrame, p->pgno);
61986 }
61987 assert( pLast!=0 || nExtra==0 );
61988 while( rc==SQLITE_OK && nExtra>0 ){
61989 iFrame++;
61990 nExtra--;
61991 rc = walIndexAppend(pWal, iFrame, pLast->pgno);
61992 }
@@ -64898,13 +64994,16 @@
64994 testcase( gap+1==top );
64995 testcase( gap==top );
64996 if( (data[hdr+2] || data[hdr+1]) && gap+2<=top ){
64997 u8 *pSpace = pageFindSlot(pPage, nByte, &rc);
64998 if( pSpace ){
64999 assert( pSpace+nByte<=data+pPage->pBt->usableSize );
65000 if( (*pIdx = (int)(pSpace-data))<=gap ){
65001 return SQLITE_CORRUPT_PAGE(pPage);
65002 }else{
65003 return SQLITE_OK;
65004 }
65005 }else if( rc ){
65006 return rc;
65007 }
65008 }
65009
@@ -68127,10 +68226,11 @@
68226 u8 aSave[4];
68227 u8 *aWrite = &pBuf[-4];
68228 assert( aWrite>=pBufStart ); /* due to (6) */
68229 memcpy(aSave, aWrite, 4);
68230 rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));
68231 if( rc && nextPage>pBt->nPage ) rc = SQLITE_CORRUPT_BKPT;
68232 nextPage = get4byte(aWrite);
68233 memcpy(aWrite, aSave, 4);
68234 }else
68235 #endif
68236
@@ -69915,16 +70015,11 @@
70015 assert( MX_CELL(pPage->pBt)<=10921 );
70016 assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );
70017 assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
70018 assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
70019 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
70020 assert( sz==pPage->xCellSize(pPage, pCell) || CORRUPT_DB );
 
 
 
 
 
70021 assert( pPage->nFree>=0 );
70022 if( pPage->nOverflow || sz+2>pPage->nFree ){
70023 if( pTemp ){
70024 memcpy(pTemp, pCell, sz);
70025 pCell = pTemp;
@@ -70152,11 +70247,11 @@
70247 int k; /* Current slot in pCArray->apEnd[] */
70248 u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */
70249
70250 assert( i<iEnd );
70251 j = get2byte(&aData[hdr+5]);
70252 if( j>(u32)usableSize ){ j = 0; }
70253 memcpy(&pTmp[j], &aData[j], usableSize - j);
70254
70255 for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
70256 pSrcEnd = pCArray->apEnd[k];
70257
@@ -70244,11 +70339,12 @@
70339 for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
70340 pEnd = pCArray->apEnd[k];
70341 while( 1 /*Exit by break*/ ){
70342 int sz, rc;
70343 u8 *pSlot;
70344 assert( pCArray->szCell[i]!=0 );
70345 sz = pCArray->szCell[i];
70346 if( (aData[1]==0 && aData[2]==0) || (pSlot = pageFindSlot(pPg,sz,&rc))==0 ){
70347 if( (pData - pBegin)<sz ) return 1;
70348 pData -= sz;
70349 pSlot = pData;
70350 }
@@ -70405,10 +70501,11 @@
70501 pCellptr = &pPg->aCellIdx[iCell * 2];
70502 if( nCell>iCell ){
70503 memmove(&pCellptr[2], pCellptr, (nCell - iCell) * 2);
70504 }
70505 nCell++;
70506 cachedCellSize(pCArray, iCell+iNew);
70507 if( pageInsertArray(
70508 pPg, pBegin, &pData, pCellptr,
70509 iCell+iNew, 1, pCArray
70510 ) ) goto editpage_fail;
70511 }
@@ -70927,11 +71024,11 @@
71024 ** long be able to find the cells if a pointer to each cell is not saved
71025 ** first.
71026 */
71027 memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*(limit+pOld->nOverflow));
71028 if( pOld->nOverflow>0 ){
71029 if( NEVER(limit<pOld->aiOvfl[0]) ){
71030 rc = SQLITE_CORRUPT_BKPT;
71031 goto balance_cleanup;
71032 }
71033 limit = pOld->aiOvfl[0];
71034 for(j=0; j<limit; j++){
@@ -71213,10 +71310,12 @@
71310 nNew>=5 ? apNew[4]->pgno : 0, nNew>=5 ? szNew[4] : 0,
71311 nNew>=5 ? cntNew[4] - cntNew[3] - !leafData : 0
71312 ));
71313
71314 assert( sqlite3PagerIswriteable(pParent->pDbPage) );
71315 assert( nNew>=1 && nNew<=ArraySize(apNew) );
71316 assert( apNew[nNew-1]!=0 );
71317 put4byte(pRight, apNew[nNew-1]->pgno);
71318
71319 /* If the sibling pages are not leaves, ensure that the right-child pointer
71320 ** of the right-most new sibling page is set to the value that was
71321 ** originally in the same field of the right-most old sibling page. */
@@ -71558,15 +71657,17 @@
71657
71658 VVA_ONLY( int balance_quick_called = 0 );
71659 VVA_ONLY( int balance_deeper_called = 0 );
71660
71661 do {
71662 int iPage;
71663 MemPage *pPage = pCur->pPage;
71664
71665 if( NEVER(pPage->nFree<0) && btreeComputeFreeSpace(pPage) ) break;
71666 if( pPage->nOverflow==0 && pPage->nFree<=nMin ){
71667 break;
71668 }else if( (iPage = pCur->iPage)==0 ){
71669 if( pPage->nOverflow ){
71670 /* The root page of the b-tree is overfull. In this case call the
71671 ** balance_deeper() function to create a new child for the root-page
71672 ** and copy the current contents of the root-page to it. The
71673 ** next iteration of the do-loop will balance the child page.
@@ -71583,12 +71684,10 @@
71684 assert( pCur->pPage->nOverflow );
71685 }
71686 }else{
71687 break;
71688 }
 
 
71689 }else{
71690 MemPage * const pParent = pCur->apPage[iPage-1];
71691 int const iIdx = pCur->aiIdx[iPage-1];
71692
71693 rc = sqlite3PagerWrite(pParent->pDbPage);
@@ -71726,11 +71825,13 @@
71825 MemPage *pPage = pCur->pPage; /* Page being written */
71826 BtShared *pBt; /* Btree */
71827 Pgno ovflPgno; /* Next overflow page to write */
71828 u32 ovflPageSize; /* Size to write on overflow page */
71829
71830 if( pCur->info.pPayload + pCur->info.nLocal > pPage->aDataEnd
71831 || pCur->info.pPayload < pPage->aData + pPage->cellOffset
71832 ){
71833 return SQLITE_CORRUPT_BKPT;
71834 }
71835 /* Overwrite the local portion first */
71836 rc = btreeOverwriteContent(pPage, pCur->info.pPayload, pX,
71837 0, pCur->info.nLocal);
@@ -71967,10 +72068,12 @@
72068 oldCell = findCell(pPage, idx);
72069 if( !pPage->leaf ){
72070 memcpy(newCell, oldCell, 4);
72071 }
72072 rc = clearCell(pPage, oldCell, &info);
72073 testcase( pCur->curFlags & BTCF_ValidOvfl );
72074 invalidateOverflowCache(pCur);
72075 if( info.nSize==szNew && info.nLocal==info.nPayload
72076 && (!ISAUTOVACUUM || szNew<pPage->minLocal)
72077 ){
72078 /* Overwrite the old cell with the new if they are the same size.
72079 ** We could also try to do this if the old cell is smaller, then add
@@ -71980,11 +72083,16 @@
72083 **
72084 ** This optimization cannot be used on an autovacuum database if the
72085 ** new entry uses overflow pages, as the insertCell() call below is
72086 ** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry. */
72087 assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */
72088 if( oldCell < pPage->aData+pPage->hdrOffset+10 ){
72089 return SQLITE_CORRUPT_BKPT;
72090 }
72091 if( oldCell+szNew > pPage->aDataEnd ){
72092 return SQLITE_CORRUPT_BKPT;
72093 }
72094 memcpy(oldCell, newCell, szNew);
72095 return SQLITE_OK;
72096 }
72097 dropCell(pPage, idx, info.nSize, &rc);
72098 if( rc ) goto end_insert;
@@ -74317,12 +74425,14 @@
74425 if( p->pDestDb ){
74426 p->pSrc->nBackup--;
74427 }
74428 if( p->isAttached ){
74429 pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));
74430 assert( pp!=0 );
74431 while( *pp!=p ){
74432 pp = &(*pp)->pNext;
74433 assert( pp!=0 );
74434 }
74435 *pp = p->pNext;
74436 }
74437
74438 /* If a transaction is still open on the Btree, roll it back. */
@@ -75804,11 +75914,11 @@
75914 ** already been allocated, allocate the UnpackedRecord structure that
75915 ** that function will return to its caller here. Then return a pointer to
75916 ** an sqlite3_value within the UnpackedRecord.a[] array.
75917 */
75918 static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){
75919 #ifdef SQLITE_ENABLE_STAT4
75920 if( p ){
75921 UnpackedRecord *pRec = p->ppRec[0];
75922
75923 if( pRec==0 ){
75924 Index *pIdx = p->pIdx; /* Index being probed */
@@ -75840,11 +75950,11 @@
75950 pRec->nField = p->iVal+1;
75951 return &pRec->aMem[p->iVal];
75952 }
75953 #else
75954 UNUSED_PARAMETER(p);
75955 #endif /* defined(SQLITE_ENABLE_STAT4) */
75956 return sqlite3ValueNew(db);
75957 }
75958
75959 /*
75960 ** The expression object indicated by the second argument is guaranteed
@@ -75864,11 +75974,11 @@
75974 **
75975 ** If the conditions above are not met, this function returns SQLITE_OK
75976 ** and sets (*ppVal) to NULL. Or, if an error occurs, (*ppVal) is set to
75977 ** NULL and an SQLite error code returned.
75978 */
75979 #ifdef SQLITE_ENABLE_STAT4
75980 static int valueFromFunction(
75981 sqlite3 *db, /* The database connection */
75982 Expr *p, /* The expression to evaluate */
75983 u8 enc, /* Encoding to use */
75984 u8 aff, /* Affinity to use */
@@ -75947,11 +76057,11 @@
76057 *ppVal = pVal;
76058 return rc;
76059 }
76060 #else
76061 # define valueFromFunction(a,b,c,d,e,f) SQLITE_OK
76062 #endif /* defined(SQLITE_ENABLE_STAT4) */
76063
76064 /*
76065 ** Extract a value from the supplied expression in the manner described
76066 ** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object
76067 ** using valueNew().
@@ -75976,11 +76086,11 @@
76086 const char *zNeg = "";
76087 int rc = SQLITE_OK;
76088
76089 assert( pExpr!=0 );
76090 while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft;
76091 #if defined(SQLITE_ENABLE_STAT4)
76092 if( op==TK_REGISTER ) op = pExpr->op2;
76093 #else
76094 if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
76095 #endif
76096
@@ -76069,11 +76179,11 @@
76179 assert( zVal[nVal]=='\'' );
76180 sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
76181 0, SQLITE_DYNAMIC);
76182 }
76183 #endif
76184 #ifdef SQLITE_ENABLE_STAT4
76185 else if( op==TK_FUNCTION && pCtx!=0 ){
76186 rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
76187 }
76188 #endif
76189 else if( op==TK_TRUEFALSE ){
@@ -76086,17 +76196,17 @@
76196
76197 *ppVal = pVal;
76198 return rc;
76199
76200 no_mem:
76201 #ifdef SQLITE_ENABLE_STAT4
76202 if( pCtx==0 || pCtx->pParse->nErr==0 )
76203 #endif
76204 sqlite3OomFault(db);
76205 sqlite3DbFree(db, zVal);
76206 assert( *ppVal==0 );
76207 #ifdef SQLITE_ENABLE_STAT4
76208 if( pCtx==0 ) sqlite3ValueFree(pVal);
76209 #else
76210 assert( pCtx==0 ); sqlite3ValueFree(pVal);
76211 #endif
76212 return SQLITE_NOMEM_BKPT;
@@ -76120,60 +76230,11 @@
76230 sqlite3_value **ppVal /* Write the new value here */
76231 ){
76232 return pExpr ? valueFromExpr(db, pExpr, enc, affinity, ppVal, 0) : 0;
76233 }
76234
76235 #ifdef SQLITE_ENABLE_STAT4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76236 /*
76237 ** Attempt to extract a value from pExpr and use it to construct *ppVal.
76238 **
76239 ** If pAlloc is not NULL, then an UnpackedRecord object is created for
76240 ** pAlloc if one does not exist and the new value is added to the
@@ -77413,20 +77474,20 @@
77474
77475 /*
77476 ** Change the value of the opcode, or P1, P2, P3, or P5 operands
77477 ** for a specific instruction.
77478 */
77479 SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe *p, int addr, u8 iNewOpcode){
77480 sqlite3VdbeGetOp(p,addr)->opcode = iNewOpcode;
77481 }
77482 SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe *p, int addr, int val){
77483 sqlite3VdbeGetOp(p,addr)->p1 = val;
77484 }
77485 SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe *p, int addr, int val){
77486 sqlite3VdbeGetOp(p,addr)->p2 = val;
77487 }
77488 SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe *p, int addr, int val){
77489 sqlite3VdbeGetOp(p,addr)->p3 = val;
77490 }
77491 SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe *p, u16 p5){
77492 assert( p->nOp>0 || p->db->mallocFailed );
77493 if( p->nOp>0 ) p->aOp[p->nOp-1].p5 = p5;
@@ -77929,18 +77990,20 @@
77990 sqlite3StrAccumInit(&x, 0, zTemp, nTemp, 0);
77991 switch( pOp->p4type ){
77992 case P4_KEYINFO: {
77993 int j;
77994 KeyInfo *pKeyInfo = pOp->p4.pKeyInfo;
77995 assert( pKeyInfo->aSortFlags!=0 );
77996 sqlite3_str_appendf(&x, "k(%d", pKeyInfo->nKeyField);
77997 for(j=0; j<pKeyInfo->nKeyField; j++){
77998 CollSeq *pColl = pKeyInfo->aColl[j];
77999 const char *zColl = pColl ? pColl->zName : "";
78000 if( strcmp(zColl, "BINARY")==0 ) zColl = "B";
78001 sqlite3_str_appendf(&x, ",%s%s%s",
78002 (pKeyInfo->aSortFlags[j] & KEYINFO_ORDER_DESC) ? "-" : "",
78003 (pKeyInfo->aSortFlags[j] & KEYINFO_ORDER_BIGNULL)? "N." : "",
78004 zColl);
78005 }
78006 sqlite3_str_append(&x, ")", 1);
78007 break;
78008 }
78009 #ifdef SQLITE_ENABLE_CURSOR_HINTS
@@ -78343,12 +78406,15 @@
78406 }else{
78407 /* We are currently listing subprograms. Figure out which one and
78408 ** pick up the appropriate opcode. */
78409 int j;
78410 i -= p->nOp;
78411 assert( apSub!=0 );
78412 assert( nSub>0 );
78413 for(j=0; i>=apSub[j]->nOp; j++){
78414 i -= apSub[j]->nOp;
78415 assert( i<apSub[j]->nOp || j+1<nSub );
78416 }
78417 pOp = &apSub[j]->aOp[i];
78418 }
78419
78420 /* When an OP_Program opcode is encounter (the only opcode that has
@@ -79866,14 +79932,21 @@
79932 **
79933 ** The 8 and 9 types were added in 3.3.0, file format 4. Prior versions
79934 ** of SQLite will not understand those serial types.
79935 */
79936
79937 #if 0 /* Inlined into the OP_MakeRecord opcode */
79938 /*
79939 ** Return the serial-type for the value stored in pMem.
79940 **
79941 ** This routine might convert a large MEM_IntReal value into MEM_Real.
79942 **
79943 ** 2019-07-11: The primary user of this subroutine was the OP_MakeRecord
79944 ** opcode in the byte-code engine. But by moving this routine in-line, we
79945 ** can omit some redundant tests and make that opcode a lot faster. So
79946 ** this routine is now only used by the STAT3 logic and STAT3 support has
79947 ** ended. The code is kept here for historical reference only.
79948 */
79949 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format, u32 *pLen){
79950 int flags = pMem->flags;
79951 u32 n;
79952
@@ -79930,10 +80003,11 @@
80003 n += pMem->u.nZero;
80004 }
80005 *pLen = n;
80006 return ((n*2) + 12 + ((flags&MEM_Str)!=0));
80007 }
80008 #endif /* inlined into OP_MakeRecord */
80009
80010 /*
80011 ** The sizes for serial types less than 128
80012 */
80013 static const u8 sqlite3SmallTypeSizes[] = {
@@ -80238,11 +80312,11 @@
80312 int nByte; /* Number of bytes required for *p */
80313 nByte = ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1);
80314 p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte);
80315 if( !p ) return 0;
80316 p->aMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))];
80317 assert( pKeyInfo->aSortFlags!=0 );
80318 p->pKeyInfo = pKeyInfo;
80319 p->nField = pKeyInfo->nKeyField + 1;
80320 return p;
80321 }
80322
@@ -80337,11 +80411,11 @@
80411
80412 idx1 = getVarint32(aKey1, szHdr1);
80413 if( szHdr1>98307 ) return SQLITE_CORRUPT;
80414 d1 = szHdr1;
80415 assert( pKeyInfo->nAllField>=pPKey2->nField || CORRUPT_DB );
80416 assert( pKeyInfo->aSortFlags!=0 );
80417 assert( pKeyInfo->nKeyField>0 );
80418 assert( idx1<=szHdr1 || CORRUPT_DB );
80419 do{
80420 u32 serial_type1;
80421
@@ -80368,11 +80442,16 @@
80442 */
80443 rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
80444 pKeyInfo->nAllField>i ? pKeyInfo->aColl[i] : 0);
80445 if( rc!=0 ){
80446 assert( mem1.szMalloc==0 ); /* See comment below */
80447 if( (pKeyInfo->aSortFlags[i] & KEYINFO_ORDER_BIGNULL)
80448 && ((mem1.flags & MEM_Null) || (pPKey2->aMem[i].flags & MEM_Null))
80449 ){
80450 rc = -rc;
80451 }
80452 if( pKeyInfo->aSortFlags[i] & KEYINFO_ORDER_DESC ){
80453 rc = -rc; /* Invert the result for DESC sort order. */
80454 }
80455 goto debugCompareEnd;
80456 }
80457 i++;
@@ -80744,11 +80823,11 @@
80823 }
80824
80825 VVA_ONLY( mem1.szMalloc = 0; ) /* Only needed by assert() statements */
80826 assert( pPKey2->pKeyInfo->nAllField>=pPKey2->nField
80827 || CORRUPT_DB );
80828 assert( pPKey2->pKeyInfo->aSortFlags!=0 );
80829 assert( pPKey2->pKeyInfo->nKeyField>0 );
80830 assert( idx1<=szHdr1 || CORRUPT_DB );
80831 do{
80832 u32 serial_type;
80833
@@ -80867,12 +80946,18 @@
80946 serial_type = aKey1[idx1];
80947 rc = (serial_type!=0);
80948 }
80949
80950 if( rc!=0 ){
80951 int sortFlags = pPKey2->pKeyInfo->aSortFlags[i];
80952 if( sortFlags ){
80953 if( (sortFlags & KEYINFO_ORDER_BIGNULL)==0
80954 || ((sortFlags & KEYINFO_ORDER_DESC)
80955 !=(serial_type==0 || (pRhs->flags&MEM_Null)))
80956 ){
80957 rc = -rc;
80958 }
80959 }
80960 assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );
80961 assert( mem1.szMalloc==0 ); /* See comment below */
80962 return rc;
80963 }
@@ -81036,11 +81121,15 @@
81121 return 0; /* Corruption */
81122 }
81123 nCmp = MIN( pPKey2->aMem[0].n, nStr );
81124 res = memcmp(&aKey1[szHdr], pPKey2->aMem[0].z, nCmp);
81125
81126 if( res>0 ){
81127 res = pPKey2->r2;
81128 }else if( res<0 ){
81129 res = pPKey2->r1;
81130 }else{
81131 res = nStr - pPKey2->aMem[0].n;
81132 if( res==0 ){
81133 if( pPKey2->nField>1 ){
81134 res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
81135 }else{
@@ -81050,14 +81139,10 @@
81139 }else if( res>0 ){
81140 res = pPKey2->r2;
81141 }else{
81142 res = pPKey2->r1;
81143 }
 
 
 
 
81144 }
81145 }
81146
81147 assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, res)
81148 || CORRUPT_DB
@@ -81085,11 +81170,14 @@
81170 ** The easiest way to enforce this limit is to consider only records with
81171 ** 13 fields or less. If the first field is an integer, the maximum legal
81172 ** header size is (12*5 + 1 + 1) bytes. */
81173 if( p->pKeyInfo->nAllField<=13 ){
81174 int flags = p->aMem[0].flags;
81175 if( p->pKeyInfo->aSortFlags[0] ){
81176 if( p->pKeyInfo->aSortFlags[0] & KEYINFO_ORDER_BIGNULL ){
81177 return sqlite3VdbeRecordCompare;
81178 }
81179 p->r1 = 1;
81180 p->r2 = -1;
81181 }else{
81182 p->r1 = -1;
81183 p->r2 = 1;
@@ -81334,11 +81422,11 @@
81422 ** throw an error if it is given inputs that would make it non-deterministic.
81423 ** This routine is invoked by date/time functions that use non-deterministic
81424 ** features such as 'now'.
81425 */
81426 SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){
81427 #ifdef SQLITE_ENABLE_STAT4
81428 if( pCtx->pVdbe==0 ) return 1;
81429 #endif
81430 if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){
81431 sqlite3_result_error(pCtx,
81432 "non-deterministic function in index expression or CHECK constraint",
@@ -81431,11 +81519,11 @@
81519 preupdate.op = op;
81520 preupdate.iNewReg = iReg;
81521 preupdate.keyinfo.db = db;
81522 preupdate.keyinfo.enc = ENC(db);
81523 preupdate.keyinfo.nKeyField = pTab->nCol;
81524 preupdate.keyinfo.aSortFlags = (u8*)&fakeSortOrder;
81525 preupdate.iKey1 = iKey1;
81526 preupdate.iKey2 = iKey2;
81527 preupdate.pTab = pTab;
81528
81529 db->pPreUpdate = &preupdate;
@@ -82300,11 +82388,11 @@
82388 ** of the amount of time that elapses between invocations. In other words,
82389 ** the time returned is always the time of the first call.
82390 */
82391 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
82392 int rc;
82393 #ifndef SQLITE_ENABLE_STAT4
82394 sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;
82395 assert( p->pVdbe!=0 );
82396 #else
82397 sqlite3_int64 iTime = 0;
82398 sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
@@ -82365,11 +82453,11 @@
82453 */
82454 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
82455 AuxData *pAuxData;
82456
82457 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
82458 #if SQLITE_ENABLE_STAT4
82459 if( pCtx->pVdbe==0 ) return 0;
82460 #else
82461 assert( pCtx->pVdbe!=0 );
82462 #endif
82463 for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){
@@ -82399,11 +82487,11 @@
82487 ){
82488 AuxData *pAuxData;
82489 Vdbe *pVdbe = pCtx->pVdbe;
82490
82491 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
82492 #ifdef SQLITE_ENABLE_STAT4
82493 if( pVdbe==0 ) goto failed;
82494 #else
82495 assert( pVdbe!=0 );
82496 #endif
82497
@@ -84051,10 +84139,11 @@
84139 **
84140 ** SQLITE_AFF_TEXT:
84141 ** Convert pRec to a text representation.
84142 **
84143 ** SQLITE_AFF_BLOB:
84144 ** SQLITE_AFF_NONE:
84145 ** No-op. pRec is unchanged.
84146 */
84147 static void applyAffinity(
84148 Mem *pRec, /* The value to apply affinity to */
84149 char affinity, /* The affinity to be applied */
@@ -84192,15 +84281,16 @@
84281 c = 's';
84282 }
84283 *(zCsr++) = c;
84284 sqlite3_snprintf(100, zCsr, "%d[", pMem->n);
84285 zCsr += sqlite3Strlen30(zCsr);
84286 for(i=0; i<25 && i<pMem->n; i++){
84287 sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
84288 zCsr += sqlite3Strlen30(zCsr);
84289 }
84290 *zCsr++ = '|';
84291 for(i=0; i<25 && i<pMem->n; i++){
84292 char z = pMem->z[i];
84293 if( z<32 || z>126 ) *zCsr++ = '.';
84294 else *zCsr++ = z;
84295 }
84296 *(zCsr++) = ']';
@@ -84226,11 +84316,11 @@
84316 }
84317 k = 2;
84318 sqlite3_snprintf(100, &zBuf[k], "%d", pMem->n);
84319 k += sqlite3Strlen30(&zBuf[k]);
84320 zBuf[k++] = '[';
84321 for(j=0; j<25 && j<pMem->n; j++){
84322 u8 c = pMem->z[j];
84323 if( c>=0x20 && c<0x7f ){
84324 zBuf[k++] = c;
84325 }else{
84326 zBuf[k++] = '.';
@@ -85628,10 +85718,11 @@
85718 pIn1 = &aMem[pOp->p1];
85719 if( pIn1->flags & (MEM_Int|MEM_IntReal) ){
85720 testcase( pIn1->flags & MEM_Int );
85721 testcase( pIn1->flags & MEM_IntReal );
85722 sqlite3VdbeMemRealify(pIn1);
85723 REGISTER_TRACE(pOp->p1, pIn1);
85724 }
85725 break;
85726 }
85727 #endif
85728
@@ -86023,13 +86114,18 @@
86114 assert( memIsValid(&aMem[p2+idx]) );
86115 REGISTER_TRACE(p1+idx, &aMem[p1+idx]);
86116 REGISTER_TRACE(p2+idx, &aMem[p2+idx]);
86117 assert( i<pKeyInfo->nKeyField );
86118 pColl = pKeyInfo->aColl[i];
86119 bRev = (pKeyInfo->aSortFlags[i] & KEYINFO_ORDER_DESC);
86120 iCompare = sqlite3MemCompare(&aMem[p1+idx], &aMem[p2+idx], pColl);
86121 if( iCompare ){
86122 if( (pKeyInfo->aSortFlags[i] & KEYINFO_ORDER_BIGNULL)
86123 && ((aMem[p1+idx].flags & MEM_Null) || (aMem[p2+idx].flags & MEM_Null))
86124 ){
86125 iCompare = -iCompare;
86126 }
86127 if( bRev ) iCompare = -iCompare;
86128 break;
86129 }
86130 }
86131 break;
@@ -86316,15 +86412,10 @@
86412 **
86413 ** If the record contains fewer than P2 fields, then extract a NULL. Or,
86414 ** if the P4 argument is a P4_MEM use the value of the P4 argument as
86415 ** the result.
86416 **
 
 
 
 
 
86417 ** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 then
86418 ** the result is guaranteed to only be used as the argument of a length()
86419 ** or typeof() function, respectively. The loading of large blobs can be
86420 ** skipped for length() and all content loading can be skipped for typeof().
86421 */
@@ -86609,19 +86700,31 @@
86700 zAffinity = pOp->p4.z;
86701 assert( zAffinity!=0 );
86702 assert( pOp->p2>0 );
86703 assert( zAffinity[pOp->p2]==0 );
86704 pIn1 = &aMem[pOp->p1];
86705 while( 1 /*exit-by-break*/ ){
86706 assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] );
86707 assert( memIsValid(pIn1) );
86708 applyAffinity(pIn1, zAffinity[0], encoding);
86709 if( zAffinity[0]==SQLITE_AFF_REAL && (pIn1->flags & MEM_Int)!=0 ){
86710 /* When applying REAL affinity, if the result is still an MEM_Int
86711 ** that will fit in 6 bytes, then change the type to MEM_IntReal
86712 ** so that we keep the high-resolution integer value but know that
86713 ** the type really wants to be REAL. */
86714 testcase( pIn1->u.i==140737488355328LL );
86715 testcase( pIn1->u.i==140737488355327LL );
86716 testcase( pIn1->u.i==-140737488355328LL );
86717 testcase( pIn1->u.i==-140737488355329LL );
86718 if( pIn1->u.i<=140737488355327LL && pIn1->u.i>=-140737488355328LL ){
86719 pIn1->flags |= MEM_IntReal;
86720 pIn1->flags &= ~MEM_Int;
86721 }else{
86722 pIn1->u.r = (double)pIn1->u.i;
86723 pIn1->flags |= MEM_Real;
86724 pIn1->flags &= ~MEM_Int;
86725 }
86726 }
86727 REGISTER_TRACE((int)(pIn1-aMem), pIn1);
86728 zAffinity++;
86729 if( zAffinity[0]==0 ) break;
86730 pIn1++;
@@ -86724,38 +86827,124 @@
86827 }
86828 }
86829 #endif
86830
86831 /* Loop through the elements that will make up the record to figure
86832 ** out how much space is required for the new record. After this loop,
86833 ** the Mem.uTemp field of each term should hold the serial-type that will
86834 ** be used for that term in the generated record:
86835 **
86836 ** Mem.uTemp value type
86837 ** --------------- ---------------
86838 ** 0 NULL
86839 ** 1 1-byte signed integer
86840 ** 2 2-byte signed integer
86841 ** 3 3-byte signed integer
86842 ** 4 4-byte signed integer
86843 ** 5 6-byte signed integer
86844 ** 6 8-byte signed integer
86845 ** 7 IEEE float
86846 ** 8 Integer constant 0
86847 ** 9 Integer constant 1
86848 ** 10,11 reserved for expansion
86849 ** N>=12 and even BLOB
86850 ** N>=13 and odd text
86851 **
86852 ** The following additional values are computed:
86853 ** nHdr Number of bytes needed for the record header
86854 ** nData Number of bytes of data space needed for the record
86855 ** nZero Zero bytes at the end of the record
86856 */
86857 pRec = pLast;
86858 do{
86859 assert( memIsValid(pRec) );
86860 if( pRec->flags & MEM_Null ){
86861 if( pRec->flags & MEM_Zero ){
 
86862 /* Values with MEM_Null and MEM_Zero are created by xColumn virtual
86863 ** table methods that never invoke sqlite3_result_xxxxx() while
86864 ** computing an unchanging column value in an UPDATE statement.
86865 ** Give such values a special internal-use-only serial-type of 10
86866 ** so that they can be passed through to xUpdate and have
86867 ** a true sqlite3_value_nochange(). */
86868 assert( pOp->p5==OPFLAG_NOCHNG_MAGIC || CORRUPT_DB );
86869 pRec->uTemp = 10;
 
 
86870 }else{
86871 pRec->uTemp = 0;
86872 }
86873 nHdr++;
86874 }else if( pRec->flags & (MEM_Int|MEM_IntReal) ){
86875 /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */
86876 i64 i = pRec->u.i;
86877 u64 uu;
86878 testcase( pRec->flags & MEM_Int );
86879 testcase( pRec->flags & MEM_IntReal );
86880 if( i<0 ){
86881 uu = ~i;
86882 }else{
86883 uu = i;
86884 }
86885 nHdr++;
86886 testcase( uu==127 ); testcase( uu==128 );
86887 testcase( uu==32767 ); testcase( uu==32768 );
86888 testcase( uu==8388607 ); testcase( uu==8388608 );
86889 testcase( uu==2147483647 ); testcase( uu==2147483648 );
86890 testcase( uu==140737488355327LL ); testcase( uu==140737488355328LL );
86891 if( uu<=127 ){
86892 if( (i&1)==i && file_format>=4 ){
86893 pRec->uTemp = 8+(u32)uu;
86894 }else{
86895 nData++;
86896 pRec->uTemp = 1;
86897 }
86898 }else if( uu<=32767 ){
86899 nData += 2;
86900 pRec->uTemp = 2;
86901 }else if( uu<=8388607 ){
86902 nData += 3;
86903 pRec->uTemp = 3;
86904 }else if( uu<=2147483647 ){
86905 nData += 4;
86906 pRec->uTemp = 4;
86907 }else if( uu<=140737488355327LL ){
86908 nData += 6;
86909 pRec->uTemp = 5;
86910 }else{
86911 nData += 8;
86912 if( pRec->flags & MEM_IntReal ){
86913 /* If the value is IntReal and is going to take up 8 bytes to store
86914 ** as an integer, then we might as well make it an 8-byte floating
86915 ** point value */
86916 pRec->u.r = (double)pRec->u.i;
86917 pRec->flags &= ~MEM_IntReal;
86918 pRec->flags |= MEM_Real;
86919 pRec->uTemp = 7;
86920 }else{
86921 pRec->uTemp = 6;
86922 }
86923 }
86924 }else if( pRec->flags & MEM_Real ){
86925 nHdr++;
86926 nData += 8;
86927 pRec->uTemp = 7;
86928 }else{
86929 assert( db->mallocFailed || pRec->flags&(MEM_Str|MEM_Blob) );
86930 assert( pRec->n>=0 );
86931 len = (u32)pRec->n;
86932 serial_type = (len*2) + 12 + ((pRec->flags & MEM_Str)!=0);
86933 if( pRec->flags & MEM_Zero ){
86934 serial_type += pRec->u.nZero*2;
86935 if( nData ){
86936 if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem;
86937 len += pRec->u.nZero;
86938 }else{
86939 nZero += pRec->u.nZero;
86940 }
86941 }
86942 nData += len;
86943 nHdr += sqlite3VarintLen(serial_type);
86944 pRec->uTemp = serial_type;
86945 }
86946 if( pRec==pData0 ) break;
86947 pRec--;
86948 }while(1);
86949
86950 /* EVIDENCE-OF: R-22564-11647 The header begins with a single varint
@@ -87087,11 +87276,11 @@
87276 "cannot commit - no transaction is active"));
87277
87278 rc = SQLITE_ERROR;
87279 goto abort_due_to_error;
87280 }
87281 /*NOTREACHED*/ assert(0);
87282 }
87283
87284 /* Opcode: Transaction P1 P2 P3 P4 P5
87285 **
87286 ** Begin a transaction on database P1 if a transaction is not already
@@ -87825,30 +88014,34 @@
88014 #endif
88015
88016 pC->deferredMoveto = 0;
88017 pC->cacheStatus = CACHE_STALE;
88018 if( pC->isTable ){
88019 u16 flags3, newType;
88020 /* The BTREE_SEEK_EQ flag is only set on index cursors */
88021 assert( sqlite3BtreeCursorHasHint(pC->uc.pCursor, BTREE_SEEK_EQ)==0
88022 || CORRUPT_DB );
88023
88024 /* The input value in P3 might be of any type: integer, real, string,
88025 ** blob, or NULL. But it needs to be an integer before we can do
88026 ** the seek, so convert it. */
88027 pIn3 = &aMem[pOp->p3];
88028 flags3 = pIn3->flags;
88029 if( (flags3 & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Str))==MEM_Str ){
88030 applyNumericAffinity(pIn3, 0);
88031 }
88032 iKey = sqlite3VdbeIntValue(pIn3); /* Get the integer key value */
88033 newType = pIn3->flags; /* Record the type after applying numeric affinity */
88034 pIn3->flags = flags3; /* But convert the type back to its original */
88035
88036 /* If the P3 value could not be converted into an integer without
88037 ** loss of information, then special processing is required... */
88038 if( (newType & (MEM_Int|MEM_IntReal))==0 ){
88039 if( (newType & MEM_Real)==0 ){
88040 if( (newType & MEM_Null) || oc>=OP_SeekGE ){
88041 VdbeBranchTaken(1,2);
88042 goto jump_to_p2;
88043 }else{
88044 rc = sqlite3BtreeLast(pC->uc.pCursor, &res);
88045 if( rc!=SQLITE_OK ) goto abort_due_to_error;
88046 goto seek_not_found;
88047 }
@@ -89138,15 +89331,16 @@
89331
89332 /* The Next opcode is only used after SeekGT, SeekGE, Rewind, and Found.
89333 ** The Prev opcode is only used after SeekLT, SeekLE, and Last. */
89334 assert( pOp->opcode!=OP_Next
89335 || pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
89336 || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
89337 || pC->seekOp==OP_NullRow|| pC->seekOp==OP_SeekRowid
89338 || pC->seekOp==OP_IfNoHope);
89339 assert( pOp->opcode!=OP_Prev
89340 || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
89341 || pC->seekOp==OP_Last || pC->seekOp==OP_IfNoHope
89342 || pC->seekOp==OP_NullRow);
89343
89344 rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
89345 next_tail:
89346 pC->cacheStatus = CACHE_STALE;
@@ -89661,11 +89855,11 @@
89855 initData.db = db;
89856 initData.iDb = iDb;
89857 initData.pzErrMsg = &p->zErrMsg;
89858 initData.mInitFlags = 0;
89859 zSql = sqlite3MPrintf(db,
89860 "SELECT*FROM\"%w\".%s WHERE %s ORDER BY rowid",
89861 db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);
89862 if( zSql==0 ){
89863 rc = SQLITE_NOMEM_BKPT;
89864 }else{
89865 assert( db->init.busy==0 );
@@ -91868,15 +92062,16 @@
92062 Incrblob *p = (Incrblob *)pBlob;
92063 int rc;
92064 sqlite3 *db;
92065
92066 if( p ){
92067 sqlite3_stmt *pStmt = p->pStmt;
92068 db = p->db;
92069 sqlite3_mutex_enter(db->mutex);
 
92070 sqlite3DbFree(db, p);
92071 sqlite3_mutex_leave(db->mutex);
92072 rc = sqlite3_finalize(pStmt);
92073 }else{
92074 rc = SQLITE_OK;
92075 }
92076 return rc;
92077 }
@@ -92852,11 +93047,12 @@
93047 res = vdbeSorterCompareTail(
93048 pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2
93049 );
93050 }
93051 }else{
93052 assert( !(pTask->pSorter->pKeyInfo->aSortFlags[0]&KEYINFO_ORDER_BIGNULL) );
93053 if( pTask->pSorter->pKeyInfo->aSortFlags[0] ){
93054 res = res * -1;
93055 }
93056 }
93057
93058 return res;
@@ -92920,11 +93116,12 @@
93116 if( pTask->pSorter->pKeyInfo->nKeyField>1 ){
93117 res = vdbeSorterCompareTail(
93118 pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2
93119 );
93120 }
93121 }else if( pTask->pSorter->pKeyInfo->aSortFlags[0] ){
93122 assert( !(pTask->pSorter->pKeyInfo->aSortFlags[0]&KEYINFO_ORDER_BIGNULL) );
93123 res = res * -1;
93124 }
93125
93126 return res;
93127 }
@@ -93035,10 +93232,11 @@
93232 }
93233 }
93234
93235 if( pKeyInfo->nAllField<13
93236 && (pKeyInfo->aColl[0]==0 || pKeyInfo->aColl[0]==db->pDfltColl)
93237 && (pKeyInfo->aSortFlags[0] & KEYINFO_ORDER_BIGNULL)==0
93238 ){
93239 pSorter->typeMask = SORTER_TYPE_INTEGER | SORTER_TYPE_TEXT;
93240 }
93241 }
93242
@@ -93751,17 +93949,20 @@
93949 if( i==nWorker ){
93950 /* Use the foreground thread for this operation */
93951 rc = vdbeSorterListToPMA(&pSorter->aTask[nWorker], &pSorter->list);
93952 }else{
93953 /* Launch a background thread for this operation */
93954 u8 *aMem;
93955 void *pCtx;
93956
93957 assert( pTask!=0 );
93958 assert( pTask->pThread==0 && pTask->bDone==0 );
93959 assert( pTask->list.pList==0 );
93960 assert( pTask->list.aMemory==0 || pSorter->list.aMemory!=0 );
93961
93962 aMem = pTask->list.aMemory;
93963 pCtx = (void*)pTask;
93964 pSorter->iPrev = (u8)(pTask - pSorter->aTask);
93965 pTask->list = pSorter->list;
93966 pSorter->list.pList = 0;
93967 pSorter->list.szPMA = 0;
93968 if( aMem ){
@@ -94881,18 +95082,13 @@
95082 u8 *zOut = zBuf;
95083 int nRead = iAmt;
95084 int iChunkOffset;
95085 FileChunk *pChunk;
95086
 
 
95087 if( (iAmt+iOfst)>p->endpoint.iOffset ){
95088 return SQLITE_IOERR_SHORT_READ;
95089 }
 
 
 
95090 assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 );
95091 if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
95092 sqlite3_int64 iOff = 0;
95093 for(pChunk=p->pFirst;
95094 ALWAYS(pChunk) && (iOff+p->nChunkSize)<=iOfst;
@@ -95247,13 +95443,26 @@
95443 ** as the second argument.
95444 */
95445 static int walkWindowList(Walker *pWalker, Window *pList){
95446 Window *pWin;
95447 for(pWin=pList; pWin; pWin=pWin->pNextWin){
95448 int rc;
95449 rc = sqlite3WalkExprList(pWalker, pWin->pOrderBy);
95450 if( rc ) return WRC_Abort;
95451 rc = sqlite3WalkExprList(pWalker, pWin->pPartition);
95452 if( rc ) return WRC_Abort;
95453 rc = sqlite3WalkExpr(pWalker, pWin->pFilter);
95454 if( rc ) return WRC_Abort;
95455
95456 /* The next two are purely for calls to sqlite3RenameExprUnmap()
95457 ** within sqlite3WindowOffsetExpr(). Because of constraints imposed
95458 ** by sqlite3WindowOffsetExpr(), they can never fail. The results do
95459 ** not matter anyhow. */
95460 rc = sqlite3WalkExpr(pWalker, pWin->pStart);
95461 if( NEVER(rc) ) return WRC_Abort;
95462 rc = sqlite3WalkExpr(pWalker, pWin->pEnd);
95463 if( NEVER(rc) ) return WRC_Abort;
95464 }
95465 return WRC_Continue;
95466 }
95467 #endif
95468
@@ -95285,22 +95494,26 @@
95494 if( rc ) return rc & WRC_Abort;
95495 if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){
95496 if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
95497 assert( pExpr->x.pList==0 || pExpr->pRight==0 );
95498 if( pExpr->pRight ){
95499 assert( !ExprHasProperty(pExpr, EP_WinFunc) );
95500 pExpr = pExpr->pRight;
95501 continue;
95502 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
95503 assert( !ExprHasProperty(pExpr, EP_WinFunc) );
95504 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
95505 }else{
95506 if( pExpr->x.pList ){
95507 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
95508 }
95509 #ifndef SQLITE_OMIT_WINDOWFUNC
95510 if( ExprHasProperty(pExpr, EP_WinFunc) ){
95511 if( walkWindowList(pWalker, pExpr->y.pWin) ) return WRC_Abort;
95512 }
95513 #endif
95514 }
 
95515 }
95516 break;
95517 }
95518 return WRC_Continue;
95519 }
@@ -95338,12 +95551,13 @@
95551 if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;
95552 #if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE)
95553 {
95554 Parse *pParse = pWalker->pParse;
95555 if( pParse && IN_RENAME_OBJECT ){
95556 /* The following may return WRC_Abort if there are unresolvable
95557 ** symbols (e.g. a table that does not exist) in a window definition. */
95558 int rc = walkWindowList(pWalker, p->pWinDefn);
 
95559 return rc;
95560 }
95561 }
95562 #endif
95563 return WRC_Continue;
@@ -95796,11 +96010,11 @@
96010 }else
96011 #endif /* SQLITE_OMIT_UPSERT */
96012 {
96013 #ifndef SQLITE_OMIT_TRIGGER
96014 if( iCol<0 ){
96015 pExpr->affExpr = SQLITE_AFF_INTEGER;
96016 }else if( pExpr->iTable==0 ){
96017 testcase( iCol==31 );
96018 testcase( iCol==32 );
96019 pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
96020 }else{
@@ -95828,11 +96042,11 @@
96042 && sqlite3IsRowid(zCol)
96043 && VisibleRowid(pMatch->pTab)
96044 ){
96045 cnt = 1;
96046 pExpr->iColumn = -1;
96047 pExpr->affExpr = SQLITE_AFF_INTEGER;
96048 }
96049
96050 /*
96051 ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z
96052 ** might refer to an result-set alias. This happens, for example, when
@@ -96104,11 +96318,11 @@
96318 assert( HasRowid(pItem->pTab) && pItem->pTab->pSelect==0 );
96319 pExpr->op = TK_COLUMN;
96320 pExpr->y.pTab = pItem->pTab;
96321 pExpr->iTable = pItem->iCursor;
96322 pExpr->iColumn = -1;
96323 pExpr->affExpr = SQLITE_AFF_INTEGER;
96324 break;
96325 }
96326 #endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)
96327 && !defined(SQLITE_OMIT_SUBQUERY) */
96328
@@ -96164,11 +96378,13 @@
96378 int nId; /* Number of characters in function name */
96379 const char *zId; /* The function name. */
96380 FuncDef *pDef; /* Information about the function */
96381 u8 enc = ENC(pParse->db); /* The database encoding */
96382 int savedAllowFlags = (pNC->ncFlags & (NC_AllowAgg | NC_AllowWin));
96383 #ifndef SQLITE_OMIT_WINDOWFUNC
96384 Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0);
96385 #endif
96386 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
96387 zId = pExpr->u.zToken;
96388 nId = sqlite3Strlen30(zId);
96389 pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);
96390 if( pDef==0 ){
@@ -96236,31 +96452,40 @@
96452 ){
96453 /* Internal-use-only functions are disallowed unless the
96454 ** SQL is being compiled using sqlite3NestedParse() */
96455 no_such_func = 1;
96456 pDef = 0;
96457 }else
96458 if( (pDef->funcFlags & SQLITE_FUNC_DIRECT)!=0
96459 && ExprHasProperty(pExpr, EP_Indirect)
96460 && !IN_RENAME_OBJECT
96461 ){
96462 /* Functions tagged with SQLITE_DIRECTONLY may not be used
96463 ** inside of triggers and views */
96464 sqlite3ErrorMsg(pParse, "%s() prohibited in triggers and views",
96465 pDef->zName);
96466 }
96467 }
96468
96469 if( 0==IN_RENAME_OBJECT ){
96470 #ifndef SQLITE_OMIT_WINDOWFUNC
96471 assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
96472 || (pDef->xValue==0 && pDef->xInverse==0)
96473 || (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
96474 );
96475 if( pDef && pDef->xValue==0 && pWin ){
96476 sqlite3ErrorMsg(pParse,
96477 "%.*s() may not be used as a window function", nId, zId
96478 );
96479 pNC->nErr++;
96480 }else if(
96481 (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
96482 || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pWin)
96483 || (is_agg && pWin && (pNC->ncFlags & NC_AllowWin)==0)
96484 ){
96485 const char *zType;
96486 if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pWin ){
96487 zType = "window";
96488 }else{
96489 zType = "aggregate";
96490 }
96491 sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
@@ -96284,51 +96509,66 @@
96509 }else if( wrong_num_args ){
96510 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
96511 nId, zId);
96512 pNC->nErr++;
96513 }
96514 #ifndef SQLITE_OMIT_WINDOWFUNC
96515 else if( is_agg==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
96516 sqlite3ErrorMsg(pParse,
96517 "FILTER may not be used with non-aggregate %.*s()",
96518 nId, zId
96519 );
96520 pNC->nErr++;
96521 }
96522 #endif
96523 if( is_agg ){
96524 /* Window functions may not be arguments of aggregate functions.
96525 ** Or arguments of other window functions. But aggregate functions
96526 ** may be arguments for window functions. */
96527 #ifndef SQLITE_OMIT_WINDOWFUNC
96528 pNC->ncFlags &= ~(NC_AllowWin | (!pWin ? NC_AllowAgg : 0));
96529 #else
96530 pNC->ncFlags &= ~NC_AllowAgg;
96531 #endif
96532 }
96533 }
96534 #ifndef SQLITE_OMIT_WINDOWFUNC
96535 else if( ExprHasProperty(pExpr, EP_WinFunc) ){
96536 is_agg = 1;
96537 }
96538 #endif
96539 sqlite3WalkExprList(pWalker, pList);
96540 if( is_agg ){
96541 #ifndef SQLITE_OMIT_WINDOWFUNC
96542 if( pWin ){
96543 Select *pSel = pNC->pWinSelect;
96544 assert( pWin==pExpr->y.pWin );
96545 if( IN_RENAME_OBJECT==0 ){
96546 sqlite3WindowUpdate(pParse, pSel->pWinDefn, pWin, pDef);
96547 }
96548 sqlite3WalkExprList(pWalker, pWin->pPartition);
96549 sqlite3WalkExprList(pWalker, pWin->pOrderBy);
96550 sqlite3WalkExpr(pWalker, pWin->pFilter);
96551 sqlite3WindowLink(pSel, pWin);
 
 
 
 
 
96552 pNC->ncFlags |= NC_HasWin;
96553 }else
96554 #endif /* SQLITE_OMIT_WINDOWFUNC */
96555 {
96556 NameContext *pNC2 = pNC;
96557 pExpr->op = TK_AGG_FUNCTION;
96558 pExpr->op2 = 0;
96559 #ifndef SQLITE_OMIT_WINDOWFUNC
96560 if( ExprHasProperty(pExpr, EP_WinFunc) ){
96561 sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter);
96562 }
96563 #endif
96564 while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){
96565 pExpr->op2++;
96566 pNC2 = pNC2->pNext;
96567 }
96568 assert( pDef!=0 || IN_RENAME_OBJECT );
96569 if( pNC2 && pDef ){
96570 assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
96571 testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
96572 pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
96573
96574 }
@@ -96362,11 +96602,11 @@
96602 notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
96603 break;
96604 }
96605 case TK_IS:
96606 case TK_ISNOT: {
96607 Expr *pRight = sqlite3ExprSkipCollateAndLikely(pExpr->pRight);
96608 assert( !ExprHasProperty(pExpr, EP_Reduced) );
96609 /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE",
96610 ** and "x IS NOT FALSE". */
96611 if( pRight->op==TK_ID ){
96612 int rc = resolveExprStep(pWalker, pRight);
@@ -96573,11 +96813,11 @@
96813 assert( pEList!=0 );
96814 for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
96815 int iCol = -1;
96816 Expr *pE, *pDup;
96817 if( pItem->done ) continue;
96818 pE = sqlite3ExprSkipCollateAndLikely(pItem->pExpr);
96819 if( sqlite3ExprIsInteger(pE, &iCol) ){
96820 if( iCol<=0 || iCol>pEList->nExpr ){
96821 resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr);
96822 return 1;
96823 }
@@ -96667,11 +96907,11 @@
96907 int i;
96908 sqlite3 *db = pParse->db;
96909 ExprList *pEList;
96910 struct ExprList_item *pItem;
96911
96912 if( pOrderBy==0 || pParse->db->mallocFailed || IN_RENAME_OBJECT ) return 0;
96913 if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){
96914 sqlite3ErrorMsg(pParse, "too many terms in %s BY clause", zType);
96915 return 1;
96916 }
96917 pEList = pSelect->pEList;
@@ -96689,39 +96929,37 @@
96929 return 0;
96930 }
96931
96932 #ifndef SQLITE_OMIT_WINDOWFUNC
96933 /*
96934 ** Walker callback for windowRemoveExprFromSelect().
96935 */
96936 static int resolveRemoveWindowsCb(Walker *pWalker, Expr *pExpr){
96937 UNUSED_PARAMETER(pWalker);
96938 if( ExprHasProperty(pExpr, EP_WinFunc) ){
96939 Window *pWin = pExpr->y.pWin;
96940 sqlite3WindowUnlinkFromSelect(pWin);
 
 
 
 
 
96941 }
96942 return WRC_Continue;
96943 }
96944
96945 /*
96946 ** Remove any Window objects owned by the expression pExpr from the
96947 ** Select.pWin list of Select object pSelect.
96948 */
96949 static void windowRemoveExprFromSelect(Select *pSelect, Expr *pExpr){
96950 if( pSelect->pWin ){
96951 Walker sWalker;
96952 memset(&sWalker, 0, sizeof(Walker));
96953 sWalker.xExprCallback = resolveRemoveWindowsCb;
96954 sWalker.u.pSelect = pSelect;
96955 sqlite3WalkExpr(&sWalker, pExpr);
96956 }
96957 }
96958 #else
96959 # define windowRemoveExprFromSelect(a, b)
96960 #endif /* SQLITE_OMIT_WINDOWFUNC */
96961
96962 /*
96963 ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.
96964 ** The Name context of the SELECT statement is pNC. zType is either
96965 ** "ORDER" or "GROUP" depending on which type of clause pOrderBy is.
@@ -96754,11 +96992,11 @@
96992 if( pOrderBy==0 ) return 0;
96993 nResult = pSelect->pEList->nExpr;
96994 pParse = pNC->pParse;
96995 for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
96996 Expr *pE = pItem->pExpr;
96997 Expr *pE2 = sqlite3ExprSkipCollateAndLikely(pE);
96998 if( zType[0]!='G' ){
96999 iCol = resolveAsName(pParse, pSelect->pEList, pE2);
97000 if( iCol>0 ){
97001 /* If an AS-name match is found, mark this ORDER BY column as being
97002 ** a copy of the iCol-th result-set column. The subsequent call to
@@ -96788,11 +97026,11 @@
97026 for(j=0; j<pSelect->pEList->nExpr; j++){
97027 if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
97028 /* Since this expresion is being changed into a reference
97029 ** to an identical expression in the result set, remove all Window
97030 ** objects belonging to the expression from the Select.pWin list. */
97031 windowRemoveExprFromSelect(pSelect, pE);
97032 pItem->u.x.iOrderByCol = j+1;
97033 }
97034 }
97035 }
97036 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -97256,11 +97494,10 @@
97494 ** SELECT a AS b FROM t1 WHERE b;
97495 ** SELECT * FROM t1 WHERE (select a from t1);
97496 */
97497 SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){
97498 int op;
 
97499 while( ExprHasProperty(pExpr, EP_Skip) ){
97500 assert( pExpr->op==TK_COLLATE );
97501 pExpr = pExpr->pLeft;
97502 assert( pExpr!=0 );
97503 }
@@ -97283,11 +97520,11 @@
97520 assert( pExpr->pLeft->flags&EP_xIsSelect );
97521 return sqlite3ExprAffinity(
97522 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
97523 );
97524 }
97525 return pExpr->affExpr;
97526 }
97527
97528 /*
97529 ** Set the collating sequence for expression pExpr to be the collating
97530 ** sequence named by pToken. Return a pointer to a new Expr node that
@@ -97318,14 +97555,26 @@
97555 sqlite3TokenInit(&s, (char*)zC);
97556 return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0);
97557 }
97558
97559 /*
97560 ** Skip over any TK_COLLATE operators.
 
97561 */
97562 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){
97563 while( pExpr && ExprHasProperty(pExpr, EP_Skip) ){
97564 assert( pExpr->op==TK_COLLATE );
97565 pExpr = pExpr->pLeft;
97566 }
97567 return pExpr;
97568 }
97569
97570 /*
97571 ** Skip over any TK_COLLATE operators and/or any unlikely()
97572 ** or likelihood() or likely() functions at the root of an
97573 ** expression.
97574 */
97575 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr *pExpr){
97576 while( pExpr && ExprHasProperty(pExpr, EP_Skip|EP_Unlikely) ){
97577 if( ExprHasProperty(pExpr, EP_Unlikely) ){
97578 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
97579 assert( pExpr->x.pList->nExpr>0 );
97580 assert( pExpr->op==TK_FUNCTION );
@@ -97356,11 +97605,10 @@
97605 sqlite3 *db = pParse->db;
97606 CollSeq *pColl = 0;
97607 Expr *p = pExpr;
97608 while( p ){
97609 int op = p->op;
 
97610 if( op==TK_REGISTER ) op = p->op2;
97611 if( (op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_TRIGGER)
97612 && p->y.pTab!=0
97613 ){
97614 /* op==TK_REGISTER && p->y.pTab!=0 happens when pExpr was originally
@@ -97442,28 +97690,23 @@
97690 ** type affinity of the other operand. This routine returns the
97691 ** type affinity that should be used for the comparison operator.
97692 */
97693 SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2){
97694 char aff1 = sqlite3ExprAffinity(pExpr);
97695 if( aff1>SQLITE_AFF_NONE && aff2>SQLITE_AFF_NONE ){
97696 /* Both sides of the comparison are columns. If one has numeric
97697 ** affinity, use that. Otherwise use no affinity.
97698 */
97699 if( sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2) ){
97700 return SQLITE_AFF_NUMERIC;
97701 }else{
97702 return SQLITE_AFF_BLOB;
97703 }
 
 
 
 
 
97704 }else{
97705 /* One side is a column, the other is not. Use the columns affinity. */
97706 assert( aff1<=SQLITE_AFF_NONE || aff2<=SQLITE_AFF_NONE );
97707 return (aff1<=SQLITE_AFF_NONE ? aff2 : aff1) | SQLITE_AFF_NONE;
97708 }
97709 }
97710
97711 /*
97712 ** pExpr is a comparison operator. Return the type affinity that should
@@ -97492,18 +97735,17 @@
97735 ** if the index with affinity idx_affinity may be used to implement
97736 ** the comparison in pExpr.
97737 */
97738 SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){
97739 char aff = comparisonAffinity(pExpr);
97740 if( aff<SQLITE_AFF_TEXT ){
97741 return 1;
97742 }
97743 if( aff==SQLITE_AFF_TEXT ){
97744 return idx_affinity==SQLITE_AFF_TEXT;
97745 }
97746 return sqlite3IsNumericAffinity(idx_affinity);
 
97747 }
97748
97749 /*
97750 ** Return the P5 value that should be used for a binary comparison
97751 ** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2.
@@ -98252,19 +98494,22 @@
98494 if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){
98495 /* The Expr.x union is never used at the same time as Expr.pRight */
98496 assert( p->x.pList==0 || p->pRight==0 );
98497 if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);
98498 if( p->pRight ){
98499 assert( !ExprHasProperty(p, EP_WinFunc) );
98500 sqlite3ExprDeleteNN(db, p->pRight);
98501 }else if( ExprHasProperty(p, EP_xIsSelect) ){
98502 assert( !ExprHasProperty(p, EP_WinFunc) );
98503 sqlite3SelectDelete(db, p->x.pSelect);
98504 }else{
98505 sqlite3ExprListDelete(db, p->x.pList);
98506 #ifndef SQLITE_OMIT_WINDOWFUNC
98507 if( ExprHasProperty(p, EP_WinFunc) ){
98508 sqlite3WindowDelete(db, p->y.pWin);
98509 }
98510 #endif
98511 }
98512 }
98513 if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
98514 if( !ExprHasProperty(p, EP_Static) ){
98515 sqlite3DbFreeNN(db, p);
@@ -98295,20 +98540,10 @@
98540 if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE;
98541 if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE;
98542 return EXPR_FULLSIZE;
98543 }
98544
 
 
 
 
 
 
 
 
 
 
98545 /*
98546 ** The dupedExpr*Size() routines each return the number of bytes required
98547 ** to store a copy of an expression or expression tree. They differ in
98548 ** how much of the tree is measured.
98549 **
@@ -98544,14 +98779,17 @@
98779 ** gatherSelectWindowsCallback() are used to scan all the expressions
98780 ** an a newly duplicated SELECT statement and gather all of the Window
98781 ** objects found there, assembling them onto the linked list at Select->pWin.
98782 */
98783 static int gatherSelectWindowsCallback(Walker *pWalker, Expr *pExpr){
98784 if( pExpr->op==TK_FUNCTION && ExprHasProperty(pExpr, EP_WinFunc) ){
98785 Select *pSelect = pWalker->u.pSelect;
98786 Window *pWin = pExpr->y.pWin;
98787 assert( pWin );
98788 assert( IsWindowFunc(pExpr) );
98789 assert( pWin->ppThis==0 );
98790 sqlite3WindowLink(pSelect, pWin);
98791 }
98792 return WRC_Continue;
98793 }
98794 static int gatherSelectWindowsSelectCallback(Walker *pWalker, Select *p){
98795 return p==pWalker->u.pSelect ? WRC_Continue : WRC_Prune;
@@ -98621,12 +98859,13 @@
98859 pNewExpr->pLeft = pPriorSelectCol;
98860 }
98861 }
98862 pItem->zName = sqlite3DbStrDup(db, pOldItem->zName);
98863 pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan);
98864 pItem->sortFlags = pOldItem->sortFlags;
98865 pItem->done = 0;
98866 pItem->bNulls = pOldItem->bNulls;
98867 pItem->bSpanIsTab = pOldItem->bSpanIsTab;
98868 pItem->bSorterRef = pOldItem->bSorterRef;
98869 pItem->u = pOldItem->u;
98870 }
98871 return pNew;
@@ -98733,11 +98972,11 @@
98972 pNew->nSelectRow = p->nSelectRow;
98973 pNew->pWith = withDup(db, p->pWith);
98974 #ifndef SQLITE_OMIT_WINDOWFUNC
98975 pNew->pWin = 0;
98976 pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
98977 if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew);
98978 #endif
98979 pNew->selId = p->selId;
98980 *pp = pNew;
98981 pp = &pNew->pPrior;
98982 pNext = pNew;
@@ -98842,10 +99081,14 @@
99081 goto vector_append_error;
99082 }
99083
99084 for(i=0; i<pColumns->nId; i++){
99085 Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);
99086 assert( pSubExpr!=0 || db->mallocFailed );
99087 assert( pSubExpr==0 || pSubExpr->iTable==0 );
99088 if( pSubExpr==0 ) continue;
99089 pSubExpr->iTable = pColumns->nId;
99090 pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);
99091 if( pList ){
99092 assert( pList->nExpr==iFirst+i+1 );
99093 pList->a[pList->nExpr-1].zName = pColumns->a[i].zName;
99094 pColumns->a[i].zName = 0;
@@ -98874,19 +99117,38 @@
99117 }
99118
99119 /*
99120 ** Set the sort order for the last element on the given ExprList.
99121 */
99122 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder, int eNulls){
99123 struct ExprList_item *pItem;
99124 if( p==0 ) return;
 
99125 assert( p->nExpr>0 );
99126
99127 assert( SQLITE_SO_UNDEFINED<0 && SQLITE_SO_ASC==0 && SQLITE_SO_DESC>0 );
99128 assert( iSortOrder==SQLITE_SO_UNDEFINED
99129 || iSortOrder==SQLITE_SO_ASC
99130 || iSortOrder==SQLITE_SO_DESC
99131 );
99132 assert( eNulls==SQLITE_SO_UNDEFINED
99133 || eNulls==SQLITE_SO_ASC
99134 || eNulls==SQLITE_SO_DESC
99135 );
99136
99137 pItem = &p->a[p->nExpr-1];
99138 assert( pItem->bNulls==0 );
99139 if( iSortOrder==SQLITE_SO_UNDEFINED ){
99140 iSortOrder = SQLITE_SO_ASC;
99141 }
99142 pItem->sortFlags = (u8)iSortOrder;
99143
99144 if( eNulls!=SQLITE_SO_UNDEFINED ){
99145 pItem->bNulls = 1;
99146 if( iSortOrder!=eNulls ){
99147 pItem->sortFlags |= KEYINFO_ORDER_BIGNULL;
99148 }
99149 }
99150 }
99151
99152 /*
99153 ** Set the ExprList.a[].zName element of the most recently added item
99154 ** on the expression list.
@@ -99381,31 +99643,34 @@
99643 ** is harmless. A false positive, however, can result in the wrong
99644 ** answer.
99645 */
99646 SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr *p, char aff){
99647 u8 op;
99648 int unaryMinus = 0;
99649 if( aff==SQLITE_AFF_BLOB ) return 1;
99650 while( p->op==TK_UPLUS || p->op==TK_UMINUS ){
99651 if( p->op==TK_UMINUS ) unaryMinus = 1;
99652 p = p->pLeft;
99653 }
99654 op = p->op;
99655 if( op==TK_REGISTER ) op = p->op2;
99656 switch( op ){
99657 case TK_INTEGER: {
99658 return aff>=SQLITE_AFF_NUMERIC;
99659 }
99660 case TK_FLOAT: {
99661 return aff>=SQLITE_AFF_NUMERIC;
99662 }
99663 case TK_STRING: {
99664 return !unaryMinus && aff==SQLITE_AFF_TEXT;
99665 }
99666 case TK_BLOB: {
99667 return !unaryMinus;
99668 }
99669 case TK_COLUMN: {
99670 assert( p->iTable>=0 ); /* p cannot be part of a CHECK constraint */
99671 return aff>=SQLITE_AFF_NUMERIC && p->iColumn<0;
 
99672 }
99673 default: {
99674 return 0;
99675 }
99676 }
@@ -99584,11 +99849,11 @@
99849 ** then aiMap[] is populated with {2, 0, 1}.
99850 */
99851 #ifndef SQLITE_OMIT_SUBQUERY
99852 SQLITE_PRIVATE int sqlite3FindInIndex(
99853 Parse *pParse, /* Parsing context */
99854 Expr *pX, /* The IN expression */
99855 u32 inFlags, /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */
99856 int *prRhsHasNull, /* Register holding NULL status. See notes */
99857 int *aiMap, /* Mapping from Index fields to RHS fields */
99858 int *piTab /* OUT: index to use */
99859 ){
@@ -100009,13 +100274,13 @@
100274 */
100275 char affinity; /* Affinity of the LHS of the IN */
100276 int i;
100277 ExprList *pList = pExpr->x.pList;
100278 struct ExprList_item *pItem;
100279 int r1, r2;
100280 affinity = sqlite3ExprAffinity(pLeft);
100281 if( affinity<=SQLITE_AFF_NONE ){
100282 affinity = SQLITE_AFF_BLOB;
100283 }
100284 if( pKeyInfo ){
100285 assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
100286 pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
@@ -100037,13 +100302,13 @@
100302 ExprClearProperty(pExpr, EP_Subrtn);
100303 addrOnce = 0;
100304 }
100305
100306 /* Evaluate the expression and insert it into the temp table */
100307 sqlite3ExprCode(pParse, pE2, r1);
100308 sqlite3VdbeAddOp4(v, OP_MakeRecord, r1, 1, r2, &affinity, 1);
100309 sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r1, 1);
100310 }
100311 sqlite3ReleaseTempReg(pParse, r1);
100312 sqlite3ReleaseTempReg(pParse, r2);
100313 }
100314 if( pKeyInfo ){
@@ -100065,11 +100330,11 @@
100330 ** (SELECT a FROM b) -- subquery
100331 ** EXISTS (SELECT a FROM b) -- EXISTS subquery
100332 **
100333 ** The pExpr parameter is the SELECT or EXISTS operator to be coded.
100334 **
100335 ** Return the register that holds the result. For a multi-column SELECT,
100336 ** the result is stored in a contiguous array of registers and the
100337 ** return value is the register of the left-most result column.
100338 ** Return 0 if an error occurs.
100339 */
100340 #ifndef SQLITE_OMIT_SUBQUERY
@@ -100309,17 +100574,25 @@
100574 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
100575 int labelOk = sqlite3VdbeMakeLabel(pParse);
100576 int r2, regToFree;
100577 int regCkNull = 0;
100578 int ii;
100579 int bLhsReal; /* True if the LHS of the IN has REAL affinity */
100580 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
100581 if( destIfNull!=destIfFalse ){
100582 regCkNull = sqlite3GetTempReg(pParse);
100583 sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull);
100584 }
100585 bLhsReal = sqlite3ExprAffinity(pExpr->pLeft)==SQLITE_AFF_REAL;
100586 for(ii=0; ii<pList->nExpr; ii++){
100587 if( bLhsReal ){
100588 r2 = regToFree = sqlite3GetTempReg(pParse);
100589 sqlite3ExprCode(pParse, pList->a[ii].pExpr, r2);
100590 sqlite3VdbeAddOp4(v, OP_Affinity, r2, 1, 0, "E", P4_STATIC);
100591 }else{
100592 r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);
100593 }
100594 if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
100595 sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);
100596 }
100597 if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){
100598 sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2,
@@ -100600,11 +100873,11 @@
100873 ** Convert a scalar expression node to a TK_REGISTER referencing
100874 ** register iReg. The caller must ensure that iReg already contains
100875 ** the correct value for the expression.
100876 */
100877 static void exprToRegister(Expr *pExpr, int iReg){
100878 Expr *p = sqlite3ExprSkipCollateAndLikely(pExpr);
100879 p->op2 = p->op;
100880 p->op = TK_REGISTER;
100881 p->iTable = iReg;
100882 ExprClearProperty(p, EP_Skip);
100883 }
@@ -100701,11 +100974,11 @@
100974 ** datatype by applying the Affinity of the table column to the
100975 ** constant.
100976 */
100977 int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
100978 int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
100979 if( aff>SQLITE_AFF_BLOB ){
100980 static const char zAff[] = "B\000C\000D\000E";
100981 assert( SQLITE_AFF_BLOB=='A' );
100982 assert( SQLITE_AFF_TEXT=='B' );
100983 if( iReg!=target ){
100984 sqlite3VdbeAddOp2(v, OP_SCopy, iReg, target);
@@ -100717,11 +100990,23 @@
100990 return iReg;
100991 }
100992 if( iTab<0 ){
100993 if( pParse->iSelfTab<0 ){
100994 /* Generating CHECK constraints or inserting into partial index */
100995 assert( pExpr->y.pTab!=0 );
100996 assert( pExpr->iColumn>=XN_ROWID );
100997 assert( pExpr->iColumn<pExpr->y.pTab->nCol );
100998 if( pExpr->iColumn>=0
100999 && pExpr->y.pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL
101000 ){
101001 sqlite3VdbeAddOp2(v, OP_SCopy, pExpr->iColumn - pParse->iSelfTab,
101002 target);
101003 sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
101004 return target;
101005 }else{
101006 return pExpr->iColumn - pParse->iSelfTab;
101007 }
101008 }else{
101009 /* Coding an expression that is part of an index where column names
101010 ** in the index refer to the table to which the index belongs */
101011 iTab = pParse->iSelfTab - 1;
101012 }
@@ -101004,11 +101289,11 @@
101289 const char *azAff[] = { "blob", "text", "numeric", "integer", "real" };
101290 char aff;
101291 assert( nFarg==1 );
101292 aff = sqlite3ExprAffinity(pFarg->a[0].pExpr);
101293 sqlite3VdbeLoadString(v, target,
101294 (aff<=SQLITE_AFF_NONE) ? "none" : azAff[aff-SQLITE_AFF_BLOB]);
101295 return target;
101296 }
101297 #endif
101298
101299 for(i=0; i<nFarg; i++){
@@ -101112,12 +101397,12 @@
101397 int n;
101398 if( pExpr->pLeft->iTable==0 ){
101399 pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
101400 }
101401 assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );
101402 if( pExpr->iTable!=0
101403 && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
101404 ){
101405 sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
101406 pExpr->iTable, n);
101407 }
101408 return pExpr->pLeft->iTable + pExpr->iColumn;
@@ -101216,14 +101501,27 @@
101501 case TK_VECTOR: {
101502 sqlite3ErrorMsg(pParse, "row value misused");
101503 break;
101504 }
101505
101506 /* TK_IF_NULL_ROW Expr nodes are inserted ahead of expressions
101507 ** that derive from the right-hand table of a LEFT JOIN. The
101508 ** Expr.iTable value is the table number for the right-hand table.
101509 ** The expression is only evaluated if that table is not currently
101510 ** on a LEFT JOIN NULL row.
101511 */
101512 case TK_IF_NULL_ROW: {
101513 int addrINR;
101514 u8 okConstFactor = pParse->okConstFactor;
101515 addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable);
101516 /* Temporarily disable factoring of constant expressions, since
101517 ** even though expressions may appear to be constant, they are not
101518 ** really constant because they originate from the right-hand side
101519 ** of a LEFT JOIN. */
101520 pParse->okConstFactor = 0;
101521 inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
101522 pParse->okConstFactor = okConstFactor;
101523 sqlite3VdbeJumpHere(v, addrINR);
101524 sqlite3VdbeChangeP3(v, addrINR, inReg);
101525 break;
101526 }
101527
@@ -101256,25 +101554,31 @@
101554 ExprList *pEList; /* List of WHEN terms */
101555 struct ExprList_item *aListelem; /* Array of WHEN terms */
101556 Expr opCompare; /* The X==Ei expression */
101557 Expr *pX; /* The X expression */
101558 Expr *pTest = 0; /* X==Ei (form A) or just Ei (form B) */
101559 Expr *pDel = 0;
101560 sqlite3 *db = pParse->db;
101561
101562 assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
101563 assert(pExpr->x.pList->nExpr > 0);
101564 pEList = pExpr->x.pList;
101565 aListelem = pEList->a;
101566 nExpr = pEList->nExpr;
101567 endLabel = sqlite3VdbeMakeLabel(pParse);
101568 if( (pX = pExpr->pLeft)!=0 ){
101569 pDel = sqlite3ExprDup(db, pX, 0);
101570 if( db->mallocFailed ){
101571 sqlite3ExprDelete(db, pDel);
101572 break;
101573 }
101574 testcase( pX->op==TK_COLUMN );
101575 exprToRegister(pDel, exprCodeVector(pParse, pDel, &regFree1));
101576 testcase( regFree1==0 );
101577 memset(&opCompare, 0, sizeof(opCompare));
101578 opCompare.op = TK_EQ;
101579 opCompare.pLeft = pDel;
101580 pTest = &opCompare;
101581 /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
101582 ** The value in regFree1 might get SCopy-ed into the file result.
101583 ** So make sure that the regFree1 register is not reused for other
101584 ** purposes and possibly overwritten. */
@@ -101298,36 +101602,37 @@
101602 if( (nExpr&1)!=0 ){
101603 sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);
101604 }else{
101605 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
101606 }
101607 sqlite3ExprDelete(db, pDel);
101608 sqlite3VdbeResolveLabel(v, endLabel);
101609 break;
101610 }
101611 #ifndef SQLITE_OMIT_TRIGGER
101612 case TK_RAISE: {
101613 assert( pExpr->affExpr==OE_Rollback
101614 || pExpr->affExpr==OE_Abort
101615 || pExpr->affExpr==OE_Fail
101616 || pExpr->affExpr==OE_Ignore
101617 );
101618 if( !pParse->pTriggerTab ){
101619 sqlite3ErrorMsg(pParse,
101620 "RAISE() may only be used within a trigger-program");
101621 return 0;
101622 }
101623 if( pExpr->affExpr==OE_Abort ){
101624 sqlite3MayAbort(pParse);
101625 }
101626 assert( !ExprHasProperty(pExpr, EP_IntValue) );
101627 if( pExpr->affExpr==OE_Ignore ){
101628 sqlite3VdbeAddOp4(
101629 v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);
101630 VdbeCoverage(v);
101631 }else{
101632 sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER,
101633 pExpr->affExpr, pExpr->u.zToken, 0, 0);
101634 }
101635
101636 break;
101637 }
101638 #endif
@@ -101388,11 +101693,11 @@
101693 ** code to fill the register in the initialization section of the
101694 ** VDBE program, in order to factor it out of the evaluation loop.
101695 */
101696 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){
101697 int r2;
101698 pExpr = sqlite3ExprSkipCollateAndLikely(pExpr);
101699 if( ConstFactorOk(pParse)
101700 && pExpr->op!=TK_REGISTER
101701 && sqlite3ExprIsConstantNotJoin(pExpr)
101702 ){
101703 *pReg = 0;
@@ -101579,44 +101884,48 @@
101884 Expr *pExpr, /* The BETWEEN expression */
101885 int dest, /* Jump destination or storage location */
101886 void (*xJump)(Parse*,Expr*,int,int), /* Action to take */
101887 int jumpIfNull /* Take the jump if the BETWEEN is NULL */
101888 ){
101889 Expr exprAnd; /* The AND operator in x>=y AND x<=z */
101890 Expr compLeft; /* The x>=y term */
101891 Expr compRight; /* The x<=z term */
 
101892 int regFree1 = 0; /* Temporary use register */
101893 Expr *pDel = 0;
101894 sqlite3 *db = pParse->db;
101895
101896 memset(&compLeft, 0, sizeof(Expr));
101897 memset(&compRight, 0, sizeof(Expr));
101898 memset(&exprAnd, 0, sizeof(Expr));
101899
101900 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
101901 pDel = sqlite3ExprDup(db, pExpr->pLeft, 0);
101902 if( db->mallocFailed==0 ){
101903 exprAnd.op = TK_AND;
101904 exprAnd.pLeft = &compLeft;
101905 exprAnd.pRight = &compRight;
101906 compLeft.op = TK_GE;
101907 compLeft.pLeft = pDel;
101908 compLeft.pRight = pExpr->x.pList->a[0].pExpr;
101909 compRight.op = TK_LE;
101910 compRight.pLeft = pDel;
101911 compRight.pRight = pExpr->x.pList->a[1].pExpr;
101912 exprToRegister(pDel, exprCodeVector(pParse, pDel, &regFree1));
101913 if( xJump ){
101914 xJump(pParse, &exprAnd, dest, jumpIfNull);
101915 }else{
101916 /* Mark the expression is being from the ON or USING clause of a join
101917 ** so that the sqlite3ExprCodeTarget() routine will not attempt to move
101918 ** it into the Parse.pConstExpr list. We should use a new bit for this,
101919 ** for clarity, but we are out of bits in the Expr.flags field so we
101920 ** have to reuse the EP_FromJoin bit. Bummer. */
101921 pDel->flags |= EP_FromJoin;
101922 sqlite3ExprCodeTarget(pParse, &exprAnd, dest);
101923 }
101924 sqlite3ReleaseTempReg(pParse, regFree1);
101925 }
101926 sqlite3ExprDelete(db, pDel);
101927
101928 /* Ensure adequate test coverage */
101929 testcase( xJump==sqlite3ExprIfTrue && jumpIfNull==0 && regFree1==0 );
101930 testcase( xJump==sqlite3ExprIfTrue && jumpIfNull==0 && regFree1!=0 );
101931 testcase( xJump==sqlite3ExprIfTrue && jumpIfNull!=0 && regFree1==0 );
@@ -102051,24 +102360,21 @@
102360 return 1;
102361 }
102362 return 2;
102363 }
102364 if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
102365 if( pA->op==TK_FUNCTION || pA->op==TK_AGG_FUNCTION ){
102366 if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
102367 #ifndef SQLITE_OMIT_WINDOWFUNC
102368 assert( pA->op==pB->op );
102369 if( ExprHasProperty(pA,EP_WinFunc)!=ExprHasProperty(pB,EP_WinFunc) ){
102370 return 2;
102371 }
 
 
 
 
 
102372 if( ExprHasProperty(pA,EP_WinFunc) ){
102373 if( sqlite3WindowCompare(pParse, pA->y.pWin, pB->y.pWin, 1)!=0 ){
102374 return 2;
102375 }
102376 }
102377 #endif
102378 }else if( pA->op==TK_NULL ){
102379 return 0;
102380 }else if( pA->op==TK_COLLATE ){
@@ -102118,11 +102424,11 @@
102424 if( pA==0 || pB==0 ) return 1;
102425 if( pA->nExpr!=pB->nExpr ) return 1;
102426 for(i=0; i<pA->nExpr; i++){
102427 Expr *pExprA = pA->a[i].pExpr;
102428 Expr *pExprB = pB->a[i].pExpr;
102429 if( pA->a[i].sortFlags!=pB->a[i].sortFlags ) return 1;
102430 if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1;
102431 }
102432 return 0;
102433 }
102434
@@ -102130,78 +102436,85 @@
102436 ** Like sqlite3ExprCompare() except COLLATE operators at the top-level
102437 ** are ignored.
102438 */
102439 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
102440 return sqlite3ExprCompare(0,
102441 sqlite3ExprSkipCollateAndLikely(pA),
102442 sqlite3ExprSkipCollateAndLikely(pB),
102443 iTab);
102444 }
102445
102446 /*
102447 ** Return non-zero if Expr p can only be true if pNN is not NULL.
102448 **
102449 ** Or if seenNot is true, return non-zero if Expr p can only be
102450 ** non-NULL if pNN is not NULL
102451 */
102452 static int exprImpliesNotNull(
102453 Parse *pParse, /* Parsing context */
102454 Expr *p, /* The expression to be checked */
102455 Expr *pNN, /* The expression that is NOT NULL */
102456 int iTab, /* Table being evaluated */
102457 int seenNot /* Return true only if p can be any non-NULL value */
102458 ){
102459 assert( p );
102460 assert( pNN );
102461 if( sqlite3ExprCompare(pParse, p, pNN, iTab)==0 ){
102462 return pNN->op!=TK_NULL;
102463 }
102464 switch( p->op ){
102465 case TK_IN: {
102466 if( seenNot && ExprHasProperty(p, EP_xIsSelect) ) return 0;
102467 assert( ExprHasProperty(p,EP_xIsSelect)
102468 || (p->x.pList!=0 && p->x.pList->nExpr>0) );
102469 return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
102470 }
102471 case TK_BETWEEN: {
102472 ExprList *pList = p->x.pList;
102473 assert( pList!=0 );
102474 assert( pList->nExpr==2 );
102475 if( seenNot ) return 0;
102476 if( exprImpliesNotNull(pParse, pList->a[0].pExpr, pNN, iTab, 1)
102477 || exprImpliesNotNull(pParse, pList->a[1].pExpr, pNN, iTab, 1)
102478 ){
102479 return 1;
102480 }
102481 return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
102482 }
102483 case TK_EQ:
102484 case TK_NE:
102485 case TK_LT:
102486 case TK_LE:
102487 case TK_GT:
102488 case TK_GE:
102489 case TK_PLUS:
102490 case TK_MINUS:
102491 case TK_BITOR:
102492 case TK_LSHIFT:
102493 case TK_RSHIFT:
102494 case TK_CONCAT:
102495 seenNot = 1;
102496 /* Fall thru */
102497 case TK_STAR:
102498 case TK_REM:
102499 case TK_BITAND:
102500 case TK_SLASH: {
 
 
 
 
102501 if( exprImpliesNotNull(pParse, p->pRight, pNN, iTab, seenNot) ) return 1;
102502 /* Fall thru into the next case */
102503 }
102504 case TK_SPAN:
102505 case TK_COLLATE:
 
102506 case TK_UPLUS:
102507 case TK_UMINUS: {
102508 return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
102509 }
102510 case TK_TRUTH: {
102511 if( seenNot ) return 0;
102512 if( p->op2!=TK_IS ) return 0;
102513 return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
102514 }
102515 case TK_BITNOT:
102516 case TK_NOT: {
102517 return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
102518 }
102519 }
102520 return 0;
@@ -102263,20 +102576,18 @@
102576 testcase( pExpr->op==TK_AGG_COLUMN );
102577 testcase( pExpr->op==TK_AGG_FUNCTION );
102578 if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;
102579 switch( pExpr->op ){
102580 case TK_ISNOT:
 
102581 case TK_ISNULL:
102582 case TK_NOTNULL:
102583 case TK_IS:
102584 case TK_OR:
102585 case TK_CASE:
102586 case TK_IN:
102587 case TK_FUNCTION:
102588 testcase( pExpr->op==TK_ISNOT );
 
102589 testcase( pExpr->op==TK_ISNULL );
102590 testcase( pExpr->op==TK_NOTNULL );
102591 testcase( pExpr->op==TK_IS );
102592 testcase( pExpr->op==TK_OR );
102593 testcase( pExpr->op==TK_CASE );
@@ -102288,10 +102599,22 @@
102599 pWalker->eCode = 1;
102600 return WRC_Abort;
102601 }
102602 return WRC_Prune;
102603
102604 case TK_AND:
102605 if( sqlite3ExprImpliesNonNullRow(pExpr->pLeft, pWalker->u.iCur)
102606 && sqlite3ExprImpliesNonNullRow(pExpr->pRight, pWalker->u.iCur)
102607 ){
102608 pWalker->eCode = 1;
102609 }
102610 return WRC_Prune;
102611
102612 case TK_BETWEEN:
102613 sqlite3WalkExpr(pWalker, pExpr->pLeft);
102614 return WRC_Prune;
102615
102616 /* Virtual tables are allowed to use constraints like x=NULL. So
102617 ** a term of the form x=y does not prove that y is not null if x
102618 ** is the column of a virtual table */
102619 case TK_EQ:
102620 case TK_NE:
@@ -102308,10 +102631,11 @@
102631 if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->y.pTab))
102632 || (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->y.pTab))
102633 ){
102634 return WRC_Prune;
102635 }
102636
102637 default:
102638 return WRC_Continue;
102639 }
102640 }
102641
@@ -102337,11 +102661,11 @@
102661 ** be non-NULL, then the LEFT JOIN can be safely converted into an
102662 ** ordinary join.
102663 */
102664 SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){
102665 Walker w;
102666 p = sqlite3ExprSkipCollateAndLikely(p);
102667 while( p ){
102668 if( p->op==TK_NOTNULL ){
102669 p = p->pLeft;
102670 }else if( p->op==TK_AND ){
102671 if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1;
@@ -102443,11 +102767,14 @@
102767 for(i=0; i<nSrc; i++){
102768 if( pExpr->iTable==pSrc->a[i].iCursor ) break;
102769 }
102770 if( i<nSrc ){
102771 p->nThis++;
102772 }else if( nSrc==0 || pExpr->iTable<pSrc->a[0].iCursor ){
102773 /* In a well-formed parse tree (no name resolution errors),
102774 ** TK_COLUMN nodes with smaller Expr.iTable values are in an
102775 ** outer context. Those are the only ones to count as "other" */
102776 p->nOther++;
102777 }
102778 }
102779 return WRC_Continue;
102780 }
@@ -102460,12 +102787,13 @@
102787 */
102788 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){
102789 Walker w;
102790 struct SrcCount cnt;
102791 assert( pExpr->op==TK_AGG_FUNCTION );
102792 memset(&w, 0, sizeof(w));
102793 w.xExprCallback = exprSrcCount;
102794 w.xSelectCallback = sqlite3SelectWalkNoop;
102795 w.u.pSrcCount = &cnt;
102796 cnt.pSrc = pSrcList;
102797 cnt.nThis = 0;
102798 cnt.nOther = 0;
102799 sqlite3WalkExprList(&w, pExpr->x.pList);
@@ -102899,12 +103227,12 @@
103227 ** that the table is being renamed to.
103228 */
103229 if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){
103230 goto exit_rename_table;
103231 }
103232 if( SQLITE_OK!=sqlite3CheckObjectName(pParse,zName,"table",zName) ){
103233 goto exit_rename_table;
103234 }
103235
103236 #ifndef SQLITE_OMIT_VIEW
103237 if( pTab->pSelect ){
103238 sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName);
@@ -104461,17 +104789,17 @@
104789 ** Additional tables might be added in future releases of SQLite.
104790 ** The sqlite_stat2 table is not created or used unless the SQLite version
104791 ** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled
104792 ** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated.
104793 ** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
104794 ** created and used by SQLite versions 3.7.9 through 3.29.0 when
104795 ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
104796 ** is a superset of sqlite_stat2 and is also now deprecated. The
104797 ** sqlite_stat4 is an enhanced version of sqlite_stat3 and is only
104798 ** available when compiled with SQLITE_ENABLE_STAT4 and in SQLite
104799 ** versions 3.8.1 and later. STAT4 is the only variant that is still
104800 ** supported.
104801 **
104802 ** For most applications, sqlite_stat1 provides all the statistics required
104803 ** for the query planner to make good choices.
104804 **
104805 ** Format of sqlite_stat1:
@@ -104578,21 +104906,15 @@
104906 #ifndef SQLITE_OMIT_ANALYZE
104907 /* #include "sqliteInt.h" */
104908
104909 #if defined(SQLITE_ENABLE_STAT4)
104910 # define IsStat4 1
 
 
 
 
104911 #else
104912 # define IsStat4 0
 
104913 # undef SQLITE_STAT4_SAMPLES
104914 # define SQLITE_STAT4_SAMPLES 1
104915 #endif
 
104916
104917 /*
104918 ** This routine generates code that opens the sqlite_statN tables.
104919 ** The sqlite_stat1 table is always relevant. sqlite_stat2 is now
104920 ** obsolete. sqlite_stat3 and sqlite_stat4 are only opened when
@@ -104617,18 +104939,14 @@
104939 const char *zCols;
104940 } aTable[] = {
104941 { "sqlite_stat1", "tbl,idx,stat" },
104942 #if defined(SQLITE_ENABLE_STAT4)
104943 { "sqlite_stat4", "tbl,idx,neq,nlt,ndlt,sample" },
 
 
 
 
104944 #else
 
104945 { "sqlite_stat4", 0 },
104946 #endif
104947 { "sqlite_stat3", 0 },
104948 };
104949 int i;
104950 sqlite3 *db = pParse->db;
104951 Db *pDb;
104952 Vdbe *v = sqlite3GetVdbe(pParse);
@@ -104705,11 +105023,11 @@
105023 typedef struct Stat4Accum Stat4Accum;
105024 typedef struct Stat4Sample Stat4Sample;
105025 struct Stat4Sample {
105026 tRowcnt *anEq; /* sqlite_stat4.nEq */
105027 tRowcnt *anDLt; /* sqlite_stat4.nDLt */
105028 #ifdef SQLITE_ENABLE_STAT4
105029 tRowcnt *anLt; /* sqlite_stat4.nLt */
105030 union {
105031 i64 iRowid; /* Rowid in main table of the key */
105032 u8 *aRowid; /* Key for WITHOUT ROWID tables */
105033 } u;
@@ -104736,11 +105054,11 @@
105054 sqlite3 *db; /* Database connection, for malloc() */
105055 };
105056
105057 /* Reclaim memory used by a Stat4Sample
105058 */
105059 #ifdef SQLITE_ENABLE_STAT4
105060 static void sampleClear(sqlite3 *db, Stat4Sample *p){
105061 assert( db!=0 );
105062 if( p->nRowid ){
105063 sqlite3DbFree(db, p->u.aRowid);
105064 p->nRowid = 0;
@@ -104748,11 +105066,11 @@
105066 }
105067 #endif
105068
105069 /* Initialize the BLOB value of a ROWID
105070 */
105071 #ifdef SQLITE_ENABLE_STAT4
105072 static void sampleSetRowid(sqlite3 *db, Stat4Sample *p, int n, const u8 *pData){
105073 assert( db!=0 );
105074 if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);
105075 p->u.aRowid = sqlite3DbMallocRawNN(db, n);
105076 if( p->u.aRowid ){
@@ -104764,11 +105082,11 @@
105082 }
105083 #endif
105084
105085 /* Initialize the INTEGER value of a ROWID.
105086 */
105087 #ifdef SQLITE_ENABLE_STAT4
105088 static void sampleSetRowidInt64(sqlite3 *db, Stat4Sample *p, i64 iRowid){
105089 assert( db!=0 );
105090 if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);
105091 p->nRowid = 0;
105092 p->u.iRowid = iRowid;
@@ -104777,11 +105095,11 @@
105095
105096
105097 /*
105098 ** Copy the contents of object (*pFrom) into (*pTo).
105099 */
105100 #ifdef SQLITE_ENABLE_STAT4
105101 static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
105102 pTo->isPSample = pFrom->isPSample;
105103 pTo->iCol = pFrom->iCol;
105104 pTo->iHash = pFrom->iHash;
105105 memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);
@@ -104798,11 +105116,11 @@
105116 /*
105117 ** Reclaim all memory of a Stat4Accum structure.
105118 */
105119 static void stat4Destructor(void *pOld){
105120 Stat4Accum *p = (Stat4Accum*)pOld;
105121 #ifdef SQLITE_ENABLE_STAT4
105122 int i;
105123 for(i=0; i<p->nCol; i++) sampleClear(p->db, p->aBest+i);
105124 for(i=0; i<p->mxSample; i++) sampleClear(p->db, p->a+i);
105125 sampleClear(p->db, &p->current);
105126 #endif
@@ -104818,11 +105136,11 @@
105136 **
105137 ** Note 1: In the special case of the covering index that implements a
105138 ** WITHOUT ROWID table, N is the number of PRIMARY KEY columns, not the
105139 ** total number of columns in the table.
105140 **
105141 ** Note 2: C is only used for STAT4.
105142 **
105143 ** For indexes on ordinary rowid tables, N==K+1. But for indexes on
105144 ** WITHOUT ROWID tables, N=K+P where P is the number of columns in the
105145 ** PRIMARY KEY of the table. The covering index that implements the
105146 ** original WITHOUT ROWID table as N==K as a special case.
@@ -104841,11 +105159,11 @@
105159 int nCol; /* Number of columns in index being sampled */
105160 int nKeyCol; /* Number of key columns */
105161 int nColUp; /* nCol rounded up for alignment */
105162 int n; /* Bytes of space to allocate */
105163 sqlite3 *db; /* Database connection */
105164 #ifdef SQLITE_ENABLE_STAT4
105165 int mxSample = SQLITE_STAT4_SAMPLES;
105166 #endif
105167
105168 /* Decode the three function arguments */
105169 UNUSED_PARAMETER(argc);
@@ -104858,11 +105176,11 @@
105176
105177 /* Allocate the space required for the Stat4Accum object */
105178 n = sizeof(*p)
105179 + sizeof(tRowcnt)*nColUp /* Stat4Accum.anEq */
105180 + sizeof(tRowcnt)*nColUp /* Stat4Accum.anDLt */
105181 #ifdef SQLITE_ENABLE_STAT4
105182 + sizeof(tRowcnt)*nColUp /* Stat4Accum.anLt */
105183 + sizeof(Stat4Sample)*(nCol+mxSample) /* Stat4Accum.aBest[], a[] */
105184 + sizeof(tRowcnt)*3*nColUp*(nCol+mxSample)
105185 #endif
105186 ;
@@ -104878,11 +105196,11 @@
105196 p->nCol = nCol;
105197 p->nKeyCol = nKeyCol;
105198 p->current.anDLt = (tRowcnt*)&p[1];
105199 p->current.anEq = &p->current.anDLt[nColUp];
105200
105201 #ifdef SQLITE_ENABLE_STAT4
105202 {
105203 u8 *pSpace; /* Allocated space not yet assigned */
105204 int i; /* Used to iterate through p->aSample[] */
105205
105206 p->iGet = -1;
@@ -104913,11 +105231,11 @@
105231 ** (given by the 3rd parameter) is never used and can be any positive
105232 ** value. */
105233 sqlite3_result_blob(context, p, sizeof(*p), stat4Destructor);
105234 }
105235 static const FuncDef statInitFuncdef = {
105236 2+IsStat4, /* nArg */
105237 SQLITE_UTF8, /* funcFlags */
105238 0, /* pUserData */
105239 0, /* pNext */
105240 statInit, /* xSFunc */
105241 0, /* xFinalize */
@@ -104953,11 +105271,11 @@
105271 if( pNew->iHash>pOld->iHash ) return 1;
105272 return 0;
105273 }
105274 #endif
105275
105276 #ifdef SQLITE_ENABLE_STAT4
105277 /*
105278 ** Return true if pNew is to be preferred over pOld.
105279 **
105280 ** This function assumes that for each argument sample, the contents of
105281 ** the anEq[] array from pSample->anEq[pSample->iCol] onwards are valid.
@@ -104972,19 +105290,15 @@
105290
105291 assert( pOld->isPSample==0 && pNew->isPSample==0 );
105292 assert( IsStat4 || (pNew->iCol==0 && pOld->iCol==0) );
105293
105294 if( (nEqNew>nEqOld) ) return 1;
 
105295 if( nEqNew==nEqOld ){
105296 if( pNew->iCol<pOld->iCol ) return 1;
105297 return (pNew->iCol==pOld->iCol && sampleIsBetterPost(pAccum, pNew, pOld));
105298 }
105299 return 0;
 
 
 
105300 }
105301
105302 /*
105303 ** Copy the contents of sample *pNew into the p->a[] array. If necessary,
105304 ** remove the least desirable sample from p->a[] to make room.
@@ -104993,11 +105307,10 @@
105307 Stat4Sample *pSample = 0;
105308 int i;
105309
105310 assert( IsStat4 || nEqZero==0 );
105311
 
105312 /* Stat4Accum.nMaxEqZero is set to the maximum number of leading 0
105313 ** values in the anEq[] array of any sample in Stat4Accum.a[]. In
105314 ** other words, if nMaxEqZero is n, then it is guaranteed that there
105315 ** are no samples with Stat4Sample.anEq[m]==0 for (m>=n). */
105316 if( nEqZero>p->nMaxEqZero ){
@@ -105027,11 +105340,10 @@
105340 pUpgrade->iCol = pNew->iCol;
105341 pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol];
105342 goto find_new_min;
105343 }
105344 }
 
105345
105346 /* If necessary, remove sample iMin to make room for the new sample. */
105347 if( p->nSample>=p->mxSample ){
105348 Stat4Sample *pMin = &p->a[p->iMin];
105349 tRowcnt *anEq = pMin->anEq;
@@ -105048,26 +105360,22 @@
105360 }
105361
105362 /* The "rows less-than" for the rowid column must be greater than that
105363 ** for the last sample in the p->a[] array. Otherwise, the samples would
105364 ** be out of order. */
 
105365 assert( p->nSample==0
105366 || pNew->anLt[p->nCol-1] > p->a[p->nSample-1].anLt[p->nCol-1] );
 
105367
105368 /* Insert the new sample */
105369 pSample = &p->a[p->nSample];
105370 sampleCopy(p, pSample, pNew);
105371 p->nSample++;
105372
105373 /* Zero the first nEqZero entries in the anEq[] array. */
105374 memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero);
105375
105376 find_new_min:
 
 
105377 if( p->nSample>=p->mxSample ){
105378 int iMin = -1;
105379 for(i=0; i<p->mxSample; i++){
105380 if( p->a[i].isPSample ) continue;
105381 if( iMin<0 || sampleIsBetter(p, &p->a[iMin], &p->a[i]) ){
@@ -105076,11 +105384,11 @@
105384 }
105385 assert( iMin>=0 );
105386 p->iMin = iMin;
105387 }
105388 }
105389 #endif /* SQLITE_ENABLE_STAT4 */
105390
105391 /*
105392 ** Field iChng of the index being scanned has changed. So at this point
105393 ** p->current contains a sample that reflects the previous row of the
105394 ** index. The value of anEq[iChng] and subsequent anEq[] elements are
@@ -105117,32 +105425,11 @@
105425 }
105426 p->nMaxEqZero = iChng;
105427 }
105428 #endif
105429
105430 #ifndef SQLITE_ENABLE_STAT4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105431 UNUSED_PARAMETER( p );
105432 UNUSED_PARAMETER( iChng );
105433 #endif
105434 }
105435
@@ -105158,11 +105445,11 @@
105445 ** This SQL function always returns NULL. It's purpose it to accumulate
105446 ** statistical data and/or samples in the Stat4Accum object about the
105447 ** index being analyzed. The stat_get() SQL function will later be used to
105448 ** extract relevant information for constructing the sqlite_statN tables.
105449 **
105450 ** The R parameter is only used for STAT4
105451 */
105452 static void statPush(
105453 sqlite3_context *context,
105454 int argc,
105455 sqlite3_value **argv
@@ -105190,18 +105477,18 @@
105477 for(i=0; i<iChng; i++){
105478 p->current.anEq[i]++;
105479 }
105480 for(i=iChng; i<p->nCol; i++){
105481 p->current.anDLt[i]++;
105482 #ifdef SQLITE_ENABLE_STAT4
105483 p->current.anLt[i] += p->current.anEq[i];
105484 #endif
105485 p->current.anEq[i] = 1;
105486 }
105487 }
105488 p->nRow++;
105489 #ifdef SQLITE_ENABLE_STAT4
105490 if( sqlite3_value_type(argv[2])==SQLITE_INTEGER ){
105491 sampleSetRowidInt64(p->db, &p->current, sqlite3_value_int64(argv[2]));
105492 }else{
105493 sampleSetRowid(p->db, &p->current, sqlite3_value_bytes(argv[2]),
105494 sqlite3_value_blob(argv[2]));
@@ -105230,11 +105517,11 @@
105517 }
105518 }
105519 #endif
105520 }
105521 static const FuncDef statPushFuncdef = {
105522 2+IsStat4, /* nArg */
105523 SQLITE_UTF8, /* funcFlags */
105524 0, /* pUserData */
105525 0, /* pNext */
105526 statPush, /* xSFunc */
105527 0, /* xFinalize */
@@ -105261,11 +105548,11 @@
105548 ** inserted as part of a manually constructed bytecode program. (See
105549 ** the callStatGet() routine below.) It is guaranteed that the P
105550 ** parameter will always be a poiner to a Stat4Accum object, never a
105551 ** NULL.
105552 **
105553 ** If STAT4 is not enabled, then J is always
105554 ** STAT_GET_STAT1 and is hence omitted and this routine becomes
105555 ** a one-parameter function, stat_get(P), that always returns the
105556 ** stat1 table entry information.
105557 */
105558 static void statGet(
@@ -105272,12 +105559,12 @@
105559 sqlite3_context *context,
105560 int argc,
105561 sqlite3_value **argv
105562 ){
105563 Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);
105564 #ifdef SQLITE_ENABLE_STAT4
105565 /* STAT4 has a parameter on this routine. */
105566 int eCall = sqlite3_value_int(argv[1]);
105567 assert( argc==2 );
105568 assert( eCall==STAT_GET_STAT1 || eCall==STAT_GET_NEQ
105569 || eCall==STAT_GET_ROWID || eCall==STAT_GET_NLT
105570 || eCall==STAT_GET_NDLT
@@ -105328,11 +105615,11 @@
105615 }
105616 assert( z[0]=='\0' && z>zRet );
105617
105618 sqlite3_result_text(context, zRet, -1, sqlite3_free);
105619 }
105620 #ifdef SQLITE_ENABLE_STAT4
105621 else if( eCall==STAT_GET_ROWID ){
105622 if( p->iGet<0 ){
105623 samplePushPrevious(p, 0);
105624 p->iGet = 0;
105625 }
@@ -105357,13 +105644,11 @@
105644 p->iGet++;
105645 break;
105646 }
105647 }
105648
105649 {
 
 
105650 char *zRet = sqlite3MallocZero(p->nCol * 25);
105651 if( zRet==0 ){
105652 sqlite3_result_error_nomem(context);
105653 }else{
105654 int i;
@@ -105376,17 +105661,17 @@
105661 z[-1] = '\0';
105662 sqlite3_result_text(context, zRet, -1, sqlite3_free);
105663 }
105664 }
105665 }
105666 #endif /* SQLITE_ENABLE_STAT4 */
105667 #ifndef SQLITE_DEBUG
105668 UNUSED_PARAMETER( argc );
105669 #endif
105670 }
105671 static const FuncDef statGetFuncdef = {
105672 1+IsStat4, /* nArg */
105673 SQLITE_UTF8, /* funcFlags */
105674 0, /* pUserData */
105675 0, /* pNext */
105676 statGet, /* xSFunc */
105677 0, /* xFinalize */
@@ -105395,20 +105680,20 @@
105680 {0}
105681 };
105682
105683 static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
105684 assert( regOut!=regStat4 && regOut!=regStat4+1 );
105685 #ifdef SQLITE_ENABLE_STAT4
105686 sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
105687 #elif SQLITE_DEBUG
105688 assert( iParam==STAT_GET_STAT1 );
105689 #else
105690 UNUSED_PARAMETER( iParam );
105691 #endif
105692 sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4, regOut,
105693 (char*)&statGetFuncdef, P4_FUNCDEF);
105694 sqlite3VdbeChangeP5(v, 1 + IsStat4);
105695 }
105696
105697 /*
105698 ** Generate code to do an analysis of all indices associated with
105699 ** a single table.
@@ -105431,11 +105716,11 @@
105716 int iDb; /* Index of database containing pTab */
105717 u8 needTableCnt = 1; /* True to count the table */
105718 int regNewRowid = iMem++; /* Rowid for the inserted record */
105719 int regStat4 = iMem++; /* Register to hold Stat4Accum object */
105720 int regChng = iMem++; /* Index of changed index field */
105721 #ifdef SQLITE_ENABLE_STAT4
105722 int regRowid = iMem++; /* Rowid argument passed to stat_push() */
105723 #endif
105724 int regTemp = iMem++; /* Temporary use register */
105725 int regTabname = iMem++; /* Register containing table name */
105726 int regIdxname = iMem++; /* Register containing index name */
@@ -105565,20 +105850,20 @@
105850 ** (or for a WITHOUT ROWID table, the number of PK columns),
105851 ** (2) the number of columns in the key without the rowid/pk
105852 ** (3) the number of rows in the index,
105853 **
105854 **
105855 ** The third argument is only used for STAT4
105856 */
105857 #ifdef SQLITE_ENABLE_STAT4
105858 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+3);
105859 #endif
105860 sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1);
105861 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);
105862 sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4+1, regStat4,
105863 (char*)&statInitFuncdef, P4_FUNCDEF);
105864 sqlite3VdbeChangeP5(v, 2+IsStat4);
105865
105866 /* Implementation of the following:
105867 **
105868 ** Rewind csr
105869 ** if eof(csr) goto end_of_scan;
@@ -105645,16 +105930,16 @@
105930 sqlite3DbFree(db, aGotoChng);
105931 }
105932
105933 /*
105934 ** chng_addr_N:
105935 ** regRowid = idx(rowid) // STAT4 only
105936 ** stat_push(P, regChng, regRowid) // 3rd parameter STAT4 only
105937 ** Next csr
105938 ** if !eof(csr) goto next_row;
105939 */
105940 #ifdef SQLITE_ENABLE_STAT4
105941 assert( regRowid==(regStat4+2) );
105942 if( HasRowid(pTab) ){
105943 sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, regRowid);
105944 }else{
105945 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
@@ -105671,11 +105956,11 @@
105956 }
105957 #endif
105958 assert( regChng==(regStat4+1) );
105959 sqlite3VdbeAddOp4(v, OP_Function0, 1, regStat4, regTemp,
105960 (char*)&statPushFuncdef, P4_FUNCDEF);
105961 sqlite3VdbeChangeP5(v, 2+IsStat4);
105962 sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, addrNextRow); VdbeCoverage(v);
105963
105964 /* Add the entry to the stat1 table. */
105965 callStatGet(v, regStat4, STAT_GET_STAT1, regStat1);
105966 assert( "BBB"[0]==SQLITE_AFF_TEXT );
@@ -105685,12 +105970,12 @@
105970 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
105971 sqlite3VdbeChangeP4(v, -1, (char*)pStat1, P4_TABLE);
105972 #endif
105973 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
105974
105975 /* Add the entries to the stat4 table. */
105976 #ifdef SQLITE_ENABLE_STAT4
105977 {
105978 int regEq = regStat1;
105979 int regLt = regStat1+1;
105980 int regDLt = regStat1+2;
105981 int regSample = regStat1+3;
@@ -105709,25 +105994,21 @@
105994 callStatGet(v, regStat4, STAT_GET_NEQ, regEq);
105995 callStatGet(v, regStat4, STAT_GET_NLT, regLt);
105996 callStatGet(v, regStat4, STAT_GET_NDLT, regDLt);
105997 sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);
105998 VdbeCoverage(v);
 
 
 
105999 for(i=0; i<nCol; i++){
106000 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
106001 }
106002 sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol, regSample);
 
106003 sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp);
106004 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid);
106005 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regTemp, regNewRowid);
106006 sqlite3VdbeAddOp2(v, OP_Goto, 1, addrNext); /* P1==1 for end-of-loop */
106007 sqlite3VdbeJumpHere(v, addrIsNull);
106008 }
106009 #endif /* SQLITE_ENABLE_STAT4 */
106010
106011 /* End of analysis */
106012 sqlite3VdbeJumpHere(v, addrRewind);
106013 }
106014
@@ -105898,11 +106179,11 @@
106179 char *z = zIntArray;
106180 int c;
106181 int i;
106182 tRowcnt v;
106183
106184 #ifdef SQLITE_ENABLE_STAT4
106185 if( z==0 ) z = "";
106186 #else
106187 assert( z!=0 );
106188 #endif
106189 for(i=0; *z && i<nOut; i++){
@@ -105909,11 +106190,11 @@
106190 v = 0;
106191 while( (c=z[0])>='0' && c<='9' ){
106192 v = v*10 + c - '0';
106193 z++;
106194 }
106195 #ifdef SQLITE_ENABLE_STAT4
106196 if( aOut ) aOut[i] = v;
106197 if( aLog ) aLog[i] = sqlite3LogEst(v);
106198 #else
106199 assert( aOut==0 );
106200 UNUSED_PARAMETER(aOut);
@@ -105920,11 +106201,11 @@
106201 assert( aLog!=0 );
106202 aLog[i] = sqlite3LogEst(v);
106203 #endif
106204 if( *z==' ' ) z++;
106205 }
106206 #ifndef SQLITE_ENABLE_STAT4
106207 assert( pIndex!=0 ); {
106208 #else
106209 if( pIndex ){
106210 #endif
106211 pIndex->bUnordered = 0;
@@ -105931,11 +106212,13 @@
106212 pIndex->noSkipScan = 0;
106213 while( z[0] ){
106214 if( sqlite3_strglob("unordered*", z)==0 ){
106215 pIndex->bUnordered = 1;
106216 }else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){
106217 int sz = sqlite3Atoi(z+3);
106218 if( sz<2 ) sz = 2;
106219 pIndex->szIdxRow = sqlite3LogEst(sz);
106220 }else if( sqlite3_strglob("noskipscan*", z)==0 ){
106221 pIndex->noSkipScan = 1;
106222 }
106223 #ifdef SQLITE_ENABLE_COSTMULT
106224 else if( sqlite3_strglob("costmult=[0-9]*",z)==0 ){
@@ -105985,11 +106268,11 @@
106268 z = argv[2];
106269
106270 if( pIndex ){
106271 tRowcnt *aiRowEst = 0;
106272 int nCol = pIndex->nKeyCol+1;
106273 #ifdef SQLITE_ENABLE_STAT4
106274 /* Index.aiRowEst may already be set here if there are duplicate
106275 ** sqlite_stat1 entries for this index. In that case just clobber
106276 ** the old data with the new instead of allocating a new array. */
106277 if( pIndex->aiRowEst==0 ){
106278 pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(sizeof(tRowcnt) * nCol);
@@ -106021,11 +106304,11 @@
106304 /*
106305 ** If the Index.aSample variable is not NULL, delete the aSample[] array
106306 ** and its contents.
106307 */
106308 SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){
106309 #ifdef SQLITE_ENABLE_STAT4
106310 if( pIdx->aSample ){
106311 int j;
106312 for(j=0; j<pIdx->nSample; j++){
106313 IndexSample *p = &pIdx->aSample[j];
106314 sqlite3DbFree(db, p->p);
@@ -106037,14 +106320,14 @@
106320 pIdx->aSample = 0;
106321 }
106322 #else
106323 UNUSED_PARAMETER(db);
106324 UNUSED_PARAMETER(pIdx);
106325 #endif /* SQLITE_ENABLE_STAT4 */
106326 }
106327
106328 #ifdef SQLITE_ENABLE_STAT4
106329 /*
106330 ** Populate the pIdx->aAvgEq[] array based on the samples currently
106331 ** stored in pIdx->aSample[].
106332 */
106333 static void initAvgEq(Index *pIdx){
@@ -106118,25 +106401,23 @@
106401 }
106402 return pIdx;
106403 }
106404
106405 /*
106406 ** Load the content from either the sqlite_stat4
106407 ** into the relevant Index.aSample[] arrays.
106408 **
106409 ** Arguments zSql1 and zSql2 must point to SQL statements that return
106410 ** data equivalent to the following:
 
106411 **
106412 ** zSql1: SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx
106413 ** zSql2: SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4
106414 **
106415 ** where %Q is replaced with the database name before the SQL is executed.
106416 */
106417 static int loadStatTbl(
106418 sqlite3 *db, /* Database handle */
 
106419 const char *zSql1, /* SQL statement 1 (see above) */
106420 const char *zSql2, /* SQL statement 2 (see above) */
106421 const char *zDb /* Database name (e.g. "main") */
106422 ){
106423 int rc; /* Result codes from subroutines */
@@ -106166,21 +106447,17 @@
106447
106448 zIndex = (char *)sqlite3_column_text(pStmt, 0);
106449 if( zIndex==0 ) continue;
106450 nSample = sqlite3_column_int(pStmt, 1);
106451 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
106452 assert( pIdx==0 || pIdx->nSample==0 );
106453 if( pIdx==0 ) continue;
106454 assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );
106455 if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
106456 nIdxCol = pIdx->nKeyCol;
106457 }else{
106458 nIdxCol = pIdx->nColumn;
 
 
 
 
106459 }
106460 pIdx->nSampleCol = nIdxCol;
106461 nByte = sizeof(IndexSample) * nSample;
106462 nByte += sizeof(tRowcnt) * nIdxCol * 3 * nSample;
106463 nByte += nIdxCol * sizeof(tRowcnt); /* Space for Index.aAvgEq[] */
@@ -106218,13 +106495,12 @@
106495 zIndex = (char *)sqlite3_column_text(pStmt, 0);
106496 if( zIndex==0 ) continue;
106497 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
106498 if( pIdx==0 ) continue;
106499 /* This next condition is true if data has already been loaded from
106500 ** the sqlite_stat4 table. */
106501 nCol = pIdx->nSampleCol;
 
106502 if( pIdx!=pPrevIdx ){
106503 initAvgEq(pPrevIdx);
106504 pPrevIdx = pIdx;
106505 }
106506 pSample = &pIdx->aSample[pIdx->nSample];
@@ -106253,49 +106529,40 @@
106529 if( rc==SQLITE_OK ) initAvgEq(pPrevIdx);
106530 return rc;
106531 }
106532
106533 /*
106534 ** Load content from the sqlite_stat4 table into
106535 ** the Index.aSample[] arrays of all indices.
106536 */
106537 static int loadStat4(sqlite3 *db, const char *zDb){
106538 int rc = SQLITE_OK; /* Result codes from subroutines */
106539
106540 assert( db->lookaside.bDisable );
106541 if( sqlite3FindTable(db, "sqlite_stat4", zDb) ){
106542 rc = loadStatTbl(db,
106543 "SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx",
106544 "SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4",
106545 zDb
106546 );
106547 }
 
 
 
 
 
 
 
 
 
106548 return rc;
106549 }
106550 #endif /* SQLITE_ENABLE_STAT4 */
106551
106552 /*
106553 ** Load the content of the sqlite_stat1 and sqlite_stat4 tables. The
106554 ** contents of sqlite_stat1 are used to populate the Index.aiRowEst[]
106555 ** arrays. The contents of sqlite_stat4 are used to populate the
106556 ** Index.aSample[] arrays.
106557 **
106558 ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
106559 ** is returned. In this case, even if SQLITE_ENABLE_STAT4 was defined
106560 ** during compilation and the sqlite_stat4 table is present, no data is
106561 ** read from it.
106562 **
106563 ** If SQLITE_ENABLE_STAT4 was defined during compilation and the
106564 ** sqlite_stat4 table is not present in the database, SQLITE_ERROR is
106565 ** returned. However, in this case, data is read from the sqlite_stat1
106566 ** table (if it is present) before returning.
106567 **
106568 ** If an OOM error occurs, this function always sets db->mallocFailed.
@@ -106319,11 +106586,11 @@
106586 pTab->tabFlags &= ~TF_HasStat1;
106587 }
106588 for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
106589 Index *pIdx = sqliteHashData(i);
106590 pIdx->hasStat1 = 0;
106591 #ifdef SQLITE_ENABLE_STAT4
106592 sqlite3DeleteIndexSamples(db, pIdx);
106593 pIdx->aSample = 0;
106594 #endif
106595 }
106596
@@ -106347,11 +106614,11 @@
106614 Index *pIdx = sqliteHashData(i);
106615 if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
106616 }
106617
106618 /* Load the statistics from the sqlite_stat4 table. */
106619 #ifdef SQLITE_ENABLE_STAT4
106620 if( rc==SQLITE_OK ){
106621 db->lookaside.bDisable++;
106622 rc = loadStat4(db, sInfo.zDatabase);
106623 db->lookaside.bDisable--;
106624 }
@@ -106672,10 +106939,11 @@
106939 ){
106940 const char *zName = (const char *)sqlite3_value_text(argv[0]);
106941 sqlite3 *db = sqlite3_context_db_handle(context);
106942 int i;
106943 Db *pDb = 0;
106944 HashElem *pEntry;
106945 char zErr[128];
106946
106947 UNUSED_PARAMETER(NotUsed);
106948
106949 if( zName==0 ) zName = "";
@@ -106695,10 +106963,22 @@
106963 }
106964 if( sqlite3BtreeIsInReadTrans(pDb->pBt) || sqlite3BtreeIsInBackup(pDb->pBt) ){
106965 sqlite3_snprintf(sizeof(zErr),zErr, "database %s is locked", zName);
106966 goto detach_error;
106967 }
106968
106969 /* If any TEMP triggers reference the schema being detached, move those
106970 ** triggers to reference the TEMP schema itself. */
106971 assert( db->aDb[1].pSchema );
106972 pEntry = sqliteHashFirst(&db->aDb[1].pSchema->trigHash);
106973 while( pEntry ){
106974 Trigger *pTrig = (Trigger*)sqliteHashData(pEntry);
106975 if( pTrig->pTabSchema==pDb->pSchema ){
106976 pTrig->pTabSchema = pTrig->pSchema;
106977 }
106978 pEntry = sqliteHashNext(pEntry);
106979 }
106980
106981 sqlite3BtreeClose(pDb->pBt);
106982 pDb->pBt = 0;
106983 pDb->pSchema = 0;
106984 sqlite3CollapseDatabaseArray(db);
@@ -106933,10 +107213,11 @@
107213 SQLITE_PRIVATE int sqlite3FixExpr(
107214 DbFixer *pFix, /* Context of the fixation */
107215 Expr *pExpr /* The expression to be fixed to one database */
107216 ){
107217 while( pExpr ){
107218 ExprSetProperty(pExpr, EP_Indirect);
107219 if( pExpr->op==TK_VARIABLE ){
107220 if( pFix->pParse->db->init.busy ){
107221 pExpr->op = TK_NULL;
107222 }else{
107223 sqlite3ErrorMsg(pFix->pParse, "%s cannot use variables", pFix->zType);
@@ -107085,11 +107366,11 @@
107366 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
107367 #endif
107368 sqlite3_mutex_enter(db->mutex);
107369 db->xAuth = (sqlite3_xauth)xAuth;
107370 db->pAuthArg = pArg;
107371 if( db->xAuth ) sqlite3ExpirePreparedStatements(db, 1);
107372 sqlite3_mutex_leave(db->mutex);
107373 return SQLITE_OK;
107374 }
107375
107376 /*
@@ -107739,11 +108020,11 @@
108020 #endif
108021 sqlite3ExprDelete(db, p->pPartIdxWhere);
108022 sqlite3ExprListDelete(db, p->aColExpr);
108023 sqlite3DbFree(db, p->zColAff);
108024 if( p->isResized ) sqlite3DbFree(db, (void *)p->azColl);
108025 #ifdef SQLITE_ENABLE_STAT4
108026 sqlite3_free(p->aiRowEst);
108027 #endif
108028 sqlite3DbFree(db, p);
108029 }
108030
@@ -108112,17 +108393,44 @@
108393 ** This routine is used to check if the UTF-8 string zName is a legal
108394 ** unqualified name for a new schema object (table, index, view or
108395 ** trigger). All names are legal except those that begin with the string
108396 ** "sqlite_" (in upper, lower or mixed case). This portion of the namespace
108397 ** is reserved for internal use.
108398 **
108399 ** When parsing the sqlite_master table, this routine also checks to
108400 ** make sure the "type", "name", and "tbl_name" columns are consistent
108401 ** with the SQL.
108402 */
108403 SQLITE_PRIVATE int sqlite3CheckObjectName(
108404 Parse *pParse, /* Parsing context */
108405 const char *zName, /* Name of the object to check */
108406 const char *zType, /* Type of this object */
108407 const char *zTblName /* Parent table name for triggers and indexes */
108408 ){
108409 sqlite3 *db = pParse->db;
108410 if( sqlite3WritableSchema(db) || db->init.imposterTable ){
108411 /* Skip these error checks for writable_schema=ON */
108412 return SQLITE_OK;
108413 }
108414 if( db->init.busy ){
108415 if( sqlite3_stricmp(zType, db->init.azInit[0])
108416 || sqlite3_stricmp(zName, db->init.azInit[1])
108417 || sqlite3_stricmp(zTblName, db->init.azInit[2])
108418 ){
108419 if( sqlite3Config.bExtraSchemaChecks ){
108420 sqlite3ErrorMsg(pParse, ""); /* corruptSchema() will supply the error */
108421 return SQLITE_ERROR;
108422 }
108423 }
108424 }else{
108425 if( pParse->nested==0
108426 && 0==sqlite3StrNICmp(zName, "sqlite_", 7)
108427 ){
108428 sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s",
108429 zName);
108430 return SQLITE_ERROR;
108431 }
108432 }
108433 return SQLITE_OK;
108434 }
108435
108436 /*
@@ -108199,11 +108507,11 @@
108507 sqlite3RenameTokenMap(pParse, (void*)zName, pName);
108508 }
108509 }
108510 pParse->sNameToken = *pName;
108511 if( zName==0 ) return;
108512 if( sqlite3CheckObjectName(pParse, zName, isView?"view":"table", zName) ){
108513 goto begin_table_error;
108514 }
108515 if( db->init.iDb==1 ) isTemp = 1;
108516 #ifndef SQLITE_OMIT_AUTHORIZATION
108517 assert( isTemp==0 || isTemp==1 );
@@ -108699,11 +109007,11 @@
109007 }
109008 pTab->iPKey = iCol;
109009 pTab->keyConf = (u8)onError;
109010 assert( autoInc==0 || autoInc==1 );
109011 pTab->tabFlags |= autoInc*TF_Autoincrement;
109012 if( pList ) pParse->iPkSortOrder = pList->a[0].sortFlags;
109013 }else if( autoInc ){
109014 #ifndef SQLITE_OMIT_AUTOINCREMENT
109015 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
109016 "INTEGER PRIMARY KEY");
109017 #endif
@@ -109114,10 +109422,11 @@
109422 */
109423 static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
109424 Index *pIdx;
109425 Index *pPk;
109426 int nPk;
109427 int nExtra;
109428 int i, j;
109429 sqlite3 *db = pParse->db;
109430 Vdbe *v = pParse->pVdbe;
109431
109432 /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)
@@ -109149,17 +109458,18 @@
109458 sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
109459 if( pList==0 ) return;
109460 if( IN_RENAME_OBJECT ){
109461 sqlite3RenameTokenRemap(pParse, pList->a[0].pExpr, &pTab->iPKey);
109462 }
109463 pList->a[0].sortFlags = pParse->iPkSortOrder;
109464 assert( pParse->pNewTable==pTab );
109465 pTab->iPKey = -1;
109466 sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
109467 SQLITE_IDXTYPE_PRIMARYKEY);
109468 if( db->mallocFailed || pParse->nErr ) return;
109469 pPk = sqlite3PrimaryKeyIndex(pTab);
109470 assert( pPk->nKeyCol==1 );
109471 }else{
109472 pPk = sqlite3PrimaryKeyIndex(pTab);
109473 assert( pPk!=0 );
109474
109475 /*
@@ -109170,19 +109480,21 @@
109480 for(i=j=1; i<pPk->nKeyCol; i++){
109481 if( isDupColumn(pPk, j, pPk, i) ){
109482 pPk->nColumn--;
109483 }else{
109484 testcase( hasColumn(pPk->aiColumn, j, pPk->aiColumn[i]) );
109485 pPk->azColl[j] = pPk->azColl[i];
109486 pPk->aSortOrder[j] = pPk->aSortOrder[i];
109487 pPk->aiColumn[j++] = pPk->aiColumn[i];
109488 }
109489 }
109490 pPk->nKeyCol = j;
109491 }
109492 assert( pPk!=0 );
109493 pPk->isCovering = 1;
109494 if( !db->init.imposterTable ) pPk->uniqNotNull = 1;
109495 nPk = pPk->nColumn = pPk->nKeyCol;
109496
109497 /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master
109498 ** table entry. This is only required if currently generating VDBE
109499 ** code for a CREATE TABLE (not when parsing one as part of reading
109500 ** a database schema). */
@@ -109228,25 +109540,25 @@
109540 assert( pIdx->nColumn>=j );
109541 }
109542
109543 /* Add all table columns to the PRIMARY KEY index
109544 */
109545 nExtra = 0;
109546 for(i=0; i<pTab->nCol; i++){
109547 if( !hasColumn(pPk->aiColumn, nPk, i) ) nExtra++;
109548 }
109549 if( resizeIndexObject(db, pPk, nPk+nExtra) ) return;
109550 for(i=0, j=nPk; i<pTab->nCol; i++){
109551 if( !hasColumn(pPk->aiColumn, j, i) ){
109552 assert( j<pPk->nColumn );
109553 pPk->aiColumn[j] = i;
109554 pPk->azColl[j] = sqlite3StrBINARY;
109555 j++;
109556 }
109557 }
109558 assert( pPk->nColumn==j );
109559 assert( pTab->nCol<=j );
109560 recomputeColumnsNotIndexed(pPk);
109561 }
109562
109563 #ifndef SQLITE_OMIT_VIRTUALTABLE
109564 /*
@@ -109439,11 +109751,11 @@
109751 sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);
109752 pParse->nTab = 2;
109753 addrTop = sqlite3VdbeCurrentAddr(v) + 1;
109754 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
109755 if( pParse->nErr ) return;
109756 pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect, SQLITE_AFF_BLOB);
109757 if( pSelTab==0 ) return;
109758 assert( p->aCol==0 );
109759 p->nCol = pSelTab->nCol;
109760 p->aCol = pSelTab->aCol;
109761 pSelTab->nCol = 0;
@@ -109703,14 +110015,14 @@
110015 pTable->nCol = -1;
110016 db->lookaside.bDisable++;
110017 #ifndef SQLITE_OMIT_AUTHORIZATION
110018 xAuth = db->xAuth;
110019 db->xAuth = 0;
110020 pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE);
110021 db->xAuth = xAuth;
110022 #else
110023 pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE);
110024 #endif
110025 pParse->nTab = n;
110026 if( pTable->pCheck ){
110027 /* CREATE VIEW name(arglist) AS ...
110028 ** The names of the columns in the table are taken from
@@ -109722,11 +110034,12 @@
110034 &pTable->nCol, &pTable->aCol);
110035 if( db->mallocFailed==0
110036 && pParse->nErr==0
110037 && pTable->nCol==pSel->pEList->nExpr
110038 ){
110039 sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel,
110040 SQLITE_AFF_NONE);
110041 }
110042 }else if( pSelTab ){
110043 /* CREATE VIEW name AS... without an argument list. Construct
110044 ** the column names from the SELECT statement that defines the view.
110045 */
@@ -110403,10 +110716,31 @@
110716 p->nKeyCol = nCol - 1;
110717 *ppExtra = ((char*)p) + nByte;
110718 }
110719 return p;
110720 }
110721
110722 /*
110723 ** If expression list pList contains an expression that was parsed with
110724 ** an explicit "NULLS FIRST" or "NULLS LAST" clause, leave an error in
110725 ** pParse and return non-zero. Otherwise, return zero.
110726 */
110727 SQLITE_PRIVATE int sqlite3HasExplicitNulls(Parse *pParse, ExprList *pList){
110728 if( pList ){
110729 int i;
110730 for(i=0; i<pList->nExpr; i++){
110731 if( pList->a[i].bNulls ){
110732 u8 sf = pList->a[i].sortFlags;
110733 sqlite3ErrorMsg(pParse, "unsupported use of NULLS %s",
110734 (sf==0 || sf==3) ? "FIRST" : "LAST"
110735 );
110736 return 1;
110737 }
110738 }
110739 }
110740 return 0;
110741 }
110742
110743 /*
110744 ** Create a new index for an SQL table. pName1.pName2 is the name of the index
110745 ** and pTblList is the name of the table that is to be indexed. Both will
110746 ** be NULL for a primary key or an index that is created to satisfy a
@@ -110454,10 +110788,13 @@
110788 if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
110789 goto exit_create_index;
110790 }
110791 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
110792 goto exit_create_index;
110793 }
110794 if( sqlite3HasExplicitNulls(pParse, pList) ){
110795 goto exit_create_index;
110796 }
110797
110798 /*
110799 ** Find the table that is to be indexed. Return early if not found.
110800 */
@@ -110553,11 +110890,11 @@
110890 */
110891 if( pName ){
110892 zName = sqlite3NameFromToken(db, pName);
110893 if( zName==0 ) goto exit_create_index;
110894 assert( pName->z!=0 );
110895 if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName,"index",pTab->zName) ){
110896 goto exit_create_index;
110897 }
110898 if( !IN_RENAME_OBJECT ){
110899 if( !db->init.busy ){
110900 if( sqlite3FindTable(db, zName, 0)!=0 ){
@@ -110619,11 +110956,11 @@
110956 sqlite3TokenInit(&prevCol, pCol->zName);
110957 pList = sqlite3ExprListAppend(pParse, 0,
110958 sqlite3ExprAlloc(db, TK_ID, &prevCol, 0));
110959 if( pList==0 ) goto exit_create_index;
110960 assert( pList->nExpr==1 );
110961 sqlite3ExprListSetSortOrder(pList, sortOrder, SQLITE_SO_UNDEFINED);
110962 }else{
110963 sqlite3ExprListCheckLength(pParse, pList, "index");
110964 if( pParse->nErr ) goto exit_create_index;
110965 }
110966
@@ -110737,11 +111074,11 @@
111074 if( !zColl ) zColl = sqlite3StrBINARY;
111075 if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){
111076 goto exit_create_index;
111077 }
111078 pIndex->azColl[i] = zColl;
111079 requestedSortOrder = pListItem->sortFlags & sortOrderMask;
111080 pIndex->aSortOrder[i] = (u8)requestedSortOrder;
111081 }
111082
111083 /* Append the table key to the end of the index. For WITHOUT ROWID
111084 ** tables (when pPk!=0) this will be the declared PRIMARY KEY. For
@@ -110912,10 +111249,11 @@
111249 sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY);
111250
111251 /* Gather the complete text of the CREATE INDEX statement into
111252 ** the zStmt variable
111253 */
111254 assert( pName!=0 || pStart==0 );
111255 if( pStart ){
111256 int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
111257 if( pName->z[n-1]==';' ) n--;
111258 /* A named index with an explicit CREATE INDEX statement */
111259 zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
@@ -111954,11 +112292,12 @@
112292 assert( sqlite3KeyInfoIsWriteable(pKey) );
112293 for(i=0; i<nCol; i++){
112294 const char *zColl = pIdx->azColl[i];
112295 pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
112296 sqlite3LocateCollSeq(pParse, zColl);
112297 pKey->aSortFlags[i] = pIdx->aSortOrder[i];
112298 assert( 0==(pKey->aSortFlags[i] & KEYINFO_ORDER_BIGNULL) );
112299 }
112300 if( pParse->nErr ){
112301 assert( pParse->rc==SQLITE_ERROR_MISSING_COLLSEQ );
112302 if( pIdx->bNoQuery==0 ){
112303 /* Deactivate the index because it contains an unknown collating
@@ -115493,13 +115832,10 @@
115832 };
115833 #ifndef SQLITE_OMIT_ALTERTABLE
115834 sqlite3AlterFunctions();
115835 #endif
115836 sqlite3WindowFunctions();
 
 
 
115837 sqlite3RegisterDateTimeFunctions();
115838 sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));
115839
115840 #if 0 /* Enable to print out how the built-in functions are hashed */
115841 {
@@ -115998,17 +116334,17 @@
116334 pExpr = sqlite3Expr(db, TK_REGISTER, 0);
116335 if( pExpr ){
116336 if( iCol>=0 && iCol!=pTab->iPKey ){
116337 pCol = &pTab->aCol[iCol];
116338 pExpr->iTable = regBase + iCol + 1;
116339 pExpr->affExpr = pCol->affinity;
116340 zColl = pCol->zColl;
116341 if( zColl==0 ) zColl = db->pDfltColl->zName;
116342 pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl);
116343 }else{
116344 pExpr->iTable = regBase;
116345 pExpr->affExpr = SQLITE_AFF_INTEGER;
116346 }
116347 }
116348 return pExpr;
116349 }
116350
@@ -116807,11 +117143,11 @@
117143
117144 tFrom.z = zFrom;
117145 tFrom.n = nFrom;
117146 pRaise = sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed");
117147 if( pRaise ){
117148 pRaise->affExpr = OE_Abort;
117149 }
117150 pSelect = sqlite3SelectNew(pParse,
117151 sqlite3ExprListAppend(pParse, 0, pRaise),
117152 sqlite3SrcListAppend(pParse, 0, &tFrom, 0),
117153 pWhere,
@@ -116852,10 +117188,11 @@
117188 if( db->mallocFailed==1 ){
117189 fkTriggerDelete(db, pTrigger);
117190 return 0;
117191 }
117192 assert( pStep!=0 );
117193 assert( pTrigger!=0 );
117194
117195 switch( action ){
117196 case OE_Restrict:
117197 pStep->op = TK_SELECT;
117198 break;
@@ -117042,22 +117379,23 @@
117379 sqlite3OomFault(db);
117380 return 0;
117381 }
117382 for(n=0; n<pIdx->nColumn; n++){
117383 i16 x = pIdx->aiColumn[n];
117384 char aff;
117385 if( x>=0 ){
117386 aff = pTab->aCol[x].affinity;
117387 }else if( x==XN_ROWID ){
117388 aff = SQLITE_AFF_INTEGER;
117389 }else{
 
117390 assert( x==XN_EXPR );
117391 assert( pIdx->aColExpr!=0 );
117392 aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);
 
 
117393 }
117394 if( aff<SQLITE_AFF_BLOB ) aff = SQLITE_AFF_BLOB;
117395 if( aff>SQLITE_AFF_NUMERIC) aff = SQLITE_AFF_NUMERIC;
117396 pIdx->zColAff[n] = aff;
117397 }
117398 pIdx->zColAff[n] = 0;
117399 }
117400
117401 return pIdx->zColAff;
@@ -117093,15 +117431,16 @@
117431 sqlite3OomFault(db);
117432 return;
117433 }
117434
117435 for(i=0; i<pTab->nCol; i++){
117436 assert( pTab->aCol[i].affinity!=0 );
117437 zColAff[i] = pTab->aCol[i].affinity;
117438 }
117439 do{
117440 zColAff[i--] = 0;
117441 }while( i>=0 && zColAff[i]<=SQLITE_AFF_BLOB );
117442 pTab->zColAff = zColAff;
117443 }
117444 assert( zColAff!=0 );
117445 i = sqlite3Strlen30NN(zColAff);
117446 if( i ){
@@ -117785,10 +118124,13 @@
118124 if( pUpsert ){
118125 if( IsVirtual(pTab) ){
118126 sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"",
118127 pTab->zName);
118128 goto insert_cleanup;
118129 }
118130 if( sqlite3HasExplicitNulls(pParse, pUpsert->pUpsertTarget) ){
118131 goto insert_cleanup;
118132 }
118133 pTabList->a[0].iCursor = iDataCur;
118134 pUpsert->pUpsertSrc = pTabList;
118135 pUpsert->regData = regData;
118136 pUpsert->iDataCur = iDataCur;
@@ -119899,10 +120241,12 @@
120241 /* Version 3.26.0 and later */
120242 const char *(*normalized_sql)(sqlite3_stmt*);
120243 /* Version 3.28.0 and later */
120244 int (*stmt_isexplain)(sqlite3_stmt*);
120245 int (*value_frombind)(sqlite3_value*);
120246 /* Version 3.30.0 and later */
120247 int (*drop_modules)(sqlite3*,const char**);
120248 };
120249
120250 /*
120251 ** This is the function signature used for all extension entry points. It
120252 ** is also defined in the file "loadext.c".
@@ -120191,10 +120535,12 @@
120535 /* Version 3.26.0 and later */
120536 #define sqlite3_normalized_sql sqlite3_api->normalized_sql
120537 /* Version 3.28.0 and later */
120538 #define sqlite3_stmt_isexplain sqlite3_api->isexplain
120539 #define sqlite3_value_frombind sqlite3_api->frombind
120540 /* Version 3.30.0 and later */
120541 #define sqlite3_drop_modules sqlite3_api->drop_modules
120542 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
120543
120544 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
120545 /* This case when the file really is being compiled as a loadable
120546 ** extension */
@@ -120656,11 +121002,13 @@
121002 #else
121003 0,
121004 #endif
121005 /* Version 3.28.0 and later */
121006 sqlite3_stmt_isexplain,
121007 sqlite3_value_frombind,
121008 /* Version 3.30.0 and later */
121009 sqlite3_drop_modules,
121010 };
121011
121012 /*
121013 ** Attempt to load an SQLite extension library contained in the file
121014 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -121369,11 +121717,11 @@
121717 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121718 /* ColNames: */ 0, 0,
121719 /* iArg: */ SQLITE_FullFSync },
121720 #endif
121721 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
121722 #if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
121723 {/* zName: */ "function_list",
121724 /* ePragTyp: */ PragTyp_FUNCTION_LIST,
121725 /* ePragFlg: */ PragFlg_Result0,
121726 /* ColNames: */ 41, 2,
121727 /* iArg: */ 0 },
@@ -121493,11 +121841,11 @@
121841 /* ColNames: */ 0, 0,
121842 /* iArg: */ 0 },
121843 #endif
121844 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
121845 #if !defined(SQLITE_OMIT_VIRTUALTABLE)
121846 #if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
121847 {/* zName: */ "module_list",
121848 /* ePragTyp: */ PragTyp_MODULE_LIST,
121849 /* ePragFlg: */ PragFlg_Result0,
121850 /* ColNames: */ 9, 1,
121851 /* iArg: */ 0 },
@@ -121528,11 +121876,11 @@
121876 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121877 /* ColNames: */ 0, 0,
121878 /* iArg: */ SQLITE_ParserTrace },
121879 #endif
121880 #endif
121881 #if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
121882 {/* zName: */ "pragma_list",
121883 /* ePragTyp: */ PragTyp_PRAGMA_LIST,
121884 /* ePragFlg: */ PragFlg_Result0,
121885 /* ColNames: */ 9, 1,
121886 /* iArg: */ 0 },
@@ -121726,11 +122074,11 @@
122074 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
122075 /* ColNames: */ 0, 0,
122076 /* iArg: */ SQLITE_WriteSchema|SQLITE_NoSchemaError },
122077 #endif
122078 };
122079 /* Number of pragmas: 65 on by default, 81 total. */
122080
122081 /************** End of pragma.h **********************************************/
122082 /************** Continuing where we left off in pragma.c *********************/
122083
122084 /*
@@ -122858,10 +123206,19 @@
123206
123207 case PragTyp_INDEX_INFO: if( zRight ){
123208 Index *pIdx;
123209 Table *pTab;
123210 pIdx = sqlite3FindIndex(db, zRight, zDb);
123211 if( pIdx==0 ){
123212 /* If there is no index named zRight, check to see if there is a
123213 ** WITHOUT ROWID table named zRight, and if there is, show the
123214 ** structure of the PRIMARY KEY index for that table. */
123215 pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);
123216 if( pTab && !HasRowid(pTab) ){
123217 pIdx = sqlite3PrimaryKeyIndex(pTab);
123218 }
123219 }
123220 if( pIdx ){
123221 int iIdxDb = sqlite3SchemaToIndex(db, pIdx->pSchema);
123222 int i;
123223 int mx;
123224 if( pPragma->iArg ){
@@ -122937,11 +123294,11 @@
123294 sqlite3VdbeMultiLoad(v, 1, "is", i++, pColl->zName);
123295 }
123296 }
123297 break;
123298
123299 #ifndef SQLITE_OMIT_INTROSPECTION_PRAGMAS
123300 case PragTyp_FUNCTION_LIST: {
123301 int i;
123302 HashElem *j;
123303 FuncDef *p;
123304 pParse->nMem = 2;
@@ -124272,35 +124629,37 @@
124629 ** database. See sqlite3Init() below for additional information.
124630 ** This routine is also called from the OP_ParseSchema opcode of the VDBE.
124631 **
124632 ** Each callback contains the following information:
124633 **
124634 ** argv[0] = type of object: "table", "index", "trigger", or "view".
124635 ** argv[1] = name of thing being created
124636 ** argv[2] = associated table if an index or trigger
124637 ** argv[3] = root page number for table or index. 0 for trigger or view.
124638 ** argv[4] = SQL text for the CREATE statement.
124639 **
124640 */
124641 SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){
124642 InitData *pData = (InitData*)pInit;
124643 sqlite3 *db = pData->db;
124644 int iDb = pData->iDb;
124645
124646 assert( argc==5 );
124647 UNUSED_PARAMETER2(NotUsed, argc);
124648 assert( sqlite3_mutex_held(db->mutex) );
124649 DbClearProperty(db, iDb, DB_Empty);
124650 pData->nInitRow++;
124651 if( db->mallocFailed ){
124652 corruptSchema(pData, argv[1], 0);
124653 return 1;
124654 }
124655
124656 assert( iDb>=0 && iDb<db->nDb );
124657 if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */
124658 if( argv[3]==0 ){
124659 corruptSchema(pData, argv[1], 0);
124660 }else if( sqlite3_strnicmp(argv[4],"create ",7)==0 ){
124661 /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
124662 ** But because db->init.busy is set to 1, no VDBE code is generated
124663 ** or executed. All the parser does is build the internal data
124664 ** structures that describe the table, index, or view.
124665 */
@@ -124309,47 +124668,48 @@
124668 sqlite3_stmt *pStmt;
124669 TESTONLY(int rcp); /* Return code from sqlite3_prepare() */
124670
124671 assert( db->init.busy );
124672 db->init.iDb = iDb;
124673 db->init.newTnum = sqlite3Atoi(argv[3]);
124674 db->init.orphanTrigger = 0;
124675 db->init.azInit = argv;
124676 TESTONLY(rcp = ) sqlite3_prepare(db, argv[4], -1, &pStmt, 0);
124677 rc = db->errCode;
124678 assert( (rc&0xFF)==(rcp&0xFF) );
124679 db->init.iDb = saved_iDb;
124680 /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */
124681 if( SQLITE_OK!=rc ){
124682 if( db->init.orphanTrigger ){
124683 assert( iDb==1 );
124684 }else{
124685 if( rc > pData->rc ) pData->rc = rc;
124686 if( rc==SQLITE_NOMEM ){
124687 sqlite3OomFault(db);
124688 }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){
124689 corruptSchema(pData, argv[1], sqlite3_errmsg(db));
124690 }
124691 }
124692 }
124693 sqlite3_finalize(pStmt);
124694 }else if( argv[1]==0 || (argv[4]!=0 && argv[4][0]!=0) ){
124695 corruptSchema(pData, argv[1], 0);
124696 }else{
124697 /* If the SQL column is blank it means this is an index that
124698 ** was created to be the PRIMARY KEY or to fulfill a UNIQUE
124699 ** constraint for a CREATE TABLE. The index should have already
124700 ** been created when we processed the CREATE TABLE. All we have
124701 ** to do here is record the root page number for that index.
124702 */
124703 Index *pIndex;
124704 pIndex = sqlite3FindIndex(db, argv[1], db->aDb[iDb].zDbSName);
124705 if( pIndex==0
124706 || sqlite3GetInt32(argv[3],&pIndex->tnum)==0
124707 || pIndex->tnum<2
124708 || sqlite3IndexHasDuplicateRootPage(pIndex)
124709 ){
124710 corruptSchema(pData, argv[1], pIndex?"invalid rootpage":"orphan index");
124711 }
124712 }
124713 return 0;
124714 }
124715
@@ -124366,11 +124726,11 @@
124726 int i;
124727 #ifndef SQLITE_OMIT_DEPRECATED
124728 int size;
124729 #endif
124730 Db *pDb;
124731 char const *azArg[6];
124732 int meta[5];
124733 InitData initData;
124734 const char *zMasterName;
124735 int openedTransaction = 0;
124736
@@ -124385,22 +124745,24 @@
124745 /* Construct the in-memory representation schema tables (sqlite_master or
124746 ** sqlite_temp_master) by invoking the parser directly. The appropriate
124747 ** table name will be inserted automatically by the parser so we can just
124748 ** use the abbreviation "x" here. The parser will also automatically tag
124749 ** the schema table as read-only. */
124750 azArg[0] = "table";
124751 azArg[1] = zMasterName = SCHEMA_TABLE(iDb);
124752 azArg[2] = azArg[1];
124753 azArg[3] = "1";
124754 azArg[4] = "CREATE TABLE x(type text,name text,tbl_name text,"
124755 "rootpage int,sql text)";
124756 azArg[5] = 0;
124757 initData.db = db;
124758 initData.iDb = iDb;
124759 initData.rc = SQLITE_OK;
124760 initData.pzErrMsg = pzErrMsg;
124761 initData.mInitFlags = mFlags;
124762 initData.nInitRow = 0;
124763 sqlite3InitCallback(&initData, 5, (char **)azArg, 0);
124764 if( initData.rc ){
124765 rc = initData.rc;
124766 goto error_out;
124767 }
124768
@@ -124522,11 +124884,11 @@
124884 */
124885 assert( db->init.busy );
124886 {
124887 char *zSql;
124888 zSql = sqlite3MPrintf(db,
124889 "SELECT*FROM\"%w\".%s ORDER BY rowid",
124890 db->aDb[iDb].zDbSName, zMasterName);
124891 #ifndef SQLITE_OMIT_AUTHORIZATION
124892 {
124893 sqlite3_xauth xAuth;
124894 xAuth = db->xAuth;
@@ -124843,11 +125205,14 @@
125205 *pzTail = sParse.zTail;
125206 }
125207 rc = sParse.rc;
125208
125209 #ifndef SQLITE_OMIT_EXPLAIN
125210 /* Justification for the ALWAYS(): The only way for rc to be SQLITE_OK and
125211 ** sParse.pVdbe to be NULL is if the input SQL is an empty string, but in
125212 ** that case, sParse.explain will be false. */
125213 if( sParse.explain && rc==SQLITE_OK && ALWAYS(sParse.pVdbe) ){
125214 static const char * const azColName[] = {
125215 "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment",
125216 "id", "parent", "notused", "detail"
125217 };
125218 int iFirst, mx;
@@ -124868,12 +125233,12 @@
125233 #endif
125234
125235 if( db->init.busy==0 ){
125236 sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);
125237 }
125238 if( rc!=SQLITE_OK || db->mallocFailed ){
125239 if( sParse.pVdbe ) sqlite3VdbeFinalize(sParse.pVdbe);
125240 assert(!(*ppStmt));
125241 }else{
125242 *ppStmt = (sqlite3_stmt*)sParse.pVdbe;
125243 }
125244
@@ -125242,10 +125607,11 @@
125607 if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){
125608 sqlite3WindowListDelete(db, p->pWinDefn);
125609 }
125610 #endif
125611 if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);
125612 assert( p->pWin==0 );
125613 if( bFree ) sqlite3DbFreeNN(db, p);
125614 p = pPrior;
125615 bFree = 1;
125616 }
125617 }
@@ -125803,11 +126169,11 @@
126169 sqlite3VdbeAddOp3(v, OP_Compare, regPrevKey, regBase, pSort->nOBSat);
126170 pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);
126171 if( pParse->db->mallocFailed ) return;
126172 pOp->p2 = nKey + nData;
126173 pKI = pOp->p4.pKeyInfo;
126174 memset(pKI->aSortFlags, 0, pKI->nKeyField); /* Makes OP_Jump testable */
126175 sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
126176 testcase( pKI->nAllField > pKI->nKeyField+2 );
126177 pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat,
126178 pKI->nAllField-pKI->nKeyField-1);
126179 addrJmp = sqlite3VdbeCurrentAddr(v);
@@ -126414,11 +126780,11 @@
126780 */
126781 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
126782 int nExtra = (N+X)*(sizeof(CollSeq*)+1) - sizeof(CollSeq*);
126783 KeyInfo *p = sqlite3DbMallocRawNN(db, sizeof(KeyInfo) + nExtra);
126784 if( p ){
126785 p->aSortFlags = (u8*)&p->aColl[N+X];
126786 p->nKeyField = (u16)N;
126787 p->nAllField = (u16)(N+X);
126788 p->enc = ENC(db);
126789 p->db = db;
126790 p->nRef = 1;
@@ -126491,11 +126857,11 @@
126857 pInfo = sqlite3KeyInfoAlloc(db, nExpr-iStart, nExtra+1);
126858 if( pInfo ){
126859 assert( sqlite3KeyInfoIsWriteable(pInfo) );
126860 for(i=iStart, pItem=pList->a+iStart; i<nExpr; i++, pItem++){
126861 pInfo->aColl[i-iStart] = sqlite3ExprNNCollSeq(pParse, pItem->pExpr);
126862 pInfo->aSortFlags[i-iStart] = pItem->sortFlags;
126863 }
126864 }
126865 return pInfo;
126866 }
126867
@@ -126783,12 +127149,10 @@
127149 char const *zOrigCol = 0;
127150 #endif
127151
127152 assert( pExpr!=0 );
127153 assert( pNC->pSrcList!=0 );
 
 
127154 switch( pExpr->op ){
127155 case TK_COLUMN: {
127156 /* The expression is a column. Locate the table the column is being
127157 ** extracted from in NameContext.pSrcList. This table may be real
127158 ** database table or a subquery.
@@ -127101,16 +127465,15 @@
127465 /* Get an appropriate name for the column
127466 */
127467 if( (zName = pEList->a[i].zName)!=0 ){
127468 /* If the column contains an "AS <name>" phrase, use <name> as the name */
127469 }else{
127470 Expr *pColExpr = sqlite3ExprSkipCollateAndLikely(pEList->a[i].pExpr);
127471 while( pColExpr->op==TK_DOT ){
127472 pColExpr = pColExpr->pRight;
127473 assert( pColExpr!=0 );
127474 }
 
127475 if( pColExpr->op==TK_COLUMN ){
127476 /* For columns use the column name name */
127477 int iCol = pColExpr->iColumn;
127478 Table *pTab = pColExpr->y.pTab;
127479 assert( pTab!=0 );
@@ -127174,11 +127537,12 @@
127537 ** statement be resolved.
127538 */
127539 SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(
127540 Parse *pParse, /* Parsing contexts */
127541 Table *pTab, /* Add column type information to this table */
127542 Select *pSelect, /* SELECT used to determine types and collations */
127543 char aff /* Default affinity for columns */
127544 ){
127545 sqlite3 *db = pParse->db;
127546 NameContext sNC;
127547 Column *pCol;
127548 CollSeq *pColl;
@@ -127207,11 +127571,11 @@
127571 if( pCol->zName ){
127572 memcpy(&pCol->zName[n+1], zType, m+1);
127573 pCol->colFlags |= COLFLAG_HASTYPE;
127574 }
127575 }
127576 if( pCol->affinity<=SQLITE_AFF_NONE ) pCol->affinity = aff;
127577 pColl = sqlite3ExprCollSeq(pParse, p);
127578 if( pColl && pCol->zColl==0 ){
127579 pCol->zColl = sqlite3DbStrDup(db, pColl->zName);
127580 }
127581 }
@@ -127220,11 +127584,11 @@
127584
127585 /*
127586 ** Given a SELECT statement, generate a Table structure that describes
127587 ** the result set of that SELECT.
127588 */
127589 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect, char aff){
127590 Table *pTab;
127591 sqlite3 *db = pParse->db;
127592 u64 savedFlags;
127593
127594 savedFlags = db->flags;
@@ -127240,11 +127604,11 @@
127604 }
127605 pTab->nTabRef = 1;
127606 pTab->zName = 0;
127607 pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
127608 sqlite3ColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);
127609 sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSelect, aff);
127610 pTab->iPKey = -1;
127611 if( db->mallocFailed ){
127612 sqlite3DeleteTable(db, pTab);
127613 return 0;
127614 }
@@ -127394,11 +127758,11 @@
127758 pOrderBy->a[i].pExpr =
127759 sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);
127760 }
127761 assert( sqlite3KeyInfoIsWriteable(pRet) );
127762 pRet->aColl[i] = pColl;
127763 pRet->aSortFlags[i] = pOrderBy->a[i].sortFlags;
127764 }
127765 }
127766
127767 return pRet;
127768 }
@@ -128105,15 +128469,18 @@
128469 break;
128470 }
128471
128472 /* If this is a scalar select that is part of an expression, then
128473 ** store the results in the appropriate memory cell and break out
128474 ** of the scan loop. Note that the select might return multiple columns
128475 ** if it is the RHS of a row-value IN operator.
128476 */
128477 case SRT_Mem: {
128478 if( pParse->nErr==0 ){
128479 testcase( pIn->nSdst>1 );
128480 sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, pIn->nSdst);
128481 }
128482 /* The LIMIT clause will jump out of the loop for us */
128483 break;
128484 }
128485 #endif /* #ifndef SQLITE_OMIT_SUBQUERY */
128486
@@ -128366,11 +128733,11 @@
128733 pKeyDup = sqlite3KeyInfoAlloc(db, nExpr, 1);
128734 if( pKeyDup ){
128735 assert( sqlite3KeyInfoIsWriteable(pKeyDup) );
128736 for(i=0; i<nExpr; i++){
128737 pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
128738 pKeyDup->aSortFlags[i] = 0;
128739 }
128740 }
128741 }
128742
128743 /* Separate the left and the right query from one another
@@ -129089,10 +129456,11 @@
129456 ** elements we are now copying in.
129457 */
129458 for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){
129459 int nSubSrc;
129460 u8 jointype = 0;
129461 assert( pSub!=0 );
129462 pSubSrc = pSub->pSrc; /* FROM clause of subquery */
129463 nSubSrc = pSubSrc->nSrc; /* Number of terms in subquery FROM clause */
129464 pSrc = pParent->pSrc; /* FROM clause of the outer query */
129465
129466 if( pSrc ){
@@ -129539,28 +129907,31 @@
129907 static u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){
129908 int eRet = WHERE_ORDERBY_NORMAL; /* Return value */
129909 ExprList *pEList = pFunc->x.pList; /* Arguments to agg function */
129910 const char *zFunc; /* Name of aggregate function pFunc */
129911 ExprList *pOrderBy;
129912 u8 sortFlags;
129913
129914 assert( *ppMinMax==0 );
129915 assert( pFunc->op==TK_AGG_FUNCTION );
129916 assert( !IsWindowFunc(pFunc) );
129917 if( pEList==0 || pEList->nExpr!=1 || ExprHasProperty(pFunc, EP_WinFunc) ){
129918 return eRet;
129919 }
129920 zFunc = pFunc->u.zToken;
129921 if( sqlite3StrICmp(zFunc, "min")==0 ){
129922 eRet = WHERE_ORDERBY_MIN;
129923 sortFlags = KEYINFO_ORDER_BIGNULL;
129924 }else if( sqlite3StrICmp(zFunc, "max")==0 ){
129925 eRet = WHERE_ORDERBY_MAX;
129926 sortFlags = KEYINFO_ORDER_DESC;
129927 }else{
129928 return eRet;
129929 }
129930 *ppMinMax = pOrderBy = sqlite3ExprListDup(db, pEList, 0);
129931 assert( pOrderBy!=0 || db->mallocFailed );
129932 if( pOrderBy ) pOrderBy->a[0].sortFlags = sortFlags;
129933 return eRet;
129934 }
129935
129936 /*
129937 ** The select statement passed as the first argument is an aggregate query.
@@ -129590,11 +129961,11 @@
129961
129962 if( IsVirtual(pTab) ) return 0;
129963 if( pExpr->op!=TK_AGG_FUNCTION ) return 0;
129964 if( NEVER(pAggInfo->nFunc==0) ) return 0;
129965 if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0;
129966 if( ExprHasProperty(pExpr, EP_Distinct|EP_WinFunc) ) return 0;
129967
129968 return pTab;
129969 }
129970
129971 /*
@@ -130037,10 +130408,14 @@
130408 if( IsVirtual(pTab) || pTab->pSelect ){
130409 i16 nCol;
130410 u8 eCodeOrig = pWalker->eCode;
130411 if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;
130412 assert( pFrom->pSelect==0 );
130413 if( pTab->pSelect && (db->flags & SQLITE_EnableView)==0 ){
130414 sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited",
130415 pTab->zName);
130416 }
130417 pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);
130418 nCol = pTab->nCol;
130419 pTab->nCol = -1;
130420 pWalker->eCode = 1; /* Turn on Select.selId renumbering */
130421 sqlite3WalkSelect(pWalker, pFrom->pSelect);
@@ -130330,11 +130705,12 @@
130705 if( (pTab->tabFlags & TF_Ephemeral)!=0 ){
130706 /* A sub-query in the FROM clause of a SELECT */
130707 Select *pSel = pFrom->pSelect;
130708 if( pSel ){
130709 while( pSel->pPrior ) pSel = pSel->pPrior;
130710 sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSel,
130711 SQLITE_AFF_NONE);
130712 }
130713 }
130714 }
130715 }
130716 #endif
@@ -130470,20 +130846,28 @@
130846 int nArg;
130847 int addrNext = 0;
130848 int regAgg;
130849 ExprList *pList = pF->pExpr->x.pList;
130850 assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
130851 assert( !IsWindowFunc(pF->pExpr) );
130852 if( ExprHasProperty(pF->pExpr, EP_WinFunc) ){
130853 Expr *pFilter = pF->pExpr->y.pWin->pFilter;
130854 addrNext = sqlite3VdbeMakeLabel(pParse);
130855 sqlite3ExprIfFalse(pParse, pFilter, addrNext, SQLITE_JUMPIFNULL);
130856 }
130857 if( pList ){
130858 nArg = pList->nExpr;
130859 regAgg = sqlite3GetTempRange(pParse, nArg);
130860 sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP);
130861 }else{
130862 nArg = 0;
130863 regAgg = 0;
130864 }
130865 if( pF->iDistinct>=0 ){
130866 if( addrNext==0 ){
130867 addrNext = sqlite3VdbeMakeLabel(pParse);
130868 }
130869 testcase( nArg==0 ); /* Error condition */
130870 testcase( nArg>1 ); /* Also an error */
130871 codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);
130872 }
130873 if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
@@ -130982,11 +131366,11 @@
131366 ** "" column. The original design was for the fake column name to be a NULL,
131367 ** which would be unambiguous. But legacy authorization callbacks might
131368 ** assume the column name is non-NULL and segfault. The use of an empty
131369 ** string for the fake column name seems safer.
131370 */
131371 if( pItem->colUsed==0 && pItem->zName!=0 ){
131372 sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase);
131373 }
131374
131375 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
131376 /* Generate code for all sub-queries in the FROM clause
@@ -130996,12 +131380,19 @@
131380
131381 /* The code for a subquery should only be generated once, though it is
131382 ** technically harmless for it to be generated multiple times. The
131383 ** following assert() will detect if something changes to cause
131384 ** the same subquery to be coded multiple times, as a signal to the
131385 ** developers to try to optimize the situation.
131386 **
131387 ** Update 2019-07-24:
131388 ** See ticket https://sqlite.org/src/tktview/c52b09c7f38903b1311cec40.
131389 ** The dbsqlfuzz fuzzer found a case where the same subquery gets
131390 ** coded twice. So this assert() now becomes a testcase(). It should
131391 ** be very rare, though.
131392 */
131393 testcase( pItem->addrFillSub!=0 );
131394
131395 /* Increment Parse.nHeight by the height of the largest expression
131396 ** tree referred to by this, the parent select. The child select
131397 ** may contain expression trees of at most
131398 ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit
@@ -131071,11 +131462,11 @@
131462 int topAddr;
131463 int onceAddr = 0;
131464 int retAddr;
131465 struct SrcList_item *pPrior;
131466
131467 testcase( pItem->addrFillSub==0 ); /* Ticket c52b09c7f38903b1311 */
131468 pItem->regReturn = ++pParse->nMem;
131469 topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn);
131470 pItem->addrFillSub = topAddr+1;
131471 if( pItem->fg.isCorrelated==0 ){
131472 /* If the subquery is not correlated and if we are not inside of
@@ -131362,13 +131753,20 @@
131753 minMaxFlag = minMaxQuery(db, sAggInfo.aFunc[0].pExpr, &pMinMaxOrderBy);
131754 }else{
131755 minMaxFlag = WHERE_ORDERBY_NORMAL;
131756 }
131757 for(i=0; i<sAggInfo.nFunc; i++){
131758 Expr *pExpr = sAggInfo.aFunc[i].pExpr;
131759 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
131760 sNC.ncFlags |= NC_InAggFunc;
131761 sqlite3ExprAnalyzeAggList(&sNC, pExpr->x.pList);
131762 #ifndef SQLITE_OMIT_WINDOWFUNC
131763 assert( !IsWindowFunc(pExpr) );
131764 if( ExprHasProperty(pExpr, EP_WinFunc) ){
131765 sqlite3ExprAnalyzeAggregates(&sNC, pExpr->y.pWin->pFilter);
131766 }
131767 #endif
131768 sNC.ncFlags &= ~NC_InAggFunc;
131769 }
131770 sAggInfo.mxReg = pParse->nMem;
131771 if( db->mallocFailed ) goto select_end;
131772 #if SELECTTRACE_ENABLED
@@ -132153,11 +132551,15 @@
132551 }
132552
132553 /* Check that the trigger name is not reserved and that no trigger of the
132554 ** specified name exists */
132555 zName = sqlite3NameFromToken(db, pName);
132556 if( zName==0 ){
132557 assert( db->mallocFailed );
132558 goto trigger_cleanup;
132559 }
132560 if( sqlite3CheckObjectName(pParse, zName, "trigger", pTab->zName) ){
132561 goto trigger_cleanup;
132562 }
132563 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
132564 if( !IN_RENAME_OBJECT ){
132565 if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),zName) ){
@@ -132316,10 +132718,11 @@
132718
132719 if( db->init.busy ){
132720 Trigger *pLink = pTrig;
132721 Hash *pHash = &db->aDb[iDb].pSchema->trigHash;
132722 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
132723 assert( pLink!=0 );
132724 pTrig = sqlite3HashInsert(pHash, zName, pTrig);
132725 if( pTrig ){
132726 sqlite3OomFault(db);
132727 }else if( pLink->pSchema==pLink->pTabSchema ){
132728 Table *pTab;
@@ -132434,10 +132837,13 @@
132837 pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
132838 }
132839 pTriggerStep->pIdList = pColumn;
132840 pTriggerStep->pUpsert = pUpsert;
132841 pTriggerStep->orconf = orconf;
132842 if( pUpsert ){
132843 sqlite3HasExplicitNulls(pParse, pUpsert->pUpsertTarget);
132844 }
132845 }else{
132846 testcase( pColumn );
132847 sqlite3IdListDelete(db, pColumn);
132848 testcase( pUpsert );
132849 sqlite3UpsertDelete(db, pUpsert);
@@ -132589,14 +132995,13 @@
132995 int iDb;
132996
132997 iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema);
132998 assert( iDb>=0 && iDb<db->nDb );
132999 pTable = tableOfTrigger(pTrigger);
133000 assert( (pTable && pTable->pSchema==pTrigger->pSchema) || iDb==1 );
 
133001 #ifndef SQLITE_OMIT_AUTHORIZATION
133002 if( pTable ){
133003 int code = SQLITE_DROP_TRIGGER;
133004 const char *zDb = db->aDb[iDb].zDbSName;
133005 const char *zTab = SCHEMA_TABLE(iDb);
133006 if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;
133007 if( sqlite3AuthCheck(pParse, code, pTrigger->zName, pTable->zName, zDb) ||
@@ -132606,11 +133011,10 @@
133011 }
133012 #endif
133013
133014 /* Generate code to destroy the database record of the trigger.
133015 */
 
133016 if( (v = sqlite3GetVdbe(pParse))!=0 ){
133017 sqlite3NestedParse(pParse,
133018 "DELETE FROM %Q.%s WHERE name=%Q AND type='trigger'",
133019 db->aDb[iDb].zDbSName, MASTER_NAME, pTrigger->zName
133020 );
@@ -132630,13 +133034,15 @@
133034 pHash = &(db->aDb[iDb].pSchema->trigHash);
133035 pTrigger = sqlite3HashInsert(pHash, zName, 0);
133036 if( ALWAYS(pTrigger) ){
133037 if( pTrigger->pSchema==pTrigger->pTabSchema ){
133038 Table *pTab = tableOfTrigger(pTrigger);
133039 if( pTab ){
133040 Trigger **pp;
133041 for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext));
133042 *pp = (*pp)->pNext;
133043 }
133044 }
133045 sqlite3DeleteTrigger(db, pTrigger);
133046 db->mDbFlags |= DBFLAG_SchemaChange;
133047 }
133048 }
@@ -133880,32 +134286,34 @@
134286 }
134287 }
134288 }
134289
134290 if( !isView ){
 
 
134291 /* Do constraint checks. */
134292 assert( regOldRowid>0 );
134293 sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
134294 regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace,
134295 aXRef, 0);
134296
134297 /* If REPLACE conflict handling may have been used, or if the PK of the
134298 ** row is changing, then the GenerateConstraintChecks() above may have
134299 ** moved cursor iDataCur. Reseek it. */
134300 if( bReplace || chngKey ){
134301 if( pPk ){
134302 sqlite3VdbeAddOp4Int(v, OP_NotFound,iDataCur,labelContinue,regKey,nKey);
134303 }else{
134304 sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue,regOldRowid);
134305 }
134306 VdbeCoverageNeverTaken(v);
134307 }
134308
134309 /* Do FK constraint checks. */
134310 if( hasFK ){
134311 sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);
134312 }
134313
134314 /* Delete the index entries associated with the current record. */
 
 
 
 
 
 
 
 
134315 sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, aRegIdx, -1);
134316
134317 /* If changing the rowid value, or if there are foreign key constraints
134318 ** to process, delete the old record. Otherwise, add a noop OP_Delete
134319 ** to invoke the pre-update hook.
@@ -133931,13 +134339,10 @@
134339 #else
134340 if( hasFK>1 || chngKey ){
134341 sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0);
134342 }
134343 #endif
 
 
 
134344
134345 if( hasFK ){
134346 sqlite3FkCheck(pParse, pTab, 0, regNewRowid, aXRef, chngKey);
134347 }
134348
@@ -134372,10 +134777,11 @@
134777 ){
134778 Vdbe *v = pParse->pVdbe;
134779 sqlite3 *db = pParse->db;
134780 SrcList *pSrc; /* FROM clause for the UPDATE */
134781 int iDataCur;
134782 int i;
134783
134784 assert( v!=0 );
134785 assert( pUpsert!=0 );
134786 VdbeNoopComment((v, "Begin DO UPDATE of UPSERT"));
134787 iDataCur = pUpsert->iDataCur;
@@ -134388,11 +134794,10 @@
134794 sqlite3ReleaseTempReg(pParse, regRowid);
134795 }else{
134796 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
134797 int nPk = pPk->nKeyCol;
134798 int iPk = pParse->nMem+1;
 
134799 pParse->nMem += nPk;
134800 for(i=0; i<nPk; i++){
134801 int k;
134802 assert( pPk->aiColumn[i]>=0 );
134803 k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
@@ -134409,10 +134814,16 @@
134814 }
134815 }
134816 /* pUpsert does not own pUpsertSrc - the outer INSERT statement does. So
134817 ** we have to make a copy before passing it down into sqlite3Update() */
134818 pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
134819 /* excluded.* columns of type REAL need to be converted to a hard real */
134820 for(i=0; i<pTab->nCol; i++){
134821 if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){
134822 sqlite3VdbeAddOp1(v, OP_RealAffinity, pUpsert->regData+i);
134823 }
134824 }
134825 sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet,
134826 pUpsert->pUpsertWhere, OE_Abort, 0, 0, pUpsert);
134827 pUpsert->pUpsertSet = 0; /* Will have been deleted by sqlite3Update() */
134828 pUpsert->pUpsertWhere = 0; /* Will have been deleted by sqlite3Update() */
134829 VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
@@ -134872,38 +135283,52 @@
135283
135284 /*
135285 ** Construct and install a Module object for a virtual table. When this
135286 ** routine is called, it is guaranteed that all appropriate locks are held
135287 ** and the module is not already part of the connection.
135288 **
135289 ** If there already exists a module with zName, replace it with the new one.
135290 ** If pModule==0, then delete the module zName if it exists.
135291 */
135292 SQLITE_PRIVATE Module *sqlite3VtabCreateModule(
135293 sqlite3 *db, /* Database in which module is registered */
135294 const char *zName, /* Name assigned to this module */
135295 const sqlite3_module *pModule, /* The definition of the module */
135296 void *pAux, /* Context pointer for xCreate/xConnect */
135297 void (*xDestroy)(void *) /* Module destructor function */
135298 ){
135299 Module *pMod;
135300 Module *pDel;
135301 char *zCopy;
135302 if( pModule==0 ){
135303 zCopy = (char*)zName;
135304 pMod = 0;
135305 }else{
135306 int nName = sqlite3Strlen30(zName);
135307 pMod = (Module *)sqlite3Malloc(sizeof(Module) + nName + 1);
135308 if( pMod==0 ){
135309 sqlite3OomFault(db);
135310 return 0;
135311 }
135312 zCopy = (char *)(&pMod[1]);
135313 memcpy(zCopy, zName, nName+1);
135314 pMod->zName = zCopy;
135315 pMod->pModule = pModule;
135316 pMod->pAux = pAux;
135317 pMod->xDestroy = xDestroy;
135318 pMod->pEpoTab = 0;
135319 pMod->nRefModule = 1;
135320 }
135321 pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,(void*)pMod);
135322 if( pDel ){
135323 if( pDel==pMod ){
135324 sqlite3OomFault(db);
135325 sqlite3DbFree(db, pDel);
135326 pMod = 0;
135327 }else{
135328 sqlite3VtabEponymousTableClear(db, pDel);
135329 sqlite3VtabModuleUnref(db, pDel);
135330 }
135331 }
135332 return pMod;
135333 }
135334
@@ -134920,15 +135345,11 @@
135345 void (*xDestroy)(void *) /* Module destructor function */
135346 ){
135347 int rc = SQLITE_OK;
135348
135349 sqlite3_mutex_enter(db->mutex);
135350 (void)sqlite3VtabCreateModule(db, zName, pModule, pAux, xDestroy);
 
 
 
 
135351 rc = sqlite3ApiExit(db, rc);
135352 if( rc!=SQLITE_OK && xDestroy ) xDestroy(pAux);
135353 sqlite3_mutex_leave(db->mutex);
135354 return rc;
135355 }
@@ -134962,10 +135383,48 @@
135383 #ifdef SQLITE_ENABLE_API_ARMOR
135384 if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;
135385 #endif
135386 return createModule(db, zName, pModule, pAux, xDestroy);
135387 }
135388
135389 /*
135390 ** External API to drop all virtual-table modules, except those named
135391 ** on the azNames list.
135392 */
135393 SQLITE_API int sqlite3_drop_modules(sqlite3 *db, const char** azNames){
135394 HashElem *pThis, *pNext;
135395 #ifdef SQLITE_ENABLE_API_ARMOR
135396 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
135397 #endif
135398 for(pThis=sqliteHashFirst(&db->aModule); pThis; pThis=pNext){
135399 Module *pMod = (Module*)sqliteHashData(pThis);
135400 pNext = sqliteHashNext(pThis);
135401 if( azNames ){
135402 int ii;
135403 for(ii=0; azNames[ii]!=0 && strcmp(azNames[ii],pMod->zName)!=0; ii++){}
135404 if( azNames[ii]!=0 ) continue;
135405 }
135406 createModule(db, pMod->zName, 0, 0, 0);
135407 }
135408 return SQLITE_OK;
135409 }
135410
135411 /*
135412 ** Decrement the reference count on a Module object. Destroy the
135413 ** module when the reference count reaches zero.
135414 */
135415 SQLITE_PRIVATE void sqlite3VtabModuleUnref(sqlite3 *db, Module *pMod){
135416 assert( pMod->nRefModule>0 );
135417 pMod->nRefModule--;
135418 if( pMod->nRefModule==0 ){
135419 if( pMod->xDestroy ){
135420 pMod->xDestroy(pMod->pAux);
135421 }
135422 assert( pMod->pEpoTab==0 );
135423 sqlite3DbFree(db, pMod);
135424 }
135425 }
135426
135427 /*
135428 ** Lock the virtual table so that it cannot be disconnected.
135429 ** Locks nest. Every lock should have a corresponding unlock.
135430 ** If an unlock is omitted, resources leaks will occur.
@@ -135002,10 +135461,11 @@
135461 assert( db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_ZOMBIE );
135462
135463 pVTab->nRef--;
135464 if( pVTab->nRef==0 ){
135465 sqlite3_vtab *p = pVTab->pVtab;
135466 sqlite3VtabModuleUnref(pVTab->db, pVTab->pMod);
135467 if( p ){
135468 p->pModule->xDisconnect(p);
135469 }
135470 sqlite3DbFree(db, pVTab);
135471 }
@@ -135406,10 +135866,11 @@
135866 }else if( ALWAYS(pVTable->pVtab) ){
135867 /* Justification of ALWAYS(): A correct vtab constructor must allocate
135868 ** the sqlite3_vtab object if successful. */
135869 memset(pVTable->pVtab, 0, sizeof(pVTable->pVtab[0]));
135870 pVTable->pVtab->pModule = pMod->pModule;
135871 pMod->nRefModule++;
135872 pVTable->nRef = 1;
135873 if( sCtx.bDeclared==0 ){
135874 const char *zFormat = "vtable constructor did not declare schema: %s";
135875 *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
135876 sqlite3VtabUnlock(pVTable);
@@ -136190,17 +136651,19 @@
136651 int addrNxt; /* Jump here to start the next IN combination */
136652 int addrSkip; /* Jump here for next iteration of skip-scan */
136653 int addrCont; /* Jump here to continue with the next loop cycle */
136654 int addrFirst; /* First instruction of interior of the loop */
136655 int addrBody; /* Beginning of the body of this loop */
136656 int regBignull; /* big-null flag reg. True if a NULL-scan is needed */
136657 int addrBignull; /* Jump here for next part of big-null scan */
136658 #ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS
136659 u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */
136660 int addrLikeRep; /* LIKE range processing address */
136661 #endif
136662 u8 iFrom; /* Which entry in the FROM clause */
136663 u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
136664 int p1, p2; /* Operands of the opcode used to end the loop */
136665 union { /* Information that depends on pWLoop->wsFlags */
136666 struct {
136667 int nIn; /* Number of entries in aInLoop[] */
136668 struct InLoop {
136669 int iCur; /* The VDBE cursor used by this IN operator */
@@ -136247,11 +136710,11 @@
136710 union {
136711 struct { /* Information for internal btree tables */
136712 u16 nEq; /* Number of equality constraints */
136713 u16 nBtm; /* Size of BTM vector */
136714 u16 nTop; /* Size of TOP vector */
136715 u16 nDistinctCol; /* Index columns used to sort for DISTINCT */
136716 Index *pIndex; /* Index used, or NULL */
136717 } btree;
136718 struct { /* Information for virtual tables */
136719 int idxNum; /* Index number */
136720 u8 needFree; /* True if sqlite3_free(idxStr) is needed */
@@ -136398,20 +136861,21 @@
136861 #define TERM_CODED 0x04 /* This term is already coded */
136862 #define TERM_COPIED 0x08 /* Has a child */
136863 #define TERM_ORINFO 0x10 /* Need to free the WhereTerm.u.pOrInfo object */
136864 #define TERM_ANDINFO 0x20 /* Need to free the WhereTerm.u.pAndInfo obj */
136865 #define TERM_OR_OK 0x40 /* Used during OR-clause processing */
136866 #ifdef SQLITE_ENABLE_STAT4
136867 # define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */
136868 #else
136869 # define TERM_VNULL 0x00 /* Disabled if not using stat4 */
136870 #endif
136871 #define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
136872 #define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
136873 #define TERM_LIKE 0x400 /* The original LIKE operator */
136874 #define TERM_IS 0x800 /* Term.pExpr is an IS operator */
136875 #define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
136876 #define TERM_NOPARTIDX 0x2000 /* Not for use to enable a partial index */
136877
136878 /*
136879 ** An instance of the WhereScan object is used as an iterator for locating
136880 ** terms in the WHERE clause that are useful to the query planner.
136881 */
@@ -136518,11 +136982,11 @@
136982 WhereInfo *pWInfo; /* Information about this WHERE */
136983 WhereClause *pWC; /* WHERE clause terms */
136984 ExprList *pOrderBy; /* ORDER BY clause */
136985 WhereLoop *pNew; /* Template WhereLoop */
136986 WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
136987 #ifdef SQLITE_ENABLE_STAT4
136988 UnpackedRecord *pRec; /* Probe for stat4 (if required) */
136989 int nRecValid; /* Number of valid fields currently in pRec */
136990 #endif
136991 unsigned int bldFlags; /* SQLITE_BLDF_* flags */
136992 unsigned int iPlanLimit; /* Search limiter */
@@ -136705,10 +137169,11 @@
137169 #define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
137170 #define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
137171 #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
137172 #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
137173 #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
137174 #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
137175
137176 #endif /* !defined(SQLITE_WHEREINT_H) */
137177
137178 /************** End of whereInt.h ********************************************/
137179 /************** Continuing where we left off in wherecode.c ******************/
@@ -137009,13 +137474,13 @@
137474
137475 /*
137476 ** Code an OP_Affinity opcode to apply the column affinity string zAff
137477 ** to the n registers starting at base.
137478 **
137479 ** As an optimization, SQLITE_AFF_BLOB and SQLITE_AFF_NONE entries (which
137480 ** are no-ops) at the beginning and end of zAff are ignored. If all entries
137481 ** in zAff are SQLITE_AFF_BLOB or SQLITE_AFF_NONE, then no code gets generated.
137482 **
137483 ** This routine makes its own copy of zAff so that the caller is free
137484 ** to modify zAff after this routine returns.
137485 */
137486 static void codeApplyAffinity(Parse *pParse, int base, int n, char *zAff){
@@ -137024,19 +137489,20 @@
137489 assert( pParse->db->mallocFailed );
137490 return;
137491 }
137492 assert( v!=0 );
137493
137494 /* Adjust base and n to skip over SQLITE_AFF_BLOB and SQLITE_AFF_NONE
137495 ** entries at the beginning and end of the affinity string.
137496 */
137497 assert( SQLITE_AFF_NONE<SQLITE_AFF_BLOB );
137498 while( n>0 && zAff[0]<=SQLITE_AFF_BLOB ){
137499 n--;
137500 base++;
137501 zAff++;
137502 }
137503 while( n>1 && zAff[n-1]<=SQLITE_AFF_BLOB ){
137504 n--;
137505 }
137506
137507 /* Code the OP_Affinity opcode if there is anything left to do. */
137508 if( n>0 ){
@@ -137807,10 +138273,11 @@
138273 ** that contains the value of pExpr.
138274 */
138275 static int whereIndexExprTransNode(Walker *p, Expr *pExpr){
138276 IdxExprTrans *pX = p->u.pIdxTrans;
138277 if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
138278 pExpr->affExpr = sqlite3ExprAffinity(pExpr);
138279 pExpr->op = TK_COLUMN;
138280 pExpr->iTable = pX->iIdxCur;
138281 pExpr->iColumn = pX->iIdxCol;
138282 pExpr->y.pTab = 0;
138283 return WRC_Prune;
@@ -138239,36 +138706,16 @@
138706 char *zStartAff; /* Affinity for start of range constraint */
138707 char *zEndAff = 0; /* Affinity for end of range constraint */
138708 u8 bSeekPastNull = 0; /* True to seek past initial nulls */
138709 u8 bStopAtNull = 0; /* Add condition to terminate at NULLs */
138710 int omitTable; /* True if we use the index only */
138711 int regBignull = 0; /* big-null flag register */
138712
138713 pIdx = pLoop->u.btree.pIndex;
138714 iIdxCur = pLevel->iIdxCur;
138715 assert( nEq>=pLoop->nSkip );
138716
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138717 /* Find any inequality constraint terms for the start and end
138718 ** of the range.
138719 */
138720 j = nEq;
138721 if( pLoop->wsFlags & WHERE_BTM_LIMIT ){
@@ -138304,10 +138751,29 @@
138751 bSeekPastNull = 1;
138752 }
138753 }
138754 }
138755 assert( pRangeEnd==0 || (pRangeEnd->wtFlags & TERM_VNULL)==0 );
138756
138757 /* If the WHERE_BIGNULL_SORT flag is set, then index column nEq uses
138758 ** a non-default "big-null" sort (either ASC NULLS LAST or DESC NULLS
138759 ** FIRST). In both cases separate ordered scans are made of those
138760 ** index entries for which the column is null and for those for which
138761 ** it is not. For an ASC sort, the non-NULL entries are scanned first.
138762 ** For DESC, NULL entries are scanned first.
138763 */
138764 if( (pLoop->wsFlags & (WHERE_TOP_LIMIT|WHERE_BTM_LIMIT))==0
138765 && (pLoop->wsFlags & WHERE_BIGNULL_SORT)!=0
138766 ){
138767 assert( bSeekPastNull==0 && nExtraReg==0 && nBtm==0 && nTop==0 );
138768 assert( pRangeEnd==0 && pRangeStart==0 );
138769 assert( pLoop->nSkip==0 );
138770 nExtraReg = 1;
138771 bSeekPastNull = 1;
138772 pLevel->regBignull = regBignull = ++pParse->nMem;
138773 pLevel->addrBignull = sqlite3VdbeMakeLabel(pParse);
138774 }
138775
138776 /* If we are doing a reverse order scan on an ascending index, or
138777 ** a forward order scan on a descending index, interchange the
138778 ** start and end terms (pRangeStart and pRangeEnd).
138779 */
@@ -138327,11 +138793,11 @@
138793 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
138794 assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );
138795 if( zStartAff && nTop ){
138796 zEndAff = sqlite3DbStrDup(db, &zStartAff[nEq]);
138797 }
138798 addrNxt = (regBignull ? pLevel->addrBignull : pLevel->addrNxt);
138799
138800 testcase( pRangeStart && (pRangeStart->eOperator & WO_LE)!=0 );
138801 testcase( pRangeStart && (pRangeStart->eOperator & WO_GE)!=0 );
138802 testcase( pRangeEnd && (pRangeEnd->eOperator & WO_LE)!=0 );
138803 testcase( pRangeEnd && (pRangeEnd->eOperator & WO_GE)!=0 );
@@ -138361,14 +138827,18 @@
138827 }else{
138828 startEq = 1;
138829 }
138830 bSeekPastNull = 0;
138831 }else if( bSeekPastNull ){
 
 
138832 startEq = 0;
138833 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
138834 start_constraints = 1;
138835 nConstraint++;
138836 }else if( regBignull ){
138837 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
138838 start_constraints = 1;
138839 nConstraint++;
138840 }
138841 codeApplyAffinity(pParse, regBase, nConstraint - bSeekPastNull, zStartAff);
138842 if( pLoop->nSkip>0 && nConstraint==pLoop->nSkip ){
138843 /* The skip-scan logic inside the call to codeAllEqualityConstraints()
138844 ** above has already left the cursor sitting on the correct row,
@@ -138375,10 +138845,15 @@
138845 ** so no further seeking is needed */
138846 }else{
138847 if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
138848 sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur);
138849 }
138850 if( regBignull ){
138851 sqlite3VdbeAddOp2(v, OP_Integer, 1, regBignull);
138852 VdbeComment((v, "NULL-scan pass ctr"));
138853 }
138854
138855 op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
138856 assert( op!=0 );
138857 sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
138858 VdbeCoverage(v);
138859 VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind );
@@ -138385,10 +138860,27 @@
138860 VdbeCoverageIf(v, op==OP_Last); testcase( op==OP_Last );
138861 VdbeCoverageIf(v, op==OP_SeekGT); testcase( op==OP_SeekGT );
138862 VdbeCoverageIf(v, op==OP_SeekGE); testcase( op==OP_SeekGE );
138863 VdbeCoverageIf(v, op==OP_SeekLE); testcase( op==OP_SeekLE );
138864 VdbeCoverageIf(v, op==OP_SeekLT); testcase( op==OP_SeekLT );
138865
138866 assert( bSeekPastNull==0 || bStopAtNull==0 );
138867 if( regBignull ){
138868 assert( bSeekPastNull==1 || bStopAtNull==1 );
138869 assert( bSeekPastNull==!bStopAtNull );
138870 assert( bStopAtNull==startEq );
138871 sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2);
138872 op = aStartOp[(nConstraint>1)*4 + 2 + bRev];
138873 sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase,
138874 nConstraint-startEq);
138875 VdbeCoverage(v);
138876 VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind );
138877 VdbeCoverageIf(v, op==OP_Last); testcase( op==OP_Last );
138878 VdbeCoverageIf(v, op==OP_SeekGE); testcase( op==OP_SeekGE );
138879 VdbeCoverageIf(v, op==OP_SeekLE); testcase( op==OP_SeekLE );
138880 assert( op==OP_Rewind || op==OP_Last || op==OP_SeekGE || op==OP_SeekLE);
138881 }
138882 }
138883
138884 /* Load the value for the inequality constraint at the end of the
138885 ** range (if any).
138886 */
@@ -138416,12 +138908,14 @@
138908 disableTerm(pLevel, pRangeEnd);
138909 }else{
138910 endEq = 1;
138911 }
138912 }else if( bStopAtNull ){
138913 if( regBignull==0 ){
138914 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
138915 endEq = 0;
138916 }
138917 nConstraint++;
138918 }
138919 sqlite3DbFree(db, zStartAff);
138920 sqlite3DbFree(db, zEndAff);
138921
@@ -138428,12 +138922,35 @@
138922 /* Top of the loop body */
138923 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
138924
138925 /* Check if the index cursor is past the end of the range. */
138926 if( nConstraint ){
138927 if( regBignull ){
138928 /* Except, skip the end-of-range check while doing the NULL-scan */
138929 sqlite3VdbeAddOp2(v, OP_IfNot, regBignull, sqlite3VdbeCurrentAddr(v)+3);
138930 VdbeComment((v, "If NULL-scan 2nd pass"));
138931 VdbeCoverage(v);
138932 }
138933 op = aEndOp[bRev*2 + endEq];
138934 sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
138935 testcase( op==OP_IdxGT ); VdbeCoverageIf(v, op==OP_IdxGT );
138936 testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE );
138937 testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
138938 testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
138939 }
138940 if( regBignull ){
138941 /* During a NULL-scan, check to see if we have reached the end of
138942 ** the NULLs */
138943 assert( bSeekPastNull==!bStopAtNull );
138944 assert( bSeekPastNull+bStopAtNull==1 );
138945 assert( nConstraint+bSeekPastNull>0 );
138946 sqlite3VdbeAddOp2(v, OP_If, regBignull, sqlite3VdbeCurrentAddr(v)+2);
138947 VdbeComment((v, "If NULL-scan 1st pass"));
138948 VdbeCoverage(v);
138949 op = aEndOp[bRev*2 + bSeekPastNull];
138950 sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase,
138951 nConstraint+bSeekPastNull);
138952 testcase( op==OP_IdxGT ); VdbeCoverageIf(v, op==OP_IdxGT );
138953 testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE );
138954 testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
138955 testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
138956 }
@@ -139061,11 +139578,11 @@
139578 if( p && ExprHasProperty(p, EP_Unlikely) ){
139579 pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;
139580 }else{
139581 pTerm->truthProb = 1;
139582 }
139583 pTerm->pExpr = sqlite3ExprSkipCollateAndLikely(p);
139584 pTerm->wtFlags = wtFlags;
139585 pTerm->pWC = pWC;
139586 pTerm->iParent = -1;
139587 memset(&pTerm->eOperator, 0,
139588 sizeof(WhereTerm) - offsetof(WhereTerm,eOperator));
@@ -139094,26 +139611,34 @@
139611 ** that the collating sequence does not change. For example:
139612 ** "Y collate NOCASE op X" becomes "X op Y" because any collation sequence on
139613 ** the left hand side of a comparison overrides any collation sequence
139614 ** attached to the right. For the same reason the EP_Collate flag
139615 ** is not commuted.
139616 **
139617 ** The return value is extra flags that are added to the WhereTerm object
139618 ** after it is commuted. The only extra flag ever added is TERM_NOPARTIDX
139619 ** which prevents the term from being used to enable a partial index if
139620 ** COLLATE changes have been made.
139621 */
139622 static u16 exprCommute(Parse *pParse, Expr *pExpr){
139623 u16 expRight = (pExpr->pRight->flags & EP_Collate);
139624 u16 expLeft = (pExpr->pLeft->flags & EP_Collate);
139625 u16 wtFlags = 0;
139626 assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );
139627 if( expRight==expLeft ){
139628 /* Either X and Y both have COLLATE operator or neither do */
139629 if( expRight ){
139630 /* Both X and Y have COLLATE operators. Make sure X is always
139631 ** used by clearing the EP_Collate flag from Y. */
139632 pExpr->pRight->flags &= ~EP_Collate;
139633 wtFlags |= TERM_NOPARTIDX;
139634 }else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){
139635 /* Neither X nor Y have COLLATE operators, but X has a non-default
139636 ** collating sequence. So add the EP_Collate marker on X to cause
139637 ** it to be searched first. */
139638 pExpr->pLeft->flags |= EP_Collate;
139639 wtFlags |= TERM_NOPARTIDX;
139640 }
139641 }
139642 SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
139643 if( pExpr->op>=TK_GT ){
139644 assert( TK_LT==TK_GT+2 );
@@ -139121,10 +139646,11 @@
139646 assert( TK_GT>TK_EQ );
139647 assert( TK_GT<TK_LE );
139648 assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );
139649 pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;
139650 }
139651 return wtFlags;
139652 }
139653
139654 /*
139655 ** Translate from TK_xx operator to WO_xx bitmask.
139656 */
@@ -140117,11 +140643,11 @@
140643 }
140644 }else{
140645 pDup = pExpr;
140646 pNew = pTerm;
140647 }
140648 pNew->wtFlags |= exprCommute(pParse, pDup);
140649 pNew->leftCursor = aiCurCol[0];
140650 pNew->u.leftColumn = aiCurCol[1];
140651 testcase( (prereqLeft | extraRight) != prereqLeft );
140652 pNew->prereqRight = prereqLeft | extraRight;
140653 pNew->prereqAll = prereqAll;
@@ -140358,12 +140884,12 @@
140884 exprAnalyze(pSrc, pWC, idxNew);
140885 markTermAsChild(pWC, idxNew, idxTerm);
140886 }
140887 }
140888
140889 #ifdef SQLITE_ENABLE_STAT4
140890 /* When sqlite_stat4 histogram data is available an operator of the
140891 ** form "x IS NOT NULL" can sometimes be evaluated more efficiently
140892 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
140893 ** virtual term of that form.
140894 **
140895 ** Note that the virtual term must be tagged with TERM_VNULL.
@@ -140370,11 +140896,11 @@
140896 */
140897 if( pExpr->op==TK_NOTNULL
140898 && pExpr->pLeft->op==TK_COLUMN
140899 && pExpr->pLeft->iColumn>=0
140900 && !ExprHasProperty(pExpr, EP_FromJoin)
140901 && OptimizationEnabled(db, SQLITE_Stat4)
140902 ){
140903 Expr *pNewExpr;
140904 Expr *pLeft = pExpr->pLeft;
140905 int idxNew;
140906 WhereTerm *pNewTerm;
@@ -140395,11 +140921,11 @@
140921 pTerm = &pWC->a[idxTerm];
140922 pTerm->wtFlags |= TERM_COPIED;
140923 pNewTerm->prereqAll = pTerm->prereqAll;
140924 }
140925 }
140926 #endif /* SQLITE_ENABLE_STAT4 */
140927
140928 /* Prevent ON clause terms of a LEFT JOIN from being used to drive
140929 ** an index for tables to the left of the join.
140930 */
140931 testcase( pTerm!=&pWC->a[idxTerm] );
@@ -140428,11 +140954,11 @@
140954 ** In the previous sentence and in the diagram, "slot[]" refers to
140955 ** the WhereClause.a[] array. The slot[] array grows as needed to contain
140956 ** all terms of the WHERE clause.
140957 */
140958 SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause *pWC, Expr *pExpr, u8 op){
140959 Expr *pE2 = sqlite3ExprSkipCollateAndLikely(pExpr);
140960 pWC->op = op;
140961 if( pE2==0 ) return;
140962 if( pE2->op!=op ){
140963 whereClauseInsert(pWC, pExpr, 0);
140964 }else{
@@ -140843,11 +141369,12 @@
141369 pScan->pIdxExpr,iCur)==0)
141370 && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
141371 ){
141372 if( (pTerm->eOperator & WO_EQUIV)!=0
141373 && pScan->nEquiv<ArraySize(pScan->aiCur)
141374 && (pX = sqlite3ExprSkipCollateAndLikely(pTerm->pExpr->pRight))->op
141375 ==TK_COLUMN
141376 ){
141377 int j;
141378 for(j=0; j<pScan->nEquiv; j++){
141379 if( pScan->aiCur[j]==pX->iTable
141380 && pScan->aiColumn[j]==pX->iColumn ){
@@ -141039,11 +141566,11 @@
141566 ){
141567 int i;
141568 const char *zColl = pIdx->azColl[iCol];
141569
141570 for(i=0; i<pList->nExpr; i++){
141571 Expr *p = sqlite3ExprSkipCollateAndLikely(pList->a[i].pExpr);
141572 if( p->op==TK_COLUMN
141573 && p->iColumn==pIdx->aiColumn[iCol]
141574 && p->iTable==iBase
141575 ){
141576 CollSeq *pColl = sqlite3ExprNNCollSeq(pParse, pList->a[i].pExpr);
@@ -141103,11 +141630,11 @@
141630 /* If any of the expressions is an IPK column on table iBase, then return
141631 ** true. Note: The (p->iTable==iBase) part of this test may be false if the
141632 ** current SELECT is a correlated sub-query.
141633 */
141634 for(i=0; i<pDistinct->nExpr; i++){
141635 Expr *p = sqlite3ExprSkipCollateAndLikely(pDistinct->a[i].pExpr);
141636 if( p->op==TK_COLUMN && p->iTable==iBase && p->iColumn<0 ) return 1;
141637 }
141638
141639 /* Loop through all indices on the table, checking each to see if it makes
141640 ** the DISTINCT qualifier redundant. It does so if:
@@ -141523,10 +142050,11 @@
142050 if( pOrderBy ){
142051 int n = pOrderBy->nExpr;
142052 for(i=0; i<n; i++){
142053 Expr *pExpr = pOrderBy->a[i].pExpr;
142054 if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;
142055 if( pOrderBy->a[i].sortFlags & KEYINFO_ORDER_BIGNULL ) break;
142056 }
142057 if( i==n){
142058 nOrderBy = n;
142059 }
142060 }
@@ -141621,11 +142149,11 @@
142149 j++;
142150 }
142151 for(i=0; i<nOrderBy; i++){
142152 Expr *pExpr = pOrderBy->a[i].pExpr;
142153 pIdxOrderBy[i].iColumn = pExpr->iColumn;
142154 pIdxOrderBy[i].desc = pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC;
142155 }
142156
142157 *pmNoOmit = mNoOmit;
142158 return pIdxInfo;
142159 }
@@ -141667,11 +142195,11 @@
142195 pVtab->zErrMsg = 0;
142196 return rc;
142197 }
142198 #endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */
142199
142200 #ifdef SQLITE_ENABLE_STAT4
142201 /*
142202 ** Estimate the location of a particular key among all keys in an
142203 ** index. Store the results in aStat as follows:
142204 **
142205 ** aStat[0] Est. number of rows less than pRec
@@ -141860,11 +142388,11 @@
142388
142389 /* Restore the pRec->nField value before returning. */
142390 pRec->nField = nField;
142391 return i;
142392 }
142393 #endif /* SQLITE_ENABLE_STAT4 */
142394
142395 /*
142396 ** If it is not NULL, pTerm is a term that provides an upper or lower
142397 ** bound on a range scan. Without considering pTerm, it is estimated
142398 ** that the scan will visit nNew rows. This function returns the number
@@ -141886,25 +142414,26 @@
142414 }
142415 return nRet;
142416 }
142417
142418
142419 #ifdef SQLITE_ENABLE_STAT4
142420 /*
142421 ** Return the affinity for a single column of an index.
142422 */
142423 SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){
142424 assert( iCol>=0 && iCol<pIdx->nColumn );
142425 if( !pIdx->zColAff ){
142426 if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;
142427 }
142428 assert( pIdx->zColAff[iCol]!=0 );
142429 return pIdx->zColAff[iCol];
142430 }
142431 #endif
142432
142433
142434 #ifdef SQLITE_ENABLE_STAT4
142435 /*
142436 ** This function is called to estimate the number of rows visited by a
142437 ** range-scan on a skip-scan index. For example:
142438 **
142439 ** CREATE INDEX i1 ON t1(a, b, c);
@@ -142006,11 +142535,11 @@
142535 sqlite3ValueFree(p2);
142536 sqlite3ValueFree(pVal);
142537
142538 return rc;
142539 }
142540 #endif /* SQLITE_ENABLE_STAT4 */
142541
142542 /*
142543 ** This function is used to estimate the number of rows that will be visited
142544 ** by scanning an index for a range of values. The range may have an upper
142545 ** bound, a lower bound, or both. The WHERE clause terms that set the upper
@@ -142059,16 +142588,16 @@
142588 ){
142589 int rc = SQLITE_OK;
142590 int nOut = pLoop->nOut;
142591 LogEst nNew;
142592
142593 #ifdef SQLITE_ENABLE_STAT4
142594 Index *p = pLoop->u.btree.pIndex;
142595 int nEq = pLoop->u.btree.nEq;
142596
142597 if( p->nSample>0 && ALWAYS(nEq<p->nSampleCol)
142598 && OptimizationEnabled(pParse->db, SQLITE_Stat4)
142599 ){
142600 if( nEq==pBuilder->nRecValid ){
142601 UnpackedRecord *pRec = pBuilder->pRec;
142602 tRowcnt a[2];
142603 int nBtm = pLoop->u.btree.nBtm;
@@ -142162,11 +142691,11 @@
142691 if( iUpper>iLower ){
142692 nNew = sqlite3LogEst(iUpper - iLower);
142693 /* TUNING: If both iUpper and iLower are derived from the same
142694 ** sample, then assume they are 4x more selective. This brings
142695 ** the estimated selectivity more in line with what it would be
142696 ** if estimated without the use of STAT4 tables. */
142697 if( iLwrIdx==iUprIdx ) nNew -= 20; assert( 20==sqlite3LogEst(4) );
142698 }else{
142699 nNew = 10; assert( 10==sqlite3LogEst(2) );
142700 }
142701 if( nNew<nOut ){
@@ -142211,16 +142740,16 @@
142740 #endif
142741 pLoop->nOut = (LogEst)nOut;
142742 return rc;
142743 }
142744
142745 #ifdef SQLITE_ENABLE_STAT4
142746 /*
142747 ** Estimate the number of rows that will be returned based on
142748 ** an equality constraint x=VALUE and where that VALUE occurs in
142749 ** the histogram data. This only works when x is the left-most
142750 ** column of an index and sqlite_stat4 histogram data is available
142751 ** for that index. When pExpr==NULL that means the constraint is
142752 ** "x IS NULL" instead of "x=VALUE".
142753 **
142754 ** Write the estimated row count into *pnRow and return SQLITE_OK.
142755 ** If unable to make an estimate, leave *pnRow unchanged and return
@@ -142274,13 +142803,13 @@
142803 p->zName, nEq-1, (int)a[1]));
142804 *pnRow = a[1];
142805
142806 return rc;
142807 }
142808 #endif /* SQLITE_ENABLE_STAT4 */
142809
142810 #ifdef SQLITE_ENABLE_STAT4
142811 /*
142812 ** Estimate the number of rows that will be returned based on
142813 ** an IN constraint where the right-hand side of the IN operator
142814 ** is a list of values. Example:
142815 **
@@ -142323,11 +142852,11 @@
142852 WHERETRACE(0x10,("IN row estimate: est=%d\n", nRowEst));
142853 }
142854 assert( pBuilder->nRecValid==nRecValid );
142855 return rc;
142856 }
142857 #endif /* SQLITE_ENABLE_STAT4 */
142858
142859
142860 #ifdef WHERETRACE_ENABLED
142861 /*
142862 ** Print the content of a WhereTerm object
@@ -142860,10 +143389,11 @@
143389 int i, j, k;
143390 LogEst iReduce = 0; /* pLoop->nOut should not exceed nRow-iReduce */
143391
143392 assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
143393 for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){
143394 assert( pTerm!=0 );
143395 if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
143396 if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
143397 if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
143398 for(j=pLoop->nLTerm-1; j>=0; j--){
143399 pX = pLoop->aLTerm[j];
@@ -143043,11 +143573,11 @@
143573 for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
143574 u16 eOp = pTerm->eOperator; /* Shorthand for pTerm->eOperator */
143575 LogEst rCostIdx;
143576 LogEst nOutUnadjusted; /* nOut before IN() and WHERE adjustments */
143577 int nIn = 0;
143578 #ifdef SQLITE_ENABLE_STAT4
143579 int nRecValid = pBuilder->nRecValid;
143580 #endif
143581 if( (eOp==WO_ISNULL || (pTerm->wtFlags&TERM_VNULL)!=0)
143582 && indexColumnNotNull(pProbe, saved_nEq)
143583 ){
@@ -143104,12 +143634,10 @@
143634 if( pNew->aLTerm[i] && pNew->aLTerm[i]->pExpr==pExpr ) nIn = 0;
143635 }
143636 }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
143637 /* "x IN (value, value, ...)" */
143638 nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
 
 
143639 }
143640 if( pProbe->hasStat1 ){
143641 LogEst M, logK, safetyMargin;
143642 /* Let:
143643 ** N = the total number of rows in the table
@@ -143201,11 +143729,11 @@
143729 ** values of nIn and nInMul. In other words, assuming that all
143730 ** "x IN(...)" terms are replaced with "x = ?". This block updates
143731 ** the value of pNew->nOut to account for pTerm (but not nIn/nInMul). */
143732 assert( pNew->nOut==saved_nOut );
143733 if( pNew->wsFlags & WHERE_COLUMN_RANGE ){
143734 /* Adjust nOut using stat4 data. Or, if there is no stat4
143735 ** data, using some other estimate. */
143736 whereRangeScanEst(pParse, pBuilder, pBtm, pTop, pNew);
143737 }else{
143738 int nEq = ++pNew->u.btree.nEq;
143739 assert( eOp & (WO_ISNULL|WO_EQ|WO_IN|WO_IS) );
@@ -143215,17 +143743,17 @@
143743 assert( (eOp & WO_IN) || nIn==0 );
143744 testcase( eOp & WO_IN );
143745 pNew->nOut += pTerm->truthProb;
143746 pNew->nOut -= nIn;
143747 }else{
143748 #ifdef SQLITE_ENABLE_STAT4
143749 tRowcnt nOut = 0;
143750 if( nInMul==0
143751 && pProbe->nSample
143752 && pNew->u.btree.nEq<=pProbe->nSampleCol
143753 && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))
143754 && OptimizationEnabled(db, SQLITE_Stat4)
143755 ){
143756 Expr *pExpr = pTerm->pExpr;
143757 if( (eOp & (WO_EQ|WO_ISNULL|WO_IS))!=0 ){
143758 testcase( eOp & WO_EQ );
143759 testcase( eOp & WO_IS );
@@ -143258,10 +143786,11 @@
143786
143787 /* Set rCostIdx to the cost of visiting selected rows in index. Add
143788 ** it to pNew->rRun, which is currently set to the cost of the index
143789 ** seek only. Then, if this is a non-covering index, add the cost of
143790 ** visiting the rows in the main table. */
143791 assert( pSrc->pTab->szTabRow>0 );
143792 rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow;
143793 pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx);
143794 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
143795 pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16);
143796 }
@@ -143283,11 +143812,11 @@
143812 && pNew->u.btree.nEq<pProbe->nColumn
143813 ){
143814 whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
143815 }
143816 pNew->nOut = saved_nOut;
143817 #ifdef SQLITE_ENABLE_STAT4
143818 pBuilder->nRecValid = nRecValid;
143819 #endif
143820 }
143821 pNew->prereq = saved_prereq;
143822 pNew->u.btree.nEq = saved_nEq;
@@ -143356,11 +143885,11 @@
143885 int ii, jj;
143886
143887 if( pIndex->bUnordered ) return 0;
143888 if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0;
143889 for(ii=0; ii<pOB->nExpr; ii++){
143890 Expr *pExpr = sqlite3ExprSkipCollateAndLikely(pOB->a[ii].pExpr);
143891 if( pExpr->op==TK_COLUMN && pExpr->iTable==iCursor ){
143892 if( pExpr->iColumn<0 ) return 1;
143893 for(jj=0; jj<pIndex->nKeyCol; jj++){
143894 if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
143895 }
@@ -143387,11 +143916,13 @@
143916 if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;
143917 pWhere = pWhere->pRight;
143918 }
143919 if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
143920 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
143921 Expr *pExpr;
143922 if( pTerm->wtFlags & TERM_NOPARTIDX ) continue;
143923 pExpr = pTerm->pExpr;
143924 if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
143925 && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
143926 ){
143927 return 1;
143928 }
@@ -143656,11 +144187,11 @@
144187 ** unique index is used (making the index functionally non-unique)
144188 ** then the sqlite_stat1 data becomes important for scoring the
144189 ** plan */
144190 pTab->tabFlags |= TF_StatsUsed;
144191 }
144192 #ifdef SQLITE_ENABLE_STAT4
144193 sqlite3Stat4ProbeFree(pBuilder->pRec);
144194 pBuilder->nRecValid = 0;
144195 pBuilder->pRec = 0;
144196 #endif
144197 }
@@ -144284,12 +144815,12 @@
144815 pLoop = pLast;
144816 }
144817 if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
144818 if( pLoop->u.vtab.isOrdered ) obSat = obDone;
144819 break;
144820 }else if( wctrlFlags & WHERE_DISTINCTBY ){
144821 pLoop->u.btree.nDistinctCol = 0;
144822 }
144823 iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
144824
144825 /* Mark off any ORDER BY term X that is a column in the table of
144826 ** the current loop for which there is term in the WHERE
@@ -144296,11 +144827,11 @@
144827 ** clause of the form X IS NULL or X=? that reference only outer
144828 ** loops.
144829 */
144830 for(i=0; i<nOrderBy; i++){
144831 if( MASKBIT(i) & obSat ) continue;
144832 pOBExpr = sqlite3ExprSkipCollateAndLikely(pOrderBy->a[i].pExpr);
144833 if( pOBExpr->op!=TK_COLUMN ) continue;
144834 if( pOBExpr->iTable!=iCur ) continue;
144835 pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
144836 ~ready, eqOpMask, 0);
144837 if( pTerm==0 ) continue;
@@ -144333,11 +144864,12 @@
144864 nKeyCol = pIndex->nKeyCol;
144865 nColumn = pIndex->nColumn;
144866 assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) );
144867 assert( pIndex->aiColumn[nColumn-1]==XN_ROWID
144868 || !HasRowid(pIndex->pTable));
144869 isOrderDistinct = IsUniqueIndex(pIndex)
144870 && (pLoop->wsFlags & WHERE_SKIPSCAN)==0;
144871 }
144872
144873 /* Loop through all columns of the index and deal with the ones
144874 ** that are not constrained by == or IN.
144875 */
@@ -144351,19 +144883,25 @@
144883 );
144884 if( j<pLoop->u.btree.nEq && j>=pLoop->nSkip ){
144885 u16 eOp = pLoop->aLTerm[j]->eOperator;
144886
144887 /* Skip over == and IS and ISNULL terms. (Also skip IN terms when
144888 ** doing WHERE_ORDERBY_LIMIT processing). Except, IS and ISNULL
144889 ** terms imply that the index is not UNIQUE NOT NULL in which case
144890 ** the loop need to be marked as not order-distinct because it can
144891 ** have repeated NULL rows.
144892 **
144893 ** If the current term is a column of an ((?,?) IN (SELECT...))
144894 ** expression for which the SELECT returns more than one column,
144895 ** check that it is the only column used by this loop. Otherwise,
144896 ** if it is one of two or more, none of the columns can be
144897 ** considered to match an ORDER BY term.
144898 */
144899 if( (eOp & eqOpMask)!=0 ){
144900 if( eOp & (WO_ISNULL|WO_IS) ){
144901 testcase( eOp & WO_ISNULL );
144902 testcase( eOp & WO_IS );
144903 testcase( isOrderDistinct );
144904 isOrderDistinct = 0;
144905 }
144906 continue;
144907 }else if( ALWAYS(eOp & WO_IN) ){
@@ -144385,11 +144923,11 @@
144923 /* Get the column number in the table (iColumn) and sort order
144924 ** (revIdx) for the j-th column of the index.
144925 */
144926 if( pIndex ){
144927 iColumn = pIndex->aiColumn[j];
144928 revIdx = pIndex->aSortOrder[j] & KEYINFO_ORDER_DESC;
144929 if( iColumn==pIndex->pTable->iPKey ) iColumn = XN_ROWID;
144930 }else{
144931 iColumn = XN_ROWID;
144932 revIdx = 0;
144933 }
@@ -144409,11 +144947,11 @@
144947 ** of the index and mark that ORDER BY term off
144948 */
144949 isMatch = 0;
144950 for(i=0; bOnce && i<nOrderBy; i++){
144951 if( MASKBIT(i) & obSat ) continue;
144952 pOBExpr = sqlite3ExprSkipCollateAndLikely(pOrderBy->a[i].pExpr);
144953 testcase( wctrlFlags & WHERE_GROUPBY );
144954 testcase( wctrlFlags & WHERE_DISTINCTBY );
144955 if( (wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY))==0 ) bOnce = 0;
144956 if( iColumn>=XN_ROWID ){
144957 if( pOBExpr->op!=TK_COLUMN ) continue;
@@ -144427,24 +144965,35 @@
144965 }
144966 if( iColumn!=XN_ROWID ){
144967 pColl = sqlite3ExprNNCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
144968 if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ) continue;
144969 }
144970 if( wctrlFlags & WHERE_DISTINCTBY ){
144971 pLoop->u.btree.nDistinctCol = j+1;
144972 }
144973 isMatch = 1;
144974 break;
144975 }
144976 if( isMatch && (wctrlFlags & WHERE_GROUPBY)==0 ){
144977 /* Make sure the sort order is compatible in an ORDER BY clause.
144978 ** Sort order is irrelevant for a GROUP BY clause. */
144979 if( revSet ){
144980 if( (rev ^ revIdx)!=(pOrderBy->a[i].sortFlags&KEYINFO_ORDER_DESC) ){
144981 isMatch = 0;
144982 }
144983 }else{
144984 rev = revIdx ^ (pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC);
144985 if( rev ) *pRevMask |= MASKBIT(iLoop);
144986 revSet = 1;
144987 }
144988 }
144989 if( isMatch && (pOrderBy->a[i].sortFlags & KEYINFO_ORDER_BIGNULL) ){
144990 if( j==pLoop->u.btree.nEq ){
144991 pLoop->wsFlags |= WHERE_BIGNULL_SORT;
144992 }else{
144993 isMatch = 0;
144994 }
144995 }
144996 if( isMatch ){
144997 if( iColumn==XN_ROWID ){
144998 testcase( distinctColumns==0 );
144999 distinctColumns = 1;
@@ -145355,10 +145904,20 @@
145904 sqlite3DebugPrintf("*** Optimizer Start *** (wctrlFlags: 0x%x",wctrlFlags);
145905 if( wctrlFlags & WHERE_USE_LIMIT ){
145906 sqlite3DebugPrintf(", limit: %d", iAuxArg);
145907 }
145908 sqlite3DebugPrintf(")\n");
145909 if( sqlite3WhereTrace & 0x100 ){
145910 Select sSelect;
145911 memset(&sSelect, 0, sizeof(sSelect));
145912 sSelect.selFlags = SF_WhereBegin;
145913 sSelect.pSrc = pTabList;
145914 sSelect.pWhere = pWhere;
145915 sSelect.pOrderBy = pOrderBy;
145916 sSelect.pEList = pResultSet;
145917 sqlite3TreeViewSelect(0, &sSelect, 0);
145918 }
145919 }
145920 if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
145921 sqlite3WhereClausePrint(sWLB.pWC);
145922 }
145923 #endif
@@ -145631,10 +146190,11 @@
146190 if( op ){
146191 sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);
146192 sqlite3VdbeSetP4KeyInfo(pParse, pIx);
146193 if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0
146194 && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0
146195 && (pLoop->wsFlags & WHERE_BIGNULL_SORT)==0
146196 && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0
146197 && pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED
146198 ){
146199 sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */
146200 }
@@ -145748,11 +146308,11 @@
146308 int n;
146309 if( pWInfo->eDistinct==WHERE_DISTINCT_ORDERED
146310 && i==pWInfo->nLevel-1 /* Ticket [ef9318757b152e3] 2017-10-21 */
146311 && (pLoop->wsFlags & WHERE_INDEXED)!=0
146312 && (pIdx = pLoop->u.btree.pIndex)->hasStat1
146313 && (n = pLoop->u.btree.nDistinctCol)>0
146314 && pIdx->aiRowLogEst[n]>=36
146315 ){
146316 int r1 = pParse->nMem+1;
146317 int j, op;
146318 for(j=0; j<n; j++){
@@ -145772,10 +146332,15 @@
146332 sqlite3VdbeChangeP5(v, pLevel->p5);
146333 VdbeCoverage(v);
146334 VdbeCoverageIf(v, pLevel->op==OP_Next);
146335 VdbeCoverageIf(v, pLevel->op==OP_Prev);
146336 VdbeCoverageIf(v, pLevel->op==OP_VNext);
146337 if( pLevel->regBignull ){
146338 sqlite3VdbeResolveLabel(v, pLevel->addrBignull);
146339 sqlite3VdbeAddOp2(v, OP_DecrJumpZero, pLevel->regBignull, pLevel->p2-1);
146340 VdbeCoverage(v);
146341 }
146342 #ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT
146343 if( addrSeek ) sqlite3VdbeJumpHere(v, addrSeek);
146344 #endif
146345 }else{
146346 sqlite3VdbeResolveLabel(v, pLevel->addrCont);
@@ -146711,10 +147276,12 @@
147276 ** expression (*ppExpr) in place.
147277 */
147278 static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){
147279 struct WindowRewrite *p = pWalker->u.pRewrite;
147280 Parse *pParse = pWalker->pParse;
147281 assert( p!=0 );
147282 assert( p->pWin!=0 );
147283
147284 /* If this function is being called from within a scalar sub-select
147285 ** that used by the SELECT statement being processed, only process
147286 ** TK_COLUMN expressions that refer to it (the outer SELECT). Do
147287 ** not process aggregates or window functions at all, as they belong
@@ -146810,10 +147377,11 @@
147377 ExprList **ppSub /* IN/OUT: Sub-select expression-list */
147378 ){
147379 Walker sWalker;
147380 WindowRewrite sRewrite;
147381
147382 assert( pWin!=0 );
147383 memset(&sWalker, 0, sizeof(Walker));
147384 memset(&sRewrite, 0, sizeof(WindowRewrite));
147385
147386 sRewrite.pSub = *ppSub;
147387 sRewrite.pWin = pWin;
@@ -146848,11 +147416,11 @@
147416 if( bIntToNull && pDup && pDup->op==TK_INTEGER ){
147417 pDup->op = TK_NULL;
147418 pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
147419 }
147420 pList = sqlite3ExprListAppend(pParse, pList, pDup);
147421 if( pList ) pList->a[nInit+i].sortFlags = pAppend->a[i].sortFlags;
147422 }
147423 }
147424 return pList;
147425 }
147426
@@ -146894,15 +147462,18 @@
147462 /* Create the ORDER BY clause for the sub-select. This is the concatenation
147463 ** of the window PARTITION and ORDER BY clauses. Then, if this makes it
147464 ** redundant, remove the ORDER BY from the parent SELECT. */
147465 pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);
147466 pSort = exprListAppendList(pParse, pSort, pMWin->pOrderBy, 1);
147467 if( pSort && p->pOrderBy && p->pOrderBy->nExpr<=pSort->nExpr ){
147468 int nSave = pSort->nExpr;
147469 pSort->nExpr = p->pOrderBy->nExpr;
147470 if( sqlite3ExprListCompare(pSort, p->pOrderBy, -1)==0 ){
147471 sqlite3ExprListDelete(db, p->pOrderBy);
147472 p->pOrderBy = 0;
147473 }
147474 pSort->nExpr = nSave;
147475 }
147476
147477 /* Assign a cursor number for the ephemeral table used to buffer rows.
147478 ** The OpenEphemeral instruction is coded later, after it is known how
147479 ** many columns the table will have. */
@@ -146954,11 +147525,11 @@
147525 if( p->pSrc ){
147526 Table *pTab2;
147527 p->pSrc->a[0].pSelect = pSub;
147528 sqlite3SrcListAssignCursors(pParse, p->pSrc);
147529 pSub->selFlags |= SF_Expanded;
147530 pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
147531 if( pTab2==0 ){
147532 rc = SQLITE_NOMEM;
147533 }else{
147534 memcpy(pTab, pTab2, sizeof(Table));
147535 pTab->tabFlags |= TF_Ephemeral;
@@ -146976,16 +147547,29 @@
147547 sqlite3DbFree(db, pTab);
147548 }
147549
147550 return rc;
147551 }
147552
147553 /*
147554 ** Unlink the Window object from the Select to which it is attached,
147555 ** if it is attached.
147556 */
147557 SQLITE_PRIVATE void sqlite3WindowUnlinkFromSelect(Window *p){
147558 if( p->ppThis ){
147559 *p->ppThis = p->pNextWin;
147560 if( p->pNextWin ) p->pNextWin->ppThis = p->ppThis;
147561 p->ppThis = 0;
147562 }
147563 }
147564
147565 /*
147566 ** Free the Window object passed as the second argument.
147567 */
147568 SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3 *db, Window *p){
147569 if( p ){
147570 sqlite3WindowUnlinkFromSelect(p);
147571 sqlite3ExprDelete(db, p->pFilter);
147572 sqlite3ExprListDelete(db, p->pPartition);
147573 sqlite3ExprListDelete(db, p->pOrderBy);
147574 sqlite3ExprDelete(db, p->pEnd);
147575 sqlite3ExprDelete(db, p->pStart);
@@ -147159,40 +147743,59 @@
147743 ** Attach window object pWin to expression p.
147744 */
147745 SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
147746 if( p ){
147747 assert( p->op==TK_FUNCTION );
147748 assert( pWin );
147749 p->y.pWin = pWin;
147750 ExprSetProperty(p, EP_WinFunc);
147751 pWin->pOwner = p;
147752 if( (p->flags & EP_Distinct) && pWin->eFrmType!=TK_FILTER ){
147753 sqlite3ErrorMsg(pParse,
147754 "DISTINCT is not supported for window functions"
147755 );
 
 
 
147756 }
147757 }else{
147758 sqlite3WindowDelete(pParse->db, pWin);
147759 }
147760 }
147761
147762 /*
147763 ** Possibly link window pWin into the list at pSel->pWin (window functions
147764 ** to be processed as part of SELECT statement pSel). The window is linked
147765 ** in if either (a) there are no other windows already linked to this
147766 ** SELECT, or (b) the windows already linked use a compatible window frame.
147767 */
147768 SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin){
147769 if( 0==pSel->pWin
147770 || 0==sqlite3WindowCompare(0, pSel->pWin, pWin, 0)
147771 ){
147772 pWin->pNextWin = pSel->pWin;
147773 if( pSel->pWin ){
147774 pSel->pWin->ppThis = &pWin->pNextWin;
147775 }
147776 pSel->pWin = pWin;
147777 pWin->ppThis = &pSel->pWin;
147778 }
147779 }
147780
147781 /*
147782 ** Return 0 if the two window objects are identical, or non-zero otherwise.
147783 ** Identical window objects can be processed in a single scan.
147784 */
147785 SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, int bFilter){
147786 if( p1->eFrmType!=p2->eFrmType ) return 1;
147787 if( p1->eStart!=p2->eStart ) return 1;
147788 if( p1->eEnd!=p2->eEnd ) return 1;
147789 if( p1->eExclude!=p2->eExclude ) return 1;
147790 if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
147791 if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1;
147792 if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1;
147793 if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1;
147794 if( bFilter ){
147795 if( sqlite3ExprCompare(pParse, p1->pFilter, p2->pFilter, -1) ) return 1;
147796 }
147797 return 0;
147798 }
147799
147800
147801 /*
@@ -147240,12 +147843,12 @@
147843 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0);
147844 pWin->csrApp = pParse->nTab++;
147845 pWin->regApp = pParse->nMem+1;
147846 pParse->nMem += 3;
147847 if( pKeyInfo && pWin->pFunc->zName[1]=='i' ){
147848 assert( pKeyInfo->aSortFlags[0]==0 );
147849 pKeyInfo->aSortFlags[0] = KEYINFO_ORDER_DESC;
147850 }
147851 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2);
147852 sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);
147853 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
147854 }
@@ -147360,10 +147963,12 @@
147963 FuncDef *pFunc = pWin->pFunc;
147964 int regArg;
147965 int nArg = windowArgCount(pWin);
147966 int i;
147967
147968 assert( bInverse==0 || pWin->eStart!=TK_UNBOUNDED );
147969
147970 for(i=0; i<nArg; i++){
147971 if( i!=1 || pFunc->zName!=nth_valueName ){
147972 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
147973 }else{
147974 sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+i, reg+i);
@@ -147422,23 +148027,82 @@
148027 }
148028 }
148029
148030 typedef struct WindowCodeArg WindowCodeArg;
148031 typedef struct WindowCsrAndReg WindowCsrAndReg;
148032
148033 /*
148034 ** See comments above struct WindowCodeArg.
148035 */
148036 struct WindowCsrAndReg {
148037 int csr; /* Cursor number */
148038 int reg; /* First in array of peer values */
148039 };
148040
148041 /*
148042 ** A single instance of this structure is allocated on the stack by
148043 ** sqlite3WindowCodeStep() and a pointer to it passed to the various helper
148044 ** routines. This is to reduce the number of arguments required by each
148045 ** helper function.
148046 **
148047 ** regArg:
148048 ** Each window function requires an accumulator register (just as an
148049 ** ordinary aggregate function does). This variable is set to the first
148050 ** in an array of accumulator registers - one for each window function
148051 ** in the WindowCodeArg.pMWin list.
148052 **
148053 ** eDelete:
148054 ** The window functions implementation sometimes caches the input rows
148055 ** that it processes in a temporary table. If it is not zero, this
148056 ** variable indicates when rows may be removed from the temp table (in
148057 ** order to reduce memory requirements - it would always be safe just
148058 ** to leave them there). Possible values for eDelete are:
148059 **
148060 ** WINDOW_RETURN_ROW:
148061 ** An input row can be discarded after it is returned to the caller.
148062 **
148063 ** WINDOW_AGGINVERSE:
148064 ** An input row can be discarded after the window functions xInverse()
148065 ** callbacks have been invoked in it.
148066 **
148067 ** WINDOW_AGGSTEP:
148068 ** An input row can be discarded after the window functions xStep()
148069 ** callbacks have been invoked in it.
148070 **
148071 ** start,current,end
148072 ** Consider a window-frame similar to the following:
148073 **
148074 ** (ORDER BY a, b GROUPS BETWEEN 2 PRECEDING AND 2 FOLLOWING)
148075 **
148076 ** The windows functions implmentation caches the input rows in a temp
148077 ** table, sorted by "a, b" (it actually populates the cache lazily, and
148078 ** aggressively removes rows once they are no longer required, but that's
148079 ** a mere detail). It keeps three cursors open on the temp table. One
148080 ** (current) that points to the next row to return to the query engine
148081 ** once its window function values have been calculated. Another (end)
148082 ** points to the next row to call the xStep() method of each window function
148083 ** on (so that it is 2 groups ahead of current). And a third (start) that
148084 ** points to the next row to call the xInverse() method of each window
148085 ** function on.
148086 **
148087 ** Each cursor (start, current and end) consists of a VDBE cursor
148088 ** (WindowCsrAndReg.csr) and an array of registers (starting at
148089 ** WindowCodeArg.reg) that always contains a copy of the peer values
148090 ** read from the corresponding cursor.
148091 **
148092 ** Depending on the window-frame in question, all three cursors may not
148093 ** be required. In this case both WindowCodeArg.csr and reg are set to
148094 ** 0.
148095 */
148096 struct WindowCodeArg {
148097 Parse *pParse; /* Parse context */
148098 Window *pMWin; /* First in list of functions being processed */
148099 Vdbe *pVdbe; /* VDBE object */
148100 int addrGosub; /* OP_Gosub to this address to return one row */
148101 int regGosub; /* Register used with OP_Gosub(addrGosub) */
148102 int regArg; /* First in array of accumulator registers */
148103 int eDelete; /* See above */
148104
148105 WindowCsrAndReg start;
148106 WindowCsrAndReg current;
148107 WindowCsrAndReg end;
148108 };
@@ -147530,12 +148194,14 @@
148194
148195 int nPeer;
148196 int lblNext;
148197 int lblBrk;
148198 int addrNext;
148199 int csr;
148200
148201 assert( pMWin!=0 );
148202 csr = pMWin->csrApp;
148203 nPeer = (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
148204
148205 lblNext = sqlite3VdbeMakeLabel(pParse);
148206 lblBrk = sqlite3VdbeMakeLabel(pParse);
148207
@@ -147775,67 +148441,147 @@
148441 }
148442
148443 /*
148444 ** This function is called as part of generating VM programs for RANGE
148445 ** offset PRECEDING/FOLLOWING frame boundaries. Assuming "ASC" order for
148446 ** the ORDER BY term in the window, and that argument op is OP_Ge, it generates
148447 ** code equivalent to:
148448 **
148449 ** if( csr1.peerVal + regVal >= csr2.peerVal ) goto lbl;
148450 **
148451 ** The value of parameter op may also be OP_Gt or OP_Le. In these cases the
148452 ** operator in the above pseudo-code is replaced with ">" or "<=", respectively.
148453 **
148454 ** If the sort-order for the ORDER BY term in the window is DESC, then the
148455 ** comparison is reversed. Instead of adding regVal to csr1.peerVal, it is
148456 ** subtracted. And the comparison operator is inverted to - ">=" becomes "<=",
148457 ** ">" becomes "<", and so on. So, with DESC sort order, if the argument op
148458 ** is OP_Ge, the generated code is equivalent to:
148459 **
148460 ** if( csr1.peerVal - regVal <= csr2.peerVal ) goto lbl;
148461 **
148462 ** A special type of arithmetic is used such that if csr1.peerVal is not
148463 ** a numeric type (real or integer), then the result of the addition addition
148464 ** or subtraction is a a copy of csr1.peerVal.
148465 */
148466 static void windowCodeRangeTest(
148467 WindowCodeArg *p,
148468 int op, /* OP_Ge, OP_Gt, or OP_Le */
148469 int csr1, /* Cursor number for cursor 1 */
148470 int regVal, /* Register containing non-negative number */
148471 int csr2, /* Cursor number for cursor 2 */
148472 int lbl /* Jump destination if condition is true */
148473 ){
148474 Parse *pParse = p->pParse;
148475 Vdbe *v = sqlite3GetVdbe(pParse);
148476 ExprList *pOrderBy = p->pMWin->pOrderBy; /* ORDER BY clause for window */
148477 int reg1 = sqlite3GetTempReg(pParse); /* Reg. for csr1.peerVal+regVal */
148478 int reg2 = sqlite3GetTempReg(pParse); /* Reg. for csr2.peerVal */
148479 int regString = ++pParse->nMem; /* Reg. for constant value '' */
148480 int arith = OP_Add; /* OP_Add or OP_Subtract */
148481 int addrGe; /* Jump destination */
148482
148483 assert( op==OP_Ge || op==OP_Gt || op==OP_Le );
148484 assert( pOrderBy && pOrderBy->nExpr==1 );
148485 if( pOrderBy->a[0].sortFlags & KEYINFO_ORDER_DESC ){
148486 switch( op ){
148487 case OP_Ge: op = OP_Le; break;
148488 case OP_Gt: op = OP_Lt; break;
148489 default: assert( op==OP_Le ); op = OP_Ge; break;
148490 }
148491 arith = OP_Subtract;
148492 }
148493
148494 /* Read the peer-value from each cursor into a register */
148495 windowReadPeerValues(p, csr1, reg1);
148496 windowReadPeerValues(p, csr2, reg2);
148497
148498 VdbeModuleComment((v, "CodeRangeTest: if( R%d %s R%d %s R%d ) goto lbl",
148499 reg1, (arith==OP_Add ? "+" : "-"), regVal,
148500 ((op==OP_Ge) ? ">=" : (op==OP_Le) ? "<=" : (op==OP_Gt) ? ">" : "<"), reg2
148501 ));
148502
148503 /* Register reg1 currently contains csr1.peerVal (the peer-value from csr1).
148504 ** This block adds (or subtracts for DESC) the numeric value in regVal
148505 ** from it. Or, if reg1 is not numeric (it is a NULL, a text value or a blob),
148506 ** then leave reg1 as it is. In pseudo-code, this is implemented as:
148507 **
148508 ** if( reg1>='' ) goto addrGe;
148509 ** reg1 = reg1 +/- regVal
148510 ** addrGe:
148511 **
148512 ** Since all strings and blobs are greater-than-or-equal-to an empty string,
148513 ** the add/subtract is skipped for these, as required. If reg1 is a NULL,
148514 ** then the arithmetic is performed, but since adding or subtracting from
148515 ** NULL is always NULL anyway, this case is handled as required too. */
148516 sqlite3VdbeAddOp4(v, OP_String8, 0, regString, 0, "", P4_STATIC);
148517 addrGe = sqlite3VdbeAddOp3(v, OP_Ge, regString, 0, reg1);
148518 VdbeCoverage(v);
148519 sqlite3VdbeAddOp3(v, arith, regVal, reg1, reg1);
148520 sqlite3VdbeJumpHere(v, addrGe);
148521
148522 /* If the BIGNULL flag is set for the ORDER BY, then it is required to
148523 ** consider NULL values to be larger than all other values, instead of
148524 ** the usual smaller. The VDBE opcodes OP_Ge and so on do not handle this
148525 ** (and adding that capability causes a performance regression), so
148526 ** instead if the BIGNULL flag is set then cases where either reg1 or
148527 ** reg2 are NULL are handled separately in the following block. The code
148528 ** generated is equivalent to:
148529 **
148530 ** if( reg1 IS NULL ){
148531 ** if( op==OP_Ge ) goto lbl;
148532 ** if( op==OP_Gt && reg2 IS NOT NULL ) goto lbl;
148533 ** if( op==OP_Le && reg2 IS NULL ) goto lbl;
148534 ** }else if( reg2 IS NULL ){
148535 ** if( op==OP_Le ) goto lbl;
148536 ** }
148537 **
148538 ** Additionally, if either reg1 or reg2 are NULL but the jump to lbl is
148539 ** not taken, control jumps over the comparison operator coded below this
148540 ** block. */
148541 if( pOrderBy->a[0].sortFlags & KEYINFO_ORDER_BIGNULL ){
148542 /* This block runs if reg1 contains a NULL. */
148543 int addr = sqlite3VdbeAddOp1(v, OP_NotNull, reg1); VdbeCoverage(v);
148544 switch( op ){
148545 case OP_Ge:
148546 sqlite3VdbeAddOp2(v, OP_Goto, 0, lbl);
148547 break;
148548 case OP_Gt:
148549 sqlite3VdbeAddOp2(v, OP_NotNull, reg2, lbl);
148550 VdbeCoverage(v);
148551 break;
148552 case OP_Le:
148553 sqlite3VdbeAddOp2(v, OP_IsNull, reg2, lbl);
148554 VdbeCoverage(v);
148555 break;
148556 default: assert( op==OP_Lt ); /* no-op */ break;
148557 }
148558 sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+3);
148559
148560 /* This block runs if reg1 is not NULL, but reg2 is. */
148561 sqlite3VdbeJumpHere(v, addr);
148562 sqlite3VdbeAddOp2(v, OP_IsNull, reg2, lbl); VdbeCoverage(v);
148563 if( op==OP_Gt || op==OP_Ge ){
148564 sqlite3VdbeChangeP2(v, -1, sqlite3VdbeCurrentAddr(v)+1);
148565 }
148566 }
148567
148568 /* Compare registers reg2 and reg1, taking the jump if required. Note that
148569 ** control skips over this test if the BIGNULL flag is set and either
148570 ** reg1 or reg2 contain a NULL value. */
148571 sqlite3VdbeAddOp3(v, op, reg2, lbl, reg1); VdbeCoverage(v);
148572 sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
148573
148574 assert( op==OP_Ge || op==OP_Gt || op==OP_Lt || op==OP_Le );
148575 testcase(op==OP_Ge); VdbeCoverageIf(v, op==OP_Ge);
148576 testcase(op==OP_Lt); VdbeCoverageIf(v, op==OP_Lt);
148577 testcase(op==OP_Le); VdbeCoverageIf(v, op==OP_Le);
148578 testcase(op==OP_Gt); VdbeCoverageIf(v, op==OP_Gt);
 
148579 sqlite3ReleaseTempReg(pParse, reg1);
148580 sqlite3ReleaseTempReg(pParse, reg2);
148581
148582 VdbeModuleComment((v, "CodeRangeTest: end"));
148583 }
148584
148585 /*
148586 ** Helper function for sqlite3WindowCodeStep(). Each call to this function
148587 ** generates VM code for a single RETURN_ROW, AGGSTEP or AGGINVERSE
@@ -147980,10 +148726,11 @@
148726 pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
148727 pNew->eFrmType = p->eFrmType;
148728 pNew->eEnd = p->eEnd;
148729 pNew->eStart = p->eStart;
148730 pNew->eExclude = p->eExclude;
148731 pNew->regResult = p->regResult;
148732 pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);
148733 pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);
148734 pNew->pOwner = pOwner;
148735 }
148736 }
@@ -148786,10 +149533,11 @@
149533 ** For a compound SELECT statement, make sure p->pPrior->pNext==p for
149534 ** all elements in the list. And make sure list length does not exceed
149535 ** SQLITE_LIMIT_COMPOUND_SELECT.
149536 */
149537 static void parserDoubleLinkSelect(Parse *pParse, Select *p){
149538 assert( p!=0 );
149539 if( p->pPrior ){
149540 Select *pNext = 0, *pLoop;
149541 int mxSelect, cnt = 0;
149542 for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){
149543 pLoop->pNext = pNext;
@@ -148812,11 +149560,11 @@
149560 static Expr *tokenExpr(Parse *pParse, int op, Token t){
149561 Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);
149562 if( p ){
149563 /* memset(p, 0, sizeof(Expr)); */
149564 p->op = (u8)op;
149565 p->affExpr = 0;
149566 p->flags = EP_Leaf;
149567 p->iAgg = -1;
149568 p->pLeft = p->pRight = 0;
149569 p->x.pList = 0;
149570 p->pAggInfo = 0;
@@ -148939,32 +149687,32 @@
149687 #ifndef INTERFACE
149688 # define INTERFACE 1
149689 #endif
149690 /************* Begin control #defines *****************************************/
149691 #define YYCODETYPE unsigned short int
149692 #define YYNOCODE 307
149693 #define YYACTIONTYPE unsigned short int
149694 #define YYWILDCARD 98
149695 #define sqlite3ParserTOKENTYPE Token
149696 typedef union {
149697 int yyinit;
149698 sqlite3ParserTOKENTYPE yy0;
149699 const char* yy8;
149700 Select* yy25;
149701 int yy32;
149702 Expr* yy46;
149703 struct FrameBound yy57;
149704 u8 yy118;
149705 ExprList* yy138;
149706 Upsert* yy288;
149707 With* yy297;
149708 IdList* yy406;
149709 Window* yy455;
149710 struct {int value; int mask;} yy495;
149711 TriggerStep* yy527;
149712 struct TrigEvent yy572;
149713 SrcList* yy609;
149714 } YYMINORTYPE;
149715 #ifndef YYSTACKDEPTH
149716 #define YYSTACKDEPTH 100
149717 #endif
149718 #define sqlite3ParserARG_SDECL
@@ -148976,21 +149724,21 @@
149724 #define sqlite3ParserCTX_PDECL ,Parse *pParse
149725 #define sqlite3ParserCTX_PARAM ,pParse
149726 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
149727 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
149728 #define YYFALLBACK 1
149729 #define YYNSTATE 543
149730 #define YYNRULE 381
149731 #define YYNTOKEN 179
149732 #define YY_MAX_SHIFT 542
149733 #define YY_MIN_SHIFTREDUCE 790
149734 #define YY_MAX_SHIFTREDUCE 1170
149735 #define YY_ERROR_ACTION 1171
149736 #define YY_ACCEPT_ACTION 1172
149737 #define YY_NO_ACTION 1173
149738 #define YY_MIN_REDUCE 1174
149739 #define YY_MAX_REDUCE 1554
149740 /************* End control #defines *******************************************/
149741 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
149742
149743 /* Define the yytestcase() macro to be a no-op if is not already defined
149744 ** otherwise.
@@ -149053,605 +149801,577 @@
149801 ** yy_reduce_ofst[] For each state, the offset into yy_action for
149802 ** shifting non-terminals after a reduce.
149803 ** yy_default[] Default action for each state.
149804 **
149805 *********** Begin parsing tables **********************************************/
149806 #define YY_ACTTAB_COUNT (1913)
149807 static const YYACTIONTYPE yy_action[] = {
149808 /* 0 */ 537, 339, 537, 1241, 1220, 537, 12, 537, 112, 109,
149809 /* 10 */ 209, 537, 1241, 537, 1205, 462, 112, 109, 209, 386,
149810 /* 20 */ 338, 462, 42, 42, 42, 42, 445, 42, 42, 70,
149811 /* 30 */ 70, 922, 1208, 70, 70, 70, 70, 1443, 403, 923,
149812 /* 40 */ 531, 531, 531, 119, 120, 110, 1148, 1148, 991, 994,
149813 /* 50 */ 984, 984, 117, 117, 118, 118, 118, 118, 425, 386,
149814 /* 60 */ 1498, 542, 2, 1176, 1442, 519, 141, 1518, 289, 519,
149815 /* 70 */ 134, 519, 95, 259, 495, 1215, 189, 1254, 518, 494,
149816 /* 80 */ 484, 437, 296, 119, 120, 110, 1148, 1148, 991, 994,
149817 /* 90 */ 984, 984, 117, 117, 118, 118, 118, 118, 270, 116,
149818 /* 100 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
149819 /* 110 */ 264, 264, 264, 264, 423, 1479, 352, 1481, 123, 351,
149820 /* 120 */ 1479, 508, 1094, 534, 1034, 534, 1099, 386, 1099, 239,
149821 /* 130 */ 206, 112, 109, 209, 96, 1094, 376, 219, 1094, 116,
149822 /* 140 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
149823 /* 150 */ 480, 119, 120, 110, 1148, 1148, 991, 994, 984, 984,
149824 /* 160 */ 117, 117, 118, 118, 118, 118, 353, 422, 1407, 264,
149825 /* 170 */ 264, 114, 114, 114, 113, 418, 883, 121, 416, 416,
149826 /* 180 */ 416, 882, 534, 116, 116, 116, 116, 115, 115, 114,
149827 /* 190 */ 114, 114, 113, 418, 212, 415, 414, 386, 443, 383,
149828 /* 200 */ 382, 118, 118, 118, 118, 111, 177, 116, 116, 116,
149829 /* 210 */ 116, 115, 115, 114, 114, 114, 113, 418, 112, 109,
149830 /* 220 */ 209, 119, 120, 110, 1148, 1148, 991, 994, 984, 984,
149831 /* 230 */ 117, 117, 118, 118, 118, 118, 386, 438, 312, 1163,
149832 /* 240 */ 1155, 80, 1155, 1127, 514, 79, 116, 116, 116, 116,
149833 /* 250 */ 115, 115, 114, 114, 114, 113, 418, 514, 428, 418,
149834 /* 260 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
149835 /* 270 */ 117, 118, 118, 118, 118, 428, 427, 116, 116, 116,
149836 /* 280 */ 116, 115, 115, 114, 114, 114, 113, 418, 115, 115,
149837 /* 290 */ 114, 114, 114, 113, 418, 1127, 1127, 1128, 1129, 1094,
149838 /* 300 */ 258, 258, 192, 386, 408, 371, 1168, 326, 118, 118,
149839 /* 310 */ 118, 118, 1094, 534, 374, 1094, 116, 116, 116, 116,
149840 /* 320 */ 115, 115, 114, 114, 114, 113, 418, 119, 120, 110,
149841 /* 330 */ 1148, 1148, 991, 994, 984, 984, 117, 117, 118, 118,
149842 /* 340 */ 118, 118, 386, 354, 445, 428, 829, 238, 1127, 1128,
149843 /* 350 */ 1129, 515, 1466, 116, 116, 116, 116, 115, 115, 114,
149844 /* 360 */ 114, 114, 113, 418, 1127, 1467, 119, 120, 110, 1148,
149845 /* 370 */ 1148, 991, 994, 984, 984, 117, 117, 118, 118, 118,
149846 /* 380 */ 118, 1169, 82, 116, 116, 116, 116, 115, 115, 114,
149847 /* 390 */ 114, 114, 113, 418, 405, 112, 109, 209, 161, 445,
149848 /* 400 */ 250, 267, 336, 478, 331, 477, 236, 951, 1127, 386,
149849 /* 410 */ 888, 1521, 329, 822, 852, 162, 274, 1127, 1128, 1129,
149850 /* 420 */ 338, 169, 116, 116, 116, 116, 115, 115, 114, 114,
149851 /* 430 */ 114, 113, 418, 119, 120, 110, 1148, 1148, 991, 994,
149852 /* 440 */ 984, 984, 117, 117, 118, 118, 118, 118, 386, 438,
149853 /* 450 */ 312, 1502, 1112, 1176, 161, 288, 528, 311, 289, 883,
149854 /* 460 */ 134, 1127, 1128, 1129, 882, 537, 143, 1254, 288, 528,
149855 /* 470 */ 297, 275, 119, 120, 110, 1148, 1148, 991, 994, 984,
149856 /* 480 */ 984, 117, 117, 118, 118, 118, 118, 70, 70, 116,
149857 /* 490 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
149858 /* 500 */ 264, 264, 12, 264, 264, 395, 1127, 483, 1473, 1094,
149859 /* 510 */ 204, 482, 6, 534, 1258, 386, 534, 1474, 825, 972,
149860 /* 520 */ 504, 6, 1094, 500, 95, 1094, 534, 219, 116, 116,
149861 /* 530 */ 116, 116, 115, 115, 114, 114, 114, 113, 418, 119,
149862 /* 540 */ 120, 110, 1148, 1148, 991, 994, 984, 984, 117, 117,
149863 /* 550 */ 118, 118, 118, 118, 386, 1339, 971, 422, 956, 1127,
149864 /* 560 */ 1128, 1129, 231, 512, 1473, 475, 472, 471, 6, 113,
149865 /* 570 */ 418, 825, 962, 298, 503, 470, 961, 452, 119, 120,
149866 /* 580 */ 110, 1148, 1148, 991, 994, 984, 984, 117, 117, 118,
149867 /* 590 */ 118, 118, 118, 395, 537, 116, 116, 116, 116, 115,
149868 /* 600 */ 115, 114, 114, 114, 113, 418, 202, 961, 961, 963,
149869 /* 610 */ 231, 971, 1127, 475, 472, 471, 13, 13, 951, 1127,
149870 /* 620 */ 834, 386, 1207, 470, 399, 183, 447, 962, 462, 162,
149871 /* 630 */ 397, 961, 1246, 1246, 116, 116, 116, 116, 115, 115,
149872 /* 640 */ 114, 114, 114, 113, 418, 119, 120, 110, 1148, 1148,
149873 /* 650 */ 991, 994, 984, 984, 117, 117, 118, 118, 118, 118,
149874 /* 660 */ 386, 271, 961, 961, 963, 1127, 1128, 1129, 311, 433,
149875 /* 670 */ 299, 1406, 1127, 1128, 1129, 178, 1471, 138, 162, 32,
149876 /* 680 */ 6, 1127, 288, 528, 119, 120, 110, 1148, 1148, 991,
149877 /* 690 */ 994, 984, 984, 117, 117, 118, 118, 118, 118, 909,
149878 /* 700 */ 390, 116, 116, 116, 116, 115, 115, 114, 114, 114,
149879 /* 710 */ 113, 418, 1127, 429, 817, 537, 1127, 265, 265, 981,
149880 /* 720 */ 981, 992, 995, 324, 1055, 93, 520, 5, 338, 537,
149881 /* 730 */ 534, 288, 528, 1522, 1127, 1128, 1129, 70, 70, 1056,
149882 /* 740 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
149883 /* 750 */ 418, 70, 70, 1495, 1057, 537, 98, 1244, 1244, 264,
149884 /* 760 */ 264, 908, 371, 1076, 1127, 1127, 1128, 1129, 817, 1127,
149885 /* 770 */ 1128, 1129, 534, 519, 140, 863, 386, 13, 13, 456,
149886 /* 780 */ 192, 193, 521, 453, 319, 864, 322, 284, 365, 430,
149887 /* 790 */ 985, 402, 379, 1077, 1548, 101, 386, 1548, 3, 395,
149888 /* 800 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
149889 /* 810 */ 117, 118, 118, 118, 118, 386, 451, 1127, 1128, 1129,
149890 /* 820 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
149891 /* 830 */ 117, 118, 118, 118, 118, 1127, 1354, 1412, 1169, 119,
149892 /* 840 */ 108, 110, 1148, 1148, 991, 994, 984, 984, 117, 117,
149893 /* 850 */ 118, 118, 118, 118, 1412, 1414, 116, 116, 116, 116,
149894 /* 860 */ 115, 115, 114, 114, 114, 113, 418, 272, 535, 1075,
149895 /* 870 */ 877, 877, 337, 1492, 309, 462, 116, 116, 116, 116,
149896 /* 880 */ 115, 115, 114, 114, 114, 113, 418, 537, 1127, 1128,
149897 /* 890 */ 1129, 537, 360, 537, 356, 116, 116, 116, 116, 115,
149898 /* 900 */ 115, 114, 114, 114, 113, 418, 386, 264, 264, 13,
149899 /* 910 */ 13, 273, 1127, 13, 13, 13, 13, 304, 1253, 386,
149900 /* 920 */ 534, 1077, 1549, 404, 1412, 1549, 496, 277, 451, 186,
149901 /* 930 */ 1252, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
149902 /* 940 */ 117, 118, 118, 118, 118, 110, 1148, 1148, 991, 994,
149903 /* 950 */ 984, 984, 117, 117, 118, 118, 118, 118, 105, 529,
149904 /* 960 */ 537, 4, 1339, 264, 264, 1127, 1128, 1129, 1039, 1039,
149905 /* 970 */ 459, 795, 796, 797, 536, 532, 534, 242, 301, 807,
149906 /* 980 */ 303, 462, 69, 69, 451, 1353, 116, 116, 116, 116,
149907 /* 990 */ 115, 115, 114, 114, 114, 113, 418, 1075, 419, 116,
149908 /* 1000 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
149909 /* 1010 */ 526, 537, 1146, 192, 350, 105, 529, 537, 4, 497,
149910 /* 1020 */ 162, 337, 1492, 310, 1249, 385, 1550, 372, 9, 462,
149911 /* 1030 */ 242, 400, 532, 13, 13, 499, 971, 843, 436, 70,
149912 /* 1040 */ 70, 359, 103, 103, 8, 339, 278, 187, 278, 104,
149913 /* 1050 */ 1127, 419, 539, 538, 1339, 419, 961, 302, 1339, 1172,
149914 /* 1060 */ 1, 1, 542, 2, 1176, 1146, 1146, 526, 476, 289,
149915 /* 1070 */ 30, 134, 317, 288, 528, 285, 844, 1014, 1254, 276,
149916 /* 1080 */ 1472, 506, 410, 1194, 6, 207, 505, 961, 961, 963,
149917 /* 1090 */ 964, 27, 449, 971, 415, 414, 234, 233, 232, 103,
149918 /* 1100 */ 103, 31, 1152, 1127, 1128, 1129, 104, 1154, 419, 539,
149919 /* 1110 */ 538, 264, 264, 961, 1399, 1153, 264, 264, 1470, 1146,
149920 /* 1120 */ 537, 216, 6, 401, 534, 1197, 392, 458, 406, 534,
149921 /* 1130 */ 537, 485, 358, 537, 261, 537, 1339, 907, 219, 1155,
149922 /* 1140 */ 467, 1155, 50, 50, 961, 961, 963, 964, 27, 1497,
149923 /* 1150 */ 1116, 421, 70, 70, 268, 70, 70, 13, 13, 369,
149924 /* 1160 */ 369, 368, 253, 366, 264, 264, 804, 235, 422, 105,
149925 /* 1170 */ 529, 516, 4, 287, 487, 510, 493, 534, 486, 213,
149926 /* 1180 */ 1055, 294, 490, 384, 1127, 450, 532, 338, 413, 293,
149927 /* 1190 */ 522, 417, 335, 1036, 509, 1056, 107, 1036, 16, 16,
149928 /* 1200 */ 1469, 1094, 334, 1105, 6, 411, 1145, 264, 264, 419,
149929 /* 1210 */ 1057, 102, 511, 100, 1094, 264, 264, 1094, 922, 215,
149930 /* 1220 */ 534, 526, 907, 264, 264, 208, 923, 154, 534, 457,
149931 /* 1230 */ 156, 525, 391, 142, 218, 506, 534, 1127, 1128, 1129,
149932 /* 1240 */ 507, 139, 1131, 38, 214, 530, 392, 971, 329, 1454,
149933 /* 1250 */ 907, 1105, 537, 103, 103, 105, 529, 537, 4, 537,
149934 /* 1260 */ 104, 424, 419, 539, 538, 537, 502, 961, 517, 537,
149935 /* 1270 */ 1072, 537, 532, 373, 54, 54, 288, 528, 387, 55,
149936 /* 1280 */ 55, 15, 15, 288, 528, 17, 136, 44, 44, 1451,
149937 /* 1290 */ 537, 56, 56, 57, 57, 419, 1131, 291, 961, 961,
149938 /* 1300 */ 963, 964, 27, 393, 163, 537, 426, 526, 263, 206,
149939 /* 1310 */ 208, 517, 58, 58, 235, 440, 842, 841, 197, 105,
149940 /* 1320 */ 529, 506, 4, 1033, 439, 1033, 505, 59, 59, 308,
149941 /* 1330 */ 849, 850, 95, 971, 537, 907, 532, 948, 832, 103,
149942 /* 1340 */ 103, 105, 529, 537, 4, 1021, 104, 537, 419, 539,
149943 /* 1350 */ 538, 1116, 421, 961, 537, 268, 60, 60, 532, 419,
149944 /* 1360 */ 369, 369, 368, 253, 366, 61, 61, 804, 965, 45,
149945 /* 1370 */ 45, 526, 537, 1032, 1277, 1032, 46, 46, 537, 391,
149946 /* 1380 */ 213, 419, 294, 266, 961, 961, 963, 964, 27, 292,
149947 /* 1390 */ 293, 295, 832, 526, 48, 48, 1290, 971, 1289, 1021,
149948 /* 1400 */ 49, 49, 432, 103, 103, 887, 953, 537, 1457, 241,
149949 /* 1410 */ 104, 305, 419, 539, 538, 925, 926, 961, 444, 971,
149950 /* 1420 */ 215, 241, 965, 1224, 537, 103, 103, 1431, 154, 62,
149951 /* 1430 */ 62, 156, 104, 1430, 419, 539, 538, 97, 529, 961,
149952 /* 1440 */ 4, 537, 454, 537, 314, 214, 63, 63, 961, 961,
149953 /* 1450 */ 963, 964, 27, 537, 532, 446, 1286, 318, 241, 537,
149954 /* 1460 */ 321, 323, 325, 64, 64, 14, 14, 1237, 537, 1223,
149955 /* 1470 */ 961, 961, 963, 964, 27, 65, 65, 419, 537, 387,
149956 /* 1480 */ 537, 125, 125, 537, 288, 528, 537, 1486, 537, 526,
149957 /* 1490 */ 66, 66, 313, 524, 537, 95, 468, 1221, 1511, 237,
149958 /* 1500 */ 51, 51, 67, 67, 330, 68, 68, 426, 52, 52,
149959 /* 1510 */ 149, 149, 1222, 340, 341, 971, 150, 150, 1298, 463,
149960 /* 1520 */ 327, 103, 103, 95, 537, 1338, 1273, 537, 104, 537,
149961 /* 1530 */ 419, 539, 538, 1284, 537, 961, 268, 283, 523, 1344,
149962 /* 1540 */ 1204, 369, 369, 368, 253, 366, 75, 75, 804, 53,
149963 /* 1550 */ 53, 71, 71, 537, 1196, 537, 126, 126, 537, 1017,
149964 /* 1560 */ 537, 213, 237, 294, 537, 1185, 961, 961, 963, 964,
149965 /* 1570 */ 27, 293, 537, 1184, 537, 72, 72, 127, 127, 1186,
149966 /* 1580 */ 128, 128, 124, 124, 1505, 537, 148, 148, 537, 256,
149967 /* 1590 */ 195, 537, 1270, 537, 147, 147, 132, 132, 537, 11,
149968 /* 1600 */ 537, 215, 537, 199, 343, 345, 347, 131, 131, 154,
149969 /* 1610 */ 129, 129, 156, 130, 130, 74, 74, 537, 370, 1323,
149970 /* 1620 */ 76, 76, 73, 73, 43, 43, 214, 431, 211, 1331,
149971 /* 1630 */ 300, 916, 880, 815, 241, 107, 137, 307, 881, 47,
149972 /* 1640 */ 47, 107, 473, 378, 203, 448, 333, 1403, 1220, 1402,
149973 /* 1650 */ 349, 190, 527, 191, 363, 198, 1508, 1163, 245, 165,
149974 /* 1660 */ 387, 1450, 1448, 1160, 78, 288, 528, 1408, 81, 394,
149975 /* 1670 */ 82, 442, 175, 159, 167, 93, 1328, 35, 1320, 434,
149976 /* 1680 */ 170, 171, 172, 173, 435, 466, 221, 375, 426, 377,
149977 /* 1690 */ 1334, 179, 455, 441, 1397, 225, 87, 36, 461, 1419,
149978 /* 1700 */ 316, 257, 227, 184, 320, 464, 228, 479, 1187, 229,
149979 /* 1710 */ 380, 1240, 1239, 407, 1238, 1212, 834, 332, 1231, 381,
149980 /* 1720 */ 409, 1211, 204, 1210, 1491, 498, 1520, 1281, 92, 281,
149981 /* 1730 */ 1230, 489, 282, 492, 342, 243, 1282, 344, 244, 1280,
149982 /* 1740 */ 346, 412, 1279, 1477, 348, 122, 1476, 517, 10, 357,
149983 /* 1750 */ 286, 1305, 1304, 99, 1383, 94, 501, 251, 1193, 34,
149984 /* 1760 */ 1263, 355, 540, 194, 1262, 361, 362, 1122, 252, 254,
149985 /* 1770 */ 255, 388, 541, 1182, 1177, 151, 1435, 389, 1436, 1434,
149986 /* 1780 */ 1433, 791, 152, 135, 279, 200, 201, 420, 196, 77,
149987 /* 1790 */ 153, 290, 269, 210, 1031, 133, 1029, 945, 166, 155,
149988 /* 1800 */ 217, 168, 866, 306, 220, 1045, 174, 949, 157, 396,
149989 /* 1810 */ 83, 398, 176, 84, 85, 164, 86, 158, 1048, 222,
149990 /* 1820 */ 223, 1044, 144, 18, 224, 315, 1037, 180, 241, 460,
149991 /* 1830 */ 1157, 226, 181, 37, 806, 465, 334, 230, 328, 469,
149992 /* 1840 */ 182, 88, 474, 19, 20, 160, 89, 280, 145, 90,
149993 /* 1850 */ 481, 845, 1110, 146, 997, 205, 1080, 39, 91, 40,
149994 /* 1860 */ 488, 1081, 915, 491, 260, 262, 185, 910, 240, 107,
149995 /* 1870 */ 1100, 1096, 1098, 1104, 21, 1084, 33, 513, 247, 22,
149996 /* 1880 */ 23, 24, 1103, 25, 188, 95, 1012, 998, 996, 26,
149997 /* 1890 */ 1000, 1054, 7, 1053, 1001, 246, 28, 41, 533, 966,
149998 /* 1900 */ 816, 106, 29, 367, 248, 249, 1513, 1512, 364, 1117,
149999 /* 1910 */ 1173, 1173, 876,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150000 };
150001 static const YYCODETYPE yy_lookahead[] = {
150002 /* 0 */ 187, 187, 187, 216, 217, 187, 206, 187, 264, 265,
150003 /* 10 */ 266, 187, 225, 187, 209, 187, 264, 265, 266, 19,
150004 /* 20 */ 187, 187, 209, 210, 209, 210, 187, 209, 210, 209,
150005 /* 30 */ 210, 31, 209, 209, 210, 209, 210, 285, 224, 39,
150006 /* 40 */ 203, 204, 205, 43, 44, 45, 46, 47, 48, 49,
150007 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 230, 19,
150008 /* 60 */ 181, 182, 183, 184, 230, 245, 233, 208, 189, 245,
150009 /* 70 */ 191, 245, 26, 206, 254, 216, 276, 198, 254, 198,
150010 /* 80 */ 254, 281, 187, 43, 44, 45, 46, 47, 48, 49,
150011 /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 259, 99,
150012 /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150013 /* 110 */ 231, 232, 231, 232, 286, 302, 303, 302, 22, 304,
150014 /* 120 */ 302, 303, 76, 244, 11, 244, 86, 19, 88, 248,
150015 /* 130 */ 249, 264, 265, 266, 26, 89, 198, 258, 92, 99,
150016 /* 140 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150017 /* 150 */ 105, 43, 44, 45, 46, 47, 48, 49, 50, 51,
150018 /* 160 */ 52, 53, 54, 55, 56, 57, 212, 288, 273, 231,
150019 /* 170 */ 232, 105, 106, 107, 108, 109, 131, 69, 203, 204,
150020 /* 180 */ 205, 136, 244, 99, 100, 101, 102, 103, 104, 105,
150021 /* 190 */ 106, 107, 108, 109, 15, 103, 104, 19, 260, 103,
150022 /* 200 */ 104, 54, 55, 56, 57, 58, 22, 99, 100, 101,
150023 /* 210 */ 102, 103, 104, 105, 106, 107, 108, 109, 264, 265,
150024 /* 220 */ 266, 43, 44, 45, 46, 47, 48, 49, 50, 51,
150025 /* 230 */ 52, 53, 54, 55, 56, 57, 19, 124, 125, 60,
150026 /* 240 */ 148, 24, 150, 59, 187, 67, 99, 100, 101, 102,
150027 /* 250 */ 103, 104, 105, 106, 107, 108, 109, 187, 187, 109,
150028 /* 260 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150029 /* 270 */ 53, 54, 55, 56, 57, 204, 205, 99, 100, 101,
150030 /* 280 */ 102, 103, 104, 105, 106, 107, 108, 109, 103, 104,
150031 /* 290 */ 105, 106, 107, 108, 109, 59, 112, 113, 114, 76,
150032 /* 300 */ 231, 232, 187, 19, 19, 22, 23, 23, 54, 55,
150033 /* 310 */ 56, 57, 89, 244, 199, 92, 99, 100, 101, 102,
150034 /* 320 */ 103, 104, 105, 106, 107, 108, 109, 43, 44, 45,
150035 /* 330 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
150036 /* 340 */ 56, 57, 19, 212, 187, 274, 23, 26, 112, 113,
150037 /* 350 */ 114, 294, 295, 99, 100, 101, 102, 103, 104, 105,
150038 /* 360 */ 106, 107, 108, 109, 59, 295, 43, 44, 45, 46,
150039 /* 370 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
150040 /* 380 */ 57, 98, 146, 99, 100, 101, 102, 103, 104, 105,
150041 /* 390 */ 106, 107, 108, 109, 109, 264, 265, 266, 187, 187,
150042 /* 400 */ 115, 116, 117, 118, 119, 120, 121, 73, 59, 19,
150043 /* 410 */ 105, 23, 127, 23, 26, 81, 259, 112, 113, 114,
150044 /* 420 */ 187, 72, 99, 100, 101, 102, 103, 104, 105, 106,
150045 /* 430 */ 107, 108, 109, 43, 44, 45, 46, 47, 48, 49,
150046 /* 440 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 124,
150047 /* 450 */ 125, 182, 23, 184, 187, 134, 135, 123, 189, 131,
150048 /* 460 */ 191, 112, 113, 114, 136, 187, 233, 198, 134, 135,
150049 /* 470 */ 198, 259, 43, 44, 45, 46, 47, 48, 49, 50,
150050 /* 480 */ 51, 52, 53, 54, 55, 56, 57, 209, 210, 99,
150051 /* 490 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150052 /* 500 */ 231, 232, 206, 231, 232, 187, 59, 296, 297, 76,
150053 /* 510 */ 160, 161, 301, 244, 232, 19, 244, 297, 59, 23,
150054 /* 520 */ 87, 301, 89, 245, 26, 92, 244, 258, 99, 100,
150055 /* 530 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 43,
150056 /* 540 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
150057 /* 550 */ 54, 55, 56, 57, 19, 187, 97, 288, 23, 112,
150058 /* 560 */ 113, 114, 115, 296, 297, 118, 119, 120, 301, 108,
150059 /* 570 */ 109, 112, 113, 255, 141, 128, 117, 281, 43, 44,
150060 /* 580 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
150061 /* 590 */ 55, 56, 57, 187, 187, 99, 100, 101, 102, 103,
150062 /* 600 */ 104, 105, 106, 107, 108, 109, 26, 148, 149, 150,
150063 /* 610 */ 115, 97, 59, 118, 119, 120, 209, 210, 73, 59,
150064 /* 620 */ 122, 19, 209, 128, 256, 72, 187, 113, 187, 81,
150065 /* 630 */ 223, 117, 227, 228, 99, 100, 101, 102, 103, 104,
150066 /* 640 */ 105, 106, 107, 108, 109, 43, 44, 45, 46, 47,
150067 /* 650 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
150068 /* 660 */ 19, 255, 148, 149, 150, 112, 113, 114, 123, 124,
150069 /* 670 */ 125, 230, 112, 113, 114, 22, 297, 22, 81, 22,
150070 /* 680 */ 301, 59, 134, 135, 43, 44, 45, 46, 47, 48,
150071 /* 690 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 139,
150072 /* 700 */ 192, 99, 100, 101, 102, 103, 104, 105, 106, 107,
150073 /* 710 */ 108, 109, 59, 116, 59, 187, 59, 231, 232, 46,
150074 /* 720 */ 47, 48, 49, 16, 12, 145, 198, 22, 187, 187,
150075 /* 730 */ 244, 134, 135, 222, 112, 113, 114, 209, 210, 27,
150076 /* 740 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
150077 /* 750 */ 109, 209, 210, 187, 42, 187, 154, 227, 228, 231,
150078 /* 760 */ 232, 139, 22, 23, 59, 112, 113, 114, 113, 112,
150079 /* 770 */ 113, 114, 244, 245, 233, 63, 19, 209, 210, 271,
150080 /* 780 */ 187, 24, 254, 275, 77, 73, 79, 245, 195, 260,
150081 /* 790 */ 117, 223, 199, 22, 23, 154, 19, 26, 22, 187,
150082 /* 800 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150083 /* 810 */ 53, 54, 55, 56, 57, 19, 187, 112, 113, 114,
150084 /* 820 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150085 /* 830 */ 53, 54, 55, 56, 57, 59, 263, 187, 98, 43,
150086 /* 840 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
150087 /* 850 */ 54, 55, 56, 57, 204, 205, 99, 100, 101, 102,
150088 /* 860 */ 103, 104, 105, 106, 107, 108, 109, 255, 130, 98,
150089 /* 870 */ 132, 133, 299, 300, 198, 187, 99, 100, 101, 102,
150090 /* 880 */ 103, 104, 105, 106, 107, 108, 109, 187, 112, 113,
150091 /* 890 */ 114, 187, 241, 187, 243, 99, 100, 101, 102, 103,
150092 /* 900 */ 104, 105, 106, 107, 108, 109, 19, 231, 232, 209,
150093 /* 910 */ 210, 282, 59, 209, 210, 209, 210, 16, 230, 19,
150094 /* 920 */ 244, 22, 23, 223, 274, 26, 19, 223, 187, 223,
150095 /* 930 */ 198, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150096 /* 940 */ 53, 54, 55, 56, 57, 45, 46, 47, 48, 49,
150097 /* 950 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 20,
150098 /* 960 */ 187, 22, 187, 231, 232, 112, 113, 114, 123, 124,
150099 /* 970 */ 125, 7, 8, 9, 187, 36, 244, 24, 77, 21,
150100 /* 980 */ 79, 187, 209, 210, 187, 263, 99, 100, 101, 102,
150101 /* 990 */ 103, 104, 105, 106, 107, 108, 109, 98, 59, 99,
150102 /* 1000 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150103 /* 1010 */ 71, 187, 59, 187, 187, 19, 20, 187, 22, 112,
150104 /* 1020 */ 81, 299, 300, 282, 230, 199, 291, 292, 22, 187,
150105 /* 1030 */ 24, 256, 36, 209, 210, 187, 97, 35, 80, 209,
150106 /* 1040 */ 210, 268, 103, 104, 48, 187, 220, 223, 222, 110,
150107 /* 1050 */ 59, 112, 113, 114, 187, 59, 117, 156, 187, 179,
150108 /* 1060 */ 180, 181, 182, 183, 184, 59, 113, 71, 66, 189,
150109 /* 1070 */ 22, 191, 230, 134, 135, 245, 74, 119, 198, 282,
150110 /* 1080 */ 297, 85, 224, 198, 301, 187, 90, 148, 149, 150,
150111 /* 1090 */ 151, 152, 19, 97, 103, 104, 123, 124, 125, 103,
150112 /* 1100 */ 104, 53, 111, 112, 113, 114, 110, 116, 112, 113,
150113 /* 1110 */ 114, 231, 232, 117, 156, 124, 231, 232, 297, 113,
150114 /* 1120 */ 187, 24, 301, 256, 244, 201, 202, 256, 126, 244,
150115 /* 1130 */ 187, 198, 187, 187, 23, 187, 187, 26, 258, 148,
150116 /* 1140 */ 19, 150, 209, 210, 148, 149, 150, 151, 152, 0,
150117 /* 1150 */ 1, 2, 209, 210, 5, 209, 210, 209, 210, 10,
150118 /* 1160 */ 11, 12, 13, 14, 231, 232, 17, 46, 288, 19,
150119 /* 1170 */ 20, 223, 22, 236, 198, 66, 187, 244, 245, 30,
150120 /* 1180 */ 12, 32, 198, 246, 59, 112, 36, 187, 245, 40,
150121 /* 1190 */ 198, 245, 117, 29, 85, 27, 26, 33, 209, 210,
150122 /* 1200 */ 297, 76, 127, 94, 301, 256, 26, 231, 232, 59,
150123 /* 1210 */ 42, 153, 87, 155, 89, 231, 232, 92, 31, 70,
150124 /* 1220 */ 244, 71, 26, 231, 232, 114, 39, 78, 244, 65,
150125 /* 1230 */ 81, 63, 111, 233, 137, 85, 244, 112, 113, 114,
150126 /* 1240 */ 90, 22, 59, 24, 95, 201, 202, 97, 127, 187,
150127 /* 1250 */ 139, 142, 187, 103, 104, 19, 20, 187, 22, 187,
150128 /* 1260 */ 110, 187, 112, 113, 114, 187, 141, 117, 141, 187,
150129 /* 1270 */ 23, 187, 36, 26, 209, 210, 134, 135, 129, 209,
150130 /* 1280 */ 210, 209, 210, 134, 135, 22, 159, 209, 210, 187,
150131 /* 1290 */ 187, 209, 210, 209, 210, 59, 113, 187, 148, 149,
150132 /* 1300 */ 150, 151, 152, 289, 290, 187, 157, 71, 248, 249,
150133 /* 1310 */ 114, 141, 209, 210, 46, 125, 116, 117, 138, 19,
150134 /* 1320 */ 20, 85, 22, 148, 61, 150, 90, 209, 210, 23,
150135 /* 1330 */ 7, 8, 26, 97, 187, 139, 36, 147, 59, 103,
150136 /* 1340 */ 104, 19, 20, 187, 22, 59, 110, 187, 112, 113,
150137 /* 1350 */ 114, 1, 2, 117, 187, 5, 209, 210, 36, 59,
150138 /* 1360 */ 10, 11, 12, 13, 14, 209, 210, 17, 59, 209,
150139 /* 1370 */ 210, 71, 187, 148, 250, 150, 209, 210, 187, 111,
150140 /* 1380 */ 30, 59, 32, 22, 148, 149, 150, 151, 152, 187,
150141 /* 1390 */ 40, 187, 113, 71, 209, 210, 187, 97, 187, 113,
150142 /* 1400 */ 209, 210, 187, 103, 104, 105, 23, 187, 187, 26,
150143 /* 1410 */ 110, 187, 112, 113, 114, 83, 84, 117, 23, 97,
150144 /* 1420 */ 70, 26, 113, 218, 187, 103, 104, 187, 78, 209,
150145 /* 1430 */ 210, 81, 110, 187, 112, 113, 114, 19, 20, 117,
150146 /* 1440 */ 22, 187, 187, 187, 187, 95, 209, 210, 148, 149,
150147 /* 1450 */ 150, 151, 152, 187, 36, 23, 187, 187, 26, 187,
150148 /* 1460 */ 187, 187, 187, 209, 210, 209, 210, 187, 187, 218,
150149 /* 1470 */ 148, 149, 150, 151, 152, 209, 210, 59, 187, 129,
150150 /* 1480 */ 187, 209, 210, 187, 134, 135, 187, 306, 187, 71,
150151 /* 1490 */ 209, 210, 23, 228, 187, 26, 23, 187, 137, 26,
150152 /* 1500 */ 209, 210, 209, 210, 187, 209, 210, 157, 209, 210,
150153 /* 1510 */ 209, 210, 218, 187, 187, 97, 209, 210, 187, 278,
150154 /* 1520 */ 23, 103, 104, 26, 187, 187, 187, 187, 110, 187,
150155 /* 1530 */ 112, 113, 114, 187, 187, 117, 5, 247, 187, 187,
150156 /* 1540 */ 187, 10, 11, 12, 13, 14, 209, 210, 17, 209,
150157 /* 1550 */ 210, 209, 210, 187, 187, 187, 209, 210, 187, 23,
150158 /* 1560 */ 187, 30, 26, 32, 187, 187, 148, 149, 150, 151,
150159 /* 1570 */ 152, 40, 187, 187, 187, 209, 210, 209, 210, 187,
150160 /* 1580 */ 209, 210, 209, 210, 187, 187, 209, 210, 187, 277,
150161 /* 1590 */ 234, 187, 247, 187, 209, 210, 209, 210, 187, 235,
150162 /* 1600 */ 187, 70, 187, 207, 247, 247, 247, 209, 210, 78,
150163 /* 1610 */ 209, 210, 81, 209, 210, 209, 210, 187, 185, 238,
150164 /* 1620 */ 209, 210, 209, 210, 209, 210, 95, 251, 287, 238,
150165 /* 1630 */ 251, 23, 23, 23, 26, 26, 26, 283, 23, 209,
150166 /* 1640 */ 210, 26, 213, 238, 221, 283, 212, 212, 217, 212,
150167 /* 1650 */ 251, 241, 270, 241, 237, 235, 190, 60, 137, 287,
150168 /* 1660 */ 129, 194, 194, 38, 284, 134, 135, 273, 284, 194,
150169 /* 1670 */ 146, 111, 22, 43, 226, 145, 262, 261, 238, 18,
150170 /* 1680 */ 229, 229, 229, 229, 194, 18, 193, 238, 157, 262,
150171 /* 1690 */ 226, 226, 194, 238, 238, 193, 153, 261, 62, 280,
150172 /* 1700 */ 279, 194, 193, 22, 194, 214, 193, 111, 194, 193,
150173 /* 1710 */ 214, 211, 211, 64, 211, 211, 122, 211, 219, 214,
150174 /* 1720 */ 109, 213, 160, 211, 300, 140, 211, 253, 111, 272,
150175 /* 1730 */ 219, 214, 272, 214, 252, 194, 253, 252, 91, 253,
150176 /* 1740 */ 252, 82, 253, 305, 252, 144, 305, 141, 22, 194,
150177 /* 1750 */ 269, 257, 257, 153, 267, 143, 142, 25, 197, 26,
150178 /* 1760 */ 242, 241, 196, 240, 242, 239, 238, 13, 188, 188,
150179 /* 1770 */ 6, 293, 186, 186, 186, 200, 206, 293, 206, 206,
150180 /* 1780 */ 206, 4, 200, 215, 215, 207, 207, 3, 22, 206,
150181 /* 1790 */ 200, 158, 96, 15, 23, 16, 23, 135, 146, 126,
150182 /* 1800 */ 24, 138, 20, 16, 140, 1, 138, 147, 126, 61,
150183 /* 1810 */ 53, 37, 146, 53, 53, 290, 53, 126, 112, 34,
150184 /* 1820 */ 137, 1, 5, 22, 111, 156, 68, 68, 26, 41,
150185 /* 1830 */ 75, 137, 111, 24, 20, 19, 127, 121, 23, 67,
150186 /* 1840 */ 22, 22, 67, 22, 22, 37, 22, 67, 23, 145,
150187 /* 1850 */ 22, 28, 23, 23, 23, 137, 23, 22, 26, 22,
150188 /* 1860 */ 24, 23, 112, 24, 23, 23, 22, 139, 34, 26,
150189 /* 1870 */ 75, 88, 86, 75, 34, 23, 22, 24, 22, 34,
150190 /* 1880 */ 34, 34, 93, 34, 26, 26, 23, 23, 23, 34,
150191 /* 1890 */ 23, 23, 44, 23, 11, 26, 22, 22, 26, 23,
150192 /* 1900 */ 23, 22, 22, 15, 137, 137, 137, 137, 23, 1,
150193 /* 1910 */ 307, 307, 131, 307, 307, 307, 307, 307, 307, 307,
150194 /* 1920 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150195 /* 1930 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150196 /* 1940 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150197 /* 1950 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150198 /* 1960 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150199 /* 1970 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150200 /* 1980 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150201 /* 1990 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150202 /* 2000 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150203 /* 2010 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150204 /* 2020 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150205 /* 2030 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150206 /* 2040 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150207 /* 2050 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150208 /* 2060 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150209 /* 2070 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150210 /* 2080 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150211 /* 2090 */ 307, 307,
150212 };
150213 #define YY_SHIFT_COUNT (542)
 
 
 
 
 
 
 
150214 #define YY_SHIFT_MIN (0)
150215 #define YY_SHIFT_MAX (1908)
150216 static const unsigned short int yy_shift_ofst[] = {
150217 /* 0 */ 1350, 1149, 1531, 939, 939, 548, 996, 1150, 1236, 1322,
150218 /* 10 */ 1322, 1322, 334, 0, 0, 178, 777, 1322, 1322, 1322,
150219 /* 20 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150220 /* 30 */ 991, 991, 1125, 1125, 447, 597, 548, 548, 548, 548,
150221 /* 40 */ 548, 548, 40, 108, 217, 284, 323, 390, 429, 496,
150222 /* 50 */ 535, 602, 641, 757, 777, 777, 777, 777, 777, 777,
150223 /* 60 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777,
150224 /* 70 */ 777, 777, 796, 777, 887, 900, 900, 1300, 1322, 1322,
150225 /* 80 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150226 /* 90 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150227 /* 100 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150228 /* 110 */ 1418, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150229 /* 120 */ 1322, 1322, 1322, 1322, 147, 254, 254, 254, 254, 254,
150230 /* 130 */ 84, 185, 66, 853, 958, 1121, 853, 92, 92, 853,
150231 /* 140 */ 321, 321, 321, 321, 325, 350, 350, 461, 150, 1913,
150232 /* 150 */ 1913, 285, 285, 285, 236, 184, 349, 184, 184, 712,
150233 /* 160 */ 712, 433, 553, 771, 899, 853, 853, 853, 853, 853,
150234 /* 170 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 853,
150235 /* 180 */ 853, 853, 853, 853, 853, 853, 46, 46, 853, 113,
150236 /* 190 */ 223, 223, 1183, 1183, 1127, 1142, 1913, 1913, 1913, 459,
150237 /* 200 */ 514, 514, 653, 495, 657, 305, 705, 560, 622, 776,
150238 /* 210 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 545,
150239 /* 220 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 853,
150240 /* 230 */ 853, 853, 1002, 1002, 1002, 853, 853, 853, 853, 1111,
150241 /* 240 */ 853, 853, 853, 1006, 1109, 853, 853, 1168, 853, 853,
150242 /* 250 */ 853, 853, 853, 853, 853, 853, 845, 1164, 738, 953,
150243 /* 260 */ 953, 953, 953, 1196, 738, 738, 45, 96, 964, 179,
150244 /* 270 */ 580, 907, 907, 1073, 580, 580, 1073, 498, 388, 1268,
150245 /* 280 */ 1187, 1187, 1187, 907, 1170, 1170, 1058, 1180, 328, 1219,
150246 /* 290 */ 1597, 1521, 1521, 1625, 1625, 1521, 1524, 1560, 1650, 1630,
150247 /* 300 */ 1530, 1661, 1661, 1661, 1661, 1521, 1667, 1530, 1530, 1560,
150248 /* 310 */ 1650, 1630, 1630, 1530, 1521, 1667, 1543, 1636, 1521, 1667,
150249 /* 320 */ 1681, 1521, 1667, 1521, 1667, 1681, 1596, 1596, 1596, 1649,
150250 /* 330 */ 1681, 1596, 1594, 1596, 1649, 1596, 1596, 1562, 1681, 1611,
150251 /* 340 */ 1611, 1681, 1585, 1617, 1585, 1617, 1585, 1617, 1585, 1617,
150252 /* 350 */ 1521, 1647, 1647, 1659, 1659, 1601, 1606, 1726, 1521, 1600,
150253 /* 360 */ 1601, 1612, 1614, 1530, 1732, 1733, 1754, 1754, 1764, 1764,
150254 /* 370 */ 1764, 1913, 1913, 1913, 1913, 1913, 1913, 1913, 1913, 1913,
150255 /* 380 */ 1913, 1913, 1913, 1913, 1913, 1913, 673, 901, 283, 740,
150256 /* 390 */ 707, 973, 655, 1247, 1048, 1097, 1190, 1306, 1263, 1383,
150257 /* 400 */ 1395, 1432, 1469, 1473, 1497, 1279, 1200, 1323, 1075, 1286,
150258 /* 410 */ 1536, 1608, 1332, 1609, 1175, 1225, 1610, 1615, 1309, 1361,
150259 /* 420 */ 1777, 1784, 1766, 1633, 1778, 1696, 1779, 1771, 1773, 1662,
150260 /* 430 */ 1652, 1673, 1776, 1663, 1782, 1664, 1787, 1804, 1668, 1660,
150261 /* 440 */ 1682, 1748, 1774, 1666, 1757, 1760, 1761, 1763, 1691, 1706,
150262 /* 450 */ 1785, 1683, 1820, 1817, 1801, 1713, 1669, 1758, 1802, 1759,
150263 /* 460 */ 1755, 1788, 1694, 1721, 1809, 1814, 1816, 1709, 1716, 1818,
150264 /* 470 */ 1772, 1819, 1821, 1815, 1822, 1775, 1823, 1824, 1780, 1808,
150265 /* 480 */ 1825, 1704, 1828, 1829, 1830, 1831, 1832, 1833, 1835, 1836,
150266 /* 490 */ 1838, 1837, 1839, 1718, 1841, 1842, 1750, 1834, 1844, 1728,
150267 /* 500 */ 1843, 1840, 1845, 1846, 1847, 1783, 1795, 1786, 1848, 1798,
150268 /* 510 */ 1789, 1849, 1852, 1854, 1853, 1858, 1859, 1855, 1863, 1843,
150269 /* 520 */ 1864, 1865, 1867, 1868, 1869, 1870, 1856, 1883, 1874, 1875,
150270 /* 530 */ 1876, 1877, 1879, 1880, 1872, 1781, 1767, 1768, 1769, 1770,
150271 /* 540 */ 1885, 1888, 1908,
150272 };
150273 #define YY_REDUCE_COUNT (385)
150274 #define YY_REDUCE_MIN (-256)
150275 #define YY_REDUCE_MAX (1590)
150276 static const short yy_reduce_ofst[] = {
150277 /* 0 */ 880, -121, 269, 528, 933, -119, -187, -185, -182, -180,
150278 /* 10 */ -176, -174, -62, -46, 131, -248, -133, 407, 568, 700,
150279 /* 20 */ 704, 278, 706, 824, 542, 830, 948, 773, 943, 946,
150280 /* 30 */ 71, 650, 211, 267, 826, 272, 676, 732, 885, 976,
150281 /* 40 */ 984, 992, -256, -256, -256, -256, -256, -256, -256, -256,
150282 /* 50 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
150283 /* 60 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
150284 /* 70 */ -256, -256, -256, -256, -256, -256, -256, 989, 1065, 1070,
150285 /* 80 */ 1072, 1078, 1082, 1084, 1103, 1118, 1147, 1156, 1160, 1167,
150286 /* 90 */ 1185, 1191, 1220, 1237, 1254, 1256, 1266, 1272, 1281, 1291,
150287 /* 100 */ 1293, 1296, 1299, 1301, 1307, 1337, 1340, 1342, 1347, 1366,
150288 /* 110 */ 1368, 1371, 1373, 1377, 1385, 1387, 1398, 1401, 1404, 1406,
150289 /* 120 */ 1411, 1413, 1415, 1430, -256, -256, -256, -256, -256, -256,
150290 /* 130 */ -256, -256, -256, -172, 508, -213, 57, -163, -25, 593,
150291 /* 140 */ 69, 486, 69, 486, -200, 573, 722, -256, -256, -256,
150292 /* 150 */ -256, -141, -141, -141, -105, -161, -167, 157, 212, 405,
150293 /* 160 */ 530, 220, 233, 735, 735, 115, 318, 406, 612, 541,
150294 /* 170 */ -166, 441, 688, 794, 629, 368, 741, 775, 867, 797,
150295 /* 180 */ 871, 842, -186, 1000, 858, 949, 379, 783, 70, 296,
150296 /* 190 */ 821, 903, 924, 1044, 651, 282, 1014, 1060, 937, -195,
150297 /* 200 */ -177, 413, 439, 511, 566, 787, 827, 848, 898, 945,
150298 /* 210 */ 1062, 1074, 1102, 1110, 1202, 1204, 1209, 1211, 1215, 529,
150299 /* 220 */ 1221, 1224, 1240, 1246, 1255, 1257, 1269, 1270, 1273, 1274,
150300 /* 230 */ 1275, 1280, 1205, 1251, 1294, 1310, 1317, 1326, 1327, 1124,
150301 /* 240 */ 1331, 1338, 1339, 1290, 1181, 1346, 1351, 1265, 1352, 787,
150302 /* 250 */ 1353, 1367, 1378, 1386, 1392, 1397, 1241, 1312, 1356, 1345,
150303 /* 260 */ 1357, 1358, 1359, 1124, 1356, 1356, 1364, 1396, 1433, 1341,
150304 /* 270 */ 1381, 1376, 1379, 1354, 1391, 1405, 1362, 1429, 1423, 1431,
150305 /* 280 */ 1434, 1435, 1437, 1399, 1410, 1412, 1382, 1417, 1420, 1466,
150306 /* 290 */ 1372, 1467, 1468, 1380, 1384, 1475, 1394, 1414, 1416, 1448,
150307 /* 300 */ 1440, 1451, 1452, 1453, 1454, 1490, 1493, 1449, 1455, 1427,
150308 /* 310 */ 1436, 1464, 1465, 1456, 1498, 1502, 1419, 1421, 1507, 1509,
150309 /* 320 */ 1491, 1510, 1513, 1514, 1516, 1496, 1500, 1501, 1503, 1499,
150310 /* 330 */ 1505, 1504, 1508, 1506, 1511, 1512, 1515, 1424, 1517, 1457,
150311 /* 340 */ 1460, 1519, 1474, 1482, 1483, 1485, 1486, 1488, 1489, 1492,
150312 /* 350 */ 1541, 1438, 1441, 1494, 1495, 1518, 1520, 1487, 1555, 1481,
150313 /* 360 */ 1522, 1523, 1526, 1528, 1561, 1566, 1580, 1581, 1586, 1587,
150314 /* 370 */ 1588, 1478, 1484, 1525, 1575, 1570, 1572, 1573, 1574, 1582,
150315 /* 380 */ 1568, 1569, 1578, 1579, 1583, 1590,
150316 };
150317 static const YYACTIONTYPE yy_default[] = {
150318 /* 0 */ 1554, 1554, 1554, 1392, 1171, 1278, 1171, 1171, 1171, 1392,
150319 /* 10 */ 1392, 1392, 1171, 1308, 1308, 1445, 1202, 1171, 1171, 1171,
150320 /* 20 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1391, 1171, 1171,
150321 /* 30 */ 1171, 1171, 1475, 1475, 1171, 1171, 1171, 1171, 1171, 1171,
150322 /* 40 */ 1171, 1171, 1171, 1317, 1171, 1171, 1171, 1171, 1171, 1393,
150323 /* 50 */ 1394, 1171, 1171, 1171, 1444, 1446, 1409, 1327, 1326, 1325,
150324 /* 60 */ 1324, 1427, 1295, 1322, 1315, 1319, 1387, 1388, 1386, 1390,
150325 /* 70 */ 1394, 1393, 1171, 1318, 1358, 1372, 1357, 1171, 1171, 1171,
150326 /* 80 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150327 /* 90 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150328 /* 100 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150329 /* 110 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150330 /* 120 */ 1171, 1171, 1171, 1171, 1366, 1371, 1377, 1370, 1367, 1360,
150331 /* 130 */ 1359, 1361, 1362, 1171, 1192, 1242, 1171, 1171, 1171, 1171,
150332 /* 140 */ 1463, 1462, 1171, 1171, 1202, 1352, 1351, 1363, 1364, 1374,
150333 /* 150 */ 1373, 1452, 1510, 1509, 1410, 1171, 1171, 1171, 1171, 1171,
150334 /* 160 */ 1171, 1475, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150335 /* 170 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150336 /* 180 */ 1171, 1171, 1171, 1171, 1171, 1171, 1475, 1475, 1171, 1202,
150337 /* 190 */ 1475, 1475, 1198, 1198, 1302, 1171, 1458, 1278, 1269, 1171,
150338 /* 200 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150339 /* 210 */ 1171, 1171, 1171, 1449, 1447, 1171, 1171, 1171, 1171, 1171,
150340 /* 220 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150341 /* 230 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150342 /* 240 */ 1171, 1171, 1171, 1274, 1171, 1171, 1171, 1171, 1171, 1171,
150343 /* 250 */ 1171, 1171, 1171, 1171, 1171, 1504, 1171, 1422, 1256, 1274,
150344 /* 260 */ 1274, 1274, 1274, 1276, 1257, 1255, 1268, 1203, 1178, 1546,
150345 /* 270 */ 1321, 1297, 1297, 1543, 1321, 1321, 1543, 1217, 1524, 1214,
150346 /* 280 */ 1308, 1308, 1308, 1297, 1302, 1302, 1389, 1275, 1268, 1171,
150347 /* 290 */ 1546, 1283, 1283, 1545, 1545, 1283, 1410, 1330, 1336, 1245,
150348 /* 300 */ 1321, 1251, 1251, 1251, 1251, 1283, 1189, 1321, 1321, 1330,
150349 /* 310 */ 1336, 1245, 1245, 1321, 1283, 1189, 1426, 1540, 1283, 1189,
150350 /* 320 */ 1400, 1283, 1189, 1283, 1189, 1400, 1243, 1243, 1243, 1232,
150351 /* 330 */ 1400, 1243, 1217, 1243, 1232, 1243, 1243, 1493, 1400, 1404,
150352 /* 340 */ 1404, 1400, 1301, 1296, 1301, 1296, 1301, 1296, 1301, 1296,
150353 /* 350 */ 1283, 1485, 1485, 1311, 1311, 1316, 1302, 1395, 1283, 1171,
150354 /* 360 */ 1316, 1314, 1312, 1321, 1195, 1235, 1507, 1507, 1503, 1503,
150355 /* 370 */ 1503, 1551, 1551, 1458, 1519, 1202, 1202, 1202, 1202, 1519,
150356 /* 380 */ 1219, 1219, 1203, 1203, 1202, 1519, 1171, 1171, 1171, 1171,
150357 /* 390 */ 1171, 1171, 1514, 1171, 1411, 1287, 1171, 1171, 1171, 1171,
150358 /* 400 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150359 /* 410 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1341,
150360 /* 420 */ 1171, 1174, 1455, 1171, 1171, 1453, 1171, 1171, 1171, 1171,
150361 /* 430 */ 1171, 1171, 1288, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150362 /* 440 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150363 /* 450 */ 1171, 1542, 1171, 1171, 1171, 1171, 1171, 1171, 1425, 1424,
150364 /* 460 */ 1171, 1171, 1285, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150365 /* 470 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150366 /* 480 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150367 /* 490 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150368 /* 500 */ 1313, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150369 /* 510 */ 1171, 1171, 1171, 1171, 1171, 1490, 1303, 1171, 1171, 1533,
150370 /* 520 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150371 /* 530 */ 1171, 1171, 1171, 1171, 1528, 1259, 1343, 1171, 1342, 1346,
150372 /* 540 */ 1171, 1183, 1171,
150373 };
150374 /********** End of lemon-generated parsing tables *****************************/
150375
150376 /* The next table maps tokens (terminal symbols) into fallback tokens.
150377 ** If a construct like the following:
@@ -149749,10 +150469,13 @@
150469 59, /* TRIGGER => ID */
150470 59, /* VACUUM => ID */
150471 59, /* VIEW => ID */
150472 59, /* VIRTUAL => ID */
150473 59, /* WITH => ID */
150474 59, /* NULLS => ID */
150475 59, /* FIRST => ID */
150476 59, /* LAST => ID */
150477 59, /* CURRENT => ID */
150478 59, /* FOLLOWING => ID */
150479 59, /* PARTITION => ID */
150480 59, /* PRECEDING => ID */
150481 59, /* RANGE => ID */
@@ -149762,10 +150485,91 @@
150485 59, /* OTHERS => ID */
150486 59, /* TIES => ID */
150487 59, /* REINDEX => ID */
150488 59, /* RENAME => ID */
150489 59, /* CTIME_KW => ID */
150490 0, /* ANY => nothing */
150491 0, /* BITAND => nothing */
150492 0, /* BITOR => nothing */
150493 0, /* LSHIFT => nothing */
150494 0, /* RSHIFT => nothing */
150495 0, /* PLUS => nothing */
150496 0, /* MINUS => nothing */
150497 0, /* STAR => nothing */
150498 0, /* SLASH => nothing */
150499 0, /* REM => nothing */
150500 0, /* CONCAT => nothing */
150501 0, /* COLLATE => nothing */
150502 0, /* BITNOT => nothing */
150503 0, /* ON => nothing */
150504 0, /* INDEXED => nothing */
150505 0, /* STRING => nothing */
150506 0, /* JOIN_KW => nothing */
150507 0, /* CONSTRAINT => nothing */
150508 0, /* DEFAULT => nothing */
150509 0, /* NULL => nothing */
150510 0, /* PRIMARY => nothing */
150511 0, /* UNIQUE => nothing */
150512 0, /* CHECK => nothing */
150513 0, /* REFERENCES => nothing */
150514 0, /* AUTOINCR => nothing */
150515 0, /* INSERT => nothing */
150516 0, /* DELETE => nothing */
150517 0, /* UPDATE => nothing */
150518 0, /* SET => nothing */
150519 0, /* DEFERRABLE => nothing */
150520 0, /* FOREIGN => nothing */
150521 0, /* DROP => nothing */
150522 0, /* UNION => nothing */
150523 0, /* ALL => nothing */
150524 0, /* EXCEPT => nothing */
150525 0, /* INTERSECT => nothing */
150526 0, /* SELECT => nothing */
150527 0, /* VALUES => nothing */
150528 0, /* DISTINCT => nothing */
150529 0, /* DOT => nothing */
150530 0, /* FROM => nothing */
150531 0, /* JOIN => nothing */
150532 0, /* USING => nothing */
150533 0, /* ORDER => nothing */
150534 0, /* GROUP => nothing */
150535 0, /* HAVING => nothing */
150536 0, /* LIMIT => nothing */
150537 0, /* WHERE => nothing */
150538 0, /* INTO => nothing */
150539 0, /* NOTHING => nothing */
150540 0, /* FLOAT => nothing */
150541 0, /* BLOB => nothing */
150542 0, /* INTEGER => nothing */
150543 0, /* VARIABLE => nothing */
150544 0, /* CASE => nothing */
150545 0, /* WHEN => nothing */
150546 0, /* THEN => nothing */
150547 0, /* ELSE => nothing */
150548 0, /* INDEX => nothing */
150549 0, /* ALTER => nothing */
150550 0, /* ADD => nothing */
150551 0, /* WINDOW => nothing */
150552 0, /* OVER => nothing */
150553 0, /* FILTER => nothing */
150554 0, /* COLUMN => nothing */
150555 0, /* AGG_FUNCTION => nothing */
150556 0, /* AGG_COLUMN => nothing */
150557 0, /* TRUEFALSE => nothing */
150558 0, /* ISNOT => nothing */
150559 0, /* FUNCTION => nothing */
150560 0, /* UMINUS => nothing */
150561 0, /* UPLUS => nothing */
150562 0, /* TRUTH => nothing */
150563 0, /* REGISTER => nothing */
150564 0, /* VECTOR => nothing */
150565 0, /* SELECT_COLUMN => nothing */
150566 0, /* IF_NULL_ROW => nothing */
150567 0, /* ASTERISK => nothing */
150568 0, /* SPAN => nothing */
150569 0, /* SPACE => nothing */
150570 0, /* ILLEGAL => nothing */
150571 };
150572 #endif /* YYFALLBACK */
150573
150574 /* The following structure represents a single element of the
150575 ** parser's stack. Information stored includes:
@@ -149931,230 +150735,235 @@
150735 /* 77 */ "TRIGGER",
150736 /* 78 */ "VACUUM",
150737 /* 79 */ "VIEW",
150738 /* 80 */ "VIRTUAL",
150739 /* 81 */ "WITH",
150740 /* 82 */ "NULLS",
150741 /* 83 */ "FIRST",
150742 /* 84 */ "LAST",
150743 /* 85 */ "CURRENT",
150744 /* 86 */ "FOLLOWING",
150745 /* 87 */ "PARTITION",
150746 /* 88 */ "PRECEDING",
150747 /* 89 */ "RANGE",
150748 /* 90 */ "UNBOUNDED",
150749 /* 91 */ "EXCLUDE",
150750 /* 92 */ "GROUPS",
150751 /* 93 */ "OTHERS",
150752 /* 94 */ "TIES",
150753 /* 95 */ "REINDEX",
150754 /* 96 */ "RENAME",
150755 /* 97 */ "CTIME_KW",
150756 /* 98 */ "ANY",
150757 /* 99 */ "BITAND",
150758 /* 100 */ "BITOR",
150759 /* 101 */ "LSHIFT",
150760 /* 102 */ "RSHIFT",
150761 /* 103 */ "PLUS",
150762 /* 104 */ "MINUS",
150763 /* 105 */ "STAR",
150764 /* 106 */ "SLASH",
150765 /* 107 */ "REM",
150766 /* 108 */ "CONCAT",
150767 /* 109 */ "COLLATE",
150768 /* 110 */ "BITNOT",
150769 /* 111 */ "ON",
150770 /* 112 */ "INDEXED",
150771 /* 113 */ "STRING",
150772 /* 114 */ "JOIN_KW",
150773 /* 115 */ "CONSTRAINT",
150774 /* 116 */ "DEFAULT",
150775 /* 117 */ "NULL",
150776 /* 118 */ "PRIMARY",
150777 /* 119 */ "UNIQUE",
150778 /* 120 */ "CHECK",
150779 /* 121 */ "REFERENCES",
150780 /* 122 */ "AUTOINCR",
150781 /* 123 */ "INSERT",
150782 /* 124 */ "DELETE",
150783 /* 125 */ "UPDATE",
150784 /* 126 */ "SET",
150785 /* 127 */ "DEFERRABLE",
150786 /* 128 */ "FOREIGN",
150787 /* 129 */ "DROP",
150788 /* 130 */ "UNION",
150789 /* 131 */ "ALL",
150790 /* 132 */ "EXCEPT",
150791 /* 133 */ "INTERSECT",
150792 /* 134 */ "SELECT",
150793 /* 135 */ "VALUES",
150794 /* 136 */ "DISTINCT",
150795 /* 137 */ "DOT",
150796 /* 138 */ "FROM",
150797 /* 139 */ "JOIN",
150798 /* 140 */ "USING",
150799 /* 141 */ "ORDER",
150800 /* 142 */ "GROUP",
150801 /* 143 */ "HAVING",
150802 /* 144 */ "LIMIT",
150803 /* 145 */ "WHERE",
150804 /* 146 */ "INTO",
150805 /* 147 */ "NOTHING",
150806 /* 148 */ "FLOAT",
150807 /* 149 */ "BLOB",
150808 /* 150 */ "INTEGER",
150809 /* 151 */ "VARIABLE",
150810 /* 152 */ "CASE",
150811 /* 153 */ "WHEN",
150812 /* 154 */ "THEN",
150813 /* 155 */ "ELSE",
150814 /* 156 */ "INDEX",
150815 /* 157 */ "ALTER",
150816 /* 158 */ "ADD",
150817 /* 159 */ "WINDOW",
150818 /* 160 */ "OVER",
150819 /* 161 */ "FILTER",
150820 /* 162 */ "COLUMN",
150821 /* 163 */ "AGG_FUNCTION",
150822 /* 164 */ "AGG_COLUMN",
150823 /* 165 */ "TRUEFALSE",
150824 /* 166 */ "ISNOT",
150825 /* 167 */ "FUNCTION",
150826 /* 168 */ "UMINUS",
150827 /* 169 */ "UPLUS",
150828 /* 170 */ "TRUTH",
150829 /* 171 */ "REGISTER",
150830 /* 172 */ "VECTOR",
150831 /* 173 */ "SELECT_COLUMN",
150832 /* 174 */ "IF_NULL_ROW",
150833 /* 175 */ "ASTERISK",
150834 /* 176 */ "SPAN",
150835 /* 177 */ "SPACE",
150836 /* 178 */ "ILLEGAL",
150837 /* 179 */ "input",
150838 /* 180 */ "cmdlist",
150839 /* 181 */ "ecmd",
150840 /* 182 */ "cmdx",
150841 /* 183 */ "explain",
150842 /* 184 */ "cmd",
150843 /* 185 */ "transtype",
150844 /* 186 */ "trans_opt",
150845 /* 187 */ "nm",
150846 /* 188 */ "savepoint_opt",
150847 /* 189 */ "create_table",
150848 /* 190 */ "create_table_args",
150849 /* 191 */ "createkw",
150850 /* 192 */ "temp",
150851 /* 193 */ "ifnotexists",
150852 /* 194 */ "dbnm",
150853 /* 195 */ "columnlist",
150854 /* 196 */ "conslist_opt",
150855 /* 197 */ "table_options",
150856 /* 198 */ "select",
150857 /* 199 */ "columnname",
150858 /* 200 */ "carglist",
150859 /* 201 */ "typetoken",
150860 /* 202 */ "typename",
150861 /* 203 */ "signed",
150862 /* 204 */ "plus_num",
150863 /* 205 */ "minus_num",
150864 /* 206 */ "scanpt",
150865 /* 207 */ "scantok",
150866 /* 208 */ "ccons",
150867 /* 209 */ "term",
150868 /* 210 */ "expr",
150869 /* 211 */ "onconf",
150870 /* 212 */ "sortorder",
150871 /* 213 */ "autoinc",
150872 /* 214 */ "eidlist_opt",
150873 /* 215 */ "refargs",
150874 /* 216 */ "defer_subclause",
150875 /* 217 */ "refarg",
150876 /* 218 */ "refact",
150877 /* 219 */ "init_deferred_pred_opt",
150878 /* 220 */ "conslist",
150879 /* 221 */ "tconscomma",
150880 /* 222 */ "tcons",
150881 /* 223 */ "sortlist",
150882 /* 224 */ "eidlist",
150883 /* 225 */ "defer_subclause_opt",
150884 /* 226 */ "orconf",
150885 /* 227 */ "resolvetype",
150886 /* 228 */ "raisetype",
150887 /* 229 */ "ifexists",
150888 /* 230 */ "fullname",
150889 /* 231 */ "selectnowith",
150890 /* 232 */ "oneselect",
150891 /* 233 */ "wqlist",
150892 /* 234 */ "multiselect_op",
150893 /* 235 */ "distinct",
150894 /* 236 */ "selcollist",
150895 /* 237 */ "from",
150896 /* 238 */ "where_opt",
150897 /* 239 */ "groupby_opt",
150898 /* 240 */ "having_opt",
150899 /* 241 */ "orderby_opt",
150900 /* 242 */ "limit_opt",
150901 /* 243 */ "window_clause",
150902 /* 244 */ "values",
150903 /* 245 */ "nexprlist",
150904 /* 246 */ "sclp",
150905 /* 247 */ "as",
150906 /* 248 */ "seltablist",
150907 /* 249 */ "stl_prefix",
150908 /* 250 */ "joinop",
150909 /* 251 */ "indexed_opt",
150910 /* 252 */ "on_opt",
150911 /* 253 */ "using_opt",
150912 /* 254 */ "exprlist",
150913 /* 255 */ "xfullname",
150914 /* 256 */ "idlist",
150915 /* 257 */ "nulls",
150916 /* 258 */ "with",
150917 /* 259 */ "setlist",
150918 /* 260 */ "insert_cmd",
150919 /* 261 */ "idlist_opt",
150920 /* 262 */ "upsert",
150921 /* 263 */ "filter_over",
150922 /* 264 */ "likeop",
150923 /* 265 */ "between_op",
150924 /* 266 */ "in_op",
150925 /* 267 */ "paren_exprlist",
150926 /* 268 */ "case_operand",
150927 /* 269 */ "case_exprlist",
150928 /* 270 */ "case_else",
150929 /* 271 */ "uniqueflag",
150930 /* 272 */ "collate",
150931 /* 273 */ "vinto",
150932 /* 274 */ "nmnum",
150933 /* 275 */ "trigger_decl",
150934 /* 276 */ "trigger_cmd_list",
150935 /* 277 */ "trigger_time",
150936 /* 278 */ "trigger_event",
150937 /* 279 */ "foreach_clause",
150938 /* 280 */ "when_clause",
150939 /* 281 */ "trigger_cmd",
150940 /* 282 */ "trnm",
150941 /* 283 */ "tridxby",
150942 /* 284 */ "database_kw_opt",
150943 /* 285 */ "key_opt",
150944 /* 286 */ "add_column_fullname",
150945 /* 287 */ "kwcolumn_opt",
150946 /* 288 */ "create_vtab",
150947 /* 289 */ "vtabarglist",
150948 /* 290 */ "vtabarg",
150949 /* 291 */ "vtabargtoken",
150950 /* 292 */ "lp",
150951 /* 293 */ "anylist",
150952 /* 294 */ "windowdefn_list",
150953 /* 295 */ "windowdefn",
150954 /* 296 */ "window",
150955 /* 297 */ "frame_opt",
150956 /* 298 */ "part_opt",
150957 /* 299 */ "filter_clause",
150958 /* 300 */ "over_clause",
150959 /* 301 */ "range_or_rows",
150960 /* 302 */ "frame_bound",
150961 /* 303 */ "frame_bound_s",
150962 /* 304 */ "frame_bound_e",
150963 /* 305 */ "frame_exclude_opt",
150964 /* 306 */ "frame_exclude",
150965 };
150966 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
150967
150968 #ifndef NDEBUG
150969 /* For tracing reduce actions, the names of all rules are required.
@@ -150288,256 +151097,261 @@
151097 /* 125 */ "indexed_opt ::= NOT INDEXED",
151098 /* 126 */ "using_opt ::= USING LP idlist RP",
151099 /* 127 */ "using_opt ::=",
151100 /* 128 */ "orderby_opt ::=",
151101 /* 129 */ "orderby_opt ::= ORDER BY sortlist",
151102 /* 130 */ "sortlist ::= sortlist COMMA expr sortorder nulls",
151103 /* 131 */ "sortlist ::= expr sortorder nulls",
151104 /* 132 */ "sortorder ::= ASC",
151105 /* 133 */ "sortorder ::= DESC",
151106 /* 134 */ "sortorder ::=",
151107 /* 135 */ "nulls ::= NULLS FIRST",
151108 /* 136 */ "nulls ::= NULLS LAST",
151109 /* 137 */ "nulls ::=",
151110 /* 138 */ "groupby_opt ::=",
151111 /* 139 */ "groupby_opt ::= GROUP BY nexprlist",
151112 /* 140 */ "having_opt ::=",
151113 /* 141 */ "having_opt ::= HAVING expr",
151114 /* 142 */ "limit_opt ::=",
151115 /* 143 */ "limit_opt ::= LIMIT expr",
151116 /* 144 */ "limit_opt ::= LIMIT expr OFFSET expr",
151117 /* 145 */ "limit_opt ::= LIMIT expr COMMA expr",
151118 /* 146 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
151119 /* 147 */ "where_opt ::=",
151120 /* 148 */ "where_opt ::= WHERE expr",
151121 /* 149 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
151122 /* 150 */ "setlist ::= setlist COMMA nm EQ expr",
151123 /* 151 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
151124 /* 152 */ "setlist ::= nm EQ expr",
151125 /* 153 */ "setlist ::= LP idlist RP EQ expr",
151126 /* 154 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
151127 /* 155 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
151128 /* 156 */ "upsert ::=",
151129 /* 157 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
151130 /* 158 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
151131 /* 159 */ "upsert ::= ON CONFLICT DO NOTHING",
151132 /* 160 */ "insert_cmd ::= INSERT orconf",
151133 /* 161 */ "insert_cmd ::= REPLACE",
151134 /* 162 */ "idlist_opt ::=",
151135 /* 163 */ "idlist_opt ::= LP idlist RP",
151136 /* 164 */ "idlist ::= idlist COMMA nm",
151137 /* 165 */ "idlist ::= nm",
151138 /* 166 */ "expr ::= LP expr RP",
151139 /* 167 */ "expr ::= ID|INDEXED",
151140 /* 168 */ "expr ::= JOIN_KW",
151141 /* 169 */ "expr ::= nm DOT nm",
151142 /* 170 */ "expr ::= nm DOT nm DOT nm",
151143 /* 171 */ "term ::= NULL|FLOAT|BLOB",
151144 /* 172 */ "term ::= STRING",
151145 /* 173 */ "term ::= INTEGER",
151146 /* 174 */ "expr ::= VARIABLE",
151147 /* 175 */ "expr ::= expr COLLATE ID|STRING",
151148 /* 176 */ "expr ::= CAST LP expr AS typetoken RP",
151149 /* 177 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
151150 /* 178 */ "expr ::= ID|INDEXED LP STAR RP",
151151 /* 179 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over",
151152 /* 180 */ "expr ::= ID|INDEXED LP STAR RP filter_over",
151153 /* 181 */ "term ::= CTIME_KW",
151154 /* 182 */ "expr ::= LP nexprlist COMMA expr RP",
151155 /* 183 */ "expr ::= expr AND expr",
151156 /* 184 */ "expr ::= expr OR expr",
151157 /* 185 */ "expr ::= expr LT|GT|GE|LE expr",
151158 /* 186 */ "expr ::= expr EQ|NE expr",
151159 /* 187 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
151160 /* 188 */ "expr ::= expr PLUS|MINUS expr",
151161 /* 189 */ "expr ::= expr STAR|SLASH|REM expr",
151162 /* 190 */ "expr ::= expr CONCAT expr",
151163 /* 191 */ "likeop ::= NOT LIKE_KW|MATCH",
151164 /* 192 */ "expr ::= expr likeop expr",
151165 /* 193 */ "expr ::= expr likeop expr ESCAPE expr",
151166 /* 194 */ "expr ::= expr ISNULL|NOTNULL",
151167 /* 195 */ "expr ::= expr NOT NULL",
151168 /* 196 */ "expr ::= expr IS expr",
151169 /* 197 */ "expr ::= expr IS NOT expr",
151170 /* 198 */ "expr ::= NOT expr",
151171 /* 199 */ "expr ::= BITNOT expr",
151172 /* 200 */ "expr ::= PLUS|MINUS expr",
151173 /* 201 */ "between_op ::= BETWEEN",
151174 /* 202 */ "between_op ::= NOT BETWEEN",
151175 /* 203 */ "expr ::= expr between_op expr AND expr",
151176 /* 204 */ "in_op ::= IN",
151177 /* 205 */ "in_op ::= NOT IN",
151178 /* 206 */ "expr ::= expr in_op LP exprlist RP",
151179 /* 207 */ "expr ::= LP select RP",
151180 /* 208 */ "expr ::= expr in_op LP select RP",
151181 /* 209 */ "expr ::= expr in_op nm dbnm paren_exprlist",
151182 /* 210 */ "expr ::= EXISTS LP select RP",
151183 /* 211 */ "expr ::= CASE case_operand case_exprlist case_else END",
151184 /* 212 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
151185 /* 213 */ "case_exprlist ::= WHEN expr THEN expr",
151186 /* 214 */ "case_else ::= ELSE expr",
151187 /* 215 */ "case_else ::=",
151188 /* 216 */ "case_operand ::= expr",
151189 /* 217 */ "case_operand ::=",
151190 /* 218 */ "exprlist ::=",
151191 /* 219 */ "nexprlist ::= nexprlist COMMA expr",
151192 /* 220 */ "nexprlist ::= expr",
151193 /* 221 */ "paren_exprlist ::=",
151194 /* 222 */ "paren_exprlist ::= LP exprlist RP",
151195 /* 223 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
151196 /* 224 */ "uniqueflag ::= UNIQUE",
151197 /* 225 */ "uniqueflag ::=",
151198 /* 226 */ "eidlist_opt ::=",
151199 /* 227 */ "eidlist_opt ::= LP eidlist RP",
151200 /* 228 */ "eidlist ::= eidlist COMMA nm collate sortorder",
151201 /* 229 */ "eidlist ::= nm collate sortorder",
151202 /* 230 */ "collate ::=",
151203 /* 231 */ "collate ::= COLLATE ID|STRING",
151204 /* 232 */ "cmd ::= DROP INDEX ifexists fullname",
151205 /* 233 */ "cmd ::= VACUUM vinto",
151206 /* 234 */ "cmd ::= VACUUM nm vinto",
151207 /* 235 */ "vinto ::= INTO expr",
151208 /* 236 */ "vinto ::=",
151209 /* 237 */ "cmd ::= PRAGMA nm dbnm",
151210 /* 238 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
151211 /* 239 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
151212 /* 240 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
151213 /* 241 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
151214 /* 242 */ "plus_num ::= PLUS INTEGER|FLOAT",
151215 /* 243 */ "minus_num ::= MINUS INTEGER|FLOAT",
151216 /* 244 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
151217 /* 245 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
151218 /* 246 */ "trigger_time ::= BEFORE|AFTER",
151219 /* 247 */ "trigger_time ::= INSTEAD OF",
151220 /* 248 */ "trigger_time ::=",
151221 /* 249 */ "trigger_event ::= DELETE|INSERT",
151222 /* 250 */ "trigger_event ::= UPDATE",
151223 /* 251 */ "trigger_event ::= UPDATE OF idlist",
151224 /* 252 */ "when_clause ::=",
151225 /* 253 */ "when_clause ::= WHEN expr",
151226 /* 254 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
151227 /* 255 */ "trigger_cmd_list ::= trigger_cmd SEMI",
151228 /* 256 */ "trnm ::= nm DOT nm",
151229 /* 257 */ "tridxby ::= INDEXED BY nm",
151230 /* 258 */ "tridxby ::= NOT INDEXED",
151231 /* 259 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
151232 /* 260 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
151233 /* 261 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
151234 /* 262 */ "trigger_cmd ::= scanpt select scanpt",
151235 /* 263 */ "expr ::= RAISE LP IGNORE RP",
151236 /* 264 */ "expr ::= RAISE LP raisetype COMMA nm RP",
151237 /* 265 */ "raisetype ::= ROLLBACK",
151238 /* 266 */ "raisetype ::= ABORT",
151239 /* 267 */ "raisetype ::= FAIL",
151240 /* 268 */ "cmd ::= DROP TRIGGER ifexists fullname",
151241 /* 269 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
151242 /* 270 */ "cmd ::= DETACH database_kw_opt expr",
151243 /* 271 */ "key_opt ::=",
151244 /* 272 */ "key_opt ::= KEY expr",
151245 /* 273 */ "cmd ::= REINDEX",
151246 /* 274 */ "cmd ::= REINDEX nm dbnm",
151247 /* 275 */ "cmd ::= ANALYZE",
151248 /* 276 */ "cmd ::= ANALYZE nm dbnm",
151249 /* 277 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
151250 /* 278 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
151251 /* 279 */ "add_column_fullname ::= fullname",
151252 /* 280 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
151253 /* 281 */ "cmd ::= create_vtab",
151254 /* 282 */ "cmd ::= create_vtab LP vtabarglist RP",
151255 /* 283 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
151256 /* 284 */ "vtabarg ::=",
151257 /* 285 */ "vtabargtoken ::= ANY",
151258 /* 286 */ "vtabargtoken ::= lp anylist RP",
151259 /* 287 */ "lp ::= LP",
151260 /* 288 */ "with ::= WITH wqlist",
151261 /* 289 */ "with ::= WITH RECURSIVE wqlist",
151262 /* 290 */ "wqlist ::= nm eidlist_opt AS LP select RP",
151263 /* 291 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
151264 /* 292 */ "windowdefn_list ::= windowdefn",
151265 /* 293 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
151266 /* 294 */ "windowdefn ::= nm AS LP window RP",
151267 /* 295 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
151268 /* 296 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
151269 /* 297 */ "window ::= ORDER BY sortlist frame_opt",
151270 /* 298 */ "window ::= nm ORDER BY sortlist frame_opt",
151271 /* 299 */ "window ::= frame_opt",
151272 /* 300 */ "window ::= nm frame_opt",
151273 /* 301 */ "frame_opt ::=",
151274 /* 302 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
151275 /* 303 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
151276 /* 304 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
151277 /* 305 */ "frame_bound_s ::= frame_bound",
151278 /* 306 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
151279 /* 307 */ "frame_bound_e ::= frame_bound",
151280 /* 308 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
151281 /* 309 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
151282 /* 310 */ "frame_bound ::= CURRENT ROW",
151283 /* 311 */ "frame_exclude_opt ::=",
151284 /* 312 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
151285 /* 313 */ "frame_exclude ::= NO OTHERS",
151286 /* 314 */ "frame_exclude ::= CURRENT ROW",
151287 /* 315 */ "frame_exclude ::= GROUP|TIES",
151288 /* 316 */ "window_clause ::= WINDOW windowdefn_list",
151289 /* 317 */ "filter_over ::= filter_clause over_clause",
151290 /* 318 */ "filter_over ::= over_clause",
151291 /* 319 */ "filter_over ::= filter_clause",
151292 /* 320 */ "over_clause ::= OVER LP window RP",
151293 /* 321 */ "over_clause ::= OVER nm",
151294 /* 322 */ "filter_clause ::= FILTER LP WHERE expr RP",
151295 /* 323 */ "input ::= cmdlist",
151296 /* 324 */ "cmdlist ::= cmdlist ecmd",
151297 /* 325 */ "cmdlist ::= ecmd",
151298 /* 326 */ "ecmd ::= SEMI",
151299 /* 327 */ "ecmd ::= cmdx SEMI",
151300 /* 328 */ "ecmd ::= explain cmdx",
151301 /* 329 */ "trans_opt ::=",
151302 /* 330 */ "trans_opt ::= TRANSACTION",
151303 /* 331 */ "trans_opt ::= TRANSACTION nm",
151304 /* 332 */ "savepoint_opt ::= SAVEPOINT",
151305 /* 333 */ "savepoint_opt ::=",
151306 /* 334 */ "cmd ::= create_table create_table_args",
151307 /* 335 */ "columnlist ::= columnlist COMMA columnname carglist",
151308 /* 336 */ "columnlist ::= columnname carglist",
151309 /* 337 */ "nm ::= ID|INDEXED",
151310 /* 338 */ "nm ::= STRING",
151311 /* 339 */ "nm ::= JOIN_KW",
151312 /* 340 */ "typetoken ::= typename",
151313 /* 341 */ "typename ::= ID|STRING",
151314 /* 342 */ "signed ::= plus_num",
151315 /* 343 */ "signed ::= minus_num",
151316 /* 344 */ "carglist ::= carglist ccons",
151317 /* 345 */ "carglist ::=",
151318 /* 346 */ "ccons ::= NULL onconf",
151319 /* 347 */ "conslist_opt ::= COMMA conslist",
151320 /* 348 */ "conslist ::= conslist tconscomma tcons",
151321 /* 349 */ "conslist ::= tcons",
151322 /* 350 */ "tconscomma ::=",
151323 /* 351 */ "defer_subclause_opt ::= defer_subclause",
151324 /* 352 */ "resolvetype ::= raisetype",
151325 /* 353 */ "selectnowith ::= oneselect",
151326 /* 354 */ "oneselect ::= values",
151327 /* 355 */ "sclp ::= selcollist COMMA",
151328 /* 356 */ "as ::= ID|STRING",
151329 /* 357 */ "expr ::= term",
151330 /* 358 */ "likeop ::= LIKE_KW|MATCH",
151331 /* 359 */ "exprlist ::= nexprlist",
151332 /* 360 */ "nmnum ::= plus_num",
151333 /* 361 */ "nmnum ::= nm",
151334 /* 362 */ "nmnum ::= ON",
151335 /* 363 */ "nmnum ::= DELETE",
151336 /* 364 */ "nmnum ::= DEFAULT",
151337 /* 365 */ "plus_num ::= INTEGER|FLOAT",
151338 /* 366 */ "foreach_clause ::=",
151339 /* 367 */ "foreach_clause ::= FOR EACH ROW",
151340 /* 368 */ "trnm ::= nm",
151341 /* 369 */ "tridxby ::=",
151342 /* 370 */ "database_kw_opt ::= DATABASE",
151343 /* 371 */ "database_kw_opt ::=",
151344 /* 372 */ "kwcolumn_opt ::=",
151345 /* 373 */ "kwcolumn_opt ::= COLUMNKW",
151346 /* 374 */ "vtabarglist ::= vtabarg",
151347 /* 375 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
151348 /* 376 */ "vtabarg ::= vtabarg vtabargtoken",
151349 /* 377 */ "anylist ::=",
151350 /* 378 */ "anylist ::= anylist LP anylist RP",
151351 /* 379 */ "anylist ::= anylist ANY",
151352 /* 380 */ "with ::=",
151353 };
151354 #endif /* NDEBUG */
151355
151356
151357 #if YYSTACKDEPTH<=0
@@ -150659,101 +151473,102 @@
151473 ** Note: during a reduce, the only symbols destroyed are those
151474 ** which appear on the RHS of the rule, but which are *not* used
151475 ** inside the C code.
151476 */
151477 /********* Begin destructor definitions ***************************************/
151478 case 198: /* select */
151479 case 231: /* selectnowith */
151480 case 232: /* oneselect */
151481 case 244: /* values */
151482 {
151483 sqlite3SelectDelete(pParse->db, (yypminor->yy25));
151484 }
151485 break;
151486 case 209: /* term */
151487 case 210: /* expr */
151488 case 238: /* where_opt */
151489 case 240: /* having_opt */
151490 case 252: /* on_opt */
151491 case 268: /* case_operand */
151492 case 270: /* case_else */
151493 case 273: /* vinto */
151494 case 280: /* when_clause */
151495 case 285: /* key_opt */
151496 case 299: /* filter_clause */
151497 {
151498 sqlite3ExprDelete(pParse->db, (yypminor->yy46));
151499 }
151500 break;
151501 case 214: /* eidlist_opt */
151502 case 223: /* sortlist */
151503 case 224: /* eidlist */
151504 case 236: /* selcollist */
151505 case 239: /* groupby_opt */
151506 case 241: /* orderby_opt */
151507 case 245: /* nexprlist */
151508 case 246: /* sclp */
151509 case 254: /* exprlist */
151510 case 259: /* setlist */
151511 case 267: /* paren_exprlist */
151512 case 269: /* case_exprlist */
151513 case 298: /* part_opt */
151514 {
151515 sqlite3ExprListDelete(pParse->db, (yypminor->yy138));
151516 }
151517 break;
151518 case 230: /* fullname */
151519 case 237: /* from */
151520 case 248: /* seltablist */
151521 case 249: /* stl_prefix */
151522 case 255: /* xfullname */
151523 {
151524 sqlite3SrcListDelete(pParse->db, (yypminor->yy609));
151525 }
151526 break;
151527 case 233: /* wqlist */
151528 {
151529 sqlite3WithDelete(pParse->db, (yypminor->yy297));
151530 }
151531 break;
151532 case 243: /* window_clause */
151533 case 294: /* windowdefn_list */
151534 {
151535 sqlite3WindowListDelete(pParse->db, (yypminor->yy455));
151536 }
151537 break;
151538 case 253: /* using_opt */
151539 case 256: /* idlist */
151540 case 261: /* idlist_opt */
151541 {
151542 sqlite3IdListDelete(pParse->db, (yypminor->yy406));
151543 }
151544 break;
151545 case 263: /* filter_over */
151546 case 295: /* windowdefn */
151547 case 296: /* window */
151548 case 297: /* frame_opt */
151549 case 300: /* over_clause */
151550 {
151551 sqlite3WindowDelete(pParse->db, (yypminor->yy455));
151552 }
151553 break;
151554 case 276: /* trigger_cmd_list */
151555 case 281: /* trigger_cmd */
151556 {
151557 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy527));
151558 }
151559 break;
151560 case 278: /* trigger_event */
151561 {
151562 sqlite3IdListDelete(pParse->db, (yypminor->yy572).b);
151563 }
151564 break;
151565 case 302: /* frame_bound */
151566 case 303: /* frame_bound_s */
151567 case 304: /* frame_bound_e */
151568 {
151569 sqlite3ExprDelete(pParse->db, (yypminor->yy57).pExpr);
151570 }
151571 break;
151572 /********* End destructor definitions *****************************************/
151573 default: break; /* If no destructor action specified: do nothing */
151574 }
@@ -150875,19 +151690,22 @@
151690 yycoverage[stateno][iLookAhead] = 1;
151691 #endif
151692 do{
151693 i = yy_shift_ofst[stateno];
151694 assert( i>=0 );
151695 assert( i<=YY_ACTTAB_COUNT );
151696 assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD );
151697 assert( iLookAhead!=YYNOCODE );
151698 assert( iLookAhead < YYNTOKEN );
151699 i += iLookAhead;
151700 assert( i<(int)YY_NLOOKAHEAD );
151701 if( yy_lookahead[i]!=iLookAhead ){
151702 #ifdef YYFALLBACK
151703 YYCODETYPE iFallback; /* Fallback token */
151704 assert( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) );
151705 iFallback = yyFallback[iLookAhead];
151706 if( iFallback!=0 ){
151707 #ifndef NDEBUG
151708 if( yyTraceFILE ){
151709 fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
151710 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
151711 }
@@ -150898,20 +151716,12 @@
151716 }
151717 #endif
151718 #ifdef YYWILDCARD
151719 {
151720 int j = i - iLookAhead + YYWILDCARD;
151721 assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) );
151722 if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){
 
 
 
 
 
 
 
 
151723 #ifndef NDEBUG
151724 if( yyTraceFILE ){
151725 fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
151726 yyTracePrompt, yyTokenName[iLookAhead],
151727 yyTokenName[YYWILDCARD]);
@@ -150921,10 +151731,11 @@
151731 }
151732 }
151733 #endif /* YYWILDCARD */
151734 return yy_default[stateno];
151735 }else{
151736 assert( i>=0 && i<sizeof(yy_action)/sizeof(yy_action[0]) );
151737 return yy_action[i];
151738 }
151739 }while(1);
151740 }
151741
@@ -151044,386 +151855,391 @@
151855 }
151856
151857 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
151858 ** of that rule */
151859 static const YYCODETYPE yyRuleInfoLhs[] = {
151860 183, /* (0) explain ::= EXPLAIN */
151861 183, /* (1) explain ::= EXPLAIN QUERY PLAN */
151862 182, /* (2) cmdx ::= cmd */
151863 184, /* (3) cmd ::= BEGIN transtype trans_opt */
151864 185, /* (4) transtype ::= */
151865 185, /* (5) transtype ::= DEFERRED */
151866 185, /* (6) transtype ::= IMMEDIATE */
151867 185, /* (7) transtype ::= EXCLUSIVE */
151868 184, /* (8) cmd ::= COMMIT|END trans_opt */
151869 184, /* (9) cmd ::= ROLLBACK trans_opt */
151870 184, /* (10) cmd ::= SAVEPOINT nm */
151871 184, /* (11) cmd ::= RELEASE savepoint_opt nm */
151872 184, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
151873 189, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
151874 191, /* (14) createkw ::= CREATE */
151875 193, /* (15) ifnotexists ::= */
151876 193, /* (16) ifnotexists ::= IF NOT EXISTS */
151877 192, /* (17) temp ::= TEMP */
151878 192, /* (18) temp ::= */
151879 190, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
151880 190, /* (20) create_table_args ::= AS select */
151881 197, /* (21) table_options ::= */
151882 197, /* (22) table_options ::= WITHOUT nm */
151883 199, /* (23) columnname ::= nm typetoken */
151884 201, /* (24) typetoken ::= */
151885 201, /* (25) typetoken ::= typename LP signed RP */
151886 201, /* (26) typetoken ::= typename LP signed COMMA signed RP */
151887 202, /* (27) typename ::= typename ID|STRING */
151888 206, /* (28) scanpt ::= */
151889 207, /* (29) scantok ::= */
151890 208, /* (30) ccons ::= CONSTRAINT nm */
151891 208, /* (31) ccons ::= DEFAULT scantok term */
151892 208, /* (32) ccons ::= DEFAULT LP expr RP */
151893 208, /* (33) ccons ::= DEFAULT PLUS scantok term */
151894 208, /* (34) ccons ::= DEFAULT MINUS scantok term */
151895 208, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
151896 208, /* (36) ccons ::= NOT NULL onconf */
151897 208, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
151898 208, /* (38) ccons ::= UNIQUE onconf */
151899 208, /* (39) ccons ::= CHECK LP expr RP */
151900 208, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
151901 208, /* (41) ccons ::= defer_subclause */
151902 208, /* (42) ccons ::= COLLATE ID|STRING */
151903 213, /* (43) autoinc ::= */
151904 213, /* (44) autoinc ::= AUTOINCR */
151905 215, /* (45) refargs ::= */
151906 215, /* (46) refargs ::= refargs refarg */
151907 217, /* (47) refarg ::= MATCH nm */
151908 217, /* (48) refarg ::= ON INSERT refact */
151909 217, /* (49) refarg ::= ON DELETE refact */
151910 217, /* (50) refarg ::= ON UPDATE refact */
151911 218, /* (51) refact ::= SET NULL */
151912 218, /* (52) refact ::= SET DEFAULT */
151913 218, /* (53) refact ::= CASCADE */
151914 218, /* (54) refact ::= RESTRICT */
151915 218, /* (55) refact ::= NO ACTION */
151916 216, /* (56) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
151917 216, /* (57) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
151918 219, /* (58) init_deferred_pred_opt ::= */
151919 219, /* (59) init_deferred_pred_opt ::= INITIALLY DEFERRED */
151920 219, /* (60) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
151921 196, /* (61) conslist_opt ::= */
151922 221, /* (62) tconscomma ::= COMMA */
151923 222, /* (63) tcons ::= CONSTRAINT nm */
151924 222, /* (64) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
151925 222, /* (65) tcons ::= UNIQUE LP sortlist RP onconf */
151926 222, /* (66) tcons ::= CHECK LP expr RP onconf */
151927 222, /* (67) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
151928 225, /* (68) defer_subclause_opt ::= */
151929 211, /* (69) onconf ::= */
151930 211, /* (70) onconf ::= ON CONFLICT resolvetype */
151931 226, /* (71) orconf ::= */
151932 226, /* (72) orconf ::= OR resolvetype */
151933 227, /* (73) resolvetype ::= IGNORE */
151934 227, /* (74) resolvetype ::= REPLACE */
151935 184, /* (75) cmd ::= DROP TABLE ifexists fullname */
151936 229, /* (76) ifexists ::= IF EXISTS */
151937 229, /* (77) ifexists ::= */
151938 184, /* (78) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
151939 184, /* (79) cmd ::= DROP VIEW ifexists fullname */
151940 184, /* (80) cmd ::= select */
151941 198, /* (81) select ::= WITH wqlist selectnowith */
151942 198, /* (82) select ::= WITH RECURSIVE wqlist selectnowith */
151943 198, /* (83) select ::= selectnowith */
151944 231, /* (84) selectnowith ::= selectnowith multiselect_op oneselect */
151945 234, /* (85) multiselect_op ::= UNION */
151946 234, /* (86) multiselect_op ::= UNION ALL */
151947 234, /* (87) multiselect_op ::= EXCEPT|INTERSECT */
151948 232, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
151949 232, /* (89) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
151950 244, /* (90) values ::= VALUES LP nexprlist RP */
151951 244, /* (91) values ::= values COMMA LP nexprlist RP */
151952 235, /* (92) distinct ::= DISTINCT */
151953 235, /* (93) distinct ::= ALL */
151954 235, /* (94) distinct ::= */
151955 246, /* (95) sclp ::= */
151956 236, /* (96) selcollist ::= sclp scanpt expr scanpt as */
151957 236, /* (97) selcollist ::= sclp scanpt STAR */
151958 236, /* (98) selcollist ::= sclp scanpt nm DOT STAR */
151959 247, /* (99) as ::= AS nm */
151960 247, /* (100) as ::= */
151961 237, /* (101) from ::= */
151962 237, /* (102) from ::= FROM seltablist */
151963 249, /* (103) stl_prefix ::= seltablist joinop */
151964 249, /* (104) stl_prefix ::= */
151965 248, /* (105) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
151966 248, /* (106) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
151967 248, /* (107) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
151968 248, /* (108) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
151969 194, /* (109) dbnm ::= */
151970 194, /* (110) dbnm ::= DOT nm */
151971 230, /* (111) fullname ::= nm */
151972 230, /* (112) fullname ::= nm DOT nm */
151973 255, /* (113) xfullname ::= nm */
151974 255, /* (114) xfullname ::= nm DOT nm */
151975 255, /* (115) xfullname ::= nm DOT nm AS nm */
151976 255, /* (116) xfullname ::= nm AS nm */
151977 250, /* (117) joinop ::= COMMA|JOIN */
151978 250, /* (118) joinop ::= JOIN_KW JOIN */
151979 250, /* (119) joinop ::= JOIN_KW nm JOIN */
151980 250, /* (120) joinop ::= JOIN_KW nm nm JOIN */
151981 252, /* (121) on_opt ::= ON expr */
151982 252, /* (122) on_opt ::= */
151983 251, /* (123) indexed_opt ::= */
151984 251, /* (124) indexed_opt ::= INDEXED BY nm */
151985 251, /* (125) indexed_opt ::= NOT INDEXED */
151986 253, /* (126) using_opt ::= USING LP idlist RP */
151987 253, /* (127) using_opt ::= */
151988 241, /* (128) orderby_opt ::= */
151989 241, /* (129) orderby_opt ::= ORDER BY sortlist */
151990 223, /* (130) sortlist ::= sortlist COMMA expr sortorder nulls */
151991 223, /* (131) sortlist ::= expr sortorder nulls */
151992 212, /* (132) sortorder ::= ASC */
151993 212, /* (133) sortorder ::= DESC */
151994 212, /* (134) sortorder ::= */
151995 257, /* (135) nulls ::= NULLS FIRST */
151996 257, /* (136) nulls ::= NULLS LAST */
151997 257, /* (137) nulls ::= */
151998 239, /* (138) groupby_opt ::= */
151999 239, /* (139) groupby_opt ::= GROUP BY nexprlist */
152000 240, /* (140) having_opt ::= */
152001 240, /* (141) having_opt ::= HAVING expr */
152002 242, /* (142) limit_opt ::= */
152003 242, /* (143) limit_opt ::= LIMIT expr */
152004 242, /* (144) limit_opt ::= LIMIT expr OFFSET expr */
152005 242, /* (145) limit_opt ::= LIMIT expr COMMA expr */
152006 184, /* (146) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
152007 238, /* (147) where_opt ::= */
152008 238, /* (148) where_opt ::= WHERE expr */
152009 184, /* (149) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
152010 259, /* (150) setlist ::= setlist COMMA nm EQ expr */
152011 259, /* (151) setlist ::= setlist COMMA LP idlist RP EQ expr */
152012 259, /* (152) setlist ::= nm EQ expr */
152013 259, /* (153) setlist ::= LP idlist RP EQ expr */
152014 184, /* (154) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
152015 184, /* (155) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
152016 262, /* (156) upsert ::= */
152017 262, /* (157) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
152018 262, /* (158) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
152019 262, /* (159) upsert ::= ON CONFLICT DO NOTHING */
152020 260, /* (160) insert_cmd ::= INSERT orconf */
152021 260, /* (161) insert_cmd ::= REPLACE */
152022 261, /* (162) idlist_opt ::= */
152023 261, /* (163) idlist_opt ::= LP idlist RP */
152024 256, /* (164) idlist ::= idlist COMMA nm */
152025 256, /* (165) idlist ::= nm */
152026 210, /* (166) expr ::= LP expr RP */
152027 210, /* (167) expr ::= ID|INDEXED */
152028 210, /* (168) expr ::= JOIN_KW */
152029 210, /* (169) expr ::= nm DOT nm */
152030 210, /* (170) expr ::= nm DOT nm DOT nm */
152031 209, /* (171) term ::= NULL|FLOAT|BLOB */
152032 209, /* (172) term ::= STRING */
152033 209, /* (173) term ::= INTEGER */
152034 210, /* (174) expr ::= VARIABLE */
152035 210, /* (175) expr ::= expr COLLATE ID|STRING */
152036 210, /* (176) expr ::= CAST LP expr AS typetoken RP */
152037 210, /* (177) expr ::= ID|INDEXED LP distinct exprlist RP */
152038 210, /* (178) expr ::= ID|INDEXED LP STAR RP */
152039 210, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
152040 210, /* (180) expr ::= ID|INDEXED LP STAR RP filter_over */
152041 209, /* (181) term ::= CTIME_KW */
152042 210, /* (182) expr ::= LP nexprlist COMMA expr RP */
152043 210, /* (183) expr ::= expr AND expr */
152044 210, /* (184) expr ::= expr OR expr */
152045 210, /* (185) expr ::= expr LT|GT|GE|LE expr */
152046 210, /* (186) expr ::= expr EQ|NE expr */
152047 210, /* (187) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
152048 210, /* (188) expr ::= expr PLUS|MINUS expr */
152049 210, /* (189) expr ::= expr STAR|SLASH|REM expr */
152050 210, /* (190) expr ::= expr CONCAT expr */
152051 264, /* (191) likeop ::= NOT LIKE_KW|MATCH */
152052 210, /* (192) expr ::= expr likeop expr */
152053 210, /* (193) expr ::= expr likeop expr ESCAPE expr */
152054 210, /* (194) expr ::= expr ISNULL|NOTNULL */
152055 210, /* (195) expr ::= expr NOT NULL */
152056 210, /* (196) expr ::= expr IS expr */
152057 210, /* (197) expr ::= expr IS NOT expr */
152058 210, /* (198) expr ::= NOT expr */
152059 210, /* (199) expr ::= BITNOT expr */
152060 210, /* (200) expr ::= PLUS|MINUS expr */
152061 265, /* (201) between_op ::= BETWEEN */
152062 265, /* (202) between_op ::= NOT BETWEEN */
152063 210, /* (203) expr ::= expr between_op expr AND expr */
152064 266, /* (204) in_op ::= IN */
152065 266, /* (205) in_op ::= NOT IN */
152066 210, /* (206) expr ::= expr in_op LP exprlist RP */
152067 210, /* (207) expr ::= LP select RP */
152068 210, /* (208) expr ::= expr in_op LP select RP */
152069 210, /* (209) expr ::= expr in_op nm dbnm paren_exprlist */
152070 210, /* (210) expr ::= EXISTS LP select RP */
152071 210, /* (211) expr ::= CASE case_operand case_exprlist case_else END */
152072 269, /* (212) case_exprlist ::= case_exprlist WHEN expr THEN expr */
152073 269, /* (213) case_exprlist ::= WHEN expr THEN expr */
152074 270, /* (214) case_else ::= ELSE expr */
152075 270, /* (215) case_else ::= */
152076 268, /* (216) case_operand ::= expr */
152077 268, /* (217) case_operand ::= */
152078 254, /* (218) exprlist ::= */
152079 245, /* (219) nexprlist ::= nexprlist COMMA expr */
152080 245, /* (220) nexprlist ::= expr */
152081 267, /* (221) paren_exprlist ::= */
152082 267, /* (222) paren_exprlist ::= LP exprlist RP */
152083 184, /* (223) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
152084 271, /* (224) uniqueflag ::= UNIQUE */
152085 271, /* (225) uniqueflag ::= */
152086 214, /* (226) eidlist_opt ::= */
152087 214, /* (227) eidlist_opt ::= LP eidlist RP */
152088 224, /* (228) eidlist ::= eidlist COMMA nm collate sortorder */
152089 224, /* (229) eidlist ::= nm collate sortorder */
152090 272, /* (230) collate ::= */
152091 272, /* (231) collate ::= COLLATE ID|STRING */
152092 184, /* (232) cmd ::= DROP INDEX ifexists fullname */
152093 184, /* (233) cmd ::= VACUUM vinto */
152094 184, /* (234) cmd ::= VACUUM nm vinto */
152095 273, /* (235) vinto ::= INTO expr */
152096 273, /* (236) vinto ::= */
152097 184, /* (237) cmd ::= PRAGMA nm dbnm */
152098 184, /* (238) cmd ::= PRAGMA nm dbnm EQ nmnum */
152099 184, /* (239) cmd ::= PRAGMA nm dbnm LP nmnum RP */
152100 184, /* (240) cmd ::= PRAGMA nm dbnm EQ minus_num */
152101 184, /* (241) cmd ::= PRAGMA nm dbnm LP minus_num RP */
152102 204, /* (242) plus_num ::= PLUS INTEGER|FLOAT */
152103 205, /* (243) minus_num ::= MINUS INTEGER|FLOAT */
152104 184, /* (244) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
152105 275, /* (245) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
152106 277, /* (246) trigger_time ::= BEFORE|AFTER */
152107 277, /* (247) trigger_time ::= INSTEAD OF */
152108 277, /* (248) trigger_time ::= */
152109 278, /* (249) trigger_event ::= DELETE|INSERT */
152110 278, /* (250) trigger_event ::= UPDATE */
152111 278, /* (251) trigger_event ::= UPDATE OF idlist */
152112 280, /* (252) when_clause ::= */
152113 280, /* (253) when_clause ::= WHEN expr */
152114 276, /* (254) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
152115 276, /* (255) trigger_cmd_list ::= trigger_cmd SEMI */
152116 282, /* (256) trnm ::= nm DOT nm */
152117 283, /* (257) tridxby ::= INDEXED BY nm */
152118 283, /* (258) tridxby ::= NOT INDEXED */
152119 281, /* (259) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
152120 281, /* (260) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
152121 281, /* (261) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
152122 281, /* (262) trigger_cmd ::= scanpt select scanpt */
152123 210, /* (263) expr ::= RAISE LP IGNORE RP */
152124 210, /* (264) expr ::= RAISE LP raisetype COMMA nm RP */
152125 228, /* (265) raisetype ::= ROLLBACK */
152126 228, /* (266) raisetype ::= ABORT */
152127 228, /* (267) raisetype ::= FAIL */
152128 184, /* (268) cmd ::= DROP TRIGGER ifexists fullname */
152129 184, /* (269) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
152130 184, /* (270) cmd ::= DETACH database_kw_opt expr */
152131 285, /* (271) key_opt ::= */
152132 285, /* (272) key_opt ::= KEY expr */
152133 184, /* (273) cmd ::= REINDEX */
152134 184, /* (274) cmd ::= REINDEX nm dbnm */
152135 184, /* (275) cmd ::= ANALYZE */
152136 184, /* (276) cmd ::= ANALYZE nm dbnm */
152137 184, /* (277) cmd ::= ALTER TABLE fullname RENAME TO nm */
152138 184, /* (278) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
152139 286, /* (279) add_column_fullname ::= fullname */
152140 184, /* (280) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
152141 184, /* (281) cmd ::= create_vtab */
152142 184, /* (282) cmd ::= create_vtab LP vtabarglist RP */
152143 288, /* (283) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
152144 290, /* (284) vtabarg ::= */
152145 291, /* (285) vtabargtoken ::= ANY */
152146 291, /* (286) vtabargtoken ::= lp anylist RP */
152147 292, /* (287) lp ::= LP */
152148 258, /* (288) with ::= WITH wqlist */
152149 258, /* (289) with ::= WITH RECURSIVE wqlist */
152150 233, /* (290) wqlist ::= nm eidlist_opt AS LP select RP */
152151 233, /* (291) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
152152 294, /* (292) windowdefn_list ::= windowdefn */
152153 294, /* (293) windowdefn_list ::= windowdefn_list COMMA windowdefn */
152154 295, /* (294) windowdefn ::= nm AS LP window RP */
152155 296, /* (295) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
152156 296, /* (296) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
152157 296, /* (297) window ::= ORDER BY sortlist frame_opt */
152158 296, /* (298) window ::= nm ORDER BY sortlist frame_opt */
152159 296, /* (299) window ::= frame_opt */
152160 296, /* (300) window ::= nm frame_opt */
152161 297, /* (301) frame_opt ::= */
152162 297, /* (302) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
152163 297, /* (303) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
152164 301, /* (304) range_or_rows ::= RANGE|ROWS|GROUPS */
152165 303, /* (305) frame_bound_s ::= frame_bound */
152166 303, /* (306) frame_bound_s ::= UNBOUNDED PRECEDING */
152167 304, /* (307) frame_bound_e ::= frame_bound */
152168 304, /* (308) frame_bound_e ::= UNBOUNDED FOLLOWING */
152169 302, /* (309) frame_bound ::= expr PRECEDING|FOLLOWING */
152170 302, /* (310) frame_bound ::= CURRENT ROW */
152171 305, /* (311) frame_exclude_opt ::= */
152172 305, /* (312) frame_exclude_opt ::= EXCLUDE frame_exclude */
152173 306, /* (313) frame_exclude ::= NO OTHERS */
152174 306, /* (314) frame_exclude ::= CURRENT ROW */
152175 306, /* (315) frame_exclude ::= GROUP|TIES */
152176 243, /* (316) window_clause ::= WINDOW windowdefn_list */
152177 263, /* (317) filter_over ::= filter_clause over_clause */
152178 263, /* (318) filter_over ::= over_clause */
152179 263, /* (319) filter_over ::= filter_clause */
152180 300, /* (320) over_clause ::= OVER LP window RP */
152181 300, /* (321) over_clause ::= OVER nm */
152182 299, /* (322) filter_clause ::= FILTER LP WHERE expr RP */
152183 179, /* (323) input ::= cmdlist */
152184 180, /* (324) cmdlist ::= cmdlist ecmd */
152185 180, /* (325) cmdlist ::= ecmd */
152186 181, /* (326) ecmd ::= SEMI */
152187 181, /* (327) ecmd ::= cmdx SEMI */
152188 181, /* (328) ecmd ::= explain cmdx */
152189 186, /* (329) trans_opt ::= */
152190 186, /* (330) trans_opt ::= TRANSACTION */
152191 186, /* (331) trans_opt ::= TRANSACTION nm */
152192 188, /* (332) savepoint_opt ::= SAVEPOINT */
152193 188, /* (333) savepoint_opt ::= */
152194 184, /* (334) cmd ::= create_table create_table_args */
152195 195, /* (335) columnlist ::= columnlist COMMA columnname carglist */
152196 195, /* (336) columnlist ::= columnname carglist */
152197 187, /* (337) nm ::= ID|INDEXED */
152198 187, /* (338) nm ::= STRING */
152199 187, /* (339) nm ::= JOIN_KW */
152200 201, /* (340) typetoken ::= typename */
152201 202, /* (341) typename ::= ID|STRING */
152202 203, /* (342) signed ::= plus_num */
152203 203, /* (343) signed ::= minus_num */
152204 200, /* (344) carglist ::= carglist ccons */
152205 200, /* (345) carglist ::= */
152206 208, /* (346) ccons ::= NULL onconf */
152207 196, /* (347) conslist_opt ::= COMMA conslist */
152208 220, /* (348) conslist ::= conslist tconscomma tcons */
152209 220, /* (349) conslist ::= tcons */
152210 221, /* (350) tconscomma ::= */
152211 225, /* (351) defer_subclause_opt ::= defer_subclause */
152212 227, /* (352) resolvetype ::= raisetype */
152213 231, /* (353) selectnowith ::= oneselect */
152214 232, /* (354) oneselect ::= values */
152215 246, /* (355) sclp ::= selcollist COMMA */
152216 247, /* (356) as ::= ID|STRING */
152217 210, /* (357) expr ::= term */
152218 264, /* (358) likeop ::= LIKE_KW|MATCH */
152219 254, /* (359) exprlist ::= nexprlist */
152220 274, /* (360) nmnum ::= plus_num */
152221 274, /* (361) nmnum ::= nm */
152222 274, /* (362) nmnum ::= ON */
152223 274, /* (363) nmnum ::= DELETE */
152224 274, /* (364) nmnum ::= DEFAULT */
152225 204, /* (365) plus_num ::= INTEGER|FLOAT */
152226 279, /* (366) foreach_clause ::= */
152227 279, /* (367) foreach_clause ::= FOR EACH ROW */
152228 282, /* (368) trnm ::= nm */
152229 283, /* (369) tridxby ::= */
152230 284, /* (370) database_kw_opt ::= DATABASE */
152231 284, /* (371) database_kw_opt ::= */
152232 287, /* (372) kwcolumn_opt ::= */
152233 287, /* (373) kwcolumn_opt ::= COLUMNKW */
152234 289, /* (374) vtabarglist ::= vtabarg */
152235 289, /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */
152236 290, /* (376) vtabarg ::= vtabarg vtabargtoken */
152237 293, /* (377) anylist ::= */
152238 293, /* (378) anylist ::= anylist LP anylist RP */
152239 293, /* (379) anylist ::= anylist ANY */
152240 258, /* (380) with ::= */
152241 };
152242
152243 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
152244 ** of symbols on the right-hand side of that rule. */
152245 static const signed char yyRuleInfoNRhs[] = {
@@ -151555,256 +152371,261 @@
152371 -2, /* (125) indexed_opt ::= NOT INDEXED */
152372 -4, /* (126) using_opt ::= USING LP idlist RP */
152373 0, /* (127) using_opt ::= */
152374 0, /* (128) orderby_opt ::= */
152375 -3, /* (129) orderby_opt ::= ORDER BY sortlist */
152376 -5, /* (130) sortlist ::= sortlist COMMA expr sortorder nulls */
152377 -3, /* (131) sortlist ::= expr sortorder nulls */
152378 -1, /* (132) sortorder ::= ASC */
152379 -1, /* (133) sortorder ::= DESC */
152380 0, /* (134) sortorder ::= */
152381 -2, /* (135) nulls ::= NULLS FIRST */
152382 -2, /* (136) nulls ::= NULLS LAST */
152383 0, /* (137) nulls ::= */
152384 0, /* (138) groupby_opt ::= */
152385 -3, /* (139) groupby_opt ::= GROUP BY nexprlist */
152386 0, /* (140) having_opt ::= */
152387 -2, /* (141) having_opt ::= HAVING expr */
152388 0, /* (142) limit_opt ::= */
152389 -2, /* (143) limit_opt ::= LIMIT expr */
152390 -4, /* (144) limit_opt ::= LIMIT expr OFFSET expr */
152391 -4, /* (145) limit_opt ::= LIMIT expr COMMA expr */
152392 -6, /* (146) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
152393 0, /* (147) where_opt ::= */
152394 -2, /* (148) where_opt ::= WHERE expr */
152395 -8, /* (149) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
152396 -5, /* (150) setlist ::= setlist COMMA nm EQ expr */
152397 -7, /* (151) setlist ::= setlist COMMA LP idlist RP EQ expr */
152398 -3, /* (152) setlist ::= nm EQ expr */
152399 -5, /* (153) setlist ::= LP idlist RP EQ expr */
152400 -7, /* (154) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
152401 -7, /* (155) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
152402 0, /* (156) upsert ::= */
152403 -11, /* (157) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
152404 -8, /* (158) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
152405 -4, /* (159) upsert ::= ON CONFLICT DO NOTHING */
152406 -2, /* (160) insert_cmd ::= INSERT orconf */
152407 -1, /* (161) insert_cmd ::= REPLACE */
152408 0, /* (162) idlist_opt ::= */
152409 -3, /* (163) idlist_opt ::= LP idlist RP */
152410 -3, /* (164) idlist ::= idlist COMMA nm */
152411 -1, /* (165) idlist ::= nm */
152412 -3, /* (166) expr ::= LP expr RP */
152413 -1, /* (167) expr ::= ID|INDEXED */
152414 -1, /* (168) expr ::= JOIN_KW */
152415 -3, /* (169) expr ::= nm DOT nm */
152416 -5, /* (170) expr ::= nm DOT nm DOT nm */
152417 -1, /* (171) term ::= NULL|FLOAT|BLOB */
152418 -1, /* (172) term ::= STRING */
152419 -1, /* (173) term ::= INTEGER */
152420 -1, /* (174) expr ::= VARIABLE */
152421 -3, /* (175) expr ::= expr COLLATE ID|STRING */
152422 -6, /* (176) expr ::= CAST LP expr AS typetoken RP */
152423 -5, /* (177) expr ::= ID|INDEXED LP distinct exprlist RP */
152424 -4, /* (178) expr ::= ID|INDEXED LP STAR RP */
152425 -6, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
152426 -5, /* (180) expr ::= ID|INDEXED LP STAR RP filter_over */
152427 -1, /* (181) term ::= CTIME_KW */
152428 -5, /* (182) expr ::= LP nexprlist COMMA expr RP */
152429 -3, /* (183) expr ::= expr AND expr */
152430 -3, /* (184) expr ::= expr OR expr */
152431 -3, /* (185) expr ::= expr LT|GT|GE|LE expr */
152432 -3, /* (186) expr ::= expr EQ|NE expr */
152433 -3, /* (187) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
152434 -3, /* (188) expr ::= expr PLUS|MINUS expr */
152435 -3, /* (189) expr ::= expr STAR|SLASH|REM expr */
152436 -3, /* (190) expr ::= expr CONCAT expr */
152437 -2, /* (191) likeop ::= NOT LIKE_KW|MATCH */
152438 -3, /* (192) expr ::= expr likeop expr */
152439 -5, /* (193) expr ::= expr likeop expr ESCAPE expr */
152440 -2, /* (194) expr ::= expr ISNULL|NOTNULL */
152441 -3, /* (195) expr ::= expr NOT NULL */
152442 -3, /* (196) expr ::= expr IS expr */
152443 -4, /* (197) expr ::= expr IS NOT expr */
152444 -2, /* (198) expr ::= NOT expr */
152445 -2, /* (199) expr ::= BITNOT expr */
152446 -2, /* (200) expr ::= PLUS|MINUS expr */
152447 -1, /* (201) between_op ::= BETWEEN */
152448 -2, /* (202) between_op ::= NOT BETWEEN */
152449 -5, /* (203) expr ::= expr between_op expr AND expr */
152450 -1, /* (204) in_op ::= IN */
152451 -2, /* (205) in_op ::= NOT IN */
152452 -5, /* (206) expr ::= expr in_op LP exprlist RP */
152453 -3, /* (207) expr ::= LP select RP */
152454 -5, /* (208) expr ::= expr in_op LP select RP */
152455 -5, /* (209) expr ::= expr in_op nm dbnm paren_exprlist */
152456 -4, /* (210) expr ::= EXISTS LP select RP */
152457 -5, /* (211) expr ::= CASE case_operand case_exprlist case_else END */
152458 -5, /* (212) case_exprlist ::= case_exprlist WHEN expr THEN expr */
152459 -4, /* (213) case_exprlist ::= WHEN expr THEN expr */
152460 -2, /* (214) case_else ::= ELSE expr */
152461 0, /* (215) case_else ::= */
152462 -1, /* (216) case_operand ::= expr */
152463 0, /* (217) case_operand ::= */
152464 0, /* (218) exprlist ::= */
152465 -3, /* (219) nexprlist ::= nexprlist COMMA expr */
152466 -1, /* (220) nexprlist ::= expr */
152467 0, /* (221) paren_exprlist ::= */
152468 -3, /* (222) paren_exprlist ::= LP exprlist RP */
152469 -12, /* (223) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
152470 -1, /* (224) uniqueflag ::= UNIQUE */
152471 0, /* (225) uniqueflag ::= */
152472 0, /* (226) eidlist_opt ::= */
152473 -3, /* (227) eidlist_opt ::= LP eidlist RP */
152474 -5, /* (228) eidlist ::= eidlist COMMA nm collate sortorder */
152475 -3, /* (229) eidlist ::= nm collate sortorder */
152476 0, /* (230) collate ::= */
152477 -2, /* (231) collate ::= COLLATE ID|STRING */
152478 -4, /* (232) cmd ::= DROP INDEX ifexists fullname */
152479 -2, /* (233) cmd ::= VACUUM vinto */
152480 -3, /* (234) cmd ::= VACUUM nm vinto */
152481 -2, /* (235) vinto ::= INTO expr */
152482 0, /* (236) vinto ::= */
152483 -3, /* (237) cmd ::= PRAGMA nm dbnm */
152484 -5, /* (238) cmd ::= PRAGMA nm dbnm EQ nmnum */
152485 -6, /* (239) cmd ::= PRAGMA nm dbnm LP nmnum RP */
152486 -5, /* (240) cmd ::= PRAGMA nm dbnm EQ minus_num */
152487 -6, /* (241) cmd ::= PRAGMA nm dbnm LP minus_num RP */
152488 -2, /* (242) plus_num ::= PLUS INTEGER|FLOAT */
152489 -2, /* (243) minus_num ::= MINUS INTEGER|FLOAT */
152490 -5, /* (244) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
152491 -11, /* (245) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
152492 -1, /* (246) trigger_time ::= BEFORE|AFTER */
152493 -2, /* (247) trigger_time ::= INSTEAD OF */
152494 0, /* (248) trigger_time ::= */
152495 -1, /* (249) trigger_event ::= DELETE|INSERT */
152496 -1, /* (250) trigger_event ::= UPDATE */
152497 -3, /* (251) trigger_event ::= UPDATE OF idlist */
152498 0, /* (252) when_clause ::= */
152499 -2, /* (253) when_clause ::= WHEN expr */
152500 -3, /* (254) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
152501 -2, /* (255) trigger_cmd_list ::= trigger_cmd SEMI */
152502 -3, /* (256) trnm ::= nm DOT nm */
152503 -3, /* (257) tridxby ::= INDEXED BY nm */
152504 -2, /* (258) tridxby ::= NOT INDEXED */
152505 -8, /* (259) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
152506 -8, /* (260) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
152507 -6, /* (261) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
152508 -3, /* (262) trigger_cmd ::= scanpt select scanpt */
152509 -4, /* (263) expr ::= RAISE LP IGNORE RP */
152510 -6, /* (264) expr ::= RAISE LP raisetype COMMA nm RP */
152511 -1, /* (265) raisetype ::= ROLLBACK */
152512 -1, /* (266) raisetype ::= ABORT */
152513 -1, /* (267) raisetype ::= FAIL */
152514 -4, /* (268) cmd ::= DROP TRIGGER ifexists fullname */
152515 -6, /* (269) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
152516 -3, /* (270) cmd ::= DETACH database_kw_opt expr */
152517 0, /* (271) key_opt ::= */
152518 -2, /* (272) key_opt ::= KEY expr */
152519 -1, /* (273) cmd ::= REINDEX */
152520 -3, /* (274) cmd ::= REINDEX nm dbnm */
152521 -1, /* (275) cmd ::= ANALYZE */
152522 -3, /* (276) cmd ::= ANALYZE nm dbnm */
152523 -6, /* (277) cmd ::= ALTER TABLE fullname RENAME TO nm */
152524 -7, /* (278) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
152525 -1, /* (279) add_column_fullname ::= fullname */
152526 -8, /* (280) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
152527 -1, /* (281) cmd ::= create_vtab */
152528 -4, /* (282) cmd ::= create_vtab LP vtabarglist RP */
152529 -8, /* (283) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
152530 0, /* (284) vtabarg ::= */
152531 -1, /* (285) vtabargtoken ::= ANY */
152532 -3, /* (286) vtabargtoken ::= lp anylist RP */
152533 -1, /* (287) lp ::= LP */
152534 -2, /* (288) with ::= WITH wqlist */
152535 -3, /* (289) with ::= WITH RECURSIVE wqlist */
152536 -6, /* (290) wqlist ::= nm eidlist_opt AS LP select RP */
152537 -8, /* (291) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
152538 -1, /* (292) windowdefn_list ::= windowdefn */
152539 -3, /* (293) windowdefn_list ::= windowdefn_list COMMA windowdefn */
152540 -5, /* (294) windowdefn ::= nm AS LP window RP */
152541 -5, /* (295) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
152542 -6, /* (296) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
152543 -4, /* (297) window ::= ORDER BY sortlist frame_opt */
152544 -5, /* (298) window ::= nm ORDER BY sortlist frame_opt */
152545 -1, /* (299) window ::= frame_opt */
152546 -2, /* (300) window ::= nm frame_opt */
152547 0, /* (301) frame_opt ::= */
152548 -3, /* (302) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
152549 -6, /* (303) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
152550 -1, /* (304) range_or_rows ::= RANGE|ROWS|GROUPS */
152551 -1, /* (305) frame_bound_s ::= frame_bound */
152552 -2, /* (306) frame_bound_s ::= UNBOUNDED PRECEDING */
152553 -1, /* (307) frame_bound_e ::= frame_bound */
152554 -2, /* (308) frame_bound_e ::= UNBOUNDED FOLLOWING */
152555 -2, /* (309) frame_bound ::= expr PRECEDING|FOLLOWING */
152556 -2, /* (310) frame_bound ::= CURRENT ROW */
152557 0, /* (311) frame_exclude_opt ::= */
152558 -2, /* (312) frame_exclude_opt ::= EXCLUDE frame_exclude */
152559 -2, /* (313) frame_exclude ::= NO OTHERS */
152560 -2, /* (314) frame_exclude ::= CURRENT ROW */
152561 -1, /* (315) frame_exclude ::= GROUP|TIES */
152562 -2, /* (316) window_clause ::= WINDOW windowdefn_list */
152563 -2, /* (317) filter_over ::= filter_clause over_clause */
152564 -1, /* (318) filter_over ::= over_clause */
152565 -1, /* (319) filter_over ::= filter_clause */
152566 -4, /* (320) over_clause ::= OVER LP window RP */
152567 -2, /* (321) over_clause ::= OVER nm */
152568 -5, /* (322) filter_clause ::= FILTER LP WHERE expr RP */
152569 -1, /* (323) input ::= cmdlist */
152570 -2, /* (324) cmdlist ::= cmdlist ecmd */
152571 -1, /* (325) cmdlist ::= ecmd */
152572 -1, /* (326) ecmd ::= SEMI */
152573 -2, /* (327) ecmd ::= cmdx SEMI */
152574 -2, /* (328) ecmd ::= explain cmdx */
152575 0, /* (329) trans_opt ::= */
152576 -1, /* (330) trans_opt ::= TRANSACTION */
152577 -2, /* (331) trans_opt ::= TRANSACTION nm */
152578 -1, /* (332) savepoint_opt ::= SAVEPOINT */
152579 0, /* (333) savepoint_opt ::= */
152580 -2, /* (334) cmd ::= create_table create_table_args */
152581 -4, /* (335) columnlist ::= columnlist COMMA columnname carglist */
152582 -2, /* (336) columnlist ::= columnname carglist */
152583 -1, /* (337) nm ::= ID|INDEXED */
152584 -1, /* (338) nm ::= STRING */
152585 -1, /* (339) nm ::= JOIN_KW */
152586 -1, /* (340) typetoken ::= typename */
152587 -1, /* (341) typename ::= ID|STRING */
152588 -1, /* (342) signed ::= plus_num */
152589 -1, /* (343) signed ::= minus_num */
152590 -2, /* (344) carglist ::= carglist ccons */
152591 0, /* (345) carglist ::= */
152592 -2, /* (346) ccons ::= NULL onconf */
152593 -2, /* (347) conslist_opt ::= COMMA conslist */
152594 -3, /* (348) conslist ::= conslist tconscomma tcons */
152595 -1, /* (349) conslist ::= tcons */
152596 0, /* (350) tconscomma ::= */
152597 -1, /* (351) defer_subclause_opt ::= defer_subclause */
152598 -1, /* (352) resolvetype ::= raisetype */
152599 -1, /* (353) selectnowith ::= oneselect */
152600 -1, /* (354) oneselect ::= values */
152601 -2, /* (355) sclp ::= selcollist COMMA */
152602 -1, /* (356) as ::= ID|STRING */
152603 -1, /* (357) expr ::= term */
152604 -1, /* (358) likeop ::= LIKE_KW|MATCH */
152605 -1, /* (359) exprlist ::= nexprlist */
152606 -1, /* (360) nmnum ::= plus_num */
152607 -1, /* (361) nmnum ::= nm */
152608 -1, /* (362) nmnum ::= ON */
152609 -1, /* (363) nmnum ::= DELETE */
152610 -1, /* (364) nmnum ::= DEFAULT */
152611 -1, /* (365) plus_num ::= INTEGER|FLOAT */
152612 0, /* (366) foreach_clause ::= */
152613 -3, /* (367) foreach_clause ::= FOR EACH ROW */
152614 -1, /* (368) trnm ::= nm */
152615 0, /* (369) tridxby ::= */
152616 -1, /* (370) database_kw_opt ::= DATABASE */
152617 0, /* (371) database_kw_opt ::= */
152618 0, /* (372) kwcolumn_opt ::= */
152619 -1, /* (373) kwcolumn_opt ::= COLUMNKW */
152620 -1, /* (374) vtabarglist ::= vtabarg */
152621 -3, /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */
152622 -2, /* (376) vtabarg ::= vtabarg vtabargtoken */
152623 0, /* (377) anylist ::= */
152624 -4, /* (378) anylist ::= anylist LP anylist RP */
152625 -2, /* (379) anylist ::= anylist ANY */
152626 0, /* (380) with ::= */
152627 };
152628
152629 static void yy_accept(yyParser*); /* Forward Declaration */
152630
152631 /*
@@ -151897,20 +152718,20 @@
152718 break;
152719 case 2: /* cmdx ::= cmd */
152720 { sqlite3FinishCoding(pParse); }
152721 break;
152722 case 3: /* cmd ::= BEGIN transtype trans_opt */
152723 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy32);}
152724 break;
152725 case 4: /* transtype ::= */
152726 {yymsp[1].minor.yy32 = TK_DEFERRED;}
152727 break;
152728 case 5: /* transtype ::= DEFERRED */
152729 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
152730 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
152731 case 304: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==304);
152732 {yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-X*/}
152733 break;
152734 case 8: /* cmd ::= COMMIT|END trans_opt */
152735 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
152736 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
152737 break;
@@ -151929,11 +152750,11 @@
152750 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
152751 }
152752 break;
152753 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
152754 {
152755 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy32,0,0,yymsp[-2].minor.yy32);
152756 }
152757 break;
152758 case 14: /* createkw ::= CREATE */
152759 {disableLookaside(pParse);}
152760 break;
@@ -151943,37 +152764,37 @@
152764 case 43: /* autoinc ::= */ yytestcase(yyruleno==43);
152765 case 58: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==58);
152766 case 68: /* defer_subclause_opt ::= */ yytestcase(yyruleno==68);
152767 case 77: /* ifexists ::= */ yytestcase(yyruleno==77);
152768 case 94: /* distinct ::= */ yytestcase(yyruleno==94);
152769 case 230: /* collate ::= */ yytestcase(yyruleno==230);
152770 {yymsp[1].minor.yy32 = 0;}
152771 break;
152772 case 16: /* ifnotexists ::= IF NOT EXISTS */
152773 {yymsp[-2].minor.yy32 = 1;}
152774 break;
152775 case 17: /* temp ::= TEMP */
152776 case 44: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==44);
152777 {yymsp[0].minor.yy32 = 1;}
152778 break;
152779 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
152780 {
152781 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy32,0);
152782 }
152783 break;
152784 case 20: /* create_table_args ::= AS select */
152785 {
152786 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy25);
152787 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy25);
152788 }
152789 break;
152790 case 22: /* table_options ::= WITHOUT nm */
152791 {
152792 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
152793 yymsp[-1].minor.yy32 = TF_WithoutRowid | TF_NoVisibleRowid;
152794 }else{
152795 yymsp[-1].minor.yy32 = 0;
152796 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
152797 }
152798 }
152799 break;
152800 case 23: /* columnname ::= nm typetoken */
@@ -151998,11 +152819,11 @@
152819 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
152820 break;
152821 case 28: /* scanpt ::= */
152822 {
152823 assert( yyLookahead!=YYNOCODE );
152824 yymsp[1].minor.yy8 = yyLookaheadToken.z;
152825 }
152826 break;
152827 case 29: /* scantok ::= */
152828 {
152829 assert( yyLookahead!=YYNOCODE );
@@ -152012,21 +152833,21 @@
152833 case 30: /* ccons ::= CONSTRAINT nm */
152834 case 63: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==63);
152835 {pParse->constraintName = yymsp[0].minor.yy0;}
152836 break;
152837 case 31: /* ccons ::= DEFAULT scantok term */
152838 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy46,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
152839 break;
152840 case 32: /* ccons ::= DEFAULT LP expr RP */
152841 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy46,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
152842 break;
152843 case 33: /* ccons ::= DEFAULT PLUS scantok term */
152844 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy46,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
152845 break;
152846 case 34: /* ccons ::= DEFAULT MINUS scantok term */
152847 {
152848 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy46, 0);
152849 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
152850 }
152851 break;
152852 case 35: /* ccons ::= DEFAULT scantok ID|INDEXED */
152853 {
@@ -152037,319 +152858,319 @@
152858 }
152859 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
152860 }
152861 break;
152862 case 36: /* ccons ::= NOT NULL onconf */
152863 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy32);}
152864 break;
152865 case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
152866 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy32,yymsp[0].minor.yy32,yymsp[-2].minor.yy32);}
152867 break;
152868 case 38: /* ccons ::= UNIQUE onconf */
152869 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy32,0,0,0,0,
152870 SQLITE_IDXTYPE_UNIQUE);}
152871 break;
152872 case 39: /* ccons ::= CHECK LP expr RP */
152873 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy46);}
152874 break;
152875 case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */
152876 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy138,yymsp[0].minor.yy32);}
152877 break;
152878 case 41: /* ccons ::= defer_subclause */
152879 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy32);}
152880 break;
152881 case 42: /* ccons ::= COLLATE ID|STRING */
152882 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
152883 break;
152884 case 45: /* refargs ::= */
152885 { yymsp[1].minor.yy32 = OE_None*0x0101; /* EV: R-19803-45884 */}
152886 break;
152887 case 46: /* refargs ::= refargs refarg */
152888 { yymsp[-1].minor.yy32 = (yymsp[-1].minor.yy32 & ~yymsp[0].minor.yy495.mask) | yymsp[0].minor.yy495.value; }
152889 break;
152890 case 47: /* refarg ::= MATCH nm */
152891 { yymsp[-1].minor.yy495.value = 0; yymsp[-1].minor.yy495.mask = 0x000000; }
152892 break;
152893 case 48: /* refarg ::= ON INSERT refact */
152894 { yymsp[-2].minor.yy495.value = 0; yymsp[-2].minor.yy495.mask = 0x000000; }
152895 break;
152896 case 49: /* refarg ::= ON DELETE refact */
152897 { yymsp[-2].minor.yy495.value = yymsp[0].minor.yy32; yymsp[-2].minor.yy495.mask = 0x0000ff; }
152898 break;
152899 case 50: /* refarg ::= ON UPDATE refact */
152900 { yymsp[-2].minor.yy495.value = yymsp[0].minor.yy32<<8; yymsp[-2].minor.yy495.mask = 0x00ff00; }
152901 break;
152902 case 51: /* refact ::= SET NULL */
152903 { yymsp[-1].minor.yy32 = OE_SetNull; /* EV: R-33326-45252 */}
152904 break;
152905 case 52: /* refact ::= SET DEFAULT */
152906 { yymsp[-1].minor.yy32 = OE_SetDflt; /* EV: R-33326-45252 */}
152907 break;
152908 case 53: /* refact ::= CASCADE */
152909 { yymsp[0].minor.yy32 = OE_Cascade; /* EV: R-33326-45252 */}
152910 break;
152911 case 54: /* refact ::= RESTRICT */
152912 { yymsp[0].minor.yy32 = OE_Restrict; /* EV: R-33326-45252 */}
152913 break;
152914 case 55: /* refact ::= NO ACTION */
152915 { yymsp[-1].minor.yy32 = OE_None; /* EV: R-33326-45252 */}
152916 break;
152917 case 56: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
152918 {yymsp[-2].minor.yy32 = 0;}
152919 break;
152920 case 57: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
152921 case 72: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==72);
152922 case 160: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==160);
152923 {yymsp[-1].minor.yy32 = yymsp[0].minor.yy32;}
152924 break;
152925 case 59: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
152926 case 76: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==76);
152927 case 202: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==202);
152928 case 205: /* in_op ::= NOT IN */ yytestcase(yyruleno==205);
152929 case 231: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==231);
152930 {yymsp[-1].minor.yy32 = 1;}
152931 break;
152932 case 60: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
152933 {yymsp[-1].minor.yy32 = 0;}
152934 break;
152935 case 62: /* tconscomma ::= COMMA */
152936 {pParse->constraintName.n = 0;}
152937 break;
152938 case 64: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
152939 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy138,yymsp[0].minor.yy32,yymsp[-2].minor.yy32,0);}
152940 break;
152941 case 65: /* tcons ::= UNIQUE LP sortlist RP onconf */
152942 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy138,yymsp[0].minor.yy32,0,0,0,0,
152943 SQLITE_IDXTYPE_UNIQUE);}
152944 break;
152945 case 66: /* tcons ::= CHECK LP expr RP onconf */
152946 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy46);}
152947 break;
152948 case 67: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
152949 {
152950 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy138, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy138, yymsp[-1].minor.yy32);
152951 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy32);
152952 }
152953 break;
152954 case 69: /* onconf ::= */
152955 case 71: /* orconf ::= */ yytestcase(yyruleno==71);
152956 {yymsp[1].minor.yy32 = OE_Default;}
152957 break;
152958 case 70: /* onconf ::= ON CONFLICT resolvetype */
152959 {yymsp[-2].minor.yy32 = yymsp[0].minor.yy32;}
152960 break;
152961 case 73: /* resolvetype ::= IGNORE */
152962 {yymsp[0].minor.yy32 = OE_Ignore;}
152963 break;
152964 case 74: /* resolvetype ::= REPLACE */
152965 case 161: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==161);
152966 {yymsp[0].minor.yy32 = OE_Replace;}
152967 break;
152968 case 75: /* cmd ::= DROP TABLE ifexists fullname */
152969 {
152970 sqlite3DropTable(pParse, yymsp[0].minor.yy609, 0, yymsp[-1].minor.yy32);
152971 }
152972 break;
152973 case 78: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
152974 {
152975 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy138, yymsp[0].minor.yy25, yymsp[-7].minor.yy32, yymsp[-5].minor.yy32);
152976 }
152977 break;
152978 case 79: /* cmd ::= DROP VIEW ifexists fullname */
152979 {
152980 sqlite3DropTable(pParse, yymsp[0].minor.yy609, 1, yymsp[-1].minor.yy32);
152981 }
152982 break;
152983 case 80: /* cmd ::= select */
152984 {
152985 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
152986 sqlite3Select(pParse, yymsp[0].minor.yy25, &dest);
152987 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy25);
152988 }
152989 break;
152990 case 81: /* select ::= WITH wqlist selectnowith */
152991 {
152992 Select *p = yymsp[0].minor.yy25;
152993 if( p ){
152994 p->pWith = yymsp[-1].minor.yy297;
152995 parserDoubleLinkSelect(pParse, p);
152996 }else{
152997 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy297);
152998 }
152999 yymsp[-2].minor.yy25 = p;
153000 }
153001 break;
153002 case 82: /* select ::= WITH RECURSIVE wqlist selectnowith */
153003 {
153004 Select *p = yymsp[0].minor.yy25;
153005 if( p ){
153006 p->pWith = yymsp[-1].minor.yy297;
153007 parserDoubleLinkSelect(pParse, p);
153008 }else{
153009 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy297);
153010 }
153011 yymsp[-3].minor.yy25 = p;
153012 }
153013 break;
153014 case 83: /* select ::= selectnowith */
153015 {
153016 Select *p = yymsp[0].minor.yy25;
153017 if( p ){
153018 parserDoubleLinkSelect(pParse, p);
153019 }
153020 yymsp[0].minor.yy25 = p; /*A-overwrites-X*/
153021 }
153022 break;
153023 case 84: /* selectnowith ::= selectnowith multiselect_op oneselect */
153024 {
153025 Select *pRhs = yymsp[0].minor.yy25;
153026 Select *pLhs = yymsp[-2].minor.yy25;
153027 if( pRhs && pRhs->pPrior ){
153028 SrcList *pFrom;
153029 Token x;
153030 x.n = 0;
153031 parserDoubleLinkSelect(pParse, pRhs);
153032 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
153033 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
153034 }
153035 if( pRhs ){
153036 pRhs->op = (u8)yymsp[-1].minor.yy32;
153037 pRhs->pPrior = pLhs;
153038 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
153039 pRhs->selFlags &= ~SF_MultiValue;
153040 if( yymsp[-1].minor.yy32!=TK_ALL ) pParse->hasCompound = 1;
153041 }else{
153042 sqlite3SelectDelete(pParse->db, pLhs);
153043 }
153044 yymsp[-2].minor.yy25 = pRhs;
153045 }
153046 break;
153047 case 85: /* multiselect_op ::= UNION */
153048 case 87: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==87);
153049 {yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-OP*/}
153050 break;
153051 case 86: /* multiselect_op ::= UNION ALL */
153052 {yymsp[-1].minor.yy32 = TK_ALL;}
153053 break;
153054 case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
153055 {
153056 yymsp[-8].minor.yy25 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy138,yymsp[-5].minor.yy609,yymsp[-4].minor.yy46,yymsp[-3].minor.yy138,yymsp[-2].minor.yy46,yymsp[-1].minor.yy138,yymsp[-7].minor.yy32,yymsp[0].minor.yy46);
153057 }
153058 break;
153059 case 89: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
153060 {
153061 yymsp[-9].minor.yy25 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy138,yymsp[-6].minor.yy609,yymsp[-5].minor.yy46,yymsp[-4].minor.yy138,yymsp[-3].minor.yy46,yymsp[-1].minor.yy138,yymsp[-8].minor.yy32,yymsp[0].minor.yy46);
153062 if( yymsp[-9].minor.yy25 ){
153063 yymsp[-9].minor.yy25->pWinDefn = yymsp[-2].minor.yy455;
153064 }else{
153065 sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy455);
153066 }
153067 }
153068 break;
153069 case 90: /* values ::= VALUES LP nexprlist RP */
153070 {
153071 yymsp[-3].minor.yy25 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy138,0,0,0,0,0,SF_Values,0);
153072 }
153073 break;
153074 case 91: /* values ::= values COMMA LP nexprlist RP */
153075 {
153076 Select *pRight, *pLeft = yymsp[-4].minor.yy25;
153077 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy138,0,0,0,0,0,SF_Values|SF_MultiValue,0);
153078 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
153079 if( pRight ){
153080 pRight->op = TK_ALL;
153081 pRight->pPrior = pLeft;
153082 yymsp[-4].minor.yy25 = pRight;
153083 }else{
153084 yymsp[-4].minor.yy25 = pLeft;
153085 }
153086 }
153087 break;
153088 case 92: /* distinct ::= DISTINCT */
153089 {yymsp[0].minor.yy32 = SF_Distinct;}
153090 break;
153091 case 93: /* distinct ::= ALL */
153092 {yymsp[0].minor.yy32 = SF_All;}
153093 break;
153094 case 95: /* sclp ::= */
153095 case 128: /* orderby_opt ::= */ yytestcase(yyruleno==128);
153096 case 138: /* groupby_opt ::= */ yytestcase(yyruleno==138);
153097 case 218: /* exprlist ::= */ yytestcase(yyruleno==218);
153098 case 221: /* paren_exprlist ::= */ yytestcase(yyruleno==221);
153099 case 226: /* eidlist_opt ::= */ yytestcase(yyruleno==226);
153100 {yymsp[1].minor.yy138 = 0;}
153101 break;
153102 case 96: /* selcollist ::= sclp scanpt expr scanpt as */
153103 {
153104 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy138, yymsp[-2].minor.yy46);
153105 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy138, &yymsp[0].minor.yy0, 1);
153106 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy138,yymsp[-3].minor.yy8,yymsp[-1].minor.yy8);
153107 }
153108 break;
153109 case 97: /* selcollist ::= sclp scanpt STAR */
153110 {
153111 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
153112 yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy138, p);
153113 }
153114 break;
153115 case 98: /* selcollist ::= sclp scanpt nm DOT STAR */
153116 {
153117 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
153118 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
153119 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
153120 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, pDot);
153121 }
153122 break;
153123 case 99: /* as ::= AS nm */
153124 case 110: /* dbnm ::= DOT nm */ yytestcase(yyruleno==110);
153125 case 242: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==242);
153126 case 243: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==243);
153127 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
153128 break;
153129 case 101: /* from ::= */
153130 {yymsp[1].minor.yy609 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy609));}
153131 break;
153132 case 102: /* from ::= FROM seltablist */
153133 {
153134 yymsp[-1].minor.yy609 = yymsp[0].minor.yy609;
153135 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy609);
153136 }
153137 break;
153138 case 103: /* stl_prefix ::= seltablist joinop */
153139 {
153140 if( ALWAYS(yymsp[-1].minor.yy609 && yymsp[-1].minor.yy609->nSrc>0) ) yymsp[-1].minor.yy609->a[yymsp[-1].minor.yy609->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy32;
153141 }
153142 break;
153143 case 104: /* stl_prefix ::= */
153144 {yymsp[1].minor.yy609 = 0;}
153145 break;
153146 case 105: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
153147 {
153148 yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy46,yymsp[0].minor.yy406);
153149 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy609, &yymsp[-2].minor.yy0);
153150 }
153151 break;
153152 case 106: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
153153 {
153154 yymsp[-8].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy609,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy46,yymsp[0].minor.yy406);
153155 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy609, yymsp[-4].minor.yy138);
153156 }
153157 break;
153158 case 107: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
153159 {
153160 yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy25,yymsp[-1].minor.yy46,yymsp[0].minor.yy406);
153161 }
153162 break;
153163 case 108: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
153164 {
153165 if( yymsp[-6].minor.yy609==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy46==0 && yymsp[0].minor.yy406==0 ){
153166 yymsp[-6].minor.yy609 = yymsp[-4].minor.yy609;
153167 }else if( yymsp[-4].minor.yy609->nSrc==1 ){
153168 yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy46,yymsp[0].minor.yy406);
153169 if( yymsp[-6].minor.yy609 ){
153170 struct SrcList_item *pNew = &yymsp[-6].minor.yy609->a[yymsp[-6].minor.yy609->nSrc-1];
153171 struct SrcList_item *pOld = yymsp[-4].minor.yy609->a;
153172 pNew->zName = pOld->zName;
153173 pNew->zDatabase = pOld->zDatabase;
153174 pNew->pSelect = pOld->pSelect;
153175 if( pOld->fg.isTabFunc ){
153176 pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -152358,953 +153179,946 @@
153179 pNew->fg.isTabFunc = 1;
153180 }
153181 pOld->zName = pOld->zDatabase = 0;
153182 pOld->pSelect = 0;
153183 }
153184 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy609);
153185 }else{
153186 Select *pSubquery;
153187 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy609);
153188 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy609,0,0,0,0,SF_NestedFrom,0);
153189 yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy46,yymsp[0].minor.yy406);
153190 }
153191 }
153192 break;
153193 case 109: /* dbnm ::= */
153194 case 123: /* indexed_opt ::= */ yytestcase(yyruleno==123);
153195 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
153196 break;
153197 case 111: /* fullname ::= nm */
153198 {
153199 yylhsminor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
153200 if( IN_RENAME_OBJECT && yylhsminor.yy609 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy609->a[0].zName, &yymsp[0].minor.yy0);
153201 }
153202 yymsp[0].minor.yy609 = yylhsminor.yy609;
153203 break;
153204 case 112: /* fullname ::= nm DOT nm */
153205 {
153206 yylhsminor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
153207 if( IN_RENAME_OBJECT && yylhsminor.yy609 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy609->a[0].zName, &yymsp[0].minor.yy0);
153208 }
153209 yymsp[-2].minor.yy609 = yylhsminor.yy609;
153210 break;
153211 case 113: /* xfullname ::= nm */
153212 {yymsp[0].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
153213 break;
153214 case 114: /* xfullname ::= nm DOT nm */
153215 {yymsp[-2].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
153216 break;
153217 case 115: /* xfullname ::= nm DOT nm AS nm */
153218 {
153219 yymsp[-4].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
153220 if( yymsp[-4].minor.yy609 ) yymsp[-4].minor.yy609->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
153221 }
153222 break;
153223 case 116: /* xfullname ::= nm AS nm */
153224 {
153225 yymsp[-2].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
153226 if( yymsp[-2].minor.yy609 ) yymsp[-2].minor.yy609->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
153227 }
153228 break;
153229 case 117: /* joinop ::= COMMA|JOIN */
153230 { yymsp[0].minor.yy32 = JT_INNER; }
153231 break;
153232 case 118: /* joinop ::= JOIN_KW JOIN */
153233 {yymsp[-1].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
153234 break;
153235 case 119: /* joinop ::= JOIN_KW nm JOIN */
153236 {yymsp[-2].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
153237 break;
153238 case 120: /* joinop ::= JOIN_KW nm nm JOIN */
153239 {yymsp[-3].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
153240 break;
153241 case 121: /* on_opt ::= ON expr */
153242 case 141: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==141);
153243 case 148: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==148);
153244 case 214: /* case_else ::= ELSE expr */ yytestcase(yyruleno==214);
153245 case 235: /* vinto ::= INTO expr */ yytestcase(yyruleno==235);
153246 {yymsp[-1].minor.yy46 = yymsp[0].minor.yy46;}
153247 break;
153248 case 122: /* on_opt ::= */
153249 case 140: /* having_opt ::= */ yytestcase(yyruleno==140);
153250 case 142: /* limit_opt ::= */ yytestcase(yyruleno==142);
153251 case 147: /* where_opt ::= */ yytestcase(yyruleno==147);
153252 case 215: /* case_else ::= */ yytestcase(yyruleno==215);
153253 case 217: /* case_operand ::= */ yytestcase(yyruleno==217);
153254 case 236: /* vinto ::= */ yytestcase(yyruleno==236);
153255 {yymsp[1].minor.yy46 = 0;}
153256 break;
153257 case 124: /* indexed_opt ::= INDEXED BY nm */
153258 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
153259 break;
153260 case 125: /* indexed_opt ::= NOT INDEXED */
153261 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
153262 break;
153263 case 126: /* using_opt ::= USING LP idlist RP */
153264 {yymsp[-3].minor.yy406 = yymsp[-1].minor.yy406;}
153265 break;
153266 case 127: /* using_opt ::= */
153267 case 162: /* idlist_opt ::= */ yytestcase(yyruleno==162);
153268 {yymsp[1].minor.yy406 = 0;}
153269 break;
153270 case 129: /* orderby_opt ::= ORDER BY sortlist */
153271 case 139: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==139);
153272 {yymsp[-2].minor.yy138 = yymsp[0].minor.yy138;}
153273 break;
153274 case 130: /* sortlist ::= sortlist COMMA expr sortorder nulls */
153275 {
153276 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138,yymsp[-2].minor.yy46);
153277 sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy138,yymsp[-1].minor.yy32,yymsp[0].minor.yy32);
153278 }
153279 break;
153280 case 131: /* sortlist ::= expr sortorder nulls */
153281 {
153282 yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy46); /*A-overwrites-Y*/
153283 sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy138,yymsp[-1].minor.yy32,yymsp[0].minor.yy32);
153284 }
153285 break;
153286 case 132: /* sortorder ::= ASC */
153287 {yymsp[0].minor.yy32 = SQLITE_SO_ASC;}
153288 break;
153289 case 133: /* sortorder ::= DESC */
153290 {yymsp[0].minor.yy32 = SQLITE_SO_DESC;}
153291 break;
153292 case 134: /* sortorder ::= */
153293 case 137: /* nulls ::= */ yytestcase(yyruleno==137);
153294 {yymsp[1].minor.yy32 = SQLITE_SO_UNDEFINED;}
153295 break;
153296 case 135: /* nulls ::= NULLS FIRST */
153297 {yymsp[-1].minor.yy32 = SQLITE_SO_ASC;}
153298 break;
153299 case 136: /* nulls ::= NULLS LAST */
153300 {yymsp[-1].minor.yy32 = SQLITE_SO_DESC;}
153301 break;
153302 case 143: /* limit_opt ::= LIMIT expr */
153303 {yymsp[-1].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy46,0);}
153304 break;
153305 case 144: /* limit_opt ::= LIMIT expr OFFSET expr */
153306 {yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153307 break;
153308 case 145: /* limit_opt ::= LIMIT expr COMMA expr */
153309 {yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy46,yymsp[-2].minor.yy46);}
153310 break;
153311 case 146: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
153312 {
153313 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy609, &yymsp[-1].minor.yy0);
153314 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy609,yymsp[0].minor.yy46,0,0);
153315 }
153316 break;
153317 case 149: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
153318 {
153319 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy609, &yymsp[-3].minor.yy0);
153320 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy138,"set list");
153321 sqlite3Update(pParse,yymsp[-4].minor.yy609,yymsp[-1].minor.yy138,yymsp[0].minor.yy46,yymsp[-5].minor.yy32,0,0,0);
153322 }
153323 break;
153324 case 150: /* setlist ::= setlist COMMA nm EQ expr */
153325 {
153326 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy138, yymsp[0].minor.yy46);
153327 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy138, &yymsp[-2].minor.yy0, 1);
153328 }
153329 break;
153330 case 151: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
153331 {
153332 yymsp[-6].minor.yy138 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy138, yymsp[-3].minor.yy406, yymsp[0].minor.yy46);
153333 }
153334 break;
153335 case 152: /* setlist ::= nm EQ expr */
153336 {
153337 yylhsminor.yy138 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy46);
153338 sqlite3ExprListSetName(pParse, yylhsminor.yy138, &yymsp[-2].minor.yy0, 1);
153339 }
153340 yymsp[-2].minor.yy138 = yylhsminor.yy138;
153341 break;
153342 case 153: /* setlist ::= LP idlist RP EQ expr */
153343 {
153344 yymsp[-4].minor.yy138 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy406, yymsp[0].minor.yy46);
153345 }
153346 break;
153347 case 154: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
153348 {
153349 sqlite3Insert(pParse, yymsp[-3].minor.yy609, yymsp[-1].minor.yy25, yymsp[-2].minor.yy406, yymsp[-5].minor.yy32, yymsp[0].minor.yy288);
153350 }
153351 break;
153352 case 155: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
153353 {
153354 sqlite3Insert(pParse, yymsp[-3].minor.yy609, 0, yymsp[-2].minor.yy406, yymsp[-5].minor.yy32, 0);
153355 }
153356 break;
153357 case 156: /* upsert ::= */
153358 { yymsp[1].minor.yy288 = 0; }
153359 break;
153360 case 157: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
153361 { yymsp[-10].minor.yy288 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy138,yymsp[-5].minor.yy46,yymsp[-1].minor.yy138,yymsp[0].minor.yy46);}
153362 break;
153363 case 158: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
153364 { yymsp[-7].minor.yy288 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy138,yymsp[-2].minor.yy46,0,0); }
153365 break;
153366 case 159: /* upsert ::= ON CONFLICT DO NOTHING */
153367 { yymsp[-3].minor.yy288 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
153368 break;
153369 case 163: /* idlist_opt ::= LP idlist RP */
153370 {yymsp[-2].minor.yy406 = yymsp[-1].minor.yy406;}
153371 break;
153372 case 164: /* idlist ::= idlist COMMA nm */
153373 {yymsp[-2].minor.yy406 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy406,&yymsp[0].minor.yy0);}
153374 break;
153375 case 165: /* idlist ::= nm */
153376 {yymsp[0].minor.yy406 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
153377 break;
153378 case 166: /* expr ::= LP expr RP */
153379 {yymsp[-2].minor.yy46 = yymsp[-1].minor.yy46;}
153380 break;
153381 case 167: /* expr ::= ID|INDEXED */
153382 case 168: /* expr ::= JOIN_KW */ yytestcase(yyruleno==168);
153383 {yymsp[0].minor.yy46=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
153384 break;
153385 case 169: /* expr ::= nm DOT nm */
153386 {
153387 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
153388 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
153389 if( IN_RENAME_OBJECT ){
153390 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
153391 sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
153392 }
153393 yylhsminor.yy46 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
153394 }
153395 yymsp[-2].minor.yy46 = yylhsminor.yy46;
153396 break;
153397 case 170: /* expr ::= nm DOT nm DOT nm */
153398 {
153399 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
153400 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
153401 Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
153402 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
153403 if( IN_RENAME_OBJECT ){
153404 sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
153405 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
153406 }
153407 yylhsminor.yy46 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
153408 }
153409 yymsp[-4].minor.yy46 = yylhsminor.yy46;
153410 break;
153411 case 171: /* term ::= NULL|FLOAT|BLOB */
153412 case 172: /* term ::= STRING */ yytestcase(yyruleno==172);
153413 {yymsp[0].minor.yy46=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
153414 break;
153415 case 173: /* term ::= INTEGER */
153416 {
153417 yylhsminor.yy46 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
153418 }
153419 yymsp[0].minor.yy46 = yylhsminor.yy46;
153420 break;
153421 case 174: /* expr ::= VARIABLE */
153422 {
153423 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
153424 u32 n = yymsp[0].minor.yy0.n;
153425 yymsp[0].minor.yy46 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
153426 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy46, n);
153427 }else{
153428 /* When doing a nested parse, one can include terms in an expression
153429 ** that look like this: #1 #2 ... These terms refer to registers
153430 ** in the virtual machine. #N is the N-th register. */
153431 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
153432 assert( t.n>=2 );
153433 if( pParse->nested==0 ){
153434 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
153435 yymsp[0].minor.yy46 = 0;
153436 }else{
153437 yymsp[0].minor.yy46 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
153438 if( yymsp[0].minor.yy46 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy46->iTable);
153439 }
153440 }
153441 }
153442 break;
153443 case 175: /* expr ::= expr COLLATE ID|STRING */
153444 {
153445 yymsp[-2].minor.yy46 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy46, &yymsp[0].minor.yy0, 1);
153446 }
153447 break;
153448 case 176: /* expr ::= CAST LP expr AS typetoken RP */
153449 {
153450 yymsp[-5].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
153451 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy46, yymsp[-3].minor.yy46, 0);
153452 }
153453 break;
153454 case 177: /* expr ::= ID|INDEXED LP distinct exprlist RP */
153455 {
153456 yylhsminor.yy46 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy138, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy32);
153457 }
153458 yymsp[-4].minor.yy46 = yylhsminor.yy46;
153459 break;
153460 case 178: /* expr ::= ID|INDEXED LP STAR RP */
153461 {
153462 yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
153463 }
153464 yymsp[-3].minor.yy46 = yylhsminor.yy46;
153465 break;
153466 case 179: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
153467 {
153468 yylhsminor.yy46 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy138, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy32);
153469 sqlite3WindowAttach(pParse, yylhsminor.yy46, yymsp[0].minor.yy455);
153470 }
153471 yymsp[-5].minor.yy46 = yylhsminor.yy46;
153472 break;
153473 case 180: /* expr ::= ID|INDEXED LP STAR RP filter_over */
153474 {
153475 yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
153476 sqlite3WindowAttach(pParse, yylhsminor.yy46, yymsp[0].minor.yy455);
153477 }
153478 yymsp[-4].minor.yy46 = yylhsminor.yy46;
153479 break;
153480 case 181: /* term ::= CTIME_KW */
153481 {
153482 yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
153483 }
153484 yymsp[0].minor.yy46 = yylhsminor.yy46;
153485 break;
153486 case 182: /* expr ::= LP nexprlist COMMA expr RP */
153487 {
153488 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy138, yymsp[-1].minor.yy46);
153489 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
153490 if( yymsp[-4].minor.yy46 ){
153491 yymsp[-4].minor.yy46->x.pList = pList;
153492 }else{
153493 sqlite3ExprListDelete(pParse->db, pList);
153494 }
153495 }
153496 break;
153497 case 183: /* expr ::= expr AND expr */
153498 {yymsp[-2].minor.yy46=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153499 break;
153500 case 184: /* expr ::= expr OR expr */
153501 case 185: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==185);
153502 case 186: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==186);
153503 case 187: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==187);
153504 case 188: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==188);
153505 case 189: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==189);
153506 case 190: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==190);
153507 {yymsp[-2].minor.yy46=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153508 break;
153509 case 191: /* likeop ::= NOT LIKE_KW|MATCH */
153510 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
153511 break;
153512 case 192: /* expr ::= expr likeop expr */
153513 {
153514 ExprList *pList;
153515 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
153516 yymsp[-1].minor.yy0.n &= 0x7fffffff;
153517 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy46);
153518 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy46);
153519 yymsp[-2].minor.yy46 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
153520 if( bNot ) yymsp[-2].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy46, 0);
153521 if( yymsp[-2].minor.yy46 ) yymsp[-2].minor.yy46->flags |= EP_InfixFunc;
153522 }
153523 break;
153524 case 193: /* expr ::= expr likeop expr ESCAPE expr */
153525 {
153526 ExprList *pList;
153527 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
153528 yymsp[-3].minor.yy0.n &= 0x7fffffff;
153529 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153530 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy46);
153531 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy46);
153532 yymsp[-4].minor.yy46 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
153533 if( bNot ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153534 if( yymsp[-4].minor.yy46 ) yymsp[-4].minor.yy46->flags |= EP_InfixFunc;
153535 }
153536 break;
153537 case 194: /* expr ::= expr ISNULL|NOTNULL */
153538 {yymsp[-1].minor.yy46 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy46,0);}
153539 break;
153540 case 195: /* expr ::= expr NOT NULL */
153541 {yymsp[-2].minor.yy46 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy46,0);}
153542 break;
153543 case 196: /* expr ::= expr IS expr */
153544 {
153545 yymsp[-2].minor.yy46 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);
153546 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy46, yymsp[-2].minor.yy46, TK_ISNULL);
153547 }
153548 break;
153549 case 197: /* expr ::= expr IS NOT expr */
153550 {
153551 yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy46,yymsp[0].minor.yy46);
153552 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy46, yymsp[-3].minor.yy46, TK_NOTNULL);
153553 }
153554 break;
153555 case 198: /* expr ::= NOT expr */
153556 case 199: /* expr ::= BITNOT expr */ yytestcase(yyruleno==199);
153557 {yymsp[-1].minor.yy46 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy46, 0);/*A-overwrites-B*/}
153558 break;
153559 case 200: /* expr ::= PLUS|MINUS expr */
153560 {
153561 yymsp[-1].minor.yy46 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy46, 0);
153562 /*A-overwrites-B*/
153563 }
153564 break;
153565 case 201: /* between_op ::= BETWEEN */
153566 case 204: /* in_op ::= IN */ yytestcase(yyruleno==204);
153567 {yymsp[0].minor.yy32 = 0;}
153568 break;
153569 case 203: /* expr ::= expr between_op expr AND expr */
153570 {
153571 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153572 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy46);
153573 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy46, 0);
153574 if( yymsp[-4].minor.yy46 ){
153575 yymsp[-4].minor.yy46->x.pList = pList;
153576 }else{
153577 sqlite3ExprListDelete(pParse->db, pList);
153578 }
153579 if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153580 }
153581 break;
153582 case 206: /* expr ::= expr in_op LP exprlist RP */
153583 {
153584 if( yymsp[-1].minor.yy138==0 ){
153585 /* Expressions of the form
153586 **
153587 ** expr1 IN ()
153588 ** expr1 NOT IN ()
153589 **
153590 ** simplify to constants 0 (false) and 1 (true), respectively,
153591 ** regardless of the value of expr1.
153592 */
153593 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy46);
153594 yymsp[-4].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy32],1);
153595 }else{
153596 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153597 if( yymsp[-4].minor.yy46 ){
153598 yymsp[-4].minor.yy46->x.pList = yymsp[-1].minor.yy138;
153599 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy46);
153600 }else{
153601 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy138);
153602 }
153603 if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153604 }
153605 }
153606 break;
153607 case 207: /* expr ::= LP select RP */
153608 {
153609 yymsp[-2].minor.yy46 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
153610 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy46, yymsp[-1].minor.yy25);
153611 }
153612 break;
153613 case 208: /* expr ::= expr in_op LP select RP */
153614 {
153615 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153616 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy46, yymsp[-1].minor.yy25);
153617 if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153618 }
153619 break;
153620 case 209: /* expr ::= expr in_op nm dbnm paren_exprlist */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153621 {
153622 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
153623 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
153624 if( yymsp[0].minor.yy138 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy138);
153625 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153626 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy46, pSelect);
153627 if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153628 }
153629 break;
153630 case 210: /* expr ::= EXISTS LP select RP */
153631 {
153632 Expr *p;
153633 p = yymsp[-3].minor.yy46 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
153634 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy25);
153635 }
153636 break;
153637 case 211: /* expr ::= CASE case_operand case_exprlist case_else END */
153638 {
153639 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy46, 0);
153640 if( yymsp[-4].minor.yy46 ){
153641 yymsp[-4].minor.yy46->x.pList = yymsp[-1].minor.yy46 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy138,yymsp[-1].minor.yy46) : yymsp[-2].minor.yy138;
153642 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy46);
153643 }else{
153644 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy138);
153645 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy46);
153646 }
153647 }
153648 break;
153649 case 212: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
153650 {
153651 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, yymsp[-2].minor.yy46);
153652 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, yymsp[0].minor.yy46);
153653 }
153654 break;
153655 case 213: /* case_exprlist ::= WHEN expr THEN expr */
153656 {
153657 yymsp[-3].minor.yy138 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153658 yymsp[-3].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy138, yymsp[0].minor.yy46);
153659 }
153660 break;
153661 case 216: /* case_operand ::= expr */
153662 {yymsp[0].minor.yy46 = yymsp[0].minor.yy46; /*A-overwrites-X*/}
153663 break;
153664 case 219: /* nexprlist ::= nexprlist COMMA expr */
153665 {yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy138,yymsp[0].minor.yy46);}
153666 break;
153667 case 220: /* nexprlist ::= expr */
153668 {yymsp[0].minor.yy138 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy46); /*A-overwrites-Y*/}
153669 break;
153670 case 222: /* paren_exprlist ::= LP exprlist RP */
153671 case 227: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==227);
153672 {yymsp[-2].minor.yy138 = yymsp[-1].minor.yy138;}
153673 break;
153674 case 223: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
153675 {
153676 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
153677 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy138, yymsp[-10].minor.yy32,
153678 &yymsp[-11].minor.yy0, yymsp[0].minor.yy46, SQLITE_SO_ASC, yymsp[-8].minor.yy32, SQLITE_IDXTYPE_APPDEF);
153679 if( IN_RENAME_OBJECT && pParse->pNewIndex ){
153680 sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
153681 }
153682 }
153683 break;
153684 case 224: /* uniqueflag ::= UNIQUE */
153685 case 266: /* raisetype ::= ABORT */ yytestcase(yyruleno==266);
153686 {yymsp[0].minor.yy32 = OE_Abort;}
153687 break;
153688 case 225: /* uniqueflag ::= */
153689 {yymsp[1].minor.yy32 = OE_None;}
153690 break;
153691 case 228: /* eidlist ::= eidlist COMMA nm collate sortorder */
153692 {
153693 yymsp[-4].minor.yy138 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy138, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy32, yymsp[0].minor.yy32);
153694 }
153695 break;
153696 case 229: /* eidlist ::= nm collate sortorder */
153697 {
153698 yymsp[-2].minor.yy138 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy32, yymsp[0].minor.yy32); /*A-overwrites-Y*/
153699 }
153700 break;
153701 case 232: /* cmd ::= DROP INDEX ifexists fullname */
153702 {sqlite3DropIndex(pParse, yymsp[0].minor.yy609, yymsp[-1].minor.yy32);}
153703 break;
153704 case 233: /* cmd ::= VACUUM vinto */
153705 {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy46);}
153706 break;
153707 case 234: /* cmd ::= VACUUM nm vinto */
153708 {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy46);}
153709 break;
153710 case 237: /* cmd ::= PRAGMA nm dbnm */
153711 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
153712 break;
153713 case 238: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
153714 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
153715 break;
153716 case 239: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
153717 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
153718 break;
153719 case 240: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
153720 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
153721 break;
153722 case 241: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
153723 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
153724 break;
153725 case 244: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
153726 {
153727 Token all;
153728 all.z = yymsp[-3].minor.yy0.z;
153729 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
153730 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy527, &all);
153731 }
153732 break;
153733 case 245: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
153734 {
153735 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy32, yymsp[-4].minor.yy572.a, yymsp[-4].minor.yy572.b, yymsp[-2].minor.yy609, yymsp[0].minor.yy46, yymsp[-10].minor.yy32, yymsp[-8].minor.yy32);
153736 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
153737 }
153738 break;
153739 case 246: /* trigger_time ::= BEFORE|AFTER */
153740 { yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-X*/ }
153741 break;
153742 case 247: /* trigger_time ::= INSTEAD OF */
153743 { yymsp[-1].minor.yy32 = TK_INSTEAD;}
153744 break;
153745 case 248: /* trigger_time ::= */
153746 { yymsp[1].minor.yy32 = TK_BEFORE; }
153747 break;
153748 case 249: /* trigger_event ::= DELETE|INSERT */
153749 case 250: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==250);
153750 {yymsp[0].minor.yy572.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy572.b = 0;}
153751 break;
153752 case 251: /* trigger_event ::= UPDATE OF idlist */
153753 {yymsp[-2].minor.yy572.a = TK_UPDATE; yymsp[-2].minor.yy572.b = yymsp[0].minor.yy406;}
153754 break;
153755 case 252: /* when_clause ::= */
153756 case 271: /* key_opt ::= */ yytestcase(yyruleno==271);
153757 { yymsp[1].minor.yy46 = 0; }
153758 break;
153759 case 253: /* when_clause ::= WHEN expr */
153760 case 272: /* key_opt ::= KEY expr */ yytestcase(yyruleno==272);
153761 { yymsp[-1].minor.yy46 = yymsp[0].minor.yy46; }
153762 break;
153763 case 254: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
153764 {
153765 assert( yymsp[-2].minor.yy527!=0 );
153766 yymsp[-2].minor.yy527->pLast->pNext = yymsp[-1].minor.yy527;
153767 yymsp[-2].minor.yy527->pLast = yymsp[-1].minor.yy527;
153768 }
153769 break;
153770 case 255: /* trigger_cmd_list ::= trigger_cmd SEMI */
153771 {
153772 assert( yymsp[-1].minor.yy527!=0 );
153773 yymsp[-1].minor.yy527->pLast = yymsp[-1].minor.yy527;
153774 }
153775 break;
153776 case 256: /* trnm ::= nm DOT nm */
 
153777 {
153778 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
153779 sqlite3ErrorMsg(pParse,
153780 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
153781 "statements within triggers");
153782 }
153783 break;
153784 case 257: /* tridxby ::= INDEXED BY nm */
153785 {
153786 sqlite3ErrorMsg(pParse,
153787 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
153788 "within triggers");
153789 }
153790 break;
153791 case 258: /* tridxby ::= NOT INDEXED */
153792 {
153793 sqlite3ErrorMsg(pParse,
153794 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
153795 "within triggers");
153796 }
153797 break;
153798 case 259: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
153799 {yylhsminor.yy527 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy138, yymsp[-1].minor.yy46, yymsp[-6].minor.yy32, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy8);}
153800 yymsp[-7].minor.yy527 = yylhsminor.yy527;
153801 break;
153802 case 260: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
153803 {
153804 yylhsminor.yy527 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy406,yymsp[-2].minor.yy25,yymsp[-6].minor.yy32,yymsp[-1].minor.yy288,yymsp[-7].minor.yy8,yymsp[0].minor.yy8);/*yylhsminor.yy527-overwrites-yymsp[-6].minor.yy32*/
153805 }
153806 yymsp[-7].minor.yy527 = yylhsminor.yy527;
153807 break;
153808 case 261: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
153809 {yylhsminor.yy527 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy46, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy8);}
153810 yymsp[-5].minor.yy527 = yylhsminor.yy527;
153811 break;
153812 case 262: /* trigger_cmd ::= scanpt select scanpt */
153813 {yylhsminor.yy527 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy25, yymsp[-2].minor.yy8, yymsp[0].minor.yy8); /*yylhsminor.yy527-overwrites-yymsp[-1].minor.yy25*/}
153814 yymsp[-2].minor.yy527 = yylhsminor.yy527;
153815 break;
153816 case 263: /* expr ::= RAISE LP IGNORE RP */
153817 {
153818 yymsp[-3].minor.yy46 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
153819 if( yymsp[-3].minor.yy46 ){
153820 yymsp[-3].minor.yy46->affExpr = OE_Ignore;
153821 }
153822 }
153823 break;
153824 case 264: /* expr ::= RAISE LP raisetype COMMA nm RP */
153825 {
153826 yymsp[-5].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
153827 if( yymsp[-5].minor.yy46 ) {
153828 yymsp[-5].minor.yy46->affExpr = (char)yymsp[-3].minor.yy32;
153829 }
153830 }
153831 break;
153832 case 265: /* raisetype ::= ROLLBACK */
153833 {yymsp[0].minor.yy32 = OE_Rollback;}
153834 break;
153835 case 267: /* raisetype ::= FAIL */
153836 {yymsp[0].minor.yy32 = OE_Fail;}
153837 break;
153838 case 268: /* cmd ::= DROP TRIGGER ifexists fullname */
153839 {
153840 sqlite3DropTrigger(pParse,yymsp[0].minor.yy609,yymsp[-1].minor.yy32);
153841 }
153842 break;
153843 case 269: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
153844 {
153845 sqlite3Attach(pParse, yymsp[-3].minor.yy46, yymsp[-1].minor.yy46, yymsp[0].minor.yy46);
153846 }
153847 break;
153848 case 270: /* cmd ::= DETACH database_kw_opt expr */
153849 {
153850 sqlite3Detach(pParse, yymsp[0].minor.yy46);
153851 }
153852 break;
153853 case 273: /* cmd ::= REINDEX */
153854 {sqlite3Reindex(pParse, 0, 0);}
153855 break;
153856 case 274: /* cmd ::= REINDEX nm dbnm */
153857 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
153858 break;
153859 case 275: /* cmd ::= ANALYZE */
153860 {sqlite3Analyze(pParse, 0, 0);}
153861 break;
153862 case 276: /* cmd ::= ANALYZE nm dbnm */
153863 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
153864 break;
153865 case 277: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
153866 {
153867 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy609,&yymsp[0].minor.yy0);
153868 }
153869 break;
153870 case 278: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
153871 {
153872 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
153873 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
153874 }
153875 break;
153876 case 279: /* add_column_fullname ::= fullname */
153877 {
153878 disableLookaside(pParse);
153879 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy609);
153880 }
153881 break;
153882 case 280: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
153883 {
153884 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy609, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
153885 }
153886 break;
153887 case 281: /* cmd ::= create_vtab */
153888 {sqlite3VtabFinishParse(pParse,0);}
153889 break;
153890 case 282: /* cmd ::= create_vtab LP vtabarglist RP */
153891 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
153892 break;
153893 case 283: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
153894 {
153895 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy32);
153896 }
153897 break;
153898 case 284: /* vtabarg ::= */
153899 {sqlite3VtabArgInit(pParse);}
153900 break;
153901 case 285: /* vtabargtoken ::= ANY */
153902 case 286: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==286);
153903 case 287: /* lp ::= LP */ yytestcase(yyruleno==287);
153904 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
153905 break;
153906 case 288: /* with ::= WITH wqlist */
153907 case 289: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==289);
153908 { sqlite3WithPush(pParse, yymsp[0].minor.yy297, 1); }
153909 break;
153910 case 290: /* wqlist ::= nm eidlist_opt AS LP select RP */
153911 {
153912 yymsp[-5].minor.yy297 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy138, yymsp[-1].minor.yy25); /*A-overwrites-X*/
153913 }
153914 break;
153915 case 291: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
153916 {
153917 yymsp[-7].minor.yy297 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy297, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy138, yymsp[-1].minor.yy25);
153918 }
153919 break;
153920 case 292: /* windowdefn_list ::= windowdefn */
153921 { yylhsminor.yy455 = yymsp[0].minor.yy455; }
153922 yymsp[0].minor.yy455 = yylhsminor.yy455;
153923 break;
153924 case 293: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
153925 {
153926 assert( yymsp[0].minor.yy455!=0 );
153927 sqlite3WindowChain(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy455);
153928 yymsp[0].minor.yy455->pNextWin = yymsp[-2].minor.yy455;
153929 yylhsminor.yy455 = yymsp[0].minor.yy455;
153930 }
153931 yymsp[-2].minor.yy455 = yylhsminor.yy455;
153932 break;
153933 case 294: /* windowdefn ::= nm AS LP window RP */
153934 {
153935 if( ALWAYS(yymsp[-1].minor.yy455) ){
153936 yymsp[-1].minor.yy455->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
153937 }
153938 yylhsminor.yy455 = yymsp[-1].minor.yy455;
153939 }
153940 yymsp[-4].minor.yy455 = yylhsminor.yy455;
153941 break;
153942 case 295: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
153943 {
153944 yymsp[-4].minor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy138, yymsp[-1].minor.yy138, 0);
153945 }
153946 break;
153947 case 296: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
153948 {
153949 yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy138, yymsp[-1].minor.yy138, &yymsp[-5].minor.yy0);
153950 }
153951 yymsp[-5].minor.yy455 = yylhsminor.yy455;
153952 break;
153953 case 297: /* window ::= ORDER BY sortlist frame_opt */
153954 {
153955 yymsp[-3].minor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, yymsp[-1].minor.yy138, 0);
153956 }
153957 break;
153958 case 298: /* window ::= nm ORDER BY sortlist frame_opt */
153959 {
153960 yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, yymsp[-1].minor.yy138, &yymsp[-4].minor.yy0);
153961 }
153962 yymsp[-4].minor.yy455 = yylhsminor.yy455;
153963 break;
153964 case 299: /* window ::= frame_opt */
153965 case 318: /* filter_over ::= over_clause */ yytestcase(yyruleno==318);
153966 {
153967 yylhsminor.yy455 = yymsp[0].minor.yy455;
153968 }
153969 yymsp[0].minor.yy455 = yylhsminor.yy455;
153970 break;
153971 case 300: /* window ::= nm frame_opt */
153972 {
153973 yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, 0, &yymsp[-1].minor.yy0);
153974 }
153975 yymsp[-1].minor.yy455 = yylhsminor.yy455;
153976 break;
153977 case 301: /* frame_opt ::= */
153978 {
153979 yymsp[1].minor.yy455 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
153980 }
153981 break;
153982 case 302: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
153983 {
153984 yylhsminor.yy455 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy32, yymsp[-1].minor.yy57.eType, yymsp[-1].minor.yy57.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy118);
153985 }
153986 yymsp[-2].minor.yy455 = yylhsminor.yy455;
153987 break;
153988 case 303: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
153989 {
153990 yylhsminor.yy455 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy32, yymsp[-3].minor.yy57.eType, yymsp[-3].minor.yy57.pExpr, yymsp[-1].minor.yy57.eType, yymsp[-1].minor.yy57.pExpr, yymsp[0].minor.yy118);
153991 }
153992 yymsp[-5].minor.yy455 = yylhsminor.yy455;
153993 break;
153994 case 305: /* frame_bound_s ::= frame_bound */
153995 case 307: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==307);
153996 {yylhsminor.yy57 = yymsp[0].minor.yy57;}
153997 yymsp[0].minor.yy57 = yylhsminor.yy57;
153998 break;
153999 case 306: /* frame_bound_s ::= UNBOUNDED PRECEDING */
154000 case 308: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==308);
154001 case 310: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==310);
154002 {yylhsminor.yy57.eType = yymsp[-1].major; yylhsminor.yy57.pExpr = 0;}
154003 yymsp[-1].minor.yy57 = yylhsminor.yy57;
154004 break;
154005 case 309: /* frame_bound ::= expr PRECEDING|FOLLOWING */
154006 {yylhsminor.yy57.eType = yymsp[0].major; yylhsminor.yy57.pExpr = yymsp[-1].minor.yy46;}
154007 yymsp[-1].minor.yy57 = yylhsminor.yy57;
154008 break;
154009 case 311: /* frame_exclude_opt ::= */
154010 {yymsp[1].minor.yy118 = 0;}
154011 break;
154012 case 312: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
154013 {yymsp[-1].minor.yy118 = yymsp[0].minor.yy118;}
154014 break;
154015 case 313: /* frame_exclude ::= NO OTHERS */
154016 case 314: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==314);
154017 {yymsp[-1].minor.yy118 = yymsp[-1].major; /*A-overwrites-X*/}
154018 break;
154019 case 315: /* frame_exclude ::= GROUP|TIES */
154020 {yymsp[0].minor.yy118 = yymsp[0].major; /*A-overwrites-X*/}
154021 break;
154022 case 316: /* window_clause ::= WINDOW windowdefn_list */
154023 { yymsp[-1].minor.yy455 = yymsp[0].minor.yy455; }
154024 break;
154025 case 317: /* filter_over ::= filter_clause over_clause */
154026 {
154027 yymsp[0].minor.yy455->pFilter = yymsp[-1].minor.yy46;
154028 yylhsminor.yy455 = yymsp[0].minor.yy455;
154029 }
154030 yymsp[-1].minor.yy455 = yylhsminor.yy455;
154031 break;
154032 case 319: /* filter_over ::= filter_clause */
154033 {
154034 yylhsminor.yy455 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
154035 if( yylhsminor.yy455 ){
154036 yylhsminor.yy455->eFrmType = TK_FILTER;
154037 yylhsminor.yy455->pFilter = yymsp[0].minor.yy46;
154038 }else{
154039 sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy46);
154040 }
154041 }
154042 yymsp[0].minor.yy455 = yylhsminor.yy455;
154043 break;
154044 case 320: /* over_clause ::= OVER LP window RP */
154045 {
154046 yymsp[-3].minor.yy455 = yymsp[-1].minor.yy455;
154047 assert( yymsp[-3].minor.yy455!=0 );
154048 }
154049 break;
154050 case 321: /* over_clause ::= OVER nm */
154051 {
154052 yymsp[-1].minor.yy455 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
154053 if( yymsp[-1].minor.yy455 ){
154054 yymsp[-1].minor.yy455->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
154055 }
154056 }
154057 break;
154058 case 322: /* filter_clause ::= FILTER LP WHERE expr RP */
154059 { yymsp[-4].minor.yy46 = yymsp[-1].minor.yy46; }
154060 break;
154061 default:
154062 /* (323) input ::= cmdlist */ yytestcase(yyruleno==323);
154063 /* (324) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==324);
154064 /* (325) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=325);
154065 /* (326) ecmd ::= SEMI */ yytestcase(yyruleno==326);
154066 /* (327) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==327);
154067 /* (328) ecmd ::= explain cmdx */ yytestcase(yyruleno==328);
154068 /* (329) trans_opt ::= */ yytestcase(yyruleno==329);
154069 /* (330) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==330);
154070 /* (331) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==331);
154071 /* (332) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==332);
154072 /* (333) savepoint_opt ::= */ yytestcase(yyruleno==333);
154073 /* (334) cmd ::= create_table create_table_args */ yytestcase(yyruleno==334);
154074 /* (335) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==335);
154075 /* (336) columnlist ::= columnname carglist */ yytestcase(yyruleno==336);
154076 /* (337) nm ::= ID|INDEXED */ yytestcase(yyruleno==337);
154077 /* (338) nm ::= STRING */ yytestcase(yyruleno==338);
154078 /* (339) nm ::= JOIN_KW */ yytestcase(yyruleno==339);
154079 /* (340) typetoken ::= typename */ yytestcase(yyruleno==340);
154080 /* (341) typename ::= ID|STRING */ yytestcase(yyruleno==341);
154081 /* (342) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=342);
154082 /* (343) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=343);
154083 /* (344) carglist ::= carglist ccons */ yytestcase(yyruleno==344);
154084 /* (345) carglist ::= */ yytestcase(yyruleno==345);
154085 /* (346) ccons ::= NULL onconf */ yytestcase(yyruleno==346);
154086 /* (347) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==347);
154087 /* (348) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==348);
154088 /* (349) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=349);
154089 /* (350) tconscomma ::= */ yytestcase(yyruleno==350);
154090 /* (351) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=351);
154091 /* (352) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=352);
154092 /* (353) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=353);
154093 /* (354) oneselect ::= values */ yytestcase(yyruleno==354);
154094 /* (355) sclp ::= selcollist COMMA */ yytestcase(yyruleno==355);
154095 /* (356) as ::= ID|STRING */ yytestcase(yyruleno==356);
154096 /* (357) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=357);
154097 /* (358) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==358);
154098 /* (359) exprlist ::= nexprlist */ yytestcase(yyruleno==359);
154099 /* (360) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=360);
154100 /* (361) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=361);
154101 /* (362) nmnum ::= ON */ yytestcase(yyruleno==362);
154102 /* (363) nmnum ::= DELETE */ yytestcase(yyruleno==363);
154103 /* (364) nmnum ::= DEFAULT */ yytestcase(yyruleno==364);
154104 /* (365) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==365);
154105 /* (366) foreach_clause ::= */ yytestcase(yyruleno==366);
154106 /* (367) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==367);
154107 /* (368) trnm ::= nm */ yytestcase(yyruleno==368);
154108 /* (369) tridxby ::= */ yytestcase(yyruleno==369);
154109 /* (370) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==370);
154110 /* (371) database_kw_opt ::= */ yytestcase(yyruleno==371);
154111 /* (372) kwcolumn_opt ::= */ yytestcase(yyruleno==372);
154112 /* (373) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==373);
154113 /* (374) vtabarglist ::= vtabarg */ yytestcase(yyruleno==374);
154114 /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==375);
154115 /* (376) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==376);
154116 /* (377) anylist ::= */ yytestcase(yyruleno==377);
154117 /* (378) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==378);
154118 /* (379) anylist ::= anylist ANY */ yytestcase(yyruleno==379);
154119 /* (380) with ::= */ yytestcase(yyruleno==380);
154120 break;
154121 /********** End reduce actions ************************************************/
154122 };
154123 assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
154124 yygoto = yyRuleInfoLhs[yyruleno];
@@ -153592,13 +154406,12 @@
154406 ** Return the fallback token corresponding to canonical token iToken, or
154407 ** 0 if iToken has no fallback.
154408 */
154409 SQLITE_PRIVATE int sqlite3ParserFallback(int iToken){
154410 #ifdef YYFALLBACK
154411 assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) );
154412 return yyFallback[iToken];
 
154413 #else
154414 (void)iToken;
154415 #endif
154416 return 0;
154417 }
@@ -153763,148 +154576,150 @@
154576 ** might be implemented more directly using a hand-written hash table.
154577 ** But by using this automatically generated code, the size of the code
154578 ** is substantially reduced. This is important for embedded applications
154579 ** on platforms with limited memory.
154580 */
154581 /* Hash score: 221 */
154582 /* zKWText[] encodes 967 bytes of keyword text in 638 bytes */
154583 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
154584 /* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYISNULLSAVEPOINTERSECT */
154585 /* IESNOTNULLIKEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTS */
154586 /* CONSTRAINTOFFSETRIGGEREFERENCESUNIQUERYWITHOUTERELEASEATTACH */
154587 /* AVINGLOBEGINNERANGEBETWEENOTHINGROUPSCASCADETACHCASECOLLATE */
154588 /* CREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORT */
154589 /* UPDATEVALUESVIRTUALASTWHENWHERECURSIVEAFTERENAMEANDEFAULT */
154590 /* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */
154591 /* ARTITIONDEFERREDISTINCTDROPRECEDINGFAILIMITFILTEREPLACEFIRST */
154592 /* FOLLOWINGFROMFULLIFORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */
154593 /* UNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBYINITIALLYPRIMARY */
154594 static const char zKWText[637] = {
154595 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
154596 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
154597 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
154598 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
154599 'E','R','R','A','B','L','E','L','S','E','X','C','L','U','D','E','L','E',
154600 'T','E','M','P','O','R','A','R','Y','I','S','N','U','L','L','S','A','V',
154601 'E','P','O','I','N','T','E','R','S','E','C','T','I','E','S','N','O','T',
154602 'N','U','L','L','I','K','E','X','C','E','P','T','R','A','N','S','A','C',
154603 'T','I','O','N','A','T','U','R','A','L','T','E','R','A','I','S','E','X',
154604 'C','L','U','S','I','V','E','X','I','S','T','S','C','O','N','S','T','R',
154605 'A','I','N','T','O','F','F','S','E','T','R','I','G','G','E','R','E','F',
154606 'E','R','E','N','C','E','S','U','N','I','Q','U','E','R','Y','W','I','T',
154607 'H','O','U','T','E','R','E','L','E','A','S','E','A','T','T','A','C','H',
154608 'A','V','I','N','G','L','O','B','E','G','I','N','N','E','R','A','N','G',
154609 'E','B','E','T','W','E','E','N','O','T','H','I','N','G','R','O','U','P',
154610 'S','C','A','S','C','A','D','E','T','A','C','H','C','A','S','E','C','O',
154611 'L','L','A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T',
154612 '_','D','A','T','E','I','M','M','E','D','I','A','T','E','J','O','I','N',
154613 'S','E','R','T','M','A','T','C','H','P','L','A','N','A','L','Y','Z','E',
154614 'P','R','A','G','M','A','B','O','R','T','U','P','D','A','T','E','V','A',
154615 'L','U','E','S','V','I','R','T','U','A','L','A','S','T','W','H','E','N',
154616 'W','H','E','R','E','C','U','R','S','I','V','E','A','F','T','E','R','E',
154617 'N','A','M','E','A','N','D','E','F','A','U','L','T','A','U','T','O','I',
154618 'N','C','R','E','M','E','N','T','C','A','S','T','C','O','L','U','M','N',
154619 'C','O','M','M','I','T','C','O','N','F','L','I','C','T','C','R','O','S',
154620 'S','C','U','R','R','E','N','T','_','T','I','M','E','S','T','A','M','P',
154621 'A','R','T','I','T','I','O','N','D','E','F','E','R','R','E','D','I','S',
154622 'T','I','N','C','T','D','R','O','P','R','E','C','E','D','I','N','G','F',
154623 'A','I','L','I','M','I','T','F','I','L','T','E','R','E','P','L','A','C',
154624 'E','F','I','R','S','T','F','O','L','L','O','W','I','N','G','F','R','O',
154625 'M','F','U','L','L','I','F','O','R','D','E','R','E','S','T','R','I','C',
154626 'T','O','T','H','E','R','S','O','V','E','R','I','G','H','T','R','O','L',
154627 'L','B','A','C','K','R','O','W','S','U','N','B','O','U','N','D','E','D',
154628 'U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M','V','I',
154629 'E','W','I','N','D','O','W','B','Y','I','N','I','T','I','A','L','L','Y',
154630 'P','R','I','M','A','R','Y',
154631 };
154632 /* aKWHash[i] is the hash value for the i-th keyword */
154633 static const unsigned char aKWHash[127] = {
154634 82, 113, 130, 80, 110, 29, 0, 0, 89, 0, 83, 70, 0,
154635 53, 35, 84, 15, 0, 129, 92, 64, 124, 131, 19, 0, 0,
154636 136, 0, 134, 126, 0, 22, 100, 0, 9, 0, 0, 121, 78,
154637 0, 76, 6, 0, 58, 97, 143, 0, 132, 108, 0, 0, 48,
154638 0, 111, 24, 0, 17, 0, 137, 63, 23, 26, 5, 65, 138,
154639 103, 120, 0, 142, 114, 69, 141, 66, 118, 72, 0, 98, 0,
154640 107, 41, 0, 106, 0, 0, 0, 102, 99, 104, 109, 123, 14,
154641 50, 122, 0, 87, 0, 139, 119, 140, 68, 127, 135, 86, 81,
154642 37, 91, 117, 0, 0, 101, 51, 128, 125, 0, 133, 0, 0,
154643 44, 0, 93, 67, 39, 0, 20, 45, 115, 88,
154644 };
154645 /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
154646 ** then the i-th keyword has no more hash collisions. Otherwise,
154647 ** the next keyword with the same hash is aKWHash[i]-1. */
154648 static const unsigned char aKWNext[143] = {
154649 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
154650 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
154651 0, 0, 0, 21, 0, 0, 0, 0, 12, 0, 0, 0, 0,
154652 0, 0, 0, 7, 0, 36, 0, 0, 28, 0, 0, 0, 31,
154653 0, 0, 0, 40, 0, 0, 0, 0, 0, 60, 0, 54, 0,
154654 0, 38, 47, 0, 0, 0, 3, 0, 0, 74, 1, 73, 0,
154655 0, 0, 52, 0, 0, 0, 0, 0, 0, 57, 59, 56, 30,
154656 0, 0, 0, 46, 0, 16, 49, 10, 0, 0, 0, 0, 0,
154657 0, 0, 11, 79, 95, 0, 0, 8, 0, 112, 0, 105, 0,
154658 43, 62, 0, 77, 0, 116, 0, 61, 0, 0, 94, 42, 55,
154659 0, 75, 34, 90, 32, 33, 27, 25, 18, 96, 0, 71, 85,
154660 };
154661 /* aKWLen[i] is the length (in bytes) of the i-th keyword */
154662 static const unsigned char aKWLen[143] = {
154663 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
154664 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7,
154665 6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4,
154666 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 10, 4, 6,
154667 2, 3, 7, 10, 6, 5, 7, 4, 5, 7, 6, 6, 4,
154668 5, 5, 5, 7, 7, 6, 5, 7, 3, 6, 4, 7, 6,
154669 12, 9, 4, 6, 5, 4, 7, 6, 5, 6, 6, 7, 4,
154670 4, 5, 9, 5, 6, 3, 7, 13, 2, 2, 4, 6, 6,
154671 8, 5, 17, 12, 7, 9, 8, 8, 2, 4, 9, 4, 5,
154672 6, 7, 5, 9, 4, 4, 2, 5, 8, 6, 4, 5, 8,
154673 4, 3, 9, 5, 5, 6, 4, 6, 2, 2, 9, 3, 7,
154674 };
154675 /* aKWOffset[i] is the index into zKWText[] of the start of
154676 ** the text for the i-th keyword. */
154677 static const unsigned short int aKWOffset[143] = {
154678 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
154679 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
154680 86, 90, 90, 94, 99, 101, 105, 111, 119, 123, 123, 123, 126,
154681 129, 132, 137, 142, 146, 147, 152, 156, 160, 168, 174, 181, 184,
154682 184, 187, 189, 195, 205, 208, 213, 213, 217, 221, 228, 233, 238,
154683 241, 244, 248, 253, 259, 265, 265, 271, 272, 276, 282, 286, 293,
154684 299, 311, 320, 322, 328, 333, 335, 342, 347, 352, 358, 364, 370,
154685 374, 378, 381, 390, 394, 400, 402, 409, 411, 413, 422, 426, 432,
154686 438, 446, 451, 451, 451, 467, 476, 483, 484, 491, 494, 503, 506,
154687 511, 516, 523, 528, 537, 541, 545, 547, 551, 559, 565, 568, 573,
154688 581, 581, 585, 594, 599, 604, 610, 613, 616, 619, 621, 626, 630,
154689 };
154690 /* aKWCode[i] is the parser symbol code for the i-th keyword */
154691 static const unsigned char aKWCode[143] = {
154692 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
154693 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
154694 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
154695 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
154696 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
154697 TK_EXCLUDE, TK_DELETE, TK_TEMP, TK_TEMP, TK_OR,
154698 TK_ISNULL, TK_NULLS, TK_SAVEPOINT, TK_INTERSECT, TK_TIES,
154699 TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
154700 TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
154701 TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_CONSTRAINT,
154702 TK_INTO, TK_OFFSET, TK_OF, TK_SET, TK_TRIGGER,
154703 TK_REFERENCES, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
154704 TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_LIKE_KW,
154705 TK_BEGIN, TK_JOIN_KW, TK_RANGE, TK_BETWEEN, TK_NOTHING,
154706 TK_GROUPS, TK_GROUP, TK_CASCADE, TK_ASC, TK_DETACH,
154707 TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_IMMEDIATE,
154708 TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE,
154709 TK_PRAGMA, TK_ABORT, TK_UPDATE, TK_VALUES, TK_VIRTUAL,
154710 TK_LAST, TK_WHEN, TK_WHERE, TK_RECURSIVE, TK_AFTER,
154711 TK_RENAME, TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO,
154712 TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT,
154713 TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT, TK_PARTITION,
154714 TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP, TK_PRECEDING,
154715 TK_FAIL, TK_LIMIT, TK_FILTER, TK_REPLACE, TK_FIRST,
154716 TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_IF, TK_ORDER,
154717 TK_RESTRICT, TK_OTHERS, TK_OVER, TK_JOIN_KW, TK_ROLLBACK,
154718 TK_ROWS, TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING,
154719 TK_VACUUM, TK_VIEW, TK_WINDOW, TK_DO, TK_BY,
154720 TK_INITIALLY, TK_ALL, TK_PRIMARY,
154721 };
154722 /* Check to see if z[0..n-1] is a keyword. If it is, write the
154723 ** parser symbol code for that keyword into *pType. Always
154724 ** return the integer n (the length of the token). */
154725 static int keywordCode(const char *z, int n, int *pType){
@@ -153951,120 +154766,123 @@
154766 testcase( i==25 ); /* EXCLUDE */
154767 testcase( i==26 ); /* DELETE */
154768 testcase( i==27 ); /* TEMPORARY */
154769 testcase( i==28 ); /* TEMP */
154770 testcase( i==29 ); /* OR */
154771 testcase( i==30 ); /* ISNULL */
154772 testcase( i==31 ); /* NULLS */
154773 testcase( i==32 ); /* SAVEPOINT */
154774 testcase( i==33 ); /* INTERSECT */
154775 testcase( i==34 ); /* TIES */
154776 testcase( i==35 ); /* NOTNULL */
154777 testcase( i==36 ); /* NOT */
154778 testcase( i==37 ); /* NO */
154779 testcase( i==38 ); /* NULL */
154780 testcase( i==39 ); /* LIKE */
154781 testcase( i==40 ); /* EXCEPT */
154782 testcase( i==41 ); /* TRANSACTION */
154783 testcase( i==42 ); /* ACTION */
154784 testcase( i==43 ); /* ON */
154785 testcase( i==44 ); /* NATURAL */
154786 testcase( i==45 ); /* ALTER */
154787 testcase( i==46 ); /* RAISE */
154788 testcase( i==47 ); /* EXCLUSIVE */
154789 testcase( i==48 ); /* EXISTS */
154790 testcase( i==49 ); /* CONSTRAINT */
154791 testcase( i==50 ); /* INTO */
154792 testcase( i==51 ); /* OFFSET */
154793 testcase( i==52 ); /* OF */
154794 testcase( i==53 ); /* SET */
154795 testcase( i==54 ); /* TRIGGER */
154796 testcase( i==55 ); /* REFERENCES */
154797 testcase( i==56 ); /* UNIQUE */
154798 testcase( i==57 ); /* QUERY */
154799 testcase( i==58 ); /* WITHOUT */
154800 testcase( i==59 ); /* WITH */
154801 testcase( i==60 ); /* OUTER */
154802 testcase( i==61 ); /* RELEASE */
154803 testcase( i==62 ); /* ATTACH */
154804 testcase( i==63 ); /* HAVING */
154805 testcase( i==64 ); /* GLOB */
154806 testcase( i==65 ); /* BEGIN */
154807 testcase( i==66 ); /* INNER */
154808 testcase( i==67 ); /* RANGE */
154809 testcase( i==68 ); /* BETWEEN */
154810 testcase( i==69 ); /* NOTHING */
154811 testcase( i==70 ); /* GROUPS */
154812 testcase( i==71 ); /* GROUP */
154813 testcase( i==72 ); /* CASCADE */
154814 testcase( i==73 ); /* ASC */
154815 testcase( i==74 ); /* DETACH */
154816 testcase( i==75 ); /* CASE */
154817 testcase( i==76 ); /* COLLATE */
154818 testcase( i==77 ); /* CREATE */
154819 testcase( i==78 ); /* CURRENT_DATE */
154820 testcase( i==79 ); /* IMMEDIATE */
154821 testcase( i==80 ); /* JOIN */
154822 testcase( i==81 ); /* INSERT */
154823 testcase( i==82 ); /* MATCH */
154824 testcase( i==83 ); /* PLAN */
154825 testcase( i==84 ); /* ANALYZE */
154826 testcase( i==85 ); /* PRAGMA */
154827 testcase( i==86 ); /* ABORT */
154828 testcase( i==87 ); /* UPDATE */
154829 testcase( i==88 ); /* VALUES */
154830 testcase( i==89 ); /* VIRTUAL */
154831 testcase( i==90 ); /* LAST */
154832 testcase( i==91 ); /* WHEN */
154833 testcase( i==92 ); /* WHERE */
154834 testcase( i==93 ); /* RECURSIVE */
154835 testcase( i==94 ); /* AFTER */
154836 testcase( i==95 ); /* RENAME */
154837 testcase( i==96 ); /* AND */
154838 testcase( i==97 ); /* DEFAULT */
154839 testcase( i==98 ); /* AUTOINCREMENT */
154840 testcase( i==99 ); /* TO */
154841 testcase( i==100 ); /* IN */
154842 testcase( i==101 ); /* CAST */
154843 testcase( i==102 ); /* COLUMN */
154844 testcase( i==103 ); /* COMMIT */
154845 testcase( i==104 ); /* CONFLICT */
154846 testcase( i==105 ); /* CROSS */
154847 testcase( i==106 ); /* CURRENT_TIMESTAMP */
154848 testcase( i==107 ); /* CURRENT_TIME */
154849 testcase( i==108 ); /* CURRENT */
154850 testcase( i==109 ); /* PARTITION */
154851 testcase( i==110 ); /* DEFERRED */
154852 testcase( i==111 ); /* DISTINCT */
154853 testcase( i==112 ); /* IS */
154854 testcase( i==113 ); /* DROP */
154855 testcase( i==114 ); /* PRECEDING */
154856 testcase( i==115 ); /* FAIL */
154857 testcase( i==116 ); /* LIMIT */
154858 testcase( i==117 ); /* FILTER */
154859 testcase( i==118 ); /* REPLACE */
154860 testcase( i==119 ); /* FIRST */
154861 testcase( i==120 ); /* FOLLOWING */
154862 testcase( i==121 ); /* FROM */
154863 testcase( i==122 ); /* FULL */
154864 testcase( i==123 ); /* IF */
154865 testcase( i==124 ); /* ORDER */
154866 testcase( i==125 ); /* RESTRICT */
154867 testcase( i==126 ); /* OTHERS */
154868 testcase( i==127 ); /* OVER */
154869 testcase( i==128 ); /* RIGHT */
154870 testcase( i==129 ); /* ROLLBACK */
154871 testcase( i==130 ); /* ROWS */
154872 testcase( i==131 ); /* ROW */
154873 testcase( i==132 ); /* UNBOUNDED */
154874 testcase( i==133 ); /* UNION */
154875 testcase( i==134 ); /* USING */
154876 testcase( i==135 ); /* VACUUM */
154877 testcase( i==136 ); /* VIEW */
154878 testcase( i==137 ); /* WINDOW */
154879 testcase( i==138 ); /* DO */
154880 testcase( i==139 ); /* BY */
154881 testcase( i==140 ); /* INITIALLY */
154882 testcase( i==141 ); /* ALL */
154883 testcase( i==142 ); /* PRIMARY */
154884 *pType = aKWCode[i];
154885 break;
154886 }
154887 }
154888 return n;
@@ -154072,11 +154890,11 @@
154890 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
154891 int id = TK_ID;
154892 keywordCode((char*)z, n, &id);
154893 return id;
154894 }
154895 #define SQLITE_N_KEYWORD 143
154896 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
154897 if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
154898 *pzName = zKWText + aKWOffset[i];
154899 *pnName = aKWLen[i];
154900 return SQLITE_OK;
@@ -156033,10 +156851,11 @@
156851 int op; /* The opcode */
156852 u32 mask; /* Mask of the bit in sqlite3.flags to set/clear */
156853 } aFlagOp[] = {
156854 { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
156855 { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
156856 { SQLITE_DBCONFIG_ENABLE_VIEW, SQLITE_EnableView },
156857 { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
156858 { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
156859 { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
156860 { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
156861 { SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP },
@@ -156432,15 +157251,12 @@
157251 }
157252 sqlite3HashClear(&db->aCollSeq);
157253 #ifndef SQLITE_OMIT_VIRTUALTABLE
157254 for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){
157255 Module *pMod = (Module *)sqliteHashData(i);
 
 
 
157256 sqlite3VtabEponymousTableClear(db, pMod);
157257 sqlite3VtabModuleUnref(db, pMod);
157258 }
157259 sqlite3HashClear(&db->aModule);
157260 #endif
157261
157262 sqlite3Error(db, SQLITE_OK); /* Deallocates any cached error strings. */
@@ -156917,11 +157733,12 @@
157733 ){
157734 return SQLITE_MISUSE_BKPT;
157735 }
157736
157737 assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
157738 assert( SQLITE_FUNC_DIRECT==SQLITE_DIRECTONLY );
157739 extraFlags = enc & (SQLITE_DETERMINISTIC|SQLITE_DIRECTONLY);
157740 enc &= (SQLITE_FUNC_ENCMASK|SQLITE_ANY);
157741
157742 #ifndef SQLITE_OMIT_UTF16
157743 /* If SQLITE_UTF16 is specified as the encoding type, transform this
157744 ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
@@ -156980,10 +157797,11 @@
157797 pDestructor->nRef++;
157798 }
157799 p->u.pDestructor = pDestructor;
157800 p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags;
157801 testcase( p->funcFlags & SQLITE_DETERMINISTIC );
157802 testcase( p->funcFlags & SQLITE_DIRECTONLY );
157803 p->xSFunc = xSFunc ? xSFunc : xStep;
157804 p->xFinalize = xFinal;
157805 p->xValue = xValue;
157806 p->xInverse = xInverse;
157807 p->pUserData = pUserData;
@@ -158272,10 +159090,11 @@
159090 db->szMmap = sqlite3GlobalConfig.szMmap;
159091 db->nextPagesize = 0;
159092 db->nMaxSorterMmap = 0x7FFFFFFF;
159093 db->flags |= SQLITE_ShortColNames
159094 | SQLITE_EnableTrigger
159095 | SQLITE_EnableView
159096 | SQLITE_CacheSpill
159097
159098 /* The SQLITE_DQS compile-time option determines the default settings
159099 ** for SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML.
159100 **
@@ -159021,16 +159840,37 @@
159840 case SQLITE_TESTCTRL_PRNG_RESTORE: {
159841 sqlite3PrngRestoreState();
159842 break;
159843 }
159844
159845 /* sqlite3_test_control(SQLITE_TESTCTRL_PRNG_SEED, int x, sqlite3 *db);
159846 **
159847 ** Control the seed for the pseudo-random number generator (PRNG) that
159848 ** is built into SQLite. Cases:
159849 **
159850 ** x!=0 && db!=0 Seed the PRNG to the current value of the
159851 ** schema cookie in the main database for db, or
159852 ** x if the schema cookie is zero. This case
159853 ** is convenient to use with database fuzzers
159854 ** as it allows the fuzzer some control over the
159855 ** the PRNG seed.
159856 **
159857 ** x!=0 && db==0 Seed the PRNG to the value of x.
159858 **
159859 ** x==0 && db==0 Revert to default behavior of using the
159860 ** xRandomness method on the primary VFS.
159861 **
159862 ** This test-control also resets the PRNG so that the new seed will
159863 ** be used for the next call to sqlite3_randomness().
159864 */
159865 case SQLITE_TESTCTRL_PRNG_SEED: {
159866 int x = va_arg(ap, int);
159867 int y;
159868 sqlite3 *db = va_arg(ap, sqlite3*);
159869 assert( db==0 || db->aDb[0].pSchema!=0 );
159870 if( db && (y = db->aDb[0].pSchema->schema_cookie)!=0 ){ x = y; }
159871 sqlite3Config.iPrngSeed = x;
159872 sqlite3_randomness(0,0);
159873 break;
159874 }
159875
159876 /*
@@ -159238,10 +160078,21 @@
160078 */
160079 case SQLITE_TESTCTRL_NEVER_CORRUPT: {
160080 sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int);
160081 break;
160082 }
160083
160084 /* sqlite3_test_control(SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS, int);
160085 **
160086 ** Set or clear a flag that causes SQLite to verify that type, name,
160087 ** and tbl_name fields of the sqlite_master table. This is normally
160088 ** on, but it is sometimes useful to turn it off for testing.
160089 */
160090 case SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS: {
160091 sqlite3GlobalConfig.bExtraSchemaChecks = va_arg(ap, int);
160092 break;
160093 }
160094
160095 /* Set the threshold at which OP_Once counters reset back to zero.
160096 ** By default this is 0x7ffffffe (over 2 billion), but that value is
160097 ** too big to test in a reasonable amount of time, so this control is
160098 ** provided to set a small and easily reachable reset value.
@@ -174941,10 +175792,11 @@
175792 blobGrowBuffer(pPrev, nTerm, &rc);
175793 if( rc!=SQLITE_OK ) return rc;
175794
175795 nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);
175796 nSuffix = nTerm - nPrefix;
175797 if( nSuffix<=0 ) return FTS_CORRUPT_VTAB;
175798 memcpy(pPrev->a, zTerm, nTerm);
175799 pPrev->n = nTerm;
175800
175801 if( bFirst==0 ){
175802 pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);
@@ -177161,14 +178013,14 @@
178013 char *pCsr = pPhrase->pTail;
178014 int iCsr = pPhrase->iTail;
178015
178016 while( iCsr<(iStart+pIter->nSnippet) && iCsr>=iStart ){
178017 int j;
178018 u64 mPhrase = (u64)1 << (i%64);
178019 u64 mPos = (u64)1 << (iCsr - iStart);
178020 assert( iCsr>=iStart && (iCsr - iStart)<=64 );
178021 assert( i>=0 );
178022 if( (mCover|mCovered)&mPhrase ){
178023 iScore++;
178024 }else{
178025 iScore += 1000;
178026 }
@@ -180325,10 +181177,11 @@
181177 ){
181178 u32 i, j, nKey;
181179 const char *zKey;
181180 JsonNode *pRoot = &pParse->aNode[iRoot];
181181 if( zPath[0]==0 ) return pRoot;
181182 if( pRoot->jnFlags & JNODE_REPLACE ) return 0;
181183 if( zPath[0]=='.' ){
181184 if( pRoot->eType!=JSON_OBJECT ) return 0;
181185 zPath++;
181186 if( zPath[0]=='"' ){
181187 zKey = zPath + 1;
@@ -182455,18 +183308,20 @@
183308
183309 /* Check if the requested node is already in the hash table. If so,
183310 ** increase its reference count and return it.
183311 */
183312 if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
 
183313 if( pParent && !pNode->pParent ){
183314 if( nodeInParentChain(pNode, pParent) ){
183315 RTREE_IS_CORRUPT(pRtree);
183316 return SQLITE_CORRUPT_VTAB;
183317 }
183318 pParent->nRef++;
183319 pNode->pParent = pParent;
183320 }else if( pParent && pNode->pParent && pParent!=pNode->pParent ){
183321 RTREE_IS_CORRUPT(pRtree);
183322 return SQLITE_CORRUPT_VTAB;
183323 }
183324 pNode->nRef++;
183325 *ppNode = pNode;
183326 return SQLITE_OK;
183327 }
@@ -183350,17 +184205,18 @@
184205 int eInt;
184206 RtreeSearchPoint x;
184207
184208 eInt = pRtree->eCoordType==RTREE_COORD_INT32;
184209 while( (p = rtreeSearchPointFirst(pCur))!=0 && p->iLevel>0 ){
184210 u8 *pCellData;
184211 pNode = rtreeNodeOfFirstSearchPoint(pCur, &rc);
184212 if( rc ) return rc;
184213 nCell = NCELL(pNode);
184214 assert( nCell<200 );
184215 pCellData = pNode->zData + (4+pRtree->nBytesPerCell*p->iCell);
184216 while( p->iCell<nCell ){
184217 sqlite3_rtree_dbl rScore = (sqlite3_rtree_dbl)-1;
 
184218 eWithin = FULLY_WITHIN;
184219 for(ii=0; ii<nConstraint; ii++){
184220 RtreeConstraint *pConstraint = pCur->aConstraint + ii;
184221 if( pConstraint->op>=RTREE_MATCH ){
184222 rc = rtreeCallbackConstraint(pConstraint, eInt, pCellData, p,
@@ -183369,17 +184225,27 @@
184225 }else if( p->iLevel==1 ){
184226 rtreeLeafConstraint(pConstraint, eInt, pCellData, &eWithin);
184227 }else{
184228 rtreeNonleafConstraint(pConstraint, eInt, pCellData, &eWithin);
184229 }
184230 if( eWithin==NOT_WITHIN ){
184231 p->iCell++;
184232 pCellData += pRtree->nBytesPerCell;
184233 break;
184234 }
184235 }
 
184236 if( eWithin==NOT_WITHIN ) continue;
184237 p->iCell++;
184238 x.iLevel = p->iLevel - 1;
184239 if( x.iLevel ){
184240 x.id = readInt64(pCellData);
184241 for(ii=0; ii<pCur->nPoint; ii++){
184242 if( pCur->aPoint[ii].id==x.id ){
184243 RTREE_IS_CORRUPT(pRtree);
184244 return SQLITE_CORRUPT_VTAB;
184245 }
184246 }
184247 x.iCell = 0;
184248 }else{
184249 x.id = p->id;
184250 x.iCell = p->iCell - 1;
184251 }
@@ -189683,10 +190549,11 @@
190549 "CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)"
190550
190551 typedef struct RbuFrame RbuFrame;
190552 typedef struct RbuObjIter RbuObjIter;
190553 typedef struct RbuState RbuState;
190554 typedef struct RbuSpan RbuSpan;
190555 typedef struct rbu_vfs rbu_vfs;
190556 typedef struct rbu_file rbu_file;
190557 typedef struct RbuUpdateStmt RbuUpdateStmt;
190558
190559 #if !defined(SQLITE_AMALGAMATION)
@@ -189726,10 +190593,15 @@
190593 struct RbuUpdateStmt {
190594 char *zMask; /* Copy of update mask used with pUpdate */
190595 sqlite3_stmt *pUpdate; /* Last update statement (or NULL) */
190596 RbuUpdateStmt *pNext;
190597 };
190598
190599 struct RbuSpan {
190600 const char *zSpan;
190601 int nSpan;
190602 };
190603
190604 /*
190605 ** An iterator of this type is used to iterate through all objects in
190606 ** the target database that require updating. For each such table, the
190607 ** iterator visits, in order:
@@ -189776,10 +190648,13 @@
190648 int nCol; /* Number of columns in current object */
190649 sqlite3_stmt *pSelect; /* Source data */
190650 sqlite3_stmt *pInsert; /* Statement for INSERT operations */
190651 sqlite3_stmt *pDelete; /* Statement for DELETE ops */
190652 sqlite3_stmt *pTmpInsert; /* Insert into rbu_tmp_$zDataTbl */
190653 int nIdxCol;
190654 RbuSpan *aIdxCol;
190655 char *zIdxSql;
190656
190657 /* Last UPDATE used (for PK b-tree updates only), or NULL. */
190658 RbuUpdateStmt *pRbuUpdate;
190659 };
190660
@@ -190310,17 +191185,22 @@
191185 RbuUpdateStmt *pTmp = pUp->pNext;
191186 sqlite3_finalize(pUp->pUpdate);
191187 sqlite3_free(pUp);
191188 pUp = pTmp;
191189 }
191190 sqlite3_free(pIter->aIdxCol);
191191 sqlite3_free(pIter->zIdxSql);
191192
191193 pIter->pSelect = 0;
191194 pIter->pInsert = 0;
191195 pIter->pDelete = 0;
191196 pIter->pRbuUpdate = 0;
191197 pIter->pTmpInsert = 0;
191198 pIter->nCol = 0;
191199 pIter->nIdxCol = 0;
191200 pIter->aIdxCol = 0;
191201 pIter->zIdxSql = 0;
191202 }
191203
191204 /*
191205 ** Clean up any resources allocated as part of the iterator object passed
191206 ** as the only argument.
@@ -190431,12 +191311,12 @@
191311 assert( argc==1 || argc==2 );
191312
191313 zIn = (const char*)sqlite3_value_text(argv[0]);
191314 if( zIn ){
191315 if( rbuIsVacuum(p) ){
191316 assert( argc==2 || argc==1 );
191317 if( argc==1 || 0==sqlite3_value_int(argv[1]) ){
191318 sqlite3_result_text(pCtx, zIn, -1, SQLITE_STATIC);
191319 }
191320 }else{
191321 if( strlen(zIn)>4 && memcmp("data", zIn, 4)==0 ){
191322 int i;
@@ -190590,18 +191470,19 @@
191470 ** if the allocation succeeds, (*pRc) is left unchanged.
191471 */
191472 static char *rbuStrndup(const char *zStr, int *pRc){
191473 char *zRet = 0;
191474
191475 if( *pRc==SQLITE_OK ){
191476 if( zStr ){
191477 size_t nCopy = strlen(zStr) + 1;
191478 zRet = (char*)sqlite3_malloc64(nCopy);
191479 if( zRet ){
191480 memcpy(zRet, zStr, nCopy);
191481 }else{
191482 *pRc = SQLITE_NOMEM;
191483 }
191484 }
191485 }
191486
191487 return zRet;
191488 }
@@ -190769,10 +191650,13 @@
191650 sqlite3_mprintf("PRAGMA main.index_xinfo = %Q", zIdx)
191651 );
191652 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){
191653 int iCid = sqlite3_column_int(pXInfo, 1);
191654 if( iCid>=0 ) pIter->abIndexed[iCid] = 1;
191655 if( iCid==-2 ){
191656 memset(pIter->abIndexed, 0x01, sizeof(u8)*pIter->nTblCol);
191657 }
191658 }
191659 rbuFinalize(p, pXInfo);
191660 bIndex = 1;
191661 pIter->nIndex++;
191662 }
@@ -191180,33 +192064,41 @@
192064
192065 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){
192066 int iCid = sqlite3_column_int(pXInfo, 1);
192067 int bDesc = sqlite3_column_int(pXInfo, 3);
192068 const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4);
192069 const char *zCol = 0;
192070 const char *zType;
192071
192072 if( iCid==-2 ){
192073 int iSeq = sqlite3_column_int(pXInfo, 0);
192074 zRet = sqlite3_mprintf("%z%s(%.*s) COLLATE %Q", zRet, zCom,
192075 pIter->aIdxCol[iSeq].nSpan, pIter->aIdxCol[iSeq].zSpan, zCollate
192076 );
192077 zType = "";
192078 }else {
192079 if( iCid<0 ){
192080 /* An integer primary key. If the table has an explicit IPK, use
192081 ** its name. Otherwise, use "rbu_rowid". */
192082 if( pIter->eType==RBU_PK_IPK ){
192083 int i;
192084 for(i=0; pIter->abTblPk[i]==0; i++);
192085 assert( i<pIter->nTblCol );
192086 zCol = pIter->azTblCol[i];
192087 }else if( rbuIsVacuum(p) ){
192088 zCol = "_rowid_";
192089 }else{
192090 zCol = "rbu_rowid";
192091 }
192092 zType = "INTEGER";
192093 }else{
192094 zCol = pIter->azTblCol[iCid];
192095 zType = pIter->azTblType[iCid];
192096 }
192097 zRet = sqlite3_mprintf("%z%s\"%w\" COLLATE %Q", zRet, zCom,zCol,zCollate);
192098 }
192099
192100 if( pIter->bUnique==0 || sqlite3_column_int(pXInfo, 5) ){
192101 const char *zOrder = (bDesc ? " DESC" : "");
192102 zImpPK = sqlite3_mprintf("%z%s\"rbu_imp_%d%w\"%s",
192103 zImpPK, zCom, nBind, zCol, zOrder
192104 );
@@ -191682,34 +192574,65 @@
192574 static char *rbuObjIterGetIndexWhere(sqlite3rbu *p, RbuObjIter *pIter){
192575 sqlite3_stmt *pStmt = 0;
192576 int rc = p->rc;
192577 char *zRet = 0;
192578
192579 assert( pIter->zIdxSql==0 && pIter->nIdxCol==0 && pIter->aIdxCol==0 );
192580
192581 if( rc==SQLITE_OK ){
192582 rc = prepareAndCollectError(p->dbMain, &pStmt, &p->zErrmsg,
192583 "SELECT trim(sql) FROM sqlite_master WHERE type='index' AND name=?"
192584 );
192585 }
192586 if( rc==SQLITE_OK ){
192587 int rc2;
192588 rc = sqlite3_bind_text(pStmt, 1, pIter->zIdx, -1, SQLITE_STATIC);
192589 if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
192590 char *zSql = (char*)sqlite3_column_text(pStmt, 0);
192591 if( zSql ){
192592 pIter->zIdxSql = zSql = rbuStrndup(zSql, &rc);
192593 }
192594 if( zSql ){
192595 int nParen = 0; /* Number of open parenthesis */
192596 int i;
192597 int iIdxCol = 0;
192598 int nIdxAlloc = 0;
192599 for(i=0; zSql[i]; i++){
192600 char c = zSql[i];
192601
192602 /* If necessary, grow the pIter->aIdxCol[] array */
192603 if( iIdxCol==nIdxAlloc ){
192604 RbuSpan *aIdxCol = (RbuSpan*)sqlite3_realloc(
192605 pIter->aIdxCol, (nIdxAlloc+16)*sizeof(RbuSpan)
192606 );
192607 if( aIdxCol==0 ){
192608 rc = SQLITE_NOMEM;
192609 break;
192610 }
192611 pIter->aIdxCol = aIdxCol;
192612 nIdxAlloc += 16;
192613 }
192614
192615 if( c=='(' ){
192616 if( nParen==0 ){
192617 assert( iIdxCol==0 );
192618 pIter->aIdxCol[0].zSpan = &zSql[i+1];
192619 }
192620 nParen++;
192621 }
192622 else if( c==')' ){
192623 nParen--;
192624 if( nParen==0 ){
192625 int nSpan = &zSql[i] - pIter->aIdxCol[iIdxCol].zSpan;
192626 pIter->aIdxCol[iIdxCol++].nSpan = nSpan;
192627 i++;
192628 break;
192629 }
192630 }else if( c==',' && nParen==1 ){
192631 int nSpan = &zSql[i] - pIter->aIdxCol[iIdxCol].zSpan;
192632 pIter->aIdxCol[iIdxCol++].nSpan = nSpan;
192633 pIter->aIdxCol[iIdxCol].zSpan = &zSql[i+1];
192634 }else if( c=='"' || c=='\'' || c=='`' ){
192635 for(i++; 1; i++){
192636 if( zSql[i]==c ){
192637 if( zSql[i+1]!=c ) break;
192638 i++;
@@ -191717,15 +192640,23 @@
192640 }
192641 }else if( c=='[' ){
192642 for(i++; 1; i++){
192643 if( zSql[i]==']' ) break;
192644 }
192645 }else if( c=='-' && zSql[i+1]=='-' ){
192646 for(i=i+2; zSql[i] && zSql[i]!='\n'; i++);
192647 if( zSql[i]=='\0' ) break;
192648 }else if( c=='/' && zSql[i+1]=='*' ){
192649 for(i=i+2; zSql[i] && (zSql[i]!='*' || zSql[i+1]!='/'); i++);
192650 if( zSql[i]=='\0' ) break;
192651 i++;
192652 }
192653 }
192654 if( zSql[i] ){
192655 zRet = rbuStrndup(&zSql[i], &rc);
192656 }
192657 pIter->nIdxCol = iIdxCol;
192658 }
192659 }
192660
192661 rc2 = sqlite3_finalize(pStmt);
192662 if( rc==SQLITE_OK ) rc = rc2;
@@ -191766,15 +192697,15 @@
192697 char *zBind = 0;
192698 char *zPart = 0;
192699 int nBind = 0;
192700
192701 assert( pIter->eType!=RBU_PK_VTAB );
192702 zPart = rbuObjIterGetIndexWhere(p, pIter);
192703 zCollist = rbuObjIterGetIndexCols(
192704 p, pIter, &zImposterCols, &zImposterPK, &zWhere, &nBind
192705 );
192706 zBind = rbuObjIterGetBindlist(p, nBind);
 
192707
192708 /* Create the imposter table used to write to this index. */
192709 sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, "main", 0, 1);
192710 sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, "main", 1,tnum);
192711 rbuMPrintfExec(p, p->dbMain,
@@ -193296,14 +194227,15 @@
194227 ){
194228 sqlite3rbu *p = (sqlite3rbu*)sqlite3_user_data(pCtx);
194229 sqlite3_stmt *pStmt = 0;
194230 char *zErrmsg = 0;
194231 int rc;
194232 sqlite3 *db = (rbuIsVacuum(p) ? p->dbRbu : p->dbMain);
194233
194234 assert( nVal==1 );
194235
194236 rc = prepareFreeAndCollectError(db, &pStmt, &zErrmsg,
194237 sqlite3_mprintf("SELECT count(*) FROM sqlite_master "
194238 "WHERE type='index' AND tbl_name = %Q", sqlite3_value_text(apVal[0]))
194239 );
194240 if( rc!=SQLITE_OK ){
194241 sqlite3_result_error(pCtx, zErrmsg, -1);
@@ -193314,11 +194246,11 @@
194246 }
194247 rc = sqlite3_finalize(pStmt);
194248 if( rc==SQLITE_OK ){
194249 sqlite3_result_int(pCtx, nIndex);
194250 }else{
194251 sqlite3_result_error(pCtx, sqlite3_errmsg(db), -1);
194252 }
194253 }
194254
194255 sqlite3_free(zErrmsg);
194256 }
@@ -197757,11 +198689,11 @@
198689 if( *pRc==SQLITE_OK && (size_t)(p->nAlloc-p->nBuf)<nByte ){
198690 u8 *aNew;
198691 i64 nNew = p->nAlloc ? p->nAlloc : 128;
198692 do {
198693 nNew = nNew*2;
198694 }while( (size_t)(nNew-p->nBuf)<nByte );
198695
198696 aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);
198697 if( 0==aNew ){
198698 *pRc = SQLITE_NOMEM;
198699 }else{
@@ -202158,10 +203090,11 @@
203090 int bColumnsize; /* "columnsize=" option value (dflt==1) */
203091 int eDetail; /* FTS5_DETAIL_XXX value */
203092 char *zContentExprlist;
203093 Fts5Tokenizer *pTok;
203094 fts5_tokenizer *pTokApi;
203095 int bLock; /* True when table is preparing statement */
203096
203097 /* Values loaded from the %_config table */
203098 int iCookie; /* Incremented when %_config is modified */
203099 int pgsz; /* Approximate page size used in %_data */
203100 int nAutomerge; /* 'automerge' setting */
@@ -203525,19 +204458,22 @@
204458 fts5yycoverage[stateno][iLookAhead] = 1;
204459 #endif
204460 do{
204461 i = fts5yy_shift_ofst[stateno];
204462 assert( i>=0 );
204463 assert( i<=fts5YY_ACTTAB_COUNT );
204464 assert( i+fts5YYNFTS5TOKEN<=(int)fts5YY_NLOOKAHEAD );
204465 assert( iLookAhead!=fts5YYNOCODE );
204466 assert( iLookAhead < fts5YYNFTS5TOKEN );
204467 i += iLookAhead;
204468 assert( i<(int)fts5YY_NLOOKAHEAD );
204469 if( fts5yy_lookahead[i]!=iLookAhead ){
204470 #ifdef fts5YYFALLBACK
204471 fts5YYCODETYPE iFallback; /* Fallback token */
204472 assert( iLookAhead<sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0]) );
204473 iFallback = fts5yyFallback[iLookAhead];
204474 if( iFallback!=0 ){
204475 #ifndef NDEBUG
204476 if( fts5yyTraceFILE ){
204477 fprintf(fts5yyTraceFILE, "%sFALLBACK %s => %s\n",
204478 fts5yyTracePrompt, fts5yyTokenName[iLookAhead], fts5yyTokenName[iFallback]);
204479 }
@@ -203548,20 +204484,12 @@
204484 }
204485 #endif
204486 #ifdef fts5YYWILDCARD
204487 {
204488 int j = i - iLookAhead + fts5YYWILDCARD;
204489 assert( j<(int)(sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0])) );
204490 if( fts5yy_lookahead[j]==fts5YYWILDCARD && iLookAhead>0 ){
 
 
 
 
 
 
 
 
204491 #ifndef NDEBUG
204492 if( fts5yyTraceFILE ){
204493 fprintf(fts5yyTraceFILE, "%sWILDCARD %s => %s\n",
204494 fts5yyTracePrompt, fts5yyTokenName[iLookAhead],
204495 fts5yyTokenName[fts5YYWILDCARD]);
@@ -203571,10 +204499,11 @@
204499 }
204500 }
204501 #endif /* fts5YYWILDCARD */
204502 return fts5yy_default[stateno];
204503 }else{
204504 assert( i>=0 && i<sizeof(fts5yy_action)/sizeof(fts5yy_action[0]) );
204505 return fts5yy_action[i];
204506 }
204507 }while(1);
204508 }
204509
@@ -204271,13 +205200,12 @@
205200 ** Return the fallback token corresponding to canonical token iToken, or
205201 ** 0 if iToken has no fallback.
205202 */
205203 static int sqlite3Fts5ParserFallback(int iToken){
205204 #ifdef fts5YYFALLBACK
205205 assert( iToken<(int)(sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])) );
205206 return fts5yyFallback[iToken];
 
205207 #else
205208 (void)iToken;
205209 #endif
205210 return 0;
205211 }
@@ -210470,10 +211398,11 @@
211398 sqlite3_free(pRet);
211399 pRet = 0;
211400 }else{
211401 /* TODO1: Fix this */
211402 pRet->p[nByte] = 0x00;
211403 pRet->p[nByte+1] = 0x00;
211404 pRet->szLeaf = fts5GetU16(&pRet->p[2]);
211405 }
211406 }
211407 p->rc = rc;
211408 p->nRead++;
@@ -214776,13 +215705,16 @@
215705
215706 i64 iPrev = 0;
215707 Fts5PoslistWriter writer;
215708 memset(&writer, 0, sizeof(writer));
215709
215710 /* See the earlier comment in this function for an explanation of why
215711 ** corrupt input position lists might cause the output to consume
215712 ** at most 20 bytes of unexpected space. */
215713 fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);
215714 fts5BufferZero(&tmp);
215715 sqlite3Fts5BufferSize(&p->rc, &tmp, i1.nPoslist + i2.nPoslist + 10 + 10);
215716 if( p->rc ) break;
215717
215718 sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);
215719 sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);
215720 assert_nc( iPos1>=0 && iPos2>=0 );
@@ -214826,10 +215758,16 @@
215758 if( nCopy>0 ){
215759 fts5BufferSafeAppendBlob(&tmp, aCopy, nCopy);
215760 }
215761
215762 /* WRITEPOSLISTSIZE */
215763 assert_nc( tmp.n<=i1.nPoslist+i2.nPoslist );
215764 assert( tmp.n<=i1.nPoslist+i2.nPoslist+10+10 );
215765 if( tmp.n>i1.nPoslist+i2.nPoslist ){
215766 if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT;
215767 break;
215768 }
215769 fts5BufferSafeAppendVarint(&out, tmp.n * 2);
215770 fts5BufferSafeAppendBlob(&out, tmp.p, tmp.n);
215771 fts5DoclistIterNext(&i1);
215772 fts5DoclistIterNext(&i2);
215773 assert_nc( out.n<=(p1->n+p2->n+9) );
@@ -216897,10 +217835,17 @@
217835 assert( SQLITE_INDEX_CONSTRAINT_EQ<SQLITE_INDEX_CONSTRAINT_MATCH );
217836 assert( SQLITE_INDEX_CONSTRAINT_GT<SQLITE_INDEX_CONSTRAINT_MATCH );
217837 assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH );
217838 assert( SQLITE_INDEX_CONSTRAINT_GE<SQLITE_INDEX_CONSTRAINT_MATCH );
217839 assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH );
217840
217841 if( pConfig->bLock ){
217842 pTab->base.zErrMsg = sqlite3_mprintf(
217843 "recursively defined fts5 content table"
217844 );
217845 return SQLITE_ERROR;
217846 }
217847
217848 /* Set idxFlags flags for all WHERE clause terms that will be used. */
217849 for(i=0; i<pInfo->nConstraint; i++){
217850 struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];
217851 int iCol = p->iColumn;
@@ -217287,11 +218232,11 @@
218232 ** And since the statement required here reads from this very virtual
218233 ** table, saving it creates a circular reference.
218234 **
218235 ** If SQLite a built-in statement cache, this wouldn't be a problem. */
218236 rc = fts5PrepareStatement(&pSorter->pStmt, pConfig,
218237 "SELECT rowid, rank FROM %Q.%Q ORDER BY %s(\"%w\"%s%s) %s",
218238 pConfig->zDb, pConfig->zName, zRank, pConfig->zName,
218239 (zRankArgs ? ", " : ""),
218240 (zRankArgs ? zRankArgs : ""),
218241 bDesc ? "DESC" : "ASC"
218242 );
@@ -217343,14 +218288,14 @@
218288 for(n=0; z[n] && z[n]!=' '; n++);
218289
218290 assert( pTab->p.base.zErrMsg==0 );
218291 pCsr->ePlan = FTS5_PLAN_SPECIAL;
218292
218293 if( n==5 && 0==sqlite3_strnicmp("reads", z, n) ){
218294 pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->p.pIndex);
218295 }
218296 else if( n==2 && 0==sqlite3_strnicmp("id", z, n) ){
218297 pCsr->iSpecial = pCsr->iCsrId;
218298 }
218299 else{
218300 /* An unrecognized directive. Return an error message. */
218301 pTab->p.base.zErrMsg = sqlite3_mprintf("unknown special query: %.*s", n, z);
@@ -218594,11 +219539,11 @@
219539 assert( argc>=1 );
219540 pAux = (Fts5Auxiliary*)sqlite3_user_data(context);
219541 iCsrId = sqlite3_value_int64(argv[0]);
219542
219543 pCsr = fts5CursorFromCsrid(pAux->pGlobal, iCsrId);
219544 if( pCsr==0 || pCsr->ePlan==0 ){
219545 char *zErr = sqlite3_mprintf("no such cursor: %lld", iCsrId);
219546 sqlite3_result_error(context, zErr, -1);
219547 sqlite3_free(zErr);
219548 }else{
219549 fts5ApiInvoke(pAux, pCsr, context, argc-1, &argv[1]);
@@ -219010,11 +219955,11 @@
219955 int nArg, /* Number of args */
219956 sqlite3_value **apUnused /* Function arguments */
219957 ){
219958 assert( nArg==0 );
219959 UNUSED_PARAM2(nArg, apUnused);
219960 sqlite3_result_text(pCtx, "fts5: 2019-09-03 16:23:41 3044cf6917ea8324175fc91657e9a5978af9748f72e1914bc361753f0b2d897d", -1, SQLITE_TRANSIENT);
219961 }
219962
219963 /*
219964 ** Return true if zName is the extension on one of the shadow tables used
219965 ** by this module.
@@ -219282,11 +220227,13 @@
220227 if( zSql==0 ){
220228 rc = SQLITE_NOMEM;
220229 }else{
220230 int f = SQLITE_PREPARE_PERSISTENT;
220231 if( eStmt>FTS5_STMT_LOOKUP ) f |= SQLITE_PREPARE_NO_VTAB;
220232 p->pConfig->bLock++;
220233 rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);
220234 p->pConfig->bLock--;
220235 sqlite3_free(zSql);
220236 if( rc!=SQLITE_OK && pzErrMsg ){
220237 *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
220238 }
220239 }
@@ -223776,12 +224723,12 @@
224723 }
224724 #endif /* SQLITE_CORE */
224725 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
224726
224727 /************** End of stmt.c ************************************************/
224728 #if __LINE__!=224728
224729 #undef SQLITE_SOURCE_ID
224730 #define SQLITE_SOURCE_ID "2019-09-03 16:23:41 3044cf6917ea8324175fc91657e9a5978af9748f72e1914bc361753f0b2dalt2"
224731 #endif
224732 /* Return the source-id for this library */
224733 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
224734 /************************** End of sqlite3.c ******************************/
224735
+56 -8
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121121
**
122122
** See also: [sqlite3_libversion()],
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126
-#define SQLITE_VERSION "3.29.0"
127
-#define SQLITE_VERSION_NUMBER 3029000
128
-#define SQLITE_SOURCE_ID "2019-07-10 17:32:03 fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6"
126
+#define SQLITE_VERSION "3.30.0"
127
+#define SQLITE_VERSION_NUMBER 3030000
128
+#define SQLITE_SOURCE_ID "2019-09-03 16:23:41 3044cf6917ea8324175fc91657e9a5978af9748f72e1914bc361753f0b2d897d"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -2091,10 +2091,21 @@
20912091
** The second parameter is a pointer to an integer into which
20922092
** is written 0 or 1 to indicate whether triggers are disabled or enabled
20932093
** following this call. The second parameter may be a NULL pointer, in
20942094
** which case the trigger setting is not reported back. </dd>
20952095
**
2096
+** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
2097
+** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
2098
+** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
2099
+** There should be two additional arguments.
2100
+** The first argument is an integer which is 0 to disable views,
2101
+** positive to enable views or negative to leave the setting unchanged.
2102
+** The second parameter is a pointer to an integer into which
2103
+** is written 0 or 1 to indicate whether views are disabled or enabled
2104
+** following this call. The second parameter may be a NULL pointer, in
2105
+** which case the view setting is not reported back. </dd>
2106
+**
20962107
** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
20972108
** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
20982109
** <dd> ^This option is used to enable or disable the
20992110
** [fts3_tokenizer()] function which is part of the
21002111
** [FTS3] full-text search engine extension.
@@ -2263,11 +2274,12 @@
22632274
#define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
22642275
#define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
22652276
#define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
22662277
#define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
22672278
#define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
2268
-#define SQLITE_DBCONFIG_MAX 1014 /* Largest DBCONFIG */
2279
+#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2280
+#define SQLITE_DBCONFIG_MAX 1015 /* Largest DBCONFIG */
22692281
22702282
/*
22712283
** CAPI3REF: Enable Or Disable Extended Result Codes
22722284
** METHOD: sqlite3
22732285
**
@@ -3812,11 +3824,11 @@
38123824
** a schema change, on the first [sqlite3_step()] call following any change
38133825
** to the [sqlite3_bind_text | bindings] of that [parameter].
38143826
** ^The specific value of WHERE-clause [parameter] might influence the
38153827
** choice of query plan if the parameter is the left-hand side of a [LIKE]
38163828
** or [GLOB] operator or if the parameter is compared to an indexed column
3817
-** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3829
+** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled.
38183830
** </li>
38193831
** </ol>
38203832
**
38213833
** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
38223834
** the extra prepFlags parameter, which is a bit array consisting of zero or
@@ -4846,10 +4858,13 @@
48464858
** the same inputs within a single SQL statement. Most SQL functions are
48474859
** deterministic. The built-in [random()] SQL function is an example of a
48484860
** function that is not deterministic. The SQLite query planner is able to
48494861
** perform additional optimizations on deterministic functions, so use
48504862
** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
4863
+** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY]
4864
+** flag, which if present prevents the function from being invoked from
4865
+** within VIEWs or TRIGGERs.
48514866
**
48524867
** ^(The fifth parameter is an arbitrary pointer. The implementation of the
48534868
** function can gain access to this pointer using [sqlite3_user_data()].)^
48544869
**
48554870
** ^The sixth, seventh and eighth parameters passed to the three
@@ -4963,12 +4978,20 @@
49634978
**
49644979
** These constants may be ORed together with the
49654980
** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
49664981
** to [sqlite3_create_function()], [sqlite3_create_function16()], or
49674982
** [sqlite3_create_function_v2()].
4983
+**
4984
+** The SQLITE_DETERMINISTIC flag means that the new function will always
4985
+** maps the same inputs into the same output. The abs() function is
4986
+** deterministic, for example, but randomblob() is not.
4987
+**
4988
+** The SQLITE_DIRECTONLY flag means that the function may only be invoked
4989
+** from top-level SQL, and cannot be used in VIEWs or TRIGGERs.
49684990
*/
4969
-#define SQLITE_DETERMINISTIC 0x800
4991
+#define SQLITE_DETERMINISTIC 0x000000800
4992
+#define SQLITE_DIRECTONLY 0x000080000
49704993
49714994
/*
49724995
** CAPI3REF: Deprecated Functions
49734996
** DEPRECATED
49744997
**
@@ -6610,10 +6633,16 @@
66106633
** no longer needs the pClientData pointer. ^The destructor will also
66116634
** be invoked if the call to sqlite3_create_module_v2() fails.
66126635
** ^The sqlite3_create_module()
66136636
** interface is equivalent to sqlite3_create_module_v2() with a NULL
66146637
** destructor.
6638
+**
6639
+** ^If the third parameter (the pointer to the sqlite3_module object) is
6640
+** NULL then no new module is create and any existing modules with the
6641
+** same name are dropped.
6642
+**
6643
+** See also: [sqlite3_drop_modules()]
66156644
*/
66166645
SQLITE_API int sqlite3_create_module(
66176646
sqlite3 *db, /* SQLite connection to register module with */
66186647
const char *zName, /* Name of the module */
66196648
const sqlite3_module *p, /* Methods for the module */
@@ -6624,10 +6653,27 @@
66246653
const char *zName, /* Name of the module */
66256654
const sqlite3_module *p, /* Methods for the module */
66266655
void *pClientData, /* Client data for xCreate/xConnect */
66276656
void(*xDestroy)(void*) /* Module destructor function */
66286657
);
6658
+
6659
+/*
6660
+** CAPI3REF: Remove Unnecessary Virtual Table Implementations
6661
+** METHOD: sqlite3
6662
+**
6663
+** ^The sqlite3_drop_modules(D,L) interface removes all virtual
6664
+** table modules from database connection D except those named on list L.
6665
+** The L parameter must be either NULL or a pointer to an array of pointers
6666
+** to strings where the array is terminated by a single NULL pointer.
6667
+** ^If the L parameter is NULL, then all virtual table modules are removed.
6668
+**
6669
+** See also: [sqlite3_create_module()]
6670
+*/
6671
+SQLITE_API int sqlite3_drop_modules(
6672
+ sqlite3 *db, /* Remove modules from this connection */
6673
+ const char **azKeep /* Except, do not remove the ones named here */
6674
+);
66296675
66306676
/*
66316677
** CAPI3REF: Virtual Table Instance Object
66326678
** KEYWORDS: sqlite3_vtab
66336679
**
@@ -7333,11 +7379,11 @@
73337379
** [sqlite3_test_control()] interface.
73347380
*/
73357381
#define SQLITE_TESTCTRL_FIRST 5
73367382
#define SQLITE_TESTCTRL_PRNG_SAVE 5
73377383
#define SQLITE_TESTCTRL_PRNG_RESTORE 6
7338
-#define SQLITE_TESTCTRL_PRNG_RESET 7
7384
+#define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */
73397385
#define SQLITE_TESTCTRL_BITVEC_TEST 8
73407386
#define SQLITE_TESTCTRL_FAULT_INSTALL 9
73417387
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
73427388
#define SQLITE_TESTCTRL_PENDING_BYTE 11
73437389
#define SQLITE_TESTCTRL_ASSERT 12
@@ -7356,11 +7402,13 @@
73567402
#define SQLITE_TESTCTRL_ISINIT 23
73577403
#define SQLITE_TESTCTRL_SORTER_MMAP 24
73587404
#define SQLITE_TESTCTRL_IMPOSTER 25
73597405
#define SQLITE_TESTCTRL_PARSER_COVERAGE 26
73607406
#define SQLITE_TESTCTRL_RESULT_INTREAL 27
7361
-#define SQLITE_TESTCTRL_LAST 27 /* Largest TESTCTRL */
7407
+#define SQLITE_TESTCTRL_PRNG_SEED 28
7408
+#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
7409
+#define SQLITE_TESTCTRL_LAST 29 /* Largest TESTCTRL */
73627410
73637411
/*
73647412
** CAPI3REF: SQL Keyword Checking
73657413
**
73667414
** These routines provide access to the set of SQL language keywords
73677415
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121 **
122 ** See also: [sqlite3_libversion()],
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.29.0"
127 #define SQLITE_VERSION_NUMBER 3029000
128 #define SQLITE_SOURCE_ID "2019-07-10 17:32:03 fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -2091,10 +2091,21 @@
2091 ** The second parameter is a pointer to an integer into which
2092 ** is written 0 or 1 to indicate whether triggers are disabled or enabled
2093 ** following this call. The second parameter may be a NULL pointer, in
2094 ** which case the trigger setting is not reported back. </dd>
2095 **
 
 
 
 
 
 
 
 
 
 
 
2096 ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
2097 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
2098 ** <dd> ^This option is used to enable or disable the
2099 ** [fts3_tokenizer()] function which is part of the
2100 ** [FTS3] full-text search engine extension.
@@ -2263,11 +2274,12 @@
2263 #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
2264 #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
2265 #define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
2266 #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
2267 #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
2268 #define SQLITE_DBCONFIG_MAX 1014 /* Largest DBCONFIG */
 
2269
2270 /*
2271 ** CAPI3REF: Enable Or Disable Extended Result Codes
2272 ** METHOD: sqlite3
2273 **
@@ -3812,11 +3824,11 @@
3812 ** a schema change, on the first [sqlite3_step()] call following any change
3813 ** to the [sqlite3_bind_text | bindings] of that [parameter].
3814 ** ^The specific value of WHERE-clause [parameter] might influence the
3815 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
3816 ** or [GLOB] operator or if the parameter is compared to an indexed column
3817 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3818 ** </li>
3819 ** </ol>
3820 **
3821 ** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
3822 ** the extra prepFlags parameter, which is a bit array consisting of zero or
@@ -4846,10 +4858,13 @@
4846 ** the same inputs within a single SQL statement. Most SQL functions are
4847 ** deterministic. The built-in [random()] SQL function is an example of a
4848 ** function that is not deterministic. The SQLite query planner is able to
4849 ** perform additional optimizations on deterministic functions, so use
4850 ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
 
 
 
4851 **
4852 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
4853 ** function can gain access to this pointer using [sqlite3_user_data()].)^
4854 **
4855 ** ^The sixth, seventh and eighth parameters passed to the three
@@ -4963,12 +4978,20 @@
4963 **
4964 ** These constants may be ORed together with the
4965 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
4966 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or
4967 ** [sqlite3_create_function_v2()].
 
 
 
 
 
 
 
4968 */
4969 #define SQLITE_DETERMINISTIC 0x800
 
4970
4971 /*
4972 ** CAPI3REF: Deprecated Functions
4973 ** DEPRECATED
4974 **
@@ -6610,10 +6633,16 @@
6610 ** no longer needs the pClientData pointer. ^The destructor will also
6611 ** be invoked if the call to sqlite3_create_module_v2() fails.
6612 ** ^The sqlite3_create_module()
6613 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
6614 ** destructor.
 
 
 
 
 
 
6615 */
6616 SQLITE_API int sqlite3_create_module(
6617 sqlite3 *db, /* SQLite connection to register module with */
6618 const char *zName, /* Name of the module */
6619 const sqlite3_module *p, /* Methods for the module */
@@ -6624,10 +6653,27 @@
6624 const char *zName, /* Name of the module */
6625 const sqlite3_module *p, /* Methods for the module */
6626 void *pClientData, /* Client data for xCreate/xConnect */
6627 void(*xDestroy)(void*) /* Module destructor function */
6628 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6629
6630 /*
6631 ** CAPI3REF: Virtual Table Instance Object
6632 ** KEYWORDS: sqlite3_vtab
6633 **
@@ -7333,11 +7379,11 @@
7333 ** [sqlite3_test_control()] interface.
7334 */
7335 #define SQLITE_TESTCTRL_FIRST 5
7336 #define SQLITE_TESTCTRL_PRNG_SAVE 5
7337 #define SQLITE_TESTCTRL_PRNG_RESTORE 6
7338 #define SQLITE_TESTCTRL_PRNG_RESET 7
7339 #define SQLITE_TESTCTRL_BITVEC_TEST 8
7340 #define SQLITE_TESTCTRL_FAULT_INSTALL 9
7341 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
7342 #define SQLITE_TESTCTRL_PENDING_BYTE 11
7343 #define SQLITE_TESTCTRL_ASSERT 12
@@ -7356,11 +7402,13 @@
7356 #define SQLITE_TESTCTRL_ISINIT 23
7357 #define SQLITE_TESTCTRL_SORTER_MMAP 24
7358 #define SQLITE_TESTCTRL_IMPOSTER 25
7359 #define SQLITE_TESTCTRL_PARSER_COVERAGE 26
7360 #define SQLITE_TESTCTRL_RESULT_INTREAL 27
7361 #define SQLITE_TESTCTRL_LAST 27 /* Largest TESTCTRL */
 
 
7362
7363 /*
7364 ** CAPI3REF: SQL Keyword Checking
7365 **
7366 ** These routines provide access to the set of SQL language keywords
7367
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121 **
122 ** See also: [sqlite3_libversion()],
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.30.0"
127 #define SQLITE_VERSION_NUMBER 3030000
128 #define SQLITE_SOURCE_ID "2019-09-03 16:23:41 3044cf6917ea8324175fc91657e9a5978af9748f72e1914bc361753f0b2d897d"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -2091,10 +2091,21 @@
2091 ** The second parameter is a pointer to an integer into which
2092 ** is written 0 or 1 to indicate whether triggers are disabled or enabled
2093 ** following this call. The second parameter may be a NULL pointer, in
2094 ** which case the trigger setting is not reported back. </dd>
2095 **
2096 ** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
2097 ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
2098 ** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
2099 ** There should be two additional arguments.
2100 ** The first argument is an integer which is 0 to disable views,
2101 ** positive to enable views or negative to leave the setting unchanged.
2102 ** The second parameter is a pointer to an integer into which
2103 ** is written 0 or 1 to indicate whether views are disabled or enabled
2104 ** following this call. The second parameter may be a NULL pointer, in
2105 ** which case the view setting is not reported back. </dd>
2106 **
2107 ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
2108 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
2109 ** <dd> ^This option is used to enable or disable the
2110 ** [fts3_tokenizer()] function which is part of the
2111 ** [FTS3] full-text search engine extension.
@@ -2263,11 +2274,12 @@
2274 #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
2275 #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
2276 #define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
2277 #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
2278 #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
2279 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2280 #define SQLITE_DBCONFIG_MAX 1015 /* Largest DBCONFIG */
2281
2282 /*
2283 ** CAPI3REF: Enable Or Disable Extended Result Codes
2284 ** METHOD: sqlite3
2285 **
@@ -3812,11 +3824,11 @@
3824 ** a schema change, on the first [sqlite3_step()] call following any change
3825 ** to the [sqlite3_bind_text | bindings] of that [parameter].
3826 ** ^The specific value of WHERE-clause [parameter] might influence the
3827 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
3828 ** or [GLOB] operator or if the parameter is compared to an indexed column
3829 ** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled.
3830 ** </li>
3831 ** </ol>
3832 **
3833 ** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
3834 ** the extra prepFlags parameter, which is a bit array consisting of zero or
@@ -4846,10 +4858,13 @@
4858 ** the same inputs within a single SQL statement. Most SQL functions are
4859 ** deterministic. The built-in [random()] SQL function is an example of a
4860 ** function that is not deterministic. The SQLite query planner is able to
4861 ** perform additional optimizations on deterministic functions, so use
4862 ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
4863 ** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY]
4864 ** flag, which if present prevents the function from being invoked from
4865 ** within VIEWs or TRIGGERs.
4866 **
4867 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
4868 ** function can gain access to this pointer using [sqlite3_user_data()].)^
4869 **
4870 ** ^The sixth, seventh and eighth parameters passed to the three
@@ -4963,12 +4978,20 @@
4978 **
4979 ** These constants may be ORed together with the
4980 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
4981 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or
4982 ** [sqlite3_create_function_v2()].
4983 **
4984 ** The SQLITE_DETERMINISTIC flag means that the new function will always
4985 ** maps the same inputs into the same output. The abs() function is
4986 ** deterministic, for example, but randomblob() is not.
4987 **
4988 ** The SQLITE_DIRECTONLY flag means that the function may only be invoked
4989 ** from top-level SQL, and cannot be used in VIEWs or TRIGGERs.
4990 */
4991 #define SQLITE_DETERMINISTIC 0x000000800
4992 #define SQLITE_DIRECTONLY 0x000080000
4993
4994 /*
4995 ** CAPI3REF: Deprecated Functions
4996 ** DEPRECATED
4997 **
@@ -6610,10 +6633,16 @@
6633 ** no longer needs the pClientData pointer. ^The destructor will also
6634 ** be invoked if the call to sqlite3_create_module_v2() fails.
6635 ** ^The sqlite3_create_module()
6636 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
6637 ** destructor.
6638 **
6639 ** ^If the third parameter (the pointer to the sqlite3_module object) is
6640 ** NULL then no new module is create and any existing modules with the
6641 ** same name are dropped.
6642 **
6643 ** See also: [sqlite3_drop_modules()]
6644 */
6645 SQLITE_API int sqlite3_create_module(
6646 sqlite3 *db, /* SQLite connection to register module with */
6647 const char *zName, /* Name of the module */
6648 const sqlite3_module *p, /* Methods for the module */
@@ -6624,10 +6653,27 @@
6653 const char *zName, /* Name of the module */
6654 const sqlite3_module *p, /* Methods for the module */
6655 void *pClientData, /* Client data for xCreate/xConnect */
6656 void(*xDestroy)(void*) /* Module destructor function */
6657 );
6658
6659 /*
6660 ** CAPI3REF: Remove Unnecessary Virtual Table Implementations
6661 ** METHOD: sqlite3
6662 **
6663 ** ^The sqlite3_drop_modules(D,L) interface removes all virtual
6664 ** table modules from database connection D except those named on list L.
6665 ** The L parameter must be either NULL or a pointer to an array of pointers
6666 ** to strings where the array is terminated by a single NULL pointer.
6667 ** ^If the L parameter is NULL, then all virtual table modules are removed.
6668 **
6669 ** See also: [sqlite3_create_module()]
6670 */
6671 SQLITE_API int sqlite3_drop_modules(
6672 sqlite3 *db, /* Remove modules from this connection */
6673 const char **azKeep /* Except, do not remove the ones named here */
6674 );
6675
6676 /*
6677 ** CAPI3REF: Virtual Table Instance Object
6678 ** KEYWORDS: sqlite3_vtab
6679 **
@@ -7333,11 +7379,11 @@
7379 ** [sqlite3_test_control()] interface.
7380 */
7381 #define SQLITE_TESTCTRL_FIRST 5
7382 #define SQLITE_TESTCTRL_PRNG_SAVE 5
7383 #define SQLITE_TESTCTRL_PRNG_RESTORE 6
7384 #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */
7385 #define SQLITE_TESTCTRL_BITVEC_TEST 8
7386 #define SQLITE_TESTCTRL_FAULT_INSTALL 9
7387 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
7388 #define SQLITE_TESTCTRL_PENDING_BYTE 11
7389 #define SQLITE_TESTCTRL_ASSERT 12
@@ -7356,11 +7402,13 @@
7402 #define SQLITE_TESTCTRL_ISINIT 23
7403 #define SQLITE_TESTCTRL_SORTER_MMAP 24
7404 #define SQLITE_TESTCTRL_IMPOSTER 25
7405 #define SQLITE_TESTCTRL_PARSER_COVERAGE 26
7406 #define SQLITE_TESTCTRL_RESULT_INTREAL 27
7407 #define SQLITE_TESTCTRL_PRNG_SEED 28
7408 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
7409 #define SQLITE_TESTCTRL_LAST 29 /* Largest TESTCTRL */
7410
7411 /*
7412 ** CAPI3REF: SQL Keyword Checking
7413 **
7414 ** These routines provide access to the set of SQL language keywords
7415

Keyboard Shortcuts

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