Fossil SCM

Update the built-in SQLite to the latest 3.31.0 alpha version as a beta-test for SQLite.

drh 2019-11-20 15:29 UTC trunk
Commit a9027e7d10e2fd2178d1e9d2872080aba427b58f15ccfeb20b71c50587d820af
3 files changed +66 -28 +6249 -4666 +65 -24
+66 -28
--- src/shell.c
+++ src/shell.c
@@ -5188,29 +5188,30 @@
51885188
static int zipfileDeflate(
51895189
const u8 *aIn, int nIn, /* Input */
51905190
u8 **ppOut, int *pnOut, /* Output */
51915191
char **pzErr /* OUT: Error message */
51925192
){
5193
- sqlite3_int64 nAlloc = compressBound(nIn);
5193
+ int rc = SQLITE_OK;
5194
+ sqlite3_int64 nAlloc;
5195
+ z_stream str;
51945196
u8 *aOut;
5195
- int rc = SQLITE_OK;
51965197
5198
+ memset(&str, 0, sizeof(str));
5199
+ str.next_in = (Bytef*)aIn;
5200
+ str.avail_in = nIn;
5201
+ deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
5202
+
5203
+ nAlloc = deflateBound(&str, nIn);
51975204
aOut = (u8*)sqlite3_malloc64(nAlloc);
51985205
if( aOut==0 ){
51995206
rc = SQLITE_NOMEM;
52005207
}else{
52015208
int res;
5202
- z_stream str;
5203
- memset(&str, 0, sizeof(str));
5204
- str.next_in = (Bytef*)aIn;
5205
- str.avail_in = nIn;
52065209
str.next_out = aOut;
52075210
str.avail_out = nAlloc;
5208
-
52095211
deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
52105212
res = deflate(&str, Z_FINISH);
5211
-
52125213
if( res==Z_STREAM_END ){
52135214
*ppOut = aOut;
52145215
*pnOut = (int)str.total_out;
52155216
}else{
52165217
sqlite3_free(aOut);
@@ -6523,12 +6524,12 @@
65236524
** May you find forgiveness for yourself and forgive others.
65246525
** May you share freely, never taking more than you give.
65256526
**
65266527
*************************************************************************
65276528
*/
6528
-
6529
-
6529
+#if !defined(SQLITEEXPERT_H)
6530
+#define SQLITEEXPERT_H 1
65306531
/* #include "sqlite3.h" */
65316532
65326533
typedef struct sqlite3expert sqlite3expert;
65336534
65346535
/*
@@ -6678,11 +6679,11 @@
66786679
** should be one call to this function for each successful call to
66796680
** sqlite3-expert_new().
66806681
*/
66816682
void sqlite3_expert_destroy(sqlite3expert*);
66826683
6683
-
6684
+#endif /* !defined(SQLITEEXPERT_H) */
66846685
66856686
/************************* End ../ext/expert/sqlite3expert.h ********************/
66866687
/************************* Begin ../ext/expert/sqlite3expert.c ******************/
66876688
/*
66886689
** 2017 April 09
@@ -9564,10 +9565,11 @@
95649565
u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
95659566
unsigned mEqpLines; /* Mask of veritical lines in the EQP output graph */
95669567
int outCount; /* Revert to stdout when reaching zero */
95679568
int cnt; /* Number of records displayed so far */
95689569
int lineno; /* Line number of last line read from in */
9570
+ int openFlags; /* Additional flags to open. (SQLITE_OPEN_NOFOLLOW) */
95699571
FILE *in; /* Read commands from this stream */
95709572
FILE *out; /* Write results here */
95719573
FILE *traceOut; /* Output for sqlite3_trace() */
95729574
int nErr; /* Number of errors seen */
95739575
int mode; /* An output mode setting */
@@ -10398,23 +10400,26 @@
1039810400
case MODE_Column: {
1039910401
static const int aExplainWidths[] = {4, 13, 4, 4, 4, 13, 2, 13};
1040010402
const int *colWidth;
1040110403
int showHdr;
1040210404
char *rowSep;
10405
+ int nWidth;
1040310406
if( p->cMode==MODE_Column ){
1040410407
colWidth = p->colWidth;
10408
+ nWidth = ArraySize(p->colWidth);
1040510409
showHdr = p->showHeader;
1040610410
rowSep = p->rowSeparator;
1040710411
}else{
1040810412
colWidth = aExplainWidths;
10413
+ nWidth = ArraySize(aExplainWidths);
1040910414
showHdr = 1;
1041010415
rowSep = SEP_Row;
1041110416
}
1041210417
if( p->cnt++==0 ){
1041310418
for(i=0; i<nArg; i++){
1041410419
int w, n;
10415
- if( i<ArraySize(p->colWidth) ){
10420
+ if( i<nWidth ){
1041610421
w = colWidth[i];
1041710422
}else{
1041810423
w = 0;
1041910424
}
1042010425
if( w==0 ){
@@ -12051,13 +12056,11 @@
1205112056
#endif
1205212057
" trigger Like \"full\" but also show trigger bytecode",
1205312058
".excel Display the output of next command in spreadsheet",
1205412059
".exit ?CODE? Exit this program with return-code CODE",
1205512060
".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",*/
12061
+ ".explain ?on|off|auto? Change the EXPLAIN formatting mode. Default: auto",
1205912062
".filectrl CMD ... Run various sqlite3_file_control() operations",
1206012063
" Run \".filectrl\" with no arguments for details",
1206112064
".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
1206212065
".headers on|off Turn display of headers on or off",
1206312066
".help ?-all? ?PATTERN? Show help text for PATTERN",
@@ -12104,10 +12107,11 @@
1210412107
" --deserialize Load into memory useing sqlite3_deserialize()",
1210512108
" --hexdb Load the output of \"dbtotxt\" as an in-memory db",
1210612109
" --maxsize N Maximum size for --hexdb or --deserialized database",
1210712110
#endif
1210812111
" --new Initialize FILE to an empty database",
12112
+ " --nofollow Do not follow symbolic links",
1210912113
" --readonly Open FILE readonly",
1211012114
" --zip FILE is a ZIP archive",
1211112115
".output ?FILE? Send output to FILE or stdout if FILE is omitted",
1211212116
" If FILE begins with '|' then open it as a pipe.",
1211312117
".parameter CMD ... Manage SQL parameter bindings",
@@ -12668,11 +12672,11 @@
1266812672
}
1266912673
}
1267012674
switch( p->openMode ){
1267112675
case SHELL_OPEN_APPENDVFS: {
1267212676
sqlite3_open_v2(p->zDbFilename, &p->db,
12673
- SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "apndvfs");
12677
+ SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|p->openFlags, "apndvfs");
1267412678
break;
1267512679
}
1267612680
case SHELL_OPEN_HEXDB:
1267712681
case SHELL_OPEN_DESERIALIZE: {
1267812682
sqlite3_open(0, &p->db);
@@ -12681,16 +12685,18 @@
1268112685
case SHELL_OPEN_ZIPFILE: {
1268212686
sqlite3_open(":memory:", &p->db);
1268312687
break;
1268412688
}
1268512689
case SHELL_OPEN_READONLY: {
12686
- sqlite3_open_v2(p->zDbFilename, &p->db, SQLITE_OPEN_READONLY, 0);
12690
+ sqlite3_open_v2(p->zDbFilename, &p->db,
12691
+ SQLITE_OPEN_READONLY|p->openFlags, 0);
1268712692
break;
1268812693
}
1268912694
case SHELL_OPEN_UNSPEC:
1269012695
case SHELL_OPEN_NORMAL: {
12691
- sqlite3_open(p->zDbFilename, &p->db);
12696
+ sqlite3_open_v2(p->zDbFilename, &p->db,
12697
+ SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|p->openFlags, 0);
1269212698
break;
1269312699
}
1269412700
}
1269512701
globalDb = p->db;
1269612702
if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){
@@ -15711,10 +15717,11 @@
1571115717
{ "defensive", SQLITE_DBCONFIG_DEFENSIVE },
1571215718
{ "writable_schema", SQLITE_DBCONFIG_WRITABLE_SCHEMA },
1571315719
{ "legacy_alter_table", SQLITE_DBCONFIG_LEGACY_ALTER_TABLE },
1571415720
{ "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
1571515721
{ "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
15722
+ { "legacy_file_format", SQLITE_DBCONFIG_LEGACY_FILE_FORMAT },
1571615723
};
1571715724
int ii, v;
1571815725
open_db(p, 0);
1571915726
for(ii=0; ii<ArraySize(aDbConfig); ii++){
1572015727
if( nArg>1 && strcmp(azArg[1], aDbConfig[ii].zName)!=0 ) continue;
@@ -16301,35 +16308,47 @@
1630116308
if( c=='i' && strncmp(azArg[0], "imposter", n)==0 ){
1630216309
char *zSql;
1630316310
char *zCollist = 0;
1630416311
sqlite3_stmt *pStmt;
1630516312
int tnum = 0;
16313
+ int isWO = 0; /* True if making an imposter of a WITHOUT ROWID table */
16314
+ int lenPK = 0; /* Length of the PRIMARY KEY string for isWO tables */
1630616315
int i;
1630716316
if( !(nArg==3 || (nArg==2 && sqlite3_stricmp(azArg[1],"off")==0)) ){
1630816317
utf8_printf(stderr, "Usage: .imposter INDEX IMPOSTER\n"
1630916318
" .imposter off\n");
16319
+ /* Also allowed, but not documented:
16320
+ **
16321
+ ** .imposter TABLE IMPOSTER
16322
+ **
16323
+ ** where TABLE is a WITHOUT ROWID table. In that case, the
16324
+ ** imposter is another WITHOUT ROWID table with the columns in
16325
+ ** storage order. */
1631016326
rc = 1;
1631116327
goto meta_command_exit;
1631216328
}
1631316329
open_db(p, 0);
1631416330
if( nArg==2 ){
1631516331
sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 0, 1);
1631616332
goto meta_command_exit;
1631716333
}
16318
- zSql = sqlite3_mprintf("SELECT rootpage FROM sqlite_master"
16319
- " WHERE name='%q' AND type='index'", azArg[1]);
16334
+ zSql = sqlite3_mprintf(
16335
+ "SELECT rootpage, 0 FROM sqlite_master"
16336
+ " WHERE name='%q' AND type='index'"
16337
+ "UNION ALL "
16338
+ "SELECT rootpage, 1 FROM sqlite_master"
16339
+ " WHERE name='%q' AND type='table'"
16340
+ " AND sql LIKE '%%without%%rowid%%'",
16341
+ azArg[1], azArg[1]
16342
+ );
1632016343
sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
1632116344
sqlite3_free(zSql);
1632216345
if( sqlite3_step(pStmt)==SQLITE_ROW ){
1632316346
tnum = sqlite3_column_int(pStmt, 0);
16347
+ isWO = sqlite3_column_int(pStmt, 1);
1632416348
}
1632516349
sqlite3_finalize(pStmt);
16326
- if( tnum==0 ){
16327
- utf8_printf(stderr, "no such index: \"%s\"\n", azArg[1]);
16328
- rc = 1;
16329
- goto meta_command_exit;
16330
- }
1633116350
zSql = sqlite3_mprintf("PRAGMA index_xinfo='%q'", azArg[1]);
1633216351
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
1633316352
sqlite3_free(zSql);
1633416353
i = 0;
1633516354
while( sqlite3_step(pStmt)==SQLITE_ROW ){
@@ -16342,20 +16361,30 @@
1634216361
}else{
1634316362
sqlite3_snprintf(sizeof(zLabel),zLabel,"expr%d",i);
1634416363
zCol = zLabel;
1634516364
}
1634616365
}
16366
+ if( isWO && lenPK==0 && sqlite3_column_int(pStmt,5)==0 && zCollist ){
16367
+ lenPK = (int)strlen(zCollist);
16368
+ }
1634716369
if( zCollist==0 ){
1634816370
zCollist = sqlite3_mprintf("\"%w\"", zCol);
1634916371
}else{
1635016372
zCollist = sqlite3_mprintf("%z,\"%w\"", zCollist, zCol);
1635116373
}
1635216374
}
1635316375
sqlite3_finalize(pStmt);
16376
+ if( i==0 || tnum==0 ){
16377
+ utf8_printf(stderr, "no such index: \"%s\"\n", azArg[1]);
16378
+ rc = 1;
16379
+ sqlite3_free(zCollist);
16380
+ goto meta_command_exit;
16381
+ }
16382
+ if( lenPK==0 ) lenPK = 100000;
1635416383
zSql = sqlite3_mprintf(
16355
- "CREATE TABLE \"%w\"(%s,PRIMARY KEY(%s))WITHOUT ROWID",
16356
- azArg[2], zCollist, zCollist);
16384
+ "CREATE TABLE \"%w\"(%s,PRIMARY KEY(%.*s))WITHOUT ROWID",
16385
+ azArg[2], zCollist, lenPK, zCollist);
1635716386
sqlite3_free(zCollist);
1635816387
rc = sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 1, tnum);
1635916388
if( rc==SQLITE_OK ){
1636016389
rc = sqlite3_exec(p->db, zSql, 0, 0, 0);
1636116390
sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 0, 0);
@@ -16362,11 +16391,12 @@
1636216391
if( rc ){
1636316392
utf8_printf(stderr, "Error in [%s]: %s\n", zSql, sqlite3_errmsg(p->db));
1636416393
}else{
1636516394
utf8_printf(stdout, "%s;\n", zSql);
1636616395
raw_printf(stdout,
16367
- "WARNING: writing to an imposter table will corrupt the index!\n"
16396
+ "WARNING: writing to an imposter table will corrupt the \"%s\" %s!\n",
16397
+ azArg[1], isWO ? "table" : "index"
1636816398
);
1636916399
}
1637016400
}else{
1637116401
raw_printf(stderr, "SQLITE_TESTCTRL_IMPOSTER returns %d\n", rc);
1637216402
rc = 1;
@@ -16560,10 +16590,11 @@
1656016590
p->db = 0;
1656116591
p->zDbFilename = 0;
1656216592
sqlite3_free(p->zFreeOnClose);
1656316593
p->zFreeOnClose = 0;
1656416594
p->openMode = SHELL_OPEN_UNSPEC;
16595
+ p->openFlags = 0;
1656516596
p->szMax = 0;
1656616597
/* Check for command-line arguments */
1656716598
for(iName=1; iName<nArg && azArg[iName][0]=='-'; iName++){
1656816599
const char *z = azArg[iName];
1656916600
if( optionMatch(z,"new") ){
@@ -16574,10 +16605,12 @@
1657416605
#endif
1657516606
}else if( optionMatch(z, "append") ){
1657616607
p->openMode = SHELL_OPEN_APPENDVFS;
1657716608
}else if( optionMatch(z, "readonly") ){
1657816609
p->openMode = SHELL_OPEN_READONLY;
16610
+ }else if( optionMatch(z, "nofollow") ){
16611
+ p->openFlags |= SQLITE_OPEN_NOFOLLOW;
1657916612
#ifdef SQLITE_ENABLE_DESERIALIZE
1658016613
}else if( optionMatch(z, "deserialize") ){
1658116614
p->openMode = SHELL_OPEN_DESERIALIZE;
1658216615
}else if( optionMatch(z, "hexdb") ){
1658316616
p->openMode = SHELL_OPEN_HEXDB;
@@ -18494,10 +18527,11 @@
1849418527
" -mmap N default mmap size set to N\n"
1849518528
#ifdef SQLITE_ENABLE_MULTIPLEX
1849618529
" -multiplex enable the multiplexor VFS\n"
1849718530
#endif
1849818531
" -newline SEP set output row separator. Default: '\\n'\n"
18532
+ " -nofollow refuse to open symbolic links to database files\n"
1849918533
" -nullvalue TEXT set text string for NULL values. Default ''\n"
1850018534
" -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n"
1850118535
" -quote set output mode to 'quote'\n"
1850218536
" -readonly open the database read-only\n"
1850318537
" -separator SEP set output column separator. Default: '|'\n"
@@ -18804,10 +18838,12 @@
1880418838
}else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
1880518839
data.szMax = integerValue(argv[++i]);
1880618840
#endif
1880718841
}else if( strcmp(z,"-readonly")==0 ){
1880818842
data.openMode = SHELL_OPEN_READONLY;
18843
+ }else if( strcmp(z,"-nofollow")==0 ){
18844
+ data.openFlags = SQLITE_OPEN_NOFOLLOW;
1880918845
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
1881018846
}else if( strncmp(z, "-A",2)==0 ){
1881118847
/* All remaining command-line arguments are passed to the ".archive"
1881218848
** command, so ignore them */
1881318849
break;
@@ -18907,10 +18943,12 @@
1890718943
}else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
1890818944
data.szMax = integerValue(argv[++i]);
1890918945
#endif
1891018946
}else if( strcmp(z,"-readonly")==0 ){
1891118947
data.openMode = SHELL_OPEN_READONLY;
18948
+ }else if( strcmp(z,"-nofollow")==0 ){
18949
+ data.openFlags |= SQLITE_OPEN_NOFOLLOW;
1891218950
}else if( strcmp(z,"-ascii")==0 ){
1891318951
data.mode = MODE_Ascii;
1891418952
sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
1891518953
SEP_Unit);
1891618954
sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,
1891718955
--- src/shell.c
+++ src/shell.c
@@ -5188,29 +5188,30 @@
5188 static int zipfileDeflate(
5189 const u8 *aIn, int nIn, /* Input */
5190 u8 **ppOut, int *pnOut, /* Output */
5191 char **pzErr /* OUT: Error message */
5192 ){
5193 sqlite3_int64 nAlloc = compressBound(nIn);
 
 
5194 u8 *aOut;
5195 int rc = SQLITE_OK;
5196
 
 
 
 
 
 
5197 aOut = (u8*)sqlite3_malloc64(nAlloc);
5198 if( aOut==0 ){
5199 rc = SQLITE_NOMEM;
5200 }else{
5201 int res;
5202 z_stream str;
5203 memset(&str, 0, sizeof(str));
5204 str.next_in = (Bytef*)aIn;
5205 str.avail_in = nIn;
5206 str.next_out = aOut;
5207 str.avail_out = nAlloc;
5208
5209 deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
5210 res = deflate(&str, Z_FINISH);
5211
5212 if( res==Z_STREAM_END ){
5213 *ppOut = aOut;
5214 *pnOut = (int)str.total_out;
5215 }else{
5216 sqlite3_free(aOut);
@@ -6523,12 +6524,12 @@
6523 ** May you find forgiveness for yourself and forgive others.
6524 ** May you share freely, never taking more than you give.
6525 **
6526 *************************************************************************
6527 */
6528
6529
6530 /* #include "sqlite3.h" */
6531
6532 typedef struct sqlite3expert sqlite3expert;
6533
6534 /*
@@ -6678,11 +6679,11 @@
6678 ** should be one call to this function for each successful call to
6679 ** sqlite3-expert_new().
6680 */
6681 void sqlite3_expert_destroy(sqlite3expert*);
6682
6683
6684
6685 /************************* End ../ext/expert/sqlite3expert.h ********************/
6686 /************************* Begin ../ext/expert/sqlite3expert.c ******************/
6687 /*
6688 ** 2017 April 09
@@ -9564,10 +9565,11 @@
9564 u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
9565 unsigned mEqpLines; /* Mask of veritical lines in the EQP output graph */
9566 int outCount; /* Revert to stdout when reaching zero */
9567 int cnt; /* Number of records displayed so far */
9568 int lineno; /* Line number of last line read from in */
 
9569 FILE *in; /* Read commands from this stream */
9570 FILE *out; /* Write results here */
9571 FILE *traceOut; /* Output for sqlite3_trace() */
9572 int nErr; /* Number of errors seen */
9573 int mode; /* An output mode setting */
@@ -10398,23 +10400,26 @@
10398 case MODE_Column: {
10399 static const int aExplainWidths[] = {4, 13, 4, 4, 4, 13, 2, 13};
10400 const int *colWidth;
10401 int showHdr;
10402 char *rowSep;
 
10403 if( p->cMode==MODE_Column ){
10404 colWidth = p->colWidth;
 
10405 showHdr = p->showHeader;
10406 rowSep = p->rowSeparator;
10407 }else{
10408 colWidth = aExplainWidths;
 
10409 showHdr = 1;
10410 rowSep = SEP_Row;
10411 }
10412 if( p->cnt++==0 ){
10413 for(i=0; i<nArg; i++){
10414 int w, n;
10415 if( i<ArraySize(p->colWidth) ){
10416 w = colWidth[i];
10417 }else{
10418 w = 0;
10419 }
10420 if( w==0 ){
@@ -12051,13 +12056,11 @@
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",
@@ -12104,10 +12107,11 @@
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",
12111 ".output ?FILE? Send output to FILE or stdout if FILE is omitted",
12112 " If FILE begins with '|' then open it as a pipe.",
12113 ".parameter CMD ... Manage SQL parameter bindings",
@@ -12668,11 +12672,11 @@
12668 }
12669 }
12670 switch( p->openMode ){
12671 case SHELL_OPEN_APPENDVFS: {
12672 sqlite3_open_v2(p->zDbFilename, &p->db,
12673 SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "apndvfs");
12674 break;
12675 }
12676 case SHELL_OPEN_HEXDB:
12677 case SHELL_OPEN_DESERIALIZE: {
12678 sqlite3_open(0, &p->db);
@@ -12681,16 +12685,18 @@
12681 case SHELL_OPEN_ZIPFILE: {
12682 sqlite3_open(":memory:", &p->db);
12683 break;
12684 }
12685 case SHELL_OPEN_READONLY: {
12686 sqlite3_open_v2(p->zDbFilename, &p->db, SQLITE_OPEN_READONLY, 0);
 
12687 break;
12688 }
12689 case SHELL_OPEN_UNSPEC:
12690 case SHELL_OPEN_NORMAL: {
12691 sqlite3_open(p->zDbFilename, &p->db);
 
12692 break;
12693 }
12694 }
12695 globalDb = p->db;
12696 if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){
@@ -15711,10 +15717,11 @@
15711 { "defensive", SQLITE_DBCONFIG_DEFENSIVE },
15712 { "writable_schema", SQLITE_DBCONFIG_WRITABLE_SCHEMA },
15713 { "legacy_alter_table", SQLITE_DBCONFIG_LEGACY_ALTER_TABLE },
15714 { "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
15715 { "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
 
15716 };
15717 int ii, v;
15718 open_db(p, 0);
15719 for(ii=0; ii<ArraySize(aDbConfig); ii++){
15720 if( nArg>1 && strcmp(azArg[1], aDbConfig[ii].zName)!=0 ) continue;
@@ -16301,35 +16308,47 @@
16301 if( c=='i' && strncmp(azArg[0], "imposter", n)==0 ){
16302 char *zSql;
16303 char *zCollist = 0;
16304 sqlite3_stmt *pStmt;
16305 int tnum = 0;
 
 
16306 int i;
16307 if( !(nArg==3 || (nArg==2 && sqlite3_stricmp(azArg[1],"off")==0)) ){
16308 utf8_printf(stderr, "Usage: .imposter INDEX IMPOSTER\n"
16309 " .imposter off\n");
 
 
 
 
 
 
 
16310 rc = 1;
16311 goto meta_command_exit;
16312 }
16313 open_db(p, 0);
16314 if( nArg==2 ){
16315 sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 0, 1);
16316 goto meta_command_exit;
16317 }
16318 zSql = sqlite3_mprintf("SELECT rootpage FROM sqlite_master"
16319 " WHERE name='%q' AND type='index'", azArg[1]);
 
 
 
 
 
 
 
16320 sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
16321 sqlite3_free(zSql);
16322 if( sqlite3_step(pStmt)==SQLITE_ROW ){
16323 tnum = sqlite3_column_int(pStmt, 0);
 
16324 }
16325 sqlite3_finalize(pStmt);
16326 if( tnum==0 ){
16327 utf8_printf(stderr, "no such index: \"%s\"\n", azArg[1]);
16328 rc = 1;
16329 goto meta_command_exit;
16330 }
16331 zSql = sqlite3_mprintf("PRAGMA index_xinfo='%q'", azArg[1]);
16332 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
16333 sqlite3_free(zSql);
16334 i = 0;
16335 while( sqlite3_step(pStmt)==SQLITE_ROW ){
@@ -16342,20 +16361,30 @@
16342 }else{
16343 sqlite3_snprintf(sizeof(zLabel),zLabel,"expr%d",i);
16344 zCol = zLabel;
16345 }
16346 }
 
 
 
16347 if( zCollist==0 ){
16348 zCollist = sqlite3_mprintf("\"%w\"", zCol);
16349 }else{
16350 zCollist = sqlite3_mprintf("%z,\"%w\"", zCollist, zCol);
16351 }
16352 }
16353 sqlite3_finalize(pStmt);
 
 
 
 
 
 
 
16354 zSql = sqlite3_mprintf(
16355 "CREATE TABLE \"%w\"(%s,PRIMARY KEY(%s))WITHOUT ROWID",
16356 azArg[2], zCollist, zCollist);
16357 sqlite3_free(zCollist);
16358 rc = sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 1, tnum);
16359 if( rc==SQLITE_OK ){
16360 rc = sqlite3_exec(p->db, zSql, 0, 0, 0);
16361 sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 0, 0);
@@ -16362,11 +16391,12 @@
16362 if( rc ){
16363 utf8_printf(stderr, "Error in [%s]: %s\n", zSql, sqlite3_errmsg(p->db));
16364 }else{
16365 utf8_printf(stdout, "%s;\n", zSql);
16366 raw_printf(stdout,
16367 "WARNING: writing to an imposter table will corrupt the index!\n"
 
16368 );
16369 }
16370 }else{
16371 raw_printf(stderr, "SQLITE_TESTCTRL_IMPOSTER returns %d\n", rc);
16372 rc = 1;
@@ -16560,10 +16590,11 @@
16560 p->db = 0;
16561 p->zDbFilename = 0;
16562 sqlite3_free(p->zFreeOnClose);
16563 p->zFreeOnClose = 0;
16564 p->openMode = SHELL_OPEN_UNSPEC;
 
16565 p->szMax = 0;
16566 /* Check for command-line arguments */
16567 for(iName=1; iName<nArg && azArg[iName][0]=='-'; iName++){
16568 const char *z = azArg[iName];
16569 if( optionMatch(z,"new") ){
@@ -16574,10 +16605,12 @@
16574 #endif
16575 }else if( optionMatch(z, "append") ){
16576 p->openMode = SHELL_OPEN_APPENDVFS;
16577 }else if( optionMatch(z, "readonly") ){
16578 p->openMode = SHELL_OPEN_READONLY;
 
 
16579 #ifdef SQLITE_ENABLE_DESERIALIZE
16580 }else if( optionMatch(z, "deserialize") ){
16581 p->openMode = SHELL_OPEN_DESERIALIZE;
16582 }else if( optionMatch(z, "hexdb") ){
16583 p->openMode = SHELL_OPEN_HEXDB;
@@ -18494,10 +18527,11 @@
18494 " -mmap N default mmap size set to N\n"
18495 #ifdef SQLITE_ENABLE_MULTIPLEX
18496 " -multiplex enable the multiplexor VFS\n"
18497 #endif
18498 " -newline SEP set output row separator. Default: '\\n'\n"
 
18499 " -nullvalue TEXT set text string for NULL values. Default ''\n"
18500 " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n"
18501 " -quote set output mode to 'quote'\n"
18502 " -readonly open the database read-only\n"
18503 " -separator SEP set output column separator. Default: '|'\n"
@@ -18804,10 +18838,12 @@
18804 }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
18805 data.szMax = integerValue(argv[++i]);
18806 #endif
18807 }else if( strcmp(z,"-readonly")==0 ){
18808 data.openMode = SHELL_OPEN_READONLY;
 
 
18809 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
18810 }else if( strncmp(z, "-A",2)==0 ){
18811 /* All remaining command-line arguments are passed to the ".archive"
18812 ** command, so ignore them */
18813 break;
@@ -18907,10 +18943,12 @@
18907 }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
18908 data.szMax = integerValue(argv[++i]);
18909 #endif
18910 }else if( strcmp(z,"-readonly")==0 ){
18911 data.openMode = SHELL_OPEN_READONLY;
 
 
18912 }else if( strcmp(z,"-ascii")==0 ){
18913 data.mode = MODE_Ascii;
18914 sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
18915 SEP_Unit);
18916 sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,
18917
--- src/shell.c
+++ src/shell.c
@@ -5188,29 +5188,30 @@
5188 static int zipfileDeflate(
5189 const u8 *aIn, int nIn, /* Input */
5190 u8 **ppOut, int *pnOut, /* Output */
5191 char **pzErr /* OUT: Error message */
5192 ){
5193 int rc = SQLITE_OK;
5194 sqlite3_int64 nAlloc;
5195 z_stream str;
5196 u8 *aOut;
 
5197
5198 memset(&str, 0, sizeof(str));
5199 str.next_in = (Bytef*)aIn;
5200 str.avail_in = nIn;
5201 deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
5202
5203 nAlloc = deflateBound(&str, nIn);
5204 aOut = (u8*)sqlite3_malloc64(nAlloc);
5205 if( aOut==0 ){
5206 rc = SQLITE_NOMEM;
5207 }else{
5208 int res;
 
 
 
 
5209 str.next_out = aOut;
5210 str.avail_out = nAlloc;
 
5211 deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
5212 res = deflate(&str, Z_FINISH);
 
5213 if( res==Z_STREAM_END ){
5214 *ppOut = aOut;
5215 *pnOut = (int)str.total_out;
5216 }else{
5217 sqlite3_free(aOut);
@@ -6523,12 +6524,12 @@
6524 ** May you find forgiveness for yourself and forgive others.
6525 ** May you share freely, never taking more than you give.
6526 **
6527 *************************************************************************
6528 */
6529 #if !defined(SQLITEEXPERT_H)
6530 #define SQLITEEXPERT_H 1
6531 /* #include "sqlite3.h" */
6532
6533 typedef struct sqlite3expert sqlite3expert;
6534
6535 /*
@@ -6678,11 +6679,11 @@
6679 ** should be one call to this function for each successful call to
6680 ** sqlite3-expert_new().
6681 */
6682 void sqlite3_expert_destroy(sqlite3expert*);
6683
6684 #endif /* !defined(SQLITEEXPERT_H) */
6685
6686 /************************* End ../ext/expert/sqlite3expert.h ********************/
6687 /************************* Begin ../ext/expert/sqlite3expert.c ******************/
6688 /*
6689 ** 2017 April 09
@@ -9564,10 +9565,11 @@
9565 u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
9566 unsigned mEqpLines; /* Mask of veritical lines in the EQP output graph */
9567 int outCount; /* Revert to stdout when reaching zero */
9568 int cnt; /* Number of records displayed so far */
9569 int lineno; /* Line number of last line read from in */
9570 int openFlags; /* Additional flags to open. (SQLITE_OPEN_NOFOLLOW) */
9571 FILE *in; /* Read commands from this stream */
9572 FILE *out; /* Write results here */
9573 FILE *traceOut; /* Output for sqlite3_trace() */
9574 int nErr; /* Number of errors seen */
9575 int mode; /* An output mode setting */
@@ -10398,23 +10400,26 @@
10400 case MODE_Column: {
10401 static const int aExplainWidths[] = {4, 13, 4, 4, 4, 13, 2, 13};
10402 const int *colWidth;
10403 int showHdr;
10404 char *rowSep;
10405 int nWidth;
10406 if( p->cMode==MODE_Column ){
10407 colWidth = p->colWidth;
10408 nWidth = ArraySize(p->colWidth);
10409 showHdr = p->showHeader;
10410 rowSep = p->rowSeparator;
10411 }else{
10412 colWidth = aExplainWidths;
10413 nWidth = ArraySize(aExplainWidths);
10414 showHdr = 1;
10415 rowSep = SEP_Row;
10416 }
10417 if( p->cnt++==0 ){
10418 for(i=0; i<nArg; i++){
10419 int w, n;
10420 if( i<nWidth ){
10421 w = colWidth[i];
10422 }else{
10423 w = 0;
10424 }
10425 if( w==0 ){
@@ -12051,13 +12056,11 @@
12056 #endif
12057 " trigger Like \"full\" but also show trigger bytecode",
12058 ".excel Display the output of next command in spreadsheet",
12059 ".exit ?CODE? Exit this program with return-code CODE",
12060 ".expert EXPERIMENTAL. Suggest indexes for queries",
12061 ".explain ?on|off|auto? Change the EXPLAIN formatting mode. Default: auto",
 
 
12062 ".filectrl CMD ... Run various sqlite3_file_control() operations",
12063 " Run \".filectrl\" with no arguments for details",
12064 ".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
12065 ".headers on|off Turn display of headers on or off",
12066 ".help ?-all? ?PATTERN? Show help text for PATTERN",
@@ -12104,10 +12107,11 @@
12107 " --deserialize Load into memory useing sqlite3_deserialize()",
12108 " --hexdb Load the output of \"dbtotxt\" as an in-memory db",
12109 " --maxsize N Maximum size for --hexdb or --deserialized database",
12110 #endif
12111 " --new Initialize FILE to an empty database",
12112 " --nofollow Do not follow symbolic links",
12113 " --readonly Open FILE readonly",
12114 " --zip FILE is a ZIP archive",
12115 ".output ?FILE? Send output to FILE or stdout if FILE is omitted",
12116 " If FILE begins with '|' then open it as a pipe.",
12117 ".parameter CMD ... Manage SQL parameter bindings",
@@ -12668,11 +12672,11 @@
12672 }
12673 }
12674 switch( p->openMode ){
12675 case SHELL_OPEN_APPENDVFS: {
12676 sqlite3_open_v2(p->zDbFilename, &p->db,
12677 SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|p->openFlags, "apndvfs");
12678 break;
12679 }
12680 case SHELL_OPEN_HEXDB:
12681 case SHELL_OPEN_DESERIALIZE: {
12682 sqlite3_open(0, &p->db);
@@ -12681,16 +12685,18 @@
12685 case SHELL_OPEN_ZIPFILE: {
12686 sqlite3_open(":memory:", &p->db);
12687 break;
12688 }
12689 case SHELL_OPEN_READONLY: {
12690 sqlite3_open_v2(p->zDbFilename, &p->db,
12691 SQLITE_OPEN_READONLY|p->openFlags, 0);
12692 break;
12693 }
12694 case SHELL_OPEN_UNSPEC:
12695 case SHELL_OPEN_NORMAL: {
12696 sqlite3_open_v2(p->zDbFilename, &p->db,
12697 SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|p->openFlags, 0);
12698 break;
12699 }
12700 }
12701 globalDb = p->db;
12702 if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){
@@ -15711,10 +15717,11 @@
15717 { "defensive", SQLITE_DBCONFIG_DEFENSIVE },
15718 { "writable_schema", SQLITE_DBCONFIG_WRITABLE_SCHEMA },
15719 { "legacy_alter_table", SQLITE_DBCONFIG_LEGACY_ALTER_TABLE },
15720 { "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
15721 { "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
15722 { "legacy_file_format", SQLITE_DBCONFIG_LEGACY_FILE_FORMAT },
15723 };
15724 int ii, v;
15725 open_db(p, 0);
15726 for(ii=0; ii<ArraySize(aDbConfig); ii++){
15727 if( nArg>1 && strcmp(azArg[1], aDbConfig[ii].zName)!=0 ) continue;
@@ -16301,35 +16308,47 @@
16308 if( c=='i' && strncmp(azArg[0], "imposter", n)==0 ){
16309 char *zSql;
16310 char *zCollist = 0;
16311 sqlite3_stmt *pStmt;
16312 int tnum = 0;
16313 int isWO = 0; /* True if making an imposter of a WITHOUT ROWID table */
16314 int lenPK = 0; /* Length of the PRIMARY KEY string for isWO tables */
16315 int i;
16316 if( !(nArg==3 || (nArg==2 && sqlite3_stricmp(azArg[1],"off")==0)) ){
16317 utf8_printf(stderr, "Usage: .imposter INDEX IMPOSTER\n"
16318 " .imposter off\n");
16319 /* Also allowed, but not documented:
16320 **
16321 ** .imposter TABLE IMPOSTER
16322 **
16323 ** where TABLE is a WITHOUT ROWID table. In that case, the
16324 ** imposter is another WITHOUT ROWID table with the columns in
16325 ** storage order. */
16326 rc = 1;
16327 goto meta_command_exit;
16328 }
16329 open_db(p, 0);
16330 if( nArg==2 ){
16331 sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 0, 1);
16332 goto meta_command_exit;
16333 }
16334 zSql = sqlite3_mprintf(
16335 "SELECT rootpage, 0 FROM sqlite_master"
16336 " WHERE name='%q' AND type='index'"
16337 "UNION ALL "
16338 "SELECT rootpage, 1 FROM sqlite_master"
16339 " WHERE name='%q' AND type='table'"
16340 " AND sql LIKE '%%without%%rowid%%'",
16341 azArg[1], azArg[1]
16342 );
16343 sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
16344 sqlite3_free(zSql);
16345 if( sqlite3_step(pStmt)==SQLITE_ROW ){
16346 tnum = sqlite3_column_int(pStmt, 0);
16347 isWO = sqlite3_column_int(pStmt, 1);
16348 }
16349 sqlite3_finalize(pStmt);
 
 
 
 
 
16350 zSql = sqlite3_mprintf("PRAGMA index_xinfo='%q'", azArg[1]);
16351 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
16352 sqlite3_free(zSql);
16353 i = 0;
16354 while( sqlite3_step(pStmt)==SQLITE_ROW ){
@@ -16342,20 +16361,30 @@
16361 }else{
16362 sqlite3_snprintf(sizeof(zLabel),zLabel,"expr%d",i);
16363 zCol = zLabel;
16364 }
16365 }
16366 if( isWO && lenPK==0 && sqlite3_column_int(pStmt,5)==0 && zCollist ){
16367 lenPK = (int)strlen(zCollist);
16368 }
16369 if( zCollist==0 ){
16370 zCollist = sqlite3_mprintf("\"%w\"", zCol);
16371 }else{
16372 zCollist = sqlite3_mprintf("%z,\"%w\"", zCollist, zCol);
16373 }
16374 }
16375 sqlite3_finalize(pStmt);
16376 if( i==0 || tnum==0 ){
16377 utf8_printf(stderr, "no such index: \"%s\"\n", azArg[1]);
16378 rc = 1;
16379 sqlite3_free(zCollist);
16380 goto meta_command_exit;
16381 }
16382 if( lenPK==0 ) lenPK = 100000;
16383 zSql = sqlite3_mprintf(
16384 "CREATE TABLE \"%w\"(%s,PRIMARY KEY(%.*s))WITHOUT ROWID",
16385 azArg[2], zCollist, lenPK, zCollist);
16386 sqlite3_free(zCollist);
16387 rc = sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 1, tnum);
16388 if( rc==SQLITE_OK ){
16389 rc = sqlite3_exec(p->db, zSql, 0, 0, 0);
16390 sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 0, 0);
@@ -16362,11 +16391,12 @@
16391 if( rc ){
16392 utf8_printf(stderr, "Error in [%s]: %s\n", zSql, sqlite3_errmsg(p->db));
16393 }else{
16394 utf8_printf(stdout, "%s;\n", zSql);
16395 raw_printf(stdout,
16396 "WARNING: writing to an imposter table will corrupt the \"%s\" %s!\n",
16397 azArg[1], isWO ? "table" : "index"
16398 );
16399 }
16400 }else{
16401 raw_printf(stderr, "SQLITE_TESTCTRL_IMPOSTER returns %d\n", rc);
16402 rc = 1;
@@ -16560,10 +16590,11 @@
16590 p->db = 0;
16591 p->zDbFilename = 0;
16592 sqlite3_free(p->zFreeOnClose);
16593 p->zFreeOnClose = 0;
16594 p->openMode = SHELL_OPEN_UNSPEC;
16595 p->openFlags = 0;
16596 p->szMax = 0;
16597 /* Check for command-line arguments */
16598 for(iName=1; iName<nArg && azArg[iName][0]=='-'; iName++){
16599 const char *z = azArg[iName];
16600 if( optionMatch(z,"new") ){
@@ -16574,10 +16605,12 @@
16605 #endif
16606 }else if( optionMatch(z, "append") ){
16607 p->openMode = SHELL_OPEN_APPENDVFS;
16608 }else if( optionMatch(z, "readonly") ){
16609 p->openMode = SHELL_OPEN_READONLY;
16610 }else if( optionMatch(z, "nofollow") ){
16611 p->openFlags |= SQLITE_OPEN_NOFOLLOW;
16612 #ifdef SQLITE_ENABLE_DESERIALIZE
16613 }else if( optionMatch(z, "deserialize") ){
16614 p->openMode = SHELL_OPEN_DESERIALIZE;
16615 }else if( optionMatch(z, "hexdb") ){
16616 p->openMode = SHELL_OPEN_HEXDB;
@@ -18494,10 +18527,11 @@
18527 " -mmap N default mmap size set to N\n"
18528 #ifdef SQLITE_ENABLE_MULTIPLEX
18529 " -multiplex enable the multiplexor VFS\n"
18530 #endif
18531 " -newline SEP set output row separator. Default: '\\n'\n"
18532 " -nofollow refuse to open symbolic links to database files\n"
18533 " -nullvalue TEXT set text string for NULL values. Default ''\n"
18534 " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n"
18535 " -quote set output mode to 'quote'\n"
18536 " -readonly open the database read-only\n"
18537 " -separator SEP set output column separator. Default: '|'\n"
@@ -18804,10 +18838,12 @@
18838 }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
18839 data.szMax = integerValue(argv[++i]);
18840 #endif
18841 }else if( strcmp(z,"-readonly")==0 ){
18842 data.openMode = SHELL_OPEN_READONLY;
18843 }else if( strcmp(z,"-nofollow")==0 ){
18844 data.openFlags = SQLITE_OPEN_NOFOLLOW;
18845 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
18846 }else if( strncmp(z, "-A",2)==0 ){
18847 /* All remaining command-line arguments are passed to the ".archive"
18848 ** command, so ignore them */
18849 break;
@@ -18907,10 +18943,12 @@
18943 }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
18944 data.szMax = integerValue(argv[++i]);
18945 #endif
18946 }else if( strcmp(z,"-readonly")==0 ){
18947 data.openMode = SHELL_OPEN_READONLY;
18948 }else if( strcmp(z,"-nofollow")==0 ){
18949 data.openFlags |= SQLITE_OPEN_NOFOLLOW;
18950 }else if( strcmp(z,"-ascii")==0 ){
18951 data.mode = MODE_Ascii;
18952 sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
18953 SEP_Unit);
18954 sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,
18955
+6249 -4666
--- 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.30.0. By combining all the individual C code files into this
3
+** version 3.31.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.
@@ -1163,13 +1163,13 @@
11631163
**
11641164
** See also: [sqlite3_libversion()],
11651165
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11661166
** [sqlite_version()] and [sqlite_source_id()].
11671167
*/
1168
-#define SQLITE_VERSION "3.30.0"
1169
-#define SQLITE_VERSION_NUMBER 3030000
1170
-#define SQLITE_SOURCE_ID "2019-10-04 15:03:17 c20a35336432025445f9f7e289d0cc3e4003fb17f45a4ce74c6269c407c6e09f"
1168
+#define SQLITE_VERSION "3.31.0"
1169
+#define SQLITE_VERSION_NUMBER 3031000
1170
+#define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9f49b"
11711171
11721172
/*
11731173
** CAPI3REF: Run-Time Library Version Numbers
11741174
** KEYWORDS: sqlite3_version sqlite3_sourceid
11751175
**
@@ -1556,10 +1556,11 @@
15561556
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
15571557
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
15581558
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
15591559
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
15601560
#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
1561
+#define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8))
15611562
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
15621563
#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
15631564
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
15641565
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
15651566
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -1608,10 +1609,11 @@
16081609
#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
16091610
#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
16101611
#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
16111612
#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
16121613
#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
1614
+#define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */
16131615
16141616
/* Reserved: 0x00F00000 */
16151617
16161618
/*
16171619
** CAPI3REF: Device Characteristics
@@ -2446,10 +2448,11 @@
24462448
** SQLite.
24472449
*/
24482450
#define SQLITE_ACCESS_EXISTS 0
24492451
#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
24502452
#define SQLITE_ACCESS_READ 2 /* Unused */
2453
+#define SQLITE_ACCESS_SYMLINK 3 /* Test if file is symbolic link */
24512454
24522455
/*
24532456
** CAPI3REF: Flags for the xShmLock VFS method
24542457
**
24552458
** These integer constants define the various locking operations
@@ -2782,10 +2785,11 @@
27822785
** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
27832786
** interpreted as a boolean, which enables or disables the collection of
27842787
** memory allocation statistics. ^(When memory allocation statistics are
27852788
** disabled, the following SQLite interfaces become non-operational:
27862789
** <ul>
2790
+** <li> [sqlite3_hard_heap_limit64()]
27872791
** <li> [sqlite3_memory_used()]
27882792
** <li> [sqlite3_memory_highwater()]
27892793
** <li> [sqlite3_soft_heap_limit64()]
27902794
** <li> [sqlite3_status64()]
27912795
** </ul>)^
@@ -3299,10 +3303,32 @@
32993303
** the legacy [double-quoted string literal] misfeature for DDL statements,
33003304
** such as CREATE TABLE and CREATE INDEX. The
33013305
** default value of this setting is determined by the [-DSQLITE_DQS]
33023306
** compile-time option.
33033307
** </dd>
3308
+**
3309
+** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]]
3310
+** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</td>
3311
+** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates
3312
+** the legacy file format flag. When activated, this flag causes all newly
3313
+** created database file to have a schema format version number (the 4-byte
3314
+** integer found at offset 44 into the database header) of 1. This in turn
3315
+** means that the resulting database file will be readable and writable by
3316
+** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting,
3317
+** newly created databases are generally not understandable by SQLite versions
3318
+** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there
3319
+** is now scarcely any need to generated database files that are compatible
3320
+** all the way back to version 3.0.0, and so this setting is of little
3321
+** practical use, but is provided so that SQLite can continue to claim the
3322
+** ability to generate new database files that are compatible with version
3323
+** 3.0.0.
3324
+** <p>Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on,
3325
+** the [VACUUM] command will fail with an obscure error when attempting to
3326
+** process a table with generated columns and a descending index. This is
3327
+** not considered a bug since SQLite versions 3.3.0 and earlier do not support
3328
+** either generated columns or decending indexes.
3329
+** </dd>
33043330
** </dl>
33053331
*/
33063332
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
33073333
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
33083334
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -3317,11 +3343,12 @@
33173343
#define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
33183344
#define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
33193345
#define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
33203346
#define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
33213347
#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
3322
-#define SQLITE_DBCONFIG_MAX 1015 /* Largest DBCONFIG */
3348
+#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
3349
+#define SQLITE_DBCONFIG_MAX 1016 /* Largest DBCONFIG */
33233350
33243351
/*
33253352
** CAPI3REF: Enable Or Disable Extended Result Codes
33263353
** METHOD: sqlite3
33273354
**
@@ -7155,10 +7182,13 @@
71557182
*/
71567183
SQLITE_API int sqlite3_db_release_memory(sqlite3*);
71577184
71587185
/*
71597186
** CAPI3REF: Impose A Limit On Heap Size
7187
+**
7188
+** These interfaces impose limits on the amount of heap memory that will be
7189
+** by all database connections within a single process.
71607190
**
71617191
** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
71627192
** soft limit on the amount of heap memory that may be allocated by SQLite.
71637193
** ^SQLite strives to keep heap memory utilization below the soft heap
71647194
** limit by reducing the number of pages held in the page cache
@@ -7166,24 +7196,45 @@
71667196
** ^The soft heap limit is "soft" because even though SQLite strives to stay
71677197
** below the limit, it will exceed the limit rather than generate
71687198
** an [SQLITE_NOMEM] error. In other words, the soft heap limit
71697199
** is advisory only.
71707200
**
7171
-** ^The return value from sqlite3_soft_heap_limit64() is the size of
7172
-** the soft heap limit prior to the call, or negative in the case of an
7201
+** ^The sqlite3_hard_heap_limit64(N) interface sets a hard upper bound of
7202
+** N bytes on the amount of memory that will be allocated. ^The
7203
+** sqlite3_hard_heap_limit64(N) interface is similar to
7204
+** sqlite3_soft_heap_limit64(N) except that memory allocations will fail
7205
+** when the hard heap limit is reached.
7206
+**
7207
+** ^The return value from both sqlite3_soft_heap_limit64() and
7208
+** sqlite3_hard_heap_limit64() is the size of
7209
+** the heap limit prior to the call, or negative in the case of an
71737210
** error. ^If the argument N is negative
7174
-** then no change is made to the soft heap limit. Hence, the current
7175
-** size of the soft heap limit can be determined by invoking
7176
-** sqlite3_soft_heap_limit64() with a negative argument.
7211
+** then no change is made to the heap limit. Hence, the current
7212
+** size of heap limits can be determined by invoking
7213
+** sqlite3_soft_heap_limit64(-1) or sqlite3_hard_heap_limit(-1).
71777214
**
7178
-** ^If the argument N is zero then the soft heap limit is disabled.
7215
+** ^Setting the heap limits to zero disables the heap limiter mechanism.
71797216
**
7180
-** ^(The soft heap limit is not enforced in the current implementation
7217
+** ^The soft heap limit may not be greater than the hard heap limit.
7218
+** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N)
7219
+** is invoked with a value of N that is greater than the hard heap limit,
7220
+** the the soft heap limit is set to the value of the hard heap limit.
7221
+** ^The soft heap limit is automatically enabled whenever the hard heap
7222
+** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and
7223
+** the soft heap limit is outside the range of 1..N, then the soft heap
7224
+** limit is set to N. ^Invoking sqlite3_soft_heap_limit64(0) when the
7225
+** hard heap limit is enabled makes the soft heap limit equal to the
7226
+** hard heap limit.
7227
+**
7228
+** The memory allocation limits can also be adjusted using
7229
+** [PRAGMA soft_heap_limit] and [PRAGMA hard_heap_limit].
7230
+**
7231
+** ^(The heap limits are not enforced in the current implementation
71817232
** if one or more of following conditions are true:
71827233
**
71837234
** <ul>
7184
-** <li> The soft heap limit is set to zero.
7235
+** <li> The limit value is set to zero.
71857236
** <li> Memory accounting is disabled using a combination of the
71867237
** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
71877238
** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
71887239
** <li> An alternative page cache implementation is specified using
71897240
** [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).
@@ -7190,25 +7241,15 @@
71907241
** <li> The page cache allocates from its own memory pool supplied
71917242
** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
71927243
** from the heap.
71937244
** </ul>)^
71947245
**
7195
-** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]),
7196
-** the soft heap limit is enforced
7197
-** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]
7198
-** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT],
7199
-** the soft heap limit is enforced on every memory allocation. Without
7200
-** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced
7201
-** when memory is allocated by the page cache. Testing suggests that because
7202
-** the page cache is the predominate memory user in SQLite, most
7203
-** applications will achieve adequate soft heap limit enforcement without
7204
-** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
7205
-**
7206
-** The circumstances under which SQLite will enforce the soft heap limit may
7246
+** The circumstances under which SQLite will enforce the heap limits may
72077247
** changes in future releases of SQLite.
72087248
*/
72097249
SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
7250
+SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
72107251
72117252
/*
72127253
** CAPI3REF: Deprecated Soft Heap Limit Interface
72137254
** DEPRECATED
72147255
**
@@ -13671,94 +13712,96 @@
1367113712
#define TK_UNBOUNDED 90
1367213713
#define TK_EXCLUDE 91
1367313714
#define TK_GROUPS 92
1367413715
#define TK_OTHERS 93
1367513716
#define TK_TIES 94
13676
-#define TK_REINDEX 95
13677
-#define TK_RENAME 96
13678
-#define TK_CTIME_KW 97
13679
-#define TK_ANY 98
13680
-#define TK_BITAND 99
13681
-#define TK_BITOR 100
13682
-#define TK_LSHIFT 101
13683
-#define TK_RSHIFT 102
13684
-#define TK_PLUS 103
13685
-#define TK_MINUS 104
13686
-#define TK_STAR 105
13687
-#define TK_SLASH 106
13688
-#define TK_REM 107
13689
-#define TK_CONCAT 108
13690
-#define TK_COLLATE 109
13691
-#define TK_BITNOT 110
13692
-#define TK_ON 111
13693
-#define TK_INDEXED 112
13694
-#define TK_STRING 113
13695
-#define TK_JOIN_KW 114
13696
-#define TK_CONSTRAINT 115
13697
-#define TK_DEFAULT 116
13698
-#define TK_NULL 117
13699
-#define TK_PRIMARY 118
13700
-#define TK_UNIQUE 119
13701
-#define TK_CHECK 120
13702
-#define TK_REFERENCES 121
13703
-#define TK_AUTOINCR 122
13704
-#define TK_INSERT 123
13705
-#define TK_DELETE 124
13706
-#define TK_UPDATE 125
13707
-#define TK_SET 126
13708
-#define TK_DEFERRABLE 127
13709
-#define TK_FOREIGN 128
13710
-#define TK_DROP 129
13711
-#define TK_UNION 130
13712
-#define TK_ALL 131
13713
-#define TK_EXCEPT 132
13714
-#define TK_INTERSECT 133
13715
-#define TK_SELECT 134
13716
-#define TK_VALUES 135
13717
-#define TK_DISTINCT 136
13718
-#define TK_DOT 137
13719
-#define TK_FROM 138
13720
-#define TK_JOIN 139
13721
-#define TK_USING 140
13722
-#define TK_ORDER 141
13723
-#define TK_GROUP 142
13724
-#define TK_HAVING 143
13725
-#define TK_LIMIT 144
13726
-#define TK_WHERE 145
13727
-#define TK_INTO 146
13728
-#define TK_NOTHING 147
13729
-#define TK_FLOAT 148
13730
-#define TK_BLOB 149
13731
-#define TK_INTEGER 150
13732
-#define TK_VARIABLE 151
13733
-#define TK_CASE 152
13734
-#define TK_WHEN 153
13735
-#define TK_THEN 154
13736
-#define TK_ELSE 155
13737
-#define TK_INDEX 156
13738
-#define TK_ALTER 157
13739
-#define TK_ADD 158
13740
-#define TK_WINDOW 159
13741
-#define TK_OVER 160
13742
-#define TK_FILTER 161
13743
-#define TK_COLUMN 162
13744
-#define TK_AGG_FUNCTION 163
13745
-#define TK_AGG_COLUMN 164
13746
-#define TK_TRUEFALSE 165
13747
-#define TK_ISNOT 166
13748
-#define TK_FUNCTION 167
13749
-#define TK_UMINUS 168
13750
-#define TK_UPLUS 169
13751
-#define TK_TRUTH 170
13752
-#define TK_REGISTER 171
13753
-#define TK_VECTOR 172
13754
-#define TK_SELECT_COLUMN 173
13755
-#define TK_IF_NULL_ROW 174
13756
-#define TK_ASTERISK 175
13757
-#define TK_SPAN 176
13758
-#define TK_SPACE 177
13759
-#define TK_ILLEGAL 178
13717
+#define TK_GENERATED 95
13718
+#define TK_ALWAYS 96
13719
+#define TK_REINDEX 97
13720
+#define TK_RENAME 98
13721
+#define TK_CTIME_KW 99
13722
+#define TK_ANY 100
13723
+#define TK_BITAND 101
13724
+#define TK_BITOR 102
13725
+#define TK_LSHIFT 103
13726
+#define TK_RSHIFT 104
13727
+#define TK_PLUS 105
13728
+#define TK_MINUS 106
13729
+#define TK_STAR 107
13730
+#define TK_SLASH 108
13731
+#define TK_REM 109
13732
+#define TK_CONCAT 110
13733
+#define TK_COLLATE 111
13734
+#define TK_BITNOT 112
13735
+#define TK_ON 113
13736
+#define TK_INDEXED 114
13737
+#define TK_STRING 115
13738
+#define TK_JOIN_KW 116
13739
+#define TK_CONSTRAINT 117
13740
+#define TK_DEFAULT 118
13741
+#define TK_NULL 119
13742
+#define TK_PRIMARY 120
13743
+#define TK_UNIQUE 121
13744
+#define TK_CHECK 122
13745
+#define TK_REFERENCES 123
13746
+#define TK_AUTOINCR 124
13747
+#define TK_INSERT 125
13748
+#define TK_DELETE 126
13749
+#define TK_UPDATE 127
13750
+#define TK_SET 128
13751
+#define TK_DEFERRABLE 129
13752
+#define TK_FOREIGN 130
13753
+#define TK_DROP 131
13754
+#define TK_UNION 132
13755
+#define TK_ALL 133
13756
+#define TK_EXCEPT 134
13757
+#define TK_INTERSECT 135
13758
+#define TK_SELECT 136
13759
+#define TK_VALUES 137
13760
+#define TK_DISTINCT 138
13761
+#define TK_DOT 139
13762
+#define TK_FROM 140
13763
+#define TK_JOIN 141
13764
+#define TK_USING 142
13765
+#define TK_ORDER 143
13766
+#define TK_GROUP 144
13767
+#define TK_HAVING 145
13768
+#define TK_LIMIT 146
13769
+#define TK_WHERE 147
13770
+#define TK_INTO 148
13771
+#define TK_NOTHING 149
13772
+#define TK_FLOAT 150
13773
+#define TK_BLOB 151
13774
+#define TK_INTEGER 152
13775
+#define TK_VARIABLE 153
13776
+#define TK_CASE 154
13777
+#define TK_WHEN 155
13778
+#define TK_THEN 156
13779
+#define TK_ELSE 157
13780
+#define TK_INDEX 158
13781
+#define TK_ALTER 159
13782
+#define TK_ADD 160
13783
+#define TK_WINDOW 161
13784
+#define TK_OVER 162
13785
+#define TK_FILTER 163
13786
+#define TK_COLUMN 164
13787
+#define TK_AGG_FUNCTION 165
13788
+#define TK_AGG_COLUMN 166
13789
+#define TK_TRUEFALSE 167
13790
+#define TK_ISNOT 168
13791
+#define TK_FUNCTION 169
13792
+#define TK_UMINUS 170
13793
+#define TK_UPLUS 171
13794
+#define TK_TRUTH 172
13795
+#define TK_REGISTER 173
13796
+#define TK_VECTOR 174
13797
+#define TK_SELECT_COLUMN 175
13798
+#define TK_IF_NULL_ROW 176
13799
+#define TK_ASTERISK 177
13800
+#define TK_SPAN 178
13801
+#define TK_SPACE 179
13802
+#define TK_ILLEGAL 180
1376013803
1376113804
/************** End of parse.h ***********************************************/
1376213805
/************** Continuing where we left off in sqliteInt.h ******************/
1376313806
#include <stdio.h>
1376413807
#include <stdlib.h>
@@ -14686,11 +14729,11 @@
1468614729
SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
1468714730
SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
1468814731
SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
1468914732
SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*);
1469014733
14691
-SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
14734
+SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(sqlite3*,Btree*,int*aRoot,int nRoot,int,int*);
1469214735
SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
1469314736
SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);
1469414737
1469514738
#ifndef SQLITE_OMIT_INCRBLOB
1469614739
SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*);
@@ -14707,11 +14750,11 @@
1470714750
SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);
1470814751
#endif
1470914752
SQLITE_PRIVATE int sqlite3BtreeCursorIsValidNN(BtCursor*);
1471014753
1471114754
#ifndef SQLITE_OMIT_BTREECOUNT
14712
-SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *, i64 *);
14755
+SQLITE_PRIVATE int sqlite3BtreeCount(sqlite3*, BtCursor*, i64*);
1471314756
#endif
1471414757
1471514758
#ifdef SQLITE_TEST
1471614759
SQLITE_PRIVATE int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
1471714760
SQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*);
@@ -15000,121 +15043,119 @@
1500015043
#define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
1500115044
#define OP_ElseNotEq 58 /* jump, same as TK_ESCAPE */
1500215045
#define OP_IncrVacuum 59 /* jump */
1500315046
#define OP_VNext 60 /* jump */
1500415047
#define OP_Init 61 /* jump, synopsis: Start at P2 */
15005
-#define OP_PureFunc0 62
15006
-#define OP_Function0 63 /* synopsis: r[P3]=func(r[P2@P5]) */
15007
-#define OP_PureFunc 64
15008
-#define OP_Function 65 /* synopsis: r[P3]=func(r[P2@P5]) */
15009
-#define OP_Return 66
15010
-#define OP_EndCoroutine 67
15011
-#define OP_HaltIfNull 68 /* synopsis: if r[P3]=null halt */
15012
-#define OP_Halt 69
15013
-#define OP_Integer 70 /* synopsis: r[P2]=P1 */
15014
-#define OP_Int64 71 /* synopsis: r[P2]=P4 */
15015
-#define OP_String 72 /* synopsis: r[P2]='P4' (len=P1) */
15016
-#define OP_Null 73 /* synopsis: r[P2..P3]=NULL */
15017
-#define OP_SoftNull 74 /* synopsis: r[P1]=NULL */
15018
-#define OP_Blob 75 /* synopsis: r[P2]=P4 (len=P1) */
15019
-#define OP_Variable 76 /* synopsis: r[P2]=parameter(P1,P4) */
15020
-#define OP_Move 77 /* synopsis: r[P2@P3]=r[P1@P3] */
15021
-#define OP_Copy 78 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
15022
-#define OP_SCopy 79 /* synopsis: r[P2]=r[P1] */
15023
-#define OP_IntCopy 80 /* synopsis: r[P2]=r[P1] */
15024
-#define OP_ResultRow 81 /* synopsis: output=r[P1@P2] */
15025
-#define OP_CollSeq 82
15026
-#define OP_AddImm 83 /* synopsis: r[P1]=r[P1]+P2 */
15027
-#define OP_RealAffinity 84
15028
-#define OP_Cast 85 /* synopsis: affinity(r[P1]) */
15029
-#define OP_Permutation 86
15030
-#define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */
15031
-#define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
15032
-#define OP_Offset 89 /* synopsis: r[P3] = sqlite_offset(P1) */
15033
-#define OP_Column 90 /* synopsis: r[P3]=PX */
15034
-#define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */
15035
-#define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
15036
-#define OP_Count 93 /* synopsis: r[P2]=count() */
15037
-#define OP_ReadCookie 94
15038
-#define OP_SetCookie 95
15039
-#define OP_ReopenIdx 96 /* synopsis: root=P2 iDb=P3 */
15040
-#define OP_OpenRead 97 /* synopsis: root=P2 iDb=P3 */
15041
-#define OP_OpenWrite 98 /* synopsis: root=P2 iDb=P3 */
15042
-#define OP_BitAnd 99 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
15043
-#define OP_BitOr 100 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
15044
-#define OP_ShiftLeft 101 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
15045
-#define OP_ShiftRight 102 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
15046
-#define OP_Add 103 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
15047
-#define OP_Subtract 104 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
15048
-#define OP_Multiply 105 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
15049
-#define OP_Divide 106 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
15050
-#define OP_Remainder 107 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
15051
-#define OP_Concat 108 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
15052
-#define OP_OpenDup 109
15053
-#define OP_BitNot 110 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
15054
-#define OP_OpenAutoindex 111 /* synopsis: nColumn=P2 */
15055
-#define OP_OpenEphemeral 112 /* synopsis: nColumn=P2 */
15056
-#define OP_String8 113 /* same as TK_STRING, synopsis: r[P2]='P4' */
15057
-#define OP_SorterOpen 114
15058
-#define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15059
-#define OP_OpenPseudo 116 /* synopsis: P3 columns in r[P2] */
15060
-#define OP_Close 117
15061
-#define OP_ColumnsUsed 118
15062
-#define OP_SeekHit 119 /* synopsis: seekHit=P2 */
15063
-#define OP_Sequence 120 /* synopsis: r[P2]=cursor[P1].ctr++ */
15064
-#define OP_NewRowid 121 /* synopsis: r[P2]=rowid */
15065
-#define OP_Insert 122 /* synopsis: intkey=r[P3] data=r[P2] */
15066
-#define OP_Delete 123
15067
-#define OP_ResetCount 124
15068
-#define OP_SorterCompare 125 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15069
-#define OP_SorterData 126 /* synopsis: r[P2]=data */
15070
-#define OP_RowData 127 /* synopsis: r[P2]=data */
15071
-#define OP_Rowid 128 /* synopsis: r[P2]=rowid */
15072
-#define OP_NullRow 129
15073
-#define OP_SeekEnd 130
15074
-#define OP_SorterInsert 131 /* synopsis: key=r[P2] */
15075
-#define OP_IdxInsert 132 /* synopsis: key=r[P2] */
15076
-#define OP_IdxDelete 133 /* synopsis: key=r[P2@P3] */
15077
-#define OP_DeferredSeek 134 /* synopsis: Move P3 to P1.rowid if needed */
15078
-#define OP_IdxRowid 135 /* synopsis: r[P2]=rowid */
15079
-#define OP_Destroy 136
15080
-#define OP_Clear 137
15081
-#define OP_ResetSorter 138
15082
-#define OP_CreateBtree 139 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15083
-#define OP_SqlExec 140
15084
-#define OP_ParseSchema 141
15085
-#define OP_LoadAnalysis 142
15086
-#define OP_DropTable 143
15087
-#define OP_DropIndex 144
15088
-#define OP_DropTrigger 145
15089
-#define OP_IntegrityCk 146
15090
-#define OP_RowSetAdd 147 /* synopsis: rowset(P1)=r[P2] */
15091
-#define OP_Real 148 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15092
-#define OP_Param 149
15093
-#define OP_FkCounter 150 /* synopsis: fkctr[P1]+=P2 */
15094
-#define OP_MemMax 151 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15095
-#define OP_OffsetLimit 152 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15096
-#define OP_AggInverse 153 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15097
-#define OP_AggStep 154 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15098
-#define OP_AggStep1 155 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15099
-#define OP_AggValue 156 /* synopsis: r[P3]=value N=P2 */
15100
-#define OP_AggFinal 157 /* synopsis: accum=r[P1] N=P2 */
15101
-#define OP_Expire 158
15102
-#define OP_TableLock 159 /* synopsis: iDb=P1 root=P2 write=P3 */
15103
-#define OP_VBegin 160
15104
-#define OP_VCreate 161
15105
-#define OP_VDestroy 162
15106
-#define OP_VOpen 163
15107
-#define OP_VColumn 164 /* synopsis: r[P3]=vcolumn(P2) */
15108
-#define OP_VRename 165
15109
-#define OP_Pagecount 166
15110
-#define OP_MaxPgcnt 167
15111
-#define OP_Trace 168
15112
-#define OP_CursorHint 169
15113
-#define OP_Noop 170
15114
-#define OP_Explain 171
15115
-#define OP_Abortable 172
15048
+#define OP_PureFunc 62 /* synopsis: r[P3]=func(r[P2@P5]) */
15049
+#define OP_Function 63 /* synopsis: r[P3]=func(r[P2@P5]) */
15050
+#define OP_Return 64
15051
+#define OP_EndCoroutine 65
15052
+#define OP_HaltIfNull 66 /* synopsis: if r[P3]=null halt */
15053
+#define OP_Halt 67
15054
+#define OP_Integer 68 /* synopsis: r[P2]=P1 */
15055
+#define OP_Int64 69 /* synopsis: r[P2]=P4 */
15056
+#define OP_String 70 /* synopsis: r[P2]='P4' (len=P1) */
15057
+#define OP_Null 71 /* synopsis: r[P2..P3]=NULL */
15058
+#define OP_SoftNull 72 /* synopsis: r[P1]=NULL */
15059
+#define OP_Blob 73 /* synopsis: r[P2]=P4 (len=P1) */
15060
+#define OP_Variable 74 /* synopsis: r[P2]=parameter(P1,P4) */
15061
+#define OP_Move 75 /* synopsis: r[P2@P3]=r[P1@P3] */
15062
+#define OP_Copy 76 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
15063
+#define OP_SCopy 77 /* synopsis: r[P2]=r[P1] */
15064
+#define OP_IntCopy 78 /* synopsis: r[P2]=r[P1] */
15065
+#define OP_ResultRow 79 /* synopsis: output=r[P1@P2] */
15066
+#define OP_CollSeq 80
15067
+#define OP_AddImm 81 /* synopsis: r[P1]=r[P1]+P2 */
15068
+#define OP_RealAffinity 82
15069
+#define OP_Cast 83 /* synopsis: affinity(r[P1]) */
15070
+#define OP_Permutation 84
15071
+#define OP_Compare 85 /* synopsis: r[P1@P3] <-> r[P2@P3] */
15072
+#define OP_IsTrue 86 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
15073
+#define OP_Offset 87 /* synopsis: r[P3] = sqlite_offset(P1) */
15074
+#define OP_Column 88 /* synopsis: r[P3]=PX */
15075
+#define OP_Affinity 89 /* synopsis: affinity(r[P1@P2]) */
15076
+#define OP_MakeRecord 90 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
15077
+#define OP_Count 91 /* synopsis: r[P2]=count() */
15078
+#define OP_ReadCookie 92
15079
+#define OP_SetCookie 93
15080
+#define OP_ReopenIdx 94 /* synopsis: root=P2 iDb=P3 */
15081
+#define OP_OpenRead 95 /* synopsis: root=P2 iDb=P3 */
15082
+#define OP_OpenWrite 96 /* synopsis: root=P2 iDb=P3 */
15083
+#define OP_OpenDup 97
15084
+#define OP_OpenAutoindex 98 /* synopsis: nColumn=P2 */
15085
+#define OP_OpenEphemeral 99 /* synopsis: nColumn=P2 */
15086
+#define OP_SorterOpen 100
15087
+#define OP_BitAnd 101 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
15088
+#define OP_BitOr 102 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
15089
+#define OP_ShiftLeft 103 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
15090
+#define OP_ShiftRight 104 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
15091
+#define OP_Add 105 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
15092
+#define OP_Subtract 106 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
15093
+#define OP_Multiply 107 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
15094
+#define OP_Divide 108 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
15095
+#define OP_Remainder 109 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
15096
+#define OP_Concat 110 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
15097
+#define OP_SequenceTest 111 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15098
+#define OP_BitNot 112 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
15099
+#define OP_OpenPseudo 113 /* synopsis: P3 columns in r[P2] */
15100
+#define OP_Close 114
15101
+#define OP_String8 115 /* same as TK_STRING, synopsis: r[P2]='P4' */
15102
+#define OP_ColumnsUsed 116
15103
+#define OP_SeekHit 117 /* synopsis: seekHit=P2 */
15104
+#define OP_Sequence 118 /* synopsis: r[P2]=cursor[P1].ctr++ */
15105
+#define OP_NewRowid 119 /* synopsis: r[P2]=rowid */
15106
+#define OP_Insert 120 /* synopsis: intkey=r[P3] data=r[P2] */
15107
+#define OP_Delete 121
15108
+#define OP_ResetCount 122
15109
+#define OP_SorterCompare 123 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15110
+#define OP_SorterData 124 /* synopsis: r[P2]=data */
15111
+#define OP_RowData 125 /* synopsis: r[P2]=data */
15112
+#define OP_Rowid 126 /* synopsis: r[P2]=rowid */
15113
+#define OP_NullRow 127
15114
+#define OP_SeekEnd 128
15115
+#define OP_SorterInsert 129 /* synopsis: key=r[P2] */
15116
+#define OP_IdxInsert 130 /* synopsis: key=r[P2] */
15117
+#define OP_IdxDelete 131 /* synopsis: key=r[P2@P3] */
15118
+#define OP_DeferredSeek 132 /* synopsis: Move P3 to P1.rowid if needed */
15119
+#define OP_IdxRowid 133 /* synopsis: r[P2]=rowid */
15120
+#define OP_Destroy 134
15121
+#define OP_Clear 135
15122
+#define OP_ResetSorter 136
15123
+#define OP_CreateBtree 137 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15124
+#define OP_SqlExec 138
15125
+#define OP_ParseSchema 139
15126
+#define OP_LoadAnalysis 140
15127
+#define OP_DropTable 141
15128
+#define OP_DropIndex 142
15129
+#define OP_DropTrigger 143
15130
+#define OP_IntegrityCk 144
15131
+#define OP_RowSetAdd 145 /* synopsis: rowset(P1)=r[P2] */
15132
+#define OP_Param 146
15133
+#define OP_FkCounter 147 /* synopsis: fkctr[P1]+=P2 */
15134
+#define OP_MemMax 148 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15135
+#define OP_OffsetLimit 149 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15136
+#define OP_Real 150 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15137
+#define OP_AggInverse 151 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15138
+#define OP_AggStep 152 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15139
+#define OP_AggStep1 153 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15140
+#define OP_AggValue 154 /* synopsis: r[P3]=value N=P2 */
15141
+#define OP_AggFinal 155 /* synopsis: accum=r[P1] N=P2 */
15142
+#define OP_Expire 156
15143
+#define OP_TableLock 157 /* synopsis: iDb=P1 root=P2 write=P3 */
15144
+#define OP_VBegin 158
15145
+#define OP_VCreate 159
15146
+#define OP_VDestroy 160
15147
+#define OP_VOpen 161
15148
+#define OP_VColumn 162 /* synopsis: r[P3]=vcolumn(P2) */
15149
+#define OP_VRename 163
15150
+#define OP_Pagecount 164
15151
+#define OP_MaxPgcnt 165
15152
+#define OP_Trace 166
15153
+#define OP_CursorHint 167
15154
+#define OP_Noop 168
15155
+#define OP_Explain 169
15156
+#define OP_Abortable 170
1511615157
1511715158
/* Properties such as "out2" or "jump" that are specified in
1511815159
** comments following the "case" for each opcode in the vdbe.c
1511915160
** are encoded into bitvectors as follows:
1512015161
*/
@@ -15131,24 +15172,24 @@
1513115172
/* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
1513215173
/* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
1513315174
/* 40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\
1513415175
/* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
1513515176
/* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\
15136
-/* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
15137
-/* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
15138
-/* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
15139
-/* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
15140
-/* 96 */ 0x00, 0x00, 0x00, 0x26, 0x26, 0x26, 0x26, 0x26,\
15141
-/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12, 0x00,\
15142
-/* 112 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15143
-/* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15144
-/* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
15145
-/* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15146
-/* 144 */ 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x04,\
15147
-/* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15148
-/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
15149
-/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,}
15177
+/* 64 */ 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10,\
15178
+/* 72 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00,\
15179
+/* 80 */ 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x12, 0x20,\
15180
+/* 88 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
15181
+/* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26, 0x26,\
15182
+/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\
15183
+/* 112 */ 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10,\
15184
+/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\
15185
+/* 128 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x00,\
15186
+/* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15187
+/* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x10, 0x00,\
15188
+/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15189
+/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
15190
+/* 168 */ 0x00, 0x00, 0x00,}
1515015191
1515115192
/* The sqlite3P2Values() routine is able to run faster if it knows
1515215193
** the value of the largest JUMP opcode. The smaller the maximum
1515315194
** JUMP opcode the better, so the mkopcodeh.tcl script that
1515415195
** generated this include file strives to group all JUMP opcodes
@@ -15168,10 +15209,11 @@
1516815209
/*
1516915210
** Prototypes for the VDBE interface. See comments on the implementation
1517015211
** for a description of what each of these routines does.
1517115212
*/
1517215213
SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*);
15214
+SQLITE_PRIVATE Parse *sqlite3VdbeParser(Vdbe*);
1517315215
SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int);
1517415216
SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int);
1517515217
SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int);
1517615218
SQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe*,int);
1517715219
SQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe*,int,const char*);
@@ -15178,10 +15220,11 @@
1517815220
SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...);
1517915221
SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);
1518015222
SQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);
1518115223
SQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int);
1518215224
SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);
15225
+SQLITE_PRIVATE int sqlite3VdbeAddFunctionCall(Parse*,int,int,int,int,const FuncDef*,int);
1518315226
SQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe*,int);
1518415227
#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
1518515228
SQLITE_PRIVATE void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);
1518615229
SQLITE_PRIVATE void sqlite3VdbeVerifyNoResultRow(Vdbe *p);
1518715230
#else
@@ -15267,13 +15310,12 @@
1526715310
SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*);
1526815311
1526915312
typedef int (*RecordCompare)(int,const void*,UnpackedRecord*);
1527015313
SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
1527115314
15272
-#ifndef SQLITE_OMIT_TRIGGER
1527315315
SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
15274
-#endif
15316
+SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*);
1527515317
1527615318
SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);
1527715319
1527815320
/* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on
1527915321
** each VDBE opcode.
@@ -16303,14 +16345,21 @@
1630316345
** with a particular database connection. Hence, schema information cannot
1630416346
** be stored in lookaside because in shared cache mode the schema information
1630516347
** is shared by multiple database connections. Therefore, while parsing
1630616348
** schema information, the Lookaside.bEnabled flag is cleared so that
1630716349
** lookaside allocations are not used to construct the schema objects.
16350
+**
16351
+** New lookaside allocations are only allowed if bDisable==0. When
16352
+** bDisable is greater than zero, sz is set to zero which effectively
16353
+** disables lookaside without adding a new test for the bDisable flag
16354
+** in a performance-critical path. sz should be set by to szTrue whenever
16355
+** bDisable changes back to zero.
1630816356
*/
1630916357
struct Lookaside {
1631016358
u32 bDisable; /* Only operate the lookaside when zero */
1631116359
u16 sz; /* Size of each buffer in bytes */
16360
+ u16 szTrue; /* True value of sz, even if disabled */
1631216361
u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */
1631316362
u32 nSlot; /* Number of lookaside slots allocated */
1631416363
u32 anStat[3]; /* 0: hits. 1: size misses. 2: full misses */
1631516364
LookasideSlot *pInit; /* List of buffers not previously used */
1631616365
LookasideSlot *pFree; /* List of available buffers */
@@ -16318,10 +16367,14 @@
1631816367
void *pEnd; /* First byte past end of available space */
1631916368
};
1632016369
struct LookasideSlot {
1632116370
LookasideSlot *pNext; /* Next buffer in the list of free buffers */
1632216371
};
16372
+
16373
+#define DisableLookaside db->lookaside.bDisable++;db->lookaside.sz=0
16374
+#define EnableLookaside db->lookaside.bDisable--;\
16375
+ db->lookaside.sz=db->lookaside.bDisable?0:db->lookaside.szTrue
1632316376
1632416377
/*
1632516378
** A hash table for built-in function definitions. (Application-defined
1632616379
** functions use a regular table table from hash.h.)
1632716380
**
@@ -16839,30 +16892,49 @@
1683916892
void (*xDestroy)(void *); /* Module destructor function */
1684016893
Table *pEpoTab; /* Eponymous table for this module */
1684116894
};
1684216895
1684316896
/*
16844
-** information about each column of an SQL table is held in an instance
16845
-** of this structure.
16897
+** Information about each column of an SQL table is held in an instance
16898
+** of the Column structure, in the Table.aCol[] array.
16899
+**
16900
+** Definitions:
16901
+**
16902
+** "table column index" This is the index of the column in the
16903
+** Table.aCol[] array, and also the index of
16904
+** the column in the original CREATE TABLE stmt.
16905
+**
16906
+** "storage column index" This is the index of the column in the
16907
+** record BLOB generated by the OP_MakeRecord
16908
+** opcode. The storage column index is less than
16909
+** or equal to the table column index. It is
16910
+** equal if and only if there are no VIRTUAL
16911
+** columns to the left.
1684616912
*/
1684716913
struct Column {
1684816914
char *zName; /* Name of this column, \000, then the type */
16849
- Expr *pDflt; /* Default value of this column */
16915
+ Expr *pDflt; /* Default value or GENERATED ALWAYS AS value */
1685016916
char *zColl; /* Collating sequence. If NULL, use the default */
1685116917
u8 notNull; /* An OE_ code for handling a NOT NULL constraint */
1685216918
char affinity; /* One of the SQLITE_AFF_... values */
1685316919
u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */
16854
- u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */
16920
+ u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */
1685516921
};
1685616922
1685716923
/* Allowed values for Column.colFlags:
1685816924
*/
16859
-#define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */
16860
-#define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */
16861
-#define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */
16862
-#define COLFLAG_UNIQUE 0x0008 /* Column def contains "UNIQUE" or "PK" */
16925
+#define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */
16926
+#define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */
16927
+#define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */
16928
+#define COLFLAG_UNIQUE 0x0008 /* Column def contains "UNIQUE" or "PK" */
1686316929
#define COLFLAG_SORTERREF 0x0010 /* Use sorter-refs with this column */
16930
+#define COLFLAG_VIRTUAL 0x0020 /* GENERATED ALWAYS AS ... VIRTUAL */
16931
+#define COLFLAG_STORED 0x0040 /* GENERATED ALWAYS AS ... STORED */
16932
+#define COLFLAG_NOTAVAIL 0x0080 /* STORED column not yet calculated */
16933
+#define COLFLAG_BUSY 0x0100 /* Blocks recursion on GENERATED columns */
16934
+#define COLFLAG_GENERATED 0x0060 /* Combo: _STORED, _VIRTUAL */
16935
+#define COLFLAG_NOINSERT 0x0062 /* Combo: _HIDDEN, _STORED, _VIRTUAL */
1686416936
1686516937
/*
1686616938
** A "Collating Sequence" is defined by an instance of the following
1686716939
** structure. Conceptually, a collating sequence consists of a name and
1686816940
** a comparison routine that defines the order of that sequence.
@@ -16998,10 +17070,11 @@
1699817070
int tnum; /* Root BTree page for this table */
1699917071
u32 nTabRef; /* Number of pointers to this Table */
1700017072
u32 tabFlags; /* Mask of TF_* values */
1700117073
i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */
1700217074
i16 nCol; /* Number of columns in this table */
17075
+ i16 nNVCol; /* Number of columns that are not VIRTUAL */
1700317076
LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
1700417077
LogEst szTabRow; /* Estimated size of each table row in bytes */
1700517078
#ifdef SQLITE_ENABLE_COSTMULT
1700617079
LogEst costMult; /* Cost multiplier for using this table */
1700717080
#endif
@@ -17024,24 +17097,32 @@
1702417097
**
1702517098
** TF_OOOHidden applies to tables or view that have hidden columns that are
1702617099
** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING
1702717100
** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden,
1702817101
** the TF_OOOHidden attribute would apply in this case. Such tables require
17029
-** special handling during INSERT processing.
17102
+** special handling during INSERT processing. The "OOO" means "Out Of Order".
17103
+**
17104
+** Constraints:
17105
+**
17106
+** TF_HasVirtual == COLFLAG_Virtual
17107
+** TF_HasStored == COLFLAG_Stored
1703017108
*/
1703117109
#define TF_Readonly 0x0001 /* Read-only system table */
1703217110
#define TF_Ephemeral 0x0002 /* An ephemeral table */
1703317111
#define TF_HasPrimaryKey 0x0004 /* Table has a primary key */
1703417112
#define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */
1703517113
#define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */
17036
-#define TF_WithoutRowid 0x0020 /* No rowid. PRIMARY KEY is the key */
17037
-#define TF_NoVisibleRowid 0x0040 /* No user-visible "rowid" column */
17038
-#define TF_OOOHidden 0x0080 /* Out-of-Order hidden columns */
17114
+#define TF_HasVirtual 0x0020 /* Has one or more VIRTUAL columns */
17115
+#define TF_HasStored 0x0040 /* Has one or more STORED columns */
17116
+#define TF_HasGenerated 0x0060 /* Combo: HasVirtual + HasStored */
17117
+#define TF_WithoutRowid 0x0080 /* No rowid. PRIMARY KEY is the key */
1703917118
#define TF_StatsUsed 0x0100 /* Query planner decisions affected by
1704017119
** Index.aiRowLogEst[] values */
17041
-#define TF_HasNotNull 0x0200 /* Contains NOT NULL constraints */
17042
-#define TF_Shadow 0x0400 /* True for a shadow table */
17120
+#define TF_NoVisibleRowid 0x0200 /* No user-visible "rowid" column */
17121
+#define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */
17122
+#define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */
17123
+#define TF_Shadow 0x1000 /* True for a shadow table */
1704317124
1704417125
/*
1704517126
** Test to see whether or not a table is a virtual table. This is
1704617127
** done as a macro so that it will be optimized out when virtual
1704717128
** table support is omitted from the build.
@@ -17288,10 +17369,11 @@
1728817369
unsigned isCovering:1; /* True if this is a covering index */
1728917370
unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
1729017371
unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
1729117372
unsigned bNoQuery:1; /* Do not use this index to optimize queries */
1729217373
unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
17374
+ unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
1729317375
#ifdef SQLITE_ENABLE_STAT4
1729417376
int nSample; /* Number of elements in aSample[] */
1729517377
int nSampleCol; /* Size of IndexSample.anEq[] and so on */
1729617378
tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
1729717379
IndexSample *aSample; /* Samples of the left-most key */
@@ -17479,10 +17561,14 @@
1747917561
** allocated, regardless of whether or not EP_Reduced is set.
1748017562
*/
1748117563
struct Expr {
1748217564
u8 op; /* Operation performed by this node */
1748317565
char affExpr; /* affinity, or RAISE type */
17566
+ u8 op2; /* TK_REGISTER/TK_TRUTH: original value of Expr.op
17567
+ ** TK_COLUMN: the value of p5 for OP_Column
17568
+ ** TK_AGG_FUNCTION: nesting depth
17569
+ ** TK_FUNCTION: NC_SelfRef flag if needs OP_PureFunc */
1748417570
u32 flags; /* Various flags. EP_* See below */
1748517571
union {
1748617572
char *zToken; /* Token value. Zero terminated and dequoted */
1748717573
int iValue; /* Non-negative integer value if EP_IntValue */
1748817574
} u;
@@ -17517,13 +17603,10 @@
1751717603
ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
1751817604
** TK_VARIABLE: variable number (always >= 1).
1751917605
** TK_SELECT_COLUMN: column of the result vector */
1752017606
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
1752117607
i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
17522
- u8 op2; /* TK_REGISTER/TK_TRUTH: original value of Expr.op
17523
- ** TK_COLUMN: the value of p5 for OP_Column
17524
- ** TK_AGG_FUNCTION: nesting depth */
1752517608
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
1752617609
union {
1752717610
Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
1752817611
** for a column of an index on an expression */
1752917612
Window *pWin; /* EP_WinFunc: Window/Filter defn for a function */
@@ -17548,11 +17631,11 @@
1754817631
#define EP_Agg 0x000010 /* Contains one or more aggregate functions */
1754917632
#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
1755017633
#define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
1755117634
#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
1755217635
#define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
17553
- /* 0x000200 Available for reuse */
17636
+#define EP_Commuted 0x000200 /* Comparison operator has been commuted */
1755417637
#define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
1755517638
#define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
1755617639
#define EP_Skip 0x001000 /* Operator does not contribute to affinity */
1755717640
#define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
1755817641
#define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
@@ -17617,13 +17700,17 @@
1761717700
1761817701
/*
1761917702
** True if the expression passed as an argument was a function with
1762017703
** an OVER() clause (a window function).
1762117704
*/
17622
-#define IsWindowFunc(p) ( \
17705
+#ifdef SQLITE_OMIT_WINDOWFUNC
17706
+# define IsWindowFunc(p) 0
17707
+#else
17708
+# define IsWindowFunc(p) ( \
1762317709
ExprHasProperty((p), EP_WinFunc) && p->y.pWin->eFrmType!=TK_FILTER \
17624
-)
17710
+ )
17711
+#endif
1762517712
1762617713
/*
1762717714
** A list of expressions. Each expression may optionally have a
1762817715
** name. An expr/name combination can be used in several ways, such
1762917716
** as the list of "expr AS ID" fields following a "SELECT" or in the
@@ -17825,25 +17912,27 @@
1782517912
** NC_HasAgg == SF_HasAgg == EP_Agg
1782617913
** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
1782717914
** NC_HasWin == EP_Win
1782817915
**
1782917916
*/
17830
-#define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */
17831
-#define NC_PartIdx 0x0002 /* True if resolving a partial index WHERE */
17832
-#define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */
17833
-#define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */
17834
-#define NC_HasAgg 0x0010 /* One or more aggregate functions seen */
17835
-#define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */
17836
-#define NC_VarSelect 0x0040 /* A correlated subquery has been seen */
17837
-#define NC_UEList 0x0080 /* True if uNC.pEList is used */
17838
-#define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */
17839
-#define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */
17840
-#define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
17841
-#define NC_Complex 0x2000 /* True if a function or subquery seen */
17842
-#define NC_AllowWin 0x4000 /* Window functions are allowed here */
17843
-#define NC_HasWin 0x8000 /* One or more window functions seen */
17844
-#define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */
17917
+#define NC_AllowAgg 0x00001 /* Aggregate functions are allowed here */
17918
+#define NC_PartIdx 0x00002 /* True if resolving a partial index WHERE */
17919
+#define NC_IsCheck 0x00004 /* True if resolving a CHECK constraint */
17920
+#define NC_GenCol 0x00008 /* True for a GENERATED ALWAYS AS clause */
17921
+#define NC_HasAgg 0x00010 /* One or more aggregate functions seen */
17922
+#define NC_IdxExpr 0x00020 /* True if resolving columns of CREATE INDEX */
17923
+#define NC_SelfRef 0x0002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */
17924
+#define NC_VarSelect 0x00040 /* A correlated subquery has been seen */
17925
+#define NC_UEList 0x00080 /* True if uNC.pEList is used */
17926
+#define NC_UAggInfo 0x00100 /* True if uNC.pAggInfo is used */
17927
+#define NC_UUpsert 0x00200 /* True if uNC.pUpsert is used */
17928
+#define NC_MinMaxAgg 0x01000 /* min/max aggregates seen. See note above */
17929
+#define NC_Complex 0x02000 /* True if a function or subquery seen */
17930
+#define NC_AllowWin 0x04000 /* Window functions are allowed here */
17931
+#define NC_HasWin 0x08000 /* One or more window functions seen */
17932
+#define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */
17933
+#define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */
1784517934
1784617935
/*
1784717936
** An instance of the following object describes a single ON CONFLICT
1784817937
** clause in an upsert.
1784917938
**
@@ -17920,30 +18009,31 @@
1792018009
** Value constraints (all checked via assert())
1792118010
** SF_HasAgg == NC_HasAgg
1792218011
** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX
1792318012
** SF_FixedLimit == WHERE_USE_LIMIT
1792418013
*/
17925
-#define SF_Distinct 0x00001 /* Output should be DISTINCT */
17926
-#define SF_All 0x00002 /* Includes the ALL keyword */
17927
-#define SF_Resolved 0x00004 /* Identifiers have been resolved */
17928
-#define SF_Aggregate 0x00008 /* Contains agg functions or a GROUP BY */
17929
-#define SF_HasAgg 0x00010 /* Contains aggregate functions */
17930
-#define SF_UsesEphemeral 0x00020 /* Uses the OpenEphemeral opcode */
17931
-#define SF_Expanded 0x00040 /* sqlite3SelectExpand() called on this */
17932
-#define SF_HasTypeInfo 0x00080 /* FROM subqueries have Table metadata */
17933
-#define SF_Compound 0x00100 /* Part of a compound query */
17934
-#define SF_Values 0x00200 /* Synthesized from VALUES clause */
17935
-#define SF_MultiValue 0x00400 /* Single VALUES term with multiple rows */
17936
-#define SF_NestedFrom 0x00800 /* Part of a parenthesized FROM clause */
17937
-#define SF_MinMaxAgg 0x01000 /* Aggregate containing min() or max() */
17938
-#define SF_Recursive 0x02000 /* The recursive part of a recursive CTE */
17939
-#define SF_FixedLimit 0x04000 /* nSelectRow set by a constant LIMIT */
17940
-#define SF_MaybeConvert 0x08000 /* Need convertCompoundSelectToSubquery() */
17941
-#define SF_Converted 0x10000 /* By convertCompoundSelectToSubquery() */
17942
-#define SF_IncludeHidden 0x20000 /* Include hidden columns in output */
17943
-#define SF_ComplexResult 0x40000 /* Result contains subquery or function */
17944
-#define SF_WhereBegin 0x80000 /* Really a WhereBegin() call. Debug Only */
18014
+#define SF_Distinct 0x0000001 /* Output should be DISTINCT */
18015
+#define SF_All 0x0000002 /* Includes the ALL keyword */
18016
+#define SF_Resolved 0x0000004 /* Identifiers have been resolved */
18017
+#define SF_Aggregate 0x0000008 /* Contains agg functions or a GROUP BY */
18018
+#define SF_HasAgg 0x0000010 /* Contains aggregate functions */
18019
+#define SF_UsesEphemeral 0x0000020 /* Uses the OpenEphemeral opcode */
18020
+#define SF_Expanded 0x0000040 /* sqlite3SelectExpand() called on this */
18021
+#define SF_HasTypeInfo 0x0000080 /* FROM subqueries have Table metadata */
18022
+#define SF_Compound 0x0000100 /* Part of a compound query */
18023
+#define SF_Values 0x0000200 /* Synthesized from VALUES clause */
18024
+#define SF_MultiValue 0x0000400 /* Single VALUES term with multiple rows */
18025
+#define SF_NestedFrom 0x0000800 /* Part of a parenthesized FROM clause */
18026
+#define SF_MinMaxAgg 0x0001000 /* Aggregate containing min() or max() */
18027
+#define SF_Recursive 0x0002000 /* The recursive part of a recursive CTE */
18028
+#define SF_FixedLimit 0x0004000 /* nSelectRow set by a constant LIMIT */
18029
+#define SF_MaybeConvert 0x0008000 /* Need convertCompoundSelectToSubquery() */
18030
+#define SF_Converted 0x0010000 /* By convertCompoundSelectToSubquery() */
18031
+#define SF_IncludeHidden 0x0020000 /* Include hidden columns in output */
18032
+#define SF_ComplexResult 0x0040000 /* Result contains subquery or function */
18033
+#define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */
18034
+#define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */
1794518035
1794618036
/*
1794718037
** The results of a SELECT can be distributed in several ways, as defined
1794818038
** by one of the following macros. The "SRT" prefix means "SELECT Result
1794918039
** Type".
@@ -18531,11 +18621,11 @@
1853118621
Parse *pParse; /* Parser context. */
1853218622
int (*xExprCallback)(Walker*, Expr*); /* Callback for expressions */
1853318623
int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */
1853418624
void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */
1853518625
int walkerDepth; /* Number of subqueries */
18536
- u8 eCode; /* A small processing code */
18626
+ u16 eCode; /* A small processing code */
1853718627
union { /* Extra data for callback */
1853818628
NameContext *pNC; /* Naming context */
1853918629
int n; /* A counter */
1854018630
int iCur; /* A cursor number */
1854118631
SrcList *pSrcList; /* FROM clause */
@@ -18547,10 +18637,11 @@
1854718637
ExprList *pGroupBy; /* GROUP BY clause */
1854818638
Select *pSelect; /* HAVING to WHERE clause ctx */
1854918639
struct WindowRewrite *pRewrite; /* Window rewrite context */
1855018640
struct WhereConst *pConst; /* WHERE clause constants */
1855118641
struct RenameCtx *pRename; /* RENAME COLUMN context */
18642
+ struct Table *pTab; /* Table of generated column */
1855218643
} u;
1855318644
};
1855418645
1855518646
/* Forward declarations */
1855618647
SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -18954,11 +19045,18 @@
1895419045
SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
1895519046
SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char);
1895619047
SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char);
1895719048
SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
1895819049
SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
18959
-SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);
19050
+SQLITE_PRIVATE i16 sqlite3TableColumnToIndex(Index*, i16);
19051
+#ifdef SQLITE_OMIT_GENERATED_COLUMNS
19052
+# define sqlite3TableColumnToStorage(T,X) (X) /* No-op pass-through */
19053
+# define sqlite3StorageColumnToTable(T,X) (X) /* No-op pass-through */
19054
+#else
19055
+SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table*, i16);
19056
+SQLITE_PRIVATE i16 sqlite3StorageColumnToTable(Table*, i16);
19057
+#endif
1896019058
SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
1896119059
#if SQLITE_ENABLE_HIDDEN_COLUMNS
1896219060
SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*);
1896319061
#else
1896419062
# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */
@@ -18967,11 +19065,15 @@
1896719065
SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);
1896819066
SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
1896919067
SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*);
1897019068
SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);
1897119069
SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*);
19070
+SQLITE_PRIVATE void sqlite3AddGenerated(Parse*,Expr*,Token*);
1897219071
SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
19072
+#ifdef SQLITE_DEBUG
19073
+SQLITE_PRIVATE int sqlite3UriCount(const char*);
19074
+#endif
1897319075
SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*,
1897419076
sqlite3_vfs**,char**,char **);
1897519077
#ifdef SQLITE_HAS_CODEC
1897619078
SQLITE_PRIVATE int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*);
1897719079
#else
@@ -19024,10 +19126,13 @@
1902419126
#else
1902519127
# define sqlite3AutoincrementBegin(X)
1902619128
# define sqlite3AutoincrementEnd(X)
1902719129
#endif
1902819130
SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);
19131
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
19132
+SQLITE_PRIVATE void sqlite3ComputeGeneratedColumns(Parse*, int, Table*);
19133
+#endif
1902919134
SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
1903019135
SQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse*, IdList*, Token*);
1903119136
SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);
1903219137
SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(Parse*, SrcList*, int, int);
1903319138
SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(Parse*, SrcList*, Token*, Token*);
@@ -19073,16 +19178,18 @@
1907319178
SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);
1907419179
SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
1907519180
SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
1907619181
SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
1907719182
SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
19183
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
19184
+SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Column*, int);
19185
+#endif
1907819186
SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
1907919187
SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
1908019188
SQLITE_PRIVATE int sqlite3ExprCodeAtInit(Parse*, Expr*, int);
1908119189
SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
1908219190
SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
19083
-SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);
1908419191
SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);
1908519192
#define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */
1908619193
#define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */
1908719194
#define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */
1908819195
#define SQLITE_ECEL_OMITREF 0x08 /* Omit if ExprList.u.x.iOrderByCol */
@@ -19215,10 +19322,11 @@
1921519322
# define sqlite3IsToplevel(p) 1
1921619323
# define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0
1921719324
#endif
1921819325
1921919326
SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);
19327
+SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr*,int);
1922019328
SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
1922119329
SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);
1922219330
#ifndef SQLITE_OMIT_AUTHORIZATION
1922319331
SQLITE_PRIVATE void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);
1922419332
SQLITE_PRIVATE int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);
@@ -19512,10 +19620,16 @@
1951219620
const sqlite3_module*,
1951319621
void*,
1951419622
void(*)(void*)
1951519623
);
1951619624
# define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
19625
+#endif
19626
+SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db);
19627
+#ifndef SQLITE_OMIT_VIRTUALTABLE
19628
+SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName);
19629
+#else
19630
+# define sqlite3ShadowTableName(A,B) 0
1951719631
#endif
1951819632
SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*);
1951919633
SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
1952019634
SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);
1952119635
SQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);
@@ -19534,10 +19648,11 @@
1953419648
#ifdef SQLITE_ENABLE_NORMALIZE
1953519649
SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*);
1953619650
#endif
1953719651
SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
1953819652
SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
19653
+SQLITE_PRIVATE CollSeq *sqlite3ExprCompareCollSeq(Parse*,Expr*);
1953919654
SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
1954019655
SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
1954119656
SQLITE_PRIVATE const char *sqlite3JournalModename(int);
1954219657
#ifndef SQLITE_OMIT_WAL
1954319658
SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);
@@ -20376,11 +20491,12 @@
2037620491
2037720492
/*
2037820493
** True if Mem X is a NULL-nochng type.
2037920494
*/
2038020495
#define MemNullNochng(X) \
20381
- ((X)->flags==(MEM_Null|MEM_Zero) && (X)->n==0 && (X)->u.nZero==0)
20496
+ (((X)->flags&MEM_TypeMask)==(MEM_Null|MEM_Zero) \
20497
+ && (X)->n==0 && (X)->u.nZero==0)
2038220498
2038320499
/*
2038420500
** Return true if a memory cell is not marked as invalid. This macro
2038520501
** is for use inside assert() statements only.
2038620502
*/
@@ -26056,11 +26172,11 @@
2605626172
** May you share freely, never taking more than you give.
2605726173
**
2605826174
******************************************************************************
2605926175
**
2606026176
** This file contains inline asm code for retrieving "high-performance"
26061
-** counters for x86 class CPUs.
26177
+** counters for x86 and x86_64 class CPUs.
2606226178
*/
2606326179
#ifndef SQLITE_HWTIME_H
2606426180
#define SQLITE_HWTIME_H
2606526181
2606626182
/*
@@ -26067,12 +26183,13 @@
2606726183
** The following routine only works on pentium-class (or newer) processors.
2606826184
** It uses the RDTSC opcode to read the cycle count value out of the
2606926185
** processor and returns that value. This can be used for high-res
2607026186
** profiling.
2607126187
*/
26072
-#if (defined(__GNUC__) || defined(_MSC_VER)) && \
26073
- (defined(i386) || defined(__i386__) || defined(_M_IX86))
26188
+#if !defined(__STRICT_ANSI__) && \
26189
+ (defined(__GNUC__) || defined(_MSC_VER)) && \
26190
+ (defined(i386) || defined(__i386__) || defined(_M_IX86))
2607426191
2607526192
#if defined(__GNUC__)
2607626193
2607726194
__inline__ sqlite_uint64 sqlite3Hwtime(void){
2607826195
unsigned int lo, hi;
@@ -26089,19 +26206,19 @@
2608926206
}
2609026207
}
2609126208
2609226209
#endif
2609326210
26094
-#elif (defined(__GNUC__) && defined(__x86_64__))
26211
+#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__))
2609526212
2609626213
__inline__ sqlite_uint64 sqlite3Hwtime(void){
2609726214
unsigned long val;
2609826215
__asm__ __volatile__ ("rdtsc" : "=A" (val));
2609926216
return val;
2610026217
}
2610126218
26102
-#elif (defined(__GNUC__) && defined(__ppc__))
26219
+#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__))
2610326220
2610426221
__inline__ sqlite_uint64 sqlite3Hwtime(void){
2610526222
unsigned long long retval;
2610626223
unsigned long junk;
2610726224
__asm__ __volatile__ ("\n\
@@ -26114,18 +26231,17 @@
2611426231
return retval;
2611526232
}
2611626233
2611726234
#else
2611826235
26119
- #error Need implementation of sqlite3Hwtime() for your platform.
26120
-
2612126236
/*
26122
- ** To compile without implementing sqlite3Hwtime() for your platform,
26123
- ** you can remove the above #error and use the following
26124
- ** stub function. You will lose timing support for many
26125
- ** of the debugging and testing utilities, but it should at
26126
- ** least compile and run.
26237
+ ** asm() is needed for hardware timing support. Without asm(),
26238
+ ** disable the sqlite3Hwtime() routine.
26239
+ **
26240
+ ** sqlite3Hwtime() is only used for some obscure debugging
26241
+ ** and analysis configurations, not in any deliverable, so this
26242
+ ** should not be a great loss.
2612726243
*/
2612826244
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
2612926245
2613026246
#endif
2613126247
@@ -26705,23 +26821,31 @@
2670526821
UNUSED_PARAMETER(n);
2670626822
return 0;
2670726823
#endif
2670826824
}
2670926825
26826
+/*
26827
+** Default value of the hard heap limit. 0 means "no limit".
26828
+*/
26829
+#ifndef SQLITE_MAX_MEMORY
26830
+# define SQLITE_MAX_MEMORY 0
26831
+#endif
26832
+
2671026833
/*
2671126834
** State information local to the memory allocation subsystem.
2671226835
*/
2671326836
static SQLITE_WSD struct Mem0Global {
2671426837
sqlite3_mutex *mutex; /* Mutex to serialize access */
2671526838
sqlite3_int64 alarmThreshold; /* The soft heap limit */
26839
+ sqlite3_int64 hardLimit; /* The hard upper bound on memory */
2671626840
2671726841
/*
2671826842
** True if heap is nearly "full" where "full" is defined by the
2671926843
** sqlite3_soft_heap_limit() setting.
2672026844
*/
2672126845
int nearlyFull;
26722
-} mem0 = { 0, 0, 0 };
26846
+} mem0 = { 0, SQLITE_MAX_MEMORY, SQLITE_MAX_MEMORY, 0 };
2672326847
2672426848
#define mem0 GLOBAL(struct Mem0Global, mem0)
2672526849
2672626850
/*
2672726851
** Return the memory allocator mutex. sqlite3_status() needs it.
@@ -26747,12 +26871,19 @@
2674726871
return SQLITE_OK;
2674826872
}
2674926873
#endif
2675026874
2675126875
/*
26752
-** Set the soft heap-size limit for the library. Passing a zero or
26753
-** negative value indicates no limit.
26876
+** Set the soft heap-size limit for the library. An argument of
26877
+** zero disables the limit. A negative argument is a no-op used to
26878
+** obtain the return value.
26879
+**
26880
+** The return value is the value of the heap limit just before this
26881
+** interface was called.
26882
+**
26883
+** If the hard heap limit is enabled, then the soft heap limit cannot
26884
+** be disabled nor raised above the hard heap limit.
2675426885
*/
2675526886
SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){
2675626887
sqlite3_int64 priorLimit;
2675726888
sqlite3_int64 excess;
2675826889
sqlite3_int64 nUsed;
@@ -26763,10 +26894,13 @@
2676326894
sqlite3_mutex_enter(mem0.mutex);
2676426895
priorLimit = mem0.alarmThreshold;
2676526896
if( n<0 ){
2676626897
sqlite3_mutex_leave(mem0.mutex);
2676726898
return priorLimit;
26899
+ }
26900
+ if( mem0.hardLimit>0 && (n>mem0.hardLimit || n==0) ){
26901
+ n = mem0.hardLimit;
2676826902
}
2676926903
mem0.alarmThreshold = n;
2677026904
nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
2677126905
mem0.nearlyFull = (n>0 && n<=nUsed);
2677226906
sqlite3_mutex_leave(mem0.mutex);
@@ -26776,10 +26910,41 @@
2677626910
}
2677726911
SQLITE_API void sqlite3_soft_heap_limit(int n){
2677826912
if( n<0 ) n = 0;
2677926913
sqlite3_soft_heap_limit64(n);
2678026914
}
26915
+
26916
+/*
26917
+** Set the hard heap-size limit for the library. An argument of zero
26918
+** disables the hard heap limit. A negative argument is a no-op used
26919
+** to obtain the return value without affecting the hard heap limit.
26920
+**
26921
+** The return value is the value of the hard heap limit just prior to
26922
+** calling this interface.
26923
+**
26924
+** Setting the hard heap limit will also activate the soft heap limit
26925
+** and constrain the soft heap limit to be no more than the hard heap
26926
+** limit.
26927
+*/
26928
+SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 n){
26929
+ sqlite3_int64 priorLimit;
26930
+#ifndef SQLITE_OMIT_AUTOINIT
26931
+ int rc = sqlite3_initialize();
26932
+ if( rc ) return -1;
26933
+#endif
26934
+ sqlite3_mutex_enter(mem0.mutex);
26935
+ priorLimit = mem0.hardLimit;
26936
+ if( n>=0 ){
26937
+ mem0.hardLimit = n;
26938
+ if( n<mem0.alarmThreshold || mem0.alarmThreshold==0 ){
26939
+ mem0.alarmThreshold = n;
26940
+ }
26941
+ }
26942
+ sqlite3_mutex_leave(mem0.mutex);
26943
+ return priorLimit;
26944
+}
26945
+
2678126946
2678226947
/*
2678326948
** Initialize the memory allocation subsystem.
2678426949
*/
2678526950
SQLITE_PRIVATE int sqlite3MallocInit(void){
@@ -26863,23 +27028,23 @@
2686327028
** mode and specifically when the DMD "Dark Matter Detector" is enabled
2686427029
** or else a crash results. Hence, do not attempt to optimize out the
2686527030
** following xRoundup() call. */
2686627031
nFull = sqlite3GlobalConfig.m.xRoundup(n);
2686727032
26868
-#ifdef SQLITE_MAX_MEMORY
26869
- if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nFull>SQLITE_MAX_MEMORY ){
26870
- *pp = 0;
26871
- return;
26872
- }
26873
-#endif
26874
-
2687527033
sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);
2687627034
if( mem0.alarmThreshold>0 ){
2687727035
sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
2687827036
if( nUsed >= mem0.alarmThreshold - nFull ){
2687927037
mem0.nearlyFull = 1;
2688027038
sqlite3MallocAlarm(nFull);
27039
+ if( mem0.hardLimit ){
27040
+ nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
27041
+ if( nUsed >= mem0.hardLimit - nFull ){
27042
+ *pp = 0;
27043
+ return;
27044
+ }
27045
+ }
2688127046
}else{
2688227047
mem0.nearlyFull = 0;
2688327048
}
2688427049
}
2688527050
p = sqlite3GlobalConfig.m.xMalloc(nFull);
@@ -26971,11 +27136,11 @@
2697127136
}
2697227137
#endif
2697327138
return sqlite3GlobalConfig.m.xSize(p);
2697427139
}else{
2697527140
assert( sqlite3_mutex_held(db->mutex) );
26976
- return db->lookaside.sz;
27141
+ return db->lookaside.szTrue;
2697727142
}
2697827143
}
2697927144
SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){
2698027145
assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
2698127146
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
@@ -27023,11 +27188,11 @@
2702327188
}
2702427189
if( isLookaside(db, p) ){
2702527190
LookasideSlot *pBuf = (LookasideSlot*)p;
2702627191
#ifdef SQLITE_DEBUG
2702727192
/* Trash all content in the buffer being freed */
27028
- memset(p, 0xaa, db->lookaside.sz);
27193
+ memset(p, 0xaa, db->lookaside.szTrue);
2702927194
#endif
2703027195
pBuf->pNext = db->lookaside.pFree;
2703127196
db->lookaside.pFree = pBuf;
2703227197
return;
2703327198
}
@@ -27183,27 +27348,25 @@
2718327348
#ifndef SQLITE_OMIT_LOOKASIDE
2718427349
LookasideSlot *pBuf;
2718527350
assert( db!=0 );
2718627351
assert( sqlite3_mutex_held(db->mutex) );
2718727352
assert( db->pnBytesFreed==0 );
27188
- if( db->lookaside.bDisable==0 ){
27189
- assert( db->mallocFailed==0 );
27190
- if( n>db->lookaside.sz ){
27191
- db->lookaside.anStat[1]++;
27192
- }else if( (pBuf = db->lookaside.pFree)!=0 ){
27193
- db->lookaside.pFree = pBuf->pNext;
27194
- db->lookaside.anStat[0]++;
27195
- return (void*)pBuf;
27196
- }else if( (pBuf = db->lookaside.pInit)!=0 ){
27197
- db->lookaside.pInit = pBuf->pNext;
27198
- db->lookaside.anStat[0]++;
27199
- return (void*)pBuf;
27200
- }else{
27201
- db->lookaside.anStat[2]++;
27202
- }
27203
- }else if( db->mallocFailed ){
27204
- return 0;
27353
+ if( n>db->lookaside.sz ){
27354
+ if( db->lookaside.bDisable ){
27355
+ return db->mallocFailed ? 0 : dbMallocRawFinish(db, n);
27356
+ }
27357
+ db->lookaside.anStat[1]++;
27358
+ }else if( (pBuf = db->lookaside.pFree)!=0 ){
27359
+ db->lookaside.pFree = pBuf->pNext;
27360
+ db->lookaside.anStat[0]++;
27361
+ return (void*)pBuf;
27362
+ }else if( (pBuf = db->lookaside.pInit)!=0 ){
27363
+ db->lookaside.pInit = pBuf->pNext;
27364
+ db->lookaside.anStat[0]++;
27365
+ return (void*)pBuf;
27366
+ }else{
27367
+ db->lookaside.anStat[2]++;
2720527368
}
2720627369
#else
2720727370
assert( db!=0 );
2720827371
assert( sqlite3_mutex_held(db->mutex) );
2720927372
assert( db->pnBytesFreed==0 );
@@ -27223,11 +27386,11 @@
2722327386
*/
2722427387
SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){
2722527388
assert( db!=0 );
2722627389
if( p==0 ) return sqlite3DbMallocRawNN(db, n);
2722727390
assert( sqlite3_mutex_held(db->mutex) );
27228
- if( isLookaside(db,p) && n<=db->lookaside.sz ) return p;
27391
+ if( isLookaside(db,p) && n<=db->lookaside.szTrue ) return p;
2722927392
return dbReallocFinish(db, p, n);
2723027393
}
2723127394
static SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n){
2723227395
void *pNew = 0;
2723327396
assert( db!=0 );
@@ -27234,11 +27397,11 @@
2723427397
assert( p!=0 );
2723527398
if( db->mallocFailed==0 ){
2723627399
if( isLookaside(db, p) ){
2723727400
pNew = sqlite3DbMallocRawNN(db, n);
2723827401
if( pNew ){
27239
- memcpy(pNew, p, db->lookaside.sz);
27402
+ memcpy(pNew, p, db->lookaside.szTrue);
2724027403
sqlite3DbFree(db, p);
2724127404
}
2724227405
}else{
2724327406
assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
2724427407
assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
@@ -27333,11 +27496,11 @@
2733327496
if( db->mallocFailed==0 && db->bBenignMalloc==0 ){
2733427497
db->mallocFailed = 1;
2733527498
if( db->nVdbeExec>0 ){
2733627499
db->u1.isInterrupted = 1;
2733727500
}
27338
- db->lookaside.bDisable++;
27501
+ DisableLookaside;
2733927502
if( db->pParse ){
2734027503
db->pParse->rc = SQLITE_NOMEM_BKPT;
2734127504
}
2734227505
}
2734327506
}
@@ -27352,11 +27515,11 @@
2735227515
SQLITE_PRIVATE void sqlite3OomClear(sqlite3 *db){
2735327516
if( db->mallocFailed && db->nVdbeExec==0 ){
2735427517
db->mallocFailed = 0;
2735527518
db->u1.isInterrupted = 0;
2735627519
assert( db->lookaside.bDisable>0 );
27357
- db->lookaside.bDisable--;
27520
+ EnableLookaside;
2735827521
}
2735927522
}
2736027523
2736127524
/*
2736227525
** Take actions at the end of an API call to indicate an OOM error
@@ -28760,11 +28923,11 @@
2876028923
}
2876128924
if( zFormat!=0 ){
2876228925
va_start(ap, zFormat);
2876328926
sqlite3_str_vappendf(&acc, zFormat, ap);
2876428927
va_end(ap);
28765
- assert( acc.nChar>0 );
28928
+ assert( acc.nChar>0 || acc.accError );
2876628929
sqlite3_str_append(&acc, "\n", 1);
2876728930
}
2876828931
sqlite3StrAccumFinish(&acc);
2876928932
fprintf(stdout,"%s", zBuf);
2877028933
fflush(stdout);
@@ -28825,11 +28988,11 @@
2882528988
for(i=0; i<pSrc->nSrc; i++){
2882628989
const struct SrcList_item *pItem = &pSrc->a[i];
2882728990
StrAccum x;
2882828991
char zLine[100];
2882928992
sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
28830
- sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor);
28993
+ sqlite3_str_appendf(&x, "{%d:*}", pItem->iCursor);
2883128994
if( pItem->zDatabase ){
2883228995
sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
2883328996
}else if( pItem->zName ){
2883428997
sqlite3_str_appendf(&x, " %s", pItem->zName);
2883528998
}
@@ -29117,11 +29280,18 @@
2911729280
break;
2911829281
}
2911929282
case TK_COLUMN: {
2912029283
if( pExpr->iTable<0 ){
2912129284
/* This only happens when coding check constraints */
29122
- sqlite3TreeViewLine(pView, "COLUMN(%d)%s", pExpr->iColumn, zFlgs);
29285
+ char zOp2[16];
29286
+ if( pExpr->op2 ){
29287
+ sqlite3_snprintf(sizeof(zOp2),zOp2," op2=0x%02x",pExpr->op2);
29288
+ }else{
29289
+ zOp2[0] = 0;
29290
+ }
29291
+ sqlite3TreeViewLine(pView, "COLUMN(%d)%s%s",
29292
+ pExpr->iColumn, zFlgs, zOp2);
2912329293
}else{
2912429294
sqlite3TreeViewLine(pView, "{%d:%d}%s",
2912529295
pExpr->iTable, pExpr->iColumn, zFlgs);
2912629296
}
2912729297
if( ExprHasProperty(pExpr, EP_FixedCol) ){
@@ -29260,10 +29430,21 @@
2926029430
#endif
2926129431
}
2926229432
if( pExpr->op==TK_AGG_FUNCTION ){
2926329433
sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s",
2926429434
pExpr->op2, pExpr->u.zToken, zFlgs);
29435
+ }else if( pExpr->op2!=0 ){
29436
+ const char *zOp2;
29437
+ char zBuf[8];
29438
+ sqlite3_snprintf(sizeof(zBuf),zBuf,"0x%02x",pExpr->op2);
29439
+ zOp2 = zBuf;
29440
+ if( pExpr->op2==NC_IsCheck ) zOp2 = "NC_IsCheck";
29441
+ if( pExpr->op2==NC_IdxExpr ) zOp2 = "NC_IdxExpr";
29442
+ if( pExpr->op2==NC_PartIdx ) zOp2 = "NC_PartIdx";
29443
+ if( pExpr->op2==NC_GenCol ) zOp2 = "NC_GenCol";
29444
+ sqlite3TreeViewLine(pView, "FUNCTION %Q%s op2=%s",
29445
+ pExpr->u.zToken, zFlgs, zOp2);
2926529446
}else{
2926629447
sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs);
2926729448
}
2926829449
if( pFarg ){
2926929450
sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);
@@ -29355,11 +29536,13 @@
2935529536
pExpr->iTable, pExpr->iColumn, zFlgs);
2935629537
sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
2935729538
break;
2935829539
}
2935929540
case TK_VECTOR: {
29360
- sqlite3TreeViewBareExprList(pView, pExpr->x.pList, "VECTOR");
29541
+ char *z = sqlite3_mprintf("VECTOR%s",zFlgs);
29542
+ sqlite3TreeViewBareExprList(pView, pExpr->x.pList, z);
29543
+ sqlite3_free(z);
2936129544
break;
2936229545
}
2936329546
case TK_SELECT_COLUMN: {
2936429547
sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn);
2936529548
sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);
@@ -30581,10 +30764,11 @@
3058130764
}else{
3058230765
pParse->nErr++;
3058330766
sqlite3DbFree(db, pParse->zErrMsg);
3058430767
pParse->zErrMsg = zMsg;
3058530768
pParse->rc = SQLITE_ERROR;
30769
+ pParse->pWith = 0;
3058630770
}
3058730771
}
3058830772
3058930773
/*
3059030774
** If database connection db is currently parsing SQL, then transfer
@@ -30771,10 +30955,13 @@
3077130955
**
3077230956
** If some prefix of the input string is a valid number, this routine
3077330957
** returns FALSE but it still converts the prefix and writes the result
3077430958
** into *pResult.
3077530959
*/
30960
+#if defined(_MSC_VER)
30961
+#pragma warning(disable : 4756)
30962
+#endif
3077630963
SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
3077730964
#ifndef SQLITE_OMIT_FLOATING_POINT
3077830965
int incr;
3077930966
const char *zEnd = z + length;
3078030967
/* sign * significand * (10 ^ (esign * exponent)) */
@@ -30958,10 +31145,13 @@
3095831145
}
3095931146
#else
3096031147
return !sqlite3Atoi64(z, pResult, length, enc);
3096131148
#endif /* SQLITE_OMIT_FLOATING_POINT */
3096231149
}
31150
+#if defined(_MSC_VER)
31151
+#pragma warning(default : 4756)
31152
+#endif
3096331153
3096431154
/*
3096531155
** Compare the 19-character string zNum against the text representation
3096631156
** value 2^63: 9223372036854775808. Return negative, zero, or positive
3096731157
** if zNum is less than, equal to, or greater than the string.
@@ -32364,121 +32554,119 @@
3236432554
/* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
3236532555
/* 58 */ "ElseNotEq" OpHelp(""),
3236632556
/* 59 */ "IncrVacuum" OpHelp(""),
3236732557
/* 60 */ "VNext" OpHelp(""),
3236832558
/* 61 */ "Init" OpHelp("Start at P2"),
32369
- /* 62 */ "PureFunc0" OpHelp(""),
32370
- /* 63 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
32371
- /* 64 */ "PureFunc" OpHelp(""),
32372
- /* 65 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
32373
- /* 66 */ "Return" OpHelp(""),
32374
- /* 67 */ "EndCoroutine" OpHelp(""),
32375
- /* 68 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
32376
- /* 69 */ "Halt" OpHelp(""),
32377
- /* 70 */ "Integer" OpHelp("r[P2]=P1"),
32378
- /* 71 */ "Int64" OpHelp("r[P2]=P4"),
32379
- /* 72 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
32380
- /* 73 */ "Null" OpHelp("r[P2..P3]=NULL"),
32381
- /* 74 */ "SoftNull" OpHelp("r[P1]=NULL"),
32382
- /* 75 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
32383
- /* 76 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
32384
- /* 77 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
32385
- /* 78 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
32386
- /* 79 */ "SCopy" OpHelp("r[P2]=r[P1]"),
32387
- /* 80 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
32388
- /* 81 */ "ResultRow" OpHelp("output=r[P1@P2]"),
32389
- /* 82 */ "CollSeq" OpHelp(""),
32390
- /* 83 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
32391
- /* 84 */ "RealAffinity" OpHelp(""),
32392
- /* 85 */ "Cast" OpHelp("affinity(r[P1])"),
32393
- /* 86 */ "Permutation" OpHelp(""),
32394
- /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
32395
- /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
32396
- /* 89 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
32397
- /* 90 */ "Column" OpHelp("r[P3]=PX"),
32398
- /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
32399
- /* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
32400
- /* 93 */ "Count" OpHelp("r[P2]=count()"),
32401
- /* 94 */ "ReadCookie" OpHelp(""),
32402
- /* 95 */ "SetCookie" OpHelp(""),
32403
- /* 96 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32404
- /* 97 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32405
- /* 98 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32406
- /* 99 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32407
- /* 100 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32408
- /* 101 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32409
- /* 102 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32410
- /* 103 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32411
- /* 104 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32412
- /* 105 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32413
- /* 106 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32414
- /* 107 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32415
- /* 108 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32416
- /* 109 */ "OpenDup" OpHelp(""),
32417
- /* 110 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32418
- /* 111 */ "OpenAutoindex" OpHelp("nColumn=P2"),
32419
- /* 112 */ "OpenEphemeral" OpHelp("nColumn=P2"),
32420
- /* 113 */ "String8" OpHelp("r[P2]='P4'"),
32421
- /* 114 */ "SorterOpen" OpHelp(""),
32422
- /* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
32423
- /* 116 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
32424
- /* 117 */ "Close" OpHelp(""),
32425
- /* 118 */ "ColumnsUsed" OpHelp(""),
32426
- /* 119 */ "SeekHit" OpHelp("seekHit=P2"),
32427
- /* 120 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
32428
- /* 121 */ "NewRowid" OpHelp("r[P2]=rowid"),
32429
- /* 122 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
32430
- /* 123 */ "Delete" OpHelp(""),
32431
- /* 124 */ "ResetCount" OpHelp(""),
32432
- /* 125 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
32433
- /* 126 */ "SorterData" OpHelp("r[P2]=data"),
32434
- /* 127 */ "RowData" OpHelp("r[P2]=data"),
32435
- /* 128 */ "Rowid" OpHelp("r[P2]=rowid"),
32436
- /* 129 */ "NullRow" OpHelp(""),
32437
- /* 130 */ "SeekEnd" OpHelp(""),
32438
- /* 131 */ "SorterInsert" OpHelp("key=r[P2]"),
32439
- /* 132 */ "IdxInsert" OpHelp("key=r[P2]"),
32440
- /* 133 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
32441
- /* 134 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
32442
- /* 135 */ "IdxRowid" OpHelp("r[P2]=rowid"),
32443
- /* 136 */ "Destroy" OpHelp(""),
32444
- /* 137 */ "Clear" OpHelp(""),
32445
- /* 138 */ "ResetSorter" OpHelp(""),
32446
- /* 139 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
32447
- /* 140 */ "SqlExec" OpHelp(""),
32448
- /* 141 */ "ParseSchema" OpHelp(""),
32449
- /* 142 */ "LoadAnalysis" OpHelp(""),
32450
- /* 143 */ "DropTable" OpHelp(""),
32451
- /* 144 */ "DropIndex" OpHelp(""),
32452
- /* 145 */ "DropTrigger" OpHelp(""),
32453
- /* 146 */ "IntegrityCk" OpHelp(""),
32454
- /* 147 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
32455
- /* 148 */ "Real" OpHelp("r[P2]=P4"),
32456
- /* 149 */ "Param" OpHelp(""),
32457
- /* 150 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
32458
- /* 151 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
32459
- /* 152 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
32460
- /* 153 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
32461
- /* 154 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
32462
- /* 155 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
32463
- /* 156 */ "AggValue" OpHelp("r[P3]=value N=P2"),
32464
- /* 157 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
32465
- /* 158 */ "Expire" OpHelp(""),
32466
- /* 159 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
32467
- /* 160 */ "VBegin" OpHelp(""),
32468
- /* 161 */ "VCreate" OpHelp(""),
32469
- /* 162 */ "VDestroy" OpHelp(""),
32470
- /* 163 */ "VOpen" OpHelp(""),
32471
- /* 164 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
32472
- /* 165 */ "VRename" OpHelp(""),
32473
- /* 166 */ "Pagecount" OpHelp(""),
32474
- /* 167 */ "MaxPgcnt" OpHelp(""),
32475
- /* 168 */ "Trace" OpHelp(""),
32476
- /* 169 */ "CursorHint" OpHelp(""),
32477
- /* 170 */ "Noop" OpHelp(""),
32478
- /* 171 */ "Explain" OpHelp(""),
32479
- /* 172 */ "Abortable" OpHelp(""),
32559
+ /* 62 */ "PureFunc" OpHelp("r[P3]=func(r[P2@P5])"),
32560
+ /* 63 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
32561
+ /* 64 */ "Return" OpHelp(""),
32562
+ /* 65 */ "EndCoroutine" OpHelp(""),
32563
+ /* 66 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
32564
+ /* 67 */ "Halt" OpHelp(""),
32565
+ /* 68 */ "Integer" OpHelp("r[P2]=P1"),
32566
+ /* 69 */ "Int64" OpHelp("r[P2]=P4"),
32567
+ /* 70 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
32568
+ /* 71 */ "Null" OpHelp("r[P2..P3]=NULL"),
32569
+ /* 72 */ "SoftNull" OpHelp("r[P1]=NULL"),
32570
+ /* 73 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
32571
+ /* 74 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
32572
+ /* 75 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
32573
+ /* 76 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
32574
+ /* 77 */ "SCopy" OpHelp("r[P2]=r[P1]"),
32575
+ /* 78 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
32576
+ /* 79 */ "ResultRow" OpHelp("output=r[P1@P2]"),
32577
+ /* 80 */ "CollSeq" OpHelp(""),
32578
+ /* 81 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
32579
+ /* 82 */ "RealAffinity" OpHelp(""),
32580
+ /* 83 */ "Cast" OpHelp("affinity(r[P1])"),
32581
+ /* 84 */ "Permutation" OpHelp(""),
32582
+ /* 85 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
32583
+ /* 86 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
32584
+ /* 87 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
32585
+ /* 88 */ "Column" OpHelp("r[P3]=PX"),
32586
+ /* 89 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
32587
+ /* 90 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
32588
+ /* 91 */ "Count" OpHelp("r[P2]=count()"),
32589
+ /* 92 */ "ReadCookie" OpHelp(""),
32590
+ /* 93 */ "SetCookie" OpHelp(""),
32591
+ /* 94 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32592
+ /* 95 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32593
+ /* 96 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32594
+ /* 97 */ "OpenDup" OpHelp(""),
32595
+ /* 98 */ "OpenAutoindex" OpHelp("nColumn=P2"),
32596
+ /* 99 */ "OpenEphemeral" OpHelp("nColumn=P2"),
32597
+ /* 100 */ "SorterOpen" OpHelp(""),
32598
+ /* 101 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32599
+ /* 102 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32600
+ /* 103 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32601
+ /* 104 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32602
+ /* 105 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32603
+ /* 106 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32604
+ /* 107 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32605
+ /* 108 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32606
+ /* 109 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32607
+ /* 110 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32608
+ /* 111 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
32609
+ /* 112 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32610
+ /* 113 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
32611
+ /* 114 */ "Close" OpHelp(""),
32612
+ /* 115 */ "String8" OpHelp("r[P2]='P4'"),
32613
+ /* 116 */ "ColumnsUsed" OpHelp(""),
32614
+ /* 117 */ "SeekHit" OpHelp("seekHit=P2"),
32615
+ /* 118 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
32616
+ /* 119 */ "NewRowid" OpHelp("r[P2]=rowid"),
32617
+ /* 120 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
32618
+ /* 121 */ "Delete" OpHelp(""),
32619
+ /* 122 */ "ResetCount" OpHelp(""),
32620
+ /* 123 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
32621
+ /* 124 */ "SorterData" OpHelp("r[P2]=data"),
32622
+ /* 125 */ "RowData" OpHelp("r[P2]=data"),
32623
+ /* 126 */ "Rowid" OpHelp("r[P2]=rowid"),
32624
+ /* 127 */ "NullRow" OpHelp(""),
32625
+ /* 128 */ "SeekEnd" OpHelp(""),
32626
+ /* 129 */ "SorterInsert" OpHelp("key=r[P2]"),
32627
+ /* 130 */ "IdxInsert" OpHelp("key=r[P2]"),
32628
+ /* 131 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
32629
+ /* 132 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
32630
+ /* 133 */ "IdxRowid" OpHelp("r[P2]=rowid"),
32631
+ /* 134 */ "Destroy" OpHelp(""),
32632
+ /* 135 */ "Clear" OpHelp(""),
32633
+ /* 136 */ "ResetSorter" OpHelp(""),
32634
+ /* 137 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
32635
+ /* 138 */ "SqlExec" OpHelp(""),
32636
+ /* 139 */ "ParseSchema" OpHelp(""),
32637
+ /* 140 */ "LoadAnalysis" OpHelp(""),
32638
+ /* 141 */ "DropTable" OpHelp(""),
32639
+ /* 142 */ "DropIndex" OpHelp(""),
32640
+ /* 143 */ "DropTrigger" OpHelp(""),
32641
+ /* 144 */ "IntegrityCk" OpHelp(""),
32642
+ /* 145 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
32643
+ /* 146 */ "Param" OpHelp(""),
32644
+ /* 147 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
32645
+ /* 148 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
32646
+ /* 149 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
32647
+ /* 150 */ "Real" OpHelp("r[P2]=P4"),
32648
+ /* 151 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
32649
+ /* 152 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
32650
+ /* 153 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
32651
+ /* 154 */ "AggValue" OpHelp("r[P3]=value N=P2"),
32652
+ /* 155 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
32653
+ /* 156 */ "Expire" OpHelp(""),
32654
+ /* 157 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
32655
+ /* 158 */ "VBegin" OpHelp(""),
32656
+ /* 159 */ "VCreate" OpHelp(""),
32657
+ /* 160 */ "VDestroy" OpHelp(""),
32658
+ /* 161 */ "VOpen" OpHelp(""),
32659
+ /* 162 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
32660
+ /* 163 */ "VRename" OpHelp(""),
32661
+ /* 164 */ "Pagecount" OpHelp(""),
32662
+ /* 165 */ "MaxPgcnt" OpHelp(""),
32663
+ /* 166 */ "Trace" OpHelp(""),
32664
+ /* 167 */ "CursorHint" OpHelp(""),
32665
+ /* 168 */ "Noop" OpHelp(""),
32666
+ /* 169 */ "Explain" OpHelp(""),
32667
+ /* 170 */ "Abortable" OpHelp(""),
3248032668
};
3248132669
return azName[i];
3248232670
}
3248332671
#endif
3248432672
@@ -32838,11 +33026,11 @@
3283833026
** May you share freely, never taking more than you give.
3283933027
**
3284033028
******************************************************************************
3284133029
**
3284233030
** This file contains inline asm code for retrieving "high-performance"
32843
-** counters for x86 class CPUs.
33031
+** counters for x86 and x86_64 class CPUs.
3284433032
*/
3284533033
#ifndef SQLITE_HWTIME_H
3284633034
#define SQLITE_HWTIME_H
3284733035
3284833036
/*
@@ -32849,12 +33037,13 @@
3284933037
** The following routine only works on pentium-class (or newer) processors.
3285033038
** It uses the RDTSC opcode to read the cycle count value out of the
3285133039
** processor and returns that value. This can be used for high-res
3285233040
** profiling.
3285333041
*/
32854
-#if (defined(__GNUC__) || defined(_MSC_VER)) && \
32855
- (defined(i386) || defined(__i386__) || defined(_M_IX86))
33042
+#if !defined(__STRICT_ANSI__) && \
33043
+ (defined(__GNUC__) || defined(_MSC_VER)) && \
33044
+ (defined(i386) || defined(__i386__) || defined(_M_IX86))
3285633045
3285733046
#if defined(__GNUC__)
3285833047
3285933048
__inline__ sqlite_uint64 sqlite3Hwtime(void){
3286033049
unsigned int lo, hi;
@@ -32871,19 +33060,19 @@
3287133060
}
3287233061
}
3287333062
3287433063
#endif
3287533064
32876
-#elif (defined(__GNUC__) && defined(__x86_64__))
33065
+#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__))
3287733066
3287833067
__inline__ sqlite_uint64 sqlite3Hwtime(void){
3287933068
unsigned long val;
3288033069
__asm__ __volatile__ ("rdtsc" : "=A" (val));
3288133070
return val;
3288233071
}
3288333072
32884
-#elif (defined(__GNUC__) && defined(__ppc__))
33073
+#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__))
3288533074
3288633075
__inline__ sqlite_uint64 sqlite3Hwtime(void){
3288733076
unsigned long long retval;
3288833077
unsigned long junk;
3288933078
__asm__ __volatile__ ("\n\
@@ -32896,18 +33085,17 @@
3289633085
return retval;
3289733086
}
3289833087
3289933088
#else
3290033089
32901
- #error Need implementation of sqlite3Hwtime() for your platform.
32902
-
3290333090
/*
32904
- ** To compile without implementing sqlite3Hwtime() for your platform,
32905
- ** you can remove the above #error and use the following
32906
- ** stub function. You will lose timing support for many
32907
- ** of the debugging and testing utilities, but it should at
32908
- ** least compile and run.
33091
+ ** asm() is needed for hardware timing support. Without asm(),
33092
+ ** disable the sqlite3Hwtime() routine.
33093
+ **
33094
+ ** sqlite3Hwtime() is only used for some obscure debugging
33095
+ ** and analysis configurations, not in any deliverable, so this
33096
+ ** should not be a great loss.
3290933097
*/
3291033098
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
3291133099
3291233100
#endif
3291333101
@@ -38933,19 +39121,29 @@
3893339121
){
3893439122
UNUSED_PARAMETER(NotUsed);
3893539123
SimulateIOError( return SQLITE_IOERR_ACCESS; );
3893639124
assert( pResOut!=0 );
3893739125
38938
- /* The spec says there are three possible values for flags. But only
38939
- ** two of them are actually used */
38940
- assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE );
39126
+ /* The spec says there are four possible values for flags. But the
39127
+ ** SQLITE_ACCESS_READ flag is never used */
39128
+ assert( flags==SQLITE_ACCESS_EXISTS
39129
+ || flags==SQLITE_ACCESS_READWRITE
39130
+ || flags==SQLITE_ACCESS_SYMLINK );
3894139131
3894239132
if( flags==SQLITE_ACCESS_EXISTS ){
3894339133
struct stat buf;
3894439134
*pResOut = (0==osStat(zPath, &buf) && buf.st_size>0);
38945
- }else{
39135
+ }else if( flags==SQLITE_ACCESS_READWRITE ){
3894639136
*pResOut = osAccess(zPath, W_OK|R_OK)==0;
39137
+ }else{
39138
+#if !defined(HAVE_LSTAT)
39139
+ *pResOut = 0;
39140
+#else
39141
+ struct stat buf;
39142
+ *pResOut = (0==osLstat(zPath, &buf) && S_ISLNK(buf.st_mode));
39143
+#endif
39144
+ assert( flags==SQLITE_ACCESS_SYMLINK );
3894739145
}
3894839146
return SQLITE_OK;
3894939147
}
3895039148
3895139149
/*
@@ -40660,11 +40858,11 @@
4066040858
** May you share freely, never taking more than you give.
4066140859
**
4066240860
******************************************************************************
4066340861
**
4066440862
** This file contains inline asm code for retrieving "high-performance"
40665
-** counters for x86 class CPUs.
40863
+** counters for x86 and x86_64 class CPUs.
4066640864
*/
4066740865
#ifndef SQLITE_HWTIME_H
4066840866
#define SQLITE_HWTIME_H
4066940867
4067040868
/*
@@ -40671,12 +40869,13 @@
4067140869
** The following routine only works on pentium-class (or newer) processors.
4067240870
** It uses the RDTSC opcode to read the cycle count value out of the
4067340871
** processor and returns that value. This can be used for high-res
4067440872
** profiling.
4067540873
*/
40676
-#if (defined(__GNUC__) || defined(_MSC_VER)) && \
40677
- (defined(i386) || defined(__i386__) || defined(_M_IX86))
40874
+#if !defined(__STRICT_ANSI__) && \
40875
+ (defined(__GNUC__) || defined(_MSC_VER)) && \
40876
+ (defined(i386) || defined(__i386__) || defined(_M_IX86))
4067840877
4067940878
#if defined(__GNUC__)
4068040879
4068140880
__inline__ sqlite_uint64 sqlite3Hwtime(void){
4068240881
unsigned int lo, hi;
@@ -40693,19 +40892,19 @@
4069340892
}
4069440893
}
4069540894
4069640895
#endif
4069740896
40698
-#elif (defined(__GNUC__) && defined(__x86_64__))
40897
+#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__))
4069940898
4070040899
__inline__ sqlite_uint64 sqlite3Hwtime(void){
4070140900
unsigned long val;
4070240901
__asm__ __volatile__ ("rdtsc" : "=A" (val));
4070340902
return val;
4070440903
}
4070540904
40706
-#elif (defined(__GNUC__) && defined(__ppc__))
40905
+#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__))
4070740906
4070840907
__inline__ sqlite_uint64 sqlite3Hwtime(void){
4070940908
unsigned long long retval;
4071040909
unsigned long junk;
4071140910
__asm__ __volatile__ ("\n\
@@ -40718,18 +40917,17 @@
4071840917
return retval;
4071940918
}
4072040919
4072140920
#else
4072240921
40723
- #error Need implementation of sqlite3Hwtime() for your platform.
40724
-
4072540922
/*
40726
- ** To compile without implementing sqlite3Hwtime() for your platform,
40727
- ** you can remove the above #error and use the following
40728
- ** stub function. You will lose timing support for many
40729
- ** of the debugging and testing utilities, but it should at
40730
- ** least compile and run.
40923
+ ** asm() is needed for hardware timing support. Without asm(),
40924
+ ** disable the sqlite3Hwtime() routine.
40925
+ **
40926
+ ** sqlite3Hwtime() is only used for some obscure debugging
40927
+ ** and analysis configurations, not in any deliverable, so this
40928
+ ** should not be a great loss.
4073140929
*/
4073240930
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
4073340931
4073440932
#endif
4073540933
@@ -40862,10 +41060,18 @@
4086241060
4086341061
#ifndef NTDDI_WINTHRESHOLD
4086441062
# define NTDDI_WINTHRESHOLD 0x06040000
4086541063
#endif
4086641064
41065
+/*
41066
+** This constant is needed by the winAccess function; therefore, define
41067
+** it when it is missing from the SDK header files.
41068
+*/
41069
+#ifndef FILE_ATTRIBUTE_REPARSE_POINT
41070
+# define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
41071
+#endif
41072
+
4086741073
/*
4086841074
** Check to see if the GetVersionEx[AW] functions are deprecated on the
4086941075
** target system. GetVersionEx was first deprecated in Win8.1.
4087041076
*/
4087141077
#ifndef SQLITE_WIN32_GETVERSIONEX
@@ -46254,10 +46460,14 @@
4625446460
break;
4625546461
case SQLITE_ACCESS_READWRITE:
4625646462
rc = attr!=INVALID_FILE_ATTRIBUTES &&
4625746463
(attr & FILE_ATTRIBUTE_READONLY)==0;
4625846464
break;
46465
+ case SQLITE_ACCESS_SYMLINK:
46466
+ rc = attr!=INVALID_FILE_ATTRIBUTES &&
46467
+ (attr & FILE_ATTRIBUTE_REPARSE_POINT)!=0;
46468
+ break;
4625946469
default:
4626046470
assert(!"Invalid flags argument");
4626146471
}
4626246472
*pResOut = rc;
4626346473
OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
@@ -52141,10 +52351,11 @@
5214152351
** master-journal filename.
5214252352
*/
5214352353
len = 0;
5214452354
}
5214552355
zMaster[len] = '\0';
52356
+ zMaster[len+1] = '\0';
5214652357
5214752358
return SQLITE_OK;
5214852359
}
5214952360
5215052361
/*
@@ -53377,19 +53588,20 @@
5337753588
** journal files extracted from regular rollback-journals.
5337853589
*/
5337953590
rc = sqlite3OsFileSize(pMaster, &nMasterJournal);
5338053591
if( rc!=SQLITE_OK ) goto delmaster_out;
5338153592
nMasterPtr = pVfs->mxPathname+1;
53382
- zMasterJournal = sqlite3Malloc(nMasterJournal + nMasterPtr + 1);
53593
+ zMasterJournal = sqlite3Malloc(nMasterJournal + nMasterPtr + 2);
5338353594
if( !zMasterJournal ){
5338453595
rc = SQLITE_NOMEM_BKPT;
5338553596
goto delmaster_out;
5338653597
}
53387
- zMasterPtr = &zMasterJournal[nMasterJournal+1];
53598
+ zMasterPtr = &zMasterJournal[nMasterJournal+2];
5338853599
rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0);
5338953600
if( rc!=SQLITE_OK ) goto delmaster_out;
5339053601
zMasterJournal[nMasterJournal] = 0;
53602
+ zMasterJournal[nMasterJournal+1] = 0;
5339153603
5339253604
zJournal = zMasterJournal;
5339353605
while( (zJournal-zMasterJournal)<nMasterJournal ){
5339453606
int exists;
5339553607
rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);
@@ -55542,11 +55754,12 @@
5554255754
int nPathname = 0; /* Number of bytes in zPathname */
5554355755
int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */
5554455756
int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */
5554555757
u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */
5554655758
const char *zUri = 0; /* URI args to copy */
55547
- int nUri = 0; /* Number of bytes of URI args at *zUri */
55759
+ int nUriByte = 1; /* Number of bytes of URI args at *zUri */
55760
+ int nUri = 0; /* Number of URI parameters */
5554855761
5554955762
/* Figure out how much space is required for each journal file-handle
5555055763
** (there are two of them, the main journal and the sub-journal). */
5555155764
journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
5555255765
@@ -55569,10 +55782,16 @@
5556955782
** to by zPathname, length nPathname. Or, if this is a temporary file,
5557055783
** leave both nPathname and zPathname set to 0.
5557155784
*/
5557255785
if( zFilename && zFilename[0] ){
5557355786
const char *z;
55787
+ if( (vfsFlags & SQLITE_OPEN_NOFOLLOW)!=0 ){
55788
+ int isLink = 0;
55789
+ int rc = sqlite3OsAccess(pVfs, zFilename, SQLITE_ACCESS_SYMLINK, &isLink);
55790
+ if( rc==SQLITE_OK && isLink ) rc = SQLITE_CANTOPEN_SYMLINK;
55791
+ if( rc ) return rc;
55792
+ }
5557455793
nPathname = pVfs->mxPathname+1;
5557555794
zPathname = sqlite3DbMallocRaw(0, nPathname*2);
5557655795
if( zPathname==0 ){
5557755796
return SQLITE_NOMEM_BKPT;
5557855797
}
@@ -55579,15 +55798,16 @@
5557955798
zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */
5558055799
rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
5558155800
nPathname = sqlite3Strlen30(zPathname);
5558255801
z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
5558355802
while( *z ){
55584
- z += sqlite3Strlen30(z)+1;
55585
- z += sqlite3Strlen30(z)+1;
55803
+ z += strlen(z)+1;
55804
+ z += strlen(z)+1;
55805
+ nUri++;
5558655806
}
55587
- nUri = (int)(&z[1] - zUri);
55588
- assert( nUri>=0 );
55807
+ nUriByte = (int)(&z[2] - zUri);
55808
+ assert( nUriByte>=1 );
5558955809
if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
5559055810
/* This branch is taken when the journal path required by
5559155811
** the database being opened will be more than pVfs->mxPathname
5559255812
** bytes in length. This means the database cannot be opened,
5559355813
** as it will not be possible to open the journal file or even
@@ -55616,11 +55836,11 @@
5561655836
pPtr = (u8 *)sqlite3MallocZero(
5561755837
ROUND8(sizeof(*pPager)) + /* Pager structure */
5561855838
ROUND8(pcacheSize) + /* PCache object */
5561955839
ROUND8(pVfs->szOsFile) + /* The main db file */
5562055840
journalFileSize * 2 + /* The two journal files */
55621
- nPathname + 1 + nUri + /* zFilename */
55841
+ nPathname + 1 + nUriByte + /* zFilename */
5562255842
nPathname + 8 + 2 /* zJournal */
5562355843
#ifndef SQLITE_OMIT_WAL
5562455844
+ nPathname + 4 + 2 /* zWal */
5562555845
#endif
5562655846
);
@@ -55638,22 +55858,25 @@
5563855858
assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) );
5563955859
5564055860
/* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */
5564155861
if( zPathname ){
5564255862
assert( nPathname>0 );
55643
- pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri);
5564455863
memcpy(pPager->zFilename, zPathname, nPathname);
55645
- if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUri);
55864
+ if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUriByte);
55865
+ pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUriByte);
5564655866
memcpy(pPager->zJournal, zPathname, nPathname);
55647
- memcpy(&pPager->zJournal[nPathname], "-journal\000", 8+2);
55867
+ memcpy(&pPager->zJournal[nPathname], "-journal", 8);
5564855868
sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal);
5564955869
#ifndef SQLITE_OMIT_WAL
55650
- pPager->zWal = &pPager->zJournal[nPathname+8+1];
55870
+ pPager->zWal = (char*)(pPtr += nPathname + 8 + 2);
5565155871
memcpy(pPager->zWal, zPathname, nPathname);
55652
- memcpy(&pPager->zWal[nPathname], "-wal\000", 4+1);
55872
+ memcpy(&pPager->zWal[nPathname], "-wal", 4);
5565355873
sqlite3FileSuffix3(pPager->zFilename, pPager->zWal);
55874
+ assert( sqlite3UriCount(pPager->zWal)==0 );
5565455875
#endif
55876
+ assert( sqlite3UriCount(pPager->zFilename)==nUri );
55877
+ assert( sqlite3UriCount(pPager->zJournal)==0 );
5565555878
sqlite3DbFree(0, zPathname);
5565655879
}
5565755880
pPager->pVfs = pVfs;
5565855881
pPager->vfsFlags = vfsFlags;
5565955882
@@ -63072,10 +63295,11 @@
6307263295
int mallocFailed; /* A memory allocation error has occurred */
6307363296
const char *zPfx; /* Error message prefix */
6307463297
int v1, v2; /* Values for up to two %d fields in zPfx */
6307563298
StrAccum errMsg; /* Accumulate the error message text here */
6307663299
u32 *heap; /* Min-heap used for analyzing cell coverage */
63300
+ sqlite3 *db; /* Database connection running the check */
6307763301
};
6307863302
6307963303
/*
6308063304
** Routines to read or write a two- and four-byte big-endian integer values.
6308163305
*/
@@ -67759,12 +67983,13 @@
6775967983
);
6776067984
6776167985
/* The following assert statements verify that if this is a sharable
6776267986
** b-tree database, the connection is holding the required table locks,
6776367987
** and that no other connection has any open cursor that conflicts with
67764
- ** this lock. */
67765
- assert( hasSharedCacheTableLock(p, iTable, pKeyInfo!=0, (wrFlag?2:1)) );
67988
+ ** this lock. The iTable<1 term disables the check for corrupt schemas. */
67989
+ assert( hasSharedCacheTableLock(p, iTable, pKeyInfo!=0, (wrFlag?2:1))
67990
+ || iTable<1 );
6776667991
assert( wrFlag==0 || !hasReadConflicts(p, iTable) );
6776767992
6776867993
/* Assert that the caller has opened the required transaction. */
6776967994
assert( p->inTrans>TRANS_NONE );
6777067995
assert( wrFlag==0 || p->inTrans==TRANS_WRITE );
@@ -67773,13 +67998,17 @@
6777367998
6777467999
if( wrFlag ){
6777568000
allocateTempSpace(pBt);
6777668001
if( pBt->pTmpSpace==0 ) return SQLITE_NOMEM_BKPT;
6777768002
}
67778
- if( iTable==1 && btreePagecount(pBt)==0 ){
67779
- assert( wrFlag==0 );
67780
- iTable = 0;
68003
+ if( iTable<=1 ){
68004
+ if( iTable<1 ){
68005
+ return SQLITE_CORRUPT_BKPT;
68006
+ }else if( btreePagecount(pBt)==0 ){
68007
+ assert( wrFlag==0 );
68008
+ iTable = 0;
68009
+ }
6778168010
}
6778268011
6778368012
/* Now that no other errors can occur, finish filling in the BtCursor
6778468013
** variables and link the cursor into the BtShared list. */
6778568014
pCur->pgnoRoot = (Pgno)iTable;
@@ -67799,27 +68028,36 @@
6779968028
}
6780068029
pCur->pNext = pBt->pCursor;
6780168030
pBt->pCursor = pCur;
6780268031
pCur->eState = CURSOR_INVALID;
6780368032
return SQLITE_OK;
68033
+}
68034
+static int btreeCursorWithLock(
68035
+ Btree *p, /* The btree */
68036
+ int iTable, /* Root page of table to open */
68037
+ int wrFlag, /* 1 to write. 0 read-only */
68038
+ struct KeyInfo *pKeyInfo, /* First arg to comparison function */
68039
+ BtCursor *pCur /* Space for new cursor */
68040
+){
68041
+ int rc;
68042
+ sqlite3BtreeEnter(p);
68043
+ rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
68044
+ sqlite3BtreeLeave(p);
68045
+ return rc;
6780468046
}
6780568047
SQLITE_PRIVATE int sqlite3BtreeCursor(
6780668048
Btree *p, /* The btree */
6780768049
int iTable, /* Root page of table to open */
6780868050
int wrFlag, /* 1 to write. 0 read-only */
6780968051
struct KeyInfo *pKeyInfo, /* First arg to xCompare() */
6781068052
BtCursor *pCur /* Write new cursor here */
6781168053
){
67812
- int rc;
67813
- if( iTable<1 ){
67814
- rc = SQLITE_CORRUPT_BKPT;
68054
+ if( p->sharable ){
68055
+ return btreeCursorWithLock(p, iTable, wrFlag, pKeyInfo, pCur);
6781568056
}else{
67816
- sqlite3BtreeEnter(p);
67817
- rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
67818
- sqlite3BtreeLeave(p);
68057
+ return btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
6781968058
}
67820
- return rc;
6782168059
}
6782268060
6782368061
/*
6782468062
** Return the size of a BtCursor object in bytes.
6782568063
**
@@ -72853,11 +73091,11 @@
7285373091
**
7285473092
** SQLITE_OK is returned if the operation is successfully executed.
7285573093
** Otherwise, if an error is encountered (i.e. an IO error or database
7285673094
** corruption) an SQLite error code is returned.
7285773095
*/
72858
-SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *pCur, i64 *pnEntry){
73096
+SQLITE_PRIVATE int sqlite3BtreeCount(sqlite3 *db, BtCursor *pCur, i64 *pnEntry){
7285973097
i64 nEntry = 0; /* Value to return in *pnEntry */
7286073098
int rc; /* Return code */
7286173099
7286273100
rc = moveToRoot(pCur);
7286373101
if( rc==SQLITE_EMPTY ){
@@ -72866,11 +73104,11 @@
7286673104
}
7286773105
7286873106
/* Unless an error occurs, the following loop runs one iteration for each
7286973107
** page in the B-Tree structure (not including overflow pages).
7287073108
*/
72871
- while( rc==SQLITE_OK ){
73109
+ while( rc==SQLITE_OK && !db->u1.isInterrupted ){
7287273110
int iIdx; /* Index of child node in parent */
7287373111
MemPage *pPage; /* Current page of the b-tree */
7287473112
7287573113
/* If this is a leaf page or the tree is not an int-key tree, then
7287673114
** this page contains countable entries. Increment the entry counter
@@ -72992,10 +73230,11 @@
7299273230
}
7299373231
if( getPageReferenced(pCheck, iPage) ){
7299473232
checkAppendMsg(pCheck, "2nd reference to page %d", iPage);
7299573233
return 1;
7299673234
}
73235
+ if( pCheck->db->u1.isInterrupted ) return 1;
7299773236
setPageReferenced(pCheck, iPage);
7299873237
return 0;
7299973238
}
7300073239
7300173240
#ifndef SQLITE_OMIT_AUTOVACUUM
@@ -73435,10 +73674,11 @@
7343573674
** allocation errors, an error message held in memory obtained from
7343673675
** malloc is returned if *pnErr is non-zero. If *pnErr==0 then NULL is
7343773676
** returned. If a memory allocation error occurs, NULL is returned.
7343873677
*/
7343973678
SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(
73679
+ sqlite3 *db, /* Database connection that is running the check */
7344073680
Btree *p, /* The btree to be checked */
7344173681
int *aRoot, /* An array of root pages numbers for individual trees */
7344273682
int nRoot, /* Number of entries in aRoot[] */
7344373683
int mxErr, /* Stop reporting errors after this many */
7344473684
int *pnErr /* Write number of errors seen to this variable */
@@ -73452,10 +73692,11 @@
7345273692
7345373693
sqlite3BtreeEnter(p);
7345473694
assert( p->inTrans>TRANS_NONE && pBt->inTransaction>TRANS_NONE );
7345573695
VVA_ONLY( nRef = sqlite3PagerRefcount(pBt->pPager) );
7345673696
assert( nRef>=0 );
73697
+ sCheck.db = db;
7345773698
sCheck.pBt = pBt;
7345873699
sCheck.pPager = pBt->pPager;
7345973700
sCheck.nPage = btreePagecount(sCheck.pBt);
7346073701
sCheck.mxErr = mxErr;
7346173702
sCheck.nErr = 0;
@@ -75118,19 +75359,15 @@
7511875359
** otherwise.
7511975360
*/
7512075361
#ifndef SQLITE_OMIT_WINDOWFUNC
7512175362
SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem *pAccum, Mem *pOut, FuncDef *pFunc){
7512275363
sqlite3_context ctx;
75123
- Mem t;
7512475364
assert( pFunc!=0 );
7512575365
assert( pFunc->xValue!=0 );
7512675366
assert( (pAccum->flags & MEM_Null)!=0 || pFunc==pAccum->u.pDef );
7512775367
assert( pAccum->db==0 || sqlite3_mutex_held(pAccum->db->mutex) );
7512875368
memset(&ctx, 0, sizeof(ctx));
75129
- memset(&t, 0, sizeof(t));
75130
- t.flags = MEM_Null;
75131
- t.db = pAccum->db;
7513275369
sqlite3VdbeMemSetNull(pOut);
7513375370
ctx.pOut = pOut;
7513475371
ctx.pMem = pAccum;
7513575372
ctx.pFunc = pFunc;
7513675373
pFunc->xValue(&ctx);
@@ -76565,10 +76802,14 @@
7656576802
** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)
7656676803
*/
7656776804
/* #include "sqliteInt.h" */
7656876805
/* #include "vdbeInt.h" */
7656976806
76807
+/* Forward references */
76808
+static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef);
76809
+static void vdbeFreeOpArray(sqlite3 *, Op *, int);
76810
+
7657076811
/*
7657176812
** Create a new virtual database engine.
7657276813
*/
7657376814
SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){
7657476815
sqlite3 *db = pParse->db;
@@ -76591,10 +76832,17 @@
7659176832
assert( p->nOpAlloc==0 );
7659276833
assert( pParse->szOpAlloc==0 );
7659376834
sqlite3VdbeAddOp2(p, OP_Init, 0, 1);
7659476835
return p;
7659576836
}
76837
+
76838
+/*
76839
+** Return the Parse object that owns a Vdbe object.
76840
+*/
76841
+SQLITE_PRIVATE Parse *sqlite3VdbeParser(Vdbe *p){
76842
+ return p->pParse;
76843
+}
7659676844
7659776845
/*
7659876846
** Change the error string stored in Vdbe.zErrMsg
7659976847
*/
7660076848
SQLITE_PRIVATE void sqlite3VdbeError(Vdbe *p, const char *zFormat, ...){
@@ -76672,11 +76920,11 @@
7667276920
pA->pPrev = pB->pPrev;
7667376921
pB->pPrev = pTmp;
7667476922
zTmp = pA->zSql;
7667576923
pA->zSql = pB->zSql;
7667676924
pB->zSql = zTmp;
76677
-#if 0
76925
+#ifdef SQLITE_ENABLE_NORMALIZE
7667876926
zTmp = pA->zNormSql;
7667976927
pA->zNormSql = pB->zNormSql;
7668076928
pB->zNormSql = zTmp;
7668176929
#endif
7668276930
pB->expmask = pA->expmask;
@@ -76870,10 +77118,53 @@
7687077118
){
7687177119
int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);
7687277120
sqlite3VdbeChangeP4(p, addr, zP4, p4type);
7687377121
return addr;
7687477122
}
77123
+
77124
+/*
77125
+** Add an OP_Function or OP_PureFunc opcode.
77126
+**
77127
+** The eCallCtx argument is information (typically taken from Expr.op2)
77128
+** that describes the calling context of the function. 0 means a general
77129
+** function call. NC_IsCheck means called by a check constraint,
77130
+** NC_IdxExpr means called as part of an index expression. NC_PartIdx
77131
+** means in the WHERE clause of a partial index. NC_GenCol means called
77132
+** while computing a generated column value. 0 is the usual case.
77133
+*/
77134
+SQLITE_PRIVATE int sqlite3VdbeAddFunctionCall(
77135
+ Parse *pParse, /* Parsing context */
77136
+ int p1, /* Constant argument mask */
77137
+ int p2, /* First argument register */
77138
+ int p3, /* Register into which results are written */
77139
+ int nArg, /* Number of argument */
77140
+ const FuncDef *pFunc, /* The function to be invoked */
77141
+ int eCallCtx /* Calling context */
77142
+){
77143
+ Vdbe *v = pParse->pVdbe;
77144
+ int nByte;
77145
+ int addr;
77146
+ sqlite3_context *pCtx;
77147
+ assert( v );
77148
+ nByte = sizeof(*pCtx) + (nArg-1)*sizeof(sqlite3_value*);
77149
+ pCtx = sqlite3DbMallocRawNN(pParse->db, nByte);
77150
+ if( pCtx==0 ){
77151
+ assert( pParse->db->mallocFailed );
77152
+ freeEphemeralFunction(pParse->db, (FuncDef*)pFunc);
77153
+ return 0;
77154
+ }
77155
+ pCtx->pOut = 0;
77156
+ pCtx->pFunc = (FuncDef*)pFunc;
77157
+ pCtx->pVdbe = 0;
77158
+ pCtx->isError = 0;
77159
+ pCtx->argc = nArg;
77160
+ pCtx->iOp = sqlite3VdbeCurrentAddr(v);
77161
+ addr = sqlite3VdbeAddOp4(v, eCallCtx ? OP_PureFunc : OP_Function,
77162
+ p1, p2, p3, (char*)pCtx, P4_FUNCCTX);
77163
+ sqlite3VdbeChangeP5(v, eCallCtx & NC_SelfRef);
77164
+ return addr;
77165
+}
7687577166
7687677167
/*
7687777168
** Add an opcode that includes the p4 value with a P4_INT64 or
7687877169
** P4_REAL type.
7687977170
*/
@@ -77190,11 +77481,11 @@
7719077481
7719177482
while( (pOp = opIterNext(&sIter))!=0 ){
7719277483
int opcode = pOp->opcode;
7719377484
if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
7719477485
|| opcode==OP_VDestroy
77195
- || (opcode==OP_Function0 && pOp->p4.pFunc->funcFlags&SQLITE_FUNC_INTERNAL)
77486
+ || (opcode==OP_ParseSchema && pOp->p4.z==0)
7719677487
|| ((opcode==OP_Halt || opcode==OP_HaltIfNull)
7719777488
&& ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
7719877489
){
7719977490
hasAbort = 1;
7720077491
break;
@@ -77563,22 +77854,20 @@
7756377854
if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){
7756477855
sqlite3DbFreeNN(db, pDef);
7756577856
}
7756677857
}
7756777858
77568
-static void vdbeFreeOpArray(sqlite3 *, Op *, int);
77569
-
7757077859
/*
7757177860
** Delete a P4 value if necessary.
7757277861
*/
7757377862
static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){
7757477863
if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
7757577864
sqlite3DbFreeNN(db, p);
7757677865
}
7757777866
static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){
7757877867
freeEphemeralFunction(db, p->pFunc);
77579
- sqlite3DbFreeNN(db, p);
77868
+ sqlite3DbFreeNN(db, p);
7758077869
}
7758177870
static void freeP4(sqlite3 *db, int p4type, void *p4){
7758277871
assert( db );
7758377872
switch( p4type ){
7758477873
case P4_FUNCCTX: {
@@ -77647,10 +77936,17 @@
7764777936
*/
7764877937
SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){
7764977938
p->pNext = pVdbe->pProgram;
7765077939
pVdbe->pProgram = p;
7765177940
}
77941
+
77942
+/*
77943
+** Return true if the given Vdbe has any SubPrograms.
77944
+*/
77945
+SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe *pVdbe){
77946
+ return pVdbe->pProgram!=0;
77947
+}
7765277948
7765377949
/*
7765477950
** Change the opcode at addr into OP_Noop
7765577951
*/
7765677952
SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe *p, int addr){
@@ -78073,17 +78369,15 @@
7807378369
case P4_FUNCDEF: {
7807478370
FuncDef *pDef = pOp->p4.pFunc;
7807578371
sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg);
7807678372
break;
7807778373
}
78078
-#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
7807978374
case P4_FUNCCTX: {
7808078375
FuncDef *pDef = pOp->p4.pCtx->pFunc;
7808178376
sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg);
7808278377
break;
7808378378
}
78084
-#endif
7808578379
case P4_INT64: {
7808678380
sqlite3_str_appendf(&x, "%lld", *pOp->p4.pI64);
7808778381
break;
7808878382
}
7808978383
case P4_INT32: {
@@ -78773,12 +79067,30 @@
7877379067
assert( x.nFree>=0 );
7877479068
assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) );
7877579069
7877679070
resolveP2Values(p, &nArg);
7877779071
p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);
78778
- if( pParse->explain && nMem<10 ){
78779
- nMem = 10;
79072
+ if( pParse->explain ){
79073
+ static const char * const azColName[] = {
79074
+ "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment",
79075
+ "id", "parent", "notused", "detail"
79076
+ };
79077
+ int iFirst, mx, i;
79078
+ if( nMem<10 ) nMem = 10;
79079
+ if( pParse->explain==2 ){
79080
+ sqlite3VdbeSetNumCols(p, 4);
79081
+ iFirst = 8;
79082
+ mx = 12;
79083
+ }else{
79084
+ sqlite3VdbeSetNumCols(p, 8);
79085
+ iFirst = 0;
79086
+ mx = 8;
79087
+ }
79088
+ for(i=iFirst; i<mx; i++){
79089
+ sqlite3VdbeSetColName(p, i-iFirst, COLNAME_NAME,
79090
+ azColName[i], SQLITE_STATIC);
79091
+ }
7878079092
}
7878179093
p->expired = 0;
7878279094
7878379095
/* Memory for registers, parameters, cursor, etc, is allocated in one or two
7878479096
** passes. On the first pass, we try to reuse unused memory at the
@@ -79124,11 +79436,11 @@
7912479436
int retryCount = 0;
7912579437
int nMainFile;
7912679438
7912779439
/* Select a master journal file name */
7912879440
nMainFile = sqlite3Strlen30(zMainFile);
79129
- zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XXz", zMainFile);
79441
+ zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XXz%c%c", zMainFile, 0, 0);
7913079442
if( zMaster==0 ) return SQLITE_NOMEM_BKPT;
7913179443
do {
7913279444
u32 iRandom;
7913379445
if( retryCount ){
7913479446
if( retryCount>100 ){
@@ -81475,17 +81787,29 @@
8147581787
** throw an error if it is given inputs that would make it non-deterministic.
8147681788
** This routine is invoked by date/time functions that use non-deterministic
8147781789
** features such as 'now'.
8147881790
*/
8147981791
SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){
81792
+ const VdbeOp *pOp;
8148081793
#ifdef SQLITE_ENABLE_STAT4
8148181794
if( pCtx->pVdbe==0 ) return 1;
8148281795
#endif
81483
- if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){
81484
- sqlite3_result_error(pCtx,
81485
- "non-deterministic function in index expression or CHECK constraint",
81486
- -1);
81796
+ pOp = pCtx->pVdbe->aOp + pCtx->iOp;
81797
+ if( pOp->opcode==OP_PureFunc ){
81798
+ const char *zContext;
81799
+ char *zMsg;
81800
+ if( pOp->p5 & NC_IsCheck ){
81801
+ zContext = "a CHECK constraint";
81802
+ }else if( pOp->p5 & NC_GenCol ){
81803
+ zContext = "a generated column";
81804
+ }else{
81805
+ zContext = "an index";
81806
+ }
81807
+ zMsg = sqlite3_mprintf("non-deterministic use of %s() in %s",
81808
+ pCtx->pFunc->zName, zContext);
81809
+ sqlite3_result_error(pCtx, zMsg, -1);
81810
+ sqlite3_free(zMsg);
8148781811
return 0;
8148881812
}
8148981813
return 1;
8149081814
}
8149181815
@@ -83428,11 +83752,11 @@
8342883752
if( !p || p->op==SQLITE_INSERT ){
8342983753
rc = SQLITE_MISUSE_BKPT;
8343083754
goto preupdate_old_out;
8343183755
}
8343283756
if( p->pPk ){
83433
- iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);
83757
+ iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
8343483758
}
8343583759
if( iIdx>=p->pCsr->nField || iIdx<0 ){
8343683760
rc = SQLITE_RANGE;
8343783761
goto preupdate_old_out;
8343883762
}
@@ -83518,11 +83842,11 @@
8351883842
if( !p || p->op==SQLITE_DELETE ){
8351983843
rc = SQLITE_MISUSE_BKPT;
8352083844
goto preupdate_new_out;
8352183845
}
8352283846
if( p->pPk && p->op!=SQLITE_UPDATE ){
83523
- iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);
83847
+ iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
8352483848
}
8352583849
if( iIdx>=p->pCsr->nField || iIdx<0 ){
8352683850
rc = SQLITE_RANGE;
8352783851
goto preupdate_new_out;
8352883852
}
@@ -84450,11 +84774,11 @@
8445084774
** May you share freely, never taking more than you give.
8445184775
**
8445284776
******************************************************************************
8445384777
**
8445484778
** This file contains inline asm code for retrieving "high-performance"
84455
-** counters for x86 class CPUs.
84779
+** counters for x86 and x86_64 class CPUs.
8445684780
*/
8445784781
#ifndef SQLITE_HWTIME_H
8445884782
#define SQLITE_HWTIME_H
8445984783
8446084784
/*
@@ -84461,12 +84785,13 @@
8446184785
** The following routine only works on pentium-class (or newer) processors.
8446284786
** It uses the RDTSC opcode to read the cycle count value out of the
8446384787
** processor and returns that value. This can be used for high-res
8446484788
** profiling.
8446584789
*/
84466
-#if (defined(__GNUC__) || defined(_MSC_VER)) && \
84467
- (defined(i386) || defined(__i386__) || defined(_M_IX86))
84790
+#if !defined(__STRICT_ANSI__) && \
84791
+ (defined(__GNUC__) || defined(_MSC_VER)) && \
84792
+ (defined(i386) || defined(__i386__) || defined(_M_IX86))
8446884793
8446984794
#if defined(__GNUC__)
8447084795
8447184796
__inline__ sqlite_uint64 sqlite3Hwtime(void){
8447284797
unsigned int lo, hi;
@@ -84483,19 +84808,19 @@
8448384808
}
8448484809
}
8448584810
8448684811
#endif
8448784812
84488
-#elif (defined(__GNUC__) && defined(__x86_64__))
84813
+#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__))
8448984814
8449084815
__inline__ sqlite_uint64 sqlite3Hwtime(void){
8449184816
unsigned long val;
8449284817
__asm__ __volatile__ ("rdtsc" : "=A" (val));
8449384818
return val;
8449484819
}
8449584820
84496
-#elif (defined(__GNUC__) && defined(__ppc__))
84821
+#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__))
8449784822
8449884823
__inline__ sqlite_uint64 sqlite3Hwtime(void){
8449984824
unsigned long long retval;
8450084825
unsigned long junk;
8450184826
__asm__ __volatile__ ("\n\
@@ -84508,18 +84833,17 @@
8450884833
return retval;
8450984834
}
8451084835
8451184836
#else
8451284837
84513
- #error Need implementation of sqlite3Hwtime() for your platform.
84514
-
8451584838
/*
84516
- ** To compile without implementing sqlite3Hwtime() for your platform,
84517
- ** you can remove the above #error and use the following
84518
- ** stub function. You will lose timing support for many
84519
- ** of the debugging and testing utilities, but it should at
84520
- ** least compile and run.
84839
+ ** asm() is needed for hardware timing support. Without asm(),
84840
+ ** disable the sqlite3Hwtime() routine.
84841
+ **
84842
+ ** sqlite3Hwtime() is only used for some obscure debugging
84843
+ ** and analysis configurations, not in any deliverable, so this
84844
+ ** should not be a great loss.
8452184845
*/
8452284846
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
8452384847
8452484848
#endif
8452584849
@@ -87081,15 +87405,15 @@
8708187405
8708287406
assert( p->apCsr[pOp->p1]->eCurType==CURTYPE_BTREE );
8708387407
pCrsr = p->apCsr[pOp->p1]->uc.pCursor;
8708487408
assert( pCrsr );
8708587409
nEntry = 0; /* Not needed. Only used to silence a warning. */
87086
- rc = sqlite3BtreeCount(pCrsr, &nEntry);
87410
+ rc = sqlite3BtreeCount(db, pCrsr, &nEntry);
8708787411
if( rc ) goto abort_due_to_error;
8708887412
pOut = out2Prerelease(p, pOp);
8708987413
pOut->u.i = nEntry;
87090
- break;
87414
+ goto check_for_interrupt;
8709187415
}
8709287416
#endif
8709387417
8709487418
/* Opcode: Savepoint P1 * * P4 *
8709587419
**
@@ -87313,11 +87637,10 @@
8731387637
p->pc = (int)(pOp - aOp);
8731487638
db->autoCommit = (u8)(1-desiredAutoCommit);
8731587639
p->rc = rc = SQLITE_BUSY;
8731687640
goto vdbe_return;
8731787641
}
87318
- assert( db->nStatement==0 );
8731987642
sqlite3CloseSavepoints(db);
8732087643
if( p->rc==SQLITE_OK ){
8732187644
rc = SQLITE_DONE;
8732287645
}else{
8732387646
rc = SQLITE_ERROR;
@@ -87394,11 +87717,12 @@
8739487717
goto vdbe_return;
8739587718
}
8739687719
goto abort_due_to_error;
8739787720
}
8739887721
87399
- if( pOp->p2 && p->usesStmtJournal
87722
+ if( p->usesStmtJournal
87723
+ && pOp->p2
8740087724
&& (db->autoCommit==0 || db->nVdbeRead>1)
8740187725
){
8740287726
assert( sqlite3BtreeIsInTrans(pBt) );
8740387727
if( p->iStatement==0 ){
8740487728
assert( db->nStatement>=0 && db->nSavepoint>=0 );
@@ -88476,27 +88800,31 @@
8847688800
u64 iKey;
8847788801
8847888802
pIn3 = &aMem[pOp->p3];
8847988803
testcase( pIn3->flags & MEM_Int );
8848088804
testcase( pIn3->flags & MEM_IntReal );
88805
+ testcase( pIn3->flags & MEM_Real );
88806
+ testcase( (pIn3->flags & (MEM_Str|MEM_Int))==MEM_Str );
8848188807
if( (pIn3->flags & (MEM_Int|MEM_IntReal))==0 ){
88482
- /* Make sure pIn3->u.i contains a valid integer representation of
88483
- ** the key value, but do not change the datatype of the register, as
88484
- ** other parts of the perpared statement might be depending on the
88485
- ** current datatype. */
88486
- u16 origFlags = pIn3->flags;
88487
- int isNotInt;
88488
- applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);
88489
- isNotInt = (pIn3->flags & MEM_Int)==0;
88490
- pIn3->flags = origFlags;
88491
- if( isNotInt ) goto jump_to_p2;
88808
+ /* If pIn3->u.i does not contain an integer, compute iKey as the
88809
+ ** integer value of pIn3. Jump to P2 if pIn3 cannot be converted
88810
+ ** into an integer without loss of information. Take care to avoid
88811
+ ** changing the datatype of pIn3, however, as it is used by other
88812
+ ** parts of the prepared statement. */
88813
+ Mem x = pIn3[0];
88814
+ applyAffinity(&x, SQLITE_AFF_NUMERIC, encoding);
88815
+ if( (x.flags & MEM_Int)==0 ) goto jump_to_p2;
88816
+ iKey = x.u.i;
88817
+ goto notExistsWithKey;
8849288818
}
8849388819
/* Fall through into OP_NotExists */
8849488820
case OP_NotExists: /* jump, in3 */
8849588821
pIn3 = &aMem[pOp->p3];
8849688822
assert( (pIn3->flags & MEM_Int)!=0 || pOp->opcode==OP_SeekRowid );
8849788823
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
88824
+ iKey = pIn3->u.i;
88825
+notExistsWithKey:
8849888826
pC = p->apCsr[pOp->p1];
8849988827
assert( pC!=0 );
8850088828
#ifdef SQLITE_DEBUG
8850188829
if( pOp->opcode==OP_SeekRowid ) pC->seekOp = OP_SeekRowid;
8850288830
#endif
@@ -88503,11 +88831,10 @@
8850388831
assert( pC->isTable );
8850488832
assert( pC->eCurType==CURTYPE_BTREE );
8850588833
pCrsr = pC->uc.pCursor;
8850688834
assert( pCrsr!=0 );
8850788835
res = 0;
88508
- iKey = pIn3->u.i;
8850988836
rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res);
8851088837
assert( rc==SQLITE_OK || res==0 );
8851188838
pC->movetoTarget = iKey; /* Used by OP_Delete */
8851288839
pC->nullRow = 0;
8851388840
pC->cacheStatus = CACHE_STALE;
@@ -90038,11 +90365,11 @@
9003890365
assert( (pnErr->flags & MEM_Int)!=0 );
9003990366
assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
9004090367
pIn1 = &aMem[pOp->p1];
9004190368
assert( pOp->p5<db->nDb );
9004290369
assert( DbMaskTest(p->btreeMask, pOp->p5) );
90043
- z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, &aRoot[1], nRoot,
90370
+ z = sqlite3BtreeIntegrityCheck(db, db->aDb[pOp->p5].pBt, &aRoot[1], nRoot,
9004490371
(int)pnErr->u.i+1, &nErr);
9004590372
sqlite3VdbeMemSetNull(pIn1);
9004690373
if( nErr==0 ){
9004790374
assert( z==0 );
9004890375
}else if( z==0 ){
@@ -90051,11 +90378,11 @@
9005190378
pnErr->u.i -= nErr-1;
9005290379
sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free);
9005390380
}
9005490381
UPDATE_MAX_BLOBSIZE(pIn1);
9005590382
sqlite3VdbeChangeEncoding(pIn1, encoding);
90056
- break;
90383
+ goto check_for_interrupt;
9005790384
}
9005890385
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */
9005990386
9006090387
/* Opcode: RowSetAdd P1 P2 * * *
9006190388
** Synopsis: rowset(P1)=r[P2]
@@ -91377,76 +91704,56 @@
9137791704
pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);
9137891705
break;
9137991706
}
9138091707
#endif
9138191708
91382
-/* Opcode: Function0 P1 P2 P3 P4 P5
91709
+/* Opcode: Function P1 P2 P3 P4 *
9138391710
** Synopsis: r[P3]=func(r[P2@P5])
9138491711
**
91385
-** Invoke a user function (P4 is a pointer to a FuncDef object that
91386
-** defines the function) with P5 arguments taken from register P2 and
91387
-** successors. The result of the function is stored in register P3.
91388
-** Register P3 must not be one of the function inputs.
91712
+** Invoke a user function (P4 is a pointer to an sqlite3_context object that
91713
+** contains a pointer to the function to be run) with arguments taken
91714
+** from register P2 and successors. The number of arguments is in
91715
+** the sqlite3_context object that P4 points to.
91716
+** The result of the function is stored
91717
+** in register P3. Register P3 must not be one of the function inputs.
9138991718
**
9139091719
** P1 is a 32-bit bitmask indicating whether or not each argument to the
9139191720
** function was determined to be constant at compile time. If the first
9139291721
** argument was constant then bit 0 of P1 is set. This is used to determine
9139391722
** whether meta data associated with a user function argument using the
9139491723
** sqlite3_set_auxdata() API may be safely retained until the next
9139591724
** invocation of this opcode.
9139691725
**
91397
-** See also: Function, AggStep, AggFinal
91726
+** See also: AggStep, AggFinal, PureFunc
9139891727
*/
91399
-/* Opcode: Function P1 P2 P3 P4 P5
91728
+/* Opcode: PureFunc P1 P2 P3 P4 *
9140091729
** Synopsis: r[P3]=func(r[P2@P5])
9140191730
**
9140291731
** Invoke a user function (P4 is a pointer to an sqlite3_context object that
91403
-** contains a pointer to the function to be run) with P5 arguments taken
91404
-** from register P2 and successors. The result of the function is stored
91732
+** contains a pointer to the function to be run) with arguments taken
91733
+** from register P2 and successors. The number of arguments is in
91734
+** the sqlite3_context object that P4 points to.
91735
+** The result of the function is stored
9140591736
** in register P3. Register P3 must not be one of the function inputs.
9140691737
**
9140791738
** P1 is a 32-bit bitmask indicating whether or not each argument to the
9140891739
** function was determined to be constant at compile time. If the first
9140991740
** argument was constant then bit 0 of P1 is set. This is used to determine
9141091741
** whether meta data associated with a user function argument using the
9141191742
** sqlite3_set_auxdata() API may be safely retained until the next
9141291743
** invocation of this opcode.
9141391744
**
91414
-** SQL functions are initially coded as OP_Function0 with P4 pointing
91415
-** to a FuncDef object. But on first evaluation, the P4 operand is
91416
-** automatically converted into an sqlite3_context object and the operation
91417
-** changed to this OP_Function opcode. In this way, the initialization of
91418
-** the sqlite3_context object occurs only once, rather than once for each
91419
-** evaluation of the function.
91745
+** This opcode works exactly like OP_Function. The only difference is in
91746
+** its name. This opcode is used in places where the function must be
91747
+** purely non-deterministic. Some built-in date/time functions can be
91748
+** either determinitic of non-deterministic, depending on their arguments.
91749
+** When those function are used in a non-deterministic way, they will check
91750
+** to see if they were called using OP_PureFunc instead of OP_Function, and
91751
+** if they were, they throw an error.
9142091752
**
91421
-** See also: Function0, AggStep, AggFinal
91753
+** See also: AggStep, AggFinal, Function
9142291754
*/
91423
-case OP_PureFunc0: /* group */
91424
-case OP_Function0: { /* group */
91425
- int n;
91426
- sqlite3_context *pCtx;
91427
-
91428
- assert( pOp->p4type==P4_FUNCDEF );
91429
- n = pOp->p5;
91430
- assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
91431
- assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );
91432
- assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );
91433
- pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*));
91434
- if( pCtx==0 ) goto no_mem;
91435
- pCtx->pOut = 0;
91436
- pCtx->pFunc = pOp->p4.pFunc;
91437
- pCtx->iOp = (int)(pOp - aOp);
91438
- pCtx->pVdbe = p;
91439
- pCtx->isError = 0;
91440
- pCtx->argc = n;
91441
- pOp->p4type = P4_FUNCCTX;
91442
- pOp->p4.pCtx = pCtx;
91443
- assert( OP_PureFunc == OP_PureFunc0+2 );
91444
- assert( OP_Function == OP_Function0+2 );
91445
- pOp->opcode += 2;
91446
- /* Fall through into OP_Function */
91447
-}
9144891755
case OP_PureFunc: /* group */
9144991756
case OP_Function: { /* group */
9145091757
int i;
9145191758
sqlite3_context *pCtx;
9145291759
@@ -91457,13 +91764,15 @@
9145791764
** might change from one evaluation to the next. The next block of code
9145891765
** checks to see if the register array has changed, and if so it
9145991766
** reinitializes the relavant parts of the sqlite3_context object */
9146091767
pOut = &aMem[pOp->p3];
9146191768
if( pCtx->pOut != pOut ){
91769
+ pCtx->pVdbe = p;
9146291770
pCtx->pOut = pOut;
9146391771
for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];
9146491772
}
91773
+ assert( pCtx->pVdbe==p );
9146591774
9146691775
memAboutToChange(p, pOut);
9146791776
#ifdef SQLITE_DEBUG
9146891777
for(i=0; i<pCtx->argc; i++){
9146991778
assert( memIsValid(pCtx->argv[i]) );
@@ -93668,24 +93977,20 @@
9366893977
** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if
9366993978
** an error occurs.
9367093979
*/
9367193980
static int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){
9367293981
int i;
93673
- SorterRecord **aSlot;
9367493982
SorterRecord *p;
9367593983
int rc;
93984
+ SorterRecord *aSlot[64];
9367693985
9367793986
rc = vdbeSortAllocUnpacked(pTask);
9367893987
if( rc!=SQLITE_OK ) return rc;
9367993988
9368093989
p = pList->pList;
9368193990
pTask->xCompare = vdbeSorterGetCompare(pTask->pSorter);
93682
-
93683
- aSlot = (SorterRecord **)sqlite3MallocZero(64 * sizeof(SorterRecord *));
93684
- if( !aSlot ){
93685
- return SQLITE_NOMEM_BKPT;
93686
- }
93991
+ memset(aSlot, 0, sizeof(aSlot));
9368793992
9368893993
while( p ){
9368993994
SorterRecord *pNext;
9369093995
if( pList->aMemory ){
9369193996
if( (u8*)p==pList->aMemory ){
@@ -93706,17 +94011,16 @@
9370694011
aSlot[i] = p;
9370794012
p = pNext;
9370894013
}
9370994014
9371094015
p = 0;
93711
- for(i=0; i<64; i++){
94016
+ for(i=0; i<ArraySize(aSlot); i++){
9371294017
if( aSlot[i]==0 ) continue;
9371394018
p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i];
9371494019
}
9371594020
pList->pList = p;
9371694021
93717
- sqlite3_free(aSlot);
9371894022
assert( pTask->pUnpacked->errCode==SQLITE_OK
9371994023
|| pTask->pUnpacked->errCode==SQLITE_NOMEM
9372094024
);
9372194025
return pTask->pUnpacked->errCode;
9372294026
}
@@ -96097,11 +96401,11 @@
9609796401
** Perhaps the name is a reference to the ROWID
9609896402
*/
9609996403
if( cnt==0
9610096404
&& cntTab==1
9610196405
&& pMatch
96102
- && (pNC->ncFlags & NC_IdxExpr)==0
96406
+ && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0
9610396407
&& sqlite3IsRowid(zCol)
9610496408
&& VisibleRowid(pMatch->pTab)
9610596409
){
9610696410
cnt = 1;
9610796411
pExpr->iColumn = -1;
@@ -96308,17 +96612,20 @@
9630896612
Parse *pParse, /* Leave error message here */
9630996613
NameContext *pNC, /* The name context */
9631096614
const char *zMsg, /* Type of error */
9631196615
int validMask /* Set of contexts for which prohibited */
9631296616
){
96313
- assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr))==0 );
96617
+ assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 );
9631496618
if( (pNC->ncFlags & validMask)!=0 ){
9631596619
const char *zIn = "partial index WHERE clauses";
9631696620
if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions";
9631796621
#ifndef SQLITE_OMIT_CHECK
9631896622
else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints";
9631996623
#endif
96624
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
96625
+ else if( pNC->ncFlags & NC_GenCol ) zIn = "generated columns";
96626
+#endif
9632096627
sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn);
9632196628
}
9632296629
}
9632396630
9632496631
/*
@@ -96406,11 +96713,11 @@
9640696713
zDb = 0;
9640796714
zTable = 0;
9640896715
zColumn = pExpr->u.zToken;
9640996716
}else{
9641096717
Expr *pLeft = pExpr->pLeft;
96411
- notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr);
96718
+ notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr|NC_GenCol);
9641296719
pRight = pExpr->pRight;
9641396720
if( pRight->op==TK_ID ){
9641496721
zDb = 0;
9641596722
}else{
9641696723
assert( pRight->op==TK_DOT );
@@ -96495,19 +96802,22 @@
9649596802
}
9649696803
#endif
9649796804
if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){
9649896805
/* For the purposes of the EP_ConstFunc flag, date and time
9649996806
** functions and other functions that change slowly are considered
96500
- ** constant because they are constant for the duration of one query */
96807
+ ** constant because they are constant for the duration of one query.
96808
+ ** This allows them to be factored out of inner loops. */
9650196809
ExprSetProperty(pExpr,EP_ConstFunc);
9650296810
}
9650396811
if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){
9650496812
/* Date/time functions that use 'now', and other functions like
9650596813
** sqlite_version() that might change over time cannot be used
9650696814
** in an index. */
96507
- notValid(pParse, pNC, "non-deterministic functions",
96508
- NC_IdxExpr|NC_PartIdx);
96815
+ notValid(pParse, pNC, "non-deterministic functions", NC_SelfRef);
96816
+ }else{
96817
+ assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
96818
+ pExpr->op2 = pNC->ncFlags & NC_SelfRef;
9650996819
}
9651096820
if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0
9651196821
&& pParse->nested==0
9651296822
&& sqlite3Config.bInternalFunctions==0
9651396823
){
@@ -96647,11 +96957,12 @@
9664796957
#endif
9664896958
case TK_IN: {
9664996959
testcase( pExpr->op==TK_IN );
9665096960
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
9665196961
int nRef = pNC->nRef;
96652
- notValid(pParse, pNC, "subqueries", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
96962
+ notValid(pParse, pNC, "subqueries",
96963
+ NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol);
9665396964
sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
9665496965
assert( pNC->nRef>=nRef );
9665596966
if( nRef!=pNC->nRef ){
9665696967
ExprSetProperty(pExpr, EP_VarSelect);
9665796968
pNC->ncFlags |= NC_VarSelect;
@@ -96658,11 +96969,12 @@
9665896969
}
9665996970
}
9666096971
break;
9666196972
}
9666296973
case TK_VARIABLE: {
96663
- notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
96974
+ notValid(pParse, pNC, "parameters",
96975
+ NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol);
9666496976
break;
9666596977
}
9666696978
case TK_IS:
9666796979
case TK_ISNOT: {
9666896980
Expr *pRight = sqlite3ExprSkipCollateAndLikely(pExpr->pRight);
@@ -97467,34 +97779,38 @@
9746797779
9746897780
/*
9746997781
** Resolve names in expressions that can only reference a single table
9747097782
** or which cannot reference any tables at all. Examples:
9747197783
**
97472
-** (1) CHECK constraints
97473
-** (2) WHERE clauses on partial indices
97474
-** (3) Expressions in indexes on expressions
97475
-** (4) Expression arguments to VACUUM INTO.
97784
+** "type" flag
97785
+** ------------
97786
+** (1) CHECK constraints NC_IsCheck
97787
+** (2) WHERE clauses on partial indices NC_PartIdx
97788
+** (3) Expressions in indexes on expressions NC_IdxExpr
97789
+** (4) Expression arguments to VACUUM INTO. 0
97790
+** (5) GENERATED ALWAYS as expressions NC_GenCol
9747697791
**
9747797792
** In all cases except (4), the Expr.iTable value for Expr.op==TK_COLUMN
9747897793
** nodes of the expression is set to -1 and the Expr.iColumn value is
9747997794
** set to the column number. In case (4), TK_COLUMN nodes cause an error.
9748097795
**
9748197796
** Any errors cause an error message to be set in pParse.
9748297797
*/
9748397798
SQLITE_PRIVATE int sqlite3ResolveSelfReference(
97484
- Parse *pParse, /* Parsing context */
97485
- Table *pTab, /* The table being referenced, or NULL */
97486
- int type, /* NC_IsCheck or NC_PartIdx or NC_IdxExpr, or 0 */
97487
- Expr *pExpr, /* Expression to resolve. May be NULL. */
97488
- ExprList *pList /* Expression list to resolve. May be NULL. */
97799
+ Parse *pParse, /* Parsing context */
97800
+ Table *pTab, /* The table being referenced, or NULL */
97801
+ int type, /* NC_IsCheck, NC_PartIdx, NC_IdxExpr, NC_GenCol, or 0 */
97802
+ Expr *pExpr, /* Expression to resolve. May be NULL. */
97803
+ ExprList *pList /* Expression list to resolve. May be NULL. */
9748997804
){
9749097805
SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
9749197806
NameContext sNC; /* Name context for pParse->pNewTable */
9749297807
int rc;
9749397808
9749497809
assert( type==0 || pTab!=0 );
97495
- assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr || pTab==0 );
97810
+ assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr
97811
+ || type==NC_GenCol || pTab==0 );
9749697812
memset(&sNC, 0, sizeof(sNC));
9749797813
memset(&sSrc, 0, sizeof(sSrc));
9749897814
if( pTab ){
9749997815
sSrc.nSrc = 1;
9750097816
sSrc.a[0].zName = pTab->zName;
@@ -97581,10 +97897,13 @@
9758197897
assert( pExpr->pLeft->flags&EP_xIsSelect );
9758297898
return sqlite3ExprAffinity(
9758397899
pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
9758497900
);
9758597901
}
97902
+ if( op==TK_VECTOR ){
97903
+ return sqlite3ExprAffinity(pExpr->x.pList->a[0].pExpr);
97904
+ }
9758697905
return pExpr->affExpr;
9758797906
}
9758897907
9758997908
/*
9759097909
** Set the collating sequence for expression pExpr to be the collating
@@ -97682,10 +98001,14 @@
9768298001
break;
9768398002
}
9768498003
if( op==TK_CAST || op==TK_UPLUS ){
9768598004
p = p->pLeft;
9768698005
continue;
98006
+ }
98007
+ if( op==TK_VECTOR ){
98008
+ p = p->x.pList->a[0].pExpr;
98009
+ continue;
9768798010
}
9768898011
if( op==TK_COLLATE ){
9768998012
pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken);
9769098013
break;
9769198014
}
@@ -97694,16 +98017,16 @@
9769498017
p = p->pLeft;
9769598018
}else{
9769698019
Expr *pNext = p->pRight;
9769798020
/* The Expr.x union is never used at the same time as Expr.pRight */
9769898021
assert( p->x.pList==0 || p->pRight==0 );
97699
- /* p->flags holds EP_Collate and p->pLeft->flags does not. And
97700
- ** p->x.pSelect cannot. So if p->x.pLeft exists, it must hold at
97701
- ** least one EP_Collate. Thus the following two ALWAYS. */
97702
- if( p->x.pList!=0 && ALWAYS(!ExprHasProperty(p, EP_xIsSelect)) ){
98022
+ if( p->x.pList!=0
98023
+ && !db->mallocFailed
98024
+ && ALWAYS(!ExprHasProperty(p, EP_xIsSelect))
98025
+ ){
9770398026
int i;
97704
- for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){
98027
+ for(i=0; i<p->x.pList->nExpr; i++){
9770598028
if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){
9770698029
pNext = p->x.pList->a[i].pExpr;
9770798030
break;
9770898031
}
9770998032
}
@@ -97846,10 +98169,26 @@
9784698169
pColl = sqlite3ExprCollSeq(pParse, pRight);
9784798170
}
9784898171
}
9784998172
return pColl;
9785098173
}
98174
+
98175
+/* Expresssion p is a comparison operator. Return a collation sequence
98176
+** appropriate for the comparison operator.
98177
+**
98178
+** This is normally just a wrapper around sqlite3BinaryCompareCollSeq().
98179
+** However, if the OP_Commuted flag is set, then the order of the operands
98180
+** is reversed in the sqlite3BinaryCompareCollSeq() call so that the
98181
+** correct collating sequence is found.
98182
+*/
98183
+SQLITE_PRIVATE CollSeq *sqlite3ExprCompareCollSeq(Parse *pParse, Expr *p){
98184
+ if( ExprHasProperty(p, EP_Commuted) ){
98185
+ return sqlite3BinaryCompareCollSeq(pParse, p->pRight, p->pLeft);
98186
+ }else{
98187
+ return sqlite3BinaryCompareCollSeq(pParse, p->pLeft, p->pRight);
98188
+ }
98189
+}
9785198190
9785298191
/*
9785398192
** Generate code for a comparison operator.
9785498193
*/
9785598194
static int codeCompare(
@@ -97857,17 +98196,22 @@
9785798196
Expr *pLeft, /* The left operand */
9785898197
Expr *pRight, /* The right operand */
9785998198
int opcode, /* The comparison opcode */
9786098199
int in1, int in2, /* Register holding operands */
9786198200
int dest, /* Jump here if true. */
97862
- int jumpIfNull /* If true, jump if either operand is NULL */
98201
+ int jumpIfNull, /* If true, jump if either operand is NULL */
98202
+ int isCommuted /* The comparison has been commuted */
9786398203
){
9786498204
int p5;
9786598205
int addr;
9786698206
CollSeq *p4;
9786798207
97868
- p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
98208
+ if( isCommuted ){
98209
+ p4 = sqlite3BinaryCompareCollSeq(pParse, pRight, pLeft);
98210
+ }else{
98211
+ p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
98212
+ }
9786998213
p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
9787098214
addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
9787198215
(void*)p4, P4_COLLSEQ);
9787298216
sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
9787398217
return addr;
@@ -98074,10 +98418,11 @@
9807498418
int i;
9807598419
int regLeft = 0;
9807698420
int regRight = 0;
9807798421
u8 opx = op;
9807898422
int addrDone = sqlite3VdbeMakeLabel(pParse);
98423
+ int isCommuted = ExprHasProperty(pExpr,EP_Commuted);
9807998424
9808098425
if( nLeft!=sqlite3ExprVectorSize(pRight) ){
9808198426
sqlite3ErrorMsg(pParse, "row value misused");
9808298427
return;
9808398428
}
@@ -98103,11 +98448,11 @@
9810398448
Expr *pL, *pR;
9810498449
int r1, r2;
9810598450
assert( i>=0 && i<nLeft );
9810698451
r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);
9810798452
r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);
98108
- codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5);
98453
+ codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5, isCommuted);
9810998454
testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
9811098455
testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
9811198456
testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
9811298457
testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
9811398458
testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
@@ -100878,35 +101223,77 @@
100878101223
sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
100879101224
iTabCol, regOut);
100880101225
}
100881101226
}
100882101227
101228
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
101229
+/*
101230
+** Generate code that will compute the value of generated column pCol
101231
+** and store the result in register regOut
101232
+*/
101233
+SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(
101234
+ Parse *pParse,
101235
+ Column *pCol,
101236
+ int regOut
101237
+){
101238
+ sqlite3ExprCode(pParse, pCol->pDflt, regOut);
101239
+ if( pCol->affinity>=SQLITE_AFF_TEXT ){
101240
+ sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, regOut, 1, 0,
101241
+ &pCol->affinity, 1);
101242
+ }
101243
+}
101244
+#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
101245
+
100883101246
/*
100884101247
** Generate code to extract the value of the iCol-th column of a table.
100885101248
*/
100886101249
SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(
100887
- Vdbe *v, /* The VDBE under construction */
101250
+ Vdbe *v, /* Parsing context */
100888101251
Table *pTab, /* The table containing the value */
100889101252
int iTabCur, /* The table cursor. Or the PK cursor for WITHOUT ROWID */
100890101253
int iCol, /* Index of the column to extract */
100891101254
int regOut /* Extract the value into this register */
100892101255
){
101256
+ Column *pCol;
101257
+ assert( v!=0 );
100893101258
if( pTab==0 ){
100894101259
sqlite3VdbeAddOp3(v, OP_Column, iTabCur, iCol, regOut);
100895101260
return;
100896101261
}
100897101262
if( iCol<0 || iCol==pTab->iPKey ){
100898101263
sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);
100899101264
}else{
100900
- int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;
100901
- int x = iCol;
100902
- if( !HasRowid(pTab) && !IsVirtual(pTab) ){
100903
- x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
101265
+ int op;
101266
+ int x;
101267
+ if( IsVirtual(pTab) ){
101268
+ op = OP_VColumn;
101269
+ x = iCol;
101270
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
101271
+ }else if( (pCol = &pTab->aCol[iCol])->colFlags & COLFLAG_VIRTUAL ){
101272
+ Parse *pParse = sqlite3VdbeParser(v);
101273
+ if( pCol->colFlags & COLFLAG_BUSY ){
101274
+ sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pCol->zName);
101275
+ }else{
101276
+ int savedSelfTab = pParse->iSelfTab;
101277
+ pCol->colFlags |= COLFLAG_BUSY;
101278
+ pParse->iSelfTab = iTabCur+1;
101279
+ sqlite3ExprCodeGeneratedColumn(pParse, pCol, regOut);
101280
+ pParse->iSelfTab = savedSelfTab;
101281
+ pCol->colFlags &= ~COLFLAG_BUSY;
101282
+ }
101283
+ return;
101284
+#endif
101285
+ }else if( !HasRowid(pTab) ){
101286
+ testcase( iCol!=sqlite3TableColumnToStorage(pTab, iCol) );
101287
+ x = sqlite3TableColumnToIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
101288
+ op = OP_Column;
101289
+ }else{
101290
+ x = sqlite3TableColumnToStorage(pTab,iCol);
101291
+ testcase( x!=iCol );
101292
+ op = OP_Column;
100904101293
}
100905101294
sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);
100906
- }
100907
- if( iCol>=0 ){
100908101295
sqlite3ColumnDefault(v, pTab, iCol, regOut);
100909101296
}
100910101297
}
100911101298
100912101299
/*
@@ -100922,15 +101309,14 @@
100922101309
int iColumn, /* Index of the table column */
100923101310
int iTable, /* The cursor pointing to the table */
100924101311
int iReg, /* Store results here */
100925101312
u8 p5 /* P5 value for OP_Column + FLAGS */
100926101313
){
100927
- Vdbe *v = pParse->pVdbe;
100928
- assert( v!=0 );
100929
- sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
101314
+ assert( pParse->pVdbe!=0 );
101315
+ sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pTab, iTable, iColumn, iReg);
100930101316
if( p5 ){
100931
- sqlite3VdbeChangeP5(v, p5);
101317
+ sqlite3VdbeChangeP5(pParse->pVdbe, p5);
100932101318
}
100933101319
return iReg;
100934101320
}
100935101321
100936101322
/*
@@ -101062,23 +101448,50 @@
101062101448
}
101063101449
return iReg;
101064101450
}
101065101451
if( iTab<0 ){
101066101452
if( pParse->iSelfTab<0 ){
101067
- /* Generating CHECK constraints or inserting into partial index */
101068
- assert( pExpr->y.pTab!=0 );
101069
- assert( pExpr->iColumn>=XN_ROWID );
101070
- assert( pExpr->iColumn<pExpr->y.pTab->nCol );
101071
- if( pExpr->iColumn>=0
101072
- && pExpr->y.pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL
101073
- ){
101074
- sqlite3VdbeAddOp2(v, OP_SCopy, pExpr->iColumn - pParse->iSelfTab,
101075
- target);
101453
+ /* Other columns in the same row for CHECK constraints or
101454
+ ** generated columns or for inserting into partial index.
101455
+ ** The row is unpacked into registers beginning at
101456
+ ** 0-(pParse->iSelfTab). The rowid (if any) is in a register
101457
+ ** immediately prior to the first column.
101458
+ */
101459
+ Column *pCol;
101460
+ Table *pTab = pExpr->y.pTab;
101461
+ int iSrc;
101462
+ int iCol = pExpr->iColumn;
101463
+ assert( pTab!=0 );
101464
+ assert( iCol>=XN_ROWID );
101465
+ assert( iCol<pExpr->y.pTab->nCol );
101466
+ if( iCol<0 ){
101467
+ return -1-pParse->iSelfTab;
101468
+ }
101469
+ pCol = pTab->aCol + iCol;
101470
+ testcase( iCol!=sqlite3TableColumnToStorage(pTab,iCol) );
101471
+ iSrc = sqlite3TableColumnToStorage(pTab, iCol) - pParse->iSelfTab;
101472
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
101473
+ if( pCol->colFlags & COLFLAG_GENERATED ){
101474
+ if( pCol->colFlags & COLFLAG_BUSY ){
101475
+ sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"",
101476
+ pCol->zName);
101477
+ return 0;
101478
+ }
101479
+ pCol->colFlags |= COLFLAG_BUSY;
101480
+ if( pCol->colFlags & COLFLAG_NOTAVAIL ){
101481
+ sqlite3ExprCodeGeneratedColumn(pParse, pCol, iSrc);
101482
+ }
101483
+ pCol->colFlags &= ~(COLFLAG_BUSY|COLFLAG_NOTAVAIL);
101484
+ return iSrc;
101485
+ }else
101486
+#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
101487
+ if( pCol->affinity==SQLITE_AFF_REAL ){
101488
+ sqlite3VdbeAddOp2(v, OP_SCopy, iSrc, target);
101076101489
sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
101077101490
return target;
101078101491
}else{
101079
- return pExpr->iColumn - pParse->iSelfTab;
101492
+ return iSrc;
101080101493
}
101081101494
}else{
101082101495
/* Coding an expression that is part of an index where column names
101083101496
** in the index refer to the table to which the index belongs */
101084101497
iTab = pParse->iSelfTab - 1;
@@ -101173,11 +101586,12 @@
101173101586
codeVectorCompare(pParse, pExpr, target, op, p5);
101174101587
}else{
101175101588
r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);
101176101589
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
101177101590
codeCompare(pParse, pLeft, pExpr->pRight, op,
101178
- r1, r2, inReg, SQLITE_STOREP2 | p5);
101591
+ r1, r2, inReg, SQLITE_STOREP2 | p5,
101592
+ ExprHasProperty(pExpr,EP_Commuted));
101179101593
assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
101180101594
assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
101181101595
assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
101182101596
assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
101183101597
assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
@@ -101442,13 +101856,12 @@
101442101856
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
101443101857
}
101444101858
}else
101445101859
#endif
101446101860
{
101447
- sqlite3VdbeAddOp4(v, pParse->iSelfTab ? OP_PureFunc0 : OP_Function0,
101448
- constMask, r1, target, (char*)pDef, P4_FUNCDEF);
101449
- sqlite3VdbeChangeP5(v, (u8)nFarg);
101861
+ sqlite3VdbeAddFunctionCall(pParse, constMask, r1, target, nFarg,
101862
+ pDef, pExpr->op2);
101450101863
}
101451101864
if( nFarg && constMask==0 ){
101452101865
sqlite3ReleaseTempRange(pParse, r1, nFarg);
101453101866
}
101454101867
return target;
@@ -101541,32 +101954,32 @@
101541101954
** p1==0 -> old.rowid p1==3 -> new.rowid
101542101955
** p1==1 -> old.a p1==4 -> new.a
101543101956
** p1==2 -> old.b p1==5 -> new.b
101544101957
*/
101545101958
Table *pTab = pExpr->y.pTab;
101546
- int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;
101959
+ int iCol = pExpr->iColumn;
101960
+ int p1 = pExpr->iTable * (pTab->nCol+1) + 1
101961
+ + (iCol>=0 ? sqlite3TableColumnToStorage(pTab, iCol) : -1);
101547101962
101548101963
assert( pExpr->iTable==0 || pExpr->iTable==1 );
101549
- assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );
101550
- assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );
101964
+ assert( iCol>=-1 && iCol<pTab->nCol );
101965
+ assert( pTab->iPKey<0 || iCol!=pTab->iPKey );
101551101966
assert( p1>=0 && p1<(pTab->nCol*2+2) );
101552101967
101553101968
sqlite3VdbeAddOp2(v, OP_Param, p1, target);
101554101969
VdbeComment((v, "r[%d]=%s.%s", target,
101555101970
(pExpr->iTable ? "new" : "old"),
101556
- (pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[pExpr->iColumn].zName)
101971
+ (pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[iCol].zName)
101557101972
));
101558101973
101559101974
#ifndef SQLITE_OMIT_FLOATING_POINT
101560101975
/* If the column has REAL affinity, it may currently be stored as an
101561101976
** integer. Use OP_RealAffinity to make sure it is really real.
101562101977
**
101563101978
** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to
101564101979
** floating point when extracting it from the record. */
101565
- if( pExpr->iColumn>=0
101566
- && pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL
101567
- ){
101980
+ if( iCol>=0 && pTab->aCol[iCol].affinity==SQLITE_AFF_REAL ){
101568101981
sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
101569101982
}
101570101983
#endif
101571101984
break;
101572101985
}
@@ -101795,18 +102208,14 @@
101795102208
*/
101796102209
SQLITE_PRIVATE void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){
101797102210
int inReg;
101798102211
101799102212
assert( target>0 && target<=pParse->nMem );
101800
- if( pExpr && pExpr->op==TK_REGISTER ){
101801
- sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);
101802
- }else{
101803
- inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
101804
- assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );
101805
- if( inReg!=target && pParse->pVdbe ){
101806
- sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);
101807
- }
102213
+ inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
102214
+ assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );
102215
+ if( inReg!=target && pParse->pVdbe ){
102216
+ sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);
101808102217
}
101809102218
}
101810102219
101811102220
/*
101812102221
** Make a transient copy of expression pExpr and then code it using
@@ -101832,34 +102241,10 @@
101832102241
}else{
101833102242
sqlite3ExprCode(pParse, pExpr, target);
101834102243
}
101835102244
}
101836102245
101837
-/*
101838
-** Generate code that evaluates the given expression and puts the result
101839
-** in register target.
101840
-**
101841
-** Also make a copy of the expression results into another "cache" register
101842
-** and modify the expression so that the next time it is evaluated,
101843
-** the result is a copy of the cache register.
101844
-**
101845
-** This routine is used for expressions that are used multiple
101846
-** times. They are evaluated once and the results of the expression
101847
-** are reused.
101848
-*/
101849
-SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){
101850
- Vdbe *v = pParse->pVdbe;
101851
- int iMem;
101852
-
101853
- assert( target>0 );
101854
- assert( pExpr->op!=TK_REGISTER );
101855
- sqlite3ExprCode(pParse, pExpr, target);
101856
- iMem = ++pParse->nMem;
101857
- sqlite3VdbeAddOp2(v, OP_Copy, target, iMem);
101858
- exprToRegister(pExpr, iMem);
101859
-}
101860
-
101861102246
/*
101862102247
** Generate code that pushes the value of every element of the given
101863102248
** expression list into a sequence of registers beginning at target.
101864102249
**
101865102250
** Return the number of elements evaluated. The number returned will
@@ -102093,11 +102478,11 @@
102093102478
if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
102094102479
testcase( jumpIfNull==0 );
102095102480
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
102096102481
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
102097102482
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
102098
- r1, r2, dest, jumpIfNull);
102483
+ r1, r2, dest, jumpIfNull, ExprHasProperty(pExpr,EP_Commuted));
102099102484
assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
102100102485
assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
102101102486
assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
102102102487
assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
102103102488
assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);
@@ -102268,11 +102653,11 @@
102268102653
if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
102269102654
testcase( jumpIfNull==0 );
102270102655
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
102271102656
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
102272102657
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
102273
- r1, r2, dest, jumpIfNull);
102658
+ r1, r2, dest, jumpIfNull,ExprHasProperty(pExpr,EP_Commuted));
102274102659
assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
102275102660
assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
102276102661
assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
102277102662
assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
102278102663
assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);
@@ -102454,11 +102839,12 @@
102454102839
if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
102455102840
}else if( ALWAYS(pB->u.zToken!=0) && strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
102456102841
return 2;
102457102842
}
102458102843
}
102459
- if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
102844
+ if( (pA->flags & (EP_Distinct|EP_Commuted))
102845
+ != (pB->flags & (EP_Distinct|EP_Commuted)) ) return 2;
102460102846
if( (combinedFlags & EP_TokenOnly)==0 ){
102461102847
if( combinedFlags & EP_xIsSelect ) return 2;
102462102848
if( (combinedFlags & EP_FixedCol)==0
102463102849
&& sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
102464102850
if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
@@ -102466,14 +102852,28 @@
102466102852
if( pA->op!=TK_STRING
102467102853
&& pA->op!=TK_TRUEFALSE
102468102854
&& (combinedFlags & EP_Reduced)==0
102469102855
){
102470102856
if( pA->iColumn!=pB->iColumn ) return 2;
102471
- if( pA->op2!=pB->op2 ) return 2;
102472
- if( pA->op!=TK_IN
102473
- && pA->iTable!=pB->iTable
102474
- && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
102857
+ if( pA->op2!=pB->op2 ){
102858
+ if( pA->op==TK_TRUTH ) return 2;
102859
+ if( pA->op==TK_FUNCTION && iTab<0 ){
102860
+ /* Ex: CREATE TABLE t1(a CHECK( a<julianday('now') ));
102861
+ ** INSERT INTO t1(a) VALUES(julianday('now')+10);
102862
+ ** Without this test, sqlite3ExprCodeAtInit() will run on the
102863
+ ** the julianday() of INSERT first, and remember that expression.
102864
+ ** Then sqlite3ExprCodeInit() will see the julianday() in the CHECK
102865
+ ** constraint as redundant, reusing the one from the INSERT, even
102866
+ ** though the julianday() in INSERT lacks the critical NC_IsCheck
102867
+ ** flag. See ticket [830277d9db6c3ba1] (2019-10-30)
102868
+ */
102869
+ return 2;
102870
+ }
102871
+ }
102872
+ if( pA->op!=TK_IN && pA->iTable!=pB->iTable && pA->iTable!=iTab ){
102873
+ return 2;
102874
+ }
102475102875
}
102476102876
}
102477102877
return 0;
102478102878
}
102479102879
@@ -102636,11 +103036,11 @@
102636103036
}
102637103037
return 0;
102638103038
}
102639103039
102640103040
/*
102641
-** This is the Expr node callback for sqlite3ExprImpliesNotNullRow().
103041
+** This is the Expr node callback for sqlite3ExprImpliesNonNullRow().
102642103042
** If the expression node requires that the table at pWalker->iCur
102643103043
** have one or more non-NULL column, then set pWalker->eCode to 1 and abort.
102644103044
**
102645103045
** This routine controls an optimization. False positives (setting
102646103046
** pWalker->eCode to 1 when it should not be) are deadly, but false-negatives
@@ -102654,34 +103054,39 @@
102654103054
case TK_ISNOT:
102655103055
case TK_ISNULL:
102656103056
case TK_NOTNULL:
102657103057
case TK_IS:
102658103058
case TK_OR:
103059
+ case TK_VECTOR:
102659103060
case TK_CASE:
102660103061
case TK_IN:
102661103062
case TK_FUNCTION:
103063
+ case TK_TRUTH:
102662103064
testcase( pExpr->op==TK_ISNOT );
102663103065
testcase( pExpr->op==TK_ISNULL );
102664103066
testcase( pExpr->op==TK_NOTNULL );
102665103067
testcase( pExpr->op==TK_IS );
102666103068
testcase( pExpr->op==TK_OR );
103069
+ testcase( pExpr->op==TK_VECTOR );
102667103070
testcase( pExpr->op==TK_CASE );
102668103071
testcase( pExpr->op==TK_IN );
102669103072
testcase( pExpr->op==TK_FUNCTION );
103073
+ testcase( pExpr->op==TK_TRUTH );
102670103074
return WRC_Prune;
102671103075
case TK_COLUMN:
102672103076
if( pWalker->u.iCur==pExpr->iTable ){
102673103077
pWalker->eCode = 1;
102674103078
return WRC_Abort;
102675103079
}
102676103080
return WRC_Prune;
102677103081
102678103082
case TK_AND:
102679
- if( sqlite3ExprImpliesNonNullRow(pExpr->pLeft, pWalker->u.iCur)
102680
- && sqlite3ExprImpliesNonNullRow(pExpr->pRight, pWalker->u.iCur)
102681
- ){
102682
- pWalker->eCode = 1;
103083
+ assert( pWalker->eCode==0 );
103084
+ sqlite3WalkExpr(pWalker, pExpr->pLeft);
103085
+ if( pWalker->eCode ){
103086
+ pWalker->eCode = 0;
103087
+ sqlite3WalkExpr(pWalker, pExpr->pRight);
102683103088
}
102684103089
return WRC_Prune;
102685103090
102686103091
case TK_BETWEEN:
102687103092
sqlite3WalkExpr(pWalker, pExpr->pLeft);
@@ -102736,18 +103141,17 @@
102736103141
** ordinary join.
102737103142
*/
102738103143
SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){
102739103144
Walker w;
102740103145
p = sqlite3ExprSkipCollateAndLikely(p);
102741
- while( p ){
102742
- if( p->op==TK_NOTNULL ){
102743
- p = p->pLeft;
102744
- }else if( p->op==TK_AND ){
103146
+ if( p==0 ) return 0;
103147
+ if( p->op==TK_NOTNULL ){
103148
+ p = p->pLeft;
103149
+ }else{
103150
+ while( p->op==TK_AND ){
102745103151
if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1;
102746103152
p = p->pRight;
102747
- }else{
102748
- break;
102749103153
}
102750103154
}
102751103155
w.xExprCallback = impliesNotNullRow;
102752103156
w.xSelectCallback = 0;
102753103157
w.xSelectCallback2 = 0;
@@ -102775,11 +103179,11 @@
102775103179
** pWalker->u.pIdxCover->pIdx.
102776103180
*/
102777103181
static int exprIdxCover(Walker *pWalker, Expr *pExpr){
102778103182
if( pExpr->op==TK_COLUMN
102779103183
&& pExpr->iTable==pWalker->u.pIdxCover->iCur
102780
- && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
103184
+ && sqlite3TableColumnToIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
102781103185
){
102782103186
pWalker->eCode = 1;
102783103187
return WRC_Abort;
102784103188
}
102785103189
return WRC_Continue;
@@ -103201,13 +103605,12 @@
103201103605
** Or, if zName is not a system table, zero is returned.
103202103606
*/
103203103607
static int isAlterableTable(Parse *pParse, Table *pTab){
103204103608
if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7)
103205103609
#ifndef SQLITE_OMIT_VIRTUALTABLE
103206
- || ( (pTab->tabFlags & TF_Shadow)
103207
- && (pParse->db->flags & SQLITE_Defensive)
103208
- && pParse->db->nVdbeExec==0
103610
+ || ( (pTab->tabFlags & TF_Shadow)!=0
103611
+ && sqlite3ReadOnlyShadowTables(pParse->db)
103209103612
)
103210103613
#endif
103211103614
){
103212103615
sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);
103213103616
return 1;
@@ -103468,18 +103871,10 @@
103468103871
if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){
103469103872
return;
103470103873
}
103471103874
#endif
103472103875
103473
- /* If the default value for the new column was specified with a
103474
- ** literal NULL, then set pDflt to 0. This simplifies checking
103475
- ** for an SQL NULL default below.
103476
- */
103477
- assert( pDflt==0 || pDflt->op==TK_SPAN );
103478
- if( pDflt && pDflt->pLeft->op==TK_NULL ){
103479
- pDflt = 0;
103480
- }
103481103876
103482103877
/* Check that the new column is not specified as PRIMARY KEY or UNIQUE.
103483103878
** If there is a NOT NULL constraint, then the default value for the
103484103879
** column must not be NULL.
103485103880
*/
@@ -103489,39 +103884,53 @@
103489103884
}
103490103885
if( pNew->pIndex ){
103491103886
sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");
103492103887
return;
103493103888
}
103494
- if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){
103495
- sqlite3ErrorMsg(pParse,
103496
- "Cannot add a REFERENCES column with non-NULL default value");
103497
- return;
103498
- }
103499
- if( pCol->notNull && !pDflt ){
103500
- sqlite3ErrorMsg(pParse,
103501
- "Cannot add a NOT NULL column with default value NULL");
103502
- return;
103503
- }
103504
-
103505
- /* Ensure the default expression is something that sqlite3ValueFromExpr()
103506
- ** can handle (i.e. not CURRENT_TIME etc.)
103507
- */
103508
- if( pDflt ){
103509
- sqlite3_value *pVal = 0;
103510
- int rc;
103511
- rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal);
103512
- assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
103513
- if( rc!=SQLITE_OK ){
103514
- assert( db->mallocFailed == 1 );
103515
- return;
103516
- }
103517
- if( !pVal ){
103518
- sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default");
103519
- return;
103520
- }
103521
- sqlite3ValueFree(pVal);
103522
- }
103889
+ if( (pCol->colFlags & COLFLAG_GENERATED)==0 ){
103890
+ /* If the default value for the new column was specified with a
103891
+ ** literal NULL, then set pDflt to 0. This simplifies checking
103892
+ ** for an SQL NULL default below.
103893
+ */
103894
+ assert( pDflt==0 || pDflt->op==TK_SPAN );
103895
+ if( pDflt && pDflt->pLeft->op==TK_NULL ){
103896
+ pDflt = 0;
103897
+ }
103898
+ if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){
103899
+ sqlite3ErrorMsg(pParse,
103900
+ "Cannot add a REFERENCES column with non-NULL default value");
103901
+ return;
103902
+ }
103903
+ if( pCol->notNull && !pDflt ){
103904
+ sqlite3ErrorMsg(pParse,
103905
+ "Cannot add a NOT NULL column with default value NULL");
103906
+ return;
103907
+ }
103908
+
103909
+ /* Ensure the default expression is something that sqlite3ValueFromExpr()
103910
+ ** can handle (i.e. not CURRENT_TIME etc.)
103911
+ */
103912
+ if( pDflt ){
103913
+ sqlite3_value *pVal = 0;
103914
+ int rc;
103915
+ rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal);
103916
+ assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
103917
+ if( rc!=SQLITE_OK ){
103918
+ assert( db->mallocFailed == 1 );
103919
+ return;
103920
+ }
103921
+ if( !pVal ){
103922
+ sqlite3ErrorMsg(pParse,"Cannot add a column with non-constant default");
103923
+ return;
103924
+ }
103925
+ sqlite3ValueFree(pVal);
103926
+ }
103927
+ }else if( pCol->colFlags & COLFLAG_STORED ){
103928
+ sqlite3ErrorMsg(pParse, "cannot add a STORED column");
103929
+ return;
103930
+ }
103931
+
103523103932
103524103933
/* Modify the CREATE TABLE statement. */
103525103934
zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);
103526103935
if( zCol ){
103527103936
char *zEnd = &zCol[pColDef->n-1];
@@ -103605,10 +104014,11 @@
103605104014
}
103606104015
if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){
103607104016
goto exit_begin_add_column;
103608104017
}
103609104018
104019
+ sqlite3MayAbort(pParse);
103610104020
assert( pTab->addColOffset>0 );
103611104021
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
103612104022
103613104023
/* Put a copy of the Table struct in Parse.pNewTable for the
103614104024
** sqlite3AddColumn() function and friends to modify. But modify
@@ -104500,10 +104910,15 @@
104500104910
}
104501104911
for(pIdx=sParse.pNewIndex; pIdx; pIdx=pIdx->pNext){
104502104912
sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
104503104913
}
104504104914
}
104915
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
104916
+ for(i=0; i<sParse.pNewTable->nCol; i++){
104917
+ sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt);
104918
+ }
104919
+#endif
104505104920
104506104921
for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
104507104922
for(i=0; i<pFKey->nCol; i++){
104508104923
if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){
104509104924
renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]);
@@ -105757,22 +106172,21 @@
105757106172
0, 0, /* xValue, xInverse */
105758106173
"stat_get", /* zName */
105759106174
{0}
105760106175
};
105761106176
105762
-static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
105763
- assert( regOut!=regStat4 && regOut!=regStat4+1 );
106177
+static void callStatGet(Parse *pParse, int regStat4, int iParam, int regOut){
105764106178
#ifdef SQLITE_ENABLE_STAT4
105765
- sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
106179
+ sqlite3VdbeAddOp2(pParse->pVdbe, OP_Integer, iParam, regStat4+1);
105766106180
#elif SQLITE_DEBUG
105767106181
assert( iParam==STAT_GET_STAT1 );
105768106182
#else
105769106183
UNUSED_PARAMETER( iParam );
105770106184
#endif
105771
- sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4, regOut,
105772
- (char*)&statGetFuncdef, P4_FUNCDEF);
105773
- sqlite3VdbeChangeP5(v, 1 + IsStat4);
106185
+ assert( regOut!=regStat4 && regOut!=regStat4+1 );
106186
+ sqlite3VdbeAddFunctionCall(pParse, 0, regStat4, regOut, 1+IsStat4,
106187
+ &statGetFuncdef, 0);
105774106188
}
105775106189
105776106190
/*
105777106191
** Generate code to do an analysis of all indices associated with
105778106192
** a single table.
@@ -105936,13 +106350,12 @@
105936106350
#ifdef SQLITE_ENABLE_STAT4
105937106351
sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+3);
105938106352
#endif
105939106353
sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1);
105940106354
sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);
105941
- sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4+1, regStat4,
105942
- (char*)&statInitFuncdef, P4_FUNCDEF);
105943
- sqlite3VdbeChangeP5(v, 2+IsStat4);
106355
+ sqlite3VdbeAddFunctionCall(pParse, 0, regStat4+1, regStat4, 2+IsStat4,
106356
+ &statInitFuncdef, 0);
105944106357
105945106358
/* Implementation of the following:
105946106359
**
105947106360
** Rewind csr
105948106361
** if eof(csr) goto end_of_scan;
@@ -106023,27 +106436,26 @@
106023106436
}else{
106024106437
Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
106025106438
int j, k, regKey;
106026106439
regKey = sqlite3GetTempRange(pParse, pPk->nKeyCol);
106027106440
for(j=0; j<pPk->nKeyCol; j++){
106028
- k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);
106441
+ k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[j]);
106029106442
assert( k>=0 && k<pIdx->nColumn );
106030106443
sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, regKey+j);
106031106444
VdbeComment((v, "%s", pTab->aCol[pPk->aiColumn[j]].zName));
106032106445
}
106033106446
sqlite3VdbeAddOp3(v, OP_MakeRecord, regKey, pPk->nKeyCol, regRowid);
106034106447
sqlite3ReleaseTempRange(pParse, regKey, pPk->nKeyCol);
106035106448
}
106036106449
#endif
106037106450
assert( regChng==(regStat4+1) );
106038
- sqlite3VdbeAddOp4(v, OP_Function0, 1, regStat4, regTemp,
106039
- (char*)&statPushFuncdef, P4_FUNCDEF);
106040
- sqlite3VdbeChangeP5(v, 2+IsStat4);
106451
+ sqlite3VdbeAddFunctionCall(pParse, 1, regStat4, regTemp, 2+IsStat4,
106452
+ &statPushFuncdef, 0);
106041106453
sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, addrNextRow); VdbeCoverage(v);
106042106454
106043106455
/* Add the entry to the stat1 table. */
106044
- callStatGet(v, regStat4, STAT_GET_STAT1, regStat1);
106456
+ callStatGet(pParse, regStat4, STAT_GET_STAT1, regStat1);
106045106457
assert( "BBB"[0]==SQLITE_AFF_TEXT );
106046106458
sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, "BBB", 0);
106047106459
sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
106048106460
sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regTemp, regNewRowid);
106049106461
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
@@ -106065,16 +106477,16 @@
106065106477
u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;
106066106478
106067106479
pParse->nMem = MAX(pParse->nMem, regCol+nCol);
106068106480
106069106481
addrNext = sqlite3VdbeCurrentAddr(v);
106070
- callStatGet(v, regStat4, STAT_GET_ROWID, regSampleRowid);
106482
+ callStatGet(pParse, regStat4, STAT_GET_ROWID, regSampleRowid);
106071106483
addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regSampleRowid);
106072106484
VdbeCoverage(v);
106073
- callStatGet(v, regStat4, STAT_GET_NEQ, regEq);
106074
- callStatGet(v, regStat4, STAT_GET_NLT, regLt);
106075
- callStatGet(v, regStat4, STAT_GET_NDLT, regDLt);
106485
+ callStatGet(pParse, regStat4, STAT_GET_NEQ, regEq);
106486
+ callStatGet(pParse, regStat4, STAT_GET_NLT, regLt);
106487
+ callStatGet(pParse, regStat4, STAT_GET_NDLT, regDLt);
106076106488
sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);
106077106489
VdbeCoverage(v);
106078106490
for(i=0; i<nCol; i++){
106079106491
sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
106080106492
}
@@ -106695,13 +107107,13 @@
106695107107
}
106696107108
106697107109
/* Load the statistics from the sqlite_stat4 table. */
106698107110
#ifdef SQLITE_ENABLE_STAT4
106699107111
if( rc==SQLITE_OK ){
106700
- db->lookaside.bDisable++;
107112
+ DisableLookaside;
106701107113
rc = loadStat4(db, sInfo.zDatabase);
106702
- db->lookaside.bDisable--;
107114
+ EnableLookaside;
106703107115
}
106704107116
for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
106705107117
Index *pIdx = sqliteHashData(i);
106706107118
sqlite3_free(pIdx->aiRowEst);
106707107119
pIdx->aiRowEst = 0;
@@ -107120,15 +107532,12 @@
107120107532
sqlite3ExprCode(pParse, pDbname, regArgs+1);
107121107533
sqlite3ExprCode(pParse, pKey, regArgs+2);
107122107534
107123107535
assert( v || db->mallocFailed );
107124107536
if( v ){
107125
- sqlite3VdbeAddOp4(v, OP_Function0, 0, regArgs+3-pFunc->nArg, regArgs+3,
107126
- (char *)pFunc, P4_FUNCDEF);
107127
- assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );
107128
- sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));
107129
-
107537
+ sqlite3VdbeAddFunctionCall(pParse, 0, regArgs+3-pFunc->nArg, regArgs+3,
107538
+ pFunc->nArg, pFunc, 0);
107130107539
/* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this
107131107540
** statement only). For DETACH, set it to false (expire all existing
107132107541
** statements).
107133107542
*/
107134107543
sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));
@@ -108499,17 +108908,18 @@
108499108908
sqlite3ErrorMsg(pParse, ""); /* corruptSchema() will supply the error */
108500108909
return SQLITE_ERROR;
108501108910
}
108502108911
}
108503108912
}else{
108504
- if( pParse->nested==0
108505
- && 0==sqlite3StrNICmp(zName, "sqlite_", 7)
108913
+ if( (pParse->nested==0 && 0==sqlite3StrNICmp(zName, "sqlite_", 7))
108914
+ || (sqlite3ReadOnlyShadowTables(db) && sqlite3ShadowTableName(db, zName))
108506108915
){
108507108916
sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s",
108508108917
zName);
108509108918
return SQLITE_ERROR;
108510108919
}
108920
+
108511108921
}
108512108922
return SQLITE_OK;
108513108923
}
108514108924
108515108925
/*
@@ -108520,20 +108930,98 @@
108520108930
for(p=pTab->pIndex; p && !IsPrimaryKeyIndex(p); p=p->pNext){}
108521108931
return p;
108522108932
}
108523108933
108524108934
/*
108525
-** Return the column of index pIdx that corresponds to table
108526
-** column iCol. Return -1 if not found.
108935
+** Convert an table column number into a index column number. That is,
108936
+** for the column iCol in the table (as defined by the CREATE TABLE statement)
108937
+** find the (first) offset of that column in index pIdx. Or return -1
108938
+** if column iCol is not used in index pIdx.
108527108939
*/
108528
-SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){
108940
+SQLITE_PRIVATE i16 sqlite3TableColumnToIndex(Index *pIdx, i16 iCol){
108529108941
int i;
108530108942
for(i=0; i<pIdx->nColumn; i++){
108531108943
if( iCol==pIdx->aiColumn[i] ) return i;
108532108944
}
108533108945
return -1;
108534108946
}
108947
+
108948
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
108949
+/* Convert a storage column number into a table column number.
108950
+**
108951
+** The storage column number (0,1,2,....) is the index of the value
108952
+** as it appears in the record on disk. The true column number
108953
+** is the index (0,1,2,...) of the column in the CREATE TABLE statement.
108954
+**
108955
+** The storage column number is less than the table column number if
108956
+** and only there are VIRTUAL columns to the left.
108957
+**
108958
+** If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro.
108959
+*/
108960
+SQLITE_PRIVATE i16 sqlite3StorageColumnToTable(Table *pTab, i16 iCol){
108961
+ if( pTab->tabFlags & TF_HasVirtual ){
108962
+ int i;
108963
+ for(i=0; i<=iCol; i++){
108964
+ if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ) iCol++;
108965
+ }
108966
+ }
108967
+ return iCol;
108968
+}
108969
+#endif
108970
+
108971
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
108972
+/* Convert a table column number into a storage column number.
108973
+**
108974
+** The storage column number (0,1,2,....) is the index of the value
108975
+** as it appears in the record on disk. Or, if the input column is
108976
+** the N-th virtual column (zero-based) then the storage number is
108977
+** the number of non-virtual columns in the table plus N.
108978
+**
108979
+** The true column number is the index (0,1,2,...) of the column in
108980
+** the CREATE TABLE statement.
108981
+**
108982
+** If the input column is a VIRTUAL column, then it should not appear
108983
+** in storage. But the value sometimes is cached in registers that
108984
+** follow the range of registers used to construct storage. This
108985
+** avoids computing the same VIRTUAL column multiple times, and provides
108986
+** values for use by OP_Param opcodes in triggers. Hence, if the
108987
+** input column is a VIRTUAL table, put it after all the other columns.
108988
+**
108989
+** In the following, N means "normal column", S means STORED, and
108990
+** V means VIRTUAL. Suppose the CREATE TABLE has columns like this:
108991
+**
108992
+** CREATE TABLE ex(N,S,V,N,S,V,N,S,V);
108993
+** -- 0 1 2 3 4 5 6 7 8
108994
+**
108995
+** Then the mapping from this function is as follows:
108996
+**
108997
+** INPUTS: 0 1 2 3 4 5 6 7 8
108998
+** OUTPUTS: 0 1 6 2 3 7 4 5 8
108999
+**
109000
+** So, in other words, this routine shifts all the virtual columns to
109001
+** the end.
109002
+**
109003
+** If SQLITE_OMIT_GENERATED_COLUMNS then there are no virtual columns and
109004
+** this routine is a no-op macro.
109005
+*/
109006
+SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table *pTab, i16 iCol){
109007
+ int i;
109008
+ i16 n;
109009
+ assert( iCol<pTab->nCol );
109010
+ if( (pTab->tabFlags & TF_HasVirtual)==0 ) return iCol;
109011
+ for(i=0, n=0; i<iCol; i++){
109012
+ if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) n++;
109013
+ }
109014
+ if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ){
109015
+ /* iCol is a virtual column itself */
109016
+ return pTab->nNVCol + i - n;
109017
+ }else{
109018
+ /* iCol is a normal or stored column */
109019
+ return n;
109020
+ }
109021
+}
109022
+#endif
108535109023
108536109024
/*
108537109025
** Begin constructing a new table representation in memory. This is
108538109026
** the first of several action routines that get called in response
108539109027
** to a CREATE TABLE statement. In particular, this routine is called
@@ -108821,10 +109309,11 @@
108821109309
sqlite3Dequote(zType);
108822109310
pCol->affinity = sqlite3AffinityType(zType, pCol);
108823109311
pCol->colFlags |= COLFLAG_HASTYPE;
108824109312
}
108825109313
p->nCol++;
109314
+ p->nNVCol++;
108826109315
pParse->constraintName.n = 0;
108827109316
}
108828109317
108829109318
/*
108830109319
** This routine is called by the parser while in the middle of
@@ -108969,10 +109458,16 @@
108969109458
if( p!=0 ){
108970109459
pCol = &(p->aCol[p->nCol-1]);
108971109460
if( !sqlite3ExprIsConstantOrFunction(pExpr, db->init.busy) ){
108972109461
sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant",
108973109462
pCol->zName);
109463
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
109464
+ }else if( pCol->colFlags & COLFLAG_GENERATED ){
109465
+ testcase( pCol->colFlags & COLFLAG_VIRTUAL );
109466
+ testcase( pCol->colFlags & COLFLAG_STORED );
109467
+ sqlite3ErrorMsg(pParse, "cannot use DEFAULT on a generated column");
109468
+#endif
108974109469
}else{
108975109470
/* A copy of pExpr is used instead of the original, as pExpr contains
108976109471
** tokens that point to volatile memory.
108977109472
*/
108978109473
Expr x;
@@ -109013,10 +109508,25 @@
109013109508
p->op = TK_ID;
109014109509
}else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){
109015109510
p->pLeft->op = TK_ID;
109016109511
}
109017109512
}
109513
+
109514
+/*
109515
+** Tag the given column as being part of the PRIMARY KEY
109516
+*/
109517
+static void makeColumnPartOfPrimaryKey(Parse *pParse, Column *pCol){
109518
+ pCol->colFlags |= COLFLAG_PRIMKEY;
109519
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
109520
+ if( pCol->colFlags & COLFLAG_GENERATED ){
109521
+ testcase( pCol->colFlags & COLFLAG_VIRTUAL );
109522
+ testcase( pCol->colFlags & COLFLAG_STORED );
109523
+ sqlite3ErrorMsg(pParse,
109524
+ "generated columns cannot be part of the PRIMARY KEY");
109525
+ }
109526
+#endif
109527
+}
109018109528
109019109529
/*
109020109530
** Designate the PRIMARY KEY for the table. pList is a list of names
109021109531
** of columns that form the primary key. If pList is NULL, then the
109022109532
** most recently added column of the table is the primary key.
@@ -109053,11 +109563,11 @@
109053109563
}
109054109564
pTab->tabFlags |= TF_HasPrimaryKey;
109055109565
if( pList==0 ){
109056109566
iCol = pTab->nCol - 1;
109057109567
pCol = &pTab->aCol[iCol];
109058
- pCol->colFlags |= COLFLAG_PRIMKEY;
109568
+ makeColumnPartOfPrimaryKey(pParse, pCol);
109059109569
nTerm = 1;
109060109570
}else{
109061109571
nTerm = pList->nExpr;
109062109572
for(i=0; i<nTerm; i++){
109063109573
Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);
@@ -109066,11 +109576,11 @@
109066109576
if( pCExpr->op==TK_ID ){
109067109577
const char *zCName = pCExpr->u.zToken;
109068109578
for(iCol=0; iCol<pTab->nCol; iCol++){
109069109579
if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){
109070109580
pCol = &pTab->aCol[iCol];
109071
- pCol->colFlags |= COLFLAG_PRIMKEY;
109581
+ makeColumnPartOfPrimaryKey(pParse, pCol);
109072109582
break;
109073109583
}
109074109584
}
109075109585
}
109076109586
}
@@ -109163,44 +109673,58 @@
109163109673
}else{
109164109674
sqlite3DbFree(db, zColl);
109165109675
}
109166109676
}
109167109677
109168
-/*
109169
-** This function returns the collation sequence for database native text
109170
-** encoding identified by the string zName, length nName.
109171
-**
109172
-** If the requested collation sequence is not available, or not available
109173
-** in the database native encoding, the collation factory is invoked to
109174
-** request it. If the collation factory does not supply such a sequence,
109175
-** and the sequence is available in another text encoding, then that is
109176
-** returned instead.
109177
-**
109178
-** If no versions of the requested collations sequence are available, or
109179
-** another error occurs, NULL is returned and an error message written into
109180
-** pParse.
109181
-**
109182
-** This routine is a wrapper around sqlite3FindCollSeq(). This routine
109183
-** invokes the collation factory if the named collation cannot be found
109184
-** and generates an error message.
109185
-**
109186
-** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq()
109678
+/* Change the most recently parsed column to be a GENERATED ALWAYS AS
109679
+** column.
109187109680
*/
109188
-SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){
109189
- sqlite3 *db = pParse->db;
109190
- u8 enc = ENC(db);
109191
- u8 initbusy = db->init.busy;
109192
- CollSeq *pColl;
109193
-
109194
- pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);
109195
- if( !initbusy && (!pColl || !pColl->xCmp) ){
109196
- pColl = sqlite3GetCollSeq(pParse, enc, pColl, zName);
109197
- }
109198
-
109199
- return pColl;
109200
-}
109201
-
109681
+SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){
109682
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
109683
+ u8 eType = COLFLAG_VIRTUAL;
109684
+ Table *pTab = pParse->pNewTable;
109685
+ Column *pCol;
109686
+ if( NEVER(pTab==0) ) goto generated_done;
109687
+ pCol = &(pTab->aCol[pTab->nCol-1]);
109688
+ if( IN_DECLARE_VTAB ){
109689
+ sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns");
109690
+ goto generated_done;
109691
+ }
109692
+ if( pCol->pDflt ) goto generated_error;
109693
+ if( pType ){
109694
+ if( pType->n==7 && sqlite3StrNICmp("virtual",pType->z,7)==0 ){
109695
+ /* no-op */
109696
+ }else if( pType->n==6 && sqlite3StrNICmp("stored",pType->z,6)==0 ){
109697
+ eType = COLFLAG_STORED;
109698
+ }else{
109699
+ goto generated_error;
109700
+ }
109701
+ }
109702
+ if( eType==COLFLAG_VIRTUAL ) pTab->nNVCol--;
109703
+ pCol->colFlags |= eType;
109704
+ assert( TF_HasVirtual==COLFLAG_VIRTUAL );
109705
+ assert( TF_HasStored==COLFLAG_STORED );
109706
+ pTab->tabFlags |= eType;
109707
+ if( pCol->colFlags & COLFLAG_PRIMKEY ){
109708
+ makeColumnPartOfPrimaryKey(pParse, pCol); /* For the error message */
109709
+ }
109710
+ pCol->pDflt = pExpr;
109711
+ pExpr = 0;
109712
+ goto generated_done;
109713
+
109714
+generated_error:
109715
+ sqlite3ErrorMsg(pParse, "error in generated column \"%s\"",
109716
+ pCol->zName);
109717
+generated_done:
109718
+ sqlite3ExprDelete(pParse->db, pExpr);
109719
+#else
109720
+ /* Throw and error for the GENERATED ALWAYS AS clause if the
109721
+ ** SQLITE_OMIT_GENERATED_COLUMNS compile-time option is used. */
109722
+ sqlite3ErrorMsg(pParse, "generated columns not supported");
109723
+ sqlite3ExprDelete(pParse->db, pExpr);
109724
+#endif
109725
+}
109202109726
109203109727
/*
109204109728
** Generate code that will increment the schema cookie.
109205109729
**
109206109730
** The schema cookie is used to determine when the schema for the
@@ -109454,20 +109978,29 @@
109454109978
**
109455109979
** colNotIdxed is a bitmask that has a 0 bit representing each indexed
109456109980
** columns that are within the first 63 columns of the table. The
109457109981
** high-order bit of colNotIdxed is always 1. All unindexed columns
109458109982
** of the table have a 1.
109983
+**
109984
+** 2019-10-24: For the purpose of this computation, virtual columns are
109985
+** not considered to be covered by the index, even if they are in the
109986
+** index, because we do not trust the logic in whereIndexExprTrans() to be
109987
+** able to find all instances of a reference to the indexed table column
109988
+** and convert them into references to the index. Hence we always want
109989
+** the actual table at hand in order to recompute the virtual column, if
109990
+** necessary.
109459109991
**
109460109992
** The colNotIdxed mask is AND-ed with the SrcList.a[].colUsed mask
109461109993
** to determine if the index is covering index.
109462109994
*/
109463109995
static void recomputeColumnsNotIndexed(Index *pIdx){
109464109996
Bitmask m = 0;
109465109997
int j;
109998
+ Table *pTab = pIdx->pTable;
109466109999
for(j=pIdx->nColumn-1; j>=0; j--){
109467110000
int x = pIdx->aiColumn[j];
109468
- if( x>=0 ){
110001
+ if( x>=0 && (pTab->aCol[x].colFlags & COLFLAG_VIRTUAL)==0 ){
109469110002
testcase( x==BMS-1 );
109470110003
testcase( x==BMS-2 );
109471110004
if( x<BMS-1 ) m |= MASKBIT(x);
109472110005
}
109473110006
}
@@ -109514,10 +110047,11 @@
109514110047
for(i=0; i<pTab->nCol; i++){
109515110048
if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){
109516110049
pTab->aCol[i].notNull = OE_Abort;
109517110050
}
109518110051
}
110052
+ pTab->tabFlags |= TF_HasNotNull;
109519110053
}
109520110054
109521110055
/* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY
109522110056
** into BTREE_BLOBKEY.
109523110057
*/
@@ -109621,23 +110155,26 @@
109621110155
109622110156
/* Add all table columns to the PRIMARY KEY index
109623110157
*/
109624110158
nExtra = 0;
109625110159
for(i=0; i<pTab->nCol; i++){
109626
- if( !hasColumn(pPk->aiColumn, nPk, i) ) nExtra++;
110160
+ if( !hasColumn(pPk->aiColumn, nPk, i)
110161
+ && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) nExtra++;
109627110162
}
109628110163
if( resizeIndexObject(db, pPk, nPk+nExtra) ) return;
109629110164
for(i=0, j=nPk; i<pTab->nCol; i++){
109630
- if( !hasColumn(pPk->aiColumn, j, i) ){
110165
+ if( !hasColumn(pPk->aiColumn, j, i)
110166
+ && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0
110167
+ ){
109631110168
assert( j<pPk->nColumn );
109632110169
pPk->aiColumn[j] = i;
109633110170
pPk->azColl[j] = sqlite3StrBINARY;
109634110171
j++;
109635110172
}
109636110173
}
109637110174
assert( pPk->nColumn==j );
109638
- assert( pTab->nCol<=j );
110175
+ assert( pTab->nNVCol<=j );
109639110176
recomputeColumnsNotIndexed(pPk);
109640110177
}
109641110178
109642110179
#ifndef SQLITE_OMIT_VIRTUALTABLE
109643110180
/*
@@ -109645,11 +110182,11 @@
109645110182
** connection.
109646110183
**
109647110184
** zName is temporarily modified while this routine is running, but is
109648110185
** restored to its original value prior to this routine returning.
109649110186
*/
109650
-static int isShadowTableName(sqlite3 *db, char *zName){
110187
+SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName){
109651110188
char *zTail; /* Pointer to the last "_" in zName */
109652110189
Table *pTab; /* Table that zName is a shadow of */
109653110190
Module *pMod; /* Module for the virtual table */
109654110191
109655110192
zTail = strrchr(zName, '_');
@@ -109663,12 +110200,10 @@
109663110200
if( pMod==0 ) return 0;
109664110201
if( pMod->pModule->iVersion<3 ) return 0;
109665110202
if( pMod->pModule->xShadowName==0 ) return 0;
109666110203
return pMod->pModule->xShadowName(zTail+1);
109667110204
}
109668
-#else
109669
-# define isShadowTableName(x,y) 0
109670110205
#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
109671110206
109672110207
/*
109673110208
** This routine is called to report the final ")" that terminates
109674110209
** a CREATE TABLE statement.
@@ -109706,11 +110241,11 @@
109706110241
}
109707110242
assert( !db->mallocFailed );
109708110243
p = pParse->pNewTable;
109709110244
if( p==0 ) return;
109710110245
109711
- if( pSelect==0 && isShadowTableName(db, p->zName) ){
110246
+ if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){
109712110247
p->tabFlags |= TF_Shadow;
109713110248
}
109714110249
109715110250
/* If the db->init.busy is 1 it means we are reading the SQL off the
109716110251
** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -109742,25 +110277,46 @@
109742110277
"AUTOINCREMENT not allowed on WITHOUT ROWID tables");
109743110278
return;
109744110279
}
109745110280
if( (p->tabFlags & TF_HasPrimaryKey)==0 ){
109746110281
sqlite3ErrorMsg(pParse, "PRIMARY KEY missing on table %s", p->zName);
109747
- }else{
109748
- p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;
109749
- convertToWithoutRowidTable(pParse, p);
110282
+ return;
109750110283
}
110284
+ p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;
110285
+ convertToWithoutRowidTable(pParse, p);
109751110286
}
109752
-
109753110287
iDb = sqlite3SchemaToIndex(db, p->pSchema);
109754110288
109755110289
#ifndef SQLITE_OMIT_CHECK
109756110290
/* Resolve names in all CHECK constraint expressions.
109757110291
*/
109758110292
if( p->pCheck ){
109759110293
sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
109760110294
}
109761110295
#endif /* !defined(SQLITE_OMIT_CHECK) */
110296
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
110297
+ if( p->tabFlags & TF_HasGenerated ){
110298
+ int ii, nNG = 0;
110299
+ testcase( p->tabFlags & TF_HasVirtual );
110300
+ testcase( p->tabFlags & TF_HasStored );
110301
+ for(ii=0; ii<p->nCol; ii++){
110302
+ u32 colFlags = p->aCol[ii].colFlags;
110303
+ if( (colFlags & COLFLAG_GENERATED)!=0 ){
110304
+ testcase( colFlags & COLFLAG_VIRTUAL );
110305
+ testcase( colFlags & COLFLAG_STORED );
110306
+ sqlite3ResolveSelfReference(pParse, p, NC_GenCol,
110307
+ p->aCol[ii].pDflt, 0);
110308
+ }else{
110309
+ nNG++;
110310
+ }
110311
+ }
110312
+ if( nNG==0 ){
110313
+ sqlite3ErrorMsg(pParse, "must have at least one non-generated column");
110314
+ return;
110315
+ }
110316
+ }
110317
+#endif
109762110318
109763110319
/* Estimate the average row size for the table and for all implied indices */
109764110320
estimateTableWidth(p);
109765110321
for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
109766110322
estimateIndexWidth(pIdx);
@@ -109833,11 +110389,11 @@
109833110389
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
109834110390
if( pParse->nErr ) return;
109835110391
pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect, SQLITE_AFF_BLOB);
109836110392
if( pSelTab==0 ) return;
109837110393
assert( p->aCol==0 );
109838
- p->nCol = pSelTab->nCol;
110394
+ p->nCol = p->nNVCol = pSelTab->nCol;
109839110395
p->aCol = pSelTab->aCol;
109840110396
pSelTab->nCol = 0;
109841110397
pSelTab->aCol = 0;
109842110398
sqlite3DeleteTable(db, pSelTab);
109843110399
sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
@@ -109905,11 +110461,10 @@
109905110461
109906110462
/* Reparse everything to update our internal data structures */
109907110463
sqlite3VdbeAddParseSchemaOp(v, iDb,
109908110464
sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName));
109909110465
}
109910
-
109911110466
109912110467
/* Add the table to the in-memory representation of the database.
109913110468
*/
109914110469
if( db->init.busy ){
109915110470
Table *pOld;
@@ -110090,11 +110645,11 @@
110090110645
pParse->eParseMode = PARSE_MODE_NORMAL;
110091110646
#endif
110092110647
n = pParse->nTab;
110093110648
sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
110094110649
pTable->nCol = -1;
110095
- db->lookaside.bDisable++;
110650
+ DisableLookaside;
110096110651
#ifndef SQLITE_OMIT_AUTHORIZATION
110097110652
xAuth = db->xAuth;
110098110653
db->xAuth = 0;
110099110654
pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE);
110100110655
db->xAuth = xAuth;
@@ -110130,13 +110685,14 @@
110130110685
assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );
110131110686
}else{
110132110687
pTable->nCol = 0;
110133110688
nErr++;
110134110689
}
110690
+ pTable->nNVCol = pTable->nCol;
110135110691
sqlite3DeleteTable(db, pSelTab);
110136110692
sqlite3SelectDelete(db, pSel);
110137
- db->lookaside.bDisable--;
110693
+ EnableLookaside;
110138110694
#ifndef SQLITE_OMIT_ALTERTABLE
110139110695
pParse->eParseMode = eParseMode;
110140110696
#endif
110141110697
} else {
110142110698
nErr++;
@@ -110388,10 +110944,41 @@
110388110944
}
110389110945
sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
110390110946
sqlite3ChangeCookie(pParse, iDb);
110391110947
sqliteViewResetAll(db, iDb);
110392110948
}
110949
+
110950
+/*
110951
+** Return TRUE if shadow tables should be read-only in the current
110952
+** context.
110953
+*/
110954
+SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db){
110955
+#ifndef SQLITE_OMIT_VIRTUALTABLE
110956
+ if( (db->flags & SQLITE_Defensive)!=0
110957
+ && db->pVtabCtx==0
110958
+ && db->nVdbeExec==0
110959
+ ){
110960
+ return 1;
110961
+ }
110962
+#endif
110963
+ return 0;
110964
+}
110965
+
110966
+/*
110967
+** Return true if it is not allowed to drop the given table
110968
+*/
110969
+static int tableMayNotBeDropped(sqlite3 *db, Table *pTab){
110970
+ if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){
110971
+ if( sqlite3StrNICmp(pTab->zName+7, "stat", 4)==0 ) return 0;
110972
+ if( sqlite3StrNICmp(pTab->zName+7, "parameters", 10)==0 ) return 0;
110973
+ return 1;
110974
+ }
110975
+ if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){
110976
+ return 1;
110977
+ }
110978
+ return 0;
110979
+}
110393110980
110394110981
/*
110395110982
** This routine is called to do the work of a DROP TABLE statement.
110396110983
** pName is the name of the table to be dropped.
110397110984
*/
@@ -110458,13 +111045,11 @@
110458111045
if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){
110459111046
goto exit_drop_table;
110460111047
}
110461111048
}
110462111049
#endif
110463
- if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
110464
- && sqlite3StrNICmp(pTab->zName+7, "stat", 4)!=0
110465
- && sqlite3StrNICmp(pTab->zName+7, "parameters", 10)!=0 ){
111050
+ if( tableMayNotBeDropped(db, pTab) ){
110466111051
sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab->zName);
110467111052
goto exit_drop_table;
110468111053
}
110469111054
110470111055
#ifndef SQLITE_OMIT_VIEW
@@ -111131,12 +111716,17 @@
111131111716
}else{
111132111717
j = pCExpr->iColumn;
111133111718
assert( j<=0x7fff );
111134111719
if( j<0 ){
111135111720
j = pTab->iPKey;
111136
- }else if( pTab->aCol[j].notNull==0 ){
111137
- pIndex->uniqNotNull = 0;
111721
+ }else{
111722
+ if( pTab->aCol[j].notNull==0 ){
111723
+ pIndex->uniqNotNull = 0;
111724
+ }
111725
+ if( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL ){
111726
+ pIndex->bHasVCol = 1;
111727
+ }
111138111728
}
111139111729
pIndex->aiColumn[i] = (i16)j;
111140111730
}
111141111731
zColl = 0;
111142111732
if( pListItem->pExpr->op==TK_COLLATE ){
@@ -111187,17 +111777,17 @@
111187111777
if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);
111188111778
111189111779
/* If this index contains every column of its table, then mark
111190111780
** it as a covering index */
111191111781
assert( HasRowid(pTab)
111192
- || pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 );
111782
+ || pTab->iPKey<0 || sqlite3TableColumnToIndex(pIndex, pTab->iPKey)>=0 );
111193111783
recomputeColumnsNotIndexed(pIndex);
111194111784
if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){
111195111785
pIndex->isCovering = 1;
111196111786
for(j=0; j<pTab->nCol; j++){
111197111787
if( j==pTab->iPKey ) continue;
111198
- if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue;
111788
+ if( sqlite3TableColumnToIndex(pIndex,j)>=0 ) continue;
111199111789
pIndex->isCovering = 0;
111200111790
break;
111201111791
}
111202111792
}
111203111793
@@ -112533,55 +113123,10 @@
112533113123
}
112534113124
}
112535113125
return SQLITE_ERROR;
112536113126
}
112537113127
112538
-/*
112539
-** This function is responsible for invoking the collation factory callback
112540
-** or substituting a collation sequence of a different encoding when the
112541
-** requested collation sequence is not available in the desired encoding.
112542
-**
112543
-** If it is not NULL, then pColl must point to the database native encoding
112544
-** collation sequence with name zName, length nName.
112545
-**
112546
-** The return value is either the collation sequence to be used in database
112547
-** db for collation type name zName, length nName, or NULL, if no collation
112548
-** sequence can be found. If no collation is found, leave an error message.
112549
-**
112550
-** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()
112551
-*/
112552
-SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(
112553
- Parse *pParse, /* Parsing context */
112554
- u8 enc, /* The desired encoding for the collating sequence */
112555
- CollSeq *pColl, /* Collating sequence with native encoding, or NULL */
112556
- const char *zName /* Collating sequence name */
112557
-){
112558
- CollSeq *p;
112559
- sqlite3 *db = pParse->db;
112560
-
112561
- p = pColl;
112562
- if( !p ){
112563
- p = sqlite3FindCollSeq(db, enc, zName, 0);
112564
- }
112565
- if( !p || !p->xCmp ){
112566
- /* No collation sequence of this type for this encoding is registered.
112567
- ** Call the collation factory to see if it can supply us with one.
112568
- */
112569
- callCollNeeded(db, enc, zName);
112570
- p = sqlite3FindCollSeq(db, enc, zName, 0);
112571
- }
112572
- if( p && !p->xCmp && synthCollSeq(db, p) ){
112573
- p = 0;
112574
- }
112575
- assert( !p || p->xCmp );
112576
- if( p==0 ){
112577
- sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
112578
- pParse->rc = SQLITE_ERROR_MISSING_COLLSEQ;
112579
- }
112580
- return p;
112581
-}
112582
-
112583113128
/*
112584113129
** This routine is called on a collation sequence before it is used to
112585113130
** check that it is defined. An undefined collation sequence exists when
112586113131
** a database is loaded that contains references to collation sequences
112587113132
** that have not been defined by sqlite3_create_collation() etc.
@@ -112670,14 +113215,14 @@
112670113215
** cannot be found.
112671113216
**
112672113217
** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq()
112673113218
*/
112674113219
SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(
112675
- sqlite3 *db,
112676
- u8 enc,
112677
- const char *zName,
112678
- int create
113220
+ sqlite3 *db, /* Database connection to search */
113221
+ u8 enc, /* Desired text encoding */
113222
+ const char *zName, /* Name of the collating sequence. Might be NULL */
113223
+ int create /* True to create CollSeq if doesn't already exist */
112679113224
){
112680113225
CollSeq *pColl;
112681113226
if( zName ){
112682113227
pColl = findCollSeqEntry(db, zName, create);
112683113228
}else{
@@ -112684,10 +113229,89 @@
112684113229
pColl = db->pDfltColl;
112685113230
}
112686113231
assert( SQLITE_UTF8==1 && SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
112687113232
assert( enc>=SQLITE_UTF8 && enc<=SQLITE_UTF16BE );
112688113233
if( pColl ) pColl += enc-1;
113234
+ return pColl;
113235
+}
113236
+
113237
+/*
113238
+** This function is responsible for invoking the collation factory callback
113239
+** or substituting a collation sequence of a different encoding when the
113240
+** requested collation sequence is not available in the desired encoding.
113241
+**
113242
+** If it is not NULL, then pColl must point to the database native encoding
113243
+** collation sequence with name zName, length nName.
113244
+**
113245
+** The return value is either the collation sequence to be used in database
113246
+** db for collation type name zName, length nName, or NULL, if no collation
113247
+** sequence can be found. If no collation is found, leave an error message.
113248
+**
113249
+** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()
113250
+*/
113251
+SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(
113252
+ Parse *pParse, /* Parsing context */
113253
+ u8 enc, /* The desired encoding for the collating sequence */
113254
+ CollSeq *pColl, /* Collating sequence with native encoding, or NULL */
113255
+ const char *zName /* Collating sequence name */
113256
+){
113257
+ CollSeq *p;
113258
+ sqlite3 *db = pParse->db;
113259
+
113260
+ p = pColl;
113261
+ if( !p ){
113262
+ p = sqlite3FindCollSeq(db, enc, zName, 0);
113263
+ }
113264
+ if( !p || !p->xCmp ){
113265
+ /* No collation sequence of this type for this encoding is registered.
113266
+ ** Call the collation factory to see if it can supply us with one.
113267
+ */
113268
+ callCollNeeded(db, enc, zName);
113269
+ p = sqlite3FindCollSeq(db, enc, zName, 0);
113270
+ }
113271
+ if( p && !p->xCmp && synthCollSeq(db, p) ){
113272
+ p = 0;
113273
+ }
113274
+ assert( !p || p->xCmp );
113275
+ if( p==0 ){
113276
+ sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
113277
+ pParse->rc = SQLITE_ERROR_MISSING_COLLSEQ;
113278
+ }
113279
+ return p;
113280
+}
113281
+
113282
+/*
113283
+** This function returns the collation sequence for database native text
113284
+** encoding identified by the string zName.
113285
+**
113286
+** If the requested collation sequence is not available, or not available
113287
+** in the database native encoding, the collation factory is invoked to
113288
+** request it. If the collation factory does not supply such a sequence,
113289
+** and the sequence is available in another text encoding, then that is
113290
+** returned instead.
113291
+**
113292
+** If no versions of the requested collations sequence are available, or
113293
+** another error occurs, NULL is returned and an error message written into
113294
+** pParse.
113295
+**
113296
+** This routine is a wrapper around sqlite3FindCollSeq(). This routine
113297
+** invokes the collation factory if the named collation cannot be found
113298
+** and generates an error message.
113299
+**
113300
+** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq()
113301
+*/
113302
+SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){
113303
+ sqlite3 *db = pParse->db;
113304
+ u8 enc = ENC(db);
113305
+ u8 initbusy = db->init.busy;
113306
+ CollSeq *pColl;
113307
+
113308
+ pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);
113309
+ if( !initbusy && (!pColl || !pColl->xCmp) ){
113310
+ pColl = sqlite3GetCollSeq(pParse, enc, pColl, zName);
113311
+ }
113312
+
112689113313
return pColl;
112690113314
}
112691113315
112692113316
/* During the search for the best function definition, this procedure
112693113317
** is called to test how well the function passed as the first argument
@@ -113029,15 +113653,11 @@
113029113653
db = pParse->db;
113030113654
if( (pTab->tabFlags & TF_Readonly)!=0 ){
113031113655
return sqlite3WritableSchema(db)==0 && pParse->nested==0;
113032113656
}
113033113657
assert( pTab->tabFlags & TF_Shadow );
113034
- return (db->flags & SQLITE_Defensive)!=0
113035
-#ifndef SQLITE_OMIT_VIRTUALTABLE
113036
- && db->pVtabCtx==0
113037
-#endif
113038
- && db->nVdbeExec==0;
113658
+ return sqlite3ReadOnlyShadowTables(db);
113039113659
}
113040113660
113041113661
/*
113042113662
** Check to make sure the given table is writable. If it is not
113043113663
** writable, generate an error message and return 1. If it is
@@ -113696,11 +114316,12 @@
113696114316
sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);
113697114317
for(iCol=0; iCol<pTab->nCol; iCol++){
113698114318
testcase( mask!=0xffffffff && iCol==31 );
113699114319
testcase( mask!=0xffffffff && iCol==32 );
113700114320
if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){
113701
- sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1);
114321
+ int kk = sqlite3TableColumnToStorage(pTab, iCol);
114322
+ sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+kk+1);
113702114323
}
113703114324
}
113704114325
113705114326
/* Invoke BEFORE DELETE trigger programs. */
113706114327
addrStart = sqlite3VdbeCurrentAddr(v);
@@ -113876,10 +114497,12 @@
113876114497
*piPartIdxLabel = sqlite3VdbeMakeLabel(pParse);
113877114498
pParse->iSelfTab = iDataCur + 1;
113878114499
sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
113879114500
SQLITE_JUMPIFNULL);
113880114501
pParse->iSelfTab = 0;
114502
+ pPrior = 0; /* Ticket a9efb42811fa41ee 2019-11-02;
114503
+ ** pPartIdxWhere may have corrupted regPrior registers */
113881114504
}else{
113882114505
*piPartIdxLabel = 0;
113883114506
}
113884114507
}
113885114508
nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;
@@ -116304,11 +116927,11 @@
116304116927
if( nIncr<0 ){
116305116928
sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, iOk);
116306116929
VdbeCoverage(v);
116307116930
}
116308116931
for(i=0; i<pFKey->nCol; i++){
116309
- int iReg = aiCol[i] + regData + 1;
116932
+ int iReg = sqlite3TableColumnToStorage(pFKey->pFrom,aiCol[i]) + regData + 1;
116310116933
sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk); VdbeCoverage(v);
116311116934
}
116312116935
116313116936
if( isIgnore==0 ){
116314116937
if( pIdx==0 ){
@@ -116320,11 +116943,12 @@
116320116943
/* Invoke MustBeInt to coerce the child key value to an integer (i.e.
116321116944
** apply the affinity of the parent key). If this fails, then there
116322116945
** is no matching parent key. Before using MustBeInt, make a copy of
116323116946
** the value. Otherwise, the value inserted into the child key column
116324116947
** will have INTEGER affinity applied to it, which may not be correct. */
116325
- sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0]+1+regData, regTemp);
116948
+ sqlite3VdbeAddOp2(v, OP_SCopy,
116949
+ sqlite3TableColumnToStorage(pFKey->pFrom,aiCol[0])+1+regData, regTemp);
116326116950
iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0);
116327116951
VdbeCoverage(v);
116328116952
116329116953
/* If the parent table is the same as the child table, and we are about
116330116954
** to increment the constraint-counter (i.e. this is an INSERT operation),
@@ -116347,11 +116971,13 @@
116347116971
int regRec = sqlite3GetTempReg(pParse);
116348116972
116349116973
sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);
116350116974
sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
116351116975
for(i=0; i<nCol; i++){
116352
- sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i]+1+regData, regTemp+i);
116976
+ sqlite3VdbeAddOp2(v, OP_Copy,
116977
+ sqlite3TableColumnToStorage(pFKey->pFrom, aiCol[i])+1+regData,
116978
+ regTemp+i);
116353116979
}
116354116980
116355116981
/* If the parent table is the same as the child table, and we are about
116356116982
** to increment the constraint-counter (i.e. this is an INSERT operation),
116357116983
** then check if the row being inserted matches itself. If so, do not
@@ -116363,12 +116989,15 @@
116363116989
** none of the child key values are).
116364116990
*/
116365116991
if( pTab==pFKey->pFrom && nIncr==1 ){
116366116992
int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1;
116367116993
for(i=0; i<nCol; i++){
116368
- int iChild = aiCol[i]+1+regData;
116369
- int iParent = pIdx->aiColumn[i]+1+regData;
116994
+ int iChild = sqlite3TableColumnToStorage(pFKey->pFrom,aiCol[i])
116995
+ +1+regData;
116996
+ int iParent = 1+regData;
116997
+ iParent += sqlite3TableColumnToStorage(pIdx->pTable,
116998
+ pIdx->aiColumn[i]);
116370116999
assert( pIdx->aiColumn[i]>=0 );
116371117000
assert( aiCol[i]!=pTab->iPKey );
116372117001
if( pIdx->aiColumn[i]==pTab->iPKey ){
116373117002
/* The parent key is a composite key that includes the IPK column */
116374117003
iParent = regData;
@@ -116432,11 +117061,11 @@
116432117061
116433117062
pExpr = sqlite3Expr(db, TK_REGISTER, 0);
116434117063
if( pExpr ){
116435117064
if( iCol>=0 && iCol!=pTab->iPKey ){
116436117065
pCol = &pTab->aCol[iCol];
116437
- pExpr->iTable = regBase + iCol + 1;
117066
+ pExpr->iTable = regBase + sqlite3TableColumnToStorage(pTab,iCol) + 1;
116438117067
pExpr->affExpr = pCol->affinity;
116439117068
zColl = pCol->zColl;
116440117069
if( zColl==0 ) zColl = db->pDfltColl->zName;
116441117070
pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl);
116442117071
}else{
@@ -116881,11 +117510,13 @@
116881117510
** FK counter for each row of the current table with non-NULL keys.
116882117511
*/
116883117512
Vdbe *v = sqlite3GetVdbe(pParse);
116884117513
int iJump = sqlite3VdbeCurrentAddr(v) + pFKey->nCol + 1;
116885117514
for(i=0; i<pFKey->nCol; i++){
116886
- int iReg = pFKey->aCol[i].iFrom + regOld + 1;
117515
+ int iFromCol, iReg;
117516
+ iFromCol = pFKey->aCol[i].iFrom;
117517
+ iReg = sqlite3TableColumnToStorage(pFKey->pFrom,iFromCol) + regOld+1;
116887117518
sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iJump); VdbeCoverage(v);
116888117519
}
116889117520
sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, -1);
116890117521
}
116891117522
continue;
@@ -117216,11 +117847,19 @@
117216117847
if( action==OE_Cascade ){
117217117848
pNew = sqlite3PExpr(pParse, TK_DOT,
117218117849
sqlite3ExprAlloc(db, TK_ID, &tNew, 0),
117219117850
sqlite3ExprAlloc(db, TK_ID, &tToCol, 0));
117220117851
}else if( action==OE_SetDflt ){
117221
- Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;
117852
+ Column *pCol = pFKey->pFrom->aCol + iFromCol;
117853
+ Expr *pDflt;
117854
+ if( pCol->colFlags & COLFLAG_GENERATED ){
117855
+ testcase( pCol->colFlags & COLFLAG_VIRTUAL );
117856
+ testcase( pCol->colFlags & COLFLAG_STORED );
117857
+ pDflt = 0;
117858
+ }else{
117859
+ pDflt = pCol->pDflt;
117860
+ }
117222117861
if( pDflt ){
117223117862
pNew = sqlite3ExprDup(db, pDflt, 0);
117224117863
}else{
117225117864
pNew = sqlite3ExprAlloc(db, TK_NULL, 0, 0);
117226117865
}
@@ -117254,11 +117893,11 @@
117254117893
);
117255117894
pWhere = 0;
117256117895
}
117257117896
117258117897
/* Disable lookaside memory allocation */
117259
- db->lookaside.bDisable++;
117898
+ DisableLookaside;
117260117899
117261117900
pTrigger = (Trigger *)sqlite3DbMallocZero(db,
117262117901
sizeof(Trigger) + /* struct Trigger */
117263117902
sizeof(TriggerStep) + /* Single step in trigger program */
117264117903
nFrom + 1 /* Space for pStep->zTarget */
@@ -117276,11 +117915,11 @@
117276117915
pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);
117277117916
}
117278117917
}
117279117918
117280117919
/* Re-enable the lookaside buffer, if it was disabled earlier. */
117281
- db->lookaside.bDisable--;
117920
+ EnableLookaside;
117282117921
117283117922
sqlite3ExprDelete(db, pWhere);
117284117923
sqlite3ExprDelete(db, pWhen);
117285117924
sqlite3ExprListDelete(db, pList);
117286117925
sqlite3SelectDelete(db, pSelect);
@@ -117427,11 +118066,11 @@
117427118066
v = sqlite3GetVdbe(pParse);
117428118067
assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );
117429118068
sqlite3TableLock(pParse, iDb, pTab->tnum,
117430118069
(opcode==OP_OpenWrite)?1:0, pTab->zName);
117431118070
if( HasRowid(pTab) ){
117432
- sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nCol);
118071
+ sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nNVCol);
117433118072
VdbeComment((v, "%s", pTab->zName));
117434118073
}else{
117435118074
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
117436118075
assert( pPk!=0 );
117437118076
assert( pPk->tnum==pTab->tnum );
@@ -117519,27 +118158,29 @@
117519118158
** 'C' NUMERIC
117520118159
** 'D' INTEGER
117521118160
** 'E' REAL
117522118161
*/
117523118162
SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){
117524
- int i;
118163
+ int i, j;
117525118164
char *zColAff = pTab->zColAff;
117526118165
if( zColAff==0 ){
117527118166
sqlite3 *db = sqlite3VdbeDb(v);
117528118167
zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1);
117529118168
if( !zColAff ){
117530118169
sqlite3OomFault(db);
117531118170
return;
117532118171
}
117533118172
117534
- for(i=0; i<pTab->nCol; i++){
118173
+ for(i=j=0; i<pTab->nCol; i++){
117535118174
assert( pTab->aCol[i].affinity!=0 );
117536
- zColAff[i] = pTab->aCol[i].affinity;
118175
+ if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ){
118176
+ zColAff[j++] = pTab->aCol[i].affinity;
118177
+ }
117537118178
}
117538118179
do{
117539
- zColAff[i--] = 0;
117540
- }while( i>=0 && zColAff[i]<=SQLITE_AFF_BLOB );
118180
+ zColAff[j--] = 0;
118181
+ }while( j>=0 && zColAff[j]<=SQLITE_AFF_BLOB );
117541118182
pTab->zColAff = zColAff;
117542118183
}
117543118184
assert( zColAff!=0 );
117544118185
i = sqlite3Strlen30NN(zColAff);
117545118186
if( i ){
@@ -117588,10 +118229,92 @@
117588118229
}
117589118230
#endif
117590118231
}
117591118232
return 0;
117592118233
}
118234
+
118235
+/* This walker callback will compute the union of colFlags flags for all
118236
+** references columns in a CHECK constraint or generated column expression.
118237
+*/
118238
+static int exprColumnFlagUnion(Walker *pWalker, Expr *pExpr){
118239
+ if( pExpr->op==TK_COLUMN ){
118240
+ pWalker->eCode |= pWalker->u.pTab->aCol[pExpr->iColumn].colFlags;
118241
+ }
118242
+ return WRC_Continue;
118243
+}
118244
+
118245
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
118246
+/*
118247
+** All regular columns for table pTab have been puts into registers
118248
+** starting with iRegStore. The registers that correspond to STORED
118249
+** or VIRTUAL columns have not yet been initialized. This routine goes
118250
+** back and computes the values for those columns based on the previously
118251
+** computed normal columns.
118252
+*/
118253
+SQLITE_PRIVATE void sqlite3ComputeGeneratedColumns(
118254
+ Parse *pParse, /* Parsing context */
118255
+ int iRegStore, /* Register holding the first column */
118256
+ Table *pTab /* The table */
118257
+){
118258
+ int i;
118259
+ Walker w;
118260
+ Column *pRedo;
118261
+ int eProgress;
118262
+
118263
+ /* Because there can be multiple generated columns that refer to one another,
118264
+ ** this is a two-pass algorithm. On the first pass, mark all generated
118265
+ ** columns as "not available".
118266
+ */
118267
+ for(i=0; i<pTab->nCol; i++){
118268
+ if( pTab->aCol[i].colFlags & COLFLAG_GENERATED ){
118269
+ testcase( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL );
118270
+ testcase( pTab->aCol[i].colFlags & COLFLAG_STORED );
118271
+ pTab->aCol[i].colFlags |= COLFLAG_NOTAVAIL;
118272
+ }
118273
+ }
118274
+
118275
+ w.u.pTab = pTab;
118276
+ w.xExprCallback = exprColumnFlagUnion;
118277
+ w.xSelectCallback = 0;
118278
+ w.xSelectCallback2 = 0;
118279
+
118280
+ /* On the second pass, compute the value of each NOT-AVAILABLE column.
118281
+ ** Companion code in the TK_COLUMN case of sqlite3ExprCodeTarget() will
118282
+ ** compute dependencies and mark remove the COLSPAN_NOTAVAIL mark, as
118283
+ ** they are needed.
118284
+ */
118285
+ pParse->iSelfTab = -iRegStore;
118286
+ do{
118287
+ eProgress = 0;
118288
+ pRedo = 0;
118289
+ for(i=0; i<pTab->nCol; i++){
118290
+ Column *pCol = pTab->aCol + i;
118291
+ if( (pCol->colFlags & COLFLAG_NOTAVAIL)!=0 ){
118292
+ int x;
118293
+ pCol->colFlags |= COLFLAG_BUSY;
118294
+ w.eCode = 0;
118295
+ sqlite3WalkExpr(&w, pCol->pDflt);
118296
+ pCol->colFlags &= ~COLFLAG_BUSY;
118297
+ if( w.eCode & COLFLAG_NOTAVAIL ){
118298
+ pRedo = pCol;
118299
+ continue;
118300
+ }
118301
+ eProgress = 1;
118302
+ assert( pCol->colFlags & COLFLAG_GENERATED );
118303
+ x = sqlite3TableColumnToStorage(pTab, i) + iRegStore;
118304
+ sqlite3ExprCodeGeneratedColumn(pParse, pCol, x);
118305
+ pCol->colFlags &= ~COLFLAG_NOTAVAIL;
118306
+ }
118307
+ }
118308
+ }while( pRedo && eProgress );
118309
+ if( pRedo ){
118310
+ sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pRedo->zName);
118311
+ }
118312
+ pParse->iSelfTab = 0;
118313
+}
118314
+#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
118315
+
117593118316
117594118317
#ifndef SQLITE_OMIT_AUTOINCREMENT
117595118318
/*
117596118319
** Locate or create an AutoincInfo structure associated with table pTab
117597118320
** which is in database iDb. Return the register number for the register
@@ -117896,11 +118619,11 @@
117896118619
*/
117897118620
SQLITE_PRIVATE void sqlite3Insert(
117898118621
Parse *pParse, /* Parser context */
117899118622
SrcList *pTabList, /* Name of table into which we are inserting */
117900118623
Select *pSelect, /* A SELECT statement to use as the data source */
117901
- IdList *pColumn, /* Column names corresponding to IDLIST. */
118624
+ IdList *pColumn, /* Column names corresponding to IDLIST, or NULL. */
117902118625
int onError, /* How to handle constraint errors */
117903118626
Upsert *pUpsert /* ON CONFLICT clauses for upsert, or NULL */
117904118627
){
117905118628
sqlite3 *db; /* The main database structure */
117906118629
Table *pTab; /* The table to insert into. aka TABLE */
@@ -117921,10 +118644,11 @@
117921118644
u8 useTempTable = 0; /* Store SELECT results in intermediate table */
117922118645
u8 appendFlag = 0; /* True if the insert is likely to be an append */
117923118646
u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */
117924118647
u8 bIdListInOrder; /* True if IDLIST is in table order */
117925118648
ExprList *pList = 0; /* List of VALUES() to be inserted */
118649
+ int iRegStore; /* Register in which to store next column */
117926118650
117927118651
/* Register allocations */
117928118652
int regFromSelect = 0;/* Base register for data coming from SELECT */
117929118653
int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */
117930118654
int regRowCount = 0; /* Memory cell used for the row counter */
@@ -118028,12 +118752,12 @@
118028118752
/* If this is an AUTOINCREMENT table, look up the sequence number in the
118029118753
** sqlite_sequence table and store it in memory cell regAutoinc.
118030118754
*/
118031118755
regAutoinc = autoIncBegin(pParse, iDb, pTab);
118032118756
118033
- /* Allocate registers for holding the rowid of the new row,
118034
- ** the content of the new row, and the assembled row record.
118757
+ /* Allocate a block registers to hold the rowid and the values
118758
+ ** for all columns of the new row.
118035118759
*/
118036118760
regRowid = regIns = pParse->nMem+1;
118037118761
pParse->nMem += pTab->nCol + 1;
118038118762
if( IsVirtual(pTab) ){
118039118763
regRowid++;
@@ -118048,13 +118772,21 @@
118048118772
** If the table has an INTEGER PRIMARY KEY column and that column
118049118773
** is named in the IDLIST, then record in the ipkColumn variable
118050118774
** the index into IDLIST of the primary key column. ipkColumn is
118051118775
** the index of the primary key as it appears in IDLIST, not as
118052118776
** is appears in the original table. (The index of the INTEGER
118053
- ** PRIMARY KEY in the original table is pTab->iPKey.)
118777
+ ** PRIMARY KEY in the original table is pTab->iPKey.) After this
118778
+ ** loop, if ipkColumn==(-1), that means that integer primary key
118779
+ ** is unspecified, and hence the table is either WITHOUT ROWID or
118780
+ ** it will automatically generated an integer primary key.
118781
+ **
118782
+ ** bIdListInOrder is true if the columns in IDLIST are in storage
118783
+ ** order. This enables an optimization that avoids shuffling the
118784
+ ** columns into storage order. False negatives are harmless,
118785
+ ** but false positives will cause database corruption.
118054118786
*/
118055
- bIdListInOrder = (pTab->tabFlags & TF_OOOHidden)==0;
118787
+ bIdListInOrder = (pTab->tabFlags & (TF_OOOHidden|TF_HasStored))==0;
118056118788
if( pColumn ){
118057118789
for(i=0; i<pColumn->nId; i++){
118058118790
pColumn->a[i].idx = -1;
118059118791
}
118060118792
for(i=0; i<pColumn->nId; i++){
@@ -118063,10 +118795,18 @@
118063118795
pColumn->a[i].idx = j;
118064118796
if( i!=j ) bIdListInOrder = 0;
118065118797
if( j==pTab->iPKey ){
118066118798
ipkColumn = i; assert( !withoutRowid );
118067118799
}
118800
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
118801
+ if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){
118802
+ sqlite3ErrorMsg(pParse,
118803
+ "cannot INSERT into generated column \"%s\"",
118804
+ pTab->aCol[j].zName);
118805
+ goto insert_cleanup;
118806
+ }
118807
+#endif
118068118808
break;
118069118809
}
118070118810
}
118071118811
if( j>=pTab->nCol ){
118072118812
if( sqlite3IsRowid(pColumn->a[i].zName) && !withoutRowid ){
@@ -118172,17 +118912,30 @@
118172118912
** key, the set the ipkColumn variable to the integer primary key
118173118913
** column index in the original table definition.
118174118914
*/
118175118915
if( pColumn==0 && nColumn>0 ){
118176118916
ipkColumn = pTab->iPKey;
118917
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
118918
+ if( ipkColumn>=0 && (pTab->tabFlags & TF_HasGenerated)!=0 ){
118919
+ testcase( pTab->tabFlags & TF_HasVirtual );
118920
+ testcase( pTab->tabFlags & TF_HasStored );
118921
+ for(i=ipkColumn-1; i>=0; i--){
118922
+ if( pTab->aCol[i].colFlags & COLFLAG_GENERATED ){
118923
+ testcase( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL );
118924
+ testcase( pTab->aCol[i].colFlags & COLFLAG_STORED );
118925
+ ipkColumn--;
118926
+ }
118927
+ }
118928
+ }
118929
+#endif
118177118930
}
118178118931
118179118932
/* Make sure the number of columns in the source data matches the number
118180118933
** of columns to be inserted into the table.
118181118934
*/
118182118935
for(i=0; i<pTab->nCol; i++){
118183
- nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0);
118936
+ if( pTab->aCol[i].colFlags & COLFLAG_NOINSERT ) nHidden++;
118184118937
}
118185118938
if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){
118186118939
sqlite3ErrorMsg(pParse,
118187118940
"table %S has %d columns but %d values were supplied",
118188118941
pTabList, 0, pTab->nCol-nHidden, nColumn);
@@ -118263,11 +119016,91 @@
118263119016
** goto C
118264119017
** D: ...
118265119018
*/
118266119019
addrInsTop = addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);
118267119020
VdbeCoverage(v);
119021
+ if( ipkColumn>=0 ){
119022
+ /* tag-20191021-001: If the INTEGER PRIMARY KEY is being generated by the
119023
+ ** SELECT, go ahead and copy the value into the rowid slot now, so that
119024
+ ** the value does not get overwritten by a NULL at tag-20191021-002. */
119025
+ sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid);
119026
+ }
118268119027
}
119028
+
119029
+ /* Compute data for ordinary columns of the new entry. Values
119030
+ ** are written in storage order into registers starting with regData.
119031
+ ** Only ordinary columns are computed in this loop. The rowid
119032
+ ** (if there is one) is computed later and generated columns are
119033
+ ** computed after the rowid since they might depend on the value
119034
+ ** of the rowid.
119035
+ */
119036
+ nHidden = 0;
119037
+ iRegStore = regData; assert( regData==regRowid+1 );
119038
+ for(i=0; i<pTab->nCol; i++, iRegStore++){
119039
+ int k;
119040
+ u32 colFlags;
119041
+ assert( i>=nHidden );
119042
+ if( i==pTab->iPKey ){
119043
+ /* tag-20191021-002: References to the INTEGER PRIMARY KEY are filled
119044
+ ** using the rowid. So put a NULL in the IPK slot of the record to avoid
119045
+ ** using excess space. The file format definition requires this extra
119046
+ ** NULL - we cannot optimize further by skipping the column completely */
119047
+ sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);
119048
+ continue;
119049
+ }
119050
+ if( ((colFlags = pTab->aCol[i].colFlags) & COLFLAG_NOINSERT)!=0 ){
119051
+ nHidden++;
119052
+ if( (colFlags & COLFLAG_VIRTUAL)!=0 ){
119053
+ /* Virtual columns do not participate in OP_MakeRecord. So back up
119054
+ ** iRegStore by one slot to compensate for the iRegStore++ in the
119055
+ ** outer for() loop */
119056
+ iRegStore--;
119057
+ continue;
119058
+ }else if( (colFlags & COLFLAG_STORED)!=0 ){
119059
+ /* Stored columns are computed later. But if there are BEFORE
119060
+ ** triggers, the slots used for stored columns will be OP_Copy-ed
119061
+ ** to a second block of registers, so the register needs to be
119062
+ ** initialized to NULL to avoid an uninitialized register read */
119063
+ if( tmask & TRIGGER_BEFORE ){
119064
+ sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);
119065
+ }
119066
+ continue;
119067
+ }else if( pColumn==0 ){
119068
+ /* Hidden columns that are not explicitly named in the INSERT
119069
+ ** get there default value */
119070
+ sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);
119071
+ continue;
119072
+ }
119073
+ }
119074
+ if( pColumn ){
119075
+ for(j=0; j<pColumn->nId && pColumn->a[j].idx!=i; j++){}
119076
+ if( j>=pColumn->nId ){
119077
+ /* A column not named in the insert column list gets its
119078
+ ** default value */
119079
+ sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);
119080
+ continue;
119081
+ }
119082
+ k = j;
119083
+ }else if( nColumn==0 ){
119084
+ /* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */
119085
+ sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);
119086
+ continue;
119087
+ }else{
119088
+ k = i - nHidden;
119089
+ }
119090
+
119091
+ if( useTempTable ){
119092
+ sqlite3VdbeAddOp3(v, OP_Column, srcTab, k, iRegStore);
119093
+ }else if( pSelect ){
119094
+ if( regFromSelect!=regData ){
119095
+ sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+k, iRegStore);
119096
+ }
119097
+ }else{
119098
+ sqlite3ExprCode(pParse, pList->a[k].pExpr, iRegStore);
119099
+ }
119100
+ }
119101
+
118269119102
118270119103
/* Run the BEFORE and INSTEAD OF triggers, if there are any
118271119104
*/
118272119105
endOfLoop = sqlite3VdbeMakeLabel(pParse);
118273119106
if( tmask & TRIGGER_BEFORE ){
@@ -118299,29 +119132,25 @@
118299119132
/* Cannot have triggers on a virtual table. If it were possible,
118300119133
** this block would have to account for hidden column.
118301119134
*/
118302119135
assert( !IsVirtual(pTab) );
118303119136
118304
- /* Create the new column data
118305
- */
118306
- for(i=j=0; i<pTab->nCol; i++){
118307
- if( pColumn ){
118308
- for(j=0; j<pColumn->nId; j++){
118309
- if( pColumn->a[j].idx==i ) break;
118310
- }
118311
- }
118312
- if( (!useTempTable && !pList) || (pColumn && j>=pColumn->nId)
118313
- || (pColumn==0 && IsOrdinaryHiddenColumn(&pTab->aCol[i])) ){
118314
- sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regCols+i+1);
118315
- }else if( useTempTable ){
118316
- sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, regCols+i+1);
118317
- }else{
118318
- assert( pSelect==0 ); /* Otherwise useTempTable is true */
118319
- sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1);
118320
- }
118321
- if( pColumn==0 && !IsOrdinaryHiddenColumn(&pTab->aCol[i]) ) j++;
118322
- }
119137
+ /* Copy the new data already generated. */
119138
+ assert( pTab->nNVCol>0 );
119139
+ sqlite3VdbeAddOp3(v, OP_Copy, regRowid+1, regCols+1, pTab->nNVCol-1);
119140
+
119141
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
119142
+ /* Compute the new value for generated columns after all other
119143
+ ** columns have already been computed. This must be done after
119144
+ ** computing the ROWID in case one of the generated columns
119145
+ ** refers to the ROWID. */
119146
+ if( pTab->tabFlags & TF_HasGenerated ){
119147
+ testcase( pTab->tabFlags & TF_HasVirtual );
119148
+ testcase( pTab->tabFlags & TF_HasStored );
119149
+ sqlite3ComputeGeneratedColumns(pParse, regCols+1, pTab);
119150
+ }
119151
+#endif
118323119152
118324119153
/* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,
118325119154
** do not attempt any conversions before assembling the record.
118326119155
** If this is a real table, attempt conversions as required by the
118327119156
** table column affinities.
@@ -118335,23 +119164,21 @@
118335119164
pTab, regCols-pTab->nCol-1, onError, endOfLoop);
118336119165
118337119166
sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);
118338119167
}
118339119168
118340
- /* Compute the content of the next row to insert into a range of
118341
- ** registers beginning at regIns.
118342
- */
118343119169
if( !isView ){
118344119170
if( IsVirtual(pTab) ){
118345119171
/* The row that the VUpdate opcode will delete: none */
118346119172
sqlite3VdbeAddOp2(v, OP_Null, 0, regIns);
118347119173
}
118348119174
if( ipkColumn>=0 ){
119175
+ /* Compute the new rowid */
118349119176
if( useTempTable ){
118350119177
sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regRowid);
118351119178
}else if( pSelect ){
118352
- sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid);
119179
+ /* Rowid already initialized at tag-20191021-001 */
118353119180
}else{
118354119181
Expr *pIpk = pList->a[ipkColumn].pExpr;
118355119182
if( pIpk->op==TK_NULL && !IsVirtual(pTab) ){
118356119183
sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);
118357119184
appendFlag = 1;
@@ -118380,49 +119207,21 @@
118380119207
sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);
118381119208
appendFlag = 1;
118382119209
}
118383119210
autoIncStep(pParse, regAutoinc, regRowid);
118384119211
118385
- /* Compute data for all columns of the new entry, beginning
118386
- ** with the first column.
118387
- */
118388
- nHidden = 0;
118389
- for(i=0; i<pTab->nCol; i++){
118390
- int iRegStore = regRowid+1+i;
118391
- if( i==pTab->iPKey ){
118392
- /* The value of the INTEGER PRIMARY KEY column is always a NULL.
118393
- ** Whenever this column is read, the rowid will be substituted
118394
- ** in its place. Hence, fill this column with a NULL to avoid
118395
- ** taking up data space with information that will never be used.
118396
- ** As there may be shallow copies of this value, make it a soft-NULL */
118397
- sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);
118398
- continue;
118399
- }
118400
- if( pColumn==0 ){
118401
- if( IsHiddenColumn(&pTab->aCol[i]) ){
118402
- j = -1;
118403
- nHidden++;
118404
- }else{
118405
- j = i - nHidden;
118406
- }
118407
- }else{
118408
- for(j=0; j<pColumn->nId; j++){
118409
- if( pColumn->a[j].idx==i ) break;
118410
- }
118411
- }
118412
- if( j<0 || nColumn==0 || (pColumn && j>=pColumn->nId) ){
118413
- sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);
118414
- }else if( useTempTable ){
118415
- sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, iRegStore);
118416
- }else if( pSelect ){
118417
- if( regFromSelect!=regData ){
118418
- sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+j, iRegStore);
118419
- }
118420
- }else{
118421
- sqlite3ExprCode(pParse, pList->a[j].pExpr, iRegStore);
118422
- }
118423
- }
119212
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
119213
+ /* Compute the new value for generated columns after all other
119214
+ ** columns have already been computed. This must be done after
119215
+ ** computing the ROWID in case one of the generated columns
119216
+ ** refers to the ROWID. */
119217
+ if( pTab->tabFlags & TF_HasGenerated ){
119218
+ testcase( pTab->tabFlags & TF_HasVirtual );
119219
+ testcase( pTab->tabFlags & TF_HasStored );
119220
+ sqlite3ComputeGeneratedColumns(pParse, regRowid+1, pTab);
119221
+ }
119222
+#endif
118424119223
118425119224
/* Generate code to check constraints and generate index keys and
118426119225
** do the insertion.
118427119226
*/
118428119227
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -118448,13 +119247,11 @@
118448119247
** flag in the second case as if any REPLACE constraint is hit, an
118449119248
** OP_Delete or OP_IdxDelete instruction will be executed on each
118450119249
** cursor that is disturbed. And these instructions both clear the
118451119250
** VdbeCursor.seekResult variable, disabling the OPFLAG_USESEEKRESULT
118452119251
** functionality. */
118453
- bUseSeek = (isReplace==0 || (pTrigger==0 &&
118454
- ((db->flags & SQLITE_ForeignKeys)==0 || sqlite3FkReferences(pTab)==0)
118455
- ));
119252
+ bUseSeek = (isReplace==0 || !sqlite3VdbeHasSubProgram(v));
118456119253
sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur,
118457119254
regIns, aRegIdx, 0, appendFlag, bUseSeek
118458119255
);
118459119256
}
118460119257
}
@@ -118711,10 +119508,17 @@
118711119508
u8 bAffinityDone = 0; /* True if the OP_Affinity operation has been run */
118712119509
int upsertBypass = 0; /* Address of Goto to bypass upsert subroutine */
118713119510
int upsertJump = 0; /* Address of Goto that jumps into upsert subroutine */
118714119511
int ipkTop = 0; /* Top of the IPK uniqueness check */
118715119512
int ipkBottom = 0; /* OP_Goto at the end of the IPK uniqueness check */
119513
+ /* Variables associated with retesting uniqueness constraints after
119514
+ ** replace triggers fire have run */
119515
+ int regTrigCnt; /* Register used to count replace trigger invocations */
119516
+ int addrRecheck = 0; /* Jump here to recheck all uniqueness constraints */
119517
+ int lblRecheckOk = 0; /* Each recheck jumps to this label if it passes */
119518
+ Trigger *pTrigger; /* List of DELETE triggers on the table pTab */
119519
+ int nReplaceTrig = 0; /* Number of replace triggers coded */
118716119520
118717119521
isUpdate = regOldData!=0;
118718119522
db = pParse->db;
118719119523
v = sqlite3GetVdbe(pParse);
118720119524
assert( v!=0 );
@@ -118737,64 +119541,73 @@
118737119541
VdbeModuleComment((v, "BEGIN: GenCnstCks(%d,%d,%d,%d,%d)",
118738119542
iDataCur, iIdxCur, regNewData, regOldData, pkChng));
118739119543
118740119544
/* Test all NOT NULL constraints.
118741119545
*/
118742
- for(i=0; i<nCol; i++){
118743
- if( i==pTab->iPKey ){
118744
- continue; /* ROWID is never NULL */
118745
- }
118746
- if( aiChng && aiChng[i]<0 ){
118747
- /* Don't bother checking for NOT NULL on columns that do not change */
118748
- continue;
118749
- }
118750
- onError = pTab->aCol[i].notNull;
118751
- if( onError==OE_None ) continue; /* This column is allowed to be NULL */
118752
- if( overrideError!=OE_Default ){
118753
- onError = overrideError;
118754
- }else if( onError==OE_Default ){
118755
- onError = OE_Abort;
118756
- }
118757
- if( onError==OE_Replace && pTab->aCol[i].pDflt==0 ){
118758
- onError = OE_Abort;
118759
- }
118760
- assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
118761
- || onError==OE_Ignore || onError==OE_Replace );
118762
- addr1 = 0;
118763
- switch( onError ){
118764
- case OE_Replace: {
118765
- assert( onError==OE_Replace );
118766
- addr1 = sqlite3VdbeMakeLabel(pParse);
118767
- sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);
118768
- VdbeCoverage(v);
118769
- sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);
118770
- sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);
118771
- VdbeCoverage(v);
118772
- onError = OE_Abort;
118773
- /* Fall through into the OE_Abort case to generate code that runs
118774
- ** if both the input and the default value are NULL */
118775
- }
118776
- case OE_Abort:
118777
- sqlite3MayAbort(pParse);
118778
- /* Fall through */
118779
- case OE_Rollback:
118780
- case OE_Fail: {
118781
- char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName,
118782
- pTab->aCol[i].zName);
118783
- sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, onError,
118784
- regNewData+1+i);
118785
- sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC);
118786
- sqlite3VdbeChangeP5(v, P5_ConstraintNotNull);
118787
- VdbeCoverage(v);
118788
- if( addr1 ) sqlite3VdbeResolveLabel(v, addr1);
118789
- break;
118790
- }
118791
- default: {
118792
- assert( onError==OE_Ignore );
118793
- sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest);
118794
- VdbeCoverage(v);
118795
- break;
119546
+ if( pTab->tabFlags & TF_HasNotNull ){
119547
+ for(i=0; i<nCol; i++){
119548
+ int iReg;
119549
+ onError = pTab->aCol[i].notNull;
119550
+ if( onError==OE_None ) continue; /* No NOT NULL on this column */
119551
+ if( i==pTab->iPKey ){
119552
+ continue; /* ROWID is never NULL */
119553
+ }
119554
+ if( aiChng && aiChng[i]<0 ){
119555
+ /* Don't bother checking for NOT NULL on columns that do not change */
119556
+ continue;
119557
+ }
119558
+ if( overrideError!=OE_Default ){
119559
+ onError = overrideError;
119560
+ }else if( onError==OE_Default ){
119561
+ onError = OE_Abort;
119562
+ }
119563
+ if( onError==OE_Replace && pTab->aCol[i].pDflt==0 ){
119564
+ onError = OE_Abort;
119565
+ }
119566
+ assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
119567
+ || onError==OE_Ignore || onError==OE_Replace );
119568
+ addr1 = 0;
119569
+ testcase( i!=sqlite3TableColumnToStorage(pTab, i) );
119570
+ testcase( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL );
119571
+ testcase( pTab->aCol[i].colFlags & COLFLAG_STORED );
119572
+ iReg = sqlite3TableColumnToStorage(pTab, i) + regNewData + 1;
119573
+ switch( onError ){
119574
+ case OE_Replace: {
119575
+ assert( onError==OE_Replace );
119576
+ addr1 = sqlite3VdbeMakeLabel(pParse);
119577
+ sqlite3VdbeAddOp2(v, OP_NotNull, iReg, addr1);
119578
+ VdbeCoverage(v);
119579
+ if( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 ){
119580
+ sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);
119581
+ sqlite3VdbeAddOp2(v, OP_NotNull, iReg, addr1);
119582
+ VdbeCoverage(v);
119583
+ }
119584
+ onError = OE_Abort;
119585
+ /* Fall through into the OE_Abort case to generate code that runs
119586
+ ** if both the input and the default value are NULL */
119587
+ }
119588
+ case OE_Abort:
119589
+ sqlite3MayAbort(pParse);
119590
+ /* Fall through */
119591
+ case OE_Rollback:
119592
+ case OE_Fail: {
119593
+ char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName,
119594
+ pTab->aCol[i].zName);
119595
+ sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL,
119596
+ onError, iReg);
119597
+ sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC);
119598
+ sqlite3VdbeChangeP5(v, P5_ConstraintNotNull);
119599
+ VdbeCoverage(v);
119600
+ if( addr1 ) sqlite3VdbeResolveLabel(v, addr1);
119601
+ break;
119602
+ }
119603
+ default: {
119604
+ assert( onError==OE_Ignore );
119605
+ sqlite3VdbeAddOp2(v, OP_IsNull, iReg, ignoreDest);
119606
+ VdbeCoverage(v);
119607
+ break;
119608
+ }
118796119609
}
118797119610
}
118798119611
}
118799119612
118800119613
/* Test all CHECK constraints
@@ -118874,10 +119687,54 @@
118874119687
** Jump to that uniqueness check now */
118875119688
upsertJump = sqlite3VdbeAddOp0(v, OP_Goto);
118876119689
VdbeComment((v, "UPSERT constraint goes first"));
118877119690
}
118878119691
}
119692
+
119693
+ /* Determine if it is possible that triggers (either explicitly coded
119694
+ ** triggers or FK resolution actions) might run as a result of deletes
119695
+ ** that happen when OE_Replace conflict resolution occurs. (Call these
119696
+ ** "replace triggers".) If any replace triggers run, we will need to
119697
+ ** recheck all of the uniqueness constraints after they have all run.
119698
+ ** But on the recheck, the resolution is OE_Abort instead of OE_Replace.
119699
+ **
119700
+ ** If replace triggers are a possibility, then
119701
+ **
119702
+ ** (1) Allocate register regTrigCnt and initialize it to zero.
119703
+ ** That register will count the number of replace triggers that
119704
+ ** fire. Constraint recheck only occurs if the number is positive.
119705
+ ** (2) Initialize pTrigger to the list of all DELETE triggers on pTab.
119706
+ ** (3) Initialize addrRecheck and lblRecheckOk
119707
+ **
119708
+ ** The uniqueness rechecking code will create a series of tests to run
119709
+ ** in a second pass. The addrRecheck and lblRecheckOk variables are
119710
+ ** used to link together these tests which are separated from each other
119711
+ ** in the generate bytecode.
119712
+ */
119713
+ if( (db->flags & (SQLITE_RecTriggers|SQLITE_ForeignKeys))==0 ){
119714
+ /* There are not DELETE triggers nor FK constraints. No constraint
119715
+ ** rechecks are needed. */
119716
+ pTrigger = 0;
119717
+ regTrigCnt = 0;
119718
+ }else{
119719
+ if( db->flags&SQLITE_RecTriggers ){
119720
+ pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
119721
+ regTrigCnt = pTrigger!=0 || sqlite3FkRequired(pParse, pTab, 0, 0);
119722
+ }else{
119723
+ pTrigger = 0;
119724
+ regTrigCnt = sqlite3FkRequired(pParse, pTab, 0, 0);
119725
+ }
119726
+ if( regTrigCnt ){
119727
+ /* Replace triggers might exist. Allocate the counter and
119728
+ ** initialize it to zero. */
119729
+ regTrigCnt = ++pParse->nMem;
119730
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, regTrigCnt);
119731
+ VdbeComment((v, "trigger count"));
119732
+ lblRecheckOk = sqlite3VdbeMakeLabel(pParse);
119733
+ addrRecheck = lblRecheckOk;
119734
+ }
119735
+ }
118879119736
118880119737
/* If rowid is changing, make sure the new rowid does not previously
118881119738
** exist in the table.
118882119739
*/
118883119740
if( pkChng && pPk==0 ){
@@ -118964,18 +119821,16 @@
118964119821
** REPLACE INTO t(rowid) VALUES($newrowid)
118965119822
**
118966119823
** to run without a statement journal if there are no indexes on the
118967119824
** table.
118968119825
*/
118969
- Trigger *pTrigger = 0;
118970
- if( db->flags&SQLITE_RecTriggers ){
118971
- pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
118972
- }
118973
- if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
119826
+ if( regTrigCnt ){
118974119827
sqlite3MultiWrite(pParse);
118975119828
sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
118976119829
regNewData, 1, 0, OE_Replace, 1, -1);
119830
+ sqlite3VdbeAddOp2(v, OP_AddImm, regTrigCnt, 1); /* incr trigger cnt */
119831
+ nReplaceTrig++;
118977119832
}else{
118978119833
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
118979119834
assert( HasRowid(pTab) );
118980119835
/* This OP_Delete opcode fires the pre-update-hook only. It does
118981119836
** not modify the b-tree. It is more efficient to let the coming
@@ -119021,10 +119876,11 @@
119021119876
for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){
119022119877
int regIdx; /* Range of registers hold conent for pIdx */
119023119878
int regR; /* Range of registers holding conflicting PK */
119024119879
int iThisCur; /* Cursor for this UNIQUE index */
119025119880
int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */
119881
+ int addrConflictCk; /* First opcode in the conflict check logic */
119026119882
119027119883
if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */
119028119884
if( pUpIdx==pIdx ){
119029119885
addrUniqueOk = upsertJump+1;
119030119886
upsertBypass = sqlite3VdbeGoto(v, 0);
@@ -119060,18 +119916,19 @@
119060119916
if( iField==XN_EXPR ){
119061119917
pParse->iSelfTab = -(regNewData+1);
119062119918
sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
119063119919
pParse->iSelfTab = 0;
119064119920
VdbeComment((v, "%s column %d", pIdx->zName, i));
119065
- }else{
119066
- if( iField==XN_ROWID || iField==pTab->iPKey ){
119067
- x = regNewData;
119068
- }else{
119069
- x = iField + regNewData + 1;
119070
- }
119071
- sqlite3VdbeAddOp2(v, iField<0 ? OP_IntCopy : OP_SCopy, x, regIdx+i);
119072
- VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName));
119921
+ }else if( iField==XN_ROWID || iField==pTab->iPKey ){
119922
+ x = regNewData;
119923
+ sqlite3VdbeAddOp2(v, OP_IntCopy, x, regIdx+i);
119924
+ VdbeComment((v, "rowid"));
119925
+ }else{
119926
+ testcase( sqlite3TableColumnToStorage(pTab, iField)!=iField );
119927
+ x = sqlite3TableColumnToStorage(pTab, iField) + regNewData + 1;
119928
+ sqlite3VdbeAddOp2(v, OP_SCopy, x, regIdx+i);
119929
+ VdbeComment((v, "%s", pTab->aCol[iField].zName));
119073119930
}
119074119931
}
119075119932
sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
119076119933
VdbeComment((v, "for %s", pIdx->zName));
119077119934
#ifdef SQLITE_ENABLE_NULL_TRIM
@@ -119134,12 +119991,13 @@
119134119991
}
119135119992
#endif /* ifndef SQLITE_ENABLE_PREUPDATE_HOOK */
119136119993
119137119994
/* Check to see if the new index entry will be unique */
119138119995
sqlite3VdbeVerifyAbortable(v, onError);
119139
- sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
119140
- regIdx, pIdx->nKeyCol); VdbeCoverage(v);
119996
+ addrConflictCk =
119997
+ sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
119998
+ regIdx, pIdx->nKeyCol); VdbeCoverage(v);
119141119999
119142120000
/* Generate code to handle collisions */
119143120001
regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);
119144120002
if( isUpdate || onError==OE_Replace ){
119145120003
if( HasRowid(pTab) ){
@@ -119156,11 +120014,11 @@
119156120014
/* Extract the PRIMARY KEY from the end of the index entry and
119157120015
** store it in registers regR..regR+nPk-1 */
119158120016
if( pIdx!=pPk ){
119159120017
for(i=0; i<pPk->nKeyCol; i++){
119160120018
assert( pPk->aiColumn[i]>=0 );
119161
- x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
120019
+ x = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]);
119162120020
sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i);
119163120021
VdbeComment((v, "%s.%s", pTab->zName,
119164120022
pTab->aCol[pPk->aiColumn[i]].zName));
119165120023
}
119166120024
}
@@ -119182,10 +120040,11 @@
119182120040
assert( x>=0 );
119183120041
if( i==(pPk->nKeyCol-1) ){
119184120042
addrJump = addrUniqueOk;
119185120043
op = OP_Eq;
119186120044
}
120045
+ x = sqlite3TableColumnToStorage(pTab, x);
119187120046
sqlite3VdbeAddOp4(v, op,
119188120047
regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ
119189120048
);
119190120049
sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
119191120050
VdbeCoverageIf(v, op==OP_Eq);
@@ -119218,21 +120077,69 @@
119218120077
testcase( onError==OE_Ignore );
119219120078
sqlite3VdbeGoto(v, ignoreDest);
119220120079
break;
119221120080
}
119222120081
default: {
119223
- Trigger *pTrigger = 0;
120082
+ int nConflictCk; /* Number of opcodes in conflict check logic */
120083
+
119224120084
assert( onError==OE_Replace );
119225
- if( db->flags&SQLITE_RecTriggers ){
119226
- pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
119227
- }
119228
- if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
120085
+ nConflictCk = sqlite3VdbeCurrentAddr(v) - addrConflictCk;
120086
+ assert( nConflictCk>0 );
120087
+ testcase( nConflictCk>1 );
120088
+ if( regTrigCnt ){
119229120089
sqlite3MultiWrite(pParse);
120090
+ nReplaceTrig++;
119230120091
}
119231120092
sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
119232120093
regR, nPkField, 0, OE_Replace,
119233120094
(pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
120095
+ if( regTrigCnt ){
120096
+ int addrBypass; /* Jump destination to bypass recheck logic */
120097
+
120098
+ sqlite3VdbeAddOp2(v, OP_AddImm, regTrigCnt, 1); /* incr trigger cnt */
120099
+ addrBypass = sqlite3VdbeAddOp0(v, OP_Goto); /* Bypass recheck */
120100
+ VdbeComment((v, "bypass recheck"));
120101
+
120102
+ /* Here we insert code that will be invoked after all constraint
120103
+ ** checks have run, if and only if one or more replace triggers
120104
+ ** fired. */
120105
+ sqlite3VdbeResolveLabel(v, lblRecheckOk);
120106
+ lblRecheckOk = sqlite3VdbeMakeLabel(pParse);
120107
+ if( pIdx->pPartIdxWhere ){
120108
+ /* Bypass the recheck if this partial index is not defined
120109
+ ** for the current row */
120110
+ sqlite3VdbeAddOp2(v, OP_IsNull, regIdx-1, lblRecheckOk);
120111
+ VdbeCoverage(v);
120112
+ }
120113
+ /* Copy the constraint check code from above, except change
120114
+ ** the constraint-ok jump destination to be the address of
120115
+ ** the next retest block */
120116
+ while( nConflictCk>0 ){
120117
+ VdbeOp x; /* Conflict check opcode to copy */
120118
+ /* The sqlite3VdbeAddOp4() call might reallocate the opcode array.
120119
+ ** Hence, make a complete copy of the opcode, rather than using
120120
+ ** a pointer to the opcode. */
120121
+ x = *sqlite3VdbeGetOp(v, addrConflictCk);
120122
+ if( x.opcode!=OP_IdxRowid ){
120123
+ int p2; /* New P2 value for copied conflict check opcode */
120124
+ if( sqlite3OpcodeProperty[x.opcode]&OPFLG_JUMP ){
120125
+ p2 = lblRecheckOk;
120126
+ }else{
120127
+ p2 = x.p2;
120128
+ }
120129
+ sqlite3VdbeAddOp4(v, x.opcode, x.p1, p2, x.p3, x.p4.z, x.p4type);
120130
+ sqlite3VdbeChangeP5(v, x.p5);
120131
+ VdbeCoverageIf(v, p2!=x.p2);
120132
+ }
120133
+ nConflictCk--;
120134
+ addrConflictCk++;
120135
+ }
120136
+ /* If the retest fails, issue an abort */
120137
+ sqlite3UniqueConstraint(pParse, OE_Abort, pIdx);
120138
+
120139
+ sqlite3VdbeJumpHere(v, addrBypass); /* Terminate the recheck bypass */
120140
+ }
119234120141
seenReplace = 1;
119235120142
break;
119236120143
}
119237120144
}
119238120145
if( pUpIdx==pIdx ){
@@ -119248,15 +120155,35 @@
119248120155
if( ipkTop ){
119249120156
sqlite3VdbeGoto(v, ipkTop);
119250120157
VdbeComment((v, "Do IPK REPLACE"));
119251120158
sqlite3VdbeJumpHere(v, ipkBottom);
119252120159
}
120160
+
120161
+ /* Recheck all uniqueness constraints after replace triggers have run */
120162
+ testcase( regTrigCnt!=0 && nReplaceTrig==0 );
120163
+ assert( regTrigCnt!=0 || nReplaceTrig==0 );
120164
+ if( nReplaceTrig ){
120165
+ sqlite3VdbeAddOp2(v, OP_IfNot, regTrigCnt, lblRecheckOk);VdbeCoverage(v);
120166
+ if( !pPk ){
120167
+ if( isUpdate ){
120168
+ sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRecheck, regOldData);
120169
+ sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
120170
+ VdbeCoverage(v);
120171
+ }
120172
+ sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRecheck, regNewData);
120173
+ VdbeCoverage(v);
120174
+ sqlite3RowidConstraint(pParse, OE_Abort, pTab);
120175
+ }else{
120176
+ sqlite3VdbeGoto(v, addrRecheck);
120177
+ }
120178
+ sqlite3VdbeResolveLabel(v, lblRecheckOk);
120179
+ }
119253120180
119254120181
/* Generate the table record */
119255120182
if( HasRowid(pTab) ){
119256120183
int regRec = aRegIdx[ix];
119257
- sqlite3VdbeAddOp3(v, OP_MakeRecord, regNewData+1, pTab->nCol, regRec);
120184
+ sqlite3VdbeAddOp3(v, OP_MakeRecord, regNewData+1, pTab->nNVCol, regRec);
119258120185
sqlite3SetMakeRecordP5(v, pTab);
119259120186
if( !bAffinityDone ){
119260120187
sqlite3TableAffinity(v, pTab, 0);
119261120188
}
119262120189
}
@@ -119469,11 +120396,11 @@
119469120396
*/
119470120397
static int xferCompatibleIndex(Index *pDest, Index *pSrc){
119471120398
int i;
119472120399
assert( pDest && pSrc );
119473120400
assert( pDest->pTable!=pSrc->pTable );
119474
- if( pDest->nKeyCol!=pSrc->nKeyCol ){
120401
+ if( pDest->nKeyCol!=pSrc->nKeyCol || pDest->nColumn!=pSrc->nColumn ){
119475120402
return 0; /* Different number of columns */
119476120403
}
119477120404
if( pDest->onError!=pSrc->onError ){
119478120405
return 0; /* Different conflict resolution strategies */
119479120406
}
@@ -119646,10 +120573,43 @@
119646120573
if( (db->mDbFlags & DBFLAG_Vacuum)==0
119647120574
&& (pDestCol->colFlags | pSrcCol->colFlags) & COLFLAG_HIDDEN
119648120575
){
119649120576
return 0; /* Neither table may have __hidden__ columns */
119650120577
}
120578
+#endif
120579
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
120580
+ /* Even if tables t1 and t2 have identical schemas, if they contain
120581
+ ** generated columns, then this statement is semantically incorrect:
120582
+ **
120583
+ ** INSERT INTO t2 SELECT * FROM t1;
120584
+ **
120585
+ ** The reason is that generated column values are returned by the
120586
+ ** the SELECT statement on the right but the INSERT statement on the
120587
+ ** left wants them to be omitted.
120588
+ **
120589
+ ** Nevertheless, this is a useful notational shorthand to tell SQLite
120590
+ ** to do a bulk transfer all of the content from t1 over to t2.
120591
+ **
120592
+ ** We could, in theory, disable this (except for internal use by the
120593
+ ** VACUUM command where it is actually needed). But why do that? It
120594
+ ** seems harmless enough, and provides a useful service.
120595
+ */
120596
+ if( (pDestCol->colFlags & COLFLAG_GENERATED) !=
120597
+ (pSrcCol->colFlags & COLFLAG_GENERATED) ){
120598
+ return 0; /* Both columns have the same generated-column type */
120599
+ }
120600
+ /* But the transfer is only allowed if both the source and destination
120601
+ ** tables have the exact same expressions for generated columns.
120602
+ ** This requirement could be relaxed for VIRTUAL columns, I suppose.
120603
+ */
120604
+ if( (pDestCol->colFlags & COLFLAG_GENERATED)!=0 ){
120605
+ if( sqlite3ExprCompare(0, pSrcCol->pDflt, pDestCol->pDflt, -1)!=0 ){
120606
+ testcase( pDestCol->colFlags & COLFLAG_VIRTUAL );
120607
+ testcase( pDestCol->colFlags & COLFLAG_STORED );
120608
+ return 0; /* Different generator expressions */
120609
+ }
120610
+ }
119651120611
#endif
119652120612
if( pDestCol->affinity!=pSrcCol->affinity ){
119653120613
return 0; /* Affinity must be the same on all columns */
119654120614
}
119655120615
if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){
@@ -119657,11 +120617,11 @@
119657120617
}
119658120618
if( pDestCol->notNull && !pSrcCol->notNull ){
119659120619
return 0; /* tab2 must be NOT NULL if tab1 is */
119660120620
}
119661120621
/* Default values for second and subsequent columns need to match. */
119662
- if( i>0 ){
120622
+ if( (pDestCol->colFlags & COLFLAG_GENERATED)==0 && i>0 ){
119663120623
assert( pDestCol->pDflt==0 || pDestCol->pDflt->op==TK_SPAN );
119664120624
assert( pSrcCol->pDflt==0 || pSrcCol->pDflt->op==TK_SPAN );
119665120625
if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0)
119666120626
|| (pDestCol->pDflt && strcmp(pDestCol->pDflt->u.zToken,
119667120627
pSrcCol->pDflt->u.zToken)!=0)
@@ -120342,10 +121302,11 @@
120342121302
/* Version 3.28.0 and later */
120343121303
int (*stmt_isexplain)(sqlite3_stmt*);
120344121304
int (*value_frombind)(sqlite3_value*);
120345121305
/* Version 3.30.0 and later */
120346121306
int (*drop_modules)(sqlite3*,const char**);
121307
+ sqlite3_int64 (*hard_heap_limit64)(sqlite3_int64);
120347121308
};
120348121309
120349121310
/*
120350121311
** This is the function signature used for all extension entry points. It
120351121312
** is also defined in the file "loadext.c".
@@ -120636,10 +121597,11 @@
120636121597
/* Version 3.28.0 and later */
120637121598
#define sqlite3_stmt_isexplain sqlite3_api->isexplain
120638121599
#define sqlite3_value_frombind sqlite3_api->frombind
120639121600
/* Version 3.30.0 and later */
120640121601
#define sqlite3_drop_modules sqlite3_api->drop_modules
121602
+#define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64
120641121603
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
120642121604
120643121605
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
120644121606
/* This case when the file really is being compiled as a loadable
120645121607
** extension */
@@ -121108,10 +122070,12 @@
121108122070
#ifndef SQLITE_OMIT_VIRTUALTABLE
121109122071
sqlite3_drop_modules,
121110122072
#else
121111122073
0,
121112122074
#endif
122075
+ /* Version 3.31.0 and later */
122076
+ sqlite3_hard_heap_limit64,
121113122077
};
121114122078
121115122079
/*
121116122080
** Attempt to load an SQLite extension library contained in the file
121117122081
** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -121530,38 +122494,39 @@
121530122494
#define PragTyp_DEFAULT_CACHE_SIZE 11
121531122495
#define PragTyp_ENCODING 12
121532122496
#define PragTyp_FOREIGN_KEY_CHECK 13
121533122497
#define PragTyp_FOREIGN_KEY_LIST 14
121534122498
#define PragTyp_FUNCTION_LIST 15
121535
-#define PragTyp_INCREMENTAL_VACUUM 16
121536
-#define PragTyp_INDEX_INFO 17
121537
-#define PragTyp_INDEX_LIST 18
121538
-#define PragTyp_INTEGRITY_CHECK 19
121539
-#define PragTyp_JOURNAL_MODE 20
121540
-#define PragTyp_JOURNAL_SIZE_LIMIT 21
121541
-#define PragTyp_LOCK_PROXY_FILE 22
121542
-#define PragTyp_LOCKING_MODE 23
121543
-#define PragTyp_PAGE_COUNT 24
121544
-#define PragTyp_MMAP_SIZE 25
121545
-#define PragTyp_MODULE_LIST 26
121546
-#define PragTyp_OPTIMIZE 27
121547
-#define PragTyp_PAGE_SIZE 28
121548
-#define PragTyp_PRAGMA_LIST 29
121549
-#define PragTyp_SECURE_DELETE 30
121550
-#define PragTyp_SHRINK_MEMORY 31
121551
-#define PragTyp_SOFT_HEAP_LIMIT 32
121552
-#define PragTyp_SYNCHRONOUS 33
121553
-#define PragTyp_TABLE_INFO 34
121554
-#define PragTyp_TEMP_STORE 35
121555
-#define PragTyp_TEMP_STORE_DIRECTORY 36
121556
-#define PragTyp_THREADS 37
121557
-#define PragTyp_WAL_AUTOCHECKPOINT 38
121558
-#define PragTyp_WAL_CHECKPOINT 39
121559
-#define PragTyp_ACTIVATE_EXTENSIONS 40
121560
-#define PragTyp_KEY 41
121561
-#define PragTyp_LOCK_STATUS 42
121562
-#define PragTyp_STATS 43
122499
+#define PragTyp_HARD_HEAP_LIMIT 16
122500
+#define PragTyp_INCREMENTAL_VACUUM 17
122501
+#define PragTyp_INDEX_INFO 18
122502
+#define PragTyp_INDEX_LIST 19
122503
+#define PragTyp_INTEGRITY_CHECK 20
122504
+#define PragTyp_JOURNAL_MODE 21
122505
+#define PragTyp_JOURNAL_SIZE_LIMIT 22
122506
+#define PragTyp_LOCK_PROXY_FILE 23
122507
+#define PragTyp_LOCKING_MODE 24
122508
+#define PragTyp_PAGE_COUNT 25
122509
+#define PragTyp_MMAP_SIZE 26
122510
+#define PragTyp_MODULE_LIST 27
122511
+#define PragTyp_OPTIMIZE 28
122512
+#define PragTyp_PAGE_SIZE 29
122513
+#define PragTyp_PRAGMA_LIST 30
122514
+#define PragTyp_SECURE_DELETE 31
122515
+#define PragTyp_SHRINK_MEMORY 32
122516
+#define PragTyp_SOFT_HEAP_LIMIT 33
122517
+#define PragTyp_SYNCHRONOUS 34
122518
+#define PragTyp_TABLE_INFO 35
122519
+#define PragTyp_TEMP_STORE 36
122520
+#define PragTyp_TEMP_STORE_DIRECTORY 37
122521
+#define PragTyp_THREADS 38
122522
+#define PragTyp_WAL_AUTOCHECKPOINT 39
122523
+#define PragTyp_WAL_CHECKPOINT 40
122524
+#define PragTyp_ACTIVATE_EXTENSIONS 41
122525
+#define PragTyp_KEY 42
122526
+#define PragTyp_LOCK_STATUS 43
122527
+#define PragTyp_STATS 44
121563122528
121564122529
/* Property flags associated with various pragma. */
121565122530
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
121566122531
#define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
121567122532
#define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -121828,10 +122793,15 @@
121828122793
/* ePragFlg: */ PragFlg_Result0,
121829122794
/* ColNames: */ 41, 2,
121830122795
/* iArg: */ 0 },
121831122796
#endif
121832122797
#endif
122798
+ {/* zName: */ "hard_heap_limit",
122799
+ /* ePragTyp: */ PragTyp_HARD_HEAP_LIMIT,
122800
+ /* ePragFlg: */ PragFlg_Result0,
122801
+ /* ColNames: */ 0, 0,
122802
+ /* iArg: */ 0 },
121833122803
#if defined(SQLITE_HAS_CODEC)
121834122804
{/* zName: */ "hexkey",
121835122805
/* ePragTyp: */ PragTyp_KEY,
121836122806
/* ePragFlg: */ 0,
121837122807
/* ColNames: */ 0, 0,
@@ -121905,15 +122875,10 @@
121905122875
{/* zName: */ "legacy_alter_table",
121906122876
/* ePragTyp: */ PragTyp_FLAG,
121907122877
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121908122878
/* ColNames: */ 0, 0,
121909122879
/* iArg: */ SQLITE_LegacyAlter },
121910
- {/* zName: */ "legacy_file_format",
121911
- /* ePragTyp: */ PragTyp_FLAG,
121912
- /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121913
- /* ColNames: */ 0, 0,
121914
- /* iArg: */ SQLITE_LegacyFileFmt },
121915122880
#endif
121916122881
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE
121917122882
{/* zName: */ "lock_proxy_file",
121918122883
/* ePragTyp: */ PragTyp_LOCK_PROXY_FILE,
121919122884
/* ePragFlg: */ PragFlg_NoColumns1,
@@ -123252,29 +124217,38 @@
123252124217
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
123253124218
pParse->nMem = 7;
123254124219
sqlite3CodeVerifySchema(pParse, iTabDb);
123255124220
sqlite3ViewGetColumnNames(pParse, pTab);
123256124221
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
123257
- int isHidden = IsHiddenColumn(pCol);
123258
- if( isHidden && pPragma->iArg==0 ){
123259
- nHidden++;
123260
- continue;
124222
+ int isHidden = 0;
124223
+ if( pCol->colFlags & COLFLAG_NOINSERT ){
124224
+ if( pPragma->iArg==0 ){
124225
+ nHidden++;
124226
+ continue;
124227
+ }
124228
+ if( pCol->colFlags & COLFLAG_VIRTUAL ){
124229
+ isHidden = 2; /* GENERATED ALWAYS AS ... VIRTUAL */
124230
+ }else if( pCol->colFlags & COLFLAG_STORED ){
124231
+ isHidden = 3; /* GENERATED ALWAYS AS ... STORED */
124232
+ }else{ assert( pCol->colFlags & COLFLAG_HIDDEN );
124233
+ isHidden = 1; /* HIDDEN */
124234
+ }
123261124235
}
123262124236
if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
123263124237
k = 0;
123264124238
}else if( pPk==0 ){
123265124239
k = 1;
123266124240
}else{
123267124241
for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
123268124242
}
123269
- assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN );
124243
+ assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN || isHidden>=2 );
123270124244
sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? "issisii" : "issisi",
123271124245
i-nHidden,
123272124246
pCol->zName,
123273124247
sqlite3ColumnType(pCol,""),
123274124248
pCol->notNull ? 1 : 0,
123275
- pCol->pDflt ? pCol->pDflt->u.zToken : 0,
124249
+ pCol->pDflt && isHidden<2 ? pCol->pDflt->u.zToken : 0,
123276124250
k,
123277124251
isHidden);
123278124252
}
123279124253
}
123280124254
}
@@ -123729,11 +124703,11 @@
123729124703
assert( sqlite3NoTempsInRange(pParse,1,7+j) );
123730124704
sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
123731124705
loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
123732124706
if( !isQuick ){
123733124707
/* Sanity check on record header decoding */
123734
- sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3);
124708
+ sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nNVCol-1,3);
123735124709
sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
123736124710
}
123737124711
/* Verify that all NOT NULL columns really are NOT NULL */
123738124712
for(j=0; j<pTab->nCol; j++){
123739124713
char *zErr;
@@ -124231,10 +125205,31 @@
124231125205
sqlite3_soft_heap_limit64(N);
124232125206
}
124233125207
returnSingleInt(v, sqlite3_soft_heap_limit64(-1));
124234125208
break;
124235125209
}
125210
+
125211
+ /*
125212
+ ** PRAGMA hard_heap_limit
125213
+ ** PRAGMA hard_heap_limit = N
125214
+ **
125215
+ ** Invoke sqlite3_hard_heap_limit64() to query or set the hard heap
125216
+ ** limit. The hard heap limit can be activated or lowered by this
125217
+ ** pragma, but not raised or deactivated. Only the
125218
+ ** sqlite3_hard_heap_limit64() C-language API can raise or deactivate
125219
+ ** the hard heap limit. This allows an application to set a heap limit
125220
+ ** constraint that cannot be relaxed by an untrusted SQL script.
125221
+ */
125222
+ case PragTyp_HARD_HEAP_LIMIT: {
125223
+ sqlite3_int64 N;
125224
+ if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){
125225
+ sqlite3_int64 iPrior = sqlite3_hard_heap_limit64(-1);
125226
+ if( N>0 && (iPrior==0 || iPrior>N) ) sqlite3_hard_heap_limit64(N);
125227
+ }
125228
+ returnSingleInt(v, sqlite3_hard_heap_limit64(-1));
125229
+ break;
125230
+ }
124236125231
124237125232
/*
124238125233
** PRAGMA threads
124239125234
** PRAGMA threads = N
124240125235
**
@@ -124724,10 +125719,22 @@
124724125719
for(p=pIndex->pTable->pIndex; p; p=p->pNext){
124725125720
if( p->tnum==pIndex->tnum && p!=pIndex ) return 1;
124726125721
}
124727125722
return 0;
124728125723
}
125724
+
125725
+/* forward declaration */
125726
+static int sqlite3Prepare(
125727
+ sqlite3 *db, /* Database handle. */
125728
+ const char *zSql, /* UTF-8 encoded SQL statement. */
125729
+ int nBytes, /* Length of zSql in bytes. */
125730
+ u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
125731
+ Vdbe *pReprepare, /* VM being reprepared */
125732
+ sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
125733
+ const char **pzTail /* OUT: End of parsed string */
125734
+);
125735
+
124729125736
124730125737
/*
124731125738
** This is the callback routine for the code that initializes the
124732125739
** database. See sqlite3Init() below for additional information.
124733125740
** This routine is also called from the OP_ParseSchema opcode of the VDBE.
@@ -124774,11 +125781,12 @@
124774125781
assert( db->init.busy );
124775125782
db->init.iDb = iDb;
124776125783
db->init.newTnum = sqlite3Atoi(argv[3]);
124777125784
db->init.orphanTrigger = 0;
124778125785
db->init.azInit = argv;
124779
- TESTONLY(rcp = ) sqlite3_prepare(db, argv[4], -1, &pStmt, 0);
125786
+ pStmt = 0;
125787
+ TESTONLY(rcp = ) sqlite3Prepare(db, argv[4], -1, 0, 0, &pStmt, 0);
124780125788
rc = db->errCode;
124781125789
assert( (rc&0xFF)==(rcp&0xFF) );
124782125790
db->init.iDb = saved_iDb;
124783125791
/* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */
124784125792
if( SQLITE_OK!=rc ){
@@ -125195,10 +126203,11 @@
125195126203
sqlite3DbFree(db, pParse->aLabel);
125196126204
sqlite3ExprListDelete(db, pParse->pConstExpr);
125197126205
if( db ){
125198126206
assert( db->lookaside.bDisable >= pParse->disableLookaside );
125199126207
db->lookaside.bDisable -= pParse->disableLookaside;
126208
+ db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue;
125200126209
}
125201126210
pParse->disableLookaside = 0;
125202126211
}
125203126212
125204126213
/*
@@ -125228,11 +126237,11 @@
125228126237
/* For a long-term use prepared statement avoid the use of
125229126238
** lookaside memory.
125230126239
*/
125231126240
if( prepFlags & SQLITE_PREPARE_PERSISTENT ){
125232126241
sParse.disableLookaside++;
125233
- db->lookaside.bDisable++;
126242
+ DisableLookaside;
125234126243
}
125235126244
sParse.disableVtab = (prepFlags & SQLITE_PREPARE_NO_VTAB)!=0;
125236126245
125237126246
/* Check to verify that it is possible to get a read lock on all
125238126247
** database schemas. The inability to get a read lock indicates that
@@ -125255,20 +126264,22 @@
125255126264
**
125256126265
** Note that setting READ_UNCOMMITTED overrides most lock detection,
125257126266
** but it does *not* override schema lock detection, so this all still
125258126267
** works even if READ_UNCOMMITTED is set.
125259126268
*/
125260
- for(i=0; i<db->nDb; i++) {
125261
- Btree *pBt = db->aDb[i].pBt;
125262
- if( pBt ){
125263
- assert( sqlite3BtreeHoldsMutex(pBt) );
125264
- rc = sqlite3BtreeSchemaLocked(pBt);
125265
- if( rc ){
125266
- const char *zDb = db->aDb[i].zDbSName;
125267
- sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
125268
- testcase( db->flags & SQLITE_ReadUncommit );
125269
- goto end_prepare;
126269
+ if( !db->noSharedCache ){
126270
+ for(i=0; i<db->nDb; i++) {
126271
+ Btree *pBt = db->aDb[i].pBt;
126272
+ if( pBt ){
126273
+ assert( sqlite3BtreeHoldsMutex(pBt) );
126274
+ rc = sqlite3BtreeSchemaLocked(pBt);
126275
+ if( rc ){
126276
+ const char *zDb = db->aDb[i].zDbSName;
126277
+ sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
126278
+ testcase( db->flags & SQLITE_ReadUncommit );
126279
+ goto end_prepare;
126280
+ }
125270126281
}
125271126282
}
125272126283
}
125273126284
125274126285
sqlite3VtabUnlockList(db);
@@ -125295,52 +126306,28 @@
125295126306
}else{
125296126307
sqlite3RunParser(&sParse, zSql, &zErrMsg);
125297126308
}
125298126309
assert( 0==sParse.nQueryLoop );
125299126310
125300
- if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;
126311
+ if( sParse.rc==SQLITE_DONE ){
126312
+ sParse.rc = SQLITE_OK;
126313
+ }
125301126314
if( sParse.checkSchema ){
125302126315
schemaIsValid(&sParse);
125303126316
}
125304
- if( db->mallocFailed ){
125305
- sParse.rc = SQLITE_NOMEM_BKPT;
125306
- }
125307126317
if( pzTail ){
125308126318
*pzTail = sParse.zTail;
125309126319
}
125310
- rc = sParse.rc;
125311
-
125312
-#ifndef SQLITE_OMIT_EXPLAIN
125313
- /* Justification for the ALWAYS(): The only way for rc to be SQLITE_OK and
125314
- ** sParse.pVdbe to be NULL is if the input SQL is an empty string, but in
125315
- ** that case, sParse.explain will be false. */
125316
- if( sParse.explain && rc==SQLITE_OK && ALWAYS(sParse.pVdbe) ){
125317
- static const char * const azColName[] = {
125318
- "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment",
125319
- "id", "parent", "notused", "detail"
125320
- };
125321
- int iFirst, mx;
125322
- if( sParse.explain==2 ){
125323
- sqlite3VdbeSetNumCols(sParse.pVdbe, 4);
125324
- iFirst = 8;
125325
- mx = 12;
125326
- }else{
125327
- sqlite3VdbeSetNumCols(sParse.pVdbe, 8);
125328
- iFirst = 0;
125329
- mx = 8;
125330
- }
125331
- for(i=iFirst; i<mx; i++){
125332
- sqlite3VdbeSetColName(sParse.pVdbe, i-iFirst, COLNAME_NAME,
125333
- azColName[i], SQLITE_STATIC);
125334
- }
125335
- }
125336
-#endif
125337126320
125338126321
if( db->init.busy==0 ){
125339126322
sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);
125340126323
}
125341
- if( rc!=SQLITE_OK || db->mallocFailed ){
126324
+ if( db->mallocFailed ){
126325
+ sParse.rc = SQLITE_NOMEM_BKPT;
126326
+ }
126327
+ rc = sParse.rc;
126328
+ if( rc!=SQLITE_OK ){
125342126329
if( sParse.pVdbe ) sqlite3VdbeFinalize(sParse.pVdbe);
125343126330
assert(!(*ppStmt));
125344126331
}else{
125345126332
*ppStmt = (sqlite3_stmt*)sParse.pVdbe;
125346126333
}
@@ -125708,13 +126695,13 @@
125708126695
sqlite3ExprDelete(db, p->pLimit);
125709126696
#ifndef SQLITE_OMIT_WINDOWFUNC
125710126697
if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){
125711126698
sqlite3WindowListDelete(db, p->pWinDefn);
125712126699
}
125713
-#endif
125714
- if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);
125715126700
assert( p->pWin==0 );
126701
+#endif
126702
+ if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);
125716126703
if( bFree ) sqlite3DbFreeNN(db, p);
125717126704
p = pPrior;
125718126705
bFree = 1;
125719126706
}
125720126707
}
@@ -125993,28 +126980,28 @@
125993126980
** NULL t2 row will be inserted whenever t1.x!=5. If we do not
125994126981
** defer the handling of t1.x=5, it will be processed immediately
125995126982
** after the t1 loop and rows with t1.x!=5 will never appear in
125996126983
** the output, which is incorrect.
125997126984
*/
125998
-static void setJoinExpr(Expr *p, int iTable){
126985
+SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){
125999126986
while( p ){
126000126987
ExprSetProperty(p, EP_FromJoin);
126001126988
assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
126002126989
ExprSetVVAProperty(p, EP_NoReduce);
126003126990
p->iRightJoinTable = (i16)iTable;
126004126991
if( p->op==TK_FUNCTION && p->x.pList ){
126005126992
int i;
126006126993
for(i=0; i<p->x.pList->nExpr; i++){
126007
- setJoinExpr(p->x.pList->a[i].pExpr, iTable);
126994
+ sqlite3SetJoinExpr(p->x.pList->a[i].pExpr, iTable);
126008126995
}
126009126996
}
126010
- setJoinExpr(p->pLeft, iTable);
126997
+ sqlite3SetJoinExpr(p->pLeft, iTable);
126011126998
p = p->pRight;
126012126999
}
126013127000
}
126014127001
126015
-/* Undo the work of setJoinExpr(). In the expression tree p, convert every
127002
+/* Undo the work of sqlite3SetJoinExpr(). In the expression p, convert every
126016127003
** term that is marked with EP_FromJoin and iRightJoinTable==iTable into
126017127004
** an ordinary term that omits the EP_FromJoin mark.
126018127005
**
126019127006
** This happens when a LEFT JOIN is simplified into an ordinary JOIN.
126020127007
*/
@@ -126097,11 +127084,11 @@
126097127084
126098127085
/* Add the ON clause to the end of the WHERE clause, connected by
126099127086
** an AND operator.
126100127087
*/
126101127088
if( pRight->pOn ){
126102
- if( isOuter ) setJoinExpr(pRight->pOn, pRight->iCursor);
127089
+ if( isOuter ) sqlite3SetJoinExpr(pRight->pOn, pRight->iCursor);
126103127090
p->pWhere = sqlite3ExprAnd(pParse, p->pWhere, pRight->pOn);
126104127091
pRight->pOn = 0;
126105127092
}
126106127093
126107127094
/* Create extra terms on the WHERE clause for each column named
@@ -126277,10 +127264,11 @@
126277127264
memset(pKI->aSortFlags, 0, pKI->nKeyField); /* Makes OP_Jump testable */
126278127265
sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
126279127266
testcase( pKI->nAllField > pKI->nKeyField+2 );
126280127267
pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat,
126281127268
pKI->nAllField-pKI->nKeyField-1);
127269
+ pOp = 0; /* Ensure pOp not used after sqltie3VdbeAddOp3() */
126282127270
addrJmp = sqlite3VdbeCurrentAddr(v);
126283127271
sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
126284127272
pSort->labelBkOut = sqlite3VdbeMakeLabel(pParse);
126285127273
pSort->regReturn = ++pParse->nMem;
126286127274
sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
@@ -126639,10 +127627,11 @@
126639127627
sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);
126640127628
pOp = sqlite3VdbeGetOp(v, pDistinct->addrTnct);
126641127629
pOp->opcode = OP_Null;
126642127630
pOp->p1 = 1;
126643127631
pOp->p2 = regPrev;
127632
+ pOp = 0; /* Ensure pOp is not used after sqlite3VdbeAddOp() */
126644127633
126645127634
iJump = sqlite3VdbeCurrentAddr(v) + nResultCol;
126646127635
for(i=0; i<nResultCol; i++){
126647127636
CollSeq *pColl = sqlite3ExprCollSeq(pParse, p->pEList->a[i].pExpr);
126648127637
if( i<nResultCol-1 ){
@@ -129111,10 +130100,18 @@
129111130100
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
129112130101
substSelect(pSubst, pExpr->x.pSelect, 1);
129113130102
}else{
129114130103
substExprList(pSubst, pExpr->x.pList);
129115130104
}
130105
+#ifndef SQLITE_OMIT_WINDOWFUNC
130106
+ if( ExprHasProperty(pExpr, EP_WinFunc) ){
130107
+ Window *pWin = pExpr->y.pWin;
130108
+ pWin->pFilter = substExpr(pSubst, pWin->pFilter);
130109
+ substExprList(pSubst, pWin->pPartition);
130110
+ substExprList(pSubst, pWin->pOrderBy);
130111
+ }
130112
+#endif
129116130113
}
129117130114
return pExpr;
129118130115
}
129119130116
static void substExprList(
129120130117
SubstContext *pSubst, /* Description of the substitution */
@@ -129653,11 +130650,11 @@
129653130650
pSub->pOrderBy = 0;
129654130651
}
129655130652
pWhere = pSub->pWhere;
129656130653
pSub->pWhere = 0;
129657130654
if( isLeftJoin>0 ){
129658
- setJoinExpr(pWhere, iNewParent);
130655
+ sqlite3SetJoinExpr(pWhere, iNewParent);
129659130656
}
129660130657
pParent->pWhere = sqlite3ExprAnd(pParse, pWhere, pParent->pWhere);
129661130658
if( db->mallocFailed==0 ){
129662130659
SubstContext x;
129663130660
x.pParse = pParse;
@@ -129770,18 +130767,18 @@
129770130767
assert( pRight!=0 );
129771130768
assert( pLeft!=0 );
129772130769
if( pRight->op==TK_COLUMN
129773130770
&& !ExprHasProperty(pRight, EP_FixedCol)
129774130771
&& sqlite3ExprIsConstant(pLeft)
129775
- && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight))
130772
+ && sqlite3IsBinary(sqlite3ExprCompareCollSeq(pConst->pParse,pExpr))
129776130773
){
129777130774
constInsert(pConst, pRight, pLeft);
129778130775
}else
129779130776
if( pLeft->op==TK_COLUMN
129780130777
&& !ExprHasProperty(pLeft, EP_FixedCol)
129781130778
&& sqlite3ExprIsConstant(pRight)
129782
- && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight))
130779
+ && sqlite3IsBinary(sqlite3ExprCompareCollSeq(pConst->pParse,pExpr))
129783130780
){
129784130781
constInsert(pConst, pLeft, pRight);
129785130782
}
129786130783
}
129787130784
@@ -130266,10 +131263,13 @@
130266131263
sqlite3 *db = pParse->db;
130267131264
struct Cte *pCte; /* Matched CTE (or NULL if no match) */
130268131265
With *pWith; /* WITH clause that pCte belongs to */
130269131266
130270131267
assert( pFrom->pTab==0 );
131268
+ if( pParse->nErr ){
131269
+ return SQLITE_ERROR;
131270
+ }
130271131271
130272131272
pCte = searchWith(pParse->pWith, pFrom, &pWith);
130273131273
if( pCte ){
130274131274
Table *pTab;
130275131275
ExprList *pEList;
@@ -131327,11 +132327,11 @@
131327132327
#ifndef SQLITE_OMIT_WINDOWFUNC
131328132328
if( sqlite3WindowRewrite(pParse, p) ){
131329132329
goto select_end;
131330132330
}
131331132331
#if SELECTTRACE_ENABLED
131332
- if( sqlite3SelectTrace & 0x108 ){
132332
+ if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){
131333132333
SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n"));
131334132334
sqlite3TreeViewSelect(0, p, 0);
131335132335
}
131336132336
#endif
131337132337
#endif /* SQLITE_OMIT_WINDOWFUNC */
@@ -133864,11 +134864,11 @@
133864134864
int onError, /* How to handle constraint errors */
133865134865
ExprList *pOrderBy, /* ORDER BY clause. May be null */
133866134866
Expr *pLimit, /* LIMIT clause. May be null */
133867134867
Upsert *pUpsert /* ON CONFLICT clause, or null */
133868134868
){
133869
- int i, j; /* Loop counters */
134869
+ int i, j, k; /* Loop counters */
133870134870
Table *pTab; /* The table to be updated */
133871134871
int addrTop = 0; /* VDBE instruction address of the start of the loop */
133872134872
WhereInfo *pWInfo; /* Information about the WHERE clause */
133873134873
Vdbe *v; /* The virtual database engine */
133874134874
Index *pIdx; /* For looping over indices */
@@ -134006,10 +135006,14 @@
134006135006
sNC.pParse = pParse;
134007135007
sNC.pSrcList = pTabList;
134008135008
sNC.uNC.pUpsert = pUpsert;
134009135009
sNC.ncFlags = NC_UUpsert;
134010135010
135011
+ /* Begin generating code. */
135012
+ v = sqlite3GetVdbe(pParse);
135013
+ if( v==0 ) goto update_cleanup;
135014
+
134011135015
/* Resolve the column names in all the expressions of the
134012135016
** of the UPDATE statement. Also find the column index
134013135017
** for each column to be updated in the pChanges array. For each
134014135018
** column to be updated, make sure we have authorization to change
134015135019
** that column.
@@ -134025,10 +135029,20 @@
134025135029
chngRowid = 1;
134026135030
pRowidExpr = pChanges->a[i].pExpr;
134027135031
}else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){
134028135032
chngPk = 1;
134029135033
}
135034
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
135035
+ else if( pTab->aCol[j].colFlags & COLFLAG_GENERATED ){
135036
+ testcase( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL );
135037
+ testcase( pTab->aCol[j].colFlags & COLFLAG_STORED );
135038
+ sqlite3ErrorMsg(pParse,
135039
+ "cannot UPDATE generated column \"%s\"",
135040
+ pTab->aCol[j].zName);
135041
+ goto update_cleanup;
135042
+ }
135043
+#endif
134030135044
aXRef[j] = i;
134031135045
break;
134032135046
}
134033135047
}
134034135048
if( j>=pTab->nCol ){
@@ -134058,10 +135072,37 @@
134058135072
}
134059135073
assert( (chngRowid & chngPk)==0 );
134060135074
assert( chngRowid==0 || chngRowid==1 );
134061135075
assert( chngPk==0 || chngPk==1 );
134062135076
chngKey = chngRowid + chngPk;
135077
+
135078
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
135079
+ /* Mark generated columns as changing if their generator expressions
135080
+ ** reference any changing column. The actual aXRef[] value for
135081
+ ** generated expressions is not used, other than to check to see that it
135082
+ ** is non-negative, so the value of aXRef[] for generated columns can be
135083
+ ** set to any non-negative number. We use 99999 so that the value is
135084
+ ** obvious when looking at aXRef[] in a symbolic debugger.
135085
+ */
135086
+ if( pTab->tabFlags & TF_HasGenerated ){
135087
+ int bProgress;
135088
+ testcase( pTab->tabFlags & TF_HasVirtual );
135089
+ testcase( pTab->tabFlags & TF_HasStored );
135090
+ do{
135091
+ bProgress = 0;
135092
+ for(i=0; i<pTab->nCol; i++){
135093
+ if( aXRef[i]>=0 ) continue;
135094
+ if( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 ) continue;
135095
+ if( sqlite3ExprReferencesUpdatedColumn(pTab->aCol[i].pDflt,
135096
+ aXRef, chngRowid) ){
135097
+ aXRef[i] = 99999;
135098
+ bProgress = 1;
135099
+ }
135100
+ }
135101
+ }while( bProgress );
135102
+ }
135103
+#endif
134063135104
134064135105
/* The SET expressions are not actually used inside the WHERE loop.
134065135106
** So reset the colUsed mask. Unless this is a virtual table. In that
134066135107
** case, set all bits of the colUsed mask (to ensure that the virtual
134067135108
** table implementation makes all columns available).
@@ -134103,13 +135144,10 @@
134103135144
/* If REPLACE conflict resolution might be invoked, open cursors on all
134104135145
** indexes in case they are needed to delete records. */
134105135146
memset(aToOpen, 1, nIdx+1);
134106135147
}
134107135148
134108
- /* Begin generating code. */
134109
- v = sqlite3GetVdbe(pParse);
134110
- if( v==0 ) goto update_cleanup;
134111135149
if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
134112135150
sqlite3BeginWriteOperation(pParse, pTrigger || hasFK, iDb);
134113135151
134114135152
/* Allocate required registers. */
134115135153
if( !IsVirtual(pTab) ){
@@ -134259,11 +135297,12 @@
134259135297
** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change
134260135298
** the OP_OpenEphemeral instruction to a Noop (the ephemeral table
134261135299
** is not required) and leave the PK fields in the array of registers. */
134262135300
for(i=0; i<nPk; i++){
134263135301
assert( pPk->aiColumn[i]>=0 );
134264
- sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,pPk->aiColumn[i],iPk+i);
135302
+ sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,
135303
+ pPk->aiColumn[i], iPk+i);
134265135304
}
134266135305
if( eOnePass ){
134267135306
if( addrOpen ) sqlite3VdbeChangeToNoop(v, addrOpen);
134268135307
nKey = nPk;
134269135308
regKey = iPk;
@@ -134340,18 +135379,20 @@
134340135379
u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);
134341135380
oldmask |= sqlite3TriggerColmask(pParse,
134342135381
pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError
134343135382
);
134344135383
for(i=0; i<pTab->nCol; i++){
135384
+ u32 colFlags = pTab->aCol[i].colFlags;
135385
+ k = sqlite3TableColumnToStorage(pTab, i) + regOld;
134345135386
if( oldmask==0xffffffff
134346135387
|| (i<32 && (oldmask & MASKBIT32(i))!=0)
134347
- || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0
135388
+ || (colFlags & COLFLAG_PRIMKEY)!=0
134348135389
){
134349135390
testcase( oldmask!=0xffffffff && i==31 );
134350
- sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i);
135391
+ sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, k);
134351135392
}else{
134352
- sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);
135393
+ sqlite3VdbeAddOp2(v, OP_Null, 0, k);
134353135394
}
134354135395
}
134355135396
if( chngRowid==0 && pPk==0 ){
134356135397
sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);
134357135398
}
@@ -134371,31 +135412,40 @@
134371135412
** be used eliminates some redundant opcodes.
134372135413
*/
134373135414
newmask = sqlite3TriggerColmask(
134374135415
pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError
134375135416
);
134376
- for(i=0; i<pTab->nCol; i++){
135417
+ for(i=0, k=regNew; i<pTab->nCol; i++, k++){
134377135418
if( i==pTab->iPKey ){
134378
- sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
135419
+ sqlite3VdbeAddOp2(v, OP_Null, 0, k);
135420
+ }else if( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)!=0 ){
135421
+ if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ) k--;
134379135422
}else{
134380135423
j = aXRef[i];
134381135424
if( j>=0 ){
134382
- sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
135425
+ sqlite3ExprCode(pParse, pChanges->a[j].pExpr, k);
134383135426
}else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){
134384135427
/* This branch loads the value of a column that will not be changed
134385135428
** into a register. This is done if there are no BEFORE triggers, or
134386135429
** if there are one or more BEFORE triggers that use this value via
134387135430
** a new.* reference in a trigger program.
134388135431
*/
134389135432
testcase( i==31 );
134390135433
testcase( i==32 );
134391
- sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i);
135434
+ sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, k);
134392135435
}else{
134393
- sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
135436
+ sqlite3VdbeAddOp2(v, OP_Null, 0, k);
134394135437
}
134395135438
}
134396135439
}
135440
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
135441
+ if( pTab->tabFlags & TF_HasGenerated ){
135442
+ testcase( pTab->tabFlags & TF_HasVirtual );
135443
+ testcase( pTab->tabFlags & TF_HasStored );
135444
+ sqlite3ComputeGeneratedColumns(pParse, regNew, pTab);
135445
+ }
135446
+#endif
134397135447
134398135448
/* Fire any BEFORE UPDATE triggers. This happens before constraints are
134399135449
** verified. One could argue that this is wrong.
134400135450
*/
134401135451
if( tmask&TRIGGER_BEFORE ){
@@ -134424,15 +135474,24 @@
134424135474
** in case this has happened. Only unmodified columns are reloaded.
134425135475
** The values computed for modified columns use the values before the
134426135476
** BEFORE trigger runs. See test case trigger1-18.0 (added 2018-04-26)
134427135477
** for an example.
134428135478
*/
134429
- for(i=0; i<pTab->nCol; i++){
134430
- if( aXRef[i]<0 && i!=pTab->iPKey ){
134431
- sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i);
135479
+ for(i=0, k=regNew; i<pTab->nCol; i++, k++){
135480
+ if( pTab->aCol[i].colFlags & COLFLAG_GENERATED ){
135481
+ if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ) k--;
135482
+ }else if( aXRef[i]<0 && i!=pTab->iPKey ){
135483
+ sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, k);
134432135484
}
134433135485
}
135486
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
135487
+ if( pTab->tabFlags & TF_HasGenerated ){
135488
+ testcase( pTab->tabFlags & TF_HasVirtual );
135489
+ testcase( pTab->tabFlags & TF_HasStored );
135490
+ sqlite3ComputeGeneratedColumns(pParse, regNew, pTab);
135491
+ }
135492
+#endif
134434135493
}
134435135494
134436135495
if( !isView ){
134437135496
/* Do constraint checks. */
134438135497
assert( regOldRowid>0 );
@@ -134634,10 +135693,11 @@
134634135693
pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0,0,WHERE_ONEPASS_DESIRED,0);
134635135694
if( pWInfo==0 ) return;
134636135695
134637135696
/* Populate the argument registers. */
134638135697
for(i=0; i<pTab->nCol; i++){
135698
+ assert( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 );
134639135699
if( aXRef[i]>=0 ){
134640135700
sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);
134641135701
}else{
134642135702
sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i);
134643135703
sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG);/* Enable sqlite3_vtab_nochange() */
@@ -134944,11 +136004,11 @@
134944136004
int iPk = pParse->nMem+1;
134945136005
pParse->nMem += nPk;
134946136006
for(i=0; i<nPk; i++){
134947136007
int k;
134948136008
assert( pPk->aiColumn[i]>=0 );
134949
- k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
136009
+ k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]);
134950136010
sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i);
134951136011
VdbeComment((v, "%s.%s", pIdx->zName,
134952136012
pTab->aCol[pPk->aiColumn[i]].zName));
134953136013
}
134954136014
sqlite3VdbeVerifyAbortable(v, OE_Abort);
@@ -135702,16 +136762,16 @@
135702136762
** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously
135703136763
** by multiple threads. It is thread-safe.
135704136764
*/
135705136765
SQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3 *db){
135706136766
VTable *p = db->pDisconnect;
135707
- db->pDisconnect = 0;
135708136767
135709136768
assert( sqlite3BtreeHoldsAllMutexes(db) );
135710136769
assert( sqlite3_mutex_held(db->mutex) );
135711136770
135712136771
if( p ){
136772
+ db->pDisconnect = 0;
135713136773
sqlite3ExpirePreparedStatements(db, 0);
135714136774
do {
135715136775
VTable *pNext = p->pNext;
135716136776
sqlite3VtabUnlock(p);
135717136777
p = pNext;
@@ -136021,11 +137081,11 @@
136021137081
*pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
136022137082
sqlite3VtabUnlock(pVTable);
136023137083
rc = SQLITE_ERROR;
136024137084
}else{
136025137085
int iCol;
136026
- u8 oooHidden = 0;
137086
+ u16 oooHidden = 0;
136027137087
/* If everything went according to plan, link the new VTable structure
136028137088
** into the linked list headed by pTab->pVTable. Then loop through the
136029137089
** columns of the table to see if any of them contain the token "hidden".
136030137090
** If so, set the Column COLFLAG_HIDDEN flag and remove the token from
136031137091
** the type string. */
@@ -137017,11 +138077,10 @@
137017138077
#define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
137018138078
#define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
137019138079
#define TERM_LIKE 0x400 /* The original LIKE operator */
137020138080
#define TERM_IS 0x800 /* Term.pExpr is an IS operator */
137021138081
#define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
137022
-#define TERM_NOPARTIDX 0x2000 /* Not for use to enable a partial index */
137023138082
137024138083
/*
137025138084
** An instance of the WhereScan object is used as an iterator for locating
137026138085
** terms in the WHERE clause that are useful to the query planner.
137027138086
*/
@@ -138125,11 +139184,11 @@
138125139184
static int codeCursorHintCheckExpr(Walker *pWalker, Expr *pExpr){
138126139185
struct CCurHint *pHint = pWalker->u.pCCurHint;
138127139186
assert( pHint->pIdx!=0 );
138128139187
if( pExpr->op==TK_COLUMN
138129139188
&& pExpr->iTable==pHint->iTabCur
138130
- && sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn)<0
139189
+ && sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn)<0
138131139190
){
138132139191
pWalker->eCode = 1;
138133139192
}
138134139193
return WRC_Continue;
138135139194
}
@@ -138193,11 +139252,11 @@
138193139252
sqlite3ExprCode(pWalker->pParse, pExpr, reg);
138194139253
pExpr->op = TK_REGISTER;
138195139254
pExpr->iTable = reg;
138196139255
}else if( pHint->pIdx!=0 ){
138197139256
pExpr->iTable = pHint->iIdxCur;
138198
- pExpr->iColumn = sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn);
139257
+ pExpr->iColumn = sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn);
138199139258
assert( pExpr->iColumn>=0 );
138200139259
}
138201139260
}else if( pExpr->op==TK_AGG_FUNCTION ){
138202139261
/* An aggregate function in the WHERE clause of a query means this must
138203139262
** be a correlated sub-query, and expression pExpr is an aggregate from
@@ -138356,12 +139415,16 @@
138356139415
Table *pTab = pIdx->pTable;
138357139416
int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));
138358139417
if( ai ){
138359139418
ai[0] = pTab->nCol;
138360139419
for(i=0; i<pIdx->nColumn-1; i++){
139420
+ int x1, x2;
138361139421
assert( pIdx->aiColumn[i]<pTab->nCol );
138362
- if( pIdx->aiColumn[i]>=0 ) ai[pIdx->aiColumn[i]+1] = i+1;
139422
+ x1 = pIdx->aiColumn[i];
139423
+ x2 = sqlite3TableColumnToStorage(pTab, x1);
139424
+ testcase( x1!=x2 );
139425
+ if( x1>=0 ) ai[x2+1] = i+1;
138363139426
}
138364139427
sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY);
138365139428
}
138366139429
}
138367139430
}
@@ -138408,10 +139471,11 @@
138408139471
typedef struct IdxExprTrans {
138409139472
Expr *pIdxExpr; /* The index expression */
138410139473
int iTabCur; /* The cursor of the corresponding table */
138411139474
int iIdxCur; /* The cursor for the index */
138412139475
int iIdxCol; /* The column for the index */
139476
+ int iTabCol; /* The column for the table */
138413139477
} IdxExprTrans;
138414139478
138415139479
/* The walker node callback used to transform matching expressions into
138416139480
** a reference to an index column for an index on an expression.
138417139481
**
@@ -138430,37 +139494,73 @@
138430139494
}else{
138431139495
return WRC_Continue;
138432139496
}
138433139497
}
138434139498
139499
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
139500
+/* A walker node callback that translates a column reference to a table
139501
+** into a corresponding column reference of an index.
139502
+*/
139503
+static int whereIndexExprTransColumn(Walker *p, Expr *pExpr){
139504
+ if( pExpr->op==TK_COLUMN ){
139505
+ IdxExprTrans *pX = p->u.pIdxTrans;
139506
+ if( pExpr->iTable==pX->iTabCur && pExpr->iColumn==pX->iTabCol ){
139507
+ pExpr->iTable = pX->iIdxCur;
139508
+ pExpr->iColumn = pX->iIdxCol;
139509
+ pExpr->y.pTab = 0;
139510
+ }
139511
+ }
139512
+ return WRC_Continue;
139513
+}
139514
+#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
139515
+
138435139516
/*
138436139517
** For an indexes on expression X, locate every instance of expression X
138437139518
** in pExpr and change that subexpression into a reference to the appropriate
138438139519
** column of the index.
139520
+**
139521
+** 2019-10-24: Updated to also translate references to a VIRTUAL column in
139522
+** the table into references to the corresponding (stored) column of the
139523
+** index.
138439139524
*/
138440139525
static void whereIndexExprTrans(
138441139526
Index *pIdx, /* The Index */
138442139527
int iTabCur, /* Cursor of the table that is being indexed */
138443139528
int iIdxCur, /* Cursor of the index itself */
138444139529
WhereInfo *pWInfo /* Transform expressions in this WHERE clause */
138445139530
){
138446139531
int iIdxCol; /* Column number of the index */
138447139532
ExprList *aColExpr; /* Expressions that are indexed */
139533
+ Table *pTab;
138448139534
Walker w;
138449139535
IdxExprTrans x;
138450139536
aColExpr = pIdx->aColExpr;
138451
- if( aColExpr==0 ) return; /* Not an index on expressions */
139537
+ if( aColExpr==0 && !pIdx->bHasVCol ){
139538
+ /* The index does not reference any expressions or virtual columns
139539
+ ** so no translations are needed. */
139540
+ return;
139541
+ }
139542
+ pTab = pIdx->pTable;
138452139543
memset(&w, 0, sizeof(w));
138453
- w.xExprCallback = whereIndexExprTransNode;
138454139544
w.u.pIdxTrans = &x;
138455139545
x.iTabCur = iTabCur;
138456139546
x.iIdxCur = iIdxCur;
138457
- for(iIdxCol=0; iIdxCol<aColExpr->nExpr; iIdxCol++){
138458
- if( pIdx->aiColumn[iIdxCol]!=XN_EXPR ) continue;
138459
- assert( aColExpr->a[iIdxCol].pExpr!=0 );
139547
+ for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){
139548
+ i16 iRef = pIdx->aiColumn[iIdxCol];
139549
+ if( iRef==XN_EXPR ){
139550
+ assert( aColExpr->a[iIdxCol].pExpr!=0 );
139551
+ x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;
139552
+ w.xExprCallback = whereIndexExprTransNode;
139553
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
139554
+ }else if( iRef>=0 && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0 ){
139555
+ x.iTabCol = iRef;
139556
+ w.xExprCallback = whereIndexExprTransColumn;
139557
+#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
139558
+ }else{
139559
+ continue;
139560
+ }
138460139561
x.iIdxCol = iIdxCol;
138461
- x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;
138462139562
sqlite3WalkExpr(&w, pWInfo->pWhere);
138463139563
sqlite3WalkExprList(&w, pWInfo->pOrderBy);
138464139564
sqlite3WalkExprList(&w, pWInfo->pResultSet);
138465139565
}
138466139566
}
@@ -138607,13 +139707,16 @@
138607139707
pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;
138608139708
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
138609139709
iIn = pLevel->u.in.nIn;
138610139710
for(j=nConstraint-1; j>=0; j--){
138611139711
pTerm = pLoop->aLTerm[j];
139712
+ if( (pTerm->eOperator & WO_IN)!=0 ) iIn--;
138612139713
if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
138613139714
disableTerm(pLevel, pTerm);
138614
- }else if( (pTerm->eOperator & WO_IN)!=0 ){
139715
+ }else if( (pTerm->eOperator & WO_IN)!=0
139716
+ && sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1
139717
+ ){
138615139718
Expr *pCompare; /* The comparison operator */
138616139719
Expr *pRight; /* RHS of the comparison */
138617139720
VdbeOp *pOp; /* Opcode to access the value of the IN constraint */
138618139721
138619139722
/* Reload the constraint value into reg[iReg+j+2]. The same value
@@ -138620,12 +139723,12 @@
138620139723
** was loaded into the same register prior to the OP_VFilter, but
138621139724
** the xFilter implementation might have changed the datatype or
138622139725
** encoding of the value in the register, so it *must* be reloaded. */
138623139726
assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );
138624139727
if( !db->mallocFailed ){
138625
- assert( iIn>0 );
138626
- pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[--iIn].addrInTop);
139728
+ assert( iIn>=0 && iIn<pLevel->u.in.nIn );
139729
+ pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[iIn].addrInTop);
138627139730
assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );
138628139731
assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );
138629139732
assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );
138630139733
testcase( pOp->opcode==OP_Rowid );
138631139734
sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
@@ -138645,10 +139748,11 @@
138645139748
pCompare->pLeft = 0;
138646139749
sqlite3ExprDelete(db, pCompare);
138647139750
}
138648139751
}
138649139752
}
139753
+ assert( iIn==0 || db->mallocFailed );
138650139754
/* These registers need to be preserved in case there is an IN operator
138651139755
** loop. So we could deallocate the registers here (and potentially
138652139756
** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems
138653139757
** simpler and safer to simply not reuse the registers.
138654139758
**
@@ -139124,44 +140228,57 @@
139124140228
}
139125140229
}else if( iCur!=iIdxCur ){
139126140230
Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
139127140231
iRowidReg = sqlite3GetTempRange(pParse, pPk->nKeyCol);
139128140232
for(j=0; j<pPk->nKeyCol; j++){
139129
- k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);
140233
+ k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[j]);
139130140234
sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j);
139131140235
}
139132140236
sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,
139133140237
iRowidReg, pPk->nKeyCol); VdbeCoverage(v);
139134140238
}
139135140239
139136
- /* If pIdx is an index on one or more expressions, then look through
139137
- ** all the expressions in pWInfo and try to transform matching expressions
139138
- ** into reference to index columns.
139139
- **
139140
- ** Do not do this for the RHS of a LEFT JOIN. This is because the
139141
- ** expression may be evaluated after OP_NullRow has been executed on
139142
- ** the cursor. In this case it is important to do the full evaluation,
139143
- ** as the result of the expression may not be NULL, even if all table
139144
- ** column values are. https://www.sqlite.org/src/info/7fa8049685b50b5a
139145
- **
139146
- ** Also, do not do this when processing one index an a multi-index
139147
- ** OR clause, since the transformation will become invalid once we
139148
- ** move forward to the next index.
139149
- ** https://sqlite.org/src/info/4e8e4857d32d401f
139150
- */
139151
- if( pLevel->iLeftJoin==0 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){
139152
- whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
139153
- }
139154
-
139155
- /* If a partial index is driving the loop, try to eliminate WHERE clause
139156
- ** terms from the query that must be true due to the WHERE clause of
139157
- ** the partial index
139158
- */
139159
- if( pIdx->pPartIdxWhere ){
139160
- whereApplyPartialIndexConstraints(pIdx->pPartIdxWhere, iCur, pWC);
139161
- }
139162
-
140240
+ if( pLevel->iLeftJoin==0 ){
140241
+ /* If pIdx is an index on one or more expressions, then look through
140242
+ ** all the expressions in pWInfo and try to transform matching expressions
140243
+ ** into reference to index columns. Also attempt to translate references
140244
+ ** to virtual columns in the table into references to (stored) columns
140245
+ ** of the index.
140246
+ **
140247
+ ** Do not do this for the RHS of a LEFT JOIN. This is because the
140248
+ ** expression may be evaluated after OP_NullRow has been executed on
140249
+ ** the cursor. In this case it is important to do the full evaluation,
140250
+ ** as the result of the expression may not be NULL, even if all table
140251
+ ** column values are. https://www.sqlite.org/src/info/7fa8049685b50b5a
140252
+ **
140253
+ ** Also, do not do this when processing one index an a multi-index
140254
+ ** OR clause, since the transformation will become invalid once we
140255
+ ** move forward to the next index.
140256
+ ** https://sqlite.org/src/info/4e8e4857d32d401f
140257
+ */
140258
+ if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){
140259
+ whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
140260
+ }
140261
+
140262
+ /* If a partial index is driving the loop, try to eliminate WHERE clause
140263
+ ** terms from the query that must be true due to the WHERE clause of
140264
+ ** the partial index.
140265
+ **
140266
+ ** 2019-11-02 ticket 623eff57e76d45f6: This optimization does not work
140267
+ ** for a LEFT JOIN.
140268
+ */
140269
+ if( pIdx->pPartIdxWhere ){
140270
+ whereApplyPartialIndexConstraints(pIdx->pPartIdxWhere, iCur, pWC);
140271
+ }
140272
+ }else{
140273
+ testcase( pIdx->pPartIdxWhere );
140274
+ /* The following assert() is not a requirement, merely an observation:
140275
+ ** The OR-optimization doesn't work for the right hand table of
140276
+ ** a LEFT JOIN: */
140277
+ assert( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 );
140278
+ }
140279
+
139163140280
/* Record the instruction used to terminate the loop. */
139164140281
if( pLoop->wsFlags & WHERE_ONEROW ){
139165140282
pLevel->op = OP_Noop;
139166140283
}else if( bRev ){
139167140284
pLevel->op = OP_Prev;
@@ -139384,11 +140501,11 @@
139384140501
139385140502
/* Read the PK into an array of temp registers. */
139386140503
r = sqlite3GetTempRange(pParse, nPk);
139387140504
for(iPk=0; iPk<nPk; iPk++){
139388140505
int iCol = pPk->aiColumn[iPk];
139389
- sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol, r+iPk);
140506
+ sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol,r+iPk);
139390140507
}
139391140508
139392140509
/* Check if the temp table already contains this key. If so,
139393140510
** the row has already been included in the result set and
139394140511
** can be ignored (by jumping past the Gosub below). Otherwise,
@@ -139749,43 +140866,18 @@
139749140866
}
139750140867
139751140868
/*
139752140869
** Commute a comparison operator. Expressions of the form "X op Y"
139753140870
** are converted into "Y op X".
139754
-**
139755
-** If left/right precedence rules come into play when determining the
139756
-** collating sequence, then COLLATE operators are adjusted to ensure
139757
-** that the collating sequence does not change. For example:
139758
-** "Y collate NOCASE op X" becomes "X op Y" because any collation sequence on
139759
-** the left hand side of a comparison overrides any collation sequence
139760
-** attached to the right. For the same reason the EP_Collate flag
139761
-** is not commuted.
139762
-**
139763
-** The return value is extra flags that are added to the WhereTerm object
139764
-** after it is commuted. The only extra flag ever added is TERM_NOPARTIDX
139765
-** which prevents the term from being used to enable a partial index if
139766
-** COLLATE changes have been made.
139767140871
*/
139768140872
static u16 exprCommute(Parse *pParse, Expr *pExpr){
139769
- u16 expRight = (pExpr->pRight->flags & EP_Collate);
139770
- u16 expLeft = (pExpr->pLeft->flags & EP_Collate);
139771
- u16 wtFlags = 0;
139772
- assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );
139773
- if( expRight==expLeft ){
139774
- /* Either X and Y both have COLLATE operator or neither do */
139775
- if( expRight ){
139776
- /* Both X and Y have COLLATE operators. Make sure X is always
139777
- ** used by clearing the EP_Collate flag from Y. */
139778
- pExpr->pRight->flags &= ~EP_Collate;
139779
- wtFlags |= TERM_NOPARTIDX;
139780
- }else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){
139781
- /* Neither X nor Y have COLLATE operators, but X has a non-default
139782
- ** collating sequence. So add the EP_Collate marker on X to cause
139783
- ** it to be searched first. */
139784
- pExpr->pLeft->flags |= EP_Collate;
139785
- wtFlags |= TERM_NOPARTIDX;
139786
- }
140873
+ if( pExpr->pLeft->op==TK_VECTOR
140874
+ || pExpr->pRight->op==TK_VECTOR
140875
+ || sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight) !=
140876
+ sqlite3BinaryCompareCollSeq(pParse, pExpr->pRight, pExpr->pLeft)
140877
+ ){
140878
+ pExpr->flags ^= EP_Commuted;
139787140879
}
139788140880
SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
139789140881
if( pExpr->op>=TK_GT ){
139790140882
assert( TK_LT==TK_GT+2 );
139791140883
assert( TK_GE==TK_LE+2 );
@@ -139792,11 +140884,11 @@
139792140884
assert( TK_GT>TK_EQ );
139793140885
assert( TK_GT<TK_LE );
139794140886
assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );
139795140887
pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;
139796140888
}
139797
- return wtFlags;
140889
+ return 0;
139798140890
}
139799140891
139800140892
/*
139801140893
** Translate from TK_xx operator to WO_xx bitmask.
139802140894
*/
@@ -140570,11 +141662,11 @@
140570141662
if( aff1!=aff2
140571141663
&& (!sqlite3IsNumericAffinity(aff1) || !sqlite3IsNumericAffinity(aff2))
140572141664
){
140573141665
return 0;
140574141666
}
140575
- pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);
141667
+ pColl = sqlite3ExprCompareCollSeq(pParse, pExpr);
140576141668
if( sqlite3IsBinary(pColl) ) return 1;
140577141669
return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight);
140578141670
}
140579141671
140580141672
/*
@@ -141259,10 +142351,13 @@
141259142351
pColRef->iColumn = k++;
141260142352
pColRef->y.pTab = pTab;
141261142353
pRhs = sqlite3PExpr(pParse, TK_UPLUS,
141262142354
sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);
141263142355
pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);
142356
+ if( pItem->fg.jointype & JT_LEFT ){
142357
+ sqlite3SetJoinExpr(pTerm, pItem->iCursor);
142358
+ }
141264142359
whereClauseInsert(pWC, pTerm, TERM_DYNAMIC);
141265142360
}
141266142361
}
141267142362
141268142363
/************** End of whereexpr.c *******************************************/
@@ -141546,12 +142641,11 @@
141546142641
pX = pTerm->pExpr;
141547142642
if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){
141548142643
continue;
141549142644
}
141550142645
assert(pX->pLeft);
141551
- pColl = sqlite3BinaryCompareCollSeq(pParse,
141552
- pX->pLeft, pX->pRight);
142646
+ pColl = sqlite3ExprCompareCollSeq(pParse, pX);
141553142647
if( pColl==0 ) pColl = pParse->db->pDfltColl;
141554142648
if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){
141555142649
continue;
141556142650
}
141557142651
}
@@ -142068,12 +143162,12 @@
142068143162
testcase( iCol==BMS );
142069143163
if( (idxCols & cMask)==0 ){
142070143164
Expr *pX = pTerm->pExpr;
142071143165
idxCols |= cMask;
142072143166
pIdx->aiColumn[n] = pTerm->u.leftColumn;
142073
- pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
142074
- pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
143167
+ pColl = sqlite3ExprCompareCollSeq(pParse, pX);
143168
+ pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : sqlite3StrBINARY;
142075143169
n++;
142076143170
}
142077143171
}
142078143172
}
142079143173
assert( (u32)n==pLoop->u.btree.nEq );
@@ -144069,11 +145163,10 @@
144069145163
pWhere = pWhere->pRight;
144070145164
}
144071145165
if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
144072145166
for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
144073145167
Expr *pExpr;
144074
- if( pTerm->wtFlags & TERM_NOPARTIDX ) continue;
144075145168
pExpr = pTerm->pExpr;
144076145169
if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
144077145170
&& sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
144078145171
){
144079145172
return 1;
@@ -144532,11 +145625,11 @@
144532145625
if( iCons>=0 && iCons<pIdxInfo->nConstraint ){
144533145626
CollSeq *pC = 0;
144534145627
int iTerm = pIdxInfo->aConstraint[iCons].iTermOffset;
144535145628
Expr *pX = pHidden->pWC->a[iTerm].pExpr;
144536145629
if( pX->pLeft ){
144537
- pC = sqlite3BinaryCompareCollSeq(pHidden->pParse, pX->pLeft, pX->pRight);
145630
+ pC = sqlite3ExprCompareCollSeq(pHidden->pParse, pX);
144538145631
}
144539145632
zRet = (pC ? pC->zName : sqlite3StrBINARY);
144540145633
}
144541145634
return zRet;
144542145635
}
@@ -144965,11 +146058,13 @@
144965146058
if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue;
144966146059
}else{
144967146060
pLoop = pLast;
144968146061
}
144969146062
if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
144970
- if( pLoop->u.vtab.isOrdered ) obSat = obDone;
146063
+ if( pLoop->u.vtab.isOrdered && (wctrlFlags & WHERE_DISTINCTBY)==0 ){
146064
+ obSat = obDone;
146065
+ }
144971146066
break;
144972146067
}else if( wctrlFlags & WHERE_DISTINCTBY ){
144973146068
pLoop->u.btree.nDistinctCol = 0;
144974146069
}
144975146070
iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
@@ -146283,11 +147378,17 @@
146283147378
};
146284147379
sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op);
146285147380
assert( pTabItem->iCursor==pLevel->iTabCur );
146286147381
testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS-1 );
146287147382
testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS );
146288
- if( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol<BMS && HasRowid(pTab) ){
147383
+ if( pWInfo->eOnePass==ONEPASS_OFF
147384
+ && pTab->nCol<BMS
147385
+ && (pTab->tabFlags & (TF_HasGenerated|TF_WithoutRowid))==0
147386
+ ){
147387
+ /* If we know that only a prefix of the record will be used,
147388
+ ** it is advantageous to reduce the "column count" field in
147389
+ ** the P4 operand of the OP_OpenRead/Write opcode. */
146289147390
Bitmask b = pTabItem->colUsed;
146290147391
int n = 0;
146291147392
for(; b; b=b>>1, n++){}
146292147393
sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(n), P4_INT32);
146293147394
assert( n<=pTab->nCol );
@@ -146645,12 +147746,15 @@
146645147746
assert( pIdx->pTable==pTab );
146646147747
if( !HasRowid(pTab) ){
146647147748
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
146648147749
x = pPk->aiColumn[x];
146649147750
assert( x>=0 );
147751
+ }else{
147752
+ testcase( x!=sqlite3StorageColumnToTable(pTab,x) );
147753
+ x = sqlite3StorageColumnToTable(pTab,x);
146650147754
}
146651
- x = sqlite3ColumnOfIndex(pIdx, x);
147755
+ x = sqlite3TableColumnToIndex(pIdx, x);
146652147756
if( x>=0 ){
146653147757
pOp->p2 = x;
146654147758
pOp->p1 = pLevel->iIdxCur;
146655147759
OpcodeRewriteTrace(db, k, pOp);
146656147760
}
@@ -147583,11 +148687,11 @@
147583148687
** are invoked in the correct order as described under "SELECT REWRITING"
147584148688
** at the top of this file.
147585148689
*/
147586148690
SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
147587148691
int rc = SQLITE_OK;
147588
- if( p->pWin && p->pPrior==0 ){
148692
+ if( p->pWin && p->pPrior==0 && (p->selFlags & SF_WinRewrite)==0 ){
147589148693
Vdbe *v = sqlite3GetVdbe(pParse);
147590148694
sqlite3 *db = pParse->db;
147591148695
Select *pSub = 0; /* The subquery */
147592148696
SrcList *pSrc = p->pSrc;
147593148697
Expr *pWhere = p->pWhere;
@@ -147608,10 +148712,11 @@
147608148712
p->pSrc = 0;
147609148713
p->pWhere = 0;
147610148714
p->pGroupBy = 0;
147611148715
p->pHaving = 0;
147612148716
p->selFlags &= ~SF_Aggregate;
148717
+ p->selFlags |= SF_WinRewrite;
147613148718
147614148719
/* Create the ORDER BY clause for the sub-select. This is the concatenation
147615148720
** of the window PARTITION and ORDER BY clauses. Then, if this makes it
147616148721
** redundant, remove the ORDER BY from the parent SELECT. */
147617148722
pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);
@@ -147923,12 +149028,12 @@
147923149028
** to be processed as part of SELECT statement pSel). The window is linked
147924149029
** in if either (a) there are no other windows already linked to this
147925149030
** SELECT, or (b) the windows already linked use a compatible window frame.
147926149031
*/
147927149032
SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin){
147928
- if( 0==pSel->pWin
147929
- || 0==sqlite3WindowCompare(0, pSel->pWin, pWin, 0)
149033
+ if( pSel!=0
149034
+ && (0==pSel->pWin || 0==sqlite3WindowCompare(0, pSel->pWin, pWin, 0))
147930149035
){
147931149036
pWin->pNextWin = pSel->pWin;
147932149037
if( pSel->pWin ){
147933149038
pSel->pWin->ppThis = &pWin->pNextWin;
147934149039
}
@@ -149725,12 +150830,13 @@
149725150830
/*
149726150831
** Disable lookaside memory allocation for objects that might be
149727150832
** shared across database connections.
149728150833
*/
149729150834
static void disableLookaside(Parse *pParse){
150835
+ sqlite3 *db = pParse->db;
149730150836
pParse->disableLookaside++;
149731
- pParse->db->lookaside.bDisable++;
150837
+ DisableLookaside;
149732150838
}
149733150839
149734150840
149735150841
/*
149736150842
** For a compound SELECT statement, make sure p->pPrior->pNext==p for
@@ -149890,32 +150996,32 @@
149890150996
#ifndef INTERFACE
149891150997
# define INTERFACE 1
149892150998
#endif
149893150999
/************* Begin control #defines *****************************************/
149894151000
#define YYCODETYPE unsigned short int
149895
-#define YYNOCODE 307
151001
+#define YYNOCODE 310
149896151002
#define YYACTIONTYPE unsigned short int
149897
-#define YYWILDCARD 98
151003
+#define YYWILDCARD 100
149898151004
#define sqlite3ParserTOKENTYPE Token
149899151005
typedef union {
149900151006
int yyinit;
149901151007
sqlite3ParserTOKENTYPE yy0;
149902
- const char* yy8;
149903
- Select* yy25;
149904
- int yy32;
149905
- Expr* yy46;
149906
- struct FrameBound yy57;
149907
- u8 yy118;
149908
- ExprList* yy138;
149909
- Upsert* yy288;
149910
- With* yy297;
149911
- IdList* yy406;
149912
- Window* yy455;
149913
- struct {int value; int mask;} yy495;
149914
- TriggerStep* yy527;
149915
- struct TrigEvent yy572;
149916
- SrcList* yy609;
151008
+ SrcList* yy47;
151009
+ u8 yy58;
151010
+ struct FrameBound yy77;
151011
+ With* yy131;
151012
+ int yy192;
151013
+ Expr* yy202;
151014
+ struct {int value; int mask;} yy207;
151015
+ struct TrigEvent yy230;
151016
+ ExprList* yy242;
151017
+ Window* yy303;
151018
+ Upsert* yy318;
151019
+ const char* yy436;
151020
+ TriggerStep* yy447;
151021
+ Select* yy539;
151022
+ IdList* yy600;
149917151023
} YYMINORTYPE;
149918151024
#ifndef YYSTACKDEPTH
149919151025
#define YYSTACKDEPTH 100
149920151026
#endif
149921151027
#define sqlite3ParserARG_SDECL
@@ -149927,21 +151033,21 @@
149927151033
#define sqlite3ParserCTX_PDECL ,Parse *pParse
149928151034
#define sqlite3ParserCTX_PARAM ,pParse
149929151035
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
149930151036
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
149931151037
#define YYFALLBACK 1
149932
-#define YYNSTATE 543
149933
-#define YYNRULE 381
149934
-#define YYNTOKEN 179
149935
-#define YY_MAX_SHIFT 542
149936
-#define YY_MIN_SHIFTREDUCE 790
149937
-#define YY_MAX_SHIFTREDUCE 1170
149938
-#define YY_ERROR_ACTION 1171
149939
-#define YY_ACCEPT_ACTION 1172
149940
-#define YY_NO_ACTION 1173
149941
-#define YY_MIN_REDUCE 1174
149942
-#define YY_MAX_REDUCE 1554
151038
+#define YYNSTATE 550
151039
+#define YYNRULE 385
151040
+#define YYNTOKEN 181
151041
+#define YY_MAX_SHIFT 549
151042
+#define YY_MIN_SHIFTREDUCE 800
151043
+#define YY_MAX_SHIFTREDUCE 1184
151044
+#define YY_ERROR_ACTION 1185
151045
+#define YY_ACCEPT_ACTION 1186
151046
+#define YY_NO_ACTION 1187
151047
+#define YY_MIN_REDUCE 1188
151048
+#define YY_MAX_REDUCE 1572
149943151049
/************* End control #defines *******************************************/
149944151050
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
149945151051
149946151052
/* Define the yytestcase() macro to be a no-op if is not already defined
149947151053
** otherwise.
@@ -150004,577 +151110,585 @@
150004151110
** yy_reduce_ofst[] For each state, the offset into yy_action for
150005151111
** shifting non-terminals after a reduce.
150006151112
** yy_default[] Default action for each state.
150007151113
**
150008151114
*********** Begin parsing tables **********************************************/
150009
-#define YY_ACTTAB_COUNT (1913)
151115
+#define YY_ACTTAB_COUNT (1958)
150010151116
static const YYACTIONTYPE yy_action[] = {
150011
- /* 0 */ 537, 339, 537, 1241, 1220, 537, 12, 537, 112, 109,
150012
- /* 10 */ 209, 537, 1241, 537, 1205, 462, 112, 109, 209, 386,
150013
- /* 20 */ 338, 462, 42, 42, 42, 42, 445, 42, 42, 70,
150014
- /* 30 */ 70, 922, 1208, 70, 70, 70, 70, 1443, 403, 923,
150015
- /* 40 */ 531, 531, 531, 119, 120, 110, 1148, 1148, 991, 994,
150016
- /* 50 */ 984, 984, 117, 117, 118, 118, 118, 118, 425, 386,
150017
- /* 60 */ 1498, 542, 2, 1176, 1442, 519, 141, 1518, 289, 519,
150018
- /* 70 */ 134, 519, 95, 259, 495, 1215, 189, 1254, 518, 494,
150019
- /* 80 */ 484, 437, 296, 119, 120, 110, 1148, 1148, 991, 994,
150020
- /* 90 */ 984, 984, 117, 117, 118, 118, 118, 118, 270, 116,
150021
- /* 100 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
150022
- /* 110 */ 264, 264, 264, 264, 423, 1479, 352, 1481, 123, 351,
150023
- /* 120 */ 1479, 508, 1094, 534, 1034, 534, 1099, 386, 1099, 239,
150024
- /* 130 */ 206, 112, 109, 209, 96, 1094, 376, 219, 1094, 116,
150025
- /* 140 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
150026
- /* 150 */ 480, 119, 120, 110, 1148, 1148, 991, 994, 984, 984,
150027
- /* 160 */ 117, 117, 118, 118, 118, 118, 353, 422, 1407, 264,
150028
- /* 170 */ 264, 114, 114, 114, 113, 418, 883, 121, 416, 416,
150029
- /* 180 */ 416, 882, 534, 116, 116, 116, 116, 115, 115, 114,
150030
- /* 190 */ 114, 114, 113, 418, 212, 415, 414, 386, 443, 383,
150031
- /* 200 */ 382, 118, 118, 118, 118, 111, 177, 116, 116, 116,
150032
- /* 210 */ 116, 115, 115, 114, 114, 114, 113, 418, 112, 109,
150033
- /* 220 */ 209, 119, 120, 110, 1148, 1148, 991, 994, 984, 984,
150034
- /* 230 */ 117, 117, 118, 118, 118, 118, 386, 438, 312, 1163,
150035
- /* 240 */ 1155, 80, 1155, 1127, 514, 79, 116, 116, 116, 116,
150036
- /* 250 */ 115, 115, 114, 114, 114, 113, 418, 514, 428, 418,
150037
- /* 260 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
150038
- /* 270 */ 117, 118, 118, 118, 118, 428, 427, 116, 116, 116,
150039
- /* 280 */ 116, 115, 115, 114, 114, 114, 113, 418, 115, 115,
150040
- /* 290 */ 114, 114, 114, 113, 418, 1127, 1127, 1128, 1129, 1094,
150041
- /* 300 */ 258, 258, 192, 386, 408, 371, 1168, 326, 118, 118,
150042
- /* 310 */ 118, 118, 1094, 534, 374, 1094, 116, 116, 116, 116,
150043
- /* 320 */ 115, 115, 114, 114, 114, 113, 418, 119, 120, 110,
150044
- /* 330 */ 1148, 1148, 991, 994, 984, 984, 117, 117, 118, 118,
150045
- /* 340 */ 118, 118, 386, 354, 445, 428, 829, 238, 1127, 1128,
150046
- /* 350 */ 1129, 515, 1466, 116, 116, 116, 116, 115, 115, 114,
150047
- /* 360 */ 114, 114, 113, 418, 1127, 1467, 119, 120, 110, 1148,
150048
- /* 370 */ 1148, 991, 994, 984, 984, 117, 117, 118, 118, 118,
150049
- /* 380 */ 118, 1169, 82, 116, 116, 116, 116, 115, 115, 114,
150050
- /* 390 */ 114, 114, 113, 418, 405, 112, 109, 209, 161, 445,
150051
- /* 400 */ 250, 267, 336, 478, 331, 477, 236, 951, 1127, 386,
150052
- /* 410 */ 888, 1521, 329, 822, 852, 162, 274, 1127, 1128, 1129,
150053
- /* 420 */ 338, 169, 116, 116, 116, 116, 115, 115, 114, 114,
150054
- /* 430 */ 114, 113, 418, 119, 120, 110, 1148, 1148, 991, 994,
150055
- /* 440 */ 984, 984, 117, 117, 118, 118, 118, 118, 386, 438,
150056
- /* 450 */ 312, 1502, 1112, 1176, 161, 288, 528, 311, 289, 883,
150057
- /* 460 */ 134, 1127, 1128, 1129, 882, 537, 143, 1254, 288, 528,
150058
- /* 470 */ 297, 275, 119, 120, 110, 1148, 1148, 991, 994, 984,
150059
- /* 480 */ 984, 117, 117, 118, 118, 118, 118, 70, 70, 116,
150060
- /* 490 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
150061
- /* 500 */ 264, 264, 12, 264, 264, 395, 1127, 483, 1473, 1094,
150062
- /* 510 */ 204, 482, 6, 534, 1258, 386, 534, 1474, 825, 972,
150063
- /* 520 */ 504, 6, 1094, 500, 95, 1094, 534, 219, 116, 116,
150064
- /* 530 */ 116, 116, 115, 115, 114, 114, 114, 113, 418, 119,
150065
- /* 540 */ 120, 110, 1148, 1148, 991, 994, 984, 984, 117, 117,
150066
- /* 550 */ 118, 118, 118, 118, 386, 1339, 971, 422, 956, 1127,
150067
- /* 560 */ 1128, 1129, 231, 512, 1473, 475, 472, 471, 6, 113,
150068
- /* 570 */ 418, 825, 962, 298, 503, 470, 961, 452, 119, 120,
150069
- /* 580 */ 110, 1148, 1148, 991, 994, 984, 984, 117, 117, 118,
150070
- /* 590 */ 118, 118, 118, 395, 537, 116, 116, 116, 116, 115,
150071
- /* 600 */ 115, 114, 114, 114, 113, 418, 202, 961, 961, 963,
150072
- /* 610 */ 231, 971, 1127, 475, 472, 471, 13, 13, 951, 1127,
150073
- /* 620 */ 834, 386, 1207, 470, 399, 183, 447, 962, 462, 162,
150074
- /* 630 */ 397, 961, 1246, 1246, 116, 116, 116, 116, 115, 115,
150075
- /* 640 */ 114, 114, 114, 113, 418, 119, 120, 110, 1148, 1148,
150076
- /* 650 */ 991, 994, 984, 984, 117, 117, 118, 118, 118, 118,
150077
- /* 660 */ 386, 271, 961, 961, 963, 1127, 1128, 1129, 311, 433,
150078
- /* 670 */ 299, 1406, 1127, 1128, 1129, 178, 1471, 138, 162, 32,
150079
- /* 680 */ 6, 1127, 288, 528, 119, 120, 110, 1148, 1148, 991,
150080
- /* 690 */ 994, 984, 984, 117, 117, 118, 118, 118, 118, 909,
150081
- /* 700 */ 390, 116, 116, 116, 116, 115, 115, 114, 114, 114,
150082
- /* 710 */ 113, 418, 1127, 429, 817, 537, 1127, 265, 265, 981,
150083
- /* 720 */ 981, 992, 995, 324, 1055, 93, 520, 5, 338, 537,
150084
- /* 730 */ 534, 288, 528, 1522, 1127, 1128, 1129, 70, 70, 1056,
150085
- /* 740 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
150086
- /* 750 */ 418, 70, 70, 1495, 1057, 537, 98, 1244, 1244, 264,
150087
- /* 760 */ 264, 908, 371, 1076, 1127, 1127, 1128, 1129, 817, 1127,
150088
- /* 770 */ 1128, 1129, 534, 519, 140, 863, 386, 13, 13, 456,
150089
- /* 780 */ 192, 193, 521, 453, 319, 864, 322, 284, 365, 430,
150090
- /* 790 */ 985, 402, 379, 1077, 1548, 101, 386, 1548, 3, 395,
150091
- /* 800 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
150092
- /* 810 */ 117, 118, 118, 118, 118, 386, 451, 1127, 1128, 1129,
150093
- /* 820 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
150094
- /* 830 */ 117, 118, 118, 118, 118, 1127, 1354, 1412, 1169, 119,
150095
- /* 840 */ 108, 110, 1148, 1148, 991, 994, 984, 984, 117, 117,
150096
- /* 850 */ 118, 118, 118, 118, 1412, 1414, 116, 116, 116, 116,
150097
- /* 860 */ 115, 115, 114, 114, 114, 113, 418, 272, 535, 1075,
150098
- /* 870 */ 877, 877, 337, 1492, 309, 462, 116, 116, 116, 116,
150099
- /* 880 */ 115, 115, 114, 114, 114, 113, 418, 537, 1127, 1128,
150100
- /* 890 */ 1129, 537, 360, 537, 356, 116, 116, 116, 116, 115,
150101
- /* 900 */ 115, 114, 114, 114, 113, 418, 386, 264, 264, 13,
150102
- /* 910 */ 13, 273, 1127, 13, 13, 13, 13, 304, 1253, 386,
150103
- /* 920 */ 534, 1077, 1549, 404, 1412, 1549, 496, 277, 451, 186,
150104
- /* 930 */ 1252, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
150105
- /* 940 */ 117, 118, 118, 118, 118, 110, 1148, 1148, 991, 994,
150106
- /* 950 */ 984, 984, 117, 117, 118, 118, 118, 118, 105, 529,
150107
- /* 960 */ 537, 4, 1339, 264, 264, 1127, 1128, 1129, 1039, 1039,
150108
- /* 970 */ 459, 795, 796, 797, 536, 532, 534, 242, 301, 807,
150109
- /* 980 */ 303, 462, 69, 69, 451, 1353, 116, 116, 116, 116,
150110
- /* 990 */ 115, 115, 114, 114, 114, 113, 418, 1075, 419, 116,
150111
- /* 1000 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
150112
- /* 1010 */ 526, 537, 1146, 192, 350, 105, 529, 537, 4, 497,
150113
- /* 1020 */ 162, 337, 1492, 310, 1249, 385, 1550, 372, 9, 462,
150114
- /* 1030 */ 242, 400, 532, 13, 13, 499, 971, 843, 436, 70,
150115
- /* 1040 */ 70, 359, 103, 103, 8, 339, 278, 187, 278, 104,
150116
- /* 1050 */ 1127, 419, 539, 538, 1339, 419, 961, 302, 1339, 1172,
150117
- /* 1060 */ 1, 1, 542, 2, 1176, 1146, 1146, 526, 476, 289,
150118
- /* 1070 */ 30, 134, 317, 288, 528, 285, 844, 1014, 1254, 276,
150119
- /* 1080 */ 1472, 506, 410, 1194, 6, 207, 505, 961, 961, 963,
150120
- /* 1090 */ 964, 27, 449, 971, 415, 414, 234, 233, 232, 103,
150121
- /* 1100 */ 103, 31, 1152, 1127, 1128, 1129, 104, 1154, 419, 539,
150122
- /* 1110 */ 538, 264, 264, 961, 1399, 1153, 264, 264, 1470, 1146,
150123
- /* 1120 */ 537, 216, 6, 401, 534, 1197, 392, 458, 406, 534,
150124
- /* 1130 */ 537, 485, 358, 537, 261, 537, 1339, 907, 219, 1155,
150125
- /* 1140 */ 467, 1155, 50, 50, 961, 961, 963, 964, 27, 1497,
150126
- /* 1150 */ 1116, 421, 70, 70, 268, 70, 70, 13, 13, 369,
150127
- /* 1160 */ 369, 368, 253, 366, 264, 264, 804, 235, 422, 105,
150128
- /* 1170 */ 529, 516, 4, 287, 487, 510, 493, 534, 486, 213,
150129
- /* 1180 */ 1055, 294, 490, 384, 1127, 450, 532, 338, 413, 293,
150130
- /* 1190 */ 522, 417, 335, 1036, 509, 1056, 107, 1036, 16, 16,
150131
- /* 1200 */ 1469, 1094, 334, 1105, 6, 411, 1145, 264, 264, 419,
150132
- /* 1210 */ 1057, 102, 511, 100, 1094, 264, 264, 1094, 922, 215,
150133
- /* 1220 */ 534, 526, 907, 264, 264, 208, 923, 154, 534, 457,
150134
- /* 1230 */ 156, 525, 391, 142, 218, 506, 534, 1127, 1128, 1129,
150135
- /* 1240 */ 507, 139, 1131, 38, 214, 530, 392, 971, 329, 1454,
150136
- /* 1250 */ 907, 1105, 537, 103, 103, 105, 529, 537, 4, 537,
150137
- /* 1260 */ 104, 424, 419, 539, 538, 537, 502, 961, 517, 537,
150138
- /* 1270 */ 1072, 537, 532, 373, 54, 54, 288, 528, 387, 55,
150139
- /* 1280 */ 55, 15, 15, 288, 528, 17, 136, 44, 44, 1451,
150140
- /* 1290 */ 537, 56, 56, 57, 57, 419, 1131, 291, 961, 961,
150141
- /* 1300 */ 963, 964, 27, 393, 163, 537, 426, 526, 263, 206,
150142
- /* 1310 */ 208, 517, 58, 58, 235, 440, 842, 841, 197, 105,
150143
- /* 1320 */ 529, 506, 4, 1033, 439, 1033, 505, 59, 59, 308,
150144
- /* 1330 */ 849, 850, 95, 971, 537, 907, 532, 948, 832, 103,
150145
- /* 1340 */ 103, 105, 529, 537, 4, 1021, 104, 537, 419, 539,
150146
- /* 1350 */ 538, 1116, 421, 961, 537, 268, 60, 60, 532, 419,
150147
- /* 1360 */ 369, 369, 368, 253, 366, 61, 61, 804, 965, 45,
150148
- /* 1370 */ 45, 526, 537, 1032, 1277, 1032, 46, 46, 537, 391,
150149
- /* 1380 */ 213, 419, 294, 266, 961, 961, 963, 964, 27, 292,
150150
- /* 1390 */ 293, 295, 832, 526, 48, 48, 1290, 971, 1289, 1021,
150151
- /* 1400 */ 49, 49, 432, 103, 103, 887, 953, 537, 1457, 241,
150152
- /* 1410 */ 104, 305, 419, 539, 538, 925, 926, 961, 444, 971,
150153
- /* 1420 */ 215, 241, 965, 1224, 537, 103, 103, 1431, 154, 62,
150154
- /* 1430 */ 62, 156, 104, 1430, 419, 539, 538, 97, 529, 961,
150155
- /* 1440 */ 4, 537, 454, 537, 314, 214, 63, 63, 961, 961,
150156
- /* 1450 */ 963, 964, 27, 537, 532, 446, 1286, 318, 241, 537,
150157
- /* 1460 */ 321, 323, 325, 64, 64, 14, 14, 1237, 537, 1223,
150158
- /* 1470 */ 961, 961, 963, 964, 27, 65, 65, 419, 537, 387,
150159
- /* 1480 */ 537, 125, 125, 537, 288, 528, 537, 1486, 537, 526,
150160
- /* 1490 */ 66, 66, 313, 524, 537, 95, 468, 1221, 1511, 237,
150161
- /* 1500 */ 51, 51, 67, 67, 330, 68, 68, 426, 52, 52,
150162
- /* 1510 */ 149, 149, 1222, 340, 341, 971, 150, 150, 1298, 463,
150163
- /* 1520 */ 327, 103, 103, 95, 537, 1338, 1273, 537, 104, 537,
150164
- /* 1530 */ 419, 539, 538, 1284, 537, 961, 268, 283, 523, 1344,
150165
- /* 1540 */ 1204, 369, 369, 368, 253, 366, 75, 75, 804, 53,
150166
- /* 1550 */ 53, 71, 71, 537, 1196, 537, 126, 126, 537, 1017,
150167
- /* 1560 */ 537, 213, 237, 294, 537, 1185, 961, 961, 963, 964,
150168
- /* 1570 */ 27, 293, 537, 1184, 537, 72, 72, 127, 127, 1186,
150169
- /* 1580 */ 128, 128, 124, 124, 1505, 537, 148, 148, 537, 256,
150170
- /* 1590 */ 195, 537, 1270, 537, 147, 147, 132, 132, 537, 11,
150171
- /* 1600 */ 537, 215, 537, 199, 343, 345, 347, 131, 131, 154,
150172
- /* 1610 */ 129, 129, 156, 130, 130, 74, 74, 537, 370, 1323,
150173
- /* 1620 */ 76, 76, 73, 73, 43, 43, 214, 431, 211, 1331,
150174
- /* 1630 */ 300, 916, 880, 815, 241, 107, 137, 307, 881, 47,
150175
- /* 1640 */ 47, 107, 473, 378, 203, 448, 333, 1403, 1220, 1402,
150176
- /* 1650 */ 349, 190, 527, 191, 363, 198, 1508, 1163, 245, 165,
150177
- /* 1660 */ 387, 1450, 1448, 1160, 78, 288, 528, 1408, 81, 394,
150178
- /* 1670 */ 82, 442, 175, 159, 167, 93, 1328, 35, 1320, 434,
150179
- /* 1680 */ 170, 171, 172, 173, 435, 466, 221, 375, 426, 377,
150180
- /* 1690 */ 1334, 179, 455, 441, 1397, 225, 87, 36, 461, 1419,
150181
- /* 1700 */ 316, 257, 227, 184, 320, 464, 228, 479, 1187, 229,
150182
- /* 1710 */ 380, 1240, 1239, 407, 1238, 1212, 834, 332, 1231, 381,
150183
- /* 1720 */ 409, 1211, 204, 1210, 1491, 498, 1520, 1281, 92, 281,
150184
- /* 1730 */ 1230, 489, 282, 492, 342, 243, 1282, 344, 244, 1280,
150185
- /* 1740 */ 346, 412, 1279, 1477, 348, 122, 1476, 517, 10, 357,
150186
- /* 1750 */ 286, 1305, 1304, 99, 1383, 94, 501, 251, 1193, 34,
150187
- /* 1760 */ 1263, 355, 540, 194, 1262, 361, 362, 1122, 252, 254,
150188
- /* 1770 */ 255, 388, 541, 1182, 1177, 151, 1435, 389, 1436, 1434,
150189
- /* 1780 */ 1433, 791, 152, 135, 279, 200, 201, 420, 196, 77,
150190
- /* 1790 */ 153, 290, 269, 210, 1031, 133, 1029, 945, 166, 155,
150191
- /* 1800 */ 217, 168, 866, 306, 220, 1045, 174, 949, 157, 396,
150192
- /* 1810 */ 83, 398, 176, 84, 85, 164, 86, 158, 1048, 222,
150193
- /* 1820 */ 223, 1044, 144, 18, 224, 315, 1037, 180, 241, 460,
150194
- /* 1830 */ 1157, 226, 181, 37, 806, 465, 334, 230, 328, 469,
150195
- /* 1840 */ 182, 88, 474, 19, 20, 160, 89, 280, 145, 90,
150196
- /* 1850 */ 481, 845, 1110, 146, 997, 205, 1080, 39, 91, 40,
150197
- /* 1860 */ 488, 1081, 915, 491, 260, 262, 185, 910, 240, 107,
150198
- /* 1870 */ 1100, 1096, 1098, 1104, 21, 1084, 33, 513, 247, 22,
150199
- /* 1880 */ 23, 24, 1103, 25, 188, 95, 1012, 998, 996, 26,
150200
- /* 1890 */ 1000, 1054, 7, 1053, 1001, 246, 28, 41, 533, 966,
150201
- /* 1900 */ 816, 106, 29, 367, 248, 249, 1513, 1512, 364, 1117,
150202
- /* 1910 */ 1173, 1173, 876,
151117
+ /* 0 */ 544, 1219, 544, 449, 1257, 544, 1236, 544, 114, 111,
151118
+ /* 10 */ 211, 544, 1534, 544, 1257, 521, 114, 111, 211, 390,
151119
+ /* 20 */ 1229, 342, 42, 42, 42, 42, 1222, 42, 42, 71,
151120
+ /* 30 */ 71, 934, 1221, 71, 71, 71, 71, 1459, 1490, 935,
151121
+ /* 40 */ 817, 451, 6, 121, 122, 112, 1162, 1162, 1003, 1006,
151122
+ /* 50 */ 996, 996, 119, 119, 120, 120, 120, 120, 1540, 390,
151123
+ /* 60 */ 1355, 1514, 549, 2, 1190, 194, 526, 434, 143, 291,
151124
+ /* 70 */ 526, 136, 526, 369, 261, 502, 272, 383, 1270, 525,
151125
+ /* 80 */ 501, 491, 164, 121, 122, 112, 1162, 1162, 1003, 1006,
151126
+ /* 90 */ 996, 996, 119, 119, 120, 120, 120, 120, 1355, 440,
151127
+ /* 100 */ 1511, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151128
+ /* 110 */ 115, 422, 266, 266, 266, 266, 1495, 356, 1497, 433,
151129
+ /* 120 */ 355, 1495, 515, 522, 1482, 541, 1111, 541, 1111, 390,
151130
+ /* 130 */ 403, 241, 208, 114, 111, 211, 98, 290, 535, 221,
151131
+ /* 140 */ 1026, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151132
+ /* 150 */ 115, 422, 1139, 121, 122, 112, 1162, 1162, 1003, 1006,
151133
+ /* 160 */ 996, 996, 119, 119, 120, 120, 120, 120, 404, 426,
151134
+ /* 170 */ 117, 117, 116, 116, 116, 115, 422, 1415, 466, 123,
151135
+ /* 180 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151136
+ /* 190 */ 422, 116, 116, 116, 115, 422, 538, 538, 538, 390,
151137
+ /* 200 */ 503, 120, 120, 120, 120, 113, 1048, 1139, 1140, 1141,
151138
+ /* 210 */ 1048, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151139
+ /* 220 */ 115, 422, 1458, 121, 122, 112, 1162, 1162, 1003, 1006,
151140
+ /* 230 */ 996, 996, 119, 119, 120, 120, 120, 120, 390, 442,
151141
+ /* 240 */ 314, 83, 461, 81, 357, 380, 1139, 80, 118, 118,
151142
+ /* 250 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 179,
151143
+ /* 260 */ 432, 422, 121, 122, 112, 1162, 1162, 1003, 1006, 996,
151144
+ /* 270 */ 996, 119, 119, 120, 120, 120, 120, 432, 431, 266,
151145
+ /* 280 */ 266, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151146
+ /* 290 */ 115, 422, 541, 1106, 900, 504, 1139, 114, 111, 211,
151147
+ /* 300 */ 1428, 1139, 1140, 1141, 206, 489, 1106, 390, 447, 1106,
151148
+ /* 310 */ 543, 328, 120, 120, 120, 120, 298, 1428, 1430, 17,
151149
+ /* 320 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151150
+ /* 330 */ 422, 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996,
151151
+ /* 340 */ 119, 119, 120, 120, 120, 120, 390, 1355, 432, 1139,
151152
+ /* 350 */ 480, 1139, 1140, 1141, 993, 993, 1004, 1007, 443, 118,
151153
+ /* 360 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422,
151154
+ /* 370 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151155
+ /* 380 */ 119, 120, 120, 120, 120, 1051, 1051, 463, 1428, 118,
151156
+ /* 390 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422,
151157
+ /* 400 */ 1139, 449, 544, 1423, 1139, 1140, 1141, 233, 963, 1139,
151158
+ /* 410 */ 479, 476, 475, 171, 358, 390, 164, 405, 412, 839,
151159
+ /* 420 */ 474, 164, 185, 332, 71, 71, 1240, 997, 118, 118,
151160
+ /* 430 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 121,
151161
+ /* 440 */ 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119, 119,
151162
+ /* 450 */ 120, 120, 120, 120, 390, 1139, 1140, 1141, 832, 12,
151163
+ /* 460 */ 313, 507, 163, 354, 1139, 1140, 1141, 114, 111, 211,
151164
+ /* 470 */ 506, 290, 535, 544, 276, 180, 290, 535, 121, 122,
151165
+ /* 480 */ 112, 1162, 1162, 1003, 1006, 996, 996, 119, 119, 120,
151166
+ /* 490 */ 120, 120, 120, 343, 482, 71, 71, 118, 118, 118,
151167
+ /* 500 */ 118, 117, 117, 116, 116, 116, 115, 422, 1139, 209,
151168
+ /* 510 */ 409, 521, 1139, 1106, 1568, 376, 252, 269, 340, 485,
151169
+ /* 520 */ 335, 484, 238, 390, 511, 362, 1106, 1124, 331, 1106,
151170
+ /* 530 */ 191, 407, 286, 32, 455, 441, 118, 118, 118, 118,
151171
+ /* 540 */ 117, 117, 116, 116, 116, 115, 422, 121, 122, 112,
151172
+ /* 550 */ 1162, 1162, 1003, 1006, 996, 996, 119, 119, 120, 120,
151173
+ /* 560 */ 120, 120, 390, 1139, 1140, 1141, 984, 1139, 1140, 1141,
151174
+ /* 570 */ 1139, 233, 490, 1489, 479, 476, 475, 6, 163, 544,
151175
+ /* 580 */ 510, 544, 115, 422, 474, 5, 121, 122, 112, 1162,
151176
+ /* 590 */ 1162, 1003, 1006, 996, 996, 119, 119, 120, 120, 120,
151177
+ /* 600 */ 120, 13, 13, 13, 13, 118, 118, 118, 118, 117,
151178
+ /* 610 */ 117, 116, 116, 116, 115, 422, 401, 500, 406, 544,
151179
+ /* 620 */ 1483, 542, 1139, 889, 889, 1139, 1140, 1141, 1470, 1139,
151180
+ /* 630 */ 275, 390, 805, 806, 807, 968, 420, 420, 420, 16,
151181
+ /* 640 */ 16, 55, 55, 1239, 118, 118, 118, 118, 117, 117,
151182
+ /* 650 */ 116, 116, 116, 115, 422, 121, 122, 112, 1162, 1162,
151183
+ /* 660 */ 1003, 1006, 996, 996, 119, 119, 120, 120, 120, 120,
151184
+ /* 670 */ 390, 1186, 1, 1, 549, 2, 1190, 1139, 1140, 1141,
151185
+ /* 680 */ 194, 291, 895, 136, 1139, 1140, 1141, 894, 519, 1489,
151186
+ /* 690 */ 1270, 3, 378, 6, 121, 122, 112, 1162, 1162, 1003,
151187
+ /* 700 */ 1006, 996, 996, 119, 119, 120, 120, 120, 120, 855,
151188
+ /* 710 */ 544, 921, 544, 118, 118, 118, 118, 117, 117, 116,
151189
+ /* 720 */ 116, 116, 115, 422, 266, 266, 1089, 1566, 1139, 1518,
151190
+ /* 730 */ 1566, 1190, 13, 13, 13, 13, 291, 541, 136, 390,
151191
+ /* 740 */ 483, 419, 418, 963, 342, 1270, 466, 408, 856, 279,
151192
+ /* 750 */ 140, 221, 118, 118, 118, 118, 117, 117, 116, 116,
151193
+ /* 760 */ 116, 115, 422, 121, 122, 112, 1162, 1162, 1003, 1006,
151194
+ /* 770 */ 996, 996, 119, 119, 120, 120, 120, 120, 544, 266,
151195
+ /* 780 */ 266, 426, 390, 1139, 1140, 1141, 1169, 827, 1169, 466,
151196
+ /* 790 */ 429, 145, 541, 1143, 399, 313, 437, 301, 835, 1487,
151197
+ /* 800 */ 71, 71, 410, 6, 1087, 471, 221, 100, 112, 1162,
151198
+ /* 810 */ 1162, 1003, 1006, 996, 996, 119, 119, 120, 120, 120,
151199
+ /* 820 */ 120, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151200
+ /* 830 */ 115, 422, 237, 1422, 544, 449, 426, 287, 983, 544,
151201
+ /* 840 */ 236, 235, 234, 827, 97, 527, 427, 1262, 1262, 1143,
151202
+ /* 850 */ 492, 306, 428, 835, 974, 544, 71, 71, 973, 1238,
151203
+ /* 860 */ 544, 51, 51, 300, 118, 118, 118, 118, 117, 117,
151204
+ /* 870 */ 116, 116, 116, 115, 422, 194, 103, 70, 70, 266,
151205
+ /* 880 */ 266, 544, 71, 71, 266, 266, 30, 389, 342, 973,
151206
+ /* 890 */ 973, 975, 541, 526, 1106, 326, 390, 541, 493, 395,
151207
+ /* 900 */ 1467, 195, 528, 13, 13, 1355, 240, 1106, 277, 280,
151208
+ /* 910 */ 1106, 280, 303, 455, 305, 331, 390, 31, 188, 417,
151209
+ /* 920 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151210
+ /* 930 */ 119, 120, 120, 120, 120, 142, 390, 363, 455, 983,
151211
+ /* 940 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151212
+ /* 950 */ 119, 120, 120, 120, 120, 974, 321, 1139, 324, 973,
151213
+ /* 960 */ 121, 110, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151214
+ /* 970 */ 119, 120, 120, 120, 120, 462, 375, 1182, 118, 118,
151215
+ /* 980 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1139,
151216
+ /* 990 */ 973, 973, 975, 304, 9, 364, 244, 360, 118, 118,
151217
+ /* 1000 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 312,
151218
+ /* 1010 */ 544, 342, 1139, 1140, 1141, 299, 290, 535, 118, 118,
151219
+ /* 1020 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1260,
151220
+ /* 1030 */ 1260, 1160, 13, 13, 278, 419, 418, 466, 390, 920,
151221
+ /* 1040 */ 260, 260, 289, 1166, 1139, 1140, 1141, 189, 1168, 266,
151222
+ /* 1050 */ 266, 466, 388, 541, 1183, 544, 1167, 263, 144, 487,
151223
+ /* 1060 */ 919, 544, 541, 122, 112, 1162, 1162, 1003, 1006, 996,
151224
+ /* 1070 */ 996, 119, 119, 120, 120, 120, 120, 71, 71, 1139,
151225
+ /* 1080 */ 1169, 1269, 1169, 13, 13, 895, 1067, 1160, 544, 466,
151226
+ /* 1090 */ 894, 107, 536, 1488, 4, 1265, 1106, 6, 523, 1046,
151227
+ /* 1100 */ 12, 1068, 1089, 1567, 311, 453, 1567, 518, 539, 1106,
151228
+ /* 1110 */ 56, 56, 1106, 1486, 421, 1355, 1069, 6, 343, 285,
151229
+ /* 1120 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151230
+ /* 1130 */ 422, 423, 1268, 319, 1139, 1140, 1141, 875, 266, 266,
151231
+ /* 1140 */ 1274, 107, 536, 533, 4, 1485, 293, 876, 1208, 6,
151232
+ /* 1150 */ 210, 541, 541, 164, 1539, 494, 414, 864, 539, 267,
151233
+ /* 1160 */ 267, 1211, 396, 509, 497, 204, 266, 266, 394, 529,
151234
+ /* 1170 */ 8, 983, 541, 517, 544, 919, 456, 105, 105, 541,
151235
+ /* 1180 */ 1087, 423, 266, 266, 106, 415, 423, 546, 545, 266,
151236
+ /* 1190 */ 266, 973, 516, 533, 1370, 541, 15, 15, 266, 266,
151237
+ /* 1200 */ 454, 1117, 541, 266, 266, 1067, 1369, 513, 290, 535,
151238
+ /* 1210 */ 544, 541, 512, 97, 442, 314, 541, 544, 919, 125,
151239
+ /* 1220 */ 1068, 983, 973, 973, 975, 976, 27, 105, 105, 399,
151240
+ /* 1230 */ 341, 1508, 44, 44, 106, 1069, 423, 546, 545, 57,
151241
+ /* 1240 */ 57, 973, 341, 1508, 107, 536, 544, 4, 460, 399,
151242
+ /* 1250 */ 214, 1117, 457, 294, 375, 1088, 532, 297, 544, 537,
151243
+ /* 1260 */ 396, 539, 290, 535, 104, 244, 102, 524, 58, 58,
151244
+ /* 1270 */ 544, 109, 973, 973, 975, 976, 27, 1513, 1128, 425,
151245
+ /* 1280 */ 59, 59, 270, 237, 423, 138, 95, 373, 373, 372,
151246
+ /* 1290 */ 255, 370, 60, 60, 814, 1177, 533, 544, 273, 544,
151247
+ /* 1300 */ 1160, 842, 387, 386, 544, 1306, 544, 215, 210, 296,
151248
+ /* 1310 */ 513, 846, 544, 265, 208, 514, 1305, 295, 274, 61,
151249
+ /* 1320 */ 61, 62, 62, 436, 983, 1159, 45, 45, 46, 46,
151250
+ /* 1330 */ 105, 105, 1183, 919, 47, 47, 1473, 106, 544, 423,
151251
+ /* 1340 */ 546, 545, 218, 544, 973, 934, 1084, 217, 544, 377,
151252
+ /* 1350 */ 395, 107, 536, 935, 4, 156, 1160, 842, 158, 544,
151253
+ /* 1360 */ 49, 49, 141, 544, 38, 50, 50, 544, 539, 307,
151254
+ /* 1370 */ 63, 63, 544, 1447, 216, 973, 973, 975, 976, 27,
151255
+ /* 1380 */ 444, 64, 64, 544, 1446, 65, 65, 544, 524, 14,
151256
+ /* 1390 */ 14, 423, 458, 544, 66, 66, 310, 544, 316, 97,
151257
+ /* 1400 */ 1033, 544, 960, 533, 268, 127, 127, 544, 391, 67,
151258
+ /* 1410 */ 67, 544, 977, 290, 535, 52, 52, 513, 544, 68,
151259
+ /* 1420 */ 68, 1293, 512, 69, 69, 397, 165, 854, 853, 53,
151260
+ /* 1430 */ 53, 983, 965, 151, 151, 243, 430, 105, 105, 199,
151261
+ /* 1440 */ 152, 152, 448, 1302, 106, 243, 423, 546, 545, 1128,
151262
+ /* 1450 */ 425, 973, 320, 270, 861, 862, 1033, 220, 373, 373,
151263
+ /* 1460 */ 372, 255, 370, 450, 323, 814, 243, 544, 977, 544,
151264
+ /* 1470 */ 107, 536, 544, 4, 544, 937, 938, 325, 215, 1045,
151265
+ /* 1480 */ 296, 1045, 973, 973, 975, 976, 27, 539, 295, 76,
151266
+ /* 1490 */ 76, 54, 54, 327, 72, 72, 128, 128, 1502, 1253,
151267
+ /* 1500 */ 107, 536, 544, 4, 1044, 544, 1044, 531, 1237, 544,
151268
+ /* 1510 */ 423, 544, 315, 334, 544, 97, 544, 539, 217, 544,
151269
+ /* 1520 */ 472, 1527, 533, 239, 73, 73, 156, 129, 129, 158,
151270
+ /* 1530 */ 467, 130, 130, 126, 126, 344, 150, 150, 149, 149,
151271
+ /* 1540 */ 423, 134, 134, 329, 1029, 216, 97, 239, 928, 345,
151272
+ /* 1550 */ 983, 243, 533, 1314, 339, 544, 105, 105, 899, 1354,
151273
+ /* 1560 */ 544, 1289, 258, 106, 338, 423, 546, 545, 544, 1300,
151274
+ /* 1570 */ 973, 892, 99, 536, 109, 4, 544, 133, 133, 391,
151275
+ /* 1580 */ 983, 197, 131, 131, 290, 535, 105, 105, 530, 539,
151276
+ /* 1590 */ 132, 132, 1360, 106, 1218, 423, 546, 545, 75, 75,
151277
+ /* 1600 */ 973, 973, 973, 975, 976, 27, 544, 430, 825, 1210,
151278
+ /* 1610 */ 893, 139, 423, 109, 544, 1199, 1198, 1200, 1521, 544,
151279
+ /* 1620 */ 201, 544, 11, 374, 533, 1286, 347, 349, 77, 77,
151280
+ /* 1630 */ 1339, 973, 973, 975, 976, 27, 74, 74, 351, 213,
151281
+ /* 1640 */ 435, 43, 43, 48, 48, 302, 477, 309, 1347, 382,
151282
+ /* 1650 */ 353, 452, 983, 337, 1236, 1419, 1418, 205, 105, 105,
151283
+ /* 1660 */ 192, 367, 193, 534, 1524, 106, 1177, 423, 546, 545,
151284
+ /* 1670 */ 247, 167, 973, 270, 1466, 200, 1464, 1174, 373, 373,
151285
+ /* 1680 */ 372, 255, 370, 398, 79, 814, 83, 82, 1424, 446,
151286
+ /* 1690 */ 161, 177, 169, 95, 1336, 438, 172, 173, 215, 174,
151287
+ /* 1700 */ 296, 175, 35, 973, 973, 975, 976, 27, 295, 1344,
151288
+ /* 1710 */ 439, 470, 223, 36, 379, 445, 1413, 381, 459, 1350,
151289
+ /* 1720 */ 181, 227, 88, 465, 259, 229, 1435, 318, 186, 468,
151290
+ /* 1730 */ 322, 230, 384, 1201, 231, 486, 1256, 1255, 217, 411,
151291
+ /* 1740 */ 1254, 1247, 90, 846, 206, 413, 156, 505, 1538, 158,
151292
+ /* 1750 */ 1225, 1537, 283, 1507, 1226, 336, 385, 284, 1224, 496,
151293
+ /* 1760 */ 1536, 1297, 94, 346, 348, 216, 1246, 499, 1298, 245,
151294
+ /* 1770 */ 246, 1296, 416, 350, 1493, 124, 1492, 10, 524, 361,
151295
+ /* 1780 */ 1399, 101, 96, 288, 508, 253, 1134, 1207, 34, 1295,
151296
+ /* 1790 */ 547, 254, 256, 257, 392, 548, 1196, 1191, 359, 391,
151297
+ /* 1800 */ 1279, 1278, 196, 365, 290, 535, 366, 352, 1451, 1321,
151298
+ /* 1810 */ 1320, 1452, 153, 137, 281, 154, 801, 424, 155, 1450,
151299
+ /* 1820 */ 1449, 198, 292, 202, 203, 78, 212, 430, 271, 135,
151300
+ /* 1830 */ 1043, 1041, 957, 168, 219, 157, 170, 878, 308, 222,
151301
+ /* 1840 */ 1057, 176, 159, 961, 400, 84, 402, 178, 85, 86,
151302
+ /* 1850 */ 87, 166, 160, 393, 1060, 224, 225, 1056, 146, 18,
151303
+ /* 1860 */ 226, 317, 1049, 1171, 243, 464, 182, 228, 37, 183,
151304
+ /* 1870 */ 816, 469, 338, 232, 330, 481, 184, 89, 844, 19,
151305
+ /* 1880 */ 20, 92, 473, 478, 333, 91, 162, 857, 147, 488,
151306
+ /* 1890 */ 282, 1122, 148, 1009, 927, 1092, 39, 93, 40, 495,
151307
+ /* 1900 */ 1093, 187, 498, 207, 262, 264, 922, 242, 1108, 109,
151308
+ /* 1910 */ 1112, 1110, 1096, 33, 21, 1116, 520, 1024, 22, 23,
151309
+ /* 1920 */ 24, 1115, 25, 190, 97, 1010, 1008, 26, 1012, 1066,
151310
+ /* 1930 */ 248, 7, 1065, 249, 1013, 28, 41, 888, 978, 826,
151311
+ /* 1940 */ 108, 29, 250, 540, 251, 1529, 371, 368, 1129, 1187,
151312
+ /* 1950 */ 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1528,
150203151313
};
150204151314
static const YYCODETYPE yy_lookahead[] = {
150205
- /* 0 */ 187, 187, 187, 216, 217, 187, 206, 187, 264, 265,
150206
- /* 10 */ 266, 187, 225, 187, 209, 187, 264, 265, 266, 19,
150207
- /* 20 */ 187, 187, 209, 210, 209, 210, 187, 209, 210, 209,
150208
- /* 30 */ 210, 31, 209, 209, 210, 209, 210, 285, 224, 39,
150209
- /* 40 */ 203, 204, 205, 43, 44, 45, 46, 47, 48, 49,
150210
- /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 230, 19,
150211
- /* 60 */ 181, 182, 183, 184, 230, 245, 233, 208, 189, 245,
150212
- /* 70 */ 191, 245, 26, 206, 254, 216, 276, 198, 254, 198,
150213
- /* 80 */ 254, 281, 187, 43, 44, 45, 46, 47, 48, 49,
150214
- /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 259, 99,
150215
- /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150216
- /* 110 */ 231, 232, 231, 232, 286, 302, 303, 302, 22, 304,
150217
- /* 120 */ 302, 303, 76, 244, 11, 244, 86, 19, 88, 248,
150218
- /* 130 */ 249, 264, 265, 266, 26, 89, 198, 258, 92, 99,
150219
- /* 140 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150220
- /* 150 */ 105, 43, 44, 45, 46, 47, 48, 49, 50, 51,
150221
- /* 160 */ 52, 53, 54, 55, 56, 57, 212, 288, 273, 231,
150222
- /* 170 */ 232, 105, 106, 107, 108, 109, 131, 69, 203, 204,
150223
- /* 180 */ 205, 136, 244, 99, 100, 101, 102, 103, 104, 105,
150224
- /* 190 */ 106, 107, 108, 109, 15, 103, 104, 19, 260, 103,
150225
- /* 200 */ 104, 54, 55, 56, 57, 58, 22, 99, 100, 101,
150226
- /* 210 */ 102, 103, 104, 105, 106, 107, 108, 109, 264, 265,
150227
- /* 220 */ 266, 43, 44, 45, 46, 47, 48, 49, 50, 51,
150228
- /* 230 */ 52, 53, 54, 55, 56, 57, 19, 124, 125, 60,
150229
- /* 240 */ 148, 24, 150, 59, 187, 67, 99, 100, 101, 102,
150230
- /* 250 */ 103, 104, 105, 106, 107, 108, 109, 187, 187, 109,
150231
- /* 260 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150232
- /* 270 */ 53, 54, 55, 56, 57, 204, 205, 99, 100, 101,
150233
- /* 280 */ 102, 103, 104, 105, 106, 107, 108, 109, 103, 104,
150234
- /* 290 */ 105, 106, 107, 108, 109, 59, 112, 113, 114, 76,
150235
- /* 300 */ 231, 232, 187, 19, 19, 22, 23, 23, 54, 55,
150236
- /* 310 */ 56, 57, 89, 244, 199, 92, 99, 100, 101, 102,
150237
- /* 320 */ 103, 104, 105, 106, 107, 108, 109, 43, 44, 45,
150238
- /* 330 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
150239
- /* 340 */ 56, 57, 19, 212, 187, 274, 23, 26, 112, 113,
150240
- /* 350 */ 114, 294, 295, 99, 100, 101, 102, 103, 104, 105,
150241
- /* 360 */ 106, 107, 108, 109, 59, 295, 43, 44, 45, 46,
150242
- /* 370 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
150243
- /* 380 */ 57, 98, 146, 99, 100, 101, 102, 103, 104, 105,
150244
- /* 390 */ 106, 107, 108, 109, 109, 264, 265, 266, 187, 187,
150245
- /* 400 */ 115, 116, 117, 118, 119, 120, 121, 73, 59, 19,
150246
- /* 410 */ 105, 23, 127, 23, 26, 81, 259, 112, 113, 114,
150247
- /* 420 */ 187, 72, 99, 100, 101, 102, 103, 104, 105, 106,
150248
- /* 430 */ 107, 108, 109, 43, 44, 45, 46, 47, 48, 49,
150249
- /* 440 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 124,
150250
- /* 450 */ 125, 182, 23, 184, 187, 134, 135, 123, 189, 131,
150251
- /* 460 */ 191, 112, 113, 114, 136, 187, 233, 198, 134, 135,
150252
- /* 470 */ 198, 259, 43, 44, 45, 46, 47, 48, 49, 50,
150253
- /* 480 */ 51, 52, 53, 54, 55, 56, 57, 209, 210, 99,
150254
- /* 490 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150255
- /* 500 */ 231, 232, 206, 231, 232, 187, 59, 296, 297, 76,
150256
- /* 510 */ 160, 161, 301, 244, 232, 19, 244, 297, 59, 23,
150257
- /* 520 */ 87, 301, 89, 245, 26, 92, 244, 258, 99, 100,
150258
- /* 530 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 43,
150259
- /* 540 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
150260
- /* 550 */ 54, 55, 56, 57, 19, 187, 97, 288, 23, 112,
150261
- /* 560 */ 113, 114, 115, 296, 297, 118, 119, 120, 301, 108,
150262
- /* 570 */ 109, 112, 113, 255, 141, 128, 117, 281, 43, 44,
150263
- /* 580 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
150264
- /* 590 */ 55, 56, 57, 187, 187, 99, 100, 101, 102, 103,
150265
- /* 600 */ 104, 105, 106, 107, 108, 109, 26, 148, 149, 150,
150266
- /* 610 */ 115, 97, 59, 118, 119, 120, 209, 210, 73, 59,
150267
- /* 620 */ 122, 19, 209, 128, 256, 72, 187, 113, 187, 81,
150268
- /* 630 */ 223, 117, 227, 228, 99, 100, 101, 102, 103, 104,
150269
- /* 640 */ 105, 106, 107, 108, 109, 43, 44, 45, 46, 47,
150270
- /* 650 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
150271
- /* 660 */ 19, 255, 148, 149, 150, 112, 113, 114, 123, 124,
150272
- /* 670 */ 125, 230, 112, 113, 114, 22, 297, 22, 81, 22,
150273
- /* 680 */ 301, 59, 134, 135, 43, 44, 45, 46, 47, 48,
150274
- /* 690 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 139,
150275
- /* 700 */ 192, 99, 100, 101, 102, 103, 104, 105, 106, 107,
150276
- /* 710 */ 108, 109, 59, 116, 59, 187, 59, 231, 232, 46,
150277
- /* 720 */ 47, 48, 49, 16, 12, 145, 198, 22, 187, 187,
150278
- /* 730 */ 244, 134, 135, 222, 112, 113, 114, 209, 210, 27,
150279
- /* 740 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
150280
- /* 750 */ 109, 209, 210, 187, 42, 187, 154, 227, 228, 231,
150281
- /* 760 */ 232, 139, 22, 23, 59, 112, 113, 114, 113, 112,
150282
- /* 770 */ 113, 114, 244, 245, 233, 63, 19, 209, 210, 271,
150283
- /* 780 */ 187, 24, 254, 275, 77, 73, 79, 245, 195, 260,
150284
- /* 790 */ 117, 223, 199, 22, 23, 154, 19, 26, 22, 187,
150285
- /* 800 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150286
- /* 810 */ 53, 54, 55, 56, 57, 19, 187, 112, 113, 114,
150287
- /* 820 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150288
- /* 830 */ 53, 54, 55, 56, 57, 59, 263, 187, 98, 43,
150289
- /* 840 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
150290
- /* 850 */ 54, 55, 56, 57, 204, 205, 99, 100, 101, 102,
150291
- /* 860 */ 103, 104, 105, 106, 107, 108, 109, 255, 130, 98,
150292
- /* 870 */ 132, 133, 299, 300, 198, 187, 99, 100, 101, 102,
150293
- /* 880 */ 103, 104, 105, 106, 107, 108, 109, 187, 112, 113,
150294
- /* 890 */ 114, 187, 241, 187, 243, 99, 100, 101, 102, 103,
150295
- /* 900 */ 104, 105, 106, 107, 108, 109, 19, 231, 232, 209,
150296
- /* 910 */ 210, 282, 59, 209, 210, 209, 210, 16, 230, 19,
150297
- /* 920 */ 244, 22, 23, 223, 274, 26, 19, 223, 187, 223,
150298
- /* 930 */ 198, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150299
- /* 940 */ 53, 54, 55, 56, 57, 45, 46, 47, 48, 49,
150300
- /* 950 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 20,
150301
- /* 960 */ 187, 22, 187, 231, 232, 112, 113, 114, 123, 124,
150302
- /* 970 */ 125, 7, 8, 9, 187, 36, 244, 24, 77, 21,
150303
- /* 980 */ 79, 187, 209, 210, 187, 263, 99, 100, 101, 102,
150304
- /* 990 */ 103, 104, 105, 106, 107, 108, 109, 98, 59, 99,
150305
- /* 1000 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150306
- /* 1010 */ 71, 187, 59, 187, 187, 19, 20, 187, 22, 112,
150307
- /* 1020 */ 81, 299, 300, 282, 230, 199, 291, 292, 22, 187,
150308
- /* 1030 */ 24, 256, 36, 209, 210, 187, 97, 35, 80, 209,
150309
- /* 1040 */ 210, 268, 103, 104, 48, 187, 220, 223, 222, 110,
150310
- /* 1050 */ 59, 112, 113, 114, 187, 59, 117, 156, 187, 179,
150311
- /* 1060 */ 180, 181, 182, 183, 184, 59, 113, 71, 66, 189,
150312
- /* 1070 */ 22, 191, 230, 134, 135, 245, 74, 119, 198, 282,
150313
- /* 1080 */ 297, 85, 224, 198, 301, 187, 90, 148, 149, 150,
150314
- /* 1090 */ 151, 152, 19, 97, 103, 104, 123, 124, 125, 103,
150315
- /* 1100 */ 104, 53, 111, 112, 113, 114, 110, 116, 112, 113,
150316
- /* 1110 */ 114, 231, 232, 117, 156, 124, 231, 232, 297, 113,
150317
- /* 1120 */ 187, 24, 301, 256, 244, 201, 202, 256, 126, 244,
150318
- /* 1130 */ 187, 198, 187, 187, 23, 187, 187, 26, 258, 148,
150319
- /* 1140 */ 19, 150, 209, 210, 148, 149, 150, 151, 152, 0,
150320
- /* 1150 */ 1, 2, 209, 210, 5, 209, 210, 209, 210, 10,
150321
- /* 1160 */ 11, 12, 13, 14, 231, 232, 17, 46, 288, 19,
150322
- /* 1170 */ 20, 223, 22, 236, 198, 66, 187, 244, 245, 30,
150323
- /* 1180 */ 12, 32, 198, 246, 59, 112, 36, 187, 245, 40,
150324
- /* 1190 */ 198, 245, 117, 29, 85, 27, 26, 33, 209, 210,
150325
- /* 1200 */ 297, 76, 127, 94, 301, 256, 26, 231, 232, 59,
150326
- /* 1210 */ 42, 153, 87, 155, 89, 231, 232, 92, 31, 70,
150327
- /* 1220 */ 244, 71, 26, 231, 232, 114, 39, 78, 244, 65,
150328
- /* 1230 */ 81, 63, 111, 233, 137, 85, 244, 112, 113, 114,
150329
- /* 1240 */ 90, 22, 59, 24, 95, 201, 202, 97, 127, 187,
150330
- /* 1250 */ 139, 142, 187, 103, 104, 19, 20, 187, 22, 187,
150331
- /* 1260 */ 110, 187, 112, 113, 114, 187, 141, 117, 141, 187,
150332
- /* 1270 */ 23, 187, 36, 26, 209, 210, 134, 135, 129, 209,
150333
- /* 1280 */ 210, 209, 210, 134, 135, 22, 159, 209, 210, 187,
150334
- /* 1290 */ 187, 209, 210, 209, 210, 59, 113, 187, 148, 149,
150335
- /* 1300 */ 150, 151, 152, 289, 290, 187, 157, 71, 248, 249,
150336
- /* 1310 */ 114, 141, 209, 210, 46, 125, 116, 117, 138, 19,
150337
- /* 1320 */ 20, 85, 22, 148, 61, 150, 90, 209, 210, 23,
150338
- /* 1330 */ 7, 8, 26, 97, 187, 139, 36, 147, 59, 103,
150339
- /* 1340 */ 104, 19, 20, 187, 22, 59, 110, 187, 112, 113,
150340
- /* 1350 */ 114, 1, 2, 117, 187, 5, 209, 210, 36, 59,
150341
- /* 1360 */ 10, 11, 12, 13, 14, 209, 210, 17, 59, 209,
150342
- /* 1370 */ 210, 71, 187, 148, 250, 150, 209, 210, 187, 111,
150343
- /* 1380 */ 30, 59, 32, 22, 148, 149, 150, 151, 152, 187,
150344
- /* 1390 */ 40, 187, 113, 71, 209, 210, 187, 97, 187, 113,
150345
- /* 1400 */ 209, 210, 187, 103, 104, 105, 23, 187, 187, 26,
150346
- /* 1410 */ 110, 187, 112, 113, 114, 83, 84, 117, 23, 97,
150347
- /* 1420 */ 70, 26, 113, 218, 187, 103, 104, 187, 78, 209,
150348
- /* 1430 */ 210, 81, 110, 187, 112, 113, 114, 19, 20, 117,
150349
- /* 1440 */ 22, 187, 187, 187, 187, 95, 209, 210, 148, 149,
150350
- /* 1450 */ 150, 151, 152, 187, 36, 23, 187, 187, 26, 187,
150351
- /* 1460 */ 187, 187, 187, 209, 210, 209, 210, 187, 187, 218,
150352
- /* 1470 */ 148, 149, 150, 151, 152, 209, 210, 59, 187, 129,
150353
- /* 1480 */ 187, 209, 210, 187, 134, 135, 187, 306, 187, 71,
150354
- /* 1490 */ 209, 210, 23, 228, 187, 26, 23, 187, 137, 26,
150355
- /* 1500 */ 209, 210, 209, 210, 187, 209, 210, 157, 209, 210,
150356
- /* 1510 */ 209, 210, 218, 187, 187, 97, 209, 210, 187, 278,
150357
- /* 1520 */ 23, 103, 104, 26, 187, 187, 187, 187, 110, 187,
150358
- /* 1530 */ 112, 113, 114, 187, 187, 117, 5, 247, 187, 187,
150359
- /* 1540 */ 187, 10, 11, 12, 13, 14, 209, 210, 17, 209,
150360
- /* 1550 */ 210, 209, 210, 187, 187, 187, 209, 210, 187, 23,
150361
- /* 1560 */ 187, 30, 26, 32, 187, 187, 148, 149, 150, 151,
150362
- /* 1570 */ 152, 40, 187, 187, 187, 209, 210, 209, 210, 187,
150363
- /* 1580 */ 209, 210, 209, 210, 187, 187, 209, 210, 187, 277,
150364
- /* 1590 */ 234, 187, 247, 187, 209, 210, 209, 210, 187, 235,
150365
- /* 1600 */ 187, 70, 187, 207, 247, 247, 247, 209, 210, 78,
150366
- /* 1610 */ 209, 210, 81, 209, 210, 209, 210, 187, 185, 238,
150367
- /* 1620 */ 209, 210, 209, 210, 209, 210, 95, 251, 287, 238,
150368
- /* 1630 */ 251, 23, 23, 23, 26, 26, 26, 283, 23, 209,
150369
- /* 1640 */ 210, 26, 213, 238, 221, 283, 212, 212, 217, 212,
150370
- /* 1650 */ 251, 241, 270, 241, 237, 235, 190, 60, 137, 287,
150371
- /* 1660 */ 129, 194, 194, 38, 284, 134, 135, 273, 284, 194,
150372
- /* 1670 */ 146, 111, 22, 43, 226, 145, 262, 261, 238, 18,
150373
- /* 1680 */ 229, 229, 229, 229, 194, 18, 193, 238, 157, 262,
150374
- /* 1690 */ 226, 226, 194, 238, 238, 193, 153, 261, 62, 280,
150375
- /* 1700 */ 279, 194, 193, 22, 194, 214, 193, 111, 194, 193,
150376
- /* 1710 */ 214, 211, 211, 64, 211, 211, 122, 211, 219, 214,
150377
- /* 1720 */ 109, 213, 160, 211, 300, 140, 211, 253, 111, 272,
150378
- /* 1730 */ 219, 214, 272, 214, 252, 194, 253, 252, 91, 253,
150379
- /* 1740 */ 252, 82, 253, 305, 252, 144, 305, 141, 22, 194,
150380
- /* 1750 */ 269, 257, 257, 153, 267, 143, 142, 25, 197, 26,
150381
- /* 1760 */ 242, 241, 196, 240, 242, 239, 238, 13, 188, 188,
150382
- /* 1770 */ 6, 293, 186, 186, 186, 200, 206, 293, 206, 206,
150383
- /* 1780 */ 206, 4, 200, 215, 215, 207, 207, 3, 22, 206,
150384
- /* 1790 */ 200, 158, 96, 15, 23, 16, 23, 135, 146, 126,
150385
- /* 1800 */ 24, 138, 20, 16, 140, 1, 138, 147, 126, 61,
150386
- /* 1810 */ 53, 37, 146, 53, 53, 290, 53, 126, 112, 34,
150387
- /* 1820 */ 137, 1, 5, 22, 111, 156, 68, 68, 26, 41,
150388
- /* 1830 */ 75, 137, 111, 24, 20, 19, 127, 121, 23, 67,
150389
- /* 1840 */ 22, 22, 67, 22, 22, 37, 22, 67, 23, 145,
150390
- /* 1850 */ 22, 28, 23, 23, 23, 137, 23, 22, 26, 22,
150391
- /* 1860 */ 24, 23, 112, 24, 23, 23, 22, 139, 34, 26,
150392
- /* 1870 */ 75, 88, 86, 75, 34, 23, 22, 24, 22, 34,
150393
- /* 1880 */ 34, 34, 93, 34, 26, 26, 23, 23, 23, 34,
150394
- /* 1890 */ 23, 23, 44, 23, 11, 26, 22, 22, 26, 23,
150395
- /* 1900 */ 23, 22, 22, 15, 137, 137, 137, 137, 23, 1,
150396
- /* 1910 */ 307, 307, 131, 307, 307, 307, 307, 307, 307, 307,
150397
- /* 1920 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150398
- /* 1930 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150399
- /* 1940 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150400
- /* 1950 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150401
- /* 1960 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150402
- /* 1970 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150403
- /* 1980 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150404
- /* 1990 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150405
- /* 2000 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150406
- /* 2010 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150407
- /* 2020 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150408
- /* 2030 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150409
- /* 2040 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150410
- /* 2050 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150411
- /* 2060 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150412
- /* 2070 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150413
- /* 2080 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150414
- /* 2090 */ 307, 307,
150415
-};
150416
-#define YY_SHIFT_COUNT (542)
151315
+ /* 0 */ 189, 211, 189, 189, 218, 189, 220, 189, 267, 268,
151316
+ /* 10 */ 269, 189, 210, 189, 228, 189, 267, 268, 269, 19,
151317
+ /* 20 */ 218, 189, 211, 212, 211, 212, 211, 211, 212, 211,
151318
+ /* 30 */ 212, 31, 211, 211, 212, 211, 212, 288, 300, 39,
151319
+ /* 40 */ 21, 189, 304, 43, 44, 45, 46, 47, 48, 49,
151320
+ /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 225, 19,
151321
+ /* 60 */ 189, 183, 184, 185, 186, 189, 248, 263, 236, 191,
151322
+ /* 70 */ 248, 193, 248, 197, 208, 257, 262, 201, 200, 257,
151323
+ /* 80 */ 200, 257, 81, 43, 44, 45, 46, 47, 48, 49,
151324
+ /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 189, 80,
151325
+ /* 100 */ 189, 101, 102, 103, 104, 105, 106, 107, 108, 109,
151326
+ /* 110 */ 110, 111, 234, 235, 234, 235, 305, 306, 305, 118,
151327
+ /* 120 */ 307, 305, 306, 297, 298, 247, 86, 247, 88, 19,
151328
+ /* 130 */ 259, 251, 252, 267, 268, 269, 26, 136, 137, 261,
151329
+ /* 140 */ 121, 101, 102, 103, 104, 105, 106, 107, 108, 109,
151330
+ /* 150 */ 110, 111, 59, 43, 44, 45, 46, 47, 48, 49,
151331
+ /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 259, 291,
151332
+ /* 170 */ 105, 106, 107, 108, 109, 110, 111, 158, 189, 69,
151333
+ /* 180 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
151334
+ /* 190 */ 111, 107, 108, 109, 110, 111, 205, 206, 207, 19,
151335
+ /* 200 */ 19, 54, 55, 56, 57, 58, 29, 114, 115, 116,
151336
+ /* 210 */ 33, 101, 102, 103, 104, 105, 106, 107, 108, 109,
151337
+ /* 220 */ 110, 111, 233, 43, 44, 45, 46, 47, 48, 49,
151338
+ /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 126,
151339
+ /* 240 */ 127, 148, 65, 24, 214, 200, 59, 67, 101, 102,
151340
+ /* 250 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 22,
151341
+ /* 260 */ 189, 111, 43, 44, 45, 46, 47, 48, 49, 50,
151342
+ /* 270 */ 51, 52, 53, 54, 55, 56, 57, 206, 207, 234,
151343
+ /* 280 */ 235, 101, 102, 103, 104, 105, 106, 107, 108, 109,
151344
+ /* 290 */ 110, 111, 247, 76, 107, 114, 59, 267, 268, 269,
151345
+ /* 300 */ 189, 114, 115, 116, 162, 163, 89, 19, 263, 92,
151346
+ /* 310 */ 189, 23, 54, 55, 56, 57, 189, 206, 207, 22,
151347
+ /* 320 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
151348
+ /* 330 */ 111, 43, 44, 45, 46, 47, 48, 49, 50, 51,
151349
+ /* 340 */ 52, 53, 54, 55, 56, 57, 19, 189, 277, 59,
151350
+ /* 350 */ 23, 114, 115, 116, 46, 47, 48, 49, 61, 101,
151351
+ /* 360 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
151352
+ /* 370 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
151353
+ /* 380 */ 53, 54, 55, 56, 57, 125, 126, 127, 277, 101,
151354
+ /* 390 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
151355
+ /* 400 */ 59, 189, 189, 276, 114, 115, 116, 117, 73, 59,
151356
+ /* 410 */ 120, 121, 122, 72, 214, 19, 81, 259, 19, 23,
151357
+ /* 420 */ 130, 81, 72, 24, 211, 212, 221, 119, 101, 102,
151358
+ /* 430 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 43,
151359
+ /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
151360
+ /* 450 */ 54, 55, 56, 57, 19, 114, 115, 116, 23, 208,
151361
+ /* 460 */ 125, 248, 189, 189, 114, 115, 116, 267, 268, 269,
151362
+ /* 470 */ 189, 136, 137, 189, 262, 22, 136, 137, 43, 44,
151363
+ /* 480 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
151364
+ /* 490 */ 55, 56, 57, 189, 95, 211, 212, 101, 102, 103,
151365
+ /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 59, 189,
151366
+ /* 510 */ 111, 189, 59, 76, 294, 295, 117, 118, 119, 120,
151367
+ /* 520 */ 121, 122, 123, 19, 87, 189, 89, 23, 129, 92,
151368
+ /* 530 */ 279, 227, 248, 22, 189, 284, 101, 102, 103, 104,
151369
+ /* 540 */ 105, 106, 107, 108, 109, 110, 111, 43, 44, 45,
151370
+ /* 550 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
151371
+ /* 560 */ 56, 57, 19, 114, 115, 116, 23, 114, 115, 116,
151372
+ /* 570 */ 59, 117, 299, 300, 120, 121, 122, 304, 189, 189,
151373
+ /* 580 */ 143, 189, 110, 111, 130, 22, 43, 44, 45, 46,
151374
+ /* 590 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
151375
+ /* 600 */ 57, 211, 212, 211, 212, 101, 102, 103, 104, 105,
151376
+ /* 610 */ 106, 107, 108, 109, 110, 111, 226, 189, 226, 189,
151377
+ /* 620 */ 298, 132, 59, 134, 135, 114, 115, 116, 189, 59,
151378
+ /* 630 */ 285, 19, 7, 8, 9, 23, 205, 206, 207, 211,
151379
+ /* 640 */ 212, 211, 212, 221, 101, 102, 103, 104, 105, 106,
151380
+ /* 650 */ 107, 108, 109, 110, 111, 43, 44, 45, 46, 47,
151381
+ /* 660 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
151382
+ /* 670 */ 19, 181, 182, 183, 184, 185, 186, 114, 115, 116,
151383
+ /* 680 */ 189, 191, 133, 193, 114, 115, 116, 138, 299, 300,
151384
+ /* 690 */ 200, 22, 201, 304, 43, 44, 45, 46, 47, 48,
151385
+ /* 700 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 35,
151386
+ /* 710 */ 189, 141, 189, 101, 102, 103, 104, 105, 106, 107,
151387
+ /* 720 */ 108, 109, 110, 111, 234, 235, 22, 23, 59, 184,
151388
+ /* 730 */ 26, 186, 211, 212, 211, 212, 191, 247, 193, 19,
151389
+ /* 740 */ 66, 105, 106, 73, 189, 200, 189, 226, 74, 226,
151390
+ /* 750 */ 22, 261, 101, 102, 103, 104, 105, 106, 107, 108,
151391
+ /* 760 */ 109, 110, 111, 43, 44, 45, 46, 47, 48, 49,
151392
+ /* 770 */ 50, 51, 52, 53, 54, 55, 56, 57, 189, 234,
151393
+ /* 780 */ 235, 291, 19, 114, 115, 116, 150, 59, 152, 189,
151394
+ /* 790 */ 233, 236, 247, 59, 189, 125, 126, 127, 59, 300,
151395
+ /* 800 */ 211, 212, 128, 304, 100, 19, 261, 156, 45, 46,
151396
+ /* 810 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
151397
+ /* 820 */ 57, 101, 102, 103, 104, 105, 106, 107, 108, 109,
151398
+ /* 830 */ 110, 111, 46, 233, 189, 189, 291, 248, 99, 189,
151399
+ /* 840 */ 125, 126, 127, 115, 26, 200, 289, 230, 231, 115,
151400
+ /* 850 */ 200, 16, 189, 114, 115, 189, 211, 212, 119, 221,
151401
+ /* 860 */ 189, 211, 212, 258, 101, 102, 103, 104, 105, 106,
151402
+ /* 870 */ 107, 108, 109, 110, 111, 189, 156, 211, 212, 234,
151403
+ /* 880 */ 235, 189, 211, 212, 234, 235, 22, 201, 189, 150,
151404
+ /* 890 */ 151, 152, 247, 248, 76, 16, 19, 247, 248, 113,
151405
+ /* 900 */ 189, 24, 257, 211, 212, 189, 26, 89, 262, 223,
151406
+ /* 910 */ 92, 225, 77, 189, 79, 129, 19, 53, 226, 248,
151407
+ /* 920 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
151408
+ /* 930 */ 53, 54, 55, 56, 57, 236, 19, 271, 189, 99,
151409
+ /* 940 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
151410
+ /* 950 */ 53, 54, 55, 56, 57, 115, 77, 59, 79, 119,
151411
+ /* 960 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
151412
+ /* 970 */ 53, 54, 55, 56, 57, 259, 22, 23, 101, 102,
151413
+ /* 980 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 59,
151414
+ /* 990 */ 150, 151, 152, 158, 22, 244, 24, 246, 101, 102,
151415
+ /* 1000 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 285,
151416
+ /* 1010 */ 189, 189, 114, 115, 116, 200, 136, 137, 101, 102,
151417
+ /* 1020 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 230,
151418
+ /* 1030 */ 231, 59, 211, 212, 285, 105, 106, 189, 19, 141,
151419
+ /* 1040 */ 234, 235, 239, 113, 114, 115, 116, 226, 118, 234,
151420
+ /* 1050 */ 235, 189, 249, 247, 100, 189, 126, 23, 236, 107,
151421
+ /* 1060 */ 26, 189, 247, 44, 45, 46, 47, 48, 49, 50,
151422
+ /* 1070 */ 51, 52, 53, 54, 55, 56, 57, 211, 212, 59,
151423
+ /* 1080 */ 150, 233, 152, 211, 212, 133, 12, 115, 189, 189,
151424
+ /* 1090 */ 138, 19, 20, 300, 22, 233, 76, 304, 226, 11,
151425
+ /* 1100 */ 208, 27, 22, 23, 200, 19, 26, 87, 36, 89,
151426
+ /* 1110 */ 211, 212, 92, 300, 248, 189, 42, 304, 189, 250,
151427
+ /* 1120 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
151428
+ /* 1130 */ 111, 59, 200, 233, 114, 115, 116, 63, 234, 235,
151429
+ /* 1140 */ 235, 19, 20, 71, 22, 300, 189, 73, 200, 304,
151430
+ /* 1150 */ 116, 247, 247, 81, 23, 200, 227, 26, 36, 234,
151431
+ /* 1160 */ 235, 203, 204, 143, 200, 26, 234, 235, 194, 200,
151432
+ /* 1170 */ 48, 99, 247, 66, 189, 141, 284, 105, 106, 247,
151433
+ /* 1180 */ 100, 59, 234, 235, 112, 259, 114, 115, 116, 234,
151434
+ /* 1190 */ 235, 119, 85, 71, 266, 247, 211, 212, 234, 235,
151435
+ /* 1200 */ 114, 94, 247, 234, 235, 12, 266, 85, 136, 137,
151436
+ /* 1210 */ 189, 247, 90, 26, 126, 127, 247, 189, 26, 22,
151437
+ /* 1220 */ 27, 99, 150, 151, 152, 153, 154, 105, 106, 189,
151438
+ /* 1230 */ 302, 303, 211, 212, 112, 42, 114, 115, 116, 211,
151439
+ /* 1240 */ 212, 119, 302, 303, 19, 20, 189, 22, 274, 189,
151440
+ /* 1250 */ 15, 144, 278, 189, 22, 23, 63, 189, 189, 203,
151441
+ /* 1260 */ 204, 36, 136, 137, 155, 24, 157, 143, 211, 212,
151442
+ /* 1270 */ 189, 26, 150, 151, 152, 153, 154, 0, 1, 2,
151443
+ /* 1280 */ 211, 212, 5, 46, 59, 161, 147, 10, 11, 12,
151444
+ /* 1290 */ 13, 14, 211, 212, 17, 60, 71, 189, 258, 189,
151445
+ /* 1300 */ 59, 59, 105, 106, 189, 189, 189, 30, 116, 32,
151446
+ /* 1310 */ 85, 124, 189, 251, 252, 90, 189, 40, 258, 211,
151447
+ /* 1320 */ 212, 211, 212, 189, 99, 26, 211, 212, 211, 212,
151448
+ /* 1330 */ 105, 106, 100, 141, 211, 212, 189, 112, 189, 114,
151449
+ /* 1340 */ 115, 116, 24, 189, 119, 31, 23, 70, 189, 26,
151450
+ /* 1350 */ 113, 19, 20, 39, 22, 78, 115, 115, 81, 189,
151451
+ /* 1360 */ 211, 212, 22, 189, 24, 211, 212, 189, 36, 189,
151452
+ /* 1370 */ 211, 212, 189, 189, 97, 150, 151, 152, 153, 154,
151453
+ /* 1380 */ 127, 211, 212, 189, 189, 211, 212, 189, 143, 211,
151454
+ /* 1390 */ 212, 59, 189, 189, 211, 212, 23, 189, 189, 26,
151455
+ /* 1400 */ 59, 189, 149, 71, 22, 211, 212, 189, 131, 211,
151456
+ /* 1410 */ 212, 189, 59, 136, 137, 211, 212, 85, 189, 211,
151457
+ /* 1420 */ 212, 253, 90, 211, 212, 292, 293, 118, 119, 211,
151458
+ /* 1430 */ 212, 99, 23, 211, 212, 26, 159, 105, 106, 140,
151459
+ /* 1440 */ 211, 212, 23, 189, 112, 26, 114, 115, 116, 1,
151460
+ /* 1450 */ 2, 119, 189, 5, 7, 8, 115, 139, 10, 11,
151461
+ /* 1460 */ 12, 13, 14, 23, 189, 17, 26, 189, 115, 189,
151462
+ /* 1470 */ 19, 20, 189, 22, 189, 83, 84, 189, 30, 150,
151463
+ /* 1480 */ 32, 152, 150, 151, 152, 153, 154, 36, 40, 211,
151464
+ /* 1490 */ 212, 211, 212, 189, 211, 212, 211, 212, 309, 189,
151465
+ /* 1500 */ 19, 20, 189, 22, 150, 189, 152, 231, 189, 189,
151466
+ /* 1510 */ 59, 189, 23, 189, 189, 26, 189, 36, 70, 189,
151467
+ /* 1520 */ 23, 139, 71, 26, 211, 212, 78, 211, 212, 81,
151468
+ /* 1530 */ 281, 211, 212, 211, 212, 189, 211, 212, 211, 212,
151469
+ /* 1540 */ 59, 211, 212, 23, 23, 97, 26, 26, 23, 189,
151470
+ /* 1550 */ 99, 26, 71, 189, 119, 189, 105, 106, 107, 189,
151471
+ /* 1560 */ 189, 189, 280, 112, 129, 114, 115, 116, 189, 189,
151472
+ /* 1570 */ 119, 23, 19, 20, 26, 22, 189, 211, 212, 131,
151473
+ /* 1580 */ 99, 237, 211, 212, 136, 137, 105, 106, 189, 36,
151474
+ /* 1590 */ 211, 212, 189, 112, 189, 114, 115, 116, 211, 212,
151475
+ /* 1600 */ 119, 150, 151, 152, 153, 154, 189, 159, 23, 189,
151476
+ /* 1610 */ 23, 26, 59, 26, 189, 189, 189, 189, 189, 189,
151477
+ /* 1620 */ 209, 189, 238, 187, 71, 250, 250, 250, 211, 212,
151478
+ /* 1630 */ 241, 150, 151, 152, 153, 154, 211, 212, 250, 290,
151479
+ /* 1640 */ 254, 211, 212, 211, 212, 254, 215, 286, 241, 241,
151480
+ /* 1650 */ 254, 286, 99, 214, 220, 214, 214, 224, 105, 106,
151481
+ /* 1660 */ 244, 240, 244, 273, 192, 112, 60, 114, 115, 116,
151482
+ /* 1670 */ 139, 290, 119, 5, 196, 238, 196, 38, 10, 11,
151483
+ /* 1680 */ 12, 13, 14, 196, 287, 17, 148, 287, 276, 113,
151484
+ /* 1690 */ 43, 22, 229, 147, 241, 18, 232, 232, 30, 232,
151485
+ /* 1700 */ 32, 232, 264, 150, 151, 152, 153, 154, 40, 265,
151486
+ /* 1710 */ 196, 18, 195, 264, 241, 241, 241, 265, 196, 229,
151487
+ /* 1720 */ 229, 195, 155, 62, 196, 195, 283, 282, 22, 216,
151488
+ /* 1730 */ 196, 195, 216, 196, 195, 113, 213, 213, 70, 64,
151489
+ /* 1740 */ 213, 222, 22, 124, 162, 111, 78, 142, 219, 81,
151490
+ /* 1750 */ 215, 219, 275, 303, 213, 213, 216, 275, 213, 216,
151491
+ /* 1760 */ 213, 256, 113, 255, 255, 97, 222, 216, 256, 196,
151492
+ /* 1770 */ 91, 256, 82, 255, 308, 146, 308, 22, 143, 196,
151493
+ /* 1780 */ 270, 155, 145, 272, 144, 25, 13, 199, 26, 256,
151494
+ /* 1790 */ 198, 190, 190, 6, 296, 188, 188, 188, 244, 131,
151495
+ /* 1800 */ 245, 245, 243, 242, 136, 137, 241, 255, 208, 260,
151496
+ /* 1810 */ 260, 208, 202, 217, 217, 202, 4, 3, 202, 208,
151497
+ /* 1820 */ 208, 22, 160, 209, 209, 208, 15, 159, 98, 16,
151498
+ /* 1830 */ 23, 23, 137, 148, 24, 128, 140, 20, 16, 142,
151499
+ /* 1840 */ 1, 140, 128, 149, 61, 53, 37, 148, 53, 53,
151500
+ /* 1850 */ 53, 293, 128, 296, 114, 34, 139, 1, 5, 22,
151501
+ /* 1860 */ 113, 158, 68, 75, 26, 41, 68, 139, 24, 113,
151502
+ /* 1870 */ 20, 19, 129, 123, 23, 96, 22, 22, 59, 22,
151503
+ /* 1880 */ 22, 147, 67, 67, 24, 22, 37, 28, 23, 22,
151504
+ /* 1890 */ 67, 23, 23, 23, 114, 23, 22, 26, 22, 24,
151505
+ /* 1900 */ 23, 22, 24, 139, 23, 23, 141, 34, 88, 26,
151506
+ /* 1910 */ 75, 86, 23, 22, 34, 75, 24, 23, 34, 34,
151507
+ /* 1920 */ 34, 93, 34, 26, 26, 23, 23, 34, 23, 23,
151508
+ /* 1930 */ 26, 44, 23, 22, 11, 22, 22, 133, 23, 23,
151509
+ /* 1940 */ 22, 22, 139, 26, 139, 139, 15, 23, 1, 310,
151510
+ /* 1950 */ 310, 310, 310, 310, 310, 310, 310, 139, 310, 310,
151511
+ /* 1960 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151512
+ /* 1970 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151513
+ /* 1980 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151514
+ /* 1990 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151515
+ /* 2000 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151516
+ /* 2010 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151517
+ /* 2020 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151518
+ /* 2030 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151519
+ /* 2040 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151520
+ /* 2050 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151521
+ /* 2060 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151522
+ /* 2070 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151523
+ /* 2080 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151524
+ /* 2090 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151525
+ /* 2100 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151526
+ /* 2110 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151527
+ /* 2120 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151528
+ /* 2130 */ 310, 310, 310, 310, 310, 310, 310, 310, 310,
151529
+};
151530
+#define YY_SHIFT_COUNT (549)
150417151531
#define YY_SHIFT_MIN (0)
150418
-#define YY_SHIFT_MAX (1908)
151532
+#define YY_SHIFT_MAX (1947)
150419151533
static const unsigned short int yy_shift_ofst[] = {
150420
- /* 0 */ 1350, 1149, 1531, 939, 939, 548, 996, 1150, 1236, 1322,
150421
- /* 10 */ 1322, 1322, 334, 0, 0, 178, 777, 1322, 1322, 1322,
150422
- /* 20 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150423
- /* 30 */ 991, 991, 1125, 1125, 447, 597, 548, 548, 548, 548,
150424
- /* 40 */ 548, 548, 40, 108, 217, 284, 323, 390, 429, 496,
150425
- /* 50 */ 535, 602, 641, 757, 777, 777, 777, 777, 777, 777,
150426
- /* 60 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777,
150427
- /* 70 */ 777, 777, 796, 777, 887, 900, 900, 1300, 1322, 1322,
150428
- /* 80 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150429
- /* 90 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150430
- /* 100 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150431
- /* 110 */ 1418, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150432
- /* 120 */ 1322, 1322, 1322, 1322, 147, 254, 254, 254, 254, 254,
150433
- /* 130 */ 84, 185, 66, 853, 958, 1121, 853, 92, 92, 853,
150434
- /* 140 */ 321, 321, 321, 321, 325, 350, 350, 461, 150, 1913,
150435
- /* 150 */ 1913, 285, 285, 285, 236, 184, 349, 184, 184, 712,
150436
- /* 160 */ 712, 433, 553, 771, 899, 853, 853, 853, 853, 853,
150437
- /* 170 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 853,
150438
- /* 180 */ 853, 853, 853, 853, 853, 853, 46, 46, 853, 113,
150439
- /* 190 */ 223, 223, 1183, 1183, 1127, 1142, 1913, 1913, 1913, 459,
150440
- /* 200 */ 514, 514, 653, 495, 657, 305, 705, 560, 622, 776,
150441
- /* 210 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 545,
150442
- /* 220 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 853,
150443
- /* 230 */ 853, 853, 1002, 1002, 1002, 853, 853, 853, 853, 1111,
150444
- /* 240 */ 853, 853, 853, 1006, 1109, 853, 853, 1168, 853, 853,
150445
- /* 250 */ 853, 853, 853, 853, 853, 853, 845, 1164, 738, 953,
150446
- /* 260 */ 953, 953, 953, 1196, 738, 738, 45, 96, 964, 179,
150447
- /* 270 */ 580, 907, 907, 1073, 580, 580, 1073, 498, 388, 1268,
150448
- /* 280 */ 1187, 1187, 1187, 907, 1170, 1170, 1058, 1180, 328, 1219,
150449
- /* 290 */ 1597, 1521, 1521, 1625, 1625, 1521, 1524, 1560, 1650, 1630,
150450
- /* 300 */ 1530, 1661, 1661, 1661, 1661, 1521, 1667, 1530, 1530, 1560,
150451
- /* 310 */ 1650, 1630, 1630, 1530, 1521, 1667, 1543, 1636, 1521, 1667,
150452
- /* 320 */ 1681, 1521, 1667, 1521, 1667, 1681, 1596, 1596, 1596, 1649,
150453
- /* 330 */ 1681, 1596, 1594, 1596, 1649, 1596, 1596, 1562, 1681, 1611,
150454
- /* 340 */ 1611, 1681, 1585, 1617, 1585, 1617, 1585, 1617, 1585, 1617,
150455
- /* 350 */ 1521, 1647, 1647, 1659, 1659, 1601, 1606, 1726, 1521, 1600,
150456
- /* 360 */ 1601, 1612, 1614, 1530, 1732, 1733, 1754, 1754, 1764, 1764,
150457
- /* 370 */ 1764, 1913, 1913, 1913, 1913, 1913, 1913, 1913, 1913, 1913,
150458
- /* 380 */ 1913, 1913, 1913, 1913, 1913, 1913, 673, 901, 283, 740,
150459
- /* 390 */ 707, 973, 655, 1247, 1048, 1097, 1190, 1306, 1263, 1383,
150460
- /* 400 */ 1395, 1432, 1469, 1473, 1497, 1279, 1200, 1323, 1075, 1286,
150461
- /* 410 */ 1536, 1608, 1332, 1609, 1175, 1225, 1610, 1615, 1309, 1361,
150462
- /* 420 */ 1777, 1784, 1766, 1633, 1778, 1696, 1779, 1771, 1773, 1662,
150463
- /* 430 */ 1652, 1673, 1776, 1663, 1782, 1664, 1787, 1804, 1668, 1660,
150464
- /* 440 */ 1682, 1748, 1774, 1666, 1757, 1760, 1761, 1763, 1691, 1706,
150465
- /* 450 */ 1785, 1683, 1820, 1817, 1801, 1713, 1669, 1758, 1802, 1759,
150466
- /* 460 */ 1755, 1788, 1694, 1721, 1809, 1814, 1816, 1709, 1716, 1818,
150467
- /* 470 */ 1772, 1819, 1821, 1815, 1822, 1775, 1823, 1824, 1780, 1808,
150468
- /* 480 */ 1825, 1704, 1828, 1829, 1830, 1831, 1832, 1833, 1835, 1836,
150469
- /* 490 */ 1838, 1837, 1839, 1718, 1841, 1842, 1750, 1834, 1844, 1728,
150470
- /* 500 */ 1843, 1840, 1845, 1846, 1847, 1783, 1795, 1786, 1848, 1798,
150471
- /* 510 */ 1789, 1849, 1852, 1854, 1853, 1858, 1859, 1855, 1863, 1843,
150472
- /* 520 */ 1864, 1865, 1867, 1868, 1869, 1870, 1856, 1883, 1874, 1875,
150473
- /* 530 */ 1876, 1877, 1879, 1880, 1872, 1781, 1767, 1768, 1769, 1770,
150474
- /* 540 */ 1885, 1888, 1908,
150475
-};
150476
-#define YY_REDUCE_COUNT (385)
150477
-#define YY_REDUCE_MIN (-256)
150478
-#define YY_REDUCE_MAX (1590)
151534
+ /* 0 */ 1448, 1277, 1668, 1072, 1072, 340, 1122, 1225, 1332, 1481,
151535
+ /* 10 */ 1481, 1481, 335, 0, 0, 180, 897, 1481, 1481, 1481,
151536
+ /* 20 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151537
+ /* 30 */ 930, 930, 1020, 1020, 290, 1, 340, 340, 340, 340,
151538
+ /* 40 */ 340, 340, 40, 110, 219, 288, 327, 396, 435, 504,
151539
+ /* 50 */ 543, 612, 651, 720, 877, 897, 897, 897, 897, 897,
151540
+ /* 60 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897,
151541
+ /* 70 */ 897, 897, 897, 917, 897, 1019, 763, 763, 1451, 1481,
151542
+ /* 80 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151543
+ /* 90 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151544
+ /* 100 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151545
+ /* 110 */ 1481, 1481, 1553, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151546
+ /* 120 */ 1481, 1481, 1481, 1481, 1481, 1481, 147, 258, 258, 258,
151547
+ /* 130 */ 258, 258, 79, 65, 84, 449, 19, 786, 449, 636,
151548
+ /* 140 */ 636, 449, 880, 880, 880, 880, 113, 142, 142, 472,
151549
+ /* 150 */ 150, 1958, 1958, 399, 399, 399, 93, 237, 341, 237,
151550
+ /* 160 */ 237, 1074, 1074, 437, 350, 704, 1080, 449, 449, 449,
151551
+ /* 170 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449,
151552
+ /* 180 */ 449, 449, 449, 449, 449, 449, 449, 449, 818, 818,
151553
+ /* 190 */ 449, 1088, 217, 217, 734, 734, 1124, 1126, 1958, 1958,
151554
+ /* 200 */ 1958, 739, 840, 840, 453, 454, 511, 187, 563, 570,
151555
+ /* 210 */ 898, 669, 449, 449, 449, 449, 449, 449, 449, 449,
151556
+ /* 220 */ 449, 670, 449, 449, 449, 449, 449, 449, 449, 449,
151557
+ /* 230 */ 449, 449, 449, 449, 674, 674, 674, 449, 449, 449,
151558
+ /* 240 */ 449, 1034, 449, 449, 449, 972, 1107, 449, 449, 1193,
151559
+ /* 250 */ 449, 449, 449, 449, 449, 449, 449, 449, 260, 177,
151560
+ /* 260 */ 489, 1241, 1241, 1241, 1241, 1192, 489, 489, 952, 1197,
151561
+ /* 270 */ 625, 1235, 1139, 181, 181, 1086, 1139, 1139, 1086, 1187,
151562
+ /* 280 */ 1131, 1237, 1314, 1314, 1314, 181, 1245, 1245, 1109, 1299,
151563
+ /* 290 */ 549, 1340, 1606, 1531, 1531, 1639, 1639, 1531, 1538, 1576,
151564
+ /* 300 */ 1669, 1647, 1546, 1677, 1677, 1677, 1677, 1531, 1693, 1546,
151565
+ /* 310 */ 1546, 1576, 1669, 1647, 1647, 1546, 1531, 1693, 1567, 1661,
151566
+ /* 320 */ 1531, 1693, 1706, 1531, 1693, 1531, 1693, 1706, 1622, 1622,
151567
+ /* 330 */ 1622, 1675, 1720, 1720, 1706, 1622, 1619, 1622, 1675, 1622,
151568
+ /* 340 */ 1622, 1582, 1706, 1634, 1634, 1706, 1605, 1649, 1605, 1649,
151569
+ /* 350 */ 1605, 1649, 1605, 1649, 1531, 1679, 1679, 1690, 1690, 1629,
151570
+ /* 360 */ 1635, 1755, 1531, 1626, 1629, 1637, 1640, 1546, 1760, 1762,
151571
+ /* 370 */ 1773, 1773, 1787, 1787, 1787, 1958, 1958, 1958, 1958, 1958,
151572
+ /* 380 */ 1958, 1958, 1958, 1958, 1958, 1958, 1958, 1958, 1958, 1958,
151573
+ /* 390 */ 308, 835, 954, 1232, 879, 715, 728, 1323, 864, 1318,
151574
+ /* 400 */ 1253, 1373, 297, 1409, 1419, 1440, 1489, 1497, 1520, 1242,
151575
+ /* 410 */ 1309, 1447, 1435, 1341, 1521, 1525, 1392, 1548, 1329, 1354,
151576
+ /* 420 */ 1585, 1587, 1353, 1382, 1812, 1814, 1799, 1662, 1811, 1730,
151577
+ /* 430 */ 1813, 1807, 1808, 1695, 1685, 1707, 1810, 1696, 1817, 1697,
151578
+ /* 440 */ 1822, 1839, 1701, 1694, 1714, 1783, 1809, 1699, 1792, 1795,
151579
+ /* 450 */ 1796, 1797, 1724, 1740, 1821, 1717, 1856, 1853, 1837, 1747,
151580
+ /* 460 */ 1703, 1794, 1838, 1798, 1788, 1824, 1728, 1756, 1844, 1850,
151581
+ /* 470 */ 1852, 1743, 1750, 1854, 1815, 1855, 1857, 1851, 1858, 1816,
151582
+ /* 480 */ 1819, 1860, 1779, 1859, 1863, 1823, 1849, 1865, 1734, 1867,
151583
+ /* 490 */ 1868, 1869, 1870, 1871, 1872, 1874, 1875, 1877, 1876, 1878,
151584
+ /* 500 */ 1764, 1881, 1882, 1780, 1873, 1879, 1765, 1883, 1880, 1884,
151585
+ /* 510 */ 1885, 1886, 1820, 1835, 1825, 1887, 1840, 1828, 1888, 1889,
151586
+ /* 520 */ 1891, 1892, 1897, 1898, 1893, 1894, 1883, 1902, 1903, 1905,
151587
+ /* 530 */ 1906, 1904, 1909, 1911, 1923, 1913, 1914, 1915, 1916, 1918,
151588
+ /* 540 */ 1919, 1917, 1804, 1803, 1805, 1806, 1818, 1924, 1931, 1947,
151589
+};
151590
+#define YY_REDUCE_COUNT (389)
151591
+#define YY_REDUCE_MIN (-262)
151592
+#define YY_REDUCE_MAX (1617)
150479151593
static const short yy_reduce_ofst[] = {
150480
- /* 0 */ 880, -121, 269, 528, 933, -119, -187, -185, -182, -180,
150481
- /* 10 */ -176, -174, -62, -46, 131, -248, -133, 407, 568, 700,
150482
- /* 20 */ 704, 278, 706, 824, 542, 830, 948, 773, 943, 946,
150483
- /* 30 */ 71, 650, 211, 267, 826, 272, 676, 732, 885, 976,
150484
- /* 40 */ 984, 992, -256, -256, -256, -256, -256, -256, -256, -256,
150485
- /* 50 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
150486
- /* 60 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
150487
- /* 70 */ -256, -256, -256, -256, -256, -256, -256, 989, 1065, 1070,
150488
- /* 80 */ 1072, 1078, 1082, 1084, 1103, 1118, 1147, 1156, 1160, 1167,
150489
- /* 90 */ 1185, 1191, 1220, 1237, 1254, 1256, 1266, 1272, 1281, 1291,
150490
- /* 100 */ 1293, 1296, 1299, 1301, 1307, 1337, 1340, 1342, 1347, 1366,
150491
- /* 110 */ 1368, 1371, 1373, 1377, 1385, 1387, 1398, 1401, 1404, 1406,
150492
- /* 120 */ 1411, 1413, 1415, 1430, -256, -256, -256, -256, -256, -256,
150493
- /* 130 */ -256, -256, -256, -172, 508, -213, 57, -163, -25, 593,
150494
- /* 140 */ 69, 486, 69, 486, -200, 573, 722, -256, -256, -256,
150495
- /* 150 */ -256, -141, -141, -141, -105, -161, -167, 157, 212, 405,
150496
- /* 160 */ 530, 220, 233, 735, 735, 115, 318, 406, 612, 541,
150497
- /* 170 */ -166, 441, 688, 794, 629, 368, 741, 775, 867, 797,
150498
- /* 180 */ 871, 842, -186, 1000, 858, 949, 379, 783, 70, 296,
150499
- /* 190 */ 821, 903, 924, 1044, 651, 282, 1014, 1060, 937, -195,
150500
- /* 200 */ -177, 413, 439, 511, 566, 787, 827, 848, 898, 945,
150501
- /* 210 */ 1062, 1074, 1102, 1110, 1202, 1204, 1209, 1211, 1215, 529,
150502
- /* 220 */ 1221, 1224, 1240, 1246, 1255, 1257, 1269, 1270, 1273, 1274,
150503
- /* 230 */ 1275, 1280, 1205, 1251, 1294, 1310, 1317, 1326, 1327, 1124,
150504
- /* 240 */ 1331, 1338, 1339, 1290, 1181, 1346, 1351, 1265, 1352, 787,
150505
- /* 250 */ 1353, 1367, 1378, 1386, 1392, 1397, 1241, 1312, 1356, 1345,
150506
- /* 260 */ 1357, 1358, 1359, 1124, 1356, 1356, 1364, 1396, 1433, 1341,
150507
- /* 270 */ 1381, 1376, 1379, 1354, 1391, 1405, 1362, 1429, 1423, 1431,
150508
- /* 280 */ 1434, 1435, 1437, 1399, 1410, 1412, 1382, 1417, 1420, 1466,
150509
- /* 290 */ 1372, 1467, 1468, 1380, 1384, 1475, 1394, 1414, 1416, 1448,
150510
- /* 300 */ 1440, 1451, 1452, 1453, 1454, 1490, 1493, 1449, 1455, 1427,
150511
- /* 310 */ 1436, 1464, 1465, 1456, 1498, 1502, 1419, 1421, 1507, 1509,
150512
- /* 320 */ 1491, 1510, 1513, 1514, 1516, 1496, 1500, 1501, 1503, 1499,
150513
- /* 330 */ 1505, 1504, 1508, 1506, 1511, 1512, 1515, 1424, 1517, 1457,
150514
- /* 340 */ 1460, 1519, 1474, 1482, 1483, 1485, 1486, 1488, 1489, 1492,
150515
- /* 350 */ 1541, 1438, 1441, 1494, 1495, 1518, 1520, 1487, 1555, 1481,
150516
- /* 360 */ 1522, 1523, 1526, 1528, 1561, 1566, 1580, 1581, 1586, 1587,
150517
- /* 370 */ 1588, 1478, 1484, 1525, 1575, 1570, 1572, 1573, 1574, 1582,
150518
- /* 380 */ 1568, 1569, 1578, 1579, 1583, 1590,
151594
+ /* 0 */ 490, -122, 545, 645, 650, -120, -189, -187, -184, -182,
151595
+ /* 10 */ -178, -176, 45, 30, 200, -251, -134, 390, 392, 521,
151596
+ /* 20 */ 523, 213, 692, 821, 284, 589, 872, 666, 671, 866,
151597
+ /* 30 */ 71, 111, 273, 389, 686, 815, 904, 932, 948, 955,
151598
+ /* 40 */ 964, 969, -259, -259, -259, -259, -259, -259, -259, -259,
151599
+ /* 50 */ -259, -259, -259, -259, -259, -259, -259, -259, -259, -259,
151600
+ /* 60 */ -259, -259, -259, -259, -259, -259, -259, -259, -259, -259,
151601
+ /* 70 */ -259, -259, -259, -259, -259, -259, -259, -259, 428, 430,
151602
+ /* 80 */ 899, 985, 1021, 1028, 1057, 1069, 1081, 1108, 1110, 1115,
151603
+ /* 90 */ 1117, 1123, 1149, 1154, 1159, 1170, 1174, 1178, 1183, 1194,
151604
+ /* 100 */ 1198, 1204, 1208, 1212, 1218, 1222, 1229, 1278, 1280, 1283,
151605
+ /* 110 */ 1285, 1313, 1316, 1320, 1322, 1325, 1327, 1330, 1366, 1371,
151606
+ /* 120 */ 1379, 1387, 1417, 1425, 1430, 1432, -259, -259, -259, -259,
151607
+ /* 130 */ -259, -259, -259, -259, -259, 557, 974, -214, -174, -9,
151608
+ /* 140 */ 431, -124, 806, 925, 806, 925, 251, 928, 940, -259,
151609
+ /* 150 */ -259, -259, -259, -198, -198, -198, 127, -186, -168, 212,
151610
+ /* 160 */ 646, 617, 799, -262, 555, 220, 220, 491, 605, 1040,
151611
+ /* 170 */ 1060, 699, -11, 600, 848, 862, 345, -129, 724, -91,
151612
+ /* 180 */ 158, 749, 716, 900, 304, 822, 929, 926, 499, 793,
151613
+ /* 190 */ 322, 892, 813, 845, 958, 1056, 751, 905, 1133, 1062,
151614
+ /* 200 */ 803, -210, -185, -179, -148, -167, -89, 121, 274, 281,
151615
+ /* 210 */ 320, 336, 439, 663, 711, 957, 1064, 1068, 1116, 1127,
151616
+ /* 220 */ 1134, -196, 1147, 1180, 1184, 1195, 1203, 1209, 1254, 1263,
151617
+ /* 230 */ 1275, 1288, 1304, 1310, 205, 422, 638, 1319, 1324, 1346,
151618
+ /* 240 */ 1360, 1168, 1364, 1370, 1372, 869, 1189, 1380, 1399, 1276,
151619
+ /* 250 */ 1403, 121, 1405, 1420, 1426, 1427, 1428, 1429, 1249, 1282,
151620
+ /* 260 */ 1344, 1375, 1376, 1377, 1388, 1168, 1344, 1344, 1384, 1411,
151621
+ /* 270 */ 1436, 1349, 1389, 1386, 1391, 1361, 1407, 1408, 1365, 1431,
151622
+ /* 280 */ 1433, 1434, 1439, 1441, 1442, 1396, 1416, 1418, 1390, 1421,
151623
+ /* 290 */ 1437, 1472, 1381, 1478, 1480, 1397, 1400, 1487, 1412, 1444,
151624
+ /* 300 */ 1438, 1463, 1453, 1464, 1465, 1467, 1469, 1514, 1517, 1473,
151625
+ /* 310 */ 1474, 1452, 1449, 1490, 1491, 1475, 1522, 1526, 1443, 1445,
151626
+ /* 320 */ 1528, 1530, 1513, 1534, 1536, 1537, 1539, 1516, 1523, 1524,
151627
+ /* 330 */ 1527, 1519, 1529, 1532, 1540, 1541, 1535, 1542, 1544, 1545,
151628
+ /* 340 */ 1547, 1450, 1543, 1477, 1482, 1551, 1505, 1508, 1512, 1509,
151629
+ /* 350 */ 1515, 1518, 1533, 1552, 1573, 1466, 1468, 1549, 1550, 1555,
151630
+ /* 360 */ 1554, 1510, 1583, 1511, 1556, 1559, 1561, 1565, 1588, 1592,
151631
+ /* 370 */ 1601, 1602, 1607, 1608, 1609, 1498, 1557, 1558, 1610, 1600,
151632
+ /* 380 */ 1603, 1611, 1612, 1613, 1596, 1597, 1614, 1615, 1617, 1616,
150519151633
};
150520151634
static const YYACTIONTYPE yy_default[] = {
150521
- /* 0 */ 1554, 1554, 1554, 1392, 1171, 1278, 1171, 1171, 1171, 1392,
150522
- /* 10 */ 1392, 1392, 1171, 1308, 1308, 1445, 1202, 1171, 1171, 1171,
150523
- /* 20 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1391, 1171, 1171,
150524
- /* 30 */ 1171, 1171, 1475, 1475, 1171, 1171, 1171, 1171, 1171, 1171,
150525
- /* 40 */ 1171, 1171, 1171, 1317, 1171, 1171, 1171, 1171, 1171, 1393,
150526
- /* 50 */ 1394, 1171, 1171, 1171, 1444, 1446, 1409, 1327, 1326, 1325,
150527
- /* 60 */ 1324, 1427, 1295, 1322, 1315, 1319, 1387, 1388, 1386, 1390,
150528
- /* 70 */ 1394, 1393, 1171, 1318, 1358, 1372, 1357, 1171, 1171, 1171,
150529
- /* 80 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150530
- /* 90 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150531
- /* 100 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150532
- /* 110 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150533
- /* 120 */ 1171, 1171, 1171, 1171, 1366, 1371, 1377, 1370, 1367, 1360,
150534
- /* 130 */ 1359, 1361, 1362, 1171, 1192, 1242, 1171, 1171, 1171, 1171,
150535
- /* 140 */ 1463, 1462, 1171, 1171, 1202, 1352, 1351, 1363, 1364, 1374,
150536
- /* 150 */ 1373, 1452, 1510, 1509, 1410, 1171, 1171, 1171, 1171, 1171,
150537
- /* 160 */ 1171, 1475, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150538
- /* 170 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150539
- /* 180 */ 1171, 1171, 1171, 1171, 1171, 1171, 1475, 1475, 1171, 1202,
150540
- /* 190 */ 1475, 1475, 1198, 1198, 1302, 1171, 1458, 1278, 1269, 1171,
150541
- /* 200 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150542
- /* 210 */ 1171, 1171, 1171, 1449, 1447, 1171, 1171, 1171, 1171, 1171,
150543
- /* 220 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150544
- /* 230 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150545
- /* 240 */ 1171, 1171, 1171, 1274, 1171, 1171, 1171, 1171, 1171, 1171,
150546
- /* 250 */ 1171, 1171, 1171, 1171, 1171, 1504, 1171, 1422, 1256, 1274,
150547
- /* 260 */ 1274, 1274, 1274, 1276, 1257, 1255, 1268, 1203, 1178, 1546,
150548
- /* 270 */ 1321, 1297, 1297, 1543, 1321, 1321, 1543, 1217, 1524, 1214,
150549
- /* 280 */ 1308, 1308, 1308, 1297, 1302, 1302, 1389, 1275, 1268, 1171,
150550
- /* 290 */ 1546, 1283, 1283, 1545, 1545, 1283, 1410, 1330, 1336, 1245,
150551
- /* 300 */ 1321, 1251, 1251, 1251, 1251, 1283, 1189, 1321, 1321, 1330,
150552
- /* 310 */ 1336, 1245, 1245, 1321, 1283, 1189, 1426, 1540, 1283, 1189,
150553
- /* 320 */ 1400, 1283, 1189, 1283, 1189, 1400, 1243, 1243, 1243, 1232,
150554
- /* 330 */ 1400, 1243, 1217, 1243, 1232, 1243, 1243, 1493, 1400, 1404,
150555
- /* 340 */ 1404, 1400, 1301, 1296, 1301, 1296, 1301, 1296, 1301, 1296,
150556
- /* 350 */ 1283, 1485, 1485, 1311, 1311, 1316, 1302, 1395, 1283, 1171,
150557
- /* 360 */ 1316, 1314, 1312, 1321, 1195, 1235, 1507, 1507, 1503, 1503,
150558
- /* 370 */ 1503, 1551, 1551, 1458, 1519, 1202, 1202, 1202, 1202, 1519,
150559
- /* 380 */ 1219, 1219, 1203, 1203, 1202, 1519, 1171, 1171, 1171, 1171,
150560
- /* 390 */ 1171, 1171, 1514, 1171, 1411, 1287, 1171, 1171, 1171, 1171,
150561
- /* 400 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150562
- /* 410 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1341,
150563
- /* 420 */ 1171, 1174, 1455, 1171, 1171, 1453, 1171, 1171, 1171, 1171,
150564
- /* 430 */ 1171, 1171, 1288, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150565
- /* 440 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150566
- /* 450 */ 1171, 1542, 1171, 1171, 1171, 1171, 1171, 1171, 1425, 1424,
150567
- /* 460 */ 1171, 1171, 1285, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150568
- /* 470 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150569
- /* 480 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150570
- /* 490 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150571
- /* 500 */ 1313, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150572
- /* 510 */ 1171, 1171, 1171, 1171, 1171, 1490, 1303, 1171, 1171, 1533,
150573
- /* 520 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150574
- /* 530 */ 1171, 1171, 1171, 1171, 1528, 1259, 1343, 1171, 1342, 1346,
150575
- /* 540 */ 1171, 1183, 1171,
151635
+ /* 0 */ 1572, 1572, 1572, 1408, 1185, 1294, 1185, 1185, 1185, 1408,
151636
+ /* 10 */ 1408, 1408, 1185, 1324, 1324, 1461, 1216, 1185, 1185, 1185,
151637
+ /* 20 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1407, 1185, 1185,
151638
+ /* 30 */ 1185, 1185, 1491, 1491, 1185, 1185, 1185, 1185, 1185, 1185,
151639
+ /* 40 */ 1185, 1185, 1185, 1333, 1185, 1185, 1185, 1185, 1185, 1185,
151640
+ /* 50 */ 1409, 1410, 1185, 1185, 1185, 1460, 1462, 1425, 1343, 1342,
151641
+ /* 60 */ 1341, 1340, 1443, 1311, 1338, 1331, 1335, 1403, 1404, 1402,
151642
+ /* 70 */ 1406, 1410, 1409, 1185, 1334, 1374, 1388, 1373, 1185, 1185,
151643
+ /* 80 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151644
+ /* 90 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151645
+ /* 100 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151646
+ /* 110 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151647
+ /* 120 */ 1185, 1185, 1185, 1185, 1185, 1185, 1382, 1387, 1393, 1386,
151648
+ /* 130 */ 1383, 1376, 1375, 1377, 1378, 1185, 1206, 1258, 1185, 1185,
151649
+ /* 140 */ 1185, 1185, 1479, 1478, 1185, 1185, 1216, 1368, 1367, 1379,
151650
+ /* 150 */ 1380, 1390, 1389, 1468, 1526, 1525, 1426, 1185, 1185, 1185,
151651
+ /* 160 */ 1185, 1185, 1185, 1491, 1185, 1185, 1185, 1185, 1185, 1185,
151652
+ /* 170 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151653
+ /* 180 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1491, 1491,
151654
+ /* 190 */ 1185, 1216, 1491, 1491, 1212, 1212, 1318, 1185, 1474, 1294,
151655
+ /* 200 */ 1285, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151656
+ /* 210 */ 1185, 1185, 1185, 1185, 1185, 1465, 1463, 1185, 1185, 1185,
151657
+ /* 220 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151658
+ /* 230 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151659
+ /* 240 */ 1185, 1185, 1185, 1185, 1185, 1290, 1185, 1185, 1185, 1185,
151660
+ /* 250 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1520, 1185, 1438,
151661
+ /* 260 */ 1272, 1290, 1290, 1290, 1290, 1292, 1273, 1271, 1284, 1217,
151662
+ /* 270 */ 1192, 1564, 1337, 1313, 1313, 1561, 1337, 1337, 1561, 1233,
151663
+ /* 280 */ 1542, 1228, 1324, 1324, 1324, 1313, 1318, 1318, 1405, 1291,
151664
+ /* 290 */ 1284, 1185, 1564, 1299, 1299, 1563, 1563, 1299, 1426, 1346,
151665
+ /* 300 */ 1352, 1261, 1337, 1267, 1267, 1267, 1267, 1299, 1203, 1337,
151666
+ /* 310 */ 1337, 1346, 1352, 1261, 1261, 1337, 1299, 1203, 1442, 1558,
151667
+ /* 320 */ 1299, 1203, 1416, 1299, 1203, 1299, 1203, 1416, 1259, 1259,
151668
+ /* 330 */ 1259, 1248, 1185, 1185, 1416, 1259, 1233, 1259, 1248, 1259,
151669
+ /* 340 */ 1259, 1509, 1416, 1420, 1420, 1416, 1317, 1312, 1317, 1312,
151670
+ /* 350 */ 1317, 1312, 1317, 1312, 1299, 1501, 1501, 1327, 1327, 1332,
151671
+ /* 360 */ 1318, 1411, 1299, 1185, 1332, 1330, 1328, 1337, 1209, 1251,
151672
+ /* 370 */ 1523, 1523, 1519, 1519, 1519, 1569, 1569, 1474, 1535, 1216,
151673
+ /* 380 */ 1216, 1216, 1216, 1535, 1235, 1235, 1217, 1217, 1216, 1535,
151674
+ /* 390 */ 1185, 1185, 1185, 1185, 1185, 1185, 1530, 1185, 1427, 1303,
151675
+ /* 400 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151676
+ /* 410 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151677
+ /* 420 */ 1185, 1185, 1185, 1357, 1185, 1188, 1471, 1185, 1185, 1469,
151678
+ /* 430 */ 1185, 1185, 1185, 1185, 1185, 1185, 1304, 1185, 1185, 1185,
151679
+ /* 440 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151680
+ /* 450 */ 1185, 1185, 1185, 1185, 1185, 1560, 1185, 1185, 1185, 1185,
151681
+ /* 460 */ 1185, 1185, 1441, 1440, 1185, 1185, 1301, 1185, 1185, 1185,
151682
+ /* 470 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151683
+ /* 480 */ 1231, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151684
+ /* 490 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151685
+ /* 500 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1329, 1185, 1185,
151686
+ /* 510 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151687
+ /* 520 */ 1185, 1185, 1506, 1319, 1185, 1185, 1551, 1185, 1185, 1185,
151688
+ /* 530 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151689
+ /* 540 */ 1185, 1546, 1275, 1359, 1185, 1358, 1362, 1185, 1197, 1185,
150576151690
};
150577151691
/********** End of lemon-generated parsing tables *****************************/
150578151692
150579151693
/* The next table maps tokens (terminal symbols) into fallback tokens.
150580151694
** If a construct like the following:
@@ -150685,10 +151799,12 @@
150685151799
59, /* UNBOUNDED => ID */
150686151800
59, /* EXCLUDE => ID */
150687151801
59, /* GROUPS => ID */
150688151802
59, /* OTHERS => ID */
150689151803
59, /* TIES => ID */
151804
+ 59, /* GENERATED => ID */
151805
+ 59, /* ALWAYS => ID */
150690151806
59, /* REINDEX => ID */
150691151807
59, /* RENAME => ID */
150692151808
59, /* CTIME_KW => ID */
150693151809
0, /* ANY => nothing */
150694151810
0, /* BITAND => nothing */
@@ -150951,222 +152067,225 @@
150951152067
/* 90 */ "UNBOUNDED",
150952152068
/* 91 */ "EXCLUDE",
150953152069
/* 92 */ "GROUPS",
150954152070
/* 93 */ "OTHERS",
150955152071
/* 94 */ "TIES",
150956
- /* 95 */ "REINDEX",
150957
- /* 96 */ "RENAME",
150958
- /* 97 */ "CTIME_KW",
150959
- /* 98 */ "ANY",
150960
- /* 99 */ "BITAND",
150961
- /* 100 */ "BITOR",
150962
- /* 101 */ "LSHIFT",
150963
- /* 102 */ "RSHIFT",
150964
- /* 103 */ "PLUS",
150965
- /* 104 */ "MINUS",
150966
- /* 105 */ "STAR",
150967
- /* 106 */ "SLASH",
150968
- /* 107 */ "REM",
150969
- /* 108 */ "CONCAT",
150970
- /* 109 */ "COLLATE",
150971
- /* 110 */ "BITNOT",
150972
- /* 111 */ "ON",
150973
- /* 112 */ "INDEXED",
150974
- /* 113 */ "STRING",
150975
- /* 114 */ "JOIN_KW",
150976
- /* 115 */ "CONSTRAINT",
150977
- /* 116 */ "DEFAULT",
150978
- /* 117 */ "NULL",
150979
- /* 118 */ "PRIMARY",
150980
- /* 119 */ "UNIQUE",
150981
- /* 120 */ "CHECK",
150982
- /* 121 */ "REFERENCES",
150983
- /* 122 */ "AUTOINCR",
150984
- /* 123 */ "INSERT",
150985
- /* 124 */ "DELETE",
150986
- /* 125 */ "UPDATE",
150987
- /* 126 */ "SET",
150988
- /* 127 */ "DEFERRABLE",
150989
- /* 128 */ "FOREIGN",
150990
- /* 129 */ "DROP",
150991
- /* 130 */ "UNION",
150992
- /* 131 */ "ALL",
150993
- /* 132 */ "EXCEPT",
150994
- /* 133 */ "INTERSECT",
150995
- /* 134 */ "SELECT",
150996
- /* 135 */ "VALUES",
150997
- /* 136 */ "DISTINCT",
150998
- /* 137 */ "DOT",
150999
- /* 138 */ "FROM",
151000
- /* 139 */ "JOIN",
151001
- /* 140 */ "USING",
151002
- /* 141 */ "ORDER",
151003
- /* 142 */ "GROUP",
151004
- /* 143 */ "HAVING",
151005
- /* 144 */ "LIMIT",
151006
- /* 145 */ "WHERE",
151007
- /* 146 */ "INTO",
151008
- /* 147 */ "NOTHING",
151009
- /* 148 */ "FLOAT",
151010
- /* 149 */ "BLOB",
151011
- /* 150 */ "INTEGER",
151012
- /* 151 */ "VARIABLE",
151013
- /* 152 */ "CASE",
151014
- /* 153 */ "WHEN",
151015
- /* 154 */ "THEN",
151016
- /* 155 */ "ELSE",
151017
- /* 156 */ "INDEX",
151018
- /* 157 */ "ALTER",
151019
- /* 158 */ "ADD",
151020
- /* 159 */ "WINDOW",
151021
- /* 160 */ "OVER",
151022
- /* 161 */ "FILTER",
151023
- /* 162 */ "COLUMN",
151024
- /* 163 */ "AGG_FUNCTION",
151025
- /* 164 */ "AGG_COLUMN",
151026
- /* 165 */ "TRUEFALSE",
151027
- /* 166 */ "ISNOT",
151028
- /* 167 */ "FUNCTION",
151029
- /* 168 */ "UMINUS",
151030
- /* 169 */ "UPLUS",
151031
- /* 170 */ "TRUTH",
151032
- /* 171 */ "REGISTER",
151033
- /* 172 */ "VECTOR",
151034
- /* 173 */ "SELECT_COLUMN",
151035
- /* 174 */ "IF_NULL_ROW",
151036
- /* 175 */ "ASTERISK",
151037
- /* 176 */ "SPAN",
151038
- /* 177 */ "SPACE",
151039
- /* 178 */ "ILLEGAL",
151040
- /* 179 */ "input",
151041
- /* 180 */ "cmdlist",
151042
- /* 181 */ "ecmd",
151043
- /* 182 */ "cmdx",
151044
- /* 183 */ "explain",
151045
- /* 184 */ "cmd",
151046
- /* 185 */ "transtype",
151047
- /* 186 */ "trans_opt",
151048
- /* 187 */ "nm",
151049
- /* 188 */ "savepoint_opt",
151050
- /* 189 */ "create_table",
151051
- /* 190 */ "create_table_args",
151052
- /* 191 */ "createkw",
151053
- /* 192 */ "temp",
151054
- /* 193 */ "ifnotexists",
151055
- /* 194 */ "dbnm",
151056
- /* 195 */ "columnlist",
151057
- /* 196 */ "conslist_opt",
151058
- /* 197 */ "table_options",
151059
- /* 198 */ "select",
151060
- /* 199 */ "columnname",
151061
- /* 200 */ "carglist",
151062
- /* 201 */ "typetoken",
151063
- /* 202 */ "typename",
151064
- /* 203 */ "signed",
151065
- /* 204 */ "plus_num",
151066
- /* 205 */ "minus_num",
151067
- /* 206 */ "scanpt",
151068
- /* 207 */ "scantok",
151069
- /* 208 */ "ccons",
151070
- /* 209 */ "term",
151071
- /* 210 */ "expr",
151072
- /* 211 */ "onconf",
151073
- /* 212 */ "sortorder",
151074
- /* 213 */ "autoinc",
151075
- /* 214 */ "eidlist_opt",
151076
- /* 215 */ "refargs",
151077
- /* 216 */ "defer_subclause",
151078
- /* 217 */ "refarg",
151079
- /* 218 */ "refact",
151080
- /* 219 */ "init_deferred_pred_opt",
151081
- /* 220 */ "conslist",
151082
- /* 221 */ "tconscomma",
151083
- /* 222 */ "tcons",
151084
- /* 223 */ "sortlist",
151085
- /* 224 */ "eidlist",
151086
- /* 225 */ "defer_subclause_opt",
151087
- /* 226 */ "orconf",
151088
- /* 227 */ "resolvetype",
151089
- /* 228 */ "raisetype",
151090
- /* 229 */ "ifexists",
151091
- /* 230 */ "fullname",
151092
- /* 231 */ "selectnowith",
151093
- /* 232 */ "oneselect",
151094
- /* 233 */ "wqlist",
151095
- /* 234 */ "multiselect_op",
151096
- /* 235 */ "distinct",
151097
- /* 236 */ "selcollist",
151098
- /* 237 */ "from",
151099
- /* 238 */ "where_opt",
151100
- /* 239 */ "groupby_opt",
151101
- /* 240 */ "having_opt",
151102
- /* 241 */ "orderby_opt",
151103
- /* 242 */ "limit_opt",
151104
- /* 243 */ "window_clause",
151105
- /* 244 */ "values",
151106
- /* 245 */ "nexprlist",
151107
- /* 246 */ "sclp",
151108
- /* 247 */ "as",
151109
- /* 248 */ "seltablist",
151110
- /* 249 */ "stl_prefix",
151111
- /* 250 */ "joinop",
151112
- /* 251 */ "indexed_opt",
151113
- /* 252 */ "on_opt",
151114
- /* 253 */ "using_opt",
151115
- /* 254 */ "exprlist",
151116
- /* 255 */ "xfullname",
151117
- /* 256 */ "idlist",
151118
- /* 257 */ "nulls",
151119
- /* 258 */ "with",
151120
- /* 259 */ "setlist",
151121
- /* 260 */ "insert_cmd",
151122
- /* 261 */ "idlist_opt",
151123
- /* 262 */ "upsert",
151124
- /* 263 */ "filter_over",
151125
- /* 264 */ "likeop",
151126
- /* 265 */ "between_op",
151127
- /* 266 */ "in_op",
151128
- /* 267 */ "paren_exprlist",
151129
- /* 268 */ "case_operand",
151130
- /* 269 */ "case_exprlist",
151131
- /* 270 */ "case_else",
151132
- /* 271 */ "uniqueflag",
151133
- /* 272 */ "collate",
151134
- /* 273 */ "vinto",
151135
- /* 274 */ "nmnum",
151136
- /* 275 */ "trigger_decl",
151137
- /* 276 */ "trigger_cmd_list",
151138
- /* 277 */ "trigger_time",
151139
- /* 278 */ "trigger_event",
151140
- /* 279 */ "foreach_clause",
151141
- /* 280 */ "when_clause",
151142
- /* 281 */ "trigger_cmd",
151143
- /* 282 */ "trnm",
151144
- /* 283 */ "tridxby",
151145
- /* 284 */ "database_kw_opt",
151146
- /* 285 */ "key_opt",
151147
- /* 286 */ "add_column_fullname",
151148
- /* 287 */ "kwcolumn_opt",
151149
- /* 288 */ "create_vtab",
151150
- /* 289 */ "vtabarglist",
151151
- /* 290 */ "vtabarg",
151152
- /* 291 */ "vtabargtoken",
151153
- /* 292 */ "lp",
151154
- /* 293 */ "anylist",
151155
- /* 294 */ "windowdefn_list",
151156
- /* 295 */ "windowdefn",
151157
- /* 296 */ "window",
151158
- /* 297 */ "frame_opt",
151159
- /* 298 */ "part_opt",
151160
- /* 299 */ "filter_clause",
151161
- /* 300 */ "over_clause",
151162
- /* 301 */ "range_or_rows",
151163
- /* 302 */ "frame_bound",
151164
- /* 303 */ "frame_bound_s",
151165
- /* 304 */ "frame_bound_e",
151166
- /* 305 */ "frame_exclude_opt",
151167
- /* 306 */ "frame_exclude",
152072
+ /* 95 */ "GENERATED",
152073
+ /* 96 */ "ALWAYS",
152074
+ /* 97 */ "REINDEX",
152075
+ /* 98 */ "RENAME",
152076
+ /* 99 */ "CTIME_KW",
152077
+ /* 100 */ "ANY",
152078
+ /* 101 */ "BITAND",
152079
+ /* 102 */ "BITOR",
152080
+ /* 103 */ "LSHIFT",
152081
+ /* 104 */ "RSHIFT",
152082
+ /* 105 */ "PLUS",
152083
+ /* 106 */ "MINUS",
152084
+ /* 107 */ "STAR",
152085
+ /* 108 */ "SLASH",
152086
+ /* 109 */ "REM",
152087
+ /* 110 */ "CONCAT",
152088
+ /* 111 */ "COLLATE",
152089
+ /* 112 */ "BITNOT",
152090
+ /* 113 */ "ON",
152091
+ /* 114 */ "INDEXED",
152092
+ /* 115 */ "STRING",
152093
+ /* 116 */ "JOIN_KW",
152094
+ /* 117 */ "CONSTRAINT",
152095
+ /* 118 */ "DEFAULT",
152096
+ /* 119 */ "NULL",
152097
+ /* 120 */ "PRIMARY",
152098
+ /* 121 */ "UNIQUE",
152099
+ /* 122 */ "CHECK",
152100
+ /* 123 */ "REFERENCES",
152101
+ /* 124 */ "AUTOINCR",
152102
+ /* 125 */ "INSERT",
152103
+ /* 126 */ "DELETE",
152104
+ /* 127 */ "UPDATE",
152105
+ /* 128 */ "SET",
152106
+ /* 129 */ "DEFERRABLE",
152107
+ /* 130 */ "FOREIGN",
152108
+ /* 131 */ "DROP",
152109
+ /* 132 */ "UNION",
152110
+ /* 133 */ "ALL",
152111
+ /* 134 */ "EXCEPT",
152112
+ /* 135 */ "INTERSECT",
152113
+ /* 136 */ "SELECT",
152114
+ /* 137 */ "VALUES",
152115
+ /* 138 */ "DISTINCT",
152116
+ /* 139 */ "DOT",
152117
+ /* 140 */ "FROM",
152118
+ /* 141 */ "JOIN",
152119
+ /* 142 */ "USING",
152120
+ /* 143 */ "ORDER",
152121
+ /* 144 */ "GROUP",
152122
+ /* 145 */ "HAVING",
152123
+ /* 146 */ "LIMIT",
152124
+ /* 147 */ "WHERE",
152125
+ /* 148 */ "INTO",
152126
+ /* 149 */ "NOTHING",
152127
+ /* 150 */ "FLOAT",
152128
+ /* 151 */ "BLOB",
152129
+ /* 152 */ "INTEGER",
152130
+ /* 153 */ "VARIABLE",
152131
+ /* 154 */ "CASE",
152132
+ /* 155 */ "WHEN",
152133
+ /* 156 */ "THEN",
152134
+ /* 157 */ "ELSE",
152135
+ /* 158 */ "INDEX",
152136
+ /* 159 */ "ALTER",
152137
+ /* 160 */ "ADD",
152138
+ /* 161 */ "WINDOW",
152139
+ /* 162 */ "OVER",
152140
+ /* 163 */ "FILTER",
152141
+ /* 164 */ "COLUMN",
152142
+ /* 165 */ "AGG_FUNCTION",
152143
+ /* 166 */ "AGG_COLUMN",
152144
+ /* 167 */ "TRUEFALSE",
152145
+ /* 168 */ "ISNOT",
152146
+ /* 169 */ "FUNCTION",
152147
+ /* 170 */ "UMINUS",
152148
+ /* 171 */ "UPLUS",
152149
+ /* 172 */ "TRUTH",
152150
+ /* 173 */ "REGISTER",
152151
+ /* 174 */ "VECTOR",
152152
+ /* 175 */ "SELECT_COLUMN",
152153
+ /* 176 */ "IF_NULL_ROW",
152154
+ /* 177 */ "ASTERISK",
152155
+ /* 178 */ "SPAN",
152156
+ /* 179 */ "SPACE",
152157
+ /* 180 */ "ILLEGAL",
152158
+ /* 181 */ "input",
152159
+ /* 182 */ "cmdlist",
152160
+ /* 183 */ "ecmd",
152161
+ /* 184 */ "cmdx",
152162
+ /* 185 */ "explain",
152163
+ /* 186 */ "cmd",
152164
+ /* 187 */ "transtype",
152165
+ /* 188 */ "trans_opt",
152166
+ /* 189 */ "nm",
152167
+ /* 190 */ "savepoint_opt",
152168
+ /* 191 */ "create_table",
152169
+ /* 192 */ "create_table_args",
152170
+ /* 193 */ "createkw",
152171
+ /* 194 */ "temp",
152172
+ /* 195 */ "ifnotexists",
152173
+ /* 196 */ "dbnm",
152174
+ /* 197 */ "columnlist",
152175
+ /* 198 */ "conslist_opt",
152176
+ /* 199 */ "table_options",
152177
+ /* 200 */ "select",
152178
+ /* 201 */ "columnname",
152179
+ /* 202 */ "carglist",
152180
+ /* 203 */ "typetoken",
152181
+ /* 204 */ "typename",
152182
+ /* 205 */ "signed",
152183
+ /* 206 */ "plus_num",
152184
+ /* 207 */ "minus_num",
152185
+ /* 208 */ "scanpt",
152186
+ /* 209 */ "scantok",
152187
+ /* 210 */ "ccons",
152188
+ /* 211 */ "term",
152189
+ /* 212 */ "expr",
152190
+ /* 213 */ "onconf",
152191
+ /* 214 */ "sortorder",
152192
+ /* 215 */ "autoinc",
152193
+ /* 216 */ "eidlist_opt",
152194
+ /* 217 */ "refargs",
152195
+ /* 218 */ "defer_subclause",
152196
+ /* 219 */ "generated",
152197
+ /* 220 */ "refarg",
152198
+ /* 221 */ "refact",
152199
+ /* 222 */ "init_deferred_pred_opt",
152200
+ /* 223 */ "conslist",
152201
+ /* 224 */ "tconscomma",
152202
+ /* 225 */ "tcons",
152203
+ /* 226 */ "sortlist",
152204
+ /* 227 */ "eidlist",
152205
+ /* 228 */ "defer_subclause_opt",
152206
+ /* 229 */ "orconf",
152207
+ /* 230 */ "resolvetype",
152208
+ /* 231 */ "raisetype",
152209
+ /* 232 */ "ifexists",
152210
+ /* 233 */ "fullname",
152211
+ /* 234 */ "selectnowith",
152212
+ /* 235 */ "oneselect",
152213
+ /* 236 */ "wqlist",
152214
+ /* 237 */ "multiselect_op",
152215
+ /* 238 */ "distinct",
152216
+ /* 239 */ "selcollist",
152217
+ /* 240 */ "from",
152218
+ /* 241 */ "where_opt",
152219
+ /* 242 */ "groupby_opt",
152220
+ /* 243 */ "having_opt",
152221
+ /* 244 */ "orderby_opt",
152222
+ /* 245 */ "limit_opt",
152223
+ /* 246 */ "window_clause",
152224
+ /* 247 */ "values",
152225
+ /* 248 */ "nexprlist",
152226
+ /* 249 */ "sclp",
152227
+ /* 250 */ "as",
152228
+ /* 251 */ "seltablist",
152229
+ /* 252 */ "stl_prefix",
152230
+ /* 253 */ "joinop",
152231
+ /* 254 */ "indexed_opt",
152232
+ /* 255 */ "on_opt",
152233
+ /* 256 */ "using_opt",
152234
+ /* 257 */ "exprlist",
152235
+ /* 258 */ "xfullname",
152236
+ /* 259 */ "idlist",
152237
+ /* 260 */ "nulls",
152238
+ /* 261 */ "with",
152239
+ /* 262 */ "setlist",
152240
+ /* 263 */ "insert_cmd",
152241
+ /* 264 */ "idlist_opt",
152242
+ /* 265 */ "upsert",
152243
+ /* 266 */ "filter_over",
152244
+ /* 267 */ "likeop",
152245
+ /* 268 */ "between_op",
152246
+ /* 269 */ "in_op",
152247
+ /* 270 */ "paren_exprlist",
152248
+ /* 271 */ "case_operand",
152249
+ /* 272 */ "case_exprlist",
152250
+ /* 273 */ "case_else",
152251
+ /* 274 */ "uniqueflag",
152252
+ /* 275 */ "collate",
152253
+ /* 276 */ "vinto",
152254
+ /* 277 */ "nmnum",
152255
+ /* 278 */ "trigger_decl",
152256
+ /* 279 */ "trigger_cmd_list",
152257
+ /* 280 */ "trigger_time",
152258
+ /* 281 */ "trigger_event",
152259
+ /* 282 */ "foreach_clause",
152260
+ /* 283 */ "when_clause",
152261
+ /* 284 */ "trigger_cmd",
152262
+ /* 285 */ "trnm",
152263
+ /* 286 */ "tridxby",
152264
+ /* 287 */ "database_kw_opt",
152265
+ /* 288 */ "key_opt",
152266
+ /* 289 */ "add_column_fullname",
152267
+ /* 290 */ "kwcolumn_opt",
152268
+ /* 291 */ "create_vtab",
152269
+ /* 292 */ "vtabarglist",
152270
+ /* 293 */ "vtabarg",
152271
+ /* 294 */ "vtabargtoken",
152272
+ /* 295 */ "lp",
152273
+ /* 296 */ "anylist",
152274
+ /* 297 */ "windowdefn_list",
152275
+ /* 298 */ "windowdefn",
152276
+ /* 299 */ "window",
152277
+ /* 300 */ "frame_opt",
152278
+ /* 301 */ "part_opt",
152279
+ /* 302 */ "filter_clause",
152280
+ /* 303 */ "over_clause",
152281
+ /* 304 */ "range_or_rows",
152282
+ /* 305 */ "frame_bound",
152283
+ /* 306 */ "frame_bound_s",
152284
+ /* 307 */ "frame_bound_e",
152285
+ /* 308 */ "frame_exclude_opt",
152286
+ /* 309 */ "frame_exclude",
151168152287
};
151169152288
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
151170152289
151171152290
#ifndef NDEBUG
151172152291
/* For tracing reduce actions, the names of all rules are required.
@@ -151213,348 +152332,352 @@
151213152332
/* 38 */ "ccons ::= UNIQUE onconf",
151214152333
/* 39 */ "ccons ::= CHECK LP expr RP",
151215152334
/* 40 */ "ccons ::= REFERENCES nm eidlist_opt refargs",
151216152335
/* 41 */ "ccons ::= defer_subclause",
151217152336
/* 42 */ "ccons ::= COLLATE ID|STRING",
151218
- /* 43 */ "autoinc ::=",
151219
- /* 44 */ "autoinc ::= AUTOINCR",
151220
- /* 45 */ "refargs ::=",
151221
- /* 46 */ "refargs ::= refargs refarg",
151222
- /* 47 */ "refarg ::= MATCH nm",
151223
- /* 48 */ "refarg ::= ON INSERT refact",
151224
- /* 49 */ "refarg ::= ON DELETE refact",
151225
- /* 50 */ "refarg ::= ON UPDATE refact",
151226
- /* 51 */ "refact ::= SET NULL",
151227
- /* 52 */ "refact ::= SET DEFAULT",
151228
- /* 53 */ "refact ::= CASCADE",
151229
- /* 54 */ "refact ::= RESTRICT",
151230
- /* 55 */ "refact ::= NO ACTION",
151231
- /* 56 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
151232
- /* 57 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
151233
- /* 58 */ "init_deferred_pred_opt ::=",
151234
- /* 59 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
151235
- /* 60 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
151236
- /* 61 */ "conslist_opt ::=",
151237
- /* 62 */ "tconscomma ::= COMMA",
151238
- /* 63 */ "tcons ::= CONSTRAINT nm",
151239
- /* 64 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf",
151240
- /* 65 */ "tcons ::= UNIQUE LP sortlist RP onconf",
151241
- /* 66 */ "tcons ::= CHECK LP expr RP onconf",
151242
- /* 67 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt",
151243
- /* 68 */ "defer_subclause_opt ::=",
151244
- /* 69 */ "onconf ::=",
151245
- /* 70 */ "onconf ::= ON CONFLICT resolvetype",
151246
- /* 71 */ "orconf ::=",
151247
- /* 72 */ "orconf ::= OR resolvetype",
151248
- /* 73 */ "resolvetype ::= IGNORE",
151249
- /* 74 */ "resolvetype ::= REPLACE",
151250
- /* 75 */ "cmd ::= DROP TABLE ifexists fullname",
151251
- /* 76 */ "ifexists ::= IF EXISTS",
151252
- /* 77 */ "ifexists ::=",
151253
- /* 78 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
151254
- /* 79 */ "cmd ::= DROP VIEW ifexists fullname",
151255
- /* 80 */ "cmd ::= select",
151256
- /* 81 */ "select ::= WITH wqlist selectnowith",
151257
- /* 82 */ "select ::= WITH RECURSIVE wqlist selectnowith",
151258
- /* 83 */ "select ::= selectnowith",
151259
- /* 84 */ "selectnowith ::= selectnowith multiselect_op oneselect",
151260
- /* 85 */ "multiselect_op ::= UNION",
151261
- /* 86 */ "multiselect_op ::= UNION ALL",
151262
- /* 87 */ "multiselect_op ::= EXCEPT|INTERSECT",
151263
- /* 88 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
151264
- /* 89 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt",
151265
- /* 90 */ "values ::= VALUES LP nexprlist RP",
151266
- /* 91 */ "values ::= values COMMA LP nexprlist RP",
151267
- /* 92 */ "distinct ::= DISTINCT",
151268
- /* 93 */ "distinct ::= ALL",
151269
- /* 94 */ "distinct ::=",
151270
- /* 95 */ "sclp ::=",
151271
- /* 96 */ "selcollist ::= sclp scanpt expr scanpt as",
151272
- /* 97 */ "selcollist ::= sclp scanpt STAR",
151273
- /* 98 */ "selcollist ::= sclp scanpt nm DOT STAR",
151274
- /* 99 */ "as ::= AS nm",
151275
- /* 100 */ "as ::=",
151276
- /* 101 */ "from ::=",
151277
- /* 102 */ "from ::= FROM seltablist",
151278
- /* 103 */ "stl_prefix ::= seltablist joinop",
151279
- /* 104 */ "stl_prefix ::=",
151280
- /* 105 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
151281
- /* 106 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
151282
- /* 107 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
151283
- /* 108 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
151284
- /* 109 */ "dbnm ::=",
151285
- /* 110 */ "dbnm ::= DOT nm",
151286
- /* 111 */ "fullname ::= nm",
151287
- /* 112 */ "fullname ::= nm DOT nm",
151288
- /* 113 */ "xfullname ::= nm",
151289
- /* 114 */ "xfullname ::= nm DOT nm",
151290
- /* 115 */ "xfullname ::= nm DOT nm AS nm",
151291
- /* 116 */ "xfullname ::= nm AS nm",
151292
- /* 117 */ "joinop ::= COMMA|JOIN",
151293
- /* 118 */ "joinop ::= JOIN_KW JOIN",
151294
- /* 119 */ "joinop ::= JOIN_KW nm JOIN",
151295
- /* 120 */ "joinop ::= JOIN_KW nm nm JOIN",
151296
- /* 121 */ "on_opt ::= ON expr",
151297
- /* 122 */ "on_opt ::=",
151298
- /* 123 */ "indexed_opt ::=",
151299
- /* 124 */ "indexed_opt ::= INDEXED BY nm",
151300
- /* 125 */ "indexed_opt ::= NOT INDEXED",
151301
- /* 126 */ "using_opt ::= USING LP idlist RP",
151302
- /* 127 */ "using_opt ::=",
151303
- /* 128 */ "orderby_opt ::=",
151304
- /* 129 */ "orderby_opt ::= ORDER BY sortlist",
151305
- /* 130 */ "sortlist ::= sortlist COMMA expr sortorder nulls",
151306
- /* 131 */ "sortlist ::= expr sortorder nulls",
151307
- /* 132 */ "sortorder ::= ASC",
151308
- /* 133 */ "sortorder ::= DESC",
151309
- /* 134 */ "sortorder ::=",
151310
- /* 135 */ "nulls ::= NULLS FIRST",
151311
- /* 136 */ "nulls ::= NULLS LAST",
151312
- /* 137 */ "nulls ::=",
151313
- /* 138 */ "groupby_opt ::=",
151314
- /* 139 */ "groupby_opt ::= GROUP BY nexprlist",
151315
- /* 140 */ "having_opt ::=",
151316
- /* 141 */ "having_opt ::= HAVING expr",
151317
- /* 142 */ "limit_opt ::=",
151318
- /* 143 */ "limit_opt ::= LIMIT expr",
151319
- /* 144 */ "limit_opt ::= LIMIT expr OFFSET expr",
151320
- /* 145 */ "limit_opt ::= LIMIT expr COMMA expr",
151321
- /* 146 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
151322
- /* 147 */ "where_opt ::=",
151323
- /* 148 */ "where_opt ::= WHERE expr",
151324
- /* 149 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
151325
- /* 150 */ "setlist ::= setlist COMMA nm EQ expr",
151326
- /* 151 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
151327
- /* 152 */ "setlist ::= nm EQ expr",
151328
- /* 153 */ "setlist ::= LP idlist RP EQ expr",
151329
- /* 154 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
151330
- /* 155 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
151331
- /* 156 */ "upsert ::=",
151332
- /* 157 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
151333
- /* 158 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
151334
- /* 159 */ "upsert ::= ON CONFLICT DO NOTHING",
151335
- /* 160 */ "insert_cmd ::= INSERT orconf",
151336
- /* 161 */ "insert_cmd ::= REPLACE",
151337
- /* 162 */ "idlist_opt ::=",
151338
- /* 163 */ "idlist_opt ::= LP idlist RP",
151339
- /* 164 */ "idlist ::= idlist COMMA nm",
151340
- /* 165 */ "idlist ::= nm",
151341
- /* 166 */ "expr ::= LP expr RP",
151342
- /* 167 */ "expr ::= ID|INDEXED",
151343
- /* 168 */ "expr ::= JOIN_KW",
151344
- /* 169 */ "expr ::= nm DOT nm",
151345
- /* 170 */ "expr ::= nm DOT nm DOT nm",
151346
- /* 171 */ "term ::= NULL|FLOAT|BLOB",
151347
- /* 172 */ "term ::= STRING",
151348
- /* 173 */ "term ::= INTEGER",
151349
- /* 174 */ "expr ::= VARIABLE",
151350
- /* 175 */ "expr ::= expr COLLATE ID|STRING",
151351
- /* 176 */ "expr ::= CAST LP expr AS typetoken RP",
151352
- /* 177 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
151353
- /* 178 */ "expr ::= ID|INDEXED LP STAR RP",
151354
- /* 179 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over",
151355
- /* 180 */ "expr ::= ID|INDEXED LP STAR RP filter_over",
151356
- /* 181 */ "term ::= CTIME_KW",
151357
- /* 182 */ "expr ::= LP nexprlist COMMA expr RP",
151358
- /* 183 */ "expr ::= expr AND expr",
151359
- /* 184 */ "expr ::= expr OR expr",
151360
- /* 185 */ "expr ::= expr LT|GT|GE|LE expr",
151361
- /* 186 */ "expr ::= expr EQ|NE expr",
151362
- /* 187 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
151363
- /* 188 */ "expr ::= expr PLUS|MINUS expr",
151364
- /* 189 */ "expr ::= expr STAR|SLASH|REM expr",
151365
- /* 190 */ "expr ::= expr CONCAT expr",
151366
- /* 191 */ "likeop ::= NOT LIKE_KW|MATCH",
151367
- /* 192 */ "expr ::= expr likeop expr",
151368
- /* 193 */ "expr ::= expr likeop expr ESCAPE expr",
151369
- /* 194 */ "expr ::= expr ISNULL|NOTNULL",
151370
- /* 195 */ "expr ::= expr NOT NULL",
151371
- /* 196 */ "expr ::= expr IS expr",
151372
- /* 197 */ "expr ::= expr IS NOT expr",
151373
- /* 198 */ "expr ::= NOT expr",
151374
- /* 199 */ "expr ::= BITNOT expr",
151375
- /* 200 */ "expr ::= PLUS|MINUS expr",
151376
- /* 201 */ "between_op ::= BETWEEN",
151377
- /* 202 */ "between_op ::= NOT BETWEEN",
151378
- /* 203 */ "expr ::= expr between_op expr AND expr",
151379
- /* 204 */ "in_op ::= IN",
151380
- /* 205 */ "in_op ::= NOT IN",
151381
- /* 206 */ "expr ::= expr in_op LP exprlist RP",
151382
- /* 207 */ "expr ::= LP select RP",
151383
- /* 208 */ "expr ::= expr in_op LP select RP",
151384
- /* 209 */ "expr ::= expr in_op nm dbnm paren_exprlist",
151385
- /* 210 */ "expr ::= EXISTS LP select RP",
151386
- /* 211 */ "expr ::= CASE case_operand case_exprlist case_else END",
151387
- /* 212 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
151388
- /* 213 */ "case_exprlist ::= WHEN expr THEN expr",
151389
- /* 214 */ "case_else ::= ELSE expr",
151390
- /* 215 */ "case_else ::=",
151391
- /* 216 */ "case_operand ::= expr",
151392
- /* 217 */ "case_operand ::=",
151393
- /* 218 */ "exprlist ::=",
151394
- /* 219 */ "nexprlist ::= nexprlist COMMA expr",
151395
- /* 220 */ "nexprlist ::= expr",
151396
- /* 221 */ "paren_exprlist ::=",
151397
- /* 222 */ "paren_exprlist ::= LP exprlist RP",
151398
- /* 223 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
151399
- /* 224 */ "uniqueflag ::= UNIQUE",
151400
- /* 225 */ "uniqueflag ::=",
151401
- /* 226 */ "eidlist_opt ::=",
151402
- /* 227 */ "eidlist_opt ::= LP eidlist RP",
151403
- /* 228 */ "eidlist ::= eidlist COMMA nm collate sortorder",
151404
- /* 229 */ "eidlist ::= nm collate sortorder",
151405
- /* 230 */ "collate ::=",
151406
- /* 231 */ "collate ::= COLLATE ID|STRING",
151407
- /* 232 */ "cmd ::= DROP INDEX ifexists fullname",
151408
- /* 233 */ "cmd ::= VACUUM vinto",
151409
- /* 234 */ "cmd ::= VACUUM nm vinto",
151410
- /* 235 */ "vinto ::= INTO expr",
151411
- /* 236 */ "vinto ::=",
151412
- /* 237 */ "cmd ::= PRAGMA nm dbnm",
151413
- /* 238 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
151414
- /* 239 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
151415
- /* 240 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
151416
- /* 241 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
151417
- /* 242 */ "plus_num ::= PLUS INTEGER|FLOAT",
151418
- /* 243 */ "minus_num ::= MINUS INTEGER|FLOAT",
151419
- /* 244 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
151420
- /* 245 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
151421
- /* 246 */ "trigger_time ::= BEFORE|AFTER",
151422
- /* 247 */ "trigger_time ::= INSTEAD OF",
151423
- /* 248 */ "trigger_time ::=",
151424
- /* 249 */ "trigger_event ::= DELETE|INSERT",
151425
- /* 250 */ "trigger_event ::= UPDATE",
151426
- /* 251 */ "trigger_event ::= UPDATE OF idlist",
151427
- /* 252 */ "when_clause ::=",
151428
- /* 253 */ "when_clause ::= WHEN expr",
151429
- /* 254 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
151430
- /* 255 */ "trigger_cmd_list ::= trigger_cmd SEMI",
151431
- /* 256 */ "trnm ::= nm DOT nm",
151432
- /* 257 */ "tridxby ::= INDEXED BY nm",
151433
- /* 258 */ "tridxby ::= NOT INDEXED",
151434
- /* 259 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
151435
- /* 260 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
151436
- /* 261 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
151437
- /* 262 */ "trigger_cmd ::= scanpt select scanpt",
151438
- /* 263 */ "expr ::= RAISE LP IGNORE RP",
151439
- /* 264 */ "expr ::= RAISE LP raisetype COMMA nm RP",
151440
- /* 265 */ "raisetype ::= ROLLBACK",
151441
- /* 266 */ "raisetype ::= ABORT",
151442
- /* 267 */ "raisetype ::= FAIL",
151443
- /* 268 */ "cmd ::= DROP TRIGGER ifexists fullname",
151444
- /* 269 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
151445
- /* 270 */ "cmd ::= DETACH database_kw_opt expr",
151446
- /* 271 */ "key_opt ::=",
151447
- /* 272 */ "key_opt ::= KEY expr",
151448
- /* 273 */ "cmd ::= REINDEX",
151449
- /* 274 */ "cmd ::= REINDEX nm dbnm",
151450
- /* 275 */ "cmd ::= ANALYZE",
151451
- /* 276 */ "cmd ::= ANALYZE nm dbnm",
151452
- /* 277 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
151453
- /* 278 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
151454
- /* 279 */ "add_column_fullname ::= fullname",
151455
- /* 280 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
151456
- /* 281 */ "cmd ::= create_vtab",
151457
- /* 282 */ "cmd ::= create_vtab LP vtabarglist RP",
151458
- /* 283 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
151459
- /* 284 */ "vtabarg ::=",
151460
- /* 285 */ "vtabargtoken ::= ANY",
151461
- /* 286 */ "vtabargtoken ::= lp anylist RP",
151462
- /* 287 */ "lp ::= LP",
151463
- /* 288 */ "with ::= WITH wqlist",
151464
- /* 289 */ "with ::= WITH RECURSIVE wqlist",
151465
- /* 290 */ "wqlist ::= nm eidlist_opt AS LP select RP",
151466
- /* 291 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
151467
- /* 292 */ "windowdefn_list ::= windowdefn",
151468
- /* 293 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
151469
- /* 294 */ "windowdefn ::= nm AS LP window RP",
151470
- /* 295 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
151471
- /* 296 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
151472
- /* 297 */ "window ::= ORDER BY sortlist frame_opt",
151473
- /* 298 */ "window ::= nm ORDER BY sortlist frame_opt",
151474
- /* 299 */ "window ::= frame_opt",
151475
- /* 300 */ "window ::= nm frame_opt",
151476
- /* 301 */ "frame_opt ::=",
151477
- /* 302 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
151478
- /* 303 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
151479
- /* 304 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
151480
- /* 305 */ "frame_bound_s ::= frame_bound",
151481
- /* 306 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
151482
- /* 307 */ "frame_bound_e ::= frame_bound",
151483
- /* 308 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
151484
- /* 309 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
151485
- /* 310 */ "frame_bound ::= CURRENT ROW",
151486
- /* 311 */ "frame_exclude_opt ::=",
151487
- /* 312 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
151488
- /* 313 */ "frame_exclude ::= NO OTHERS",
151489
- /* 314 */ "frame_exclude ::= CURRENT ROW",
151490
- /* 315 */ "frame_exclude ::= GROUP|TIES",
151491
- /* 316 */ "window_clause ::= WINDOW windowdefn_list",
151492
- /* 317 */ "filter_over ::= filter_clause over_clause",
151493
- /* 318 */ "filter_over ::= over_clause",
151494
- /* 319 */ "filter_over ::= filter_clause",
151495
- /* 320 */ "over_clause ::= OVER LP window RP",
151496
- /* 321 */ "over_clause ::= OVER nm",
151497
- /* 322 */ "filter_clause ::= FILTER LP WHERE expr RP",
151498
- /* 323 */ "input ::= cmdlist",
151499
- /* 324 */ "cmdlist ::= cmdlist ecmd",
151500
- /* 325 */ "cmdlist ::= ecmd",
151501
- /* 326 */ "ecmd ::= SEMI",
151502
- /* 327 */ "ecmd ::= cmdx SEMI",
151503
- /* 328 */ "ecmd ::= explain cmdx",
151504
- /* 329 */ "trans_opt ::=",
151505
- /* 330 */ "trans_opt ::= TRANSACTION",
151506
- /* 331 */ "trans_opt ::= TRANSACTION nm",
151507
- /* 332 */ "savepoint_opt ::= SAVEPOINT",
151508
- /* 333 */ "savepoint_opt ::=",
151509
- /* 334 */ "cmd ::= create_table create_table_args",
151510
- /* 335 */ "columnlist ::= columnlist COMMA columnname carglist",
151511
- /* 336 */ "columnlist ::= columnname carglist",
151512
- /* 337 */ "nm ::= ID|INDEXED",
151513
- /* 338 */ "nm ::= STRING",
151514
- /* 339 */ "nm ::= JOIN_KW",
151515
- /* 340 */ "typetoken ::= typename",
151516
- /* 341 */ "typename ::= ID|STRING",
151517
- /* 342 */ "signed ::= plus_num",
151518
- /* 343 */ "signed ::= minus_num",
151519
- /* 344 */ "carglist ::= carglist ccons",
151520
- /* 345 */ "carglist ::=",
151521
- /* 346 */ "ccons ::= NULL onconf",
151522
- /* 347 */ "conslist_opt ::= COMMA conslist",
151523
- /* 348 */ "conslist ::= conslist tconscomma tcons",
151524
- /* 349 */ "conslist ::= tcons",
151525
- /* 350 */ "tconscomma ::=",
151526
- /* 351 */ "defer_subclause_opt ::= defer_subclause",
151527
- /* 352 */ "resolvetype ::= raisetype",
151528
- /* 353 */ "selectnowith ::= oneselect",
151529
- /* 354 */ "oneselect ::= values",
151530
- /* 355 */ "sclp ::= selcollist COMMA",
151531
- /* 356 */ "as ::= ID|STRING",
151532
- /* 357 */ "expr ::= term",
151533
- /* 358 */ "likeop ::= LIKE_KW|MATCH",
151534
- /* 359 */ "exprlist ::= nexprlist",
151535
- /* 360 */ "nmnum ::= plus_num",
151536
- /* 361 */ "nmnum ::= nm",
151537
- /* 362 */ "nmnum ::= ON",
151538
- /* 363 */ "nmnum ::= DELETE",
151539
- /* 364 */ "nmnum ::= DEFAULT",
151540
- /* 365 */ "plus_num ::= INTEGER|FLOAT",
151541
- /* 366 */ "foreach_clause ::=",
151542
- /* 367 */ "foreach_clause ::= FOR EACH ROW",
151543
- /* 368 */ "trnm ::= nm",
151544
- /* 369 */ "tridxby ::=",
151545
- /* 370 */ "database_kw_opt ::= DATABASE",
151546
- /* 371 */ "database_kw_opt ::=",
151547
- /* 372 */ "kwcolumn_opt ::=",
151548
- /* 373 */ "kwcolumn_opt ::= COLUMNKW",
151549
- /* 374 */ "vtabarglist ::= vtabarg",
151550
- /* 375 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
151551
- /* 376 */ "vtabarg ::= vtabarg vtabargtoken",
151552
- /* 377 */ "anylist ::=",
151553
- /* 378 */ "anylist ::= anylist LP anylist RP",
151554
- /* 379 */ "anylist ::= anylist ANY",
151555
- /* 380 */ "with ::=",
152337
+ /* 43 */ "generated ::= LP expr RP",
152338
+ /* 44 */ "generated ::= LP expr RP ID",
152339
+ /* 45 */ "autoinc ::=",
152340
+ /* 46 */ "autoinc ::= AUTOINCR",
152341
+ /* 47 */ "refargs ::=",
152342
+ /* 48 */ "refargs ::= refargs refarg",
152343
+ /* 49 */ "refarg ::= MATCH nm",
152344
+ /* 50 */ "refarg ::= ON INSERT refact",
152345
+ /* 51 */ "refarg ::= ON DELETE refact",
152346
+ /* 52 */ "refarg ::= ON UPDATE refact",
152347
+ /* 53 */ "refact ::= SET NULL",
152348
+ /* 54 */ "refact ::= SET DEFAULT",
152349
+ /* 55 */ "refact ::= CASCADE",
152350
+ /* 56 */ "refact ::= RESTRICT",
152351
+ /* 57 */ "refact ::= NO ACTION",
152352
+ /* 58 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
152353
+ /* 59 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
152354
+ /* 60 */ "init_deferred_pred_opt ::=",
152355
+ /* 61 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
152356
+ /* 62 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
152357
+ /* 63 */ "conslist_opt ::=",
152358
+ /* 64 */ "tconscomma ::= COMMA",
152359
+ /* 65 */ "tcons ::= CONSTRAINT nm",
152360
+ /* 66 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf",
152361
+ /* 67 */ "tcons ::= UNIQUE LP sortlist RP onconf",
152362
+ /* 68 */ "tcons ::= CHECK LP expr RP onconf",
152363
+ /* 69 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt",
152364
+ /* 70 */ "defer_subclause_opt ::=",
152365
+ /* 71 */ "onconf ::=",
152366
+ /* 72 */ "onconf ::= ON CONFLICT resolvetype",
152367
+ /* 73 */ "orconf ::=",
152368
+ /* 74 */ "orconf ::= OR resolvetype",
152369
+ /* 75 */ "resolvetype ::= IGNORE",
152370
+ /* 76 */ "resolvetype ::= REPLACE",
152371
+ /* 77 */ "cmd ::= DROP TABLE ifexists fullname",
152372
+ /* 78 */ "ifexists ::= IF EXISTS",
152373
+ /* 79 */ "ifexists ::=",
152374
+ /* 80 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
152375
+ /* 81 */ "cmd ::= DROP VIEW ifexists fullname",
152376
+ /* 82 */ "cmd ::= select",
152377
+ /* 83 */ "select ::= WITH wqlist selectnowith",
152378
+ /* 84 */ "select ::= WITH RECURSIVE wqlist selectnowith",
152379
+ /* 85 */ "select ::= selectnowith",
152380
+ /* 86 */ "selectnowith ::= selectnowith multiselect_op oneselect",
152381
+ /* 87 */ "multiselect_op ::= UNION",
152382
+ /* 88 */ "multiselect_op ::= UNION ALL",
152383
+ /* 89 */ "multiselect_op ::= EXCEPT|INTERSECT",
152384
+ /* 90 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
152385
+ /* 91 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt",
152386
+ /* 92 */ "values ::= VALUES LP nexprlist RP",
152387
+ /* 93 */ "values ::= values COMMA LP nexprlist RP",
152388
+ /* 94 */ "distinct ::= DISTINCT",
152389
+ /* 95 */ "distinct ::= ALL",
152390
+ /* 96 */ "distinct ::=",
152391
+ /* 97 */ "sclp ::=",
152392
+ /* 98 */ "selcollist ::= sclp scanpt expr scanpt as",
152393
+ /* 99 */ "selcollist ::= sclp scanpt STAR",
152394
+ /* 100 */ "selcollist ::= sclp scanpt nm DOT STAR",
152395
+ /* 101 */ "as ::= AS nm",
152396
+ /* 102 */ "as ::=",
152397
+ /* 103 */ "from ::=",
152398
+ /* 104 */ "from ::= FROM seltablist",
152399
+ /* 105 */ "stl_prefix ::= seltablist joinop",
152400
+ /* 106 */ "stl_prefix ::=",
152401
+ /* 107 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
152402
+ /* 108 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
152403
+ /* 109 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
152404
+ /* 110 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
152405
+ /* 111 */ "dbnm ::=",
152406
+ /* 112 */ "dbnm ::= DOT nm",
152407
+ /* 113 */ "fullname ::= nm",
152408
+ /* 114 */ "fullname ::= nm DOT nm",
152409
+ /* 115 */ "xfullname ::= nm",
152410
+ /* 116 */ "xfullname ::= nm DOT nm",
152411
+ /* 117 */ "xfullname ::= nm DOT nm AS nm",
152412
+ /* 118 */ "xfullname ::= nm AS nm",
152413
+ /* 119 */ "joinop ::= COMMA|JOIN",
152414
+ /* 120 */ "joinop ::= JOIN_KW JOIN",
152415
+ /* 121 */ "joinop ::= JOIN_KW nm JOIN",
152416
+ /* 122 */ "joinop ::= JOIN_KW nm nm JOIN",
152417
+ /* 123 */ "on_opt ::= ON expr",
152418
+ /* 124 */ "on_opt ::=",
152419
+ /* 125 */ "indexed_opt ::=",
152420
+ /* 126 */ "indexed_opt ::= INDEXED BY nm",
152421
+ /* 127 */ "indexed_opt ::= NOT INDEXED",
152422
+ /* 128 */ "using_opt ::= USING LP idlist RP",
152423
+ /* 129 */ "using_opt ::=",
152424
+ /* 130 */ "orderby_opt ::=",
152425
+ /* 131 */ "orderby_opt ::= ORDER BY sortlist",
152426
+ /* 132 */ "sortlist ::= sortlist COMMA expr sortorder nulls",
152427
+ /* 133 */ "sortlist ::= expr sortorder nulls",
152428
+ /* 134 */ "sortorder ::= ASC",
152429
+ /* 135 */ "sortorder ::= DESC",
152430
+ /* 136 */ "sortorder ::=",
152431
+ /* 137 */ "nulls ::= NULLS FIRST",
152432
+ /* 138 */ "nulls ::= NULLS LAST",
152433
+ /* 139 */ "nulls ::=",
152434
+ /* 140 */ "groupby_opt ::=",
152435
+ /* 141 */ "groupby_opt ::= GROUP BY nexprlist",
152436
+ /* 142 */ "having_opt ::=",
152437
+ /* 143 */ "having_opt ::= HAVING expr",
152438
+ /* 144 */ "limit_opt ::=",
152439
+ /* 145 */ "limit_opt ::= LIMIT expr",
152440
+ /* 146 */ "limit_opt ::= LIMIT expr OFFSET expr",
152441
+ /* 147 */ "limit_opt ::= LIMIT expr COMMA expr",
152442
+ /* 148 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
152443
+ /* 149 */ "where_opt ::=",
152444
+ /* 150 */ "where_opt ::= WHERE expr",
152445
+ /* 151 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
152446
+ /* 152 */ "setlist ::= setlist COMMA nm EQ expr",
152447
+ /* 153 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
152448
+ /* 154 */ "setlist ::= nm EQ expr",
152449
+ /* 155 */ "setlist ::= LP idlist RP EQ expr",
152450
+ /* 156 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
152451
+ /* 157 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
152452
+ /* 158 */ "upsert ::=",
152453
+ /* 159 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
152454
+ /* 160 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
152455
+ /* 161 */ "upsert ::= ON CONFLICT DO NOTHING",
152456
+ /* 162 */ "insert_cmd ::= INSERT orconf",
152457
+ /* 163 */ "insert_cmd ::= REPLACE",
152458
+ /* 164 */ "idlist_opt ::=",
152459
+ /* 165 */ "idlist_opt ::= LP idlist RP",
152460
+ /* 166 */ "idlist ::= idlist COMMA nm",
152461
+ /* 167 */ "idlist ::= nm",
152462
+ /* 168 */ "expr ::= LP expr RP",
152463
+ /* 169 */ "expr ::= ID|INDEXED",
152464
+ /* 170 */ "expr ::= JOIN_KW",
152465
+ /* 171 */ "expr ::= nm DOT nm",
152466
+ /* 172 */ "expr ::= nm DOT nm DOT nm",
152467
+ /* 173 */ "term ::= NULL|FLOAT|BLOB",
152468
+ /* 174 */ "term ::= STRING",
152469
+ /* 175 */ "term ::= INTEGER",
152470
+ /* 176 */ "expr ::= VARIABLE",
152471
+ /* 177 */ "expr ::= expr COLLATE ID|STRING",
152472
+ /* 178 */ "expr ::= CAST LP expr AS typetoken RP",
152473
+ /* 179 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
152474
+ /* 180 */ "expr ::= ID|INDEXED LP STAR RP",
152475
+ /* 181 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over",
152476
+ /* 182 */ "expr ::= ID|INDEXED LP STAR RP filter_over",
152477
+ /* 183 */ "term ::= CTIME_KW",
152478
+ /* 184 */ "expr ::= LP nexprlist COMMA expr RP",
152479
+ /* 185 */ "expr ::= expr AND expr",
152480
+ /* 186 */ "expr ::= expr OR expr",
152481
+ /* 187 */ "expr ::= expr LT|GT|GE|LE expr",
152482
+ /* 188 */ "expr ::= expr EQ|NE expr",
152483
+ /* 189 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
152484
+ /* 190 */ "expr ::= expr PLUS|MINUS expr",
152485
+ /* 191 */ "expr ::= expr STAR|SLASH|REM expr",
152486
+ /* 192 */ "expr ::= expr CONCAT expr",
152487
+ /* 193 */ "likeop ::= NOT LIKE_KW|MATCH",
152488
+ /* 194 */ "expr ::= expr likeop expr",
152489
+ /* 195 */ "expr ::= expr likeop expr ESCAPE expr",
152490
+ /* 196 */ "expr ::= expr ISNULL|NOTNULL",
152491
+ /* 197 */ "expr ::= expr NOT NULL",
152492
+ /* 198 */ "expr ::= expr IS expr",
152493
+ /* 199 */ "expr ::= expr IS NOT expr",
152494
+ /* 200 */ "expr ::= NOT expr",
152495
+ /* 201 */ "expr ::= BITNOT expr",
152496
+ /* 202 */ "expr ::= PLUS|MINUS expr",
152497
+ /* 203 */ "between_op ::= BETWEEN",
152498
+ /* 204 */ "between_op ::= NOT BETWEEN",
152499
+ /* 205 */ "expr ::= expr between_op expr AND expr",
152500
+ /* 206 */ "in_op ::= IN",
152501
+ /* 207 */ "in_op ::= NOT IN",
152502
+ /* 208 */ "expr ::= expr in_op LP exprlist RP",
152503
+ /* 209 */ "expr ::= LP select RP",
152504
+ /* 210 */ "expr ::= expr in_op LP select RP",
152505
+ /* 211 */ "expr ::= expr in_op nm dbnm paren_exprlist",
152506
+ /* 212 */ "expr ::= EXISTS LP select RP",
152507
+ /* 213 */ "expr ::= CASE case_operand case_exprlist case_else END",
152508
+ /* 214 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
152509
+ /* 215 */ "case_exprlist ::= WHEN expr THEN expr",
152510
+ /* 216 */ "case_else ::= ELSE expr",
152511
+ /* 217 */ "case_else ::=",
152512
+ /* 218 */ "case_operand ::= expr",
152513
+ /* 219 */ "case_operand ::=",
152514
+ /* 220 */ "exprlist ::=",
152515
+ /* 221 */ "nexprlist ::= nexprlist COMMA expr",
152516
+ /* 222 */ "nexprlist ::= expr",
152517
+ /* 223 */ "paren_exprlist ::=",
152518
+ /* 224 */ "paren_exprlist ::= LP exprlist RP",
152519
+ /* 225 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
152520
+ /* 226 */ "uniqueflag ::= UNIQUE",
152521
+ /* 227 */ "uniqueflag ::=",
152522
+ /* 228 */ "eidlist_opt ::=",
152523
+ /* 229 */ "eidlist_opt ::= LP eidlist RP",
152524
+ /* 230 */ "eidlist ::= eidlist COMMA nm collate sortorder",
152525
+ /* 231 */ "eidlist ::= nm collate sortorder",
152526
+ /* 232 */ "collate ::=",
152527
+ /* 233 */ "collate ::= COLLATE ID|STRING",
152528
+ /* 234 */ "cmd ::= DROP INDEX ifexists fullname",
152529
+ /* 235 */ "cmd ::= VACUUM vinto",
152530
+ /* 236 */ "cmd ::= VACUUM nm vinto",
152531
+ /* 237 */ "vinto ::= INTO expr",
152532
+ /* 238 */ "vinto ::=",
152533
+ /* 239 */ "cmd ::= PRAGMA nm dbnm",
152534
+ /* 240 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
152535
+ /* 241 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
152536
+ /* 242 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
152537
+ /* 243 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
152538
+ /* 244 */ "plus_num ::= PLUS INTEGER|FLOAT",
152539
+ /* 245 */ "minus_num ::= MINUS INTEGER|FLOAT",
152540
+ /* 246 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
152541
+ /* 247 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
152542
+ /* 248 */ "trigger_time ::= BEFORE|AFTER",
152543
+ /* 249 */ "trigger_time ::= INSTEAD OF",
152544
+ /* 250 */ "trigger_time ::=",
152545
+ /* 251 */ "trigger_event ::= DELETE|INSERT",
152546
+ /* 252 */ "trigger_event ::= UPDATE",
152547
+ /* 253 */ "trigger_event ::= UPDATE OF idlist",
152548
+ /* 254 */ "when_clause ::=",
152549
+ /* 255 */ "when_clause ::= WHEN expr",
152550
+ /* 256 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
152551
+ /* 257 */ "trigger_cmd_list ::= trigger_cmd SEMI",
152552
+ /* 258 */ "trnm ::= nm DOT nm",
152553
+ /* 259 */ "tridxby ::= INDEXED BY nm",
152554
+ /* 260 */ "tridxby ::= NOT INDEXED",
152555
+ /* 261 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
152556
+ /* 262 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
152557
+ /* 263 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
152558
+ /* 264 */ "trigger_cmd ::= scanpt select scanpt",
152559
+ /* 265 */ "expr ::= RAISE LP IGNORE RP",
152560
+ /* 266 */ "expr ::= RAISE LP raisetype COMMA nm RP",
152561
+ /* 267 */ "raisetype ::= ROLLBACK",
152562
+ /* 268 */ "raisetype ::= ABORT",
152563
+ /* 269 */ "raisetype ::= FAIL",
152564
+ /* 270 */ "cmd ::= DROP TRIGGER ifexists fullname",
152565
+ /* 271 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
152566
+ /* 272 */ "cmd ::= DETACH database_kw_opt expr",
152567
+ /* 273 */ "key_opt ::=",
152568
+ /* 274 */ "key_opt ::= KEY expr",
152569
+ /* 275 */ "cmd ::= REINDEX",
152570
+ /* 276 */ "cmd ::= REINDEX nm dbnm",
152571
+ /* 277 */ "cmd ::= ANALYZE",
152572
+ /* 278 */ "cmd ::= ANALYZE nm dbnm",
152573
+ /* 279 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
152574
+ /* 280 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
152575
+ /* 281 */ "add_column_fullname ::= fullname",
152576
+ /* 282 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
152577
+ /* 283 */ "cmd ::= create_vtab",
152578
+ /* 284 */ "cmd ::= create_vtab LP vtabarglist RP",
152579
+ /* 285 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
152580
+ /* 286 */ "vtabarg ::=",
152581
+ /* 287 */ "vtabargtoken ::= ANY",
152582
+ /* 288 */ "vtabargtoken ::= lp anylist RP",
152583
+ /* 289 */ "lp ::= LP",
152584
+ /* 290 */ "with ::= WITH wqlist",
152585
+ /* 291 */ "with ::= WITH RECURSIVE wqlist",
152586
+ /* 292 */ "wqlist ::= nm eidlist_opt AS LP select RP",
152587
+ /* 293 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
152588
+ /* 294 */ "windowdefn_list ::= windowdefn",
152589
+ /* 295 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
152590
+ /* 296 */ "windowdefn ::= nm AS LP window RP",
152591
+ /* 297 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
152592
+ /* 298 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
152593
+ /* 299 */ "window ::= ORDER BY sortlist frame_opt",
152594
+ /* 300 */ "window ::= nm ORDER BY sortlist frame_opt",
152595
+ /* 301 */ "window ::= frame_opt",
152596
+ /* 302 */ "window ::= nm frame_opt",
152597
+ /* 303 */ "frame_opt ::=",
152598
+ /* 304 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
152599
+ /* 305 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
152600
+ /* 306 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
152601
+ /* 307 */ "frame_bound_s ::= frame_bound",
152602
+ /* 308 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
152603
+ /* 309 */ "frame_bound_e ::= frame_bound",
152604
+ /* 310 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
152605
+ /* 311 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
152606
+ /* 312 */ "frame_bound ::= CURRENT ROW",
152607
+ /* 313 */ "frame_exclude_opt ::=",
152608
+ /* 314 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
152609
+ /* 315 */ "frame_exclude ::= NO OTHERS",
152610
+ /* 316 */ "frame_exclude ::= CURRENT ROW",
152611
+ /* 317 */ "frame_exclude ::= GROUP|TIES",
152612
+ /* 318 */ "window_clause ::= WINDOW windowdefn_list",
152613
+ /* 319 */ "filter_over ::= filter_clause over_clause",
152614
+ /* 320 */ "filter_over ::= over_clause",
152615
+ /* 321 */ "filter_over ::= filter_clause",
152616
+ /* 322 */ "over_clause ::= OVER LP window RP",
152617
+ /* 323 */ "over_clause ::= OVER nm",
152618
+ /* 324 */ "filter_clause ::= FILTER LP WHERE expr RP",
152619
+ /* 325 */ "input ::= cmdlist",
152620
+ /* 326 */ "cmdlist ::= cmdlist ecmd",
152621
+ /* 327 */ "cmdlist ::= ecmd",
152622
+ /* 328 */ "ecmd ::= SEMI",
152623
+ /* 329 */ "ecmd ::= cmdx SEMI",
152624
+ /* 330 */ "ecmd ::= explain cmdx",
152625
+ /* 331 */ "trans_opt ::=",
152626
+ /* 332 */ "trans_opt ::= TRANSACTION",
152627
+ /* 333 */ "trans_opt ::= TRANSACTION nm",
152628
+ /* 334 */ "savepoint_opt ::= SAVEPOINT",
152629
+ /* 335 */ "savepoint_opt ::=",
152630
+ /* 336 */ "cmd ::= create_table create_table_args",
152631
+ /* 337 */ "columnlist ::= columnlist COMMA columnname carglist",
152632
+ /* 338 */ "columnlist ::= columnname carglist",
152633
+ /* 339 */ "nm ::= ID|INDEXED",
152634
+ /* 340 */ "nm ::= STRING",
152635
+ /* 341 */ "nm ::= JOIN_KW",
152636
+ /* 342 */ "typetoken ::= typename",
152637
+ /* 343 */ "typename ::= ID|STRING",
152638
+ /* 344 */ "signed ::= plus_num",
152639
+ /* 345 */ "signed ::= minus_num",
152640
+ /* 346 */ "carglist ::= carglist ccons",
152641
+ /* 347 */ "carglist ::=",
152642
+ /* 348 */ "ccons ::= NULL onconf",
152643
+ /* 349 */ "ccons ::= GENERATED ALWAYS AS generated",
152644
+ /* 350 */ "ccons ::= AS generated",
152645
+ /* 351 */ "conslist_opt ::= COMMA conslist",
152646
+ /* 352 */ "conslist ::= conslist tconscomma tcons",
152647
+ /* 353 */ "conslist ::= tcons",
152648
+ /* 354 */ "tconscomma ::=",
152649
+ /* 355 */ "defer_subclause_opt ::= defer_subclause",
152650
+ /* 356 */ "resolvetype ::= raisetype",
152651
+ /* 357 */ "selectnowith ::= oneselect",
152652
+ /* 358 */ "oneselect ::= values",
152653
+ /* 359 */ "sclp ::= selcollist COMMA",
152654
+ /* 360 */ "as ::= ID|STRING",
152655
+ /* 361 */ "expr ::= term",
152656
+ /* 362 */ "likeop ::= LIKE_KW|MATCH",
152657
+ /* 363 */ "exprlist ::= nexprlist",
152658
+ /* 364 */ "nmnum ::= plus_num",
152659
+ /* 365 */ "nmnum ::= nm",
152660
+ /* 366 */ "nmnum ::= ON",
152661
+ /* 367 */ "nmnum ::= DELETE",
152662
+ /* 368 */ "nmnum ::= DEFAULT",
152663
+ /* 369 */ "plus_num ::= INTEGER|FLOAT",
152664
+ /* 370 */ "foreach_clause ::=",
152665
+ /* 371 */ "foreach_clause ::= FOR EACH ROW",
152666
+ /* 372 */ "trnm ::= nm",
152667
+ /* 373 */ "tridxby ::=",
152668
+ /* 374 */ "database_kw_opt ::= DATABASE",
152669
+ /* 375 */ "database_kw_opt ::=",
152670
+ /* 376 */ "kwcolumn_opt ::=",
152671
+ /* 377 */ "kwcolumn_opt ::= COLUMNKW",
152672
+ /* 378 */ "vtabarglist ::= vtabarg",
152673
+ /* 379 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
152674
+ /* 380 */ "vtabarg ::= vtabarg vtabargtoken",
152675
+ /* 381 */ "anylist ::=",
152676
+ /* 382 */ "anylist ::= anylist LP anylist RP",
152677
+ /* 383 */ "anylist ::= anylist ANY",
152678
+ /* 384 */ "with ::=",
151556152679
};
151557152680
#endif /* NDEBUG */
151558152681
151559152682
151560152683
#if YYSTACKDEPTH<=0
@@ -151676,102 +152799,102 @@
151676152799
** Note: during a reduce, the only symbols destroyed are those
151677152800
** which appear on the RHS of the rule, but which are *not* used
151678152801
** inside the C code.
151679152802
*/
151680152803
/********* Begin destructor definitions ***************************************/
151681
- case 198: /* select */
151682
- case 231: /* selectnowith */
151683
- case 232: /* oneselect */
151684
- case 244: /* values */
151685
-{
151686
-sqlite3SelectDelete(pParse->db, (yypminor->yy25));
151687
-}
151688
- break;
151689
- case 209: /* term */
151690
- case 210: /* expr */
151691
- case 238: /* where_opt */
151692
- case 240: /* having_opt */
151693
- case 252: /* on_opt */
151694
- case 268: /* case_operand */
151695
- case 270: /* case_else */
151696
- case 273: /* vinto */
151697
- case 280: /* when_clause */
151698
- case 285: /* key_opt */
151699
- case 299: /* filter_clause */
151700
-{
151701
-sqlite3ExprDelete(pParse->db, (yypminor->yy46));
151702
-}
151703
- break;
151704
- case 214: /* eidlist_opt */
151705
- case 223: /* sortlist */
151706
- case 224: /* eidlist */
151707
- case 236: /* selcollist */
151708
- case 239: /* groupby_opt */
151709
- case 241: /* orderby_opt */
151710
- case 245: /* nexprlist */
151711
- case 246: /* sclp */
151712
- case 254: /* exprlist */
151713
- case 259: /* setlist */
151714
- case 267: /* paren_exprlist */
151715
- case 269: /* case_exprlist */
151716
- case 298: /* part_opt */
151717
-{
151718
-sqlite3ExprListDelete(pParse->db, (yypminor->yy138));
151719
-}
151720
- break;
151721
- case 230: /* fullname */
151722
- case 237: /* from */
151723
- case 248: /* seltablist */
151724
- case 249: /* stl_prefix */
151725
- case 255: /* xfullname */
151726
-{
151727
-sqlite3SrcListDelete(pParse->db, (yypminor->yy609));
151728
-}
151729
- break;
151730
- case 233: /* wqlist */
151731
-{
151732
-sqlite3WithDelete(pParse->db, (yypminor->yy297));
151733
-}
151734
- break;
151735
- case 243: /* window_clause */
151736
- case 294: /* windowdefn_list */
151737
-{
151738
-sqlite3WindowListDelete(pParse->db, (yypminor->yy455));
151739
-}
151740
- break;
151741
- case 253: /* using_opt */
151742
- case 256: /* idlist */
151743
- case 261: /* idlist_opt */
151744
-{
151745
-sqlite3IdListDelete(pParse->db, (yypminor->yy406));
151746
-}
151747
- break;
151748
- case 263: /* filter_over */
151749
- case 295: /* windowdefn */
151750
- case 296: /* window */
151751
- case 297: /* frame_opt */
151752
- case 300: /* over_clause */
151753
-{
151754
-sqlite3WindowDelete(pParse->db, (yypminor->yy455));
151755
-}
151756
- break;
151757
- case 276: /* trigger_cmd_list */
151758
- case 281: /* trigger_cmd */
151759
-{
151760
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy527));
151761
-}
151762
- break;
151763
- case 278: /* trigger_event */
151764
-{
151765
-sqlite3IdListDelete(pParse->db, (yypminor->yy572).b);
151766
-}
151767
- break;
151768
- case 302: /* frame_bound */
151769
- case 303: /* frame_bound_s */
151770
- case 304: /* frame_bound_e */
151771
-{
151772
-sqlite3ExprDelete(pParse->db, (yypminor->yy57).pExpr);
152804
+ case 200: /* select */
152805
+ case 234: /* selectnowith */
152806
+ case 235: /* oneselect */
152807
+ case 247: /* values */
152808
+{
152809
+sqlite3SelectDelete(pParse->db, (yypminor->yy539));
152810
+}
152811
+ break;
152812
+ case 211: /* term */
152813
+ case 212: /* expr */
152814
+ case 241: /* where_opt */
152815
+ case 243: /* having_opt */
152816
+ case 255: /* on_opt */
152817
+ case 271: /* case_operand */
152818
+ case 273: /* case_else */
152819
+ case 276: /* vinto */
152820
+ case 283: /* when_clause */
152821
+ case 288: /* key_opt */
152822
+ case 302: /* filter_clause */
152823
+{
152824
+sqlite3ExprDelete(pParse->db, (yypminor->yy202));
152825
+}
152826
+ break;
152827
+ case 216: /* eidlist_opt */
152828
+ case 226: /* sortlist */
152829
+ case 227: /* eidlist */
152830
+ case 239: /* selcollist */
152831
+ case 242: /* groupby_opt */
152832
+ case 244: /* orderby_opt */
152833
+ case 248: /* nexprlist */
152834
+ case 249: /* sclp */
152835
+ case 257: /* exprlist */
152836
+ case 262: /* setlist */
152837
+ case 270: /* paren_exprlist */
152838
+ case 272: /* case_exprlist */
152839
+ case 301: /* part_opt */
152840
+{
152841
+sqlite3ExprListDelete(pParse->db, (yypminor->yy242));
152842
+}
152843
+ break;
152844
+ case 233: /* fullname */
152845
+ case 240: /* from */
152846
+ case 251: /* seltablist */
152847
+ case 252: /* stl_prefix */
152848
+ case 258: /* xfullname */
152849
+{
152850
+sqlite3SrcListDelete(pParse->db, (yypminor->yy47));
152851
+}
152852
+ break;
152853
+ case 236: /* wqlist */
152854
+{
152855
+sqlite3WithDelete(pParse->db, (yypminor->yy131));
152856
+}
152857
+ break;
152858
+ case 246: /* window_clause */
152859
+ case 297: /* windowdefn_list */
152860
+{
152861
+sqlite3WindowListDelete(pParse->db, (yypminor->yy303));
152862
+}
152863
+ break;
152864
+ case 256: /* using_opt */
152865
+ case 259: /* idlist */
152866
+ case 264: /* idlist_opt */
152867
+{
152868
+sqlite3IdListDelete(pParse->db, (yypminor->yy600));
152869
+}
152870
+ break;
152871
+ case 266: /* filter_over */
152872
+ case 298: /* windowdefn */
152873
+ case 299: /* window */
152874
+ case 300: /* frame_opt */
152875
+ case 303: /* over_clause */
152876
+{
152877
+sqlite3WindowDelete(pParse->db, (yypminor->yy303));
152878
+}
152879
+ break;
152880
+ case 279: /* trigger_cmd_list */
152881
+ case 284: /* trigger_cmd */
152882
+{
152883
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy447));
152884
+}
152885
+ break;
152886
+ case 281: /* trigger_event */
152887
+{
152888
+sqlite3IdListDelete(pParse->db, (yypminor->yy230).b);
152889
+}
152890
+ break;
152891
+ case 305: /* frame_bound */
152892
+ case 306: /* frame_bound_s */
152893
+ case 307: /* frame_bound_e */
152894
+{
152895
+sqlite3ExprDelete(pParse->db, (yypminor->yy77).pExpr);
151773152896
}
151774152897
break;
151775152898
/********* End destructor definitions *****************************************/
151776152899
default: break; /* If no destructor action specified: do nothing */
151777152900
}
@@ -152058,391 +153181,395 @@
152058153181
}
152059153182
152060153183
/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
152061153184
** of that rule */
152062153185
static const YYCODETYPE yyRuleInfoLhs[] = {
152063
- 183, /* (0) explain ::= EXPLAIN */
152064
- 183, /* (1) explain ::= EXPLAIN QUERY PLAN */
152065
- 182, /* (2) cmdx ::= cmd */
152066
- 184, /* (3) cmd ::= BEGIN transtype trans_opt */
152067
- 185, /* (4) transtype ::= */
152068
- 185, /* (5) transtype ::= DEFERRED */
152069
- 185, /* (6) transtype ::= IMMEDIATE */
152070
- 185, /* (7) transtype ::= EXCLUSIVE */
152071
- 184, /* (8) cmd ::= COMMIT|END trans_opt */
152072
- 184, /* (9) cmd ::= ROLLBACK trans_opt */
152073
- 184, /* (10) cmd ::= SAVEPOINT nm */
152074
- 184, /* (11) cmd ::= RELEASE savepoint_opt nm */
152075
- 184, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
152076
- 189, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
152077
- 191, /* (14) createkw ::= CREATE */
152078
- 193, /* (15) ifnotexists ::= */
152079
- 193, /* (16) ifnotexists ::= IF NOT EXISTS */
152080
- 192, /* (17) temp ::= TEMP */
152081
- 192, /* (18) temp ::= */
152082
- 190, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
152083
- 190, /* (20) create_table_args ::= AS select */
152084
- 197, /* (21) table_options ::= */
152085
- 197, /* (22) table_options ::= WITHOUT nm */
152086
- 199, /* (23) columnname ::= nm typetoken */
152087
- 201, /* (24) typetoken ::= */
152088
- 201, /* (25) typetoken ::= typename LP signed RP */
152089
- 201, /* (26) typetoken ::= typename LP signed COMMA signed RP */
152090
- 202, /* (27) typename ::= typename ID|STRING */
152091
- 206, /* (28) scanpt ::= */
152092
- 207, /* (29) scantok ::= */
152093
- 208, /* (30) ccons ::= CONSTRAINT nm */
152094
- 208, /* (31) ccons ::= DEFAULT scantok term */
152095
- 208, /* (32) ccons ::= DEFAULT LP expr RP */
152096
- 208, /* (33) ccons ::= DEFAULT PLUS scantok term */
152097
- 208, /* (34) ccons ::= DEFAULT MINUS scantok term */
152098
- 208, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
152099
- 208, /* (36) ccons ::= NOT NULL onconf */
152100
- 208, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
152101
- 208, /* (38) ccons ::= UNIQUE onconf */
152102
- 208, /* (39) ccons ::= CHECK LP expr RP */
152103
- 208, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
152104
- 208, /* (41) ccons ::= defer_subclause */
152105
- 208, /* (42) ccons ::= COLLATE ID|STRING */
152106
- 213, /* (43) autoinc ::= */
152107
- 213, /* (44) autoinc ::= AUTOINCR */
152108
- 215, /* (45) refargs ::= */
152109
- 215, /* (46) refargs ::= refargs refarg */
152110
- 217, /* (47) refarg ::= MATCH nm */
152111
- 217, /* (48) refarg ::= ON INSERT refact */
152112
- 217, /* (49) refarg ::= ON DELETE refact */
152113
- 217, /* (50) refarg ::= ON UPDATE refact */
152114
- 218, /* (51) refact ::= SET NULL */
152115
- 218, /* (52) refact ::= SET DEFAULT */
152116
- 218, /* (53) refact ::= CASCADE */
152117
- 218, /* (54) refact ::= RESTRICT */
152118
- 218, /* (55) refact ::= NO ACTION */
152119
- 216, /* (56) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
152120
- 216, /* (57) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
152121
- 219, /* (58) init_deferred_pred_opt ::= */
152122
- 219, /* (59) init_deferred_pred_opt ::= INITIALLY DEFERRED */
152123
- 219, /* (60) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
152124
- 196, /* (61) conslist_opt ::= */
152125
- 221, /* (62) tconscomma ::= COMMA */
152126
- 222, /* (63) tcons ::= CONSTRAINT nm */
152127
- 222, /* (64) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
152128
- 222, /* (65) tcons ::= UNIQUE LP sortlist RP onconf */
152129
- 222, /* (66) tcons ::= CHECK LP expr RP onconf */
152130
- 222, /* (67) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
152131
- 225, /* (68) defer_subclause_opt ::= */
152132
- 211, /* (69) onconf ::= */
152133
- 211, /* (70) onconf ::= ON CONFLICT resolvetype */
152134
- 226, /* (71) orconf ::= */
152135
- 226, /* (72) orconf ::= OR resolvetype */
152136
- 227, /* (73) resolvetype ::= IGNORE */
152137
- 227, /* (74) resolvetype ::= REPLACE */
152138
- 184, /* (75) cmd ::= DROP TABLE ifexists fullname */
152139
- 229, /* (76) ifexists ::= IF EXISTS */
152140
- 229, /* (77) ifexists ::= */
152141
- 184, /* (78) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
152142
- 184, /* (79) cmd ::= DROP VIEW ifexists fullname */
152143
- 184, /* (80) cmd ::= select */
152144
- 198, /* (81) select ::= WITH wqlist selectnowith */
152145
- 198, /* (82) select ::= WITH RECURSIVE wqlist selectnowith */
152146
- 198, /* (83) select ::= selectnowith */
152147
- 231, /* (84) selectnowith ::= selectnowith multiselect_op oneselect */
152148
- 234, /* (85) multiselect_op ::= UNION */
152149
- 234, /* (86) multiselect_op ::= UNION ALL */
152150
- 234, /* (87) multiselect_op ::= EXCEPT|INTERSECT */
152151
- 232, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
152152
- 232, /* (89) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
152153
- 244, /* (90) values ::= VALUES LP nexprlist RP */
152154
- 244, /* (91) values ::= values COMMA LP nexprlist RP */
152155
- 235, /* (92) distinct ::= DISTINCT */
152156
- 235, /* (93) distinct ::= ALL */
152157
- 235, /* (94) distinct ::= */
152158
- 246, /* (95) sclp ::= */
152159
- 236, /* (96) selcollist ::= sclp scanpt expr scanpt as */
152160
- 236, /* (97) selcollist ::= sclp scanpt STAR */
152161
- 236, /* (98) selcollist ::= sclp scanpt nm DOT STAR */
152162
- 247, /* (99) as ::= AS nm */
152163
- 247, /* (100) as ::= */
152164
- 237, /* (101) from ::= */
152165
- 237, /* (102) from ::= FROM seltablist */
152166
- 249, /* (103) stl_prefix ::= seltablist joinop */
152167
- 249, /* (104) stl_prefix ::= */
152168
- 248, /* (105) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
152169
- 248, /* (106) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
152170
- 248, /* (107) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
152171
- 248, /* (108) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
152172
- 194, /* (109) dbnm ::= */
152173
- 194, /* (110) dbnm ::= DOT nm */
152174
- 230, /* (111) fullname ::= nm */
152175
- 230, /* (112) fullname ::= nm DOT nm */
152176
- 255, /* (113) xfullname ::= nm */
152177
- 255, /* (114) xfullname ::= nm DOT nm */
152178
- 255, /* (115) xfullname ::= nm DOT nm AS nm */
152179
- 255, /* (116) xfullname ::= nm AS nm */
152180
- 250, /* (117) joinop ::= COMMA|JOIN */
152181
- 250, /* (118) joinop ::= JOIN_KW JOIN */
152182
- 250, /* (119) joinop ::= JOIN_KW nm JOIN */
152183
- 250, /* (120) joinop ::= JOIN_KW nm nm JOIN */
152184
- 252, /* (121) on_opt ::= ON expr */
152185
- 252, /* (122) on_opt ::= */
152186
- 251, /* (123) indexed_opt ::= */
152187
- 251, /* (124) indexed_opt ::= INDEXED BY nm */
152188
- 251, /* (125) indexed_opt ::= NOT INDEXED */
152189
- 253, /* (126) using_opt ::= USING LP idlist RP */
152190
- 253, /* (127) using_opt ::= */
152191
- 241, /* (128) orderby_opt ::= */
152192
- 241, /* (129) orderby_opt ::= ORDER BY sortlist */
152193
- 223, /* (130) sortlist ::= sortlist COMMA expr sortorder nulls */
152194
- 223, /* (131) sortlist ::= expr sortorder nulls */
152195
- 212, /* (132) sortorder ::= ASC */
152196
- 212, /* (133) sortorder ::= DESC */
152197
- 212, /* (134) sortorder ::= */
152198
- 257, /* (135) nulls ::= NULLS FIRST */
152199
- 257, /* (136) nulls ::= NULLS LAST */
152200
- 257, /* (137) nulls ::= */
152201
- 239, /* (138) groupby_opt ::= */
152202
- 239, /* (139) groupby_opt ::= GROUP BY nexprlist */
152203
- 240, /* (140) having_opt ::= */
152204
- 240, /* (141) having_opt ::= HAVING expr */
152205
- 242, /* (142) limit_opt ::= */
152206
- 242, /* (143) limit_opt ::= LIMIT expr */
152207
- 242, /* (144) limit_opt ::= LIMIT expr OFFSET expr */
152208
- 242, /* (145) limit_opt ::= LIMIT expr COMMA expr */
152209
- 184, /* (146) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
152210
- 238, /* (147) where_opt ::= */
152211
- 238, /* (148) where_opt ::= WHERE expr */
152212
- 184, /* (149) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
152213
- 259, /* (150) setlist ::= setlist COMMA nm EQ expr */
152214
- 259, /* (151) setlist ::= setlist COMMA LP idlist RP EQ expr */
152215
- 259, /* (152) setlist ::= nm EQ expr */
152216
- 259, /* (153) setlist ::= LP idlist RP EQ expr */
152217
- 184, /* (154) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
152218
- 184, /* (155) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
152219
- 262, /* (156) upsert ::= */
152220
- 262, /* (157) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
152221
- 262, /* (158) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
152222
- 262, /* (159) upsert ::= ON CONFLICT DO NOTHING */
152223
- 260, /* (160) insert_cmd ::= INSERT orconf */
152224
- 260, /* (161) insert_cmd ::= REPLACE */
152225
- 261, /* (162) idlist_opt ::= */
152226
- 261, /* (163) idlist_opt ::= LP idlist RP */
152227
- 256, /* (164) idlist ::= idlist COMMA nm */
152228
- 256, /* (165) idlist ::= nm */
152229
- 210, /* (166) expr ::= LP expr RP */
152230
- 210, /* (167) expr ::= ID|INDEXED */
152231
- 210, /* (168) expr ::= JOIN_KW */
152232
- 210, /* (169) expr ::= nm DOT nm */
152233
- 210, /* (170) expr ::= nm DOT nm DOT nm */
152234
- 209, /* (171) term ::= NULL|FLOAT|BLOB */
152235
- 209, /* (172) term ::= STRING */
152236
- 209, /* (173) term ::= INTEGER */
152237
- 210, /* (174) expr ::= VARIABLE */
152238
- 210, /* (175) expr ::= expr COLLATE ID|STRING */
152239
- 210, /* (176) expr ::= CAST LP expr AS typetoken RP */
152240
- 210, /* (177) expr ::= ID|INDEXED LP distinct exprlist RP */
152241
- 210, /* (178) expr ::= ID|INDEXED LP STAR RP */
152242
- 210, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
152243
- 210, /* (180) expr ::= ID|INDEXED LP STAR RP filter_over */
152244
- 209, /* (181) term ::= CTIME_KW */
152245
- 210, /* (182) expr ::= LP nexprlist COMMA expr RP */
152246
- 210, /* (183) expr ::= expr AND expr */
152247
- 210, /* (184) expr ::= expr OR expr */
152248
- 210, /* (185) expr ::= expr LT|GT|GE|LE expr */
152249
- 210, /* (186) expr ::= expr EQ|NE expr */
152250
- 210, /* (187) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
152251
- 210, /* (188) expr ::= expr PLUS|MINUS expr */
152252
- 210, /* (189) expr ::= expr STAR|SLASH|REM expr */
152253
- 210, /* (190) expr ::= expr CONCAT expr */
152254
- 264, /* (191) likeop ::= NOT LIKE_KW|MATCH */
152255
- 210, /* (192) expr ::= expr likeop expr */
152256
- 210, /* (193) expr ::= expr likeop expr ESCAPE expr */
152257
- 210, /* (194) expr ::= expr ISNULL|NOTNULL */
152258
- 210, /* (195) expr ::= expr NOT NULL */
152259
- 210, /* (196) expr ::= expr IS expr */
152260
- 210, /* (197) expr ::= expr IS NOT expr */
152261
- 210, /* (198) expr ::= NOT expr */
152262
- 210, /* (199) expr ::= BITNOT expr */
152263
- 210, /* (200) expr ::= PLUS|MINUS expr */
152264
- 265, /* (201) between_op ::= BETWEEN */
152265
- 265, /* (202) between_op ::= NOT BETWEEN */
152266
- 210, /* (203) expr ::= expr between_op expr AND expr */
152267
- 266, /* (204) in_op ::= IN */
152268
- 266, /* (205) in_op ::= NOT IN */
152269
- 210, /* (206) expr ::= expr in_op LP exprlist RP */
152270
- 210, /* (207) expr ::= LP select RP */
152271
- 210, /* (208) expr ::= expr in_op LP select RP */
152272
- 210, /* (209) expr ::= expr in_op nm dbnm paren_exprlist */
152273
- 210, /* (210) expr ::= EXISTS LP select RP */
152274
- 210, /* (211) expr ::= CASE case_operand case_exprlist case_else END */
152275
- 269, /* (212) case_exprlist ::= case_exprlist WHEN expr THEN expr */
152276
- 269, /* (213) case_exprlist ::= WHEN expr THEN expr */
152277
- 270, /* (214) case_else ::= ELSE expr */
152278
- 270, /* (215) case_else ::= */
152279
- 268, /* (216) case_operand ::= expr */
152280
- 268, /* (217) case_operand ::= */
152281
- 254, /* (218) exprlist ::= */
152282
- 245, /* (219) nexprlist ::= nexprlist COMMA expr */
152283
- 245, /* (220) nexprlist ::= expr */
152284
- 267, /* (221) paren_exprlist ::= */
152285
- 267, /* (222) paren_exprlist ::= LP exprlist RP */
152286
- 184, /* (223) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
152287
- 271, /* (224) uniqueflag ::= UNIQUE */
152288
- 271, /* (225) uniqueflag ::= */
152289
- 214, /* (226) eidlist_opt ::= */
152290
- 214, /* (227) eidlist_opt ::= LP eidlist RP */
152291
- 224, /* (228) eidlist ::= eidlist COMMA nm collate sortorder */
152292
- 224, /* (229) eidlist ::= nm collate sortorder */
152293
- 272, /* (230) collate ::= */
152294
- 272, /* (231) collate ::= COLLATE ID|STRING */
152295
- 184, /* (232) cmd ::= DROP INDEX ifexists fullname */
152296
- 184, /* (233) cmd ::= VACUUM vinto */
152297
- 184, /* (234) cmd ::= VACUUM nm vinto */
152298
- 273, /* (235) vinto ::= INTO expr */
152299
- 273, /* (236) vinto ::= */
152300
- 184, /* (237) cmd ::= PRAGMA nm dbnm */
152301
- 184, /* (238) cmd ::= PRAGMA nm dbnm EQ nmnum */
152302
- 184, /* (239) cmd ::= PRAGMA nm dbnm LP nmnum RP */
152303
- 184, /* (240) cmd ::= PRAGMA nm dbnm EQ minus_num */
152304
- 184, /* (241) cmd ::= PRAGMA nm dbnm LP minus_num RP */
152305
- 204, /* (242) plus_num ::= PLUS INTEGER|FLOAT */
152306
- 205, /* (243) minus_num ::= MINUS INTEGER|FLOAT */
152307
- 184, /* (244) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
152308
- 275, /* (245) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
152309
- 277, /* (246) trigger_time ::= BEFORE|AFTER */
152310
- 277, /* (247) trigger_time ::= INSTEAD OF */
152311
- 277, /* (248) trigger_time ::= */
152312
- 278, /* (249) trigger_event ::= DELETE|INSERT */
152313
- 278, /* (250) trigger_event ::= UPDATE */
152314
- 278, /* (251) trigger_event ::= UPDATE OF idlist */
152315
- 280, /* (252) when_clause ::= */
152316
- 280, /* (253) when_clause ::= WHEN expr */
152317
- 276, /* (254) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
152318
- 276, /* (255) trigger_cmd_list ::= trigger_cmd SEMI */
152319
- 282, /* (256) trnm ::= nm DOT nm */
152320
- 283, /* (257) tridxby ::= INDEXED BY nm */
152321
- 283, /* (258) tridxby ::= NOT INDEXED */
152322
- 281, /* (259) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
152323
- 281, /* (260) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
152324
- 281, /* (261) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
152325
- 281, /* (262) trigger_cmd ::= scanpt select scanpt */
152326
- 210, /* (263) expr ::= RAISE LP IGNORE RP */
152327
- 210, /* (264) expr ::= RAISE LP raisetype COMMA nm RP */
152328
- 228, /* (265) raisetype ::= ROLLBACK */
152329
- 228, /* (266) raisetype ::= ABORT */
152330
- 228, /* (267) raisetype ::= FAIL */
152331
- 184, /* (268) cmd ::= DROP TRIGGER ifexists fullname */
152332
- 184, /* (269) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
152333
- 184, /* (270) cmd ::= DETACH database_kw_opt expr */
152334
- 285, /* (271) key_opt ::= */
152335
- 285, /* (272) key_opt ::= KEY expr */
152336
- 184, /* (273) cmd ::= REINDEX */
152337
- 184, /* (274) cmd ::= REINDEX nm dbnm */
152338
- 184, /* (275) cmd ::= ANALYZE */
152339
- 184, /* (276) cmd ::= ANALYZE nm dbnm */
152340
- 184, /* (277) cmd ::= ALTER TABLE fullname RENAME TO nm */
152341
- 184, /* (278) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
152342
- 286, /* (279) add_column_fullname ::= fullname */
152343
- 184, /* (280) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
152344
- 184, /* (281) cmd ::= create_vtab */
152345
- 184, /* (282) cmd ::= create_vtab LP vtabarglist RP */
152346
- 288, /* (283) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
152347
- 290, /* (284) vtabarg ::= */
152348
- 291, /* (285) vtabargtoken ::= ANY */
152349
- 291, /* (286) vtabargtoken ::= lp anylist RP */
152350
- 292, /* (287) lp ::= LP */
152351
- 258, /* (288) with ::= WITH wqlist */
152352
- 258, /* (289) with ::= WITH RECURSIVE wqlist */
152353
- 233, /* (290) wqlist ::= nm eidlist_opt AS LP select RP */
152354
- 233, /* (291) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
152355
- 294, /* (292) windowdefn_list ::= windowdefn */
152356
- 294, /* (293) windowdefn_list ::= windowdefn_list COMMA windowdefn */
152357
- 295, /* (294) windowdefn ::= nm AS LP window RP */
152358
- 296, /* (295) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
152359
- 296, /* (296) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
152360
- 296, /* (297) window ::= ORDER BY sortlist frame_opt */
152361
- 296, /* (298) window ::= nm ORDER BY sortlist frame_opt */
152362
- 296, /* (299) window ::= frame_opt */
152363
- 296, /* (300) window ::= nm frame_opt */
152364
- 297, /* (301) frame_opt ::= */
152365
- 297, /* (302) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
152366
- 297, /* (303) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
152367
- 301, /* (304) range_or_rows ::= RANGE|ROWS|GROUPS */
152368
- 303, /* (305) frame_bound_s ::= frame_bound */
152369
- 303, /* (306) frame_bound_s ::= UNBOUNDED PRECEDING */
152370
- 304, /* (307) frame_bound_e ::= frame_bound */
152371
- 304, /* (308) frame_bound_e ::= UNBOUNDED FOLLOWING */
152372
- 302, /* (309) frame_bound ::= expr PRECEDING|FOLLOWING */
152373
- 302, /* (310) frame_bound ::= CURRENT ROW */
152374
- 305, /* (311) frame_exclude_opt ::= */
152375
- 305, /* (312) frame_exclude_opt ::= EXCLUDE frame_exclude */
152376
- 306, /* (313) frame_exclude ::= NO OTHERS */
152377
- 306, /* (314) frame_exclude ::= CURRENT ROW */
152378
- 306, /* (315) frame_exclude ::= GROUP|TIES */
152379
- 243, /* (316) window_clause ::= WINDOW windowdefn_list */
152380
- 263, /* (317) filter_over ::= filter_clause over_clause */
152381
- 263, /* (318) filter_over ::= over_clause */
152382
- 263, /* (319) filter_over ::= filter_clause */
152383
- 300, /* (320) over_clause ::= OVER LP window RP */
152384
- 300, /* (321) over_clause ::= OVER nm */
152385
- 299, /* (322) filter_clause ::= FILTER LP WHERE expr RP */
152386
- 179, /* (323) input ::= cmdlist */
152387
- 180, /* (324) cmdlist ::= cmdlist ecmd */
152388
- 180, /* (325) cmdlist ::= ecmd */
152389
- 181, /* (326) ecmd ::= SEMI */
152390
- 181, /* (327) ecmd ::= cmdx SEMI */
152391
- 181, /* (328) ecmd ::= explain cmdx */
152392
- 186, /* (329) trans_opt ::= */
152393
- 186, /* (330) trans_opt ::= TRANSACTION */
152394
- 186, /* (331) trans_opt ::= TRANSACTION nm */
152395
- 188, /* (332) savepoint_opt ::= SAVEPOINT */
152396
- 188, /* (333) savepoint_opt ::= */
152397
- 184, /* (334) cmd ::= create_table create_table_args */
152398
- 195, /* (335) columnlist ::= columnlist COMMA columnname carglist */
152399
- 195, /* (336) columnlist ::= columnname carglist */
152400
- 187, /* (337) nm ::= ID|INDEXED */
152401
- 187, /* (338) nm ::= STRING */
152402
- 187, /* (339) nm ::= JOIN_KW */
152403
- 201, /* (340) typetoken ::= typename */
152404
- 202, /* (341) typename ::= ID|STRING */
152405
- 203, /* (342) signed ::= plus_num */
152406
- 203, /* (343) signed ::= minus_num */
152407
- 200, /* (344) carglist ::= carglist ccons */
152408
- 200, /* (345) carglist ::= */
152409
- 208, /* (346) ccons ::= NULL onconf */
152410
- 196, /* (347) conslist_opt ::= COMMA conslist */
152411
- 220, /* (348) conslist ::= conslist tconscomma tcons */
152412
- 220, /* (349) conslist ::= tcons */
152413
- 221, /* (350) tconscomma ::= */
152414
- 225, /* (351) defer_subclause_opt ::= defer_subclause */
152415
- 227, /* (352) resolvetype ::= raisetype */
152416
- 231, /* (353) selectnowith ::= oneselect */
152417
- 232, /* (354) oneselect ::= values */
152418
- 246, /* (355) sclp ::= selcollist COMMA */
152419
- 247, /* (356) as ::= ID|STRING */
152420
- 210, /* (357) expr ::= term */
152421
- 264, /* (358) likeop ::= LIKE_KW|MATCH */
152422
- 254, /* (359) exprlist ::= nexprlist */
152423
- 274, /* (360) nmnum ::= plus_num */
152424
- 274, /* (361) nmnum ::= nm */
152425
- 274, /* (362) nmnum ::= ON */
152426
- 274, /* (363) nmnum ::= DELETE */
152427
- 274, /* (364) nmnum ::= DEFAULT */
152428
- 204, /* (365) plus_num ::= INTEGER|FLOAT */
152429
- 279, /* (366) foreach_clause ::= */
152430
- 279, /* (367) foreach_clause ::= FOR EACH ROW */
152431
- 282, /* (368) trnm ::= nm */
152432
- 283, /* (369) tridxby ::= */
152433
- 284, /* (370) database_kw_opt ::= DATABASE */
152434
- 284, /* (371) database_kw_opt ::= */
152435
- 287, /* (372) kwcolumn_opt ::= */
152436
- 287, /* (373) kwcolumn_opt ::= COLUMNKW */
152437
- 289, /* (374) vtabarglist ::= vtabarg */
152438
- 289, /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */
152439
- 290, /* (376) vtabarg ::= vtabarg vtabargtoken */
152440
- 293, /* (377) anylist ::= */
152441
- 293, /* (378) anylist ::= anylist LP anylist RP */
152442
- 293, /* (379) anylist ::= anylist ANY */
152443
- 258, /* (380) with ::= */
153186
+ 185, /* (0) explain ::= EXPLAIN */
153187
+ 185, /* (1) explain ::= EXPLAIN QUERY PLAN */
153188
+ 184, /* (2) cmdx ::= cmd */
153189
+ 186, /* (3) cmd ::= BEGIN transtype trans_opt */
153190
+ 187, /* (4) transtype ::= */
153191
+ 187, /* (5) transtype ::= DEFERRED */
153192
+ 187, /* (6) transtype ::= IMMEDIATE */
153193
+ 187, /* (7) transtype ::= EXCLUSIVE */
153194
+ 186, /* (8) cmd ::= COMMIT|END trans_opt */
153195
+ 186, /* (9) cmd ::= ROLLBACK trans_opt */
153196
+ 186, /* (10) cmd ::= SAVEPOINT nm */
153197
+ 186, /* (11) cmd ::= RELEASE savepoint_opt nm */
153198
+ 186, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
153199
+ 191, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
153200
+ 193, /* (14) createkw ::= CREATE */
153201
+ 195, /* (15) ifnotexists ::= */
153202
+ 195, /* (16) ifnotexists ::= IF NOT EXISTS */
153203
+ 194, /* (17) temp ::= TEMP */
153204
+ 194, /* (18) temp ::= */
153205
+ 192, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
153206
+ 192, /* (20) create_table_args ::= AS select */
153207
+ 199, /* (21) table_options ::= */
153208
+ 199, /* (22) table_options ::= WITHOUT nm */
153209
+ 201, /* (23) columnname ::= nm typetoken */
153210
+ 203, /* (24) typetoken ::= */
153211
+ 203, /* (25) typetoken ::= typename LP signed RP */
153212
+ 203, /* (26) typetoken ::= typename LP signed COMMA signed RP */
153213
+ 204, /* (27) typename ::= typename ID|STRING */
153214
+ 208, /* (28) scanpt ::= */
153215
+ 209, /* (29) scantok ::= */
153216
+ 210, /* (30) ccons ::= CONSTRAINT nm */
153217
+ 210, /* (31) ccons ::= DEFAULT scantok term */
153218
+ 210, /* (32) ccons ::= DEFAULT LP expr RP */
153219
+ 210, /* (33) ccons ::= DEFAULT PLUS scantok term */
153220
+ 210, /* (34) ccons ::= DEFAULT MINUS scantok term */
153221
+ 210, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
153222
+ 210, /* (36) ccons ::= NOT NULL onconf */
153223
+ 210, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
153224
+ 210, /* (38) ccons ::= UNIQUE onconf */
153225
+ 210, /* (39) ccons ::= CHECK LP expr RP */
153226
+ 210, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
153227
+ 210, /* (41) ccons ::= defer_subclause */
153228
+ 210, /* (42) ccons ::= COLLATE ID|STRING */
153229
+ 219, /* (43) generated ::= LP expr RP */
153230
+ 219, /* (44) generated ::= LP expr RP ID */
153231
+ 215, /* (45) autoinc ::= */
153232
+ 215, /* (46) autoinc ::= AUTOINCR */
153233
+ 217, /* (47) refargs ::= */
153234
+ 217, /* (48) refargs ::= refargs refarg */
153235
+ 220, /* (49) refarg ::= MATCH nm */
153236
+ 220, /* (50) refarg ::= ON INSERT refact */
153237
+ 220, /* (51) refarg ::= ON DELETE refact */
153238
+ 220, /* (52) refarg ::= ON UPDATE refact */
153239
+ 221, /* (53) refact ::= SET NULL */
153240
+ 221, /* (54) refact ::= SET DEFAULT */
153241
+ 221, /* (55) refact ::= CASCADE */
153242
+ 221, /* (56) refact ::= RESTRICT */
153243
+ 221, /* (57) refact ::= NO ACTION */
153244
+ 218, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
153245
+ 218, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
153246
+ 222, /* (60) init_deferred_pred_opt ::= */
153247
+ 222, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */
153248
+ 222, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
153249
+ 198, /* (63) conslist_opt ::= */
153250
+ 224, /* (64) tconscomma ::= COMMA */
153251
+ 225, /* (65) tcons ::= CONSTRAINT nm */
153252
+ 225, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
153253
+ 225, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */
153254
+ 225, /* (68) tcons ::= CHECK LP expr RP onconf */
153255
+ 225, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
153256
+ 228, /* (70) defer_subclause_opt ::= */
153257
+ 213, /* (71) onconf ::= */
153258
+ 213, /* (72) onconf ::= ON CONFLICT resolvetype */
153259
+ 229, /* (73) orconf ::= */
153260
+ 229, /* (74) orconf ::= OR resolvetype */
153261
+ 230, /* (75) resolvetype ::= IGNORE */
153262
+ 230, /* (76) resolvetype ::= REPLACE */
153263
+ 186, /* (77) cmd ::= DROP TABLE ifexists fullname */
153264
+ 232, /* (78) ifexists ::= IF EXISTS */
153265
+ 232, /* (79) ifexists ::= */
153266
+ 186, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
153267
+ 186, /* (81) cmd ::= DROP VIEW ifexists fullname */
153268
+ 186, /* (82) cmd ::= select */
153269
+ 200, /* (83) select ::= WITH wqlist selectnowith */
153270
+ 200, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */
153271
+ 200, /* (85) select ::= selectnowith */
153272
+ 234, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */
153273
+ 237, /* (87) multiselect_op ::= UNION */
153274
+ 237, /* (88) multiselect_op ::= UNION ALL */
153275
+ 237, /* (89) multiselect_op ::= EXCEPT|INTERSECT */
153276
+ 235, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
153277
+ 235, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
153278
+ 247, /* (92) values ::= VALUES LP nexprlist RP */
153279
+ 247, /* (93) values ::= values COMMA LP nexprlist RP */
153280
+ 238, /* (94) distinct ::= DISTINCT */
153281
+ 238, /* (95) distinct ::= ALL */
153282
+ 238, /* (96) distinct ::= */
153283
+ 249, /* (97) sclp ::= */
153284
+ 239, /* (98) selcollist ::= sclp scanpt expr scanpt as */
153285
+ 239, /* (99) selcollist ::= sclp scanpt STAR */
153286
+ 239, /* (100) selcollist ::= sclp scanpt nm DOT STAR */
153287
+ 250, /* (101) as ::= AS nm */
153288
+ 250, /* (102) as ::= */
153289
+ 240, /* (103) from ::= */
153290
+ 240, /* (104) from ::= FROM seltablist */
153291
+ 252, /* (105) stl_prefix ::= seltablist joinop */
153292
+ 252, /* (106) stl_prefix ::= */
153293
+ 251, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
153294
+ 251, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
153295
+ 251, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
153296
+ 251, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
153297
+ 196, /* (111) dbnm ::= */
153298
+ 196, /* (112) dbnm ::= DOT nm */
153299
+ 233, /* (113) fullname ::= nm */
153300
+ 233, /* (114) fullname ::= nm DOT nm */
153301
+ 258, /* (115) xfullname ::= nm */
153302
+ 258, /* (116) xfullname ::= nm DOT nm */
153303
+ 258, /* (117) xfullname ::= nm DOT nm AS nm */
153304
+ 258, /* (118) xfullname ::= nm AS nm */
153305
+ 253, /* (119) joinop ::= COMMA|JOIN */
153306
+ 253, /* (120) joinop ::= JOIN_KW JOIN */
153307
+ 253, /* (121) joinop ::= JOIN_KW nm JOIN */
153308
+ 253, /* (122) joinop ::= JOIN_KW nm nm JOIN */
153309
+ 255, /* (123) on_opt ::= ON expr */
153310
+ 255, /* (124) on_opt ::= */
153311
+ 254, /* (125) indexed_opt ::= */
153312
+ 254, /* (126) indexed_opt ::= INDEXED BY nm */
153313
+ 254, /* (127) indexed_opt ::= NOT INDEXED */
153314
+ 256, /* (128) using_opt ::= USING LP idlist RP */
153315
+ 256, /* (129) using_opt ::= */
153316
+ 244, /* (130) orderby_opt ::= */
153317
+ 244, /* (131) orderby_opt ::= ORDER BY sortlist */
153318
+ 226, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */
153319
+ 226, /* (133) sortlist ::= expr sortorder nulls */
153320
+ 214, /* (134) sortorder ::= ASC */
153321
+ 214, /* (135) sortorder ::= DESC */
153322
+ 214, /* (136) sortorder ::= */
153323
+ 260, /* (137) nulls ::= NULLS FIRST */
153324
+ 260, /* (138) nulls ::= NULLS LAST */
153325
+ 260, /* (139) nulls ::= */
153326
+ 242, /* (140) groupby_opt ::= */
153327
+ 242, /* (141) groupby_opt ::= GROUP BY nexprlist */
153328
+ 243, /* (142) having_opt ::= */
153329
+ 243, /* (143) having_opt ::= HAVING expr */
153330
+ 245, /* (144) limit_opt ::= */
153331
+ 245, /* (145) limit_opt ::= LIMIT expr */
153332
+ 245, /* (146) limit_opt ::= LIMIT expr OFFSET expr */
153333
+ 245, /* (147) limit_opt ::= LIMIT expr COMMA expr */
153334
+ 186, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
153335
+ 241, /* (149) where_opt ::= */
153336
+ 241, /* (150) where_opt ::= WHERE expr */
153337
+ 186, /* (151) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
153338
+ 262, /* (152) setlist ::= setlist COMMA nm EQ expr */
153339
+ 262, /* (153) setlist ::= setlist COMMA LP idlist RP EQ expr */
153340
+ 262, /* (154) setlist ::= nm EQ expr */
153341
+ 262, /* (155) setlist ::= LP idlist RP EQ expr */
153342
+ 186, /* (156) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
153343
+ 186, /* (157) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
153344
+ 265, /* (158) upsert ::= */
153345
+ 265, /* (159) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
153346
+ 265, /* (160) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
153347
+ 265, /* (161) upsert ::= ON CONFLICT DO NOTHING */
153348
+ 263, /* (162) insert_cmd ::= INSERT orconf */
153349
+ 263, /* (163) insert_cmd ::= REPLACE */
153350
+ 264, /* (164) idlist_opt ::= */
153351
+ 264, /* (165) idlist_opt ::= LP idlist RP */
153352
+ 259, /* (166) idlist ::= idlist COMMA nm */
153353
+ 259, /* (167) idlist ::= nm */
153354
+ 212, /* (168) expr ::= LP expr RP */
153355
+ 212, /* (169) expr ::= ID|INDEXED */
153356
+ 212, /* (170) expr ::= JOIN_KW */
153357
+ 212, /* (171) expr ::= nm DOT nm */
153358
+ 212, /* (172) expr ::= nm DOT nm DOT nm */
153359
+ 211, /* (173) term ::= NULL|FLOAT|BLOB */
153360
+ 211, /* (174) term ::= STRING */
153361
+ 211, /* (175) term ::= INTEGER */
153362
+ 212, /* (176) expr ::= VARIABLE */
153363
+ 212, /* (177) expr ::= expr COLLATE ID|STRING */
153364
+ 212, /* (178) expr ::= CAST LP expr AS typetoken RP */
153365
+ 212, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP */
153366
+ 212, /* (180) expr ::= ID|INDEXED LP STAR RP */
153367
+ 212, /* (181) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
153368
+ 212, /* (182) expr ::= ID|INDEXED LP STAR RP filter_over */
153369
+ 211, /* (183) term ::= CTIME_KW */
153370
+ 212, /* (184) expr ::= LP nexprlist COMMA expr RP */
153371
+ 212, /* (185) expr ::= expr AND expr */
153372
+ 212, /* (186) expr ::= expr OR expr */
153373
+ 212, /* (187) expr ::= expr LT|GT|GE|LE expr */
153374
+ 212, /* (188) expr ::= expr EQ|NE expr */
153375
+ 212, /* (189) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
153376
+ 212, /* (190) expr ::= expr PLUS|MINUS expr */
153377
+ 212, /* (191) expr ::= expr STAR|SLASH|REM expr */
153378
+ 212, /* (192) expr ::= expr CONCAT expr */
153379
+ 267, /* (193) likeop ::= NOT LIKE_KW|MATCH */
153380
+ 212, /* (194) expr ::= expr likeop expr */
153381
+ 212, /* (195) expr ::= expr likeop expr ESCAPE expr */
153382
+ 212, /* (196) expr ::= expr ISNULL|NOTNULL */
153383
+ 212, /* (197) expr ::= expr NOT NULL */
153384
+ 212, /* (198) expr ::= expr IS expr */
153385
+ 212, /* (199) expr ::= expr IS NOT expr */
153386
+ 212, /* (200) expr ::= NOT expr */
153387
+ 212, /* (201) expr ::= BITNOT expr */
153388
+ 212, /* (202) expr ::= PLUS|MINUS expr */
153389
+ 268, /* (203) between_op ::= BETWEEN */
153390
+ 268, /* (204) between_op ::= NOT BETWEEN */
153391
+ 212, /* (205) expr ::= expr between_op expr AND expr */
153392
+ 269, /* (206) in_op ::= IN */
153393
+ 269, /* (207) in_op ::= NOT IN */
153394
+ 212, /* (208) expr ::= expr in_op LP exprlist RP */
153395
+ 212, /* (209) expr ::= LP select RP */
153396
+ 212, /* (210) expr ::= expr in_op LP select RP */
153397
+ 212, /* (211) expr ::= expr in_op nm dbnm paren_exprlist */
153398
+ 212, /* (212) expr ::= EXISTS LP select RP */
153399
+ 212, /* (213) expr ::= CASE case_operand case_exprlist case_else END */
153400
+ 272, /* (214) case_exprlist ::= case_exprlist WHEN expr THEN expr */
153401
+ 272, /* (215) case_exprlist ::= WHEN expr THEN expr */
153402
+ 273, /* (216) case_else ::= ELSE expr */
153403
+ 273, /* (217) case_else ::= */
153404
+ 271, /* (218) case_operand ::= expr */
153405
+ 271, /* (219) case_operand ::= */
153406
+ 257, /* (220) exprlist ::= */
153407
+ 248, /* (221) nexprlist ::= nexprlist COMMA expr */
153408
+ 248, /* (222) nexprlist ::= expr */
153409
+ 270, /* (223) paren_exprlist ::= */
153410
+ 270, /* (224) paren_exprlist ::= LP exprlist RP */
153411
+ 186, /* (225) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
153412
+ 274, /* (226) uniqueflag ::= UNIQUE */
153413
+ 274, /* (227) uniqueflag ::= */
153414
+ 216, /* (228) eidlist_opt ::= */
153415
+ 216, /* (229) eidlist_opt ::= LP eidlist RP */
153416
+ 227, /* (230) eidlist ::= eidlist COMMA nm collate sortorder */
153417
+ 227, /* (231) eidlist ::= nm collate sortorder */
153418
+ 275, /* (232) collate ::= */
153419
+ 275, /* (233) collate ::= COLLATE ID|STRING */
153420
+ 186, /* (234) cmd ::= DROP INDEX ifexists fullname */
153421
+ 186, /* (235) cmd ::= VACUUM vinto */
153422
+ 186, /* (236) cmd ::= VACUUM nm vinto */
153423
+ 276, /* (237) vinto ::= INTO expr */
153424
+ 276, /* (238) vinto ::= */
153425
+ 186, /* (239) cmd ::= PRAGMA nm dbnm */
153426
+ 186, /* (240) cmd ::= PRAGMA nm dbnm EQ nmnum */
153427
+ 186, /* (241) cmd ::= PRAGMA nm dbnm LP nmnum RP */
153428
+ 186, /* (242) cmd ::= PRAGMA nm dbnm EQ minus_num */
153429
+ 186, /* (243) cmd ::= PRAGMA nm dbnm LP minus_num RP */
153430
+ 206, /* (244) plus_num ::= PLUS INTEGER|FLOAT */
153431
+ 207, /* (245) minus_num ::= MINUS INTEGER|FLOAT */
153432
+ 186, /* (246) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
153433
+ 278, /* (247) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
153434
+ 280, /* (248) trigger_time ::= BEFORE|AFTER */
153435
+ 280, /* (249) trigger_time ::= INSTEAD OF */
153436
+ 280, /* (250) trigger_time ::= */
153437
+ 281, /* (251) trigger_event ::= DELETE|INSERT */
153438
+ 281, /* (252) trigger_event ::= UPDATE */
153439
+ 281, /* (253) trigger_event ::= UPDATE OF idlist */
153440
+ 283, /* (254) when_clause ::= */
153441
+ 283, /* (255) when_clause ::= WHEN expr */
153442
+ 279, /* (256) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
153443
+ 279, /* (257) trigger_cmd_list ::= trigger_cmd SEMI */
153444
+ 285, /* (258) trnm ::= nm DOT nm */
153445
+ 286, /* (259) tridxby ::= INDEXED BY nm */
153446
+ 286, /* (260) tridxby ::= NOT INDEXED */
153447
+ 284, /* (261) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
153448
+ 284, /* (262) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
153449
+ 284, /* (263) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
153450
+ 284, /* (264) trigger_cmd ::= scanpt select scanpt */
153451
+ 212, /* (265) expr ::= RAISE LP IGNORE RP */
153452
+ 212, /* (266) expr ::= RAISE LP raisetype COMMA nm RP */
153453
+ 231, /* (267) raisetype ::= ROLLBACK */
153454
+ 231, /* (268) raisetype ::= ABORT */
153455
+ 231, /* (269) raisetype ::= FAIL */
153456
+ 186, /* (270) cmd ::= DROP TRIGGER ifexists fullname */
153457
+ 186, /* (271) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
153458
+ 186, /* (272) cmd ::= DETACH database_kw_opt expr */
153459
+ 288, /* (273) key_opt ::= */
153460
+ 288, /* (274) key_opt ::= KEY expr */
153461
+ 186, /* (275) cmd ::= REINDEX */
153462
+ 186, /* (276) cmd ::= REINDEX nm dbnm */
153463
+ 186, /* (277) cmd ::= ANALYZE */
153464
+ 186, /* (278) cmd ::= ANALYZE nm dbnm */
153465
+ 186, /* (279) cmd ::= ALTER TABLE fullname RENAME TO nm */
153466
+ 186, /* (280) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
153467
+ 289, /* (281) add_column_fullname ::= fullname */
153468
+ 186, /* (282) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
153469
+ 186, /* (283) cmd ::= create_vtab */
153470
+ 186, /* (284) cmd ::= create_vtab LP vtabarglist RP */
153471
+ 291, /* (285) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
153472
+ 293, /* (286) vtabarg ::= */
153473
+ 294, /* (287) vtabargtoken ::= ANY */
153474
+ 294, /* (288) vtabargtoken ::= lp anylist RP */
153475
+ 295, /* (289) lp ::= LP */
153476
+ 261, /* (290) with ::= WITH wqlist */
153477
+ 261, /* (291) with ::= WITH RECURSIVE wqlist */
153478
+ 236, /* (292) wqlist ::= nm eidlist_opt AS LP select RP */
153479
+ 236, /* (293) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
153480
+ 297, /* (294) windowdefn_list ::= windowdefn */
153481
+ 297, /* (295) windowdefn_list ::= windowdefn_list COMMA windowdefn */
153482
+ 298, /* (296) windowdefn ::= nm AS LP window RP */
153483
+ 299, /* (297) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
153484
+ 299, /* (298) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
153485
+ 299, /* (299) window ::= ORDER BY sortlist frame_opt */
153486
+ 299, /* (300) window ::= nm ORDER BY sortlist frame_opt */
153487
+ 299, /* (301) window ::= frame_opt */
153488
+ 299, /* (302) window ::= nm frame_opt */
153489
+ 300, /* (303) frame_opt ::= */
153490
+ 300, /* (304) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
153491
+ 300, /* (305) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
153492
+ 304, /* (306) range_or_rows ::= RANGE|ROWS|GROUPS */
153493
+ 306, /* (307) frame_bound_s ::= frame_bound */
153494
+ 306, /* (308) frame_bound_s ::= UNBOUNDED PRECEDING */
153495
+ 307, /* (309) frame_bound_e ::= frame_bound */
153496
+ 307, /* (310) frame_bound_e ::= UNBOUNDED FOLLOWING */
153497
+ 305, /* (311) frame_bound ::= expr PRECEDING|FOLLOWING */
153498
+ 305, /* (312) frame_bound ::= CURRENT ROW */
153499
+ 308, /* (313) frame_exclude_opt ::= */
153500
+ 308, /* (314) frame_exclude_opt ::= EXCLUDE frame_exclude */
153501
+ 309, /* (315) frame_exclude ::= NO OTHERS */
153502
+ 309, /* (316) frame_exclude ::= CURRENT ROW */
153503
+ 309, /* (317) frame_exclude ::= GROUP|TIES */
153504
+ 246, /* (318) window_clause ::= WINDOW windowdefn_list */
153505
+ 266, /* (319) filter_over ::= filter_clause over_clause */
153506
+ 266, /* (320) filter_over ::= over_clause */
153507
+ 266, /* (321) filter_over ::= filter_clause */
153508
+ 303, /* (322) over_clause ::= OVER LP window RP */
153509
+ 303, /* (323) over_clause ::= OVER nm */
153510
+ 302, /* (324) filter_clause ::= FILTER LP WHERE expr RP */
153511
+ 181, /* (325) input ::= cmdlist */
153512
+ 182, /* (326) cmdlist ::= cmdlist ecmd */
153513
+ 182, /* (327) cmdlist ::= ecmd */
153514
+ 183, /* (328) ecmd ::= SEMI */
153515
+ 183, /* (329) ecmd ::= cmdx SEMI */
153516
+ 183, /* (330) ecmd ::= explain cmdx */
153517
+ 188, /* (331) trans_opt ::= */
153518
+ 188, /* (332) trans_opt ::= TRANSACTION */
153519
+ 188, /* (333) trans_opt ::= TRANSACTION nm */
153520
+ 190, /* (334) savepoint_opt ::= SAVEPOINT */
153521
+ 190, /* (335) savepoint_opt ::= */
153522
+ 186, /* (336) cmd ::= create_table create_table_args */
153523
+ 197, /* (337) columnlist ::= columnlist COMMA columnname carglist */
153524
+ 197, /* (338) columnlist ::= columnname carglist */
153525
+ 189, /* (339) nm ::= ID|INDEXED */
153526
+ 189, /* (340) nm ::= STRING */
153527
+ 189, /* (341) nm ::= JOIN_KW */
153528
+ 203, /* (342) typetoken ::= typename */
153529
+ 204, /* (343) typename ::= ID|STRING */
153530
+ 205, /* (344) signed ::= plus_num */
153531
+ 205, /* (345) signed ::= minus_num */
153532
+ 202, /* (346) carglist ::= carglist ccons */
153533
+ 202, /* (347) carglist ::= */
153534
+ 210, /* (348) ccons ::= NULL onconf */
153535
+ 210, /* (349) ccons ::= GENERATED ALWAYS AS generated */
153536
+ 210, /* (350) ccons ::= AS generated */
153537
+ 198, /* (351) conslist_opt ::= COMMA conslist */
153538
+ 223, /* (352) conslist ::= conslist tconscomma tcons */
153539
+ 223, /* (353) conslist ::= tcons */
153540
+ 224, /* (354) tconscomma ::= */
153541
+ 228, /* (355) defer_subclause_opt ::= defer_subclause */
153542
+ 230, /* (356) resolvetype ::= raisetype */
153543
+ 234, /* (357) selectnowith ::= oneselect */
153544
+ 235, /* (358) oneselect ::= values */
153545
+ 249, /* (359) sclp ::= selcollist COMMA */
153546
+ 250, /* (360) as ::= ID|STRING */
153547
+ 212, /* (361) expr ::= term */
153548
+ 267, /* (362) likeop ::= LIKE_KW|MATCH */
153549
+ 257, /* (363) exprlist ::= nexprlist */
153550
+ 277, /* (364) nmnum ::= plus_num */
153551
+ 277, /* (365) nmnum ::= nm */
153552
+ 277, /* (366) nmnum ::= ON */
153553
+ 277, /* (367) nmnum ::= DELETE */
153554
+ 277, /* (368) nmnum ::= DEFAULT */
153555
+ 206, /* (369) plus_num ::= INTEGER|FLOAT */
153556
+ 282, /* (370) foreach_clause ::= */
153557
+ 282, /* (371) foreach_clause ::= FOR EACH ROW */
153558
+ 285, /* (372) trnm ::= nm */
153559
+ 286, /* (373) tridxby ::= */
153560
+ 287, /* (374) database_kw_opt ::= DATABASE */
153561
+ 287, /* (375) database_kw_opt ::= */
153562
+ 290, /* (376) kwcolumn_opt ::= */
153563
+ 290, /* (377) kwcolumn_opt ::= COLUMNKW */
153564
+ 292, /* (378) vtabarglist ::= vtabarg */
153565
+ 292, /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */
153566
+ 293, /* (380) vtabarg ::= vtabarg vtabargtoken */
153567
+ 296, /* (381) anylist ::= */
153568
+ 296, /* (382) anylist ::= anylist LP anylist RP */
153569
+ 296, /* (383) anylist ::= anylist ANY */
153570
+ 261, /* (384) with ::= */
152444153571
};
152445153572
152446153573
/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
152447153574
** of symbols on the right-hand side of that rule. */
152448153575
static const signed char yyRuleInfoNRhs[] = {
@@ -152487,348 +153614,352 @@
152487153614
-2, /* (38) ccons ::= UNIQUE onconf */
152488153615
-4, /* (39) ccons ::= CHECK LP expr RP */
152489153616
-4, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
152490153617
-1, /* (41) ccons ::= defer_subclause */
152491153618
-2, /* (42) ccons ::= COLLATE ID|STRING */
152492
- 0, /* (43) autoinc ::= */
152493
- -1, /* (44) autoinc ::= AUTOINCR */
152494
- 0, /* (45) refargs ::= */
152495
- -2, /* (46) refargs ::= refargs refarg */
152496
- -2, /* (47) refarg ::= MATCH nm */
152497
- -3, /* (48) refarg ::= ON INSERT refact */
152498
- -3, /* (49) refarg ::= ON DELETE refact */
152499
- -3, /* (50) refarg ::= ON UPDATE refact */
152500
- -2, /* (51) refact ::= SET NULL */
152501
- -2, /* (52) refact ::= SET DEFAULT */
152502
- -1, /* (53) refact ::= CASCADE */
152503
- -1, /* (54) refact ::= RESTRICT */
152504
- -2, /* (55) refact ::= NO ACTION */
152505
- -3, /* (56) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
152506
- -2, /* (57) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
152507
- 0, /* (58) init_deferred_pred_opt ::= */
152508
- -2, /* (59) init_deferred_pred_opt ::= INITIALLY DEFERRED */
152509
- -2, /* (60) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
152510
- 0, /* (61) conslist_opt ::= */
152511
- -1, /* (62) tconscomma ::= COMMA */
152512
- -2, /* (63) tcons ::= CONSTRAINT nm */
152513
- -7, /* (64) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
152514
- -5, /* (65) tcons ::= UNIQUE LP sortlist RP onconf */
152515
- -5, /* (66) tcons ::= CHECK LP expr RP onconf */
152516
- -10, /* (67) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
152517
- 0, /* (68) defer_subclause_opt ::= */
152518
- 0, /* (69) onconf ::= */
152519
- -3, /* (70) onconf ::= ON CONFLICT resolvetype */
152520
- 0, /* (71) orconf ::= */
152521
- -2, /* (72) orconf ::= OR resolvetype */
152522
- -1, /* (73) resolvetype ::= IGNORE */
152523
- -1, /* (74) resolvetype ::= REPLACE */
152524
- -4, /* (75) cmd ::= DROP TABLE ifexists fullname */
152525
- -2, /* (76) ifexists ::= IF EXISTS */
152526
- 0, /* (77) ifexists ::= */
152527
- -9, /* (78) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
152528
- -4, /* (79) cmd ::= DROP VIEW ifexists fullname */
152529
- -1, /* (80) cmd ::= select */
152530
- -3, /* (81) select ::= WITH wqlist selectnowith */
152531
- -4, /* (82) select ::= WITH RECURSIVE wqlist selectnowith */
152532
- -1, /* (83) select ::= selectnowith */
152533
- -3, /* (84) selectnowith ::= selectnowith multiselect_op oneselect */
152534
- -1, /* (85) multiselect_op ::= UNION */
152535
- -2, /* (86) multiselect_op ::= UNION ALL */
152536
- -1, /* (87) multiselect_op ::= EXCEPT|INTERSECT */
152537
- -9, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
152538
- -10, /* (89) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
152539
- -4, /* (90) values ::= VALUES LP nexprlist RP */
152540
- -5, /* (91) values ::= values COMMA LP nexprlist RP */
152541
- -1, /* (92) distinct ::= DISTINCT */
152542
- -1, /* (93) distinct ::= ALL */
152543
- 0, /* (94) distinct ::= */
152544
- 0, /* (95) sclp ::= */
152545
- -5, /* (96) selcollist ::= sclp scanpt expr scanpt as */
152546
- -3, /* (97) selcollist ::= sclp scanpt STAR */
152547
- -5, /* (98) selcollist ::= sclp scanpt nm DOT STAR */
152548
- -2, /* (99) as ::= AS nm */
152549
- 0, /* (100) as ::= */
152550
- 0, /* (101) from ::= */
152551
- -2, /* (102) from ::= FROM seltablist */
152552
- -2, /* (103) stl_prefix ::= seltablist joinop */
152553
- 0, /* (104) stl_prefix ::= */
152554
- -7, /* (105) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
152555
- -9, /* (106) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
152556
- -7, /* (107) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
152557
- -7, /* (108) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
152558
- 0, /* (109) dbnm ::= */
152559
- -2, /* (110) dbnm ::= DOT nm */
152560
- -1, /* (111) fullname ::= nm */
152561
- -3, /* (112) fullname ::= nm DOT nm */
152562
- -1, /* (113) xfullname ::= nm */
152563
- -3, /* (114) xfullname ::= nm DOT nm */
152564
- -5, /* (115) xfullname ::= nm DOT nm AS nm */
152565
- -3, /* (116) xfullname ::= nm AS nm */
152566
- -1, /* (117) joinop ::= COMMA|JOIN */
152567
- -2, /* (118) joinop ::= JOIN_KW JOIN */
152568
- -3, /* (119) joinop ::= JOIN_KW nm JOIN */
152569
- -4, /* (120) joinop ::= JOIN_KW nm nm JOIN */
152570
- -2, /* (121) on_opt ::= ON expr */
152571
- 0, /* (122) on_opt ::= */
152572
- 0, /* (123) indexed_opt ::= */
152573
- -3, /* (124) indexed_opt ::= INDEXED BY nm */
152574
- -2, /* (125) indexed_opt ::= NOT INDEXED */
152575
- -4, /* (126) using_opt ::= USING LP idlist RP */
152576
- 0, /* (127) using_opt ::= */
152577
- 0, /* (128) orderby_opt ::= */
152578
- -3, /* (129) orderby_opt ::= ORDER BY sortlist */
152579
- -5, /* (130) sortlist ::= sortlist COMMA expr sortorder nulls */
152580
- -3, /* (131) sortlist ::= expr sortorder nulls */
152581
- -1, /* (132) sortorder ::= ASC */
152582
- -1, /* (133) sortorder ::= DESC */
152583
- 0, /* (134) sortorder ::= */
152584
- -2, /* (135) nulls ::= NULLS FIRST */
152585
- -2, /* (136) nulls ::= NULLS LAST */
152586
- 0, /* (137) nulls ::= */
152587
- 0, /* (138) groupby_opt ::= */
152588
- -3, /* (139) groupby_opt ::= GROUP BY nexprlist */
152589
- 0, /* (140) having_opt ::= */
152590
- -2, /* (141) having_opt ::= HAVING expr */
152591
- 0, /* (142) limit_opt ::= */
152592
- -2, /* (143) limit_opt ::= LIMIT expr */
152593
- -4, /* (144) limit_opt ::= LIMIT expr OFFSET expr */
152594
- -4, /* (145) limit_opt ::= LIMIT expr COMMA expr */
152595
- -6, /* (146) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
152596
- 0, /* (147) where_opt ::= */
152597
- -2, /* (148) where_opt ::= WHERE expr */
152598
- -8, /* (149) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
152599
- -5, /* (150) setlist ::= setlist COMMA nm EQ expr */
152600
- -7, /* (151) setlist ::= setlist COMMA LP idlist RP EQ expr */
152601
- -3, /* (152) setlist ::= nm EQ expr */
152602
- -5, /* (153) setlist ::= LP idlist RP EQ expr */
152603
- -7, /* (154) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
152604
- -7, /* (155) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
152605
- 0, /* (156) upsert ::= */
152606
- -11, /* (157) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
152607
- -8, /* (158) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
152608
- -4, /* (159) upsert ::= ON CONFLICT DO NOTHING */
152609
- -2, /* (160) insert_cmd ::= INSERT orconf */
152610
- -1, /* (161) insert_cmd ::= REPLACE */
152611
- 0, /* (162) idlist_opt ::= */
152612
- -3, /* (163) idlist_opt ::= LP idlist RP */
152613
- -3, /* (164) idlist ::= idlist COMMA nm */
152614
- -1, /* (165) idlist ::= nm */
152615
- -3, /* (166) expr ::= LP expr RP */
152616
- -1, /* (167) expr ::= ID|INDEXED */
152617
- -1, /* (168) expr ::= JOIN_KW */
152618
- -3, /* (169) expr ::= nm DOT nm */
152619
- -5, /* (170) expr ::= nm DOT nm DOT nm */
152620
- -1, /* (171) term ::= NULL|FLOAT|BLOB */
152621
- -1, /* (172) term ::= STRING */
152622
- -1, /* (173) term ::= INTEGER */
152623
- -1, /* (174) expr ::= VARIABLE */
152624
- -3, /* (175) expr ::= expr COLLATE ID|STRING */
152625
- -6, /* (176) expr ::= CAST LP expr AS typetoken RP */
152626
- -5, /* (177) expr ::= ID|INDEXED LP distinct exprlist RP */
152627
- -4, /* (178) expr ::= ID|INDEXED LP STAR RP */
152628
- -6, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
152629
- -5, /* (180) expr ::= ID|INDEXED LP STAR RP filter_over */
152630
- -1, /* (181) term ::= CTIME_KW */
152631
- -5, /* (182) expr ::= LP nexprlist COMMA expr RP */
152632
- -3, /* (183) expr ::= expr AND expr */
152633
- -3, /* (184) expr ::= expr OR expr */
152634
- -3, /* (185) expr ::= expr LT|GT|GE|LE expr */
152635
- -3, /* (186) expr ::= expr EQ|NE expr */
152636
- -3, /* (187) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
152637
- -3, /* (188) expr ::= expr PLUS|MINUS expr */
152638
- -3, /* (189) expr ::= expr STAR|SLASH|REM expr */
152639
- -3, /* (190) expr ::= expr CONCAT expr */
152640
- -2, /* (191) likeop ::= NOT LIKE_KW|MATCH */
152641
- -3, /* (192) expr ::= expr likeop expr */
152642
- -5, /* (193) expr ::= expr likeop expr ESCAPE expr */
152643
- -2, /* (194) expr ::= expr ISNULL|NOTNULL */
152644
- -3, /* (195) expr ::= expr NOT NULL */
152645
- -3, /* (196) expr ::= expr IS expr */
152646
- -4, /* (197) expr ::= expr IS NOT expr */
152647
- -2, /* (198) expr ::= NOT expr */
152648
- -2, /* (199) expr ::= BITNOT expr */
152649
- -2, /* (200) expr ::= PLUS|MINUS expr */
152650
- -1, /* (201) between_op ::= BETWEEN */
152651
- -2, /* (202) between_op ::= NOT BETWEEN */
152652
- -5, /* (203) expr ::= expr between_op expr AND expr */
152653
- -1, /* (204) in_op ::= IN */
152654
- -2, /* (205) in_op ::= NOT IN */
152655
- -5, /* (206) expr ::= expr in_op LP exprlist RP */
152656
- -3, /* (207) expr ::= LP select RP */
152657
- -5, /* (208) expr ::= expr in_op LP select RP */
152658
- -5, /* (209) expr ::= expr in_op nm dbnm paren_exprlist */
152659
- -4, /* (210) expr ::= EXISTS LP select RP */
152660
- -5, /* (211) expr ::= CASE case_operand case_exprlist case_else END */
152661
- -5, /* (212) case_exprlist ::= case_exprlist WHEN expr THEN expr */
152662
- -4, /* (213) case_exprlist ::= WHEN expr THEN expr */
152663
- -2, /* (214) case_else ::= ELSE expr */
152664
- 0, /* (215) case_else ::= */
152665
- -1, /* (216) case_operand ::= expr */
152666
- 0, /* (217) case_operand ::= */
152667
- 0, /* (218) exprlist ::= */
152668
- -3, /* (219) nexprlist ::= nexprlist COMMA expr */
152669
- -1, /* (220) nexprlist ::= expr */
152670
- 0, /* (221) paren_exprlist ::= */
152671
- -3, /* (222) paren_exprlist ::= LP exprlist RP */
152672
- -12, /* (223) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
152673
- -1, /* (224) uniqueflag ::= UNIQUE */
152674
- 0, /* (225) uniqueflag ::= */
152675
- 0, /* (226) eidlist_opt ::= */
152676
- -3, /* (227) eidlist_opt ::= LP eidlist RP */
152677
- -5, /* (228) eidlist ::= eidlist COMMA nm collate sortorder */
152678
- -3, /* (229) eidlist ::= nm collate sortorder */
152679
- 0, /* (230) collate ::= */
152680
- -2, /* (231) collate ::= COLLATE ID|STRING */
152681
- -4, /* (232) cmd ::= DROP INDEX ifexists fullname */
152682
- -2, /* (233) cmd ::= VACUUM vinto */
152683
- -3, /* (234) cmd ::= VACUUM nm vinto */
152684
- -2, /* (235) vinto ::= INTO expr */
152685
- 0, /* (236) vinto ::= */
152686
- -3, /* (237) cmd ::= PRAGMA nm dbnm */
152687
- -5, /* (238) cmd ::= PRAGMA nm dbnm EQ nmnum */
152688
- -6, /* (239) cmd ::= PRAGMA nm dbnm LP nmnum RP */
152689
- -5, /* (240) cmd ::= PRAGMA nm dbnm EQ minus_num */
152690
- -6, /* (241) cmd ::= PRAGMA nm dbnm LP minus_num RP */
152691
- -2, /* (242) plus_num ::= PLUS INTEGER|FLOAT */
152692
- -2, /* (243) minus_num ::= MINUS INTEGER|FLOAT */
152693
- -5, /* (244) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
152694
- -11, /* (245) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
152695
- -1, /* (246) trigger_time ::= BEFORE|AFTER */
152696
- -2, /* (247) trigger_time ::= INSTEAD OF */
152697
- 0, /* (248) trigger_time ::= */
152698
- -1, /* (249) trigger_event ::= DELETE|INSERT */
152699
- -1, /* (250) trigger_event ::= UPDATE */
152700
- -3, /* (251) trigger_event ::= UPDATE OF idlist */
152701
- 0, /* (252) when_clause ::= */
152702
- -2, /* (253) when_clause ::= WHEN expr */
152703
- -3, /* (254) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
152704
- -2, /* (255) trigger_cmd_list ::= trigger_cmd SEMI */
152705
- -3, /* (256) trnm ::= nm DOT nm */
152706
- -3, /* (257) tridxby ::= INDEXED BY nm */
152707
- -2, /* (258) tridxby ::= NOT INDEXED */
152708
- -8, /* (259) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
152709
- -8, /* (260) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
152710
- -6, /* (261) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
152711
- -3, /* (262) trigger_cmd ::= scanpt select scanpt */
152712
- -4, /* (263) expr ::= RAISE LP IGNORE RP */
152713
- -6, /* (264) expr ::= RAISE LP raisetype COMMA nm RP */
152714
- -1, /* (265) raisetype ::= ROLLBACK */
152715
- -1, /* (266) raisetype ::= ABORT */
152716
- -1, /* (267) raisetype ::= FAIL */
152717
- -4, /* (268) cmd ::= DROP TRIGGER ifexists fullname */
152718
- -6, /* (269) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
152719
- -3, /* (270) cmd ::= DETACH database_kw_opt expr */
152720
- 0, /* (271) key_opt ::= */
152721
- -2, /* (272) key_opt ::= KEY expr */
152722
- -1, /* (273) cmd ::= REINDEX */
152723
- -3, /* (274) cmd ::= REINDEX nm dbnm */
152724
- -1, /* (275) cmd ::= ANALYZE */
152725
- -3, /* (276) cmd ::= ANALYZE nm dbnm */
152726
- -6, /* (277) cmd ::= ALTER TABLE fullname RENAME TO nm */
152727
- -7, /* (278) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
152728
- -1, /* (279) add_column_fullname ::= fullname */
152729
- -8, /* (280) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
152730
- -1, /* (281) cmd ::= create_vtab */
152731
- -4, /* (282) cmd ::= create_vtab LP vtabarglist RP */
152732
- -8, /* (283) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
152733
- 0, /* (284) vtabarg ::= */
152734
- -1, /* (285) vtabargtoken ::= ANY */
152735
- -3, /* (286) vtabargtoken ::= lp anylist RP */
152736
- -1, /* (287) lp ::= LP */
152737
- -2, /* (288) with ::= WITH wqlist */
152738
- -3, /* (289) with ::= WITH RECURSIVE wqlist */
152739
- -6, /* (290) wqlist ::= nm eidlist_opt AS LP select RP */
152740
- -8, /* (291) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
152741
- -1, /* (292) windowdefn_list ::= windowdefn */
152742
- -3, /* (293) windowdefn_list ::= windowdefn_list COMMA windowdefn */
152743
- -5, /* (294) windowdefn ::= nm AS LP window RP */
152744
- -5, /* (295) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
152745
- -6, /* (296) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
152746
- -4, /* (297) window ::= ORDER BY sortlist frame_opt */
152747
- -5, /* (298) window ::= nm ORDER BY sortlist frame_opt */
152748
- -1, /* (299) window ::= frame_opt */
152749
- -2, /* (300) window ::= nm frame_opt */
152750
- 0, /* (301) frame_opt ::= */
152751
- -3, /* (302) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
152752
- -6, /* (303) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
152753
- -1, /* (304) range_or_rows ::= RANGE|ROWS|GROUPS */
152754
- -1, /* (305) frame_bound_s ::= frame_bound */
152755
- -2, /* (306) frame_bound_s ::= UNBOUNDED PRECEDING */
152756
- -1, /* (307) frame_bound_e ::= frame_bound */
152757
- -2, /* (308) frame_bound_e ::= UNBOUNDED FOLLOWING */
152758
- -2, /* (309) frame_bound ::= expr PRECEDING|FOLLOWING */
152759
- -2, /* (310) frame_bound ::= CURRENT ROW */
152760
- 0, /* (311) frame_exclude_opt ::= */
152761
- -2, /* (312) frame_exclude_opt ::= EXCLUDE frame_exclude */
152762
- -2, /* (313) frame_exclude ::= NO OTHERS */
152763
- -2, /* (314) frame_exclude ::= CURRENT ROW */
152764
- -1, /* (315) frame_exclude ::= GROUP|TIES */
152765
- -2, /* (316) window_clause ::= WINDOW windowdefn_list */
152766
- -2, /* (317) filter_over ::= filter_clause over_clause */
152767
- -1, /* (318) filter_over ::= over_clause */
152768
- -1, /* (319) filter_over ::= filter_clause */
152769
- -4, /* (320) over_clause ::= OVER LP window RP */
152770
- -2, /* (321) over_clause ::= OVER nm */
152771
- -5, /* (322) filter_clause ::= FILTER LP WHERE expr RP */
152772
- -1, /* (323) input ::= cmdlist */
152773
- -2, /* (324) cmdlist ::= cmdlist ecmd */
152774
- -1, /* (325) cmdlist ::= ecmd */
152775
- -1, /* (326) ecmd ::= SEMI */
152776
- -2, /* (327) ecmd ::= cmdx SEMI */
152777
- -2, /* (328) ecmd ::= explain cmdx */
152778
- 0, /* (329) trans_opt ::= */
152779
- -1, /* (330) trans_opt ::= TRANSACTION */
152780
- -2, /* (331) trans_opt ::= TRANSACTION nm */
152781
- -1, /* (332) savepoint_opt ::= SAVEPOINT */
152782
- 0, /* (333) savepoint_opt ::= */
152783
- -2, /* (334) cmd ::= create_table create_table_args */
152784
- -4, /* (335) columnlist ::= columnlist COMMA columnname carglist */
152785
- -2, /* (336) columnlist ::= columnname carglist */
152786
- -1, /* (337) nm ::= ID|INDEXED */
152787
- -1, /* (338) nm ::= STRING */
152788
- -1, /* (339) nm ::= JOIN_KW */
152789
- -1, /* (340) typetoken ::= typename */
152790
- -1, /* (341) typename ::= ID|STRING */
152791
- -1, /* (342) signed ::= plus_num */
152792
- -1, /* (343) signed ::= minus_num */
152793
- -2, /* (344) carglist ::= carglist ccons */
152794
- 0, /* (345) carglist ::= */
152795
- -2, /* (346) ccons ::= NULL onconf */
152796
- -2, /* (347) conslist_opt ::= COMMA conslist */
152797
- -3, /* (348) conslist ::= conslist tconscomma tcons */
152798
- -1, /* (349) conslist ::= tcons */
152799
- 0, /* (350) tconscomma ::= */
152800
- -1, /* (351) defer_subclause_opt ::= defer_subclause */
152801
- -1, /* (352) resolvetype ::= raisetype */
152802
- -1, /* (353) selectnowith ::= oneselect */
152803
- -1, /* (354) oneselect ::= values */
152804
- -2, /* (355) sclp ::= selcollist COMMA */
152805
- -1, /* (356) as ::= ID|STRING */
152806
- -1, /* (357) expr ::= term */
152807
- -1, /* (358) likeop ::= LIKE_KW|MATCH */
152808
- -1, /* (359) exprlist ::= nexprlist */
152809
- -1, /* (360) nmnum ::= plus_num */
152810
- -1, /* (361) nmnum ::= nm */
152811
- -1, /* (362) nmnum ::= ON */
152812
- -1, /* (363) nmnum ::= DELETE */
152813
- -1, /* (364) nmnum ::= DEFAULT */
152814
- -1, /* (365) plus_num ::= INTEGER|FLOAT */
152815
- 0, /* (366) foreach_clause ::= */
152816
- -3, /* (367) foreach_clause ::= FOR EACH ROW */
152817
- -1, /* (368) trnm ::= nm */
152818
- 0, /* (369) tridxby ::= */
152819
- -1, /* (370) database_kw_opt ::= DATABASE */
152820
- 0, /* (371) database_kw_opt ::= */
152821
- 0, /* (372) kwcolumn_opt ::= */
152822
- -1, /* (373) kwcolumn_opt ::= COLUMNKW */
152823
- -1, /* (374) vtabarglist ::= vtabarg */
152824
- -3, /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */
152825
- -2, /* (376) vtabarg ::= vtabarg vtabargtoken */
152826
- 0, /* (377) anylist ::= */
152827
- -4, /* (378) anylist ::= anylist LP anylist RP */
152828
- -2, /* (379) anylist ::= anylist ANY */
152829
- 0, /* (380) with ::= */
153619
+ -3, /* (43) generated ::= LP expr RP */
153620
+ -4, /* (44) generated ::= LP expr RP ID */
153621
+ 0, /* (45) autoinc ::= */
153622
+ -1, /* (46) autoinc ::= AUTOINCR */
153623
+ 0, /* (47) refargs ::= */
153624
+ -2, /* (48) refargs ::= refargs refarg */
153625
+ -2, /* (49) refarg ::= MATCH nm */
153626
+ -3, /* (50) refarg ::= ON INSERT refact */
153627
+ -3, /* (51) refarg ::= ON DELETE refact */
153628
+ -3, /* (52) refarg ::= ON UPDATE refact */
153629
+ -2, /* (53) refact ::= SET NULL */
153630
+ -2, /* (54) refact ::= SET DEFAULT */
153631
+ -1, /* (55) refact ::= CASCADE */
153632
+ -1, /* (56) refact ::= RESTRICT */
153633
+ -2, /* (57) refact ::= NO ACTION */
153634
+ -3, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
153635
+ -2, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
153636
+ 0, /* (60) init_deferred_pred_opt ::= */
153637
+ -2, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */
153638
+ -2, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
153639
+ 0, /* (63) conslist_opt ::= */
153640
+ -1, /* (64) tconscomma ::= COMMA */
153641
+ -2, /* (65) tcons ::= CONSTRAINT nm */
153642
+ -7, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
153643
+ -5, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */
153644
+ -5, /* (68) tcons ::= CHECK LP expr RP onconf */
153645
+ -10, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
153646
+ 0, /* (70) defer_subclause_opt ::= */
153647
+ 0, /* (71) onconf ::= */
153648
+ -3, /* (72) onconf ::= ON CONFLICT resolvetype */
153649
+ 0, /* (73) orconf ::= */
153650
+ -2, /* (74) orconf ::= OR resolvetype */
153651
+ -1, /* (75) resolvetype ::= IGNORE */
153652
+ -1, /* (76) resolvetype ::= REPLACE */
153653
+ -4, /* (77) cmd ::= DROP TABLE ifexists fullname */
153654
+ -2, /* (78) ifexists ::= IF EXISTS */
153655
+ 0, /* (79) ifexists ::= */
153656
+ -9, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
153657
+ -4, /* (81) cmd ::= DROP VIEW ifexists fullname */
153658
+ -1, /* (82) cmd ::= select */
153659
+ -3, /* (83) select ::= WITH wqlist selectnowith */
153660
+ -4, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */
153661
+ -1, /* (85) select ::= selectnowith */
153662
+ -3, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */
153663
+ -1, /* (87) multiselect_op ::= UNION */
153664
+ -2, /* (88) multiselect_op ::= UNION ALL */
153665
+ -1, /* (89) multiselect_op ::= EXCEPT|INTERSECT */
153666
+ -9, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
153667
+ -10, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
153668
+ -4, /* (92) values ::= VALUES LP nexprlist RP */
153669
+ -5, /* (93) values ::= values COMMA LP nexprlist RP */
153670
+ -1, /* (94) distinct ::= DISTINCT */
153671
+ -1, /* (95) distinct ::= ALL */
153672
+ 0, /* (96) distinct ::= */
153673
+ 0, /* (97) sclp ::= */
153674
+ -5, /* (98) selcollist ::= sclp scanpt expr scanpt as */
153675
+ -3, /* (99) selcollist ::= sclp scanpt STAR */
153676
+ -5, /* (100) selcollist ::= sclp scanpt nm DOT STAR */
153677
+ -2, /* (101) as ::= AS nm */
153678
+ 0, /* (102) as ::= */
153679
+ 0, /* (103) from ::= */
153680
+ -2, /* (104) from ::= FROM seltablist */
153681
+ -2, /* (105) stl_prefix ::= seltablist joinop */
153682
+ 0, /* (106) stl_prefix ::= */
153683
+ -7, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
153684
+ -9, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
153685
+ -7, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
153686
+ -7, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
153687
+ 0, /* (111) dbnm ::= */
153688
+ -2, /* (112) dbnm ::= DOT nm */
153689
+ -1, /* (113) fullname ::= nm */
153690
+ -3, /* (114) fullname ::= nm DOT nm */
153691
+ -1, /* (115) xfullname ::= nm */
153692
+ -3, /* (116) xfullname ::= nm DOT nm */
153693
+ -5, /* (117) xfullname ::= nm DOT nm AS nm */
153694
+ -3, /* (118) xfullname ::= nm AS nm */
153695
+ -1, /* (119) joinop ::= COMMA|JOIN */
153696
+ -2, /* (120) joinop ::= JOIN_KW JOIN */
153697
+ -3, /* (121) joinop ::= JOIN_KW nm JOIN */
153698
+ -4, /* (122) joinop ::= JOIN_KW nm nm JOIN */
153699
+ -2, /* (123) on_opt ::= ON expr */
153700
+ 0, /* (124) on_opt ::= */
153701
+ 0, /* (125) indexed_opt ::= */
153702
+ -3, /* (126) indexed_opt ::= INDEXED BY nm */
153703
+ -2, /* (127) indexed_opt ::= NOT INDEXED */
153704
+ -4, /* (128) using_opt ::= USING LP idlist RP */
153705
+ 0, /* (129) using_opt ::= */
153706
+ 0, /* (130) orderby_opt ::= */
153707
+ -3, /* (131) orderby_opt ::= ORDER BY sortlist */
153708
+ -5, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */
153709
+ -3, /* (133) sortlist ::= expr sortorder nulls */
153710
+ -1, /* (134) sortorder ::= ASC */
153711
+ -1, /* (135) sortorder ::= DESC */
153712
+ 0, /* (136) sortorder ::= */
153713
+ -2, /* (137) nulls ::= NULLS FIRST */
153714
+ -2, /* (138) nulls ::= NULLS LAST */
153715
+ 0, /* (139) nulls ::= */
153716
+ 0, /* (140) groupby_opt ::= */
153717
+ -3, /* (141) groupby_opt ::= GROUP BY nexprlist */
153718
+ 0, /* (142) having_opt ::= */
153719
+ -2, /* (143) having_opt ::= HAVING expr */
153720
+ 0, /* (144) limit_opt ::= */
153721
+ -2, /* (145) limit_opt ::= LIMIT expr */
153722
+ -4, /* (146) limit_opt ::= LIMIT expr OFFSET expr */
153723
+ -4, /* (147) limit_opt ::= LIMIT expr COMMA expr */
153724
+ -6, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
153725
+ 0, /* (149) where_opt ::= */
153726
+ -2, /* (150) where_opt ::= WHERE expr */
153727
+ -8, /* (151) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
153728
+ -5, /* (152) setlist ::= setlist COMMA nm EQ expr */
153729
+ -7, /* (153) setlist ::= setlist COMMA LP idlist RP EQ expr */
153730
+ -3, /* (154) setlist ::= nm EQ expr */
153731
+ -5, /* (155) setlist ::= LP idlist RP EQ expr */
153732
+ -7, /* (156) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
153733
+ -7, /* (157) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
153734
+ 0, /* (158) upsert ::= */
153735
+ -11, /* (159) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
153736
+ -8, /* (160) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
153737
+ -4, /* (161) upsert ::= ON CONFLICT DO NOTHING */
153738
+ -2, /* (162) insert_cmd ::= INSERT orconf */
153739
+ -1, /* (163) insert_cmd ::= REPLACE */
153740
+ 0, /* (164) idlist_opt ::= */
153741
+ -3, /* (165) idlist_opt ::= LP idlist RP */
153742
+ -3, /* (166) idlist ::= idlist COMMA nm */
153743
+ -1, /* (167) idlist ::= nm */
153744
+ -3, /* (168) expr ::= LP expr RP */
153745
+ -1, /* (169) expr ::= ID|INDEXED */
153746
+ -1, /* (170) expr ::= JOIN_KW */
153747
+ -3, /* (171) expr ::= nm DOT nm */
153748
+ -5, /* (172) expr ::= nm DOT nm DOT nm */
153749
+ -1, /* (173) term ::= NULL|FLOAT|BLOB */
153750
+ -1, /* (174) term ::= STRING */
153751
+ -1, /* (175) term ::= INTEGER */
153752
+ -1, /* (176) expr ::= VARIABLE */
153753
+ -3, /* (177) expr ::= expr COLLATE ID|STRING */
153754
+ -6, /* (178) expr ::= CAST LP expr AS typetoken RP */
153755
+ -5, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP */
153756
+ -4, /* (180) expr ::= ID|INDEXED LP STAR RP */
153757
+ -6, /* (181) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
153758
+ -5, /* (182) expr ::= ID|INDEXED LP STAR RP filter_over */
153759
+ -1, /* (183) term ::= CTIME_KW */
153760
+ -5, /* (184) expr ::= LP nexprlist COMMA expr RP */
153761
+ -3, /* (185) expr ::= expr AND expr */
153762
+ -3, /* (186) expr ::= expr OR expr */
153763
+ -3, /* (187) expr ::= expr LT|GT|GE|LE expr */
153764
+ -3, /* (188) expr ::= expr EQ|NE expr */
153765
+ -3, /* (189) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
153766
+ -3, /* (190) expr ::= expr PLUS|MINUS expr */
153767
+ -3, /* (191) expr ::= expr STAR|SLASH|REM expr */
153768
+ -3, /* (192) expr ::= expr CONCAT expr */
153769
+ -2, /* (193) likeop ::= NOT LIKE_KW|MATCH */
153770
+ -3, /* (194) expr ::= expr likeop expr */
153771
+ -5, /* (195) expr ::= expr likeop expr ESCAPE expr */
153772
+ -2, /* (196) expr ::= expr ISNULL|NOTNULL */
153773
+ -3, /* (197) expr ::= expr NOT NULL */
153774
+ -3, /* (198) expr ::= expr IS expr */
153775
+ -4, /* (199) expr ::= expr IS NOT expr */
153776
+ -2, /* (200) expr ::= NOT expr */
153777
+ -2, /* (201) expr ::= BITNOT expr */
153778
+ -2, /* (202) expr ::= PLUS|MINUS expr */
153779
+ -1, /* (203) between_op ::= BETWEEN */
153780
+ -2, /* (204) between_op ::= NOT BETWEEN */
153781
+ -5, /* (205) expr ::= expr between_op expr AND expr */
153782
+ -1, /* (206) in_op ::= IN */
153783
+ -2, /* (207) in_op ::= NOT IN */
153784
+ -5, /* (208) expr ::= expr in_op LP exprlist RP */
153785
+ -3, /* (209) expr ::= LP select RP */
153786
+ -5, /* (210) expr ::= expr in_op LP select RP */
153787
+ -5, /* (211) expr ::= expr in_op nm dbnm paren_exprlist */
153788
+ -4, /* (212) expr ::= EXISTS LP select RP */
153789
+ -5, /* (213) expr ::= CASE case_operand case_exprlist case_else END */
153790
+ -5, /* (214) case_exprlist ::= case_exprlist WHEN expr THEN expr */
153791
+ -4, /* (215) case_exprlist ::= WHEN expr THEN expr */
153792
+ -2, /* (216) case_else ::= ELSE expr */
153793
+ 0, /* (217) case_else ::= */
153794
+ -1, /* (218) case_operand ::= expr */
153795
+ 0, /* (219) case_operand ::= */
153796
+ 0, /* (220) exprlist ::= */
153797
+ -3, /* (221) nexprlist ::= nexprlist COMMA expr */
153798
+ -1, /* (222) nexprlist ::= expr */
153799
+ 0, /* (223) paren_exprlist ::= */
153800
+ -3, /* (224) paren_exprlist ::= LP exprlist RP */
153801
+ -12, /* (225) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
153802
+ -1, /* (226) uniqueflag ::= UNIQUE */
153803
+ 0, /* (227) uniqueflag ::= */
153804
+ 0, /* (228) eidlist_opt ::= */
153805
+ -3, /* (229) eidlist_opt ::= LP eidlist RP */
153806
+ -5, /* (230) eidlist ::= eidlist COMMA nm collate sortorder */
153807
+ -3, /* (231) eidlist ::= nm collate sortorder */
153808
+ 0, /* (232) collate ::= */
153809
+ -2, /* (233) collate ::= COLLATE ID|STRING */
153810
+ -4, /* (234) cmd ::= DROP INDEX ifexists fullname */
153811
+ -2, /* (235) cmd ::= VACUUM vinto */
153812
+ -3, /* (236) cmd ::= VACUUM nm vinto */
153813
+ -2, /* (237) vinto ::= INTO expr */
153814
+ 0, /* (238) vinto ::= */
153815
+ -3, /* (239) cmd ::= PRAGMA nm dbnm */
153816
+ -5, /* (240) cmd ::= PRAGMA nm dbnm EQ nmnum */
153817
+ -6, /* (241) cmd ::= PRAGMA nm dbnm LP nmnum RP */
153818
+ -5, /* (242) cmd ::= PRAGMA nm dbnm EQ minus_num */
153819
+ -6, /* (243) cmd ::= PRAGMA nm dbnm LP minus_num RP */
153820
+ -2, /* (244) plus_num ::= PLUS INTEGER|FLOAT */
153821
+ -2, /* (245) minus_num ::= MINUS INTEGER|FLOAT */
153822
+ -5, /* (246) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
153823
+ -11, /* (247) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
153824
+ -1, /* (248) trigger_time ::= BEFORE|AFTER */
153825
+ -2, /* (249) trigger_time ::= INSTEAD OF */
153826
+ 0, /* (250) trigger_time ::= */
153827
+ -1, /* (251) trigger_event ::= DELETE|INSERT */
153828
+ -1, /* (252) trigger_event ::= UPDATE */
153829
+ -3, /* (253) trigger_event ::= UPDATE OF idlist */
153830
+ 0, /* (254) when_clause ::= */
153831
+ -2, /* (255) when_clause ::= WHEN expr */
153832
+ -3, /* (256) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
153833
+ -2, /* (257) trigger_cmd_list ::= trigger_cmd SEMI */
153834
+ -3, /* (258) trnm ::= nm DOT nm */
153835
+ -3, /* (259) tridxby ::= INDEXED BY nm */
153836
+ -2, /* (260) tridxby ::= NOT INDEXED */
153837
+ -8, /* (261) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
153838
+ -8, /* (262) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
153839
+ -6, /* (263) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
153840
+ -3, /* (264) trigger_cmd ::= scanpt select scanpt */
153841
+ -4, /* (265) expr ::= RAISE LP IGNORE RP */
153842
+ -6, /* (266) expr ::= RAISE LP raisetype COMMA nm RP */
153843
+ -1, /* (267) raisetype ::= ROLLBACK */
153844
+ -1, /* (268) raisetype ::= ABORT */
153845
+ -1, /* (269) raisetype ::= FAIL */
153846
+ -4, /* (270) cmd ::= DROP TRIGGER ifexists fullname */
153847
+ -6, /* (271) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
153848
+ -3, /* (272) cmd ::= DETACH database_kw_opt expr */
153849
+ 0, /* (273) key_opt ::= */
153850
+ -2, /* (274) key_opt ::= KEY expr */
153851
+ -1, /* (275) cmd ::= REINDEX */
153852
+ -3, /* (276) cmd ::= REINDEX nm dbnm */
153853
+ -1, /* (277) cmd ::= ANALYZE */
153854
+ -3, /* (278) cmd ::= ANALYZE nm dbnm */
153855
+ -6, /* (279) cmd ::= ALTER TABLE fullname RENAME TO nm */
153856
+ -7, /* (280) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
153857
+ -1, /* (281) add_column_fullname ::= fullname */
153858
+ -8, /* (282) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
153859
+ -1, /* (283) cmd ::= create_vtab */
153860
+ -4, /* (284) cmd ::= create_vtab LP vtabarglist RP */
153861
+ -8, /* (285) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
153862
+ 0, /* (286) vtabarg ::= */
153863
+ -1, /* (287) vtabargtoken ::= ANY */
153864
+ -3, /* (288) vtabargtoken ::= lp anylist RP */
153865
+ -1, /* (289) lp ::= LP */
153866
+ -2, /* (290) with ::= WITH wqlist */
153867
+ -3, /* (291) with ::= WITH RECURSIVE wqlist */
153868
+ -6, /* (292) wqlist ::= nm eidlist_opt AS LP select RP */
153869
+ -8, /* (293) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
153870
+ -1, /* (294) windowdefn_list ::= windowdefn */
153871
+ -3, /* (295) windowdefn_list ::= windowdefn_list COMMA windowdefn */
153872
+ -5, /* (296) windowdefn ::= nm AS LP window RP */
153873
+ -5, /* (297) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
153874
+ -6, /* (298) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
153875
+ -4, /* (299) window ::= ORDER BY sortlist frame_opt */
153876
+ -5, /* (300) window ::= nm ORDER BY sortlist frame_opt */
153877
+ -1, /* (301) window ::= frame_opt */
153878
+ -2, /* (302) window ::= nm frame_opt */
153879
+ 0, /* (303) frame_opt ::= */
153880
+ -3, /* (304) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
153881
+ -6, /* (305) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
153882
+ -1, /* (306) range_or_rows ::= RANGE|ROWS|GROUPS */
153883
+ -1, /* (307) frame_bound_s ::= frame_bound */
153884
+ -2, /* (308) frame_bound_s ::= UNBOUNDED PRECEDING */
153885
+ -1, /* (309) frame_bound_e ::= frame_bound */
153886
+ -2, /* (310) frame_bound_e ::= UNBOUNDED FOLLOWING */
153887
+ -2, /* (311) frame_bound ::= expr PRECEDING|FOLLOWING */
153888
+ -2, /* (312) frame_bound ::= CURRENT ROW */
153889
+ 0, /* (313) frame_exclude_opt ::= */
153890
+ -2, /* (314) frame_exclude_opt ::= EXCLUDE frame_exclude */
153891
+ -2, /* (315) frame_exclude ::= NO OTHERS */
153892
+ -2, /* (316) frame_exclude ::= CURRENT ROW */
153893
+ -1, /* (317) frame_exclude ::= GROUP|TIES */
153894
+ -2, /* (318) window_clause ::= WINDOW windowdefn_list */
153895
+ -2, /* (319) filter_over ::= filter_clause over_clause */
153896
+ -1, /* (320) filter_over ::= over_clause */
153897
+ -1, /* (321) filter_over ::= filter_clause */
153898
+ -4, /* (322) over_clause ::= OVER LP window RP */
153899
+ -2, /* (323) over_clause ::= OVER nm */
153900
+ -5, /* (324) filter_clause ::= FILTER LP WHERE expr RP */
153901
+ -1, /* (325) input ::= cmdlist */
153902
+ -2, /* (326) cmdlist ::= cmdlist ecmd */
153903
+ -1, /* (327) cmdlist ::= ecmd */
153904
+ -1, /* (328) ecmd ::= SEMI */
153905
+ -2, /* (329) ecmd ::= cmdx SEMI */
153906
+ -2, /* (330) ecmd ::= explain cmdx */
153907
+ 0, /* (331) trans_opt ::= */
153908
+ -1, /* (332) trans_opt ::= TRANSACTION */
153909
+ -2, /* (333) trans_opt ::= TRANSACTION nm */
153910
+ -1, /* (334) savepoint_opt ::= SAVEPOINT */
153911
+ 0, /* (335) savepoint_opt ::= */
153912
+ -2, /* (336) cmd ::= create_table create_table_args */
153913
+ -4, /* (337) columnlist ::= columnlist COMMA columnname carglist */
153914
+ -2, /* (338) columnlist ::= columnname carglist */
153915
+ -1, /* (339) nm ::= ID|INDEXED */
153916
+ -1, /* (340) nm ::= STRING */
153917
+ -1, /* (341) nm ::= JOIN_KW */
153918
+ -1, /* (342) typetoken ::= typename */
153919
+ -1, /* (343) typename ::= ID|STRING */
153920
+ -1, /* (344) signed ::= plus_num */
153921
+ -1, /* (345) signed ::= minus_num */
153922
+ -2, /* (346) carglist ::= carglist ccons */
153923
+ 0, /* (347) carglist ::= */
153924
+ -2, /* (348) ccons ::= NULL onconf */
153925
+ -4, /* (349) ccons ::= GENERATED ALWAYS AS generated */
153926
+ -2, /* (350) ccons ::= AS generated */
153927
+ -2, /* (351) conslist_opt ::= COMMA conslist */
153928
+ -3, /* (352) conslist ::= conslist tconscomma tcons */
153929
+ -1, /* (353) conslist ::= tcons */
153930
+ 0, /* (354) tconscomma ::= */
153931
+ -1, /* (355) defer_subclause_opt ::= defer_subclause */
153932
+ -1, /* (356) resolvetype ::= raisetype */
153933
+ -1, /* (357) selectnowith ::= oneselect */
153934
+ -1, /* (358) oneselect ::= values */
153935
+ -2, /* (359) sclp ::= selcollist COMMA */
153936
+ -1, /* (360) as ::= ID|STRING */
153937
+ -1, /* (361) expr ::= term */
153938
+ -1, /* (362) likeop ::= LIKE_KW|MATCH */
153939
+ -1, /* (363) exprlist ::= nexprlist */
153940
+ -1, /* (364) nmnum ::= plus_num */
153941
+ -1, /* (365) nmnum ::= nm */
153942
+ -1, /* (366) nmnum ::= ON */
153943
+ -1, /* (367) nmnum ::= DELETE */
153944
+ -1, /* (368) nmnum ::= DEFAULT */
153945
+ -1, /* (369) plus_num ::= INTEGER|FLOAT */
153946
+ 0, /* (370) foreach_clause ::= */
153947
+ -3, /* (371) foreach_clause ::= FOR EACH ROW */
153948
+ -1, /* (372) trnm ::= nm */
153949
+ 0, /* (373) tridxby ::= */
153950
+ -1, /* (374) database_kw_opt ::= DATABASE */
153951
+ 0, /* (375) database_kw_opt ::= */
153952
+ 0, /* (376) kwcolumn_opt ::= */
153953
+ -1, /* (377) kwcolumn_opt ::= COLUMNKW */
153954
+ -1, /* (378) vtabarglist ::= vtabarg */
153955
+ -3, /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */
153956
+ -2, /* (380) vtabarg ::= vtabarg vtabargtoken */
153957
+ 0, /* (381) anylist ::= */
153958
+ -4, /* (382) anylist ::= anylist LP anylist RP */
153959
+ -2, /* (383) anylist ::= anylist ANY */
153960
+ 0, /* (384) with ::= */
152830153961
};
152831153962
152832153963
static void yy_accept(yyParser*); /* Forward Declaration */
152833153964
152834153965
/*
@@ -152921,20 +154052,20 @@
152921154052
break;
152922154053
case 2: /* cmdx ::= cmd */
152923154054
{ sqlite3FinishCoding(pParse); }
152924154055
break;
152925154056
case 3: /* cmd ::= BEGIN transtype trans_opt */
152926
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy32);}
154057
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy192);}
152927154058
break;
152928154059
case 4: /* transtype ::= */
152929
-{yymsp[1].minor.yy32 = TK_DEFERRED;}
154060
+{yymsp[1].minor.yy192 = TK_DEFERRED;}
152930154061
break;
152931154062
case 5: /* transtype ::= DEFERRED */
152932154063
case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
152933154064
case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
152934
- case 304: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==304);
152935
-{yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-X*/}
154065
+ case 306: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==306);
154066
+{yymsp[0].minor.yy192 = yymsp[0].major; /*A-overwrites-X*/}
152936154067
break;
152937154068
case 8: /* cmd ::= COMMIT|END trans_opt */
152938154069
case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
152939154070
{sqlite3EndTransaction(pParse,yymsp[-1].major);}
152940154071
break;
@@ -152953,61 +154084,61 @@
152953154084
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
152954154085
}
152955154086
break;
152956154087
case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
152957154088
{
152958
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy32,0,0,yymsp[-2].minor.yy32);
154089
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy192,0,0,yymsp[-2].minor.yy192);
152959154090
}
152960154091
break;
152961154092
case 14: /* createkw ::= CREATE */
152962154093
{disableLookaside(pParse);}
152963154094
break;
152964154095
case 15: /* ifnotexists ::= */
152965154096
case 18: /* temp ::= */ yytestcase(yyruleno==18);
152966154097
case 21: /* table_options ::= */ yytestcase(yyruleno==21);
152967
- case 43: /* autoinc ::= */ yytestcase(yyruleno==43);
152968
- case 58: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==58);
152969
- case 68: /* defer_subclause_opt ::= */ yytestcase(yyruleno==68);
152970
- case 77: /* ifexists ::= */ yytestcase(yyruleno==77);
152971
- case 94: /* distinct ::= */ yytestcase(yyruleno==94);
152972
- case 230: /* collate ::= */ yytestcase(yyruleno==230);
152973
-{yymsp[1].minor.yy32 = 0;}
154098
+ case 45: /* autoinc ::= */ yytestcase(yyruleno==45);
154099
+ case 60: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==60);
154100
+ case 70: /* defer_subclause_opt ::= */ yytestcase(yyruleno==70);
154101
+ case 79: /* ifexists ::= */ yytestcase(yyruleno==79);
154102
+ case 96: /* distinct ::= */ yytestcase(yyruleno==96);
154103
+ case 232: /* collate ::= */ yytestcase(yyruleno==232);
154104
+{yymsp[1].minor.yy192 = 0;}
152974154105
break;
152975154106
case 16: /* ifnotexists ::= IF NOT EXISTS */
152976
-{yymsp[-2].minor.yy32 = 1;}
154107
+{yymsp[-2].minor.yy192 = 1;}
152977154108
break;
152978154109
case 17: /* temp ::= TEMP */
152979
- case 44: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==44);
152980
-{yymsp[0].minor.yy32 = 1;}
154110
+ case 46: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==46);
154111
+{yymsp[0].minor.yy192 = 1;}
152981154112
break;
152982154113
case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
152983154114
{
152984
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy32,0);
154115
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy192,0);
152985154116
}
152986154117
break;
152987154118
case 20: /* create_table_args ::= AS select */
152988154119
{
152989
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy25);
152990
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy25);
154120
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy539);
154121
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy539);
152991154122
}
152992154123
break;
152993154124
case 22: /* table_options ::= WITHOUT nm */
152994154125
{
152995154126
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
152996
- yymsp[-1].minor.yy32 = TF_WithoutRowid | TF_NoVisibleRowid;
154127
+ yymsp[-1].minor.yy192 = TF_WithoutRowid | TF_NoVisibleRowid;
152997154128
}else{
152998
- yymsp[-1].minor.yy32 = 0;
154129
+ yymsp[-1].minor.yy192 = 0;
152999154130
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
153000154131
}
153001154132
}
153002154133
break;
153003154134
case 23: /* columnname ::= nm typetoken */
153004154135
{sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
153005154136
break;
153006154137
case 24: /* typetoken ::= */
153007
- case 61: /* conslist_opt ::= */ yytestcase(yyruleno==61);
153008
- case 100: /* as ::= */ yytestcase(yyruleno==100);
154138
+ case 63: /* conslist_opt ::= */ yytestcase(yyruleno==63);
154139
+ case 102: /* as ::= */ yytestcase(yyruleno==102);
153009154140
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
153010154141
break;
153011154142
case 25: /* typetoken ::= typename LP signed RP */
153012154143
{
153013154144
yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
@@ -153022,35 +154153,35 @@
153022154153
{yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
153023154154
break;
153024154155
case 28: /* scanpt ::= */
153025154156
{
153026154157
assert( yyLookahead!=YYNOCODE );
153027
- yymsp[1].minor.yy8 = yyLookaheadToken.z;
154158
+ yymsp[1].minor.yy436 = yyLookaheadToken.z;
153028154159
}
153029154160
break;
153030154161
case 29: /* scantok ::= */
153031154162
{
153032154163
assert( yyLookahead!=YYNOCODE );
153033154164
yymsp[1].minor.yy0 = yyLookaheadToken;
153034154165
}
153035154166
break;
153036154167
case 30: /* ccons ::= CONSTRAINT nm */
153037
- case 63: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==63);
154168
+ case 65: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==65);
153038154169
{pParse->constraintName = yymsp[0].minor.yy0;}
153039154170
break;
153040154171
case 31: /* ccons ::= DEFAULT scantok term */
153041
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy46,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
154172
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy202,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
153042154173
break;
153043154174
case 32: /* ccons ::= DEFAULT LP expr RP */
153044
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy46,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
154175
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy202,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
153045154176
break;
153046154177
case 33: /* ccons ::= DEFAULT PLUS scantok term */
153047
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy46,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
154178
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy202,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
153048154179
break;
153049154180
case 34: /* ccons ::= DEFAULT MINUS scantok term */
153050154181
{
153051
- Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy46, 0);
154182
+ Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy202, 0);
153052154183
sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
153053154184
}
153054154185
break;
153055154186
case 35: /* ccons ::= DEFAULT scantok ID|INDEXED */
153056154187
{
@@ -153061,319 +154192,325 @@
153061154192
}
153062154193
sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
153063154194
}
153064154195
break;
153065154196
case 36: /* ccons ::= NOT NULL onconf */
153066
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy32);}
154197
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy192);}
153067154198
break;
153068154199
case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
153069
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy32,yymsp[0].minor.yy32,yymsp[-2].minor.yy32);}
154200
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy192,yymsp[0].minor.yy192,yymsp[-2].minor.yy192);}
153070154201
break;
153071154202
case 38: /* ccons ::= UNIQUE onconf */
153072
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy32,0,0,0,0,
154203
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy192,0,0,0,0,
153073154204
SQLITE_IDXTYPE_UNIQUE);}
153074154205
break;
153075154206
case 39: /* ccons ::= CHECK LP expr RP */
153076
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy46);}
154207
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy202);}
153077154208
break;
153078154209
case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */
153079
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy138,yymsp[0].minor.yy32);}
154210
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy242,yymsp[0].minor.yy192);}
153080154211
break;
153081154212
case 41: /* ccons ::= defer_subclause */
153082
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy32);}
154213
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy192);}
153083154214
break;
153084154215
case 42: /* ccons ::= COLLATE ID|STRING */
153085154216
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
153086154217
break;
153087
- case 45: /* refargs ::= */
153088
-{ yymsp[1].minor.yy32 = OE_None*0x0101; /* EV: R-19803-45884 */}
153089
- break;
153090
- case 46: /* refargs ::= refargs refarg */
153091
-{ yymsp[-1].minor.yy32 = (yymsp[-1].minor.yy32 & ~yymsp[0].minor.yy495.mask) | yymsp[0].minor.yy495.value; }
153092
- break;
153093
- case 47: /* refarg ::= MATCH nm */
153094
-{ yymsp[-1].minor.yy495.value = 0; yymsp[-1].minor.yy495.mask = 0x000000; }
153095
- break;
153096
- case 48: /* refarg ::= ON INSERT refact */
153097
-{ yymsp[-2].minor.yy495.value = 0; yymsp[-2].minor.yy495.mask = 0x000000; }
153098
- break;
153099
- case 49: /* refarg ::= ON DELETE refact */
153100
-{ yymsp[-2].minor.yy495.value = yymsp[0].minor.yy32; yymsp[-2].minor.yy495.mask = 0x0000ff; }
153101
- break;
153102
- case 50: /* refarg ::= ON UPDATE refact */
153103
-{ yymsp[-2].minor.yy495.value = yymsp[0].minor.yy32<<8; yymsp[-2].minor.yy495.mask = 0x00ff00; }
153104
- break;
153105
- case 51: /* refact ::= SET NULL */
153106
-{ yymsp[-1].minor.yy32 = OE_SetNull; /* EV: R-33326-45252 */}
153107
- break;
153108
- case 52: /* refact ::= SET DEFAULT */
153109
-{ yymsp[-1].minor.yy32 = OE_SetDflt; /* EV: R-33326-45252 */}
153110
- break;
153111
- case 53: /* refact ::= CASCADE */
153112
-{ yymsp[0].minor.yy32 = OE_Cascade; /* EV: R-33326-45252 */}
153113
- break;
153114
- case 54: /* refact ::= RESTRICT */
153115
-{ yymsp[0].minor.yy32 = OE_Restrict; /* EV: R-33326-45252 */}
153116
- break;
153117
- case 55: /* refact ::= NO ACTION */
153118
-{ yymsp[-1].minor.yy32 = OE_None; /* EV: R-33326-45252 */}
153119
- break;
153120
- case 56: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
153121
-{yymsp[-2].minor.yy32 = 0;}
153122
- break;
153123
- case 57: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
153124
- case 72: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==72);
153125
- case 160: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==160);
153126
-{yymsp[-1].minor.yy32 = yymsp[0].minor.yy32;}
153127
- break;
153128
- case 59: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
153129
- case 76: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==76);
153130
- case 202: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==202);
153131
- case 205: /* in_op ::= NOT IN */ yytestcase(yyruleno==205);
153132
- case 231: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==231);
153133
-{yymsp[-1].minor.yy32 = 1;}
153134
- break;
153135
- case 60: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
153136
-{yymsp[-1].minor.yy32 = 0;}
153137
- break;
153138
- case 62: /* tconscomma ::= COMMA */
153139
-{pParse->constraintName.n = 0;}
153140
- break;
153141
- case 64: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
153142
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy138,yymsp[0].minor.yy32,yymsp[-2].minor.yy32,0);}
153143
- break;
153144
- case 65: /* tcons ::= UNIQUE LP sortlist RP onconf */
153145
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy138,yymsp[0].minor.yy32,0,0,0,0,
153146
- SQLITE_IDXTYPE_UNIQUE);}
153147
- break;
153148
- case 66: /* tcons ::= CHECK LP expr RP onconf */
153149
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy46);}
153150
- break;
153151
- case 67: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
153152
-{
153153
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy138, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy138, yymsp[-1].minor.yy32);
153154
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy32);
153155
-}
153156
- break;
153157
- case 69: /* onconf ::= */
153158
- case 71: /* orconf ::= */ yytestcase(yyruleno==71);
153159
-{yymsp[1].minor.yy32 = OE_Default;}
153160
- break;
153161
- case 70: /* onconf ::= ON CONFLICT resolvetype */
153162
-{yymsp[-2].minor.yy32 = yymsp[0].minor.yy32;}
153163
- break;
153164
- case 73: /* resolvetype ::= IGNORE */
153165
-{yymsp[0].minor.yy32 = OE_Ignore;}
153166
- break;
153167
- case 74: /* resolvetype ::= REPLACE */
153168
- case 161: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==161);
153169
-{yymsp[0].minor.yy32 = OE_Replace;}
153170
- break;
153171
- case 75: /* cmd ::= DROP TABLE ifexists fullname */
153172
-{
153173
- sqlite3DropTable(pParse, yymsp[0].minor.yy609, 0, yymsp[-1].minor.yy32);
153174
-}
153175
- break;
153176
- case 78: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
153177
-{
153178
- 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);
153179
-}
153180
- break;
153181
- case 79: /* cmd ::= DROP VIEW ifexists fullname */
153182
-{
153183
- sqlite3DropTable(pParse, yymsp[0].minor.yy609, 1, yymsp[-1].minor.yy32);
153184
-}
153185
- break;
153186
- case 80: /* cmd ::= select */
153187
-{
153188
- SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
153189
- sqlite3Select(pParse, yymsp[0].minor.yy25, &dest);
153190
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy25);
153191
-}
153192
- break;
153193
- case 81: /* select ::= WITH wqlist selectnowith */
153194
-{
153195
- Select *p = yymsp[0].minor.yy25;
153196
- if( p ){
153197
- p->pWith = yymsp[-1].minor.yy297;
153198
- parserDoubleLinkSelect(pParse, p);
153199
- }else{
153200
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy297);
153201
- }
153202
- yymsp[-2].minor.yy25 = p;
153203
-}
153204
- break;
153205
- case 82: /* select ::= WITH RECURSIVE wqlist selectnowith */
153206
-{
153207
- Select *p = yymsp[0].minor.yy25;
153208
- if( p ){
153209
- p->pWith = yymsp[-1].minor.yy297;
153210
- parserDoubleLinkSelect(pParse, p);
153211
- }else{
153212
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy297);
153213
- }
153214
- yymsp[-3].minor.yy25 = p;
153215
-}
153216
- break;
153217
- case 83: /* select ::= selectnowith */
153218
-{
153219
- Select *p = yymsp[0].minor.yy25;
153220
- if( p ){
153221
- parserDoubleLinkSelect(pParse, p);
153222
- }
153223
- yymsp[0].minor.yy25 = p; /*A-overwrites-X*/
153224
-}
153225
- break;
153226
- case 84: /* selectnowith ::= selectnowith multiselect_op oneselect */
153227
-{
153228
- Select *pRhs = yymsp[0].minor.yy25;
153229
- Select *pLhs = yymsp[-2].minor.yy25;
154218
+ case 43: /* generated ::= LP expr RP */
154219
+{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy202,0);}
154220
+ break;
154221
+ case 44: /* generated ::= LP expr RP ID */
154222
+{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy202,&yymsp[0].minor.yy0);}
154223
+ break;
154224
+ case 47: /* refargs ::= */
154225
+{ yymsp[1].minor.yy192 = OE_None*0x0101; /* EV: R-19803-45884 */}
154226
+ break;
154227
+ case 48: /* refargs ::= refargs refarg */
154228
+{ yymsp[-1].minor.yy192 = (yymsp[-1].minor.yy192 & ~yymsp[0].minor.yy207.mask) | yymsp[0].minor.yy207.value; }
154229
+ break;
154230
+ case 49: /* refarg ::= MATCH nm */
154231
+{ yymsp[-1].minor.yy207.value = 0; yymsp[-1].minor.yy207.mask = 0x000000; }
154232
+ break;
154233
+ case 50: /* refarg ::= ON INSERT refact */
154234
+{ yymsp[-2].minor.yy207.value = 0; yymsp[-2].minor.yy207.mask = 0x000000; }
154235
+ break;
154236
+ case 51: /* refarg ::= ON DELETE refact */
154237
+{ yymsp[-2].minor.yy207.value = yymsp[0].minor.yy192; yymsp[-2].minor.yy207.mask = 0x0000ff; }
154238
+ break;
154239
+ case 52: /* refarg ::= ON UPDATE refact */
154240
+{ yymsp[-2].minor.yy207.value = yymsp[0].minor.yy192<<8; yymsp[-2].minor.yy207.mask = 0x00ff00; }
154241
+ break;
154242
+ case 53: /* refact ::= SET NULL */
154243
+{ yymsp[-1].minor.yy192 = OE_SetNull; /* EV: R-33326-45252 */}
154244
+ break;
154245
+ case 54: /* refact ::= SET DEFAULT */
154246
+{ yymsp[-1].minor.yy192 = OE_SetDflt; /* EV: R-33326-45252 */}
154247
+ break;
154248
+ case 55: /* refact ::= CASCADE */
154249
+{ yymsp[0].minor.yy192 = OE_Cascade; /* EV: R-33326-45252 */}
154250
+ break;
154251
+ case 56: /* refact ::= RESTRICT */
154252
+{ yymsp[0].minor.yy192 = OE_Restrict; /* EV: R-33326-45252 */}
154253
+ break;
154254
+ case 57: /* refact ::= NO ACTION */
154255
+{ yymsp[-1].minor.yy192 = OE_None; /* EV: R-33326-45252 */}
154256
+ break;
154257
+ case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
154258
+{yymsp[-2].minor.yy192 = 0;}
154259
+ break;
154260
+ case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
154261
+ case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74);
154262
+ case 162: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==162);
154263
+{yymsp[-1].minor.yy192 = yymsp[0].minor.yy192;}
154264
+ break;
154265
+ case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
154266
+ case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78);
154267
+ case 204: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==204);
154268
+ case 207: /* in_op ::= NOT IN */ yytestcase(yyruleno==207);
154269
+ case 233: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==233);
154270
+{yymsp[-1].minor.yy192 = 1;}
154271
+ break;
154272
+ case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
154273
+{yymsp[-1].minor.yy192 = 0;}
154274
+ break;
154275
+ case 64: /* tconscomma ::= COMMA */
154276
+{pParse->constraintName.n = 0;}
154277
+ break;
154278
+ case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
154279
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy242,yymsp[0].minor.yy192,yymsp[-2].minor.yy192,0);}
154280
+ break;
154281
+ case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */
154282
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy242,yymsp[0].minor.yy192,0,0,0,0,
154283
+ SQLITE_IDXTYPE_UNIQUE);}
154284
+ break;
154285
+ case 68: /* tcons ::= CHECK LP expr RP onconf */
154286
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy202);}
154287
+ break;
154288
+ case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
154289
+{
154290
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy242, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy242, yymsp[-1].minor.yy192);
154291
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy192);
154292
+}
154293
+ break;
154294
+ case 71: /* onconf ::= */
154295
+ case 73: /* orconf ::= */ yytestcase(yyruleno==73);
154296
+{yymsp[1].minor.yy192 = OE_Default;}
154297
+ break;
154298
+ case 72: /* onconf ::= ON CONFLICT resolvetype */
154299
+{yymsp[-2].minor.yy192 = yymsp[0].minor.yy192;}
154300
+ break;
154301
+ case 75: /* resolvetype ::= IGNORE */
154302
+{yymsp[0].minor.yy192 = OE_Ignore;}
154303
+ break;
154304
+ case 76: /* resolvetype ::= REPLACE */
154305
+ case 163: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==163);
154306
+{yymsp[0].minor.yy192 = OE_Replace;}
154307
+ break;
154308
+ case 77: /* cmd ::= DROP TABLE ifexists fullname */
154309
+{
154310
+ sqlite3DropTable(pParse, yymsp[0].minor.yy47, 0, yymsp[-1].minor.yy192);
154311
+}
154312
+ break;
154313
+ case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
154314
+{
154315
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy242, yymsp[0].minor.yy539, yymsp[-7].minor.yy192, yymsp[-5].minor.yy192);
154316
+}
154317
+ break;
154318
+ case 81: /* cmd ::= DROP VIEW ifexists fullname */
154319
+{
154320
+ sqlite3DropTable(pParse, yymsp[0].minor.yy47, 1, yymsp[-1].minor.yy192);
154321
+}
154322
+ break;
154323
+ case 82: /* cmd ::= select */
154324
+{
154325
+ SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
154326
+ sqlite3Select(pParse, yymsp[0].minor.yy539, &dest);
154327
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy539);
154328
+}
154329
+ break;
154330
+ case 83: /* select ::= WITH wqlist selectnowith */
154331
+{
154332
+ Select *p = yymsp[0].minor.yy539;
154333
+ if( p ){
154334
+ p->pWith = yymsp[-1].minor.yy131;
154335
+ parserDoubleLinkSelect(pParse, p);
154336
+ }else{
154337
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy131);
154338
+ }
154339
+ yymsp[-2].minor.yy539 = p;
154340
+}
154341
+ break;
154342
+ case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */
154343
+{
154344
+ Select *p = yymsp[0].minor.yy539;
154345
+ if( p ){
154346
+ p->pWith = yymsp[-1].minor.yy131;
154347
+ parserDoubleLinkSelect(pParse, p);
154348
+ }else{
154349
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy131);
154350
+ }
154351
+ yymsp[-3].minor.yy539 = p;
154352
+}
154353
+ break;
154354
+ case 85: /* select ::= selectnowith */
154355
+{
154356
+ Select *p = yymsp[0].minor.yy539;
154357
+ if( p ){
154358
+ parserDoubleLinkSelect(pParse, p);
154359
+ }
154360
+ yymsp[0].minor.yy539 = p; /*A-overwrites-X*/
154361
+}
154362
+ break;
154363
+ case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */
154364
+{
154365
+ Select *pRhs = yymsp[0].minor.yy539;
154366
+ Select *pLhs = yymsp[-2].minor.yy539;
153230154367
if( pRhs && pRhs->pPrior ){
153231154368
SrcList *pFrom;
153232154369
Token x;
153233154370
x.n = 0;
153234154371
parserDoubleLinkSelect(pParse, pRhs);
153235154372
pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
153236154373
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
153237154374
}
153238154375
if( pRhs ){
153239
- pRhs->op = (u8)yymsp[-1].minor.yy32;
154376
+ pRhs->op = (u8)yymsp[-1].minor.yy192;
153240154377
pRhs->pPrior = pLhs;
153241154378
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
153242154379
pRhs->selFlags &= ~SF_MultiValue;
153243
- if( yymsp[-1].minor.yy32!=TK_ALL ) pParse->hasCompound = 1;
154380
+ if( yymsp[-1].minor.yy192!=TK_ALL ) pParse->hasCompound = 1;
153244154381
}else{
153245154382
sqlite3SelectDelete(pParse->db, pLhs);
153246154383
}
153247
- yymsp[-2].minor.yy25 = pRhs;
153248
-}
153249
- break;
153250
- case 85: /* multiselect_op ::= UNION */
153251
- case 87: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==87);
153252
-{yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-OP*/}
153253
- break;
153254
- case 86: /* multiselect_op ::= UNION ALL */
153255
-{yymsp[-1].minor.yy32 = TK_ALL;}
153256
- break;
153257
- case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
153258
-{
153259
- 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);
153260
-}
153261
- break;
153262
- case 89: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
153263
-{
153264
- 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);
153265
- if( yymsp[-9].minor.yy25 ){
153266
- yymsp[-9].minor.yy25->pWinDefn = yymsp[-2].minor.yy455;
153267
- }else{
153268
- sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy455);
153269
- }
153270
-}
153271
- break;
153272
- case 90: /* values ::= VALUES LP nexprlist RP */
153273
-{
153274
- yymsp[-3].minor.yy25 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy138,0,0,0,0,0,SF_Values,0);
153275
-}
153276
- break;
153277
- case 91: /* values ::= values COMMA LP nexprlist RP */
153278
-{
153279
- Select *pRight, *pLeft = yymsp[-4].minor.yy25;
153280
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy138,0,0,0,0,0,SF_Values|SF_MultiValue,0);
154384
+ yymsp[-2].minor.yy539 = pRhs;
154385
+}
154386
+ break;
154387
+ case 87: /* multiselect_op ::= UNION */
154388
+ case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89);
154389
+{yymsp[0].minor.yy192 = yymsp[0].major; /*A-overwrites-OP*/}
154390
+ break;
154391
+ case 88: /* multiselect_op ::= UNION ALL */
154392
+{yymsp[-1].minor.yy192 = TK_ALL;}
154393
+ break;
154394
+ case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
154395
+{
154396
+ yymsp[-8].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy242,yymsp[-5].minor.yy47,yymsp[-4].minor.yy202,yymsp[-3].minor.yy242,yymsp[-2].minor.yy202,yymsp[-1].minor.yy242,yymsp[-7].minor.yy192,yymsp[0].minor.yy202);
154397
+}
154398
+ break;
154399
+ case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
154400
+{
154401
+ yymsp[-9].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy242,yymsp[-6].minor.yy47,yymsp[-5].minor.yy202,yymsp[-4].minor.yy242,yymsp[-3].minor.yy202,yymsp[-1].minor.yy242,yymsp[-8].minor.yy192,yymsp[0].minor.yy202);
154402
+ if( yymsp[-9].minor.yy539 ){
154403
+ yymsp[-9].minor.yy539->pWinDefn = yymsp[-2].minor.yy303;
154404
+ }else{
154405
+ sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy303);
154406
+ }
154407
+}
154408
+ break;
154409
+ case 92: /* values ::= VALUES LP nexprlist RP */
154410
+{
154411
+ yymsp[-3].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy242,0,0,0,0,0,SF_Values,0);
154412
+}
154413
+ break;
154414
+ case 93: /* values ::= values COMMA LP nexprlist RP */
154415
+{
154416
+ Select *pRight, *pLeft = yymsp[-4].minor.yy539;
154417
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy242,0,0,0,0,0,SF_Values|SF_MultiValue,0);
153281154418
if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
153282154419
if( pRight ){
153283154420
pRight->op = TK_ALL;
153284154421
pRight->pPrior = pLeft;
153285
- yymsp[-4].minor.yy25 = pRight;
153286
- }else{
153287
- yymsp[-4].minor.yy25 = pLeft;
153288
- }
153289
-}
153290
- break;
153291
- case 92: /* distinct ::= DISTINCT */
153292
-{yymsp[0].minor.yy32 = SF_Distinct;}
153293
- break;
153294
- case 93: /* distinct ::= ALL */
153295
-{yymsp[0].minor.yy32 = SF_All;}
153296
- break;
153297
- case 95: /* sclp ::= */
153298
- case 128: /* orderby_opt ::= */ yytestcase(yyruleno==128);
153299
- case 138: /* groupby_opt ::= */ yytestcase(yyruleno==138);
153300
- case 218: /* exprlist ::= */ yytestcase(yyruleno==218);
153301
- case 221: /* paren_exprlist ::= */ yytestcase(yyruleno==221);
153302
- case 226: /* eidlist_opt ::= */ yytestcase(yyruleno==226);
153303
-{yymsp[1].minor.yy138 = 0;}
153304
- break;
153305
- case 96: /* selcollist ::= sclp scanpt expr scanpt as */
153306
-{
153307
- yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy138, yymsp[-2].minor.yy46);
153308
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy138, &yymsp[0].minor.yy0, 1);
153309
- sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy138,yymsp[-3].minor.yy8,yymsp[-1].minor.yy8);
153310
-}
153311
- break;
153312
- case 97: /* selcollist ::= sclp scanpt STAR */
154422
+ yymsp[-4].minor.yy539 = pRight;
154423
+ }else{
154424
+ yymsp[-4].minor.yy539 = pLeft;
154425
+ }
154426
+}
154427
+ break;
154428
+ case 94: /* distinct ::= DISTINCT */
154429
+{yymsp[0].minor.yy192 = SF_Distinct;}
154430
+ break;
154431
+ case 95: /* distinct ::= ALL */
154432
+{yymsp[0].minor.yy192 = SF_All;}
154433
+ break;
154434
+ case 97: /* sclp ::= */
154435
+ case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130);
154436
+ case 140: /* groupby_opt ::= */ yytestcase(yyruleno==140);
154437
+ case 220: /* exprlist ::= */ yytestcase(yyruleno==220);
154438
+ case 223: /* paren_exprlist ::= */ yytestcase(yyruleno==223);
154439
+ case 228: /* eidlist_opt ::= */ yytestcase(yyruleno==228);
154440
+{yymsp[1].minor.yy242 = 0;}
154441
+ break;
154442
+ case 98: /* selcollist ::= sclp scanpt expr scanpt as */
154443
+{
154444
+ yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy242, yymsp[-2].minor.yy202);
154445
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy242, &yymsp[0].minor.yy0, 1);
154446
+ sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy242,yymsp[-3].minor.yy436,yymsp[-1].minor.yy436);
154447
+}
154448
+ break;
154449
+ case 99: /* selcollist ::= sclp scanpt STAR */
153313154450
{
153314154451
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
153315
- yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy138, p);
154452
+ yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy242, p);
153316154453
}
153317154454
break;
153318
- case 98: /* selcollist ::= sclp scanpt nm DOT STAR */
154455
+ case 100: /* selcollist ::= sclp scanpt nm DOT STAR */
153319154456
{
153320154457
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
153321154458
Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
153322154459
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
153323
- yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, pDot);
154460
+ yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, pDot);
153324154461
}
153325154462
break;
153326
- case 99: /* as ::= AS nm */
153327
- case 110: /* dbnm ::= DOT nm */ yytestcase(yyruleno==110);
153328
- case 242: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==242);
153329
- case 243: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==243);
154463
+ case 101: /* as ::= AS nm */
154464
+ case 112: /* dbnm ::= DOT nm */ yytestcase(yyruleno==112);
154465
+ case 244: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==244);
154466
+ case 245: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==245);
153330154467
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
153331154468
break;
153332
- case 101: /* from ::= */
153333
-{yymsp[1].minor.yy609 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy609));}
153334
- break;
153335
- case 102: /* from ::= FROM seltablist */
153336
-{
153337
- yymsp[-1].minor.yy609 = yymsp[0].minor.yy609;
153338
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy609);
153339
-}
153340
- break;
153341
- case 103: /* stl_prefix ::= seltablist joinop */
153342
-{
153343
- 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;
153344
-}
153345
- break;
153346
- case 104: /* stl_prefix ::= */
153347
-{yymsp[1].minor.yy609 = 0;}
153348
- break;
153349
- case 105: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
153350
-{
153351
- 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);
153352
- sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy609, &yymsp[-2].minor.yy0);
153353
-}
153354
- break;
153355
- case 106: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
153356
-{
153357
- 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);
153358
- sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy609, yymsp[-4].minor.yy138);
153359
-}
153360
- break;
153361
- case 107: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
153362
-{
153363
- 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);
153364
- }
153365
- break;
153366
- case 108: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
153367
-{
153368
- if( yymsp[-6].minor.yy609==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy46==0 && yymsp[0].minor.yy406==0 ){
153369
- yymsp[-6].minor.yy609 = yymsp[-4].minor.yy609;
153370
- }else if( yymsp[-4].minor.yy609->nSrc==1 ){
153371
- 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);
153372
- if( yymsp[-6].minor.yy609 ){
153373
- struct SrcList_item *pNew = &yymsp[-6].minor.yy609->a[yymsp[-6].minor.yy609->nSrc-1];
153374
- struct SrcList_item *pOld = yymsp[-4].minor.yy609->a;
154469
+ case 103: /* from ::= */
154470
+{yymsp[1].minor.yy47 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy47));}
154471
+ break;
154472
+ case 104: /* from ::= FROM seltablist */
154473
+{
154474
+ yymsp[-1].minor.yy47 = yymsp[0].minor.yy47;
154475
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy47);
154476
+}
154477
+ break;
154478
+ case 105: /* stl_prefix ::= seltablist joinop */
154479
+{
154480
+ if( ALWAYS(yymsp[-1].minor.yy47 && yymsp[-1].minor.yy47->nSrc>0) ) yymsp[-1].minor.yy47->a[yymsp[-1].minor.yy47->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy192;
154481
+}
154482
+ break;
154483
+ case 106: /* stl_prefix ::= */
154484
+{yymsp[1].minor.yy47 = 0;}
154485
+ break;
154486
+ case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
154487
+{
154488
+ yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600);
154489
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy47, &yymsp[-2].minor.yy0);
154490
+}
154491
+ break;
154492
+ case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
154493
+{
154494
+ yymsp[-8].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy47,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600);
154495
+ sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy47, yymsp[-4].minor.yy242);
154496
+}
154497
+ break;
154498
+ case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
154499
+{
154500
+ yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy539,yymsp[-1].minor.yy202,yymsp[0].minor.yy600);
154501
+ }
154502
+ break;
154503
+ case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
154504
+{
154505
+ if( yymsp[-6].minor.yy47==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy202==0 && yymsp[0].minor.yy600==0 ){
154506
+ yymsp[-6].minor.yy47 = yymsp[-4].minor.yy47;
154507
+ }else if( yymsp[-4].minor.yy47->nSrc==1 ){
154508
+ yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600);
154509
+ if( yymsp[-6].minor.yy47 ){
154510
+ struct SrcList_item *pNew = &yymsp[-6].minor.yy47->a[yymsp[-6].minor.yy47->nSrc-1];
154511
+ struct SrcList_item *pOld = yymsp[-4].minor.yy47->a;
153375154512
pNew->zName = pOld->zName;
153376154513
pNew->zDatabase = pOld->zDatabase;
153377154514
pNew->pSelect = pOld->pSelect;
153378154515
if( pOld->fg.isTabFunc ){
153379154516
pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -153382,946 +154519,951 @@
153382154519
pNew->fg.isTabFunc = 1;
153383154520
}
153384154521
pOld->zName = pOld->zDatabase = 0;
153385154522
pOld->pSelect = 0;
153386154523
}
153387
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy609);
154524
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy47);
153388154525
}else{
153389154526
Select *pSubquery;
153390
- sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy609);
153391
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy609,0,0,0,0,SF_NestedFrom,0);
153392
- 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);
154527
+ sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy47);
154528
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy47,0,0,0,0,SF_NestedFrom,0);
154529
+ yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy202,yymsp[0].minor.yy600);
153393154530
}
153394154531
}
153395154532
break;
153396
- case 109: /* dbnm ::= */
153397
- case 123: /* indexed_opt ::= */ yytestcase(yyruleno==123);
154533
+ case 111: /* dbnm ::= */
154534
+ case 125: /* indexed_opt ::= */ yytestcase(yyruleno==125);
153398154535
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
153399154536
break;
153400
- case 111: /* fullname ::= nm */
153401
-{
153402
- yylhsminor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
153403
- if( IN_RENAME_OBJECT && yylhsminor.yy609 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy609->a[0].zName, &yymsp[0].minor.yy0);
153404
-}
153405
- yymsp[0].minor.yy609 = yylhsminor.yy609;
153406
- break;
153407
- case 112: /* fullname ::= nm DOT nm */
153408
-{
153409
- yylhsminor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
153410
- if( IN_RENAME_OBJECT && yylhsminor.yy609 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy609->a[0].zName, &yymsp[0].minor.yy0);
153411
-}
153412
- yymsp[-2].minor.yy609 = yylhsminor.yy609;
153413
- break;
153414
- case 113: /* xfullname ::= nm */
153415
-{yymsp[0].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
153416
- break;
153417
- case 114: /* xfullname ::= nm DOT nm */
153418
-{yymsp[-2].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
153419
- break;
153420
- case 115: /* xfullname ::= nm DOT nm AS nm */
153421
-{
153422
- yymsp[-4].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
153423
- if( yymsp[-4].minor.yy609 ) yymsp[-4].minor.yy609->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
153424
-}
153425
- break;
153426
- case 116: /* xfullname ::= nm AS nm */
153427
-{
153428
- yymsp[-2].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
153429
- if( yymsp[-2].minor.yy609 ) yymsp[-2].minor.yy609->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
153430
-}
153431
- break;
153432
- case 117: /* joinop ::= COMMA|JOIN */
153433
-{ yymsp[0].minor.yy32 = JT_INNER; }
153434
- break;
153435
- case 118: /* joinop ::= JOIN_KW JOIN */
153436
-{yymsp[-1].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
153437
- break;
153438
- case 119: /* joinop ::= JOIN_KW nm JOIN */
153439
-{yymsp[-2].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
153440
- break;
153441
- case 120: /* joinop ::= JOIN_KW nm nm JOIN */
153442
-{yymsp[-3].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
153443
- break;
153444
- case 121: /* on_opt ::= ON expr */
153445
- case 141: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==141);
153446
- case 148: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==148);
153447
- case 214: /* case_else ::= ELSE expr */ yytestcase(yyruleno==214);
153448
- case 235: /* vinto ::= INTO expr */ yytestcase(yyruleno==235);
153449
-{yymsp[-1].minor.yy46 = yymsp[0].minor.yy46;}
153450
- break;
153451
- case 122: /* on_opt ::= */
153452
- case 140: /* having_opt ::= */ yytestcase(yyruleno==140);
153453
- case 142: /* limit_opt ::= */ yytestcase(yyruleno==142);
153454
- case 147: /* where_opt ::= */ yytestcase(yyruleno==147);
153455
- case 215: /* case_else ::= */ yytestcase(yyruleno==215);
153456
- case 217: /* case_operand ::= */ yytestcase(yyruleno==217);
153457
- case 236: /* vinto ::= */ yytestcase(yyruleno==236);
153458
-{yymsp[1].minor.yy46 = 0;}
153459
- break;
153460
- case 124: /* indexed_opt ::= INDEXED BY nm */
154537
+ case 113: /* fullname ::= nm */
154538
+{
154539
+ yylhsminor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
154540
+ if( IN_RENAME_OBJECT && yylhsminor.yy47 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy47->a[0].zName, &yymsp[0].minor.yy0);
154541
+}
154542
+ yymsp[0].minor.yy47 = yylhsminor.yy47;
154543
+ break;
154544
+ case 114: /* fullname ::= nm DOT nm */
154545
+{
154546
+ yylhsminor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
154547
+ if( IN_RENAME_OBJECT && yylhsminor.yy47 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy47->a[0].zName, &yymsp[0].minor.yy0);
154548
+}
154549
+ yymsp[-2].minor.yy47 = yylhsminor.yy47;
154550
+ break;
154551
+ case 115: /* xfullname ::= nm */
154552
+{yymsp[0].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
154553
+ break;
154554
+ case 116: /* xfullname ::= nm DOT nm */
154555
+{yymsp[-2].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
154556
+ break;
154557
+ case 117: /* xfullname ::= nm DOT nm AS nm */
154558
+{
154559
+ yymsp[-4].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
154560
+ if( yymsp[-4].minor.yy47 ) yymsp[-4].minor.yy47->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
154561
+}
154562
+ break;
154563
+ case 118: /* xfullname ::= nm AS nm */
154564
+{
154565
+ yymsp[-2].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
154566
+ if( yymsp[-2].minor.yy47 ) yymsp[-2].minor.yy47->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
154567
+}
154568
+ break;
154569
+ case 119: /* joinop ::= COMMA|JOIN */
154570
+{ yymsp[0].minor.yy192 = JT_INNER; }
154571
+ break;
154572
+ case 120: /* joinop ::= JOIN_KW JOIN */
154573
+{yymsp[-1].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
154574
+ break;
154575
+ case 121: /* joinop ::= JOIN_KW nm JOIN */
154576
+{yymsp[-2].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
154577
+ break;
154578
+ case 122: /* joinop ::= JOIN_KW nm nm JOIN */
154579
+{yymsp[-3].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
154580
+ break;
154581
+ case 123: /* on_opt ::= ON expr */
154582
+ case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143);
154583
+ case 150: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==150);
154584
+ case 216: /* case_else ::= ELSE expr */ yytestcase(yyruleno==216);
154585
+ case 237: /* vinto ::= INTO expr */ yytestcase(yyruleno==237);
154586
+{yymsp[-1].minor.yy202 = yymsp[0].minor.yy202;}
154587
+ break;
154588
+ case 124: /* on_opt ::= */
154589
+ case 142: /* having_opt ::= */ yytestcase(yyruleno==142);
154590
+ case 144: /* limit_opt ::= */ yytestcase(yyruleno==144);
154591
+ case 149: /* where_opt ::= */ yytestcase(yyruleno==149);
154592
+ case 217: /* case_else ::= */ yytestcase(yyruleno==217);
154593
+ case 219: /* case_operand ::= */ yytestcase(yyruleno==219);
154594
+ case 238: /* vinto ::= */ yytestcase(yyruleno==238);
154595
+{yymsp[1].minor.yy202 = 0;}
154596
+ break;
154597
+ case 126: /* indexed_opt ::= INDEXED BY nm */
153461154598
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
153462154599
break;
153463
- case 125: /* indexed_opt ::= NOT INDEXED */
154600
+ case 127: /* indexed_opt ::= NOT INDEXED */
153464154601
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
153465154602
break;
153466
- case 126: /* using_opt ::= USING LP idlist RP */
153467
-{yymsp[-3].minor.yy406 = yymsp[-1].minor.yy406;}
153468
- break;
153469
- case 127: /* using_opt ::= */
153470
- case 162: /* idlist_opt ::= */ yytestcase(yyruleno==162);
153471
-{yymsp[1].minor.yy406 = 0;}
153472
- break;
153473
- case 129: /* orderby_opt ::= ORDER BY sortlist */
153474
- case 139: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==139);
153475
-{yymsp[-2].minor.yy138 = yymsp[0].minor.yy138;}
153476
- break;
153477
- case 130: /* sortlist ::= sortlist COMMA expr sortorder nulls */
153478
-{
153479
- yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138,yymsp[-2].minor.yy46);
153480
- sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy138,yymsp[-1].minor.yy32,yymsp[0].minor.yy32);
153481
-}
153482
- break;
153483
- case 131: /* sortlist ::= expr sortorder nulls */
153484
-{
153485
- yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy46); /*A-overwrites-Y*/
153486
- sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy138,yymsp[-1].minor.yy32,yymsp[0].minor.yy32);
153487
-}
153488
- break;
153489
- case 132: /* sortorder ::= ASC */
153490
-{yymsp[0].minor.yy32 = SQLITE_SO_ASC;}
153491
- break;
153492
- case 133: /* sortorder ::= DESC */
153493
-{yymsp[0].minor.yy32 = SQLITE_SO_DESC;}
153494
- break;
153495
- case 134: /* sortorder ::= */
153496
- case 137: /* nulls ::= */ yytestcase(yyruleno==137);
153497
-{yymsp[1].minor.yy32 = SQLITE_SO_UNDEFINED;}
153498
- break;
153499
- case 135: /* nulls ::= NULLS FIRST */
153500
-{yymsp[-1].minor.yy32 = SQLITE_SO_ASC;}
153501
- break;
153502
- case 136: /* nulls ::= NULLS LAST */
153503
-{yymsp[-1].minor.yy32 = SQLITE_SO_DESC;}
153504
- break;
153505
- case 143: /* limit_opt ::= LIMIT expr */
153506
-{yymsp[-1].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy46,0);}
153507
- break;
153508
- case 144: /* limit_opt ::= LIMIT expr OFFSET expr */
153509
-{yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153510
- break;
153511
- case 145: /* limit_opt ::= LIMIT expr COMMA expr */
153512
-{yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy46,yymsp[-2].minor.yy46);}
153513
- break;
153514
- case 146: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
153515
-{
153516
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy609, &yymsp[-1].minor.yy0);
153517
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy609,yymsp[0].minor.yy46,0,0);
153518
-}
153519
- break;
153520
- case 149: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
153521
-{
153522
- sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy609, &yymsp[-3].minor.yy0);
153523
- sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy138,"set list");
153524
- sqlite3Update(pParse,yymsp[-4].minor.yy609,yymsp[-1].minor.yy138,yymsp[0].minor.yy46,yymsp[-5].minor.yy32,0,0,0);
153525
-}
153526
- break;
153527
- case 150: /* setlist ::= setlist COMMA nm EQ expr */
153528
-{
153529
- yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy138, yymsp[0].minor.yy46);
153530
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy138, &yymsp[-2].minor.yy0, 1);
153531
-}
153532
- break;
153533
- case 151: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
153534
-{
153535
- yymsp[-6].minor.yy138 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy138, yymsp[-3].minor.yy406, yymsp[0].minor.yy46);
153536
-}
153537
- break;
153538
- case 152: /* setlist ::= nm EQ expr */
153539
-{
153540
- yylhsminor.yy138 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy46);
153541
- sqlite3ExprListSetName(pParse, yylhsminor.yy138, &yymsp[-2].minor.yy0, 1);
153542
-}
153543
- yymsp[-2].minor.yy138 = yylhsminor.yy138;
153544
- break;
153545
- case 153: /* setlist ::= LP idlist RP EQ expr */
153546
-{
153547
- yymsp[-4].minor.yy138 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy406, yymsp[0].minor.yy46);
153548
-}
153549
- break;
153550
- case 154: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
153551
-{
153552
- sqlite3Insert(pParse, yymsp[-3].minor.yy609, yymsp[-1].minor.yy25, yymsp[-2].minor.yy406, yymsp[-5].minor.yy32, yymsp[0].minor.yy288);
153553
-}
153554
- break;
153555
- case 155: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
153556
-{
153557
- sqlite3Insert(pParse, yymsp[-3].minor.yy609, 0, yymsp[-2].minor.yy406, yymsp[-5].minor.yy32, 0);
153558
-}
153559
- break;
153560
- case 156: /* upsert ::= */
153561
-{ yymsp[1].minor.yy288 = 0; }
153562
- break;
153563
- case 157: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
153564
-{ yymsp[-10].minor.yy288 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy138,yymsp[-5].minor.yy46,yymsp[-1].minor.yy138,yymsp[0].minor.yy46);}
153565
- break;
153566
- case 158: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
153567
-{ yymsp[-7].minor.yy288 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy138,yymsp[-2].minor.yy46,0,0); }
153568
- break;
153569
- case 159: /* upsert ::= ON CONFLICT DO NOTHING */
153570
-{ yymsp[-3].minor.yy288 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
153571
- break;
153572
- case 163: /* idlist_opt ::= LP idlist RP */
153573
-{yymsp[-2].minor.yy406 = yymsp[-1].minor.yy406;}
153574
- break;
153575
- case 164: /* idlist ::= idlist COMMA nm */
153576
-{yymsp[-2].minor.yy406 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy406,&yymsp[0].minor.yy0);}
153577
- break;
153578
- case 165: /* idlist ::= nm */
153579
-{yymsp[0].minor.yy406 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
153580
- break;
153581
- case 166: /* expr ::= LP expr RP */
153582
-{yymsp[-2].minor.yy46 = yymsp[-1].minor.yy46;}
153583
- break;
153584
- case 167: /* expr ::= ID|INDEXED */
153585
- case 168: /* expr ::= JOIN_KW */ yytestcase(yyruleno==168);
153586
-{yymsp[0].minor.yy46=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
153587
- break;
153588
- case 169: /* expr ::= nm DOT nm */
154603
+ case 128: /* using_opt ::= USING LP idlist RP */
154604
+{yymsp[-3].minor.yy600 = yymsp[-1].minor.yy600;}
154605
+ break;
154606
+ case 129: /* using_opt ::= */
154607
+ case 164: /* idlist_opt ::= */ yytestcase(yyruleno==164);
154608
+{yymsp[1].minor.yy600 = 0;}
154609
+ break;
154610
+ case 131: /* orderby_opt ::= ORDER BY sortlist */
154611
+ case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141);
154612
+{yymsp[-2].minor.yy242 = yymsp[0].minor.yy242;}
154613
+ break;
154614
+ case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */
154615
+{
154616
+ yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242,yymsp[-2].minor.yy202);
154617
+ sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy242,yymsp[-1].minor.yy192,yymsp[0].minor.yy192);
154618
+}
154619
+ break;
154620
+ case 133: /* sortlist ::= expr sortorder nulls */
154621
+{
154622
+ yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy202); /*A-overwrites-Y*/
154623
+ sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy242,yymsp[-1].minor.yy192,yymsp[0].minor.yy192);
154624
+}
154625
+ break;
154626
+ case 134: /* sortorder ::= ASC */
154627
+{yymsp[0].minor.yy192 = SQLITE_SO_ASC;}
154628
+ break;
154629
+ case 135: /* sortorder ::= DESC */
154630
+{yymsp[0].minor.yy192 = SQLITE_SO_DESC;}
154631
+ break;
154632
+ case 136: /* sortorder ::= */
154633
+ case 139: /* nulls ::= */ yytestcase(yyruleno==139);
154634
+{yymsp[1].minor.yy192 = SQLITE_SO_UNDEFINED;}
154635
+ break;
154636
+ case 137: /* nulls ::= NULLS FIRST */
154637
+{yymsp[-1].minor.yy192 = SQLITE_SO_ASC;}
154638
+ break;
154639
+ case 138: /* nulls ::= NULLS LAST */
154640
+{yymsp[-1].minor.yy192 = SQLITE_SO_DESC;}
154641
+ break;
154642
+ case 145: /* limit_opt ::= LIMIT expr */
154643
+{yymsp[-1].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy202,0);}
154644
+ break;
154645
+ case 146: /* limit_opt ::= LIMIT expr OFFSET expr */
154646
+{yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);}
154647
+ break;
154648
+ case 147: /* limit_opt ::= LIMIT expr COMMA expr */
154649
+{yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy202,yymsp[-2].minor.yy202);}
154650
+ break;
154651
+ case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
154652
+{
154653
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy47, &yymsp[-1].minor.yy0);
154654
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy47,yymsp[0].minor.yy202,0,0);
154655
+}
154656
+ break;
154657
+ case 151: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
154658
+{
154659
+ sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy47, &yymsp[-3].minor.yy0);
154660
+ sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy242,"set list");
154661
+ sqlite3Update(pParse,yymsp[-4].minor.yy47,yymsp[-1].minor.yy242,yymsp[0].minor.yy202,yymsp[-5].minor.yy192,0,0,0);
154662
+}
154663
+ break;
154664
+ case 152: /* setlist ::= setlist COMMA nm EQ expr */
154665
+{
154666
+ yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy242, yymsp[0].minor.yy202);
154667
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy242, &yymsp[-2].minor.yy0, 1);
154668
+}
154669
+ break;
154670
+ case 153: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
154671
+{
154672
+ yymsp[-6].minor.yy242 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy242, yymsp[-3].minor.yy600, yymsp[0].minor.yy202);
154673
+}
154674
+ break;
154675
+ case 154: /* setlist ::= nm EQ expr */
154676
+{
154677
+ yylhsminor.yy242 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy202);
154678
+ sqlite3ExprListSetName(pParse, yylhsminor.yy242, &yymsp[-2].minor.yy0, 1);
154679
+}
154680
+ yymsp[-2].minor.yy242 = yylhsminor.yy242;
154681
+ break;
154682
+ case 155: /* setlist ::= LP idlist RP EQ expr */
154683
+{
154684
+ yymsp[-4].minor.yy242 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy600, yymsp[0].minor.yy202);
154685
+}
154686
+ break;
154687
+ case 156: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
154688
+{
154689
+ sqlite3Insert(pParse, yymsp[-3].minor.yy47, yymsp[-1].minor.yy539, yymsp[-2].minor.yy600, yymsp[-5].minor.yy192, yymsp[0].minor.yy318);
154690
+}
154691
+ break;
154692
+ case 157: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
154693
+{
154694
+ sqlite3Insert(pParse, yymsp[-3].minor.yy47, 0, yymsp[-2].minor.yy600, yymsp[-5].minor.yy192, 0);
154695
+}
154696
+ break;
154697
+ case 158: /* upsert ::= */
154698
+{ yymsp[1].minor.yy318 = 0; }
154699
+ break;
154700
+ case 159: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
154701
+{ yymsp[-10].minor.yy318 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy242,yymsp[-5].minor.yy202,yymsp[-1].minor.yy242,yymsp[0].minor.yy202);}
154702
+ break;
154703
+ case 160: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
154704
+{ yymsp[-7].minor.yy318 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy242,yymsp[-2].minor.yy202,0,0); }
154705
+ break;
154706
+ case 161: /* upsert ::= ON CONFLICT DO NOTHING */
154707
+{ yymsp[-3].minor.yy318 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
154708
+ break;
154709
+ case 165: /* idlist_opt ::= LP idlist RP */
154710
+{yymsp[-2].minor.yy600 = yymsp[-1].minor.yy600;}
154711
+ break;
154712
+ case 166: /* idlist ::= idlist COMMA nm */
154713
+{yymsp[-2].minor.yy600 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy600,&yymsp[0].minor.yy0);}
154714
+ break;
154715
+ case 167: /* idlist ::= nm */
154716
+{yymsp[0].minor.yy600 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
154717
+ break;
154718
+ case 168: /* expr ::= LP expr RP */
154719
+{yymsp[-2].minor.yy202 = yymsp[-1].minor.yy202;}
154720
+ break;
154721
+ case 169: /* expr ::= ID|INDEXED */
154722
+ case 170: /* expr ::= JOIN_KW */ yytestcase(yyruleno==170);
154723
+{yymsp[0].minor.yy202=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
154724
+ break;
154725
+ case 171: /* expr ::= nm DOT nm */
153589154726
{
153590154727
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
153591154728
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
153592154729
if( IN_RENAME_OBJECT ){
153593154730
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
153594154731
sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
153595154732
}
153596
- yylhsminor.yy46 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
154733
+ yylhsminor.yy202 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
153597154734
}
153598
- yymsp[-2].minor.yy46 = yylhsminor.yy46;
154735
+ yymsp[-2].minor.yy202 = yylhsminor.yy202;
153599154736
break;
153600
- case 170: /* expr ::= nm DOT nm DOT nm */
154737
+ case 172: /* expr ::= nm DOT nm DOT nm */
153601154738
{
153602154739
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
153603154740
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
153604154741
Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
153605154742
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
153606154743
if( IN_RENAME_OBJECT ){
153607154744
sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
153608154745
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
153609154746
}
153610
- yylhsminor.yy46 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
153611
-}
153612
- yymsp[-4].minor.yy46 = yylhsminor.yy46;
153613
- break;
153614
- case 171: /* term ::= NULL|FLOAT|BLOB */
153615
- case 172: /* term ::= STRING */ yytestcase(yyruleno==172);
153616
-{yymsp[0].minor.yy46=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
153617
- break;
153618
- case 173: /* term ::= INTEGER */
153619
-{
153620
- yylhsminor.yy46 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
153621
-}
153622
- yymsp[0].minor.yy46 = yylhsminor.yy46;
153623
- break;
153624
- case 174: /* expr ::= VARIABLE */
154747
+ yylhsminor.yy202 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
154748
+}
154749
+ yymsp[-4].minor.yy202 = yylhsminor.yy202;
154750
+ break;
154751
+ case 173: /* term ::= NULL|FLOAT|BLOB */
154752
+ case 174: /* term ::= STRING */ yytestcase(yyruleno==174);
154753
+{yymsp[0].minor.yy202=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
154754
+ break;
154755
+ case 175: /* term ::= INTEGER */
154756
+{
154757
+ yylhsminor.yy202 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
154758
+}
154759
+ yymsp[0].minor.yy202 = yylhsminor.yy202;
154760
+ break;
154761
+ case 176: /* expr ::= VARIABLE */
153625154762
{
153626154763
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
153627154764
u32 n = yymsp[0].minor.yy0.n;
153628
- yymsp[0].minor.yy46 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
153629
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy46, n);
154765
+ yymsp[0].minor.yy202 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
154766
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy202, n);
153630154767
}else{
153631154768
/* When doing a nested parse, one can include terms in an expression
153632154769
** that look like this: #1 #2 ... These terms refer to registers
153633154770
** in the virtual machine. #N is the N-th register. */
153634154771
Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
153635154772
assert( t.n>=2 );
153636154773
if( pParse->nested==0 ){
153637154774
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
153638
- yymsp[0].minor.yy46 = 0;
153639
- }else{
153640
- yymsp[0].minor.yy46 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
153641
- if( yymsp[0].minor.yy46 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy46->iTable);
153642
- }
153643
- }
153644
-}
153645
- break;
153646
- case 175: /* expr ::= expr COLLATE ID|STRING */
153647
-{
153648
- yymsp[-2].minor.yy46 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy46, &yymsp[0].minor.yy0, 1);
153649
-}
153650
- break;
153651
- case 176: /* expr ::= CAST LP expr AS typetoken RP */
153652
-{
153653
- yymsp[-5].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
153654
- sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy46, yymsp[-3].minor.yy46, 0);
153655
-}
153656
- break;
153657
- case 177: /* expr ::= ID|INDEXED LP distinct exprlist RP */
153658
-{
153659
- yylhsminor.yy46 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy138, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy32);
153660
-}
153661
- yymsp[-4].minor.yy46 = yylhsminor.yy46;
153662
- break;
153663
- case 178: /* expr ::= ID|INDEXED LP STAR RP */
153664
-{
153665
- yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
153666
-}
153667
- yymsp[-3].minor.yy46 = yylhsminor.yy46;
153668
- break;
153669
- case 179: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
153670
-{
153671
- yylhsminor.yy46 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy138, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy32);
153672
- sqlite3WindowAttach(pParse, yylhsminor.yy46, yymsp[0].minor.yy455);
153673
-}
153674
- yymsp[-5].minor.yy46 = yylhsminor.yy46;
153675
- break;
153676
- case 180: /* expr ::= ID|INDEXED LP STAR RP filter_over */
153677
-{
153678
- yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
153679
- sqlite3WindowAttach(pParse, yylhsminor.yy46, yymsp[0].minor.yy455);
153680
-}
153681
- yymsp[-4].minor.yy46 = yylhsminor.yy46;
153682
- break;
153683
- case 181: /* term ::= CTIME_KW */
153684
-{
153685
- yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
153686
-}
153687
- yymsp[0].minor.yy46 = yylhsminor.yy46;
153688
- break;
153689
- case 182: /* expr ::= LP nexprlist COMMA expr RP */
153690
-{
153691
- ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy138, yymsp[-1].minor.yy46);
153692
- yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
153693
- if( yymsp[-4].minor.yy46 ){
153694
- yymsp[-4].minor.yy46->x.pList = pList;
154775
+ yymsp[0].minor.yy202 = 0;
154776
+ }else{
154777
+ yymsp[0].minor.yy202 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
154778
+ if( yymsp[0].minor.yy202 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy202->iTable);
154779
+ }
154780
+ }
154781
+}
154782
+ break;
154783
+ case 177: /* expr ::= expr COLLATE ID|STRING */
154784
+{
154785
+ yymsp[-2].minor.yy202 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy202, &yymsp[0].minor.yy0, 1);
154786
+}
154787
+ break;
154788
+ case 178: /* expr ::= CAST LP expr AS typetoken RP */
154789
+{
154790
+ yymsp[-5].minor.yy202 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
154791
+ sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy202, yymsp[-3].minor.yy202, 0);
154792
+}
154793
+ break;
154794
+ case 179: /* expr ::= ID|INDEXED LP distinct exprlist RP */
154795
+{
154796
+ yylhsminor.yy202 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy242, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy192);
154797
+}
154798
+ yymsp[-4].minor.yy202 = yylhsminor.yy202;
154799
+ break;
154800
+ case 180: /* expr ::= ID|INDEXED LP STAR RP */
154801
+{
154802
+ yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
154803
+}
154804
+ yymsp[-3].minor.yy202 = yylhsminor.yy202;
154805
+ break;
154806
+ case 181: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
154807
+{
154808
+ yylhsminor.yy202 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy242, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy192);
154809
+ sqlite3WindowAttach(pParse, yylhsminor.yy202, yymsp[0].minor.yy303);
154810
+}
154811
+ yymsp[-5].minor.yy202 = yylhsminor.yy202;
154812
+ break;
154813
+ case 182: /* expr ::= ID|INDEXED LP STAR RP filter_over */
154814
+{
154815
+ yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
154816
+ sqlite3WindowAttach(pParse, yylhsminor.yy202, yymsp[0].minor.yy303);
154817
+}
154818
+ yymsp[-4].minor.yy202 = yylhsminor.yy202;
154819
+ break;
154820
+ case 183: /* term ::= CTIME_KW */
154821
+{
154822
+ yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
154823
+}
154824
+ yymsp[0].minor.yy202 = yylhsminor.yy202;
154825
+ break;
154826
+ case 184: /* expr ::= LP nexprlist COMMA expr RP */
154827
+{
154828
+ ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy242, yymsp[-1].minor.yy202);
154829
+ yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
154830
+ if( yymsp[-4].minor.yy202 ){
154831
+ yymsp[-4].minor.yy202->x.pList = pList;
154832
+ if( ALWAYS(pList->nExpr) ){
154833
+ yymsp[-4].minor.yy202->flags |= pList->a[0].pExpr->flags & EP_Propagate;
154834
+ }
153695154835
}else{
153696154836
sqlite3ExprListDelete(pParse->db, pList);
153697154837
}
153698154838
}
153699154839
break;
153700
- case 183: /* expr ::= expr AND expr */
153701
-{yymsp[-2].minor.yy46=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153702
- break;
153703
- case 184: /* expr ::= expr OR expr */
153704
- case 185: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==185);
153705
- case 186: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==186);
153706
- case 187: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==187);
153707
- case 188: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==188);
153708
- case 189: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==189);
153709
- case 190: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==190);
153710
-{yymsp[-2].minor.yy46=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153711
- break;
153712
- case 191: /* likeop ::= NOT LIKE_KW|MATCH */
154840
+ case 185: /* expr ::= expr AND expr */
154841
+{yymsp[-2].minor.yy202=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);}
154842
+ break;
154843
+ case 186: /* expr ::= expr OR expr */
154844
+ case 187: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==187);
154845
+ case 188: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==188);
154846
+ case 189: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==189);
154847
+ case 190: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==190);
154848
+ case 191: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==191);
154849
+ case 192: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==192);
154850
+{yymsp[-2].minor.yy202=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);}
154851
+ break;
154852
+ case 193: /* likeop ::= NOT LIKE_KW|MATCH */
153713154853
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
153714154854
break;
153715
- case 192: /* expr ::= expr likeop expr */
154855
+ case 194: /* expr ::= expr likeop expr */
153716154856
{
153717154857
ExprList *pList;
153718154858
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
153719154859
yymsp[-1].minor.yy0.n &= 0x7fffffff;
153720
- pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy46);
153721
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy46);
153722
- yymsp[-2].minor.yy46 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
153723
- if( bNot ) yymsp[-2].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy46, 0);
153724
- if( yymsp[-2].minor.yy46 ) yymsp[-2].minor.yy46->flags |= EP_InfixFunc;
154860
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy202);
154861
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy202);
154862
+ yymsp[-2].minor.yy202 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
154863
+ if( bNot ) yymsp[-2].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy202, 0);
154864
+ if( yymsp[-2].minor.yy202 ) yymsp[-2].minor.yy202->flags |= EP_InfixFunc;
153725154865
}
153726154866
break;
153727
- case 193: /* expr ::= expr likeop expr ESCAPE expr */
154867
+ case 195: /* expr ::= expr likeop expr ESCAPE expr */
153728154868
{
153729154869
ExprList *pList;
153730154870
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
153731154871
yymsp[-3].minor.yy0.n &= 0x7fffffff;
153732
- pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153733
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy46);
153734
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy46);
153735
- yymsp[-4].minor.yy46 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
153736
- if( bNot ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153737
- if( yymsp[-4].minor.yy46 ) yymsp[-4].minor.yy46->flags |= EP_InfixFunc;
153738
-}
153739
- break;
153740
- case 194: /* expr ::= expr ISNULL|NOTNULL */
153741
-{yymsp[-1].minor.yy46 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy46,0);}
153742
- break;
153743
- case 195: /* expr ::= expr NOT NULL */
153744
-{yymsp[-2].minor.yy46 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy46,0);}
153745
- break;
153746
- case 196: /* expr ::= expr IS expr */
153747
-{
153748
- yymsp[-2].minor.yy46 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);
153749
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy46, yymsp[-2].minor.yy46, TK_ISNULL);
153750
-}
153751
- break;
153752
- case 197: /* expr ::= expr IS NOT expr */
153753
-{
153754
- yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy46,yymsp[0].minor.yy46);
153755
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy46, yymsp[-3].minor.yy46, TK_NOTNULL);
153756
-}
153757
- break;
153758
- case 198: /* expr ::= NOT expr */
153759
- case 199: /* expr ::= BITNOT expr */ yytestcase(yyruleno==199);
153760
-{yymsp[-1].minor.yy46 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy46, 0);/*A-overwrites-B*/}
153761
- break;
153762
- case 200: /* expr ::= PLUS|MINUS expr */
153763
-{
153764
- yymsp[-1].minor.yy46 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy46, 0);
154872
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202);
154873
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy202);
154874
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy202);
154875
+ yymsp[-4].minor.yy202 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
154876
+ if( bNot ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0);
154877
+ if( yymsp[-4].minor.yy202 ) yymsp[-4].minor.yy202->flags |= EP_InfixFunc;
154878
+}
154879
+ break;
154880
+ case 196: /* expr ::= expr ISNULL|NOTNULL */
154881
+{yymsp[-1].minor.yy202 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy202,0);}
154882
+ break;
154883
+ case 197: /* expr ::= expr NOT NULL */
154884
+{yymsp[-2].minor.yy202 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy202,0);}
154885
+ break;
154886
+ case 198: /* expr ::= expr IS expr */
154887
+{
154888
+ yymsp[-2].minor.yy202 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);
154889
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy202, yymsp[-2].minor.yy202, TK_ISNULL);
154890
+}
154891
+ break;
154892
+ case 199: /* expr ::= expr IS NOT expr */
154893
+{
154894
+ yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy202,yymsp[0].minor.yy202);
154895
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy202, yymsp[-3].minor.yy202, TK_NOTNULL);
154896
+}
154897
+ break;
154898
+ case 200: /* expr ::= NOT expr */
154899
+ case 201: /* expr ::= BITNOT expr */ yytestcase(yyruleno==201);
154900
+{yymsp[-1].minor.yy202 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy202, 0);/*A-overwrites-B*/}
154901
+ break;
154902
+ case 202: /* expr ::= PLUS|MINUS expr */
154903
+{
154904
+ yymsp[-1].minor.yy202 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy202, 0);
153765154905
/*A-overwrites-B*/
153766154906
}
153767154907
break;
153768
- case 201: /* between_op ::= BETWEEN */
153769
- case 204: /* in_op ::= IN */ yytestcase(yyruleno==204);
153770
-{yymsp[0].minor.yy32 = 0;}
153771
- break;
153772
- case 203: /* expr ::= expr between_op expr AND expr */
153773
-{
153774
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153775
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy46);
153776
- yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy46, 0);
153777
- if( yymsp[-4].minor.yy46 ){
153778
- yymsp[-4].minor.yy46->x.pList = pList;
154908
+ case 203: /* between_op ::= BETWEEN */
154909
+ case 206: /* in_op ::= IN */ yytestcase(yyruleno==206);
154910
+{yymsp[0].minor.yy192 = 0;}
154911
+ break;
154912
+ case 205: /* expr ::= expr between_op expr AND expr */
154913
+{
154914
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202);
154915
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy202);
154916
+ yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy202, 0);
154917
+ if( yymsp[-4].minor.yy202 ){
154918
+ yymsp[-4].minor.yy202->x.pList = pList;
153779154919
}else{
153780154920
sqlite3ExprListDelete(pParse->db, pList);
153781154921
}
153782
- if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
154922
+ if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0);
153783154923
}
153784154924
break;
153785
- case 206: /* expr ::= expr in_op LP exprlist RP */
154925
+ case 208: /* expr ::= expr in_op LP exprlist RP */
153786154926
{
153787
- if( yymsp[-1].minor.yy138==0 ){
154927
+ if( yymsp[-1].minor.yy242==0 ){
153788154928
/* Expressions of the form
153789154929
**
153790154930
** expr1 IN ()
153791154931
** expr1 NOT IN ()
153792154932
**
153793154933
** simplify to constants 0 (false) and 1 (true), respectively,
153794154934
** regardless of the value of expr1.
153795154935
*/
153796
- sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy46);
153797
- yymsp[-4].minor.yy46 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy32 ? "1" : "0");
153798
- }else{
153799
- yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153800
- if( yymsp[-4].minor.yy46 ){
153801
- yymsp[-4].minor.yy46->x.pList = yymsp[-1].minor.yy138;
153802
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy46);
153803
- }else{
153804
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy138);
153805
- }
153806
- if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153807
- }
153808
- }
153809
- break;
153810
- case 207: /* expr ::= LP select RP */
153811
-{
153812
- yymsp[-2].minor.yy46 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
153813
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy46, yymsp[-1].minor.yy25);
153814
- }
153815
- break;
153816
- case 208: /* expr ::= expr in_op LP select RP */
153817
-{
153818
- yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153819
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy46, yymsp[-1].minor.yy25);
153820
- if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153821
- }
153822
- break;
153823
- case 209: /* expr ::= expr in_op nm dbnm paren_exprlist */
154936
+ sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy202);
154937
+ yymsp[-4].minor.yy202 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy192 ? "1" : "0");
154938
+ }else{
154939
+ yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0);
154940
+ if( yymsp[-4].minor.yy202 ){
154941
+ yymsp[-4].minor.yy202->x.pList = yymsp[-1].minor.yy242;
154942
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy202);
154943
+ }else{
154944
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy242);
154945
+ }
154946
+ if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0);
154947
+ }
154948
+ }
154949
+ break;
154950
+ case 209: /* expr ::= LP select RP */
154951
+{
154952
+ yymsp[-2].minor.yy202 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
154953
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy202, yymsp[-1].minor.yy539);
154954
+ }
154955
+ break;
154956
+ case 210: /* expr ::= expr in_op LP select RP */
154957
+{
154958
+ yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0);
154959
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy202, yymsp[-1].minor.yy539);
154960
+ if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0);
154961
+ }
154962
+ break;
154963
+ case 211: /* expr ::= expr in_op nm dbnm paren_exprlist */
153824154964
{
153825154965
SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
153826154966
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
153827
- if( yymsp[0].minor.yy138 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy138);
153828
- yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153829
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy46, pSelect);
153830
- if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
154967
+ if( yymsp[0].minor.yy242 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy242);
154968
+ yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0);
154969
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy202, pSelect);
154970
+ if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0);
153831154971
}
153832154972
break;
153833
- case 210: /* expr ::= EXISTS LP select RP */
154973
+ case 212: /* expr ::= EXISTS LP select RP */
153834154974
{
153835154975
Expr *p;
153836
- p = yymsp[-3].minor.yy46 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
153837
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy25);
153838
- }
153839
- break;
153840
- case 211: /* expr ::= CASE case_operand case_exprlist case_else END */
153841
-{
153842
- yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy46, 0);
153843
- if( yymsp[-4].minor.yy46 ){
153844
- yymsp[-4].minor.yy46->x.pList = yymsp[-1].minor.yy46 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy138,yymsp[-1].minor.yy46) : yymsp[-2].minor.yy138;
153845
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy46);
153846
- }else{
153847
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy138);
153848
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy46);
153849
- }
153850
-}
153851
- break;
153852
- case 212: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
153853
-{
153854
- yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, yymsp[-2].minor.yy46);
153855
- yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, yymsp[0].minor.yy46);
153856
-}
153857
- break;
153858
- case 213: /* case_exprlist ::= WHEN expr THEN expr */
153859
-{
153860
- yymsp[-3].minor.yy138 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153861
- yymsp[-3].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy138, yymsp[0].minor.yy46);
153862
-}
153863
- break;
153864
- case 216: /* case_operand ::= expr */
153865
-{yymsp[0].minor.yy46 = yymsp[0].minor.yy46; /*A-overwrites-X*/}
153866
- break;
153867
- case 219: /* nexprlist ::= nexprlist COMMA expr */
153868
-{yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy138,yymsp[0].minor.yy46);}
153869
- break;
153870
- case 220: /* nexprlist ::= expr */
153871
-{yymsp[0].minor.yy138 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy46); /*A-overwrites-Y*/}
153872
- break;
153873
- case 222: /* paren_exprlist ::= LP exprlist RP */
153874
- case 227: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==227);
153875
-{yymsp[-2].minor.yy138 = yymsp[-1].minor.yy138;}
153876
- break;
153877
- case 223: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
154976
+ p = yymsp[-3].minor.yy202 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
154977
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy539);
154978
+ }
154979
+ break;
154980
+ case 213: /* expr ::= CASE case_operand case_exprlist case_else END */
154981
+{
154982
+ yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy202, 0);
154983
+ if( yymsp[-4].minor.yy202 ){
154984
+ yymsp[-4].minor.yy202->x.pList = yymsp[-1].minor.yy202 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy242,yymsp[-1].minor.yy202) : yymsp[-2].minor.yy242;
154985
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy202);
154986
+ }else{
154987
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy242);
154988
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy202);
154989
+ }
154990
+}
154991
+ break;
154992
+ case 214: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
154993
+{
154994
+ yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, yymsp[-2].minor.yy202);
154995
+ yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, yymsp[0].minor.yy202);
154996
+}
154997
+ break;
154998
+ case 215: /* case_exprlist ::= WHEN expr THEN expr */
154999
+{
155000
+ yymsp[-3].minor.yy242 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202);
155001
+ yymsp[-3].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy242, yymsp[0].minor.yy202);
155002
+}
155003
+ break;
155004
+ case 218: /* case_operand ::= expr */
155005
+{yymsp[0].minor.yy202 = yymsp[0].minor.yy202; /*A-overwrites-X*/}
155006
+ break;
155007
+ case 221: /* nexprlist ::= nexprlist COMMA expr */
155008
+{yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy242,yymsp[0].minor.yy202);}
155009
+ break;
155010
+ case 222: /* nexprlist ::= expr */
155011
+{yymsp[0].minor.yy242 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy202); /*A-overwrites-Y*/}
155012
+ break;
155013
+ case 224: /* paren_exprlist ::= LP exprlist RP */
155014
+ case 229: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==229);
155015
+{yymsp[-2].minor.yy242 = yymsp[-1].minor.yy242;}
155016
+ break;
155017
+ case 225: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
153878155018
{
153879155019
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
153880
- sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy138, yymsp[-10].minor.yy32,
153881
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy46, SQLITE_SO_ASC, yymsp[-8].minor.yy32, SQLITE_IDXTYPE_APPDEF);
155020
+ sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy242, yymsp[-10].minor.yy192,
155021
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy202, SQLITE_SO_ASC, yymsp[-8].minor.yy192, SQLITE_IDXTYPE_APPDEF);
153882155022
if( IN_RENAME_OBJECT && pParse->pNewIndex ){
153883155023
sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
153884155024
}
153885155025
}
153886155026
break;
153887
- case 224: /* uniqueflag ::= UNIQUE */
153888
- case 266: /* raisetype ::= ABORT */ yytestcase(yyruleno==266);
153889
-{yymsp[0].minor.yy32 = OE_Abort;}
153890
- break;
153891
- case 225: /* uniqueflag ::= */
153892
-{yymsp[1].minor.yy32 = OE_None;}
153893
- break;
153894
- case 228: /* eidlist ::= eidlist COMMA nm collate sortorder */
153895
-{
153896
- yymsp[-4].minor.yy138 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy138, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy32, yymsp[0].minor.yy32);
153897
-}
153898
- break;
153899
- case 229: /* eidlist ::= nm collate sortorder */
153900
-{
153901
- yymsp[-2].minor.yy138 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy32, yymsp[0].minor.yy32); /*A-overwrites-Y*/
153902
-}
153903
- break;
153904
- case 232: /* cmd ::= DROP INDEX ifexists fullname */
153905
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy609, yymsp[-1].minor.yy32);}
153906
- break;
153907
- case 233: /* cmd ::= VACUUM vinto */
153908
-{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy46);}
153909
- break;
153910
- case 234: /* cmd ::= VACUUM nm vinto */
153911
-{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy46);}
153912
- break;
153913
- case 237: /* cmd ::= PRAGMA nm dbnm */
155027
+ case 226: /* uniqueflag ::= UNIQUE */
155028
+ case 268: /* raisetype ::= ABORT */ yytestcase(yyruleno==268);
155029
+{yymsp[0].minor.yy192 = OE_Abort;}
155030
+ break;
155031
+ case 227: /* uniqueflag ::= */
155032
+{yymsp[1].minor.yy192 = OE_None;}
155033
+ break;
155034
+ case 230: /* eidlist ::= eidlist COMMA nm collate sortorder */
155035
+{
155036
+ yymsp[-4].minor.yy242 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy242, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy192, yymsp[0].minor.yy192);
155037
+}
155038
+ break;
155039
+ case 231: /* eidlist ::= nm collate sortorder */
155040
+{
155041
+ yymsp[-2].minor.yy242 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy192, yymsp[0].minor.yy192); /*A-overwrites-Y*/
155042
+}
155043
+ break;
155044
+ case 234: /* cmd ::= DROP INDEX ifexists fullname */
155045
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy47, yymsp[-1].minor.yy192);}
155046
+ break;
155047
+ case 235: /* cmd ::= VACUUM vinto */
155048
+{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy202);}
155049
+ break;
155050
+ case 236: /* cmd ::= VACUUM nm vinto */
155051
+{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy202);}
155052
+ break;
155053
+ case 239: /* cmd ::= PRAGMA nm dbnm */
153914155054
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
153915155055
break;
153916
- case 238: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
155056
+ case 240: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
153917155057
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
153918155058
break;
153919
- case 239: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
155059
+ case 241: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
153920155060
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
153921155061
break;
153922
- case 240: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
155062
+ case 242: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
153923155063
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
153924155064
break;
153925
- case 241: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
155065
+ case 243: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
153926155066
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
153927155067
break;
153928
- case 244: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
155068
+ case 246: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
153929155069
{
153930155070
Token all;
153931155071
all.z = yymsp[-3].minor.yy0.z;
153932155072
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
153933
- sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy527, &all);
155073
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy447, &all);
153934155074
}
153935155075
break;
153936
- case 245: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
155076
+ case 247: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
153937155077
{
153938
- 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);
155078
+ sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy192, yymsp[-4].minor.yy230.a, yymsp[-4].minor.yy230.b, yymsp[-2].minor.yy47, yymsp[0].minor.yy202, yymsp[-10].minor.yy192, yymsp[-8].minor.yy192);
153939155079
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
153940155080
}
153941155081
break;
153942
- case 246: /* trigger_time ::= BEFORE|AFTER */
153943
-{ yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-X*/ }
153944
- break;
153945
- case 247: /* trigger_time ::= INSTEAD OF */
153946
-{ yymsp[-1].minor.yy32 = TK_INSTEAD;}
153947
- break;
153948
- case 248: /* trigger_time ::= */
153949
-{ yymsp[1].minor.yy32 = TK_BEFORE; }
153950
- break;
153951
- case 249: /* trigger_event ::= DELETE|INSERT */
153952
- case 250: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==250);
153953
-{yymsp[0].minor.yy572.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy572.b = 0;}
153954
- break;
153955
- case 251: /* trigger_event ::= UPDATE OF idlist */
153956
-{yymsp[-2].minor.yy572.a = TK_UPDATE; yymsp[-2].minor.yy572.b = yymsp[0].minor.yy406;}
153957
- break;
153958
- case 252: /* when_clause ::= */
153959
- case 271: /* key_opt ::= */ yytestcase(yyruleno==271);
153960
-{ yymsp[1].minor.yy46 = 0; }
153961
- break;
153962
- case 253: /* when_clause ::= WHEN expr */
153963
- case 272: /* key_opt ::= KEY expr */ yytestcase(yyruleno==272);
153964
-{ yymsp[-1].minor.yy46 = yymsp[0].minor.yy46; }
153965
- break;
153966
- case 254: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
153967
-{
153968
- assert( yymsp[-2].minor.yy527!=0 );
153969
- yymsp[-2].minor.yy527->pLast->pNext = yymsp[-1].minor.yy527;
153970
- yymsp[-2].minor.yy527->pLast = yymsp[-1].minor.yy527;
153971
-}
153972
- break;
153973
- case 255: /* trigger_cmd_list ::= trigger_cmd SEMI */
153974
-{
153975
- assert( yymsp[-1].minor.yy527!=0 );
153976
- yymsp[-1].minor.yy527->pLast = yymsp[-1].minor.yy527;
153977
-}
153978
- break;
153979
- case 256: /* trnm ::= nm DOT nm */
155082
+ case 248: /* trigger_time ::= BEFORE|AFTER */
155083
+{ yymsp[0].minor.yy192 = yymsp[0].major; /*A-overwrites-X*/ }
155084
+ break;
155085
+ case 249: /* trigger_time ::= INSTEAD OF */
155086
+{ yymsp[-1].minor.yy192 = TK_INSTEAD;}
155087
+ break;
155088
+ case 250: /* trigger_time ::= */
155089
+{ yymsp[1].minor.yy192 = TK_BEFORE; }
155090
+ break;
155091
+ case 251: /* trigger_event ::= DELETE|INSERT */
155092
+ case 252: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==252);
155093
+{yymsp[0].minor.yy230.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy230.b = 0;}
155094
+ break;
155095
+ case 253: /* trigger_event ::= UPDATE OF idlist */
155096
+{yymsp[-2].minor.yy230.a = TK_UPDATE; yymsp[-2].minor.yy230.b = yymsp[0].minor.yy600;}
155097
+ break;
155098
+ case 254: /* when_clause ::= */
155099
+ case 273: /* key_opt ::= */ yytestcase(yyruleno==273);
155100
+{ yymsp[1].minor.yy202 = 0; }
155101
+ break;
155102
+ case 255: /* when_clause ::= WHEN expr */
155103
+ case 274: /* key_opt ::= KEY expr */ yytestcase(yyruleno==274);
155104
+{ yymsp[-1].minor.yy202 = yymsp[0].minor.yy202; }
155105
+ break;
155106
+ case 256: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
155107
+{
155108
+ assert( yymsp[-2].minor.yy447!=0 );
155109
+ yymsp[-2].minor.yy447->pLast->pNext = yymsp[-1].minor.yy447;
155110
+ yymsp[-2].minor.yy447->pLast = yymsp[-1].minor.yy447;
155111
+}
155112
+ break;
155113
+ case 257: /* trigger_cmd_list ::= trigger_cmd SEMI */
155114
+{
155115
+ assert( yymsp[-1].minor.yy447!=0 );
155116
+ yymsp[-1].minor.yy447->pLast = yymsp[-1].minor.yy447;
155117
+}
155118
+ break;
155119
+ case 258: /* trnm ::= nm DOT nm */
153980155120
{
153981155121
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
153982155122
sqlite3ErrorMsg(pParse,
153983155123
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
153984155124
"statements within triggers");
153985155125
}
153986155126
break;
153987
- case 257: /* tridxby ::= INDEXED BY nm */
155127
+ case 259: /* tridxby ::= INDEXED BY nm */
153988155128
{
153989155129
sqlite3ErrorMsg(pParse,
153990155130
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
153991155131
"within triggers");
153992155132
}
153993155133
break;
153994
- case 258: /* tridxby ::= NOT INDEXED */
155134
+ case 260: /* tridxby ::= NOT INDEXED */
153995155135
{
153996155136
sqlite3ErrorMsg(pParse,
153997155137
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
153998155138
"within triggers");
153999155139
}
154000155140
break;
154001
- case 259: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
154002
-{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);}
154003
- yymsp[-7].minor.yy527 = yylhsminor.yy527;
154004
- break;
154005
- case 260: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
154006
-{
154007
- 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*/
154008
-}
154009
- yymsp[-7].minor.yy527 = yylhsminor.yy527;
154010
- break;
154011
- case 261: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
154012
-{yylhsminor.yy527 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy46, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy8);}
154013
- yymsp[-5].minor.yy527 = yylhsminor.yy527;
154014
- break;
154015
- case 262: /* trigger_cmd ::= scanpt select scanpt */
154016
-{yylhsminor.yy527 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy25, yymsp[-2].minor.yy8, yymsp[0].minor.yy8); /*yylhsminor.yy527-overwrites-yymsp[-1].minor.yy25*/}
154017
- yymsp[-2].minor.yy527 = yylhsminor.yy527;
154018
- break;
154019
- case 263: /* expr ::= RAISE LP IGNORE RP */
154020
-{
154021
- yymsp[-3].minor.yy46 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
154022
- if( yymsp[-3].minor.yy46 ){
154023
- yymsp[-3].minor.yy46->affExpr = OE_Ignore;
154024
- }
154025
-}
154026
- break;
154027
- case 264: /* expr ::= RAISE LP raisetype COMMA nm RP */
154028
-{
154029
- yymsp[-5].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
154030
- if( yymsp[-5].minor.yy46 ) {
154031
- yymsp[-5].minor.yy46->affExpr = (char)yymsp[-3].minor.yy32;
154032
- }
154033
-}
154034
- break;
154035
- case 265: /* raisetype ::= ROLLBACK */
154036
-{yymsp[0].minor.yy32 = OE_Rollback;}
154037
- break;
154038
- case 267: /* raisetype ::= FAIL */
154039
-{yymsp[0].minor.yy32 = OE_Fail;}
154040
- break;
154041
- case 268: /* cmd ::= DROP TRIGGER ifexists fullname */
154042
-{
154043
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy609,yymsp[-1].minor.yy32);
154044
-}
154045
- break;
154046
- case 269: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
154047
-{
154048
- sqlite3Attach(pParse, yymsp[-3].minor.yy46, yymsp[-1].minor.yy46, yymsp[0].minor.yy46);
154049
-}
154050
- break;
154051
- case 270: /* cmd ::= DETACH database_kw_opt expr */
154052
-{
154053
- sqlite3Detach(pParse, yymsp[0].minor.yy46);
154054
-}
154055
- break;
154056
- case 273: /* cmd ::= REINDEX */
155141
+ case 261: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
155142
+{yylhsminor.yy447 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy242, yymsp[-1].minor.yy202, yymsp[-6].minor.yy192, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy436);}
155143
+ yymsp[-7].minor.yy447 = yylhsminor.yy447;
155144
+ break;
155145
+ case 262: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
155146
+{
155147
+ yylhsminor.yy447 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy600,yymsp[-2].minor.yy539,yymsp[-6].minor.yy192,yymsp[-1].minor.yy318,yymsp[-7].minor.yy436,yymsp[0].minor.yy436);/*yylhsminor.yy447-overwrites-yymsp[-6].minor.yy192*/
155148
+}
155149
+ yymsp[-7].minor.yy447 = yylhsminor.yy447;
155150
+ break;
155151
+ case 263: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
155152
+{yylhsminor.yy447 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy202, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy436);}
155153
+ yymsp[-5].minor.yy447 = yylhsminor.yy447;
155154
+ break;
155155
+ case 264: /* trigger_cmd ::= scanpt select scanpt */
155156
+{yylhsminor.yy447 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy539, yymsp[-2].minor.yy436, yymsp[0].minor.yy436); /*yylhsminor.yy447-overwrites-yymsp[-1].minor.yy539*/}
155157
+ yymsp[-2].minor.yy447 = yylhsminor.yy447;
155158
+ break;
155159
+ case 265: /* expr ::= RAISE LP IGNORE RP */
155160
+{
155161
+ yymsp[-3].minor.yy202 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
155162
+ if( yymsp[-3].minor.yy202 ){
155163
+ yymsp[-3].minor.yy202->affExpr = OE_Ignore;
155164
+ }
155165
+}
155166
+ break;
155167
+ case 266: /* expr ::= RAISE LP raisetype COMMA nm RP */
155168
+{
155169
+ yymsp[-5].minor.yy202 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
155170
+ if( yymsp[-5].minor.yy202 ) {
155171
+ yymsp[-5].minor.yy202->affExpr = (char)yymsp[-3].minor.yy192;
155172
+ }
155173
+}
155174
+ break;
155175
+ case 267: /* raisetype ::= ROLLBACK */
155176
+{yymsp[0].minor.yy192 = OE_Rollback;}
155177
+ break;
155178
+ case 269: /* raisetype ::= FAIL */
155179
+{yymsp[0].minor.yy192 = OE_Fail;}
155180
+ break;
155181
+ case 270: /* cmd ::= DROP TRIGGER ifexists fullname */
155182
+{
155183
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy47,yymsp[-1].minor.yy192);
155184
+}
155185
+ break;
155186
+ case 271: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
155187
+{
155188
+ sqlite3Attach(pParse, yymsp[-3].minor.yy202, yymsp[-1].minor.yy202, yymsp[0].minor.yy202);
155189
+}
155190
+ break;
155191
+ case 272: /* cmd ::= DETACH database_kw_opt expr */
155192
+{
155193
+ sqlite3Detach(pParse, yymsp[0].minor.yy202);
155194
+}
155195
+ break;
155196
+ case 275: /* cmd ::= REINDEX */
154057155197
{sqlite3Reindex(pParse, 0, 0);}
154058155198
break;
154059
- case 274: /* cmd ::= REINDEX nm dbnm */
155199
+ case 276: /* cmd ::= REINDEX nm dbnm */
154060155200
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
154061155201
break;
154062
- case 275: /* cmd ::= ANALYZE */
155202
+ case 277: /* cmd ::= ANALYZE */
154063155203
{sqlite3Analyze(pParse, 0, 0);}
154064155204
break;
154065
- case 276: /* cmd ::= ANALYZE nm dbnm */
155205
+ case 278: /* cmd ::= ANALYZE nm dbnm */
154066155206
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
154067155207
break;
154068
- case 277: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
155208
+ case 279: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
154069155209
{
154070
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy609,&yymsp[0].minor.yy0);
155210
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy47,&yymsp[0].minor.yy0);
154071155211
}
154072155212
break;
154073
- case 278: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
155213
+ case 280: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
154074155214
{
154075155215
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
154076155216
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
154077155217
}
154078155218
break;
154079
- case 279: /* add_column_fullname ::= fullname */
155219
+ case 281: /* add_column_fullname ::= fullname */
154080155220
{
154081155221
disableLookaside(pParse);
154082
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy609);
154083
-}
154084
- break;
154085
- case 280: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
154086
-{
154087
- sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy609, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
154088
-}
154089
- break;
154090
- case 281: /* cmd ::= create_vtab */
155222
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy47);
155223
+}
155224
+ break;
155225
+ case 282: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
155226
+{
155227
+ sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy47, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
155228
+}
155229
+ break;
155230
+ case 283: /* cmd ::= create_vtab */
154091155231
{sqlite3VtabFinishParse(pParse,0);}
154092155232
break;
154093
- case 282: /* cmd ::= create_vtab LP vtabarglist RP */
155233
+ case 284: /* cmd ::= create_vtab LP vtabarglist RP */
154094155234
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
154095155235
break;
154096
- case 283: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
155236
+ case 285: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
154097155237
{
154098
- sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy32);
155238
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy192);
154099155239
}
154100155240
break;
154101
- case 284: /* vtabarg ::= */
155241
+ case 286: /* vtabarg ::= */
154102155242
{sqlite3VtabArgInit(pParse);}
154103155243
break;
154104
- case 285: /* vtabargtoken ::= ANY */
154105
- case 286: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==286);
154106
- case 287: /* lp ::= LP */ yytestcase(yyruleno==287);
155244
+ case 287: /* vtabargtoken ::= ANY */
155245
+ case 288: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==288);
155246
+ case 289: /* lp ::= LP */ yytestcase(yyruleno==289);
154107155247
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
154108155248
break;
154109
- case 288: /* with ::= WITH wqlist */
154110
- case 289: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==289);
154111
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy297, 1); }
154112
- break;
154113
- case 290: /* wqlist ::= nm eidlist_opt AS LP select RP */
154114
-{
154115
- yymsp[-5].minor.yy297 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy138, yymsp[-1].minor.yy25); /*A-overwrites-X*/
154116
-}
154117
- break;
154118
- case 291: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
154119
-{
154120
- yymsp[-7].minor.yy297 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy297, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy138, yymsp[-1].minor.yy25);
154121
-}
154122
- break;
154123
- case 292: /* windowdefn_list ::= windowdefn */
154124
-{ yylhsminor.yy455 = yymsp[0].minor.yy455; }
154125
- yymsp[0].minor.yy455 = yylhsminor.yy455;
154126
- break;
154127
- case 293: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
154128
-{
154129
- assert( yymsp[0].minor.yy455!=0 );
154130
- sqlite3WindowChain(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy455);
154131
- yymsp[0].minor.yy455->pNextWin = yymsp[-2].minor.yy455;
154132
- yylhsminor.yy455 = yymsp[0].minor.yy455;
154133
-}
154134
- yymsp[-2].minor.yy455 = yylhsminor.yy455;
154135
- break;
154136
- case 294: /* windowdefn ::= nm AS LP window RP */
154137
-{
154138
- if( ALWAYS(yymsp[-1].minor.yy455) ){
154139
- yymsp[-1].minor.yy455->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
154140
- }
154141
- yylhsminor.yy455 = yymsp[-1].minor.yy455;
154142
-}
154143
- yymsp[-4].minor.yy455 = yylhsminor.yy455;
154144
- break;
154145
- case 295: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
154146
-{
154147
- yymsp[-4].minor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy138, yymsp[-1].minor.yy138, 0);
154148
-}
154149
- break;
154150
- case 296: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
154151
-{
154152
- yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy138, yymsp[-1].minor.yy138, &yymsp[-5].minor.yy0);
154153
-}
154154
- yymsp[-5].minor.yy455 = yylhsminor.yy455;
154155
- break;
154156
- case 297: /* window ::= ORDER BY sortlist frame_opt */
154157
-{
154158
- yymsp[-3].minor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, yymsp[-1].minor.yy138, 0);
154159
-}
154160
- break;
154161
- case 298: /* window ::= nm ORDER BY sortlist frame_opt */
154162
-{
154163
- yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, yymsp[-1].minor.yy138, &yymsp[-4].minor.yy0);
154164
-}
154165
- yymsp[-4].minor.yy455 = yylhsminor.yy455;
154166
- break;
154167
- case 299: /* window ::= frame_opt */
154168
- case 318: /* filter_over ::= over_clause */ yytestcase(yyruleno==318);
154169
-{
154170
- yylhsminor.yy455 = yymsp[0].minor.yy455;
154171
-}
154172
- yymsp[0].minor.yy455 = yylhsminor.yy455;
154173
- break;
154174
- case 300: /* window ::= nm frame_opt */
154175
-{
154176
- yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, 0, &yymsp[-1].minor.yy0);
154177
-}
154178
- yymsp[-1].minor.yy455 = yylhsminor.yy455;
154179
- break;
154180
- case 301: /* frame_opt ::= */
154181
-{
154182
- yymsp[1].minor.yy455 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
154183
-}
154184
- break;
154185
- case 302: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
154186
-{
154187
- 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);
154188
-}
154189
- yymsp[-2].minor.yy455 = yylhsminor.yy455;
154190
- break;
154191
- case 303: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
154192
-{
154193
- 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);
154194
-}
154195
- yymsp[-5].minor.yy455 = yylhsminor.yy455;
154196
- break;
154197
- case 305: /* frame_bound_s ::= frame_bound */
154198
- case 307: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==307);
154199
-{yylhsminor.yy57 = yymsp[0].minor.yy57;}
154200
- yymsp[0].minor.yy57 = yylhsminor.yy57;
154201
- break;
154202
- case 306: /* frame_bound_s ::= UNBOUNDED PRECEDING */
154203
- case 308: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==308);
154204
- case 310: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==310);
154205
-{yylhsminor.yy57.eType = yymsp[-1].major; yylhsminor.yy57.pExpr = 0;}
154206
- yymsp[-1].minor.yy57 = yylhsminor.yy57;
154207
- break;
154208
- case 309: /* frame_bound ::= expr PRECEDING|FOLLOWING */
154209
-{yylhsminor.yy57.eType = yymsp[0].major; yylhsminor.yy57.pExpr = yymsp[-1].minor.yy46;}
154210
- yymsp[-1].minor.yy57 = yylhsminor.yy57;
154211
- break;
154212
- case 311: /* frame_exclude_opt ::= */
154213
-{yymsp[1].minor.yy118 = 0;}
154214
- break;
154215
- case 312: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
154216
-{yymsp[-1].minor.yy118 = yymsp[0].minor.yy118;}
154217
- break;
154218
- case 313: /* frame_exclude ::= NO OTHERS */
154219
- case 314: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==314);
154220
-{yymsp[-1].minor.yy118 = yymsp[-1].major; /*A-overwrites-X*/}
154221
- break;
154222
- case 315: /* frame_exclude ::= GROUP|TIES */
154223
-{yymsp[0].minor.yy118 = yymsp[0].major; /*A-overwrites-X*/}
154224
- break;
154225
- case 316: /* window_clause ::= WINDOW windowdefn_list */
154226
-{ yymsp[-1].minor.yy455 = yymsp[0].minor.yy455; }
154227
- break;
154228
- case 317: /* filter_over ::= filter_clause over_clause */
154229
-{
154230
- yymsp[0].minor.yy455->pFilter = yymsp[-1].minor.yy46;
154231
- yylhsminor.yy455 = yymsp[0].minor.yy455;
154232
-}
154233
- yymsp[-1].minor.yy455 = yylhsminor.yy455;
154234
- break;
154235
- case 319: /* filter_over ::= filter_clause */
154236
-{
154237
- yylhsminor.yy455 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
154238
- if( yylhsminor.yy455 ){
154239
- yylhsminor.yy455->eFrmType = TK_FILTER;
154240
- yylhsminor.yy455->pFilter = yymsp[0].minor.yy46;
154241
- }else{
154242
- sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy46);
154243
- }
154244
-}
154245
- yymsp[0].minor.yy455 = yylhsminor.yy455;
154246
- break;
154247
- case 320: /* over_clause ::= OVER LP window RP */
154248
-{
154249
- yymsp[-3].minor.yy455 = yymsp[-1].minor.yy455;
154250
- assert( yymsp[-3].minor.yy455!=0 );
154251
-}
154252
- break;
154253
- case 321: /* over_clause ::= OVER nm */
154254
-{
154255
- yymsp[-1].minor.yy455 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
154256
- if( yymsp[-1].minor.yy455 ){
154257
- yymsp[-1].minor.yy455->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
154258
- }
154259
-}
154260
- break;
154261
- case 322: /* filter_clause ::= FILTER LP WHERE expr RP */
154262
-{ yymsp[-4].minor.yy46 = yymsp[-1].minor.yy46; }
155249
+ case 290: /* with ::= WITH wqlist */
155250
+ case 291: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==291);
155251
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy131, 1); }
155252
+ break;
155253
+ case 292: /* wqlist ::= nm eidlist_opt AS LP select RP */
155254
+{
155255
+ yymsp[-5].minor.yy131 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy242, yymsp[-1].minor.yy539); /*A-overwrites-X*/
155256
+}
155257
+ break;
155258
+ case 293: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
155259
+{
155260
+ yymsp[-7].minor.yy131 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy131, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy242, yymsp[-1].minor.yy539);
155261
+}
155262
+ break;
155263
+ case 294: /* windowdefn_list ::= windowdefn */
155264
+{ yylhsminor.yy303 = yymsp[0].minor.yy303; }
155265
+ yymsp[0].minor.yy303 = yylhsminor.yy303;
155266
+ break;
155267
+ case 295: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
155268
+{
155269
+ assert( yymsp[0].minor.yy303!=0 );
155270
+ sqlite3WindowChain(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy303);
155271
+ yymsp[0].minor.yy303->pNextWin = yymsp[-2].minor.yy303;
155272
+ yylhsminor.yy303 = yymsp[0].minor.yy303;
155273
+}
155274
+ yymsp[-2].minor.yy303 = yylhsminor.yy303;
155275
+ break;
155276
+ case 296: /* windowdefn ::= nm AS LP window RP */
155277
+{
155278
+ if( ALWAYS(yymsp[-1].minor.yy303) ){
155279
+ yymsp[-1].minor.yy303->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
155280
+ }
155281
+ yylhsminor.yy303 = yymsp[-1].minor.yy303;
155282
+}
155283
+ yymsp[-4].minor.yy303 = yylhsminor.yy303;
155284
+ break;
155285
+ case 297: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
155286
+{
155287
+ yymsp[-4].minor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy242, yymsp[-1].minor.yy242, 0);
155288
+}
155289
+ break;
155290
+ case 298: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
155291
+{
155292
+ yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy242, yymsp[-1].minor.yy242, &yymsp[-5].minor.yy0);
155293
+}
155294
+ yymsp[-5].minor.yy303 = yylhsminor.yy303;
155295
+ break;
155296
+ case 299: /* window ::= ORDER BY sortlist frame_opt */
155297
+{
155298
+ yymsp[-3].minor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, yymsp[-1].minor.yy242, 0);
155299
+}
155300
+ break;
155301
+ case 300: /* window ::= nm ORDER BY sortlist frame_opt */
155302
+{
155303
+ yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, yymsp[-1].minor.yy242, &yymsp[-4].minor.yy0);
155304
+}
155305
+ yymsp[-4].minor.yy303 = yylhsminor.yy303;
155306
+ break;
155307
+ case 301: /* window ::= frame_opt */
155308
+ case 320: /* filter_over ::= over_clause */ yytestcase(yyruleno==320);
155309
+{
155310
+ yylhsminor.yy303 = yymsp[0].minor.yy303;
155311
+}
155312
+ yymsp[0].minor.yy303 = yylhsminor.yy303;
155313
+ break;
155314
+ case 302: /* window ::= nm frame_opt */
155315
+{
155316
+ yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, 0, &yymsp[-1].minor.yy0);
155317
+}
155318
+ yymsp[-1].minor.yy303 = yylhsminor.yy303;
155319
+ break;
155320
+ case 303: /* frame_opt ::= */
155321
+{
155322
+ yymsp[1].minor.yy303 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
155323
+}
155324
+ break;
155325
+ case 304: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
155326
+{
155327
+ yylhsminor.yy303 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy192, yymsp[-1].minor.yy77.eType, yymsp[-1].minor.yy77.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy58);
155328
+}
155329
+ yymsp[-2].minor.yy303 = yylhsminor.yy303;
155330
+ break;
155331
+ case 305: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
155332
+{
155333
+ yylhsminor.yy303 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy192, yymsp[-3].minor.yy77.eType, yymsp[-3].minor.yy77.pExpr, yymsp[-1].minor.yy77.eType, yymsp[-1].minor.yy77.pExpr, yymsp[0].minor.yy58);
155334
+}
155335
+ yymsp[-5].minor.yy303 = yylhsminor.yy303;
155336
+ break;
155337
+ case 307: /* frame_bound_s ::= frame_bound */
155338
+ case 309: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==309);
155339
+{yylhsminor.yy77 = yymsp[0].minor.yy77;}
155340
+ yymsp[0].minor.yy77 = yylhsminor.yy77;
155341
+ break;
155342
+ case 308: /* frame_bound_s ::= UNBOUNDED PRECEDING */
155343
+ case 310: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==310);
155344
+ case 312: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==312);
155345
+{yylhsminor.yy77.eType = yymsp[-1].major; yylhsminor.yy77.pExpr = 0;}
155346
+ yymsp[-1].minor.yy77 = yylhsminor.yy77;
155347
+ break;
155348
+ case 311: /* frame_bound ::= expr PRECEDING|FOLLOWING */
155349
+{yylhsminor.yy77.eType = yymsp[0].major; yylhsminor.yy77.pExpr = yymsp[-1].minor.yy202;}
155350
+ yymsp[-1].minor.yy77 = yylhsminor.yy77;
155351
+ break;
155352
+ case 313: /* frame_exclude_opt ::= */
155353
+{yymsp[1].minor.yy58 = 0;}
155354
+ break;
155355
+ case 314: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
155356
+{yymsp[-1].minor.yy58 = yymsp[0].minor.yy58;}
155357
+ break;
155358
+ case 315: /* frame_exclude ::= NO OTHERS */
155359
+ case 316: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==316);
155360
+{yymsp[-1].minor.yy58 = yymsp[-1].major; /*A-overwrites-X*/}
155361
+ break;
155362
+ case 317: /* frame_exclude ::= GROUP|TIES */
155363
+{yymsp[0].minor.yy58 = yymsp[0].major; /*A-overwrites-X*/}
155364
+ break;
155365
+ case 318: /* window_clause ::= WINDOW windowdefn_list */
155366
+{ yymsp[-1].minor.yy303 = yymsp[0].minor.yy303; }
155367
+ break;
155368
+ case 319: /* filter_over ::= filter_clause over_clause */
155369
+{
155370
+ yymsp[0].minor.yy303->pFilter = yymsp[-1].minor.yy202;
155371
+ yylhsminor.yy303 = yymsp[0].minor.yy303;
155372
+}
155373
+ yymsp[-1].minor.yy303 = yylhsminor.yy303;
155374
+ break;
155375
+ case 321: /* filter_over ::= filter_clause */
155376
+{
155377
+ yylhsminor.yy303 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
155378
+ if( yylhsminor.yy303 ){
155379
+ yylhsminor.yy303->eFrmType = TK_FILTER;
155380
+ yylhsminor.yy303->pFilter = yymsp[0].minor.yy202;
155381
+ }else{
155382
+ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy202);
155383
+ }
155384
+}
155385
+ yymsp[0].minor.yy303 = yylhsminor.yy303;
155386
+ break;
155387
+ case 322: /* over_clause ::= OVER LP window RP */
155388
+{
155389
+ yymsp[-3].minor.yy303 = yymsp[-1].minor.yy303;
155390
+ assert( yymsp[-3].minor.yy303!=0 );
155391
+}
155392
+ break;
155393
+ case 323: /* over_clause ::= OVER nm */
155394
+{
155395
+ yymsp[-1].minor.yy303 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
155396
+ if( yymsp[-1].minor.yy303 ){
155397
+ yymsp[-1].minor.yy303->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
155398
+ }
155399
+}
155400
+ break;
155401
+ case 324: /* filter_clause ::= FILTER LP WHERE expr RP */
155402
+{ yymsp[-4].minor.yy202 = yymsp[-1].minor.yy202; }
154263155403
break;
154264155404
default:
154265
- /* (323) input ::= cmdlist */ yytestcase(yyruleno==323);
154266
- /* (324) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==324);
154267
- /* (325) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=325);
154268
- /* (326) ecmd ::= SEMI */ yytestcase(yyruleno==326);
154269
- /* (327) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==327);
154270
- /* (328) ecmd ::= explain cmdx */ yytestcase(yyruleno==328);
154271
- /* (329) trans_opt ::= */ yytestcase(yyruleno==329);
154272
- /* (330) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==330);
154273
- /* (331) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==331);
154274
- /* (332) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==332);
154275
- /* (333) savepoint_opt ::= */ yytestcase(yyruleno==333);
154276
- /* (334) cmd ::= create_table create_table_args */ yytestcase(yyruleno==334);
154277
- /* (335) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==335);
154278
- /* (336) columnlist ::= columnname carglist */ yytestcase(yyruleno==336);
154279
- /* (337) nm ::= ID|INDEXED */ yytestcase(yyruleno==337);
154280
- /* (338) nm ::= STRING */ yytestcase(yyruleno==338);
154281
- /* (339) nm ::= JOIN_KW */ yytestcase(yyruleno==339);
154282
- /* (340) typetoken ::= typename */ yytestcase(yyruleno==340);
154283
- /* (341) typename ::= ID|STRING */ yytestcase(yyruleno==341);
154284
- /* (342) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=342);
154285
- /* (343) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=343);
154286
- /* (344) carglist ::= carglist ccons */ yytestcase(yyruleno==344);
154287
- /* (345) carglist ::= */ yytestcase(yyruleno==345);
154288
- /* (346) ccons ::= NULL onconf */ yytestcase(yyruleno==346);
154289
- /* (347) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==347);
154290
- /* (348) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==348);
154291
- /* (349) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=349);
154292
- /* (350) tconscomma ::= */ yytestcase(yyruleno==350);
154293
- /* (351) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=351);
154294
- /* (352) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=352);
154295
- /* (353) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=353);
154296
- /* (354) oneselect ::= values */ yytestcase(yyruleno==354);
154297
- /* (355) sclp ::= selcollist COMMA */ yytestcase(yyruleno==355);
154298
- /* (356) as ::= ID|STRING */ yytestcase(yyruleno==356);
154299
- /* (357) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=357);
154300
- /* (358) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==358);
154301
- /* (359) exprlist ::= nexprlist */ yytestcase(yyruleno==359);
154302
- /* (360) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=360);
154303
- /* (361) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=361);
154304
- /* (362) nmnum ::= ON */ yytestcase(yyruleno==362);
154305
- /* (363) nmnum ::= DELETE */ yytestcase(yyruleno==363);
154306
- /* (364) nmnum ::= DEFAULT */ yytestcase(yyruleno==364);
154307
- /* (365) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==365);
154308
- /* (366) foreach_clause ::= */ yytestcase(yyruleno==366);
154309
- /* (367) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==367);
154310
- /* (368) trnm ::= nm */ yytestcase(yyruleno==368);
154311
- /* (369) tridxby ::= */ yytestcase(yyruleno==369);
154312
- /* (370) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==370);
154313
- /* (371) database_kw_opt ::= */ yytestcase(yyruleno==371);
154314
- /* (372) kwcolumn_opt ::= */ yytestcase(yyruleno==372);
154315
- /* (373) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==373);
154316
- /* (374) vtabarglist ::= vtabarg */ yytestcase(yyruleno==374);
154317
- /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==375);
154318
- /* (376) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==376);
154319
- /* (377) anylist ::= */ yytestcase(yyruleno==377);
154320
- /* (378) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==378);
154321
- /* (379) anylist ::= anylist ANY */ yytestcase(yyruleno==379);
154322
- /* (380) with ::= */ yytestcase(yyruleno==380);
155405
+ /* (325) input ::= cmdlist */ yytestcase(yyruleno==325);
155406
+ /* (326) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==326);
155407
+ /* (327) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=327);
155408
+ /* (328) ecmd ::= SEMI */ yytestcase(yyruleno==328);
155409
+ /* (329) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==329);
155410
+ /* (330) ecmd ::= explain cmdx */ yytestcase(yyruleno==330);
155411
+ /* (331) trans_opt ::= */ yytestcase(yyruleno==331);
155412
+ /* (332) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==332);
155413
+ /* (333) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==333);
155414
+ /* (334) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==334);
155415
+ /* (335) savepoint_opt ::= */ yytestcase(yyruleno==335);
155416
+ /* (336) cmd ::= create_table create_table_args */ yytestcase(yyruleno==336);
155417
+ /* (337) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==337);
155418
+ /* (338) columnlist ::= columnname carglist */ yytestcase(yyruleno==338);
155419
+ /* (339) nm ::= ID|INDEXED */ yytestcase(yyruleno==339);
155420
+ /* (340) nm ::= STRING */ yytestcase(yyruleno==340);
155421
+ /* (341) nm ::= JOIN_KW */ yytestcase(yyruleno==341);
155422
+ /* (342) typetoken ::= typename */ yytestcase(yyruleno==342);
155423
+ /* (343) typename ::= ID|STRING */ yytestcase(yyruleno==343);
155424
+ /* (344) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=344);
155425
+ /* (345) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=345);
155426
+ /* (346) carglist ::= carglist ccons */ yytestcase(yyruleno==346);
155427
+ /* (347) carglist ::= */ yytestcase(yyruleno==347);
155428
+ /* (348) ccons ::= NULL onconf */ yytestcase(yyruleno==348);
155429
+ /* (349) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==349);
155430
+ /* (350) ccons ::= AS generated */ yytestcase(yyruleno==350);
155431
+ /* (351) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==351);
155432
+ /* (352) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==352);
155433
+ /* (353) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=353);
155434
+ /* (354) tconscomma ::= */ yytestcase(yyruleno==354);
155435
+ /* (355) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=355);
155436
+ /* (356) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=356);
155437
+ /* (357) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=357);
155438
+ /* (358) oneselect ::= values */ yytestcase(yyruleno==358);
155439
+ /* (359) sclp ::= selcollist COMMA */ yytestcase(yyruleno==359);
155440
+ /* (360) as ::= ID|STRING */ yytestcase(yyruleno==360);
155441
+ /* (361) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=361);
155442
+ /* (362) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==362);
155443
+ /* (363) exprlist ::= nexprlist */ yytestcase(yyruleno==363);
155444
+ /* (364) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=364);
155445
+ /* (365) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=365);
155446
+ /* (366) nmnum ::= ON */ yytestcase(yyruleno==366);
155447
+ /* (367) nmnum ::= DELETE */ yytestcase(yyruleno==367);
155448
+ /* (368) nmnum ::= DEFAULT */ yytestcase(yyruleno==368);
155449
+ /* (369) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==369);
155450
+ /* (370) foreach_clause ::= */ yytestcase(yyruleno==370);
155451
+ /* (371) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==371);
155452
+ /* (372) trnm ::= nm */ yytestcase(yyruleno==372);
155453
+ /* (373) tridxby ::= */ yytestcase(yyruleno==373);
155454
+ /* (374) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==374);
155455
+ /* (375) database_kw_opt ::= */ yytestcase(yyruleno==375);
155456
+ /* (376) kwcolumn_opt ::= */ yytestcase(yyruleno==376);
155457
+ /* (377) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==377);
155458
+ /* (378) vtabarglist ::= vtabarg */ yytestcase(yyruleno==378);
155459
+ /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==379);
155460
+ /* (380) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==380);
155461
+ /* (381) anylist ::= */ yytestcase(yyruleno==381);
155462
+ /* (382) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==382);
155463
+ /* (383) anylist ::= anylist ANY */ yytestcase(yyruleno==383);
155464
+ /* (384) with ::= */ yytestcase(yyruleno==384);
154323155465
break;
154324155466
/********** End reduce actions ************************************************/
154325155467
};
154326155468
assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
154327155469
yygoto = yyRuleInfoLhs[yyruleno];
@@ -154613,12 +155755,12 @@
154613155755
#ifdef YYFALLBACK
154614155756
assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) );
154615155757
return yyFallback[iToken];
154616155758
#else
154617155759
(void)iToken;
154618
-#endif
154619155760
return 0;
155761
+#endif
154620155762
}
154621155763
154622155764
/************** End of parse.c ***********************************************/
154623155765
/************** Begin file tokenize.c ****************************************/
154624155766
/*
@@ -154779,24 +155921,24 @@
154779155921
** might be implemented more directly using a hand-written hash table.
154780155922
** But by using this automatically generated code, the size of the code
154781155923
** is substantially reduced. This is important for embedded applications
154782155924
** on platforms with limited memory.
154783155925
*/
154784
-/* Hash score: 221 */
154785
-/* zKWText[] encodes 967 bytes of keyword text in 638 bytes */
155926
+/* Hash score: 227 */
155927
+/* zKWText[] encodes 984 bytes of keyword text in 648 bytes */
154786155928
/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
154787155929
/* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYISNULLSAVEPOINTERSECT */
154788155930
/* IESNOTNULLIKEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTS */
154789
-/* CONSTRAINTOFFSETRIGGEREFERENCESUNIQUERYWITHOUTERELEASEATTACH */
154790
-/* AVINGLOBEGINNERANGEBETWEENOTHINGROUPSCASCADETACHCASECOLLATE */
154791
-/* CREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORT */
154792
-/* UPDATEVALUESVIRTUALASTWHENWHERECURSIVEAFTERENAMEANDEFAULT */
154793
-/* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */
154794
-/* ARTITIONDEFERREDISTINCTDROPRECEDINGFAILIMITFILTEREPLACEFIRST */
154795
-/* FOLLOWINGFROMFULLIFORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */
155931
+/* CONSTRAINTOFFSETRIGGERANGENERATEDETACHAVINGLOBEGINNEREFERENCES */
155932
+/* UNIQUERYWITHOUTERELEASEATTACHBETWEENOTHINGROUPSCASCADEFAULT */
155933
+/* CASECOLLATECREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZE */
155934
+/* PRAGMABORTUPDATEVALUESVIRTUALWAYSWHENWHERECURSIVEAFTERENAMEAND */
155935
+/* EFERREDISTINCTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */
155936
+/* CURRENT_TIMESTAMPARTITIONDROPRECEDINGFAILASTFILTEREPLACEFIRST */
155937
+/* FOLLOWINGFROMFULLIMITIFORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */
154796155938
/* UNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBYINITIALLYPRIMARY */
154797
-static const char zKWText[637] = {
155939
+static const char zKWText[647] = {
154798155940
'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
154799155941
'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
154800155942
'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
154801155943
'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
154802155944
'E','R','R','A','B','L','E','L','S','E','X','C','L','U','D','E','L','E',
@@ -154803,97 +155945,100 @@
154803155945
'T','E','M','P','O','R','A','R','Y','I','S','N','U','L','L','S','A','V',
154804155946
'E','P','O','I','N','T','E','R','S','E','C','T','I','E','S','N','O','T',
154805155947
'N','U','L','L','I','K','E','X','C','E','P','T','R','A','N','S','A','C',
154806155948
'T','I','O','N','A','T','U','R','A','L','T','E','R','A','I','S','E','X',
154807155949
'C','L','U','S','I','V','E','X','I','S','T','S','C','O','N','S','T','R',
154808
- 'A','I','N','T','O','F','F','S','E','T','R','I','G','G','E','R','E','F',
154809
- 'E','R','E','N','C','E','S','U','N','I','Q','U','E','R','Y','W','I','T',
154810
- 'H','O','U','T','E','R','E','L','E','A','S','E','A','T','T','A','C','H',
154811
- 'A','V','I','N','G','L','O','B','E','G','I','N','N','E','R','A','N','G',
154812
- 'E','B','E','T','W','E','E','N','O','T','H','I','N','G','R','O','U','P',
154813
- 'S','C','A','S','C','A','D','E','T','A','C','H','C','A','S','E','C','O',
154814
- 'L','L','A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T',
154815
- '_','D','A','T','E','I','M','M','E','D','I','A','T','E','J','O','I','N',
154816
- 'S','E','R','T','M','A','T','C','H','P','L','A','N','A','L','Y','Z','E',
154817
- 'P','R','A','G','M','A','B','O','R','T','U','P','D','A','T','E','V','A',
154818
- 'L','U','E','S','V','I','R','T','U','A','L','A','S','T','W','H','E','N',
154819
- 'W','H','E','R','E','C','U','R','S','I','V','E','A','F','T','E','R','E',
154820
- 'N','A','M','E','A','N','D','E','F','A','U','L','T','A','U','T','O','I',
154821
- 'N','C','R','E','M','E','N','T','C','A','S','T','C','O','L','U','M','N',
154822
- 'C','O','M','M','I','T','C','O','N','F','L','I','C','T','C','R','O','S',
154823
- 'S','C','U','R','R','E','N','T','_','T','I','M','E','S','T','A','M','P',
154824
- 'A','R','T','I','T','I','O','N','D','E','F','E','R','R','E','D','I','S',
154825
- 'T','I','N','C','T','D','R','O','P','R','E','C','E','D','I','N','G','F',
154826
- 'A','I','L','I','M','I','T','F','I','L','T','E','R','E','P','L','A','C',
154827
- 'E','F','I','R','S','T','F','O','L','L','O','W','I','N','G','F','R','O',
154828
- 'M','F','U','L','L','I','F','O','R','D','E','R','E','S','T','R','I','C',
154829
- 'T','O','T','H','E','R','S','O','V','E','R','I','G','H','T','R','O','L',
154830
- 'L','B','A','C','K','R','O','W','S','U','N','B','O','U','N','D','E','D',
154831
- 'U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M','V','I',
154832
- 'E','W','I','N','D','O','W','B','Y','I','N','I','T','I','A','L','L','Y',
154833
- 'P','R','I','M','A','R','Y',
155950
+ 'A','I','N','T','O','F','F','S','E','T','R','I','G','G','E','R','A','N',
155951
+ 'G','E','N','E','R','A','T','E','D','E','T','A','C','H','A','V','I','N',
155952
+ 'G','L','O','B','E','G','I','N','N','E','R','E','F','E','R','E','N','C',
155953
+ 'E','S','U','N','I','Q','U','E','R','Y','W','I','T','H','O','U','T','E',
155954
+ 'R','E','L','E','A','S','E','A','T','T','A','C','H','B','E','T','W','E',
155955
+ 'E','N','O','T','H','I','N','G','R','O','U','P','S','C','A','S','C','A',
155956
+ 'D','E','F','A','U','L','T','C','A','S','E','C','O','L','L','A','T','E',
155957
+ 'C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A','T','E',
155958
+ 'I','M','M','E','D','I','A','T','E','J','O','I','N','S','E','R','T','M',
155959
+ 'A','T','C','H','P','L','A','N','A','L','Y','Z','E','P','R','A','G','M',
155960
+ 'A','B','O','R','T','U','P','D','A','T','E','V','A','L','U','E','S','V',
155961
+ 'I','R','T','U','A','L','W','A','Y','S','W','H','E','N','W','H','E','R',
155962
+ 'E','C','U','R','S','I','V','E','A','F','T','E','R','E','N','A','M','E',
155963
+ 'A','N','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','A',
155964
+ 'U','T','O','I','N','C','R','E','M','E','N','T','C','A','S','T','C','O',
155965
+ 'L','U','M','N','C','O','M','M','I','T','C','O','N','F','L','I','C','T',
155966
+ 'C','R','O','S','S','C','U','R','R','E','N','T','_','T','I','M','E','S',
155967
+ 'T','A','M','P','A','R','T','I','T','I','O','N','D','R','O','P','R','E',
155968
+ 'C','E','D','I','N','G','F','A','I','L','A','S','T','F','I','L','T','E',
155969
+ 'R','E','P','L','A','C','E','F','I','R','S','T','F','O','L','L','O','W',
155970
+ 'I','N','G','F','R','O','M','F','U','L','L','I','M','I','T','I','F','O',
155971
+ 'R','D','E','R','E','S','T','R','I','C','T','O','T','H','E','R','S','O',
155972
+ 'V','E','R','I','G','H','T','R','O','L','L','B','A','C','K','R','O','W',
155973
+ 'S','U','N','B','O','U','N','D','E','D','U','N','I','O','N','U','S','I',
155974
+ 'N','G','V','A','C','U','U','M','V','I','E','W','I','N','D','O','W','B',
155975
+ 'Y','I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R','Y',
154834155976
};
154835155977
/* aKWHash[i] is the hash value for the i-th keyword */
154836155978
static const unsigned char aKWHash[127] = {
154837
- 82, 113, 130, 80, 110, 29, 0, 0, 89, 0, 83, 70, 0,
154838
- 53, 35, 84, 15, 0, 129, 92, 64, 124, 131, 19, 0, 0,
154839
- 136, 0, 134, 126, 0, 22, 100, 0, 9, 0, 0, 121, 78,
154840
- 0, 76, 6, 0, 58, 97, 143, 0, 132, 108, 0, 0, 48,
154841
- 0, 111, 24, 0, 17, 0, 137, 63, 23, 26, 5, 65, 138,
154842
- 103, 120, 0, 142, 114, 69, 141, 66, 118, 72, 0, 98, 0,
154843
- 107, 41, 0, 106, 0, 0, 0, 102, 99, 104, 109, 123, 14,
154844
- 50, 122, 0, 87, 0, 139, 119, 140, 68, 127, 135, 86, 81,
154845
- 37, 91, 117, 0, 0, 101, 51, 128, 125, 0, 133, 0, 0,
154846
- 44, 0, 93, 67, 39, 0, 20, 45, 115, 88,
155979
+ 84, 102, 132, 82, 114, 29, 0, 0, 91, 0, 85, 72, 0,
155980
+ 53, 35, 86, 15, 0, 42, 94, 54, 126, 133, 19, 0, 0,
155981
+ 138, 0, 40, 128, 0, 22, 104, 0, 9, 0, 0, 122, 80,
155982
+ 0, 78, 6, 0, 65, 99, 145, 0, 134, 112, 0, 0, 48,
155983
+ 0, 100, 24, 0, 17, 0, 27, 70, 23, 26, 5, 60, 140,
155984
+ 107, 121, 0, 73, 101, 71, 143, 61, 119, 74, 0, 49, 0,
155985
+ 11, 41, 0, 110, 0, 0, 0, 106, 10, 108, 113, 124, 14,
155986
+ 50, 123, 0, 89, 0, 18, 120, 142, 56, 129, 137, 88, 83,
155987
+ 37, 30, 125, 0, 0, 105, 51, 130, 127, 0, 34, 0, 0,
155988
+ 44, 0, 95, 38, 39, 0, 20, 45, 116, 90,
154847155989
};
154848155990
/* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
154849155991
** then the i-th keyword has no more hash collisions. Otherwise,
154850155992
** the next keyword with the same hash is aKWHash[i]-1. */
154851
-static const unsigned char aKWNext[143] = {
154852
- 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
154853
- 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
154854
- 0, 0, 0, 21, 0, 0, 0, 0, 12, 0, 0, 0, 0,
154855
- 0, 0, 0, 7, 0, 36, 0, 0, 28, 0, 0, 0, 31,
154856
- 0, 0, 0, 40, 0, 0, 0, 0, 0, 60, 0, 54, 0,
154857
- 0, 38, 47, 0, 0, 0, 3, 0, 0, 74, 1, 73, 0,
154858
- 0, 0, 52, 0, 0, 0, 0, 0, 0, 57, 59, 56, 30,
154859
- 0, 0, 0, 46, 0, 16, 49, 10, 0, 0, 0, 0, 0,
154860
- 0, 0, 11, 79, 95, 0, 0, 8, 0, 112, 0, 105, 0,
154861
- 43, 62, 0, 77, 0, 116, 0, 61, 0, 0, 94, 42, 55,
154862
- 0, 75, 34, 90, 32, 33, 27, 25, 18, 96, 0, 71, 85,
155993
+static const unsigned char aKWNext[145] = {
155994
+ 0, 0, 0, 0, 4, 0, 43, 0, 0, 103, 111, 0, 0,
155995
+ 0, 2, 0, 0, 141, 0, 0, 0, 13, 0, 0, 0, 0,
155996
+ 139, 0, 0, 118, 52, 0, 0, 135, 12, 0, 0, 62, 0,
155997
+ 136, 0, 131, 0, 0, 36, 0, 0, 28, 77, 0, 0, 0,
155998
+ 0, 59, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
155999
+ 0, 69, 0, 0, 0, 0, 0, 144, 3, 0, 58, 0, 1,
156000
+ 75, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 64, 66,
156001
+ 63, 0, 0, 0, 0, 46, 0, 16, 0, 115, 0, 0, 0,
156002
+ 0, 0, 0, 0, 0, 0, 0, 81, 97, 0, 8, 0, 109,
156003
+ 21, 7, 67, 0, 79, 93, 117, 0, 0, 68, 0, 0, 96,
156004
+ 0, 55, 0, 76, 0, 92, 32, 33, 57, 25, 0, 98, 0,
156005
+ 0, 87,
154863156006
};
154864156007
/* aKWLen[i] is the length (in bytes) of the i-th keyword */
154865
-static const unsigned char aKWLen[143] = {
156008
+static const unsigned char aKWLen[145] = {
154866156009
7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
154867156010
7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7,
154868156011
6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4,
154869156012
4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 10, 4, 6,
154870
- 2, 3, 7, 10, 6, 5, 7, 4, 5, 7, 6, 6, 4,
154871
- 5, 5, 5, 7, 7, 6, 5, 7, 3, 6, 4, 7, 6,
154872
- 12, 9, 4, 6, 5, 4, 7, 6, 5, 6, 6, 7, 4,
154873
- 4, 5, 9, 5, 6, 3, 7, 13, 2, 2, 4, 6, 6,
154874
- 8, 5, 17, 12, 7, 9, 8, 8, 2, 4, 9, 4, 5,
154875
- 6, 7, 5, 9, 4, 4, 2, 5, 8, 6, 4, 5, 8,
154876
- 4, 3, 9, 5, 5, 6, 4, 6, 2, 2, 9, 3, 7,
156013
+ 2, 3, 7, 5, 9, 6, 6, 4, 5, 5, 10, 6, 5,
156014
+ 7, 4, 5, 7, 6, 7, 7, 6, 5, 7, 3, 7, 4,
156015
+ 7, 6, 12, 9, 4, 6, 5, 4, 7, 6, 5, 6, 6,
156016
+ 7, 6, 4, 5, 9, 5, 6, 3, 8, 8, 2, 13, 2,
156017
+ 2, 4, 6, 6, 8, 5, 17, 12, 7, 9, 4, 9, 4,
156018
+ 4, 6, 7, 5, 9, 4, 4, 5, 2, 5, 8, 6, 4,
156019
+ 5, 8, 4, 3, 9, 5, 5, 6, 4, 6, 2, 2, 9,
156020
+ 3, 7,
154877156021
};
154878156022
/* aKWOffset[i] is the index into zKWText[] of the start of
154879156023
** the text for the i-th keyword. */
154880
-static const unsigned short int aKWOffset[143] = {
156024
+static const unsigned short int aKWOffset[145] = {
154881156025
0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
154882156026
36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
154883156027
86, 90, 90, 94, 99, 101, 105, 111, 119, 123, 123, 123, 126,
154884156028
129, 132, 137, 142, 146, 147, 152, 156, 160, 168, 174, 181, 184,
154885
- 184, 187, 189, 195, 205, 208, 213, 213, 217, 221, 228, 233, 238,
154886
- 241, 244, 248, 253, 259, 265, 265, 271, 272, 276, 282, 286, 293,
154887
- 299, 311, 320, 322, 328, 333, 335, 342, 347, 352, 358, 364, 370,
154888
- 374, 378, 381, 390, 394, 400, 402, 409, 411, 413, 422, 426, 432,
154889
- 438, 446, 451, 451, 451, 467, 476, 483, 484, 491, 494, 503, 506,
154890
- 511, 516, 523, 528, 537, 541, 545, 547, 551, 559, 565, 568, 573,
154891
- 581, 581, 585, 594, 599, 604, 610, 613, 616, 619, 621, 626, 630,
156029
+ 184, 187, 189, 195, 198, 206, 211, 216, 219, 222, 226, 236, 239,
156030
+ 244, 244, 248, 252, 259, 265, 271, 277, 277, 283, 284, 288, 295,
156031
+ 299, 306, 312, 324, 333, 335, 341, 346, 348, 355, 360, 365, 371,
156032
+ 377, 382, 388, 392, 395, 404, 408, 414, 416, 423, 424, 431, 433,
156033
+ 435, 444, 448, 454, 460, 468, 473, 473, 473, 489, 498, 501, 510,
156034
+ 513, 517, 522, 529, 534, 543, 547, 550, 555, 557, 561, 569, 575,
156035
+ 578, 583, 591, 591, 595, 604, 609, 614, 620, 623, 626, 629, 631,
156036
+ 636, 640,
154892156037
};
154893156038
/* aKWCode[i] is the parser symbol code for the i-th keyword */
154894
-static const unsigned char aKWCode[143] = {
156039
+static const unsigned char aKWCode[145] = {
154895156040
TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
154896156041
TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
154897156042
TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
154898156043
TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
154899156044
TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
@@ -154901,29 +156046,158 @@
154901156046
TK_ISNULL, TK_NULLS, TK_SAVEPOINT, TK_INTERSECT, TK_TIES,
154902156047
TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
154903156048
TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
154904156049
TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_CONSTRAINT,
154905156050
TK_INTO, TK_OFFSET, TK_OF, TK_SET, TK_TRIGGER,
154906
- TK_REFERENCES, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
154907
- TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_LIKE_KW,
154908
- TK_BEGIN, TK_JOIN_KW, TK_RANGE, TK_BETWEEN, TK_NOTHING,
154909
- TK_GROUPS, TK_GROUP, TK_CASCADE, TK_ASC, TK_DETACH,
154910
- TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_IMMEDIATE,
154911
- TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE,
154912
- TK_PRAGMA, TK_ABORT, TK_UPDATE, TK_VALUES, TK_VIRTUAL,
154913
- TK_LAST, TK_WHEN, TK_WHERE, TK_RECURSIVE, TK_AFTER,
154914
- TK_RENAME, TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO,
154915
- TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT,
154916
- TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT, TK_PARTITION,
154917
- TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP, TK_PRECEDING,
154918
- TK_FAIL, TK_LIMIT, TK_FILTER, TK_REPLACE, TK_FIRST,
154919
- TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_IF, TK_ORDER,
154920
- TK_RESTRICT, TK_OTHERS, TK_OVER, TK_JOIN_KW, TK_ROLLBACK,
154921
- TK_ROWS, TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING,
154922
- TK_VACUUM, TK_VIEW, TK_WINDOW, TK_DO, TK_BY,
154923
- TK_INITIALLY, TK_ALL, TK_PRIMARY,
154924
-};
156051
+ TK_RANGE, TK_GENERATED, TK_DETACH, TK_HAVING, TK_LIKE_KW,
156052
+ TK_BEGIN, TK_JOIN_KW, TK_REFERENCES, TK_UNIQUE, TK_QUERY,
156053
+ TK_WITHOUT, TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_ATTACH,
156054
+ TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP, TK_CASCADE,
156055
+ TK_ASC, TK_DEFAULT, TK_CASE, TK_COLLATE, TK_CREATE,
156056
+ TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_MATCH,
156057
+ TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT, TK_UPDATE,
156058
+ TK_VALUES, TK_VIRTUAL, TK_ALWAYS, TK_WHEN, TK_WHERE,
156059
+ TK_RECURSIVE, TK_AFTER, TK_RENAME, TK_AND, TK_DEFERRED,
156060
+ TK_DISTINCT, TK_IS, TK_AUTOINCR, TK_TO, TK_IN,
156061
+ TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW,
156062
+ TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT, TK_PARTITION, TK_DROP,
156063
+ TK_PRECEDING, TK_FAIL, TK_LAST, TK_FILTER, TK_REPLACE,
156064
+ TK_FIRST, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_LIMIT,
156065
+ TK_IF, TK_ORDER, TK_RESTRICT, TK_OTHERS, TK_OVER,
156066
+ TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNBOUNDED,
156067
+ TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_WINDOW,
156068
+ TK_DO, TK_BY, TK_INITIALLY, TK_ALL, TK_PRIMARY,
156069
+};
156070
+/* Hash table decoded:
156071
+** 0: INSERT
156072
+** 1: IS
156073
+** 2: ROLLBACK TRIGGER
156074
+** 3: IMMEDIATE
156075
+** 4: PARTITION
156076
+** 5: TEMP
156077
+** 6:
156078
+** 7:
156079
+** 8: VALUES WITHOUT
156080
+** 9:
156081
+** 10: MATCH
156082
+** 11: NOTHING
156083
+** 12:
156084
+** 13: OF
156085
+** 14: TIES IGNORE
156086
+** 15: PLAN
156087
+** 16: INSTEAD INDEXED
156088
+** 17:
156089
+** 18: TRANSACTION RIGHT
156090
+** 19: WHEN
156091
+** 20: SET HAVING
156092
+** 21: IF
156093
+** 22: ROWS
156094
+** 23: SELECT
156095
+** 24:
156096
+** 25:
156097
+** 26: VACUUM SAVEPOINT
156098
+** 27:
156099
+** 28: LIKE UNION VIRTUAL REFERENCES
156100
+** 29: RESTRICT
156101
+** 30:
156102
+** 31: THEN REGEXP
156103
+** 32: TO
156104
+** 33:
156105
+** 34: BEFORE
156106
+** 35:
156107
+** 36:
156108
+** 37: FOLLOWING COLLATE CASCADE
156109
+** 38: CREATE
156110
+** 39:
156111
+** 40: CASE REINDEX
156112
+** 41: EACH
156113
+** 42:
156114
+** 43: QUERY
156115
+** 44: AND ADD
156116
+** 45: PRIMARY ANALYZE
156117
+** 46:
156118
+** 47: ROW ASC DETACH
156119
+** 48: CURRENT_TIME CURRENT_DATE
156120
+** 49:
156121
+** 50:
156122
+** 51: EXCLUSIVE TEMPORARY
156123
+** 52:
156124
+** 53: DEFERRED
156125
+** 54: DEFERRABLE
156126
+** 55:
156127
+** 56: DATABASE
156128
+** 57:
156129
+** 58: DELETE VIEW GENERATED
156130
+** 59: ATTACH
156131
+** 60: END
156132
+** 61: EXCLUDE
156133
+** 62: ESCAPE DESC
156134
+** 63: GLOB
156135
+** 64: WINDOW ELSE
156136
+** 65: COLUMN
156137
+** 66: FIRST
156138
+** 67:
156139
+** 68: GROUPS ALL
156140
+** 69: DISTINCT DROP KEY
156141
+** 70: BETWEEN
156142
+** 71: INITIALLY
156143
+** 72: BEGIN
156144
+** 73: FILTER CHECK ACTION
156145
+** 74: GROUP INDEX
156146
+** 75:
156147
+** 76: EXISTS DEFAULT
156148
+** 77:
156149
+** 78: FOR CURRENT_TIMESTAMP
156150
+** 79: EXCEPT
156151
+** 80:
156152
+** 81: CROSS
156153
+** 82:
156154
+** 83:
156155
+** 84:
156156
+** 85: CAST
156157
+** 86: FOREIGN AUTOINCREMENT
156158
+** 87: COMMIT
156159
+** 88: CURRENT AFTER ALTER
156160
+** 89: FULL FAIL CONFLICT
156161
+** 90: EXPLAIN
156162
+** 91: CONSTRAINT
156163
+** 92: FROM ALWAYS
156164
+** 93:
156165
+** 94: ABORT
156166
+** 95:
156167
+** 96: AS DO
156168
+** 97: REPLACE WITH RELEASE
156169
+** 98: BY RENAME
156170
+** 99: RANGE RAISE
156171
+** 100: OTHERS
156172
+** 101: USING NULLS
156173
+** 102: PRAGMA
156174
+** 103: JOIN ISNULL OFFSET
156175
+** 104: NOT
156176
+** 105: OR LAST LEFT
156177
+** 106: LIMIT
156178
+** 107:
156179
+** 108:
156180
+** 109: IN
156181
+** 110: INTO
156182
+** 111: OVER RECURSIVE
156183
+** 112: ORDER OUTER
156184
+** 113:
156185
+** 114: INTERSECT UNBOUNDED
156186
+** 115:
156187
+** 116:
156188
+** 117: ON
156189
+** 118:
156190
+** 119: WHERE
156191
+** 120: NO INNER
156192
+** 121: NULL
156193
+** 122:
156194
+** 123: TABLE
156195
+** 124: NATURAL NOTNULL
156196
+** 125: PRECEDING
156197
+** 126: UPDATE UNIQUE
156198
+*/
154925156199
/* Check to see if z[0..n-1] is a keyword. If it is, write the
154926156200
** parser symbol code for that keyword into *pType. Always
154927156201
** return the integer n (the length of the token). */
154928156202
static int keywordCode(const char *z, int n, int *pType){
154929156203
int i, j;
@@ -154994,98 +156268,100 @@
154994156268
testcase( i==50 ); /* INTO */
154995156269
testcase( i==51 ); /* OFFSET */
154996156270
testcase( i==52 ); /* OF */
154997156271
testcase( i==53 ); /* SET */
154998156272
testcase( i==54 ); /* TRIGGER */
154999
- testcase( i==55 ); /* REFERENCES */
155000
- testcase( i==56 ); /* UNIQUE */
155001
- testcase( i==57 ); /* QUERY */
155002
- testcase( i==58 ); /* WITHOUT */
155003
- testcase( i==59 ); /* WITH */
155004
- testcase( i==60 ); /* OUTER */
155005
- testcase( i==61 ); /* RELEASE */
155006
- testcase( i==62 ); /* ATTACH */
155007
- testcase( i==63 ); /* HAVING */
155008
- testcase( i==64 ); /* GLOB */
155009
- testcase( i==65 ); /* BEGIN */
155010
- testcase( i==66 ); /* INNER */
155011
- testcase( i==67 ); /* RANGE */
155012
- testcase( i==68 ); /* BETWEEN */
155013
- testcase( i==69 ); /* NOTHING */
155014
- testcase( i==70 ); /* GROUPS */
155015
- testcase( i==71 ); /* GROUP */
155016
- testcase( i==72 ); /* CASCADE */
155017
- testcase( i==73 ); /* ASC */
155018
- testcase( i==74 ); /* DETACH */
155019
- testcase( i==75 ); /* CASE */
155020
- testcase( i==76 ); /* COLLATE */
155021
- testcase( i==77 ); /* CREATE */
155022
- testcase( i==78 ); /* CURRENT_DATE */
155023
- testcase( i==79 ); /* IMMEDIATE */
155024
- testcase( i==80 ); /* JOIN */
155025
- testcase( i==81 ); /* INSERT */
155026
- testcase( i==82 ); /* MATCH */
155027
- testcase( i==83 ); /* PLAN */
155028
- testcase( i==84 ); /* ANALYZE */
155029
- testcase( i==85 ); /* PRAGMA */
155030
- testcase( i==86 ); /* ABORT */
155031
- testcase( i==87 ); /* UPDATE */
155032
- testcase( i==88 ); /* VALUES */
155033
- testcase( i==89 ); /* VIRTUAL */
155034
- testcase( i==90 ); /* LAST */
155035
- testcase( i==91 ); /* WHEN */
155036
- testcase( i==92 ); /* WHERE */
155037
- testcase( i==93 ); /* RECURSIVE */
155038
- testcase( i==94 ); /* AFTER */
155039
- testcase( i==95 ); /* RENAME */
155040
- testcase( i==96 ); /* AND */
155041
- testcase( i==97 ); /* DEFAULT */
155042
- testcase( i==98 ); /* AUTOINCREMENT */
155043
- testcase( i==99 ); /* TO */
155044
- testcase( i==100 ); /* IN */
155045
- testcase( i==101 ); /* CAST */
155046
- testcase( i==102 ); /* COLUMN */
155047
- testcase( i==103 ); /* COMMIT */
155048
- testcase( i==104 ); /* CONFLICT */
155049
- testcase( i==105 ); /* CROSS */
155050
- testcase( i==106 ); /* CURRENT_TIMESTAMP */
155051
- testcase( i==107 ); /* CURRENT_TIME */
155052
- testcase( i==108 ); /* CURRENT */
155053
- testcase( i==109 ); /* PARTITION */
155054
- testcase( i==110 ); /* DEFERRED */
155055
- testcase( i==111 ); /* DISTINCT */
155056
- testcase( i==112 ); /* IS */
155057
- testcase( i==113 ); /* DROP */
155058
- testcase( i==114 ); /* PRECEDING */
155059
- testcase( i==115 ); /* FAIL */
155060
- testcase( i==116 ); /* LIMIT */
155061
- testcase( i==117 ); /* FILTER */
155062
- testcase( i==118 ); /* REPLACE */
155063
- testcase( i==119 ); /* FIRST */
155064
- testcase( i==120 ); /* FOLLOWING */
155065
- testcase( i==121 ); /* FROM */
155066
- testcase( i==122 ); /* FULL */
155067
- testcase( i==123 ); /* IF */
155068
- testcase( i==124 ); /* ORDER */
155069
- testcase( i==125 ); /* RESTRICT */
155070
- testcase( i==126 ); /* OTHERS */
155071
- testcase( i==127 ); /* OVER */
155072
- testcase( i==128 ); /* RIGHT */
155073
- testcase( i==129 ); /* ROLLBACK */
155074
- testcase( i==130 ); /* ROWS */
155075
- testcase( i==131 ); /* ROW */
155076
- testcase( i==132 ); /* UNBOUNDED */
155077
- testcase( i==133 ); /* UNION */
155078
- testcase( i==134 ); /* USING */
155079
- testcase( i==135 ); /* VACUUM */
155080
- testcase( i==136 ); /* VIEW */
155081
- testcase( i==137 ); /* WINDOW */
155082
- testcase( i==138 ); /* DO */
155083
- testcase( i==139 ); /* BY */
155084
- testcase( i==140 ); /* INITIALLY */
155085
- testcase( i==141 ); /* ALL */
155086
- testcase( i==142 ); /* PRIMARY */
156273
+ testcase( i==55 ); /* RANGE */
156274
+ testcase( i==56 ); /* GENERATED */
156275
+ testcase( i==57 ); /* DETACH */
156276
+ testcase( i==58 ); /* HAVING */
156277
+ testcase( i==59 ); /* GLOB */
156278
+ testcase( i==60 ); /* BEGIN */
156279
+ testcase( i==61 ); /* INNER */
156280
+ testcase( i==62 ); /* REFERENCES */
156281
+ testcase( i==63 ); /* UNIQUE */
156282
+ testcase( i==64 ); /* QUERY */
156283
+ testcase( i==65 ); /* WITHOUT */
156284
+ testcase( i==66 ); /* WITH */
156285
+ testcase( i==67 ); /* OUTER */
156286
+ testcase( i==68 ); /* RELEASE */
156287
+ testcase( i==69 ); /* ATTACH */
156288
+ testcase( i==70 ); /* BETWEEN */
156289
+ testcase( i==71 ); /* NOTHING */
156290
+ testcase( i==72 ); /* GROUPS */
156291
+ testcase( i==73 ); /* GROUP */
156292
+ testcase( i==74 ); /* CASCADE */
156293
+ testcase( i==75 ); /* ASC */
156294
+ testcase( i==76 ); /* DEFAULT */
156295
+ testcase( i==77 ); /* CASE */
156296
+ testcase( i==78 ); /* COLLATE */
156297
+ testcase( i==79 ); /* CREATE */
156298
+ testcase( i==80 ); /* CURRENT_DATE */
156299
+ testcase( i==81 ); /* IMMEDIATE */
156300
+ testcase( i==82 ); /* JOIN */
156301
+ testcase( i==83 ); /* INSERT */
156302
+ testcase( i==84 ); /* MATCH */
156303
+ testcase( i==85 ); /* PLAN */
156304
+ testcase( i==86 ); /* ANALYZE */
156305
+ testcase( i==87 ); /* PRAGMA */
156306
+ testcase( i==88 ); /* ABORT */
156307
+ testcase( i==89 ); /* UPDATE */
156308
+ testcase( i==90 ); /* VALUES */
156309
+ testcase( i==91 ); /* VIRTUAL */
156310
+ testcase( i==92 ); /* ALWAYS */
156311
+ testcase( i==93 ); /* WHEN */
156312
+ testcase( i==94 ); /* WHERE */
156313
+ testcase( i==95 ); /* RECURSIVE */
156314
+ testcase( i==96 ); /* AFTER */
156315
+ testcase( i==97 ); /* RENAME */
156316
+ testcase( i==98 ); /* AND */
156317
+ testcase( i==99 ); /* DEFERRED */
156318
+ testcase( i==100 ); /* DISTINCT */
156319
+ testcase( i==101 ); /* IS */
156320
+ testcase( i==102 ); /* AUTOINCREMENT */
156321
+ testcase( i==103 ); /* TO */
156322
+ testcase( i==104 ); /* IN */
156323
+ testcase( i==105 ); /* CAST */
156324
+ testcase( i==106 ); /* COLUMN */
156325
+ testcase( i==107 ); /* COMMIT */
156326
+ testcase( i==108 ); /* CONFLICT */
156327
+ testcase( i==109 ); /* CROSS */
156328
+ testcase( i==110 ); /* CURRENT_TIMESTAMP */
156329
+ testcase( i==111 ); /* CURRENT_TIME */
156330
+ testcase( i==112 ); /* CURRENT */
156331
+ testcase( i==113 ); /* PARTITION */
156332
+ testcase( i==114 ); /* DROP */
156333
+ testcase( i==115 ); /* PRECEDING */
156334
+ testcase( i==116 ); /* FAIL */
156335
+ testcase( i==117 ); /* LAST */
156336
+ testcase( i==118 ); /* FILTER */
156337
+ testcase( i==119 ); /* REPLACE */
156338
+ testcase( i==120 ); /* FIRST */
156339
+ testcase( i==121 ); /* FOLLOWING */
156340
+ testcase( i==122 ); /* FROM */
156341
+ testcase( i==123 ); /* FULL */
156342
+ testcase( i==124 ); /* LIMIT */
156343
+ testcase( i==125 ); /* IF */
156344
+ testcase( i==126 ); /* ORDER */
156345
+ testcase( i==127 ); /* RESTRICT */
156346
+ testcase( i==128 ); /* OTHERS */
156347
+ testcase( i==129 ); /* OVER */
156348
+ testcase( i==130 ); /* RIGHT */
156349
+ testcase( i==131 ); /* ROLLBACK */
156350
+ testcase( i==132 ); /* ROWS */
156351
+ testcase( i==133 ); /* ROW */
156352
+ testcase( i==134 ); /* UNBOUNDED */
156353
+ testcase( i==135 ); /* UNION */
156354
+ testcase( i==136 ); /* USING */
156355
+ testcase( i==137 ); /* VACUUM */
156356
+ testcase( i==138 ); /* VIEW */
156357
+ testcase( i==139 ); /* WINDOW */
156358
+ testcase( i==140 ); /* DO */
156359
+ testcase( i==141 ); /* BY */
156360
+ testcase( i==142 ); /* INITIALLY */
156361
+ testcase( i==143 ); /* ALL */
156362
+ testcase( i==144 ); /* PRIMARY */
155087156363
*pType = aKWCode[i];
155088156364
break;
155089156365
}
155090156366
}
155091156367
return n;
@@ -155093,11 +156369,11 @@
155093156369
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
155094156370
int id = TK_ID;
155095156371
keywordCode((char*)z, n, &id);
155096156372
return id;
155097156373
}
155098
-#define SQLITE_N_KEYWORD 143
156374
+#define SQLITE_N_KEYWORD 145
155099156375
SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
155100156376
if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
155101156377
*pzName = zKWText + aKWOffset[i];
155102156378
*pnName = aKWLen[i];
155103156379
return SQLITE_OK;
@@ -155720,11 +156996,11 @@
155720156996
int tokenType; /* type of current token */
155721156997
int prevType = 0; /* Previous non-whitespace token */
155722156998
int nParen; /* Number of nested levels of parentheses */
155723156999
int iStartIN; /* Start of RHS of IN operator in z[] */
155724157000
int nParenAtIN; /* Value of nParent at start of RHS of IN operator */
155725
- int j; /* Bytes of normalized SQL generated so far */
157001
+ u32 j; /* Bytes of normalized SQL generated so far */
155726157002
sqlite3_str *pStr; /* The normalized SQL string under construction */
155727157003
155728157004
db = sqlite3VdbeDb(pVdbe);
155729157005
tokenType = -1;
155730157006
nParen = iStartIN = nParenAtIN = 0;
@@ -155764,11 +157040,11 @@
155764157040
sqlite3_str_append(pStr, "(", 1);
155765157041
break;
155766157042
}
155767157043
case TK_RP: {
155768157044
if( iStartIN>0 && nParen==nParenAtIN ){
155769
- assert( pStr->nChar>=iStartIN );
157045
+ assert( pStr->nChar>=(u32)iStartIN );
155770157046
pStr->nChar = iStartIN+1;
155771157047
sqlite3_str_append(pStr, "?,?,?", 5);
155772157048
iStartIN = 0;
155773157049
}
155774157050
nParen--;
@@ -156933,10 +158209,11 @@
156933158209
}
156934158210
db->lookaside.pStart = pStart;
156935158211
db->lookaside.pInit = 0;
156936158212
db->lookaside.pFree = 0;
156937158213
db->lookaside.sz = (u16)sz;
158214
+ db->lookaside.szTrue = (u16)sz;
156938158215
if( pStart ){
156939158216
int i;
156940158217
LookasideSlot *p;
156941158218
assert( sz > (int)sizeof(LookasideSlot*) );
156942158219
db->lookaside.nSlot = cnt;
@@ -156951,10 +158228,11 @@
156951158228
db->lookaside.bMalloced = pBuf==0 ?1:0;
156952158229
}else{
156953158230
db->lookaside.pStart = db;
156954158231
db->lookaside.pEnd = db;
156955158232
db->lookaside.bDisable = 1;
158233
+ db->lookaside.sz = 0;
156956158234
db->lookaside.bMalloced = 0;
156957158235
db->lookaside.nSlot = 0;
156958158236
}
156959158237
#endif /* SQLITE_OMIT_LOOKASIDE */
156960158238
return SQLITE_OK;
@@ -157067,10 +158345,11 @@
157067158345
{ SQLITE_DBCONFIG_WRITABLE_SCHEMA, SQLITE_WriteSchema|
157068158346
SQLITE_NoSchemaError },
157069158347
{ SQLITE_DBCONFIG_LEGACY_ALTER_TABLE, SQLITE_LegacyAlter },
157070158348
{ SQLITE_DBCONFIG_DQS_DDL, SQLITE_DqsDDL },
157071158349
{ SQLITE_DBCONFIG_DQS_DML, SQLITE_DqsDML },
158350
+ { SQLITE_DBCONFIG_LEGACY_FILE_FORMAT, SQLITE_LegacyFileFmt },
157072158351
};
157073158352
unsigned int i;
157074158353
rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
157075158354
for(i=0; i<ArraySize(aFlagOp); i++){
157076158355
if( aFlagOp[i].op==op ){
@@ -157605,10 +158884,11 @@
157605158884
case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
157606158885
case SQLITE_CANTOPEN_NOTEMPDIR: zName = "SQLITE_CANTOPEN_NOTEMPDIR";break;
157607158886
case SQLITE_CANTOPEN_ISDIR: zName = "SQLITE_CANTOPEN_ISDIR"; break;
157608158887
case SQLITE_CANTOPEN_FULLPATH: zName = "SQLITE_CANTOPEN_FULLPATH"; break;
157609158888
case SQLITE_CANTOPEN_CONVPATH: zName = "SQLITE_CANTOPEN_CONVPATH"; break;
158889
+ case SQLITE_CANTOPEN_SYMLINK: zName = "SQLITE_CANTOPEN_SYMLINK"; break;
157610158890
case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break;
157611158891
case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break;
157612158892
case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break;
157613158893
case SQLITE_TOOBIG: zName = "SQLITE_TOOBIG"; break;
157614158894
case SQLITE_CONSTRAINT: zName = "SQLITE_CONSTRAINT"; break;
@@ -159282,10 +160562,11 @@
159282160562
db->errMask = 0xff;
159283160563
db->nDb = 2;
159284160564
db->magic = SQLITE_MAGIC_BUSY;
159285160565
db->aDb = db->aDbStatic;
159286160566
db->lookaside.bDisable = 1;
160567
+ db->lookaside.sz = 0;
159287160568
159288160569
assert( sizeof(db->aLimit)==sizeof(aHardLimit) );
159289160570
memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
159290160571
db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS;
159291160572
db->autoCommit = 1;
@@ -160401,10 +161682,29 @@
160401161682
va_end(ap);
160402161683
#endif /* SQLITE_UNTESTABLE */
160403161684
return rc;
160404161685
}
160405161686
161687
+#ifdef SQLITE_DEBUG
161688
+/*
161689
+** This routine appears inside assert() statements only.
161690
+**
161691
+** Return the number of URI parameters that follow the filename.
161692
+*/
161693
+SQLITE_PRIVATE int sqlite3UriCount(const char *z){
161694
+ int n = 0;
161695
+ if( z==0 ) return 0;
161696
+ z += strlen(z)+1;
161697
+ while( z[0] ){
161698
+ z += strlen(z)+1;
161699
+ z += strlen(z)+1;
161700
+ n++;
161701
+ }
161702
+ return n;
161703
+}
161704
+#endif /* SQLITE_DEBUG */
161705
+
160406161706
/*
160407161707
** This is a utility routine, useful to VFS implementations, that checks
160408161708
** to see if a database file was a URI that contained a specific query
160409161709
** parameter, and if so obtains the value of the query parameter.
160410161710
**
@@ -161883,16 +163183,26 @@
161883163183
*/
161884163184
int inTransaction; /* True after xBegin but before xCommit/xRollback */
161885163185
int mxSavepoint; /* Largest valid xSavepoint integer */
161886163186
#endif
161887163187
161888
-#ifdef SQLITE_TEST
163188
+#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
161889163189
/* True to disable the incremental doclist optimization. This is controled
161890163190
** by special insert command 'test-no-incr-doclist'. */
161891163191
int bNoIncrDoclist;
163192
+
163193
+ /* Number of segments in a level */
163194
+ int nMergeCount;
161892163195
#endif
161893163196
};
163197
+
163198
+/* Macro to find the number of segments to merge */
163199
+#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
163200
+# define MergeCount(P) ((P)->nMergeCount)
163201
+#else
163202
+# define MergeCount(P) FTS3_MERGE_COUNT
163203
+#endif
161894163204
161895163205
/*
161896163206
** When the core wants to read from the virtual table, it creates a
161897163207
** virtual table cursor (an instance of the following structure) using
161898163208
** the xOpen method. Cursors are destroyed using the xClose method.
@@ -162153,10 +163463,11 @@
162153163463
162154163464
/* fts3.c */
162155163465
SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...);
162156163466
SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
162157163467
SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
163468
+SQLITE_PRIVATE int sqlite3Fts3GetVarintBounded(const char*,const char*,sqlite3_int64*);
162158163469
SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
162159163470
SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
162160163471
SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
162161163472
SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
162162163473
SQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);
@@ -162315,10 +163626,36 @@
162315163626
GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *v, 4);
162316163627
b = (a & 0x0FFFFFFF );
162317163628
162318163629
for(shift=28; shift<=63; shift+=7){
162319163630
u64 c = *p++;
163631
+ b += (c&0x7F) << shift;
163632
+ if( (c & 0x80)==0 ) break;
163633
+ }
163634
+ *v = b;
163635
+ return (int)(p - pStart);
163636
+}
163637
+
163638
+/*
163639
+** Read a 64-bit variable-length integer from memory starting at p[0] and
163640
+** not extending past pEnd[-1].
163641
+** Return the number of bytes read, or 0 on error.
163642
+** The value is stored in *v.
163643
+*/
163644
+SQLITE_PRIVATE int sqlite3Fts3GetVarintBounded(
163645
+ const char *pBuf,
163646
+ const char *pEnd,
163647
+ sqlite_int64 *v
163648
+){
163649
+ const unsigned char *p = (const unsigned char*)pBuf;
163650
+ const unsigned char *pStart = p;
163651
+ const unsigned char *pX = (const unsigned char*)pEnd;
163652
+ u64 b = 0;
163653
+ int shift;
163654
+ for(shift=0; shift<=63; shift+=7){
163655
+ u64 c = p<pX ? *p : 0;
163656
+ p++;
162320163657
b += (c&0x7F) << shift;
162321163658
if( (c & 0x80)==0 ) break;
162322163659
}
162323163660
*v = b;
162324163661
return (int)(p - pStart);
@@ -163416,10 +164753,14 @@
163416164753
163417164754
/* Figure out the page-size for the database. This is required in order to
163418164755
** estimate the cost of loading large doclists from the database. */
163419164756
fts3DatabasePageSize(&rc, p);
163420164757
p->nNodeSize = p->nPgsz-35;
164758
+
164759
+#if defined(SQLITE_DEBUG)||defined(SQLITE_TEST)
164760
+ p->nMergeCount = FTS3_MERGE_COUNT;
164761
+#endif
163421164762
163422164763
/* Declare the table schema to SQLite. */
163423164764
fts3DeclareVtab(&rc, p);
163424164765
163425164766
fts3_init_out:
@@ -163924,11 +165265,17 @@
163924165265
163925165266
if( rc==SQLITE_OK ){
163926165267
rc = sqlite3Fts3ReadBlock(p, piLeaf?*piLeaf:*piLeaf2, &zBlob, &nBlob, 0);
163927165268
}
163928165269
if( rc==SQLITE_OK ){
163929
- rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, piLeaf2);
165270
+ int iNewHeight = 0;
165271
+ fts3GetVarint32(zBlob, &iNewHeight);
165272
+ if( iNewHeight>=iHeight ){
165273
+ rc = FTS_CORRUPT_VTAB;
165274
+ }else{
165275
+ rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, piLeaf2);
165276
+ }
163930165277
}
163931165278
sqlite3_free(zBlob);
163932165279
}
163933165280
163934165281
return rc;
@@ -164411,19 +165758,20 @@
164411165758
int bDescIdx, /* True for descending docids */
164412165759
sqlite3_int64 *piPrev, /* IN/OUT: Previous value written to list */
164413165760
int *pbFirst, /* IN/OUT: True after first int written */
164414165761
sqlite3_int64 iVal /* Write this value to the list */
164415165762
){
164416
- sqlite3_int64 iWrite;
165763
+ sqlite3_uint64 iWrite;
164417165764
if( bDescIdx==0 || *pbFirst==0 ){
165765
+ assert_fts3_nc( *pbFirst==0 || iVal>=*piPrev );
164418165766
iWrite = iVal - *piPrev;
164419165767
}else{
165768
+ assert_fts3_nc( *piPrev>=iVal );
164420165769
iWrite = *piPrev - iVal;
164421165770
}
164422165771
assert( *pbFirst || *piPrev==0 );
164423165772
assert_fts3_nc( *pbFirst==0 || iWrite>0 );
164424
- assert( *pbFirst==0 || iWrite>=0 );
164425165773
*pp += sqlite3Fts3PutVarint(*pp, iWrite);
164426165774
*piPrev = iVal;
164427165775
*pbFirst = 1;
164428165776
}
164429165777
@@ -166267,11 +167615,11 @@
166267167615
** tokens or prefix tokens that cannot use a prefix-index. */
166268167616
int bHaveIncr = 0;
166269167617
int bIncrOk = (bOptOk
166270167618
&& pCsr->bDesc==pTab->bDescIdx
166271167619
&& p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0
166272
-#ifdef SQLITE_TEST
167620
+#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
166273167621
&& pTab->bNoIncrDoclist==0
166274167622
#endif
166275167623
);
166276167624
for(i=0; bIncrOk==1 && i<p->nToken; i++){
166277167625
Fts3PhraseToken *pToken = &p->aToken[i];
@@ -166789,16 +168137,17 @@
166789168137
const char *a;
166790168138
166791168139
rc = sqlite3Fts3SelectDoctotal(p, &pStmt);
166792168140
if( rc!=SQLITE_OK ) return rc;
166793168141
a = sqlite3_column_blob(pStmt, 0);
166794
- assert( a );
166795
-
166796
- pEnd = &a[sqlite3_column_bytes(pStmt, 0)];
166797
- a += sqlite3Fts3GetVarint(a, &nDoc);
166798
- while( a<pEnd ){
166799
- a += sqlite3Fts3GetVarint(a, &nByte);
168142
+ testcase( a==0 ); /* If %_stat.value set to X'' */
168143
+ if( a ){
168144
+ pEnd = &a[sqlite3_column_bytes(pStmt, 0)];
168145
+ a += sqlite3Fts3GetVarintBounded(a, pEnd, &nDoc);
168146
+ while( a<pEnd ){
168147
+ a += sqlite3Fts3GetVarintBounded(a, pEnd, &nByte);
168148
+ }
166800168149
}
166801168150
if( nDoc==0 || nByte==0 ){
166802168151
sqlite3_reset(pStmt);
166803168152
return FTS_CORRUPT_VTAB;
166804168153
}
@@ -171232,11 +172581,13 @@
171232172581
return rc;
171233172582
}
171234172583
171235172584
sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);
171236172585
if( SQLITE_ROW==sqlite3_step(pStmt) ){
171237
- if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){
172586
+ if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB
172587
+ && sqlite3_column_bytes(pStmt, 0)==sizeof(*pp)
172588
+ ){
171238172589
memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));
171239172590
}
171240172591
}
171241172592
171242172593
return sqlite3_finalize(pStmt);
@@ -172081,11 +173432,11 @@
172081173432
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
172082173433
172083173434
/* #include <string.h> */
172084173435
/* #include <assert.h> */
172085173436
/* #include <stdlib.h> */
172086
-
173437
+/* #include <stdio.h> */
172087173438
172088173439
#define FTS_MAX_APPENDABLE_HEIGHT 16
172089173440
172090173441
/*
172091173442
** When full-text index nodes are loaded from disk, the buffer that they
@@ -172125,11 +173476,11 @@
172125173476
# define FTS3_NODE_CHUNKSIZE (4*1024)
172126173477
# define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)
172127173478
#endif
172128173479
172129173480
/*
172130
-** The two values that may be meaningfully bound to the :1 parameter in
173481
+** The values that may be meaningfully bound to the :1 parameter in
172131173482
** statements SQL_REPLACE_STAT and SQL_SELECT_STAT.
172132173483
*/
172133173484
#define FTS_STAT_DOCTOTAL 0
172134173485
#define FTS_STAT_INCRMERGEHINT 1
172135173486
#define FTS_STAT_AUTOINCRMERGE 2
@@ -173211,11 +174562,11 @@
173211174562
/* If iNext is FTS3_MERGE_COUNT, indicating that level iLevel is already
173212174563
** full, merge all segments in level iLevel into a single iLevel+1
173213174564
** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,
173214174565
** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.
173215174566
*/
173216
- if( iNext>=FTS3_MERGE_COUNT ){
174567
+ if( iNext>=MergeCount(p) ){
173217174568
fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel));
173218174569
rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);
173219174570
*piIdx = 0;
173220174571
}else{
173221174572
*piIdx = iNext;
@@ -173437,11 +174788,11 @@
173437174788
** safe (no risk of overread) even if the node data is corrupted. */
173438174789
pNext += fts3GetVarint32(pNext, &nPrefix);
173439174790
pNext += fts3GetVarint32(pNext, &nSuffix);
173440174791
if( nSuffix<=0
173441174792
|| (&pReader->aNode[pReader->nNode] - pNext)<nSuffix
173442
- || nPrefix>pReader->nTermAlloc
174793
+ || nPrefix>pReader->nTerm
173443174794
){
173444174795
return FTS_CORRUPT_VTAB;
173445174796
}
173446174797
173447174798
/* Both nPrefix and nSuffix were read by fts3GetVarint32() and so are
@@ -174087,10 +175438,15 @@
174087175438
int nPrefix; /* Number of bytes of prefix compression */
174088175439
int nSuffix; /* Suffix length */
174089175440
174090175441
nPrefix = fts3PrefixCompress(pTree->zTerm, pTree->nTerm, zTerm, nTerm);
174091175442
nSuffix = nTerm-nPrefix;
175443
+
175444
+ /* If nSuffix is zero or less, then zTerm/nTerm must be a prefix of
175445
+ ** pWriter->zTerm/pWriter->nTerm. i.e. must be equal to or less than when
175446
+ ** compared with BINARY collation. This indicates corruption. */
175447
+ if( nSuffix<=0 ) return FTS_CORRUPT_VTAB;
174092175448
174093175449
nReq += sqlite3Fts3VarintLen(nPrefix)+sqlite3Fts3VarintLen(nSuffix)+nSuffix;
174094175450
if( nReq<=p->nNodeSize || !pTree->zTerm ){
174095175451
174096175452
if( nReq>p->nNodeSize ){
@@ -174381,13 +175737,15 @@
174381175737
assert( nData+nReq<=pWriter->nSize );
174382175738
174383175739
/* Append the prefix-compressed term and doclist to the buffer. */
174384175740
nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nPrefix);
174385175741
nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nSuffix);
175742
+ assert( nSuffix>0 );
174386175743
memcpy(&pWriter->aData[nData], &zTerm[nPrefix], nSuffix);
174387175744
nData += nSuffix;
174388175745
nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nDoclist);
175746
+ assert( nDoclist>0 );
174389175747
memcpy(&pWriter->aData[nData], aDoclist, nDoclist);
174390175748
pWriter->nData = nData + nDoclist;
174391175749
174392175750
/* Save the current term so that it can be used to prefix-compress the next.
174393175751
** If the isCopyTerm parameter is true, then the buffer pointed to by
@@ -174403,10 +175761,11 @@
174403175761
pWriter->nMalloc = nTerm*2;
174404175762
pWriter->zMalloc = zNew;
174405175763
pWriter->zTerm = zNew;
174406175764
}
174407175765
assert( pWriter->zTerm==pWriter->zMalloc );
175766
+ assert( nTerm>0 );
174408175767
memcpy(pWriter->zTerm, zTerm, nTerm);
174409175768
}else{
174410175769
pWriter->zTerm = (char *)zTerm;
174411175770
}
174412175771
pWriter->nTerm = nTerm;
@@ -174711,10 +176070,11 @@
174711176070
pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer);
174712176071
if( !pNew ) return SQLITE_NOMEM;
174713176072
pMsr->aBuffer = pNew;
174714176073
}
174715176074
176075
+ assert( nList>0 );
174716176076
memcpy(pMsr->aBuffer, pList, nList);
174717176077
return SQLITE_OK;
174718176078
}
174719176079
174720176080
SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
@@ -175024,18 +176384,16 @@
175024176384
175025176385
/* Calculate the 'docid' delta value to write into the merged
175026176386
** doclist. */
175027176387
sqlite3_int64 iDelta;
175028176388
if( p->bDescIdx && nDoclist>0 ){
176389
+ if( iPrev<=iDocid ) return FTS_CORRUPT_VTAB;
175029176390
iDelta = iPrev - iDocid;
175030176391
}else{
176392
+ if( nDoclist>0 && iPrev>=iDocid ) return FTS_CORRUPT_VTAB;
175031176393
iDelta = iDocid - iPrev;
175032176394
}
175033
- if( iDelta<=0 && (nDoclist>0 || iDelta!=iDocid) ){
175034
- return FTS_CORRUPT_VTAB;
175035
- }
175036
- assert( nDoclist>0 || iDelta==iDocid );
175037176395
175038176396
nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
175039176397
if( nDoclist+nByte>pCsr->nBuffer ){
175040176398
char *aNew;
175041176399
pCsr->nBuffer = (nDoclist+nByte)*2;
@@ -175540,11 +176898,14 @@
175540176898
static int fts3DoOptimize(Fts3Table *p, int bReturnDone){
175541176899
int bSeenDone = 0;
175542176900
int rc;
175543176901
sqlite3_stmt *pAllLangid = 0;
175544176902
175545
- rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
176903
+ rc = sqlite3Fts3PendingTermsFlush(p);
176904
+ if( rc==SQLITE_OK ){
176905
+ rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
176906
+ }
175546176907
if( rc==SQLITE_OK ){
175547176908
int rc2;
175548176909
sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);
175549176910
sqlite3_bind_int(pAllLangid, 2, p->nIndex);
175550176911
while( sqlite3_step(pAllLangid)==SQLITE_ROW ){
@@ -175561,11 +176922,10 @@
175561176922
rc2 = sqlite3_reset(pAllLangid);
175562176923
if( rc==SQLITE_OK ) rc = rc2;
175563176924
}
175564176925
175565176926
sqlite3Fts3SegmentsClose(p);
175566
- sqlite3Fts3PendingTermsClear(p);
175567176927
175568176928
return (rc==SQLITE_OK && bReturnDone && bSeenDone) ? SQLITE_DONE : rc;
175569176929
}
175570176930
175571176931
/*
@@ -175899,10 +177259,11 @@
175899177259
** the current node of layer iLayer. Due to the prefix compression,
175900177260
** the space required changes depending on which node the key is to
175901177261
** be added to. */
175902177262
nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);
175903177263
nSuffix = nTerm - nPrefix;
177264
+ if(nSuffix<=0 ) return FTS_CORRUPT_VTAB;
175904177265
nSpace = sqlite3Fts3VarintLen(nPrefix);
175905177266
nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
175906177267
175907177268
if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){
175908177269
/* If the current node of layer iLayer contains zero keys, or if adding
@@ -176293,10 +177654,14 @@
176293177654
pWriter->nLeafData = pWriter->nLeafData * -1;
176294177655
}
176295177656
pWriter->bNoLeafData = (pWriter->nLeafData==0);
176296177657
nRoot = sqlite3_column_bytes(pSelect, 4);
176297177658
aRoot = sqlite3_column_blob(pSelect, 4);
177659
+ if( aRoot==0 ){
177660
+ sqlite3_reset(pSelect);
177661
+ return nRoot ? SQLITE_NOMEM : FTS_CORRUPT_VTAB;
177662
+ }
176298177663
}else{
176299177664
return sqlite3_reset(pSelect);
176300177665
}
176301177666
176302177667
/* Check for the zero-length marker in the %_segments table */
@@ -176328,10 +177693,14 @@
176328177693
/* It is possible to append to this segment. Set up the IncrmergeWriter
176329177694
** object to do so. */
176330177695
int i;
176331177696
int nHeight = (int)aRoot[0];
176332177697
NodeWriter *pNode;
177698
+ if( nHeight<1 || nHeight>FTS_MAX_APPENDABLE_HEIGHT ){
177699
+ sqlite3_reset(pSelect);
177700
+ return FTS_CORRUPT_VTAB;
177701
+ }
176333177702
176334177703
pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;
176335177704
pWriter->iStart = iStart;
176336177705
pWriter->iEnd = iEnd;
176337177706
pWriter->iAbsLevel = iAbsLevel;
@@ -177006,12 +178375,19 @@
177006178375
if( rc==SQLITE_OK ){
177007178376
rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);
177008178377
}
177009178378
if( SQLITE_OK==rc && pCsr->nSegment==nSeg
177010178379
&& SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))
177011
- && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr))
177012178380
){
178381
+ int bEmpty = 0;
178382
+ rc = sqlite3Fts3SegReaderStep(p, pCsr);
178383
+ if( rc==SQLITE_OK ){
178384
+ bEmpty = 1;
178385
+ }else if( rc!=SQLITE_ROW ){
178386
+ sqlite3Fts3SegReaderFinish(pCsr);
178387
+ break;
178388
+ }
177013178389
if( bUseHint && iIdx>0 ){
177014178390
const char *zKey = pCsr->zTerm;
177015178391
int nKey = pCsr->nTerm;
177016178392
rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);
177017178393
}else{
@@ -177018,15 +178394,17 @@
177018178394
rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);
177019178395
}
177020178396
177021178397
if( rc==SQLITE_OK && pWriter->nLeafEst ){
177022178398
fts3LogMerge(nSeg, iAbsLevel);
177023
- do {
177024
- rc = fts3IncrmergeAppend(p, pWriter, pCsr);
177025
- if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);
177026
- if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;
177027
- }while( rc==SQLITE_ROW );
178399
+ if( bEmpty==0 ){
178400
+ do {
178401
+ rc = fts3IncrmergeAppend(p, pWriter, pCsr);
178402
+ if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);
178403
+ if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;
178404
+ }while( rc==SQLITE_ROW );
178405
+ }
177028178406
177029178407
/* Update or delete the input segments */
177030178408
if( rc==SQLITE_OK ){
177031178409
nRem -= (1 + pWriter->nWork);
177032178410
rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);
@@ -177087,11 +178465,11 @@
177087178465
static int fts3DoIncrmerge(
177088178466
Fts3Table *p, /* FTS3 table handle */
177089178467
const char *zParam /* Nul-terminated string containing "A,B" */
177090178468
){
177091178469
int rc;
177092
- int nMin = (FTS3_MERGE_COUNT / 2);
178470
+ int nMin = (MergeCount(p) / 2);
177093178471
int nMerge = 0;
177094178472
const char *z = zParam;
177095178473
177096178474
/* Read the first integer value */
177097178475
nMerge = fts3Getint(&z);
@@ -177132,11 +178510,11 @@
177132178510
const char *zParam /* Nul-terminated string containing boolean */
177133178511
){
177134178512
int rc = SQLITE_OK;
177135178513
sqlite3_stmt *pStmt = 0;
177136178514
p->nAutoincrmerge = fts3Getint(&zParam);
177137
- if( p->nAutoincrmerge==1 || p->nAutoincrmerge>FTS3_MERGE_COUNT ){
178515
+ if( p->nAutoincrmerge==1 || p->nAutoincrmerge>MergeCount(p) ){
177138178516
p->nAutoincrmerge = 8;
177139178517
}
177140178518
if( !p->bHasStat ){
177141178519
assert( p->bFts4==0 );
177142178520
sqlite3Fts3CreateStatTable(&rc, p);
@@ -177229,11 +178607,15 @@
177229178607
iPos = 0;
177230178608
if( iVal ){
177231178609
pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
177232178610
}else{
177233178611
pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
177234
- iDocid += iVal;
178612
+ if( p->bDescIdx ){
178613
+ iDocid -= iVal;
178614
+ }else{
178615
+ iDocid += iVal;
178616
+ }
177235178617
}
177236178618
}else{
177237178619
iPos += (iVal - 2);
177238178620
cksum = cksum ^ fts3ChecksumEntry(
177239178621
csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid,
@@ -177302,14 +178684,13 @@
177302178684
int iCol;
177303178685
177304178686
for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
177305178687
if( p->abNotindexed[iCol]==0 ){
177306178688
const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
177307
- int nText = sqlite3_column_bytes(pStmt, iCol+1);
177308178689
sqlite3_tokenizer_cursor *pT = 0;
177309178690
177310
- rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText,&pT);
178691
+ rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, -1, &pT);
177311178692
while( rc==SQLITE_OK ){
177312178693
char const *zToken; /* Buffer containing token */
177313178694
int nToken = 0; /* Number of bytes in token */
177314178695
int iDum1 = 0, iDum2 = 0; /* Dummy variables */
177315178696
int iPos = 0; /* Position of token in zText */
@@ -177390,11 +178771,11 @@
177390178771
**
177391178772
** Argument pVal contains the result of <expr>. Currently the only
177392178773
** meaningful value to insert is the text 'optimize'.
177393178774
*/
177394178775
static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){
177395
- int rc; /* Return Code */
178776
+ int rc = SQLITE_ERROR; /* Return Code */
177396178777
const char *zVal = (const char *)sqlite3_value_text(pVal);
177397178778
int nVal = sqlite3_value_bytes(pVal);
177398178779
177399178780
if( !zVal ){
177400178781
return SQLITE_NOMEM;
@@ -177406,25 +178787,31 @@
177406178787
rc = fts3DoIntegrityCheck(p);
177407178788
}else if( nVal>6 && 0==sqlite3_strnicmp(zVal, "merge=", 6) ){
177408178789
rc = fts3DoIncrmerge(p, &zVal[6]);
177409178790
}else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){
177410178791
rc = fts3DoAutoincrmerge(p, &zVal[10]);
177411
-#ifdef SQLITE_TEST
177412
- }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
177413
- p->nNodeSize = atoi(&zVal[9]);
177414
- rc = SQLITE_OK;
177415
- }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
177416
- p->nMaxPendingData = atoi(&zVal[11]);
177417
- rc = SQLITE_OK;
177418
- }else if( nVal>21 && 0==sqlite3_strnicmp(zVal, "test-no-incr-doclist=", 21) ){
177419
- p->bNoIncrDoclist = atoi(&zVal[21]);
177420
- rc = SQLITE_OK;
178792
+#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
178793
+ }else{
178794
+ int v;
178795
+ if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
178796
+ v = atoi(&zVal[9]);
178797
+ if( v>=24 && v<=p->nPgsz-35 ) p->nNodeSize = v;
178798
+ rc = SQLITE_OK;
178799
+ }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
178800
+ v = atoi(&zVal[11]);
178801
+ if( v>=64 && v<=FTS3_MAX_PENDING_DATA ) p->nMaxPendingData = v;
178802
+ rc = SQLITE_OK;
178803
+ }else if( nVal>21 && 0==sqlite3_strnicmp(zVal,"test-no-incr-doclist=",21) ){
178804
+ p->bNoIncrDoclist = atoi(&zVal[21]);
178805
+ rc = SQLITE_OK;
178806
+ }else if( nVal>11 && 0==sqlite3_strnicmp(zVal,"mergecount=",11) ){
178807
+ v = atoi(&zVal[11]);
178808
+ if( v>=4 && v<=FTS3_MERGE_COUNT && (v&1)==0 ) p->nMergeCount = v;
178809
+ rc = SQLITE_OK;
178810
+ }
177421178811
#endif
177422
- }else{
177423
- rc = SQLITE_ERROR;
177424178812
}
177425
-
177426178813
return rc;
177427178814
}
177428178815
177429178816
#ifndef SQLITE_DISABLE_FTS4_DEFERRED
177430178817
/*
@@ -178825,29 +180212,41 @@
178825180212
178826180213
static int fts3MatchinfoSelectDoctotal(
178827180214
Fts3Table *pTab,
178828180215
sqlite3_stmt **ppStmt,
178829180216
sqlite3_int64 *pnDoc,
178830
- const char **paLen
180217
+ const char **paLen,
180218
+ const char **ppEnd
178831180219
){
178832180220
sqlite3_stmt *pStmt;
178833180221
const char *a;
180222
+ const char *pEnd;
178834180223
sqlite3_int64 nDoc;
180224
+ int n;
180225
+
178835180226
178836180227
if( !*ppStmt ){
178837180228
int rc = sqlite3Fts3SelectDoctotal(pTab, ppStmt);
178838180229
if( rc!=SQLITE_OK ) return rc;
178839180230
}
178840180231
pStmt = *ppStmt;
178841180232
assert( sqlite3_data_count(pStmt)==1 );
178842180233
180234
+ n = sqlite3_column_bytes(pStmt, 0);
178843180235
a = sqlite3_column_blob(pStmt, 0);
178844
- a += sqlite3Fts3GetVarint(a, &nDoc);
178845
- if( nDoc==0 ) return FTS_CORRUPT_VTAB;
178846
- *pnDoc = (u32)nDoc;
180236
+ if( a==0 ){
180237
+ return FTS_CORRUPT_VTAB;
180238
+ }
180239
+ pEnd = a + n;
180240
+ a += sqlite3Fts3GetVarintBounded(a, pEnd, &nDoc);
180241
+ if( nDoc<=0 || a>pEnd ){
180242
+ return FTS_CORRUPT_VTAB;
180243
+ }
180244
+ *pnDoc = nDoc;
178847180245
178848180246
if( paLen ) *paLen = a;
180247
+ if( ppEnd ) *ppEnd = pEnd;
178849180248
return SQLITE_OK;
178850180249
}
178851180250
178852180251
/*
178853180252
** An instance of the following structure is used to store state while
@@ -179024,27 +180423,32 @@
179024180423
break;
179025180424
179026180425
case FTS3_MATCHINFO_NDOC:
179027180426
if( bGlobal ){
179028180427
sqlite3_int64 nDoc = 0;
179029
- rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0);
180428
+ rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0, 0);
179030180429
pInfo->aMatchinfo[0] = (u32)nDoc;
179031180430
}
179032180431
break;
179033180432
179034180433
case FTS3_MATCHINFO_AVGLENGTH:
179035180434
if( bGlobal ){
179036180435
sqlite3_int64 nDoc; /* Number of rows in table */
179037180436
const char *a; /* Aggregate column length array */
180437
+ const char *pEnd; /* First byte past end of length array */
179038180438
179039
- rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, &a);
180439
+ rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, &a, &pEnd);
179040180440
if( rc==SQLITE_OK ){
179041180441
int iCol;
179042180442
for(iCol=0; iCol<pInfo->nCol; iCol++){
179043180443
u32 iVal;
179044180444
sqlite3_int64 nToken;
179045180445
a += sqlite3Fts3GetVarint(a, &nToken);
180446
+ if( a>pEnd ){
180447
+ rc = SQLITE_CORRUPT_VTAB;
180448
+ break;
180449
+ }
179046180450
iVal = (u32)(((u32)(nToken&0xffffffff)+nDoc/2)/nDoc);
179047180451
pInfo->aMatchinfo[iCol] = iVal;
179048180452
}
179049180453
}
179050180454
}
@@ -179054,13 +180458,18 @@
179054180458
sqlite3_stmt *pSelectDocsize = 0;
179055180459
rc = sqlite3Fts3SelectDocsize(pTab, pCsr->iPrevId, &pSelectDocsize);
179056180460
if( rc==SQLITE_OK ){
179057180461
int iCol;
179058180462
const char *a = sqlite3_column_blob(pSelectDocsize, 0);
180463
+ const char *pEnd = a + sqlite3_column_bytes(pSelectDocsize, 0);
179059180464
for(iCol=0; iCol<pInfo->nCol; iCol++){
179060180465
sqlite3_int64 nToken;
179061
- a += sqlite3Fts3GetVarint(a, &nToken);
180466
+ a += sqlite3Fts3GetVarintBounded(a, pEnd, &nToken);
180467
+ if( a>pEnd ){
180468
+ rc = SQLITE_CORRUPT_VTAB;
180469
+ break;
180470
+ }
179062180471
pInfo->aMatchinfo[iCol] = (u32)nToken;
179063180472
}
179064180473
}
179065180474
sqlite3_reset(pSelectDocsize);
179066180475
break;
@@ -179087,11 +180496,11 @@
179087180496
pExpr = pCsr->pExpr;
179088180497
rc = fts3ExprLoadDoclists(pCsr, 0, 0);
179089180498
if( rc!=SQLITE_OK ) break;
179090180499
if( bGlobal ){
179091180500
if( pCsr->pDeferred ){
179092
- rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0);
180501
+ rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc,0,0);
179093180502
if( rc!=SQLITE_OK ) break;
179094180503
}
179095180504
rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
179096180505
sqlite3Fts3EvalTestDeferred(pCsr, &rc);
179097180506
if( rc!=SQLITE_OK ) break;
@@ -180822,10 +182231,41 @@
180822182231
jsonInit(&s, pCtx);
180823182232
jsonRenderNode(pNode, &s, aReplace);
180824182233
jsonResult(&s);
180825182234
sqlite3_result_subtype(pCtx, JSON_SUBTYPE);
180826182235
}
182236
+
182237
+/*
182238
+** Translate a single byte of Hex into an integer.
182239
+** This routine only works if h really is a valid hexadecimal
182240
+** character: 0..9a..fA..F
182241
+*/
182242
+static u8 jsonHexToInt(int h){
182243
+ assert( (h>='0' && h<='9') || (h>='a' && h<='f') || (h>='A' && h<='F') );
182244
+#ifdef SQLITE_EBCDIC
182245
+ h += 9*(1&~(h>>4));
182246
+#else
182247
+ h += 9*(1&(h>>6));
182248
+#endif
182249
+ return (u8)(h & 0xf);
182250
+}
182251
+
182252
+/*
182253
+** Convert a 4-byte hex string into an integer
182254
+*/
182255
+static u32 jsonHexToInt4(const char *z){
182256
+ u32 v;
182257
+ assert( safe_isxdigit(z[0]) );
182258
+ assert( safe_isxdigit(z[1]) );
182259
+ assert( safe_isxdigit(z[2]) );
182260
+ assert( safe_isxdigit(z[3]) );
182261
+ v = (jsonHexToInt(z[0])<<12)
182262
+ + (jsonHexToInt(z[1])<<8)
182263
+ + (jsonHexToInt(z[2])<<4)
182264
+ + jsonHexToInt(z[3]);
182265
+ return v;
182266
+}
180827182267
180828182268
/*
180829182269
** Make the JsonNode the return value of the function.
180830182270
*/
180831182271
static void jsonReturn(
@@ -180916,29 +182356,38 @@
180916182356
if( c!='\\' ){
180917182357
zOut[j++] = c;
180918182358
}else{
180919182359
c = z[++i];
180920182360
if( c=='u' ){
180921
- u32 v = 0, k;
180922
- for(k=0; k<4; i++, k++){
180923
- assert( i<n-2 );
180924
- c = z[i+1];
180925
- assert( safe_isxdigit(c) );
180926
- if( c<='9' ) v = v*16 + c - '0';
180927
- else if( c<='F' ) v = v*16 + c - 'A' + 10;
180928
- else v = v*16 + c - 'a' + 10;
180929
- }
182361
+ u32 v = jsonHexToInt4(z+i+1);
182362
+ i += 4;
180930182363
if( v==0 ) break;
180931182364
if( v<=0x7f ){
180932182365
zOut[j++] = (char)v;
180933182366
}else if( v<=0x7ff ){
180934182367
zOut[j++] = (char)(0xc0 | (v>>6));
180935182368
zOut[j++] = 0x80 | (v&0x3f);
180936182369
}else{
180937
- zOut[j++] = (char)(0xe0 | (v>>12));
180938
- zOut[j++] = 0x80 | ((v>>6)&0x3f);
180939
- zOut[j++] = 0x80 | (v&0x3f);
182370
+ u32 vlo;
182371
+ if( (v&0xfc00)==0xd800
182372
+ && i<n-6
182373
+ && z[i+1]=='\\'
182374
+ && z[i+2]=='u'
182375
+ && ((vlo = jsonHexToInt4(z+i+3))&0xfc00)==0xdc00
182376
+ ){
182377
+ /* We have a surrogate pair */
182378
+ v = ((v&0x3ff)<<10) + (vlo&0x3ff) + 0x10000;
182379
+ i += 6;
182380
+ zOut[j++] = 0xf0 | (v>>18);
182381
+ zOut[j++] = 0x80 | ((v>>12)&0x3f);
182382
+ zOut[j++] = 0x80 | ((v>>6)&0x3f);
182383
+ zOut[j++] = 0x80 | (v&0x3f);
182384
+ }else{
182385
+ zOut[j++] = 0xe0 | (v>>12);
182386
+ zOut[j++] = 0x80 | ((v>>6)&0x3f);
182387
+ zOut[j++] = 0x80 | (v&0x3f);
182388
+ }
180940182389
}
180941182390
}else{
180942182391
if( c=='b' ){
180943182392
c = '\b';
180944182393
}else if( c=='f' ){
@@ -195928,11 +197377,11 @@
195928197377
**
195929197378
******************************************************************************
195930197379
**
195931197380
** This file contains an implementation of the "dbstat" virtual table.
195932197381
**
195933
-** The dbstat virtual table is used to extract low-level formatting
197382
+** The dbstat virtual table is used to extract low-level storage
195934197383
** information from an SQLite database in order to implement the
195935197384
** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script
195936197385
** for an example implementation.
195937197386
**
195938197387
** Additional information is available on the "dbstat.html" page of the
@@ -195972,90 +197421,98 @@
195972197421
** the overflow pages associated with a cell will appear earlier in the
195973197422
** sort-order than its child page:
195974197423
**
195975197424
** '/1c2/000/' // Left-most child of 451st child of root
195976197425
*/
195977
-#define VTAB_SCHEMA \
195978
- "CREATE TABLE xx( " \
195979
- " name TEXT, /* Name of table or index */" \
195980
- " path TEXT, /* Path to page from root */" \
195981
- " pageno INTEGER, /* Page number */" \
195982
- " pagetype TEXT, /* 'internal', 'leaf' or 'overflow' */" \
195983
- " ncell INTEGER, /* Cells on page (0 for overflow) */" \
195984
- " payload INTEGER, /* Bytes of payload on this page */" \
195985
- " unused INTEGER, /* Bytes of unused space on this page */" \
195986
- " mx_payload INTEGER, /* Largest payload size of all cells */" \
195987
- " pgoffset INTEGER, /* Offset of page in file */" \
195988
- " pgsize INTEGER, /* Size of the page */" \
195989
- " schema TEXT HIDDEN /* Database schema being analyzed */" \
195990
- ");"
195991
-
195992
-
197426
+static const char zDbstatSchema[] =
197427
+ "CREATE TABLE x("
197428
+ " name TEXT," /* 0 Name of table or index */
197429
+ " path TEXT," /* 1 Path to page from root (NULL for agg) */
197430
+ " pageno INTEGER," /* 2 Page number (page count for aggregates) */
197431
+ " pagetype TEXT," /* 3 'internal', 'leaf', 'overflow', or NULL */
197432
+ " ncell INTEGER," /* 4 Cells on page (0 for overflow) */
197433
+ " payload INTEGER," /* 5 Bytes of payload on this page */
197434
+ " unused INTEGER," /* 6 Bytes of unused space on this page */
197435
+ " mx_payload INTEGER," /* 7 Largest payload size of all cells */
197436
+ " pgoffset INTEGER," /* 8 Offset of page in file (NULL for agg) */
197437
+ " pgsize INTEGER," /* 9 Size of the page (sum for aggregate) */
197438
+ " schema TEXT HIDDEN," /* 10 Database schema being analyzed */
197439
+ " aggregate BOOLEAN HIDDEN" /* 11 aggregate info for each table */
197440
+ ")"
197441
+;
197442
+
197443
+/* Forward reference to data structured used in this module */
195993197444
typedef struct StatTable StatTable;
195994197445
typedef struct StatCursor StatCursor;
195995197446
typedef struct StatPage StatPage;
195996197447
typedef struct StatCell StatCell;
195997197448
197449
+/* Size information for a single cell within a btree page */
195998197450
struct StatCell {
195999197451
int nLocal; /* Bytes of local payload */
196000197452
u32 iChildPg; /* Child node (or 0 if this is a leaf) */
196001197453
int nOvfl; /* Entries in aOvfl[] */
196002197454
u32 *aOvfl; /* Array of overflow page numbers */
196003197455
int nLastOvfl; /* Bytes of payload on final overflow page */
196004197456
int iOvfl; /* Iterates through aOvfl[] */
196005197457
};
196006197458
197459
+/* Size information for a single btree page */
196007197460
struct StatPage {
196008
- u32 iPgno;
196009
- DbPage *pPg;
196010
- int iCell;
197461
+ u32 iPgno; /* Page number */
197462
+ DbPage *pPg; /* Page content */
197463
+ int iCell; /* Current cell */
196011197464
196012197465
char *zPath; /* Path to this page */
196013197466
196014197467
/* Variables populated by statDecodePage(): */
196015197468
u8 flags; /* Copy of flags byte */
196016197469
int nCell; /* Number of cells on page */
196017197470
int nUnused; /* Number of unused bytes on page */
196018197471
StatCell *aCell; /* Array of parsed cells */
196019197472
u32 iRightChildPg; /* Right-child page number (or 0) */
196020
- int nMxPayload; /* Largest payload of any cell on this page */
197473
+ int nMxPayload; /* Largest payload of any cell on the page */
196021197474
};
196022197475
197476
+/* The cursor for scanning the dbstat virtual table */
196023197477
struct StatCursor {
196024
- sqlite3_vtab_cursor base;
197478
+ sqlite3_vtab_cursor base; /* base class. MUST BE FIRST! */
196025197479
sqlite3_stmt *pStmt; /* Iterates through set of root pages */
196026
- int isEof; /* After pStmt has returned SQLITE_DONE */
197480
+ u8 isEof; /* After pStmt has returned SQLITE_DONE */
197481
+ u8 isAgg; /* Aggregate results for each table */
196027197482
int iDb; /* Schema used for this query */
196028197483
196029
- StatPage aPage[32];
197484
+ StatPage aPage[32]; /* Pages in path to current page */
196030197485
int iPage; /* Current entry in aPage[] */
196031197486
196032197487
/* Values to return. */
197488
+ u32 iPageno; /* Value of 'pageno' column */
196033197489
char *zName; /* Value of 'name' column */
196034197490
char *zPath; /* Value of 'path' column */
196035
- u32 iPageno; /* Value of 'pageno' column */
196036197491
char *zPagetype; /* Value of 'pagetype' column */
197492
+ int nPage; /* Number of pages in current btree */
196037197493
int nCell; /* Value of 'ncell' column */
196038
- int nPayload; /* Value of 'payload' column */
196039
- int nUnused; /* Value of 'unused' column */
196040197494
int nMxPayload; /* Value of 'mx_payload' column */
197495
+ i64 nUnused; /* Value of 'unused' column */
197496
+ i64 nPayload; /* Value of 'payload' column */
196041197497
i64 iOffset; /* Value of 'pgOffset' column */
196042
- int szPage; /* Value of 'pgSize' column */
197498
+ i64 szPage; /* Value of 'pgSize' column */
196043197499
};
196044197500
197501
+/* An instance of the DBSTAT virtual table */
196045197502
struct StatTable {
196046
- sqlite3_vtab base;
196047
- sqlite3 *db;
197503
+ sqlite3_vtab base; /* base class. MUST BE FIRST! */
197504
+ sqlite3 *db; /* Database connection that owns this vtab */
196048197505
int iDb; /* Index of database to analyze */
196049197506
};
196050197507
196051197508
#ifndef get2byte
196052197509
# define get2byte(x) ((x)[0]<<8 | (x)[1])
196053197510
#endif
196054197511
196055197512
/*
196056
-** Connect to or create a statvfs virtual table.
197513
+** Connect to or create a new DBSTAT virtual table.
196057197514
*/
196058197515
static int statConnect(
196059197516
sqlite3 *db,
196060197517
void *pAux,
196061197518
int argc, const char *const*argv,
@@ -196075,11 +197532,11 @@
196075197532
return SQLITE_ERROR;
196076197533
}
196077197534
}else{
196078197535
iDb = 0;
196079197536
}
196080
- rc = sqlite3_declare_vtab(db, VTAB_SCHEMA);
197537
+ rc = sqlite3_declare_vtab(db, zDbstatSchema);
196081197538
if( rc==SQLITE_OK ){
196082197539
pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable));
196083197540
if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;
196084197541
}
196085197542
@@ -196093,43 +197550,76 @@
196093197550
*ppVtab = (sqlite3_vtab*)pTab;
196094197551
return rc;
196095197552
}
196096197553
196097197554
/*
196098
-** Disconnect from or destroy a statvfs virtual table.
197555
+** Disconnect from or destroy the DBSTAT virtual table.
196099197556
*/
196100197557
static int statDisconnect(sqlite3_vtab *pVtab){
196101197558
sqlite3_free(pVtab);
196102197559
return SQLITE_OK;
196103197560
}
196104197561
196105197562
/*
196106
-** There is no "best-index". This virtual table always does a linear
196107
-** scan. However, a schema=? constraint should cause this table to
196108
-** operate on a different database schema, so check for it.
197563
+** Compute the best query strategy and return the result in idxNum.
196109197564
**
196110
-** idxNum is normally 0, but will be 1 if a schema=? constraint exists.
197565
+** idxNum-Bit Meaning
197566
+** ---------- ----------------------------------------------
197567
+** 0x01 There is a schema=? term in the WHERE clause
197568
+** 0x02 There is a name=? term in the WHERE clause
197569
+** 0x04 There is an aggregate=? term in the WHERE clause
197570
+** 0x08 Output should be ordered by name and path
196111197571
*/
196112197572
static int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
196113197573
int i;
197574
+ int iSchema = -1;
197575
+ int iName = -1;
197576
+ int iAgg = -1;
196114197577
196115197578
/* Look for a valid schema=? constraint. If found, change the idxNum to
196116197579
** 1 and request the value of that constraint be sent to xFilter. And
196117197580
** lower the cost estimate to encourage the constrained version to be
196118197581
** used.
196119197582
*/
196120197583
for(i=0; i<pIdxInfo->nConstraint; i++){
196121
- if( pIdxInfo->aConstraint[i].iColumn!=10 ) continue;
196122
- if( pIdxInfo->aConstraint[i].usable==0 ) return SQLITE_CONSTRAINT;
196123197584
if( pIdxInfo->aConstraint[i].op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
196124
- pIdxInfo->idxNum = 1;
196125
- pIdxInfo->estimatedCost = 1.0;
196126
- pIdxInfo->aConstraintUsage[i].argvIndex = 1;
196127
- pIdxInfo->aConstraintUsage[i].omit = 1;
196128
- break;
197585
+ if( pIdxInfo->aConstraint[i].usable==0 ){
197586
+ /* Force DBSTAT table should always be the right-most table in a join */
197587
+ return SQLITE_CONSTRAINT;
197588
+ }
197589
+ switch( pIdxInfo->aConstraint[i].iColumn ){
197590
+ case 0: { /* name */
197591
+ iName = i;
197592
+ break;
197593
+ }
197594
+ case 10: { /* schema */
197595
+ iSchema = i;
197596
+ break;
197597
+ }
197598
+ case 11: { /* aggregate */
197599
+ iAgg = i;
197600
+ break;
197601
+ }
197602
+ }
196129197603
}
196130
-
197604
+ i = 0;
197605
+ if( iSchema>=0 ){
197606
+ pIdxInfo->aConstraintUsage[iSchema].argvIndex = ++i;
197607
+ pIdxInfo->aConstraintUsage[iSchema].omit = 1;
197608
+ pIdxInfo->idxNum |= 0x01;
197609
+ }
197610
+ if( iName>=0 ){
197611
+ pIdxInfo->aConstraintUsage[iName].argvIndex = ++i;
197612
+ pIdxInfo->aConstraintUsage[iName].omit = 1;
197613
+ pIdxInfo->idxNum |= 0x02;
197614
+ }
197615
+ if( iAgg>=0 ){
197616
+ pIdxInfo->aConstraintUsage[iAgg].argvIndex = ++i;
197617
+ pIdxInfo->aConstraintUsage[iAgg].omit = 1;
197618
+ pIdxInfo->idxNum |= 0x04;
197619
+ }
197620
+ pIdxInfo->estimatedCost = 1.0;
196131197621
196132197622
/* Records are always returned in ascending order of (name, path).
196133197623
** If this will satisfy the client, set the orderByConsumed flag so that
196134197624
** SQLite does not do an external sort.
196135197625
*/
@@ -196143,17 +197633,18 @@
196143197633
&& pIdxInfo->aOrderBy[1].iColumn==1
196144197634
&& pIdxInfo->aOrderBy[1].desc==0
196145197635
)
196146197636
){
196147197637
pIdxInfo->orderByConsumed = 1;
197638
+ pIdxInfo->idxNum |= 0x08;
196148197639
}
196149197640
196150197641
return SQLITE_OK;
196151197642
}
196152197643
196153197644
/*
196154
-** Open a new statvfs cursor.
197645
+** Open a new DBSTAT cursor.
196155197646
*/
196156197647
static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
196157197648
StatTable *pTab = (StatTable *)pVTab;
196158197649
StatCursor *pCsr;
196159197650
@@ -196198,27 +197689,41 @@
196198197689
pCsr->iPage = 0;
196199197690
sqlite3_free(pCsr->zPath);
196200197691
pCsr->zPath = 0;
196201197692
pCsr->isEof = 0;
196202197693
}
197694
+
197695
+/* Resize the space-used counters inside of the cursor */
197696
+static void statResetCounts(StatCursor *pCsr){
197697
+ pCsr->nCell = 0;
197698
+ pCsr->nMxPayload = 0;
197699
+ pCsr->nUnused = 0;
197700
+ pCsr->nPayload = 0;
197701
+ pCsr->szPage = 0;
197702
+ pCsr->nPage = 0;
197703
+}
196203197704
196204197705
/*
196205
-** Close a statvfs cursor.
197706
+** Close a DBSTAT cursor.
196206197707
*/
196207197708
static int statClose(sqlite3_vtab_cursor *pCursor){
196208197709
StatCursor *pCsr = (StatCursor *)pCursor;
196209197710
statResetCsr(pCsr);
196210197711
sqlite3_finalize(pCsr->pStmt);
196211197712
sqlite3_free(pCsr);
196212197713
return SQLITE_OK;
196213197714
}
196214197715
196215
-static void getLocalPayload(
197716
+/*
197717
+** For a single cell on a btree page, compute the number of bytes of
197718
+** content (payload) stored on that page. That is to say, compute the
197719
+** number of bytes of content not found on overflow pages.
197720
+*/
197721
+static int getLocalPayload(
196216197722
int nUsable, /* Usable bytes per page */
196217197723
u8 flags, /* Page flags */
196218
- int nTotal, /* Total record (payload) size */
196219
- int *pnLocal /* OUT: Bytes stored locally */
197724
+ int nTotal /* Total record (payload) size */
196220197725
){
196221197726
int nLocal;
196222197727
int nMinLocal;
196223197728
int nMaxLocal;
196224197729
@@ -196230,13 +197735,16 @@
196230197735
nMaxLocal = (nUsable - 12) * 64 / 255 - 23;
196231197736
}
196232197737
196233197738
nLocal = nMinLocal + (nTotal - nMinLocal) % (nUsable - 4);
196234197739
if( nLocal>nMaxLocal ) nLocal = nMinLocal;
196235
- *pnLocal = nLocal;
197740
+ return nLocal;
196236197741
}
196237197742
197743
+/* Populate the StatPage object with information about the all
197744
+** cells found on the page currently under analysis.
197745
+*/
196238197746
static int statDecodePage(Btree *pBt, StatPage *p){
196239197747
int nUnused;
196240197748
int iOff;
196241197749
int nHdr;
196242197750
int isLeaf;
@@ -196303,11 +197811,11 @@
196303197811
if( p->flags==0x0D ){
196304197812
u64 dummy;
196305197813
iOff += sqlite3GetVarint(&aData[iOff], &dummy);
196306197814
}
196307197815
if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload;
196308
- getLocalPayload(nUsable, p->flags, nPayload, &nLocal);
197816
+ nLocal = getLocalPayload(nUsable, p->flags, nPayload);
196309197817
if( nLocal<0 ) goto statPageIsCorrupt;
196310197818
pCell->nLocal = nLocal;
196311197819
assert( nPayload>=(u32)nLocal );
196312197820
assert( nLocal<=(nUsable-35) );
196313197821
if( nPayload>(u32)nLocal ){
@@ -196353,27 +197861,29 @@
196353197861
Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;
196354197862
Pager *pPager = sqlite3BtreePager(pBt);
196355197863
sqlite3_file *fd;
196356197864
sqlite3_int64 x[2];
196357197865
196358
- /* The default page size and offset */
196359
- pCsr->szPage = sqlite3BtreeGetPageSize(pBt);
196360
- pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1);
196361
-
196362
- /* If connected to a ZIPVFS backend, override the page size and
196363
- ** offset with actual values obtained from ZIPVFS.
197866
+ /* If connected to a ZIPVFS backend, find the page size and
197867
+ ** offset from ZIPVFS.
196364197868
*/
196365197869
fd = sqlite3PagerFile(pPager);
196366197870
x[0] = pCsr->iPageno;
196367197871
if( sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){
196368197872
pCsr->iOffset = x[0];
196369
- pCsr->szPage = (int)x[1];
197873
+ pCsr->szPage += x[1];
197874
+ }else{
197875
+ /* Not ZIPVFS: The default page size and offset */
197876
+ pCsr->szPage += sqlite3BtreeGetPageSize(pBt);
197877
+ pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1);
196370197878
}
196371197879
}
196372197880
196373197881
/*
196374
-** Move a statvfs cursor to the next entry in the file.
197882
+** Move a DBSTAT cursor to the next entry. Normally, the next
197883
+** entry will be the next page, but in aggregated mode (pCsr->isAgg!=0),
197884
+** the next entry is the next btree.
196375197885
*/
196376197886
static int statNext(sqlite3_vtab_cursor *pCursor){
196377197887
int rc;
196378197888
int nPayload;
196379197889
char *z;
@@ -196385,10 +197895,12 @@
196385197895
sqlite3_free(pCsr->zPath);
196386197896
pCsr->zPath = 0;
196387197897
196388197898
statNextRestart:
196389197899
if( pCsr->aPage[0].pPg==0 ){
197900
+ /* Start measuring space on the next btree */
197901
+ statResetCounts(pCsr);
196390197902
rc = sqlite3_step(pCsr->pStmt);
196391197903
if( rc==SQLITE_ROW ){
196392197904
int nPage;
196393197905
u32 iRoot = (u32)sqlite3_column_int64(pCsr->pStmt, 1);
196394197906
sqlite3PagerPagecount(pPager, &nPage);
@@ -196397,57 +197909,65 @@
196397197909
return sqlite3_reset(pCsr->pStmt);
196398197910
}
196399197911
rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg, 0);
196400197912
pCsr->aPage[0].iPgno = iRoot;
196401197913
pCsr->aPage[0].iCell = 0;
196402
- pCsr->aPage[0].zPath = z = sqlite3_mprintf("/");
197914
+ if( !pCsr->isAgg ){
197915
+ pCsr->aPage[0].zPath = z = sqlite3_mprintf("/");
197916
+ if( z==0 ) rc = SQLITE_NOMEM_BKPT;
197917
+ }
196403197918
pCsr->iPage = 0;
196404
- if( z==0 ) rc = SQLITE_NOMEM_BKPT;
197919
+ pCsr->nPage = 1;
196405197920
}else{
196406197921
pCsr->isEof = 1;
196407197922
return sqlite3_reset(pCsr->pStmt);
196408197923
}
196409197924
}else{
196410
-
196411
- /* Page p itself has already been visited. */
197925
+ /* Continue analyzing the btree previously started */
196412197926
StatPage *p = &pCsr->aPage[pCsr->iPage];
196413
-
197927
+ if( !pCsr->isAgg ) statResetCounts(pCsr);
196414197928
while( p->iCell<p->nCell ){
196415197929
StatCell *pCell = &p->aCell[p->iCell];
196416
- if( pCell->iOvfl<pCell->nOvfl ){
196417
- int nUsable;
197930
+ while( pCell->iOvfl<pCell->nOvfl ){
197931
+ int nUsable, iOvfl;
196418197932
sqlite3BtreeEnter(pBt);
196419197933
nUsable = sqlite3BtreeGetPageSize(pBt) -
196420197934
sqlite3BtreeGetReserveNoMutex(pBt);
196421197935
sqlite3BtreeLeave(pBt);
196422
- pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);
196423
- pCsr->iPageno = pCell->aOvfl[pCell->iOvfl];
196424
- pCsr->zPagetype = "overflow";
196425
- pCsr->nCell = 0;
196426
- pCsr->nMxPayload = 0;
196427
- pCsr->zPath = z = sqlite3_mprintf(
196428
- "%s%.3x+%.6x", p->zPath, p->iCell, pCell->iOvfl
196429
- );
197936
+ pCsr->nPage++;
197937
+ statSizeAndOffset(pCsr);
196430197938
if( pCell->iOvfl<pCell->nOvfl-1 ){
196431
- pCsr->nUnused = 0;
196432
- pCsr->nPayload = nUsable - 4;
197939
+ pCsr->nPayload += nUsable - 4;
196433197940
}else{
196434
- pCsr->nPayload = pCell->nLastOvfl;
196435
- pCsr->nUnused = nUsable - 4 - pCsr->nPayload;
197941
+ pCsr->nPayload += pCell->nLastOvfl;
197942
+ pCsr->nUnused += nUsable - 4 - pCell->nLastOvfl;
196436197943
}
197944
+ iOvfl = pCell->iOvfl;
196437197945
pCell->iOvfl++;
196438
- statSizeAndOffset(pCsr);
196439
- return z==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK;
197946
+ if( !pCsr->isAgg ){
197947
+ pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);
197948
+ pCsr->iPageno = pCell->aOvfl[iOvfl];
197949
+ pCsr->zPagetype = "overflow";
197950
+ pCsr->zPath = z = sqlite3_mprintf(
197951
+ "%s%.3x+%.6x", p->zPath, p->iCell, iOvfl
197952
+ );
197953
+ return z==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK;
197954
+ }
196440197955
}
196441197956
if( p->iRightChildPg ) break;
196442197957
p->iCell++;
196443197958
}
196444197959
196445197960
if( !p->iRightChildPg || p->iCell>p->nCell ){
196446197961
statClearPage(p);
196447
- if( pCsr->iPage==0 ) return statNext(pCursor);
196448
- pCsr->iPage--;
197962
+ if( pCsr->iPage>0 ){
197963
+ pCsr->iPage--;
197964
+ }else if( pCsr->isAgg ){
197965
+ /* label-statNext-done: When computing aggregate space usage over
197966
+ ** an entire btree, this is the exit point from this function */
197967
+ return SQLITE_OK;
197968
+ }
196449197969
goto statNextRestart; /* Tail recursion */
196450197970
}
196451197971
pCsr->iPage++;
196452197972
if( pCsr->iPage>=ArraySize(pCsr->aPage) ){
196453197973
statResetCsr(pCsr);
@@ -196459,14 +197979,17 @@
196459197979
p[1].iPgno = p->iRightChildPg;
196460197980
}else{
196461197981
p[1].iPgno = p->aCell[p->iCell].iChildPg;
196462197982
}
196463197983
rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg, 0);
197984
+ pCsr->nPage++;
196464197985
p[1].iCell = 0;
196465
- p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell);
197986
+ if( !pCsr->isAgg ){
197987
+ p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell);
197988
+ if( z==0 ) rc = SQLITE_NOMEM_BKPT;
197989
+ }
196466197990
p->iCell++;
196467
- if( z==0 ) rc = SQLITE_NOMEM_BKPT;
196468197991
}
196469197992
196470197993
196471197994
/* Populate the StatCursor fields with the values to be returned
196472197995
** by the xColumn() and xRowid() methods.
@@ -196492,20 +198015,27 @@
196492198015
break;
196493198016
default:
196494198017
pCsr->zPagetype = "corrupted";
196495198018
break;
196496198019
}
196497
- pCsr->nCell = p->nCell;
196498
- pCsr->nUnused = p->nUnused;
196499
- pCsr->nMxPayload = p->nMxPayload;
196500
- pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath);
196501
- if( z==0 ) rc = SQLITE_NOMEM_BKPT;
198020
+ pCsr->nCell += p->nCell;
198021
+ pCsr->nUnused += p->nUnused;
198022
+ if( p->nMxPayload>pCsr->nMxPayload ) pCsr->nMxPayload = p->nMxPayload;
198023
+ if( !pCsr->isAgg ){
198024
+ pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath);
198025
+ if( z==0 ) rc = SQLITE_NOMEM_BKPT;
198026
+ }
196502198027
nPayload = 0;
196503198028
for(i=0; i<p->nCell; i++){
196504198029
nPayload += p->aCell[i].nLocal;
196505198030
}
196506
- pCsr->nPayload = nPayload;
198031
+ pCsr->nPayload += nPayload;
198032
+
198033
+ /* If computing aggregate space usage by btree, continue with the
198034
+ ** next page. The loop will exit via the return at label-statNext-done
198035
+ */
198036
+ if( pCsr->isAgg ) goto statNextRestart;
196507198037
}
196508198038
}
196509198039
196510198040
return rc;
196511198041
}
@@ -196513,40 +198043,67 @@
196513198043
static int statEof(sqlite3_vtab_cursor *pCursor){
196514198044
StatCursor *pCsr = (StatCursor *)pCursor;
196515198045
return pCsr->isEof;
196516198046
}
196517198047
198048
+/* Initialize a cursor according to the query plan idxNum using the
198049
+** arguments in argv[0]. See statBestIndex() for a description of the
198050
+** meaning of the bits in idxNum.
198051
+*/
196518198052
static int statFilter(
196519198053
sqlite3_vtab_cursor *pCursor,
196520198054
int idxNum, const char *idxStr,
196521198055
int argc, sqlite3_value **argv
196522198056
){
196523198057
StatCursor *pCsr = (StatCursor *)pCursor;
196524198058
StatTable *pTab = (StatTable*)(pCursor->pVtab);
196525
- char *zSql;
196526
- int rc = SQLITE_OK;
198059
+ sqlite3_str *pSql; /* Query of btrees to analyze */
198060
+ char *zSql; /* String value of pSql */
198061
+ int iArg = 0; /* Count of argv[] parameters used so far */
198062
+ int rc = SQLITE_OK; /* Result of this operation */
198063
+ const char *zName = 0; /* Only provide analysis of this table */
196527198064
196528
- if( idxNum==1 ){
196529
- const char *zDbase = (const char*)sqlite3_value_text(argv[0]);
198065
+ statResetCsr(pCsr);
198066
+ sqlite3_finalize(pCsr->pStmt);
198067
+ pCsr->pStmt = 0;
198068
+ if( idxNum & 0x01 ){
198069
+ /* schema=? constraint is present. Get its value */
198070
+ const char *zDbase = (const char*)sqlite3_value_text(argv[iArg++]);
196530198071
pCsr->iDb = sqlite3FindDbName(pTab->db, zDbase);
196531198072
if( pCsr->iDb<0 ){
196532198073
sqlite3_free(pCursor->pVtab->zErrMsg);
196533198074
pCursor->pVtab->zErrMsg = sqlite3_mprintf("no such schema: %s", zDbase);
196534198075
return pCursor->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM_BKPT;
196535198076
}
196536198077
}else{
196537198078
pCsr->iDb = pTab->iDb;
196538198079
}
196539
- statResetCsr(pCsr);
196540
- sqlite3_finalize(pCsr->pStmt);
196541
- pCsr->pStmt = 0;
196542
- zSql = sqlite3_mprintf(
196543
- "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type"
196544
- " UNION ALL "
196545
- "SELECT name, rootpage, type"
196546
- " FROM \"%w\".sqlite_master WHERE rootpage!=0"
196547
- " ORDER BY name", pTab->db->aDb[pCsr->iDb].zDbSName);
198080
+ if( idxNum & 0x02 ){
198081
+ /* name=? constraint is present */
198082
+ zName = (const char*)sqlite3_value_text(argv[iArg++]);
198083
+ }
198084
+ if( idxNum & 0x04 ){
198085
+ /* aggregate=? constraint is present */
198086
+ pCsr->isAgg = sqlite3_value_double(argv[iArg++])!=0.0;
198087
+ }else{
198088
+ pCsr->isAgg = 0;
198089
+ }
198090
+ pSql = sqlite3_str_new(pTab->db);
198091
+ sqlite3_str_appendf(pSql,
198092
+ "SELECT * FROM ("
198093
+ "SELECT 'sqlite_master' AS name,1 AS rootpage,'table' AS type"
198094
+ " UNION ALL "
198095
+ "SELECT name,rootpage,type"
198096
+ " FROM \"%w\".sqlite_master WHERE rootpage!=0)",
198097
+ pTab->db->aDb[pCsr->iDb].zDbSName);
198098
+ if( zName ){
198099
+ sqlite3_str_appendf(pSql, "WHERE name=%Q", zName);
198100
+ }
198101
+ if( idxNum & 0x08 ){
198102
+ sqlite3_str_appendf(pSql, " ORDER BY name");
198103
+ }
198104
+ zSql = sqlite3_str_finish(pSql);
196548198105
if( zSql==0 ){
196549198106
return SQLITE_NOMEM_BKPT;
196550198107
}else{
196551198108
rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);
196552198109
sqlite3_free(zSql);
@@ -196567,17 +198124,25 @@
196567198124
switch( i ){
196568198125
case 0: /* name */
196569198126
sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_TRANSIENT);
196570198127
break;
196571198128
case 1: /* path */
196572
- sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT);
198129
+ if( !pCsr->isAgg ){
198130
+ sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT);
198131
+ }
196573198132
break;
196574198133
case 2: /* pageno */
196575
- sqlite3_result_int64(ctx, pCsr->iPageno);
198134
+ if( pCsr->isAgg ){
198135
+ sqlite3_result_int64(ctx, pCsr->nPage);
198136
+ }else{
198137
+ sqlite3_result_int64(ctx, pCsr->iPageno);
198138
+ }
196576198139
break;
196577198140
case 3: /* pagetype */
196578
- sqlite3_result_text(ctx, pCsr->zPagetype, -1, SQLITE_STATIC);
198141
+ if( !pCsr->isAgg ){
198142
+ sqlite3_result_text(ctx, pCsr->zPagetype, -1, SQLITE_STATIC);
198143
+ }
196579198144
break;
196580198145
case 4: /* ncell */
196581198146
sqlite3_result_int(ctx, pCsr->nCell);
196582198147
break;
196583198148
case 5: /* payload */
@@ -196588,20 +198153,26 @@
196588198153
break;
196589198154
case 7: /* mx_payload */
196590198155
sqlite3_result_int(ctx, pCsr->nMxPayload);
196591198156
break;
196592198157
case 8: /* pgoffset */
196593
- sqlite3_result_int64(ctx, pCsr->iOffset);
198158
+ if( !pCsr->isAgg ){
198159
+ sqlite3_result_int64(ctx, pCsr->iOffset);
198160
+ }
196594198161
break;
196595198162
case 9: /* pgsize */
196596198163
sqlite3_result_int(ctx, pCsr->szPage);
196597198164
break;
196598
- default: { /* schema */
198165
+ case 10: { /* schema */
196599198166
sqlite3 *db = sqlite3_context_db_handle(ctx);
196600198167
int iDb = pCsr->iDb;
196601198168
sqlite3_result_text(ctx, db->aDb[iDb].zDbSName, -1, SQLITE_STATIC);
196602198169
break;
198170
+ }
198171
+ default: { /* aggregate */
198172
+ sqlite3_result_int(ctx, pCsr->isAgg);
198173
+ break;
196603198174
}
196604198175
}
196605198176
return SQLITE_OK;
196606198177
}
196607198178
@@ -203188,10 +204759,15 @@
203188204759
** less than 32. If it is set to anything large than that, an #error
203189204760
** directive in fts5_index.c will cause the build to fail.
203190204761
*/
203191204762
#define FTS5_MAX_PREFIX_INDEXES 31
203192204763
204764
+/*
204765
+** Maximum segments permitted in a single index
204766
+*/
204767
+#define FTS5_MAX_SEGMENT 2000
204768
+
203193204769
#define FTS5_DEFAULT_NEARDIST 10
203194204770
#define FTS5_DEFAULT_RANK "bm25"
203195204771
203196204772
/* Name of rank and rowid columns */
203197204773
#define FTS5_RANK_NAME "rank"
@@ -203544,10 +205120,15 @@
203544205120
/*
203545205121
** Close an iterator opened by sqlite3Fts5IndexQuery().
203546205122
*/
203547205123
static void sqlite3Fts5IterClose(Fts5IndexIter*);
203548205124
205125
+/*
205126
+** Close the reader blob handle, if it is open.
205127
+*/
205128
+static void sqlite3Fts5IndexCloseReader(Fts5Index*);
205129
+
203549205130
/*
203550205131
** This interface is used by the fts5vocab module.
203551205132
*/
203552205133
static const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*);
203553205134
static int sqlite3Fts5IterNextScan(Fts5IndexIter*);
@@ -205420,12 +207001,12 @@
205420207001
#ifdef fts5YYFALLBACK
205421207002
assert( iToken<(int)(sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])) );
205422207003
return fts5yyFallback[iToken];
205423207004
#else
205424207005
(void)iToken;
205425
-#endif
205426207006
return 0;
207007
+#endif
205427207008
}
205428207009
205429207010
/*
205430207011
** 2014 May 31
205431207012
**
@@ -206570,11 +208151,11 @@
206570208151
#define FTS5_DEFAULT_USERMERGE 4
206571208152
#define FTS5_DEFAULT_CRISISMERGE 16
206572208153
#define FTS5_DEFAULT_HASHSIZE (1024*1024)
206573208154
206574208155
/* Maximum allowed page size */
206575
-#define FTS5_MAX_PAGE_SIZE (128*1024)
208156
+#define FTS5_MAX_PAGE_SIZE (64*1024)
206576208157
206577208158
static int fts5_iswhitespace(char x){
206578208159
return (x==' ');
206579208160
}
206580208161
@@ -207375,11 +208956,11 @@
207375208956
if( 0==sqlite3_stricmp(zKey, "pgsz") ){
207376208957
int pgsz = 0;
207377208958
if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){
207378208959
pgsz = sqlite3_value_int(pVal);
207379208960
}
207380
- if( pgsz<=0 || pgsz>FTS5_MAX_PAGE_SIZE ){
208961
+ if( pgsz<32 || pgsz>FTS5_MAX_PAGE_SIZE ){
207381208962
*pbBadkey = 1;
207382208963
}else{
207383208964
pConfig->pgsz = pgsz;
207384208965
}
207385208966
}
@@ -207428,10 +209009,11 @@
207428209009
}
207429209010
if( nCrisisMerge<0 ){
207430209011
*pbBadkey = 1;
207431209012
}else{
207432209013
if( nCrisisMerge<=1 ) nCrisisMerge = FTS5_DEFAULT_CRISISMERGE;
209014
+ if( nCrisisMerge>=FTS5_MAX_SEGMENT ) nCrisisMerge = FTS5_MAX_SEGMENT-1;
207433209015
pConfig->nCrisisMerge = nCrisisMerge;
207434209016
}
207435209017
}
207436209018
207437209019
else if( 0==sqlite3_stricmp(zKey, "rank") ){
@@ -211199,15 +212781,10 @@
211199212781
)
211200212782
211201212783
#define FTS5_SEGMENT_ROWID(segid, pgno) fts5_dri(segid, 0, 0, pgno)
211202212784
#define FTS5_DLIDX_ROWID(segid, height, pgno) fts5_dri(segid, 1, height, pgno)
211203212785
211204
-/*
211205
-** Maximum segments permitted in a single index
211206
-*/
211207
-#define FTS5_MAX_SEGMENT 2000
211208
-
211209212786
#ifdef SQLITE_DEBUG
211210212787
static int sqlite3Fts5Corrupt() { return SQLITE_CORRUPT_VTAB; }
211211212788
#endif
211212212789
211213212790
@@ -211579,11 +213156,11 @@
211579213156
}
211580213157
211581213158
/*
211582213159
** Close the read-only blob handle, if it is open.
211583213160
*/
211584
-static void fts5CloseReader(Fts5Index *p){
213161
+static void sqlite3Fts5IndexCloseReader(Fts5Index *p){
211585213162
if( p->pReader ){
211586213163
sqlite3_blob *pReader = p->pReader;
211587213164
p->pReader = 0;
211588213165
sqlite3_blob_close(pReader);
211589213166
}
@@ -211608,11 +213185,11 @@
211608213185
p->pReader = 0;
211609213186
rc = sqlite3_blob_reopen(pBlob, iRowid);
211610213187
assert( p->pReader==0 );
211611213188
p->pReader = pBlob;
211612213189
if( rc!=SQLITE_OK ){
211613
- fts5CloseReader(p);
213190
+ sqlite3Fts5IndexCloseReader(p);
211614213191
}
211615213192
if( rc==SQLITE_ABORT ) rc = SQLITE_OK;
211616213193
}
211617213194
211618213195
/* If the blob handle is not open at this point, open it and seek
@@ -216169,11 +217746,11 @@
216169217746
** Commit data to disk.
216170217747
*/
216171217748
static int sqlite3Fts5IndexSync(Fts5Index *p){
216172217749
assert( p->rc==SQLITE_OK );
216173217750
fts5IndexFlush(p);
216174
- fts5CloseReader(p);
217751
+ sqlite3Fts5IndexCloseReader(p);
216175217752
return fts5IndexReturn(p);
216176217753
}
216177217754
216178217755
/*
216179217756
** Discard any data stored in the in-memory hash tables. Do not write it
@@ -216180,11 +217757,11 @@
216180217757
** to the database. Additionally, assume that the contents of the %_data
216181217758
** table may have changed on disk. So any in-memory caches of %_data
216182217759
** records must be invalidated.
216183217760
*/
216184217761
static int sqlite3Fts5IndexRollback(Fts5Index *p){
216185
- fts5CloseReader(p);
217762
+ sqlite3Fts5IndexCloseReader(p);
216186217763
fts5IndexDiscardData(p);
216187217764
fts5StructureInvalidate(p);
216188217765
/* assert( p->rc==SQLITE_OK ); */
216189217766
return SQLITE_OK;
216190217767
}
@@ -216195,10 +217772,11 @@
216195217772
** and the initial version of the "averages" record (a zero-byte blob).
216196217773
*/
216197217774
static int sqlite3Fts5IndexReinit(Fts5Index *p){
216198217775
Fts5Structure s;
216199217776
fts5StructureInvalidate(p);
217777
+ fts5IndexDiscardData(p);
216200217778
memset(&s, 0, sizeof(Fts5Structure));
216201217779
fts5DataWrite(p, FTS5_AVERAGES_ROWID, (const u8*)"", 0);
216202217780
fts5StructureWrite(p, &s);
216203217781
return fts5IndexReturn(p);
216204217782
}
@@ -216282,10 +217860,11 @@
216282217860
int n = 0;
216283217861
int i;
216284217862
for(i=0; i<nChar; i++){
216285217863
if( n>=nByte ) return 0; /* Input contains fewer than nChar chars */
216286217864
if( (unsigned char)p[n++]>=0xc0 ){
217865
+ if( n>=nByte ) break;
216287217866
while( (p[n] & 0xc0)==0x80 ){
216288217867
n++;
216289217868
if( n>=nByte ) break;
216290217869
}
216291217870
}
@@ -216420,11 +217999,11 @@
216420217999
}
216421218000
216422218001
if( p->rc ){
216423218002
sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
216424218003
pRet = 0;
216425
- fts5CloseReader(p);
218004
+ sqlite3Fts5IndexCloseReader(p);
216426218005
}
216427218006
216428218007
*ppIter = (Fts5IndexIter*)pRet;
216429218008
sqlite3Fts5BufferFree(&buf);
216430218009
}
@@ -216493,11 +218072,11 @@
216493218072
static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){
216494218073
if( pIndexIter ){
216495218074
Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
216496218075
Fts5Index *pIndex = pIter->pIndex;
216497218076
fts5MultiIterFree(pIter);
216498
- fts5CloseReader(pIndex);
218077
+ sqlite3Fts5IndexCloseReader(pIndex);
216499218078
}
216500218079
}
216501218080
216502218081
/*
216503218082
** Read and decode the "averages" record from the database.
@@ -216850,11 +218429,12 @@
216850218429
int iDlidxPrevLeaf = pSeg->pgnoLast;
216851218430
216852218431
if( pSeg->pgnoFirst==0 ) return;
216853218432
216854218433
fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf(
216855
- "SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d",
218434
+ "SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d "
218435
+ "ORDER BY 1, 2",
216856218436
pConfig->zDb, pConfig->zName, pSeg->iSegid
216857218437
));
216858218438
216859218439
/* Iterate through the b-tree hierarchy. */
216860218440
while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
@@ -218296,10 +219876,11 @@
218296219876
if( CsrFlagTest(pCsr, FTS5CSR_FREE_ZRANK) ){
218297219877
sqlite3_free(pCsr->zRank);
218298219878
sqlite3_free(pCsr->zRankArgs);
218299219879
}
218300219880
219881
+ sqlite3Fts5IndexCloseReader(pTab->p.pIndex);
218301219882
memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan - (u8*)pCsr));
218302219883
}
218303219884
218304219885
218305219886
/*
@@ -220265,11 +221846,11 @@
220265221846
int nArg, /* Number of args */
220266221847
sqlite3_value **apUnused /* Function arguments */
220267221848
){
220268221849
assert( nArg==0 );
220269221850
UNUSED_PARAM2(nArg, apUnused);
220270
- sqlite3_result_text(pCtx, "fts5: 2019-10-04 15:03:17 c20a35336432025445f9f7e289d0cc3e4003fb17f45a4ce74c6269c407c6e09f", -1, SQLITE_TRANSIENT);
221851
+ sqlite3_result_text(pCtx, "fts5: 2019-11-20 12:07:40 2575a68c3965e72f2ab211d933012442755afe6a9b7de9e9e50cdd2155fd1ec8", -1, SQLITE_TRANSIENT);
220271221852
}
220272221853
220273221854
/*
220274221855
** Return true if zName is the extension on one of the shadow tables used
220275221856
** by this module.
@@ -220958,10 +222539,12 @@
220958222539
** Delete all entries in the FTS5 index.
220959222540
*/
220960222541
static int sqlite3Fts5StorageDeleteAll(Fts5Storage *p){
220961222542
Fts5Config *pConfig = p->pConfig;
220962222543
int rc;
222544
+
222545
+ p->bTotalsValid = 0;
220963222546
220964222547
/* Delete the contents of the %_data and %_docsize tables. */
220965222548
rc = fts5ExecPrintf(pConfig->db, 0,
220966222549
"DELETE FROM %Q.'%q_data';"
220967222550
"DELETE FROM %Q.'%q_idx';",
@@ -225033,12 +226616,12 @@
225033226616
}
225034226617
#endif /* SQLITE_CORE */
225035226618
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
225036226619
225037226620
/************** End of stmt.c ************************************************/
225038
-#if __LINE__!=225038
226621
+#if __LINE__!=226621
225039226622
#undef SQLITE_SOURCE_ID
225040
-#define SQLITE_SOURCE_ID "2019-10-04 15:03:17 c20a35336432025445f9f7e289d0cc3e4003fb17f45a4ce74c6269c407c6alt2"
226623
+#define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9alt2"
225041226624
#endif
225042226625
/* Return the source-id for this library */
225043226626
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
225044226627
/************************** End of sqlite3.c ******************************/
225045226628
--- 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.
@@ -1163,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-10-04 15:03:17 c20a35336432025445f9f7e289d0cc3e4003fb17f45a4ce74c6269c407c6e09f"
1171
1172 /*
1173 ** CAPI3REF: Run-Time Library Version Numbers
1174 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1175 **
@@ -1556,10 +1556,11 @@
1556 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1557 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
1558 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
1559 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
1560 #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
 
1561 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
1562 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
1563 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
1564 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
1565 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -1608,10 +1609,11 @@
1608 #define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
1609 #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
1610 #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
1611 #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
1612 #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
 
1613
1614 /* Reserved: 0x00F00000 */
1615
1616 /*
1617 ** CAPI3REF: Device Characteristics
@@ -2446,10 +2448,11 @@
2446 ** SQLite.
2447 */
2448 #define SQLITE_ACCESS_EXISTS 0
2449 #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
2450 #define SQLITE_ACCESS_READ 2 /* Unused */
 
2451
2452 /*
2453 ** CAPI3REF: Flags for the xShmLock VFS method
2454 **
2455 ** These integer constants define the various locking operations
@@ -2782,10 +2785,11 @@
2782 ** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
2783 ** interpreted as a boolean, which enables or disables the collection of
2784 ** memory allocation statistics. ^(When memory allocation statistics are
2785 ** disabled, the following SQLite interfaces become non-operational:
2786 ** <ul>
 
2787 ** <li> [sqlite3_memory_used()]
2788 ** <li> [sqlite3_memory_highwater()]
2789 ** <li> [sqlite3_soft_heap_limit64()]
2790 ** <li> [sqlite3_status64()]
2791 ** </ul>)^
@@ -3299,10 +3303,32 @@
3299 ** the legacy [double-quoted string literal] misfeature for DDL statements,
3300 ** such as CREATE TABLE and CREATE INDEX. The
3301 ** default value of this setting is determined by the [-DSQLITE_DQS]
3302 ** compile-time option.
3303 ** </dd>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3304 ** </dl>
3305 */
3306 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
3307 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
3308 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -3317,11 +3343,12 @@
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 **
@@ -7155,10 +7182,13 @@
7155 */
7156 SQLITE_API int sqlite3_db_release_memory(sqlite3*);
7157
7158 /*
7159 ** CAPI3REF: Impose A Limit On Heap Size
 
 
 
7160 **
7161 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
7162 ** soft limit on the amount of heap memory that may be allocated by SQLite.
7163 ** ^SQLite strives to keep heap memory utilization below the soft heap
7164 ** limit by reducing the number of pages held in the page cache
@@ -7166,24 +7196,45 @@
7166 ** ^The soft heap limit is "soft" because even though SQLite strives to stay
7167 ** below the limit, it will exceed the limit rather than generate
7168 ** an [SQLITE_NOMEM] error. In other words, the soft heap limit
7169 ** is advisory only.
7170 **
7171 ** ^The return value from sqlite3_soft_heap_limit64() is the size of
7172 ** the soft heap limit prior to the call, or negative in the case of an
 
 
 
 
 
 
 
7173 ** error. ^If the argument N is negative
7174 ** then no change is made to the soft heap limit. Hence, the current
7175 ** size of the soft heap limit can be determined by invoking
7176 ** sqlite3_soft_heap_limit64() with a negative argument.
7177 **
7178 ** ^If the argument N is zero then the soft heap limit is disabled.
7179 **
7180 ** ^(The soft heap limit is not enforced in the current implementation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7181 ** if one or more of following conditions are true:
7182 **
7183 ** <ul>
7184 ** <li> The soft heap limit is set to zero.
7185 ** <li> Memory accounting is disabled using a combination of the
7186 ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
7187 ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
7188 ** <li> An alternative page cache implementation is specified using
7189 ** [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).
@@ -7190,25 +7241,15 @@
7190 ** <li> The page cache allocates from its own memory pool supplied
7191 ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
7192 ** from the heap.
7193 ** </ul>)^
7194 **
7195 ** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]),
7196 ** the soft heap limit is enforced
7197 ** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]
7198 ** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT],
7199 ** the soft heap limit is enforced on every memory allocation. Without
7200 ** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced
7201 ** when memory is allocated by the page cache. Testing suggests that because
7202 ** the page cache is the predominate memory user in SQLite, most
7203 ** applications will achieve adequate soft heap limit enforcement without
7204 ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
7205 **
7206 ** The circumstances under which SQLite will enforce the soft heap limit may
7207 ** changes in future releases of SQLite.
7208 */
7209 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
 
7210
7211 /*
7212 ** CAPI3REF: Deprecated Soft Heap Limit Interface
7213 ** DEPRECATED
7214 **
@@ -13671,94 +13712,96 @@
13671 #define TK_UNBOUNDED 90
13672 #define TK_EXCLUDE 91
13673 #define TK_GROUPS 92
13674 #define TK_OTHERS 93
13675 #define TK_TIES 94
13676 #define TK_REINDEX 95
13677 #define TK_RENAME 96
13678 #define TK_CTIME_KW 97
13679 #define TK_ANY 98
13680 #define TK_BITAND 99
13681 #define TK_BITOR 100
13682 #define TK_LSHIFT 101
13683 #define TK_RSHIFT 102
13684 #define TK_PLUS 103
13685 #define TK_MINUS 104
13686 #define TK_STAR 105
13687 #define TK_SLASH 106
13688 #define TK_REM 107
13689 #define TK_CONCAT 108
13690 #define TK_COLLATE 109
13691 #define TK_BITNOT 110
13692 #define TK_ON 111
13693 #define TK_INDEXED 112
13694 #define TK_STRING 113
13695 #define TK_JOIN_KW 114
13696 #define TK_CONSTRAINT 115
13697 #define TK_DEFAULT 116
13698 #define TK_NULL 117
13699 #define TK_PRIMARY 118
13700 #define TK_UNIQUE 119
13701 #define TK_CHECK 120
13702 #define TK_REFERENCES 121
13703 #define TK_AUTOINCR 122
13704 #define TK_INSERT 123
13705 #define TK_DELETE 124
13706 #define TK_UPDATE 125
13707 #define TK_SET 126
13708 #define TK_DEFERRABLE 127
13709 #define TK_FOREIGN 128
13710 #define TK_DROP 129
13711 #define TK_UNION 130
13712 #define TK_ALL 131
13713 #define TK_EXCEPT 132
13714 #define TK_INTERSECT 133
13715 #define TK_SELECT 134
13716 #define TK_VALUES 135
13717 #define TK_DISTINCT 136
13718 #define TK_DOT 137
13719 #define TK_FROM 138
13720 #define TK_JOIN 139
13721 #define TK_USING 140
13722 #define TK_ORDER 141
13723 #define TK_GROUP 142
13724 #define TK_HAVING 143
13725 #define TK_LIMIT 144
13726 #define TK_WHERE 145
13727 #define TK_INTO 146
13728 #define TK_NOTHING 147
13729 #define TK_FLOAT 148
13730 #define TK_BLOB 149
13731 #define TK_INTEGER 150
13732 #define TK_VARIABLE 151
13733 #define TK_CASE 152
13734 #define TK_WHEN 153
13735 #define TK_THEN 154
13736 #define TK_ELSE 155
13737 #define TK_INDEX 156
13738 #define TK_ALTER 157
13739 #define TK_ADD 158
13740 #define TK_WINDOW 159
13741 #define TK_OVER 160
13742 #define TK_FILTER 161
13743 #define TK_COLUMN 162
13744 #define TK_AGG_FUNCTION 163
13745 #define TK_AGG_COLUMN 164
13746 #define TK_TRUEFALSE 165
13747 #define TK_ISNOT 166
13748 #define TK_FUNCTION 167
13749 #define TK_UMINUS 168
13750 #define TK_UPLUS 169
13751 #define TK_TRUTH 170
13752 #define TK_REGISTER 171
13753 #define TK_VECTOR 172
13754 #define TK_SELECT_COLUMN 173
13755 #define TK_IF_NULL_ROW 174
13756 #define TK_ASTERISK 175
13757 #define TK_SPAN 176
13758 #define TK_SPACE 177
13759 #define TK_ILLEGAL 178
 
 
13760
13761 /************** End of parse.h ***********************************************/
13762 /************** Continuing where we left off in sqliteInt.h ******************/
13763 #include <stdio.h>
13764 #include <stdlib.h>
@@ -14686,11 +14729,11 @@
14686 SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
14687 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
14688 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
14689 SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*);
14690
14691 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
14692 SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
14693 SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);
14694
14695 #ifndef SQLITE_OMIT_INCRBLOB
14696 SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*);
@@ -14707,11 +14750,11 @@
14707 SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);
14708 #endif
14709 SQLITE_PRIVATE int sqlite3BtreeCursorIsValidNN(BtCursor*);
14710
14711 #ifndef SQLITE_OMIT_BTREECOUNT
14712 SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *, i64 *);
14713 #endif
14714
14715 #ifdef SQLITE_TEST
14716 SQLITE_PRIVATE int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
14717 SQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*);
@@ -15000,121 +15043,119 @@
15000 #define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
15001 #define OP_ElseNotEq 58 /* jump, same as TK_ESCAPE */
15002 #define OP_IncrVacuum 59 /* jump */
15003 #define OP_VNext 60 /* jump */
15004 #define OP_Init 61 /* jump, synopsis: Start at P2 */
15005 #define OP_PureFunc0 62
15006 #define OP_Function0 63 /* synopsis: r[P3]=func(r[P2@P5]) */
15007 #define OP_PureFunc 64
15008 #define OP_Function 65 /* synopsis: r[P3]=func(r[P2@P5]) */
15009 #define OP_Return 66
15010 #define OP_EndCoroutine 67
15011 #define OP_HaltIfNull 68 /* synopsis: if r[P3]=null halt */
15012 #define OP_Halt 69
15013 #define OP_Integer 70 /* synopsis: r[P2]=P1 */
15014 #define OP_Int64 71 /* synopsis: r[P2]=P4 */
15015 #define OP_String 72 /* synopsis: r[P2]='P4' (len=P1) */
15016 #define OP_Null 73 /* synopsis: r[P2..P3]=NULL */
15017 #define OP_SoftNull 74 /* synopsis: r[P1]=NULL */
15018 #define OP_Blob 75 /* synopsis: r[P2]=P4 (len=P1) */
15019 #define OP_Variable 76 /* synopsis: r[P2]=parameter(P1,P4) */
15020 #define OP_Move 77 /* synopsis: r[P2@P3]=r[P1@P3] */
15021 #define OP_Copy 78 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
15022 #define OP_SCopy 79 /* synopsis: r[P2]=r[P1] */
15023 #define OP_IntCopy 80 /* synopsis: r[P2]=r[P1] */
15024 #define OP_ResultRow 81 /* synopsis: output=r[P1@P2] */
15025 #define OP_CollSeq 82
15026 #define OP_AddImm 83 /* synopsis: r[P1]=r[P1]+P2 */
15027 #define OP_RealAffinity 84
15028 #define OP_Cast 85 /* synopsis: affinity(r[P1]) */
15029 #define OP_Permutation 86
15030 #define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */
15031 #define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
15032 #define OP_Offset 89 /* synopsis: r[P3] = sqlite_offset(P1) */
15033 #define OP_Column 90 /* synopsis: r[P3]=PX */
15034 #define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */
15035 #define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
15036 #define OP_Count 93 /* synopsis: r[P2]=count() */
15037 #define OP_ReadCookie 94
15038 #define OP_SetCookie 95
15039 #define OP_ReopenIdx 96 /* synopsis: root=P2 iDb=P3 */
15040 #define OP_OpenRead 97 /* synopsis: root=P2 iDb=P3 */
15041 #define OP_OpenWrite 98 /* synopsis: root=P2 iDb=P3 */
15042 #define OP_BitAnd 99 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
15043 #define OP_BitOr 100 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
15044 #define OP_ShiftLeft 101 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
15045 #define OP_ShiftRight 102 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
15046 #define OP_Add 103 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
15047 #define OP_Subtract 104 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
15048 #define OP_Multiply 105 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
15049 #define OP_Divide 106 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
15050 #define OP_Remainder 107 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
15051 #define OP_Concat 108 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
15052 #define OP_OpenDup 109
15053 #define OP_BitNot 110 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
15054 #define OP_OpenAutoindex 111 /* synopsis: nColumn=P2 */
15055 #define OP_OpenEphemeral 112 /* synopsis: nColumn=P2 */
15056 #define OP_String8 113 /* same as TK_STRING, synopsis: r[P2]='P4' */
15057 #define OP_SorterOpen 114
15058 #define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15059 #define OP_OpenPseudo 116 /* synopsis: P3 columns in r[P2] */
15060 #define OP_Close 117
15061 #define OP_ColumnsUsed 118
15062 #define OP_SeekHit 119 /* synopsis: seekHit=P2 */
15063 #define OP_Sequence 120 /* synopsis: r[P2]=cursor[P1].ctr++ */
15064 #define OP_NewRowid 121 /* synopsis: r[P2]=rowid */
15065 #define OP_Insert 122 /* synopsis: intkey=r[P3] data=r[P2] */
15066 #define OP_Delete 123
15067 #define OP_ResetCount 124
15068 #define OP_SorterCompare 125 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15069 #define OP_SorterData 126 /* synopsis: r[P2]=data */
15070 #define OP_RowData 127 /* synopsis: r[P2]=data */
15071 #define OP_Rowid 128 /* synopsis: r[P2]=rowid */
15072 #define OP_NullRow 129
15073 #define OP_SeekEnd 130
15074 #define OP_SorterInsert 131 /* synopsis: key=r[P2] */
15075 #define OP_IdxInsert 132 /* synopsis: key=r[P2] */
15076 #define OP_IdxDelete 133 /* synopsis: key=r[P2@P3] */
15077 #define OP_DeferredSeek 134 /* synopsis: Move P3 to P1.rowid if needed */
15078 #define OP_IdxRowid 135 /* synopsis: r[P2]=rowid */
15079 #define OP_Destroy 136
15080 #define OP_Clear 137
15081 #define OP_ResetSorter 138
15082 #define OP_CreateBtree 139 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15083 #define OP_SqlExec 140
15084 #define OP_ParseSchema 141
15085 #define OP_LoadAnalysis 142
15086 #define OP_DropTable 143
15087 #define OP_DropIndex 144
15088 #define OP_DropTrigger 145
15089 #define OP_IntegrityCk 146
15090 #define OP_RowSetAdd 147 /* synopsis: rowset(P1)=r[P2] */
15091 #define OP_Real 148 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15092 #define OP_Param 149
15093 #define OP_FkCounter 150 /* synopsis: fkctr[P1]+=P2 */
15094 #define OP_MemMax 151 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15095 #define OP_OffsetLimit 152 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15096 #define OP_AggInverse 153 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15097 #define OP_AggStep 154 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15098 #define OP_AggStep1 155 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15099 #define OP_AggValue 156 /* synopsis: r[P3]=value N=P2 */
15100 #define OP_AggFinal 157 /* synopsis: accum=r[P1] N=P2 */
15101 #define OP_Expire 158
15102 #define OP_TableLock 159 /* synopsis: iDb=P1 root=P2 write=P3 */
15103 #define OP_VBegin 160
15104 #define OP_VCreate 161
15105 #define OP_VDestroy 162
15106 #define OP_VOpen 163
15107 #define OP_VColumn 164 /* synopsis: r[P3]=vcolumn(P2) */
15108 #define OP_VRename 165
15109 #define OP_Pagecount 166
15110 #define OP_MaxPgcnt 167
15111 #define OP_Trace 168
15112 #define OP_CursorHint 169
15113 #define OP_Noop 170
15114 #define OP_Explain 171
15115 #define OP_Abortable 172
15116
15117 /* Properties such as "out2" or "jump" that are specified in
15118 ** comments following the "case" for each opcode in the vdbe.c
15119 ** are encoded into bitvectors as follows:
15120 */
@@ -15131,24 +15172,24 @@
15131 /* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
15132 /* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
15133 /* 40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\
15134 /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
15135 /* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\
15136 /* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
15137 /* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
15138 /* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
15139 /* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
15140 /* 96 */ 0x00, 0x00, 0x00, 0x26, 0x26, 0x26, 0x26, 0x26,\
15141 /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12, 0x00,\
15142 /* 112 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15143 /* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15144 /* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
15145 /* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15146 /* 144 */ 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x04,\
15147 /* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15148 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
15149 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,}
15150
15151 /* The sqlite3P2Values() routine is able to run faster if it knows
15152 ** the value of the largest JUMP opcode. The smaller the maximum
15153 ** JUMP opcode the better, so the mkopcodeh.tcl script that
15154 ** generated this include file strives to group all JUMP opcodes
@@ -15168,10 +15209,11 @@
15168 /*
15169 ** Prototypes for the VDBE interface. See comments on the implementation
15170 ** for a description of what each of these routines does.
15171 */
15172 SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*);
 
15173 SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int);
15174 SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int);
15175 SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int);
15176 SQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe*,int);
15177 SQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe*,int,const char*);
@@ -15178,10 +15220,11 @@
15178 SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...);
15179 SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);
15180 SQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);
15181 SQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int);
15182 SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);
 
15183 SQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe*,int);
15184 #if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
15185 SQLITE_PRIVATE void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);
15186 SQLITE_PRIVATE void sqlite3VdbeVerifyNoResultRow(Vdbe *p);
15187 #else
@@ -15267,13 +15310,12 @@
15267 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*);
15268
15269 typedef int (*RecordCompare)(int,const void*,UnpackedRecord*);
15270 SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
15271
15272 #ifndef SQLITE_OMIT_TRIGGER
15273 SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
15274 #endif
15275
15276 SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);
15277
15278 /* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on
15279 ** each VDBE opcode.
@@ -16303,14 +16345,21 @@
16303 ** with a particular database connection. Hence, schema information cannot
16304 ** be stored in lookaside because in shared cache mode the schema information
16305 ** is shared by multiple database connections. Therefore, while parsing
16306 ** schema information, the Lookaside.bEnabled flag is cleared so that
16307 ** lookaside allocations are not used to construct the schema objects.
 
 
 
 
 
 
16308 */
16309 struct Lookaside {
16310 u32 bDisable; /* Only operate the lookaside when zero */
16311 u16 sz; /* Size of each buffer in bytes */
 
16312 u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */
16313 u32 nSlot; /* Number of lookaside slots allocated */
16314 u32 anStat[3]; /* 0: hits. 1: size misses. 2: full misses */
16315 LookasideSlot *pInit; /* List of buffers not previously used */
16316 LookasideSlot *pFree; /* List of available buffers */
@@ -16318,10 +16367,14 @@
16318 void *pEnd; /* First byte past end of available space */
16319 };
16320 struct LookasideSlot {
16321 LookasideSlot *pNext; /* Next buffer in the list of free buffers */
16322 };
 
 
 
 
16323
16324 /*
16325 ** A hash table for built-in function definitions. (Application-defined
16326 ** functions use a regular table table from hash.h.)
16327 **
@@ -16839,30 +16892,49 @@
16839 void (*xDestroy)(void *); /* Module destructor function */
16840 Table *pEpoTab; /* Eponymous table for this module */
16841 };
16842
16843 /*
16844 ** information about each column of an SQL table is held in an instance
16845 ** of this structure.
 
 
 
 
 
 
 
 
 
 
 
 
 
16846 */
16847 struct Column {
16848 char *zName; /* Name of this column, \000, then the type */
16849 Expr *pDflt; /* Default value of this column */
16850 char *zColl; /* Collating sequence. If NULL, use the default */
16851 u8 notNull; /* An OE_ code for handling a NOT NULL constraint */
16852 char affinity; /* One of the SQLITE_AFF_... values */
16853 u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */
16854 u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */
16855 };
16856
16857 /* Allowed values for Column.colFlags:
16858 */
16859 #define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */
16860 #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */
16861 #define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */
16862 #define COLFLAG_UNIQUE 0x0008 /* Column def contains "UNIQUE" or "PK" */
16863 #define COLFLAG_SORTERREF 0x0010 /* Use sorter-refs with this column */
 
 
 
 
 
 
16864
16865 /*
16866 ** A "Collating Sequence" is defined by an instance of the following
16867 ** structure. Conceptually, a collating sequence consists of a name and
16868 ** a comparison routine that defines the order of that sequence.
@@ -16998,10 +17070,11 @@
16998 int tnum; /* Root BTree page for this table */
16999 u32 nTabRef; /* Number of pointers to this Table */
17000 u32 tabFlags; /* Mask of TF_* values */
17001 i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */
17002 i16 nCol; /* Number of columns in this table */
 
17003 LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
17004 LogEst szTabRow; /* Estimated size of each table row in bytes */
17005 #ifdef SQLITE_ENABLE_COSTMULT
17006 LogEst costMult; /* Cost multiplier for using this table */
17007 #endif
@@ -17024,24 +17097,32 @@
17024 **
17025 ** TF_OOOHidden applies to tables or view that have hidden columns that are
17026 ** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING
17027 ** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden,
17028 ** the TF_OOOHidden attribute would apply in this case. Such tables require
17029 ** special handling during INSERT processing.
 
 
 
 
 
17030 */
17031 #define TF_Readonly 0x0001 /* Read-only system table */
17032 #define TF_Ephemeral 0x0002 /* An ephemeral table */
17033 #define TF_HasPrimaryKey 0x0004 /* Table has a primary key */
17034 #define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */
17035 #define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */
17036 #define TF_WithoutRowid 0x0020 /* No rowid. PRIMARY KEY is the key */
17037 #define TF_NoVisibleRowid 0x0040 /* No user-visible "rowid" column */
17038 #define TF_OOOHidden 0x0080 /* Out-of-Order hidden columns */
 
17039 #define TF_StatsUsed 0x0100 /* Query planner decisions affected by
17040 ** Index.aiRowLogEst[] values */
17041 #define TF_HasNotNull 0x0200 /* Contains NOT NULL constraints */
17042 #define TF_Shadow 0x0400 /* True for a shadow table */
 
 
17043
17044 /*
17045 ** Test to see whether or not a table is a virtual table. This is
17046 ** done as a macro so that it will be optimized out when virtual
17047 ** table support is omitted from the build.
@@ -17288,10 +17369,11 @@
17288 unsigned isCovering:1; /* True if this is a covering index */
17289 unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
17290 unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
17291 unsigned bNoQuery:1; /* Do not use this index to optimize queries */
17292 unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
 
17293 #ifdef SQLITE_ENABLE_STAT4
17294 int nSample; /* Number of elements in aSample[] */
17295 int nSampleCol; /* Size of IndexSample.anEq[] and so on */
17296 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
17297 IndexSample *aSample; /* Samples of the left-most key */
@@ -17479,10 +17561,14 @@
17479 ** allocated, regardless of whether or not EP_Reduced is set.
17480 */
17481 struct Expr {
17482 u8 op; /* Operation performed by this node */
17483 char affExpr; /* affinity, or RAISE type */
 
 
 
 
17484 u32 flags; /* Various flags. EP_* See below */
17485 union {
17486 char *zToken; /* Token value. Zero terminated and dequoted */
17487 int iValue; /* Non-negative integer value if EP_IntValue */
17488 } u;
@@ -17517,13 +17603,10 @@
17517 ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
17518 ** TK_VARIABLE: variable number (always >= 1).
17519 ** TK_SELECT_COLUMN: column of the result vector */
17520 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
17521 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
17522 u8 op2; /* TK_REGISTER/TK_TRUTH: original value of Expr.op
17523 ** TK_COLUMN: the value of p5 for OP_Column
17524 ** TK_AGG_FUNCTION: nesting depth */
17525 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
17526 union {
17527 Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
17528 ** for a column of an index on an expression */
17529 Window *pWin; /* EP_WinFunc: Window/Filter defn for a function */
@@ -17548,11 +17631,11 @@
17548 #define EP_Agg 0x000010 /* Contains one or more aggregate functions */
17549 #define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
17550 #define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
17551 #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
17552 #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
17553 /* 0x000200 Available for reuse */
17554 #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
17555 #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
17556 #define EP_Skip 0x001000 /* Operator does not contribute to affinity */
17557 #define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
17558 #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
@@ -17617,13 +17700,17 @@
17617
17618 /*
17619 ** True if the expression passed as an argument was a function with
17620 ** an OVER() clause (a window function).
17621 */
17622 #define IsWindowFunc(p) ( \
 
 
 
17623 ExprHasProperty((p), EP_WinFunc) && p->y.pWin->eFrmType!=TK_FILTER \
17624 )
 
17625
17626 /*
17627 ** A list of expressions. Each expression may optionally have a
17628 ** name. An expr/name combination can be used in several ways, such
17629 ** as the list of "expr AS ID" fields following a "SELECT" or in the
@@ -17825,25 +17912,27 @@
17825 ** NC_HasAgg == SF_HasAgg == EP_Agg
17826 ** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
17827 ** NC_HasWin == EP_Win
17828 **
17829 */
17830 #define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */
17831 #define NC_PartIdx 0x0002 /* True if resolving a partial index WHERE */
17832 #define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */
17833 #define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */
17834 #define NC_HasAgg 0x0010 /* One or more aggregate functions seen */
17835 #define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */
17836 #define NC_VarSelect 0x0040 /* A correlated subquery has been seen */
17837 #define NC_UEList 0x0080 /* True if uNC.pEList is used */
17838 #define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */
17839 #define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */
17840 #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
17841 #define NC_Complex 0x2000 /* True if a function or subquery seen */
17842 #define NC_AllowWin 0x4000 /* Window functions are allowed here */
17843 #define NC_HasWin 0x8000 /* One or more window functions seen */
17844 #define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */
 
 
17845
17846 /*
17847 ** An instance of the following object describes a single ON CONFLICT
17848 ** clause in an upsert.
17849 **
@@ -17920,30 +18009,31 @@
17920 ** Value constraints (all checked via assert())
17921 ** SF_HasAgg == NC_HasAgg
17922 ** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX
17923 ** SF_FixedLimit == WHERE_USE_LIMIT
17924 */
17925 #define SF_Distinct 0x00001 /* Output should be DISTINCT */
17926 #define SF_All 0x00002 /* Includes the ALL keyword */
17927 #define SF_Resolved 0x00004 /* Identifiers have been resolved */
17928 #define SF_Aggregate 0x00008 /* Contains agg functions or a GROUP BY */
17929 #define SF_HasAgg 0x00010 /* Contains aggregate functions */
17930 #define SF_UsesEphemeral 0x00020 /* Uses the OpenEphemeral opcode */
17931 #define SF_Expanded 0x00040 /* sqlite3SelectExpand() called on this */
17932 #define SF_HasTypeInfo 0x00080 /* FROM subqueries have Table metadata */
17933 #define SF_Compound 0x00100 /* Part of a compound query */
17934 #define SF_Values 0x00200 /* Synthesized from VALUES clause */
17935 #define SF_MultiValue 0x00400 /* Single VALUES term with multiple rows */
17936 #define SF_NestedFrom 0x00800 /* Part of a parenthesized FROM clause */
17937 #define SF_MinMaxAgg 0x01000 /* Aggregate containing min() or max() */
17938 #define SF_Recursive 0x02000 /* The recursive part of a recursive CTE */
17939 #define SF_FixedLimit 0x04000 /* nSelectRow set by a constant LIMIT */
17940 #define SF_MaybeConvert 0x08000 /* Need convertCompoundSelectToSubquery() */
17941 #define SF_Converted 0x10000 /* By convertCompoundSelectToSubquery() */
17942 #define SF_IncludeHidden 0x20000 /* Include hidden columns in output */
17943 #define SF_ComplexResult 0x40000 /* Result contains subquery or function */
17944 #define SF_WhereBegin 0x80000 /* Really a WhereBegin() call. Debug Only */
 
17945
17946 /*
17947 ** The results of a SELECT can be distributed in several ways, as defined
17948 ** by one of the following macros. The "SRT" prefix means "SELECT Result
17949 ** Type".
@@ -18531,11 +18621,11 @@
18531 Parse *pParse; /* Parser context. */
18532 int (*xExprCallback)(Walker*, Expr*); /* Callback for expressions */
18533 int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */
18534 void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */
18535 int walkerDepth; /* Number of subqueries */
18536 u8 eCode; /* A small processing code */
18537 union { /* Extra data for callback */
18538 NameContext *pNC; /* Naming context */
18539 int n; /* A counter */
18540 int iCur; /* A cursor number */
18541 SrcList *pSrcList; /* FROM clause */
@@ -18547,10 +18637,11 @@
18547 ExprList *pGroupBy; /* GROUP BY clause */
18548 Select *pSelect; /* HAVING to WHERE clause ctx */
18549 struct WindowRewrite *pRewrite; /* Window rewrite context */
18550 struct WhereConst *pConst; /* WHERE clause constants */
18551 struct RenameCtx *pRename; /* RENAME COLUMN context */
 
18552 } u;
18553 };
18554
18555 /* Forward declarations */
18556 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -18954,11 +19045,18 @@
18954 SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
18955 SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char);
18956 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char);
18957 SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
18958 SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
18959 SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);
 
 
 
 
 
 
 
18960 SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
18961 #if SQLITE_ENABLE_HIDDEN_COLUMNS
18962 SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*);
18963 #else
18964 # define sqlite3ColumnPropertiesFromName(T,C) /* no-op */
@@ -18967,11 +19065,15 @@
18967 SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);
18968 SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
18969 SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*);
18970 SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);
18971 SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*);
 
18972 SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
 
 
 
18973 SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*,
18974 sqlite3_vfs**,char**,char **);
18975 #ifdef SQLITE_HAS_CODEC
18976 SQLITE_PRIVATE int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*);
18977 #else
@@ -19024,10 +19126,13 @@
19024 #else
19025 # define sqlite3AutoincrementBegin(X)
19026 # define sqlite3AutoincrementEnd(X)
19027 #endif
19028 SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);
 
 
 
19029 SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
19030 SQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse*, IdList*, Token*);
19031 SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);
19032 SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(Parse*, SrcList*, int, int);
19033 SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(Parse*, SrcList*, Token*, Token*);
@@ -19073,16 +19178,18 @@
19073 SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);
19074 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
19075 SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
19076 SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
19077 SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
 
 
 
19078 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
19079 SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
19080 SQLITE_PRIVATE int sqlite3ExprCodeAtInit(Parse*, Expr*, int);
19081 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
19082 SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
19083 SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);
19084 SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);
19085 #define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */
19086 #define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */
19087 #define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */
19088 #define SQLITE_ECEL_OMITREF 0x08 /* Omit if ExprList.u.x.iOrderByCol */
@@ -19215,10 +19322,11 @@
19215 # define sqlite3IsToplevel(p) 1
19216 # define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0
19217 #endif
19218
19219 SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);
 
19220 SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
19221 SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);
19222 #ifndef SQLITE_OMIT_AUTHORIZATION
19223 SQLITE_PRIVATE void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);
19224 SQLITE_PRIVATE int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);
@@ -19512,10 +19620,16 @@
19512 const sqlite3_module*,
19513 void*,
19514 void(*)(void*)
19515 );
19516 # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
 
 
 
 
 
 
19517 #endif
19518 SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*);
19519 SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
19520 SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);
19521 SQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);
@@ -19534,10 +19648,11 @@
19534 #ifdef SQLITE_ENABLE_NORMALIZE
19535 SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*);
19536 #endif
19537 SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
19538 SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
 
19539 SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
19540 SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
19541 SQLITE_PRIVATE const char *sqlite3JournalModename(int);
19542 #ifndef SQLITE_OMIT_WAL
19543 SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);
@@ -20376,11 +20491,12 @@
20376
20377 /*
20378 ** True if Mem X is a NULL-nochng type.
20379 */
20380 #define MemNullNochng(X) \
20381 ((X)->flags==(MEM_Null|MEM_Zero) && (X)->n==0 && (X)->u.nZero==0)
 
20382
20383 /*
20384 ** Return true if a memory cell is not marked as invalid. This macro
20385 ** is for use inside assert() statements only.
20386 */
@@ -26056,11 +26172,11 @@
26056 ** May you share freely, never taking more than you give.
26057 **
26058 ******************************************************************************
26059 **
26060 ** This file contains inline asm code for retrieving "high-performance"
26061 ** counters for x86 class CPUs.
26062 */
26063 #ifndef SQLITE_HWTIME_H
26064 #define SQLITE_HWTIME_H
26065
26066 /*
@@ -26067,12 +26183,13 @@
26067 ** The following routine only works on pentium-class (or newer) processors.
26068 ** It uses the RDTSC opcode to read the cycle count value out of the
26069 ** processor and returns that value. This can be used for high-res
26070 ** profiling.
26071 */
26072 #if (defined(__GNUC__) || defined(_MSC_VER)) && \
26073 (defined(i386) || defined(__i386__) || defined(_M_IX86))
 
26074
26075 #if defined(__GNUC__)
26076
26077 __inline__ sqlite_uint64 sqlite3Hwtime(void){
26078 unsigned int lo, hi;
@@ -26089,19 +26206,19 @@
26089 }
26090 }
26091
26092 #endif
26093
26094 #elif (defined(__GNUC__) && defined(__x86_64__))
26095
26096 __inline__ sqlite_uint64 sqlite3Hwtime(void){
26097 unsigned long val;
26098 __asm__ __volatile__ ("rdtsc" : "=A" (val));
26099 return val;
26100 }
26101
26102 #elif (defined(__GNUC__) && defined(__ppc__))
26103
26104 __inline__ sqlite_uint64 sqlite3Hwtime(void){
26105 unsigned long long retval;
26106 unsigned long junk;
26107 __asm__ __volatile__ ("\n\
@@ -26114,18 +26231,17 @@
26114 return retval;
26115 }
26116
26117 #else
26118
26119 #error Need implementation of sqlite3Hwtime() for your platform.
26120
26121 /*
26122 ** To compile without implementing sqlite3Hwtime() for your platform,
26123 ** you can remove the above #error and use the following
26124 ** stub function. You will lose timing support for many
26125 ** of the debugging and testing utilities, but it should at
26126 ** least compile and run.
 
26127 */
26128 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
26129
26130 #endif
26131
@@ -26705,23 +26821,31 @@
26705 UNUSED_PARAMETER(n);
26706 return 0;
26707 #endif
26708 }
26709
 
 
 
 
 
 
 
26710 /*
26711 ** State information local to the memory allocation subsystem.
26712 */
26713 static SQLITE_WSD struct Mem0Global {
26714 sqlite3_mutex *mutex; /* Mutex to serialize access */
26715 sqlite3_int64 alarmThreshold; /* The soft heap limit */
 
26716
26717 /*
26718 ** True if heap is nearly "full" where "full" is defined by the
26719 ** sqlite3_soft_heap_limit() setting.
26720 */
26721 int nearlyFull;
26722 } mem0 = { 0, 0, 0 };
26723
26724 #define mem0 GLOBAL(struct Mem0Global, mem0)
26725
26726 /*
26727 ** Return the memory allocator mutex. sqlite3_status() needs it.
@@ -26747,12 +26871,19 @@
26747 return SQLITE_OK;
26748 }
26749 #endif
26750
26751 /*
26752 ** Set the soft heap-size limit for the library. Passing a zero or
26753 ** negative value indicates no limit.
 
 
 
 
 
 
 
26754 */
26755 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){
26756 sqlite3_int64 priorLimit;
26757 sqlite3_int64 excess;
26758 sqlite3_int64 nUsed;
@@ -26763,10 +26894,13 @@
26763 sqlite3_mutex_enter(mem0.mutex);
26764 priorLimit = mem0.alarmThreshold;
26765 if( n<0 ){
26766 sqlite3_mutex_leave(mem0.mutex);
26767 return priorLimit;
 
 
 
26768 }
26769 mem0.alarmThreshold = n;
26770 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
26771 mem0.nearlyFull = (n>0 && n<=nUsed);
26772 sqlite3_mutex_leave(mem0.mutex);
@@ -26776,10 +26910,41 @@
26776 }
26777 SQLITE_API void sqlite3_soft_heap_limit(int n){
26778 if( n<0 ) n = 0;
26779 sqlite3_soft_heap_limit64(n);
26780 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26781
26782 /*
26783 ** Initialize the memory allocation subsystem.
26784 */
26785 SQLITE_PRIVATE int sqlite3MallocInit(void){
@@ -26863,23 +27028,23 @@
26863 ** mode and specifically when the DMD "Dark Matter Detector" is enabled
26864 ** or else a crash results. Hence, do not attempt to optimize out the
26865 ** following xRoundup() call. */
26866 nFull = sqlite3GlobalConfig.m.xRoundup(n);
26867
26868 #ifdef SQLITE_MAX_MEMORY
26869 if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nFull>SQLITE_MAX_MEMORY ){
26870 *pp = 0;
26871 return;
26872 }
26873 #endif
26874
26875 sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);
26876 if( mem0.alarmThreshold>0 ){
26877 sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
26878 if( nUsed >= mem0.alarmThreshold - nFull ){
26879 mem0.nearlyFull = 1;
26880 sqlite3MallocAlarm(nFull);
 
 
 
 
 
 
 
26881 }else{
26882 mem0.nearlyFull = 0;
26883 }
26884 }
26885 p = sqlite3GlobalConfig.m.xMalloc(nFull);
@@ -26971,11 +27136,11 @@
26971 }
26972 #endif
26973 return sqlite3GlobalConfig.m.xSize(p);
26974 }else{
26975 assert( sqlite3_mutex_held(db->mutex) );
26976 return db->lookaside.sz;
26977 }
26978 }
26979 SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){
26980 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
26981 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
@@ -27023,11 +27188,11 @@
27023 }
27024 if( isLookaside(db, p) ){
27025 LookasideSlot *pBuf = (LookasideSlot*)p;
27026 #ifdef SQLITE_DEBUG
27027 /* Trash all content in the buffer being freed */
27028 memset(p, 0xaa, db->lookaside.sz);
27029 #endif
27030 pBuf->pNext = db->lookaside.pFree;
27031 db->lookaside.pFree = pBuf;
27032 return;
27033 }
@@ -27183,27 +27348,25 @@
27183 #ifndef SQLITE_OMIT_LOOKASIDE
27184 LookasideSlot *pBuf;
27185 assert( db!=0 );
27186 assert( sqlite3_mutex_held(db->mutex) );
27187 assert( db->pnBytesFreed==0 );
27188 if( db->lookaside.bDisable==0 ){
27189 assert( db->mallocFailed==0 );
27190 if( n>db->lookaside.sz ){
27191 db->lookaside.anStat[1]++;
27192 }else if( (pBuf = db->lookaside.pFree)!=0 ){
27193 db->lookaside.pFree = pBuf->pNext;
27194 db->lookaside.anStat[0]++;
27195 return (void*)pBuf;
27196 }else if( (pBuf = db->lookaside.pInit)!=0 ){
27197 db->lookaside.pInit = pBuf->pNext;
27198 db->lookaside.anStat[0]++;
27199 return (void*)pBuf;
27200 }else{
27201 db->lookaside.anStat[2]++;
27202 }
27203 }else if( db->mallocFailed ){
27204 return 0;
27205 }
27206 #else
27207 assert( db!=0 );
27208 assert( sqlite3_mutex_held(db->mutex) );
27209 assert( db->pnBytesFreed==0 );
@@ -27223,11 +27386,11 @@
27223 */
27224 SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){
27225 assert( db!=0 );
27226 if( p==0 ) return sqlite3DbMallocRawNN(db, n);
27227 assert( sqlite3_mutex_held(db->mutex) );
27228 if( isLookaside(db,p) && n<=db->lookaside.sz ) return p;
27229 return dbReallocFinish(db, p, n);
27230 }
27231 static SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n){
27232 void *pNew = 0;
27233 assert( db!=0 );
@@ -27234,11 +27397,11 @@
27234 assert( p!=0 );
27235 if( db->mallocFailed==0 ){
27236 if( isLookaside(db, p) ){
27237 pNew = sqlite3DbMallocRawNN(db, n);
27238 if( pNew ){
27239 memcpy(pNew, p, db->lookaside.sz);
27240 sqlite3DbFree(db, p);
27241 }
27242 }else{
27243 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
27244 assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
@@ -27333,11 +27496,11 @@
27333 if( db->mallocFailed==0 && db->bBenignMalloc==0 ){
27334 db->mallocFailed = 1;
27335 if( db->nVdbeExec>0 ){
27336 db->u1.isInterrupted = 1;
27337 }
27338 db->lookaside.bDisable++;
27339 if( db->pParse ){
27340 db->pParse->rc = SQLITE_NOMEM_BKPT;
27341 }
27342 }
27343 }
@@ -27352,11 +27515,11 @@
27352 SQLITE_PRIVATE void sqlite3OomClear(sqlite3 *db){
27353 if( db->mallocFailed && db->nVdbeExec==0 ){
27354 db->mallocFailed = 0;
27355 db->u1.isInterrupted = 0;
27356 assert( db->lookaside.bDisable>0 );
27357 db->lookaside.bDisable--;
27358 }
27359 }
27360
27361 /*
27362 ** Take actions at the end of an API call to indicate an OOM error
@@ -28760,11 +28923,11 @@
28760 }
28761 if( zFormat!=0 ){
28762 va_start(ap, zFormat);
28763 sqlite3_str_vappendf(&acc, zFormat, ap);
28764 va_end(ap);
28765 assert( acc.nChar>0 );
28766 sqlite3_str_append(&acc, "\n", 1);
28767 }
28768 sqlite3StrAccumFinish(&acc);
28769 fprintf(stdout,"%s", zBuf);
28770 fflush(stdout);
@@ -28825,11 +28988,11 @@
28825 for(i=0; i<pSrc->nSrc; i++){
28826 const struct SrcList_item *pItem = &pSrc->a[i];
28827 StrAccum x;
28828 char zLine[100];
28829 sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
28830 sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor);
28831 if( pItem->zDatabase ){
28832 sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
28833 }else if( pItem->zName ){
28834 sqlite3_str_appendf(&x, " %s", pItem->zName);
28835 }
@@ -29117,11 +29280,18 @@
29117 break;
29118 }
29119 case TK_COLUMN: {
29120 if( pExpr->iTable<0 ){
29121 /* This only happens when coding check constraints */
29122 sqlite3TreeViewLine(pView, "COLUMN(%d)%s", pExpr->iColumn, zFlgs);
 
 
 
 
 
 
 
29123 }else{
29124 sqlite3TreeViewLine(pView, "{%d:%d}%s",
29125 pExpr->iTable, pExpr->iColumn, zFlgs);
29126 }
29127 if( ExprHasProperty(pExpr, EP_FixedCol) ){
@@ -29260,10 +29430,21 @@
29260 #endif
29261 }
29262 if( pExpr->op==TK_AGG_FUNCTION ){
29263 sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s",
29264 pExpr->op2, pExpr->u.zToken, zFlgs);
 
 
 
 
 
 
 
 
 
 
 
29265 }else{
29266 sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs);
29267 }
29268 if( pFarg ){
29269 sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);
@@ -29355,11 +29536,13 @@
29355 pExpr->iTable, pExpr->iColumn, zFlgs);
29356 sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
29357 break;
29358 }
29359 case TK_VECTOR: {
29360 sqlite3TreeViewBareExprList(pView, pExpr->x.pList, "VECTOR");
 
 
29361 break;
29362 }
29363 case TK_SELECT_COLUMN: {
29364 sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn);
29365 sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);
@@ -30581,10 +30764,11 @@
30581 }else{
30582 pParse->nErr++;
30583 sqlite3DbFree(db, pParse->zErrMsg);
30584 pParse->zErrMsg = zMsg;
30585 pParse->rc = SQLITE_ERROR;
 
30586 }
30587 }
30588
30589 /*
30590 ** If database connection db is currently parsing SQL, then transfer
@@ -30771,10 +30955,13 @@
30771 **
30772 ** If some prefix of the input string is a valid number, this routine
30773 ** returns FALSE but it still converts the prefix and writes the result
30774 ** into *pResult.
30775 */
 
 
 
30776 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
30777 #ifndef SQLITE_OMIT_FLOATING_POINT
30778 int incr;
30779 const char *zEnd = z + length;
30780 /* sign * significand * (10 ^ (esign * exponent)) */
@@ -30958,10 +31145,13 @@
30958 }
30959 #else
30960 return !sqlite3Atoi64(z, pResult, length, enc);
30961 #endif /* SQLITE_OMIT_FLOATING_POINT */
30962 }
 
 
 
30963
30964 /*
30965 ** Compare the 19-character string zNum against the text representation
30966 ** value 2^63: 9223372036854775808. Return negative, zero, or positive
30967 ** if zNum is less than, equal to, or greater than the string.
@@ -32364,121 +32554,119 @@
32364 /* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
32365 /* 58 */ "ElseNotEq" OpHelp(""),
32366 /* 59 */ "IncrVacuum" OpHelp(""),
32367 /* 60 */ "VNext" OpHelp(""),
32368 /* 61 */ "Init" OpHelp("Start at P2"),
32369 /* 62 */ "PureFunc0" OpHelp(""),
32370 /* 63 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
32371 /* 64 */ "PureFunc" OpHelp(""),
32372 /* 65 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
32373 /* 66 */ "Return" OpHelp(""),
32374 /* 67 */ "EndCoroutine" OpHelp(""),
32375 /* 68 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
32376 /* 69 */ "Halt" OpHelp(""),
32377 /* 70 */ "Integer" OpHelp("r[P2]=P1"),
32378 /* 71 */ "Int64" OpHelp("r[P2]=P4"),
32379 /* 72 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
32380 /* 73 */ "Null" OpHelp("r[P2..P3]=NULL"),
32381 /* 74 */ "SoftNull" OpHelp("r[P1]=NULL"),
32382 /* 75 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
32383 /* 76 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
32384 /* 77 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
32385 /* 78 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
32386 /* 79 */ "SCopy" OpHelp("r[P2]=r[P1]"),
32387 /* 80 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
32388 /* 81 */ "ResultRow" OpHelp("output=r[P1@P2]"),
32389 /* 82 */ "CollSeq" OpHelp(""),
32390 /* 83 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
32391 /* 84 */ "RealAffinity" OpHelp(""),
32392 /* 85 */ "Cast" OpHelp("affinity(r[P1])"),
32393 /* 86 */ "Permutation" OpHelp(""),
32394 /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
32395 /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
32396 /* 89 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
32397 /* 90 */ "Column" OpHelp("r[P3]=PX"),
32398 /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
32399 /* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
32400 /* 93 */ "Count" OpHelp("r[P2]=count()"),
32401 /* 94 */ "ReadCookie" OpHelp(""),
32402 /* 95 */ "SetCookie" OpHelp(""),
32403 /* 96 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32404 /* 97 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32405 /* 98 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32406 /* 99 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32407 /* 100 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32408 /* 101 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32409 /* 102 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32410 /* 103 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32411 /* 104 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32412 /* 105 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32413 /* 106 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32414 /* 107 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32415 /* 108 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32416 /* 109 */ "OpenDup" OpHelp(""),
32417 /* 110 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32418 /* 111 */ "OpenAutoindex" OpHelp("nColumn=P2"),
32419 /* 112 */ "OpenEphemeral" OpHelp("nColumn=P2"),
32420 /* 113 */ "String8" OpHelp("r[P2]='P4'"),
32421 /* 114 */ "SorterOpen" OpHelp(""),
32422 /* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
32423 /* 116 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
32424 /* 117 */ "Close" OpHelp(""),
32425 /* 118 */ "ColumnsUsed" OpHelp(""),
32426 /* 119 */ "SeekHit" OpHelp("seekHit=P2"),
32427 /* 120 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
32428 /* 121 */ "NewRowid" OpHelp("r[P2]=rowid"),
32429 /* 122 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
32430 /* 123 */ "Delete" OpHelp(""),
32431 /* 124 */ "ResetCount" OpHelp(""),
32432 /* 125 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
32433 /* 126 */ "SorterData" OpHelp("r[P2]=data"),
32434 /* 127 */ "RowData" OpHelp("r[P2]=data"),
32435 /* 128 */ "Rowid" OpHelp("r[P2]=rowid"),
32436 /* 129 */ "NullRow" OpHelp(""),
32437 /* 130 */ "SeekEnd" OpHelp(""),
32438 /* 131 */ "SorterInsert" OpHelp("key=r[P2]"),
32439 /* 132 */ "IdxInsert" OpHelp("key=r[P2]"),
32440 /* 133 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
32441 /* 134 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
32442 /* 135 */ "IdxRowid" OpHelp("r[P2]=rowid"),
32443 /* 136 */ "Destroy" OpHelp(""),
32444 /* 137 */ "Clear" OpHelp(""),
32445 /* 138 */ "ResetSorter" OpHelp(""),
32446 /* 139 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
32447 /* 140 */ "SqlExec" OpHelp(""),
32448 /* 141 */ "ParseSchema" OpHelp(""),
32449 /* 142 */ "LoadAnalysis" OpHelp(""),
32450 /* 143 */ "DropTable" OpHelp(""),
32451 /* 144 */ "DropIndex" OpHelp(""),
32452 /* 145 */ "DropTrigger" OpHelp(""),
32453 /* 146 */ "IntegrityCk" OpHelp(""),
32454 /* 147 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
32455 /* 148 */ "Real" OpHelp("r[P2]=P4"),
32456 /* 149 */ "Param" OpHelp(""),
32457 /* 150 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
32458 /* 151 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
32459 /* 152 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
32460 /* 153 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
32461 /* 154 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
32462 /* 155 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
32463 /* 156 */ "AggValue" OpHelp("r[P3]=value N=P2"),
32464 /* 157 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
32465 /* 158 */ "Expire" OpHelp(""),
32466 /* 159 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
32467 /* 160 */ "VBegin" OpHelp(""),
32468 /* 161 */ "VCreate" OpHelp(""),
32469 /* 162 */ "VDestroy" OpHelp(""),
32470 /* 163 */ "VOpen" OpHelp(""),
32471 /* 164 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
32472 /* 165 */ "VRename" OpHelp(""),
32473 /* 166 */ "Pagecount" OpHelp(""),
32474 /* 167 */ "MaxPgcnt" OpHelp(""),
32475 /* 168 */ "Trace" OpHelp(""),
32476 /* 169 */ "CursorHint" OpHelp(""),
32477 /* 170 */ "Noop" OpHelp(""),
32478 /* 171 */ "Explain" OpHelp(""),
32479 /* 172 */ "Abortable" OpHelp(""),
32480 };
32481 return azName[i];
32482 }
32483 #endif
32484
@@ -32838,11 +33026,11 @@
32838 ** May you share freely, never taking more than you give.
32839 **
32840 ******************************************************************************
32841 **
32842 ** This file contains inline asm code for retrieving "high-performance"
32843 ** counters for x86 class CPUs.
32844 */
32845 #ifndef SQLITE_HWTIME_H
32846 #define SQLITE_HWTIME_H
32847
32848 /*
@@ -32849,12 +33037,13 @@
32849 ** The following routine only works on pentium-class (or newer) processors.
32850 ** It uses the RDTSC opcode to read the cycle count value out of the
32851 ** processor and returns that value. This can be used for high-res
32852 ** profiling.
32853 */
32854 #if (defined(__GNUC__) || defined(_MSC_VER)) && \
32855 (defined(i386) || defined(__i386__) || defined(_M_IX86))
 
32856
32857 #if defined(__GNUC__)
32858
32859 __inline__ sqlite_uint64 sqlite3Hwtime(void){
32860 unsigned int lo, hi;
@@ -32871,19 +33060,19 @@
32871 }
32872 }
32873
32874 #endif
32875
32876 #elif (defined(__GNUC__) && defined(__x86_64__))
32877
32878 __inline__ sqlite_uint64 sqlite3Hwtime(void){
32879 unsigned long val;
32880 __asm__ __volatile__ ("rdtsc" : "=A" (val));
32881 return val;
32882 }
32883
32884 #elif (defined(__GNUC__) && defined(__ppc__))
32885
32886 __inline__ sqlite_uint64 sqlite3Hwtime(void){
32887 unsigned long long retval;
32888 unsigned long junk;
32889 __asm__ __volatile__ ("\n\
@@ -32896,18 +33085,17 @@
32896 return retval;
32897 }
32898
32899 #else
32900
32901 #error Need implementation of sqlite3Hwtime() for your platform.
32902
32903 /*
32904 ** To compile without implementing sqlite3Hwtime() for your platform,
32905 ** you can remove the above #error and use the following
32906 ** stub function. You will lose timing support for many
32907 ** of the debugging and testing utilities, but it should at
32908 ** least compile and run.
 
32909 */
32910 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
32911
32912 #endif
32913
@@ -38933,19 +39121,29 @@
38933 ){
38934 UNUSED_PARAMETER(NotUsed);
38935 SimulateIOError( return SQLITE_IOERR_ACCESS; );
38936 assert( pResOut!=0 );
38937
38938 /* The spec says there are three possible values for flags. But only
38939 ** two of them are actually used */
38940 assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE );
 
 
38941
38942 if( flags==SQLITE_ACCESS_EXISTS ){
38943 struct stat buf;
38944 *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0);
38945 }else{
38946 *pResOut = osAccess(zPath, W_OK|R_OK)==0;
 
 
 
 
 
 
 
 
38947 }
38948 return SQLITE_OK;
38949 }
38950
38951 /*
@@ -40660,11 +40858,11 @@
40660 ** May you share freely, never taking more than you give.
40661 **
40662 ******************************************************************************
40663 **
40664 ** This file contains inline asm code for retrieving "high-performance"
40665 ** counters for x86 class CPUs.
40666 */
40667 #ifndef SQLITE_HWTIME_H
40668 #define SQLITE_HWTIME_H
40669
40670 /*
@@ -40671,12 +40869,13 @@
40671 ** The following routine only works on pentium-class (or newer) processors.
40672 ** It uses the RDTSC opcode to read the cycle count value out of the
40673 ** processor and returns that value. This can be used for high-res
40674 ** profiling.
40675 */
40676 #if (defined(__GNUC__) || defined(_MSC_VER)) && \
40677 (defined(i386) || defined(__i386__) || defined(_M_IX86))
 
40678
40679 #if defined(__GNUC__)
40680
40681 __inline__ sqlite_uint64 sqlite3Hwtime(void){
40682 unsigned int lo, hi;
@@ -40693,19 +40892,19 @@
40693 }
40694 }
40695
40696 #endif
40697
40698 #elif (defined(__GNUC__) && defined(__x86_64__))
40699
40700 __inline__ sqlite_uint64 sqlite3Hwtime(void){
40701 unsigned long val;
40702 __asm__ __volatile__ ("rdtsc" : "=A" (val));
40703 return val;
40704 }
40705
40706 #elif (defined(__GNUC__) && defined(__ppc__))
40707
40708 __inline__ sqlite_uint64 sqlite3Hwtime(void){
40709 unsigned long long retval;
40710 unsigned long junk;
40711 __asm__ __volatile__ ("\n\
@@ -40718,18 +40917,17 @@
40718 return retval;
40719 }
40720
40721 #else
40722
40723 #error Need implementation of sqlite3Hwtime() for your platform.
40724
40725 /*
40726 ** To compile without implementing sqlite3Hwtime() for your platform,
40727 ** you can remove the above #error and use the following
40728 ** stub function. You will lose timing support for many
40729 ** of the debugging and testing utilities, but it should at
40730 ** least compile and run.
 
40731 */
40732 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
40733
40734 #endif
40735
@@ -40862,10 +41060,18 @@
40862
40863 #ifndef NTDDI_WINTHRESHOLD
40864 # define NTDDI_WINTHRESHOLD 0x06040000
40865 #endif
40866
 
 
 
 
 
 
 
 
40867 /*
40868 ** Check to see if the GetVersionEx[AW] functions are deprecated on the
40869 ** target system. GetVersionEx was first deprecated in Win8.1.
40870 */
40871 #ifndef SQLITE_WIN32_GETVERSIONEX
@@ -46254,10 +46460,14 @@
46254 break;
46255 case SQLITE_ACCESS_READWRITE:
46256 rc = attr!=INVALID_FILE_ATTRIBUTES &&
46257 (attr & FILE_ATTRIBUTE_READONLY)==0;
46258 break;
 
 
 
 
46259 default:
46260 assert(!"Invalid flags argument");
46261 }
46262 *pResOut = rc;
46263 OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
@@ -52141,10 +52351,11 @@
52141 ** master-journal filename.
52142 */
52143 len = 0;
52144 }
52145 zMaster[len] = '\0';
 
52146
52147 return SQLITE_OK;
52148 }
52149
52150 /*
@@ -53377,19 +53588,20 @@
53377 ** journal files extracted from regular rollback-journals.
53378 */
53379 rc = sqlite3OsFileSize(pMaster, &nMasterJournal);
53380 if( rc!=SQLITE_OK ) goto delmaster_out;
53381 nMasterPtr = pVfs->mxPathname+1;
53382 zMasterJournal = sqlite3Malloc(nMasterJournal + nMasterPtr + 1);
53383 if( !zMasterJournal ){
53384 rc = SQLITE_NOMEM_BKPT;
53385 goto delmaster_out;
53386 }
53387 zMasterPtr = &zMasterJournal[nMasterJournal+1];
53388 rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0);
53389 if( rc!=SQLITE_OK ) goto delmaster_out;
53390 zMasterJournal[nMasterJournal] = 0;
 
53391
53392 zJournal = zMasterJournal;
53393 while( (zJournal-zMasterJournal)<nMasterJournal ){
53394 int exists;
53395 rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);
@@ -55542,11 +55754,12 @@
55542 int nPathname = 0; /* Number of bytes in zPathname */
55543 int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */
55544 int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */
55545 u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */
55546 const char *zUri = 0; /* URI args to copy */
55547 int nUri = 0; /* Number of bytes of URI args at *zUri */
 
55548
55549 /* Figure out how much space is required for each journal file-handle
55550 ** (there are two of them, the main journal and the sub-journal). */
55551 journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
55552
@@ -55569,10 +55782,16 @@
55569 ** to by zPathname, length nPathname. Or, if this is a temporary file,
55570 ** leave both nPathname and zPathname set to 0.
55571 */
55572 if( zFilename && zFilename[0] ){
55573 const char *z;
 
 
 
 
 
 
55574 nPathname = pVfs->mxPathname+1;
55575 zPathname = sqlite3DbMallocRaw(0, nPathname*2);
55576 if( zPathname==0 ){
55577 return SQLITE_NOMEM_BKPT;
55578 }
@@ -55579,15 +55798,16 @@
55579 zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */
55580 rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
55581 nPathname = sqlite3Strlen30(zPathname);
55582 z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
55583 while( *z ){
55584 z += sqlite3Strlen30(z)+1;
55585 z += sqlite3Strlen30(z)+1;
 
55586 }
55587 nUri = (int)(&z[1] - zUri);
55588 assert( nUri>=0 );
55589 if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
55590 /* This branch is taken when the journal path required by
55591 ** the database being opened will be more than pVfs->mxPathname
55592 ** bytes in length. This means the database cannot be opened,
55593 ** as it will not be possible to open the journal file or even
@@ -55616,11 +55836,11 @@
55616 pPtr = (u8 *)sqlite3MallocZero(
55617 ROUND8(sizeof(*pPager)) + /* Pager structure */
55618 ROUND8(pcacheSize) + /* PCache object */
55619 ROUND8(pVfs->szOsFile) + /* The main db file */
55620 journalFileSize * 2 + /* The two journal files */
55621 nPathname + 1 + nUri + /* zFilename */
55622 nPathname + 8 + 2 /* zJournal */
55623 #ifndef SQLITE_OMIT_WAL
55624 + nPathname + 4 + 2 /* zWal */
55625 #endif
55626 );
@@ -55638,22 +55858,25 @@
55638 assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) );
55639
55640 /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */
55641 if( zPathname ){
55642 assert( nPathname>0 );
55643 pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri);
55644 memcpy(pPager->zFilename, zPathname, nPathname);
55645 if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUri);
 
55646 memcpy(pPager->zJournal, zPathname, nPathname);
55647 memcpy(&pPager->zJournal[nPathname], "-journal\000", 8+2);
55648 sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal);
55649 #ifndef SQLITE_OMIT_WAL
55650 pPager->zWal = &pPager->zJournal[nPathname+8+1];
55651 memcpy(pPager->zWal, zPathname, nPathname);
55652 memcpy(&pPager->zWal[nPathname], "-wal\000", 4+1);
55653 sqlite3FileSuffix3(pPager->zFilename, pPager->zWal);
 
55654 #endif
 
 
55655 sqlite3DbFree(0, zPathname);
55656 }
55657 pPager->pVfs = pVfs;
55658 pPager->vfsFlags = vfsFlags;
55659
@@ -63072,10 +63295,11 @@
63072 int mallocFailed; /* A memory allocation error has occurred */
63073 const char *zPfx; /* Error message prefix */
63074 int v1, v2; /* Values for up to two %d fields in zPfx */
63075 StrAccum errMsg; /* Accumulate the error message text here */
63076 u32 *heap; /* Min-heap used for analyzing cell coverage */
 
63077 };
63078
63079 /*
63080 ** Routines to read or write a two- and four-byte big-endian integer values.
63081 */
@@ -67759,12 +67983,13 @@
67759 );
67760
67761 /* The following assert statements verify that if this is a sharable
67762 ** b-tree database, the connection is holding the required table locks,
67763 ** and that no other connection has any open cursor that conflicts with
67764 ** this lock. */
67765 assert( hasSharedCacheTableLock(p, iTable, pKeyInfo!=0, (wrFlag?2:1)) );
 
67766 assert( wrFlag==0 || !hasReadConflicts(p, iTable) );
67767
67768 /* Assert that the caller has opened the required transaction. */
67769 assert( p->inTrans>TRANS_NONE );
67770 assert( wrFlag==0 || p->inTrans==TRANS_WRITE );
@@ -67773,13 +67998,17 @@
67773
67774 if( wrFlag ){
67775 allocateTempSpace(pBt);
67776 if( pBt->pTmpSpace==0 ) return SQLITE_NOMEM_BKPT;
67777 }
67778 if( iTable==1 && btreePagecount(pBt)==0 ){
67779 assert( wrFlag==0 );
67780 iTable = 0;
 
 
 
 
67781 }
67782
67783 /* Now that no other errors can occur, finish filling in the BtCursor
67784 ** variables and link the cursor into the BtShared list. */
67785 pCur->pgnoRoot = (Pgno)iTable;
@@ -67799,27 +68028,36 @@
67799 }
67800 pCur->pNext = pBt->pCursor;
67801 pBt->pCursor = pCur;
67802 pCur->eState = CURSOR_INVALID;
67803 return SQLITE_OK;
 
 
 
 
 
 
 
 
 
 
 
 
 
67804 }
67805 SQLITE_PRIVATE int sqlite3BtreeCursor(
67806 Btree *p, /* The btree */
67807 int iTable, /* Root page of table to open */
67808 int wrFlag, /* 1 to write. 0 read-only */
67809 struct KeyInfo *pKeyInfo, /* First arg to xCompare() */
67810 BtCursor *pCur /* Write new cursor here */
67811 ){
67812 int rc;
67813 if( iTable<1 ){
67814 rc = SQLITE_CORRUPT_BKPT;
67815 }else{
67816 sqlite3BtreeEnter(p);
67817 rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
67818 sqlite3BtreeLeave(p);
67819 }
67820 return rc;
67821 }
67822
67823 /*
67824 ** Return the size of a BtCursor object in bytes.
67825 **
@@ -72853,11 +73091,11 @@
72853 **
72854 ** SQLITE_OK is returned if the operation is successfully executed.
72855 ** Otherwise, if an error is encountered (i.e. an IO error or database
72856 ** corruption) an SQLite error code is returned.
72857 */
72858 SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *pCur, i64 *pnEntry){
72859 i64 nEntry = 0; /* Value to return in *pnEntry */
72860 int rc; /* Return code */
72861
72862 rc = moveToRoot(pCur);
72863 if( rc==SQLITE_EMPTY ){
@@ -72866,11 +73104,11 @@
72866 }
72867
72868 /* Unless an error occurs, the following loop runs one iteration for each
72869 ** page in the B-Tree structure (not including overflow pages).
72870 */
72871 while( rc==SQLITE_OK ){
72872 int iIdx; /* Index of child node in parent */
72873 MemPage *pPage; /* Current page of the b-tree */
72874
72875 /* If this is a leaf page or the tree is not an int-key tree, then
72876 ** this page contains countable entries. Increment the entry counter
@@ -72992,10 +73230,11 @@
72992 }
72993 if( getPageReferenced(pCheck, iPage) ){
72994 checkAppendMsg(pCheck, "2nd reference to page %d", iPage);
72995 return 1;
72996 }
 
72997 setPageReferenced(pCheck, iPage);
72998 return 0;
72999 }
73000
73001 #ifndef SQLITE_OMIT_AUTOVACUUM
@@ -73435,10 +73674,11 @@
73435 ** allocation errors, an error message held in memory obtained from
73436 ** malloc is returned if *pnErr is non-zero. If *pnErr==0 then NULL is
73437 ** returned. If a memory allocation error occurs, NULL is returned.
73438 */
73439 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(
 
73440 Btree *p, /* The btree to be checked */
73441 int *aRoot, /* An array of root pages numbers for individual trees */
73442 int nRoot, /* Number of entries in aRoot[] */
73443 int mxErr, /* Stop reporting errors after this many */
73444 int *pnErr /* Write number of errors seen to this variable */
@@ -73452,10 +73692,11 @@
73452
73453 sqlite3BtreeEnter(p);
73454 assert( p->inTrans>TRANS_NONE && pBt->inTransaction>TRANS_NONE );
73455 VVA_ONLY( nRef = sqlite3PagerRefcount(pBt->pPager) );
73456 assert( nRef>=0 );
 
73457 sCheck.pBt = pBt;
73458 sCheck.pPager = pBt->pPager;
73459 sCheck.nPage = btreePagecount(sCheck.pBt);
73460 sCheck.mxErr = mxErr;
73461 sCheck.nErr = 0;
@@ -75118,19 +75359,15 @@
75118 ** otherwise.
75119 */
75120 #ifndef SQLITE_OMIT_WINDOWFUNC
75121 SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem *pAccum, Mem *pOut, FuncDef *pFunc){
75122 sqlite3_context ctx;
75123 Mem t;
75124 assert( pFunc!=0 );
75125 assert( pFunc->xValue!=0 );
75126 assert( (pAccum->flags & MEM_Null)!=0 || pFunc==pAccum->u.pDef );
75127 assert( pAccum->db==0 || sqlite3_mutex_held(pAccum->db->mutex) );
75128 memset(&ctx, 0, sizeof(ctx));
75129 memset(&t, 0, sizeof(t));
75130 t.flags = MEM_Null;
75131 t.db = pAccum->db;
75132 sqlite3VdbeMemSetNull(pOut);
75133 ctx.pOut = pOut;
75134 ctx.pMem = pAccum;
75135 ctx.pFunc = pFunc;
75136 pFunc->xValue(&ctx);
@@ -76565,10 +76802,14 @@
76565 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)
76566 */
76567 /* #include "sqliteInt.h" */
76568 /* #include "vdbeInt.h" */
76569
 
 
 
 
76570 /*
76571 ** Create a new virtual database engine.
76572 */
76573 SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){
76574 sqlite3 *db = pParse->db;
@@ -76591,10 +76832,17 @@
76591 assert( p->nOpAlloc==0 );
76592 assert( pParse->szOpAlloc==0 );
76593 sqlite3VdbeAddOp2(p, OP_Init, 0, 1);
76594 return p;
76595 }
 
 
 
 
 
 
 
76596
76597 /*
76598 ** Change the error string stored in Vdbe.zErrMsg
76599 */
76600 SQLITE_PRIVATE void sqlite3VdbeError(Vdbe *p, const char *zFormat, ...){
@@ -76672,11 +76920,11 @@
76672 pA->pPrev = pB->pPrev;
76673 pB->pPrev = pTmp;
76674 zTmp = pA->zSql;
76675 pA->zSql = pB->zSql;
76676 pB->zSql = zTmp;
76677 #if 0
76678 zTmp = pA->zNormSql;
76679 pA->zNormSql = pB->zNormSql;
76680 pB->zNormSql = zTmp;
76681 #endif
76682 pB->expmask = pA->expmask;
@@ -76870,10 +77118,53 @@
76870 ){
76871 int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);
76872 sqlite3VdbeChangeP4(p, addr, zP4, p4type);
76873 return addr;
76874 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76875
76876 /*
76877 ** Add an opcode that includes the p4 value with a P4_INT64 or
76878 ** P4_REAL type.
76879 */
@@ -77190,11 +77481,11 @@
77190
77191 while( (pOp = opIterNext(&sIter))!=0 ){
77192 int opcode = pOp->opcode;
77193 if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
77194 || opcode==OP_VDestroy
77195 || (opcode==OP_Function0 && pOp->p4.pFunc->funcFlags&SQLITE_FUNC_INTERNAL)
77196 || ((opcode==OP_Halt || opcode==OP_HaltIfNull)
77197 && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
77198 ){
77199 hasAbort = 1;
77200 break;
@@ -77563,22 +77854,20 @@
77563 if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){
77564 sqlite3DbFreeNN(db, pDef);
77565 }
77566 }
77567
77568 static void vdbeFreeOpArray(sqlite3 *, Op *, int);
77569
77570 /*
77571 ** Delete a P4 value if necessary.
77572 */
77573 static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){
77574 if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
77575 sqlite3DbFreeNN(db, p);
77576 }
77577 static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){
77578 freeEphemeralFunction(db, p->pFunc);
77579 sqlite3DbFreeNN(db, p);
77580 }
77581 static void freeP4(sqlite3 *db, int p4type, void *p4){
77582 assert( db );
77583 switch( p4type ){
77584 case P4_FUNCCTX: {
@@ -77647,10 +77936,17 @@
77647 */
77648 SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){
77649 p->pNext = pVdbe->pProgram;
77650 pVdbe->pProgram = p;
77651 }
 
 
 
 
 
 
 
77652
77653 /*
77654 ** Change the opcode at addr into OP_Noop
77655 */
77656 SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe *p, int addr){
@@ -78073,17 +78369,15 @@
78073 case P4_FUNCDEF: {
78074 FuncDef *pDef = pOp->p4.pFunc;
78075 sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg);
78076 break;
78077 }
78078 #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
78079 case P4_FUNCCTX: {
78080 FuncDef *pDef = pOp->p4.pCtx->pFunc;
78081 sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg);
78082 break;
78083 }
78084 #endif
78085 case P4_INT64: {
78086 sqlite3_str_appendf(&x, "%lld", *pOp->p4.pI64);
78087 break;
78088 }
78089 case P4_INT32: {
@@ -78773,12 +79067,30 @@
78773 assert( x.nFree>=0 );
78774 assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) );
78775
78776 resolveP2Values(p, &nArg);
78777 p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);
78778 if( pParse->explain && nMem<10 ){
78779 nMem = 10;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78780 }
78781 p->expired = 0;
78782
78783 /* Memory for registers, parameters, cursor, etc, is allocated in one or two
78784 ** passes. On the first pass, we try to reuse unused memory at the
@@ -79124,11 +79436,11 @@
79124 int retryCount = 0;
79125 int nMainFile;
79126
79127 /* Select a master journal file name */
79128 nMainFile = sqlite3Strlen30(zMainFile);
79129 zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XXz", zMainFile);
79130 if( zMaster==0 ) return SQLITE_NOMEM_BKPT;
79131 do {
79132 u32 iRandom;
79133 if( retryCount ){
79134 if( retryCount>100 ){
@@ -81475,17 +81787,29 @@
81475 ** throw an error if it is given inputs that would make it non-deterministic.
81476 ** This routine is invoked by date/time functions that use non-deterministic
81477 ** features such as 'now'.
81478 */
81479 SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){
 
81480 #ifdef SQLITE_ENABLE_STAT4
81481 if( pCtx->pVdbe==0 ) return 1;
81482 #endif
81483 if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){
81484 sqlite3_result_error(pCtx,
81485 "non-deterministic function in index expression or CHECK constraint",
81486 -1);
 
 
 
 
 
 
 
 
 
 
 
81487 return 0;
81488 }
81489 return 1;
81490 }
81491
@@ -83428,11 +83752,11 @@
83428 if( !p || p->op==SQLITE_INSERT ){
83429 rc = SQLITE_MISUSE_BKPT;
83430 goto preupdate_old_out;
83431 }
83432 if( p->pPk ){
83433 iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);
83434 }
83435 if( iIdx>=p->pCsr->nField || iIdx<0 ){
83436 rc = SQLITE_RANGE;
83437 goto preupdate_old_out;
83438 }
@@ -83518,11 +83842,11 @@
83518 if( !p || p->op==SQLITE_DELETE ){
83519 rc = SQLITE_MISUSE_BKPT;
83520 goto preupdate_new_out;
83521 }
83522 if( p->pPk && p->op!=SQLITE_UPDATE ){
83523 iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);
83524 }
83525 if( iIdx>=p->pCsr->nField || iIdx<0 ){
83526 rc = SQLITE_RANGE;
83527 goto preupdate_new_out;
83528 }
@@ -84450,11 +84774,11 @@
84450 ** May you share freely, never taking more than you give.
84451 **
84452 ******************************************************************************
84453 **
84454 ** This file contains inline asm code for retrieving "high-performance"
84455 ** counters for x86 class CPUs.
84456 */
84457 #ifndef SQLITE_HWTIME_H
84458 #define SQLITE_HWTIME_H
84459
84460 /*
@@ -84461,12 +84785,13 @@
84461 ** The following routine only works on pentium-class (or newer) processors.
84462 ** It uses the RDTSC opcode to read the cycle count value out of the
84463 ** processor and returns that value. This can be used for high-res
84464 ** profiling.
84465 */
84466 #if (defined(__GNUC__) || defined(_MSC_VER)) && \
84467 (defined(i386) || defined(__i386__) || defined(_M_IX86))
 
84468
84469 #if defined(__GNUC__)
84470
84471 __inline__ sqlite_uint64 sqlite3Hwtime(void){
84472 unsigned int lo, hi;
@@ -84483,19 +84808,19 @@
84483 }
84484 }
84485
84486 #endif
84487
84488 #elif (defined(__GNUC__) && defined(__x86_64__))
84489
84490 __inline__ sqlite_uint64 sqlite3Hwtime(void){
84491 unsigned long val;
84492 __asm__ __volatile__ ("rdtsc" : "=A" (val));
84493 return val;
84494 }
84495
84496 #elif (defined(__GNUC__) && defined(__ppc__))
84497
84498 __inline__ sqlite_uint64 sqlite3Hwtime(void){
84499 unsigned long long retval;
84500 unsigned long junk;
84501 __asm__ __volatile__ ("\n\
@@ -84508,18 +84833,17 @@
84508 return retval;
84509 }
84510
84511 #else
84512
84513 #error Need implementation of sqlite3Hwtime() for your platform.
84514
84515 /*
84516 ** To compile without implementing sqlite3Hwtime() for your platform,
84517 ** you can remove the above #error and use the following
84518 ** stub function. You will lose timing support for many
84519 ** of the debugging and testing utilities, but it should at
84520 ** least compile and run.
 
84521 */
84522 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
84523
84524 #endif
84525
@@ -87081,15 +87405,15 @@
87081
87082 assert( p->apCsr[pOp->p1]->eCurType==CURTYPE_BTREE );
87083 pCrsr = p->apCsr[pOp->p1]->uc.pCursor;
87084 assert( pCrsr );
87085 nEntry = 0; /* Not needed. Only used to silence a warning. */
87086 rc = sqlite3BtreeCount(pCrsr, &nEntry);
87087 if( rc ) goto abort_due_to_error;
87088 pOut = out2Prerelease(p, pOp);
87089 pOut->u.i = nEntry;
87090 break;
87091 }
87092 #endif
87093
87094 /* Opcode: Savepoint P1 * * P4 *
87095 **
@@ -87313,11 +87637,10 @@
87313 p->pc = (int)(pOp - aOp);
87314 db->autoCommit = (u8)(1-desiredAutoCommit);
87315 p->rc = rc = SQLITE_BUSY;
87316 goto vdbe_return;
87317 }
87318 assert( db->nStatement==0 );
87319 sqlite3CloseSavepoints(db);
87320 if( p->rc==SQLITE_OK ){
87321 rc = SQLITE_DONE;
87322 }else{
87323 rc = SQLITE_ERROR;
@@ -87394,11 +87717,12 @@
87394 goto vdbe_return;
87395 }
87396 goto abort_due_to_error;
87397 }
87398
87399 if( pOp->p2 && p->usesStmtJournal
 
87400 && (db->autoCommit==0 || db->nVdbeRead>1)
87401 ){
87402 assert( sqlite3BtreeIsInTrans(pBt) );
87403 if( p->iStatement==0 ){
87404 assert( db->nStatement>=0 && db->nSavepoint>=0 );
@@ -88476,27 +88800,31 @@
88476 u64 iKey;
88477
88478 pIn3 = &aMem[pOp->p3];
88479 testcase( pIn3->flags & MEM_Int );
88480 testcase( pIn3->flags & MEM_IntReal );
 
 
88481 if( (pIn3->flags & (MEM_Int|MEM_IntReal))==0 ){
88482 /* Make sure pIn3->u.i contains a valid integer representation of
88483 ** the key value, but do not change the datatype of the register, as
88484 ** other parts of the perpared statement might be depending on the
88485 ** current datatype. */
88486 u16 origFlags = pIn3->flags;
88487 int isNotInt;
88488 applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);
88489 isNotInt = (pIn3->flags & MEM_Int)==0;
88490 pIn3->flags = origFlags;
88491 if( isNotInt ) goto jump_to_p2;
88492 }
88493 /* Fall through into OP_NotExists */
88494 case OP_NotExists: /* jump, in3 */
88495 pIn3 = &aMem[pOp->p3];
88496 assert( (pIn3->flags & MEM_Int)!=0 || pOp->opcode==OP_SeekRowid );
88497 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
 
 
88498 pC = p->apCsr[pOp->p1];
88499 assert( pC!=0 );
88500 #ifdef SQLITE_DEBUG
88501 if( pOp->opcode==OP_SeekRowid ) pC->seekOp = OP_SeekRowid;
88502 #endif
@@ -88503,11 +88831,10 @@
88503 assert( pC->isTable );
88504 assert( pC->eCurType==CURTYPE_BTREE );
88505 pCrsr = pC->uc.pCursor;
88506 assert( pCrsr!=0 );
88507 res = 0;
88508 iKey = pIn3->u.i;
88509 rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res);
88510 assert( rc==SQLITE_OK || res==0 );
88511 pC->movetoTarget = iKey; /* Used by OP_Delete */
88512 pC->nullRow = 0;
88513 pC->cacheStatus = CACHE_STALE;
@@ -90038,11 +90365,11 @@
90038 assert( (pnErr->flags & MEM_Int)!=0 );
90039 assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
90040 pIn1 = &aMem[pOp->p1];
90041 assert( pOp->p5<db->nDb );
90042 assert( DbMaskTest(p->btreeMask, pOp->p5) );
90043 z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, &aRoot[1], nRoot,
90044 (int)pnErr->u.i+1, &nErr);
90045 sqlite3VdbeMemSetNull(pIn1);
90046 if( nErr==0 ){
90047 assert( z==0 );
90048 }else if( z==0 ){
@@ -90051,11 +90378,11 @@
90051 pnErr->u.i -= nErr-1;
90052 sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free);
90053 }
90054 UPDATE_MAX_BLOBSIZE(pIn1);
90055 sqlite3VdbeChangeEncoding(pIn1, encoding);
90056 break;
90057 }
90058 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
90059
90060 /* Opcode: RowSetAdd P1 P2 * * *
90061 ** Synopsis: rowset(P1)=r[P2]
@@ -91377,76 +91704,56 @@
91377 pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);
91378 break;
91379 }
91380 #endif
91381
91382 /* Opcode: Function0 P1 P2 P3 P4 P5
91383 ** Synopsis: r[P3]=func(r[P2@P5])
91384 **
91385 ** Invoke a user function (P4 is a pointer to a FuncDef object that
91386 ** defines the function) with P5 arguments taken from register P2 and
91387 ** successors. The result of the function is stored in register P3.
91388 ** Register P3 must not be one of the function inputs.
 
 
91389 **
91390 ** P1 is a 32-bit bitmask indicating whether or not each argument to the
91391 ** function was determined to be constant at compile time. If the first
91392 ** argument was constant then bit 0 of P1 is set. This is used to determine
91393 ** whether meta data associated with a user function argument using the
91394 ** sqlite3_set_auxdata() API may be safely retained until the next
91395 ** invocation of this opcode.
91396 **
91397 ** See also: Function, AggStep, AggFinal
91398 */
91399 /* Opcode: Function P1 P2 P3 P4 P5
91400 ** Synopsis: r[P3]=func(r[P2@P5])
91401 **
91402 ** Invoke a user function (P4 is a pointer to an sqlite3_context object that
91403 ** contains a pointer to the function to be run) with P5 arguments taken
91404 ** from register P2 and successors. The result of the function is stored
 
 
91405 ** in register P3. Register P3 must not be one of the function inputs.
91406 **
91407 ** P1 is a 32-bit bitmask indicating whether or not each argument to the
91408 ** function was determined to be constant at compile time. If the first
91409 ** argument was constant then bit 0 of P1 is set. This is used to determine
91410 ** whether meta data associated with a user function argument using the
91411 ** sqlite3_set_auxdata() API may be safely retained until the next
91412 ** invocation of this opcode.
91413 **
91414 ** SQL functions are initially coded as OP_Function0 with P4 pointing
91415 ** to a FuncDef object. But on first evaluation, the P4 operand is
91416 ** automatically converted into an sqlite3_context object and the operation
91417 ** changed to this OP_Function opcode. In this way, the initialization of
91418 ** the sqlite3_context object occurs only once, rather than once for each
91419 ** evaluation of the function.
 
91420 **
91421 ** See also: Function0, AggStep, AggFinal
91422 */
91423 case OP_PureFunc0: /* group */
91424 case OP_Function0: { /* group */
91425 int n;
91426 sqlite3_context *pCtx;
91427
91428 assert( pOp->p4type==P4_FUNCDEF );
91429 n = pOp->p5;
91430 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
91431 assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );
91432 assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );
91433 pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*));
91434 if( pCtx==0 ) goto no_mem;
91435 pCtx->pOut = 0;
91436 pCtx->pFunc = pOp->p4.pFunc;
91437 pCtx->iOp = (int)(pOp - aOp);
91438 pCtx->pVdbe = p;
91439 pCtx->isError = 0;
91440 pCtx->argc = n;
91441 pOp->p4type = P4_FUNCCTX;
91442 pOp->p4.pCtx = pCtx;
91443 assert( OP_PureFunc == OP_PureFunc0+2 );
91444 assert( OP_Function == OP_Function0+2 );
91445 pOp->opcode += 2;
91446 /* Fall through into OP_Function */
91447 }
91448 case OP_PureFunc: /* group */
91449 case OP_Function: { /* group */
91450 int i;
91451 sqlite3_context *pCtx;
91452
@@ -91457,13 +91764,15 @@
91457 ** might change from one evaluation to the next. The next block of code
91458 ** checks to see if the register array has changed, and if so it
91459 ** reinitializes the relavant parts of the sqlite3_context object */
91460 pOut = &aMem[pOp->p3];
91461 if( pCtx->pOut != pOut ){
 
91462 pCtx->pOut = pOut;
91463 for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];
91464 }
 
91465
91466 memAboutToChange(p, pOut);
91467 #ifdef SQLITE_DEBUG
91468 for(i=0; i<pCtx->argc; i++){
91469 assert( memIsValid(pCtx->argv[i]) );
@@ -93668,24 +93977,20 @@
93668 ** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if
93669 ** an error occurs.
93670 */
93671 static int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){
93672 int i;
93673 SorterRecord **aSlot;
93674 SorterRecord *p;
93675 int rc;
 
93676
93677 rc = vdbeSortAllocUnpacked(pTask);
93678 if( rc!=SQLITE_OK ) return rc;
93679
93680 p = pList->pList;
93681 pTask->xCompare = vdbeSorterGetCompare(pTask->pSorter);
93682
93683 aSlot = (SorterRecord **)sqlite3MallocZero(64 * sizeof(SorterRecord *));
93684 if( !aSlot ){
93685 return SQLITE_NOMEM_BKPT;
93686 }
93687
93688 while( p ){
93689 SorterRecord *pNext;
93690 if( pList->aMemory ){
93691 if( (u8*)p==pList->aMemory ){
@@ -93706,17 +94011,16 @@
93706 aSlot[i] = p;
93707 p = pNext;
93708 }
93709
93710 p = 0;
93711 for(i=0; i<64; i++){
93712 if( aSlot[i]==0 ) continue;
93713 p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i];
93714 }
93715 pList->pList = p;
93716
93717 sqlite3_free(aSlot);
93718 assert( pTask->pUnpacked->errCode==SQLITE_OK
93719 || pTask->pUnpacked->errCode==SQLITE_NOMEM
93720 );
93721 return pTask->pUnpacked->errCode;
93722 }
@@ -96097,11 +96401,11 @@
96097 ** Perhaps the name is a reference to the ROWID
96098 */
96099 if( cnt==0
96100 && cntTab==1
96101 && pMatch
96102 && (pNC->ncFlags & NC_IdxExpr)==0
96103 && sqlite3IsRowid(zCol)
96104 && VisibleRowid(pMatch->pTab)
96105 ){
96106 cnt = 1;
96107 pExpr->iColumn = -1;
@@ -96308,17 +96612,20 @@
96308 Parse *pParse, /* Leave error message here */
96309 NameContext *pNC, /* The name context */
96310 const char *zMsg, /* Type of error */
96311 int validMask /* Set of contexts for which prohibited */
96312 ){
96313 assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr))==0 );
96314 if( (pNC->ncFlags & validMask)!=0 ){
96315 const char *zIn = "partial index WHERE clauses";
96316 if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions";
96317 #ifndef SQLITE_OMIT_CHECK
96318 else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints";
96319 #endif
 
 
 
96320 sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn);
96321 }
96322 }
96323
96324 /*
@@ -96406,11 +96713,11 @@
96406 zDb = 0;
96407 zTable = 0;
96408 zColumn = pExpr->u.zToken;
96409 }else{
96410 Expr *pLeft = pExpr->pLeft;
96411 notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr);
96412 pRight = pExpr->pRight;
96413 if( pRight->op==TK_ID ){
96414 zDb = 0;
96415 }else{
96416 assert( pRight->op==TK_DOT );
@@ -96495,19 +96802,22 @@
96495 }
96496 #endif
96497 if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){
96498 /* For the purposes of the EP_ConstFunc flag, date and time
96499 ** functions and other functions that change slowly are considered
96500 ** constant because they are constant for the duration of one query */
 
96501 ExprSetProperty(pExpr,EP_ConstFunc);
96502 }
96503 if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){
96504 /* Date/time functions that use 'now', and other functions like
96505 ** sqlite_version() that might change over time cannot be used
96506 ** in an index. */
96507 notValid(pParse, pNC, "non-deterministic functions",
96508 NC_IdxExpr|NC_PartIdx);
 
 
96509 }
96510 if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0
96511 && pParse->nested==0
96512 && sqlite3Config.bInternalFunctions==0
96513 ){
@@ -96647,11 +96957,12 @@
96647 #endif
96648 case TK_IN: {
96649 testcase( pExpr->op==TK_IN );
96650 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
96651 int nRef = pNC->nRef;
96652 notValid(pParse, pNC, "subqueries", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
 
96653 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
96654 assert( pNC->nRef>=nRef );
96655 if( nRef!=pNC->nRef ){
96656 ExprSetProperty(pExpr, EP_VarSelect);
96657 pNC->ncFlags |= NC_VarSelect;
@@ -96658,11 +96969,12 @@
96658 }
96659 }
96660 break;
96661 }
96662 case TK_VARIABLE: {
96663 notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
 
96664 break;
96665 }
96666 case TK_IS:
96667 case TK_ISNOT: {
96668 Expr *pRight = sqlite3ExprSkipCollateAndLikely(pExpr->pRight);
@@ -97467,34 +97779,38 @@
97467
97468 /*
97469 ** Resolve names in expressions that can only reference a single table
97470 ** or which cannot reference any tables at all. Examples:
97471 **
97472 ** (1) CHECK constraints
97473 ** (2) WHERE clauses on partial indices
97474 ** (3) Expressions in indexes on expressions
97475 ** (4) Expression arguments to VACUUM INTO.
 
 
 
97476 **
97477 ** In all cases except (4), the Expr.iTable value for Expr.op==TK_COLUMN
97478 ** nodes of the expression is set to -1 and the Expr.iColumn value is
97479 ** set to the column number. In case (4), TK_COLUMN nodes cause an error.
97480 **
97481 ** Any errors cause an error message to be set in pParse.
97482 */
97483 SQLITE_PRIVATE int sqlite3ResolveSelfReference(
97484 Parse *pParse, /* Parsing context */
97485 Table *pTab, /* The table being referenced, or NULL */
97486 int type, /* NC_IsCheck or NC_PartIdx or NC_IdxExpr, or 0 */
97487 Expr *pExpr, /* Expression to resolve. May be NULL. */
97488 ExprList *pList /* Expression list to resolve. May be NULL. */
97489 ){
97490 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
97491 NameContext sNC; /* Name context for pParse->pNewTable */
97492 int rc;
97493
97494 assert( type==0 || pTab!=0 );
97495 assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr || pTab==0 );
 
97496 memset(&sNC, 0, sizeof(sNC));
97497 memset(&sSrc, 0, sizeof(sSrc));
97498 if( pTab ){
97499 sSrc.nSrc = 1;
97500 sSrc.a[0].zName = pTab->zName;
@@ -97581,10 +97897,13 @@
97581 assert( pExpr->pLeft->flags&EP_xIsSelect );
97582 return sqlite3ExprAffinity(
97583 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
97584 );
97585 }
 
 
 
97586 return pExpr->affExpr;
97587 }
97588
97589 /*
97590 ** Set the collating sequence for expression pExpr to be the collating
@@ -97682,10 +98001,14 @@
97682 break;
97683 }
97684 if( op==TK_CAST || op==TK_UPLUS ){
97685 p = p->pLeft;
97686 continue;
 
 
 
 
97687 }
97688 if( op==TK_COLLATE ){
97689 pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken);
97690 break;
97691 }
@@ -97694,16 +98017,16 @@
97694 p = p->pLeft;
97695 }else{
97696 Expr *pNext = p->pRight;
97697 /* The Expr.x union is never used at the same time as Expr.pRight */
97698 assert( p->x.pList==0 || p->pRight==0 );
97699 /* p->flags holds EP_Collate and p->pLeft->flags does not. And
97700 ** p->x.pSelect cannot. So if p->x.pLeft exists, it must hold at
97701 ** least one EP_Collate. Thus the following two ALWAYS. */
97702 if( p->x.pList!=0 && ALWAYS(!ExprHasProperty(p, EP_xIsSelect)) ){
97703 int i;
97704 for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){
97705 if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){
97706 pNext = p->x.pList->a[i].pExpr;
97707 break;
97708 }
97709 }
@@ -97846,10 +98169,26 @@
97846 pColl = sqlite3ExprCollSeq(pParse, pRight);
97847 }
97848 }
97849 return pColl;
97850 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97851
97852 /*
97853 ** Generate code for a comparison operator.
97854 */
97855 static int codeCompare(
@@ -97857,17 +98196,22 @@
97857 Expr *pLeft, /* The left operand */
97858 Expr *pRight, /* The right operand */
97859 int opcode, /* The comparison opcode */
97860 int in1, int in2, /* Register holding operands */
97861 int dest, /* Jump here if true. */
97862 int jumpIfNull /* If true, jump if either operand is NULL */
 
97863 ){
97864 int p5;
97865 int addr;
97866 CollSeq *p4;
97867
97868 p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
 
 
 
 
97869 p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
97870 addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
97871 (void*)p4, P4_COLLSEQ);
97872 sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
97873 return addr;
@@ -98074,10 +98418,11 @@
98074 int i;
98075 int regLeft = 0;
98076 int regRight = 0;
98077 u8 opx = op;
98078 int addrDone = sqlite3VdbeMakeLabel(pParse);
 
98079
98080 if( nLeft!=sqlite3ExprVectorSize(pRight) ){
98081 sqlite3ErrorMsg(pParse, "row value misused");
98082 return;
98083 }
@@ -98103,11 +98448,11 @@
98103 Expr *pL, *pR;
98104 int r1, r2;
98105 assert( i>=0 && i<nLeft );
98106 r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);
98107 r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);
98108 codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5);
98109 testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
98110 testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
98111 testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
98112 testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
98113 testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
@@ -100878,35 +101223,77 @@
100878 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
100879 iTabCol, regOut);
100880 }
100881 }
100882
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100883 /*
100884 ** Generate code to extract the value of the iCol-th column of a table.
100885 */
100886 SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(
100887 Vdbe *v, /* The VDBE under construction */
100888 Table *pTab, /* The table containing the value */
100889 int iTabCur, /* The table cursor. Or the PK cursor for WITHOUT ROWID */
100890 int iCol, /* Index of the column to extract */
100891 int regOut /* Extract the value into this register */
100892 ){
 
 
100893 if( pTab==0 ){
100894 sqlite3VdbeAddOp3(v, OP_Column, iTabCur, iCol, regOut);
100895 return;
100896 }
100897 if( iCol<0 || iCol==pTab->iPKey ){
100898 sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);
100899 }else{
100900 int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;
100901 int x = iCol;
100902 if( !HasRowid(pTab) && !IsVirtual(pTab) ){
100903 x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100904 }
100905 sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);
100906 }
100907 if( iCol>=0 ){
100908 sqlite3ColumnDefault(v, pTab, iCol, regOut);
100909 }
100910 }
100911
100912 /*
@@ -100922,15 +101309,14 @@
100922 int iColumn, /* Index of the table column */
100923 int iTable, /* The cursor pointing to the table */
100924 int iReg, /* Store results here */
100925 u8 p5 /* P5 value for OP_Column + FLAGS */
100926 ){
100927 Vdbe *v = pParse->pVdbe;
100928 assert( v!=0 );
100929 sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
100930 if( p5 ){
100931 sqlite3VdbeChangeP5(v, p5);
100932 }
100933 return iReg;
100934 }
100935
100936 /*
@@ -101062,23 +101448,50 @@
101062 }
101063 return iReg;
101064 }
101065 if( iTab<0 ){
101066 if( pParse->iSelfTab<0 ){
101067 /* Generating CHECK constraints or inserting into partial index */
101068 assert( pExpr->y.pTab!=0 );
101069 assert( pExpr->iColumn>=XN_ROWID );
101070 assert( pExpr->iColumn<pExpr->y.pTab->nCol );
101071 if( pExpr->iColumn>=0
101072 && pExpr->y.pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL
101073 ){
101074 sqlite3VdbeAddOp2(v, OP_SCopy, pExpr->iColumn - pParse->iSelfTab,
101075 target);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101076 sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
101077 return target;
101078 }else{
101079 return pExpr->iColumn - pParse->iSelfTab;
101080 }
101081 }else{
101082 /* Coding an expression that is part of an index where column names
101083 ** in the index refer to the table to which the index belongs */
101084 iTab = pParse->iSelfTab - 1;
@@ -101173,11 +101586,12 @@
101173 codeVectorCompare(pParse, pExpr, target, op, p5);
101174 }else{
101175 r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);
101176 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
101177 codeCompare(pParse, pLeft, pExpr->pRight, op,
101178 r1, r2, inReg, SQLITE_STOREP2 | p5);
 
101179 assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
101180 assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
101181 assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
101182 assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
101183 assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
@@ -101442,13 +101856,12 @@
101442 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
101443 }
101444 }else
101445 #endif
101446 {
101447 sqlite3VdbeAddOp4(v, pParse->iSelfTab ? OP_PureFunc0 : OP_Function0,
101448 constMask, r1, target, (char*)pDef, P4_FUNCDEF);
101449 sqlite3VdbeChangeP5(v, (u8)nFarg);
101450 }
101451 if( nFarg && constMask==0 ){
101452 sqlite3ReleaseTempRange(pParse, r1, nFarg);
101453 }
101454 return target;
@@ -101541,32 +101954,32 @@
101541 ** p1==0 -> old.rowid p1==3 -> new.rowid
101542 ** p1==1 -> old.a p1==4 -> new.a
101543 ** p1==2 -> old.b p1==5 -> new.b
101544 */
101545 Table *pTab = pExpr->y.pTab;
101546 int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;
 
 
101547
101548 assert( pExpr->iTable==0 || pExpr->iTable==1 );
101549 assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );
101550 assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );
101551 assert( p1>=0 && p1<(pTab->nCol*2+2) );
101552
101553 sqlite3VdbeAddOp2(v, OP_Param, p1, target);
101554 VdbeComment((v, "r[%d]=%s.%s", target,
101555 (pExpr->iTable ? "new" : "old"),
101556 (pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[pExpr->iColumn].zName)
101557 ));
101558
101559 #ifndef SQLITE_OMIT_FLOATING_POINT
101560 /* If the column has REAL affinity, it may currently be stored as an
101561 ** integer. Use OP_RealAffinity to make sure it is really real.
101562 **
101563 ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to
101564 ** floating point when extracting it from the record. */
101565 if( pExpr->iColumn>=0
101566 && pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL
101567 ){
101568 sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
101569 }
101570 #endif
101571 break;
101572 }
@@ -101795,18 +102208,14 @@
101795 */
101796 SQLITE_PRIVATE void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){
101797 int inReg;
101798
101799 assert( target>0 && target<=pParse->nMem );
101800 if( pExpr && pExpr->op==TK_REGISTER ){
101801 sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);
101802 }else{
101803 inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
101804 assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );
101805 if( inReg!=target && pParse->pVdbe ){
101806 sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);
101807 }
101808 }
101809 }
101810
101811 /*
101812 ** Make a transient copy of expression pExpr and then code it using
@@ -101832,34 +102241,10 @@
101832 }else{
101833 sqlite3ExprCode(pParse, pExpr, target);
101834 }
101835 }
101836
101837 /*
101838 ** Generate code that evaluates the given expression and puts the result
101839 ** in register target.
101840 **
101841 ** Also make a copy of the expression results into another "cache" register
101842 ** and modify the expression so that the next time it is evaluated,
101843 ** the result is a copy of the cache register.
101844 **
101845 ** This routine is used for expressions that are used multiple
101846 ** times. They are evaluated once and the results of the expression
101847 ** are reused.
101848 */
101849 SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){
101850 Vdbe *v = pParse->pVdbe;
101851 int iMem;
101852
101853 assert( target>0 );
101854 assert( pExpr->op!=TK_REGISTER );
101855 sqlite3ExprCode(pParse, pExpr, target);
101856 iMem = ++pParse->nMem;
101857 sqlite3VdbeAddOp2(v, OP_Copy, target, iMem);
101858 exprToRegister(pExpr, iMem);
101859 }
101860
101861 /*
101862 ** Generate code that pushes the value of every element of the given
101863 ** expression list into a sequence of registers beginning at target.
101864 **
101865 ** Return the number of elements evaluated. The number returned will
@@ -102093,11 +102478,11 @@
102093 if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
102094 testcase( jumpIfNull==0 );
102095 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
102096 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
102097 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
102098 r1, r2, dest, jumpIfNull);
102099 assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
102100 assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
102101 assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
102102 assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
102103 assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);
@@ -102268,11 +102653,11 @@
102268 if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
102269 testcase( jumpIfNull==0 );
102270 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
102271 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
102272 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
102273 r1, r2, dest, jumpIfNull);
102274 assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
102275 assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
102276 assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
102277 assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
102278 assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);
@@ -102454,11 +102839,12 @@
102454 if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
102455 }else if( ALWAYS(pB->u.zToken!=0) && strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
102456 return 2;
102457 }
102458 }
102459 if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
 
102460 if( (combinedFlags & EP_TokenOnly)==0 ){
102461 if( combinedFlags & EP_xIsSelect ) return 2;
102462 if( (combinedFlags & EP_FixedCol)==0
102463 && sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
102464 if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
@@ -102466,14 +102852,28 @@
102466 if( pA->op!=TK_STRING
102467 && pA->op!=TK_TRUEFALSE
102468 && (combinedFlags & EP_Reduced)==0
102469 ){
102470 if( pA->iColumn!=pB->iColumn ) return 2;
102471 if( pA->op2!=pB->op2 ) return 2;
102472 if( pA->op!=TK_IN
102473 && pA->iTable!=pB->iTable
102474 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102475 }
102476 }
102477 return 0;
102478 }
102479
@@ -102636,11 +103036,11 @@
102636 }
102637 return 0;
102638 }
102639
102640 /*
102641 ** This is the Expr node callback for sqlite3ExprImpliesNotNullRow().
102642 ** If the expression node requires that the table at pWalker->iCur
102643 ** have one or more non-NULL column, then set pWalker->eCode to 1 and abort.
102644 **
102645 ** This routine controls an optimization. False positives (setting
102646 ** pWalker->eCode to 1 when it should not be) are deadly, but false-negatives
@@ -102654,34 +103054,39 @@
102654 case TK_ISNOT:
102655 case TK_ISNULL:
102656 case TK_NOTNULL:
102657 case TK_IS:
102658 case TK_OR:
 
102659 case TK_CASE:
102660 case TK_IN:
102661 case TK_FUNCTION:
 
102662 testcase( pExpr->op==TK_ISNOT );
102663 testcase( pExpr->op==TK_ISNULL );
102664 testcase( pExpr->op==TK_NOTNULL );
102665 testcase( pExpr->op==TK_IS );
102666 testcase( pExpr->op==TK_OR );
 
102667 testcase( pExpr->op==TK_CASE );
102668 testcase( pExpr->op==TK_IN );
102669 testcase( pExpr->op==TK_FUNCTION );
 
102670 return WRC_Prune;
102671 case TK_COLUMN:
102672 if( pWalker->u.iCur==pExpr->iTable ){
102673 pWalker->eCode = 1;
102674 return WRC_Abort;
102675 }
102676 return WRC_Prune;
102677
102678 case TK_AND:
102679 if( sqlite3ExprImpliesNonNullRow(pExpr->pLeft, pWalker->u.iCur)
102680 && sqlite3ExprImpliesNonNullRow(pExpr->pRight, pWalker->u.iCur)
102681 ){
102682 pWalker->eCode = 1;
 
102683 }
102684 return WRC_Prune;
102685
102686 case TK_BETWEEN:
102687 sqlite3WalkExpr(pWalker, pExpr->pLeft);
@@ -102736,18 +103141,17 @@
102736 ** ordinary join.
102737 */
102738 SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){
102739 Walker w;
102740 p = sqlite3ExprSkipCollateAndLikely(p);
102741 while( p ){
102742 if( p->op==TK_NOTNULL ){
102743 p = p->pLeft;
102744 }else if( p->op==TK_AND ){
 
102745 if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1;
102746 p = p->pRight;
102747 }else{
102748 break;
102749 }
102750 }
102751 w.xExprCallback = impliesNotNullRow;
102752 w.xSelectCallback = 0;
102753 w.xSelectCallback2 = 0;
@@ -102775,11 +103179,11 @@
102775 ** pWalker->u.pIdxCover->pIdx.
102776 */
102777 static int exprIdxCover(Walker *pWalker, Expr *pExpr){
102778 if( pExpr->op==TK_COLUMN
102779 && pExpr->iTable==pWalker->u.pIdxCover->iCur
102780 && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
102781 ){
102782 pWalker->eCode = 1;
102783 return WRC_Abort;
102784 }
102785 return WRC_Continue;
@@ -103201,13 +103605,12 @@
103201 ** Or, if zName is not a system table, zero is returned.
103202 */
103203 static int isAlterableTable(Parse *pParse, Table *pTab){
103204 if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7)
103205 #ifndef SQLITE_OMIT_VIRTUALTABLE
103206 || ( (pTab->tabFlags & TF_Shadow)
103207 && (pParse->db->flags & SQLITE_Defensive)
103208 && pParse->db->nVdbeExec==0
103209 )
103210 #endif
103211 ){
103212 sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);
103213 return 1;
@@ -103468,18 +103871,10 @@
103468 if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){
103469 return;
103470 }
103471 #endif
103472
103473 /* If the default value for the new column was specified with a
103474 ** literal NULL, then set pDflt to 0. This simplifies checking
103475 ** for an SQL NULL default below.
103476 */
103477 assert( pDflt==0 || pDflt->op==TK_SPAN );
103478 if( pDflt && pDflt->pLeft->op==TK_NULL ){
103479 pDflt = 0;
103480 }
103481
103482 /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.
103483 ** If there is a NOT NULL constraint, then the default value for the
103484 ** column must not be NULL.
103485 */
@@ -103489,39 +103884,53 @@
103489 }
103490 if( pNew->pIndex ){
103491 sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");
103492 return;
103493 }
103494 if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){
103495 sqlite3ErrorMsg(pParse,
103496 "Cannot add a REFERENCES column with non-NULL default value");
103497 return;
103498 }
103499 if( pCol->notNull && !pDflt ){
103500 sqlite3ErrorMsg(pParse,
103501 "Cannot add a NOT NULL column with default value NULL");
103502 return;
103503 }
103504
103505 /* Ensure the default expression is something that sqlite3ValueFromExpr()
103506 ** can handle (i.e. not CURRENT_TIME etc.)
103507 */
103508 if( pDflt ){
103509 sqlite3_value *pVal = 0;
103510 int rc;
103511 rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal);
103512 assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
103513 if( rc!=SQLITE_OK ){
103514 assert( db->mallocFailed == 1 );
103515 return;
103516 }
103517 if( !pVal ){
103518 sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default");
103519 return;
103520 }
103521 sqlite3ValueFree(pVal);
103522 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103523
103524 /* Modify the CREATE TABLE statement. */
103525 zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);
103526 if( zCol ){
103527 char *zEnd = &zCol[pColDef->n-1];
@@ -103605,10 +104014,11 @@
103605 }
103606 if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){
103607 goto exit_begin_add_column;
103608 }
103609
 
103610 assert( pTab->addColOffset>0 );
103611 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
103612
103613 /* Put a copy of the Table struct in Parse.pNewTable for the
103614 ** sqlite3AddColumn() function and friends to modify. But modify
@@ -104500,10 +104910,15 @@
104500 }
104501 for(pIdx=sParse.pNewIndex; pIdx; pIdx=pIdx->pNext){
104502 sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
104503 }
104504 }
 
 
 
 
 
104505
104506 for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
104507 for(i=0; i<pFKey->nCol; i++){
104508 if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){
104509 renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]);
@@ -105757,22 +106172,21 @@
105757 0, 0, /* xValue, xInverse */
105758 "stat_get", /* zName */
105759 {0}
105760 };
105761
105762 static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
105763 assert( regOut!=regStat4 && regOut!=regStat4+1 );
105764 #ifdef SQLITE_ENABLE_STAT4
105765 sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
105766 #elif SQLITE_DEBUG
105767 assert( iParam==STAT_GET_STAT1 );
105768 #else
105769 UNUSED_PARAMETER( iParam );
105770 #endif
105771 sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4, regOut,
105772 (char*)&statGetFuncdef, P4_FUNCDEF);
105773 sqlite3VdbeChangeP5(v, 1 + IsStat4);
105774 }
105775
105776 /*
105777 ** Generate code to do an analysis of all indices associated with
105778 ** a single table.
@@ -105936,13 +106350,12 @@
105936 #ifdef SQLITE_ENABLE_STAT4
105937 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+3);
105938 #endif
105939 sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1);
105940 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);
105941 sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4+1, regStat4,
105942 (char*)&statInitFuncdef, P4_FUNCDEF);
105943 sqlite3VdbeChangeP5(v, 2+IsStat4);
105944
105945 /* Implementation of the following:
105946 **
105947 ** Rewind csr
105948 ** if eof(csr) goto end_of_scan;
@@ -106023,27 +106436,26 @@
106023 }else{
106024 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
106025 int j, k, regKey;
106026 regKey = sqlite3GetTempRange(pParse, pPk->nKeyCol);
106027 for(j=0; j<pPk->nKeyCol; j++){
106028 k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);
106029 assert( k>=0 && k<pIdx->nColumn );
106030 sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, regKey+j);
106031 VdbeComment((v, "%s", pTab->aCol[pPk->aiColumn[j]].zName));
106032 }
106033 sqlite3VdbeAddOp3(v, OP_MakeRecord, regKey, pPk->nKeyCol, regRowid);
106034 sqlite3ReleaseTempRange(pParse, regKey, pPk->nKeyCol);
106035 }
106036 #endif
106037 assert( regChng==(regStat4+1) );
106038 sqlite3VdbeAddOp4(v, OP_Function0, 1, regStat4, regTemp,
106039 (char*)&statPushFuncdef, P4_FUNCDEF);
106040 sqlite3VdbeChangeP5(v, 2+IsStat4);
106041 sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, addrNextRow); VdbeCoverage(v);
106042
106043 /* Add the entry to the stat1 table. */
106044 callStatGet(v, regStat4, STAT_GET_STAT1, regStat1);
106045 assert( "BBB"[0]==SQLITE_AFF_TEXT );
106046 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, "BBB", 0);
106047 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
106048 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regTemp, regNewRowid);
106049 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
@@ -106065,16 +106477,16 @@
106065 u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;
106066
106067 pParse->nMem = MAX(pParse->nMem, regCol+nCol);
106068
106069 addrNext = sqlite3VdbeCurrentAddr(v);
106070 callStatGet(v, regStat4, STAT_GET_ROWID, regSampleRowid);
106071 addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regSampleRowid);
106072 VdbeCoverage(v);
106073 callStatGet(v, regStat4, STAT_GET_NEQ, regEq);
106074 callStatGet(v, regStat4, STAT_GET_NLT, regLt);
106075 callStatGet(v, regStat4, STAT_GET_NDLT, regDLt);
106076 sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);
106077 VdbeCoverage(v);
106078 for(i=0; i<nCol; i++){
106079 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
106080 }
@@ -106695,13 +107107,13 @@
106695 }
106696
106697 /* Load the statistics from the sqlite_stat4 table. */
106698 #ifdef SQLITE_ENABLE_STAT4
106699 if( rc==SQLITE_OK ){
106700 db->lookaside.bDisable++;
106701 rc = loadStat4(db, sInfo.zDatabase);
106702 db->lookaside.bDisable--;
106703 }
106704 for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
106705 Index *pIdx = sqliteHashData(i);
106706 sqlite3_free(pIdx->aiRowEst);
106707 pIdx->aiRowEst = 0;
@@ -107120,15 +107532,12 @@
107120 sqlite3ExprCode(pParse, pDbname, regArgs+1);
107121 sqlite3ExprCode(pParse, pKey, regArgs+2);
107122
107123 assert( v || db->mallocFailed );
107124 if( v ){
107125 sqlite3VdbeAddOp4(v, OP_Function0, 0, regArgs+3-pFunc->nArg, regArgs+3,
107126 (char *)pFunc, P4_FUNCDEF);
107127 assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );
107128 sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));
107129
107130 /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this
107131 ** statement only). For DETACH, set it to false (expire all existing
107132 ** statements).
107133 */
107134 sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));
@@ -108499,17 +108908,18 @@
108499 sqlite3ErrorMsg(pParse, ""); /* corruptSchema() will supply the error */
108500 return SQLITE_ERROR;
108501 }
108502 }
108503 }else{
108504 if( pParse->nested==0
108505 && 0==sqlite3StrNICmp(zName, "sqlite_", 7)
108506 ){
108507 sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s",
108508 zName);
108509 return SQLITE_ERROR;
108510 }
 
108511 }
108512 return SQLITE_OK;
108513 }
108514
108515 /*
@@ -108520,20 +108930,98 @@
108520 for(p=pTab->pIndex; p && !IsPrimaryKeyIndex(p); p=p->pNext){}
108521 return p;
108522 }
108523
108524 /*
108525 ** Return the column of index pIdx that corresponds to table
108526 ** column iCol. Return -1 if not found.
 
 
108527 */
108528 SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){
108529 int i;
108530 for(i=0; i<pIdx->nColumn; i++){
108531 if( iCol==pIdx->aiColumn[i] ) return i;
108532 }
108533 return -1;
108534 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108535
108536 /*
108537 ** Begin constructing a new table representation in memory. This is
108538 ** the first of several action routines that get called in response
108539 ** to a CREATE TABLE statement. In particular, this routine is called
@@ -108821,10 +109309,11 @@
108821 sqlite3Dequote(zType);
108822 pCol->affinity = sqlite3AffinityType(zType, pCol);
108823 pCol->colFlags |= COLFLAG_HASTYPE;
108824 }
108825 p->nCol++;
 
108826 pParse->constraintName.n = 0;
108827 }
108828
108829 /*
108830 ** This routine is called by the parser while in the middle of
@@ -108969,10 +109458,16 @@
108969 if( p!=0 ){
108970 pCol = &(p->aCol[p->nCol-1]);
108971 if( !sqlite3ExprIsConstantOrFunction(pExpr, db->init.busy) ){
108972 sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant",
108973 pCol->zName);
 
 
 
 
 
 
108974 }else{
108975 /* A copy of pExpr is used instead of the original, as pExpr contains
108976 ** tokens that point to volatile memory.
108977 */
108978 Expr x;
@@ -109013,10 +109508,25 @@
109013 p->op = TK_ID;
109014 }else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){
109015 p->pLeft->op = TK_ID;
109016 }
109017 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109018
109019 /*
109020 ** Designate the PRIMARY KEY for the table. pList is a list of names
109021 ** of columns that form the primary key. If pList is NULL, then the
109022 ** most recently added column of the table is the primary key.
@@ -109053,11 +109563,11 @@
109053 }
109054 pTab->tabFlags |= TF_HasPrimaryKey;
109055 if( pList==0 ){
109056 iCol = pTab->nCol - 1;
109057 pCol = &pTab->aCol[iCol];
109058 pCol->colFlags |= COLFLAG_PRIMKEY;
109059 nTerm = 1;
109060 }else{
109061 nTerm = pList->nExpr;
109062 for(i=0; i<nTerm; i++){
109063 Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);
@@ -109066,11 +109576,11 @@
109066 if( pCExpr->op==TK_ID ){
109067 const char *zCName = pCExpr->u.zToken;
109068 for(iCol=0; iCol<pTab->nCol; iCol++){
109069 if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){
109070 pCol = &pTab->aCol[iCol];
109071 pCol->colFlags |= COLFLAG_PRIMKEY;
109072 break;
109073 }
109074 }
109075 }
109076 }
@@ -109163,44 +109673,58 @@
109163 }else{
109164 sqlite3DbFree(db, zColl);
109165 }
109166 }
109167
109168 /*
109169 ** This function returns the collation sequence for database native text
109170 ** encoding identified by the string zName, length nName.
109171 **
109172 ** If the requested collation sequence is not available, or not available
109173 ** in the database native encoding, the collation factory is invoked to
109174 ** request it. If the collation factory does not supply such a sequence,
109175 ** and the sequence is available in another text encoding, then that is
109176 ** returned instead.
109177 **
109178 ** If no versions of the requested collations sequence are available, or
109179 ** another error occurs, NULL is returned and an error message written into
109180 ** pParse.
109181 **
109182 ** This routine is a wrapper around sqlite3FindCollSeq(). This routine
109183 ** invokes the collation factory if the named collation cannot be found
109184 ** and generates an error message.
109185 **
109186 ** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq()
109187 */
109188 SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){
109189 sqlite3 *db = pParse->db;
109190 u8 enc = ENC(db);
109191 u8 initbusy = db->init.busy;
109192 CollSeq *pColl;
109193
109194 pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);
109195 if( !initbusy && (!pColl || !pColl->xCmp) ){
109196 pColl = sqlite3GetCollSeq(pParse, enc, pColl, zName);
109197 }
109198
109199 return pColl;
109200 }
109201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109202
109203 /*
109204 ** Generate code that will increment the schema cookie.
109205 **
109206 ** The schema cookie is used to determine when the schema for the
@@ -109454,20 +109978,29 @@
109454 **
109455 ** colNotIdxed is a bitmask that has a 0 bit representing each indexed
109456 ** columns that are within the first 63 columns of the table. The
109457 ** high-order bit of colNotIdxed is always 1. All unindexed columns
109458 ** of the table have a 1.
 
 
 
 
 
 
 
 
109459 **
109460 ** The colNotIdxed mask is AND-ed with the SrcList.a[].colUsed mask
109461 ** to determine if the index is covering index.
109462 */
109463 static void recomputeColumnsNotIndexed(Index *pIdx){
109464 Bitmask m = 0;
109465 int j;
 
109466 for(j=pIdx->nColumn-1; j>=0; j--){
109467 int x = pIdx->aiColumn[j];
109468 if( x>=0 ){
109469 testcase( x==BMS-1 );
109470 testcase( x==BMS-2 );
109471 if( x<BMS-1 ) m |= MASKBIT(x);
109472 }
109473 }
@@ -109514,10 +110047,11 @@
109514 for(i=0; i<pTab->nCol; i++){
109515 if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){
109516 pTab->aCol[i].notNull = OE_Abort;
109517 }
109518 }
 
109519 }
109520
109521 /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY
109522 ** into BTREE_BLOBKEY.
109523 */
@@ -109621,23 +110155,26 @@
109621
109622 /* Add all table columns to the PRIMARY KEY index
109623 */
109624 nExtra = 0;
109625 for(i=0; i<pTab->nCol; i++){
109626 if( !hasColumn(pPk->aiColumn, nPk, i) ) nExtra++;
 
109627 }
109628 if( resizeIndexObject(db, pPk, nPk+nExtra) ) return;
109629 for(i=0, j=nPk; i<pTab->nCol; i++){
109630 if( !hasColumn(pPk->aiColumn, j, i) ){
 
 
109631 assert( j<pPk->nColumn );
109632 pPk->aiColumn[j] = i;
109633 pPk->azColl[j] = sqlite3StrBINARY;
109634 j++;
109635 }
109636 }
109637 assert( pPk->nColumn==j );
109638 assert( pTab->nCol<=j );
109639 recomputeColumnsNotIndexed(pPk);
109640 }
109641
109642 #ifndef SQLITE_OMIT_VIRTUALTABLE
109643 /*
@@ -109645,11 +110182,11 @@
109645 ** connection.
109646 **
109647 ** zName is temporarily modified while this routine is running, but is
109648 ** restored to its original value prior to this routine returning.
109649 */
109650 static int isShadowTableName(sqlite3 *db, char *zName){
109651 char *zTail; /* Pointer to the last "_" in zName */
109652 Table *pTab; /* Table that zName is a shadow of */
109653 Module *pMod; /* Module for the virtual table */
109654
109655 zTail = strrchr(zName, '_');
@@ -109663,12 +110200,10 @@
109663 if( pMod==0 ) return 0;
109664 if( pMod->pModule->iVersion<3 ) return 0;
109665 if( pMod->pModule->xShadowName==0 ) return 0;
109666 return pMod->pModule->xShadowName(zTail+1);
109667 }
109668 #else
109669 # define isShadowTableName(x,y) 0
109670 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
109671
109672 /*
109673 ** This routine is called to report the final ")" that terminates
109674 ** a CREATE TABLE statement.
@@ -109706,11 +110241,11 @@
109706 }
109707 assert( !db->mallocFailed );
109708 p = pParse->pNewTable;
109709 if( p==0 ) return;
109710
109711 if( pSelect==0 && isShadowTableName(db, p->zName) ){
109712 p->tabFlags |= TF_Shadow;
109713 }
109714
109715 /* If the db->init.busy is 1 it means we are reading the SQL off the
109716 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -109742,25 +110277,46 @@
109742 "AUTOINCREMENT not allowed on WITHOUT ROWID tables");
109743 return;
109744 }
109745 if( (p->tabFlags & TF_HasPrimaryKey)==0 ){
109746 sqlite3ErrorMsg(pParse, "PRIMARY KEY missing on table %s", p->zName);
109747 }else{
109748 p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;
109749 convertToWithoutRowidTable(pParse, p);
109750 }
 
 
109751 }
109752
109753 iDb = sqlite3SchemaToIndex(db, p->pSchema);
109754
109755 #ifndef SQLITE_OMIT_CHECK
109756 /* Resolve names in all CHECK constraint expressions.
109757 */
109758 if( p->pCheck ){
109759 sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
109760 }
109761 #endif /* !defined(SQLITE_OMIT_CHECK) */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109762
109763 /* Estimate the average row size for the table and for all implied indices */
109764 estimateTableWidth(p);
109765 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
109766 estimateIndexWidth(pIdx);
@@ -109833,11 +110389,11 @@
109833 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
109834 if( pParse->nErr ) return;
109835 pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect, SQLITE_AFF_BLOB);
109836 if( pSelTab==0 ) return;
109837 assert( p->aCol==0 );
109838 p->nCol = pSelTab->nCol;
109839 p->aCol = pSelTab->aCol;
109840 pSelTab->nCol = 0;
109841 pSelTab->aCol = 0;
109842 sqlite3DeleteTable(db, pSelTab);
109843 sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
@@ -109905,11 +110461,10 @@
109905
109906 /* Reparse everything to update our internal data structures */
109907 sqlite3VdbeAddParseSchemaOp(v, iDb,
109908 sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName));
109909 }
109910
109911
109912 /* Add the table to the in-memory representation of the database.
109913 */
109914 if( db->init.busy ){
109915 Table *pOld;
@@ -110090,11 +110645,11 @@
110090 pParse->eParseMode = PARSE_MODE_NORMAL;
110091 #endif
110092 n = pParse->nTab;
110093 sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
110094 pTable->nCol = -1;
110095 db->lookaside.bDisable++;
110096 #ifndef SQLITE_OMIT_AUTHORIZATION
110097 xAuth = db->xAuth;
110098 db->xAuth = 0;
110099 pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE);
110100 db->xAuth = xAuth;
@@ -110130,13 +110685,14 @@
110130 assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );
110131 }else{
110132 pTable->nCol = 0;
110133 nErr++;
110134 }
 
110135 sqlite3DeleteTable(db, pSelTab);
110136 sqlite3SelectDelete(db, pSel);
110137 db->lookaside.bDisable--;
110138 #ifndef SQLITE_OMIT_ALTERTABLE
110139 pParse->eParseMode = eParseMode;
110140 #endif
110141 } else {
110142 nErr++;
@@ -110388,10 +110944,41 @@
110388 }
110389 sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
110390 sqlite3ChangeCookie(pParse, iDb);
110391 sqliteViewResetAll(db, iDb);
110392 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110393
110394 /*
110395 ** This routine is called to do the work of a DROP TABLE statement.
110396 ** pName is the name of the table to be dropped.
110397 */
@@ -110458,13 +111045,11 @@
110458 if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){
110459 goto exit_drop_table;
110460 }
110461 }
110462 #endif
110463 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
110464 && sqlite3StrNICmp(pTab->zName+7, "stat", 4)!=0
110465 && sqlite3StrNICmp(pTab->zName+7, "parameters", 10)!=0 ){
110466 sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab->zName);
110467 goto exit_drop_table;
110468 }
110469
110470 #ifndef SQLITE_OMIT_VIEW
@@ -111131,12 +111716,17 @@
111131 }else{
111132 j = pCExpr->iColumn;
111133 assert( j<=0x7fff );
111134 if( j<0 ){
111135 j = pTab->iPKey;
111136 }else if( pTab->aCol[j].notNull==0 ){
111137 pIndex->uniqNotNull = 0;
 
 
 
 
 
111138 }
111139 pIndex->aiColumn[i] = (i16)j;
111140 }
111141 zColl = 0;
111142 if( pListItem->pExpr->op==TK_COLLATE ){
@@ -111187,17 +111777,17 @@
111187 if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);
111188
111189 /* If this index contains every column of its table, then mark
111190 ** it as a covering index */
111191 assert( HasRowid(pTab)
111192 || pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 );
111193 recomputeColumnsNotIndexed(pIndex);
111194 if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){
111195 pIndex->isCovering = 1;
111196 for(j=0; j<pTab->nCol; j++){
111197 if( j==pTab->iPKey ) continue;
111198 if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue;
111199 pIndex->isCovering = 0;
111200 break;
111201 }
111202 }
111203
@@ -112533,55 +113123,10 @@
112533 }
112534 }
112535 return SQLITE_ERROR;
112536 }
112537
112538 /*
112539 ** This function is responsible for invoking the collation factory callback
112540 ** or substituting a collation sequence of a different encoding when the
112541 ** requested collation sequence is not available in the desired encoding.
112542 **
112543 ** If it is not NULL, then pColl must point to the database native encoding
112544 ** collation sequence with name zName, length nName.
112545 **
112546 ** The return value is either the collation sequence to be used in database
112547 ** db for collation type name zName, length nName, or NULL, if no collation
112548 ** sequence can be found. If no collation is found, leave an error message.
112549 **
112550 ** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()
112551 */
112552 SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(
112553 Parse *pParse, /* Parsing context */
112554 u8 enc, /* The desired encoding for the collating sequence */
112555 CollSeq *pColl, /* Collating sequence with native encoding, or NULL */
112556 const char *zName /* Collating sequence name */
112557 ){
112558 CollSeq *p;
112559 sqlite3 *db = pParse->db;
112560
112561 p = pColl;
112562 if( !p ){
112563 p = sqlite3FindCollSeq(db, enc, zName, 0);
112564 }
112565 if( !p || !p->xCmp ){
112566 /* No collation sequence of this type for this encoding is registered.
112567 ** Call the collation factory to see if it can supply us with one.
112568 */
112569 callCollNeeded(db, enc, zName);
112570 p = sqlite3FindCollSeq(db, enc, zName, 0);
112571 }
112572 if( p && !p->xCmp && synthCollSeq(db, p) ){
112573 p = 0;
112574 }
112575 assert( !p || p->xCmp );
112576 if( p==0 ){
112577 sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
112578 pParse->rc = SQLITE_ERROR_MISSING_COLLSEQ;
112579 }
112580 return p;
112581 }
112582
112583 /*
112584 ** This routine is called on a collation sequence before it is used to
112585 ** check that it is defined. An undefined collation sequence exists when
112586 ** a database is loaded that contains references to collation sequences
112587 ** that have not been defined by sqlite3_create_collation() etc.
@@ -112670,14 +113215,14 @@
112670 ** cannot be found.
112671 **
112672 ** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq()
112673 */
112674 SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(
112675 sqlite3 *db,
112676 u8 enc,
112677 const char *zName,
112678 int create
112679 ){
112680 CollSeq *pColl;
112681 if( zName ){
112682 pColl = findCollSeqEntry(db, zName, create);
112683 }else{
@@ -112684,10 +113229,89 @@
112684 pColl = db->pDfltColl;
112685 }
112686 assert( SQLITE_UTF8==1 && SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
112687 assert( enc>=SQLITE_UTF8 && enc<=SQLITE_UTF16BE );
112688 if( pColl ) pColl += enc-1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112689 return pColl;
112690 }
112691
112692 /* During the search for the best function definition, this procedure
112693 ** is called to test how well the function passed as the first argument
@@ -113029,15 +113653,11 @@
113029 db = pParse->db;
113030 if( (pTab->tabFlags & TF_Readonly)!=0 ){
113031 return sqlite3WritableSchema(db)==0 && pParse->nested==0;
113032 }
113033 assert( pTab->tabFlags & TF_Shadow );
113034 return (db->flags & SQLITE_Defensive)!=0
113035 #ifndef SQLITE_OMIT_VIRTUALTABLE
113036 && db->pVtabCtx==0
113037 #endif
113038 && db->nVdbeExec==0;
113039 }
113040
113041 /*
113042 ** Check to make sure the given table is writable. If it is not
113043 ** writable, generate an error message and return 1. If it is
@@ -113696,11 +114316,12 @@
113696 sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);
113697 for(iCol=0; iCol<pTab->nCol; iCol++){
113698 testcase( mask!=0xffffffff && iCol==31 );
113699 testcase( mask!=0xffffffff && iCol==32 );
113700 if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){
113701 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1);
 
113702 }
113703 }
113704
113705 /* Invoke BEFORE DELETE trigger programs. */
113706 addrStart = sqlite3VdbeCurrentAddr(v);
@@ -113876,10 +114497,12 @@
113876 *piPartIdxLabel = sqlite3VdbeMakeLabel(pParse);
113877 pParse->iSelfTab = iDataCur + 1;
113878 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
113879 SQLITE_JUMPIFNULL);
113880 pParse->iSelfTab = 0;
 
 
113881 }else{
113882 *piPartIdxLabel = 0;
113883 }
113884 }
113885 nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;
@@ -116304,11 +116927,11 @@
116304 if( nIncr<0 ){
116305 sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, iOk);
116306 VdbeCoverage(v);
116307 }
116308 for(i=0; i<pFKey->nCol; i++){
116309 int iReg = aiCol[i] + regData + 1;
116310 sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk); VdbeCoverage(v);
116311 }
116312
116313 if( isIgnore==0 ){
116314 if( pIdx==0 ){
@@ -116320,11 +116943,12 @@
116320 /* Invoke MustBeInt to coerce the child key value to an integer (i.e.
116321 ** apply the affinity of the parent key). If this fails, then there
116322 ** is no matching parent key. Before using MustBeInt, make a copy of
116323 ** the value. Otherwise, the value inserted into the child key column
116324 ** will have INTEGER affinity applied to it, which may not be correct. */
116325 sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0]+1+regData, regTemp);
 
116326 iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0);
116327 VdbeCoverage(v);
116328
116329 /* If the parent table is the same as the child table, and we are about
116330 ** to increment the constraint-counter (i.e. this is an INSERT operation),
@@ -116347,11 +116971,13 @@
116347 int regRec = sqlite3GetTempReg(pParse);
116348
116349 sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);
116350 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
116351 for(i=0; i<nCol; i++){
116352 sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i]+1+regData, regTemp+i);
 
 
116353 }
116354
116355 /* If the parent table is the same as the child table, and we are about
116356 ** to increment the constraint-counter (i.e. this is an INSERT operation),
116357 ** then check if the row being inserted matches itself. If so, do not
@@ -116363,12 +116989,15 @@
116363 ** none of the child key values are).
116364 */
116365 if( pTab==pFKey->pFrom && nIncr==1 ){
116366 int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1;
116367 for(i=0; i<nCol; i++){
116368 int iChild = aiCol[i]+1+regData;
116369 int iParent = pIdx->aiColumn[i]+1+regData;
 
 
 
116370 assert( pIdx->aiColumn[i]>=0 );
116371 assert( aiCol[i]!=pTab->iPKey );
116372 if( pIdx->aiColumn[i]==pTab->iPKey ){
116373 /* The parent key is a composite key that includes the IPK column */
116374 iParent = regData;
@@ -116432,11 +117061,11 @@
116432
116433 pExpr = sqlite3Expr(db, TK_REGISTER, 0);
116434 if( pExpr ){
116435 if( iCol>=0 && iCol!=pTab->iPKey ){
116436 pCol = &pTab->aCol[iCol];
116437 pExpr->iTable = regBase + iCol + 1;
116438 pExpr->affExpr = pCol->affinity;
116439 zColl = pCol->zColl;
116440 if( zColl==0 ) zColl = db->pDfltColl->zName;
116441 pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl);
116442 }else{
@@ -116881,11 +117510,13 @@
116881 ** FK counter for each row of the current table with non-NULL keys.
116882 */
116883 Vdbe *v = sqlite3GetVdbe(pParse);
116884 int iJump = sqlite3VdbeCurrentAddr(v) + pFKey->nCol + 1;
116885 for(i=0; i<pFKey->nCol; i++){
116886 int iReg = pFKey->aCol[i].iFrom + regOld + 1;
 
 
116887 sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iJump); VdbeCoverage(v);
116888 }
116889 sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, -1);
116890 }
116891 continue;
@@ -117216,11 +117847,19 @@
117216 if( action==OE_Cascade ){
117217 pNew = sqlite3PExpr(pParse, TK_DOT,
117218 sqlite3ExprAlloc(db, TK_ID, &tNew, 0),
117219 sqlite3ExprAlloc(db, TK_ID, &tToCol, 0));
117220 }else if( action==OE_SetDflt ){
117221 Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;
 
 
 
 
 
 
 
 
117222 if( pDflt ){
117223 pNew = sqlite3ExprDup(db, pDflt, 0);
117224 }else{
117225 pNew = sqlite3ExprAlloc(db, TK_NULL, 0, 0);
117226 }
@@ -117254,11 +117893,11 @@
117254 );
117255 pWhere = 0;
117256 }
117257
117258 /* Disable lookaside memory allocation */
117259 db->lookaside.bDisable++;
117260
117261 pTrigger = (Trigger *)sqlite3DbMallocZero(db,
117262 sizeof(Trigger) + /* struct Trigger */
117263 sizeof(TriggerStep) + /* Single step in trigger program */
117264 nFrom + 1 /* Space for pStep->zTarget */
@@ -117276,11 +117915,11 @@
117276 pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);
117277 }
117278 }
117279
117280 /* Re-enable the lookaside buffer, if it was disabled earlier. */
117281 db->lookaside.bDisable--;
117282
117283 sqlite3ExprDelete(db, pWhere);
117284 sqlite3ExprDelete(db, pWhen);
117285 sqlite3ExprListDelete(db, pList);
117286 sqlite3SelectDelete(db, pSelect);
@@ -117427,11 +118066,11 @@
117427 v = sqlite3GetVdbe(pParse);
117428 assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );
117429 sqlite3TableLock(pParse, iDb, pTab->tnum,
117430 (opcode==OP_OpenWrite)?1:0, pTab->zName);
117431 if( HasRowid(pTab) ){
117432 sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nCol);
117433 VdbeComment((v, "%s", pTab->zName));
117434 }else{
117435 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
117436 assert( pPk!=0 );
117437 assert( pPk->tnum==pTab->tnum );
@@ -117519,27 +118158,29 @@
117519 ** 'C' NUMERIC
117520 ** 'D' INTEGER
117521 ** 'E' REAL
117522 */
117523 SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){
117524 int i;
117525 char *zColAff = pTab->zColAff;
117526 if( zColAff==0 ){
117527 sqlite3 *db = sqlite3VdbeDb(v);
117528 zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1);
117529 if( !zColAff ){
117530 sqlite3OomFault(db);
117531 return;
117532 }
117533
117534 for(i=0; i<pTab->nCol; i++){
117535 assert( pTab->aCol[i].affinity!=0 );
117536 zColAff[i] = pTab->aCol[i].affinity;
 
 
117537 }
117538 do{
117539 zColAff[i--] = 0;
117540 }while( i>=0 && zColAff[i]<=SQLITE_AFF_BLOB );
117541 pTab->zColAff = zColAff;
117542 }
117543 assert( zColAff!=0 );
117544 i = sqlite3Strlen30NN(zColAff);
117545 if( i ){
@@ -117588,10 +118229,92 @@
117588 }
117589 #endif
117590 }
117591 return 0;
117592 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117593
117594 #ifndef SQLITE_OMIT_AUTOINCREMENT
117595 /*
117596 ** Locate or create an AutoincInfo structure associated with table pTab
117597 ** which is in database iDb. Return the register number for the register
@@ -117896,11 +118619,11 @@
117896 */
117897 SQLITE_PRIVATE void sqlite3Insert(
117898 Parse *pParse, /* Parser context */
117899 SrcList *pTabList, /* Name of table into which we are inserting */
117900 Select *pSelect, /* A SELECT statement to use as the data source */
117901 IdList *pColumn, /* Column names corresponding to IDLIST. */
117902 int onError, /* How to handle constraint errors */
117903 Upsert *pUpsert /* ON CONFLICT clauses for upsert, or NULL */
117904 ){
117905 sqlite3 *db; /* The main database structure */
117906 Table *pTab; /* The table to insert into. aka TABLE */
@@ -117921,10 +118644,11 @@
117921 u8 useTempTable = 0; /* Store SELECT results in intermediate table */
117922 u8 appendFlag = 0; /* True if the insert is likely to be an append */
117923 u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */
117924 u8 bIdListInOrder; /* True if IDLIST is in table order */
117925 ExprList *pList = 0; /* List of VALUES() to be inserted */
 
117926
117927 /* Register allocations */
117928 int regFromSelect = 0;/* Base register for data coming from SELECT */
117929 int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */
117930 int regRowCount = 0; /* Memory cell used for the row counter */
@@ -118028,12 +118752,12 @@
118028 /* If this is an AUTOINCREMENT table, look up the sequence number in the
118029 ** sqlite_sequence table and store it in memory cell regAutoinc.
118030 */
118031 regAutoinc = autoIncBegin(pParse, iDb, pTab);
118032
118033 /* Allocate registers for holding the rowid of the new row,
118034 ** the content of the new row, and the assembled row record.
118035 */
118036 regRowid = regIns = pParse->nMem+1;
118037 pParse->nMem += pTab->nCol + 1;
118038 if( IsVirtual(pTab) ){
118039 regRowid++;
@@ -118048,13 +118772,21 @@
118048 ** If the table has an INTEGER PRIMARY KEY column and that column
118049 ** is named in the IDLIST, then record in the ipkColumn variable
118050 ** the index into IDLIST of the primary key column. ipkColumn is
118051 ** the index of the primary key as it appears in IDLIST, not as
118052 ** is appears in the original table. (The index of the INTEGER
118053 ** PRIMARY KEY in the original table is pTab->iPKey.)
 
 
 
 
 
 
 
 
118054 */
118055 bIdListInOrder = (pTab->tabFlags & TF_OOOHidden)==0;
118056 if( pColumn ){
118057 for(i=0; i<pColumn->nId; i++){
118058 pColumn->a[i].idx = -1;
118059 }
118060 for(i=0; i<pColumn->nId; i++){
@@ -118063,10 +118795,18 @@
118063 pColumn->a[i].idx = j;
118064 if( i!=j ) bIdListInOrder = 0;
118065 if( j==pTab->iPKey ){
118066 ipkColumn = i; assert( !withoutRowid );
118067 }
 
 
 
 
 
 
 
 
118068 break;
118069 }
118070 }
118071 if( j>=pTab->nCol ){
118072 if( sqlite3IsRowid(pColumn->a[i].zName) && !withoutRowid ){
@@ -118172,17 +118912,30 @@
118172 ** key, the set the ipkColumn variable to the integer primary key
118173 ** column index in the original table definition.
118174 */
118175 if( pColumn==0 && nColumn>0 ){
118176 ipkColumn = pTab->iPKey;
 
 
 
 
 
 
 
 
 
 
 
 
 
118177 }
118178
118179 /* Make sure the number of columns in the source data matches the number
118180 ** of columns to be inserted into the table.
118181 */
118182 for(i=0; i<pTab->nCol; i++){
118183 nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0);
118184 }
118185 if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){
118186 sqlite3ErrorMsg(pParse,
118187 "table %S has %d columns but %d values were supplied",
118188 pTabList, 0, pTab->nCol-nHidden, nColumn);
@@ -118263,11 +119016,91 @@
118263 ** goto C
118264 ** D: ...
118265 */
118266 addrInsTop = addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);
118267 VdbeCoverage(v);
 
 
 
 
 
 
118268 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118269
118270 /* Run the BEFORE and INSTEAD OF triggers, if there are any
118271 */
118272 endOfLoop = sqlite3VdbeMakeLabel(pParse);
118273 if( tmask & TRIGGER_BEFORE ){
@@ -118299,29 +119132,25 @@
118299 /* Cannot have triggers on a virtual table. If it were possible,
118300 ** this block would have to account for hidden column.
118301 */
118302 assert( !IsVirtual(pTab) );
118303
118304 /* Create the new column data
118305 */
118306 for(i=j=0; i<pTab->nCol; i++){
118307 if( pColumn ){
118308 for(j=0; j<pColumn->nId; j++){
118309 if( pColumn->a[j].idx==i ) break;
118310 }
118311 }
118312 if( (!useTempTable && !pList) || (pColumn && j>=pColumn->nId)
118313 || (pColumn==0 && IsOrdinaryHiddenColumn(&pTab->aCol[i])) ){
118314 sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regCols+i+1);
118315 }else if( useTempTable ){
118316 sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, regCols+i+1);
118317 }else{
118318 assert( pSelect==0 ); /* Otherwise useTempTable is true */
118319 sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1);
118320 }
118321 if( pColumn==0 && !IsOrdinaryHiddenColumn(&pTab->aCol[i]) ) j++;
118322 }
118323
118324 /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,
118325 ** do not attempt any conversions before assembling the record.
118326 ** If this is a real table, attempt conversions as required by the
118327 ** table column affinities.
@@ -118335,23 +119164,21 @@
118335 pTab, regCols-pTab->nCol-1, onError, endOfLoop);
118336
118337 sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);
118338 }
118339
118340 /* Compute the content of the next row to insert into a range of
118341 ** registers beginning at regIns.
118342 */
118343 if( !isView ){
118344 if( IsVirtual(pTab) ){
118345 /* The row that the VUpdate opcode will delete: none */
118346 sqlite3VdbeAddOp2(v, OP_Null, 0, regIns);
118347 }
118348 if( ipkColumn>=0 ){
 
118349 if( useTempTable ){
118350 sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regRowid);
118351 }else if( pSelect ){
118352 sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid);
118353 }else{
118354 Expr *pIpk = pList->a[ipkColumn].pExpr;
118355 if( pIpk->op==TK_NULL && !IsVirtual(pTab) ){
118356 sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);
118357 appendFlag = 1;
@@ -118380,49 +119207,21 @@
118380 sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);
118381 appendFlag = 1;
118382 }
118383 autoIncStep(pParse, regAutoinc, regRowid);
118384
118385 /* Compute data for all columns of the new entry, beginning
118386 ** with the first column.
118387 */
118388 nHidden = 0;
118389 for(i=0; i<pTab->nCol; i++){
118390 int iRegStore = regRowid+1+i;
118391 if( i==pTab->iPKey ){
118392 /* The value of the INTEGER PRIMARY KEY column is always a NULL.
118393 ** Whenever this column is read, the rowid will be substituted
118394 ** in its place. Hence, fill this column with a NULL to avoid
118395 ** taking up data space with information that will never be used.
118396 ** As there may be shallow copies of this value, make it a soft-NULL */
118397 sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);
118398 continue;
118399 }
118400 if( pColumn==0 ){
118401 if( IsHiddenColumn(&pTab->aCol[i]) ){
118402 j = -1;
118403 nHidden++;
118404 }else{
118405 j = i - nHidden;
118406 }
118407 }else{
118408 for(j=0; j<pColumn->nId; j++){
118409 if( pColumn->a[j].idx==i ) break;
118410 }
118411 }
118412 if( j<0 || nColumn==0 || (pColumn && j>=pColumn->nId) ){
118413 sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);
118414 }else if( useTempTable ){
118415 sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, iRegStore);
118416 }else if( pSelect ){
118417 if( regFromSelect!=regData ){
118418 sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+j, iRegStore);
118419 }
118420 }else{
118421 sqlite3ExprCode(pParse, pList->a[j].pExpr, iRegStore);
118422 }
118423 }
118424
118425 /* Generate code to check constraints and generate index keys and
118426 ** do the insertion.
118427 */
118428 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -118448,13 +119247,11 @@
118448 ** flag in the second case as if any REPLACE constraint is hit, an
118449 ** OP_Delete or OP_IdxDelete instruction will be executed on each
118450 ** cursor that is disturbed. And these instructions both clear the
118451 ** VdbeCursor.seekResult variable, disabling the OPFLAG_USESEEKRESULT
118452 ** functionality. */
118453 bUseSeek = (isReplace==0 || (pTrigger==0 &&
118454 ((db->flags & SQLITE_ForeignKeys)==0 || sqlite3FkReferences(pTab)==0)
118455 ));
118456 sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur,
118457 regIns, aRegIdx, 0, appendFlag, bUseSeek
118458 );
118459 }
118460 }
@@ -118711,10 +119508,17 @@
118711 u8 bAffinityDone = 0; /* True if the OP_Affinity operation has been run */
118712 int upsertBypass = 0; /* Address of Goto to bypass upsert subroutine */
118713 int upsertJump = 0; /* Address of Goto that jumps into upsert subroutine */
118714 int ipkTop = 0; /* Top of the IPK uniqueness check */
118715 int ipkBottom = 0; /* OP_Goto at the end of the IPK uniqueness check */
 
 
 
 
 
 
 
118716
118717 isUpdate = regOldData!=0;
118718 db = pParse->db;
118719 v = sqlite3GetVdbe(pParse);
118720 assert( v!=0 );
@@ -118737,64 +119541,73 @@
118737 VdbeModuleComment((v, "BEGIN: GenCnstCks(%d,%d,%d,%d,%d)",
118738 iDataCur, iIdxCur, regNewData, regOldData, pkChng));
118739
118740 /* Test all NOT NULL constraints.
118741 */
118742 for(i=0; i<nCol; i++){
118743 if( i==pTab->iPKey ){
118744 continue; /* ROWID is never NULL */
118745 }
118746 if( aiChng && aiChng[i]<0 ){
118747 /* Don't bother checking for NOT NULL on columns that do not change */
118748 continue;
118749 }
118750 onError = pTab->aCol[i].notNull;
118751 if( onError==OE_None ) continue; /* This column is allowed to be NULL */
118752 if( overrideError!=OE_Default ){
118753 onError = overrideError;
118754 }else if( onError==OE_Default ){
118755 onError = OE_Abort;
118756 }
118757 if( onError==OE_Replace && pTab->aCol[i].pDflt==0 ){
118758 onError = OE_Abort;
118759 }
118760 assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
118761 || onError==OE_Ignore || onError==OE_Replace );
118762 addr1 = 0;
118763 switch( onError ){
118764 case OE_Replace: {
118765 assert( onError==OE_Replace );
118766 addr1 = sqlite3VdbeMakeLabel(pParse);
118767 sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);
118768 VdbeCoverage(v);
118769 sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);
118770 sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);
118771 VdbeCoverage(v);
118772 onError = OE_Abort;
118773 /* Fall through into the OE_Abort case to generate code that runs
118774 ** if both the input and the default value are NULL */
118775 }
118776 case OE_Abort:
118777 sqlite3MayAbort(pParse);
118778 /* Fall through */
118779 case OE_Rollback:
118780 case OE_Fail: {
118781 char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName,
118782 pTab->aCol[i].zName);
118783 sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, onError,
118784 regNewData+1+i);
118785 sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC);
118786 sqlite3VdbeChangeP5(v, P5_ConstraintNotNull);
118787 VdbeCoverage(v);
118788 if( addr1 ) sqlite3VdbeResolveLabel(v, addr1);
118789 break;
118790 }
118791 default: {
118792 assert( onError==OE_Ignore );
118793 sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest);
118794 VdbeCoverage(v);
118795 break;
 
 
 
 
 
 
 
 
 
118796 }
118797 }
118798 }
118799
118800 /* Test all CHECK constraints
@@ -118874,10 +119687,54 @@
118874 ** Jump to that uniqueness check now */
118875 upsertJump = sqlite3VdbeAddOp0(v, OP_Goto);
118876 VdbeComment((v, "UPSERT constraint goes first"));
118877 }
118878 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118879
118880 /* If rowid is changing, make sure the new rowid does not previously
118881 ** exist in the table.
118882 */
118883 if( pkChng && pPk==0 ){
@@ -118964,18 +119821,16 @@
118964 ** REPLACE INTO t(rowid) VALUES($newrowid)
118965 **
118966 ** to run without a statement journal if there are no indexes on the
118967 ** table.
118968 */
118969 Trigger *pTrigger = 0;
118970 if( db->flags&SQLITE_RecTriggers ){
118971 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
118972 }
118973 if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
118974 sqlite3MultiWrite(pParse);
118975 sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
118976 regNewData, 1, 0, OE_Replace, 1, -1);
 
 
118977 }else{
118978 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
118979 assert( HasRowid(pTab) );
118980 /* This OP_Delete opcode fires the pre-update-hook only. It does
118981 ** not modify the b-tree. It is more efficient to let the coming
@@ -119021,10 +119876,11 @@
119021 for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){
119022 int regIdx; /* Range of registers hold conent for pIdx */
119023 int regR; /* Range of registers holding conflicting PK */
119024 int iThisCur; /* Cursor for this UNIQUE index */
119025 int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */
 
119026
119027 if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */
119028 if( pUpIdx==pIdx ){
119029 addrUniqueOk = upsertJump+1;
119030 upsertBypass = sqlite3VdbeGoto(v, 0);
@@ -119060,18 +119916,19 @@
119060 if( iField==XN_EXPR ){
119061 pParse->iSelfTab = -(regNewData+1);
119062 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
119063 pParse->iSelfTab = 0;
119064 VdbeComment((v, "%s column %d", pIdx->zName, i));
119065 }else{
119066 if( iField==XN_ROWID || iField==pTab->iPKey ){
119067 x = regNewData;
119068 }else{
119069 x = iField + regNewData + 1;
119070 }
119071 sqlite3VdbeAddOp2(v, iField<0 ? OP_IntCopy : OP_SCopy, x, regIdx+i);
119072 VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName));
 
119073 }
119074 }
119075 sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
119076 VdbeComment((v, "for %s", pIdx->zName));
119077 #ifdef SQLITE_ENABLE_NULL_TRIM
@@ -119134,12 +119991,13 @@
119134 }
119135 #endif /* ifndef SQLITE_ENABLE_PREUPDATE_HOOK */
119136
119137 /* Check to see if the new index entry will be unique */
119138 sqlite3VdbeVerifyAbortable(v, onError);
119139 sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
119140 regIdx, pIdx->nKeyCol); VdbeCoverage(v);
 
119141
119142 /* Generate code to handle collisions */
119143 regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);
119144 if( isUpdate || onError==OE_Replace ){
119145 if( HasRowid(pTab) ){
@@ -119156,11 +120014,11 @@
119156 /* Extract the PRIMARY KEY from the end of the index entry and
119157 ** store it in registers regR..regR+nPk-1 */
119158 if( pIdx!=pPk ){
119159 for(i=0; i<pPk->nKeyCol; i++){
119160 assert( pPk->aiColumn[i]>=0 );
119161 x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
119162 sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i);
119163 VdbeComment((v, "%s.%s", pTab->zName,
119164 pTab->aCol[pPk->aiColumn[i]].zName));
119165 }
119166 }
@@ -119182,10 +120040,11 @@
119182 assert( x>=0 );
119183 if( i==(pPk->nKeyCol-1) ){
119184 addrJump = addrUniqueOk;
119185 op = OP_Eq;
119186 }
 
119187 sqlite3VdbeAddOp4(v, op,
119188 regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ
119189 );
119190 sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
119191 VdbeCoverageIf(v, op==OP_Eq);
@@ -119218,21 +120077,69 @@
119218 testcase( onError==OE_Ignore );
119219 sqlite3VdbeGoto(v, ignoreDest);
119220 break;
119221 }
119222 default: {
119223 Trigger *pTrigger = 0;
 
119224 assert( onError==OE_Replace );
119225 if( db->flags&SQLITE_RecTriggers ){
119226 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
119227 }
119228 if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
119229 sqlite3MultiWrite(pParse);
 
119230 }
119231 sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
119232 regR, nPkField, 0, OE_Replace,
119233 (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119234 seenReplace = 1;
119235 break;
119236 }
119237 }
119238 if( pUpIdx==pIdx ){
@@ -119248,15 +120155,35 @@
119248 if( ipkTop ){
119249 sqlite3VdbeGoto(v, ipkTop);
119250 VdbeComment((v, "Do IPK REPLACE"));
119251 sqlite3VdbeJumpHere(v, ipkBottom);
119252 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119253
119254 /* Generate the table record */
119255 if( HasRowid(pTab) ){
119256 int regRec = aRegIdx[ix];
119257 sqlite3VdbeAddOp3(v, OP_MakeRecord, regNewData+1, pTab->nCol, regRec);
119258 sqlite3SetMakeRecordP5(v, pTab);
119259 if( !bAffinityDone ){
119260 sqlite3TableAffinity(v, pTab, 0);
119261 }
119262 }
@@ -119469,11 +120396,11 @@
119469 */
119470 static int xferCompatibleIndex(Index *pDest, Index *pSrc){
119471 int i;
119472 assert( pDest && pSrc );
119473 assert( pDest->pTable!=pSrc->pTable );
119474 if( pDest->nKeyCol!=pSrc->nKeyCol ){
119475 return 0; /* Different number of columns */
119476 }
119477 if( pDest->onError!=pSrc->onError ){
119478 return 0; /* Different conflict resolution strategies */
119479 }
@@ -119646,10 +120573,43 @@
119646 if( (db->mDbFlags & DBFLAG_Vacuum)==0
119647 && (pDestCol->colFlags | pSrcCol->colFlags) & COLFLAG_HIDDEN
119648 ){
119649 return 0; /* Neither table may have __hidden__ columns */
119650 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119651 #endif
119652 if( pDestCol->affinity!=pSrcCol->affinity ){
119653 return 0; /* Affinity must be the same on all columns */
119654 }
119655 if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){
@@ -119657,11 +120617,11 @@
119657 }
119658 if( pDestCol->notNull && !pSrcCol->notNull ){
119659 return 0; /* tab2 must be NOT NULL if tab1 is */
119660 }
119661 /* Default values for second and subsequent columns need to match. */
119662 if( i>0 ){
119663 assert( pDestCol->pDflt==0 || pDestCol->pDflt->op==TK_SPAN );
119664 assert( pSrcCol->pDflt==0 || pSrcCol->pDflt->op==TK_SPAN );
119665 if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0)
119666 || (pDestCol->pDflt && strcmp(pDestCol->pDflt->u.zToken,
119667 pSrcCol->pDflt->u.zToken)!=0)
@@ -120342,10 +121302,11 @@
120342 /* Version 3.28.0 and later */
120343 int (*stmt_isexplain)(sqlite3_stmt*);
120344 int (*value_frombind)(sqlite3_value*);
120345 /* Version 3.30.0 and later */
120346 int (*drop_modules)(sqlite3*,const char**);
 
120347 };
120348
120349 /*
120350 ** This is the function signature used for all extension entry points. It
120351 ** is also defined in the file "loadext.c".
@@ -120636,10 +121597,11 @@
120636 /* Version 3.28.0 and later */
120637 #define sqlite3_stmt_isexplain sqlite3_api->isexplain
120638 #define sqlite3_value_frombind sqlite3_api->frombind
120639 /* Version 3.30.0 and later */
120640 #define sqlite3_drop_modules sqlite3_api->drop_modules
 
120641 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
120642
120643 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
120644 /* This case when the file really is being compiled as a loadable
120645 ** extension */
@@ -121108,10 +122070,12 @@
121108 #ifndef SQLITE_OMIT_VIRTUALTABLE
121109 sqlite3_drop_modules,
121110 #else
121111 0,
121112 #endif
 
 
121113 };
121114
121115 /*
121116 ** Attempt to load an SQLite extension library contained in the file
121117 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -121530,38 +122494,39 @@
121530 #define PragTyp_DEFAULT_CACHE_SIZE 11
121531 #define PragTyp_ENCODING 12
121532 #define PragTyp_FOREIGN_KEY_CHECK 13
121533 #define PragTyp_FOREIGN_KEY_LIST 14
121534 #define PragTyp_FUNCTION_LIST 15
121535 #define PragTyp_INCREMENTAL_VACUUM 16
121536 #define PragTyp_INDEX_INFO 17
121537 #define PragTyp_INDEX_LIST 18
121538 #define PragTyp_INTEGRITY_CHECK 19
121539 #define PragTyp_JOURNAL_MODE 20
121540 #define PragTyp_JOURNAL_SIZE_LIMIT 21
121541 #define PragTyp_LOCK_PROXY_FILE 22
121542 #define PragTyp_LOCKING_MODE 23
121543 #define PragTyp_PAGE_COUNT 24
121544 #define PragTyp_MMAP_SIZE 25
121545 #define PragTyp_MODULE_LIST 26
121546 #define PragTyp_OPTIMIZE 27
121547 #define PragTyp_PAGE_SIZE 28
121548 #define PragTyp_PRAGMA_LIST 29
121549 #define PragTyp_SECURE_DELETE 30
121550 #define PragTyp_SHRINK_MEMORY 31
121551 #define PragTyp_SOFT_HEAP_LIMIT 32
121552 #define PragTyp_SYNCHRONOUS 33
121553 #define PragTyp_TABLE_INFO 34
121554 #define PragTyp_TEMP_STORE 35
121555 #define PragTyp_TEMP_STORE_DIRECTORY 36
121556 #define PragTyp_THREADS 37
121557 #define PragTyp_WAL_AUTOCHECKPOINT 38
121558 #define PragTyp_WAL_CHECKPOINT 39
121559 #define PragTyp_ACTIVATE_EXTENSIONS 40
121560 #define PragTyp_KEY 41
121561 #define PragTyp_LOCK_STATUS 42
121562 #define PragTyp_STATS 43
 
121563
121564 /* Property flags associated with various pragma. */
121565 #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
121566 #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
121567 #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -121828,10 +122793,15 @@
121828 /* ePragFlg: */ PragFlg_Result0,
121829 /* ColNames: */ 41, 2,
121830 /* iArg: */ 0 },
121831 #endif
121832 #endif
 
 
 
 
 
121833 #if defined(SQLITE_HAS_CODEC)
121834 {/* zName: */ "hexkey",
121835 /* ePragTyp: */ PragTyp_KEY,
121836 /* ePragFlg: */ 0,
121837 /* ColNames: */ 0, 0,
@@ -121905,15 +122875,10 @@
121905 {/* zName: */ "legacy_alter_table",
121906 /* ePragTyp: */ PragTyp_FLAG,
121907 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121908 /* ColNames: */ 0, 0,
121909 /* iArg: */ SQLITE_LegacyAlter },
121910 {/* zName: */ "legacy_file_format",
121911 /* ePragTyp: */ PragTyp_FLAG,
121912 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
121913 /* ColNames: */ 0, 0,
121914 /* iArg: */ SQLITE_LegacyFileFmt },
121915 #endif
121916 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE
121917 {/* zName: */ "lock_proxy_file",
121918 /* ePragTyp: */ PragTyp_LOCK_PROXY_FILE,
121919 /* ePragFlg: */ PragFlg_NoColumns1,
@@ -123252,29 +124217,38 @@
123252 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
123253 pParse->nMem = 7;
123254 sqlite3CodeVerifySchema(pParse, iTabDb);
123255 sqlite3ViewGetColumnNames(pParse, pTab);
123256 for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
123257 int isHidden = IsHiddenColumn(pCol);
123258 if( isHidden && pPragma->iArg==0 ){
123259 nHidden++;
123260 continue;
 
 
 
 
 
 
 
 
 
123261 }
123262 if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
123263 k = 0;
123264 }else if( pPk==0 ){
123265 k = 1;
123266 }else{
123267 for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
123268 }
123269 assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN );
123270 sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? "issisii" : "issisi",
123271 i-nHidden,
123272 pCol->zName,
123273 sqlite3ColumnType(pCol,""),
123274 pCol->notNull ? 1 : 0,
123275 pCol->pDflt ? pCol->pDflt->u.zToken : 0,
123276 k,
123277 isHidden);
123278 }
123279 }
123280 }
@@ -123729,11 +124703,11 @@
123729 assert( sqlite3NoTempsInRange(pParse,1,7+j) );
123730 sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
123731 loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
123732 if( !isQuick ){
123733 /* Sanity check on record header decoding */
123734 sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3);
123735 sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
123736 }
123737 /* Verify that all NOT NULL columns really are NOT NULL */
123738 for(j=0; j<pTab->nCol; j++){
123739 char *zErr;
@@ -124231,10 +125205,31 @@
124231 sqlite3_soft_heap_limit64(N);
124232 }
124233 returnSingleInt(v, sqlite3_soft_heap_limit64(-1));
124234 break;
124235 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124236
124237 /*
124238 ** PRAGMA threads
124239 ** PRAGMA threads = N
124240 **
@@ -124724,10 +125719,22 @@
124724 for(p=pIndex->pTable->pIndex; p; p=p->pNext){
124725 if( p->tnum==pIndex->tnum && p!=pIndex ) return 1;
124726 }
124727 return 0;
124728 }
 
 
 
 
 
 
 
 
 
 
 
 
124729
124730 /*
124731 ** This is the callback routine for the code that initializes the
124732 ** database. See sqlite3Init() below for additional information.
124733 ** This routine is also called from the OP_ParseSchema opcode of the VDBE.
@@ -124774,11 +125781,12 @@
124774 assert( db->init.busy );
124775 db->init.iDb = iDb;
124776 db->init.newTnum = sqlite3Atoi(argv[3]);
124777 db->init.orphanTrigger = 0;
124778 db->init.azInit = argv;
124779 TESTONLY(rcp = ) sqlite3_prepare(db, argv[4], -1, &pStmt, 0);
 
124780 rc = db->errCode;
124781 assert( (rc&0xFF)==(rcp&0xFF) );
124782 db->init.iDb = saved_iDb;
124783 /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */
124784 if( SQLITE_OK!=rc ){
@@ -125195,10 +126203,11 @@
125195 sqlite3DbFree(db, pParse->aLabel);
125196 sqlite3ExprListDelete(db, pParse->pConstExpr);
125197 if( db ){
125198 assert( db->lookaside.bDisable >= pParse->disableLookaside );
125199 db->lookaside.bDisable -= pParse->disableLookaside;
 
125200 }
125201 pParse->disableLookaside = 0;
125202 }
125203
125204 /*
@@ -125228,11 +126237,11 @@
125228 /* For a long-term use prepared statement avoid the use of
125229 ** lookaside memory.
125230 */
125231 if( prepFlags & SQLITE_PREPARE_PERSISTENT ){
125232 sParse.disableLookaside++;
125233 db->lookaside.bDisable++;
125234 }
125235 sParse.disableVtab = (prepFlags & SQLITE_PREPARE_NO_VTAB)!=0;
125236
125237 /* Check to verify that it is possible to get a read lock on all
125238 ** database schemas. The inability to get a read lock indicates that
@@ -125255,20 +126264,22 @@
125255 **
125256 ** Note that setting READ_UNCOMMITTED overrides most lock detection,
125257 ** but it does *not* override schema lock detection, so this all still
125258 ** works even if READ_UNCOMMITTED is set.
125259 */
125260 for(i=0; i<db->nDb; i++) {
125261 Btree *pBt = db->aDb[i].pBt;
125262 if( pBt ){
125263 assert( sqlite3BtreeHoldsMutex(pBt) );
125264 rc = sqlite3BtreeSchemaLocked(pBt);
125265 if( rc ){
125266 const char *zDb = db->aDb[i].zDbSName;
125267 sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
125268 testcase( db->flags & SQLITE_ReadUncommit );
125269 goto end_prepare;
 
 
125270 }
125271 }
125272 }
125273
125274 sqlite3VtabUnlockList(db);
@@ -125295,52 +126306,28 @@
125295 }else{
125296 sqlite3RunParser(&sParse, zSql, &zErrMsg);
125297 }
125298 assert( 0==sParse.nQueryLoop );
125299
125300 if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;
 
 
125301 if( sParse.checkSchema ){
125302 schemaIsValid(&sParse);
125303 }
125304 if( db->mallocFailed ){
125305 sParse.rc = SQLITE_NOMEM_BKPT;
125306 }
125307 if( pzTail ){
125308 *pzTail = sParse.zTail;
125309 }
125310 rc = sParse.rc;
125311
125312 #ifndef SQLITE_OMIT_EXPLAIN
125313 /* Justification for the ALWAYS(): The only way for rc to be SQLITE_OK and
125314 ** sParse.pVdbe to be NULL is if the input SQL is an empty string, but in
125315 ** that case, sParse.explain will be false. */
125316 if( sParse.explain && rc==SQLITE_OK && ALWAYS(sParse.pVdbe) ){
125317 static const char * const azColName[] = {
125318 "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment",
125319 "id", "parent", "notused", "detail"
125320 };
125321 int iFirst, mx;
125322 if( sParse.explain==2 ){
125323 sqlite3VdbeSetNumCols(sParse.pVdbe, 4);
125324 iFirst = 8;
125325 mx = 12;
125326 }else{
125327 sqlite3VdbeSetNumCols(sParse.pVdbe, 8);
125328 iFirst = 0;
125329 mx = 8;
125330 }
125331 for(i=iFirst; i<mx; i++){
125332 sqlite3VdbeSetColName(sParse.pVdbe, i-iFirst, COLNAME_NAME,
125333 azColName[i], SQLITE_STATIC);
125334 }
125335 }
125336 #endif
125337
125338 if( db->init.busy==0 ){
125339 sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);
125340 }
125341 if( rc!=SQLITE_OK || db->mallocFailed ){
 
 
 
 
125342 if( sParse.pVdbe ) sqlite3VdbeFinalize(sParse.pVdbe);
125343 assert(!(*ppStmt));
125344 }else{
125345 *ppStmt = (sqlite3_stmt*)sParse.pVdbe;
125346 }
@@ -125708,13 +126695,13 @@
125708 sqlite3ExprDelete(db, p->pLimit);
125709 #ifndef SQLITE_OMIT_WINDOWFUNC
125710 if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){
125711 sqlite3WindowListDelete(db, p->pWinDefn);
125712 }
125713 #endif
125714 if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);
125715 assert( p->pWin==0 );
 
 
125716 if( bFree ) sqlite3DbFreeNN(db, p);
125717 p = pPrior;
125718 bFree = 1;
125719 }
125720 }
@@ -125993,28 +126980,28 @@
125993 ** NULL t2 row will be inserted whenever t1.x!=5. If we do not
125994 ** defer the handling of t1.x=5, it will be processed immediately
125995 ** after the t1 loop and rows with t1.x!=5 will never appear in
125996 ** the output, which is incorrect.
125997 */
125998 static void setJoinExpr(Expr *p, int iTable){
125999 while( p ){
126000 ExprSetProperty(p, EP_FromJoin);
126001 assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
126002 ExprSetVVAProperty(p, EP_NoReduce);
126003 p->iRightJoinTable = (i16)iTable;
126004 if( p->op==TK_FUNCTION && p->x.pList ){
126005 int i;
126006 for(i=0; i<p->x.pList->nExpr; i++){
126007 setJoinExpr(p->x.pList->a[i].pExpr, iTable);
126008 }
126009 }
126010 setJoinExpr(p->pLeft, iTable);
126011 p = p->pRight;
126012 }
126013 }
126014
126015 /* Undo the work of setJoinExpr(). In the expression tree p, convert every
126016 ** term that is marked with EP_FromJoin and iRightJoinTable==iTable into
126017 ** an ordinary term that omits the EP_FromJoin mark.
126018 **
126019 ** This happens when a LEFT JOIN is simplified into an ordinary JOIN.
126020 */
@@ -126097,11 +127084,11 @@
126097
126098 /* Add the ON clause to the end of the WHERE clause, connected by
126099 ** an AND operator.
126100 */
126101 if( pRight->pOn ){
126102 if( isOuter ) setJoinExpr(pRight->pOn, pRight->iCursor);
126103 p->pWhere = sqlite3ExprAnd(pParse, p->pWhere, pRight->pOn);
126104 pRight->pOn = 0;
126105 }
126106
126107 /* Create extra terms on the WHERE clause for each column named
@@ -126277,10 +127264,11 @@
126277 memset(pKI->aSortFlags, 0, pKI->nKeyField); /* Makes OP_Jump testable */
126278 sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
126279 testcase( pKI->nAllField > pKI->nKeyField+2 );
126280 pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat,
126281 pKI->nAllField-pKI->nKeyField-1);
 
126282 addrJmp = sqlite3VdbeCurrentAddr(v);
126283 sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
126284 pSort->labelBkOut = sqlite3VdbeMakeLabel(pParse);
126285 pSort->regReturn = ++pParse->nMem;
126286 sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
@@ -126639,10 +127627,11 @@
126639 sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);
126640 pOp = sqlite3VdbeGetOp(v, pDistinct->addrTnct);
126641 pOp->opcode = OP_Null;
126642 pOp->p1 = 1;
126643 pOp->p2 = regPrev;
 
126644
126645 iJump = sqlite3VdbeCurrentAddr(v) + nResultCol;
126646 for(i=0; i<nResultCol; i++){
126647 CollSeq *pColl = sqlite3ExprCollSeq(pParse, p->pEList->a[i].pExpr);
126648 if( i<nResultCol-1 ){
@@ -129111,10 +130100,18 @@
129111 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
129112 substSelect(pSubst, pExpr->x.pSelect, 1);
129113 }else{
129114 substExprList(pSubst, pExpr->x.pList);
129115 }
 
 
 
 
 
 
 
 
129116 }
129117 return pExpr;
129118 }
129119 static void substExprList(
129120 SubstContext *pSubst, /* Description of the substitution */
@@ -129653,11 +130650,11 @@
129653 pSub->pOrderBy = 0;
129654 }
129655 pWhere = pSub->pWhere;
129656 pSub->pWhere = 0;
129657 if( isLeftJoin>0 ){
129658 setJoinExpr(pWhere, iNewParent);
129659 }
129660 pParent->pWhere = sqlite3ExprAnd(pParse, pWhere, pParent->pWhere);
129661 if( db->mallocFailed==0 ){
129662 SubstContext x;
129663 x.pParse = pParse;
@@ -129770,18 +130767,18 @@
129770 assert( pRight!=0 );
129771 assert( pLeft!=0 );
129772 if( pRight->op==TK_COLUMN
129773 && !ExprHasProperty(pRight, EP_FixedCol)
129774 && sqlite3ExprIsConstant(pLeft)
129775 && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight))
129776 ){
129777 constInsert(pConst, pRight, pLeft);
129778 }else
129779 if( pLeft->op==TK_COLUMN
129780 && !ExprHasProperty(pLeft, EP_FixedCol)
129781 && sqlite3ExprIsConstant(pRight)
129782 && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight))
129783 ){
129784 constInsert(pConst, pLeft, pRight);
129785 }
129786 }
129787
@@ -130266,10 +131263,13 @@
130266 sqlite3 *db = pParse->db;
130267 struct Cte *pCte; /* Matched CTE (or NULL if no match) */
130268 With *pWith; /* WITH clause that pCte belongs to */
130269
130270 assert( pFrom->pTab==0 );
 
 
 
130271
130272 pCte = searchWith(pParse->pWith, pFrom, &pWith);
130273 if( pCte ){
130274 Table *pTab;
130275 ExprList *pEList;
@@ -131327,11 +132327,11 @@
131327 #ifndef SQLITE_OMIT_WINDOWFUNC
131328 if( sqlite3WindowRewrite(pParse, p) ){
131329 goto select_end;
131330 }
131331 #if SELECTTRACE_ENABLED
131332 if( sqlite3SelectTrace & 0x108 ){
131333 SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n"));
131334 sqlite3TreeViewSelect(0, p, 0);
131335 }
131336 #endif
131337 #endif /* SQLITE_OMIT_WINDOWFUNC */
@@ -133864,11 +134864,11 @@
133864 int onError, /* How to handle constraint errors */
133865 ExprList *pOrderBy, /* ORDER BY clause. May be null */
133866 Expr *pLimit, /* LIMIT clause. May be null */
133867 Upsert *pUpsert /* ON CONFLICT clause, or null */
133868 ){
133869 int i, j; /* Loop counters */
133870 Table *pTab; /* The table to be updated */
133871 int addrTop = 0; /* VDBE instruction address of the start of the loop */
133872 WhereInfo *pWInfo; /* Information about the WHERE clause */
133873 Vdbe *v; /* The virtual database engine */
133874 Index *pIdx; /* For looping over indices */
@@ -134006,10 +135006,14 @@
134006 sNC.pParse = pParse;
134007 sNC.pSrcList = pTabList;
134008 sNC.uNC.pUpsert = pUpsert;
134009 sNC.ncFlags = NC_UUpsert;
134010
 
 
 
 
134011 /* Resolve the column names in all the expressions of the
134012 ** of the UPDATE statement. Also find the column index
134013 ** for each column to be updated in the pChanges array. For each
134014 ** column to be updated, make sure we have authorization to change
134015 ** that column.
@@ -134025,10 +135029,20 @@
134025 chngRowid = 1;
134026 pRowidExpr = pChanges->a[i].pExpr;
134027 }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){
134028 chngPk = 1;
134029 }
 
 
 
 
 
 
 
 
 
 
134030 aXRef[j] = i;
134031 break;
134032 }
134033 }
134034 if( j>=pTab->nCol ){
@@ -134058,10 +135072,37 @@
134058 }
134059 assert( (chngRowid & chngPk)==0 );
134060 assert( chngRowid==0 || chngRowid==1 );
134061 assert( chngPk==0 || chngPk==1 );
134062 chngKey = chngRowid + chngPk;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134063
134064 /* The SET expressions are not actually used inside the WHERE loop.
134065 ** So reset the colUsed mask. Unless this is a virtual table. In that
134066 ** case, set all bits of the colUsed mask (to ensure that the virtual
134067 ** table implementation makes all columns available).
@@ -134103,13 +135144,10 @@
134103 /* If REPLACE conflict resolution might be invoked, open cursors on all
134104 ** indexes in case they are needed to delete records. */
134105 memset(aToOpen, 1, nIdx+1);
134106 }
134107
134108 /* Begin generating code. */
134109 v = sqlite3GetVdbe(pParse);
134110 if( v==0 ) goto update_cleanup;
134111 if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
134112 sqlite3BeginWriteOperation(pParse, pTrigger || hasFK, iDb);
134113
134114 /* Allocate required registers. */
134115 if( !IsVirtual(pTab) ){
@@ -134259,11 +135297,12 @@
134259 ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change
134260 ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table
134261 ** is not required) and leave the PK fields in the array of registers. */
134262 for(i=0; i<nPk; i++){
134263 assert( pPk->aiColumn[i]>=0 );
134264 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,pPk->aiColumn[i],iPk+i);
 
134265 }
134266 if( eOnePass ){
134267 if( addrOpen ) sqlite3VdbeChangeToNoop(v, addrOpen);
134268 nKey = nPk;
134269 regKey = iPk;
@@ -134340,18 +135379,20 @@
134340 u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);
134341 oldmask |= sqlite3TriggerColmask(pParse,
134342 pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError
134343 );
134344 for(i=0; i<pTab->nCol; i++){
 
 
134345 if( oldmask==0xffffffff
134346 || (i<32 && (oldmask & MASKBIT32(i))!=0)
134347 || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0
134348 ){
134349 testcase( oldmask!=0xffffffff && i==31 );
134350 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i);
134351 }else{
134352 sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);
134353 }
134354 }
134355 if( chngRowid==0 && pPk==0 ){
134356 sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);
134357 }
@@ -134371,31 +135412,40 @@
134371 ** be used eliminates some redundant opcodes.
134372 */
134373 newmask = sqlite3TriggerColmask(
134374 pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError
134375 );
134376 for(i=0; i<pTab->nCol; i++){
134377 if( i==pTab->iPKey ){
134378 sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
 
 
134379 }else{
134380 j = aXRef[i];
134381 if( j>=0 ){
134382 sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
134383 }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){
134384 /* This branch loads the value of a column that will not be changed
134385 ** into a register. This is done if there are no BEFORE triggers, or
134386 ** if there are one or more BEFORE triggers that use this value via
134387 ** a new.* reference in a trigger program.
134388 */
134389 testcase( i==31 );
134390 testcase( i==32 );
134391 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i);
134392 }else{
134393 sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
134394 }
134395 }
134396 }
 
 
 
 
 
 
 
134397
134398 /* Fire any BEFORE UPDATE triggers. This happens before constraints are
134399 ** verified. One could argue that this is wrong.
134400 */
134401 if( tmask&TRIGGER_BEFORE ){
@@ -134424,15 +135474,24 @@
134424 ** in case this has happened. Only unmodified columns are reloaded.
134425 ** The values computed for modified columns use the values before the
134426 ** BEFORE trigger runs. See test case trigger1-18.0 (added 2018-04-26)
134427 ** for an example.
134428 */
134429 for(i=0; i<pTab->nCol; i++){
134430 if( aXRef[i]<0 && i!=pTab->iPKey ){
134431 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i);
 
 
134432 }
134433 }
 
 
 
 
 
 
 
134434 }
134435
134436 if( !isView ){
134437 /* Do constraint checks. */
134438 assert( regOldRowid>0 );
@@ -134634,10 +135693,11 @@
134634 pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0,0,WHERE_ONEPASS_DESIRED,0);
134635 if( pWInfo==0 ) return;
134636
134637 /* Populate the argument registers. */
134638 for(i=0; i<pTab->nCol; i++){
 
134639 if( aXRef[i]>=0 ){
134640 sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);
134641 }else{
134642 sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i);
134643 sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG);/* Enable sqlite3_vtab_nochange() */
@@ -134944,11 +136004,11 @@
134944 int iPk = pParse->nMem+1;
134945 pParse->nMem += nPk;
134946 for(i=0; i<nPk; i++){
134947 int k;
134948 assert( pPk->aiColumn[i]>=0 );
134949 k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
134950 sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i);
134951 VdbeComment((v, "%s.%s", pIdx->zName,
134952 pTab->aCol[pPk->aiColumn[i]].zName));
134953 }
134954 sqlite3VdbeVerifyAbortable(v, OE_Abort);
@@ -135702,16 +136762,16 @@
135702 ** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously
135703 ** by multiple threads. It is thread-safe.
135704 */
135705 SQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3 *db){
135706 VTable *p = db->pDisconnect;
135707 db->pDisconnect = 0;
135708
135709 assert( sqlite3BtreeHoldsAllMutexes(db) );
135710 assert( sqlite3_mutex_held(db->mutex) );
135711
135712 if( p ){
 
135713 sqlite3ExpirePreparedStatements(db, 0);
135714 do {
135715 VTable *pNext = p->pNext;
135716 sqlite3VtabUnlock(p);
135717 p = pNext;
@@ -136021,11 +137081,11 @@
136021 *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
136022 sqlite3VtabUnlock(pVTable);
136023 rc = SQLITE_ERROR;
136024 }else{
136025 int iCol;
136026 u8 oooHidden = 0;
136027 /* If everything went according to plan, link the new VTable structure
136028 ** into the linked list headed by pTab->pVTable. Then loop through the
136029 ** columns of the table to see if any of them contain the token "hidden".
136030 ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from
136031 ** the type string. */
@@ -137017,11 +138077,10 @@
137017 #define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
137018 #define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
137019 #define TERM_LIKE 0x400 /* The original LIKE operator */
137020 #define TERM_IS 0x800 /* Term.pExpr is an IS operator */
137021 #define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
137022 #define TERM_NOPARTIDX 0x2000 /* Not for use to enable a partial index */
137023
137024 /*
137025 ** An instance of the WhereScan object is used as an iterator for locating
137026 ** terms in the WHERE clause that are useful to the query planner.
137027 */
@@ -138125,11 +139184,11 @@
138125 static int codeCursorHintCheckExpr(Walker *pWalker, Expr *pExpr){
138126 struct CCurHint *pHint = pWalker->u.pCCurHint;
138127 assert( pHint->pIdx!=0 );
138128 if( pExpr->op==TK_COLUMN
138129 && pExpr->iTable==pHint->iTabCur
138130 && sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn)<0
138131 ){
138132 pWalker->eCode = 1;
138133 }
138134 return WRC_Continue;
138135 }
@@ -138193,11 +139252,11 @@
138193 sqlite3ExprCode(pWalker->pParse, pExpr, reg);
138194 pExpr->op = TK_REGISTER;
138195 pExpr->iTable = reg;
138196 }else if( pHint->pIdx!=0 ){
138197 pExpr->iTable = pHint->iIdxCur;
138198 pExpr->iColumn = sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn);
138199 assert( pExpr->iColumn>=0 );
138200 }
138201 }else if( pExpr->op==TK_AGG_FUNCTION ){
138202 /* An aggregate function in the WHERE clause of a query means this must
138203 ** be a correlated sub-query, and expression pExpr is an aggregate from
@@ -138356,12 +139415,16 @@
138356 Table *pTab = pIdx->pTable;
138357 int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));
138358 if( ai ){
138359 ai[0] = pTab->nCol;
138360 for(i=0; i<pIdx->nColumn-1; i++){
 
138361 assert( pIdx->aiColumn[i]<pTab->nCol );
138362 if( pIdx->aiColumn[i]>=0 ) ai[pIdx->aiColumn[i]+1] = i+1;
 
 
 
138363 }
138364 sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY);
138365 }
138366 }
138367 }
@@ -138408,10 +139471,11 @@
138408 typedef struct IdxExprTrans {
138409 Expr *pIdxExpr; /* The index expression */
138410 int iTabCur; /* The cursor of the corresponding table */
138411 int iIdxCur; /* The cursor for the index */
138412 int iIdxCol; /* The column for the index */
 
138413 } IdxExprTrans;
138414
138415 /* The walker node callback used to transform matching expressions into
138416 ** a reference to an index column for an index on an expression.
138417 **
@@ -138430,37 +139494,73 @@
138430 }else{
138431 return WRC_Continue;
138432 }
138433 }
138434
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138435 /*
138436 ** For an indexes on expression X, locate every instance of expression X
138437 ** in pExpr and change that subexpression into a reference to the appropriate
138438 ** column of the index.
 
 
 
 
138439 */
138440 static void whereIndexExprTrans(
138441 Index *pIdx, /* The Index */
138442 int iTabCur, /* Cursor of the table that is being indexed */
138443 int iIdxCur, /* Cursor of the index itself */
138444 WhereInfo *pWInfo /* Transform expressions in this WHERE clause */
138445 ){
138446 int iIdxCol; /* Column number of the index */
138447 ExprList *aColExpr; /* Expressions that are indexed */
 
138448 Walker w;
138449 IdxExprTrans x;
138450 aColExpr = pIdx->aColExpr;
138451 if( aColExpr==0 ) return; /* Not an index on expressions */
 
 
 
 
 
138452 memset(&w, 0, sizeof(w));
138453 w.xExprCallback = whereIndexExprTransNode;
138454 w.u.pIdxTrans = &x;
138455 x.iTabCur = iTabCur;
138456 x.iIdxCur = iIdxCur;
138457 for(iIdxCol=0; iIdxCol<aColExpr->nExpr; iIdxCol++){
138458 if( pIdx->aiColumn[iIdxCol]!=XN_EXPR ) continue;
138459 assert( aColExpr->a[iIdxCol].pExpr!=0 );
 
 
 
 
 
 
 
 
 
 
 
138460 x.iIdxCol = iIdxCol;
138461 x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;
138462 sqlite3WalkExpr(&w, pWInfo->pWhere);
138463 sqlite3WalkExprList(&w, pWInfo->pOrderBy);
138464 sqlite3WalkExprList(&w, pWInfo->pResultSet);
138465 }
138466 }
@@ -138607,13 +139707,16 @@
138607 pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;
138608 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
138609 iIn = pLevel->u.in.nIn;
138610 for(j=nConstraint-1; j>=0; j--){
138611 pTerm = pLoop->aLTerm[j];
 
138612 if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
138613 disableTerm(pLevel, pTerm);
138614 }else if( (pTerm->eOperator & WO_IN)!=0 ){
 
 
138615 Expr *pCompare; /* The comparison operator */
138616 Expr *pRight; /* RHS of the comparison */
138617 VdbeOp *pOp; /* Opcode to access the value of the IN constraint */
138618
138619 /* Reload the constraint value into reg[iReg+j+2]. The same value
@@ -138620,12 +139723,12 @@
138620 ** was loaded into the same register prior to the OP_VFilter, but
138621 ** the xFilter implementation might have changed the datatype or
138622 ** encoding of the value in the register, so it *must* be reloaded. */
138623 assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );
138624 if( !db->mallocFailed ){
138625 assert( iIn>0 );
138626 pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[--iIn].addrInTop);
138627 assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );
138628 assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );
138629 assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );
138630 testcase( pOp->opcode==OP_Rowid );
138631 sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
@@ -138645,10 +139748,11 @@
138645 pCompare->pLeft = 0;
138646 sqlite3ExprDelete(db, pCompare);
138647 }
138648 }
138649 }
 
138650 /* These registers need to be preserved in case there is an IN operator
138651 ** loop. So we could deallocate the registers here (and potentially
138652 ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems
138653 ** simpler and safer to simply not reuse the registers.
138654 **
@@ -139124,44 +140228,57 @@
139124 }
139125 }else if( iCur!=iIdxCur ){
139126 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
139127 iRowidReg = sqlite3GetTempRange(pParse, pPk->nKeyCol);
139128 for(j=0; j<pPk->nKeyCol; j++){
139129 k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);
139130 sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j);
139131 }
139132 sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,
139133 iRowidReg, pPk->nKeyCol); VdbeCoverage(v);
139134 }
139135
139136 /* If pIdx is an index on one or more expressions, then look through
139137 ** all the expressions in pWInfo and try to transform matching expressions
139138 ** into reference to index columns.
139139 **
139140 ** Do not do this for the RHS of a LEFT JOIN. This is because the
139141 ** expression may be evaluated after OP_NullRow has been executed on
139142 ** the cursor. In this case it is important to do the full evaluation,
139143 ** as the result of the expression may not be NULL, even if all table
139144 ** column values are. https://www.sqlite.org/src/info/7fa8049685b50b5a
139145 **
139146 ** Also, do not do this when processing one index an a multi-index
139147 ** OR clause, since the transformation will become invalid once we
139148 ** move forward to the next index.
139149 ** https://sqlite.org/src/info/4e8e4857d32d401f
139150 */
139151 if( pLevel->iLeftJoin==0 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){
139152 whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
139153 }
139154
139155 /* If a partial index is driving the loop, try to eliminate WHERE clause
139156 ** terms from the query that must be true due to the WHERE clause of
139157 ** the partial index
139158 */
139159 if( pIdx->pPartIdxWhere ){
139160 whereApplyPartialIndexConstraints(pIdx->pPartIdxWhere, iCur, pWC);
139161 }
139162
 
 
 
 
 
 
 
 
 
 
 
 
 
139163 /* Record the instruction used to terminate the loop. */
139164 if( pLoop->wsFlags & WHERE_ONEROW ){
139165 pLevel->op = OP_Noop;
139166 }else if( bRev ){
139167 pLevel->op = OP_Prev;
@@ -139384,11 +140501,11 @@
139384
139385 /* Read the PK into an array of temp registers. */
139386 r = sqlite3GetTempRange(pParse, nPk);
139387 for(iPk=0; iPk<nPk; iPk++){
139388 int iCol = pPk->aiColumn[iPk];
139389 sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol, r+iPk);
139390 }
139391
139392 /* Check if the temp table already contains this key. If so,
139393 ** the row has already been included in the result set and
139394 ** can be ignored (by jumping past the Gosub below). Otherwise,
@@ -139749,43 +140866,18 @@
139749 }
139750
139751 /*
139752 ** Commute a comparison operator. Expressions of the form "X op Y"
139753 ** are converted into "Y op X".
139754 **
139755 ** If left/right precedence rules come into play when determining the
139756 ** collating sequence, then COLLATE operators are adjusted to ensure
139757 ** that the collating sequence does not change. For example:
139758 ** "Y collate NOCASE op X" becomes "X op Y" because any collation sequence on
139759 ** the left hand side of a comparison overrides any collation sequence
139760 ** attached to the right. For the same reason the EP_Collate flag
139761 ** is not commuted.
139762 **
139763 ** The return value is extra flags that are added to the WhereTerm object
139764 ** after it is commuted. The only extra flag ever added is TERM_NOPARTIDX
139765 ** which prevents the term from being used to enable a partial index if
139766 ** COLLATE changes have been made.
139767 */
139768 static u16 exprCommute(Parse *pParse, Expr *pExpr){
139769 u16 expRight = (pExpr->pRight->flags & EP_Collate);
139770 u16 expLeft = (pExpr->pLeft->flags & EP_Collate);
139771 u16 wtFlags = 0;
139772 assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );
139773 if( expRight==expLeft ){
139774 /* Either X and Y both have COLLATE operator or neither do */
139775 if( expRight ){
139776 /* Both X and Y have COLLATE operators. Make sure X is always
139777 ** used by clearing the EP_Collate flag from Y. */
139778 pExpr->pRight->flags &= ~EP_Collate;
139779 wtFlags |= TERM_NOPARTIDX;
139780 }else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){
139781 /* Neither X nor Y have COLLATE operators, but X has a non-default
139782 ** collating sequence. So add the EP_Collate marker on X to cause
139783 ** it to be searched first. */
139784 pExpr->pLeft->flags |= EP_Collate;
139785 wtFlags |= TERM_NOPARTIDX;
139786 }
139787 }
139788 SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
139789 if( pExpr->op>=TK_GT ){
139790 assert( TK_LT==TK_GT+2 );
139791 assert( TK_GE==TK_LE+2 );
@@ -139792,11 +140884,11 @@
139792 assert( TK_GT>TK_EQ );
139793 assert( TK_GT<TK_LE );
139794 assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );
139795 pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;
139796 }
139797 return wtFlags;
139798 }
139799
139800 /*
139801 ** Translate from TK_xx operator to WO_xx bitmask.
139802 */
@@ -140570,11 +141662,11 @@
140570 if( aff1!=aff2
140571 && (!sqlite3IsNumericAffinity(aff1) || !sqlite3IsNumericAffinity(aff2))
140572 ){
140573 return 0;
140574 }
140575 pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);
140576 if( sqlite3IsBinary(pColl) ) return 1;
140577 return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight);
140578 }
140579
140580 /*
@@ -141259,10 +142351,13 @@
141259 pColRef->iColumn = k++;
141260 pColRef->y.pTab = pTab;
141261 pRhs = sqlite3PExpr(pParse, TK_UPLUS,
141262 sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);
141263 pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);
 
 
 
141264 whereClauseInsert(pWC, pTerm, TERM_DYNAMIC);
141265 }
141266 }
141267
141268 /************** End of whereexpr.c *******************************************/
@@ -141546,12 +142641,11 @@
141546 pX = pTerm->pExpr;
141547 if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){
141548 continue;
141549 }
141550 assert(pX->pLeft);
141551 pColl = sqlite3BinaryCompareCollSeq(pParse,
141552 pX->pLeft, pX->pRight);
141553 if( pColl==0 ) pColl = pParse->db->pDfltColl;
141554 if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){
141555 continue;
141556 }
141557 }
@@ -142068,12 +143162,12 @@
142068 testcase( iCol==BMS );
142069 if( (idxCols & cMask)==0 ){
142070 Expr *pX = pTerm->pExpr;
142071 idxCols |= cMask;
142072 pIdx->aiColumn[n] = pTerm->u.leftColumn;
142073 pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
142074 pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
142075 n++;
142076 }
142077 }
142078 }
142079 assert( (u32)n==pLoop->u.btree.nEq );
@@ -144069,11 +145163,10 @@
144069 pWhere = pWhere->pRight;
144070 }
144071 if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
144072 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
144073 Expr *pExpr;
144074 if( pTerm->wtFlags & TERM_NOPARTIDX ) continue;
144075 pExpr = pTerm->pExpr;
144076 if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
144077 && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
144078 ){
144079 return 1;
@@ -144532,11 +145625,11 @@
144532 if( iCons>=0 && iCons<pIdxInfo->nConstraint ){
144533 CollSeq *pC = 0;
144534 int iTerm = pIdxInfo->aConstraint[iCons].iTermOffset;
144535 Expr *pX = pHidden->pWC->a[iTerm].pExpr;
144536 if( pX->pLeft ){
144537 pC = sqlite3BinaryCompareCollSeq(pHidden->pParse, pX->pLeft, pX->pRight);
144538 }
144539 zRet = (pC ? pC->zName : sqlite3StrBINARY);
144540 }
144541 return zRet;
144542 }
@@ -144965,11 +146058,13 @@
144965 if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue;
144966 }else{
144967 pLoop = pLast;
144968 }
144969 if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
144970 if( pLoop->u.vtab.isOrdered ) obSat = obDone;
 
 
144971 break;
144972 }else if( wctrlFlags & WHERE_DISTINCTBY ){
144973 pLoop->u.btree.nDistinctCol = 0;
144974 }
144975 iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
@@ -146283,11 +147378,17 @@
146283 };
146284 sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op);
146285 assert( pTabItem->iCursor==pLevel->iTabCur );
146286 testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS-1 );
146287 testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS );
146288 if( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol<BMS && HasRowid(pTab) ){
 
 
 
 
 
 
146289 Bitmask b = pTabItem->colUsed;
146290 int n = 0;
146291 for(; b; b=b>>1, n++){}
146292 sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(n), P4_INT32);
146293 assert( n<=pTab->nCol );
@@ -146645,12 +147746,15 @@
146645 assert( pIdx->pTable==pTab );
146646 if( !HasRowid(pTab) ){
146647 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
146648 x = pPk->aiColumn[x];
146649 assert( x>=0 );
 
 
 
146650 }
146651 x = sqlite3ColumnOfIndex(pIdx, x);
146652 if( x>=0 ){
146653 pOp->p2 = x;
146654 pOp->p1 = pLevel->iIdxCur;
146655 OpcodeRewriteTrace(db, k, pOp);
146656 }
@@ -147583,11 +148687,11 @@
147583 ** are invoked in the correct order as described under "SELECT REWRITING"
147584 ** at the top of this file.
147585 */
147586 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
147587 int rc = SQLITE_OK;
147588 if( p->pWin && p->pPrior==0 ){
147589 Vdbe *v = sqlite3GetVdbe(pParse);
147590 sqlite3 *db = pParse->db;
147591 Select *pSub = 0; /* The subquery */
147592 SrcList *pSrc = p->pSrc;
147593 Expr *pWhere = p->pWhere;
@@ -147608,10 +148712,11 @@
147608 p->pSrc = 0;
147609 p->pWhere = 0;
147610 p->pGroupBy = 0;
147611 p->pHaving = 0;
147612 p->selFlags &= ~SF_Aggregate;
 
147613
147614 /* Create the ORDER BY clause for the sub-select. This is the concatenation
147615 ** of the window PARTITION and ORDER BY clauses. Then, if this makes it
147616 ** redundant, remove the ORDER BY from the parent SELECT. */
147617 pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);
@@ -147923,12 +149028,12 @@
147923 ** to be processed as part of SELECT statement pSel). The window is linked
147924 ** in if either (a) there are no other windows already linked to this
147925 ** SELECT, or (b) the windows already linked use a compatible window frame.
147926 */
147927 SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin){
147928 if( 0==pSel->pWin
147929 || 0==sqlite3WindowCompare(0, pSel->pWin, pWin, 0)
147930 ){
147931 pWin->pNextWin = pSel->pWin;
147932 if( pSel->pWin ){
147933 pSel->pWin->ppThis = &pWin->pNextWin;
147934 }
@@ -149725,12 +150830,13 @@
149725 /*
149726 ** Disable lookaside memory allocation for objects that might be
149727 ** shared across database connections.
149728 */
149729 static void disableLookaside(Parse *pParse){
 
149730 pParse->disableLookaside++;
149731 pParse->db->lookaside.bDisable++;
149732 }
149733
149734
149735 /*
149736 ** For a compound SELECT statement, make sure p->pPrior->pNext==p for
@@ -149890,32 +150996,32 @@
149890 #ifndef INTERFACE
149891 # define INTERFACE 1
149892 #endif
149893 /************* Begin control #defines *****************************************/
149894 #define YYCODETYPE unsigned short int
149895 #define YYNOCODE 307
149896 #define YYACTIONTYPE unsigned short int
149897 #define YYWILDCARD 98
149898 #define sqlite3ParserTOKENTYPE Token
149899 typedef union {
149900 int yyinit;
149901 sqlite3ParserTOKENTYPE yy0;
149902 const char* yy8;
149903 Select* yy25;
149904 int yy32;
149905 Expr* yy46;
149906 struct FrameBound yy57;
149907 u8 yy118;
149908 ExprList* yy138;
149909 Upsert* yy288;
149910 With* yy297;
149911 IdList* yy406;
149912 Window* yy455;
149913 struct {int value; int mask;} yy495;
149914 TriggerStep* yy527;
149915 struct TrigEvent yy572;
149916 SrcList* yy609;
149917 } YYMINORTYPE;
149918 #ifndef YYSTACKDEPTH
149919 #define YYSTACKDEPTH 100
149920 #endif
149921 #define sqlite3ParserARG_SDECL
@@ -149927,21 +151033,21 @@
149927 #define sqlite3ParserCTX_PDECL ,Parse *pParse
149928 #define sqlite3ParserCTX_PARAM ,pParse
149929 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
149930 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
149931 #define YYFALLBACK 1
149932 #define YYNSTATE 543
149933 #define YYNRULE 381
149934 #define YYNTOKEN 179
149935 #define YY_MAX_SHIFT 542
149936 #define YY_MIN_SHIFTREDUCE 790
149937 #define YY_MAX_SHIFTREDUCE 1170
149938 #define YY_ERROR_ACTION 1171
149939 #define YY_ACCEPT_ACTION 1172
149940 #define YY_NO_ACTION 1173
149941 #define YY_MIN_REDUCE 1174
149942 #define YY_MAX_REDUCE 1554
149943 /************* End control #defines *******************************************/
149944 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
149945
149946 /* Define the yytestcase() macro to be a no-op if is not already defined
149947 ** otherwise.
@@ -150004,577 +151110,585 @@
150004 ** yy_reduce_ofst[] For each state, the offset into yy_action for
150005 ** shifting non-terminals after a reduce.
150006 ** yy_default[] Default action for each state.
150007 **
150008 *********** Begin parsing tables **********************************************/
150009 #define YY_ACTTAB_COUNT (1913)
150010 static const YYACTIONTYPE yy_action[] = {
150011 /* 0 */ 537, 339, 537, 1241, 1220, 537, 12, 537, 112, 109,
150012 /* 10 */ 209, 537, 1241, 537, 1205, 462, 112, 109, 209, 386,
150013 /* 20 */ 338, 462, 42, 42, 42, 42, 445, 42, 42, 70,
150014 /* 30 */ 70, 922, 1208, 70, 70, 70, 70, 1443, 403, 923,
150015 /* 40 */ 531, 531, 531, 119, 120, 110, 1148, 1148, 991, 994,
150016 /* 50 */ 984, 984, 117, 117, 118, 118, 118, 118, 425, 386,
150017 /* 60 */ 1498, 542, 2, 1176, 1442, 519, 141, 1518, 289, 519,
150018 /* 70 */ 134, 519, 95, 259, 495, 1215, 189, 1254, 518, 494,
150019 /* 80 */ 484, 437, 296, 119, 120, 110, 1148, 1148, 991, 994,
150020 /* 90 */ 984, 984, 117, 117, 118, 118, 118, 118, 270, 116,
150021 /* 100 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
150022 /* 110 */ 264, 264, 264, 264, 423, 1479, 352, 1481, 123, 351,
150023 /* 120 */ 1479, 508, 1094, 534, 1034, 534, 1099, 386, 1099, 239,
150024 /* 130 */ 206, 112, 109, 209, 96, 1094, 376, 219, 1094, 116,
150025 /* 140 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
150026 /* 150 */ 480, 119, 120, 110, 1148, 1148, 991, 994, 984, 984,
150027 /* 160 */ 117, 117, 118, 118, 118, 118, 353, 422, 1407, 264,
150028 /* 170 */ 264, 114, 114, 114, 113, 418, 883, 121, 416, 416,
150029 /* 180 */ 416, 882, 534, 116, 116, 116, 116, 115, 115, 114,
150030 /* 190 */ 114, 114, 113, 418, 212, 415, 414, 386, 443, 383,
150031 /* 200 */ 382, 118, 118, 118, 118, 111, 177, 116, 116, 116,
150032 /* 210 */ 116, 115, 115, 114, 114, 114, 113, 418, 112, 109,
150033 /* 220 */ 209, 119, 120, 110, 1148, 1148, 991, 994, 984, 984,
150034 /* 230 */ 117, 117, 118, 118, 118, 118, 386, 438, 312, 1163,
150035 /* 240 */ 1155, 80, 1155, 1127, 514, 79, 116, 116, 116, 116,
150036 /* 250 */ 115, 115, 114, 114, 114, 113, 418, 514, 428, 418,
150037 /* 260 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
150038 /* 270 */ 117, 118, 118, 118, 118, 428, 427, 116, 116, 116,
150039 /* 280 */ 116, 115, 115, 114, 114, 114, 113, 418, 115, 115,
150040 /* 290 */ 114, 114, 114, 113, 418, 1127, 1127, 1128, 1129, 1094,
150041 /* 300 */ 258, 258, 192, 386, 408, 371, 1168, 326, 118, 118,
150042 /* 310 */ 118, 118, 1094, 534, 374, 1094, 116, 116, 116, 116,
150043 /* 320 */ 115, 115, 114, 114, 114, 113, 418, 119, 120, 110,
150044 /* 330 */ 1148, 1148, 991, 994, 984, 984, 117, 117, 118, 118,
150045 /* 340 */ 118, 118, 386, 354, 445, 428, 829, 238, 1127, 1128,
150046 /* 350 */ 1129, 515, 1466, 116, 116, 116, 116, 115, 115, 114,
150047 /* 360 */ 114, 114, 113, 418, 1127, 1467, 119, 120, 110, 1148,
150048 /* 370 */ 1148, 991, 994, 984, 984, 117, 117, 118, 118, 118,
150049 /* 380 */ 118, 1169, 82, 116, 116, 116, 116, 115, 115, 114,
150050 /* 390 */ 114, 114, 113, 418, 405, 112, 109, 209, 161, 445,
150051 /* 400 */ 250, 267, 336, 478, 331, 477, 236, 951, 1127, 386,
150052 /* 410 */ 888, 1521, 329, 822, 852, 162, 274, 1127, 1128, 1129,
150053 /* 420 */ 338, 169, 116, 116, 116, 116, 115, 115, 114, 114,
150054 /* 430 */ 114, 113, 418, 119, 120, 110, 1148, 1148, 991, 994,
150055 /* 440 */ 984, 984, 117, 117, 118, 118, 118, 118, 386, 438,
150056 /* 450 */ 312, 1502, 1112, 1176, 161, 288, 528, 311, 289, 883,
150057 /* 460 */ 134, 1127, 1128, 1129, 882, 537, 143, 1254, 288, 528,
150058 /* 470 */ 297, 275, 119, 120, 110, 1148, 1148, 991, 994, 984,
150059 /* 480 */ 984, 117, 117, 118, 118, 118, 118, 70, 70, 116,
150060 /* 490 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
150061 /* 500 */ 264, 264, 12, 264, 264, 395, 1127, 483, 1473, 1094,
150062 /* 510 */ 204, 482, 6, 534, 1258, 386, 534, 1474, 825, 972,
150063 /* 520 */ 504, 6, 1094, 500, 95, 1094, 534, 219, 116, 116,
150064 /* 530 */ 116, 116, 115, 115, 114, 114, 114, 113, 418, 119,
150065 /* 540 */ 120, 110, 1148, 1148, 991, 994, 984, 984, 117, 117,
150066 /* 550 */ 118, 118, 118, 118, 386, 1339, 971, 422, 956, 1127,
150067 /* 560 */ 1128, 1129, 231, 512, 1473, 475, 472, 471, 6, 113,
150068 /* 570 */ 418, 825, 962, 298, 503, 470, 961, 452, 119, 120,
150069 /* 580 */ 110, 1148, 1148, 991, 994, 984, 984, 117, 117, 118,
150070 /* 590 */ 118, 118, 118, 395, 537, 116, 116, 116, 116, 115,
150071 /* 600 */ 115, 114, 114, 114, 113, 418, 202, 961, 961, 963,
150072 /* 610 */ 231, 971, 1127, 475, 472, 471, 13, 13, 951, 1127,
150073 /* 620 */ 834, 386, 1207, 470, 399, 183, 447, 962, 462, 162,
150074 /* 630 */ 397, 961, 1246, 1246, 116, 116, 116, 116, 115, 115,
150075 /* 640 */ 114, 114, 114, 113, 418, 119, 120, 110, 1148, 1148,
150076 /* 650 */ 991, 994, 984, 984, 117, 117, 118, 118, 118, 118,
150077 /* 660 */ 386, 271, 961, 961, 963, 1127, 1128, 1129, 311, 433,
150078 /* 670 */ 299, 1406, 1127, 1128, 1129, 178, 1471, 138, 162, 32,
150079 /* 680 */ 6, 1127, 288, 528, 119, 120, 110, 1148, 1148, 991,
150080 /* 690 */ 994, 984, 984, 117, 117, 118, 118, 118, 118, 909,
150081 /* 700 */ 390, 116, 116, 116, 116, 115, 115, 114, 114, 114,
150082 /* 710 */ 113, 418, 1127, 429, 817, 537, 1127, 265, 265, 981,
150083 /* 720 */ 981, 992, 995, 324, 1055, 93, 520, 5, 338, 537,
150084 /* 730 */ 534, 288, 528, 1522, 1127, 1128, 1129, 70, 70, 1056,
150085 /* 740 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
150086 /* 750 */ 418, 70, 70, 1495, 1057, 537, 98, 1244, 1244, 264,
150087 /* 760 */ 264, 908, 371, 1076, 1127, 1127, 1128, 1129, 817, 1127,
150088 /* 770 */ 1128, 1129, 534, 519, 140, 863, 386, 13, 13, 456,
150089 /* 780 */ 192, 193, 521, 453, 319, 864, 322, 284, 365, 430,
150090 /* 790 */ 985, 402, 379, 1077, 1548, 101, 386, 1548, 3, 395,
150091 /* 800 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
150092 /* 810 */ 117, 118, 118, 118, 118, 386, 451, 1127, 1128, 1129,
150093 /* 820 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
150094 /* 830 */ 117, 118, 118, 118, 118, 1127, 1354, 1412, 1169, 119,
150095 /* 840 */ 108, 110, 1148, 1148, 991, 994, 984, 984, 117, 117,
150096 /* 850 */ 118, 118, 118, 118, 1412, 1414, 116, 116, 116, 116,
150097 /* 860 */ 115, 115, 114, 114, 114, 113, 418, 272, 535, 1075,
150098 /* 870 */ 877, 877, 337, 1492, 309, 462, 116, 116, 116, 116,
150099 /* 880 */ 115, 115, 114, 114, 114, 113, 418, 537, 1127, 1128,
150100 /* 890 */ 1129, 537, 360, 537, 356, 116, 116, 116, 116, 115,
150101 /* 900 */ 115, 114, 114, 114, 113, 418, 386, 264, 264, 13,
150102 /* 910 */ 13, 273, 1127, 13, 13, 13, 13, 304, 1253, 386,
150103 /* 920 */ 534, 1077, 1549, 404, 1412, 1549, 496, 277, 451, 186,
150104 /* 930 */ 1252, 120, 110, 1148, 1148, 991, 994, 984, 984, 117,
150105 /* 940 */ 117, 118, 118, 118, 118, 110, 1148, 1148, 991, 994,
150106 /* 950 */ 984, 984, 117, 117, 118, 118, 118, 118, 105, 529,
150107 /* 960 */ 537, 4, 1339, 264, 264, 1127, 1128, 1129, 1039, 1039,
150108 /* 970 */ 459, 795, 796, 797, 536, 532, 534, 242, 301, 807,
150109 /* 980 */ 303, 462, 69, 69, 451, 1353, 116, 116, 116, 116,
150110 /* 990 */ 115, 115, 114, 114, 114, 113, 418, 1075, 419, 116,
150111 /* 1000 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418,
150112 /* 1010 */ 526, 537, 1146, 192, 350, 105, 529, 537, 4, 497,
150113 /* 1020 */ 162, 337, 1492, 310, 1249, 385, 1550, 372, 9, 462,
150114 /* 1030 */ 242, 400, 532, 13, 13, 499, 971, 843, 436, 70,
150115 /* 1040 */ 70, 359, 103, 103, 8, 339, 278, 187, 278, 104,
150116 /* 1050 */ 1127, 419, 539, 538, 1339, 419, 961, 302, 1339, 1172,
150117 /* 1060 */ 1, 1, 542, 2, 1176, 1146, 1146, 526, 476, 289,
150118 /* 1070 */ 30, 134, 317, 288, 528, 285, 844, 1014, 1254, 276,
150119 /* 1080 */ 1472, 506, 410, 1194, 6, 207, 505, 961, 961, 963,
150120 /* 1090 */ 964, 27, 449, 971, 415, 414, 234, 233, 232, 103,
150121 /* 1100 */ 103, 31, 1152, 1127, 1128, 1129, 104, 1154, 419, 539,
150122 /* 1110 */ 538, 264, 264, 961, 1399, 1153, 264, 264, 1470, 1146,
150123 /* 1120 */ 537, 216, 6, 401, 534, 1197, 392, 458, 406, 534,
150124 /* 1130 */ 537, 485, 358, 537, 261, 537, 1339, 907, 219, 1155,
150125 /* 1140 */ 467, 1155, 50, 50, 961, 961, 963, 964, 27, 1497,
150126 /* 1150 */ 1116, 421, 70, 70, 268, 70, 70, 13, 13, 369,
150127 /* 1160 */ 369, 368, 253, 366, 264, 264, 804, 235, 422, 105,
150128 /* 1170 */ 529, 516, 4, 287, 487, 510, 493, 534, 486, 213,
150129 /* 1180 */ 1055, 294, 490, 384, 1127, 450, 532, 338, 413, 293,
150130 /* 1190 */ 522, 417, 335, 1036, 509, 1056, 107, 1036, 16, 16,
150131 /* 1200 */ 1469, 1094, 334, 1105, 6, 411, 1145, 264, 264, 419,
150132 /* 1210 */ 1057, 102, 511, 100, 1094, 264, 264, 1094, 922, 215,
150133 /* 1220 */ 534, 526, 907, 264, 264, 208, 923, 154, 534, 457,
150134 /* 1230 */ 156, 525, 391, 142, 218, 506, 534, 1127, 1128, 1129,
150135 /* 1240 */ 507, 139, 1131, 38, 214, 530, 392, 971, 329, 1454,
150136 /* 1250 */ 907, 1105, 537, 103, 103, 105, 529, 537, 4, 537,
150137 /* 1260 */ 104, 424, 419, 539, 538, 537, 502, 961, 517, 537,
150138 /* 1270 */ 1072, 537, 532, 373, 54, 54, 288, 528, 387, 55,
150139 /* 1280 */ 55, 15, 15, 288, 528, 17, 136, 44, 44, 1451,
150140 /* 1290 */ 537, 56, 56, 57, 57, 419, 1131, 291, 961, 961,
150141 /* 1300 */ 963, 964, 27, 393, 163, 537, 426, 526, 263, 206,
150142 /* 1310 */ 208, 517, 58, 58, 235, 440, 842, 841, 197, 105,
150143 /* 1320 */ 529, 506, 4, 1033, 439, 1033, 505, 59, 59, 308,
150144 /* 1330 */ 849, 850, 95, 971, 537, 907, 532, 948, 832, 103,
150145 /* 1340 */ 103, 105, 529, 537, 4, 1021, 104, 537, 419, 539,
150146 /* 1350 */ 538, 1116, 421, 961, 537, 268, 60, 60, 532, 419,
150147 /* 1360 */ 369, 369, 368, 253, 366, 61, 61, 804, 965, 45,
150148 /* 1370 */ 45, 526, 537, 1032, 1277, 1032, 46, 46, 537, 391,
150149 /* 1380 */ 213, 419, 294, 266, 961, 961, 963, 964, 27, 292,
150150 /* 1390 */ 293, 295, 832, 526, 48, 48, 1290, 971, 1289, 1021,
150151 /* 1400 */ 49, 49, 432, 103, 103, 887, 953, 537, 1457, 241,
150152 /* 1410 */ 104, 305, 419, 539, 538, 925, 926, 961, 444, 971,
150153 /* 1420 */ 215, 241, 965, 1224, 537, 103, 103, 1431, 154, 62,
150154 /* 1430 */ 62, 156, 104, 1430, 419, 539, 538, 97, 529, 961,
150155 /* 1440 */ 4, 537, 454, 537, 314, 214, 63, 63, 961, 961,
150156 /* 1450 */ 963, 964, 27, 537, 532, 446, 1286, 318, 241, 537,
150157 /* 1460 */ 321, 323, 325, 64, 64, 14, 14, 1237, 537, 1223,
150158 /* 1470 */ 961, 961, 963, 964, 27, 65, 65, 419, 537, 387,
150159 /* 1480 */ 537, 125, 125, 537, 288, 528, 537, 1486, 537, 526,
150160 /* 1490 */ 66, 66, 313, 524, 537, 95, 468, 1221, 1511, 237,
150161 /* 1500 */ 51, 51, 67, 67, 330, 68, 68, 426, 52, 52,
150162 /* 1510 */ 149, 149, 1222, 340, 341, 971, 150, 150, 1298, 463,
150163 /* 1520 */ 327, 103, 103, 95, 537, 1338, 1273, 537, 104, 537,
150164 /* 1530 */ 419, 539, 538, 1284, 537, 961, 268, 283, 523, 1344,
150165 /* 1540 */ 1204, 369, 369, 368, 253, 366, 75, 75, 804, 53,
150166 /* 1550 */ 53, 71, 71, 537, 1196, 537, 126, 126, 537, 1017,
150167 /* 1560 */ 537, 213, 237, 294, 537, 1185, 961, 961, 963, 964,
150168 /* 1570 */ 27, 293, 537, 1184, 537, 72, 72, 127, 127, 1186,
150169 /* 1580 */ 128, 128, 124, 124, 1505, 537, 148, 148, 537, 256,
150170 /* 1590 */ 195, 537, 1270, 537, 147, 147, 132, 132, 537, 11,
150171 /* 1600 */ 537, 215, 537, 199, 343, 345, 347, 131, 131, 154,
150172 /* 1610 */ 129, 129, 156, 130, 130, 74, 74, 537, 370, 1323,
150173 /* 1620 */ 76, 76, 73, 73, 43, 43, 214, 431, 211, 1331,
150174 /* 1630 */ 300, 916, 880, 815, 241, 107, 137, 307, 881, 47,
150175 /* 1640 */ 47, 107, 473, 378, 203, 448, 333, 1403, 1220, 1402,
150176 /* 1650 */ 349, 190, 527, 191, 363, 198, 1508, 1163, 245, 165,
150177 /* 1660 */ 387, 1450, 1448, 1160, 78, 288, 528, 1408, 81, 394,
150178 /* 1670 */ 82, 442, 175, 159, 167, 93, 1328, 35, 1320, 434,
150179 /* 1680 */ 170, 171, 172, 173, 435, 466, 221, 375, 426, 377,
150180 /* 1690 */ 1334, 179, 455, 441, 1397, 225, 87, 36, 461, 1419,
150181 /* 1700 */ 316, 257, 227, 184, 320, 464, 228, 479, 1187, 229,
150182 /* 1710 */ 380, 1240, 1239, 407, 1238, 1212, 834, 332, 1231, 381,
150183 /* 1720 */ 409, 1211, 204, 1210, 1491, 498, 1520, 1281, 92, 281,
150184 /* 1730 */ 1230, 489, 282, 492, 342, 243, 1282, 344, 244, 1280,
150185 /* 1740 */ 346, 412, 1279, 1477, 348, 122, 1476, 517, 10, 357,
150186 /* 1750 */ 286, 1305, 1304, 99, 1383, 94, 501, 251, 1193, 34,
150187 /* 1760 */ 1263, 355, 540, 194, 1262, 361, 362, 1122, 252, 254,
150188 /* 1770 */ 255, 388, 541, 1182, 1177, 151, 1435, 389, 1436, 1434,
150189 /* 1780 */ 1433, 791, 152, 135, 279, 200, 201, 420, 196, 77,
150190 /* 1790 */ 153, 290, 269, 210, 1031, 133, 1029, 945, 166, 155,
150191 /* 1800 */ 217, 168, 866, 306, 220, 1045, 174, 949, 157, 396,
150192 /* 1810 */ 83, 398, 176, 84, 85, 164, 86, 158, 1048, 222,
150193 /* 1820 */ 223, 1044, 144, 18, 224, 315, 1037, 180, 241, 460,
150194 /* 1830 */ 1157, 226, 181, 37, 806, 465, 334, 230, 328, 469,
150195 /* 1840 */ 182, 88, 474, 19, 20, 160, 89, 280, 145, 90,
150196 /* 1850 */ 481, 845, 1110, 146, 997, 205, 1080, 39, 91, 40,
150197 /* 1860 */ 488, 1081, 915, 491, 260, 262, 185, 910, 240, 107,
150198 /* 1870 */ 1100, 1096, 1098, 1104, 21, 1084, 33, 513, 247, 22,
150199 /* 1880 */ 23, 24, 1103, 25, 188, 95, 1012, 998, 996, 26,
150200 /* 1890 */ 1000, 1054, 7, 1053, 1001, 246, 28, 41, 533, 966,
150201 /* 1900 */ 816, 106, 29, 367, 248, 249, 1513, 1512, 364, 1117,
150202 /* 1910 */ 1173, 1173, 876,
 
 
 
 
150203 };
150204 static const YYCODETYPE yy_lookahead[] = {
150205 /* 0 */ 187, 187, 187, 216, 217, 187, 206, 187, 264, 265,
150206 /* 10 */ 266, 187, 225, 187, 209, 187, 264, 265, 266, 19,
150207 /* 20 */ 187, 187, 209, 210, 209, 210, 187, 209, 210, 209,
150208 /* 30 */ 210, 31, 209, 209, 210, 209, 210, 285, 224, 39,
150209 /* 40 */ 203, 204, 205, 43, 44, 45, 46, 47, 48, 49,
150210 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 230, 19,
150211 /* 60 */ 181, 182, 183, 184, 230, 245, 233, 208, 189, 245,
150212 /* 70 */ 191, 245, 26, 206, 254, 216, 276, 198, 254, 198,
150213 /* 80 */ 254, 281, 187, 43, 44, 45, 46, 47, 48, 49,
150214 /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 259, 99,
150215 /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150216 /* 110 */ 231, 232, 231, 232, 286, 302, 303, 302, 22, 304,
150217 /* 120 */ 302, 303, 76, 244, 11, 244, 86, 19, 88, 248,
150218 /* 130 */ 249, 264, 265, 266, 26, 89, 198, 258, 92, 99,
150219 /* 140 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150220 /* 150 */ 105, 43, 44, 45, 46, 47, 48, 49, 50, 51,
150221 /* 160 */ 52, 53, 54, 55, 56, 57, 212, 288, 273, 231,
150222 /* 170 */ 232, 105, 106, 107, 108, 109, 131, 69, 203, 204,
150223 /* 180 */ 205, 136, 244, 99, 100, 101, 102, 103, 104, 105,
150224 /* 190 */ 106, 107, 108, 109, 15, 103, 104, 19, 260, 103,
150225 /* 200 */ 104, 54, 55, 56, 57, 58, 22, 99, 100, 101,
150226 /* 210 */ 102, 103, 104, 105, 106, 107, 108, 109, 264, 265,
150227 /* 220 */ 266, 43, 44, 45, 46, 47, 48, 49, 50, 51,
150228 /* 230 */ 52, 53, 54, 55, 56, 57, 19, 124, 125, 60,
150229 /* 240 */ 148, 24, 150, 59, 187, 67, 99, 100, 101, 102,
150230 /* 250 */ 103, 104, 105, 106, 107, 108, 109, 187, 187, 109,
150231 /* 260 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150232 /* 270 */ 53, 54, 55, 56, 57, 204, 205, 99, 100, 101,
150233 /* 280 */ 102, 103, 104, 105, 106, 107, 108, 109, 103, 104,
150234 /* 290 */ 105, 106, 107, 108, 109, 59, 112, 113, 114, 76,
150235 /* 300 */ 231, 232, 187, 19, 19, 22, 23, 23, 54, 55,
150236 /* 310 */ 56, 57, 89, 244, 199, 92, 99, 100, 101, 102,
150237 /* 320 */ 103, 104, 105, 106, 107, 108, 109, 43, 44, 45,
150238 /* 330 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
150239 /* 340 */ 56, 57, 19, 212, 187, 274, 23, 26, 112, 113,
150240 /* 350 */ 114, 294, 295, 99, 100, 101, 102, 103, 104, 105,
150241 /* 360 */ 106, 107, 108, 109, 59, 295, 43, 44, 45, 46,
150242 /* 370 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
150243 /* 380 */ 57, 98, 146, 99, 100, 101, 102, 103, 104, 105,
150244 /* 390 */ 106, 107, 108, 109, 109, 264, 265, 266, 187, 187,
150245 /* 400 */ 115, 116, 117, 118, 119, 120, 121, 73, 59, 19,
150246 /* 410 */ 105, 23, 127, 23, 26, 81, 259, 112, 113, 114,
150247 /* 420 */ 187, 72, 99, 100, 101, 102, 103, 104, 105, 106,
150248 /* 430 */ 107, 108, 109, 43, 44, 45, 46, 47, 48, 49,
150249 /* 440 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 124,
150250 /* 450 */ 125, 182, 23, 184, 187, 134, 135, 123, 189, 131,
150251 /* 460 */ 191, 112, 113, 114, 136, 187, 233, 198, 134, 135,
150252 /* 470 */ 198, 259, 43, 44, 45, 46, 47, 48, 49, 50,
150253 /* 480 */ 51, 52, 53, 54, 55, 56, 57, 209, 210, 99,
150254 /* 490 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150255 /* 500 */ 231, 232, 206, 231, 232, 187, 59, 296, 297, 76,
150256 /* 510 */ 160, 161, 301, 244, 232, 19, 244, 297, 59, 23,
150257 /* 520 */ 87, 301, 89, 245, 26, 92, 244, 258, 99, 100,
150258 /* 530 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 43,
150259 /* 540 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
150260 /* 550 */ 54, 55, 56, 57, 19, 187, 97, 288, 23, 112,
150261 /* 560 */ 113, 114, 115, 296, 297, 118, 119, 120, 301, 108,
150262 /* 570 */ 109, 112, 113, 255, 141, 128, 117, 281, 43, 44,
150263 /* 580 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
150264 /* 590 */ 55, 56, 57, 187, 187, 99, 100, 101, 102, 103,
150265 /* 600 */ 104, 105, 106, 107, 108, 109, 26, 148, 149, 150,
150266 /* 610 */ 115, 97, 59, 118, 119, 120, 209, 210, 73, 59,
150267 /* 620 */ 122, 19, 209, 128, 256, 72, 187, 113, 187, 81,
150268 /* 630 */ 223, 117, 227, 228, 99, 100, 101, 102, 103, 104,
150269 /* 640 */ 105, 106, 107, 108, 109, 43, 44, 45, 46, 47,
150270 /* 650 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
150271 /* 660 */ 19, 255, 148, 149, 150, 112, 113, 114, 123, 124,
150272 /* 670 */ 125, 230, 112, 113, 114, 22, 297, 22, 81, 22,
150273 /* 680 */ 301, 59, 134, 135, 43, 44, 45, 46, 47, 48,
150274 /* 690 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 139,
150275 /* 700 */ 192, 99, 100, 101, 102, 103, 104, 105, 106, 107,
150276 /* 710 */ 108, 109, 59, 116, 59, 187, 59, 231, 232, 46,
150277 /* 720 */ 47, 48, 49, 16, 12, 145, 198, 22, 187, 187,
150278 /* 730 */ 244, 134, 135, 222, 112, 113, 114, 209, 210, 27,
150279 /* 740 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
150280 /* 750 */ 109, 209, 210, 187, 42, 187, 154, 227, 228, 231,
150281 /* 760 */ 232, 139, 22, 23, 59, 112, 113, 114, 113, 112,
150282 /* 770 */ 113, 114, 244, 245, 233, 63, 19, 209, 210, 271,
150283 /* 780 */ 187, 24, 254, 275, 77, 73, 79, 245, 195, 260,
150284 /* 790 */ 117, 223, 199, 22, 23, 154, 19, 26, 22, 187,
150285 /* 800 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150286 /* 810 */ 53, 54, 55, 56, 57, 19, 187, 112, 113, 114,
150287 /* 820 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150288 /* 830 */ 53, 54, 55, 56, 57, 59, 263, 187, 98, 43,
150289 /* 840 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
150290 /* 850 */ 54, 55, 56, 57, 204, 205, 99, 100, 101, 102,
150291 /* 860 */ 103, 104, 105, 106, 107, 108, 109, 255, 130, 98,
150292 /* 870 */ 132, 133, 299, 300, 198, 187, 99, 100, 101, 102,
150293 /* 880 */ 103, 104, 105, 106, 107, 108, 109, 187, 112, 113,
150294 /* 890 */ 114, 187, 241, 187, 243, 99, 100, 101, 102, 103,
150295 /* 900 */ 104, 105, 106, 107, 108, 109, 19, 231, 232, 209,
150296 /* 910 */ 210, 282, 59, 209, 210, 209, 210, 16, 230, 19,
150297 /* 920 */ 244, 22, 23, 223, 274, 26, 19, 223, 187, 223,
150298 /* 930 */ 198, 44, 45, 46, 47, 48, 49, 50, 51, 52,
150299 /* 940 */ 53, 54, 55, 56, 57, 45, 46, 47, 48, 49,
150300 /* 950 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 20,
150301 /* 960 */ 187, 22, 187, 231, 232, 112, 113, 114, 123, 124,
150302 /* 970 */ 125, 7, 8, 9, 187, 36, 244, 24, 77, 21,
150303 /* 980 */ 79, 187, 209, 210, 187, 263, 99, 100, 101, 102,
150304 /* 990 */ 103, 104, 105, 106, 107, 108, 109, 98, 59, 99,
150305 /* 1000 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
150306 /* 1010 */ 71, 187, 59, 187, 187, 19, 20, 187, 22, 112,
150307 /* 1020 */ 81, 299, 300, 282, 230, 199, 291, 292, 22, 187,
150308 /* 1030 */ 24, 256, 36, 209, 210, 187, 97, 35, 80, 209,
150309 /* 1040 */ 210, 268, 103, 104, 48, 187, 220, 223, 222, 110,
150310 /* 1050 */ 59, 112, 113, 114, 187, 59, 117, 156, 187, 179,
150311 /* 1060 */ 180, 181, 182, 183, 184, 59, 113, 71, 66, 189,
150312 /* 1070 */ 22, 191, 230, 134, 135, 245, 74, 119, 198, 282,
150313 /* 1080 */ 297, 85, 224, 198, 301, 187, 90, 148, 149, 150,
150314 /* 1090 */ 151, 152, 19, 97, 103, 104, 123, 124, 125, 103,
150315 /* 1100 */ 104, 53, 111, 112, 113, 114, 110, 116, 112, 113,
150316 /* 1110 */ 114, 231, 232, 117, 156, 124, 231, 232, 297, 113,
150317 /* 1120 */ 187, 24, 301, 256, 244, 201, 202, 256, 126, 244,
150318 /* 1130 */ 187, 198, 187, 187, 23, 187, 187, 26, 258, 148,
150319 /* 1140 */ 19, 150, 209, 210, 148, 149, 150, 151, 152, 0,
150320 /* 1150 */ 1, 2, 209, 210, 5, 209, 210, 209, 210, 10,
150321 /* 1160 */ 11, 12, 13, 14, 231, 232, 17, 46, 288, 19,
150322 /* 1170 */ 20, 223, 22, 236, 198, 66, 187, 244, 245, 30,
150323 /* 1180 */ 12, 32, 198, 246, 59, 112, 36, 187, 245, 40,
150324 /* 1190 */ 198, 245, 117, 29, 85, 27, 26, 33, 209, 210,
150325 /* 1200 */ 297, 76, 127, 94, 301, 256, 26, 231, 232, 59,
150326 /* 1210 */ 42, 153, 87, 155, 89, 231, 232, 92, 31, 70,
150327 /* 1220 */ 244, 71, 26, 231, 232, 114, 39, 78, 244, 65,
150328 /* 1230 */ 81, 63, 111, 233, 137, 85, 244, 112, 113, 114,
150329 /* 1240 */ 90, 22, 59, 24, 95, 201, 202, 97, 127, 187,
150330 /* 1250 */ 139, 142, 187, 103, 104, 19, 20, 187, 22, 187,
150331 /* 1260 */ 110, 187, 112, 113, 114, 187, 141, 117, 141, 187,
150332 /* 1270 */ 23, 187, 36, 26, 209, 210, 134, 135, 129, 209,
150333 /* 1280 */ 210, 209, 210, 134, 135, 22, 159, 209, 210, 187,
150334 /* 1290 */ 187, 209, 210, 209, 210, 59, 113, 187, 148, 149,
150335 /* 1300 */ 150, 151, 152, 289, 290, 187, 157, 71, 248, 249,
150336 /* 1310 */ 114, 141, 209, 210, 46, 125, 116, 117, 138, 19,
150337 /* 1320 */ 20, 85, 22, 148, 61, 150, 90, 209, 210, 23,
150338 /* 1330 */ 7, 8, 26, 97, 187, 139, 36, 147, 59, 103,
150339 /* 1340 */ 104, 19, 20, 187, 22, 59, 110, 187, 112, 113,
150340 /* 1350 */ 114, 1, 2, 117, 187, 5, 209, 210, 36, 59,
150341 /* 1360 */ 10, 11, 12, 13, 14, 209, 210, 17, 59, 209,
150342 /* 1370 */ 210, 71, 187, 148, 250, 150, 209, 210, 187, 111,
150343 /* 1380 */ 30, 59, 32, 22, 148, 149, 150, 151, 152, 187,
150344 /* 1390 */ 40, 187, 113, 71, 209, 210, 187, 97, 187, 113,
150345 /* 1400 */ 209, 210, 187, 103, 104, 105, 23, 187, 187, 26,
150346 /* 1410 */ 110, 187, 112, 113, 114, 83, 84, 117, 23, 97,
150347 /* 1420 */ 70, 26, 113, 218, 187, 103, 104, 187, 78, 209,
150348 /* 1430 */ 210, 81, 110, 187, 112, 113, 114, 19, 20, 117,
150349 /* 1440 */ 22, 187, 187, 187, 187, 95, 209, 210, 148, 149,
150350 /* 1450 */ 150, 151, 152, 187, 36, 23, 187, 187, 26, 187,
150351 /* 1460 */ 187, 187, 187, 209, 210, 209, 210, 187, 187, 218,
150352 /* 1470 */ 148, 149, 150, 151, 152, 209, 210, 59, 187, 129,
150353 /* 1480 */ 187, 209, 210, 187, 134, 135, 187, 306, 187, 71,
150354 /* 1490 */ 209, 210, 23, 228, 187, 26, 23, 187, 137, 26,
150355 /* 1500 */ 209, 210, 209, 210, 187, 209, 210, 157, 209, 210,
150356 /* 1510 */ 209, 210, 218, 187, 187, 97, 209, 210, 187, 278,
150357 /* 1520 */ 23, 103, 104, 26, 187, 187, 187, 187, 110, 187,
150358 /* 1530 */ 112, 113, 114, 187, 187, 117, 5, 247, 187, 187,
150359 /* 1540 */ 187, 10, 11, 12, 13, 14, 209, 210, 17, 209,
150360 /* 1550 */ 210, 209, 210, 187, 187, 187, 209, 210, 187, 23,
150361 /* 1560 */ 187, 30, 26, 32, 187, 187, 148, 149, 150, 151,
150362 /* 1570 */ 152, 40, 187, 187, 187, 209, 210, 209, 210, 187,
150363 /* 1580 */ 209, 210, 209, 210, 187, 187, 209, 210, 187, 277,
150364 /* 1590 */ 234, 187, 247, 187, 209, 210, 209, 210, 187, 235,
150365 /* 1600 */ 187, 70, 187, 207, 247, 247, 247, 209, 210, 78,
150366 /* 1610 */ 209, 210, 81, 209, 210, 209, 210, 187, 185, 238,
150367 /* 1620 */ 209, 210, 209, 210, 209, 210, 95, 251, 287, 238,
150368 /* 1630 */ 251, 23, 23, 23, 26, 26, 26, 283, 23, 209,
150369 /* 1640 */ 210, 26, 213, 238, 221, 283, 212, 212, 217, 212,
150370 /* 1650 */ 251, 241, 270, 241, 237, 235, 190, 60, 137, 287,
150371 /* 1660 */ 129, 194, 194, 38, 284, 134, 135, 273, 284, 194,
150372 /* 1670 */ 146, 111, 22, 43, 226, 145, 262, 261, 238, 18,
150373 /* 1680 */ 229, 229, 229, 229, 194, 18, 193, 238, 157, 262,
150374 /* 1690 */ 226, 226, 194, 238, 238, 193, 153, 261, 62, 280,
150375 /* 1700 */ 279, 194, 193, 22, 194, 214, 193, 111, 194, 193,
150376 /* 1710 */ 214, 211, 211, 64, 211, 211, 122, 211, 219, 214,
150377 /* 1720 */ 109, 213, 160, 211, 300, 140, 211, 253, 111, 272,
150378 /* 1730 */ 219, 214, 272, 214, 252, 194, 253, 252, 91, 253,
150379 /* 1740 */ 252, 82, 253, 305, 252, 144, 305, 141, 22, 194,
150380 /* 1750 */ 269, 257, 257, 153, 267, 143, 142, 25, 197, 26,
150381 /* 1760 */ 242, 241, 196, 240, 242, 239, 238, 13, 188, 188,
150382 /* 1770 */ 6, 293, 186, 186, 186, 200, 206, 293, 206, 206,
150383 /* 1780 */ 206, 4, 200, 215, 215, 207, 207, 3, 22, 206,
150384 /* 1790 */ 200, 158, 96, 15, 23, 16, 23, 135, 146, 126,
150385 /* 1800 */ 24, 138, 20, 16, 140, 1, 138, 147, 126, 61,
150386 /* 1810 */ 53, 37, 146, 53, 53, 290, 53, 126, 112, 34,
150387 /* 1820 */ 137, 1, 5, 22, 111, 156, 68, 68, 26, 41,
150388 /* 1830 */ 75, 137, 111, 24, 20, 19, 127, 121, 23, 67,
150389 /* 1840 */ 22, 22, 67, 22, 22, 37, 22, 67, 23, 145,
150390 /* 1850 */ 22, 28, 23, 23, 23, 137, 23, 22, 26, 22,
150391 /* 1860 */ 24, 23, 112, 24, 23, 23, 22, 139, 34, 26,
150392 /* 1870 */ 75, 88, 86, 75, 34, 23, 22, 24, 22, 34,
150393 /* 1880 */ 34, 34, 93, 34, 26, 26, 23, 23, 23, 34,
150394 /* 1890 */ 23, 23, 44, 23, 11, 26, 22, 22, 26, 23,
150395 /* 1900 */ 23, 22, 22, 15, 137, 137, 137, 137, 23, 1,
150396 /* 1910 */ 307, 307, 131, 307, 307, 307, 307, 307, 307, 307,
150397 /* 1920 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150398 /* 1930 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150399 /* 1940 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150400 /* 1950 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150401 /* 1960 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150402 /* 1970 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150403 /* 1980 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150404 /* 1990 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150405 /* 2000 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150406 /* 2010 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150407 /* 2020 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150408 /* 2030 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150409 /* 2040 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150410 /* 2050 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150411 /* 2060 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150412 /* 2070 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150413 /* 2080 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
150414 /* 2090 */ 307, 307,
150415 };
150416 #define YY_SHIFT_COUNT (542)
 
 
 
 
150417 #define YY_SHIFT_MIN (0)
150418 #define YY_SHIFT_MAX (1908)
150419 static const unsigned short int yy_shift_ofst[] = {
150420 /* 0 */ 1350, 1149, 1531, 939, 939, 548, 996, 1150, 1236, 1322,
150421 /* 10 */ 1322, 1322, 334, 0, 0, 178, 777, 1322, 1322, 1322,
150422 /* 20 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150423 /* 30 */ 991, 991, 1125, 1125, 447, 597, 548, 548, 548, 548,
150424 /* 40 */ 548, 548, 40, 108, 217, 284, 323, 390, 429, 496,
150425 /* 50 */ 535, 602, 641, 757, 777, 777, 777, 777, 777, 777,
150426 /* 60 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777,
150427 /* 70 */ 777, 777, 796, 777, 887, 900, 900, 1300, 1322, 1322,
150428 /* 80 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150429 /* 90 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150430 /* 100 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150431 /* 110 */ 1418, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
150432 /* 120 */ 1322, 1322, 1322, 1322, 147, 254, 254, 254, 254, 254,
150433 /* 130 */ 84, 185, 66, 853, 958, 1121, 853, 92, 92, 853,
150434 /* 140 */ 321, 321, 321, 321, 325, 350, 350, 461, 150, 1913,
150435 /* 150 */ 1913, 285, 285, 285, 236, 184, 349, 184, 184, 712,
150436 /* 160 */ 712, 433, 553, 771, 899, 853, 853, 853, 853, 853,
150437 /* 170 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 853,
150438 /* 180 */ 853, 853, 853, 853, 853, 853, 46, 46, 853, 113,
150439 /* 190 */ 223, 223, 1183, 1183, 1127, 1142, 1913, 1913, 1913, 459,
150440 /* 200 */ 514, 514, 653, 495, 657, 305, 705, 560, 622, 776,
150441 /* 210 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 545,
150442 /* 220 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 853,
150443 /* 230 */ 853, 853, 1002, 1002, 1002, 853, 853, 853, 853, 1111,
150444 /* 240 */ 853, 853, 853, 1006, 1109, 853, 853, 1168, 853, 853,
150445 /* 250 */ 853, 853, 853, 853, 853, 853, 845, 1164, 738, 953,
150446 /* 260 */ 953, 953, 953, 1196, 738, 738, 45, 96, 964, 179,
150447 /* 270 */ 580, 907, 907, 1073, 580, 580, 1073, 498, 388, 1268,
150448 /* 280 */ 1187, 1187, 1187, 907, 1170, 1170, 1058, 1180, 328, 1219,
150449 /* 290 */ 1597, 1521, 1521, 1625, 1625, 1521, 1524, 1560, 1650, 1630,
150450 /* 300 */ 1530, 1661, 1661, 1661, 1661, 1521, 1667, 1530, 1530, 1560,
150451 /* 310 */ 1650, 1630, 1630, 1530, 1521, 1667, 1543, 1636, 1521, 1667,
150452 /* 320 */ 1681, 1521, 1667, 1521, 1667, 1681, 1596, 1596, 1596, 1649,
150453 /* 330 */ 1681, 1596, 1594, 1596, 1649, 1596, 1596, 1562, 1681, 1611,
150454 /* 340 */ 1611, 1681, 1585, 1617, 1585, 1617, 1585, 1617, 1585, 1617,
150455 /* 350 */ 1521, 1647, 1647, 1659, 1659, 1601, 1606, 1726, 1521, 1600,
150456 /* 360 */ 1601, 1612, 1614, 1530, 1732, 1733, 1754, 1754, 1764, 1764,
150457 /* 370 */ 1764, 1913, 1913, 1913, 1913, 1913, 1913, 1913, 1913, 1913,
150458 /* 380 */ 1913, 1913, 1913, 1913, 1913, 1913, 673, 901, 283, 740,
150459 /* 390 */ 707, 973, 655, 1247, 1048, 1097, 1190, 1306, 1263, 1383,
150460 /* 400 */ 1395, 1432, 1469, 1473, 1497, 1279, 1200, 1323, 1075, 1286,
150461 /* 410 */ 1536, 1608, 1332, 1609, 1175, 1225, 1610, 1615, 1309, 1361,
150462 /* 420 */ 1777, 1784, 1766, 1633, 1778, 1696, 1779, 1771, 1773, 1662,
150463 /* 430 */ 1652, 1673, 1776, 1663, 1782, 1664, 1787, 1804, 1668, 1660,
150464 /* 440 */ 1682, 1748, 1774, 1666, 1757, 1760, 1761, 1763, 1691, 1706,
150465 /* 450 */ 1785, 1683, 1820, 1817, 1801, 1713, 1669, 1758, 1802, 1759,
150466 /* 460 */ 1755, 1788, 1694, 1721, 1809, 1814, 1816, 1709, 1716, 1818,
150467 /* 470 */ 1772, 1819, 1821, 1815, 1822, 1775, 1823, 1824, 1780, 1808,
150468 /* 480 */ 1825, 1704, 1828, 1829, 1830, 1831, 1832, 1833, 1835, 1836,
150469 /* 490 */ 1838, 1837, 1839, 1718, 1841, 1842, 1750, 1834, 1844, 1728,
150470 /* 500 */ 1843, 1840, 1845, 1846, 1847, 1783, 1795, 1786, 1848, 1798,
150471 /* 510 */ 1789, 1849, 1852, 1854, 1853, 1858, 1859, 1855, 1863, 1843,
150472 /* 520 */ 1864, 1865, 1867, 1868, 1869, 1870, 1856, 1883, 1874, 1875,
150473 /* 530 */ 1876, 1877, 1879, 1880, 1872, 1781, 1767, 1768, 1769, 1770,
150474 /* 540 */ 1885, 1888, 1908,
150475 };
150476 #define YY_REDUCE_COUNT (385)
150477 #define YY_REDUCE_MIN (-256)
150478 #define YY_REDUCE_MAX (1590)
150479 static const short yy_reduce_ofst[] = {
150480 /* 0 */ 880, -121, 269, 528, 933, -119, -187, -185, -182, -180,
150481 /* 10 */ -176, -174, -62, -46, 131, -248, -133, 407, 568, 700,
150482 /* 20 */ 704, 278, 706, 824, 542, 830, 948, 773, 943, 946,
150483 /* 30 */ 71, 650, 211, 267, 826, 272, 676, 732, 885, 976,
150484 /* 40 */ 984, 992, -256, -256, -256, -256, -256, -256, -256, -256,
150485 /* 50 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
150486 /* 60 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
150487 /* 70 */ -256, -256, -256, -256, -256, -256, -256, 989, 1065, 1070,
150488 /* 80 */ 1072, 1078, 1082, 1084, 1103, 1118, 1147, 1156, 1160, 1167,
150489 /* 90 */ 1185, 1191, 1220, 1237, 1254, 1256, 1266, 1272, 1281, 1291,
150490 /* 100 */ 1293, 1296, 1299, 1301, 1307, 1337, 1340, 1342, 1347, 1366,
150491 /* 110 */ 1368, 1371, 1373, 1377, 1385, 1387, 1398, 1401, 1404, 1406,
150492 /* 120 */ 1411, 1413, 1415, 1430, -256, -256, -256, -256, -256, -256,
150493 /* 130 */ -256, -256, -256, -172, 508, -213, 57, -163, -25, 593,
150494 /* 140 */ 69, 486, 69, 486, -200, 573, 722, -256, -256, -256,
150495 /* 150 */ -256, -141, -141, -141, -105, -161, -167, 157, 212, 405,
150496 /* 160 */ 530, 220, 233, 735, 735, 115, 318, 406, 612, 541,
150497 /* 170 */ -166, 441, 688, 794, 629, 368, 741, 775, 867, 797,
150498 /* 180 */ 871, 842, -186, 1000, 858, 949, 379, 783, 70, 296,
150499 /* 190 */ 821, 903, 924, 1044, 651, 282, 1014, 1060, 937, -195,
150500 /* 200 */ -177, 413, 439, 511, 566, 787, 827, 848, 898, 945,
150501 /* 210 */ 1062, 1074, 1102, 1110, 1202, 1204, 1209, 1211, 1215, 529,
150502 /* 220 */ 1221, 1224, 1240, 1246, 1255, 1257, 1269, 1270, 1273, 1274,
150503 /* 230 */ 1275, 1280, 1205, 1251, 1294, 1310, 1317, 1326, 1327, 1124,
150504 /* 240 */ 1331, 1338, 1339, 1290, 1181, 1346, 1351, 1265, 1352, 787,
150505 /* 250 */ 1353, 1367, 1378, 1386, 1392, 1397, 1241, 1312, 1356, 1345,
150506 /* 260 */ 1357, 1358, 1359, 1124, 1356, 1356, 1364, 1396, 1433, 1341,
150507 /* 270 */ 1381, 1376, 1379, 1354, 1391, 1405, 1362, 1429, 1423, 1431,
150508 /* 280 */ 1434, 1435, 1437, 1399, 1410, 1412, 1382, 1417, 1420, 1466,
150509 /* 290 */ 1372, 1467, 1468, 1380, 1384, 1475, 1394, 1414, 1416, 1448,
150510 /* 300 */ 1440, 1451, 1452, 1453, 1454, 1490, 1493, 1449, 1455, 1427,
150511 /* 310 */ 1436, 1464, 1465, 1456, 1498, 1502, 1419, 1421, 1507, 1509,
150512 /* 320 */ 1491, 1510, 1513, 1514, 1516, 1496, 1500, 1501, 1503, 1499,
150513 /* 330 */ 1505, 1504, 1508, 1506, 1511, 1512, 1515, 1424, 1517, 1457,
150514 /* 340 */ 1460, 1519, 1474, 1482, 1483, 1485, 1486, 1488, 1489, 1492,
150515 /* 350 */ 1541, 1438, 1441, 1494, 1495, 1518, 1520, 1487, 1555, 1481,
150516 /* 360 */ 1522, 1523, 1526, 1528, 1561, 1566, 1580, 1581, 1586, 1587,
150517 /* 370 */ 1588, 1478, 1484, 1525, 1575, 1570, 1572, 1573, 1574, 1582,
150518 /* 380 */ 1568, 1569, 1578, 1579, 1583, 1590,
150519 };
150520 static const YYACTIONTYPE yy_default[] = {
150521 /* 0 */ 1554, 1554, 1554, 1392, 1171, 1278, 1171, 1171, 1171, 1392,
150522 /* 10 */ 1392, 1392, 1171, 1308, 1308, 1445, 1202, 1171, 1171, 1171,
150523 /* 20 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1391, 1171, 1171,
150524 /* 30 */ 1171, 1171, 1475, 1475, 1171, 1171, 1171, 1171, 1171, 1171,
150525 /* 40 */ 1171, 1171, 1171, 1317, 1171, 1171, 1171, 1171, 1171, 1393,
150526 /* 50 */ 1394, 1171, 1171, 1171, 1444, 1446, 1409, 1327, 1326, 1325,
150527 /* 60 */ 1324, 1427, 1295, 1322, 1315, 1319, 1387, 1388, 1386, 1390,
150528 /* 70 */ 1394, 1393, 1171, 1318, 1358, 1372, 1357, 1171, 1171, 1171,
150529 /* 80 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150530 /* 90 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150531 /* 100 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150532 /* 110 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150533 /* 120 */ 1171, 1171, 1171, 1171, 1366, 1371, 1377, 1370, 1367, 1360,
150534 /* 130 */ 1359, 1361, 1362, 1171, 1192, 1242, 1171, 1171, 1171, 1171,
150535 /* 140 */ 1463, 1462, 1171, 1171, 1202, 1352, 1351, 1363, 1364, 1374,
150536 /* 150 */ 1373, 1452, 1510, 1509, 1410, 1171, 1171, 1171, 1171, 1171,
150537 /* 160 */ 1171, 1475, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150538 /* 170 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150539 /* 180 */ 1171, 1171, 1171, 1171, 1171, 1171, 1475, 1475, 1171, 1202,
150540 /* 190 */ 1475, 1475, 1198, 1198, 1302, 1171, 1458, 1278, 1269, 1171,
150541 /* 200 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150542 /* 210 */ 1171, 1171, 1171, 1449, 1447, 1171, 1171, 1171, 1171, 1171,
150543 /* 220 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150544 /* 230 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150545 /* 240 */ 1171, 1171, 1171, 1274, 1171, 1171, 1171, 1171, 1171, 1171,
150546 /* 250 */ 1171, 1171, 1171, 1171, 1171, 1504, 1171, 1422, 1256, 1274,
150547 /* 260 */ 1274, 1274, 1274, 1276, 1257, 1255, 1268, 1203, 1178, 1546,
150548 /* 270 */ 1321, 1297, 1297, 1543, 1321, 1321, 1543, 1217, 1524, 1214,
150549 /* 280 */ 1308, 1308, 1308, 1297, 1302, 1302, 1389, 1275, 1268, 1171,
150550 /* 290 */ 1546, 1283, 1283, 1545, 1545, 1283, 1410, 1330, 1336, 1245,
150551 /* 300 */ 1321, 1251, 1251, 1251, 1251, 1283, 1189, 1321, 1321, 1330,
150552 /* 310 */ 1336, 1245, 1245, 1321, 1283, 1189, 1426, 1540, 1283, 1189,
150553 /* 320 */ 1400, 1283, 1189, 1283, 1189, 1400, 1243, 1243, 1243, 1232,
150554 /* 330 */ 1400, 1243, 1217, 1243, 1232, 1243, 1243, 1493, 1400, 1404,
150555 /* 340 */ 1404, 1400, 1301, 1296, 1301, 1296, 1301, 1296, 1301, 1296,
150556 /* 350 */ 1283, 1485, 1485, 1311, 1311, 1316, 1302, 1395, 1283, 1171,
150557 /* 360 */ 1316, 1314, 1312, 1321, 1195, 1235, 1507, 1507, 1503, 1503,
150558 /* 370 */ 1503, 1551, 1551, 1458, 1519, 1202, 1202, 1202, 1202, 1519,
150559 /* 380 */ 1219, 1219, 1203, 1203, 1202, 1519, 1171, 1171, 1171, 1171,
150560 /* 390 */ 1171, 1171, 1514, 1171, 1411, 1287, 1171, 1171, 1171, 1171,
150561 /* 400 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150562 /* 410 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1341,
150563 /* 420 */ 1171, 1174, 1455, 1171, 1171, 1453, 1171, 1171, 1171, 1171,
150564 /* 430 */ 1171, 1171, 1288, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150565 /* 440 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150566 /* 450 */ 1171, 1542, 1171, 1171, 1171, 1171, 1171, 1171, 1425, 1424,
150567 /* 460 */ 1171, 1171, 1285, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150568 /* 470 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150569 /* 480 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150570 /* 490 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150571 /* 500 */ 1313, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150572 /* 510 */ 1171, 1171, 1171, 1171, 1171, 1490, 1303, 1171, 1171, 1533,
150573 /* 520 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
150574 /* 530 */ 1171, 1171, 1171, 1171, 1528, 1259, 1343, 1171, 1342, 1346,
150575 /* 540 */ 1171, 1183, 1171,
150576 };
150577 /********** End of lemon-generated parsing tables *****************************/
150578
150579 /* The next table maps tokens (terminal symbols) into fallback tokens.
150580 ** If a construct like the following:
@@ -150685,10 +151799,12 @@
150685 59, /* UNBOUNDED => ID */
150686 59, /* EXCLUDE => ID */
150687 59, /* GROUPS => ID */
150688 59, /* OTHERS => ID */
150689 59, /* TIES => ID */
 
 
150690 59, /* REINDEX => ID */
150691 59, /* RENAME => ID */
150692 59, /* CTIME_KW => ID */
150693 0, /* ANY => nothing */
150694 0, /* BITAND => nothing */
@@ -150951,222 +152067,225 @@
150951 /* 90 */ "UNBOUNDED",
150952 /* 91 */ "EXCLUDE",
150953 /* 92 */ "GROUPS",
150954 /* 93 */ "OTHERS",
150955 /* 94 */ "TIES",
150956 /* 95 */ "REINDEX",
150957 /* 96 */ "RENAME",
150958 /* 97 */ "CTIME_KW",
150959 /* 98 */ "ANY",
150960 /* 99 */ "BITAND",
150961 /* 100 */ "BITOR",
150962 /* 101 */ "LSHIFT",
150963 /* 102 */ "RSHIFT",
150964 /* 103 */ "PLUS",
150965 /* 104 */ "MINUS",
150966 /* 105 */ "STAR",
150967 /* 106 */ "SLASH",
150968 /* 107 */ "REM",
150969 /* 108 */ "CONCAT",
150970 /* 109 */ "COLLATE",
150971 /* 110 */ "BITNOT",
150972 /* 111 */ "ON",
150973 /* 112 */ "INDEXED",
150974 /* 113 */ "STRING",
150975 /* 114 */ "JOIN_KW",
150976 /* 115 */ "CONSTRAINT",
150977 /* 116 */ "DEFAULT",
150978 /* 117 */ "NULL",
150979 /* 118 */ "PRIMARY",
150980 /* 119 */ "UNIQUE",
150981 /* 120 */ "CHECK",
150982 /* 121 */ "REFERENCES",
150983 /* 122 */ "AUTOINCR",
150984 /* 123 */ "INSERT",
150985 /* 124 */ "DELETE",
150986 /* 125 */ "UPDATE",
150987 /* 126 */ "SET",
150988 /* 127 */ "DEFERRABLE",
150989 /* 128 */ "FOREIGN",
150990 /* 129 */ "DROP",
150991 /* 130 */ "UNION",
150992 /* 131 */ "ALL",
150993 /* 132 */ "EXCEPT",
150994 /* 133 */ "INTERSECT",
150995 /* 134 */ "SELECT",
150996 /* 135 */ "VALUES",
150997 /* 136 */ "DISTINCT",
150998 /* 137 */ "DOT",
150999 /* 138 */ "FROM",
151000 /* 139 */ "JOIN",
151001 /* 140 */ "USING",
151002 /* 141 */ "ORDER",
151003 /* 142 */ "GROUP",
151004 /* 143 */ "HAVING",
151005 /* 144 */ "LIMIT",
151006 /* 145 */ "WHERE",
151007 /* 146 */ "INTO",
151008 /* 147 */ "NOTHING",
151009 /* 148 */ "FLOAT",
151010 /* 149 */ "BLOB",
151011 /* 150 */ "INTEGER",
151012 /* 151 */ "VARIABLE",
151013 /* 152 */ "CASE",
151014 /* 153 */ "WHEN",
151015 /* 154 */ "THEN",
151016 /* 155 */ "ELSE",
151017 /* 156 */ "INDEX",
151018 /* 157 */ "ALTER",
151019 /* 158 */ "ADD",
151020 /* 159 */ "WINDOW",
151021 /* 160 */ "OVER",
151022 /* 161 */ "FILTER",
151023 /* 162 */ "COLUMN",
151024 /* 163 */ "AGG_FUNCTION",
151025 /* 164 */ "AGG_COLUMN",
151026 /* 165 */ "TRUEFALSE",
151027 /* 166 */ "ISNOT",
151028 /* 167 */ "FUNCTION",
151029 /* 168 */ "UMINUS",
151030 /* 169 */ "UPLUS",
151031 /* 170 */ "TRUTH",
151032 /* 171 */ "REGISTER",
151033 /* 172 */ "VECTOR",
151034 /* 173 */ "SELECT_COLUMN",
151035 /* 174 */ "IF_NULL_ROW",
151036 /* 175 */ "ASTERISK",
151037 /* 176 */ "SPAN",
151038 /* 177 */ "SPACE",
151039 /* 178 */ "ILLEGAL",
151040 /* 179 */ "input",
151041 /* 180 */ "cmdlist",
151042 /* 181 */ "ecmd",
151043 /* 182 */ "cmdx",
151044 /* 183 */ "explain",
151045 /* 184 */ "cmd",
151046 /* 185 */ "transtype",
151047 /* 186 */ "trans_opt",
151048 /* 187 */ "nm",
151049 /* 188 */ "savepoint_opt",
151050 /* 189 */ "create_table",
151051 /* 190 */ "create_table_args",
151052 /* 191 */ "createkw",
151053 /* 192 */ "temp",
151054 /* 193 */ "ifnotexists",
151055 /* 194 */ "dbnm",
151056 /* 195 */ "columnlist",
151057 /* 196 */ "conslist_opt",
151058 /* 197 */ "table_options",
151059 /* 198 */ "select",
151060 /* 199 */ "columnname",
151061 /* 200 */ "carglist",
151062 /* 201 */ "typetoken",
151063 /* 202 */ "typename",
151064 /* 203 */ "signed",
151065 /* 204 */ "plus_num",
151066 /* 205 */ "minus_num",
151067 /* 206 */ "scanpt",
151068 /* 207 */ "scantok",
151069 /* 208 */ "ccons",
151070 /* 209 */ "term",
151071 /* 210 */ "expr",
151072 /* 211 */ "onconf",
151073 /* 212 */ "sortorder",
151074 /* 213 */ "autoinc",
151075 /* 214 */ "eidlist_opt",
151076 /* 215 */ "refargs",
151077 /* 216 */ "defer_subclause",
151078 /* 217 */ "refarg",
151079 /* 218 */ "refact",
151080 /* 219 */ "init_deferred_pred_opt",
151081 /* 220 */ "conslist",
151082 /* 221 */ "tconscomma",
151083 /* 222 */ "tcons",
151084 /* 223 */ "sortlist",
151085 /* 224 */ "eidlist",
151086 /* 225 */ "defer_subclause_opt",
151087 /* 226 */ "orconf",
151088 /* 227 */ "resolvetype",
151089 /* 228 */ "raisetype",
151090 /* 229 */ "ifexists",
151091 /* 230 */ "fullname",
151092 /* 231 */ "selectnowith",
151093 /* 232 */ "oneselect",
151094 /* 233 */ "wqlist",
151095 /* 234 */ "multiselect_op",
151096 /* 235 */ "distinct",
151097 /* 236 */ "selcollist",
151098 /* 237 */ "from",
151099 /* 238 */ "where_opt",
151100 /* 239 */ "groupby_opt",
151101 /* 240 */ "having_opt",
151102 /* 241 */ "orderby_opt",
151103 /* 242 */ "limit_opt",
151104 /* 243 */ "window_clause",
151105 /* 244 */ "values",
151106 /* 245 */ "nexprlist",
151107 /* 246 */ "sclp",
151108 /* 247 */ "as",
151109 /* 248 */ "seltablist",
151110 /* 249 */ "stl_prefix",
151111 /* 250 */ "joinop",
151112 /* 251 */ "indexed_opt",
151113 /* 252 */ "on_opt",
151114 /* 253 */ "using_opt",
151115 /* 254 */ "exprlist",
151116 /* 255 */ "xfullname",
151117 /* 256 */ "idlist",
151118 /* 257 */ "nulls",
151119 /* 258 */ "with",
151120 /* 259 */ "setlist",
151121 /* 260 */ "insert_cmd",
151122 /* 261 */ "idlist_opt",
151123 /* 262 */ "upsert",
151124 /* 263 */ "filter_over",
151125 /* 264 */ "likeop",
151126 /* 265 */ "between_op",
151127 /* 266 */ "in_op",
151128 /* 267 */ "paren_exprlist",
151129 /* 268 */ "case_operand",
151130 /* 269 */ "case_exprlist",
151131 /* 270 */ "case_else",
151132 /* 271 */ "uniqueflag",
151133 /* 272 */ "collate",
151134 /* 273 */ "vinto",
151135 /* 274 */ "nmnum",
151136 /* 275 */ "trigger_decl",
151137 /* 276 */ "trigger_cmd_list",
151138 /* 277 */ "trigger_time",
151139 /* 278 */ "trigger_event",
151140 /* 279 */ "foreach_clause",
151141 /* 280 */ "when_clause",
151142 /* 281 */ "trigger_cmd",
151143 /* 282 */ "trnm",
151144 /* 283 */ "tridxby",
151145 /* 284 */ "database_kw_opt",
151146 /* 285 */ "key_opt",
151147 /* 286 */ "add_column_fullname",
151148 /* 287 */ "kwcolumn_opt",
151149 /* 288 */ "create_vtab",
151150 /* 289 */ "vtabarglist",
151151 /* 290 */ "vtabarg",
151152 /* 291 */ "vtabargtoken",
151153 /* 292 */ "lp",
151154 /* 293 */ "anylist",
151155 /* 294 */ "windowdefn_list",
151156 /* 295 */ "windowdefn",
151157 /* 296 */ "window",
151158 /* 297 */ "frame_opt",
151159 /* 298 */ "part_opt",
151160 /* 299 */ "filter_clause",
151161 /* 300 */ "over_clause",
151162 /* 301 */ "range_or_rows",
151163 /* 302 */ "frame_bound",
151164 /* 303 */ "frame_bound_s",
151165 /* 304 */ "frame_bound_e",
151166 /* 305 */ "frame_exclude_opt",
151167 /* 306 */ "frame_exclude",
 
 
 
151168 };
151169 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
151170
151171 #ifndef NDEBUG
151172 /* For tracing reduce actions, the names of all rules are required.
@@ -151213,348 +152332,352 @@
151213 /* 38 */ "ccons ::= UNIQUE onconf",
151214 /* 39 */ "ccons ::= CHECK LP expr RP",
151215 /* 40 */ "ccons ::= REFERENCES nm eidlist_opt refargs",
151216 /* 41 */ "ccons ::= defer_subclause",
151217 /* 42 */ "ccons ::= COLLATE ID|STRING",
151218 /* 43 */ "autoinc ::=",
151219 /* 44 */ "autoinc ::= AUTOINCR",
151220 /* 45 */ "refargs ::=",
151221 /* 46 */ "refargs ::= refargs refarg",
151222 /* 47 */ "refarg ::= MATCH nm",
151223 /* 48 */ "refarg ::= ON INSERT refact",
151224 /* 49 */ "refarg ::= ON DELETE refact",
151225 /* 50 */ "refarg ::= ON UPDATE refact",
151226 /* 51 */ "refact ::= SET NULL",
151227 /* 52 */ "refact ::= SET DEFAULT",
151228 /* 53 */ "refact ::= CASCADE",
151229 /* 54 */ "refact ::= RESTRICT",
151230 /* 55 */ "refact ::= NO ACTION",
151231 /* 56 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
151232 /* 57 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
151233 /* 58 */ "init_deferred_pred_opt ::=",
151234 /* 59 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
151235 /* 60 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
151236 /* 61 */ "conslist_opt ::=",
151237 /* 62 */ "tconscomma ::= COMMA",
151238 /* 63 */ "tcons ::= CONSTRAINT nm",
151239 /* 64 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf",
151240 /* 65 */ "tcons ::= UNIQUE LP sortlist RP onconf",
151241 /* 66 */ "tcons ::= CHECK LP expr RP onconf",
151242 /* 67 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt",
151243 /* 68 */ "defer_subclause_opt ::=",
151244 /* 69 */ "onconf ::=",
151245 /* 70 */ "onconf ::= ON CONFLICT resolvetype",
151246 /* 71 */ "orconf ::=",
151247 /* 72 */ "orconf ::= OR resolvetype",
151248 /* 73 */ "resolvetype ::= IGNORE",
151249 /* 74 */ "resolvetype ::= REPLACE",
151250 /* 75 */ "cmd ::= DROP TABLE ifexists fullname",
151251 /* 76 */ "ifexists ::= IF EXISTS",
151252 /* 77 */ "ifexists ::=",
151253 /* 78 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
151254 /* 79 */ "cmd ::= DROP VIEW ifexists fullname",
151255 /* 80 */ "cmd ::= select",
151256 /* 81 */ "select ::= WITH wqlist selectnowith",
151257 /* 82 */ "select ::= WITH RECURSIVE wqlist selectnowith",
151258 /* 83 */ "select ::= selectnowith",
151259 /* 84 */ "selectnowith ::= selectnowith multiselect_op oneselect",
151260 /* 85 */ "multiselect_op ::= UNION",
151261 /* 86 */ "multiselect_op ::= UNION ALL",
151262 /* 87 */ "multiselect_op ::= EXCEPT|INTERSECT",
151263 /* 88 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
151264 /* 89 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt",
151265 /* 90 */ "values ::= VALUES LP nexprlist RP",
151266 /* 91 */ "values ::= values COMMA LP nexprlist RP",
151267 /* 92 */ "distinct ::= DISTINCT",
151268 /* 93 */ "distinct ::= ALL",
151269 /* 94 */ "distinct ::=",
151270 /* 95 */ "sclp ::=",
151271 /* 96 */ "selcollist ::= sclp scanpt expr scanpt as",
151272 /* 97 */ "selcollist ::= sclp scanpt STAR",
151273 /* 98 */ "selcollist ::= sclp scanpt nm DOT STAR",
151274 /* 99 */ "as ::= AS nm",
151275 /* 100 */ "as ::=",
151276 /* 101 */ "from ::=",
151277 /* 102 */ "from ::= FROM seltablist",
151278 /* 103 */ "stl_prefix ::= seltablist joinop",
151279 /* 104 */ "stl_prefix ::=",
151280 /* 105 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
151281 /* 106 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
151282 /* 107 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
151283 /* 108 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
151284 /* 109 */ "dbnm ::=",
151285 /* 110 */ "dbnm ::= DOT nm",
151286 /* 111 */ "fullname ::= nm",
151287 /* 112 */ "fullname ::= nm DOT nm",
151288 /* 113 */ "xfullname ::= nm",
151289 /* 114 */ "xfullname ::= nm DOT nm",
151290 /* 115 */ "xfullname ::= nm DOT nm AS nm",
151291 /* 116 */ "xfullname ::= nm AS nm",
151292 /* 117 */ "joinop ::= COMMA|JOIN",
151293 /* 118 */ "joinop ::= JOIN_KW JOIN",
151294 /* 119 */ "joinop ::= JOIN_KW nm JOIN",
151295 /* 120 */ "joinop ::= JOIN_KW nm nm JOIN",
151296 /* 121 */ "on_opt ::= ON expr",
151297 /* 122 */ "on_opt ::=",
151298 /* 123 */ "indexed_opt ::=",
151299 /* 124 */ "indexed_opt ::= INDEXED BY nm",
151300 /* 125 */ "indexed_opt ::= NOT INDEXED",
151301 /* 126 */ "using_opt ::= USING LP idlist RP",
151302 /* 127 */ "using_opt ::=",
151303 /* 128 */ "orderby_opt ::=",
151304 /* 129 */ "orderby_opt ::= ORDER BY sortlist",
151305 /* 130 */ "sortlist ::= sortlist COMMA expr sortorder nulls",
151306 /* 131 */ "sortlist ::= expr sortorder nulls",
151307 /* 132 */ "sortorder ::= ASC",
151308 /* 133 */ "sortorder ::= DESC",
151309 /* 134 */ "sortorder ::=",
151310 /* 135 */ "nulls ::= NULLS FIRST",
151311 /* 136 */ "nulls ::= NULLS LAST",
151312 /* 137 */ "nulls ::=",
151313 /* 138 */ "groupby_opt ::=",
151314 /* 139 */ "groupby_opt ::= GROUP BY nexprlist",
151315 /* 140 */ "having_opt ::=",
151316 /* 141 */ "having_opt ::= HAVING expr",
151317 /* 142 */ "limit_opt ::=",
151318 /* 143 */ "limit_opt ::= LIMIT expr",
151319 /* 144 */ "limit_opt ::= LIMIT expr OFFSET expr",
151320 /* 145 */ "limit_opt ::= LIMIT expr COMMA expr",
151321 /* 146 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
151322 /* 147 */ "where_opt ::=",
151323 /* 148 */ "where_opt ::= WHERE expr",
151324 /* 149 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
151325 /* 150 */ "setlist ::= setlist COMMA nm EQ expr",
151326 /* 151 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
151327 /* 152 */ "setlist ::= nm EQ expr",
151328 /* 153 */ "setlist ::= LP idlist RP EQ expr",
151329 /* 154 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
151330 /* 155 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
151331 /* 156 */ "upsert ::=",
151332 /* 157 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
151333 /* 158 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
151334 /* 159 */ "upsert ::= ON CONFLICT DO NOTHING",
151335 /* 160 */ "insert_cmd ::= INSERT orconf",
151336 /* 161 */ "insert_cmd ::= REPLACE",
151337 /* 162 */ "idlist_opt ::=",
151338 /* 163 */ "idlist_opt ::= LP idlist RP",
151339 /* 164 */ "idlist ::= idlist COMMA nm",
151340 /* 165 */ "idlist ::= nm",
151341 /* 166 */ "expr ::= LP expr RP",
151342 /* 167 */ "expr ::= ID|INDEXED",
151343 /* 168 */ "expr ::= JOIN_KW",
151344 /* 169 */ "expr ::= nm DOT nm",
151345 /* 170 */ "expr ::= nm DOT nm DOT nm",
151346 /* 171 */ "term ::= NULL|FLOAT|BLOB",
151347 /* 172 */ "term ::= STRING",
151348 /* 173 */ "term ::= INTEGER",
151349 /* 174 */ "expr ::= VARIABLE",
151350 /* 175 */ "expr ::= expr COLLATE ID|STRING",
151351 /* 176 */ "expr ::= CAST LP expr AS typetoken RP",
151352 /* 177 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
151353 /* 178 */ "expr ::= ID|INDEXED LP STAR RP",
151354 /* 179 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over",
151355 /* 180 */ "expr ::= ID|INDEXED LP STAR RP filter_over",
151356 /* 181 */ "term ::= CTIME_KW",
151357 /* 182 */ "expr ::= LP nexprlist COMMA expr RP",
151358 /* 183 */ "expr ::= expr AND expr",
151359 /* 184 */ "expr ::= expr OR expr",
151360 /* 185 */ "expr ::= expr LT|GT|GE|LE expr",
151361 /* 186 */ "expr ::= expr EQ|NE expr",
151362 /* 187 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
151363 /* 188 */ "expr ::= expr PLUS|MINUS expr",
151364 /* 189 */ "expr ::= expr STAR|SLASH|REM expr",
151365 /* 190 */ "expr ::= expr CONCAT expr",
151366 /* 191 */ "likeop ::= NOT LIKE_KW|MATCH",
151367 /* 192 */ "expr ::= expr likeop expr",
151368 /* 193 */ "expr ::= expr likeop expr ESCAPE expr",
151369 /* 194 */ "expr ::= expr ISNULL|NOTNULL",
151370 /* 195 */ "expr ::= expr NOT NULL",
151371 /* 196 */ "expr ::= expr IS expr",
151372 /* 197 */ "expr ::= expr IS NOT expr",
151373 /* 198 */ "expr ::= NOT expr",
151374 /* 199 */ "expr ::= BITNOT expr",
151375 /* 200 */ "expr ::= PLUS|MINUS expr",
151376 /* 201 */ "between_op ::= BETWEEN",
151377 /* 202 */ "between_op ::= NOT BETWEEN",
151378 /* 203 */ "expr ::= expr between_op expr AND expr",
151379 /* 204 */ "in_op ::= IN",
151380 /* 205 */ "in_op ::= NOT IN",
151381 /* 206 */ "expr ::= expr in_op LP exprlist RP",
151382 /* 207 */ "expr ::= LP select RP",
151383 /* 208 */ "expr ::= expr in_op LP select RP",
151384 /* 209 */ "expr ::= expr in_op nm dbnm paren_exprlist",
151385 /* 210 */ "expr ::= EXISTS LP select RP",
151386 /* 211 */ "expr ::= CASE case_operand case_exprlist case_else END",
151387 /* 212 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
151388 /* 213 */ "case_exprlist ::= WHEN expr THEN expr",
151389 /* 214 */ "case_else ::= ELSE expr",
151390 /* 215 */ "case_else ::=",
151391 /* 216 */ "case_operand ::= expr",
151392 /* 217 */ "case_operand ::=",
151393 /* 218 */ "exprlist ::=",
151394 /* 219 */ "nexprlist ::= nexprlist COMMA expr",
151395 /* 220 */ "nexprlist ::= expr",
151396 /* 221 */ "paren_exprlist ::=",
151397 /* 222 */ "paren_exprlist ::= LP exprlist RP",
151398 /* 223 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
151399 /* 224 */ "uniqueflag ::= UNIQUE",
151400 /* 225 */ "uniqueflag ::=",
151401 /* 226 */ "eidlist_opt ::=",
151402 /* 227 */ "eidlist_opt ::= LP eidlist RP",
151403 /* 228 */ "eidlist ::= eidlist COMMA nm collate sortorder",
151404 /* 229 */ "eidlist ::= nm collate sortorder",
151405 /* 230 */ "collate ::=",
151406 /* 231 */ "collate ::= COLLATE ID|STRING",
151407 /* 232 */ "cmd ::= DROP INDEX ifexists fullname",
151408 /* 233 */ "cmd ::= VACUUM vinto",
151409 /* 234 */ "cmd ::= VACUUM nm vinto",
151410 /* 235 */ "vinto ::= INTO expr",
151411 /* 236 */ "vinto ::=",
151412 /* 237 */ "cmd ::= PRAGMA nm dbnm",
151413 /* 238 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
151414 /* 239 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
151415 /* 240 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
151416 /* 241 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
151417 /* 242 */ "plus_num ::= PLUS INTEGER|FLOAT",
151418 /* 243 */ "minus_num ::= MINUS INTEGER|FLOAT",
151419 /* 244 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
151420 /* 245 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
151421 /* 246 */ "trigger_time ::= BEFORE|AFTER",
151422 /* 247 */ "trigger_time ::= INSTEAD OF",
151423 /* 248 */ "trigger_time ::=",
151424 /* 249 */ "trigger_event ::= DELETE|INSERT",
151425 /* 250 */ "trigger_event ::= UPDATE",
151426 /* 251 */ "trigger_event ::= UPDATE OF idlist",
151427 /* 252 */ "when_clause ::=",
151428 /* 253 */ "when_clause ::= WHEN expr",
151429 /* 254 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
151430 /* 255 */ "trigger_cmd_list ::= trigger_cmd SEMI",
151431 /* 256 */ "trnm ::= nm DOT nm",
151432 /* 257 */ "tridxby ::= INDEXED BY nm",
151433 /* 258 */ "tridxby ::= NOT INDEXED",
151434 /* 259 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
151435 /* 260 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
151436 /* 261 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
151437 /* 262 */ "trigger_cmd ::= scanpt select scanpt",
151438 /* 263 */ "expr ::= RAISE LP IGNORE RP",
151439 /* 264 */ "expr ::= RAISE LP raisetype COMMA nm RP",
151440 /* 265 */ "raisetype ::= ROLLBACK",
151441 /* 266 */ "raisetype ::= ABORT",
151442 /* 267 */ "raisetype ::= FAIL",
151443 /* 268 */ "cmd ::= DROP TRIGGER ifexists fullname",
151444 /* 269 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
151445 /* 270 */ "cmd ::= DETACH database_kw_opt expr",
151446 /* 271 */ "key_opt ::=",
151447 /* 272 */ "key_opt ::= KEY expr",
151448 /* 273 */ "cmd ::= REINDEX",
151449 /* 274 */ "cmd ::= REINDEX nm dbnm",
151450 /* 275 */ "cmd ::= ANALYZE",
151451 /* 276 */ "cmd ::= ANALYZE nm dbnm",
151452 /* 277 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
151453 /* 278 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
151454 /* 279 */ "add_column_fullname ::= fullname",
151455 /* 280 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
151456 /* 281 */ "cmd ::= create_vtab",
151457 /* 282 */ "cmd ::= create_vtab LP vtabarglist RP",
151458 /* 283 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
151459 /* 284 */ "vtabarg ::=",
151460 /* 285 */ "vtabargtoken ::= ANY",
151461 /* 286 */ "vtabargtoken ::= lp anylist RP",
151462 /* 287 */ "lp ::= LP",
151463 /* 288 */ "with ::= WITH wqlist",
151464 /* 289 */ "with ::= WITH RECURSIVE wqlist",
151465 /* 290 */ "wqlist ::= nm eidlist_opt AS LP select RP",
151466 /* 291 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
151467 /* 292 */ "windowdefn_list ::= windowdefn",
151468 /* 293 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
151469 /* 294 */ "windowdefn ::= nm AS LP window RP",
151470 /* 295 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
151471 /* 296 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
151472 /* 297 */ "window ::= ORDER BY sortlist frame_opt",
151473 /* 298 */ "window ::= nm ORDER BY sortlist frame_opt",
151474 /* 299 */ "window ::= frame_opt",
151475 /* 300 */ "window ::= nm frame_opt",
151476 /* 301 */ "frame_opt ::=",
151477 /* 302 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
151478 /* 303 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
151479 /* 304 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
151480 /* 305 */ "frame_bound_s ::= frame_bound",
151481 /* 306 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
151482 /* 307 */ "frame_bound_e ::= frame_bound",
151483 /* 308 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
151484 /* 309 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
151485 /* 310 */ "frame_bound ::= CURRENT ROW",
151486 /* 311 */ "frame_exclude_opt ::=",
151487 /* 312 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
151488 /* 313 */ "frame_exclude ::= NO OTHERS",
151489 /* 314 */ "frame_exclude ::= CURRENT ROW",
151490 /* 315 */ "frame_exclude ::= GROUP|TIES",
151491 /* 316 */ "window_clause ::= WINDOW windowdefn_list",
151492 /* 317 */ "filter_over ::= filter_clause over_clause",
151493 /* 318 */ "filter_over ::= over_clause",
151494 /* 319 */ "filter_over ::= filter_clause",
151495 /* 320 */ "over_clause ::= OVER LP window RP",
151496 /* 321 */ "over_clause ::= OVER nm",
151497 /* 322 */ "filter_clause ::= FILTER LP WHERE expr RP",
151498 /* 323 */ "input ::= cmdlist",
151499 /* 324 */ "cmdlist ::= cmdlist ecmd",
151500 /* 325 */ "cmdlist ::= ecmd",
151501 /* 326 */ "ecmd ::= SEMI",
151502 /* 327 */ "ecmd ::= cmdx SEMI",
151503 /* 328 */ "ecmd ::= explain cmdx",
151504 /* 329 */ "trans_opt ::=",
151505 /* 330 */ "trans_opt ::= TRANSACTION",
151506 /* 331 */ "trans_opt ::= TRANSACTION nm",
151507 /* 332 */ "savepoint_opt ::= SAVEPOINT",
151508 /* 333 */ "savepoint_opt ::=",
151509 /* 334 */ "cmd ::= create_table create_table_args",
151510 /* 335 */ "columnlist ::= columnlist COMMA columnname carglist",
151511 /* 336 */ "columnlist ::= columnname carglist",
151512 /* 337 */ "nm ::= ID|INDEXED",
151513 /* 338 */ "nm ::= STRING",
151514 /* 339 */ "nm ::= JOIN_KW",
151515 /* 340 */ "typetoken ::= typename",
151516 /* 341 */ "typename ::= ID|STRING",
151517 /* 342 */ "signed ::= plus_num",
151518 /* 343 */ "signed ::= minus_num",
151519 /* 344 */ "carglist ::= carglist ccons",
151520 /* 345 */ "carglist ::=",
151521 /* 346 */ "ccons ::= NULL onconf",
151522 /* 347 */ "conslist_opt ::= COMMA conslist",
151523 /* 348 */ "conslist ::= conslist tconscomma tcons",
151524 /* 349 */ "conslist ::= tcons",
151525 /* 350 */ "tconscomma ::=",
151526 /* 351 */ "defer_subclause_opt ::= defer_subclause",
151527 /* 352 */ "resolvetype ::= raisetype",
151528 /* 353 */ "selectnowith ::= oneselect",
151529 /* 354 */ "oneselect ::= values",
151530 /* 355 */ "sclp ::= selcollist COMMA",
151531 /* 356 */ "as ::= ID|STRING",
151532 /* 357 */ "expr ::= term",
151533 /* 358 */ "likeop ::= LIKE_KW|MATCH",
151534 /* 359 */ "exprlist ::= nexprlist",
151535 /* 360 */ "nmnum ::= plus_num",
151536 /* 361 */ "nmnum ::= nm",
151537 /* 362 */ "nmnum ::= ON",
151538 /* 363 */ "nmnum ::= DELETE",
151539 /* 364 */ "nmnum ::= DEFAULT",
151540 /* 365 */ "plus_num ::= INTEGER|FLOAT",
151541 /* 366 */ "foreach_clause ::=",
151542 /* 367 */ "foreach_clause ::= FOR EACH ROW",
151543 /* 368 */ "trnm ::= nm",
151544 /* 369 */ "tridxby ::=",
151545 /* 370 */ "database_kw_opt ::= DATABASE",
151546 /* 371 */ "database_kw_opt ::=",
151547 /* 372 */ "kwcolumn_opt ::=",
151548 /* 373 */ "kwcolumn_opt ::= COLUMNKW",
151549 /* 374 */ "vtabarglist ::= vtabarg",
151550 /* 375 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
151551 /* 376 */ "vtabarg ::= vtabarg vtabargtoken",
151552 /* 377 */ "anylist ::=",
151553 /* 378 */ "anylist ::= anylist LP anylist RP",
151554 /* 379 */ "anylist ::= anylist ANY",
151555 /* 380 */ "with ::=",
 
 
 
 
151556 };
151557 #endif /* NDEBUG */
151558
151559
151560 #if YYSTACKDEPTH<=0
@@ -151676,102 +152799,102 @@
151676 ** Note: during a reduce, the only symbols destroyed are those
151677 ** which appear on the RHS of the rule, but which are *not* used
151678 ** inside the C code.
151679 */
151680 /********* Begin destructor definitions ***************************************/
151681 case 198: /* select */
151682 case 231: /* selectnowith */
151683 case 232: /* oneselect */
151684 case 244: /* values */
151685 {
151686 sqlite3SelectDelete(pParse->db, (yypminor->yy25));
151687 }
151688 break;
151689 case 209: /* term */
151690 case 210: /* expr */
151691 case 238: /* where_opt */
151692 case 240: /* having_opt */
151693 case 252: /* on_opt */
151694 case 268: /* case_operand */
151695 case 270: /* case_else */
151696 case 273: /* vinto */
151697 case 280: /* when_clause */
151698 case 285: /* key_opt */
151699 case 299: /* filter_clause */
151700 {
151701 sqlite3ExprDelete(pParse->db, (yypminor->yy46));
151702 }
151703 break;
151704 case 214: /* eidlist_opt */
151705 case 223: /* sortlist */
151706 case 224: /* eidlist */
151707 case 236: /* selcollist */
151708 case 239: /* groupby_opt */
151709 case 241: /* orderby_opt */
151710 case 245: /* nexprlist */
151711 case 246: /* sclp */
151712 case 254: /* exprlist */
151713 case 259: /* setlist */
151714 case 267: /* paren_exprlist */
151715 case 269: /* case_exprlist */
151716 case 298: /* part_opt */
151717 {
151718 sqlite3ExprListDelete(pParse->db, (yypminor->yy138));
151719 }
151720 break;
151721 case 230: /* fullname */
151722 case 237: /* from */
151723 case 248: /* seltablist */
151724 case 249: /* stl_prefix */
151725 case 255: /* xfullname */
151726 {
151727 sqlite3SrcListDelete(pParse->db, (yypminor->yy609));
151728 }
151729 break;
151730 case 233: /* wqlist */
151731 {
151732 sqlite3WithDelete(pParse->db, (yypminor->yy297));
151733 }
151734 break;
151735 case 243: /* window_clause */
151736 case 294: /* windowdefn_list */
151737 {
151738 sqlite3WindowListDelete(pParse->db, (yypminor->yy455));
151739 }
151740 break;
151741 case 253: /* using_opt */
151742 case 256: /* idlist */
151743 case 261: /* idlist_opt */
151744 {
151745 sqlite3IdListDelete(pParse->db, (yypminor->yy406));
151746 }
151747 break;
151748 case 263: /* filter_over */
151749 case 295: /* windowdefn */
151750 case 296: /* window */
151751 case 297: /* frame_opt */
151752 case 300: /* over_clause */
151753 {
151754 sqlite3WindowDelete(pParse->db, (yypminor->yy455));
151755 }
151756 break;
151757 case 276: /* trigger_cmd_list */
151758 case 281: /* trigger_cmd */
151759 {
151760 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy527));
151761 }
151762 break;
151763 case 278: /* trigger_event */
151764 {
151765 sqlite3IdListDelete(pParse->db, (yypminor->yy572).b);
151766 }
151767 break;
151768 case 302: /* frame_bound */
151769 case 303: /* frame_bound_s */
151770 case 304: /* frame_bound_e */
151771 {
151772 sqlite3ExprDelete(pParse->db, (yypminor->yy57).pExpr);
151773 }
151774 break;
151775 /********* End destructor definitions *****************************************/
151776 default: break; /* If no destructor action specified: do nothing */
151777 }
@@ -152058,391 +153181,395 @@
152058 }
152059
152060 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
152061 ** of that rule */
152062 static const YYCODETYPE yyRuleInfoLhs[] = {
152063 183, /* (0) explain ::= EXPLAIN */
152064 183, /* (1) explain ::= EXPLAIN QUERY PLAN */
152065 182, /* (2) cmdx ::= cmd */
152066 184, /* (3) cmd ::= BEGIN transtype trans_opt */
152067 185, /* (4) transtype ::= */
152068 185, /* (5) transtype ::= DEFERRED */
152069 185, /* (6) transtype ::= IMMEDIATE */
152070 185, /* (7) transtype ::= EXCLUSIVE */
152071 184, /* (8) cmd ::= COMMIT|END trans_opt */
152072 184, /* (9) cmd ::= ROLLBACK trans_opt */
152073 184, /* (10) cmd ::= SAVEPOINT nm */
152074 184, /* (11) cmd ::= RELEASE savepoint_opt nm */
152075 184, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
152076 189, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
152077 191, /* (14) createkw ::= CREATE */
152078 193, /* (15) ifnotexists ::= */
152079 193, /* (16) ifnotexists ::= IF NOT EXISTS */
152080 192, /* (17) temp ::= TEMP */
152081 192, /* (18) temp ::= */
152082 190, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
152083 190, /* (20) create_table_args ::= AS select */
152084 197, /* (21) table_options ::= */
152085 197, /* (22) table_options ::= WITHOUT nm */
152086 199, /* (23) columnname ::= nm typetoken */
152087 201, /* (24) typetoken ::= */
152088 201, /* (25) typetoken ::= typename LP signed RP */
152089 201, /* (26) typetoken ::= typename LP signed COMMA signed RP */
152090 202, /* (27) typename ::= typename ID|STRING */
152091 206, /* (28) scanpt ::= */
152092 207, /* (29) scantok ::= */
152093 208, /* (30) ccons ::= CONSTRAINT nm */
152094 208, /* (31) ccons ::= DEFAULT scantok term */
152095 208, /* (32) ccons ::= DEFAULT LP expr RP */
152096 208, /* (33) ccons ::= DEFAULT PLUS scantok term */
152097 208, /* (34) ccons ::= DEFAULT MINUS scantok term */
152098 208, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
152099 208, /* (36) ccons ::= NOT NULL onconf */
152100 208, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
152101 208, /* (38) ccons ::= UNIQUE onconf */
152102 208, /* (39) ccons ::= CHECK LP expr RP */
152103 208, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
152104 208, /* (41) ccons ::= defer_subclause */
152105 208, /* (42) ccons ::= COLLATE ID|STRING */
152106 213, /* (43) autoinc ::= */
152107 213, /* (44) autoinc ::= AUTOINCR */
152108 215, /* (45) refargs ::= */
152109 215, /* (46) refargs ::= refargs refarg */
152110 217, /* (47) refarg ::= MATCH nm */
152111 217, /* (48) refarg ::= ON INSERT refact */
152112 217, /* (49) refarg ::= ON DELETE refact */
152113 217, /* (50) refarg ::= ON UPDATE refact */
152114 218, /* (51) refact ::= SET NULL */
152115 218, /* (52) refact ::= SET DEFAULT */
152116 218, /* (53) refact ::= CASCADE */
152117 218, /* (54) refact ::= RESTRICT */
152118 218, /* (55) refact ::= NO ACTION */
152119 216, /* (56) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
152120 216, /* (57) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
152121 219, /* (58) init_deferred_pred_opt ::= */
152122 219, /* (59) init_deferred_pred_opt ::= INITIALLY DEFERRED */
152123 219, /* (60) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
152124 196, /* (61) conslist_opt ::= */
152125 221, /* (62) tconscomma ::= COMMA */
152126 222, /* (63) tcons ::= CONSTRAINT nm */
152127 222, /* (64) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
152128 222, /* (65) tcons ::= UNIQUE LP sortlist RP onconf */
152129 222, /* (66) tcons ::= CHECK LP expr RP onconf */
152130 222, /* (67) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
152131 225, /* (68) defer_subclause_opt ::= */
152132 211, /* (69) onconf ::= */
152133 211, /* (70) onconf ::= ON CONFLICT resolvetype */
152134 226, /* (71) orconf ::= */
152135 226, /* (72) orconf ::= OR resolvetype */
152136 227, /* (73) resolvetype ::= IGNORE */
152137 227, /* (74) resolvetype ::= REPLACE */
152138 184, /* (75) cmd ::= DROP TABLE ifexists fullname */
152139 229, /* (76) ifexists ::= IF EXISTS */
152140 229, /* (77) ifexists ::= */
152141 184, /* (78) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
152142 184, /* (79) cmd ::= DROP VIEW ifexists fullname */
152143 184, /* (80) cmd ::= select */
152144 198, /* (81) select ::= WITH wqlist selectnowith */
152145 198, /* (82) select ::= WITH RECURSIVE wqlist selectnowith */
152146 198, /* (83) select ::= selectnowith */
152147 231, /* (84) selectnowith ::= selectnowith multiselect_op oneselect */
152148 234, /* (85) multiselect_op ::= UNION */
152149 234, /* (86) multiselect_op ::= UNION ALL */
152150 234, /* (87) multiselect_op ::= EXCEPT|INTERSECT */
152151 232, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
152152 232, /* (89) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
152153 244, /* (90) values ::= VALUES LP nexprlist RP */
152154 244, /* (91) values ::= values COMMA LP nexprlist RP */
152155 235, /* (92) distinct ::= DISTINCT */
152156 235, /* (93) distinct ::= ALL */
152157 235, /* (94) distinct ::= */
152158 246, /* (95) sclp ::= */
152159 236, /* (96) selcollist ::= sclp scanpt expr scanpt as */
152160 236, /* (97) selcollist ::= sclp scanpt STAR */
152161 236, /* (98) selcollist ::= sclp scanpt nm DOT STAR */
152162 247, /* (99) as ::= AS nm */
152163 247, /* (100) as ::= */
152164 237, /* (101) from ::= */
152165 237, /* (102) from ::= FROM seltablist */
152166 249, /* (103) stl_prefix ::= seltablist joinop */
152167 249, /* (104) stl_prefix ::= */
152168 248, /* (105) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
152169 248, /* (106) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
152170 248, /* (107) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
152171 248, /* (108) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
152172 194, /* (109) dbnm ::= */
152173 194, /* (110) dbnm ::= DOT nm */
152174 230, /* (111) fullname ::= nm */
152175 230, /* (112) fullname ::= nm DOT nm */
152176 255, /* (113) xfullname ::= nm */
152177 255, /* (114) xfullname ::= nm DOT nm */
152178 255, /* (115) xfullname ::= nm DOT nm AS nm */
152179 255, /* (116) xfullname ::= nm AS nm */
152180 250, /* (117) joinop ::= COMMA|JOIN */
152181 250, /* (118) joinop ::= JOIN_KW JOIN */
152182 250, /* (119) joinop ::= JOIN_KW nm JOIN */
152183 250, /* (120) joinop ::= JOIN_KW nm nm JOIN */
152184 252, /* (121) on_opt ::= ON expr */
152185 252, /* (122) on_opt ::= */
152186 251, /* (123) indexed_opt ::= */
152187 251, /* (124) indexed_opt ::= INDEXED BY nm */
152188 251, /* (125) indexed_opt ::= NOT INDEXED */
152189 253, /* (126) using_opt ::= USING LP idlist RP */
152190 253, /* (127) using_opt ::= */
152191 241, /* (128) orderby_opt ::= */
152192 241, /* (129) orderby_opt ::= ORDER BY sortlist */
152193 223, /* (130) sortlist ::= sortlist COMMA expr sortorder nulls */
152194 223, /* (131) sortlist ::= expr sortorder nulls */
152195 212, /* (132) sortorder ::= ASC */
152196 212, /* (133) sortorder ::= DESC */
152197 212, /* (134) sortorder ::= */
152198 257, /* (135) nulls ::= NULLS FIRST */
152199 257, /* (136) nulls ::= NULLS LAST */
152200 257, /* (137) nulls ::= */
152201 239, /* (138) groupby_opt ::= */
152202 239, /* (139) groupby_opt ::= GROUP BY nexprlist */
152203 240, /* (140) having_opt ::= */
152204 240, /* (141) having_opt ::= HAVING expr */
152205 242, /* (142) limit_opt ::= */
152206 242, /* (143) limit_opt ::= LIMIT expr */
152207 242, /* (144) limit_opt ::= LIMIT expr OFFSET expr */
152208 242, /* (145) limit_opt ::= LIMIT expr COMMA expr */
152209 184, /* (146) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
152210 238, /* (147) where_opt ::= */
152211 238, /* (148) where_opt ::= WHERE expr */
152212 184, /* (149) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
152213 259, /* (150) setlist ::= setlist COMMA nm EQ expr */
152214 259, /* (151) setlist ::= setlist COMMA LP idlist RP EQ expr */
152215 259, /* (152) setlist ::= nm EQ expr */
152216 259, /* (153) setlist ::= LP idlist RP EQ expr */
152217 184, /* (154) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
152218 184, /* (155) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
152219 262, /* (156) upsert ::= */
152220 262, /* (157) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
152221 262, /* (158) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
152222 262, /* (159) upsert ::= ON CONFLICT DO NOTHING */
152223 260, /* (160) insert_cmd ::= INSERT orconf */
152224 260, /* (161) insert_cmd ::= REPLACE */
152225 261, /* (162) idlist_opt ::= */
152226 261, /* (163) idlist_opt ::= LP idlist RP */
152227 256, /* (164) idlist ::= idlist COMMA nm */
152228 256, /* (165) idlist ::= nm */
152229 210, /* (166) expr ::= LP expr RP */
152230 210, /* (167) expr ::= ID|INDEXED */
152231 210, /* (168) expr ::= JOIN_KW */
152232 210, /* (169) expr ::= nm DOT nm */
152233 210, /* (170) expr ::= nm DOT nm DOT nm */
152234 209, /* (171) term ::= NULL|FLOAT|BLOB */
152235 209, /* (172) term ::= STRING */
152236 209, /* (173) term ::= INTEGER */
152237 210, /* (174) expr ::= VARIABLE */
152238 210, /* (175) expr ::= expr COLLATE ID|STRING */
152239 210, /* (176) expr ::= CAST LP expr AS typetoken RP */
152240 210, /* (177) expr ::= ID|INDEXED LP distinct exprlist RP */
152241 210, /* (178) expr ::= ID|INDEXED LP STAR RP */
152242 210, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
152243 210, /* (180) expr ::= ID|INDEXED LP STAR RP filter_over */
152244 209, /* (181) term ::= CTIME_KW */
152245 210, /* (182) expr ::= LP nexprlist COMMA expr RP */
152246 210, /* (183) expr ::= expr AND expr */
152247 210, /* (184) expr ::= expr OR expr */
152248 210, /* (185) expr ::= expr LT|GT|GE|LE expr */
152249 210, /* (186) expr ::= expr EQ|NE expr */
152250 210, /* (187) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
152251 210, /* (188) expr ::= expr PLUS|MINUS expr */
152252 210, /* (189) expr ::= expr STAR|SLASH|REM expr */
152253 210, /* (190) expr ::= expr CONCAT expr */
152254 264, /* (191) likeop ::= NOT LIKE_KW|MATCH */
152255 210, /* (192) expr ::= expr likeop expr */
152256 210, /* (193) expr ::= expr likeop expr ESCAPE expr */
152257 210, /* (194) expr ::= expr ISNULL|NOTNULL */
152258 210, /* (195) expr ::= expr NOT NULL */
152259 210, /* (196) expr ::= expr IS expr */
152260 210, /* (197) expr ::= expr IS NOT expr */
152261 210, /* (198) expr ::= NOT expr */
152262 210, /* (199) expr ::= BITNOT expr */
152263 210, /* (200) expr ::= PLUS|MINUS expr */
152264 265, /* (201) between_op ::= BETWEEN */
152265 265, /* (202) between_op ::= NOT BETWEEN */
152266 210, /* (203) expr ::= expr between_op expr AND expr */
152267 266, /* (204) in_op ::= IN */
152268 266, /* (205) in_op ::= NOT IN */
152269 210, /* (206) expr ::= expr in_op LP exprlist RP */
152270 210, /* (207) expr ::= LP select RP */
152271 210, /* (208) expr ::= expr in_op LP select RP */
152272 210, /* (209) expr ::= expr in_op nm dbnm paren_exprlist */
152273 210, /* (210) expr ::= EXISTS LP select RP */
152274 210, /* (211) expr ::= CASE case_operand case_exprlist case_else END */
152275 269, /* (212) case_exprlist ::= case_exprlist WHEN expr THEN expr */
152276 269, /* (213) case_exprlist ::= WHEN expr THEN expr */
152277 270, /* (214) case_else ::= ELSE expr */
152278 270, /* (215) case_else ::= */
152279 268, /* (216) case_operand ::= expr */
152280 268, /* (217) case_operand ::= */
152281 254, /* (218) exprlist ::= */
152282 245, /* (219) nexprlist ::= nexprlist COMMA expr */
152283 245, /* (220) nexprlist ::= expr */
152284 267, /* (221) paren_exprlist ::= */
152285 267, /* (222) paren_exprlist ::= LP exprlist RP */
152286 184, /* (223) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
152287 271, /* (224) uniqueflag ::= UNIQUE */
152288 271, /* (225) uniqueflag ::= */
152289 214, /* (226) eidlist_opt ::= */
152290 214, /* (227) eidlist_opt ::= LP eidlist RP */
152291 224, /* (228) eidlist ::= eidlist COMMA nm collate sortorder */
152292 224, /* (229) eidlist ::= nm collate sortorder */
152293 272, /* (230) collate ::= */
152294 272, /* (231) collate ::= COLLATE ID|STRING */
152295 184, /* (232) cmd ::= DROP INDEX ifexists fullname */
152296 184, /* (233) cmd ::= VACUUM vinto */
152297 184, /* (234) cmd ::= VACUUM nm vinto */
152298 273, /* (235) vinto ::= INTO expr */
152299 273, /* (236) vinto ::= */
152300 184, /* (237) cmd ::= PRAGMA nm dbnm */
152301 184, /* (238) cmd ::= PRAGMA nm dbnm EQ nmnum */
152302 184, /* (239) cmd ::= PRAGMA nm dbnm LP nmnum RP */
152303 184, /* (240) cmd ::= PRAGMA nm dbnm EQ minus_num */
152304 184, /* (241) cmd ::= PRAGMA nm dbnm LP minus_num RP */
152305 204, /* (242) plus_num ::= PLUS INTEGER|FLOAT */
152306 205, /* (243) minus_num ::= MINUS INTEGER|FLOAT */
152307 184, /* (244) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
152308 275, /* (245) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
152309 277, /* (246) trigger_time ::= BEFORE|AFTER */
152310 277, /* (247) trigger_time ::= INSTEAD OF */
152311 277, /* (248) trigger_time ::= */
152312 278, /* (249) trigger_event ::= DELETE|INSERT */
152313 278, /* (250) trigger_event ::= UPDATE */
152314 278, /* (251) trigger_event ::= UPDATE OF idlist */
152315 280, /* (252) when_clause ::= */
152316 280, /* (253) when_clause ::= WHEN expr */
152317 276, /* (254) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
152318 276, /* (255) trigger_cmd_list ::= trigger_cmd SEMI */
152319 282, /* (256) trnm ::= nm DOT nm */
152320 283, /* (257) tridxby ::= INDEXED BY nm */
152321 283, /* (258) tridxby ::= NOT INDEXED */
152322 281, /* (259) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
152323 281, /* (260) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
152324 281, /* (261) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
152325 281, /* (262) trigger_cmd ::= scanpt select scanpt */
152326 210, /* (263) expr ::= RAISE LP IGNORE RP */
152327 210, /* (264) expr ::= RAISE LP raisetype COMMA nm RP */
152328 228, /* (265) raisetype ::= ROLLBACK */
152329 228, /* (266) raisetype ::= ABORT */
152330 228, /* (267) raisetype ::= FAIL */
152331 184, /* (268) cmd ::= DROP TRIGGER ifexists fullname */
152332 184, /* (269) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
152333 184, /* (270) cmd ::= DETACH database_kw_opt expr */
152334 285, /* (271) key_opt ::= */
152335 285, /* (272) key_opt ::= KEY expr */
152336 184, /* (273) cmd ::= REINDEX */
152337 184, /* (274) cmd ::= REINDEX nm dbnm */
152338 184, /* (275) cmd ::= ANALYZE */
152339 184, /* (276) cmd ::= ANALYZE nm dbnm */
152340 184, /* (277) cmd ::= ALTER TABLE fullname RENAME TO nm */
152341 184, /* (278) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
152342 286, /* (279) add_column_fullname ::= fullname */
152343 184, /* (280) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
152344 184, /* (281) cmd ::= create_vtab */
152345 184, /* (282) cmd ::= create_vtab LP vtabarglist RP */
152346 288, /* (283) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
152347 290, /* (284) vtabarg ::= */
152348 291, /* (285) vtabargtoken ::= ANY */
152349 291, /* (286) vtabargtoken ::= lp anylist RP */
152350 292, /* (287) lp ::= LP */
152351 258, /* (288) with ::= WITH wqlist */
152352 258, /* (289) with ::= WITH RECURSIVE wqlist */
152353 233, /* (290) wqlist ::= nm eidlist_opt AS LP select RP */
152354 233, /* (291) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
152355 294, /* (292) windowdefn_list ::= windowdefn */
152356 294, /* (293) windowdefn_list ::= windowdefn_list COMMA windowdefn */
152357 295, /* (294) windowdefn ::= nm AS LP window RP */
152358 296, /* (295) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
152359 296, /* (296) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
152360 296, /* (297) window ::= ORDER BY sortlist frame_opt */
152361 296, /* (298) window ::= nm ORDER BY sortlist frame_opt */
152362 296, /* (299) window ::= frame_opt */
152363 296, /* (300) window ::= nm frame_opt */
152364 297, /* (301) frame_opt ::= */
152365 297, /* (302) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
152366 297, /* (303) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
152367 301, /* (304) range_or_rows ::= RANGE|ROWS|GROUPS */
152368 303, /* (305) frame_bound_s ::= frame_bound */
152369 303, /* (306) frame_bound_s ::= UNBOUNDED PRECEDING */
152370 304, /* (307) frame_bound_e ::= frame_bound */
152371 304, /* (308) frame_bound_e ::= UNBOUNDED FOLLOWING */
152372 302, /* (309) frame_bound ::= expr PRECEDING|FOLLOWING */
152373 302, /* (310) frame_bound ::= CURRENT ROW */
152374 305, /* (311) frame_exclude_opt ::= */
152375 305, /* (312) frame_exclude_opt ::= EXCLUDE frame_exclude */
152376 306, /* (313) frame_exclude ::= NO OTHERS */
152377 306, /* (314) frame_exclude ::= CURRENT ROW */
152378 306, /* (315) frame_exclude ::= GROUP|TIES */
152379 243, /* (316) window_clause ::= WINDOW windowdefn_list */
152380 263, /* (317) filter_over ::= filter_clause over_clause */
152381 263, /* (318) filter_over ::= over_clause */
152382 263, /* (319) filter_over ::= filter_clause */
152383 300, /* (320) over_clause ::= OVER LP window RP */
152384 300, /* (321) over_clause ::= OVER nm */
152385 299, /* (322) filter_clause ::= FILTER LP WHERE expr RP */
152386 179, /* (323) input ::= cmdlist */
152387 180, /* (324) cmdlist ::= cmdlist ecmd */
152388 180, /* (325) cmdlist ::= ecmd */
152389 181, /* (326) ecmd ::= SEMI */
152390 181, /* (327) ecmd ::= cmdx SEMI */
152391 181, /* (328) ecmd ::= explain cmdx */
152392 186, /* (329) trans_opt ::= */
152393 186, /* (330) trans_opt ::= TRANSACTION */
152394 186, /* (331) trans_opt ::= TRANSACTION nm */
152395 188, /* (332) savepoint_opt ::= SAVEPOINT */
152396 188, /* (333) savepoint_opt ::= */
152397 184, /* (334) cmd ::= create_table create_table_args */
152398 195, /* (335) columnlist ::= columnlist COMMA columnname carglist */
152399 195, /* (336) columnlist ::= columnname carglist */
152400 187, /* (337) nm ::= ID|INDEXED */
152401 187, /* (338) nm ::= STRING */
152402 187, /* (339) nm ::= JOIN_KW */
152403 201, /* (340) typetoken ::= typename */
152404 202, /* (341) typename ::= ID|STRING */
152405 203, /* (342) signed ::= plus_num */
152406 203, /* (343) signed ::= minus_num */
152407 200, /* (344) carglist ::= carglist ccons */
152408 200, /* (345) carglist ::= */
152409 208, /* (346) ccons ::= NULL onconf */
152410 196, /* (347) conslist_opt ::= COMMA conslist */
152411 220, /* (348) conslist ::= conslist tconscomma tcons */
152412 220, /* (349) conslist ::= tcons */
152413 221, /* (350) tconscomma ::= */
152414 225, /* (351) defer_subclause_opt ::= defer_subclause */
152415 227, /* (352) resolvetype ::= raisetype */
152416 231, /* (353) selectnowith ::= oneselect */
152417 232, /* (354) oneselect ::= values */
152418 246, /* (355) sclp ::= selcollist COMMA */
152419 247, /* (356) as ::= ID|STRING */
152420 210, /* (357) expr ::= term */
152421 264, /* (358) likeop ::= LIKE_KW|MATCH */
152422 254, /* (359) exprlist ::= nexprlist */
152423 274, /* (360) nmnum ::= plus_num */
152424 274, /* (361) nmnum ::= nm */
152425 274, /* (362) nmnum ::= ON */
152426 274, /* (363) nmnum ::= DELETE */
152427 274, /* (364) nmnum ::= DEFAULT */
152428 204, /* (365) plus_num ::= INTEGER|FLOAT */
152429 279, /* (366) foreach_clause ::= */
152430 279, /* (367) foreach_clause ::= FOR EACH ROW */
152431 282, /* (368) trnm ::= nm */
152432 283, /* (369) tridxby ::= */
152433 284, /* (370) database_kw_opt ::= DATABASE */
152434 284, /* (371) database_kw_opt ::= */
152435 287, /* (372) kwcolumn_opt ::= */
152436 287, /* (373) kwcolumn_opt ::= COLUMNKW */
152437 289, /* (374) vtabarglist ::= vtabarg */
152438 289, /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */
152439 290, /* (376) vtabarg ::= vtabarg vtabargtoken */
152440 293, /* (377) anylist ::= */
152441 293, /* (378) anylist ::= anylist LP anylist RP */
152442 293, /* (379) anylist ::= anylist ANY */
152443 258, /* (380) with ::= */
 
 
 
 
152444 };
152445
152446 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
152447 ** of symbols on the right-hand side of that rule. */
152448 static const signed char yyRuleInfoNRhs[] = {
@@ -152487,348 +153614,352 @@
152487 -2, /* (38) ccons ::= UNIQUE onconf */
152488 -4, /* (39) ccons ::= CHECK LP expr RP */
152489 -4, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
152490 -1, /* (41) ccons ::= defer_subclause */
152491 -2, /* (42) ccons ::= COLLATE ID|STRING */
152492 0, /* (43) autoinc ::= */
152493 -1, /* (44) autoinc ::= AUTOINCR */
152494 0, /* (45) refargs ::= */
152495 -2, /* (46) refargs ::= refargs refarg */
152496 -2, /* (47) refarg ::= MATCH nm */
152497 -3, /* (48) refarg ::= ON INSERT refact */
152498 -3, /* (49) refarg ::= ON DELETE refact */
152499 -3, /* (50) refarg ::= ON UPDATE refact */
152500 -2, /* (51) refact ::= SET NULL */
152501 -2, /* (52) refact ::= SET DEFAULT */
152502 -1, /* (53) refact ::= CASCADE */
152503 -1, /* (54) refact ::= RESTRICT */
152504 -2, /* (55) refact ::= NO ACTION */
152505 -3, /* (56) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
152506 -2, /* (57) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
152507 0, /* (58) init_deferred_pred_opt ::= */
152508 -2, /* (59) init_deferred_pred_opt ::= INITIALLY DEFERRED */
152509 -2, /* (60) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
152510 0, /* (61) conslist_opt ::= */
152511 -1, /* (62) tconscomma ::= COMMA */
152512 -2, /* (63) tcons ::= CONSTRAINT nm */
152513 -7, /* (64) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
152514 -5, /* (65) tcons ::= UNIQUE LP sortlist RP onconf */
152515 -5, /* (66) tcons ::= CHECK LP expr RP onconf */
152516 -10, /* (67) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
152517 0, /* (68) defer_subclause_opt ::= */
152518 0, /* (69) onconf ::= */
152519 -3, /* (70) onconf ::= ON CONFLICT resolvetype */
152520 0, /* (71) orconf ::= */
152521 -2, /* (72) orconf ::= OR resolvetype */
152522 -1, /* (73) resolvetype ::= IGNORE */
152523 -1, /* (74) resolvetype ::= REPLACE */
152524 -4, /* (75) cmd ::= DROP TABLE ifexists fullname */
152525 -2, /* (76) ifexists ::= IF EXISTS */
152526 0, /* (77) ifexists ::= */
152527 -9, /* (78) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
152528 -4, /* (79) cmd ::= DROP VIEW ifexists fullname */
152529 -1, /* (80) cmd ::= select */
152530 -3, /* (81) select ::= WITH wqlist selectnowith */
152531 -4, /* (82) select ::= WITH RECURSIVE wqlist selectnowith */
152532 -1, /* (83) select ::= selectnowith */
152533 -3, /* (84) selectnowith ::= selectnowith multiselect_op oneselect */
152534 -1, /* (85) multiselect_op ::= UNION */
152535 -2, /* (86) multiselect_op ::= UNION ALL */
152536 -1, /* (87) multiselect_op ::= EXCEPT|INTERSECT */
152537 -9, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
152538 -10, /* (89) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
152539 -4, /* (90) values ::= VALUES LP nexprlist RP */
152540 -5, /* (91) values ::= values COMMA LP nexprlist RP */
152541 -1, /* (92) distinct ::= DISTINCT */
152542 -1, /* (93) distinct ::= ALL */
152543 0, /* (94) distinct ::= */
152544 0, /* (95) sclp ::= */
152545 -5, /* (96) selcollist ::= sclp scanpt expr scanpt as */
152546 -3, /* (97) selcollist ::= sclp scanpt STAR */
152547 -5, /* (98) selcollist ::= sclp scanpt nm DOT STAR */
152548 -2, /* (99) as ::= AS nm */
152549 0, /* (100) as ::= */
152550 0, /* (101) from ::= */
152551 -2, /* (102) from ::= FROM seltablist */
152552 -2, /* (103) stl_prefix ::= seltablist joinop */
152553 0, /* (104) stl_prefix ::= */
152554 -7, /* (105) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
152555 -9, /* (106) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
152556 -7, /* (107) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
152557 -7, /* (108) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
152558 0, /* (109) dbnm ::= */
152559 -2, /* (110) dbnm ::= DOT nm */
152560 -1, /* (111) fullname ::= nm */
152561 -3, /* (112) fullname ::= nm DOT nm */
152562 -1, /* (113) xfullname ::= nm */
152563 -3, /* (114) xfullname ::= nm DOT nm */
152564 -5, /* (115) xfullname ::= nm DOT nm AS nm */
152565 -3, /* (116) xfullname ::= nm AS nm */
152566 -1, /* (117) joinop ::= COMMA|JOIN */
152567 -2, /* (118) joinop ::= JOIN_KW JOIN */
152568 -3, /* (119) joinop ::= JOIN_KW nm JOIN */
152569 -4, /* (120) joinop ::= JOIN_KW nm nm JOIN */
152570 -2, /* (121) on_opt ::= ON expr */
152571 0, /* (122) on_opt ::= */
152572 0, /* (123) indexed_opt ::= */
152573 -3, /* (124) indexed_opt ::= INDEXED BY nm */
152574 -2, /* (125) indexed_opt ::= NOT INDEXED */
152575 -4, /* (126) using_opt ::= USING LP idlist RP */
152576 0, /* (127) using_opt ::= */
152577 0, /* (128) orderby_opt ::= */
152578 -3, /* (129) orderby_opt ::= ORDER BY sortlist */
152579 -5, /* (130) sortlist ::= sortlist COMMA expr sortorder nulls */
152580 -3, /* (131) sortlist ::= expr sortorder nulls */
152581 -1, /* (132) sortorder ::= ASC */
152582 -1, /* (133) sortorder ::= DESC */
152583 0, /* (134) sortorder ::= */
152584 -2, /* (135) nulls ::= NULLS FIRST */
152585 -2, /* (136) nulls ::= NULLS LAST */
152586 0, /* (137) nulls ::= */
152587 0, /* (138) groupby_opt ::= */
152588 -3, /* (139) groupby_opt ::= GROUP BY nexprlist */
152589 0, /* (140) having_opt ::= */
152590 -2, /* (141) having_opt ::= HAVING expr */
152591 0, /* (142) limit_opt ::= */
152592 -2, /* (143) limit_opt ::= LIMIT expr */
152593 -4, /* (144) limit_opt ::= LIMIT expr OFFSET expr */
152594 -4, /* (145) limit_opt ::= LIMIT expr COMMA expr */
152595 -6, /* (146) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
152596 0, /* (147) where_opt ::= */
152597 -2, /* (148) where_opt ::= WHERE expr */
152598 -8, /* (149) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
152599 -5, /* (150) setlist ::= setlist COMMA nm EQ expr */
152600 -7, /* (151) setlist ::= setlist COMMA LP idlist RP EQ expr */
152601 -3, /* (152) setlist ::= nm EQ expr */
152602 -5, /* (153) setlist ::= LP idlist RP EQ expr */
152603 -7, /* (154) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
152604 -7, /* (155) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
152605 0, /* (156) upsert ::= */
152606 -11, /* (157) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
152607 -8, /* (158) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
152608 -4, /* (159) upsert ::= ON CONFLICT DO NOTHING */
152609 -2, /* (160) insert_cmd ::= INSERT orconf */
152610 -1, /* (161) insert_cmd ::= REPLACE */
152611 0, /* (162) idlist_opt ::= */
152612 -3, /* (163) idlist_opt ::= LP idlist RP */
152613 -3, /* (164) idlist ::= idlist COMMA nm */
152614 -1, /* (165) idlist ::= nm */
152615 -3, /* (166) expr ::= LP expr RP */
152616 -1, /* (167) expr ::= ID|INDEXED */
152617 -1, /* (168) expr ::= JOIN_KW */
152618 -3, /* (169) expr ::= nm DOT nm */
152619 -5, /* (170) expr ::= nm DOT nm DOT nm */
152620 -1, /* (171) term ::= NULL|FLOAT|BLOB */
152621 -1, /* (172) term ::= STRING */
152622 -1, /* (173) term ::= INTEGER */
152623 -1, /* (174) expr ::= VARIABLE */
152624 -3, /* (175) expr ::= expr COLLATE ID|STRING */
152625 -6, /* (176) expr ::= CAST LP expr AS typetoken RP */
152626 -5, /* (177) expr ::= ID|INDEXED LP distinct exprlist RP */
152627 -4, /* (178) expr ::= ID|INDEXED LP STAR RP */
152628 -6, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
152629 -5, /* (180) expr ::= ID|INDEXED LP STAR RP filter_over */
152630 -1, /* (181) term ::= CTIME_KW */
152631 -5, /* (182) expr ::= LP nexprlist COMMA expr RP */
152632 -3, /* (183) expr ::= expr AND expr */
152633 -3, /* (184) expr ::= expr OR expr */
152634 -3, /* (185) expr ::= expr LT|GT|GE|LE expr */
152635 -3, /* (186) expr ::= expr EQ|NE expr */
152636 -3, /* (187) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
152637 -3, /* (188) expr ::= expr PLUS|MINUS expr */
152638 -3, /* (189) expr ::= expr STAR|SLASH|REM expr */
152639 -3, /* (190) expr ::= expr CONCAT expr */
152640 -2, /* (191) likeop ::= NOT LIKE_KW|MATCH */
152641 -3, /* (192) expr ::= expr likeop expr */
152642 -5, /* (193) expr ::= expr likeop expr ESCAPE expr */
152643 -2, /* (194) expr ::= expr ISNULL|NOTNULL */
152644 -3, /* (195) expr ::= expr NOT NULL */
152645 -3, /* (196) expr ::= expr IS expr */
152646 -4, /* (197) expr ::= expr IS NOT expr */
152647 -2, /* (198) expr ::= NOT expr */
152648 -2, /* (199) expr ::= BITNOT expr */
152649 -2, /* (200) expr ::= PLUS|MINUS expr */
152650 -1, /* (201) between_op ::= BETWEEN */
152651 -2, /* (202) between_op ::= NOT BETWEEN */
152652 -5, /* (203) expr ::= expr between_op expr AND expr */
152653 -1, /* (204) in_op ::= IN */
152654 -2, /* (205) in_op ::= NOT IN */
152655 -5, /* (206) expr ::= expr in_op LP exprlist RP */
152656 -3, /* (207) expr ::= LP select RP */
152657 -5, /* (208) expr ::= expr in_op LP select RP */
152658 -5, /* (209) expr ::= expr in_op nm dbnm paren_exprlist */
152659 -4, /* (210) expr ::= EXISTS LP select RP */
152660 -5, /* (211) expr ::= CASE case_operand case_exprlist case_else END */
152661 -5, /* (212) case_exprlist ::= case_exprlist WHEN expr THEN expr */
152662 -4, /* (213) case_exprlist ::= WHEN expr THEN expr */
152663 -2, /* (214) case_else ::= ELSE expr */
152664 0, /* (215) case_else ::= */
152665 -1, /* (216) case_operand ::= expr */
152666 0, /* (217) case_operand ::= */
152667 0, /* (218) exprlist ::= */
152668 -3, /* (219) nexprlist ::= nexprlist COMMA expr */
152669 -1, /* (220) nexprlist ::= expr */
152670 0, /* (221) paren_exprlist ::= */
152671 -3, /* (222) paren_exprlist ::= LP exprlist RP */
152672 -12, /* (223) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
152673 -1, /* (224) uniqueflag ::= UNIQUE */
152674 0, /* (225) uniqueflag ::= */
152675 0, /* (226) eidlist_opt ::= */
152676 -3, /* (227) eidlist_opt ::= LP eidlist RP */
152677 -5, /* (228) eidlist ::= eidlist COMMA nm collate sortorder */
152678 -3, /* (229) eidlist ::= nm collate sortorder */
152679 0, /* (230) collate ::= */
152680 -2, /* (231) collate ::= COLLATE ID|STRING */
152681 -4, /* (232) cmd ::= DROP INDEX ifexists fullname */
152682 -2, /* (233) cmd ::= VACUUM vinto */
152683 -3, /* (234) cmd ::= VACUUM nm vinto */
152684 -2, /* (235) vinto ::= INTO expr */
152685 0, /* (236) vinto ::= */
152686 -3, /* (237) cmd ::= PRAGMA nm dbnm */
152687 -5, /* (238) cmd ::= PRAGMA nm dbnm EQ nmnum */
152688 -6, /* (239) cmd ::= PRAGMA nm dbnm LP nmnum RP */
152689 -5, /* (240) cmd ::= PRAGMA nm dbnm EQ minus_num */
152690 -6, /* (241) cmd ::= PRAGMA nm dbnm LP minus_num RP */
152691 -2, /* (242) plus_num ::= PLUS INTEGER|FLOAT */
152692 -2, /* (243) minus_num ::= MINUS INTEGER|FLOAT */
152693 -5, /* (244) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
152694 -11, /* (245) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
152695 -1, /* (246) trigger_time ::= BEFORE|AFTER */
152696 -2, /* (247) trigger_time ::= INSTEAD OF */
152697 0, /* (248) trigger_time ::= */
152698 -1, /* (249) trigger_event ::= DELETE|INSERT */
152699 -1, /* (250) trigger_event ::= UPDATE */
152700 -3, /* (251) trigger_event ::= UPDATE OF idlist */
152701 0, /* (252) when_clause ::= */
152702 -2, /* (253) when_clause ::= WHEN expr */
152703 -3, /* (254) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
152704 -2, /* (255) trigger_cmd_list ::= trigger_cmd SEMI */
152705 -3, /* (256) trnm ::= nm DOT nm */
152706 -3, /* (257) tridxby ::= INDEXED BY nm */
152707 -2, /* (258) tridxby ::= NOT INDEXED */
152708 -8, /* (259) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
152709 -8, /* (260) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
152710 -6, /* (261) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
152711 -3, /* (262) trigger_cmd ::= scanpt select scanpt */
152712 -4, /* (263) expr ::= RAISE LP IGNORE RP */
152713 -6, /* (264) expr ::= RAISE LP raisetype COMMA nm RP */
152714 -1, /* (265) raisetype ::= ROLLBACK */
152715 -1, /* (266) raisetype ::= ABORT */
152716 -1, /* (267) raisetype ::= FAIL */
152717 -4, /* (268) cmd ::= DROP TRIGGER ifexists fullname */
152718 -6, /* (269) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
152719 -3, /* (270) cmd ::= DETACH database_kw_opt expr */
152720 0, /* (271) key_opt ::= */
152721 -2, /* (272) key_opt ::= KEY expr */
152722 -1, /* (273) cmd ::= REINDEX */
152723 -3, /* (274) cmd ::= REINDEX nm dbnm */
152724 -1, /* (275) cmd ::= ANALYZE */
152725 -3, /* (276) cmd ::= ANALYZE nm dbnm */
152726 -6, /* (277) cmd ::= ALTER TABLE fullname RENAME TO nm */
152727 -7, /* (278) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
152728 -1, /* (279) add_column_fullname ::= fullname */
152729 -8, /* (280) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
152730 -1, /* (281) cmd ::= create_vtab */
152731 -4, /* (282) cmd ::= create_vtab LP vtabarglist RP */
152732 -8, /* (283) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
152733 0, /* (284) vtabarg ::= */
152734 -1, /* (285) vtabargtoken ::= ANY */
152735 -3, /* (286) vtabargtoken ::= lp anylist RP */
152736 -1, /* (287) lp ::= LP */
152737 -2, /* (288) with ::= WITH wqlist */
152738 -3, /* (289) with ::= WITH RECURSIVE wqlist */
152739 -6, /* (290) wqlist ::= nm eidlist_opt AS LP select RP */
152740 -8, /* (291) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
152741 -1, /* (292) windowdefn_list ::= windowdefn */
152742 -3, /* (293) windowdefn_list ::= windowdefn_list COMMA windowdefn */
152743 -5, /* (294) windowdefn ::= nm AS LP window RP */
152744 -5, /* (295) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
152745 -6, /* (296) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
152746 -4, /* (297) window ::= ORDER BY sortlist frame_opt */
152747 -5, /* (298) window ::= nm ORDER BY sortlist frame_opt */
152748 -1, /* (299) window ::= frame_opt */
152749 -2, /* (300) window ::= nm frame_opt */
152750 0, /* (301) frame_opt ::= */
152751 -3, /* (302) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
152752 -6, /* (303) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
152753 -1, /* (304) range_or_rows ::= RANGE|ROWS|GROUPS */
152754 -1, /* (305) frame_bound_s ::= frame_bound */
152755 -2, /* (306) frame_bound_s ::= UNBOUNDED PRECEDING */
152756 -1, /* (307) frame_bound_e ::= frame_bound */
152757 -2, /* (308) frame_bound_e ::= UNBOUNDED FOLLOWING */
152758 -2, /* (309) frame_bound ::= expr PRECEDING|FOLLOWING */
152759 -2, /* (310) frame_bound ::= CURRENT ROW */
152760 0, /* (311) frame_exclude_opt ::= */
152761 -2, /* (312) frame_exclude_opt ::= EXCLUDE frame_exclude */
152762 -2, /* (313) frame_exclude ::= NO OTHERS */
152763 -2, /* (314) frame_exclude ::= CURRENT ROW */
152764 -1, /* (315) frame_exclude ::= GROUP|TIES */
152765 -2, /* (316) window_clause ::= WINDOW windowdefn_list */
152766 -2, /* (317) filter_over ::= filter_clause over_clause */
152767 -1, /* (318) filter_over ::= over_clause */
152768 -1, /* (319) filter_over ::= filter_clause */
152769 -4, /* (320) over_clause ::= OVER LP window RP */
152770 -2, /* (321) over_clause ::= OVER nm */
152771 -5, /* (322) filter_clause ::= FILTER LP WHERE expr RP */
152772 -1, /* (323) input ::= cmdlist */
152773 -2, /* (324) cmdlist ::= cmdlist ecmd */
152774 -1, /* (325) cmdlist ::= ecmd */
152775 -1, /* (326) ecmd ::= SEMI */
152776 -2, /* (327) ecmd ::= cmdx SEMI */
152777 -2, /* (328) ecmd ::= explain cmdx */
152778 0, /* (329) trans_opt ::= */
152779 -1, /* (330) trans_opt ::= TRANSACTION */
152780 -2, /* (331) trans_opt ::= TRANSACTION nm */
152781 -1, /* (332) savepoint_opt ::= SAVEPOINT */
152782 0, /* (333) savepoint_opt ::= */
152783 -2, /* (334) cmd ::= create_table create_table_args */
152784 -4, /* (335) columnlist ::= columnlist COMMA columnname carglist */
152785 -2, /* (336) columnlist ::= columnname carglist */
152786 -1, /* (337) nm ::= ID|INDEXED */
152787 -1, /* (338) nm ::= STRING */
152788 -1, /* (339) nm ::= JOIN_KW */
152789 -1, /* (340) typetoken ::= typename */
152790 -1, /* (341) typename ::= ID|STRING */
152791 -1, /* (342) signed ::= plus_num */
152792 -1, /* (343) signed ::= minus_num */
152793 -2, /* (344) carglist ::= carglist ccons */
152794 0, /* (345) carglist ::= */
152795 -2, /* (346) ccons ::= NULL onconf */
152796 -2, /* (347) conslist_opt ::= COMMA conslist */
152797 -3, /* (348) conslist ::= conslist tconscomma tcons */
152798 -1, /* (349) conslist ::= tcons */
152799 0, /* (350) tconscomma ::= */
152800 -1, /* (351) defer_subclause_opt ::= defer_subclause */
152801 -1, /* (352) resolvetype ::= raisetype */
152802 -1, /* (353) selectnowith ::= oneselect */
152803 -1, /* (354) oneselect ::= values */
152804 -2, /* (355) sclp ::= selcollist COMMA */
152805 -1, /* (356) as ::= ID|STRING */
152806 -1, /* (357) expr ::= term */
152807 -1, /* (358) likeop ::= LIKE_KW|MATCH */
152808 -1, /* (359) exprlist ::= nexprlist */
152809 -1, /* (360) nmnum ::= plus_num */
152810 -1, /* (361) nmnum ::= nm */
152811 -1, /* (362) nmnum ::= ON */
152812 -1, /* (363) nmnum ::= DELETE */
152813 -1, /* (364) nmnum ::= DEFAULT */
152814 -1, /* (365) plus_num ::= INTEGER|FLOAT */
152815 0, /* (366) foreach_clause ::= */
152816 -3, /* (367) foreach_clause ::= FOR EACH ROW */
152817 -1, /* (368) trnm ::= nm */
152818 0, /* (369) tridxby ::= */
152819 -1, /* (370) database_kw_opt ::= DATABASE */
152820 0, /* (371) database_kw_opt ::= */
152821 0, /* (372) kwcolumn_opt ::= */
152822 -1, /* (373) kwcolumn_opt ::= COLUMNKW */
152823 -1, /* (374) vtabarglist ::= vtabarg */
152824 -3, /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */
152825 -2, /* (376) vtabarg ::= vtabarg vtabargtoken */
152826 0, /* (377) anylist ::= */
152827 -4, /* (378) anylist ::= anylist LP anylist RP */
152828 -2, /* (379) anylist ::= anylist ANY */
152829 0, /* (380) with ::= */
 
 
 
 
152830 };
152831
152832 static void yy_accept(yyParser*); /* Forward Declaration */
152833
152834 /*
@@ -152921,20 +154052,20 @@
152921 break;
152922 case 2: /* cmdx ::= cmd */
152923 { sqlite3FinishCoding(pParse); }
152924 break;
152925 case 3: /* cmd ::= BEGIN transtype trans_opt */
152926 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy32);}
152927 break;
152928 case 4: /* transtype ::= */
152929 {yymsp[1].minor.yy32 = TK_DEFERRED;}
152930 break;
152931 case 5: /* transtype ::= DEFERRED */
152932 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
152933 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
152934 case 304: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==304);
152935 {yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-X*/}
152936 break;
152937 case 8: /* cmd ::= COMMIT|END trans_opt */
152938 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
152939 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
152940 break;
@@ -152953,61 +154084,61 @@
152953 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
152954 }
152955 break;
152956 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
152957 {
152958 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy32,0,0,yymsp[-2].minor.yy32);
152959 }
152960 break;
152961 case 14: /* createkw ::= CREATE */
152962 {disableLookaside(pParse);}
152963 break;
152964 case 15: /* ifnotexists ::= */
152965 case 18: /* temp ::= */ yytestcase(yyruleno==18);
152966 case 21: /* table_options ::= */ yytestcase(yyruleno==21);
152967 case 43: /* autoinc ::= */ yytestcase(yyruleno==43);
152968 case 58: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==58);
152969 case 68: /* defer_subclause_opt ::= */ yytestcase(yyruleno==68);
152970 case 77: /* ifexists ::= */ yytestcase(yyruleno==77);
152971 case 94: /* distinct ::= */ yytestcase(yyruleno==94);
152972 case 230: /* collate ::= */ yytestcase(yyruleno==230);
152973 {yymsp[1].minor.yy32 = 0;}
152974 break;
152975 case 16: /* ifnotexists ::= IF NOT EXISTS */
152976 {yymsp[-2].minor.yy32 = 1;}
152977 break;
152978 case 17: /* temp ::= TEMP */
152979 case 44: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==44);
152980 {yymsp[0].minor.yy32 = 1;}
152981 break;
152982 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
152983 {
152984 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy32,0);
152985 }
152986 break;
152987 case 20: /* create_table_args ::= AS select */
152988 {
152989 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy25);
152990 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy25);
152991 }
152992 break;
152993 case 22: /* table_options ::= WITHOUT nm */
152994 {
152995 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
152996 yymsp[-1].minor.yy32 = TF_WithoutRowid | TF_NoVisibleRowid;
152997 }else{
152998 yymsp[-1].minor.yy32 = 0;
152999 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
153000 }
153001 }
153002 break;
153003 case 23: /* columnname ::= nm typetoken */
153004 {sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
153005 break;
153006 case 24: /* typetoken ::= */
153007 case 61: /* conslist_opt ::= */ yytestcase(yyruleno==61);
153008 case 100: /* as ::= */ yytestcase(yyruleno==100);
153009 {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
153010 break;
153011 case 25: /* typetoken ::= typename LP signed RP */
153012 {
153013 yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
@@ -153022,35 +154153,35 @@
153022 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
153023 break;
153024 case 28: /* scanpt ::= */
153025 {
153026 assert( yyLookahead!=YYNOCODE );
153027 yymsp[1].minor.yy8 = yyLookaheadToken.z;
153028 }
153029 break;
153030 case 29: /* scantok ::= */
153031 {
153032 assert( yyLookahead!=YYNOCODE );
153033 yymsp[1].minor.yy0 = yyLookaheadToken;
153034 }
153035 break;
153036 case 30: /* ccons ::= CONSTRAINT nm */
153037 case 63: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==63);
153038 {pParse->constraintName = yymsp[0].minor.yy0;}
153039 break;
153040 case 31: /* ccons ::= DEFAULT scantok term */
153041 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy46,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
153042 break;
153043 case 32: /* ccons ::= DEFAULT LP expr RP */
153044 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy46,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
153045 break;
153046 case 33: /* ccons ::= DEFAULT PLUS scantok term */
153047 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy46,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
153048 break;
153049 case 34: /* ccons ::= DEFAULT MINUS scantok term */
153050 {
153051 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy46, 0);
153052 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
153053 }
153054 break;
153055 case 35: /* ccons ::= DEFAULT scantok ID|INDEXED */
153056 {
@@ -153061,319 +154192,325 @@
153061 }
153062 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
153063 }
153064 break;
153065 case 36: /* ccons ::= NOT NULL onconf */
153066 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy32);}
153067 break;
153068 case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
153069 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy32,yymsp[0].minor.yy32,yymsp[-2].minor.yy32);}
153070 break;
153071 case 38: /* ccons ::= UNIQUE onconf */
153072 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy32,0,0,0,0,
153073 SQLITE_IDXTYPE_UNIQUE);}
153074 break;
153075 case 39: /* ccons ::= CHECK LP expr RP */
153076 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy46);}
153077 break;
153078 case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */
153079 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy138,yymsp[0].minor.yy32);}
153080 break;
153081 case 41: /* ccons ::= defer_subclause */
153082 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy32);}
153083 break;
153084 case 42: /* ccons ::= COLLATE ID|STRING */
153085 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
153086 break;
153087 case 45: /* refargs ::= */
153088 { yymsp[1].minor.yy32 = OE_None*0x0101; /* EV: R-19803-45884 */}
153089 break;
153090 case 46: /* refargs ::= refargs refarg */
153091 { yymsp[-1].minor.yy32 = (yymsp[-1].minor.yy32 & ~yymsp[0].minor.yy495.mask) | yymsp[0].minor.yy495.value; }
153092 break;
153093 case 47: /* refarg ::= MATCH nm */
153094 { yymsp[-1].minor.yy495.value = 0; yymsp[-1].minor.yy495.mask = 0x000000; }
153095 break;
153096 case 48: /* refarg ::= ON INSERT refact */
153097 { yymsp[-2].minor.yy495.value = 0; yymsp[-2].minor.yy495.mask = 0x000000; }
153098 break;
153099 case 49: /* refarg ::= ON DELETE refact */
153100 { yymsp[-2].minor.yy495.value = yymsp[0].minor.yy32; yymsp[-2].minor.yy495.mask = 0x0000ff; }
153101 break;
153102 case 50: /* refarg ::= ON UPDATE refact */
153103 { yymsp[-2].minor.yy495.value = yymsp[0].minor.yy32<<8; yymsp[-2].minor.yy495.mask = 0x00ff00; }
153104 break;
153105 case 51: /* refact ::= SET NULL */
153106 { yymsp[-1].minor.yy32 = OE_SetNull; /* EV: R-33326-45252 */}
153107 break;
153108 case 52: /* refact ::= SET DEFAULT */
153109 { yymsp[-1].minor.yy32 = OE_SetDflt; /* EV: R-33326-45252 */}
153110 break;
153111 case 53: /* refact ::= CASCADE */
153112 { yymsp[0].minor.yy32 = OE_Cascade; /* EV: R-33326-45252 */}
153113 break;
153114 case 54: /* refact ::= RESTRICT */
153115 { yymsp[0].minor.yy32 = OE_Restrict; /* EV: R-33326-45252 */}
153116 break;
153117 case 55: /* refact ::= NO ACTION */
153118 { yymsp[-1].minor.yy32 = OE_None; /* EV: R-33326-45252 */}
153119 break;
153120 case 56: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
153121 {yymsp[-2].minor.yy32 = 0;}
153122 break;
153123 case 57: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
153124 case 72: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==72);
153125 case 160: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==160);
153126 {yymsp[-1].minor.yy32 = yymsp[0].minor.yy32;}
153127 break;
153128 case 59: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
153129 case 76: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==76);
153130 case 202: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==202);
153131 case 205: /* in_op ::= NOT IN */ yytestcase(yyruleno==205);
153132 case 231: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==231);
153133 {yymsp[-1].minor.yy32 = 1;}
153134 break;
153135 case 60: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
153136 {yymsp[-1].minor.yy32 = 0;}
153137 break;
153138 case 62: /* tconscomma ::= COMMA */
153139 {pParse->constraintName.n = 0;}
153140 break;
153141 case 64: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
153142 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy138,yymsp[0].minor.yy32,yymsp[-2].minor.yy32,0);}
153143 break;
153144 case 65: /* tcons ::= UNIQUE LP sortlist RP onconf */
153145 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy138,yymsp[0].minor.yy32,0,0,0,0,
153146 SQLITE_IDXTYPE_UNIQUE);}
153147 break;
153148 case 66: /* tcons ::= CHECK LP expr RP onconf */
153149 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy46);}
153150 break;
153151 case 67: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
153152 {
153153 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy138, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy138, yymsp[-1].minor.yy32);
153154 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy32);
153155 }
153156 break;
153157 case 69: /* onconf ::= */
153158 case 71: /* orconf ::= */ yytestcase(yyruleno==71);
153159 {yymsp[1].minor.yy32 = OE_Default;}
153160 break;
153161 case 70: /* onconf ::= ON CONFLICT resolvetype */
153162 {yymsp[-2].minor.yy32 = yymsp[0].minor.yy32;}
153163 break;
153164 case 73: /* resolvetype ::= IGNORE */
153165 {yymsp[0].minor.yy32 = OE_Ignore;}
153166 break;
153167 case 74: /* resolvetype ::= REPLACE */
153168 case 161: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==161);
153169 {yymsp[0].minor.yy32 = OE_Replace;}
153170 break;
153171 case 75: /* cmd ::= DROP TABLE ifexists fullname */
153172 {
153173 sqlite3DropTable(pParse, yymsp[0].minor.yy609, 0, yymsp[-1].minor.yy32);
153174 }
153175 break;
153176 case 78: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
153177 {
153178 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);
153179 }
153180 break;
153181 case 79: /* cmd ::= DROP VIEW ifexists fullname */
153182 {
153183 sqlite3DropTable(pParse, yymsp[0].minor.yy609, 1, yymsp[-1].minor.yy32);
153184 }
153185 break;
153186 case 80: /* cmd ::= select */
153187 {
153188 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
153189 sqlite3Select(pParse, yymsp[0].minor.yy25, &dest);
153190 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy25);
153191 }
153192 break;
153193 case 81: /* select ::= WITH wqlist selectnowith */
153194 {
153195 Select *p = yymsp[0].minor.yy25;
153196 if( p ){
153197 p->pWith = yymsp[-1].minor.yy297;
153198 parserDoubleLinkSelect(pParse, p);
153199 }else{
153200 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy297);
153201 }
153202 yymsp[-2].minor.yy25 = p;
153203 }
153204 break;
153205 case 82: /* select ::= WITH RECURSIVE wqlist selectnowith */
153206 {
153207 Select *p = yymsp[0].minor.yy25;
153208 if( p ){
153209 p->pWith = yymsp[-1].minor.yy297;
153210 parserDoubleLinkSelect(pParse, p);
153211 }else{
153212 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy297);
153213 }
153214 yymsp[-3].minor.yy25 = p;
153215 }
153216 break;
153217 case 83: /* select ::= selectnowith */
153218 {
153219 Select *p = yymsp[0].minor.yy25;
153220 if( p ){
153221 parserDoubleLinkSelect(pParse, p);
153222 }
153223 yymsp[0].minor.yy25 = p; /*A-overwrites-X*/
153224 }
153225 break;
153226 case 84: /* selectnowith ::= selectnowith multiselect_op oneselect */
153227 {
153228 Select *pRhs = yymsp[0].minor.yy25;
153229 Select *pLhs = yymsp[-2].minor.yy25;
 
 
 
 
 
 
153230 if( pRhs && pRhs->pPrior ){
153231 SrcList *pFrom;
153232 Token x;
153233 x.n = 0;
153234 parserDoubleLinkSelect(pParse, pRhs);
153235 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
153236 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
153237 }
153238 if( pRhs ){
153239 pRhs->op = (u8)yymsp[-1].minor.yy32;
153240 pRhs->pPrior = pLhs;
153241 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
153242 pRhs->selFlags &= ~SF_MultiValue;
153243 if( yymsp[-1].minor.yy32!=TK_ALL ) pParse->hasCompound = 1;
153244 }else{
153245 sqlite3SelectDelete(pParse->db, pLhs);
153246 }
153247 yymsp[-2].minor.yy25 = pRhs;
153248 }
153249 break;
153250 case 85: /* multiselect_op ::= UNION */
153251 case 87: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==87);
153252 {yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-OP*/}
153253 break;
153254 case 86: /* multiselect_op ::= UNION ALL */
153255 {yymsp[-1].minor.yy32 = TK_ALL;}
153256 break;
153257 case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
153258 {
153259 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);
153260 }
153261 break;
153262 case 89: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
153263 {
153264 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);
153265 if( yymsp[-9].minor.yy25 ){
153266 yymsp[-9].minor.yy25->pWinDefn = yymsp[-2].minor.yy455;
153267 }else{
153268 sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy455);
153269 }
153270 }
153271 break;
153272 case 90: /* values ::= VALUES LP nexprlist RP */
153273 {
153274 yymsp[-3].minor.yy25 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy138,0,0,0,0,0,SF_Values,0);
153275 }
153276 break;
153277 case 91: /* values ::= values COMMA LP nexprlist RP */
153278 {
153279 Select *pRight, *pLeft = yymsp[-4].minor.yy25;
153280 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy138,0,0,0,0,0,SF_Values|SF_MultiValue,0);
153281 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
153282 if( pRight ){
153283 pRight->op = TK_ALL;
153284 pRight->pPrior = pLeft;
153285 yymsp[-4].minor.yy25 = pRight;
153286 }else{
153287 yymsp[-4].minor.yy25 = pLeft;
153288 }
153289 }
153290 break;
153291 case 92: /* distinct ::= DISTINCT */
153292 {yymsp[0].minor.yy32 = SF_Distinct;}
153293 break;
153294 case 93: /* distinct ::= ALL */
153295 {yymsp[0].minor.yy32 = SF_All;}
153296 break;
153297 case 95: /* sclp ::= */
153298 case 128: /* orderby_opt ::= */ yytestcase(yyruleno==128);
153299 case 138: /* groupby_opt ::= */ yytestcase(yyruleno==138);
153300 case 218: /* exprlist ::= */ yytestcase(yyruleno==218);
153301 case 221: /* paren_exprlist ::= */ yytestcase(yyruleno==221);
153302 case 226: /* eidlist_opt ::= */ yytestcase(yyruleno==226);
153303 {yymsp[1].minor.yy138 = 0;}
153304 break;
153305 case 96: /* selcollist ::= sclp scanpt expr scanpt as */
153306 {
153307 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy138, yymsp[-2].minor.yy46);
153308 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy138, &yymsp[0].minor.yy0, 1);
153309 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy138,yymsp[-3].minor.yy8,yymsp[-1].minor.yy8);
153310 }
153311 break;
153312 case 97: /* selcollist ::= sclp scanpt STAR */
153313 {
153314 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
153315 yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy138, p);
153316 }
153317 break;
153318 case 98: /* selcollist ::= sclp scanpt nm DOT STAR */
153319 {
153320 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
153321 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
153322 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
153323 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, pDot);
153324 }
153325 break;
153326 case 99: /* as ::= AS nm */
153327 case 110: /* dbnm ::= DOT nm */ yytestcase(yyruleno==110);
153328 case 242: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==242);
153329 case 243: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==243);
153330 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
153331 break;
153332 case 101: /* from ::= */
153333 {yymsp[1].minor.yy609 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy609));}
153334 break;
153335 case 102: /* from ::= FROM seltablist */
153336 {
153337 yymsp[-1].minor.yy609 = yymsp[0].minor.yy609;
153338 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy609);
153339 }
153340 break;
153341 case 103: /* stl_prefix ::= seltablist joinop */
153342 {
153343 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;
153344 }
153345 break;
153346 case 104: /* stl_prefix ::= */
153347 {yymsp[1].minor.yy609 = 0;}
153348 break;
153349 case 105: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
153350 {
153351 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);
153352 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy609, &yymsp[-2].minor.yy0);
153353 }
153354 break;
153355 case 106: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
153356 {
153357 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);
153358 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy609, yymsp[-4].minor.yy138);
153359 }
153360 break;
153361 case 107: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
153362 {
153363 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);
153364 }
153365 break;
153366 case 108: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
153367 {
153368 if( yymsp[-6].minor.yy609==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy46==0 && yymsp[0].minor.yy406==0 ){
153369 yymsp[-6].minor.yy609 = yymsp[-4].minor.yy609;
153370 }else if( yymsp[-4].minor.yy609->nSrc==1 ){
153371 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);
153372 if( yymsp[-6].minor.yy609 ){
153373 struct SrcList_item *pNew = &yymsp[-6].minor.yy609->a[yymsp[-6].minor.yy609->nSrc-1];
153374 struct SrcList_item *pOld = yymsp[-4].minor.yy609->a;
153375 pNew->zName = pOld->zName;
153376 pNew->zDatabase = pOld->zDatabase;
153377 pNew->pSelect = pOld->pSelect;
153378 if( pOld->fg.isTabFunc ){
153379 pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -153382,946 +154519,951 @@
153382 pNew->fg.isTabFunc = 1;
153383 }
153384 pOld->zName = pOld->zDatabase = 0;
153385 pOld->pSelect = 0;
153386 }
153387 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy609);
153388 }else{
153389 Select *pSubquery;
153390 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy609);
153391 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy609,0,0,0,0,SF_NestedFrom,0);
153392 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);
153393 }
153394 }
153395 break;
153396 case 109: /* dbnm ::= */
153397 case 123: /* indexed_opt ::= */ yytestcase(yyruleno==123);
153398 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
153399 break;
153400 case 111: /* fullname ::= nm */
153401 {
153402 yylhsminor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
153403 if( IN_RENAME_OBJECT && yylhsminor.yy609 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy609->a[0].zName, &yymsp[0].minor.yy0);
153404 }
153405 yymsp[0].minor.yy609 = yylhsminor.yy609;
153406 break;
153407 case 112: /* fullname ::= nm DOT nm */
153408 {
153409 yylhsminor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
153410 if( IN_RENAME_OBJECT && yylhsminor.yy609 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy609->a[0].zName, &yymsp[0].minor.yy0);
153411 }
153412 yymsp[-2].minor.yy609 = yylhsminor.yy609;
153413 break;
153414 case 113: /* xfullname ::= nm */
153415 {yymsp[0].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
153416 break;
153417 case 114: /* xfullname ::= nm DOT nm */
153418 {yymsp[-2].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
153419 break;
153420 case 115: /* xfullname ::= nm DOT nm AS nm */
153421 {
153422 yymsp[-4].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
153423 if( yymsp[-4].minor.yy609 ) yymsp[-4].minor.yy609->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
153424 }
153425 break;
153426 case 116: /* xfullname ::= nm AS nm */
153427 {
153428 yymsp[-2].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
153429 if( yymsp[-2].minor.yy609 ) yymsp[-2].minor.yy609->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
153430 }
153431 break;
153432 case 117: /* joinop ::= COMMA|JOIN */
153433 { yymsp[0].minor.yy32 = JT_INNER; }
153434 break;
153435 case 118: /* joinop ::= JOIN_KW JOIN */
153436 {yymsp[-1].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
153437 break;
153438 case 119: /* joinop ::= JOIN_KW nm JOIN */
153439 {yymsp[-2].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
153440 break;
153441 case 120: /* joinop ::= JOIN_KW nm nm JOIN */
153442 {yymsp[-3].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
153443 break;
153444 case 121: /* on_opt ::= ON expr */
153445 case 141: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==141);
153446 case 148: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==148);
153447 case 214: /* case_else ::= ELSE expr */ yytestcase(yyruleno==214);
153448 case 235: /* vinto ::= INTO expr */ yytestcase(yyruleno==235);
153449 {yymsp[-1].minor.yy46 = yymsp[0].minor.yy46;}
153450 break;
153451 case 122: /* on_opt ::= */
153452 case 140: /* having_opt ::= */ yytestcase(yyruleno==140);
153453 case 142: /* limit_opt ::= */ yytestcase(yyruleno==142);
153454 case 147: /* where_opt ::= */ yytestcase(yyruleno==147);
153455 case 215: /* case_else ::= */ yytestcase(yyruleno==215);
153456 case 217: /* case_operand ::= */ yytestcase(yyruleno==217);
153457 case 236: /* vinto ::= */ yytestcase(yyruleno==236);
153458 {yymsp[1].minor.yy46 = 0;}
153459 break;
153460 case 124: /* indexed_opt ::= INDEXED BY nm */
153461 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
153462 break;
153463 case 125: /* indexed_opt ::= NOT INDEXED */
153464 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
153465 break;
153466 case 126: /* using_opt ::= USING LP idlist RP */
153467 {yymsp[-3].minor.yy406 = yymsp[-1].minor.yy406;}
153468 break;
153469 case 127: /* using_opt ::= */
153470 case 162: /* idlist_opt ::= */ yytestcase(yyruleno==162);
153471 {yymsp[1].minor.yy406 = 0;}
153472 break;
153473 case 129: /* orderby_opt ::= ORDER BY sortlist */
153474 case 139: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==139);
153475 {yymsp[-2].minor.yy138 = yymsp[0].minor.yy138;}
153476 break;
153477 case 130: /* sortlist ::= sortlist COMMA expr sortorder nulls */
153478 {
153479 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138,yymsp[-2].minor.yy46);
153480 sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy138,yymsp[-1].minor.yy32,yymsp[0].minor.yy32);
153481 }
153482 break;
153483 case 131: /* sortlist ::= expr sortorder nulls */
153484 {
153485 yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy46); /*A-overwrites-Y*/
153486 sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy138,yymsp[-1].minor.yy32,yymsp[0].minor.yy32);
153487 }
153488 break;
153489 case 132: /* sortorder ::= ASC */
153490 {yymsp[0].minor.yy32 = SQLITE_SO_ASC;}
153491 break;
153492 case 133: /* sortorder ::= DESC */
153493 {yymsp[0].minor.yy32 = SQLITE_SO_DESC;}
153494 break;
153495 case 134: /* sortorder ::= */
153496 case 137: /* nulls ::= */ yytestcase(yyruleno==137);
153497 {yymsp[1].minor.yy32 = SQLITE_SO_UNDEFINED;}
153498 break;
153499 case 135: /* nulls ::= NULLS FIRST */
153500 {yymsp[-1].minor.yy32 = SQLITE_SO_ASC;}
153501 break;
153502 case 136: /* nulls ::= NULLS LAST */
153503 {yymsp[-1].minor.yy32 = SQLITE_SO_DESC;}
153504 break;
153505 case 143: /* limit_opt ::= LIMIT expr */
153506 {yymsp[-1].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy46,0);}
153507 break;
153508 case 144: /* limit_opt ::= LIMIT expr OFFSET expr */
153509 {yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153510 break;
153511 case 145: /* limit_opt ::= LIMIT expr COMMA expr */
153512 {yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy46,yymsp[-2].minor.yy46);}
153513 break;
153514 case 146: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
153515 {
153516 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy609, &yymsp[-1].minor.yy0);
153517 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy609,yymsp[0].minor.yy46,0,0);
153518 }
153519 break;
153520 case 149: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
153521 {
153522 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy609, &yymsp[-3].minor.yy0);
153523 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy138,"set list");
153524 sqlite3Update(pParse,yymsp[-4].minor.yy609,yymsp[-1].minor.yy138,yymsp[0].minor.yy46,yymsp[-5].minor.yy32,0,0,0);
153525 }
153526 break;
153527 case 150: /* setlist ::= setlist COMMA nm EQ expr */
153528 {
153529 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy138, yymsp[0].minor.yy46);
153530 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy138, &yymsp[-2].minor.yy0, 1);
153531 }
153532 break;
153533 case 151: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
153534 {
153535 yymsp[-6].minor.yy138 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy138, yymsp[-3].minor.yy406, yymsp[0].minor.yy46);
153536 }
153537 break;
153538 case 152: /* setlist ::= nm EQ expr */
153539 {
153540 yylhsminor.yy138 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy46);
153541 sqlite3ExprListSetName(pParse, yylhsminor.yy138, &yymsp[-2].minor.yy0, 1);
153542 }
153543 yymsp[-2].minor.yy138 = yylhsminor.yy138;
153544 break;
153545 case 153: /* setlist ::= LP idlist RP EQ expr */
153546 {
153547 yymsp[-4].minor.yy138 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy406, yymsp[0].minor.yy46);
153548 }
153549 break;
153550 case 154: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
153551 {
153552 sqlite3Insert(pParse, yymsp[-3].minor.yy609, yymsp[-1].minor.yy25, yymsp[-2].minor.yy406, yymsp[-5].minor.yy32, yymsp[0].minor.yy288);
153553 }
153554 break;
153555 case 155: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
153556 {
153557 sqlite3Insert(pParse, yymsp[-3].minor.yy609, 0, yymsp[-2].minor.yy406, yymsp[-5].minor.yy32, 0);
153558 }
153559 break;
153560 case 156: /* upsert ::= */
153561 { yymsp[1].minor.yy288 = 0; }
153562 break;
153563 case 157: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
153564 { yymsp[-10].minor.yy288 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy138,yymsp[-5].minor.yy46,yymsp[-1].minor.yy138,yymsp[0].minor.yy46);}
153565 break;
153566 case 158: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
153567 { yymsp[-7].minor.yy288 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy138,yymsp[-2].minor.yy46,0,0); }
153568 break;
153569 case 159: /* upsert ::= ON CONFLICT DO NOTHING */
153570 { yymsp[-3].minor.yy288 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
153571 break;
153572 case 163: /* idlist_opt ::= LP idlist RP */
153573 {yymsp[-2].minor.yy406 = yymsp[-1].minor.yy406;}
153574 break;
153575 case 164: /* idlist ::= idlist COMMA nm */
153576 {yymsp[-2].minor.yy406 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy406,&yymsp[0].minor.yy0);}
153577 break;
153578 case 165: /* idlist ::= nm */
153579 {yymsp[0].minor.yy406 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
153580 break;
153581 case 166: /* expr ::= LP expr RP */
153582 {yymsp[-2].minor.yy46 = yymsp[-1].minor.yy46;}
153583 break;
153584 case 167: /* expr ::= ID|INDEXED */
153585 case 168: /* expr ::= JOIN_KW */ yytestcase(yyruleno==168);
153586 {yymsp[0].minor.yy46=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
153587 break;
153588 case 169: /* expr ::= nm DOT nm */
153589 {
153590 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
153591 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
153592 if( IN_RENAME_OBJECT ){
153593 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
153594 sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
153595 }
153596 yylhsminor.yy46 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
153597 }
153598 yymsp[-2].minor.yy46 = yylhsminor.yy46;
153599 break;
153600 case 170: /* expr ::= nm DOT nm DOT nm */
153601 {
153602 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
153603 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
153604 Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
153605 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
153606 if( IN_RENAME_OBJECT ){
153607 sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
153608 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
153609 }
153610 yylhsminor.yy46 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
153611 }
153612 yymsp[-4].minor.yy46 = yylhsminor.yy46;
153613 break;
153614 case 171: /* term ::= NULL|FLOAT|BLOB */
153615 case 172: /* term ::= STRING */ yytestcase(yyruleno==172);
153616 {yymsp[0].minor.yy46=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
153617 break;
153618 case 173: /* term ::= INTEGER */
153619 {
153620 yylhsminor.yy46 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
153621 }
153622 yymsp[0].minor.yy46 = yylhsminor.yy46;
153623 break;
153624 case 174: /* expr ::= VARIABLE */
153625 {
153626 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
153627 u32 n = yymsp[0].minor.yy0.n;
153628 yymsp[0].minor.yy46 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
153629 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy46, n);
153630 }else{
153631 /* When doing a nested parse, one can include terms in an expression
153632 ** that look like this: #1 #2 ... These terms refer to registers
153633 ** in the virtual machine. #N is the N-th register. */
153634 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
153635 assert( t.n>=2 );
153636 if( pParse->nested==0 ){
153637 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
153638 yymsp[0].minor.yy46 = 0;
153639 }else{
153640 yymsp[0].minor.yy46 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
153641 if( yymsp[0].minor.yy46 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy46->iTable);
153642 }
153643 }
153644 }
153645 break;
153646 case 175: /* expr ::= expr COLLATE ID|STRING */
153647 {
153648 yymsp[-2].minor.yy46 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy46, &yymsp[0].minor.yy0, 1);
153649 }
153650 break;
153651 case 176: /* expr ::= CAST LP expr AS typetoken RP */
153652 {
153653 yymsp[-5].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
153654 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy46, yymsp[-3].minor.yy46, 0);
153655 }
153656 break;
153657 case 177: /* expr ::= ID|INDEXED LP distinct exprlist RP */
153658 {
153659 yylhsminor.yy46 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy138, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy32);
153660 }
153661 yymsp[-4].minor.yy46 = yylhsminor.yy46;
153662 break;
153663 case 178: /* expr ::= ID|INDEXED LP STAR RP */
153664 {
153665 yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
153666 }
153667 yymsp[-3].minor.yy46 = yylhsminor.yy46;
153668 break;
153669 case 179: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
153670 {
153671 yylhsminor.yy46 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy138, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy32);
153672 sqlite3WindowAttach(pParse, yylhsminor.yy46, yymsp[0].minor.yy455);
153673 }
153674 yymsp[-5].minor.yy46 = yylhsminor.yy46;
153675 break;
153676 case 180: /* expr ::= ID|INDEXED LP STAR RP filter_over */
153677 {
153678 yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
153679 sqlite3WindowAttach(pParse, yylhsminor.yy46, yymsp[0].minor.yy455);
153680 }
153681 yymsp[-4].minor.yy46 = yylhsminor.yy46;
153682 break;
153683 case 181: /* term ::= CTIME_KW */
153684 {
153685 yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
153686 }
153687 yymsp[0].minor.yy46 = yylhsminor.yy46;
153688 break;
153689 case 182: /* expr ::= LP nexprlist COMMA expr RP */
153690 {
153691 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy138, yymsp[-1].minor.yy46);
153692 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
153693 if( yymsp[-4].minor.yy46 ){
153694 yymsp[-4].minor.yy46->x.pList = pList;
 
 
 
153695 }else{
153696 sqlite3ExprListDelete(pParse->db, pList);
153697 }
153698 }
153699 break;
153700 case 183: /* expr ::= expr AND expr */
153701 {yymsp[-2].minor.yy46=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153702 break;
153703 case 184: /* expr ::= expr OR expr */
153704 case 185: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==185);
153705 case 186: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==186);
153706 case 187: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==187);
153707 case 188: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==188);
153708 case 189: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==189);
153709 case 190: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==190);
153710 {yymsp[-2].minor.yy46=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);}
153711 break;
153712 case 191: /* likeop ::= NOT LIKE_KW|MATCH */
153713 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
153714 break;
153715 case 192: /* expr ::= expr likeop expr */
153716 {
153717 ExprList *pList;
153718 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
153719 yymsp[-1].minor.yy0.n &= 0x7fffffff;
153720 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy46);
153721 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy46);
153722 yymsp[-2].minor.yy46 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
153723 if( bNot ) yymsp[-2].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy46, 0);
153724 if( yymsp[-2].minor.yy46 ) yymsp[-2].minor.yy46->flags |= EP_InfixFunc;
153725 }
153726 break;
153727 case 193: /* expr ::= expr likeop expr ESCAPE expr */
153728 {
153729 ExprList *pList;
153730 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
153731 yymsp[-3].minor.yy0.n &= 0x7fffffff;
153732 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153733 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy46);
153734 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy46);
153735 yymsp[-4].minor.yy46 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
153736 if( bNot ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153737 if( yymsp[-4].minor.yy46 ) yymsp[-4].minor.yy46->flags |= EP_InfixFunc;
153738 }
153739 break;
153740 case 194: /* expr ::= expr ISNULL|NOTNULL */
153741 {yymsp[-1].minor.yy46 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy46,0);}
153742 break;
153743 case 195: /* expr ::= expr NOT NULL */
153744 {yymsp[-2].minor.yy46 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy46,0);}
153745 break;
153746 case 196: /* expr ::= expr IS expr */
153747 {
153748 yymsp[-2].minor.yy46 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);
153749 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy46, yymsp[-2].minor.yy46, TK_ISNULL);
153750 }
153751 break;
153752 case 197: /* expr ::= expr IS NOT expr */
153753 {
153754 yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy46,yymsp[0].minor.yy46);
153755 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy46, yymsp[-3].minor.yy46, TK_NOTNULL);
153756 }
153757 break;
153758 case 198: /* expr ::= NOT expr */
153759 case 199: /* expr ::= BITNOT expr */ yytestcase(yyruleno==199);
153760 {yymsp[-1].minor.yy46 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy46, 0);/*A-overwrites-B*/}
153761 break;
153762 case 200: /* expr ::= PLUS|MINUS expr */
153763 {
153764 yymsp[-1].minor.yy46 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy46, 0);
153765 /*A-overwrites-B*/
153766 }
153767 break;
153768 case 201: /* between_op ::= BETWEEN */
153769 case 204: /* in_op ::= IN */ yytestcase(yyruleno==204);
153770 {yymsp[0].minor.yy32 = 0;}
153771 break;
153772 case 203: /* expr ::= expr between_op expr AND expr */
153773 {
153774 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153775 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy46);
153776 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy46, 0);
153777 if( yymsp[-4].minor.yy46 ){
153778 yymsp[-4].minor.yy46->x.pList = pList;
153779 }else{
153780 sqlite3ExprListDelete(pParse->db, pList);
153781 }
153782 if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153783 }
153784 break;
153785 case 206: /* expr ::= expr in_op LP exprlist RP */
153786 {
153787 if( yymsp[-1].minor.yy138==0 ){
153788 /* Expressions of the form
153789 **
153790 ** expr1 IN ()
153791 ** expr1 NOT IN ()
153792 **
153793 ** simplify to constants 0 (false) and 1 (true), respectively,
153794 ** regardless of the value of expr1.
153795 */
153796 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy46);
153797 yymsp[-4].minor.yy46 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy32 ? "1" : "0");
153798 }else{
153799 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153800 if( yymsp[-4].minor.yy46 ){
153801 yymsp[-4].minor.yy46->x.pList = yymsp[-1].minor.yy138;
153802 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy46);
153803 }else{
153804 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy138);
153805 }
153806 if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153807 }
153808 }
153809 break;
153810 case 207: /* expr ::= LP select RP */
153811 {
153812 yymsp[-2].minor.yy46 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
153813 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy46, yymsp[-1].minor.yy25);
153814 }
153815 break;
153816 case 208: /* expr ::= expr in_op LP select RP */
153817 {
153818 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153819 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy46, yymsp[-1].minor.yy25);
153820 if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153821 }
153822 break;
153823 case 209: /* expr ::= expr in_op nm dbnm paren_exprlist */
153824 {
153825 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
153826 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
153827 if( yymsp[0].minor.yy138 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy138);
153828 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0);
153829 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy46, pSelect);
153830 if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0);
153831 }
153832 break;
153833 case 210: /* expr ::= EXISTS LP select RP */
153834 {
153835 Expr *p;
153836 p = yymsp[-3].minor.yy46 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
153837 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy25);
153838 }
153839 break;
153840 case 211: /* expr ::= CASE case_operand case_exprlist case_else END */
153841 {
153842 yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy46, 0);
153843 if( yymsp[-4].minor.yy46 ){
153844 yymsp[-4].minor.yy46->x.pList = yymsp[-1].minor.yy46 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy138,yymsp[-1].minor.yy46) : yymsp[-2].minor.yy138;
153845 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy46);
153846 }else{
153847 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy138);
153848 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy46);
153849 }
153850 }
153851 break;
153852 case 212: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
153853 {
153854 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, yymsp[-2].minor.yy46);
153855 yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, yymsp[0].minor.yy46);
153856 }
153857 break;
153858 case 213: /* case_exprlist ::= WHEN expr THEN expr */
153859 {
153860 yymsp[-3].minor.yy138 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46);
153861 yymsp[-3].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy138, yymsp[0].minor.yy46);
153862 }
153863 break;
153864 case 216: /* case_operand ::= expr */
153865 {yymsp[0].minor.yy46 = yymsp[0].minor.yy46; /*A-overwrites-X*/}
153866 break;
153867 case 219: /* nexprlist ::= nexprlist COMMA expr */
153868 {yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy138,yymsp[0].minor.yy46);}
153869 break;
153870 case 220: /* nexprlist ::= expr */
153871 {yymsp[0].minor.yy138 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy46); /*A-overwrites-Y*/}
153872 break;
153873 case 222: /* paren_exprlist ::= LP exprlist RP */
153874 case 227: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==227);
153875 {yymsp[-2].minor.yy138 = yymsp[-1].minor.yy138;}
153876 break;
153877 case 223: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
153878 {
153879 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
153880 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy138, yymsp[-10].minor.yy32,
153881 &yymsp[-11].minor.yy0, yymsp[0].minor.yy46, SQLITE_SO_ASC, yymsp[-8].minor.yy32, SQLITE_IDXTYPE_APPDEF);
153882 if( IN_RENAME_OBJECT && pParse->pNewIndex ){
153883 sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
153884 }
153885 }
153886 break;
153887 case 224: /* uniqueflag ::= UNIQUE */
153888 case 266: /* raisetype ::= ABORT */ yytestcase(yyruleno==266);
153889 {yymsp[0].minor.yy32 = OE_Abort;}
153890 break;
153891 case 225: /* uniqueflag ::= */
153892 {yymsp[1].minor.yy32 = OE_None;}
153893 break;
153894 case 228: /* eidlist ::= eidlist COMMA nm collate sortorder */
153895 {
153896 yymsp[-4].minor.yy138 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy138, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy32, yymsp[0].minor.yy32);
153897 }
153898 break;
153899 case 229: /* eidlist ::= nm collate sortorder */
153900 {
153901 yymsp[-2].minor.yy138 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy32, yymsp[0].minor.yy32); /*A-overwrites-Y*/
153902 }
153903 break;
153904 case 232: /* cmd ::= DROP INDEX ifexists fullname */
153905 {sqlite3DropIndex(pParse, yymsp[0].minor.yy609, yymsp[-1].minor.yy32);}
153906 break;
153907 case 233: /* cmd ::= VACUUM vinto */
153908 {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy46);}
153909 break;
153910 case 234: /* cmd ::= VACUUM nm vinto */
153911 {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy46);}
153912 break;
153913 case 237: /* cmd ::= PRAGMA nm dbnm */
153914 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
153915 break;
153916 case 238: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
153917 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
153918 break;
153919 case 239: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
153920 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
153921 break;
153922 case 240: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
153923 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
153924 break;
153925 case 241: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
153926 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
153927 break;
153928 case 244: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
153929 {
153930 Token all;
153931 all.z = yymsp[-3].minor.yy0.z;
153932 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
153933 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy527, &all);
153934 }
153935 break;
153936 case 245: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
153937 {
153938 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);
153939 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
153940 }
153941 break;
153942 case 246: /* trigger_time ::= BEFORE|AFTER */
153943 { yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-X*/ }
153944 break;
153945 case 247: /* trigger_time ::= INSTEAD OF */
153946 { yymsp[-1].minor.yy32 = TK_INSTEAD;}
153947 break;
153948 case 248: /* trigger_time ::= */
153949 { yymsp[1].minor.yy32 = TK_BEFORE; }
153950 break;
153951 case 249: /* trigger_event ::= DELETE|INSERT */
153952 case 250: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==250);
153953 {yymsp[0].minor.yy572.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy572.b = 0;}
153954 break;
153955 case 251: /* trigger_event ::= UPDATE OF idlist */
153956 {yymsp[-2].minor.yy572.a = TK_UPDATE; yymsp[-2].minor.yy572.b = yymsp[0].minor.yy406;}
153957 break;
153958 case 252: /* when_clause ::= */
153959 case 271: /* key_opt ::= */ yytestcase(yyruleno==271);
153960 { yymsp[1].minor.yy46 = 0; }
153961 break;
153962 case 253: /* when_clause ::= WHEN expr */
153963 case 272: /* key_opt ::= KEY expr */ yytestcase(yyruleno==272);
153964 { yymsp[-1].minor.yy46 = yymsp[0].minor.yy46; }
153965 break;
153966 case 254: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
153967 {
153968 assert( yymsp[-2].minor.yy527!=0 );
153969 yymsp[-2].minor.yy527->pLast->pNext = yymsp[-1].minor.yy527;
153970 yymsp[-2].minor.yy527->pLast = yymsp[-1].minor.yy527;
153971 }
153972 break;
153973 case 255: /* trigger_cmd_list ::= trigger_cmd SEMI */
153974 {
153975 assert( yymsp[-1].minor.yy527!=0 );
153976 yymsp[-1].minor.yy527->pLast = yymsp[-1].minor.yy527;
153977 }
153978 break;
153979 case 256: /* trnm ::= nm DOT nm */
153980 {
153981 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
153982 sqlite3ErrorMsg(pParse,
153983 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
153984 "statements within triggers");
153985 }
153986 break;
153987 case 257: /* tridxby ::= INDEXED BY nm */
153988 {
153989 sqlite3ErrorMsg(pParse,
153990 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
153991 "within triggers");
153992 }
153993 break;
153994 case 258: /* tridxby ::= NOT INDEXED */
153995 {
153996 sqlite3ErrorMsg(pParse,
153997 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
153998 "within triggers");
153999 }
154000 break;
154001 case 259: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
154002 {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);}
154003 yymsp[-7].minor.yy527 = yylhsminor.yy527;
154004 break;
154005 case 260: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
154006 {
154007 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*/
154008 }
154009 yymsp[-7].minor.yy527 = yylhsminor.yy527;
154010 break;
154011 case 261: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
154012 {yylhsminor.yy527 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy46, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy8);}
154013 yymsp[-5].minor.yy527 = yylhsminor.yy527;
154014 break;
154015 case 262: /* trigger_cmd ::= scanpt select scanpt */
154016 {yylhsminor.yy527 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy25, yymsp[-2].minor.yy8, yymsp[0].minor.yy8); /*yylhsminor.yy527-overwrites-yymsp[-1].minor.yy25*/}
154017 yymsp[-2].minor.yy527 = yylhsminor.yy527;
154018 break;
154019 case 263: /* expr ::= RAISE LP IGNORE RP */
154020 {
154021 yymsp[-3].minor.yy46 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
154022 if( yymsp[-3].minor.yy46 ){
154023 yymsp[-3].minor.yy46->affExpr = OE_Ignore;
154024 }
154025 }
154026 break;
154027 case 264: /* expr ::= RAISE LP raisetype COMMA nm RP */
154028 {
154029 yymsp[-5].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
154030 if( yymsp[-5].minor.yy46 ) {
154031 yymsp[-5].minor.yy46->affExpr = (char)yymsp[-3].minor.yy32;
154032 }
154033 }
154034 break;
154035 case 265: /* raisetype ::= ROLLBACK */
154036 {yymsp[0].minor.yy32 = OE_Rollback;}
154037 break;
154038 case 267: /* raisetype ::= FAIL */
154039 {yymsp[0].minor.yy32 = OE_Fail;}
154040 break;
154041 case 268: /* cmd ::= DROP TRIGGER ifexists fullname */
154042 {
154043 sqlite3DropTrigger(pParse,yymsp[0].minor.yy609,yymsp[-1].minor.yy32);
154044 }
154045 break;
154046 case 269: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
154047 {
154048 sqlite3Attach(pParse, yymsp[-3].minor.yy46, yymsp[-1].minor.yy46, yymsp[0].minor.yy46);
154049 }
154050 break;
154051 case 270: /* cmd ::= DETACH database_kw_opt expr */
154052 {
154053 sqlite3Detach(pParse, yymsp[0].minor.yy46);
154054 }
154055 break;
154056 case 273: /* cmd ::= REINDEX */
154057 {sqlite3Reindex(pParse, 0, 0);}
154058 break;
154059 case 274: /* cmd ::= REINDEX nm dbnm */
154060 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
154061 break;
154062 case 275: /* cmd ::= ANALYZE */
154063 {sqlite3Analyze(pParse, 0, 0);}
154064 break;
154065 case 276: /* cmd ::= ANALYZE nm dbnm */
154066 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
154067 break;
154068 case 277: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
154069 {
154070 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy609,&yymsp[0].minor.yy0);
154071 }
154072 break;
154073 case 278: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
154074 {
154075 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
154076 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
154077 }
154078 break;
154079 case 279: /* add_column_fullname ::= fullname */
154080 {
154081 disableLookaside(pParse);
154082 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy609);
154083 }
154084 break;
154085 case 280: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
154086 {
154087 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy609, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
154088 }
154089 break;
154090 case 281: /* cmd ::= create_vtab */
154091 {sqlite3VtabFinishParse(pParse,0);}
154092 break;
154093 case 282: /* cmd ::= create_vtab LP vtabarglist RP */
154094 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
154095 break;
154096 case 283: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
154097 {
154098 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy32);
154099 }
154100 break;
154101 case 284: /* vtabarg ::= */
154102 {sqlite3VtabArgInit(pParse);}
154103 break;
154104 case 285: /* vtabargtoken ::= ANY */
154105 case 286: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==286);
154106 case 287: /* lp ::= LP */ yytestcase(yyruleno==287);
154107 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
154108 break;
154109 case 288: /* with ::= WITH wqlist */
154110 case 289: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==289);
154111 { sqlite3WithPush(pParse, yymsp[0].minor.yy297, 1); }
154112 break;
154113 case 290: /* wqlist ::= nm eidlist_opt AS LP select RP */
154114 {
154115 yymsp[-5].minor.yy297 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy138, yymsp[-1].minor.yy25); /*A-overwrites-X*/
154116 }
154117 break;
154118 case 291: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
154119 {
154120 yymsp[-7].minor.yy297 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy297, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy138, yymsp[-1].minor.yy25);
154121 }
154122 break;
154123 case 292: /* windowdefn_list ::= windowdefn */
154124 { yylhsminor.yy455 = yymsp[0].minor.yy455; }
154125 yymsp[0].minor.yy455 = yylhsminor.yy455;
154126 break;
154127 case 293: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
154128 {
154129 assert( yymsp[0].minor.yy455!=0 );
154130 sqlite3WindowChain(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy455);
154131 yymsp[0].minor.yy455->pNextWin = yymsp[-2].minor.yy455;
154132 yylhsminor.yy455 = yymsp[0].minor.yy455;
154133 }
154134 yymsp[-2].minor.yy455 = yylhsminor.yy455;
154135 break;
154136 case 294: /* windowdefn ::= nm AS LP window RP */
154137 {
154138 if( ALWAYS(yymsp[-1].minor.yy455) ){
154139 yymsp[-1].minor.yy455->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
154140 }
154141 yylhsminor.yy455 = yymsp[-1].minor.yy455;
154142 }
154143 yymsp[-4].minor.yy455 = yylhsminor.yy455;
154144 break;
154145 case 295: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
154146 {
154147 yymsp[-4].minor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy138, yymsp[-1].minor.yy138, 0);
154148 }
154149 break;
154150 case 296: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
154151 {
154152 yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy138, yymsp[-1].minor.yy138, &yymsp[-5].minor.yy0);
154153 }
154154 yymsp[-5].minor.yy455 = yylhsminor.yy455;
154155 break;
154156 case 297: /* window ::= ORDER BY sortlist frame_opt */
154157 {
154158 yymsp[-3].minor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, yymsp[-1].minor.yy138, 0);
154159 }
154160 break;
154161 case 298: /* window ::= nm ORDER BY sortlist frame_opt */
154162 {
154163 yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, yymsp[-1].minor.yy138, &yymsp[-4].minor.yy0);
154164 }
154165 yymsp[-4].minor.yy455 = yylhsminor.yy455;
154166 break;
154167 case 299: /* window ::= frame_opt */
154168 case 318: /* filter_over ::= over_clause */ yytestcase(yyruleno==318);
154169 {
154170 yylhsminor.yy455 = yymsp[0].minor.yy455;
154171 }
154172 yymsp[0].minor.yy455 = yylhsminor.yy455;
154173 break;
154174 case 300: /* window ::= nm frame_opt */
154175 {
154176 yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, 0, &yymsp[-1].minor.yy0);
154177 }
154178 yymsp[-1].minor.yy455 = yylhsminor.yy455;
154179 break;
154180 case 301: /* frame_opt ::= */
154181 {
154182 yymsp[1].minor.yy455 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
154183 }
154184 break;
154185 case 302: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
154186 {
154187 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);
154188 }
154189 yymsp[-2].minor.yy455 = yylhsminor.yy455;
154190 break;
154191 case 303: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
154192 {
154193 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);
154194 }
154195 yymsp[-5].minor.yy455 = yylhsminor.yy455;
154196 break;
154197 case 305: /* frame_bound_s ::= frame_bound */
154198 case 307: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==307);
154199 {yylhsminor.yy57 = yymsp[0].minor.yy57;}
154200 yymsp[0].minor.yy57 = yylhsminor.yy57;
154201 break;
154202 case 306: /* frame_bound_s ::= UNBOUNDED PRECEDING */
154203 case 308: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==308);
154204 case 310: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==310);
154205 {yylhsminor.yy57.eType = yymsp[-1].major; yylhsminor.yy57.pExpr = 0;}
154206 yymsp[-1].minor.yy57 = yylhsminor.yy57;
154207 break;
154208 case 309: /* frame_bound ::= expr PRECEDING|FOLLOWING */
154209 {yylhsminor.yy57.eType = yymsp[0].major; yylhsminor.yy57.pExpr = yymsp[-1].minor.yy46;}
154210 yymsp[-1].minor.yy57 = yylhsminor.yy57;
154211 break;
154212 case 311: /* frame_exclude_opt ::= */
154213 {yymsp[1].minor.yy118 = 0;}
154214 break;
154215 case 312: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
154216 {yymsp[-1].minor.yy118 = yymsp[0].minor.yy118;}
154217 break;
154218 case 313: /* frame_exclude ::= NO OTHERS */
154219 case 314: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==314);
154220 {yymsp[-1].minor.yy118 = yymsp[-1].major; /*A-overwrites-X*/}
154221 break;
154222 case 315: /* frame_exclude ::= GROUP|TIES */
154223 {yymsp[0].minor.yy118 = yymsp[0].major; /*A-overwrites-X*/}
154224 break;
154225 case 316: /* window_clause ::= WINDOW windowdefn_list */
154226 { yymsp[-1].minor.yy455 = yymsp[0].minor.yy455; }
154227 break;
154228 case 317: /* filter_over ::= filter_clause over_clause */
154229 {
154230 yymsp[0].minor.yy455->pFilter = yymsp[-1].minor.yy46;
154231 yylhsminor.yy455 = yymsp[0].minor.yy455;
154232 }
154233 yymsp[-1].minor.yy455 = yylhsminor.yy455;
154234 break;
154235 case 319: /* filter_over ::= filter_clause */
154236 {
154237 yylhsminor.yy455 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
154238 if( yylhsminor.yy455 ){
154239 yylhsminor.yy455->eFrmType = TK_FILTER;
154240 yylhsminor.yy455->pFilter = yymsp[0].minor.yy46;
154241 }else{
154242 sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy46);
154243 }
154244 }
154245 yymsp[0].minor.yy455 = yylhsminor.yy455;
154246 break;
154247 case 320: /* over_clause ::= OVER LP window RP */
154248 {
154249 yymsp[-3].minor.yy455 = yymsp[-1].minor.yy455;
154250 assert( yymsp[-3].minor.yy455!=0 );
154251 }
154252 break;
154253 case 321: /* over_clause ::= OVER nm */
154254 {
154255 yymsp[-1].minor.yy455 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
154256 if( yymsp[-1].minor.yy455 ){
154257 yymsp[-1].minor.yy455->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
154258 }
154259 }
154260 break;
154261 case 322: /* filter_clause ::= FILTER LP WHERE expr RP */
154262 { yymsp[-4].minor.yy46 = yymsp[-1].minor.yy46; }
154263 break;
154264 default:
154265 /* (323) input ::= cmdlist */ yytestcase(yyruleno==323);
154266 /* (324) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==324);
154267 /* (325) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=325);
154268 /* (326) ecmd ::= SEMI */ yytestcase(yyruleno==326);
154269 /* (327) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==327);
154270 /* (328) ecmd ::= explain cmdx */ yytestcase(yyruleno==328);
154271 /* (329) trans_opt ::= */ yytestcase(yyruleno==329);
154272 /* (330) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==330);
154273 /* (331) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==331);
154274 /* (332) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==332);
154275 /* (333) savepoint_opt ::= */ yytestcase(yyruleno==333);
154276 /* (334) cmd ::= create_table create_table_args */ yytestcase(yyruleno==334);
154277 /* (335) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==335);
154278 /* (336) columnlist ::= columnname carglist */ yytestcase(yyruleno==336);
154279 /* (337) nm ::= ID|INDEXED */ yytestcase(yyruleno==337);
154280 /* (338) nm ::= STRING */ yytestcase(yyruleno==338);
154281 /* (339) nm ::= JOIN_KW */ yytestcase(yyruleno==339);
154282 /* (340) typetoken ::= typename */ yytestcase(yyruleno==340);
154283 /* (341) typename ::= ID|STRING */ yytestcase(yyruleno==341);
154284 /* (342) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=342);
154285 /* (343) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=343);
154286 /* (344) carglist ::= carglist ccons */ yytestcase(yyruleno==344);
154287 /* (345) carglist ::= */ yytestcase(yyruleno==345);
154288 /* (346) ccons ::= NULL onconf */ yytestcase(yyruleno==346);
154289 /* (347) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==347);
154290 /* (348) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==348);
154291 /* (349) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=349);
154292 /* (350) tconscomma ::= */ yytestcase(yyruleno==350);
154293 /* (351) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=351);
154294 /* (352) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=352);
154295 /* (353) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=353);
154296 /* (354) oneselect ::= values */ yytestcase(yyruleno==354);
154297 /* (355) sclp ::= selcollist COMMA */ yytestcase(yyruleno==355);
154298 /* (356) as ::= ID|STRING */ yytestcase(yyruleno==356);
154299 /* (357) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=357);
154300 /* (358) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==358);
154301 /* (359) exprlist ::= nexprlist */ yytestcase(yyruleno==359);
154302 /* (360) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=360);
154303 /* (361) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=361);
154304 /* (362) nmnum ::= ON */ yytestcase(yyruleno==362);
154305 /* (363) nmnum ::= DELETE */ yytestcase(yyruleno==363);
154306 /* (364) nmnum ::= DEFAULT */ yytestcase(yyruleno==364);
154307 /* (365) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==365);
154308 /* (366) foreach_clause ::= */ yytestcase(yyruleno==366);
154309 /* (367) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==367);
154310 /* (368) trnm ::= nm */ yytestcase(yyruleno==368);
154311 /* (369) tridxby ::= */ yytestcase(yyruleno==369);
154312 /* (370) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==370);
154313 /* (371) database_kw_opt ::= */ yytestcase(yyruleno==371);
154314 /* (372) kwcolumn_opt ::= */ yytestcase(yyruleno==372);
154315 /* (373) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==373);
154316 /* (374) vtabarglist ::= vtabarg */ yytestcase(yyruleno==374);
154317 /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==375);
154318 /* (376) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==376);
154319 /* (377) anylist ::= */ yytestcase(yyruleno==377);
154320 /* (378) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==378);
154321 /* (379) anylist ::= anylist ANY */ yytestcase(yyruleno==379);
154322 /* (380) with ::= */ yytestcase(yyruleno==380);
 
 
154323 break;
154324 /********** End reduce actions ************************************************/
154325 };
154326 assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
154327 yygoto = yyRuleInfoLhs[yyruleno];
@@ -154613,12 +155755,12 @@
154613 #ifdef YYFALLBACK
154614 assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) );
154615 return yyFallback[iToken];
154616 #else
154617 (void)iToken;
154618 #endif
154619 return 0;
 
154620 }
154621
154622 /************** End of parse.c ***********************************************/
154623 /************** Begin file tokenize.c ****************************************/
154624 /*
@@ -154779,24 +155921,24 @@
154779 ** might be implemented more directly using a hand-written hash table.
154780 ** But by using this automatically generated code, the size of the code
154781 ** is substantially reduced. This is important for embedded applications
154782 ** on platforms with limited memory.
154783 */
154784 /* Hash score: 221 */
154785 /* zKWText[] encodes 967 bytes of keyword text in 638 bytes */
154786 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
154787 /* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYISNULLSAVEPOINTERSECT */
154788 /* IESNOTNULLIKEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTS */
154789 /* CONSTRAINTOFFSETRIGGEREFERENCESUNIQUERYWITHOUTERELEASEATTACH */
154790 /* AVINGLOBEGINNERANGEBETWEENOTHINGROUPSCASCADETACHCASECOLLATE */
154791 /* CREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORT */
154792 /* UPDATEVALUESVIRTUALASTWHENWHERECURSIVEAFTERENAMEANDEFAULT */
154793 /* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */
154794 /* ARTITIONDEFERREDISTINCTDROPRECEDINGFAILIMITFILTEREPLACEFIRST */
154795 /* FOLLOWINGFROMFULLIFORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */
154796 /* UNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBYINITIALLYPRIMARY */
154797 static const char zKWText[637] = {
154798 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
154799 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
154800 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
154801 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
154802 'E','R','R','A','B','L','E','L','S','E','X','C','L','U','D','E','L','E',
@@ -154803,97 +155945,100 @@
154803 'T','E','M','P','O','R','A','R','Y','I','S','N','U','L','L','S','A','V',
154804 'E','P','O','I','N','T','E','R','S','E','C','T','I','E','S','N','O','T',
154805 'N','U','L','L','I','K','E','X','C','E','P','T','R','A','N','S','A','C',
154806 'T','I','O','N','A','T','U','R','A','L','T','E','R','A','I','S','E','X',
154807 'C','L','U','S','I','V','E','X','I','S','T','S','C','O','N','S','T','R',
154808 'A','I','N','T','O','F','F','S','E','T','R','I','G','G','E','R','E','F',
154809 'E','R','E','N','C','E','S','U','N','I','Q','U','E','R','Y','W','I','T',
154810 'H','O','U','T','E','R','E','L','E','A','S','E','A','T','T','A','C','H',
154811 'A','V','I','N','G','L','O','B','E','G','I','N','N','E','R','A','N','G',
154812 'E','B','E','T','W','E','E','N','O','T','H','I','N','G','R','O','U','P',
154813 'S','C','A','S','C','A','D','E','T','A','C','H','C','A','S','E','C','O',
154814 'L','L','A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T',
154815 '_','D','A','T','E','I','M','M','E','D','I','A','T','E','J','O','I','N',
154816 'S','E','R','T','M','A','T','C','H','P','L','A','N','A','L','Y','Z','E',
154817 'P','R','A','G','M','A','B','O','R','T','U','P','D','A','T','E','V','A',
154818 'L','U','E','S','V','I','R','T','U','A','L','A','S','T','W','H','E','N',
154819 'W','H','E','R','E','C','U','R','S','I','V','E','A','F','T','E','R','E',
154820 'N','A','M','E','A','N','D','E','F','A','U','L','T','A','U','T','O','I',
154821 'N','C','R','E','M','E','N','T','C','A','S','T','C','O','L','U','M','N',
154822 'C','O','M','M','I','T','C','O','N','F','L','I','C','T','C','R','O','S',
154823 'S','C','U','R','R','E','N','T','_','T','I','M','E','S','T','A','M','P',
154824 'A','R','T','I','T','I','O','N','D','E','F','E','R','R','E','D','I','S',
154825 'T','I','N','C','T','D','R','O','P','R','E','C','E','D','I','N','G','F',
154826 'A','I','L','I','M','I','T','F','I','L','T','E','R','E','P','L','A','C',
154827 'E','F','I','R','S','T','F','O','L','L','O','W','I','N','G','F','R','O',
154828 'M','F','U','L','L','I','F','O','R','D','E','R','E','S','T','R','I','C',
154829 'T','O','T','H','E','R','S','O','V','E','R','I','G','H','T','R','O','L',
154830 'L','B','A','C','K','R','O','W','S','U','N','B','O','U','N','D','E','D',
154831 'U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M','V','I',
154832 'E','W','I','N','D','O','W','B','Y','I','N','I','T','I','A','L','L','Y',
154833 'P','R','I','M','A','R','Y',
154834 };
154835 /* aKWHash[i] is the hash value for the i-th keyword */
154836 static const unsigned char aKWHash[127] = {
154837 82, 113, 130, 80, 110, 29, 0, 0, 89, 0, 83, 70, 0,
154838 53, 35, 84, 15, 0, 129, 92, 64, 124, 131, 19, 0, 0,
154839 136, 0, 134, 126, 0, 22, 100, 0, 9, 0, 0, 121, 78,
154840 0, 76, 6, 0, 58, 97, 143, 0, 132, 108, 0, 0, 48,
154841 0, 111, 24, 0, 17, 0, 137, 63, 23, 26, 5, 65, 138,
154842 103, 120, 0, 142, 114, 69, 141, 66, 118, 72, 0, 98, 0,
154843 107, 41, 0, 106, 0, 0, 0, 102, 99, 104, 109, 123, 14,
154844 50, 122, 0, 87, 0, 139, 119, 140, 68, 127, 135, 86, 81,
154845 37, 91, 117, 0, 0, 101, 51, 128, 125, 0, 133, 0, 0,
154846 44, 0, 93, 67, 39, 0, 20, 45, 115, 88,
154847 };
154848 /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
154849 ** then the i-th keyword has no more hash collisions. Otherwise,
154850 ** the next keyword with the same hash is aKWHash[i]-1. */
154851 static const unsigned char aKWNext[143] = {
154852 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
154853 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
154854 0, 0, 0, 21, 0, 0, 0, 0, 12, 0, 0, 0, 0,
154855 0, 0, 0, 7, 0, 36, 0, 0, 28, 0, 0, 0, 31,
154856 0, 0, 0, 40, 0, 0, 0, 0, 0, 60, 0, 54, 0,
154857 0, 38, 47, 0, 0, 0, 3, 0, 0, 74, 1, 73, 0,
154858 0, 0, 52, 0, 0, 0, 0, 0, 0, 57, 59, 56, 30,
154859 0, 0, 0, 46, 0, 16, 49, 10, 0, 0, 0, 0, 0,
154860 0, 0, 11, 79, 95, 0, 0, 8, 0, 112, 0, 105, 0,
154861 43, 62, 0, 77, 0, 116, 0, 61, 0, 0, 94, 42, 55,
154862 0, 75, 34, 90, 32, 33, 27, 25, 18, 96, 0, 71, 85,
 
154863 };
154864 /* aKWLen[i] is the length (in bytes) of the i-th keyword */
154865 static const unsigned char aKWLen[143] = {
154866 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
154867 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7,
154868 6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4,
154869 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 10, 4, 6,
154870 2, 3, 7, 10, 6, 5, 7, 4, 5, 7, 6, 6, 4,
154871 5, 5, 5, 7, 7, 6, 5, 7, 3, 6, 4, 7, 6,
154872 12, 9, 4, 6, 5, 4, 7, 6, 5, 6, 6, 7, 4,
154873 4, 5, 9, 5, 6, 3, 7, 13, 2, 2, 4, 6, 6,
154874 8, 5, 17, 12, 7, 9, 8, 8, 2, 4, 9, 4, 5,
154875 6, 7, 5, 9, 4, 4, 2, 5, 8, 6, 4, 5, 8,
154876 4, 3, 9, 5, 5, 6, 4, 6, 2, 2, 9, 3, 7,
 
154877 };
154878 /* aKWOffset[i] is the index into zKWText[] of the start of
154879 ** the text for the i-th keyword. */
154880 static const unsigned short int aKWOffset[143] = {
154881 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
154882 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
154883 86, 90, 90, 94, 99, 101, 105, 111, 119, 123, 123, 123, 126,
154884 129, 132, 137, 142, 146, 147, 152, 156, 160, 168, 174, 181, 184,
154885 184, 187, 189, 195, 205, 208, 213, 213, 217, 221, 228, 233, 238,
154886 241, 244, 248, 253, 259, 265, 265, 271, 272, 276, 282, 286, 293,
154887 299, 311, 320, 322, 328, 333, 335, 342, 347, 352, 358, 364, 370,
154888 374, 378, 381, 390, 394, 400, 402, 409, 411, 413, 422, 426, 432,
154889 438, 446, 451, 451, 451, 467, 476, 483, 484, 491, 494, 503, 506,
154890 511, 516, 523, 528, 537, 541, 545, 547, 551, 559, 565, 568, 573,
154891 581, 581, 585, 594, 599, 604, 610, 613, 616, 619, 621, 626, 630,
 
154892 };
154893 /* aKWCode[i] is the parser symbol code for the i-th keyword */
154894 static const unsigned char aKWCode[143] = {
154895 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
154896 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
154897 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
154898 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
154899 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
@@ -154901,29 +156046,158 @@
154901 TK_ISNULL, TK_NULLS, TK_SAVEPOINT, TK_INTERSECT, TK_TIES,
154902 TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
154903 TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
154904 TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_CONSTRAINT,
154905 TK_INTO, TK_OFFSET, TK_OF, TK_SET, TK_TRIGGER,
154906 TK_REFERENCES, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
154907 TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_LIKE_KW,
154908 TK_BEGIN, TK_JOIN_KW, TK_RANGE, TK_BETWEEN, TK_NOTHING,
154909 TK_GROUPS, TK_GROUP, TK_CASCADE, TK_ASC, TK_DETACH,
154910 TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_IMMEDIATE,
154911 TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE,
154912 TK_PRAGMA, TK_ABORT, TK_UPDATE, TK_VALUES, TK_VIRTUAL,
154913 TK_LAST, TK_WHEN, TK_WHERE, TK_RECURSIVE, TK_AFTER,
154914 TK_RENAME, TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO,
154915 TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT,
154916 TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT, TK_PARTITION,
154917 TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP, TK_PRECEDING,
154918 TK_FAIL, TK_LIMIT, TK_FILTER, TK_REPLACE, TK_FIRST,
154919 TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_IF, TK_ORDER,
154920 TK_RESTRICT, TK_OTHERS, TK_OVER, TK_JOIN_KW, TK_ROLLBACK,
154921 TK_ROWS, TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING,
154922 TK_VACUUM, TK_VIEW, TK_WINDOW, TK_DO, TK_BY,
154923 TK_INITIALLY, TK_ALL, TK_PRIMARY,
154924 };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154925 /* Check to see if z[0..n-1] is a keyword. If it is, write the
154926 ** parser symbol code for that keyword into *pType. Always
154927 ** return the integer n (the length of the token). */
154928 static int keywordCode(const char *z, int n, int *pType){
154929 int i, j;
@@ -154994,98 +156268,100 @@
154994 testcase( i==50 ); /* INTO */
154995 testcase( i==51 ); /* OFFSET */
154996 testcase( i==52 ); /* OF */
154997 testcase( i==53 ); /* SET */
154998 testcase( i==54 ); /* TRIGGER */
154999 testcase( i==55 ); /* REFERENCES */
155000 testcase( i==56 ); /* UNIQUE */
155001 testcase( i==57 ); /* QUERY */
155002 testcase( i==58 ); /* WITHOUT */
155003 testcase( i==59 ); /* WITH */
155004 testcase( i==60 ); /* OUTER */
155005 testcase( i==61 ); /* RELEASE */
155006 testcase( i==62 ); /* ATTACH */
155007 testcase( i==63 ); /* HAVING */
155008 testcase( i==64 ); /* GLOB */
155009 testcase( i==65 ); /* BEGIN */
155010 testcase( i==66 ); /* INNER */
155011 testcase( i==67 ); /* RANGE */
155012 testcase( i==68 ); /* BETWEEN */
155013 testcase( i==69 ); /* NOTHING */
155014 testcase( i==70 ); /* GROUPS */
155015 testcase( i==71 ); /* GROUP */
155016 testcase( i==72 ); /* CASCADE */
155017 testcase( i==73 ); /* ASC */
155018 testcase( i==74 ); /* DETACH */
155019 testcase( i==75 ); /* CASE */
155020 testcase( i==76 ); /* COLLATE */
155021 testcase( i==77 ); /* CREATE */
155022 testcase( i==78 ); /* CURRENT_DATE */
155023 testcase( i==79 ); /* IMMEDIATE */
155024 testcase( i==80 ); /* JOIN */
155025 testcase( i==81 ); /* INSERT */
155026 testcase( i==82 ); /* MATCH */
155027 testcase( i==83 ); /* PLAN */
155028 testcase( i==84 ); /* ANALYZE */
155029 testcase( i==85 ); /* PRAGMA */
155030 testcase( i==86 ); /* ABORT */
155031 testcase( i==87 ); /* UPDATE */
155032 testcase( i==88 ); /* VALUES */
155033 testcase( i==89 ); /* VIRTUAL */
155034 testcase( i==90 ); /* LAST */
155035 testcase( i==91 ); /* WHEN */
155036 testcase( i==92 ); /* WHERE */
155037 testcase( i==93 ); /* RECURSIVE */
155038 testcase( i==94 ); /* AFTER */
155039 testcase( i==95 ); /* RENAME */
155040 testcase( i==96 ); /* AND */
155041 testcase( i==97 ); /* DEFAULT */
155042 testcase( i==98 ); /* AUTOINCREMENT */
155043 testcase( i==99 ); /* TO */
155044 testcase( i==100 ); /* IN */
155045 testcase( i==101 ); /* CAST */
155046 testcase( i==102 ); /* COLUMN */
155047 testcase( i==103 ); /* COMMIT */
155048 testcase( i==104 ); /* CONFLICT */
155049 testcase( i==105 ); /* CROSS */
155050 testcase( i==106 ); /* CURRENT_TIMESTAMP */
155051 testcase( i==107 ); /* CURRENT_TIME */
155052 testcase( i==108 ); /* CURRENT */
155053 testcase( i==109 ); /* PARTITION */
155054 testcase( i==110 ); /* DEFERRED */
155055 testcase( i==111 ); /* DISTINCT */
155056 testcase( i==112 ); /* IS */
155057 testcase( i==113 ); /* DROP */
155058 testcase( i==114 ); /* PRECEDING */
155059 testcase( i==115 ); /* FAIL */
155060 testcase( i==116 ); /* LIMIT */
155061 testcase( i==117 ); /* FILTER */
155062 testcase( i==118 ); /* REPLACE */
155063 testcase( i==119 ); /* FIRST */
155064 testcase( i==120 ); /* FOLLOWING */
155065 testcase( i==121 ); /* FROM */
155066 testcase( i==122 ); /* FULL */
155067 testcase( i==123 ); /* IF */
155068 testcase( i==124 ); /* ORDER */
155069 testcase( i==125 ); /* RESTRICT */
155070 testcase( i==126 ); /* OTHERS */
155071 testcase( i==127 ); /* OVER */
155072 testcase( i==128 ); /* RIGHT */
155073 testcase( i==129 ); /* ROLLBACK */
155074 testcase( i==130 ); /* ROWS */
155075 testcase( i==131 ); /* ROW */
155076 testcase( i==132 ); /* UNBOUNDED */
155077 testcase( i==133 ); /* UNION */
155078 testcase( i==134 ); /* USING */
155079 testcase( i==135 ); /* VACUUM */
155080 testcase( i==136 ); /* VIEW */
155081 testcase( i==137 ); /* WINDOW */
155082 testcase( i==138 ); /* DO */
155083 testcase( i==139 ); /* BY */
155084 testcase( i==140 ); /* INITIALLY */
155085 testcase( i==141 ); /* ALL */
155086 testcase( i==142 ); /* PRIMARY */
 
 
155087 *pType = aKWCode[i];
155088 break;
155089 }
155090 }
155091 return n;
@@ -155093,11 +156369,11 @@
155093 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
155094 int id = TK_ID;
155095 keywordCode((char*)z, n, &id);
155096 return id;
155097 }
155098 #define SQLITE_N_KEYWORD 143
155099 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
155100 if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
155101 *pzName = zKWText + aKWOffset[i];
155102 *pnName = aKWLen[i];
155103 return SQLITE_OK;
@@ -155720,11 +156996,11 @@
155720 int tokenType; /* type of current token */
155721 int prevType = 0; /* Previous non-whitespace token */
155722 int nParen; /* Number of nested levels of parentheses */
155723 int iStartIN; /* Start of RHS of IN operator in z[] */
155724 int nParenAtIN; /* Value of nParent at start of RHS of IN operator */
155725 int j; /* Bytes of normalized SQL generated so far */
155726 sqlite3_str *pStr; /* The normalized SQL string under construction */
155727
155728 db = sqlite3VdbeDb(pVdbe);
155729 tokenType = -1;
155730 nParen = iStartIN = nParenAtIN = 0;
@@ -155764,11 +157040,11 @@
155764 sqlite3_str_append(pStr, "(", 1);
155765 break;
155766 }
155767 case TK_RP: {
155768 if( iStartIN>0 && nParen==nParenAtIN ){
155769 assert( pStr->nChar>=iStartIN );
155770 pStr->nChar = iStartIN+1;
155771 sqlite3_str_append(pStr, "?,?,?", 5);
155772 iStartIN = 0;
155773 }
155774 nParen--;
@@ -156933,10 +158209,11 @@
156933 }
156934 db->lookaside.pStart = pStart;
156935 db->lookaside.pInit = 0;
156936 db->lookaside.pFree = 0;
156937 db->lookaside.sz = (u16)sz;
 
156938 if( pStart ){
156939 int i;
156940 LookasideSlot *p;
156941 assert( sz > (int)sizeof(LookasideSlot*) );
156942 db->lookaside.nSlot = cnt;
@@ -156951,10 +158228,11 @@
156951 db->lookaside.bMalloced = pBuf==0 ?1:0;
156952 }else{
156953 db->lookaside.pStart = db;
156954 db->lookaside.pEnd = db;
156955 db->lookaside.bDisable = 1;
 
156956 db->lookaside.bMalloced = 0;
156957 db->lookaside.nSlot = 0;
156958 }
156959 #endif /* SQLITE_OMIT_LOOKASIDE */
156960 return SQLITE_OK;
@@ -157067,10 +158345,11 @@
157067 { SQLITE_DBCONFIG_WRITABLE_SCHEMA, SQLITE_WriteSchema|
157068 SQLITE_NoSchemaError },
157069 { SQLITE_DBCONFIG_LEGACY_ALTER_TABLE, SQLITE_LegacyAlter },
157070 { SQLITE_DBCONFIG_DQS_DDL, SQLITE_DqsDDL },
157071 { SQLITE_DBCONFIG_DQS_DML, SQLITE_DqsDML },
 
157072 };
157073 unsigned int i;
157074 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
157075 for(i=0; i<ArraySize(aFlagOp); i++){
157076 if( aFlagOp[i].op==op ){
@@ -157605,10 +158884,11 @@
157605 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
157606 case SQLITE_CANTOPEN_NOTEMPDIR: zName = "SQLITE_CANTOPEN_NOTEMPDIR";break;
157607 case SQLITE_CANTOPEN_ISDIR: zName = "SQLITE_CANTOPEN_ISDIR"; break;
157608 case SQLITE_CANTOPEN_FULLPATH: zName = "SQLITE_CANTOPEN_FULLPATH"; break;
157609 case SQLITE_CANTOPEN_CONVPATH: zName = "SQLITE_CANTOPEN_CONVPATH"; break;
 
157610 case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break;
157611 case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break;
157612 case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break;
157613 case SQLITE_TOOBIG: zName = "SQLITE_TOOBIG"; break;
157614 case SQLITE_CONSTRAINT: zName = "SQLITE_CONSTRAINT"; break;
@@ -159282,10 +160562,11 @@
159282 db->errMask = 0xff;
159283 db->nDb = 2;
159284 db->magic = SQLITE_MAGIC_BUSY;
159285 db->aDb = db->aDbStatic;
159286 db->lookaside.bDisable = 1;
 
159287
159288 assert( sizeof(db->aLimit)==sizeof(aHardLimit) );
159289 memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
159290 db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS;
159291 db->autoCommit = 1;
@@ -160401,10 +161682,29 @@
160401 va_end(ap);
160402 #endif /* SQLITE_UNTESTABLE */
160403 return rc;
160404 }
160405
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160406 /*
160407 ** This is a utility routine, useful to VFS implementations, that checks
160408 ** to see if a database file was a URI that contained a specific query
160409 ** parameter, and if so obtains the value of the query parameter.
160410 **
@@ -161883,16 +163183,26 @@
161883 */
161884 int inTransaction; /* True after xBegin but before xCommit/xRollback */
161885 int mxSavepoint; /* Largest valid xSavepoint integer */
161886 #endif
161887
161888 #ifdef SQLITE_TEST
161889 /* True to disable the incremental doclist optimization. This is controled
161890 ** by special insert command 'test-no-incr-doclist'. */
161891 int bNoIncrDoclist;
 
 
 
161892 #endif
161893 };
 
 
 
 
 
 
 
161894
161895 /*
161896 ** When the core wants to read from the virtual table, it creates a
161897 ** virtual table cursor (an instance of the following structure) using
161898 ** the xOpen method. Cursors are destroyed using the xClose method.
@@ -162153,10 +163463,11 @@
162153
162154 /* fts3.c */
162155 SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...);
162156 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
162157 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
 
162158 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
162159 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
162160 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
162161 SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
162162 SQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);
@@ -162315,10 +163626,36 @@
162315 GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *v, 4);
162316 b = (a & 0x0FFFFFFF );
162317
162318 for(shift=28; shift<=63; shift+=7){
162319 u64 c = *p++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162320 b += (c&0x7F) << shift;
162321 if( (c & 0x80)==0 ) break;
162322 }
162323 *v = b;
162324 return (int)(p - pStart);
@@ -163416,10 +164753,14 @@
163416
163417 /* Figure out the page-size for the database. This is required in order to
163418 ** estimate the cost of loading large doclists from the database. */
163419 fts3DatabasePageSize(&rc, p);
163420 p->nNodeSize = p->nPgsz-35;
 
 
 
 
163421
163422 /* Declare the table schema to SQLite. */
163423 fts3DeclareVtab(&rc, p);
163424
163425 fts3_init_out:
@@ -163924,11 +165265,17 @@
163924
163925 if( rc==SQLITE_OK ){
163926 rc = sqlite3Fts3ReadBlock(p, piLeaf?*piLeaf:*piLeaf2, &zBlob, &nBlob, 0);
163927 }
163928 if( rc==SQLITE_OK ){
163929 rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, piLeaf2);
 
 
 
 
 
 
163930 }
163931 sqlite3_free(zBlob);
163932 }
163933
163934 return rc;
@@ -164411,19 +165758,20 @@
164411 int bDescIdx, /* True for descending docids */
164412 sqlite3_int64 *piPrev, /* IN/OUT: Previous value written to list */
164413 int *pbFirst, /* IN/OUT: True after first int written */
164414 sqlite3_int64 iVal /* Write this value to the list */
164415 ){
164416 sqlite3_int64 iWrite;
164417 if( bDescIdx==0 || *pbFirst==0 ){
 
164418 iWrite = iVal - *piPrev;
164419 }else{
 
164420 iWrite = *piPrev - iVal;
164421 }
164422 assert( *pbFirst || *piPrev==0 );
164423 assert_fts3_nc( *pbFirst==0 || iWrite>0 );
164424 assert( *pbFirst==0 || iWrite>=0 );
164425 *pp += sqlite3Fts3PutVarint(*pp, iWrite);
164426 *piPrev = iVal;
164427 *pbFirst = 1;
164428 }
164429
@@ -166267,11 +167615,11 @@
166267 ** tokens or prefix tokens that cannot use a prefix-index. */
166268 int bHaveIncr = 0;
166269 int bIncrOk = (bOptOk
166270 && pCsr->bDesc==pTab->bDescIdx
166271 && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0
166272 #ifdef SQLITE_TEST
166273 && pTab->bNoIncrDoclist==0
166274 #endif
166275 );
166276 for(i=0; bIncrOk==1 && i<p->nToken; i++){
166277 Fts3PhraseToken *pToken = &p->aToken[i];
@@ -166789,16 +168137,17 @@
166789 const char *a;
166790
166791 rc = sqlite3Fts3SelectDoctotal(p, &pStmt);
166792 if( rc!=SQLITE_OK ) return rc;
166793 a = sqlite3_column_blob(pStmt, 0);
166794 assert( a );
166795
166796 pEnd = &a[sqlite3_column_bytes(pStmt, 0)];
166797 a += sqlite3Fts3GetVarint(a, &nDoc);
166798 while( a<pEnd ){
166799 a += sqlite3Fts3GetVarint(a, &nByte);
 
166800 }
166801 if( nDoc==0 || nByte==0 ){
166802 sqlite3_reset(pStmt);
166803 return FTS_CORRUPT_VTAB;
166804 }
@@ -171232,11 +172581,13 @@
171232 return rc;
171233 }
171234
171235 sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);
171236 if( SQLITE_ROW==sqlite3_step(pStmt) ){
171237 if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){
 
 
171238 memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));
171239 }
171240 }
171241
171242 return sqlite3_finalize(pStmt);
@@ -172081,11 +173432,11 @@
172081 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
172082
172083 /* #include <string.h> */
172084 /* #include <assert.h> */
172085 /* #include <stdlib.h> */
172086
172087
172088 #define FTS_MAX_APPENDABLE_HEIGHT 16
172089
172090 /*
172091 ** When full-text index nodes are loaded from disk, the buffer that they
@@ -172125,11 +173476,11 @@
172125 # define FTS3_NODE_CHUNKSIZE (4*1024)
172126 # define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)
172127 #endif
172128
172129 /*
172130 ** The two values that may be meaningfully bound to the :1 parameter in
172131 ** statements SQL_REPLACE_STAT and SQL_SELECT_STAT.
172132 */
172133 #define FTS_STAT_DOCTOTAL 0
172134 #define FTS_STAT_INCRMERGEHINT 1
172135 #define FTS_STAT_AUTOINCRMERGE 2
@@ -173211,11 +174562,11 @@
173211 /* If iNext is FTS3_MERGE_COUNT, indicating that level iLevel is already
173212 ** full, merge all segments in level iLevel into a single iLevel+1
173213 ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,
173214 ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.
173215 */
173216 if( iNext>=FTS3_MERGE_COUNT ){
173217 fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel));
173218 rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);
173219 *piIdx = 0;
173220 }else{
173221 *piIdx = iNext;
@@ -173437,11 +174788,11 @@
173437 ** safe (no risk of overread) even if the node data is corrupted. */
173438 pNext += fts3GetVarint32(pNext, &nPrefix);
173439 pNext += fts3GetVarint32(pNext, &nSuffix);
173440 if( nSuffix<=0
173441 || (&pReader->aNode[pReader->nNode] - pNext)<nSuffix
173442 || nPrefix>pReader->nTermAlloc
173443 ){
173444 return FTS_CORRUPT_VTAB;
173445 }
173446
173447 /* Both nPrefix and nSuffix were read by fts3GetVarint32() and so are
@@ -174087,10 +175438,15 @@
174087 int nPrefix; /* Number of bytes of prefix compression */
174088 int nSuffix; /* Suffix length */
174089
174090 nPrefix = fts3PrefixCompress(pTree->zTerm, pTree->nTerm, zTerm, nTerm);
174091 nSuffix = nTerm-nPrefix;
 
 
 
 
 
174092
174093 nReq += sqlite3Fts3VarintLen(nPrefix)+sqlite3Fts3VarintLen(nSuffix)+nSuffix;
174094 if( nReq<=p->nNodeSize || !pTree->zTerm ){
174095
174096 if( nReq>p->nNodeSize ){
@@ -174381,13 +175737,15 @@
174381 assert( nData+nReq<=pWriter->nSize );
174382
174383 /* Append the prefix-compressed term and doclist to the buffer. */
174384 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nPrefix);
174385 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nSuffix);
 
174386 memcpy(&pWriter->aData[nData], &zTerm[nPrefix], nSuffix);
174387 nData += nSuffix;
174388 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nDoclist);
 
174389 memcpy(&pWriter->aData[nData], aDoclist, nDoclist);
174390 pWriter->nData = nData + nDoclist;
174391
174392 /* Save the current term so that it can be used to prefix-compress the next.
174393 ** If the isCopyTerm parameter is true, then the buffer pointed to by
@@ -174403,10 +175761,11 @@
174403 pWriter->nMalloc = nTerm*2;
174404 pWriter->zMalloc = zNew;
174405 pWriter->zTerm = zNew;
174406 }
174407 assert( pWriter->zTerm==pWriter->zMalloc );
 
174408 memcpy(pWriter->zTerm, zTerm, nTerm);
174409 }else{
174410 pWriter->zTerm = (char *)zTerm;
174411 }
174412 pWriter->nTerm = nTerm;
@@ -174711,10 +176070,11 @@
174711 pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer);
174712 if( !pNew ) return SQLITE_NOMEM;
174713 pMsr->aBuffer = pNew;
174714 }
174715
 
174716 memcpy(pMsr->aBuffer, pList, nList);
174717 return SQLITE_OK;
174718 }
174719
174720 SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
@@ -175024,18 +176384,16 @@
175024
175025 /* Calculate the 'docid' delta value to write into the merged
175026 ** doclist. */
175027 sqlite3_int64 iDelta;
175028 if( p->bDescIdx && nDoclist>0 ){
 
175029 iDelta = iPrev - iDocid;
175030 }else{
 
175031 iDelta = iDocid - iPrev;
175032 }
175033 if( iDelta<=0 && (nDoclist>0 || iDelta!=iDocid) ){
175034 return FTS_CORRUPT_VTAB;
175035 }
175036 assert( nDoclist>0 || iDelta==iDocid );
175037
175038 nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
175039 if( nDoclist+nByte>pCsr->nBuffer ){
175040 char *aNew;
175041 pCsr->nBuffer = (nDoclist+nByte)*2;
@@ -175540,11 +176898,14 @@
175540 static int fts3DoOptimize(Fts3Table *p, int bReturnDone){
175541 int bSeenDone = 0;
175542 int rc;
175543 sqlite3_stmt *pAllLangid = 0;
175544
175545 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
 
 
 
175546 if( rc==SQLITE_OK ){
175547 int rc2;
175548 sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);
175549 sqlite3_bind_int(pAllLangid, 2, p->nIndex);
175550 while( sqlite3_step(pAllLangid)==SQLITE_ROW ){
@@ -175561,11 +176922,10 @@
175561 rc2 = sqlite3_reset(pAllLangid);
175562 if( rc==SQLITE_OK ) rc = rc2;
175563 }
175564
175565 sqlite3Fts3SegmentsClose(p);
175566 sqlite3Fts3PendingTermsClear(p);
175567
175568 return (rc==SQLITE_OK && bReturnDone && bSeenDone) ? SQLITE_DONE : rc;
175569 }
175570
175571 /*
@@ -175899,10 +177259,11 @@
175899 ** the current node of layer iLayer. Due to the prefix compression,
175900 ** the space required changes depending on which node the key is to
175901 ** be added to. */
175902 nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);
175903 nSuffix = nTerm - nPrefix;
 
175904 nSpace = sqlite3Fts3VarintLen(nPrefix);
175905 nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
175906
175907 if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){
175908 /* If the current node of layer iLayer contains zero keys, or if adding
@@ -176293,10 +177654,14 @@
176293 pWriter->nLeafData = pWriter->nLeafData * -1;
176294 }
176295 pWriter->bNoLeafData = (pWriter->nLeafData==0);
176296 nRoot = sqlite3_column_bytes(pSelect, 4);
176297 aRoot = sqlite3_column_blob(pSelect, 4);
 
 
 
 
176298 }else{
176299 return sqlite3_reset(pSelect);
176300 }
176301
176302 /* Check for the zero-length marker in the %_segments table */
@@ -176328,10 +177693,14 @@
176328 /* It is possible to append to this segment. Set up the IncrmergeWriter
176329 ** object to do so. */
176330 int i;
176331 int nHeight = (int)aRoot[0];
176332 NodeWriter *pNode;
 
 
 
 
176333
176334 pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;
176335 pWriter->iStart = iStart;
176336 pWriter->iEnd = iEnd;
176337 pWriter->iAbsLevel = iAbsLevel;
@@ -177006,12 +178375,19 @@
177006 if( rc==SQLITE_OK ){
177007 rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);
177008 }
177009 if( SQLITE_OK==rc && pCsr->nSegment==nSeg
177010 && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))
177011 && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr))
177012 ){
 
 
 
 
 
 
 
 
177013 if( bUseHint && iIdx>0 ){
177014 const char *zKey = pCsr->zTerm;
177015 int nKey = pCsr->nTerm;
177016 rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);
177017 }else{
@@ -177018,15 +178394,17 @@
177018 rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);
177019 }
177020
177021 if( rc==SQLITE_OK && pWriter->nLeafEst ){
177022 fts3LogMerge(nSeg, iAbsLevel);
177023 do {
177024 rc = fts3IncrmergeAppend(p, pWriter, pCsr);
177025 if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);
177026 if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;
177027 }while( rc==SQLITE_ROW );
 
 
177028
177029 /* Update or delete the input segments */
177030 if( rc==SQLITE_OK ){
177031 nRem -= (1 + pWriter->nWork);
177032 rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);
@@ -177087,11 +178465,11 @@
177087 static int fts3DoIncrmerge(
177088 Fts3Table *p, /* FTS3 table handle */
177089 const char *zParam /* Nul-terminated string containing "A,B" */
177090 ){
177091 int rc;
177092 int nMin = (FTS3_MERGE_COUNT / 2);
177093 int nMerge = 0;
177094 const char *z = zParam;
177095
177096 /* Read the first integer value */
177097 nMerge = fts3Getint(&z);
@@ -177132,11 +178510,11 @@
177132 const char *zParam /* Nul-terminated string containing boolean */
177133 ){
177134 int rc = SQLITE_OK;
177135 sqlite3_stmt *pStmt = 0;
177136 p->nAutoincrmerge = fts3Getint(&zParam);
177137 if( p->nAutoincrmerge==1 || p->nAutoincrmerge>FTS3_MERGE_COUNT ){
177138 p->nAutoincrmerge = 8;
177139 }
177140 if( !p->bHasStat ){
177141 assert( p->bFts4==0 );
177142 sqlite3Fts3CreateStatTable(&rc, p);
@@ -177229,11 +178607,15 @@
177229 iPos = 0;
177230 if( iVal ){
177231 pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
177232 }else{
177233 pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
177234 iDocid += iVal;
 
 
 
 
177235 }
177236 }else{
177237 iPos += (iVal - 2);
177238 cksum = cksum ^ fts3ChecksumEntry(
177239 csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid,
@@ -177302,14 +178684,13 @@
177302 int iCol;
177303
177304 for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
177305 if( p->abNotindexed[iCol]==0 ){
177306 const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
177307 int nText = sqlite3_column_bytes(pStmt, iCol+1);
177308 sqlite3_tokenizer_cursor *pT = 0;
177309
177310 rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText,&pT);
177311 while( rc==SQLITE_OK ){
177312 char const *zToken; /* Buffer containing token */
177313 int nToken = 0; /* Number of bytes in token */
177314 int iDum1 = 0, iDum2 = 0; /* Dummy variables */
177315 int iPos = 0; /* Position of token in zText */
@@ -177390,11 +178771,11 @@
177390 **
177391 ** Argument pVal contains the result of <expr>. Currently the only
177392 ** meaningful value to insert is the text 'optimize'.
177393 */
177394 static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){
177395 int rc; /* Return Code */
177396 const char *zVal = (const char *)sqlite3_value_text(pVal);
177397 int nVal = sqlite3_value_bytes(pVal);
177398
177399 if( !zVal ){
177400 return SQLITE_NOMEM;
@@ -177406,25 +178787,31 @@
177406 rc = fts3DoIntegrityCheck(p);
177407 }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, "merge=", 6) ){
177408 rc = fts3DoIncrmerge(p, &zVal[6]);
177409 }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){
177410 rc = fts3DoAutoincrmerge(p, &zVal[10]);
177411 #ifdef SQLITE_TEST
177412 }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
177413 p->nNodeSize = atoi(&zVal[9]);
177414 rc = SQLITE_OK;
177415 }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
177416 p->nMaxPendingData = atoi(&zVal[11]);
177417 rc = SQLITE_OK;
177418 }else if( nVal>21 && 0==sqlite3_strnicmp(zVal, "test-no-incr-doclist=", 21) ){
177419 p->bNoIncrDoclist = atoi(&zVal[21]);
177420 rc = SQLITE_OK;
 
 
 
 
 
 
 
 
 
177421 #endif
177422 }else{
177423 rc = SQLITE_ERROR;
177424 }
177425
177426 return rc;
177427 }
177428
177429 #ifndef SQLITE_DISABLE_FTS4_DEFERRED
177430 /*
@@ -178825,29 +180212,41 @@
178825
178826 static int fts3MatchinfoSelectDoctotal(
178827 Fts3Table *pTab,
178828 sqlite3_stmt **ppStmt,
178829 sqlite3_int64 *pnDoc,
178830 const char **paLen
 
178831 ){
178832 sqlite3_stmt *pStmt;
178833 const char *a;
 
178834 sqlite3_int64 nDoc;
 
 
178835
178836 if( !*ppStmt ){
178837 int rc = sqlite3Fts3SelectDoctotal(pTab, ppStmt);
178838 if( rc!=SQLITE_OK ) return rc;
178839 }
178840 pStmt = *ppStmt;
178841 assert( sqlite3_data_count(pStmt)==1 );
178842
 
178843 a = sqlite3_column_blob(pStmt, 0);
178844 a += sqlite3Fts3GetVarint(a, &nDoc);
178845 if( nDoc==0 ) return FTS_CORRUPT_VTAB;
178846 *pnDoc = (u32)nDoc;
 
 
 
 
 
 
178847
178848 if( paLen ) *paLen = a;
 
178849 return SQLITE_OK;
178850 }
178851
178852 /*
178853 ** An instance of the following structure is used to store state while
@@ -179024,27 +180423,32 @@
179024 break;
179025
179026 case FTS3_MATCHINFO_NDOC:
179027 if( bGlobal ){
179028 sqlite3_int64 nDoc = 0;
179029 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0);
179030 pInfo->aMatchinfo[0] = (u32)nDoc;
179031 }
179032 break;
179033
179034 case FTS3_MATCHINFO_AVGLENGTH:
179035 if( bGlobal ){
179036 sqlite3_int64 nDoc; /* Number of rows in table */
179037 const char *a; /* Aggregate column length array */
 
179038
179039 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, &a);
179040 if( rc==SQLITE_OK ){
179041 int iCol;
179042 for(iCol=0; iCol<pInfo->nCol; iCol++){
179043 u32 iVal;
179044 sqlite3_int64 nToken;
179045 a += sqlite3Fts3GetVarint(a, &nToken);
 
 
 
 
179046 iVal = (u32)(((u32)(nToken&0xffffffff)+nDoc/2)/nDoc);
179047 pInfo->aMatchinfo[iCol] = iVal;
179048 }
179049 }
179050 }
@@ -179054,13 +180458,18 @@
179054 sqlite3_stmt *pSelectDocsize = 0;
179055 rc = sqlite3Fts3SelectDocsize(pTab, pCsr->iPrevId, &pSelectDocsize);
179056 if( rc==SQLITE_OK ){
179057 int iCol;
179058 const char *a = sqlite3_column_blob(pSelectDocsize, 0);
 
179059 for(iCol=0; iCol<pInfo->nCol; iCol++){
179060 sqlite3_int64 nToken;
179061 a += sqlite3Fts3GetVarint(a, &nToken);
 
 
 
 
179062 pInfo->aMatchinfo[iCol] = (u32)nToken;
179063 }
179064 }
179065 sqlite3_reset(pSelectDocsize);
179066 break;
@@ -179087,11 +180496,11 @@
179087 pExpr = pCsr->pExpr;
179088 rc = fts3ExprLoadDoclists(pCsr, 0, 0);
179089 if( rc!=SQLITE_OK ) break;
179090 if( bGlobal ){
179091 if( pCsr->pDeferred ){
179092 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0);
179093 if( rc!=SQLITE_OK ) break;
179094 }
179095 rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
179096 sqlite3Fts3EvalTestDeferred(pCsr, &rc);
179097 if( rc!=SQLITE_OK ) break;
@@ -180822,10 +182231,41 @@
180822 jsonInit(&s, pCtx);
180823 jsonRenderNode(pNode, &s, aReplace);
180824 jsonResult(&s);
180825 sqlite3_result_subtype(pCtx, JSON_SUBTYPE);
180826 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180827
180828 /*
180829 ** Make the JsonNode the return value of the function.
180830 */
180831 static void jsonReturn(
@@ -180916,29 +182356,38 @@
180916 if( c!='\\' ){
180917 zOut[j++] = c;
180918 }else{
180919 c = z[++i];
180920 if( c=='u' ){
180921 u32 v = 0, k;
180922 for(k=0; k<4; i++, k++){
180923 assert( i<n-2 );
180924 c = z[i+1];
180925 assert( safe_isxdigit(c) );
180926 if( c<='9' ) v = v*16 + c - '0';
180927 else if( c<='F' ) v = v*16 + c - 'A' + 10;
180928 else v = v*16 + c - 'a' + 10;
180929 }
180930 if( v==0 ) break;
180931 if( v<=0x7f ){
180932 zOut[j++] = (char)v;
180933 }else if( v<=0x7ff ){
180934 zOut[j++] = (char)(0xc0 | (v>>6));
180935 zOut[j++] = 0x80 | (v&0x3f);
180936 }else{
180937 zOut[j++] = (char)(0xe0 | (v>>12));
180938 zOut[j++] = 0x80 | ((v>>6)&0x3f);
180939 zOut[j++] = 0x80 | (v&0x3f);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180940 }
180941 }else{
180942 if( c=='b' ){
180943 c = '\b';
180944 }else if( c=='f' ){
@@ -195928,11 +197377,11 @@
195928 **
195929 ******************************************************************************
195930 **
195931 ** This file contains an implementation of the "dbstat" virtual table.
195932 **
195933 ** The dbstat virtual table is used to extract low-level formatting
195934 ** information from an SQLite database in order to implement the
195935 ** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script
195936 ** for an example implementation.
195937 **
195938 ** Additional information is available on the "dbstat.html" page of the
@@ -195972,90 +197421,98 @@
195972 ** the overflow pages associated with a cell will appear earlier in the
195973 ** sort-order than its child page:
195974 **
195975 ** '/1c2/000/' // Left-most child of 451st child of root
195976 */
195977 #define VTAB_SCHEMA \
195978 "CREATE TABLE xx( " \
195979 " name TEXT, /* Name of table or index */" \
195980 " path TEXT, /* Path to page from root */" \
195981 " pageno INTEGER, /* Page number */" \
195982 " pagetype TEXT, /* 'internal', 'leaf' or 'overflow' */" \
195983 " ncell INTEGER, /* Cells on page (0 for overflow) */" \
195984 " payload INTEGER, /* Bytes of payload on this page */" \
195985 " unused INTEGER, /* Bytes of unused space on this page */" \
195986 " mx_payload INTEGER, /* Largest payload size of all cells */" \
195987 " pgoffset INTEGER, /* Offset of page in file */" \
195988 " pgsize INTEGER, /* Size of the page */" \
195989 " schema TEXT HIDDEN /* Database schema being analyzed */" \
195990 ");"
195991
195992
 
 
195993 typedef struct StatTable StatTable;
195994 typedef struct StatCursor StatCursor;
195995 typedef struct StatPage StatPage;
195996 typedef struct StatCell StatCell;
195997
 
195998 struct StatCell {
195999 int nLocal; /* Bytes of local payload */
196000 u32 iChildPg; /* Child node (or 0 if this is a leaf) */
196001 int nOvfl; /* Entries in aOvfl[] */
196002 u32 *aOvfl; /* Array of overflow page numbers */
196003 int nLastOvfl; /* Bytes of payload on final overflow page */
196004 int iOvfl; /* Iterates through aOvfl[] */
196005 };
196006
 
196007 struct StatPage {
196008 u32 iPgno;
196009 DbPage *pPg;
196010 int iCell;
196011
196012 char *zPath; /* Path to this page */
196013
196014 /* Variables populated by statDecodePage(): */
196015 u8 flags; /* Copy of flags byte */
196016 int nCell; /* Number of cells on page */
196017 int nUnused; /* Number of unused bytes on page */
196018 StatCell *aCell; /* Array of parsed cells */
196019 u32 iRightChildPg; /* Right-child page number (or 0) */
196020 int nMxPayload; /* Largest payload of any cell on this page */
196021 };
196022
 
196023 struct StatCursor {
196024 sqlite3_vtab_cursor base;
196025 sqlite3_stmt *pStmt; /* Iterates through set of root pages */
196026 int isEof; /* After pStmt has returned SQLITE_DONE */
 
196027 int iDb; /* Schema used for this query */
196028
196029 StatPage aPage[32];
196030 int iPage; /* Current entry in aPage[] */
196031
196032 /* Values to return. */
 
196033 char *zName; /* Value of 'name' column */
196034 char *zPath; /* Value of 'path' column */
196035 u32 iPageno; /* Value of 'pageno' column */
196036 char *zPagetype; /* Value of 'pagetype' column */
 
196037 int nCell; /* Value of 'ncell' column */
196038 int nPayload; /* Value of 'payload' column */
196039 int nUnused; /* Value of 'unused' column */
196040 int nMxPayload; /* Value of 'mx_payload' column */
 
 
196041 i64 iOffset; /* Value of 'pgOffset' column */
196042 int szPage; /* Value of 'pgSize' column */
196043 };
196044
 
196045 struct StatTable {
196046 sqlite3_vtab base;
196047 sqlite3 *db;
196048 int iDb; /* Index of database to analyze */
196049 };
196050
196051 #ifndef get2byte
196052 # define get2byte(x) ((x)[0]<<8 | (x)[1])
196053 #endif
196054
196055 /*
196056 ** Connect to or create a statvfs virtual table.
196057 */
196058 static int statConnect(
196059 sqlite3 *db,
196060 void *pAux,
196061 int argc, const char *const*argv,
@@ -196075,11 +197532,11 @@
196075 return SQLITE_ERROR;
196076 }
196077 }else{
196078 iDb = 0;
196079 }
196080 rc = sqlite3_declare_vtab(db, VTAB_SCHEMA);
196081 if( rc==SQLITE_OK ){
196082 pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable));
196083 if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;
196084 }
196085
@@ -196093,43 +197550,76 @@
196093 *ppVtab = (sqlite3_vtab*)pTab;
196094 return rc;
196095 }
196096
196097 /*
196098 ** Disconnect from or destroy a statvfs virtual table.
196099 */
196100 static int statDisconnect(sqlite3_vtab *pVtab){
196101 sqlite3_free(pVtab);
196102 return SQLITE_OK;
196103 }
196104
196105 /*
196106 ** There is no "best-index". This virtual table always does a linear
196107 ** scan. However, a schema=? constraint should cause this table to
196108 ** operate on a different database schema, so check for it.
196109 **
196110 ** idxNum is normally 0, but will be 1 if a schema=? constraint exists.
 
 
 
 
 
196111 */
196112 static int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
196113 int i;
 
 
 
196114
196115 /* Look for a valid schema=? constraint. If found, change the idxNum to
196116 ** 1 and request the value of that constraint be sent to xFilter. And
196117 ** lower the cost estimate to encourage the constrained version to be
196118 ** used.
196119 */
196120 for(i=0; i<pIdxInfo->nConstraint; i++){
196121 if( pIdxInfo->aConstraint[i].iColumn!=10 ) continue;
196122 if( pIdxInfo->aConstraint[i].usable==0 ) return SQLITE_CONSTRAINT;
196123 if( pIdxInfo->aConstraint[i].op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
196124 pIdxInfo->idxNum = 1;
196125 pIdxInfo->estimatedCost = 1.0;
196126 pIdxInfo->aConstraintUsage[i].argvIndex = 1;
196127 pIdxInfo->aConstraintUsage[i].omit = 1;
196128 break;
 
 
 
 
 
 
 
 
 
 
 
 
 
196129 }
196130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196131
196132 /* Records are always returned in ascending order of (name, path).
196133 ** If this will satisfy the client, set the orderByConsumed flag so that
196134 ** SQLite does not do an external sort.
196135 */
@@ -196143,17 +197633,18 @@
196143 && pIdxInfo->aOrderBy[1].iColumn==1
196144 && pIdxInfo->aOrderBy[1].desc==0
196145 )
196146 ){
196147 pIdxInfo->orderByConsumed = 1;
 
196148 }
196149
196150 return SQLITE_OK;
196151 }
196152
196153 /*
196154 ** Open a new statvfs cursor.
196155 */
196156 static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
196157 StatTable *pTab = (StatTable *)pVTab;
196158 StatCursor *pCsr;
196159
@@ -196198,27 +197689,41 @@
196198 pCsr->iPage = 0;
196199 sqlite3_free(pCsr->zPath);
196200 pCsr->zPath = 0;
196201 pCsr->isEof = 0;
196202 }
 
 
 
 
 
 
 
 
 
 
196203
196204 /*
196205 ** Close a statvfs cursor.
196206 */
196207 static int statClose(sqlite3_vtab_cursor *pCursor){
196208 StatCursor *pCsr = (StatCursor *)pCursor;
196209 statResetCsr(pCsr);
196210 sqlite3_finalize(pCsr->pStmt);
196211 sqlite3_free(pCsr);
196212 return SQLITE_OK;
196213 }
196214
196215 static void getLocalPayload(
 
 
 
 
 
196216 int nUsable, /* Usable bytes per page */
196217 u8 flags, /* Page flags */
196218 int nTotal, /* Total record (payload) size */
196219 int *pnLocal /* OUT: Bytes stored locally */
196220 ){
196221 int nLocal;
196222 int nMinLocal;
196223 int nMaxLocal;
196224
@@ -196230,13 +197735,16 @@
196230 nMaxLocal = (nUsable - 12) * 64 / 255 - 23;
196231 }
196232
196233 nLocal = nMinLocal + (nTotal - nMinLocal) % (nUsable - 4);
196234 if( nLocal>nMaxLocal ) nLocal = nMinLocal;
196235 *pnLocal = nLocal;
196236 }
196237
 
 
 
196238 static int statDecodePage(Btree *pBt, StatPage *p){
196239 int nUnused;
196240 int iOff;
196241 int nHdr;
196242 int isLeaf;
@@ -196303,11 +197811,11 @@
196303 if( p->flags==0x0D ){
196304 u64 dummy;
196305 iOff += sqlite3GetVarint(&aData[iOff], &dummy);
196306 }
196307 if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload;
196308 getLocalPayload(nUsable, p->flags, nPayload, &nLocal);
196309 if( nLocal<0 ) goto statPageIsCorrupt;
196310 pCell->nLocal = nLocal;
196311 assert( nPayload>=(u32)nLocal );
196312 assert( nLocal<=(nUsable-35) );
196313 if( nPayload>(u32)nLocal ){
@@ -196353,27 +197861,29 @@
196353 Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;
196354 Pager *pPager = sqlite3BtreePager(pBt);
196355 sqlite3_file *fd;
196356 sqlite3_int64 x[2];
196357
196358 /* The default page size and offset */
196359 pCsr->szPage = sqlite3BtreeGetPageSize(pBt);
196360 pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1);
196361
196362 /* If connected to a ZIPVFS backend, override the page size and
196363 ** offset with actual values obtained from ZIPVFS.
196364 */
196365 fd = sqlite3PagerFile(pPager);
196366 x[0] = pCsr->iPageno;
196367 if( sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){
196368 pCsr->iOffset = x[0];
196369 pCsr->szPage = (int)x[1];
 
 
 
 
196370 }
196371 }
196372
196373 /*
196374 ** Move a statvfs cursor to the next entry in the file.
 
 
196375 */
196376 static int statNext(sqlite3_vtab_cursor *pCursor){
196377 int rc;
196378 int nPayload;
196379 char *z;
@@ -196385,10 +197895,12 @@
196385 sqlite3_free(pCsr->zPath);
196386 pCsr->zPath = 0;
196387
196388 statNextRestart:
196389 if( pCsr->aPage[0].pPg==0 ){
 
 
196390 rc = sqlite3_step(pCsr->pStmt);
196391 if( rc==SQLITE_ROW ){
196392 int nPage;
196393 u32 iRoot = (u32)sqlite3_column_int64(pCsr->pStmt, 1);
196394 sqlite3PagerPagecount(pPager, &nPage);
@@ -196397,57 +197909,65 @@
196397 return sqlite3_reset(pCsr->pStmt);
196398 }
196399 rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg, 0);
196400 pCsr->aPage[0].iPgno = iRoot;
196401 pCsr->aPage[0].iCell = 0;
196402 pCsr->aPage[0].zPath = z = sqlite3_mprintf("/");
 
 
 
196403 pCsr->iPage = 0;
196404 if( z==0 ) rc = SQLITE_NOMEM_BKPT;
196405 }else{
196406 pCsr->isEof = 1;
196407 return sqlite3_reset(pCsr->pStmt);
196408 }
196409 }else{
196410
196411 /* Page p itself has already been visited. */
196412 StatPage *p = &pCsr->aPage[pCsr->iPage];
196413
196414 while( p->iCell<p->nCell ){
196415 StatCell *pCell = &p->aCell[p->iCell];
196416 if( pCell->iOvfl<pCell->nOvfl ){
196417 int nUsable;
196418 sqlite3BtreeEnter(pBt);
196419 nUsable = sqlite3BtreeGetPageSize(pBt) -
196420 sqlite3BtreeGetReserveNoMutex(pBt);
196421 sqlite3BtreeLeave(pBt);
196422 pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);
196423 pCsr->iPageno = pCell->aOvfl[pCell->iOvfl];
196424 pCsr->zPagetype = "overflow";
196425 pCsr->nCell = 0;
196426 pCsr->nMxPayload = 0;
196427 pCsr->zPath = z = sqlite3_mprintf(
196428 "%s%.3x+%.6x", p->zPath, p->iCell, pCell->iOvfl
196429 );
196430 if( pCell->iOvfl<pCell->nOvfl-1 ){
196431 pCsr->nUnused = 0;
196432 pCsr->nPayload = nUsable - 4;
196433 }else{
196434 pCsr->nPayload = pCell->nLastOvfl;
196435 pCsr->nUnused = nUsable - 4 - pCsr->nPayload;
196436 }
 
196437 pCell->iOvfl++;
196438 statSizeAndOffset(pCsr);
196439 return z==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK;
 
 
 
 
 
 
 
196440 }
196441 if( p->iRightChildPg ) break;
196442 p->iCell++;
196443 }
196444
196445 if( !p->iRightChildPg || p->iCell>p->nCell ){
196446 statClearPage(p);
196447 if( pCsr->iPage==0 ) return statNext(pCursor);
196448 pCsr->iPage--;
 
 
 
 
 
196449 goto statNextRestart; /* Tail recursion */
196450 }
196451 pCsr->iPage++;
196452 if( pCsr->iPage>=ArraySize(pCsr->aPage) ){
196453 statResetCsr(pCsr);
@@ -196459,14 +197979,17 @@
196459 p[1].iPgno = p->iRightChildPg;
196460 }else{
196461 p[1].iPgno = p->aCell[p->iCell].iChildPg;
196462 }
196463 rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg, 0);
 
196464 p[1].iCell = 0;
196465 p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell);
 
 
 
196466 p->iCell++;
196467 if( z==0 ) rc = SQLITE_NOMEM_BKPT;
196468 }
196469
196470
196471 /* Populate the StatCursor fields with the values to be returned
196472 ** by the xColumn() and xRowid() methods.
@@ -196492,20 +198015,27 @@
196492 break;
196493 default:
196494 pCsr->zPagetype = "corrupted";
196495 break;
196496 }
196497 pCsr->nCell = p->nCell;
196498 pCsr->nUnused = p->nUnused;
196499 pCsr->nMxPayload = p->nMxPayload;
196500 pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath);
196501 if( z==0 ) rc = SQLITE_NOMEM_BKPT;
 
 
196502 nPayload = 0;
196503 for(i=0; i<p->nCell; i++){
196504 nPayload += p->aCell[i].nLocal;
196505 }
196506 pCsr->nPayload = nPayload;
 
 
 
 
 
196507 }
196508 }
196509
196510 return rc;
196511 }
@@ -196513,40 +198043,67 @@
196513 static int statEof(sqlite3_vtab_cursor *pCursor){
196514 StatCursor *pCsr = (StatCursor *)pCursor;
196515 return pCsr->isEof;
196516 }
196517
 
 
 
 
196518 static int statFilter(
196519 sqlite3_vtab_cursor *pCursor,
196520 int idxNum, const char *idxStr,
196521 int argc, sqlite3_value **argv
196522 ){
196523 StatCursor *pCsr = (StatCursor *)pCursor;
196524 StatTable *pTab = (StatTable*)(pCursor->pVtab);
196525 char *zSql;
196526 int rc = SQLITE_OK;
 
 
 
196527
196528 if( idxNum==1 ){
196529 const char *zDbase = (const char*)sqlite3_value_text(argv[0]);
 
 
 
 
196530 pCsr->iDb = sqlite3FindDbName(pTab->db, zDbase);
196531 if( pCsr->iDb<0 ){
196532 sqlite3_free(pCursor->pVtab->zErrMsg);
196533 pCursor->pVtab->zErrMsg = sqlite3_mprintf("no such schema: %s", zDbase);
196534 return pCursor->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM_BKPT;
196535 }
196536 }else{
196537 pCsr->iDb = pTab->iDb;
196538 }
196539 statResetCsr(pCsr);
196540 sqlite3_finalize(pCsr->pStmt);
196541 pCsr->pStmt = 0;
196542 zSql = sqlite3_mprintf(
196543 "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type"
196544 " UNION ALL "
196545 "SELECT name, rootpage, type"
196546 " FROM \"%w\".sqlite_master WHERE rootpage!=0"
196547 " ORDER BY name", pTab->db->aDb[pCsr->iDb].zDbSName);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196548 if( zSql==0 ){
196549 return SQLITE_NOMEM_BKPT;
196550 }else{
196551 rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);
196552 sqlite3_free(zSql);
@@ -196567,17 +198124,25 @@
196567 switch( i ){
196568 case 0: /* name */
196569 sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_TRANSIENT);
196570 break;
196571 case 1: /* path */
196572 sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT);
 
 
196573 break;
196574 case 2: /* pageno */
196575 sqlite3_result_int64(ctx, pCsr->iPageno);
 
 
 
 
196576 break;
196577 case 3: /* pagetype */
196578 sqlite3_result_text(ctx, pCsr->zPagetype, -1, SQLITE_STATIC);
 
 
196579 break;
196580 case 4: /* ncell */
196581 sqlite3_result_int(ctx, pCsr->nCell);
196582 break;
196583 case 5: /* payload */
@@ -196588,20 +198153,26 @@
196588 break;
196589 case 7: /* mx_payload */
196590 sqlite3_result_int(ctx, pCsr->nMxPayload);
196591 break;
196592 case 8: /* pgoffset */
196593 sqlite3_result_int64(ctx, pCsr->iOffset);
 
 
196594 break;
196595 case 9: /* pgsize */
196596 sqlite3_result_int(ctx, pCsr->szPage);
196597 break;
196598 default: { /* schema */
196599 sqlite3 *db = sqlite3_context_db_handle(ctx);
196600 int iDb = pCsr->iDb;
196601 sqlite3_result_text(ctx, db->aDb[iDb].zDbSName, -1, SQLITE_STATIC);
196602 break;
 
 
 
 
196603 }
196604 }
196605 return SQLITE_OK;
196606 }
196607
@@ -203188,10 +204759,15 @@
203188 ** less than 32. If it is set to anything large than that, an #error
203189 ** directive in fts5_index.c will cause the build to fail.
203190 */
203191 #define FTS5_MAX_PREFIX_INDEXES 31
203192
 
 
 
 
 
203193 #define FTS5_DEFAULT_NEARDIST 10
203194 #define FTS5_DEFAULT_RANK "bm25"
203195
203196 /* Name of rank and rowid columns */
203197 #define FTS5_RANK_NAME "rank"
@@ -203544,10 +205120,15 @@
203544 /*
203545 ** Close an iterator opened by sqlite3Fts5IndexQuery().
203546 */
203547 static void sqlite3Fts5IterClose(Fts5IndexIter*);
203548
 
 
 
 
 
203549 /*
203550 ** This interface is used by the fts5vocab module.
203551 */
203552 static const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*);
203553 static int sqlite3Fts5IterNextScan(Fts5IndexIter*);
@@ -205420,12 +207001,12 @@
205420 #ifdef fts5YYFALLBACK
205421 assert( iToken<(int)(sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])) );
205422 return fts5yyFallback[iToken];
205423 #else
205424 (void)iToken;
205425 #endif
205426 return 0;
 
205427 }
205428
205429 /*
205430 ** 2014 May 31
205431 **
@@ -206570,11 +208151,11 @@
206570 #define FTS5_DEFAULT_USERMERGE 4
206571 #define FTS5_DEFAULT_CRISISMERGE 16
206572 #define FTS5_DEFAULT_HASHSIZE (1024*1024)
206573
206574 /* Maximum allowed page size */
206575 #define FTS5_MAX_PAGE_SIZE (128*1024)
206576
206577 static int fts5_iswhitespace(char x){
206578 return (x==' ');
206579 }
206580
@@ -207375,11 +208956,11 @@
207375 if( 0==sqlite3_stricmp(zKey, "pgsz") ){
207376 int pgsz = 0;
207377 if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){
207378 pgsz = sqlite3_value_int(pVal);
207379 }
207380 if( pgsz<=0 || pgsz>FTS5_MAX_PAGE_SIZE ){
207381 *pbBadkey = 1;
207382 }else{
207383 pConfig->pgsz = pgsz;
207384 }
207385 }
@@ -207428,10 +209009,11 @@
207428 }
207429 if( nCrisisMerge<0 ){
207430 *pbBadkey = 1;
207431 }else{
207432 if( nCrisisMerge<=1 ) nCrisisMerge = FTS5_DEFAULT_CRISISMERGE;
 
207433 pConfig->nCrisisMerge = nCrisisMerge;
207434 }
207435 }
207436
207437 else if( 0==sqlite3_stricmp(zKey, "rank") ){
@@ -211199,15 +212781,10 @@
211199 )
211200
211201 #define FTS5_SEGMENT_ROWID(segid, pgno) fts5_dri(segid, 0, 0, pgno)
211202 #define FTS5_DLIDX_ROWID(segid, height, pgno) fts5_dri(segid, 1, height, pgno)
211203
211204 /*
211205 ** Maximum segments permitted in a single index
211206 */
211207 #define FTS5_MAX_SEGMENT 2000
211208
211209 #ifdef SQLITE_DEBUG
211210 static int sqlite3Fts5Corrupt() { return SQLITE_CORRUPT_VTAB; }
211211 #endif
211212
211213
@@ -211579,11 +213156,11 @@
211579 }
211580
211581 /*
211582 ** Close the read-only blob handle, if it is open.
211583 */
211584 static void fts5CloseReader(Fts5Index *p){
211585 if( p->pReader ){
211586 sqlite3_blob *pReader = p->pReader;
211587 p->pReader = 0;
211588 sqlite3_blob_close(pReader);
211589 }
@@ -211608,11 +213185,11 @@
211608 p->pReader = 0;
211609 rc = sqlite3_blob_reopen(pBlob, iRowid);
211610 assert( p->pReader==0 );
211611 p->pReader = pBlob;
211612 if( rc!=SQLITE_OK ){
211613 fts5CloseReader(p);
211614 }
211615 if( rc==SQLITE_ABORT ) rc = SQLITE_OK;
211616 }
211617
211618 /* If the blob handle is not open at this point, open it and seek
@@ -216169,11 +217746,11 @@
216169 ** Commit data to disk.
216170 */
216171 static int sqlite3Fts5IndexSync(Fts5Index *p){
216172 assert( p->rc==SQLITE_OK );
216173 fts5IndexFlush(p);
216174 fts5CloseReader(p);
216175 return fts5IndexReturn(p);
216176 }
216177
216178 /*
216179 ** Discard any data stored in the in-memory hash tables. Do not write it
@@ -216180,11 +217757,11 @@
216180 ** to the database. Additionally, assume that the contents of the %_data
216181 ** table may have changed on disk. So any in-memory caches of %_data
216182 ** records must be invalidated.
216183 */
216184 static int sqlite3Fts5IndexRollback(Fts5Index *p){
216185 fts5CloseReader(p);
216186 fts5IndexDiscardData(p);
216187 fts5StructureInvalidate(p);
216188 /* assert( p->rc==SQLITE_OK ); */
216189 return SQLITE_OK;
216190 }
@@ -216195,10 +217772,11 @@
216195 ** and the initial version of the "averages" record (a zero-byte blob).
216196 */
216197 static int sqlite3Fts5IndexReinit(Fts5Index *p){
216198 Fts5Structure s;
216199 fts5StructureInvalidate(p);
 
216200 memset(&s, 0, sizeof(Fts5Structure));
216201 fts5DataWrite(p, FTS5_AVERAGES_ROWID, (const u8*)"", 0);
216202 fts5StructureWrite(p, &s);
216203 return fts5IndexReturn(p);
216204 }
@@ -216282,10 +217860,11 @@
216282 int n = 0;
216283 int i;
216284 for(i=0; i<nChar; i++){
216285 if( n>=nByte ) return 0; /* Input contains fewer than nChar chars */
216286 if( (unsigned char)p[n++]>=0xc0 ){
 
216287 while( (p[n] & 0xc0)==0x80 ){
216288 n++;
216289 if( n>=nByte ) break;
216290 }
216291 }
@@ -216420,11 +217999,11 @@
216420 }
216421
216422 if( p->rc ){
216423 sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
216424 pRet = 0;
216425 fts5CloseReader(p);
216426 }
216427
216428 *ppIter = (Fts5IndexIter*)pRet;
216429 sqlite3Fts5BufferFree(&buf);
216430 }
@@ -216493,11 +218072,11 @@
216493 static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){
216494 if( pIndexIter ){
216495 Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
216496 Fts5Index *pIndex = pIter->pIndex;
216497 fts5MultiIterFree(pIter);
216498 fts5CloseReader(pIndex);
216499 }
216500 }
216501
216502 /*
216503 ** Read and decode the "averages" record from the database.
@@ -216850,11 +218429,12 @@
216850 int iDlidxPrevLeaf = pSeg->pgnoLast;
216851
216852 if( pSeg->pgnoFirst==0 ) return;
216853
216854 fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf(
216855 "SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d",
 
216856 pConfig->zDb, pConfig->zName, pSeg->iSegid
216857 ));
216858
216859 /* Iterate through the b-tree hierarchy. */
216860 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
@@ -218296,10 +219876,11 @@
218296 if( CsrFlagTest(pCsr, FTS5CSR_FREE_ZRANK) ){
218297 sqlite3_free(pCsr->zRank);
218298 sqlite3_free(pCsr->zRankArgs);
218299 }
218300
 
218301 memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan - (u8*)pCsr));
218302 }
218303
218304
218305 /*
@@ -220265,11 +221846,11 @@
220265 int nArg, /* Number of args */
220266 sqlite3_value **apUnused /* Function arguments */
220267 ){
220268 assert( nArg==0 );
220269 UNUSED_PARAM2(nArg, apUnused);
220270 sqlite3_result_text(pCtx, "fts5: 2019-10-04 15:03:17 c20a35336432025445f9f7e289d0cc3e4003fb17f45a4ce74c6269c407c6e09f", -1, SQLITE_TRANSIENT);
220271 }
220272
220273 /*
220274 ** Return true if zName is the extension on one of the shadow tables used
220275 ** by this module.
@@ -220958,10 +222539,12 @@
220958 ** Delete all entries in the FTS5 index.
220959 */
220960 static int sqlite3Fts5StorageDeleteAll(Fts5Storage *p){
220961 Fts5Config *pConfig = p->pConfig;
220962 int rc;
 
 
220963
220964 /* Delete the contents of the %_data and %_docsize tables. */
220965 rc = fts5ExecPrintf(pConfig->db, 0,
220966 "DELETE FROM %Q.'%q_data';"
220967 "DELETE FROM %Q.'%q_idx';",
@@ -225033,12 +226616,12 @@
225033 }
225034 #endif /* SQLITE_CORE */
225035 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
225036
225037 /************** End of stmt.c ************************************************/
225038 #if __LINE__!=225038
225039 #undef SQLITE_SOURCE_ID
225040 #define SQLITE_SOURCE_ID "2019-10-04 15:03:17 c20a35336432025445f9f7e289d0cc3e4003fb17f45a4ce74c6269c407c6alt2"
225041 #endif
225042 /* Return the source-id for this library */
225043 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
225044 /************************** End of sqlite3.c ******************************/
225045
--- 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.31.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.
@@ -1163,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.31.0"
1169 #define SQLITE_VERSION_NUMBER 3031000
1170 #define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9f49b"
1171
1172 /*
1173 ** CAPI3REF: Run-Time Library Version Numbers
1174 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1175 **
@@ -1556,10 +1556,11 @@
1556 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1557 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
1558 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
1559 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
1560 #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
1561 #define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8))
1562 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
1563 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
1564 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
1565 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
1566 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -1608,10 +1609,11 @@
1609 #define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
1610 #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
1611 #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
1612 #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
1613 #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
1614 #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */
1615
1616 /* Reserved: 0x00F00000 */
1617
1618 /*
1619 ** CAPI3REF: Device Characteristics
@@ -2446,10 +2448,11 @@
2448 ** SQLite.
2449 */
2450 #define SQLITE_ACCESS_EXISTS 0
2451 #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
2452 #define SQLITE_ACCESS_READ 2 /* Unused */
2453 #define SQLITE_ACCESS_SYMLINK 3 /* Test if file is symbolic link */
2454
2455 /*
2456 ** CAPI3REF: Flags for the xShmLock VFS method
2457 **
2458 ** These integer constants define the various locking operations
@@ -2782,10 +2785,11 @@
2785 ** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
2786 ** interpreted as a boolean, which enables or disables the collection of
2787 ** memory allocation statistics. ^(When memory allocation statistics are
2788 ** disabled, the following SQLite interfaces become non-operational:
2789 ** <ul>
2790 ** <li> [sqlite3_hard_heap_limit64()]
2791 ** <li> [sqlite3_memory_used()]
2792 ** <li> [sqlite3_memory_highwater()]
2793 ** <li> [sqlite3_soft_heap_limit64()]
2794 ** <li> [sqlite3_status64()]
2795 ** </ul>)^
@@ -3299,10 +3303,32 @@
3303 ** the legacy [double-quoted string literal] misfeature for DDL statements,
3304 ** such as CREATE TABLE and CREATE INDEX. The
3305 ** default value of this setting is determined by the [-DSQLITE_DQS]
3306 ** compile-time option.
3307 ** </dd>
3308 **
3309 ** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]]
3310 ** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</td>
3311 ** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates
3312 ** the legacy file format flag. When activated, this flag causes all newly
3313 ** created database file to have a schema format version number (the 4-byte
3314 ** integer found at offset 44 into the database header) of 1. This in turn
3315 ** means that the resulting database file will be readable and writable by
3316 ** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting,
3317 ** newly created databases are generally not understandable by SQLite versions
3318 ** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there
3319 ** is now scarcely any need to generated database files that are compatible
3320 ** all the way back to version 3.0.0, and so this setting is of little
3321 ** practical use, but is provided so that SQLite can continue to claim the
3322 ** ability to generate new database files that are compatible with version
3323 ** 3.0.0.
3324 ** <p>Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on,
3325 ** the [VACUUM] command will fail with an obscure error when attempting to
3326 ** process a table with generated columns and a descending index. This is
3327 ** not considered a bug since SQLite versions 3.3.0 and earlier do not support
3328 ** either generated columns or decending indexes.
3329 ** </dd>
3330 ** </dl>
3331 */
3332 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
3333 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
3334 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -3317,11 +3343,12 @@
3343 #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
3344 #define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
3345 #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
3346 #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
3347 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
3348 #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
3349 #define SQLITE_DBCONFIG_MAX 1016 /* Largest DBCONFIG */
3350
3351 /*
3352 ** CAPI3REF: Enable Or Disable Extended Result Codes
3353 ** METHOD: sqlite3
3354 **
@@ -7155,10 +7182,13 @@
7182 */
7183 SQLITE_API int sqlite3_db_release_memory(sqlite3*);
7184
7185 /*
7186 ** CAPI3REF: Impose A Limit On Heap Size
7187 **
7188 ** These interfaces impose limits on the amount of heap memory that will be
7189 ** by all database connections within a single process.
7190 **
7191 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
7192 ** soft limit on the amount of heap memory that may be allocated by SQLite.
7193 ** ^SQLite strives to keep heap memory utilization below the soft heap
7194 ** limit by reducing the number of pages held in the page cache
@@ -7166,24 +7196,45 @@
7196 ** ^The soft heap limit is "soft" because even though SQLite strives to stay
7197 ** below the limit, it will exceed the limit rather than generate
7198 ** an [SQLITE_NOMEM] error. In other words, the soft heap limit
7199 ** is advisory only.
7200 **
7201 ** ^The sqlite3_hard_heap_limit64(N) interface sets a hard upper bound of
7202 ** N bytes on the amount of memory that will be allocated. ^The
7203 ** sqlite3_hard_heap_limit64(N) interface is similar to
7204 ** sqlite3_soft_heap_limit64(N) except that memory allocations will fail
7205 ** when the hard heap limit is reached.
7206 **
7207 ** ^The return value from both sqlite3_soft_heap_limit64() and
7208 ** sqlite3_hard_heap_limit64() is the size of
7209 ** the heap limit prior to the call, or negative in the case of an
7210 ** error. ^If the argument N is negative
7211 ** then no change is made to the heap limit. Hence, the current
7212 ** size of heap limits can be determined by invoking
7213 ** sqlite3_soft_heap_limit64(-1) or sqlite3_hard_heap_limit(-1).
7214 **
7215 ** ^Setting the heap limits to zero disables the heap limiter mechanism.
7216 **
7217 ** ^The soft heap limit may not be greater than the hard heap limit.
7218 ** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N)
7219 ** is invoked with a value of N that is greater than the hard heap limit,
7220 ** the the soft heap limit is set to the value of the hard heap limit.
7221 ** ^The soft heap limit is automatically enabled whenever the hard heap
7222 ** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and
7223 ** the soft heap limit is outside the range of 1..N, then the soft heap
7224 ** limit is set to N. ^Invoking sqlite3_soft_heap_limit64(0) when the
7225 ** hard heap limit is enabled makes the soft heap limit equal to the
7226 ** hard heap limit.
7227 **
7228 ** The memory allocation limits can also be adjusted using
7229 ** [PRAGMA soft_heap_limit] and [PRAGMA hard_heap_limit].
7230 **
7231 ** ^(The heap limits are not enforced in the current implementation
7232 ** if one or more of following conditions are true:
7233 **
7234 ** <ul>
7235 ** <li> The limit value is set to zero.
7236 ** <li> Memory accounting is disabled using a combination of the
7237 ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
7238 ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
7239 ** <li> An alternative page cache implementation is specified using
7240 ** [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).
@@ -7190,25 +7241,15 @@
7241 ** <li> The page cache allocates from its own memory pool supplied
7242 ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
7243 ** from the heap.
7244 ** </ul>)^
7245 **
7246 ** The circumstances under which SQLite will enforce the heap limits may
 
 
 
 
 
 
 
 
 
 
 
7247 ** changes in future releases of SQLite.
7248 */
7249 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
7250 SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
7251
7252 /*
7253 ** CAPI3REF: Deprecated Soft Heap Limit Interface
7254 ** DEPRECATED
7255 **
@@ -13671,94 +13712,96 @@
13712 #define TK_UNBOUNDED 90
13713 #define TK_EXCLUDE 91
13714 #define TK_GROUPS 92
13715 #define TK_OTHERS 93
13716 #define TK_TIES 94
13717 #define TK_GENERATED 95
13718 #define TK_ALWAYS 96
13719 #define TK_REINDEX 97
13720 #define TK_RENAME 98
13721 #define TK_CTIME_KW 99
13722 #define TK_ANY 100
13723 #define TK_BITAND 101
13724 #define TK_BITOR 102
13725 #define TK_LSHIFT 103
13726 #define TK_RSHIFT 104
13727 #define TK_PLUS 105
13728 #define TK_MINUS 106
13729 #define TK_STAR 107
13730 #define TK_SLASH 108
13731 #define TK_REM 109
13732 #define TK_CONCAT 110
13733 #define TK_COLLATE 111
13734 #define TK_BITNOT 112
13735 #define TK_ON 113
13736 #define TK_INDEXED 114
13737 #define TK_STRING 115
13738 #define TK_JOIN_KW 116
13739 #define TK_CONSTRAINT 117
13740 #define TK_DEFAULT 118
13741 #define TK_NULL 119
13742 #define TK_PRIMARY 120
13743 #define TK_UNIQUE 121
13744 #define TK_CHECK 122
13745 #define TK_REFERENCES 123
13746 #define TK_AUTOINCR 124
13747 #define TK_INSERT 125
13748 #define TK_DELETE 126
13749 #define TK_UPDATE 127
13750 #define TK_SET 128
13751 #define TK_DEFERRABLE 129
13752 #define TK_FOREIGN 130
13753 #define TK_DROP 131
13754 #define TK_UNION 132
13755 #define TK_ALL 133
13756 #define TK_EXCEPT 134
13757 #define TK_INTERSECT 135
13758 #define TK_SELECT 136
13759 #define TK_VALUES 137
13760 #define TK_DISTINCT 138
13761 #define TK_DOT 139
13762 #define TK_FROM 140
13763 #define TK_JOIN 141
13764 #define TK_USING 142
13765 #define TK_ORDER 143
13766 #define TK_GROUP 144
13767 #define TK_HAVING 145
13768 #define TK_LIMIT 146
13769 #define TK_WHERE 147
13770 #define TK_INTO 148
13771 #define TK_NOTHING 149
13772 #define TK_FLOAT 150
13773 #define TK_BLOB 151
13774 #define TK_INTEGER 152
13775 #define TK_VARIABLE 153
13776 #define TK_CASE 154
13777 #define TK_WHEN 155
13778 #define TK_THEN 156
13779 #define TK_ELSE 157
13780 #define TK_INDEX 158
13781 #define TK_ALTER 159
13782 #define TK_ADD 160
13783 #define TK_WINDOW 161
13784 #define TK_OVER 162
13785 #define TK_FILTER 163
13786 #define TK_COLUMN 164
13787 #define TK_AGG_FUNCTION 165
13788 #define TK_AGG_COLUMN 166
13789 #define TK_TRUEFALSE 167
13790 #define TK_ISNOT 168
13791 #define TK_FUNCTION 169
13792 #define TK_UMINUS 170
13793 #define TK_UPLUS 171
13794 #define TK_TRUTH 172
13795 #define TK_REGISTER 173
13796 #define TK_VECTOR 174
13797 #define TK_SELECT_COLUMN 175
13798 #define TK_IF_NULL_ROW 176
13799 #define TK_ASTERISK 177
13800 #define TK_SPAN 178
13801 #define TK_SPACE 179
13802 #define TK_ILLEGAL 180
13803
13804 /************** End of parse.h ***********************************************/
13805 /************** Continuing where we left off in sqliteInt.h ******************/
13806 #include <stdio.h>
13807 #include <stdlib.h>
@@ -14686,11 +14729,11 @@
14729 SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
14730 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
14731 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
14732 SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*);
14733
14734 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(sqlite3*,Btree*,int*aRoot,int nRoot,int,int*);
14735 SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
14736 SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);
14737
14738 #ifndef SQLITE_OMIT_INCRBLOB
14739 SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*);
@@ -14707,11 +14750,11 @@
14750 SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);
14751 #endif
14752 SQLITE_PRIVATE int sqlite3BtreeCursorIsValidNN(BtCursor*);
14753
14754 #ifndef SQLITE_OMIT_BTREECOUNT
14755 SQLITE_PRIVATE int sqlite3BtreeCount(sqlite3*, BtCursor*, i64*);
14756 #endif
14757
14758 #ifdef SQLITE_TEST
14759 SQLITE_PRIVATE int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
14760 SQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*);
@@ -15000,121 +15043,119 @@
15043 #define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
15044 #define OP_ElseNotEq 58 /* jump, same as TK_ESCAPE */
15045 #define OP_IncrVacuum 59 /* jump */
15046 #define OP_VNext 60 /* jump */
15047 #define OP_Init 61 /* jump, synopsis: Start at P2 */
15048 #define OP_PureFunc 62 /* synopsis: r[P3]=func(r[P2@P5]) */
15049 #define OP_Function 63 /* synopsis: r[P3]=func(r[P2@P5]) */
15050 #define OP_Return 64
15051 #define OP_EndCoroutine 65
15052 #define OP_HaltIfNull 66 /* synopsis: if r[P3]=null halt */
15053 #define OP_Halt 67
15054 #define OP_Integer 68 /* synopsis: r[P2]=P1 */
15055 #define OP_Int64 69 /* synopsis: r[P2]=P4 */
15056 #define OP_String 70 /* synopsis: r[P2]='P4' (len=P1) */
15057 #define OP_Null 71 /* synopsis: r[P2..P3]=NULL */
15058 #define OP_SoftNull 72 /* synopsis: r[P1]=NULL */
15059 #define OP_Blob 73 /* synopsis: r[P2]=P4 (len=P1) */
15060 #define OP_Variable 74 /* synopsis: r[P2]=parameter(P1,P4) */
15061 #define OP_Move 75 /* synopsis: r[P2@P3]=r[P1@P3] */
15062 #define OP_Copy 76 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
15063 #define OP_SCopy 77 /* synopsis: r[P2]=r[P1] */
15064 #define OP_IntCopy 78 /* synopsis: r[P2]=r[P1] */
15065 #define OP_ResultRow 79 /* synopsis: output=r[P1@P2] */
15066 #define OP_CollSeq 80
15067 #define OP_AddImm 81 /* synopsis: r[P1]=r[P1]+P2 */
15068 #define OP_RealAffinity 82
15069 #define OP_Cast 83 /* synopsis: affinity(r[P1]) */
15070 #define OP_Permutation 84
15071 #define OP_Compare 85 /* synopsis: r[P1@P3] <-> r[P2@P3] */
15072 #define OP_IsTrue 86 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
15073 #define OP_Offset 87 /* synopsis: r[P3] = sqlite_offset(P1) */
15074 #define OP_Column 88 /* synopsis: r[P3]=PX */
15075 #define OP_Affinity 89 /* synopsis: affinity(r[P1@P2]) */
15076 #define OP_MakeRecord 90 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
15077 #define OP_Count 91 /* synopsis: r[P2]=count() */
15078 #define OP_ReadCookie 92
15079 #define OP_SetCookie 93
15080 #define OP_ReopenIdx 94 /* synopsis: root=P2 iDb=P3 */
15081 #define OP_OpenRead 95 /* synopsis: root=P2 iDb=P3 */
15082 #define OP_OpenWrite 96 /* synopsis: root=P2 iDb=P3 */
15083 #define OP_OpenDup 97
15084 #define OP_OpenAutoindex 98 /* synopsis: nColumn=P2 */
15085 #define OP_OpenEphemeral 99 /* synopsis: nColumn=P2 */
15086 #define OP_SorterOpen 100
15087 #define OP_BitAnd 101 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
15088 #define OP_BitOr 102 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
15089 #define OP_ShiftLeft 103 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
15090 #define OP_ShiftRight 104 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
15091 #define OP_Add 105 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
15092 #define OP_Subtract 106 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
15093 #define OP_Multiply 107 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
15094 #define OP_Divide 108 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
15095 #define OP_Remainder 109 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
15096 #define OP_Concat 110 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
15097 #define OP_SequenceTest 111 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15098 #define OP_BitNot 112 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
15099 #define OP_OpenPseudo 113 /* synopsis: P3 columns in r[P2] */
15100 #define OP_Close 114
15101 #define OP_String8 115 /* same as TK_STRING, synopsis: r[P2]='P4' */
15102 #define OP_ColumnsUsed 116
15103 #define OP_SeekHit 117 /* synopsis: seekHit=P2 */
15104 #define OP_Sequence 118 /* synopsis: r[P2]=cursor[P1].ctr++ */
15105 #define OP_NewRowid 119 /* synopsis: r[P2]=rowid */
15106 #define OP_Insert 120 /* synopsis: intkey=r[P3] data=r[P2] */
15107 #define OP_Delete 121
15108 #define OP_ResetCount 122
15109 #define OP_SorterCompare 123 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15110 #define OP_SorterData 124 /* synopsis: r[P2]=data */
15111 #define OP_RowData 125 /* synopsis: r[P2]=data */
15112 #define OP_Rowid 126 /* synopsis: r[P2]=rowid */
15113 #define OP_NullRow 127
15114 #define OP_SeekEnd 128
15115 #define OP_SorterInsert 129 /* synopsis: key=r[P2] */
15116 #define OP_IdxInsert 130 /* synopsis: key=r[P2] */
15117 #define OP_IdxDelete 131 /* synopsis: key=r[P2@P3] */
15118 #define OP_DeferredSeek 132 /* synopsis: Move P3 to P1.rowid if needed */
15119 #define OP_IdxRowid 133 /* synopsis: r[P2]=rowid */
15120 #define OP_Destroy 134
15121 #define OP_Clear 135
15122 #define OP_ResetSorter 136
15123 #define OP_CreateBtree 137 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15124 #define OP_SqlExec 138
15125 #define OP_ParseSchema 139
15126 #define OP_LoadAnalysis 140
15127 #define OP_DropTable 141
15128 #define OP_DropIndex 142
15129 #define OP_DropTrigger 143
15130 #define OP_IntegrityCk 144
15131 #define OP_RowSetAdd 145 /* synopsis: rowset(P1)=r[P2] */
15132 #define OP_Param 146
15133 #define OP_FkCounter 147 /* synopsis: fkctr[P1]+=P2 */
15134 #define OP_MemMax 148 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15135 #define OP_OffsetLimit 149 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15136 #define OP_Real 150 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15137 #define OP_AggInverse 151 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15138 #define OP_AggStep 152 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15139 #define OP_AggStep1 153 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15140 #define OP_AggValue 154 /* synopsis: r[P3]=value N=P2 */
15141 #define OP_AggFinal 155 /* synopsis: accum=r[P1] N=P2 */
15142 #define OP_Expire 156
15143 #define OP_TableLock 157 /* synopsis: iDb=P1 root=P2 write=P3 */
15144 #define OP_VBegin 158
15145 #define OP_VCreate 159
15146 #define OP_VDestroy 160
15147 #define OP_VOpen 161
15148 #define OP_VColumn 162 /* synopsis: r[P3]=vcolumn(P2) */
15149 #define OP_VRename 163
15150 #define OP_Pagecount 164
15151 #define OP_MaxPgcnt 165
15152 #define OP_Trace 166
15153 #define OP_CursorHint 167
15154 #define OP_Noop 168
15155 #define OP_Explain 169
15156 #define OP_Abortable 170
 
 
15157
15158 /* Properties such as "out2" or "jump" that are specified in
15159 ** comments following the "case" for each opcode in the vdbe.c
15160 ** are encoded into bitvectors as follows:
15161 */
@@ -15131,24 +15172,24 @@
15172 /* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
15173 /* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
15174 /* 40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\
15175 /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
15176 /* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\
15177 /* 64 */ 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10,\
15178 /* 72 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00,\
15179 /* 80 */ 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x12, 0x20,\
15180 /* 88 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
15181 /* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26, 0x26,\
15182 /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\
15183 /* 112 */ 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10,\
15184 /* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\
15185 /* 128 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x00,\
15186 /* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15187 /* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x10, 0x00,\
15188 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15189 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
15190 /* 168 */ 0x00, 0x00, 0x00,}
15191
15192 /* The sqlite3P2Values() routine is able to run faster if it knows
15193 ** the value of the largest JUMP opcode. The smaller the maximum
15194 ** JUMP opcode the better, so the mkopcodeh.tcl script that
15195 ** generated this include file strives to group all JUMP opcodes
@@ -15168,10 +15209,11 @@
15209 /*
15210 ** Prototypes for the VDBE interface. See comments on the implementation
15211 ** for a description of what each of these routines does.
15212 */
15213 SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*);
15214 SQLITE_PRIVATE Parse *sqlite3VdbeParser(Vdbe*);
15215 SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int);
15216 SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int);
15217 SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int);
15218 SQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe*,int);
15219 SQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe*,int,const char*);
@@ -15178,10 +15220,11 @@
15220 SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...);
15221 SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);
15222 SQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);
15223 SQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int);
15224 SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);
15225 SQLITE_PRIVATE int sqlite3VdbeAddFunctionCall(Parse*,int,int,int,int,const FuncDef*,int);
15226 SQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe*,int);
15227 #if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
15228 SQLITE_PRIVATE void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);
15229 SQLITE_PRIVATE void sqlite3VdbeVerifyNoResultRow(Vdbe *p);
15230 #else
@@ -15267,13 +15310,12 @@
15310 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*);
15311
15312 typedef int (*RecordCompare)(int,const void*,UnpackedRecord*);
15313 SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
15314
 
15315 SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
15316 SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*);
15317
15318 SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);
15319
15320 /* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on
15321 ** each VDBE opcode.
@@ -16303,14 +16345,21 @@
16345 ** with a particular database connection. Hence, schema information cannot
16346 ** be stored in lookaside because in shared cache mode the schema information
16347 ** is shared by multiple database connections. Therefore, while parsing
16348 ** schema information, the Lookaside.bEnabled flag is cleared so that
16349 ** lookaside allocations are not used to construct the schema objects.
16350 **
16351 ** New lookaside allocations are only allowed if bDisable==0. When
16352 ** bDisable is greater than zero, sz is set to zero which effectively
16353 ** disables lookaside without adding a new test for the bDisable flag
16354 ** in a performance-critical path. sz should be set by to szTrue whenever
16355 ** bDisable changes back to zero.
16356 */
16357 struct Lookaside {
16358 u32 bDisable; /* Only operate the lookaside when zero */
16359 u16 sz; /* Size of each buffer in bytes */
16360 u16 szTrue; /* True value of sz, even if disabled */
16361 u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */
16362 u32 nSlot; /* Number of lookaside slots allocated */
16363 u32 anStat[3]; /* 0: hits. 1: size misses. 2: full misses */
16364 LookasideSlot *pInit; /* List of buffers not previously used */
16365 LookasideSlot *pFree; /* List of available buffers */
@@ -16318,10 +16367,14 @@
16367 void *pEnd; /* First byte past end of available space */
16368 };
16369 struct LookasideSlot {
16370 LookasideSlot *pNext; /* Next buffer in the list of free buffers */
16371 };
16372
16373 #define DisableLookaside db->lookaside.bDisable++;db->lookaside.sz=0
16374 #define EnableLookaside db->lookaside.bDisable--;\
16375 db->lookaside.sz=db->lookaside.bDisable?0:db->lookaside.szTrue
16376
16377 /*
16378 ** A hash table for built-in function definitions. (Application-defined
16379 ** functions use a regular table table from hash.h.)
16380 **
@@ -16839,30 +16892,49 @@
16892 void (*xDestroy)(void *); /* Module destructor function */
16893 Table *pEpoTab; /* Eponymous table for this module */
16894 };
16895
16896 /*
16897 ** Information about each column of an SQL table is held in an instance
16898 ** of the Column structure, in the Table.aCol[] array.
16899 **
16900 ** Definitions:
16901 **
16902 ** "table column index" This is the index of the column in the
16903 ** Table.aCol[] array, and also the index of
16904 ** the column in the original CREATE TABLE stmt.
16905 **
16906 ** "storage column index" This is the index of the column in the
16907 ** record BLOB generated by the OP_MakeRecord
16908 ** opcode. The storage column index is less than
16909 ** or equal to the table column index. It is
16910 ** equal if and only if there are no VIRTUAL
16911 ** columns to the left.
16912 */
16913 struct Column {
16914 char *zName; /* Name of this column, \000, then the type */
16915 Expr *pDflt; /* Default value or GENERATED ALWAYS AS value */
16916 char *zColl; /* Collating sequence. If NULL, use the default */
16917 u8 notNull; /* An OE_ code for handling a NOT NULL constraint */
16918 char affinity; /* One of the SQLITE_AFF_... values */
16919 u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */
16920 u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */
16921 };
16922
16923 /* Allowed values for Column.colFlags:
16924 */
16925 #define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */
16926 #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */
16927 #define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */
16928 #define COLFLAG_UNIQUE 0x0008 /* Column def contains "UNIQUE" or "PK" */
16929 #define COLFLAG_SORTERREF 0x0010 /* Use sorter-refs with this column */
16930 #define COLFLAG_VIRTUAL 0x0020 /* GENERATED ALWAYS AS ... VIRTUAL */
16931 #define COLFLAG_STORED 0x0040 /* GENERATED ALWAYS AS ... STORED */
16932 #define COLFLAG_NOTAVAIL 0x0080 /* STORED column not yet calculated */
16933 #define COLFLAG_BUSY 0x0100 /* Blocks recursion on GENERATED columns */
16934 #define COLFLAG_GENERATED 0x0060 /* Combo: _STORED, _VIRTUAL */
16935 #define COLFLAG_NOINSERT 0x0062 /* Combo: _HIDDEN, _STORED, _VIRTUAL */
16936
16937 /*
16938 ** A "Collating Sequence" is defined by an instance of the following
16939 ** structure. Conceptually, a collating sequence consists of a name and
16940 ** a comparison routine that defines the order of that sequence.
@@ -16998,10 +17070,11 @@
17070 int tnum; /* Root BTree page for this table */
17071 u32 nTabRef; /* Number of pointers to this Table */
17072 u32 tabFlags; /* Mask of TF_* values */
17073 i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */
17074 i16 nCol; /* Number of columns in this table */
17075 i16 nNVCol; /* Number of columns that are not VIRTUAL */
17076 LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
17077 LogEst szTabRow; /* Estimated size of each table row in bytes */
17078 #ifdef SQLITE_ENABLE_COSTMULT
17079 LogEst costMult; /* Cost multiplier for using this table */
17080 #endif
@@ -17024,24 +17097,32 @@
17097 **
17098 ** TF_OOOHidden applies to tables or view that have hidden columns that are
17099 ** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING
17100 ** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden,
17101 ** the TF_OOOHidden attribute would apply in this case. Such tables require
17102 ** special handling during INSERT processing. The "OOO" means "Out Of Order".
17103 **
17104 ** Constraints:
17105 **
17106 ** TF_HasVirtual == COLFLAG_Virtual
17107 ** TF_HasStored == COLFLAG_Stored
17108 */
17109 #define TF_Readonly 0x0001 /* Read-only system table */
17110 #define TF_Ephemeral 0x0002 /* An ephemeral table */
17111 #define TF_HasPrimaryKey 0x0004 /* Table has a primary key */
17112 #define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */
17113 #define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */
17114 #define TF_HasVirtual 0x0020 /* Has one or more VIRTUAL columns */
17115 #define TF_HasStored 0x0040 /* Has one or more STORED columns */
17116 #define TF_HasGenerated 0x0060 /* Combo: HasVirtual + HasStored */
17117 #define TF_WithoutRowid 0x0080 /* No rowid. PRIMARY KEY is the key */
17118 #define TF_StatsUsed 0x0100 /* Query planner decisions affected by
17119 ** Index.aiRowLogEst[] values */
17120 #define TF_NoVisibleRowid 0x0200 /* No user-visible "rowid" column */
17121 #define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */
17122 #define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */
17123 #define TF_Shadow 0x1000 /* True for a shadow table */
17124
17125 /*
17126 ** Test to see whether or not a table is a virtual table. This is
17127 ** done as a macro so that it will be optimized out when virtual
17128 ** table support is omitted from the build.
@@ -17288,10 +17369,11 @@
17369 unsigned isCovering:1; /* True if this is a covering index */
17370 unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
17371 unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
17372 unsigned bNoQuery:1; /* Do not use this index to optimize queries */
17373 unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
17374 unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
17375 #ifdef SQLITE_ENABLE_STAT4
17376 int nSample; /* Number of elements in aSample[] */
17377 int nSampleCol; /* Size of IndexSample.anEq[] and so on */
17378 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
17379 IndexSample *aSample; /* Samples of the left-most key */
@@ -17479,10 +17561,14 @@
17561 ** allocated, regardless of whether or not EP_Reduced is set.
17562 */
17563 struct Expr {
17564 u8 op; /* Operation performed by this node */
17565 char affExpr; /* affinity, or RAISE type */
17566 u8 op2; /* TK_REGISTER/TK_TRUTH: original value of Expr.op
17567 ** TK_COLUMN: the value of p5 for OP_Column
17568 ** TK_AGG_FUNCTION: nesting depth
17569 ** TK_FUNCTION: NC_SelfRef flag if needs OP_PureFunc */
17570 u32 flags; /* Various flags. EP_* See below */
17571 union {
17572 char *zToken; /* Token value. Zero terminated and dequoted */
17573 int iValue; /* Non-negative integer value if EP_IntValue */
17574 } u;
@@ -17517,13 +17603,10 @@
17603 ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
17604 ** TK_VARIABLE: variable number (always >= 1).
17605 ** TK_SELECT_COLUMN: column of the result vector */
17606 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
17607 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
 
 
 
17608 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
17609 union {
17610 Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
17611 ** for a column of an index on an expression */
17612 Window *pWin; /* EP_WinFunc: Window/Filter defn for a function */
@@ -17548,11 +17631,11 @@
17631 #define EP_Agg 0x000010 /* Contains one or more aggregate functions */
17632 #define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
17633 #define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
17634 #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
17635 #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
17636 #define EP_Commuted 0x000200 /* Comparison operator has been commuted */
17637 #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
17638 #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
17639 #define EP_Skip 0x001000 /* Operator does not contribute to affinity */
17640 #define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
17641 #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
@@ -17617,13 +17700,17 @@
17700
17701 /*
17702 ** True if the expression passed as an argument was a function with
17703 ** an OVER() clause (a window function).
17704 */
17705 #ifdef SQLITE_OMIT_WINDOWFUNC
17706 # define IsWindowFunc(p) 0
17707 #else
17708 # define IsWindowFunc(p) ( \
17709 ExprHasProperty((p), EP_WinFunc) && p->y.pWin->eFrmType!=TK_FILTER \
17710 )
17711 #endif
17712
17713 /*
17714 ** A list of expressions. Each expression may optionally have a
17715 ** name. An expr/name combination can be used in several ways, such
17716 ** as the list of "expr AS ID" fields following a "SELECT" or in the
@@ -17825,25 +17912,27 @@
17912 ** NC_HasAgg == SF_HasAgg == EP_Agg
17913 ** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
17914 ** NC_HasWin == EP_Win
17915 **
17916 */
17917 #define NC_AllowAgg 0x00001 /* Aggregate functions are allowed here */
17918 #define NC_PartIdx 0x00002 /* True if resolving a partial index WHERE */
17919 #define NC_IsCheck 0x00004 /* True if resolving a CHECK constraint */
17920 #define NC_GenCol 0x00008 /* True for a GENERATED ALWAYS AS clause */
17921 #define NC_HasAgg 0x00010 /* One or more aggregate functions seen */
17922 #define NC_IdxExpr 0x00020 /* True if resolving columns of CREATE INDEX */
17923 #define NC_SelfRef 0x0002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */
17924 #define NC_VarSelect 0x00040 /* A correlated subquery has been seen */
17925 #define NC_UEList 0x00080 /* True if uNC.pEList is used */
17926 #define NC_UAggInfo 0x00100 /* True if uNC.pAggInfo is used */
17927 #define NC_UUpsert 0x00200 /* True if uNC.pUpsert is used */
17928 #define NC_MinMaxAgg 0x01000 /* min/max aggregates seen. See note above */
17929 #define NC_Complex 0x02000 /* True if a function or subquery seen */
17930 #define NC_AllowWin 0x04000 /* Window functions are allowed here */
17931 #define NC_HasWin 0x08000 /* One or more window functions seen */
17932 #define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */
17933 #define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */
17934
17935 /*
17936 ** An instance of the following object describes a single ON CONFLICT
17937 ** clause in an upsert.
17938 **
@@ -17920,30 +18009,31 @@
18009 ** Value constraints (all checked via assert())
18010 ** SF_HasAgg == NC_HasAgg
18011 ** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX
18012 ** SF_FixedLimit == WHERE_USE_LIMIT
18013 */
18014 #define SF_Distinct 0x0000001 /* Output should be DISTINCT */
18015 #define SF_All 0x0000002 /* Includes the ALL keyword */
18016 #define SF_Resolved 0x0000004 /* Identifiers have been resolved */
18017 #define SF_Aggregate 0x0000008 /* Contains agg functions or a GROUP BY */
18018 #define SF_HasAgg 0x0000010 /* Contains aggregate functions */
18019 #define SF_UsesEphemeral 0x0000020 /* Uses the OpenEphemeral opcode */
18020 #define SF_Expanded 0x0000040 /* sqlite3SelectExpand() called on this */
18021 #define SF_HasTypeInfo 0x0000080 /* FROM subqueries have Table metadata */
18022 #define SF_Compound 0x0000100 /* Part of a compound query */
18023 #define SF_Values 0x0000200 /* Synthesized from VALUES clause */
18024 #define SF_MultiValue 0x0000400 /* Single VALUES term with multiple rows */
18025 #define SF_NestedFrom 0x0000800 /* Part of a parenthesized FROM clause */
18026 #define SF_MinMaxAgg 0x0001000 /* Aggregate containing min() or max() */
18027 #define SF_Recursive 0x0002000 /* The recursive part of a recursive CTE */
18028 #define SF_FixedLimit 0x0004000 /* nSelectRow set by a constant LIMIT */
18029 #define SF_MaybeConvert 0x0008000 /* Need convertCompoundSelectToSubquery() */
18030 #define SF_Converted 0x0010000 /* By convertCompoundSelectToSubquery() */
18031 #define SF_IncludeHidden 0x0020000 /* Include hidden columns in output */
18032 #define SF_ComplexResult 0x0040000 /* Result contains subquery or function */
18033 #define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */
18034 #define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */
18035
18036 /*
18037 ** The results of a SELECT can be distributed in several ways, as defined
18038 ** by one of the following macros. The "SRT" prefix means "SELECT Result
18039 ** Type".
@@ -18531,11 +18621,11 @@
18621 Parse *pParse; /* Parser context. */
18622 int (*xExprCallback)(Walker*, Expr*); /* Callback for expressions */
18623 int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */
18624 void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */
18625 int walkerDepth; /* Number of subqueries */
18626 u16 eCode; /* A small processing code */
18627 union { /* Extra data for callback */
18628 NameContext *pNC; /* Naming context */
18629 int n; /* A counter */
18630 int iCur; /* A cursor number */
18631 SrcList *pSrcList; /* FROM clause */
@@ -18547,10 +18637,11 @@
18637 ExprList *pGroupBy; /* GROUP BY clause */
18638 Select *pSelect; /* HAVING to WHERE clause ctx */
18639 struct WindowRewrite *pRewrite; /* Window rewrite context */
18640 struct WhereConst *pConst; /* WHERE clause constants */
18641 struct RenameCtx *pRename; /* RENAME COLUMN context */
18642 struct Table *pTab; /* Table of generated column */
18643 } u;
18644 };
18645
18646 /* Forward declarations */
18647 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -18954,11 +19045,18 @@
19045 SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
19046 SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char);
19047 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char);
19048 SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
19049 SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
19050 SQLITE_PRIVATE i16 sqlite3TableColumnToIndex(Index*, i16);
19051 #ifdef SQLITE_OMIT_GENERATED_COLUMNS
19052 # define sqlite3TableColumnToStorage(T,X) (X) /* No-op pass-through */
19053 # define sqlite3StorageColumnToTable(T,X) (X) /* No-op pass-through */
19054 #else
19055 SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table*, i16);
19056 SQLITE_PRIVATE i16 sqlite3StorageColumnToTable(Table*, i16);
19057 #endif
19058 SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
19059 #if SQLITE_ENABLE_HIDDEN_COLUMNS
19060 SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*);
19061 #else
19062 # define sqlite3ColumnPropertiesFromName(T,C) /* no-op */
@@ -18967,11 +19065,15 @@
19065 SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);
19066 SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
19067 SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*);
19068 SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);
19069 SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*);
19070 SQLITE_PRIVATE void sqlite3AddGenerated(Parse*,Expr*,Token*);
19071 SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
19072 #ifdef SQLITE_DEBUG
19073 SQLITE_PRIVATE int sqlite3UriCount(const char*);
19074 #endif
19075 SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*,
19076 sqlite3_vfs**,char**,char **);
19077 #ifdef SQLITE_HAS_CODEC
19078 SQLITE_PRIVATE int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*);
19079 #else
@@ -19024,10 +19126,13 @@
19126 #else
19127 # define sqlite3AutoincrementBegin(X)
19128 # define sqlite3AutoincrementEnd(X)
19129 #endif
19130 SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);
19131 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
19132 SQLITE_PRIVATE void sqlite3ComputeGeneratedColumns(Parse*, int, Table*);
19133 #endif
19134 SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
19135 SQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse*, IdList*, Token*);
19136 SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);
19137 SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(Parse*, SrcList*, int, int);
19138 SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(Parse*, SrcList*, Token*, Token*);
@@ -19073,16 +19178,18 @@
19178 SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);
19179 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
19180 SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
19181 SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
19182 SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
19183 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
19184 SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Column*, int);
19185 #endif
19186 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
19187 SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
19188 SQLITE_PRIVATE int sqlite3ExprCodeAtInit(Parse*, Expr*, int);
19189 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
19190 SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
 
19191 SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);
19192 #define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */
19193 #define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */
19194 #define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */
19195 #define SQLITE_ECEL_OMITREF 0x08 /* Omit if ExprList.u.x.iOrderByCol */
@@ -19215,10 +19322,11 @@
19322 # define sqlite3IsToplevel(p) 1
19323 # define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0
19324 #endif
19325
19326 SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);
19327 SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr*,int);
19328 SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
19329 SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);
19330 #ifndef SQLITE_OMIT_AUTHORIZATION
19331 SQLITE_PRIVATE void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);
19332 SQLITE_PRIVATE int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);
@@ -19512,10 +19620,16 @@
19620 const sqlite3_module*,
19621 void*,
19622 void(*)(void*)
19623 );
19624 # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
19625 #endif
19626 SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db);
19627 #ifndef SQLITE_OMIT_VIRTUALTABLE
19628 SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName);
19629 #else
19630 # define sqlite3ShadowTableName(A,B) 0
19631 #endif
19632 SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*);
19633 SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
19634 SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);
19635 SQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);
@@ -19534,10 +19648,11 @@
19648 #ifdef SQLITE_ENABLE_NORMALIZE
19649 SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*);
19650 #endif
19651 SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
19652 SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
19653 SQLITE_PRIVATE CollSeq *sqlite3ExprCompareCollSeq(Parse*,Expr*);
19654 SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
19655 SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
19656 SQLITE_PRIVATE const char *sqlite3JournalModename(int);
19657 #ifndef SQLITE_OMIT_WAL
19658 SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);
@@ -20376,11 +20491,12 @@
20491
20492 /*
20493 ** True if Mem X is a NULL-nochng type.
20494 */
20495 #define MemNullNochng(X) \
20496 (((X)->flags&MEM_TypeMask)==(MEM_Null|MEM_Zero) \
20497 && (X)->n==0 && (X)->u.nZero==0)
20498
20499 /*
20500 ** Return true if a memory cell is not marked as invalid. This macro
20501 ** is for use inside assert() statements only.
20502 */
@@ -26056,11 +26172,11 @@
26172 ** May you share freely, never taking more than you give.
26173 **
26174 ******************************************************************************
26175 **
26176 ** This file contains inline asm code for retrieving "high-performance"
26177 ** counters for x86 and x86_64 class CPUs.
26178 */
26179 #ifndef SQLITE_HWTIME_H
26180 #define SQLITE_HWTIME_H
26181
26182 /*
@@ -26067,12 +26183,13 @@
26183 ** The following routine only works on pentium-class (or newer) processors.
26184 ** It uses the RDTSC opcode to read the cycle count value out of the
26185 ** processor and returns that value. This can be used for high-res
26186 ** profiling.
26187 */
26188 #if !defined(__STRICT_ANSI__) && \
26189 (defined(__GNUC__) || defined(_MSC_VER)) && \
26190 (defined(i386) || defined(__i386__) || defined(_M_IX86))
26191
26192 #if defined(__GNUC__)
26193
26194 __inline__ sqlite_uint64 sqlite3Hwtime(void){
26195 unsigned int lo, hi;
@@ -26089,19 +26206,19 @@
26206 }
26207 }
26208
26209 #endif
26210
26211 #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__))
26212
26213 __inline__ sqlite_uint64 sqlite3Hwtime(void){
26214 unsigned long val;
26215 __asm__ __volatile__ ("rdtsc" : "=A" (val));
26216 return val;
26217 }
26218
26219 #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__))
26220
26221 __inline__ sqlite_uint64 sqlite3Hwtime(void){
26222 unsigned long long retval;
26223 unsigned long junk;
26224 __asm__ __volatile__ ("\n\
@@ -26114,18 +26231,17 @@
26231 return retval;
26232 }
26233
26234 #else
26235
 
 
26236 /*
26237 ** asm() is needed for hardware timing support. Without asm(),
26238 ** disable the sqlite3Hwtime() routine.
26239 **
26240 ** sqlite3Hwtime() is only used for some obscure debugging
26241 ** and analysis configurations, not in any deliverable, so this
26242 ** should not be a great loss.
26243 */
26244 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
26245
26246 #endif
26247
@@ -26705,23 +26821,31 @@
26821 UNUSED_PARAMETER(n);
26822 return 0;
26823 #endif
26824 }
26825
26826 /*
26827 ** Default value of the hard heap limit. 0 means "no limit".
26828 */
26829 #ifndef SQLITE_MAX_MEMORY
26830 # define SQLITE_MAX_MEMORY 0
26831 #endif
26832
26833 /*
26834 ** State information local to the memory allocation subsystem.
26835 */
26836 static SQLITE_WSD struct Mem0Global {
26837 sqlite3_mutex *mutex; /* Mutex to serialize access */
26838 sqlite3_int64 alarmThreshold; /* The soft heap limit */
26839 sqlite3_int64 hardLimit; /* The hard upper bound on memory */
26840
26841 /*
26842 ** True if heap is nearly "full" where "full" is defined by the
26843 ** sqlite3_soft_heap_limit() setting.
26844 */
26845 int nearlyFull;
26846 } mem0 = { 0, SQLITE_MAX_MEMORY, SQLITE_MAX_MEMORY, 0 };
26847
26848 #define mem0 GLOBAL(struct Mem0Global, mem0)
26849
26850 /*
26851 ** Return the memory allocator mutex. sqlite3_status() needs it.
@@ -26747,12 +26871,19 @@
26871 return SQLITE_OK;
26872 }
26873 #endif
26874
26875 /*
26876 ** Set the soft heap-size limit for the library. An argument of
26877 ** zero disables the limit. A negative argument is a no-op used to
26878 ** obtain the return value.
26879 **
26880 ** The return value is the value of the heap limit just before this
26881 ** interface was called.
26882 **
26883 ** If the hard heap limit is enabled, then the soft heap limit cannot
26884 ** be disabled nor raised above the hard heap limit.
26885 */
26886 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){
26887 sqlite3_int64 priorLimit;
26888 sqlite3_int64 excess;
26889 sqlite3_int64 nUsed;
@@ -26763,10 +26894,13 @@
26894 sqlite3_mutex_enter(mem0.mutex);
26895 priorLimit = mem0.alarmThreshold;
26896 if( n<0 ){
26897 sqlite3_mutex_leave(mem0.mutex);
26898 return priorLimit;
26899 }
26900 if( mem0.hardLimit>0 && (n>mem0.hardLimit || n==0) ){
26901 n = mem0.hardLimit;
26902 }
26903 mem0.alarmThreshold = n;
26904 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
26905 mem0.nearlyFull = (n>0 && n<=nUsed);
26906 sqlite3_mutex_leave(mem0.mutex);
@@ -26776,10 +26910,41 @@
26910 }
26911 SQLITE_API void sqlite3_soft_heap_limit(int n){
26912 if( n<0 ) n = 0;
26913 sqlite3_soft_heap_limit64(n);
26914 }
26915
26916 /*
26917 ** Set the hard heap-size limit for the library. An argument of zero
26918 ** disables the hard heap limit. A negative argument is a no-op used
26919 ** to obtain the return value without affecting the hard heap limit.
26920 **
26921 ** The return value is the value of the hard heap limit just prior to
26922 ** calling this interface.
26923 **
26924 ** Setting the hard heap limit will also activate the soft heap limit
26925 ** and constrain the soft heap limit to be no more than the hard heap
26926 ** limit.
26927 */
26928 SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 n){
26929 sqlite3_int64 priorLimit;
26930 #ifndef SQLITE_OMIT_AUTOINIT
26931 int rc = sqlite3_initialize();
26932 if( rc ) return -1;
26933 #endif
26934 sqlite3_mutex_enter(mem0.mutex);
26935 priorLimit = mem0.hardLimit;
26936 if( n>=0 ){
26937 mem0.hardLimit = n;
26938 if( n<mem0.alarmThreshold || mem0.alarmThreshold==0 ){
26939 mem0.alarmThreshold = n;
26940 }
26941 }
26942 sqlite3_mutex_leave(mem0.mutex);
26943 return priorLimit;
26944 }
26945
26946
26947 /*
26948 ** Initialize the memory allocation subsystem.
26949 */
26950 SQLITE_PRIVATE int sqlite3MallocInit(void){
@@ -26863,23 +27028,23 @@
27028 ** mode and specifically when the DMD "Dark Matter Detector" is enabled
27029 ** or else a crash results. Hence, do not attempt to optimize out the
27030 ** following xRoundup() call. */
27031 nFull = sqlite3GlobalConfig.m.xRoundup(n);
27032
 
 
 
 
 
 
 
27033 sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);
27034 if( mem0.alarmThreshold>0 ){
27035 sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
27036 if( nUsed >= mem0.alarmThreshold - nFull ){
27037 mem0.nearlyFull = 1;
27038 sqlite3MallocAlarm(nFull);
27039 if( mem0.hardLimit ){
27040 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
27041 if( nUsed >= mem0.hardLimit - nFull ){
27042 *pp = 0;
27043 return;
27044 }
27045 }
27046 }else{
27047 mem0.nearlyFull = 0;
27048 }
27049 }
27050 p = sqlite3GlobalConfig.m.xMalloc(nFull);
@@ -26971,11 +27136,11 @@
27136 }
27137 #endif
27138 return sqlite3GlobalConfig.m.xSize(p);
27139 }else{
27140 assert( sqlite3_mutex_held(db->mutex) );
27141 return db->lookaside.szTrue;
27142 }
27143 }
27144 SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){
27145 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
27146 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
@@ -27023,11 +27188,11 @@
27188 }
27189 if( isLookaside(db, p) ){
27190 LookasideSlot *pBuf = (LookasideSlot*)p;
27191 #ifdef SQLITE_DEBUG
27192 /* Trash all content in the buffer being freed */
27193 memset(p, 0xaa, db->lookaside.szTrue);
27194 #endif
27195 pBuf->pNext = db->lookaside.pFree;
27196 db->lookaside.pFree = pBuf;
27197 return;
27198 }
@@ -27183,27 +27348,25 @@
27348 #ifndef SQLITE_OMIT_LOOKASIDE
27349 LookasideSlot *pBuf;
27350 assert( db!=0 );
27351 assert( sqlite3_mutex_held(db->mutex) );
27352 assert( db->pnBytesFreed==0 );
27353 if( n>db->lookaside.sz ){
27354 if( db->lookaside.bDisable ){
27355 return db->mallocFailed ? 0 : dbMallocRawFinish(db, n);
27356 }
27357 db->lookaside.anStat[1]++;
27358 }else if( (pBuf = db->lookaside.pFree)!=0 ){
27359 db->lookaside.pFree = pBuf->pNext;
27360 db->lookaside.anStat[0]++;
27361 return (void*)pBuf;
27362 }else if( (pBuf = db->lookaside.pInit)!=0 ){
27363 db->lookaside.pInit = pBuf->pNext;
27364 db->lookaside.anStat[0]++;
27365 return (void*)pBuf;
27366 }else{
27367 db->lookaside.anStat[2]++;
 
 
27368 }
27369 #else
27370 assert( db!=0 );
27371 assert( sqlite3_mutex_held(db->mutex) );
27372 assert( db->pnBytesFreed==0 );
@@ -27223,11 +27386,11 @@
27386 */
27387 SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){
27388 assert( db!=0 );
27389 if( p==0 ) return sqlite3DbMallocRawNN(db, n);
27390 assert( sqlite3_mutex_held(db->mutex) );
27391 if( isLookaside(db,p) && n<=db->lookaside.szTrue ) return p;
27392 return dbReallocFinish(db, p, n);
27393 }
27394 static SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n){
27395 void *pNew = 0;
27396 assert( db!=0 );
@@ -27234,11 +27397,11 @@
27397 assert( p!=0 );
27398 if( db->mallocFailed==0 ){
27399 if( isLookaside(db, p) ){
27400 pNew = sqlite3DbMallocRawNN(db, n);
27401 if( pNew ){
27402 memcpy(pNew, p, db->lookaside.szTrue);
27403 sqlite3DbFree(db, p);
27404 }
27405 }else{
27406 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
27407 assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
@@ -27333,11 +27496,11 @@
27496 if( db->mallocFailed==0 && db->bBenignMalloc==0 ){
27497 db->mallocFailed = 1;
27498 if( db->nVdbeExec>0 ){
27499 db->u1.isInterrupted = 1;
27500 }
27501 DisableLookaside;
27502 if( db->pParse ){
27503 db->pParse->rc = SQLITE_NOMEM_BKPT;
27504 }
27505 }
27506 }
@@ -27352,11 +27515,11 @@
27515 SQLITE_PRIVATE void sqlite3OomClear(sqlite3 *db){
27516 if( db->mallocFailed && db->nVdbeExec==0 ){
27517 db->mallocFailed = 0;
27518 db->u1.isInterrupted = 0;
27519 assert( db->lookaside.bDisable>0 );
27520 EnableLookaside;
27521 }
27522 }
27523
27524 /*
27525 ** Take actions at the end of an API call to indicate an OOM error
@@ -28760,11 +28923,11 @@
28923 }
28924 if( zFormat!=0 ){
28925 va_start(ap, zFormat);
28926 sqlite3_str_vappendf(&acc, zFormat, ap);
28927 va_end(ap);
28928 assert( acc.nChar>0 || acc.accError );
28929 sqlite3_str_append(&acc, "\n", 1);
28930 }
28931 sqlite3StrAccumFinish(&acc);
28932 fprintf(stdout,"%s", zBuf);
28933 fflush(stdout);
@@ -28825,11 +28988,11 @@
28988 for(i=0; i<pSrc->nSrc; i++){
28989 const struct SrcList_item *pItem = &pSrc->a[i];
28990 StrAccum x;
28991 char zLine[100];
28992 sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
28993 sqlite3_str_appendf(&x, "{%d:*}", pItem->iCursor);
28994 if( pItem->zDatabase ){
28995 sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
28996 }else if( pItem->zName ){
28997 sqlite3_str_appendf(&x, " %s", pItem->zName);
28998 }
@@ -29117,11 +29280,18 @@
29280 break;
29281 }
29282 case TK_COLUMN: {
29283 if( pExpr->iTable<0 ){
29284 /* This only happens when coding check constraints */
29285 char zOp2[16];
29286 if( pExpr->op2 ){
29287 sqlite3_snprintf(sizeof(zOp2),zOp2," op2=0x%02x",pExpr->op2);
29288 }else{
29289 zOp2[0] = 0;
29290 }
29291 sqlite3TreeViewLine(pView, "COLUMN(%d)%s%s",
29292 pExpr->iColumn, zFlgs, zOp2);
29293 }else{
29294 sqlite3TreeViewLine(pView, "{%d:%d}%s",
29295 pExpr->iTable, pExpr->iColumn, zFlgs);
29296 }
29297 if( ExprHasProperty(pExpr, EP_FixedCol) ){
@@ -29260,10 +29430,21 @@
29430 #endif
29431 }
29432 if( pExpr->op==TK_AGG_FUNCTION ){
29433 sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s",
29434 pExpr->op2, pExpr->u.zToken, zFlgs);
29435 }else if( pExpr->op2!=0 ){
29436 const char *zOp2;
29437 char zBuf[8];
29438 sqlite3_snprintf(sizeof(zBuf),zBuf,"0x%02x",pExpr->op2);
29439 zOp2 = zBuf;
29440 if( pExpr->op2==NC_IsCheck ) zOp2 = "NC_IsCheck";
29441 if( pExpr->op2==NC_IdxExpr ) zOp2 = "NC_IdxExpr";
29442 if( pExpr->op2==NC_PartIdx ) zOp2 = "NC_PartIdx";
29443 if( pExpr->op2==NC_GenCol ) zOp2 = "NC_GenCol";
29444 sqlite3TreeViewLine(pView, "FUNCTION %Q%s op2=%s",
29445 pExpr->u.zToken, zFlgs, zOp2);
29446 }else{
29447 sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs);
29448 }
29449 if( pFarg ){
29450 sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);
@@ -29355,11 +29536,13 @@
29536 pExpr->iTable, pExpr->iColumn, zFlgs);
29537 sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
29538 break;
29539 }
29540 case TK_VECTOR: {
29541 char *z = sqlite3_mprintf("VECTOR%s",zFlgs);
29542 sqlite3TreeViewBareExprList(pView, pExpr->x.pList, z);
29543 sqlite3_free(z);
29544 break;
29545 }
29546 case TK_SELECT_COLUMN: {
29547 sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn);
29548 sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);
@@ -30581,10 +30764,11 @@
30764 }else{
30765 pParse->nErr++;
30766 sqlite3DbFree(db, pParse->zErrMsg);
30767 pParse->zErrMsg = zMsg;
30768 pParse->rc = SQLITE_ERROR;
30769 pParse->pWith = 0;
30770 }
30771 }
30772
30773 /*
30774 ** If database connection db is currently parsing SQL, then transfer
@@ -30771,10 +30955,13 @@
30955 **
30956 ** If some prefix of the input string is a valid number, this routine
30957 ** returns FALSE but it still converts the prefix and writes the result
30958 ** into *pResult.
30959 */
30960 #if defined(_MSC_VER)
30961 #pragma warning(disable : 4756)
30962 #endif
30963 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
30964 #ifndef SQLITE_OMIT_FLOATING_POINT
30965 int incr;
30966 const char *zEnd = z + length;
30967 /* sign * significand * (10 ^ (esign * exponent)) */
@@ -30958,10 +31145,13 @@
31145 }
31146 #else
31147 return !sqlite3Atoi64(z, pResult, length, enc);
31148 #endif /* SQLITE_OMIT_FLOATING_POINT */
31149 }
31150 #if defined(_MSC_VER)
31151 #pragma warning(default : 4756)
31152 #endif
31153
31154 /*
31155 ** Compare the 19-character string zNum against the text representation
31156 ** value 2^63: 9223372036854775808. Return negative, zero, or positive
31157 ** if zNum is less than, equal to, or greater than the string.
@@ -32364,121 +32554,119 @@
32554 /* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
32555 /* 58 */ "ElseNotEq" OpHelp(""),
32556 /* 59 */ "IncrVacuum" OpHelp(""),
32557 /* 60 */ "VNext" OpHelp(""),
32558 /* 61 */ "Init" OpHelp("Start at P2"),
32559 /* 62 */ "PureFunc" OpHelp("r[P3]=func(r[P2@P5])"),
32560 /* 63 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
32561 /* 64 */ "Return" OpHelp(""),
32562 /* 65 */ "EndCoroutine" OpHelp(""),
32563 /* 66 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
32564 /* 67 */ "Halt" OpHelp(""),
32565 /* 68 */ "Integer" OpHelp("r[P2]=P1"),
32566 /* 69 */ "Int64" OpHelp("r[P2]=P4"),
32567 /* 70 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
32568 /* 71 */ "Null" OpHelp("r[P2..P3]=NULL"),
32569 /* 72 */ "SoftNull" OpHelp("r[P1]=NULL"),
32570 /* 73 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
32571 /* 74 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
32572 /* 75 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
32573 /* 76 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
32574 /* 77 */ "SCopy" OpHelp("r[P2]=r[P1]"),
32575 /* 78 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
32576 /* 79 */ "ResultRow" OpHelp("output=r[P1@P2]"),
32577 /* 80 */ "CollSeq" OpHelp(""),
32578 /* 81 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
32579 /* 82 */ "RealAffinity" OpHelp(""),
32580 /* 83 */ "Cast" OpHelp("affinity(r[P1])"),
32581 /* 84 */ "Permutation" OpHelp(""),
32582 /* 85 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
32583 /* 86 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
32584 /* 87 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
32585 /* 88 */ "Column" OpHelp("r[P3]=PX"),
32586 /* 89 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
32587 /* 90 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
32588 /* 91 */ "Count" OpHelp("r[P2]=count()"),
32589 /* 92 */ "ReadCookie" OpHelp(""),
32590 /* 93 */ "SetCookie" OpHelp(""),
32591 /* 94 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32592 /* 95 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32593 /* 96 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32594 /* 97 */ "OpenDup" OpHelp(""),
32595 /* 98 */ "OpenAutoindex" OpHelp("nColumn=P2"),
32596 /* 99 */ "OpenEphemeral" OpHelp("nColumn=P2"),
32597 /* 100 */ "SorterOpen" OpHelp(""),
32598 /* 101 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32599 /* 102 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32600 /* 103 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32601 /* 104 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32602 /* 105 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32603 /* 106 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32604 /* 107 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32605 /* 108 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32606 /* 109 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32607 /* 110 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32608 /* 111 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
32609 /* 112 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32610 /* 113 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
32611 /* 114 */ "Close" OpHelp(""),
32612 /* 115 */ "String8" OpHelp("r[P2]='P4'"),
32613 /* 116 */ "ColumnsUsed" OpHelp(""),
32614 /* 117 */ "SeekHit" OpHelp("seekHit=P2"),
32615 /* 118 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
32616 /* 119 */ "NewRowid" OpHelp("r[P2]=rowid"),
32617 /* 120 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
32618 /* 121 */ "Delete" OpHelp(""),
32619 /* 122 */ "ResetCount" OpHelp(""),
32620 /* 123 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
32621 /* 124 */ "SorterData" OpHelp("r[P2]=data"),
32622 /* 125 */ "RowData" OpHelp("r[P2]=data"),
32623 /* 126 */ "Rowid" OpHelp("r[P2]=rowid"),
32624 /* 127 */ "NullRow" OpHelp(""),
32625 /* 128 */ "SeekEnd" OpHelp(""),
32626 /* 129 */ "SorterInsert" OpHelp("key=r[P2]"),
32627 /* 130 */ "IdxInsert" OpHelp("key=r[P2]"),
32628 /* 131 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
32629 /* 132 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
32630 /* 133 */ "IdxRowid" OpHelp("r[P2]=rowid"),
32631 /* 134 */ "Destroy" OpHelp(""),
32632 /* 135 */ "Clear" OpHelp(""),
32633 /* 136 */ "ResetSorter" OpHelp(""),
32634 /* 137 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
32635 /* 138 */ "SqlExec" OpHelp(""),
32636 /* 139 */ "ParseSchema" OpHelp(""),
32637 /* 140 */ "LoadAnalysis" OpHelp(""),
32638 /* 141 */ "DropTable" OpHelp(""),
32639 /* 142 */ "DropIndex" OpHelp(""),
32640 /* 143 */ "DropTrigger" OpHelp(""),
32641 /* 144 */ "IntegrityCk" OpHelp(""),
32642 /* 145 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
32643 /* 146 */ "Param" OpHelp(""),
32644 /* 147 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
32645 /* 148 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
32646 /* 149 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
32647 /* 150 */ "Real" OpHelp("r[P2]=P4"),
32648 /* 151 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
32649 /* 152 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
32650 /* 153 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
32651 /* 154 */ "AggValue" OpHelp("r[P3]=value N=P2"),
32652 /* 155 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
32653 /* 156 */ "Expire" OpHelp(""),
32654 /* 157 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
32655 /* 158 */ "VBegin" OpHelp(""),
32656 /* 159 */ "VCreate" OpHelp(""),
32657 /* 160 */ "VDestroy" OpHelp(""),
32658 /* 161 */ "VOpen" OpHelp(""),
32659 /* 162 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
32660 /* 163 */ "VRename" OpHelp(""),
32661 /* 164 */ "Pagecount" OpHelp(""),
32662 /* 165 */ "MaxPgcnt" OpHelp(""),
32663 /* 166 */ "Trace" OpHelp(""),
32664 /* 167 */ "CursorHint" OpHelp(""),
32665 /* 168 */ "Noop" OpHelp(""),
32666 /* 169 */ "Explain" OpHelp(""),
32667 /* 170 */ "Abortable" OpHelp(""),
 
 
32668 };
32669 return azName[i];
32670 }
32671 #endif
32672
@@ -32838,11 +33026,11 @@
33026 ** May you share freely, never taking more than you give.
33027 **
33028 ******************************************************************************
33029 **
33030 ** This file contains inline asm code for retrieving "high-performance"
33031 ** counters for x86 and x86_64 class CPUs.
33032 */
33033 #ifndef SQLITE_HWTIME_H
33034 #define SQLITE_HWTIME_H
33035
33036 /*
@@ -32849,12 +33037,13 @@
33037 ** The following routine only works on pentium-class (or newer) processors.
33038 ** It uses the RDTSC opcode to read the cycle count value out of the
33039 ** processor and returns that value. This can be used for high-res
33040 ** profiling.
33041 */
33042 #if !defined(__STRICT_ANSI__) && \
33043 (defined(__GNUC__) || defined(_MSC_VER)) && \
33044 (defined(i386) || defined(__i386__) || defined(_M_IX86))
33045
33046 #if defined(__GNUC__)
33047
33048 __inline__ sqlite_uint64 sqlite3Hwtime(void){
33049 unsigned int lo, hi;
@@ -32871,19 +33060,19 @@
33060 }
33061 }
33062
33063 #endif
33064
33065 #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__))
33066
33067 __inline__ sqlite_uint64 sqlite3Hwtime(void){
33068 unsigned long val;
33069 __asm__ __volatile__ ("rdtsc" : "=A" (val));
33070 return val;
33071 }
33072
33073 #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__))
33074
33075 __inline__ sqlite_uint64 sqlite3Hwtime(void){
33076 unsigned long long retval;
33077 unsigned long junk;
33078 __asm__ __volatile__ ("\n\
@@ -32896,18 +33085,17 @@
33085 return retval;
33086 }
33087
33088 #else
33089
 
 
33090 /*
33091 ** asm() is needed for hardware timing support. Without asm(),
33092 ** disable the sqlite3Hwtime() routine.
33093 **
33094 ** sqlite3Hwtime() is only used for some obscure debugging
33095 ** and analysis configurations, not in any deliverable, so this
33096 ** should not be a great loss.
33097 */
33098 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
33099
33100 #endif
33101
@@ -38933,19 +39121,29 @@
39121 ){
39122 UNUSED_PARAMETER(NotUsed);
39123 SimulateIOError( return SQLITE_IOERR_ACCESS; );
39124 assert( pResOut!=0 );
39125
39126 /* The spec says there are four possible values for flags. But the
39127 ** SQLITE_ACCESS_READ flag is never used */
39128 assert( flags==SQLITE_ACCESS_EXISTS
39129 || flags==SQLITE_ACCESS_READWRITE
39130 || flags==SQLITE_ACCESS_SYMLINK );
39131
39132 if( flags==SQLITE_ACCESS_EXISTS ){
39133 struct stat buf;
39134 *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0);
39135 }else if( flags==SQLITE_ACCESS_READWRITE ){
39136 *pResOut = osAccess(zPath, W_OK|R_OK)==0;
39137 }else{
39138 #if !defined(HAVE_LSTAT)
39139 *pResOut = 0;
39140 #else
39141 struct stat buf;
39142 *pResOut = (0==osLstat(zPath, &buf) && S_ISLNK(buf.st_mode));
39143 #endif
39144 assert( flags==SQLITE_ACCESS_SYMLINK );
39145 }
39146 return SQLITE_OK;
39147 }
39148
39149 /*
@@ -40660,11 +40858,11 @@
40858 ** May you share freely, never taking more than you give.
40859 **
40860 ******************************************************************************
40861 **
40862 ** This file contains inline asm code for retrieving "high-performance"
40863 ** counters for x86 and x86_64 class CPUs.
40864 */
40865 #ifndef SQLITE_HWTIME_H
40866 #define SQLITE_HWTIME_H
40867
40868 /*
@@ -40671,12 +40869,13 @@
40869 ** The following routine only works on pentium-class (or newer) processors.
40870 ** It uses the RDTSC opcode to read the cycle count value out of the
40871 ** processor and returns that value. This can be used for high-res
40872 ** profiling.
40873 */
40874 #if !defined(__STRICT_ANSI__) && \
40875 (defined(__GNUC__) || defined(_MSC_VER)) && \
40876 (defined(i386) || defined(__i386__) || defined(_M_IX86))
40877
40878 #if defined(__GNUC__)
40879
40880 __inline__ sqlite_uint64 sqlite3Hwtime(void){
40881 unsigned int lo, hi;
@@ -40693,19 +40892,19 @@
40892 }
40893 }
40894
40895 #endif
40896
40897 #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__))
40898
40899 __inline__ sqlite_uint64 sqlite3Hwtime(void){
40900 unsigned long val;
40901 __asm__ __volatile__ ("rdtsc" : "=A" (val));
40902 return val;
40903 }
40904
40905 #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__))
40906
40907 __inline__ sqlite_uint64 sqlite3Hwtime(void){
40908 unsigned long long retval;
40909 unsigned long junk;
40910 __asm__ __volatile__ ("\n\
@@ -40718,18 +40917,17 @@
40917 return retval;
40918 }
40919
40920 #else
40921
 
 
40922 /*
40923 ** asm() is needed for hardware timing support. Without asm(),
40924 ** disable the sqlite3Hwtime() routine.
40925 **
40926 ** sqlite3Hwtime() is only used for some obscure debugging
40927 ** and analysis configurations, not in any deliverable, so this
40928 ** should not be a great loss.
40929 */
40930 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
40931
40932 #endif
40933
@@ -40862,10 +41060,18 @@
41060
41061 #ifndef NTDDI_WINTHRESHOLD
41062 # define NTDDI_WINTHRESHOLD 0x06040000
41063 #endif
41064
41065 /*
41066 ** This constant is needed by the winAccess function; therefore, define
41067 ** it when it is missing from the SDK header files.
41068 */
41069 #ifndef FILE_ATTRIBUTE_REPARSE_POINT
41070 # define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
41071 #endif
41072
41073 /*
41074 ** Check to see if the GetVersionEx[AW] functions are deprecated on the
41075 ** target system. GetVersionEx was first deprecated in Win8.1.
41076 */
41077 #ifndef SQLITE_WIN32_GETVERSIONEX
@@ -46254,10 +46460,14 @@
46460 break;
46461 case SQLITE_ACCESS_READWRITE:
46462 rc = attr!=INVALID_FILE_ATTRIBUTES &&
46463 (attr & FILE_ATTRIBUTE_READONLY)==0;
46464 break;
46465 case SQLITE_ACCESS_SYMLINK:
46466 rc = attr!=INVALID_FILE_ATTRIBUTES &&
46467 (attr & FILE_ATTRIBUTE_REPARSE_POINT)!=0;
46468 break;
46469 default:
46470 assert(!"Invalid flags argument");
46471 }
46472 *pResOut = rc;
46473 OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
@@ -52141,10 +52351,11 @@
52351 ** master-journal filename.
52352 */
52353 len = 0;
52354 }
52355 zMaster[len] = '\0';
52356 zMaster[len+1] = '\0';
52357
52358 return SQLITE_OK;
52359 }
52360
52361 /*
@@ -53377,19 +53588,20 @@
53588 ** journal files extracted from regular rollback-journals.
53589 */
53590 rc = sqlite3OsFileSize(pMaster, &nMasterJournal);
53591 if( rc!=SQLITE_OK ) goto delmaster_out;
53592 nMasterPtr = pVfs->mxPathname+1;
53593 zMasterJournal = sqlite3Malloc(nMasterJournal + nMasterPtr + 2);
53594 if( !zMasterJournal ){
53595 rc = SQLITE_NOMEM_BKPT;
53596 goto delmaster_out;
53597 }
53598 zMasterPtr = &zMasterJournal[nMasterJournal+2];
53599 rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0);
53600 if( rc!=SQLITE_OK ) goto delmaster_out;
53601 zMasterJournal[nMasterJournal] = 0;
53602 zMasterJournal[nMasterJournal+1] = 0;
53603
53604 zJournal = zMasterJournal;
53605 while( (zJournal-zMasterJournal)<nMasterJournal ){
53606 int exists;
53607 rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);
@@ -55542,11 +55754,12 @@
55754 int nPathname = 0; /* Number of bytes in zPathname */
55755 int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */
55756 int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */
55757 u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */
55758 const char *zUri = 0; /* URI args to copy */
55759 int nUriByte = 1; /* Number of bytes of URI args at *zUri */
55760 int nUri = 0; /* Number of URI parameters */
55761
55762 /* Figure out how much space is required for each journal file-handle
55763 ** (there are two of them, the main journal and the sub-journal). */
55764 journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
55765
@@ -55569,10 +55782,16 @@
55782 ** to by zPathname, length nPathname. Or, if this is a temporary file,
55783 ** leave both nPathname and zPathname set to 0.
55784 */
55785 if( zFilename && zFilename[0] ){
55786 const char *z;
55787 if( (vfsFlags & SQLITE_OPEN_NOFOLLOW)!=0 ){
55788 int isLink = 0;
55789 int rc = sqlite3OsAccess(pVfs, zFilename, SQLITE_ACCESS_SYMLINK, &isLink);
55790 if( rc==SQLITE_OK && isLink ) rc = SQLITE_CANTOPEN_SYMLINK;
55791 if( rc ) return rc;
55792 }
55793 nPathname = pVfs->mxPathname+1;
55794 zPathname = sqlite3DbMallocRaw(0, nPathname*2);
55795 if( zPathname==0 ){
55796 return SQLITE_NOMEM_BKPT;
55797 }
@@ -55579,15 +55798,16 @@
55798 zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */
55799 rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
55800 nPathname = sqlite3Strlen30(zPathname);
55801 z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
55802 while( *z ){
55803 z += strlen(z)+1;
55804 z += strlen(z)+1;
55805 nUri++;
55806 }
55807 nUriByte = (int)(&z[2] - zUri);
55808 assert( nUriByte>=1 );
55809 if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
55810 /* This branch is taken when the journal path required by
55811 ** the database being opened will be more than pVfs->mxPathname
55812 ** bytes in length. This means the database cannot be opened,
55813 ** as it will not be possible to open the journal file or even
@@ -55616,11 +55836,11 @@
55836 pPtr = (u8 *)sqlite3MallocZero(
55837 ROUND8(sizeof(*pPager)) + /* Pager structure */
55838 ROUND8(pcacheSize) + /* PCache object */
55839 ROUND8(pVfs->szOsFile) + /* The main db file */
55840 journalFileSize * 2 + /* The two journal files */
55841 nPathname + 1 + nUriByte + /* zFilename */
55842 nPathname + 8 + 2 /* zJournal */
55843 #ifndef SQLITE_OMIT_WAL
55844 + nPathname + 4 + 2 /* zWal */
55845 #endif
55846 );
@@ -55638,22 +55858,25 @@
55858 assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) );
55859
55860 /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */
55861 if( zPathname ){
55862 assert( nPathname>0 );
 
55863 memcpy(pPager->zFilename, zPathname, nPathname);
55864 if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUriByte);
55865 pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUriByte);
55866 memcpy(pPager->zJournal, zPathname, nPathname);
55867 memcpy(&pPager->zJournal[nPathname], "-journal", 8);
55868 sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal);
55869 #ifndef SQLITE_OMIT_WAL
55870 pPager->zWal = (char*)(pPtr += nPathname + 8 + 2);
55871 memcpy(pPager->zWal, zPathname, nPathname);
55872 memcpy(&pPager->zWal[nPathname], "-wal", 4);
55873 sqlite3FileSuffix3(pPager->zFilename, pPager->zWal);
55874 assert( sqlite3UriCount(pPager->zWal)==0 );
55875 #endif
55876 assert( sqlite3UriCount(pPager->zFilename)==nUri );
55877 assert( sqlite3UriCount(pPager->zJournal)==0 );
55878 sqlite3DbFree(0, zPathname);
55879 }
55880 pPager->pVfs = pVfs;
55881 pPager->vfsFlags = vfsFlags;
55882
@@ -63072,10 +63295,11 @@
63295 int mallocFailed; /* A memory allocation error has occurred */
63296 const char *zPfx; /* Error message prefix */
63297 int v1, v2; /* Values for up to two %d fields in zPfx */
63298 StrAccum errMsg; /* Accumulate the error message text here */
63299 u32 *heap; /* Min-heap used for analyzing cell coverage */
63300 sqlite3 *db; /* Database connection running the check */
63301 };
63302
63303 /*
63304 ** Routines to read or write a two- and four-byte big-endian integer values.
63305 */
@@ -67759,12 +67983,13 @@
67983 );
67984
67985 /* The following assert statements verify that if this is a sharable
67986 ** b-tree database, the connection is holding the required table locks,
67987 ** and that no other connection has any open cursor that conflicts with
67988 ** this lock. The iTable<1 term disables the check for corrupt schemas. */
67989 assert( hasSharedCacheTableLock(p, iTable, pKeyInfo!=0, (wrFlag?2:1))
67990 || iTable<1 );
67991 assert( wrFlag==0 || !hasReadConflicts(p, iTable) );
67992
67993 /* Assert that the caller has opened the required transaction. */
67994 assert( p->inTrans>TRANS_NONE );
67995 assert( wrFlag==0 || p->inTrans==TRANS_WRITE );
@@ -67773,13 +67998,17 @@
67998
67999 if( wrFlag ){
68000 allocateTempSpace(pBt);
68001 if( pBt->pTmpSpace==0 ) return SQLITE_NOMEM_BKPT;
68002 }
68003 if( iTable<=1 ){
68004 if( iTable<1 ){
68005 return SQLITE_CORRUPT_BKPT;
68006 }else if( btreePagecount(pBt)==0 ){
68007 assert( wrFlag==0 );
68008 iTable = 0;
68009 }
68010 }
68011
68012 /* Now that no other errors can occur, finish filling in the BtCursor
68013 ** variables and link the cursor into the BtShared list. */
68014 pCur->pgnoRoot = (Pgno)iTable;
@@ -67799,27 +68028,36 @@
68028 }
68029 pCur->pNext = pBt->pCursor;
68030 pBt->pCursor = pCur;
68031 pCur->eState = CURSOR_INVALID;
68032 return SQLITE_OK;
68033 }
68034 static int btreeCursorWithLock(
68035 Btree *p, /* The btree */
68036 int iTable, /* Root page of table to open */
68037 int wrFlag, /* 1 to write. 0 read-only */
68038 struct KeyInfo *pKeyInfo, /* First arg to comparison function */
68039 BtCursor *pCur /* Space for new cursor */
68040 ){
68041 int rc;
68042 sqlite3BtreeEnter(p);
68043 rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
68044 sqlite3BtreeLeave(p);
68045 return rc;
68046 }
68047 SQLITE_PRIVATE int sqlite3BtreeCursor(
68048 Btree *p, /* The btree */
68049 int iTable, /* Root page of table to open */
68050 int wrFlag, /* 1 to write. 0 read-only */
68051 struct KeyInfo *pKeyInfo, /* First arg to xCompare() */
68052 BtCursor *pCur /* Write new cursor here */
68053 ){
68054 if( p->sharable ){
68055 return btreeCursorWithLock(p, iTable, wrFlag, pKeyInfo, pCur);
 
68056 }else{
68057 return btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
 
 
68058 }
 
68059 }
68060
68061 /*
68062 ** Return the size of a BtCursor object in bytes.
68063 **
@@ -72853,11 +73091,11 @@
73091 **
73092 ** SQLITE_OK is returned if the operation is successfully executed.
73093 ** Otherwise, if an error is encountered (i.e. an IO error or database
73094 ** corruption) an SQLite error code is returned.
73095 */
73096 SQLITE_PRIVATE int sqlite3BtreeCount(sqlite3 *db, BtCursor *pCur, i64 *pnEntry){
73097 i64 nEntry = 0; /* Value to return in *pnEntry */
73098 int rc; /* Return code */
73099
73100 rc = moveToRoot(pCur);
73101 if( rc==SQLITE_EMPTY ){
@@ -72866,11 +73104,11 @@
73104 }
73105
73106 /* Unless an error occurs, the following loop runs one iteration for each
73107 ** page in the B-Tree structure (not including overflow pages).
73108 */
73109 while( rc==SQLITE_OK && !db->u1.isInterrupted ){
73110 int iIdx; /* Index of child node in parent */
73111 MemPage *pPage; /* Current page of the b-tree */
73112
73113 /* If this is a leaf page or the tree is not an int-key tree, then
73114 ** this page contains countable entries. Increment the entry counter
@@ -72992,10 +73230,11 @@
73230 }
73231 if( getPageReferenced(pCheck, iPage) ){
73232 checkAppendMsg(pCheck, "2nd reference to page %d", iPage);
73233 return 1;
73234 }
73235 if( pCheck->db->u1.isInterrupted ) return 1;
73236 setPageReferenced(pCheck, iPage);
73237 return 0;
73238 }
73239
73240 #ifndef SQLITE_OMIT_AUTOVACUUM
@@ -73435,10 +73674,11 @@
73674 ** allocation errors, an error message held in memory obtained from
73675 ** malloc is returned if *pnErr is non-zero. If *pnErr==0 then NULL is
73676 ** returned. If a memory allocation error occurs, NULL is returned.
73677 */
73678 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(
73679 sqlite3 *db, /* Database connection that is running the check */
73680 Btree *p, /* The btree to be checked */
73681 int *aRoot, /* An array of root pages numbers for individual trees */
73682 int nRoot, /* Number of entries in aRoot[] */
73683 int mxErr, /* Stop reporting errors after this many */
73684 int *pnErr /* Write number of errors seen to this variable */
@@ -73452,10 +73692,11 @@
73692
73693 sqlite3BtreeEnter(p);
73694 assert( p->inTrans>TRANS_NONE && pBt->inTransaction>TRANS_NONE );
73695 VVA_ONLY( nRef = sqlite3PagerRefcount(pBt->pPager) );
73696 assert( nRef>=0 );
73697 sCheck.db = db;
73698 sCheck.pBt = pBt;
73699 sCheck.pPager = pBt->pPager;
73700 sCheck.nPage = btreePagecount(sCheck.pBt);
73701 sCheck.mxErr = mxErr;
73702 sCheck.nErr = 0;
@@ -75118,19 +75359,15 @@
75359 ** otherwise.
75360 */
75361 #ifndef SQLITE_OMIT_WINDOWFUNC
75362 SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem *pAccum, Mem *pOut, FuncDef *pFunc){
75363 sqlite3_context ctx;
 
75364 assert( pFunc!=0 );
75365 assert( pFunc->xValue!=0 );
75366 assert( (pAccum->flags & MEM_Null)!=0 || pFunc==pAccum->u.pDef );
75367 assert( pAccum->db==0 || sqlite3_mutex_held(pAccum->db->mutex) );
75368 memset(&ctx, 0, sizeof(ctx));
 
 
 
75369 sqlite3VdbeMemSetNull(pOut);
75370 ctx.pOut = pOut;
75371 ctx.pMem = pAccum;
75372 ctx.pFunc = pFunc;
75373 pFunc->xValue(&ctx);
@@ -76565,10 +76802,14 @@
76802 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)
76803 */
76804 /* #include "sqliteInt.h" */
76805 /* #include "vdbeInt.h" */
76806
76807 /* Forward references */
76808 static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef);
76809 static void vdbeFreeOpArray(sqlite3 *, Op *, int);
76810
76811 /*
76812 ** Create a new virtual database engine.
76813 */
76814 SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){
76815 sqlite3 *db = pParse->db;
@@ -76591,10 +76832,17 @@
76832 assert( p->nOpAlloc==0 );
76833 assert( pParse->szOpAlloc==0 );
76834 sqlite3VdbeAddOp2(p, OP_Init, 0, 1);
76835 return p;
76836 }
76837
76838 /*
76839 ** Return the Parse object that owns a Vdbe object.
76840 */
76841 SQLITE_PRIVATE Parse *sqlite3VdbeParser(Vdbe *p){
76842 return p->pParse;
76843 }
76844
76845 /*
76846 ** Change the error string stored in Vdbe.zErrMsg
76847 */
76848 SQLITE_PRIVATE void sqlite3VdbeError(Vdbe *p, const char *zFormat, ...){
@@ -76672,11 +76920,11 @@
76920 pA->pPrev = pB->pPrev;
76921 pB->pPrev = pTmp;
76922 zTmp = pA->zSql;
76923 pA->zSql = pB->zSql;
76924 pB->zSql = zTmp;
76925 #ifdef SQLITE_ENABLE_NORMALIZE
76926 zTmp = pA->zNormSql;
76927 pA->zNormSql = pB->zNormSql;
76928 pB->zNormSql = zTmp;
76929 #endif
76930 pB->expmask = pA->expmask;
@@ -76870,10 +77118,53 @@
77118 ){
77119 int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);
77120 sqlite3VdbeChangeP4(p, addr, zP4, p4type);
77121 return addr;
77122 }
77123
77124 /*
77125 ** Add an OP_Function or OP_PureFunc opcode.
77126 **
77127 ** The eCallCtx argument is information (typically taken from Expr.op2)
77128 ** that describes the calling context of the function. 0 means a general
77129 ** function call. NC_IsCheck means called by a check constraint,
77130 ** NC_IdxExpr means called as part of an index expression. NC_PartIdx
77131 ** means in the WHERE clause of a partial index. NC_GenCol means called
77132 ** while computing a generated column value. 0 is the usual case.
77133 */
77134 SQLITE_PRIVATE int sqlite3VdbeAddFunctionCall(
77135 Parse *pParse, /* Parsing context */
77136 int p1, /* Constant argument mask */
77137 int p2, /* First argument register */
77138 int p3, /* Register into which results are written */
77139 int nArg, /* Number of argument */
77140 const FuncDef *pFunc, /* The function to be invoked */
77141 int eCallCtx /* Calling context */
77142 ){
77143 Vdbe *v = pParse->pVdbe;
77144 int nByte;
77145 int addr;
77146 sqlite3_context *pCtx;
77147 assert( v );
77148 nByte = sizeof(*pCtx) + (nArg-1)*sizeof(sqlite3_value*);
77149 pCtx = sqlite3DbMallocRawNN(pParse->db, nByte);
77150 if( pCtx==0 ){
77151 assert( pParse->db->mallocFailed );
77152 freeEphemeralFunction(pParse->db, (FuncDef*)pFunc);
77153 return 0;
77154 }
77155 pCtx->pOut = 0;
77156 pCtx->pFunc = (FuncDef*)pFunc;
77157 pCtx->pVdbe = 0;
77158 pCtx->isError = 0;
77159 pCtx->argc = nArg;
77160 pCtx->iOp = sqlite3VdbeCurrentAddr(v);
77161 addr = sqlite3VdbeAddOp4(v, eCallCtx ? OP_PureFunc : OP_Function,
77162 p1, p2, p3, (char*)pCtx, P4_FUNCCTX);
77163 sqlite3VdbeChangeP5(v, eCallCtx & NC_SelfRef);
77164 return addr;
77165 }
77166
77167 /*
77168 ** Add an opcode that includes the p4 value with a P4_INT64 or
77169 ** P4_REAL type.
77170 */
@@ -77190,11 +77481,11 @@
77481
77482 while( (pOp = opIterNext(&sIter))!=0 ){
77483 int opcode = pOp->opcode;
77484 if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
77485 || opcode==OP_VDestroy
77486 || (opcode==OP_ParseSchema && pOp->p4.z==0)
77487 || ((opcode==OP_Halt || opcode==OP_HaltIfNull)
77488 && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
77489 ){
77490 hasAbort = 1;
77491 break;
@@ -77563,22 +77854,20 @@
77854 if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){
77855 sqlite3DbFreeNN(db, pDef);
77856 }
77857 }
77858
 
 
77859 /*
77860 ** Delete a P4 value if necessary.
77861 */
77862 static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){
77863 if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
77864 sqlite3DbFreeNN(db, p);
77865 }
77866 static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){
77867 freeEphemeralFunction(db, p->pFunc);
77868 sqlite3DbFreeNN(db, p);
77869 }
77870 static void freeP4(sqlite3 *db, int p4type, void *p4){
77871 assert( db );
77872 switch( p4type ){
77873 case P4_FUNCCTX: {
@@ -77647,10 +77936,17 @@
77936 */
77937 SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){
77938 p->pNext = pVdbe->pProgram;
77939 pVdbe->pProgram = p;
77940 }
77941
77942 /*
77943 ** Return true if the given Vdbe has any SubPrograms.
77944 */
77945 SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe *pVdbe){
77946 return pVdbe->pProgram!=0;
77947 }
77948
77949 /*
77950 ** Change the opcode at addr into OP_Noop
77951 */
77952 SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe *p, int addr){
@@ -78073,17 +78369,15 @@
78369 case P4_FUNCDEF: {
78370 FuncDef *pDef = pOp->p4.pFunc;
78371 sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg);
78372 break;
78373 }
 
78374 case P4_FUNCCTX: {
78375 FuncDef *pDef = pOp->p4.pCtx->pFunc;
78376 sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg);
78377 break;
78378 }
 
78379 case P4_INT64: {
78380 sqlite3_str_appendf(&x, "%lld", *pOp->p4.pI64);
78381 break;
78382 }
78383 case P4_INT32: {
@@ -78773,12 +79067,30 @@
79067 assert( x.nFree>=0 );
79068 assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) );
79069
79070 resolveP2Values(p, &nArg);
79071 p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);
79072 if( pParse->explain ){
79073 static const char * const azColName[] = {
79074 "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment",
79075 "id", "parent", "notused", "detail"
79076 };
79077 int iFirst, mx, i;
79078 if( nMem<10 ) nMem = 10;
79079 if( pParse->explain==2 ){
79080 sqlite3VdbeSetNumCols(p, 4);
79081 iFirst = 8;
79082 mx = 12;
79083 }else{
79084 sqlite3VdbeSetNumCols(p, 8);
79085 iFirst = 0;
79086 mx = 8;
79087 }
79088 for(i=iFirst; i<mx; i++){
79089 sqlite3VdbeSetColName(p, i-iFirst, COLNAME_NAME,
79090 azColName[i], SQLITE_STATIC);
79091 }
79092 }
79093 p->expired = 0;
79094
79095 /* Memory for registers, parameters, cursor, etc, is allocated in one or two
79096 ** passes. On the first pass, we try to reuse unused memory at the
@@ -79124,11 +79436,11 @@
79436 int retryCount = 0;
79437 int nMainFile;
79438
79439 /* Select a master journal file name */
79440 nMainFile = sqlite3Strlen30(zMainFile);
79441 zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XXz%c%c", zMainFile, 0, 0);
79442 if( zMaster==0 ) return SQLITE_NOMEM_BKPT;
79443 do {
79444 u32 iRandom;
79445 if( retryCount ){
79446 if( retryCount>100 ){
@@ -81475,17 +81787,29 @@
81787 ** throw an error if it is given inputs that would make it non-deterministic.
81788 ** This routine is invoked by date/time functions that use non-deterministic
81789 ** features such as 'now'.
81790 */
81791 SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){
81792 const VdbeOp *pOp;
81793 #ifdef SQLITE_ENABLE_STAT4
81794 if( pCtx->pVdbe==0 ) return 1;
81795 #endif
81796 pOp = pCtx->pVdbe->aOp + pCtx->iOp;
81797 if( pOp->opcode==OP_PureFunc ){
81798 const char *zContext;
81799 char *zMsg;
81800 if( pOp->p5 & NC_IsCheck ){
81801 zContext = "a CHECK constraint";
81802 }else if( pOp->p5 & NC_GenCol ){
81803 zContext = "a generated column";
81804 }else{
81805 zContext = "an index";
81806 }
81807 zMsg = sqlite3_mprintf("non-deterministic use of %s() in %s",
81808 pCtx->pFunc->zName, zContext);
81809 sqlite3_result_error(pCtx, zMsg, -1);
81810 sqlite3_free(zMsg);
81811 return 0;
81812 }
81813 return 1;
81814 }
81815
@@ -83428,11 +83752,11 @@
83752 if( !p || p->op==SQLITE_INSERT ){
83753 rc = SQLITE_MISUSE_BKPT;
83754 goto preupdate_old_out;
83755 }
83756 if( p->pPk ){
83757 iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
83758 }
83759 if( iIdx>=p->pCsr->nField || iIdx<0 ){
83760 rc = SQLITE_RANGE;
83761 goto preupdate_old_out;
83762 }
@@ -83518,11 +83842,11 @@
83842 if( !p || p->op==SQLITE_DELETE ){
83843 rc = SQLITE_MISUSE_BKPT;
83844 goto preupdate_new_out;
83845 }
83846 if( p->pPk && p->op!=SQLITE_UPDATE ){
83847 iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
83848 }
83849 if( iIdx>=p->pCsr->nField || iIdx<0 ){
83850 rc = SQLITE_RANGE;
83851 goto preupdate_new_out;
83852 }
@@ -84450,11 +84774,11 @@
84774 ** May you share freely, never taking more than you give.
84775 **
84776 ******************************************************************************
84777 **
84778 ** This file contains inline asm code for retrieving "high-performance"
84779 ** counters for x86 and x86_64 class CPUs.
84780 */
84781 #ifndef SQLITE_HWTIME_H
84782 #define SQLITE_HWTIME_H
84783
84784 /*
@@ -84461,12 +84785,13 @@
84785 ** The following routine only works on pentium-class (or newer) processors.
84786 ** It uses the RDTSC opcode to read the cycle count value out of the
84787 ** processor and returns that value. This can be used for high-res
84788 ** profiling.
84789 */
84790 #if !defined(__STRICT_ANSI__) && \
84791 (defined(__GNUC__) || defined(_MSC_VER)) && \
84792 (defined(i386) || defined(__i386__) || defined(_M_IX86))
84793
84794 #if defined(__GNUC__)
84795
84796 __inline__ sqlite_uint64 sqlite3Hwtime(void){
84797 unsigned int lo, hi;
@@ -84483,19 +84808,19 @@
84808 }
84809 }
84810
84811 #endif
84812
84813 #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__))
84814
84815 __inline__ sqlite_uint64 sqlite3Hwtime(void){
84816 unsigned long val;
84817 __asm__ __volatile__ ("rdtsc" : "=A" (val));
84818 return val;
84819 }
84820
84821 #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__))
84822
84823 __inline__ sqlite_uint64 sqlite3Hwtime(void){
84824 unsigned long long retval;
84825 unsigned long junk;
84826 __asm__ __volatile__ ("\n\
@@ -84508,18 +84833,17 @@
84833 return retval;
84834 }
84835
84836 #else
84837
 
 
84838 /*
84839 ** asm() is needed for hardware timing support. Without asm(),
84840 ** disable the sqlite3Hwtime() routine.
84841 **
84842 ** sqlite3Hwtime() is only used for some obscure debugging
84843 ** and analysis configurations, not in any deliverable, so this
84844 ** should not be a great loss.
84845 */
84846 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
84847
84848 #endif
84849
@@ -87081,15 +87405,15 @@
87405
87406 assert( p->apCsr[pOp->p1]->eCurType==CURTYPE_BTREE );
87407 pCrsr = p->apCsr[pOp->p1]->uc.pCursor;
87408 assert( pCrsr );
87409 nEntry = 0; /* Not needed. Only used to silence a warning. */
87410 rc = sqlite3BtreeCount(db, pCrsr, &nEntry);
87411 if( rc ) goto abort_due_to_error;
87412 pOut = out2Prerelease(p, pOp);
87413 pOut->u.i = nEntry;
87414 goto check_for_interrupt;
87415 }
87416 #endif
87417
87418 /* Opcode: Savepoint P1 * * P4 *
87419 **
@@ -87313,11 +87637,10 @@
87637 p->pc = (int)(pOp - aOp);
87638 db->autoCommit = (u8)(1-desiredAutoCommit);
87639 p->rc = rc = SQLITE_BUSY;
87640 goto vdbe_return;
87641 }
 
87642 sqlite3CloseSavepoints(db);
87643 if( p->rc==SQLITE_OK ){
87644 rc = SQLITE_DONE;
87645 }else{
87646 rc = SQLITE_ERROR;
@@ -87394,11 +87717,12 @@
87717 goto vdbe_return;
87718 }
87719 goto abort_due_to_error;
87720 }
87721
87722 if( p->usesStmtJournal
87723 && pOp->p2
87724 && (db->autoCommit==0 || db->nVdbeRead>1)
87725 ){
87726 assert( sqlite3BtreeIsInTrans(pBt) );
87727 if( p->iStatement==0 ){
87728 assert( db->nStatement>=0 && db->nSavepoint>=0 );
@@ -88476,27 +88800,31 @@
88800 u64 iKey;
88801
88802 pIn3 = &aMem[pOp->p3];
88803 testcase( pIn3->flags & MEM_Int );
88804 testcase( pIn3->flags & MEM_IntReal );
88805 testcase( pIn3->flags & MEM_Real );
88806 testcase( (pIn3->flags & (MEM_Str|MEM_Int))==MEM_Str );
88807 if( (pIn3->flags & (MEM_Int|MEM_IntReal))==0 ){
88808 /* If pIn3->u.i does not contain an integer, compute iKey as the
88809 ** integer value of pIn3. Jump to P2 if pIn3 cannot be converted
88810 ** into an integer without loss of information. Take care to avoid
88811 ** changing the datatype of pIn3, however, as it is used by other
88812 ** parts of the prepared statement. */
88813 Mem x = pIn3[0];
88814 applyAffinity(&x, SQLITE_AFF_NUMERIC, encoding);
88815 if( (x.flags & MEM_Int)==0 ) goto jump_to_p2;
88816 iKey = x.u.i;
88817 goto notExistsWithKey;
88818 }
88819 /* Fall through into OP_NotExists */
88820 case OP_NotExists: /* jump, in3 */
88821 pIn3 = &aMem[pOp->p3];
88822 assert( (pIn3->flags & MEM_Int)!=0 || pOp->opcode==OP_SeekRowid );
88823 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
88824 iKey = pIn3->u.i;
88825 notExistsWithKey:
88826 pC = p->apCsr[pOp->p1];
88827 assert( pC!=0 );
88828 #ifdef SQLITE_DEBUG
88829 if( pOp->opcode==OP_SeekRowid ) pC->seekOp = OP_SeekRowid;
88830 #endif
@@ -88503,11 +88831,10 @@
88831 assert( pC->isTable );
88832 assert( pC->eCurType==CURTYPE_BTREE );
88833 pCrsr = pC->uc.pCursor;
88834 assert( pCrsr!=0 );
88835 res = 0;
 
88836 rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res);
88837 assert( rc==SQLITE_OK || res==0 );
88838 pC->movetoTarget = iKey; /* Used by OP_Delete */
88839 pC->nullRow = 0;
88840 pC->cacheStatus = CACHE_STALE;
@@ -90038,11 +90365,11 @@
90365 assert( (pnErr->flags & MEM_Int)!=0 );
90366 assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
90367 pIn1 = &aMem[pOp->p1];
90368 assert( pOp->p5<db->nDb );
90369 assert( DbMaskTest(p->btreeMask, pOp->p5) );
90370 z = sqlite3BtreeIntegrityCheck(db, db->aDb[pOp->p5].pBt, &aRoot[1], nRoot,
90371 (int)pnErr->u.i+1, &nErr);
90372 sqlite3VdbeMemSetNull(pIn1);
90373 if( nErr==0 ){
90374 assert( z==0 );
90375 }else if( z==0 ){
@@ -90051,11 +90378,11 @@
90378 pnErr->u.i -= nErr-1;
90379 sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free);
90380 }
90381 UPDATE_MAX_BLOBSIZE(pIn1);
90382 sqlite3VdbeChangeEncoding(pIn1, encoding);
90383 goto check_for_interrupt;
90384 }
90385 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
90386
90387 /* Opcode: RowSetAdd P1 P2 * * *
90388 ** Synopsis: rowset(P1)=r[P2]
@@ -91377,76 +91704,56 @@
91704 pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);
91705 break;
91706 }
91707 #endif
91708
91709 /* Opcode: Function P1 P2 P3 P4 *
91710 ** Synopsis: r[P3]=func(r[P2@P5])
91711 **
91712 ** Invoke a user function (P4 is a pointer to an sqlite3_context object that
91713 ** contains a pointer to the function to be run) with arguments taken
91714 ** from register P2 and successors. The number of arguments is in
91715 ** the sqlite3_context object that P4 points to.
91716 ** The result of the function is stored
91717 ** in register P3. Register P3 must not be one of the function inputs.
91718 **
91719 ** P1 is a 32-bit bitmask indicating whether or not each argument to the
91720 ** function was determined to be constant at compile time. If the first
91721 ** argument was constant then bit 0 of P1 is set. This is used to determine
91722 ** whether meta data associated with a user function argument using the
91723 ** sqlite3_set_auxdata() API may be safely retained until the next
91724 ** invocation of this opcode.
91725 **
91726 ** See also: AggStep, AggFinal, PureFunc
91727 */
91728 /* Opcode: PureFunc P1 P2 P3 P4 *
91729 ** Synopsis: r[P3]=func(r[P2@P5])
91730 **
91731 ** Invoke a user function (P4 is a pointer to an sqlite3_context object that
91732 ** contains a pointer to the function to be run) with arguments taken
91733 ** from register P2 and successors. The number of arguments is in
91734 ** the sqlite3_context object that P4 points to.
91735 ** The result of the function is stored
91736 ** in register P3. Register P3 must not be one of the function inputs.
91737 **
91738 ** P1 is a 32-bit bitmask indicating whether or not each argument to the
91739 ** function was determined to be constant at compile time. If the first
91740 ** argument was constant then bit 0 of P1 is set. This is used to determine
91741 ** whether meta data associated with a user function argument using the
91742 ** sqlite3_set_auxdata() API may be safely retained until the next
91743 ** invocation of this opcode.
91744 **
91745 ** This opcode works exactly like OP_Function. The only difference is in
91746 ** its name. This opcode is used in places where the function must be
91747 ** purely non-deterministic. Some built-in date/time functions can be
91748 ** either determinitic of non-deterministic, depending on their arguments.
91749 ** When those function are used in a non-deterministic way, they will check
91750 ** to see if they were called using OP_PureFunc instead of OP_Function, and
91751 ** if they were, they throw an error.
91752 **
91753 ** See also: AggStep, AggFinal, Function
91754 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91755 case OP_PureFunc: /* group */
91756 case OP_Function: { /* group */
91757 int i;
91758 sqlite3_context *pCtx;
91759
@@ -91457,13 +91764,15 @@
91764 ** might change from one evaluation to the next. The next block of code
91765 ** checks to see if the register array has changed, and if so it
91766 ** reinitializes the relavant parts of the sqlite3_context object */
91767 pOut = &aMem[pOp->p3];
91768 if( pCtx->pOut != pOut ){
91769 pCtx->pVdbe = p;
91770 pCtx->pOut = pOut;
91771 for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];
91772 }
91773 assert( pCtx->pVdbe==p );
91774
91775 memAboutToChange(p, pOut);
91776 #ifdef SQLITE_DEBUG
91777 for(i=0; i<pCtx->argc; i++){
91778 assert( memIsValid(pCtx->argv[i]) );
@@ -93668,24 +93977,20 @@
93977 ** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if
93978 ** an error occurs.
93979 */
93980 static int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){
93981 int i;
 
93982 SorterRecord *p;
93983 int rc;
93984 SorterRecord *aSlot[64];
93985
93986 rc = vdbeSortAllocUnpacked(pTask);
93987 if( rc!=SQLITE_OK ) return rc;
93988
93989 p = pList->pList;
93990 pTask->xCompare = vdbeSorterGetCompare(pTask->pSorter);
93991 memset(aSlot, 0, sizeof(aSlot));
 
 
 
 
93992
93993 while( p ){
93994 SorterRecord *pNext;
93995 if( pList->aMemory ){
93996 if( (u8*)p==pList->aMemory ){
@@ -93706,17 +94011,16 @@
94011 aSlot[i] = p;
94012 p = pNext;
94013 }
94014
94015 p = 0;
94016 for(i=0; i<ArraySize(aSlot); i++){
94017 if( aSlot[i]==0 ) continue;
94018 p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i];
94019 }
94020 pList->pList = p;
94021
 
94022 assert( pTask->pUnpacked->errCode==SQLITE_OK
94023 || pTask->pUnpacked->errCode==SQLITE_NOMEM
94024 );
94025 return pTask->pUnpacked->errCode;
94026 }
@@ -96097,11 +96401,11 @@
96401 ** Perhaps the name is a reference to the ROWID
96402 */
96403 if( cnt==0
96404 && cntTab==1
96405 && pMatch
96406 && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0
96407 && sqlite3IsRowid(zCol)
96408 && VisibleRowid(pMatch->pTab)
96409 ){
96410 cnt = 1;
96411 pExpr->iColumn = -1;
@@ -96308,17 +96612,20 @@
96612 Parse *pParse, /* Leave error message here */
96613 NameContext *pNC, /* The name context */
96614 const char *zMsg, /* Type of error */
96615 int validMask /* Set of contexts for which prohibited */
96616 ){
96617 assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 );
96618 if( (pNC->ncFlags & validMask)!=0 ){
96619 const char *zIn = "partial index WHERE clauses";
96620 if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions";
96621 #ifndef SQLITE_OMIT_CHECK
96622 else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints";
96623 #endif
96624 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
96625 else if( pNC->ncFlags & NC_GenCol ) zIn = "generated columns";
96626 #endif
96627 sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn);
96628 }
96629 }
96630
96631 /*
@@ -96406,11 +96713,11 @@
96713 zDb = 0;
96714 zTable = 0;
96715 zColumn = pExpr->u.zToken;
96716 }else{
96717 Expr *pLeft = pExpr->pLeft;
96718 notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr|NC_GenCol);
96719 pRight = pExpr->pRight;
96720 if( pRight->op==TK_ID ){
96721 zDb = 0;
96722 }else{
96723 assert( pRight->op==TK_DOT );
@@ -96495,19 +96802,22 @@
96802 }
96803 #endif
96804 if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){
96805 /* For the purposes of the EP_ConstFunc flag, date and time
96806 ** functions and other functions that change slowly are considered
96807 ** constant because they are constant for the duration of one query.
96808 ** This allows them to be factored out of inner loops. */
96809 ExprSetProperty(pExpr,EP_ConstFunc);
96810 }
96811 if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){
96812 /* Date/time functions that use 'now', and other functions like
96813 ** sqlite_version() that might change over time cannot be used
96814 ** in an index. */
96815 notValid(pParse, pNC, "non-deterministic functions", NC_SelfRef);
96816 }else{
96817 assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
96818 pExpr->op2 = pNC->ncFlags & NC_SelfRef;
96819 }
96820 if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0
96821 && pParse->nested==0
96822 && sqlite3Config.bInternalFunctions==0
96823 ){
@@ -96647,11 +96957,12 @@
96957 #endif
96958 case TK_IN: {
96959 testcase( pExpr->op==TK_IN );
96960 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
96961 int nRef = pNC->nRef;
96962 notValid(pParse, pNC, "subqueries",
96963 NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol);
96964 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
96965 assert( pNC->nRef>=nRef );
96966 if( nRef!=pNC->nRef ){
96967 ExprSetProperty(pExpr, EP_VarSelect);
96968 pNC->ncFlags |= NC_VarSelect;
@@ -96658,11 +96969,12 @@
96969 }
96970 }
96971 break;
96972 }
96973 case TK_VARIABLE: {
96974 notValid(pParse, pNC, "parameters",
96975 NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol);
96976 break;
96977 }
96978 case TK_IS:
96979 case TK_ISNOT: {
96980 Expr *pRight = sqlite3ExprSkipCollateAndLikely(pExpr->pRight);
@@ -97467,34 +97779,38 @@
97779
97780 /*
97781 ** Resolve names in expressions that can only reference a single table
97782 ** or which cannot reference any tables at all. Examples:
97783 **
97784 ** "type" flag
97785 ** ------------
97786 ** (1) CHECK constraints NC_IsCheck
97787 ** (2) WHERE clauses on partial indices NC_PartIdx
97788 ** (3) Expressions in indexes on expressions NC_IdxExpr
97789 ** (4) Expression arguments to VACUUM INTO. 0
97790 ** (5) GENERATED ALWAYS as expressions NC_GenCol
97791 **
97792 ** In all cases except (4), the Expr.iTable value for Expr.op==TK_COLUMN
97793 ** nodes of the expression is set to -1 and the Expr.iColumn value is
97794 ** set to the column number. In case (4), TK_COLUMN nodes cause an error.
97795 **
97796 ** Any errors cause an error message to be set in pParse.
97797 */
97798 SQLITE_PRIVATE int sqlite3ResolveSelfReference(
97799 Parse *pParse, /* Parsing context */
97800 Table *pTab, /* The table being referenced, or NULL */
97801 int type, /* NC_IsCheck, NC_PartIdx, NC_IdxExpr, NC_GenCol, or 0 */
97802 Expr *pExpr, /* Expression to resolve. May be NULL. */
97803 ExprList *pList /* Expression list to resolve. May be NULL. */
97804 ){
97805 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
97806 NameContext sNC; /* Name context for pParse->pNewTable */
97807 int rc;
97808
97809 assert( type==0 || pTab!=0 );
97810 assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr
97811 || type==NC_GenCol || pTab==0 );
97812 memset(&sNC, 0, sizeof(sNC));
97813 memset(&sSrc, 0, sizeof(sSrc));
97814 if( pTab ){
97815 sSrc.nSrc = 1;
97816 sSrc.a[0].zName = pTab->zName;
@@ -97581,10 +97897,13 @@
97897 assert( pExpr->pLeft->flags&EP_xIsSelect );
97898 return sqlite3ExprAffinity(
97899 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
97900 );
97901 }
97902 if( op==TK_VECTOR ){
97903 return sqlite3ExprAffinity(pExpr->x.pList->a[0].pExpr);
97904 }
97905 return pExpr->affExpr;
97906 }
97907
97908 /*
97909 ** Set the collating sequence for expression pExpr to be the collating
@@ -97682,10 +98001,14 @@
98001 break;
98002 }
98003 if( op==TK_CAST || op==TK_UPLUS ){
98004 p = p->pLeft;
98005 continue;
98006 }
98007 if( op==TK_VECTOR ){
98008 p = p->x.pList->a[0].pExpr;
98009 continue;
98010 }
98011 if( op==TK_COLLATE ){
98012 pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken);
98013 break;
98014 }
@@ -97694,16 +98017,16 @@
98017 p = p->pLeft;
98018 }else{
98019 Expr *pNext = p->pRight;
98020 /* The Expr.x union is never used at the same time as Expr.pRight */
98021 assert( p->x.pList==0 || p->pRight==0 );
98022 if( p->x.pList!=0
98023 && !db->mallocFailed
98024 && ALWAYS(!ExprHasProperty(p, EP_xIsSelect))
98025 ){
98026 int i;
98027 for(i=0; i<p->x.pList->nExpr; i++){
98028 if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){
98029 pNext = p->x.pList->a[i].pExpr;
98030 break;
98031 }
98032 }
@@ -97846,10 +98169,26 @@
98169 pColl = sqlite3ExprCollSeq(pParse, pRight);
98170 }
98171 }
98172 return pColl;
98173 }
98174
98175 /* Expresssion p is a comparison operator. Return a collation sequence
98176 ** appropriate for the comparison operator.
98177 **
98178 ** This is normally just a wrapper around sqlite3BinaryCompareCollSeq().
98179 ** However, if the OP_Commuted flag is set, then the order of the operands
98180 ** is reversed in the sqlite3BinaryCompareCollSeq() call so that the
98181 ** correct collating sequence is found.
98182 */
98183 SQLITE_PRIVATE CollSeq *sqlite3ExprCompareCollSeq(Parse *pParse, Expr *p){
98184 if( ExprHasProperty(p, EP_Commuted) ){
98185 return sqlite3BinaryCompareCollSeq(pParse, p->pRight, p->pLeft);
98186 }else{
98187 return sqlite3BinaryCompareCollSeq(pParse, p->pLeft, p->pRight);
98188 }
98189 }
98190
98191 /*
98192 ** Generate code for a comparison operator.
98193 */
98194 static int codeCompare(
@@ -97857,17 +98196,22 @@
98196 Expr *pLeft, /* The left operand */
98197 Expr *pRight, /* The right operand */
98198 int opcode, /* The comparison opcode */
98199 int in1, int in2, /* Register holding operands */
98200 int dest, /* Jump here if true. */
98201 int jumpIfNull, /* If true, jump if either operand is NULL */
98202 int isCommuted /* The comparison has been commuted */
98203 ){
98204 int p5;
98205 int addr;
98206 CollSeq *p4;
98207
98208 if( isCommuted ){
98209 p4 = sqlite3BinaryCompareCollSeq(pParse, pRight, pLeft);
98210 }else{
98211 p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
98212 }
98213 p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
98214 addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
98215 (void*)p4, P4_COLLSEQ);
98216 sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
98217 return addr;
@@ -98074,10 +98418,11 @@
98418 int i;
98419 int regLeft = 0;
98420 int regRight = 0;
98421 u8 opx = op;
98422 int addrDone = sqlite3VdbeMakeLabel(pParse);
98423 int isCommuted = ExprHasProperty(pExpr,EP_Commuted);
98424
98425 if( nLeft!=sqlite3ExprVectorSize(pRight) ){
98426 sqlite3ErrorMsg(pParse, "row value misused");
98427 return;
98428 }
@@ -98103,11 +98448,11 @@
98448 Expr *pL, *pR;
98449 int r1, r2;
98450 assert( i>=0 && i<nLeft );
98451 r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);
98452 r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);
98453 codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5, isCommuted);
98454 testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
98455 testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
98456 testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
98457 testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
98458 testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
@@ -100878,35 +101223,77 @@
101223 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
101224 iTabCol, regOut);
101225 }
101226 }
101227
101228 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
101229 /*
101230 ** Generate code that will compute the value of generated column pCol
101231 ** and store the result in register regOut
101232 */
101233 SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(
101234 Parse *pParse,
101235 Column *pCol,
101236 int regOut
101237 ){
101238 sqlite3ExprCode(pParse, pCol->pDflt, regOut);
101239 if( pCol->affinity>=SQLITE_AFF_TEXT ){
101240 sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, regOut, 1, 0,
101241 &pCol->affinity, 1);
101242 }
101243 }
101244 #endif /* SQLITE_OMIT_GENERATED_COLUMNS */
101245
101246 /*
101247 ** Generate code to extract the value of the iCol-th column of a table.
101248 */
101249 SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(
101250 Vdbe *v, /* Parsing context */
101251 Table *pTab, /* The table containing the value */
101252 int iTabCur, /* The table cursor. Or the PK cursor for WITHOUT ROWID */
101253 int iCol, /* Index of the column to extract */
101254 int regOut /* Extract the value into this register */
101255 ){
101256 Column *pCol;
101257 assert( v!=0 );
101258 if( pTab==0 ){
101259 sqlite3VdbeAddOp3(v, OP_Column, iTabCur, iCol, regOut);
101260 return;
101261 }
101262 if( iCol<0 || iCol==pTab->iPKey ){
101263 sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);
101264 }else{
101265 int op;
101266 int x;
101267 if( IsVirtual(pTab) ){
101268 op = OP_VColumn;
101269 x = iCol;
101270 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
101271 }else if( (pCol = &pTab->aCol[iCol])->colFlags & COLFLAG_VIRTUAL ){
101272 Parse *pParse = sqlite3VdbeParser(v);
101273 if( pCol->colFlags & COLFLAG_BUSY ){
101274 sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pCol->zName);
101275 }else{
101276 int savedSelfTab = pParse->iSelfTab;
101277 pCol->colFlags |= COLFLAG_BUSY;
101278 pParse->iSelfTab = iTabCur+1;
101279 sqlite3ExprCodeGeneratedColumn(pParse, pCol, regOut);
101280 pParse->iSelfTab = savedSelfTab;
101281 pCol->colFlags &= ~COLFLAG_BUSY;
101282 }
101283 return;
101284 #endif
101285 }else if( !HasRowid(pTab) ){
101286 testcase( iCol!=sqlite3TableColumnToStorage(pTab, iCol) );
101287 x = sqlite3TableColumnToIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
101288 op = OP_Column;
101289 }else{
101290 x = sqlite3TableColumnToStorage(pTab,iCol);
101291 testcase( x!=iCol );
101292 op = OP_Column;
101293 }
101294 sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);
 
 
101295 sqlite3ColumnDefault(v, pTab, iCol, regOut);
101296 }
101297 }
101298
101299 /*
@@ -100922,15 +101309,14 @@
101309 int iColumn, /* Index of the table column */
101310 int iTable, /* The cursor pointing to the table */
101311 int iReg, /* Store results here */
101312 u8 p5 /* P5 value for OP_Column + FLAGS */
101313 ){
101314 assert( pParse->pVdbe!=0 );
101315 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pTab, iTable, iColumn, iReg);
 
101316 if( p5 ){
101317 sqlite3VdbeChangeP5(pParse->pVdbe, p5);
101318 }
101319 return iReg;
101320 }
101321
101322 /*
@@ -101062,23 +101448,50 @@
101448 }
101449 return iReg;
101450 }
101451 if( iTab<0 ){
101452 if( pParse->iSelfTab<0 ){
101453 /* Other columns in the same row for CHECK constraints or
101454 ** generated columns or for inserting into partial index.
101455 ** The row is unpacked into registers beginning at
101456 ** 0-(pParse->iSelfTab). The rowid (if any) is in a register
101457 ** immediately prior to the first column.
101458 */
101459 Column *pCol;
101460 Table *pTab = pExpr->y.pTab;
101461 int iSrc;
101462 int iCol = pExpr->iColumn;
101463 assert( pTab!=0 );
101464 assert( iCol>=XN_ROWID );
101465 assert( iCol<pExpr->y.pTab->nCol );
101466 if( iCol<0 ){
101467 return -1-pParse->iSelfTab;
101468 }
101469 pCol = pTab->aCol + iCol;
101470 testcase( iCol!=sqlite3TableColumnToStorage(pTab,iCol) );
101471 iSrc = sqlite3TableColumnToStorage(pTab, iCol) - pParse->iSelfTab;
101472 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
101473 if( pCol->colFlags & COLFLAG_GENERATED ){
101474 if( pCol->colFlags & COLFLAG_BUSY ){
101475 sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"",
101476 pCol->zName);
101477 return 0;
101478 }
101479 pCol->colFlags |= COLFLAG_BUSY;
101480 if( pCol->colFlags & COLFLAG_NOTAVAIL ){
101481 sqlite3ExprCodeGeneratedColumn(pParse, pCol, iSrc);
101482 }
101483 pCol->colFlags &= ~(COLFLAG_BUSY|COLFLAG_NOTAVAIL);
101484 return iSrc;
101485 }else
101486 #endif /* SQLITE_OMIT_GENERATED_COLUMNS */
101487 if( pCol->affinity==SQLITE_AFF_REAL ){
101488 sqlite3VdbeAddOp2(v, OP_SCopy, iSrc, target);
101489 sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
101490 return target;
101491 }else{
101492 return iSrc;
101493 }
101494 }else{
101495 /* Coding an expression that is part of an index where column names
101496 ** in the index refer to the table to which the index belongs */
101497 iTab = pParse->iSelfTab - 1;
@@ -101173,11 +101586,12 @@
101586 codeVectorCompare(pParse, pExpr, target, op, p5);
101587 }else{
101588 r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);
101589 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
101590 codeCompare(pParse, pLeft, pExpr->pRight, op,
101591 r1, r2, inReg, SQLITE_STOREP2 | p5,
101592 ExprHasProperty(pExpr,EP_Commuted));
101593 assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
101594 assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
101595 assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
101596 assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
101597 assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
@@ -101442,13 +101856,12 @@
101856 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
101857 }
101858 }else
101859 #endif
101860 {
101861 sqlite3VdbeAddFunctionCall(pParse, constMask, r1, target, nFarg,
101862 pDef, pExpr->op2);
 
101863 }
101864 if( nFarg && constMask==0 ){
101865 sqlite3ReleaseTempRange(pParse, r1, nFarg);
101866 }
101867 return target;
@@ -101541,32 +101954,32 @@
101954 ** p1==0 -> old.rowid p1==3 -> new.rowid
101955 ** p1==1 -> old.a p1==4 -> new.a
101956 ** p1==2 -> old.b p1==5 -> new.b
101957 */
101958 Table *pTab = pExpr->y.pTab;
101959 int iCol = pExpr->iColumn;
101960 int p1 = pExpr->iTable * (pTab->nCol+1) + 1
101961 + (iCol>=0 ? sqlite3TableColumnToStorage(pTab, iCol) : -1);
101962
101963 assert( pExpr->iTable==0 || pExpr->iTable==1 );
101964 assert( iCol>=-1 && iCol<pTab->nCol );
101965 assert( pTab->iPKey<0 || iCol!=pTab->iPKey );
101966 assert( p1>=0 && p1<(pTab->nCol*2+2) );
101967
101968 sqlite3VdbeAddOp2(v, OP_Param, p1, target);
101969 VdbeComment((v, "r[%d]=%s.%s", target,
101970 (pExpr->iTable ? "new" : "old"),
101971 (pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[iCol].zName)
101972 ));
101973
101974 #ifndef SQLITE_OMIT_FLOATING_POINT
101975 /* If the column has REAL affinity, it may currently be stored as an
101976 ** integer. Use OP_RealAffinity to make sure it is really real.
101977 **
101978 ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to
101979 ** floating point when extracting it from the record. */
101980 if( iCol>=0 && pTab->aCol[iCol].affinity==SQLITE_AFF_REAL ){
 
 
101981 sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
101982 }
101983 #endif
101984 break;
101985 }
@@ -101795,18 +102208,14 @@
102208 */
102209 SQLITE_PRIVATE void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){
102210 int inReg;
102211
102212 assert( target>0 && target<=pParse->nMem );
102213 inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
102214 assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );
102215 if( inReg!=target && pParse->pVdbe ){
102216 sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);
 
 
 
 
102217 }
102218 }
102219
102220 /*
102221 ** Make a transient copy of expression pExpr and then code it using
@@ -101832,34 +102241,10 @@
102241 }else{
102242 sqlite3ExprCode(pParse, pExpr, target);
102243 }
102244 }
102245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102246 /*
102247 ** Generate code that pushes the value of every element of the given
102248 ** expression list into a sequence of registers beginning at target.
102249 **
102250 ** Return the number of elements evaluated. The number returned will
@@ -102093,11 +102478,11 @@
102478 if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
102479 testcase( jumpIfNull==0 );
102480 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
102481 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
102482 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
102483 r1, r2, dest, jumpIfNull, ExprHasProperty(pExpr,EP_Commuted));
102484 assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
102485 assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
102486 assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
102487 assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
102488 assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);
@@ -102268,11 +102653,11 @@
102653 if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
102654 testcase( jumpIfNull==0 );
102655 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
102656 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
102657 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
102658 r1, r2, dest, jumpIfNull,ExprHasProperty(pExpr,EP_Commuted));
102659 assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
102660 assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
102661 assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
102662 assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
102663 assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);
@@ -102454,11 +102839,12 @@
102839 if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
102840 }else if( ALWAYS(pB->u.zToken!=0) && strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
102841 return 2;
102842 }
102843 }
102844 if( (pA->flags & (EP_Distinct|EP_Commuted))
102845 != (pB->flags & (EP_Distinct|EP_Commuted)) ) return 2;
102846 if( (combinedFlags & EP_TokenOnly)==0 ){
102847 if( combinedFlags & EP_xIsSelect ) return 2;
102848 if( (combinedFlags & EP_FixedCol)==0
102849 && sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
102850 if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
@@ -102466,14 +102852,28 @@
102852 if( pA->op!=TK_STRING
102853 && pA->op!=TK_TRUEFALSE
102854 && (combinedFlags & EP_Reduced)==0
102855 ){
102856 if( pA->iColumn!=pB->iColumn ) return 2;
102857 if( pA->op2!=pB->op2 ){
102858 if( pA->op==TK_TRUTH ) return 2;
102859 if( pA->op==TK_FUNCTION && iTab<0 ){
102860 /* Ex: CREATE TABLE t1(a CHECK( a<julianday('now') ));
102861 ** INSERT INTO t1(a) VALUES(julianday('now')+10);
102862 ** Without this test, sqlite3ExprCodeAtInit() will run on the
102863 ** the julianday() of INSERT first, and remember that expression.
102864 ** Then sqlite3ExprCodeInit() will see the julianday() in the CHECK
102865 ** constraint as redundant, reusing the one from the INSERT, even
102866 ** though the julianday() in INSERT lacks the critical NC_IsCheck
102867 ** flag. See ticket [830277d9db6c3ba1] (2019-10-30)
102868 */
102869 return 2;
102870 }
102871 }
102872 if( pA->op!=TK_IN && pA->iTable!=pB->iTable && pA->iTable!=iTab ){
102873 return 2;
102874 }
102875 }
102876 }
102877 return 0;
102878 }
102879
@@ -102636,11 +103036,11 @@
103036 }
103037 return 0;
103038 }
103039
103040 /*
103041 ** This is the Expr node callback for sqlite3ExprImpliesNonNullRow().
103042 ** If the expression node requires that the table at pWalker->iCur
103043 ** have one or more non-NULL column, then set pWalker->eCode to 1 and abort.
103044 **
103045 ** This routine controls an optimization. False positives (setting
103046 ** pWalker->eCode to 1 when it should not be) are deadly, but false-negatives
@@ -102654,34 +103054,39 @@
103054 case TK_ISNOT:
103055 case TK_ISNULL:
103056 case TK_NOTNULL:
103057 case TK_IS:
103058 case TK_OR:
103059 case TK_VECTOR:
103060 case TK_CASE:
103061 case TK_IN:
103062 case TK_FUNCTION:
103063 case TK_TRUTH:
103064 testcase( pExpr->op==TK_ISNOT );
103065 testcase( pExpr->op==TK_ISNULL );
103066 testcase( pExpr->op==TK_NOTNULL );
103067 testcase( pExpr->op==TK_IS );
103068 testcase( pExpr->op==TK_OR );
103069 testcase( pExpr->op==TK_VECTOR );
103070 testcase( pExpr->op==TK_CASE );
103071 testcase( pExpr->op==TK_IN );
103072 testcase( pExpr->op==TK_FUNCTION );
103073 testcase( pExpr->op==TK_TRUTH );
103074 return WRC_Prune;
103075 case TK_COLUMN:
103076 if( pWalker->u.iCur==pExpr->iTable ){
103077 pWalker->eCode = 1;
103078 return WRC_Abort;
103079 }
103080 return WRC_Prune;
103081
103082 case TK_AND:
103083 assert( pWalker->eCode==0 );
103084 sqlite3WalkExpr(pWalker, pExpr->pLeft);
103085 if( pWalker->eCode ){
103086 pWalker->eCode = 0;
103087 sqlite3WalkExpr(pWalker, pExpr->pRight);
103088 }
103089 return WRC_Prune;
103090
103091 case TK_BETWEEN:
103092 sqlite3WalkExpr(pWalker, pExpr->pLeft);
@@ -102736,18 +103141,17 @@
103141 ** ordinary join.
103142 */
103143 SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){
103144 Walker w;
103145 p = sqlite3ExprSkipCollateAndLikely(p);
103146 if( p==0 ) return 0;
103147 if( p->op==TK_NOTNULL ){
103148 p = p->pLeft;
103149 }else{
103150 while( p->op==TK_AND ){
103151 if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1;
103152 p = p->pRight;
 
 
103153 }
103154 }
103155 w.xExprCallback = impliesNotNullRow;
103156 w.xSelectCallback = 0;
103157 w.xSelectCallback2 = 0;
@@ -102775,11 +103179,11 @@
103179 ** pWalker->u.pIdxCover->pIdx.
103180 */
103181 static int exprIdxCover(Walker *pWalker, Expr *pExpr){
103182 if( pExpr->op==TK_COLUMN
103183 && pExpr->iTable==pWalker->u.pIdxCover->iCur
103184 && sqlite3TableColumnToIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
103185 ){
103186 pWalker->eCode = 1;
103187 return WRC_Abort;
103188 }
103189 return WRC_Continue;
@@ -103201,13 +103605,12 @@
103605 ** Or, if zName is not a system table, zero is returned.
103606 */
103607 static int isAlterableTable(Parse *pParse, Table *pTab){
103608 if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7)
103609 #ifndef SQLITE_OMIT_VIRTUALTABLE
103610 || ( (pTab->tabFlags & TF_Shadow)!=0
103611 && sqlite3ReadOnlyShadowTables(pParse->db)
 
103612 )
103613 #endif
103614 ){
103615 sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);
103616 return 1;
@@ -103468,18 +103871,10 @@
103871 if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){
103872 return;
103873 }
103874 #endif
103875
 
 
 
 
 
 
 
 
103876
103877 /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.
103878 ** If there is a NOT NULL constraint, then the default value for the
103879 ** column must not be NULL.
103880 */
@@ -103489,39 +103884,53 @@
103884 }
103885 if( pNew->pIndex ){
103886 sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");
103887 return;
103888 }
103889 if( (pCol->colFlags & COLFLAG_GENERATED)==0 ){
103890 /* If the default value for the new column was specified with a
103891 ** literal NULL, then set pDflt to 0. This simplifies checking
103892 ** for an SQL NULL default below.
103893 */
103894 assert( pDflt==0 || pDflt->op==TK_SPAN );
103895 if( pDflt && pDflt->pLeft->op==TK_NULL ){
103896 pDflt = 0;
103897 }
103898 if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){
103899 sqlite3ErrorMsg(pParse,
103900 "Cannot add a REFERENCES column with non-NULL default value");
103901 return;
103902 }
103903 if( pCol->notNull && !pDflt ){
103904 sqlite3ErrorMsg(pParse,
103905 "Cannot add a NOT NULL column with default value NULL");
103906 return;
103907 }
103908
103909 /* Ensure the default expression is something that sqlite3ValueFromExpr()
103910 ** can handle (i.e. not CURRENT_TIME etc.)
103911 */
103912 if( pDflt ){
103913 sqlite3_value *pVal = 0;
103914 int rc;
103915 rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal);
103916 assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
103917 if( rc!=SQLITE_OK ){
103918 assert( db->mallocFailed == 1 );
103919 return;
103920 }
103921 if( !pVal ){
103922 sqlite3ErrorMsg(pParse,"Cannot add a column with non-constant default");
103923 return;
103924 }
103925 sqlite3ValueFree(pVal);
103926 }
103927 }else if( pCol->colFlags & COLFLAG_STORED ){
103928 sqlite3ErrorMsg(pParse, "cannot add a STORED column");
103929 return;
103930 }
103931
103932
103933 /* Modify the CREATE TABLE statement. */
103934 zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);
103935 if( zCol ){
103936 char *zEnd = &zCol[pColDef->n-1];
@@ -103605,10 +104014,11 @@
104014 }
104015 if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){
104016 goto exit_begin_add_column;
104017 }
104018
104019 sqlite3MayAbort(pParse);
104020 assert( pTab->addColOffset>0 );
104021 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
104022
104023 /* Put a copy of the Table struct in Parse.pNewTable for the
104024 ** sqlite3AddColumn() function and friends to modify. But modify
@@ -104500,10 +104910,15 @@
104910 }
104911 for(pIdx=sParse.pNewIndex; pIdx; pIdx=pIdx->pNext){
104912 sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
104913 }
104914 }
104915 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
104916 for(i=0; i<sParse.pNewTable->nCol; i++){
104917 sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt);
104918 }
104919 #endif
104920
104921 for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
104922 for(i=0; i<pFKey->nCol; i++){
104923 if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){
104924 renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]);
@@ -105757,22 +106172,21 @@
106172 0, 0, /* xValue, xInverse */
106173 "stat_get", /* zName */
106174 {0}
106175 };
106176
106177 static void callStatGet(Parse *pParse, int regStat4, int iParam, int regOut){
 
106178 #ifdef SQLITE_ENABLE_STAT4
106179 sqlite3VdbeAddOp2(pParse->pVdbe, OP_Integer, iParam, regStat4+1);
106180 #elif SQLITE_DEBUG
106181 assert( iParam==STAT_GET_STAT1 );
106182 #else
106183 UNUSED_PARAMETER( iParam );
106184 #endif
106185 assert( regOut!=regStat4 && regOut!=regStat4+1 );
106186 sqlite3VdbeAddFunctionCall(pParse, 0, regStat4, regOut, 1+IsStat4,
106187 &statGetFuncdef, 0);
106188 }
106189
106190 /*
106191 ** Generate code to do an analysis of all indices associated with
106192 ** a single table.
@@ -105936,13 +106350,12 @@
106350 #ifdef SQLITE_ENABLE_STAT4
106351 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+3);
106352 #endif
106353 sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1);
106354 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);
106355 sqlite3VdbeAddFunctionCall(pParse, 0, regStat4+1, regStat4, 2+IsStat4,
106356 &statInitFuncdef, 0);
 
106357
106358 /* Implementation of the following:
106359 **
106360 ** Rewind csr
106361 ** if eof(csr) goto end_of_scan;
@@ -106023,27 +106436,26 @@
106436 }else{
106437 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
106438 int j, k, regKey;
106439 regKey = sqlite3GetTempRange(pParse, pPk->nKeyCol);
106440 for(j=0; j<pPk->nKeyCol; j++){
106441 k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[j]);
106442 assert( k>=0 && k<pIdx->nColumn );
106443 sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, regKey+j);
106444 VdbeComment((v, "%s", pTab->aCol[pPk->aiColumn[j]].zName));
106445 }
106446 sqlite3VdbeAddOp3(v, OP_MakeRecord, regKey, pPk->nKeyCol, regRowid);
106447 sqlite3ReleaseTempRange(pParse, regKey, pPk->nKeyCol);
106448 }
106449 #endif
106450 assert( regChng==(regStat4+1) );
106451 sqlite3VdbeAddFunctionCall(pParse, 1, regStat4, regTemp, 2+IsStat4,
106452 &statPushFuncdef, 0);
 
106453 sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, addrNextRow); VdbeCoverage(v);
106454
106455 /* Add the entry to the stat1 table. */
106456 callStatGet(pParse, regStat4, STAT_GET_STAT1, regStat1);
106457 assert( "BBB"[0]==SQLITE_AFF_TEXT );
106458 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, "BBB", 0);
106459 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
106460 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regTemp, regNewRowid);
106461 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
@@ -106065,16 +106477,16 @@
106477 u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;
106478
106479 pParse->nMem = MAX(pParse->nMem, regCol+nCol);
106480
106481 addrNext = sqlite3VdbeCurrentAddr(v);
106482 callStatGet(pParse, regStat4, STAT_GET_ROWID, regSampleRowid);
106483 addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regSampleRowid);
106484 VdbeCoverage(v);
106485 callStatGet(pParse, regStat4, STAT_GET_NEQ, regEq);
106486 callStatGet(pParse, regStat4, STAT_GET_NLT, regLt);
106487 callStatGet(pParse, regStat4, STAT_GET_NDLT, regDLt);
106488 sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);
106489 VdbeCoverage(v);
106490 for(i=0; i<nCol; i++){
106491 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
106492 }
@@ -106695,13 +107107,13 @@
107107 }
107108
107109 /* Load the statistics from the sqlite_stat4 table. */
107110 #ifdef SQLITE_ENABLE_STAT4
107111 if( rc==SQLITE_OK ){
107112 DisableLookaside;
107113 rc = loadStat4(db, sInfo.zDatabase);
107114 EnableLookaside;
107115 }
107116 for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
107117 Index *pIdx = sqliteHashData(i);
107118 sqlite3_free(pIdx->aiRowEst);
107119 pIdx->aiRowEst = 0;
@@ -107120,15 +107532,12 @@
107532 sqlite3ExprCode(pParse, pDbname, regArgs+1);
107533 sqlite3ExprCode(pParse, pKey, regArgs+2);
107534
107535 assert( v || db->mallocFailed );
107536 if( v ){
107537 sqlite3VdbeAddFunctionCall(pParse, 0, regArgs+3-pFunc->nArg, regArgs+3,
107538 pFunc->nArg, pFunc, 0);
 
 
 
107539 /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this
107540 ** statement only). For DETACH, set it to false (expire all existing
107541 ** statements).
107542 */
107543 sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));
@@ -108499,17 +108908,18 @@
108908 sqlite3ErrorMsg(pParse, ""); /* corruptSchema() will supply the error */
108909 return SQLITE_ERROR;
108910 }
108911 }
108912 }else{
108913 if( (pParse->nested==0 && 0==sqlite3StrNICmp(zName, "sqlite_", 7))
108914 || (sqlite3ReadOnlyShadowTables(db) && sqlite3ShadowTableName(db, zName))
108915 ){
108916 sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s",
108917 zName);
108918 return SQLITE_ERROR;
108919 }
108920
108921 }
108922 return SQLITE_OK;
108923 }
108924
108925 /*
@@ -108520,20 +108930,98 @@
108930 for(p=pTab->pIndex; p && !IsPrimaryKeyIndex(p); p=p->pNext){}
108931 return p;
108932 }
108933
108934 /*
108935 ** Convert an table column number into a index column number. That is,
108936 ** for the column iCol in the table (as defined by the CREATE TABLE statement)
108937 ** find the (first) offset of that column in index pIdx. Or return -1
108938 ** if column iCol is not used in index pIdx.
108939 */
108940 SQLITE_PRIVATE i16 sqlite3TableColumnToIndex(Index *pIdx, i16 iCol){
108941 int i;
108942 for(i=0; i<pIdx->nColumn; i++){
108943 if( iCol==pIdx->aiColumn[i] ) return i;
108944 }
108945 return -1;
108946 }
108947
108948 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
108949 /* Convert a storage column number into a table column number.
108950 **
108951 ** The storage column number (0,1,2,....) is the index of the value
108952 ** as it appears in the record on disk. The true column number
108953 ** is the index (0,1,2,...) of the column in the CREATE TABLE statement.
108954 **
108955 ** The storage column number is less than the table column number if
108956 ** and only there are VIRTUAL columns to the left.
108957 **
108958 ** If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro.
108959 */
108960 SQLITE_PRIVATE i16 sqlite3StorageColumnToTable(Table *pTab, i16 iCol){
108961 if( pTab->tabFlags & TF_HasVirtual ){
108962 int i;
108963 for(i=0; i<=iCol; i++){
108964 if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ) iCol++;
108965 }
108966 }
108967 return iCol;
108968 }
108969 #endif
108970
108971 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
108972 /* Convert a table column number into a storage column number.
108973 **
108974 ** The storage column number (0,1,2,....) is the index of the value
108975 ** as it appears in the record on disk. Or, if the input column is
108976 ** the N-th virtual column (zero-based) then the storage number is
108977 ** the number of non-virtual columns in the table plus N.
108978 **
108979 ** The true column number is the index (0,1,2,...) of the column in
108980 ** the CREATE TABLE statement.
108981 **
108982 ** If the input column is a VIRTUAL column, then it should not appear
108983 ** in storage. But the value sometimes is cached in registers that
108984 ** follow the range of registers used to construct storage. This
108985 ** avoids computing the same VIRTUAL column multiple times, and provides
108986 ** values for use by OP_Param opcodes in triggers. Hence, if the
108987 ** input column is a VIRTUAL table, put it after all the other columns.
108988 **
108989 ** In the following, N means "normal column", S means STORED, and
108990 ** V means VIRTUAL. Suppose the CREATE TABLE has columns like this:
108991 **
108992 ** CREATE TABLE ex(N,S,V,N,S,V,N,S,V);
108993 ** -- 0 1 2 3 4 5 6 7 8
108994 **
108995 ** Then the mapping from this function is as follows:
108996 **
108997 ** INPUTS: 0 1 2 3 4 5 6 7 8
108998 ** OUTPUTS: 0 1 6 2 3 7 4 5 8
108999 **
109000 ** So, in other words, this routine shifts all the virtual columns to
109001 ** the end.
109002 **
109003 ** If SQLITE_OMIT_GENERATED_COLUMNS then there are no virtual columns and
109004 ** this routine is a no-op macro.
109005 */
109006 SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table *pTab, i16 iCol){
109007 int i;
109008 i16 n;
109009 assert( iCol<pTab->nCol );
109010 if( (pTab->tabFlags & TF_HasVirtual)==0 ) return iCol;
109011 for(i=0, n=0; i<iCol; i++){
109012 if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) n++;
109013 }
109014 if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ){
109015 /* iCol is a virtual column itself */
109016 return pTab->nNVCol + i - n;
109017 }else{
109018 /* iCol is a normal or stored column */
109019 return n;
109020 }
109021 }
109022 #endif
109023
109024 /*
109025 ** Begin constructing a new table representation in memory. This is
109026 ** the first of several action routines that get called in response
109027 ** to a CREATE TABLE statement. In particular, this routine is called
@@ -108821,10 +109309,11 @@
109309 sqlite3Dequote(zType);
109310 pCol->affinity = sqlite3AffinityType(zType, pCol);
109311 pCol->colFlags |= COLFLAG_HASTYPE;
109312 }
109313 p->nCol++;
109314 p->nNVCol++;
109315 pParse->constraintName.n = 0;
109316 }
109317
109318 /*
109319 ** This routine is called by the parser while in the middle of
@@ -108969,10 +109458,16 @@
109458 if( p!=0 ){
109459 pCol = &(p->aCol[p->nCol-1]);
109460 if( !sqlite3ExprIsConstantOrFunction(pExpr, db->init.busy) ){
109461 sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant",
109462 pCol->zName);
109463 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
109464 }else if( pCol->colFlags & COLFLAG_GENERATED ){
109465 testcase( pCol->colFlags & COLFLAG_VIRTUAL );
109466 testcase( pCol->colFlags & COLFLAG_STORED );
109467 sqlite3ErrorMsg(pParse, "cannot use DEFAULT on a generated column");
109468 #endif
109469 }else{
109470 /* A copy of pExpr is used instead of the original, as pExpr contains
109471 ** tokens that point to volatile memory.
109472 */
109473 Expr x;
@@ -109013,10 +109508,25 @@
109508 p->op = TK_ID;
109509 }else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){
109510 p->pLeft->op = TK_ID;
109511 }
109512 }
109513
109514 /*
109515 ** Tag the given column as being part of the PRIMARY KEY
109516 */
109517 static void makeColumnPartOfPrimaryKey(Parse *pParse, Column *pCol){
109518 pCol->colFlags |= COLFLAG_PRIMKEY;
109519 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
109520 if( pCol->colFlags & COLFLAG_GENERATED ){
109521 testcase( pCol->colFlags & COLFLAG_VIRTUAL );
109522 testcase( pCol->colFlags & COLFLAG_STORED );
109523 sqlite3ErrorMsg(pParse,
109524 "generated columns cannot be part of the PRIMARY KEY");
109525 }
109526 #endif
109527 }
109528
109529 /*
109530 ** Designate the PRIMARY KEY for the table. pList is a list of names
109531 ** of columns that form the primary key. If pList is NULL, then the
109532 ** most recently added column of the table is the primary key.
@@ -109053,11 +109563,11 @@
109563 }
109564 pTab->tabFlags |= TF_HasPrimaryKey;
109565 if( pList==0 ){
109566 iCol = pTab->nCol - 1;
109567 pCol = &pTab->aCol[iCol];
109568 makeColumnPartOfPrimaryKey(pParse, pCol);
109569 nTerm = 1;
109570 }else{
109571 nTerm = pList->nExpr;
109572 for(i=0; i<nTerm; i++){
109573 Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);
@@ -109066,11 +109576,11 @@
109576 if( pCExpr->op==TK_ID ){
109577 const char *zCName = pCExpr->u.zToken;
109578 for(iCol=0; iCol<pTab->nCol; iCol++){
109579 if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){
109580 pCol = &pTab->aCol[iCol];
109581 makeColumnPartOfPrimaryKey(pParse, pCol);
109582 break;
109583 }
109584 }
109585 }
109586 }
@@ -109163,44 +109673,58 @@
109673 }else{
109674 sqlite3DbFree(db, zColl);
109675 }
109676 }
109677
109678 /* Change the most recently parsed column to be a GENERATED ALWAYS AS
109679 ** column.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109680 */
109681 SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){
109682 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
109683 u8 eType = COLFLAG_VIRTUAL;
109684 Table *pTab = pParse->pNewTable;
109685 Column *pCol;
109686 if( NEVER(pTab==0) ) goto generated_done;
109687 pCol = &(pTab->aCol[pTab->nCol-1]);
109688 if( IN_DECLARE_VTAB ){
109689 sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns");
109690 goto generated_done;
109691 }
109692 if( pCol->pDflt ) goto generated_error;
109693 if( pType ){
109694 if( pType->n==7 && sqlite3StrNICmp("virtual",pType->z,7)==0 ){
109695 /* no-op */
109696 }else if( pType->n==6 && sqlite3StrNICmp("stored",pType->z,6)==0 ){
109697 eType = COLFLAG_STORED;
109698 }else{
109699 goto generated_error;
109700 }
109701 }
109702 if( eType==COLFLAG_VIRTUAL ) pTab->nNVCol--;
109703 pCol->colFlags |= eType;
109704 assert( TF_HasVirtual==COLFLAG_VIRTUAL );
109705 assert( TF_HasStored==COLFLAG_STORED );
109706 pTab->tabFlags |= eType;
109707 if( pCol->colFlags & COLFLAG_PRIMKEY ){
109708 makeColumnPartOfPrimaryKey(pParse, pCol); /* For the error message */
109709 }
109710 pCol->pDflt = pExpr;
109711 pExpr = 0;
109712 goto generated_done;
109713
109714 generated_error:
109715 sqlite3ErrorMsg(pParse, "error in generated column \"%s\"",
109716 pCol->zName);
109717 generated_done:
109718 sqlite3ExprDelete(pParse->db, pExpr);
109719 #else
109720 /* Throw and error for the GENERATED ALWAYS AS clause if the
109721 ** SQLITE_OMIT_GENERATED_COLUMNS compile-time option is used. */
109722 sqlite3ErrorMsg(pParse, "generated columns not supported");
109723 sqlite3ExprDelete(pParse->db, pExpr);
109724 #endif
109725 }
109726
109727 /*
109728 ** Generate code that will increment the schema cookie.
109729 **
109730 ** The schema cookie is used to determine when the schema for the
@@ -109454,20 +109978,29 @@
109978 **
109979 ** colNotIdxed is a bitmask that has a 0 bit representing each indexed
109980 ** columns that are within the first 63 columns of the table. The
109981 ** high-order bit of colNotIdxed is always 1. All unindexed columns
109982 ** of the table have a 1.
109983 **
109984 ** 2019-10-24: For the purpose of this computation, virtual columns are
109985 ** not considered to be covered by the index, even if they are in the
109986 ** index, because we do not trust the logic in whereIndexExprTrans() to be
109987 ** able to find all instances of a reference to the indexed table column
109988 ** and convert them into references to the index. Hence we always want
109989 ** the actual table at hand in order to recompute the virtual column, if
109990 ** necessary.
109991 **
109992 ** The colNotIdxed mask is AND-ed with the SrcList.a[].colUsed mask
109993 ** to determine if the index is covering index.
109994 */
109995 static void recomputeColumnsNotIndexed(Index *pIdx){
109996 Bitmask m = 0;
109997 int j;
109998 Table *pTab = pIdx->pTable;
109999 for(j=pIdx->nColumn-1; j>=0; j--){
110000 int x = pIdx->aiColumn[j];
110001 if( x>=0 && (pTab->aCol[x].colFlags & COLFLAG_VIRTUAL)==0 ){
110002 testcase( x==BMS-1 );
110003 testcase( x==BMS-2 );
110004 if( x<BMS-1 ) m |= MASKBIT(x);
110005 }
110006 }
@@ -109514,10 +110047,11 @@
110047 for(i=0; i<pTab->nCol; i++){
110048 if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){
110049 pTab->aCol[i].notNull = OE_Abort;
110050 }
110051 }
110052 pTab->tabFlags |= TF_HasNotNull;
110053 }
110054
110055 /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY
110056 ** into BTREE_BLOBKEY.
110057 */
@@ -109621,23 +110155,26 @@
110155
110156 /* Add all table columns to the PRIMARY KEY index
110157 */
110158 nExtra = 0;
110159 for(i=0; i<pTab->nCol; i++){
110160 if( !hasColumn(pPk->aiColumn, nPk, i)
110161 && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) nExtra++;
110162 }
110163 if( resizeIndexObject(db, pPk, nPk+nExtra) ) return;
110164 for(i=0, j=nPk; i<pTab->nCol; i++){
110165 if( !hasColumn(pPk->aiColumn, j, i)
110166 && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0
110167 ){
110168 assert( j<pPk->nColumn );
110169 pPk->aiColumn[j] = i;
110170 pPk->azColl[j] = sqlite3StrBINARY;
110171 j++;
110172 }
110173 }
110174 assert( pPk->nColumn==j );
110175 assert( pTab->nNVCol<=j );
110176 recomputeColumnsNotIndexed(pPk);
110177 }
110178
110179 #ifndef SQLITE_OMIT_VIRTUALTABLE
110180 /*
@@ -109645,11 +110182,11 @@
110182 ** connection.
110183 **
110184 ** zName is temporarily modified while this routine is running, but is
110185 ** restored to its original value prior to this routine returning.
110186 */
110187 SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName){
110188 char *zTail; /* Pointer to the last "_" in zName */
110189 Table *pTab; /* Table that zName is a shadow of */
110190 Module *pMod; /* Module for the virtual table */
110191
110192 zTail = strrchr(zName, '_');
@@ -109663,12 +110200,10 @@
110200 if( pMod==0 ) return 0;
110201 if( pMod->pModule->iVersion<3 ) return 0;
110202 if( pMod->pModule->xShadowName==0 ) return 0;
110203 return pMod->pModule->xShadowName(zTail+1);
110204 }
 
 
110205 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
110206
110207 /*
110208 ** This routine is called to report the final ")" that terminates
110209 ** a CREATE TABLE statement.
@@ -109706,11 +110241,11 @@
110241 }
110242 assert( !db->mallocFailed );
110243 p = pParse->pNewTable;
110244 if( p==0 ) return;
110245
110246 if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){
110247 p->tabFlags |= TF_Shadow;
110248 }
110249
110250 /* If the db->init.busy is 1 it means we are reading the SQL off the
110251 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -109742,25 +110277,46 @@
110277 "AUTOINCREMENT not allowed on WITHOUT ROWID tables");
110278 return;
110279 }
110280 if( (p->tabFlags & TF_HasPrimaryKey)==0 ){
110281 sqlite3ErrorMsg(pParse, "PRIMARY KEY missing on table %s", p->zName);
110282 return;
 
 
110283 }
110284 p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;
110285 convertToWithoutRowidTable(pParse, p);
110286 }
 
110287 iDb = sqlite3SchemaToIndex(db, p->pSchema);
110288
110289 #ifndef SQLITE_OMIT_CHECK
110290 /* Resolve names in all CHECK constraint expressions.
110291 */
110292 if( p->pCheck ){
110293 sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
110294 }
110295 #endif /* !defined(SQLITE_OMIT_CHECK) */
110296 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
110297 if( p->tabFlags & TF_HasGenerated ){
110298 int ii, nNG = 0;
110299 testcase( p->tabFlags & TF_HasVirtual );
110300 testcase( p->tabFlags & TF_HasStored );
110301 for(ii=0; ii<p->nCol; ii++){
110302 u32 colFlags = p->aCol[ii].colFlags;
110303 if( (colFlags & COLFLAG_GENERATED)!=0 ){
110304 testcase( colFlags & COLFLAG_VIRTUAL );
110305 testcase( colFlags & COLFLAG_STORED );
110306 sqlite3ResolveSelfReference(pParse, p, NC_GenCol,
110307 p->aCol[ii].pDflt, 0);
110308 }else{
110309 nNG++;
110310 }
110311 }
110312 if( nNG==0 ){
110313 sqlite3ErrorMsg(pParse, "must have at least one non-generated column");
110314 return;
110315 }
110316 }
110317 #endif
110318
110319 /* Estimate the average row size for the table and for all implied indices */
110320 estimateTableWidth(p);
110321 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
110322 estimateIndexWidth(pIdx);
@@ -109833,11 +110389,11 @@
110389 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
110390 if( pParse->nErr ) return;
110391 pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect, SQLITE_AFF_BLOB);
110392 if( pSelTab==0 ) return;
110393 assert( p->aCol==0 );
110394 p->nCol = p->nNVCol = pSelTab->nCol;
110395 p->aCol = pSelTab->aCol;
110396 pSelTab->nCol = 0;
110397 pSelTab->aCol = 0;
110398 sqlite3DeleteTable(db, pSelTab);
110399 sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
@@ -109905,11 +110461,10 @@
110461
110462 /* Reparse everything to update our internal data structures */
110463 sqlite3VdbeAddParseSchemaOp(v, iDb,
110464 sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName));
110465 }
 
110466
110467 /* Add the table to the in-memory representation of the database.
110468 */
110469 if( db->init.busy ){
110470 Table *pOld;
@@ -110090,11 +110645,11 @@
110645 pParse->eParseMode = PARSE_MODE_NORMAL;
110646 #endif
110647 n = pParse->nTab;
110648 sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
110649 pTable->nCol = -1;
110650 DisableLookaside;
110651 #ifndef SQLITE_OMIT_AUTHORIZATION
110652 xAuth = db->xAuth;
110653 db->xAuth = 0;
110654 pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE);
110655 db->xAuth = xAuth;
@@ -110130,13 +110685,14 @@
110685 assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );
110686 }else{
110687 pTable->nCol = 0;
110688 nErr++;
110689 }
110690 pTable->nNVCol = pTable->nCol;
110691 sqlite3DeleteTable(db, pSelTab);
110692 sqlite3SelectDelete(db, pSel);
110693 EnableLookaside;
110694 #ifndef SQLITE_OMIT_ALTERTABLE
110695 pParse->eParseMode = eParseMode;
110696 #endif
110697 } else {
110698 nErr++;
@@ -110388,10 +110944,41 @@
110944 }
110945 sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
110946 sqlite3ChangeCookie(pParse, iDb);
110947 sqliteViewResetAll(db, iDb);
110948 }
110949
110950 /*
110951 ** Return TRUE if shadow tables should be read-only in the current
110952 ** context.
110953 */
110954 SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db){
110955 #ifndef SQLITE_OMIT_VIRTUALTABLE
110956 if( (db->flags & SQLITE_Defensive)!=0
110957 && db->pVtabCtx==0
110958 && db->nVdbeExec==0
110959 ){
110960 return 1;
110961 }
110962 #endif
110963 return 0;
110964 }
110965
110966 /*
110967 ** Return true if it is not allowed to drop the given table
110968 */
110969 static int tableMayNotBeDropped(sqlite3 *db, Table *pTab){
110970 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){
110971 if( sqlite3StrNICmp(pTab->zName+7, "stat", 4)==0 ) return 0;
110972 if( sqlite3StrNICmp(pTab->zName+7, "parameters", 10)==0 ) return 0;
110973 return 1;
110974 }
110975 if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){
110976 return 1;
110977 }
110978 return 0;
110979 }
110980
110981 /*
110982 ** This routine is called to do the work of a DROP TABLE statement.
110983 ** pName is the name of the table to be dropped.
110984 */
@@ -110458,13 +111045,11 @@
111045 if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){
111046 goto exit_drop_table;
111047 }
111048 }
111049 #endif
111050 if( tableMayNotBeDropped(db, pTab) ){
 
 
111051 sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab->zName);
111052 goto exit_drop_table;
111053 }
111054
111055 #ifndef SQLITE_OMIT_VIEW
@@ -111131,12 +111716,17 @@
111716 }else{
111717 j = pCExpr->iColumn;
111718 assert( j<=0x7fff );
111719 if( j<0 ){
111720 j = pTab->iPKey;
111721 }else{
111722 if( pTab->aCol[j].notNull==0 ){
111723 pIndex->uniqNotNull = 0;
111724 }
111725 if( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL ){
111726 pIndex->bHasVCol = 1;
111727 }
111728 }
111729 pIndex->aiColumn[i] = (i16)j;
111730 }
111731 zColl = 0;
111732 if( pListItem->pExpr->op==TK_COLLATE ){
@@ -111187,17 +111777,17 @@
111777 if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);
111778
111779 /* If this index contains every column of its table, then mark
111780 ** it as a covering index */
111781 assert( HasRowid(pTab)
111782 || pTab->iPKey<0 || sqlite3TableColumnToIndex(pIndex, pTab->iPKey)>=0 );
111783 recomputeColumnsNotIndexed(pIndex);
111784 if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){
111785 pIndex->isCovering = 1;
111786 for(j=0; j<pTab->nCol; j++){
111787 if( j==pTab->iPKey ) continue;
111788 if( sqlite3TableColumnToIndex(pIndex,j)>=0 ) continue;
111789 pIndex->isCovering = 0;
111790 break;
111791 }
111792 }
111793
@@ -112533,55 +113123,10 @@
113123 }
113124 }
113125 return SQLITE_ERROR;
113126 }
113127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113128 /*
113129 ** This routine is called on a collation sequence before it is used to
113130 ** check that it is defined. An undefined collation sequence exists when
113131 ** a database is loaded that contains references to collation sequences
113132 ** that have not been defined by sqlite3_create_collation() etc.
@@ -112670,14 +113215,14 @@
113215 ** cannot be found.
113216 **
113217 ** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq()
113218 */
113219 SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(
113220 sqlite3 *db, /* Database connection to search */
113221 u8 enc, /* Desired text encoding */
113222 const char *zName, /* Name of the collating sequence. Might be NULL */
113223 int create /* True to create CollSeq if doesn't already exist */
113224 ){
113225 CollSeq *pColl;
113226 if( zName ){
113227 pColl = findCollSeqEntry(db, zName, create);
113228 }else{
@@ -112684,10 +113229,89 @@
113229 pColl = db->pDfltColl;
113230 }
113231 assert( SQLITE_UTF8==1 && SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
113232 assert( enc>=SQLITE_UTF8 && enc<=SQLITE_UTF16BE );
113233 if( pColl ) pColl += enc-1;
113234 return pColl;
113235 }
113236
113237 /*
113238 ** This function is responsible for invoking the collation factory callback
113239 ** or substituting a collation sequence of a different encoding when the
113240 ** requested collation sequence is not available in the desired encoding.
113241 **
113242 ** If it is not NULL, then pColl must point to the database native encoding
113243 ** collation sequence with name zName, length nName.
113244 **
113245 ** The return value is either the collation sequence to be used in database
113246 ** db for collation type name zName, length nName, or NULL, if no collation
113247 ** sequence can be found. If no collation is found, leave an error message.
113248 **
113249 ** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()
113250 */
113251 SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(
113252 Parse *pParse, /* Parsing context */
113253 u8 enc, /* The desired encoding for the collating sequence */
113254 CollSeq *pColl, /* Collating sequence with native encoding, or NULL */
113255 const char *zName /* Collating sequence name */
113256 ){
113257 CollSeq *p;
113258 sqlite3 *db = pParse->db;
113259
113260 p = pColl;
113261 if( !p ){
113262 p = sqlite3FindCollSeq(db, enc, zName, 0);
113263 }
113264 if( !p || !p->xCmp ){
113265 /* No collation sequence of this type for this encoding is registered.
113266 ** Call the collation factory to see if it can supply us with one.
113267 */
113268 callCollNeeded(db, enc, zName);
113269 p = sqlite3FindCollSeq(db, enc, zName, 0);
113270 }
113271 if( p && !p->xCmp && synthCollSeq(db, p) ){
113272 p = 0;
113273 }
113274 assert( !p || p->xCmp );
113275 if( p==0 ){
113276 sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
113277 pParse->rc = SQLITE_ERROR_MISSING_COLLSEQ;
113278 }
113279 return p;
113280 }
113281
113282 /*
113283 ** This function returns the collation sequence for database native text
113284 ** encoding identified by the string zName.
113285 **
113286 ** If the requested collation sequence is not available, or not available
113287 ** in the database native encoding, the collation factory is invoked to
113288 ** request it. If the collation factory does not supply such a sequence,
113289 ** and the sequence is available in another text encoding, then that is
113290 ** returned instead.
113291 **
113292 ** If no versions of the requested collations sequence are available, or
113293 ** another error occurs, NULL is returned and an error message written into
113294 ** pParse.
113295 **
113296 ** This routine is a wrapper around sqlite3FindCollSeq(). This routine
113297 ** invokes the collation factory if the named collation cannot be found
113298 ** and generates an error message.
113299 **
113300 ** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq()
113301 */
113302 SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){
113303 sqlite3 *db = pParse->db;
113304 u8 enc = ENC(db);
113305 u8 initbusy = db->init.busy;
113306 CollSeq *pColl;
113307
113308 pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);
113309 if( !initbusy && (!pColl || !pColl->xCmp) ){
113310 pColl = sqlite3GetCollSeq(pParse, enc, pColl, zName);
113311 }
113312
113313 return pColl;
113314 }
113315
113316 /* During the search for the best function definition, this procedure
113317 ** is called to test how well the function passed as the first argument
@@ -113029,15 +113653,11 @@
113653 db = pParse->db;
113654 if( (pTab->tabFlags & TF_Readonly)!=0 ){
113655 return sqlite3WritableSchema(db)==0 && pParse->nested==0;
113656 }
113657 assert( pTab->tabFlags & TF_Shadow );
113658 return sqlite3ReadOnlyShadowTables(db);
 
 
 
 
113659 }
113660
113661 /*
113662 ** Check to make sure the given table is writable. If it is not
113663 ** writable, generate an error message and return 1. If it is
@@ -113696,11 +114316,12 @@
114316 sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);
114317 for(iCol=0; iCol<pTab->nCol; iCol++){
114318 testcase( mask!=0xffffffff && iCol==31 );
114319 testcase( mask!=0xffffffff && iCol==32 );
114320 if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){
114321 int kk = sqlite3TableColumnToStorage(pTab, iCol);
114322 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+kk+1);
114323 }
114324 }
114325
114326 /* Invoke BEFORE DELETE trigger programs. */
114327 addrStart = sqlite3VdbeCurrentAddr(v);
@@ -113876,10 +114497,12 @@
114497 *piPartIdxLabel = sqlite3VdbeMakeLabel(pParse);
114498 pParse->iSelfTab = iDataCur + 1;
114499 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
114500 SQLITE_JUMPIFNULL);
114501 pParse->iSelfTab = 0;
114502 pPrior = 0; /* Ticket a9efb42811fa41ee 2019-11-02;
114503 ** pPartIdxWhere may have corrupted regPrior registers */
114504 }else{
114505 *piPartIdxLabel = 0;
114506 }
114507 }
114508 nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;
@@ -116304,11 +116927,11 @@
116927 if( nIncr<0 ){
116928 sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, iOk);
116929 VdbeCoverage(v);
116930 }
116931 for(i=0; i<pFKey->nCol; i++){
116932 int iReg = sqlite3TableColumnToStorage(pFKey->pFrom,aiCol[i]) + regData + 1;
116933 sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk); VdbeCoverage(v);
116934 }
116935
116936 if( isIgnore==0 ){
116937 if( pIdx==0 ){
@@ -116320,11 +116943,12 @@
116943 /* Invoke MustBeInt to coerce the child key value to an integer (i.e.
116944 ** apply the affinity of the parent key). If this fails, then there
116945 ** is no matching parent key. Before using MustBeInt, make a copy of
116946 ** the value. Otherwise, the value inserted into the child key column
116947 ** will have INTEGER affinity applied to it, which may not be correct. */
116948 sqlite3VdbeAddOp2(v, OP_SCopy,
116949 sqlite3TableColumnToStorage(pFKey->pFrom,aiCol[0])+1+regData, regTemp);
116950 iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0);
116951 VdbeCoverage(v);
116952
116953 /* If the parent table is the same as the child table, and we are about
116954 ** to increment the constraint-counter (i.e. this is an INSERT operation),
@@ -116347,11 +116971,13 @@
116971 int regRec = sqlite3GetTempReg(pParse);
116972
116973 sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);
116974 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
116975 for(i=0; i<nCol; i++){
116976 sqlite3VdbeAddOp2(v, OP_Copy,
116977 sqlite3TableColumnToStorage(pFKey->pFrom, aiCol[i])+1+regData,
116978 regTemp+i);
116979 }
116980
116981 /* If the parent table is the same as the child table, and we are about
116982 ** to increment the constraint-counter (i.e. this is an INSERT operation),
116983 ** then check if the row being inserted matches itself. If so, do not
@@ -116363,12 +116989,15 @@
116989 ** none of the child key values are).
116990 */
116991 if( pTab==pFKey->pFrom && nIncr==1 ){
116992 int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1;
116993 for(i=0; i<nCol; i++){
116994 int iChild = sqlite3TableColumnToStorage(pFKey->pFrom,aiCol[i])
116995 +1+regData;
116996 int iParent = 1+regData;
116997 iParent += sqlite3TableColumnToStorage(pIdx->pTable,
116998 pIdx->aiColumn[i]);
116999 assert( pIdx->aiColumn[i]>=0 );
117000 assert( aiCol[i]!=pTab->iPKey );
117001 if( pIdx->aiColumn[i]==pTab->iPKey ){
117002 /* The parent key is a composite key that includes the IPK column */
117003 iParent = regData;
@@ -116432,11 +117061,11 @@
117061
117062 pExpr = sqlite3Expr(db, TK_REGISTER, 0);
117063 if( pExpr ){
117064 if( iCol>=0 && iCol!=pTab->iPKey ){
117065 pCol = &pTab->aCol[iCol];
117066 pExpr->iTable = regBase + sqlite3TableColumnToStorage(pTab,iCol) + 1;
117067 pExpr->affExpr = pCol->affinity;
117068 zColl = pCol->zColl;
117069 if( zColl==0 ) zColl = db->pDfltColl->zName;
117070 pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl);
117071 }else{
@@ -116881,11 +117510,13 @@
117510 ** FK counter for each row of the current table with non-NULL keys.
117511 */
117512 Vdbe *v = sqlite3GetVdbe(pParse);
117513 int iJump = sqlite3VdbeCurrentAddr(v) + pFKey->nCol + 1;
117514 for(i=0; i<pFKey->nCol; i++){
117515 int iFromCol, iReg;
117516 iFromCol = pFKey->aCol[i].iFrom;
117517 iReg = sqlite3TableColumnToStorage(pFKey->pFrom,iFromCol) + regOld+1;
117518 sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iJump); VdbeCoverage(v);
117519 }
117520 sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, -1);
117521 }
117522 continue;
@@ -117216,11 +117847,19 @@
117847 if( action==OE_Cascade ){
117848 pNew = sqlite3PExpr(pParse, TK_DOT,
117849 sqlite3ExprAlloc(db, TK_ID, &tNew, 0),
117850 sqlite3ExprAlloc(db, TK_ID, &tToCol, 0));
117851 }else if( action==OE_SetDflt ){
117852 Column *pCol = pFKey->pFrom->aCol + iFromCol;
117853 Expr *pDflt;
117854 if( pCol->colFlags & COLFLAG_GENERATED ){
117855 testcase( pCol->colFlags & COLFLAG_VIRTUAL );
117856 testcase( pCol->colFlags & COLFLAG_STORED );
117857 pDflt = 0;
117858 }else{
117859 pDflt = pCol->pDflt;
117860 }
117861 if( pDflt ){
117862 pNew = sqlite3ExprDup(db, pDflt, 0);
117863 }else{
117864 pNew = sqlite3ExprAlloc(db, TK_NULL, 0, 0);
117865 }
@@ -117254,11 +117893,11 @@
117893 );
117894 pWhere = 0;
117895 }
117896
117897 /* Disable lookaside memory allocation */
117898 DisableLookaside;
117899
117900 pTrigger = (Trigger *)sqlite3DbMallocZero(db,
117901 sizeof(Trigger) + /* struct Trigger */
117902 sizeof(TriggerStep) + /* Single step in trigger program */
117903 nFrom + 1 /* Space for pStep->zTarget */
@@ -117276,11 +117915,11 @@
117915 pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);
117916 }
117917 }
117918
117919 /* Re-enable the lookaside buffer, if it was disabled earlier. */
117920 EnableLookaside;
117921
117922 sqlite3ExprDelete(db, pWhere);
117923 sqlite3ExprDelete(db, pWhen);
117924 sqlite3ExprListDelete(db, pList);
117925 sqlite3SelectDelete(db, pSelect);
@@ -117427,11 +118066,11 @@
118066 v = sqlite3GetVdbe(pParse);
118067 assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );
118068 sqlite3TableLock(pParse, iDb, pTab->tnum,
118069 (opcode==OP_OpenWrite)?1:0, pTab->zName);
118070 if( HasRowid(pTab) ){
118071 sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nNVCol);
118072 VdbeComment((v, "%s", pTab->zName));
118073 }else{
118074 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
118075 assert( pPk!=0 );
118076 assert( pPk->tnum==pTab->tnum );
@@ -117519,27 +118158,29 @@
118158 ** 'C' NUMERIC
118159 ** 'D' INTEGER
118160 ** 'E' REAL
118161 */
118162 SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){
118163 int i, j;
118164 char *zColAff = pTab->zColAff;
118165 if( zColAff==0 ){
118166 sqlite3 *db = sqlite3VdbeDb(v);
118167 zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1);
118168 if( !zColAff ){
118169 sqlite3OomFault(db);
118170 return;
118171 }
118172
118173 for(i=j=0; i<pTab->nCol; i++){
118174 assert( pTab->aCol[i].affinity!=0 );
118175 if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ){
118176 zColAff[j++] = pTab->aCol[i].affinity;
118177 }
118178 }
118179 do{
118180 zColAff[j--] = 0;
118181 }while( j>=0 && zColAff[j]<=SQLITE_AFF_BLOB );
118182 pTab->zColAff = zColAff;
118183 }
118184 assert( zColAff!=0 );
118185 i = sqlite3Strlen30NN(zColAff);
118186 if( i ){
@@ -117588,10 +118229,92 @@
118229 }
118230 #endif
118231 }
118232 return 0;
118233 }
118234
118235 /* This walker callback will compute the union of colFlags flags for all
118236 ** references columns in a CHECK constraint or generated column expression.
118237 */
118238 static int exprColumnFlagUnion(Walker *pWalker, Expr *pExpr){
118239 if( pExpr->op==TK_COLUMN ){
118240 pWalker->eCode |= pWalker->u.pTab->aCol[pExpr->iColumn].colFlags;
118241 }
118242 return WRC_Continue;
118243 }
118244
118245 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
118246 /*
118247 ** All regular columns for table pTab have been puts into registers
118248 ** starting with iRegStore. The registers that correspond to STORED
118249 ** or VIRTUAL columns have not yet been initialized. This routine goes
118250 ** back and computes the values for those columns based on the previously
118251 ** computed normal columns.
118252 */
118253 SQLITE_PRIVATE void sqlite3ComputeGeneratedColumns(
118254 Parse *pParse, /* Parsing context */
118255 int iRegStore, /* Register holding the first column */
118256 Table *pTab /* The table */
118257 ){
118258 int i;
118259 Walker w;
118260 Column *pRedo;
118261 int eProgress;
118262
118263 /* Because there can be multiple generated columns that refer to one another,
118264 ** this is a two-pass algorithm. On the first pass, mark all generated
118265 ** columns as "not available".
118266 */
118267 for(i=0; i<pTab->nCol; i++){
118268 if( pTab->aCol[i].colFlags & COLFLAG_GENERATED ){
118269 testcase( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL );
118270 testcase( pTab->aCol[i].colFlags & COLFLAG_STORED );
118271 pTab->aCol[i].colFlags |= COLFLAG_NOTAVAIL;
118272 }
118273 }
118274
118275 w.u.pTab = pTab;
118276 w.xExprCallback = exprColumnFlagUnion;
118277 w.xSelectCallback = 0;
118278 w.xSelectCallback2 = 0;
118279
118280 /* On the second pass, compute the value of each NOT-AVAILABLE column.
118281 ** Companion code in the TK_COLUMN case of sqlite3ExprCodeTarget() will
118282 ** compute dependencies and mark remove the COLSPAN_NOTAVAIL mark, as
118283 ** they are needed.
118284 */
118285 pParse->iSelfTab = -iRegStore;
118286 do{
118287 eProgress = 0;
118288 pRedo = 0;
118289 for(i=0; i<pTab->nCol; i++){
118290 Column *pCol = pTab->aCol + i;
118291 if( (pCol->colFlags & COLFLAG_NOTAVAIL)!=0 ){
118292 int x;
118293 pCol->colFlags |= COLFLAG_BUSY;
118294 w.eCode = 0;
118295 sqlite3WalkExpr(&w, pCol->pDflt);
118296 pCol->colFlags &= ~COLFLAG_BUSY;
118297 if( w.eCode & COLFLAG_NOTAVAIL ){
118298 pRedo = pCol;
118299 continue;
118300 }
118301 eProgress = 1;
118302 assert( pCol->colFlags & COLFLAG_GENERATED );
118303 x = sqlite3TableColumnToStorage(pTab, i) + iRegStore;
118304 sqlite3ExprCodeGeneratedColumn(pParse, pCol, x);
118305 pCol->colFlags &= ~COLFLAG_NOTAVAIL;
118306 }
118307 }
118308 }while( pRedo && eProgress );
118309 if( pRedo ){
118310 sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pRedo->zName);
118311 }
118312 pParse->iSelfTab = 0;
118313 }
118314 #endif /* SQLITE_OMIT_GENERATED_COLUMNS */
118315
118316
118317 #ifndef SQLITE_OMIT_AUTOINCREMENT
118318 /*
118319 ** Locate or create an AutoincInfo structure associated with table pTab
118320 ** which is in database iDb. Return the register number for the register
@@ -117896,11 +118619,11 @@
118619 */
118620 SQLITE_PRIVATE void sqlite3Insert(
118621 Parse *pParse, /* Parser context */
118622 SrcList *pTabList, /* Name of table into which we are inserting */
118623 Select *pSelect, /* A SELECT statement to use as the data source */
118624 IdList *pColumn, /* Column names corresponding to IDLIST, or NULL. */
118625 int onError, /* How to handle constraint errors */
118626 Upsert *pUpsert /* ON CONFLICT clauses for upsert, or NULL */
118627 ){
118628 sqlite3 *db; /* The main database structure */
118629 Table *pTab; /* The table to insert into. aka TABLE */
@@ -117921,10 +118644,11 @@
118644 u8 useTempTable = 0; /* Store SELECT results in intermediate table */
118645 u8 appendFlag = 0; /* True if the insert is likely to be an append */
118646 u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */
118647 u8 bIdListInOrder; /* True if IDLIST is in table order */
118648 ExprList *pList = 0; /* List of VALUES() to be inserted */
118649 int iRegStore; /* Register in which to store next column */
118650
118651 /* Register allocations */
118652 int regFromSelect = 0;/* Base register for data coming from SELECT */
118653 int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */
118654 int regRowCount = 0; /* Memory cell used for the row counter */
@@ -118028,12 +118752,12 @@
118752 /* If this is an AUTOINCREMENT table, look up the sequence number in the
118753 ** sqlite_sequence table and store it in memory cell regAutoinc.
118754 */
118755 regAutoinc = autoIncBegin(pParse, iDb, pTab);
118756
118757 /* Allocate a block registers to hold the rowid and the values
118758 ** for all columns of the new row.
118759 */
118760 regRowid = regIns = pParse->nMem+1;
118761 pParse->nMem += pTab->nCol + 1;
118762 if( IsVirtual(pTab) ){
118763 regRowid++;
@@ -118048,13 +118772,21 @@
118772 ** If the table has an INTEGER PRIMARY KEY column and that column
118773 ** is named in the IDLIST, then record in the ipkColumn variable
118774 ** the index into IDLIST of the primary key column. ipkColumn is
118775 ** the index of the primary key as it appears in IDLIST, not as
118776 ** is appears in the original table. (The index of the INTEGER
118777 ** PRIMARY KEY in the original table is pTab->iPKey.) After this
118778 ** loop, if ipkColumn==(-1), that means that integer primary key
118779 ** is unspecified, and hence the table is either WITHOUT ROWID or
118780 ** it will automatically generated an integer primary key.
118781 **
118782 ** bIdListInOrder is true if the columns in IDLIST are in storage
118783 ** order. This enables an optimization that avoids shuffling the
118784 ** columns into storage order. False negatives are harmless,
118785 ** but false positives will cause database corruption.
118786 */
118787 bIdListInOrder = (pTab->tabFlags & (TF_OOOHidden|TF_HasStored))==0;
118788 if( pColumn ){
118789 for(i=0; i<pColumn->nId; i++){
118790 pColumn->a[i].idx = -1;
118791 }
118792 for(i=0; i<pColumn->nId; i++){
@@ -118063,10 +118795,18 @@
118795 pColumn->a[i].idx = j;
118796 if( i!=j ) bIdListInOrder = 0;
118797 if( j==pTab->iPKey ){
118798 ipkColumn = i; assert( !withoutRowid );
118799 }
118800 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
118801 if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){
118802 sqlite3ErrorMsg(pParse,
118803 "cannot INSERT into generated column \"%s\"",
118804 pTab->aCol[j].zName);
118805 goto insert_cleanup;
118806 }
118807 #endif
118808 break;
118809 }
118810 }
118811 if( j>=pTab->nCol ){
118812 if( sqlite3IsRowid(pColumn->a[i].zName) && !withoutRowid ){
@@ -118172,17 +118912,30 @@
118912 ** key, the set the ipkColumn variable to the integer primary key
118913 ** column index in the original table definition.
118914 */
118915 if( pColumn==0 && nColumn>0 ){
118916 ipkColumn = pTab->iPKey;
118917 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
118918 if( ipkColumn>=0 && (pTab->tabFlags & TF_HasGenerated)!=0 ){
118919 testcase( pTab->tabFlags & TF_HasVirtual );
118920 testcase( pTab->tabFlags & TF_HasStored );
118921 for(i=ipkColumn-1; i>=0; i--){
118922 if( pTab->aCol[i].colFlags & COLFLAG_GENERATED ){
118923 testcase( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL );
118924 testcase( pTab->aCol[i].colFlags & COLFLAG_STORED );
118925 ipkColumn--;
118926 }
118927 }
118928 }
118929 #endif
118930 }
118931
118932 /* Make sure the number of columns in the source data matches the number
118933 ** of columns to be inserted into the table.
118934 */
118935 for(i=0; i<pTab->nCol; i++){
118936 if( pTab->aCol[i].colFlags & COLFLAG_NOINSERT ) nHidden++;
118937 }
118938 if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){
118939 sqlite3ErrorMsg(pParse,
118940 "table %S has %d columns but %d values were supplied",
118941 pTabList, 0, pTab->nCol-nHidden, nColumn);
@@ -118263,11 +119016,91 @@
119016 ** goto C
119017 ** D: ...
119018 */
119019 addrInsTop = addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);
119020 VdbeCoverage(v);
119021 if( ipkColumn>=0 ){
119022 /* tag-20191021-001: If the INTEGER PRIMARY KEY is being generated by the
119023 ** SELECT, go ahead and copy the value into the rowid slot now, so that
119024 ** the value does not get overwritten by a NULL at tag-20191021-002. */
119025 sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid);
119026 }
119027 }
119028
119029 /* Compute data for ordinary columns of the new entry. Values
119030 ** are written in storage order into registers starting with regData.
119031 ** Only ordinary columns are computed in this loop. The rowid
119032 ** (if there is one) is computed later and generated columns are
119033 ** computed after the rowid since they might depend on the value
119034 ** of the rowid.
119035 */
119036 nHidden = 0;
119037 iRegStore = regData; assert( regData==regRowid+1 );
119038 for(i=0; i<pTab->nCol; i++, iRegStore++){
119039 int k;
119040 u32 colFlags;
119041 assert( i>=nHidden );
119042 if( i==pTab->iPKey ){
119043 /* tag-20191021-002: References to the INTEGER PRIMARY KEY are filled
119044 ** using the rowid. So put a NULL in the IPK slot of the record to avoid
119045 ** using excess space. The file format definition requires this extra
119046 ** NULL - we cannot optimize further by skipping the column completely */
119047 sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);
119048 continue;
119049 }
119050 if( ((colFlags = pTab->aCol[i].colFlags) & COLFLAG_NOINSERT)!=0 ){
119051 nHidden++;
119052 if( (colFlags & COLFLAG_VIRTUAL)!=0 ){
119053 /* Virtual columns do not participate in OP_MakeRecord. So back up
119054 ** iRegStore by one slot to compensate for the iRegStore++ in the
119055 ** outer for() loop */
119056 iRegStore--;
119057 continue;
119058 }else if( (colFlags & COLFLAG_STORED)!=0 ){
119059 /* Stored columns are computed later. But if there are BEFORE
119060 ** triggers, the slots used for stored columns will be OP_Copy-ed
119061 ** to a second block of registers, so the register needs to be
119062 ** initialized to NULL to avoid an uninitialized register read */
119063 if( tmask & TRIGGER_BEFORE ){
119064 sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);
119065 }
119066 continue;
119067 }else if( pColumn==0 ){
119068 /* Hidden columns that are not explicitly named in the INSERT
119069 ** get there default value */
119070 sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);
119071 continue;
119072 }
119073 }
119074 if( pColumn ){
119075 for(j=0; j<pColumn->nId && pColumn->a[j].idx!=i; j++){}
119076 if( j>=pColumn->nId ){
119077 /* A column not named in the insert column list gets its
119078 ** default value */
119079 sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);
119080 continue;
119081 }
119082 k = j;
119083 }else if( nColumn==0 ){
119084 /* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */
119085 sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);
119086 continue;
119087 }else{
119088 k = i - nHidden;
119089 }
119090
119091 if( useTempTable ){
119092 sqlite3VdbeAddOp3(v, OP_Column, srcTab, k, iRegStore);
119093 }else if( pSelect ){
119094 if( regFromSelect!=regData ){
119095 sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+k, iRegStore);
119096 }
119097 }else{
119098 sqlite3ExprCode(pParse, pList->a[k].pExpr, iRegStore);
119099 }
119100 }
119101
119102
119103 /* Run the BEFORE and INSTEAD OF triggers, if there are any
119104 */
119105 endOfLoop = sqlite3VdbeMakeLabel(pParse);
119106 if( tmask & TRIGGER_BEFORE ){
@@ -118299,29 +119132,25 @@
119132 /* Cannot have triggers on a virtual table. If it were possible,
119133 ** this block would have to account for hidden column.
119134 */
119135 assert( !IsVirtual(pTab) );
119136
119137 /* Copy the new data already generated. */
119138 assert( pTab->nNVCol>0 );
119139 sqlite3VdbeAddOp3(v, OP_Copy, regRowid+1, regCols+1, pTab->nNVCol-1);
119140
119141 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
119142 /* Compute the new value for generated columns after all other
119143 ** columns have already been computed. This must be done after
119144 ** computing the ROWID in case one of the generated columns
119145 ** refers to the ROWID. */
119146 if( pTab->tabFlags & TF_HasGenerated ){
119147 testcase( pTab->tabFlags & TF_HasVirtual );
119148 testcase( pTab->tabFlags & TF_HasStored );
119149 sqlite3ComputeGeneratedColumns(pParse, regCols+1, pTab);
119150 }
119151 #endif
 
 
 
 
119152
119153 /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,
119154 ** do not attempt any conversions before assembling the record.
119155 ** If this is a real table, attempt conversions as required by the
119156 ** table column affinities.
@@ -118335,23 +119164,21 @@
119164 pTab, regCols-pTab->nCol-1, onError, endOfLoop);
119165
119166 sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);
119167 }
119168
 
 
 
119169 if( !isView ){
119170 if( IsVirtual(pTab) ){
119171 /* The row that the VUpdate opcode will delete: none */
119172 sqlite3VdbeAddOp2(v, OP_Null, 0, regIns);
119173 }
119174 if( ipkColumn>=0 ){
119175 /* Compute the new rowid */
119176 if( useTempTable ){
119177 sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regRowid);
119178 }else if( pSelect ){
119179 /* Rowid already initialized at tag-20191021-001 */
119180 }else{
119181 Expr *pIpk = pList->a[ipkColumn].pExpr;
119182 if( pIpk->op==TK_NULL && !IsVirtual(pTab) ){
119183 sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);
119184 appendFlag = 1;
@@ -118380,49 +119207,21 @@
119207 sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);
119208 appendFlag = 1;
119209 }
119210 autoIncStep(pParse, regAutoinc, regRowid);
119211
119212 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
119213 /* Compute the new value for generated columns after all other
119214 ** columns have already been computed. This must be done after
119215 ** computing the ROWID in case one of the generated columns
119216 ** refers to the ROWID. */
119217 if( pTab->tabFlags & TF_HasGenerated ){
119218 testcase( pTab->tabFlags & TF_HasVirtual );
119219 testcase( pTab->tabFlags & TF_HasStored );
119220 sqlite3ComputeGeneratedColumns(pParse, regRowid+1, pTab);
119221 }
119222 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119223
119224 /* Generate code to check constraints and generate index keys and
119225 ** do the insertion.
119226 */
119227 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -118448,13 +119247,11 @@
119247 ** flag in the second case as if any REPLACE constraint is hit, an
119248 ** OP_Delete or OP_IdxDelete instruction will be executed on each
119249 ** cursor that is disturbed. And these instructions both clear the
119250 ** VdbeCursor.seekResult variable, disabling the OPFLAG_USESEEKRESULT
119251 ** functionality. */
119252 bUseSeek = (isReplace==0 || !sqlite3VdbeHasSubProgram(v));
 
 
119253 sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur,
119254 regIns, aRegIdx, 0, appendFlag, bUseSeek
119255 );
119256 }
119257 }
@@ -118711,10 +119508,17 @@
119508 u8 bAffinityDone = 0; /* True if the OP_Affinity operation has been run */
119509 int upsertBypass = 0; /* Address of Goto to bypass upsert subroutine */
119510 int upsertJump = 0; /* Address of Goto that jumps into upsert subroutine */
119511 int ipkTop = 0; /* Top of the IPK uniqueness check */
119512 int ipkBottom = 0; /* OP_Goto at the end of the IPK uniqueness check */
119513 /* Variables associated with retesting uniqueness constraints after
119514 ** replace triggers fire have run */
119515 int regTrigCnt; /* Register used to count replace trigger invocations */
119516 int addrRecheck = 0; /* Jump here to recheck all uniqueness constraints */
119517 int lblRecheckOk = 0; /* Each recheck jumps to this label if it passes */
119518 Trigger *pTrigger; /* List of DELETE triggers on the table pTab */
119519 int nReplaceTrig = 0; /* Number of replace triggers coded */
119520
119521 isUpdate = regOldData!=0;
119522 db = pParse->db;
119523 v = sqlite3GetVdbe(pParse);
119524 assert( v!=0 );
@@ -118737,64 +119541,73 @@
119541 VdbeModuleComment((v, "BEGIN: GenCnstCks(%d,%d,%d,%d,%d)",
119542 iDataCur, iIdxCur, regNewData, regOldData, pkChng));
119543
119544 /* Test all NOT NULL constraints.
119545 */
119546 if( pTab->tabFlags & TF_HasNotNull ){
119547 for(i=0; i<nCol; i++){
119548 int iReg;
119549 onError = pTab->aCol[i].notNull;
119550 if( onError==OE_None ) continue; /* No NOT NULL on this column */
119551 if( i==pTab->iPKey ){
119552 continue; /* ROWID is never NULL */
119553 }
119554 if( aiChng && aiChng[i]<0 ){
119555 /* Don't bother checking for NOT NULL on columns that do not change */
119556 continue;
119557 }
119558 if( overrideError!=OE_Default ){
119559 onError = overrideError;
119560 }else if( onError==OE_Default ){
119561 onError = OE_Abort;
119562 }
119563 if( onError==OE_Replace && pTab->aCol[i].pDflt==0 ){
119564 onError = OE_Abort;
119565 }
119566 assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
119567 || onError==OE_Ignore || onError==OE_Replace );
119568 addr1 = 0;
119569 testcase( i!=sqlite3TableColumnToStorage(pTab, i) );
119570 testcase( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL );
119571 testcase( pTab->aCol[i].colFlags & COLFLAG_STORED );
119572 iReg = sqlite3TableColumnToStorage(pTab, i) + regNewData + 1;
119573 switch( onError ){
119574 case OE_Replace: {
119575 assert( onError==OE_Replace );
119576 addr1 = sqlite3VdbeMakeLabel(pParse);
119577 sqlite3VdbeAddOp2(v, OP_NotNull, iReg, addr1);
119578 VdbeCoverage(v);
119579 if( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 ){
119580 sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);
119581 sqlite3VdbeAddOp2(v, OP_NotNull, iReg, addr1);
119582 VdbeCoverage(v);
119583 }
119584 onError = OE_Abort;
119585 /* Fall through into the OE_Abort case to generate code that runs
119586 ** if both the input and the default value are NULL */
119587 }
119588 case OE_Abort:
119589 sqlite3MayAbort(pParse);
119590 /* Fall through */
119591 case OE_Rollback:
119592 case OE_Fail: {
119593 char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName,
119594 pTab->aCol[i].zName);
119595 sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL,
119596 onError, iReg);
119597 sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC);
119598 sqlite3VdbeChangeP5(v, P5_ConstraintNotNull);
119599 VdbeCoverage(v);
119600 if( addr1 ) sqlite3VdbeResolveLabel(v, addr1);
119601 break;
119602 }
119603 default: {
119604 assert( onError==OE_Ignore );
119605 sqlite3VdbeAddOp2(v, OP_IsNull, iReg, ignoreDest);
119606 VdbeCoverage(v);
119607 break;
119608 }
119609 }
119610 }
119611 }
119612
119613 /* Test all CHECK constraints
@@ -118874,10 +119687,54 @@
119687 ** Jump to that uniqueness check now */
119688 upsertJump = sqlite3VdbeAddOp0(v, OP_Goto);
119689 VdbeComment((v, "UPSERT constraint goes first"));
119690 }
119691 }
119692
119693 /* Determine if it is possible that triggers (either explicitly coded
119694 ** triggers or FK resolution actions) might run as a result of deletes
119695 ** that happen when OE_Replace conflict resolution occurs. (Call these
119696 ** "replace triggers".) If any replace triggers run, we will need to
119697 ** recheck all of the uniqueness constraints after they have all run.
119698 ** But on the recheck, the resolution is OE_Abort instead of OE_Replace.
119699 **
119700 ** If replace triggers are a possibility, then
119701 **
119702 ** (1) Allocate register regTrigCnt and initialize it to zero.
119703 ** That register will count the number of replace triggers that
119704 ** fire. Constraint recheck only occurs if the number is positive.
119705 ** (2) Initialize pTrigger to the list of all DELETE triggers on pTab.
119706 ** (3) Initialize addrRecheck and lblRecheckOk
119707 **
119708 ** The uniqueness rechecking code will create a series of tests to run
119709 ** in a second pass. The addrRecheck and lblRecheckOk variables are
119710 ** used to link together these tests which are separated from each other
119711 ** in the generate bytecode.
119712 */
119713 if( (db->flags & (SQLITE_RecTriggers|SQLITE_ForeignKeys))==0 ){
119714 /* There are not DELETE triggers nor FK constraints. No constraint
119715 ** rechecks are needed. */
119716 pTrigger = 0;
119717 regTrigCnt = 0;
119718 }else{
119719 if( db->flags&SQLITE_RecTriggers ){
119720 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
119721 regTrigCnt = pTrigger!=0 || sqlite3FkRequired(pParse, pTab, 0, 0);
119722 }else{
119723 pTrigger = 0;
119724 regTrigCnt = sqlite3FkRequired(pParse, pTab, 0, 0);
119725 }
119726 if( regTrigCnt ){
119727 /* Replace triggers might exist. Allocate the counter and
119728 ** initialize it to zero. */
119729 regTrigCnt = ++pParse->nMem;
119730 sqlite3VdbeAddOp2(v, OP_Integer, 0, regTrigCnt);
119731 VdbeComment((v, "trigger count"));
119732 lblRecheckOk = sqlite3VdbeMakeLabel(pParse);
119733 addrRecheck = lblRecheckOk;
119734 }
119735 }
119736
119737 /* If rowid is changing, make sure the new rowid does not previously
119738 ** exist in the table.
119739 */
119740 if( pkChng && pPk==0 ){
@@ -118964,18 +119821,16 @@
119821 ** REPLACE INTO t(rowid) VALUES($newrowid)
119822 **
119823 ** to run without a statement journal if there are no indexes on the
119824 ** table.
119825 */
119826 if( regTrigCnt ){
 
 
 
 
119827 sqlite3MultiWrite(pParse);
119828 sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
119829 regNewData, 1, 0, OE_Replace, 1, -1);
119830 sqlite3VdbeAddOp2(v, OP_AddImm, regTrigCnt, 1); /* incr trigger cnt */
119831 nReplaceTrig++;
119832 }else{
119833 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
119834 assert( HasRowid(pTab) );
119835 /* This OP_Delete opcode fires the pre-update-hook only. It does
119836 ** not modify the b-tree. It is more efficient to let the coming
@@ -119021,10 +119876,11 @@
119876 for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){
119877 int regIdx; /* Range of registers hold conent for pIdx */
119878 int regR; /* Range of registers holding conflicting PK */
119879 int iThisCur; /* Cursor for this UNIQUE index */
119880 int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */
119881 int addrConflictCk; /* First opcode in the conflict check logic */
119882
119883 if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */
119884 if( pUpIdx==pIdx ){
119885 addrUniqueOk = upsertJump+1;
119886 upsertBypass = sqlite3VdbeGoto(v, 0);
@@ -119060,18 +119916,19 @@
119916 if( iField==XN_EXPR ){
119917 pParse->iSelfTab = -(regNewData+1);
119918 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
119919 pParse->iSelfTab = 0;
119920 VdbeComment((v, "%s column %d", pIdx->zName, i));
119921 }else if( iField==XN_ROWID || iField==pTab->iPKey ){
119922 x = regNewData;
119923 sqlite3VdbeAddOp2(v, OP_IntCopy, x, regIdx+i);
119924 VdbeComment((v, "rowid"));
119925 }else{
119926 testcase( sqlite3TableColumnToStorage(pTab, iField)!=iField );
119927 x = sqlite3TableColumnToStorage(pTab, iField) + regNewData + 1;
119928 sqlite3VdbeAddOp2(v, OP_SCopy, x, regIdx+i);
119929 VdbeComment((v, "%s", pTab->aCol[iField].zName));
119930 }
119931 }
119932 sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
119933 VdbeComment((v, "for %s", pIdx->zName));
119934 #ifdef SQLITE_ENABLE_NULL_TRIM
@@ -119134,12 +119991,13 @@
119991 }
119992 #endif /* ifndef SQLITE_ENABLE_PREUPDATE_HOOK */
119993
119994 /* Check to see if the new index entry will be unique */
119995 sqlite3VdbeVerifyAbortable(v, onError);
119996 addrConflictCk =
119997 sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
119998 regIdx, pIdx->nKeyCol); VdbeCoverage(v);
119999
120000 /* Generate code to handle collisions */
120001 regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);
120002 if( isUpdate || onError==OE_Replace ){
120003 if( HasRowid(pTab) ){
@@ -119156,11 +120014,11 @@
120014 /* Extract the PRIMARY KEY from the end of the index entry and
120015 ** store it in registers regR..regR+nPk-1 */
120016 if( pIdx!=pPk ){
120017 for(i=0; i<pPk->nKeyCol; i++){
120018 assert( pPk->aiColumn[i]>=0 );
120019 x = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]);
120020 sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i);
120021 VdbeComment((v, "%s.%s", pTab->zName,
120022 pTab->aCol[pPk->aiColumn[i]].zName));
120023 }
120024 }
@@ -119182,10 +120040,11 @@
120040 assert( x>=0 );
120041 if( i==(pPk->nKeyCol-1) ){
120042 addrJump = addrUniqueOk;
120043 op = OP_Eq;
120044 }
120045 x = sqlite3TableColumnToStorage(pTab, x);
120046 sqlite3VdbeAddOp4(v, op,
120047 regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ
120048 );
120049 sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
120050 VdbeCoverageIf(v, op==OP_Eq);
@@ -119218,21 +120077,69 @@
120077 testcase( onError==OE_Ignore );
120078 sqlite3VdbeGoto(v, ignoreDest);
120079 break;
120080 }
120081 default: {
120082 int nConflictCk; /* Number of opcodes in conflict check logic */
120083
120084 assert( onError==OE_Replace );
120085 nConflictCk = sqlite3VdbeCurrentAddr(v) - addrConflictCk;
120086 assert( nConflictCk>0 );
120087 testcase( nConflictCk>1 );
120088 if( regTrigCnt ){
120089 sqlite3MultiWrite(pParse);
120090 nReplaceTrig++;
120091 }
120092 sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
120093 regR, nPkField, 0, OE_Replace,
120094 (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
120095 if( regTrigCnt ){
120096 int addrBypass; /* Jump destination to bypass recheck logic */
120097
120098 sqlite3VdbeAddOp2(v, OP_AddImm, regTrigCnt, 1); /* incr trigger cnt */
120099 addrBypass = sqlite3VdbeAddOp0(v, OP_Goto); /* Bypass recheck */
120100 VdbeComment((v, "bypass recheck"));
120101
120102 /* Here we insert code that will be invoked after all constraint
120103 ** checks have run, if and only if one or more replace triggers
120104 ** fired. */
120105 sqlite3VdbeResolveLabel(v, lblRecheckOk);
120106 lblRecheckOk = sqlite3VdbeMakeLabel(pParse);
120107 if( pIdx->pPartIdxWhere ){
120108 /* Bypass the recheck if this partial index is not defined
120109 ** for the current row */
120110 sqlite3VdbeAddOp2(v, OP_IsNull, regIdx-1, lblRecheckOk);
120111 VdbeCoverage(v);
120112 }
120113 /* Copy the constraint check code from above, except change
120114 ** the constraint-ok jump destination to be the address of
120115 ** the next retest block */
120116 while( nConflictCk>0 ){
120117 VdbeOp x; /* Conflict check opcode to copy */
120118 /* The sqlite3VdbeAddOp4() call might reallocate the opcode array.
120119 ** Hence, make a complete copy of the opcode, rather than using
120120 ** a pointer to the opcode. */
120121 x = *sqlite3VdbeGetOp(v, addrConflictCk);
120122 if( x.opcode!=OP_IdxRowid ){
120123 int p2; /* New P2 value for copied conflict check opcode */
120124 if( sqlite3OpcodeProperty[x.opcode]&OPFLG_JUMP ){
120125 p2 = lblRecheckOk;
120126 }else{
120127 p2 = x.p2;
120128 }
120129 sqlite3VdbeAddOp4(v, x.opcode, x.p1, p2, x.p3, x.p4.z, x.p4type);
120130 sqlite3VdbeChangeP5(v, x.p5);
120131 VdbeCoverageIf(v, p2!=x.p2);
120132 }
120133 nConflictCk--;
120134 addrConflictCk++;
120135 }
120136 /* If the retest fails, issue an abort */
120137 sqlite3UniqueConstraint(pParse, OE_Abort, pIdx);
120138
120139 sqlite3VdbeJumpHere(v, addrBypass); /* Terminate the recheck bypass */
120140 }
120141 seenReplace = 1;
120142 break;
120143 }
120144 }
120145 if( pUpIdx==pIdx ){
@@ -119248,15 +120155,35 @@
120155 if( ipkTop ){
120156 sqlite3VdbeGoto(v, ipkTop);
120157 VdbeComment((v, "Do IPK REPLACE"));
120158 sqlite3VdbeJumpHere(v, ipkBottom);
120159 }
120160
120161 /* Recheck all uniqueness constraints after replace triggers have run */
120162 testcase( regTrigCnt!=0 && nReplaceTrig==0 );
120163 assert( regTrigCnt!=0 || nReplaceTrig==0 );
120164 if( nReplaceTrig ){
120165 sqlite3VdbeAddOp2(v, OP_IfNot, regTrigCnt, lblRecheckOk);VdbeCoverage(v);
120166 if( !pPk ){
120167 if( isUpdate ){
120168 sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRecheck, regOldData);
120169 sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
120170 VdbeCoverage(v);
120171 }
120172 sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRecheck, regNewData);
120173 VdbeCoverage(v);
120174 sqlite3RowidConstraint(pParse, OE_Abort, pTab);
120175 }else{
120176 sqlite3VdbeGoto(v, addrRecheck);
120177 }
120178 sqlite3VdbeResolveLabel(v, lblRecheckOk);
120179 }
120180
120181 /* Generate the table record */
120182 if( HasRowid(pTab) ){
120183 int regRec = aRegIdx[ix];
120184 sqlite3VdbeAddOp3(v, OP_MakeRecord, regNewData+1, pTab->nNVCol, regRec);
120185 sqlite3SetMakeRecordP5(v, pTab);
120186 if( !bAffinityDone ){
120187 sqlite3TableAffinity(v, pTab, 0);
120188 }
120189 }
@@ -119469,11 +120396,11 @@
120396 */
120397 static int xferCompatibleIndex(Index *pDest, Index *pSrc){
120398 int i;
120399 assert( pDest && pSrc );
120400 assert( pDest->pTable!=pSrc->pTable );
120401 if( pDest->nKeyCol!=pSrc->nKeyCol || pDest->nColumn!=pSrc->nColumn ){
120402 return 0; /* Different number of columns */
120403 }
120404 if( pDest->onError!=pSrc->onError ){
120405 return 0; /* Different conflict resolution strategies */
120406 }
@@ -119646,10 +120573,43 @@
120573 if( (db->mDbFlags & DBFLAG_Vacuum)==0
120574 && (pDestCol->colFlags | pSrcCol->colFlags) & COLFLAG_HIDDEN
120575 ){
120576 return 0; /* Neither table may have __hidden__ columns */
120577 }
120578 #endif
120579 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
120580 /* Even if tables t1 and t2 have identical schemas, if they contain
120581 ** generated columns, then this statement is semantically incorrect:
120582 **
120583 ** INSERT INTO t2 SELECT * FROM t1;
120584 **
120585 ** The reason is that generated column values are returned by the
120586 ** the SELECT statement on the right but the INSERT statement on the
120587 ** left wants them to be omitted.
120588 **
120589 ** Nevertheless, this is a useful notational shorthand to tell SQLite
120590 ** to do a bulk transfer all of the content from t1 over to t2.
120591 **
120592 ** We could, in theory, disable this (except for internal use by the
120593 ** VACUUM command where it is actually needed). But why do that? It
120594 ** seems harmless enough, and provides a useful service.
120595 */
120596 if( (pDestCol->colFlags & COLFLAG_GENERATED) !=
120597 (pSrcCol->colFlags & COLFLAG_GENERATED) ){
120598 return 0; /* Both columns have the same generated-column type */
120599 }
120600 /* But the transfer is only allowed if both the source and destination
120601 ** tables have the exact same expressions for generated columns.
120602 ** This requirement could be relaxed for VIRTUAL columns, I suppose.
120603 */
120604 if( (pDestCol->colFlags & COLFLAG_GENERATED)!=0 ){
120605 if( sqlite3ExprCompare(0, pSrcCol->pDflt, pDestCol->pDflt, -1)!=0 ){
120606 testcase( pDestCol->colFlags & COLFLAG_VIRTUAL );
120607 testcase( pDestCol->colFlags & COLFLAG_STORED );
120608 return 0; /* Different generator expressions */
120609 }
120610 }
120611 #endif
120612 if( pDestCol->affinity!=pSrcCol->affinity ){
120613 return 0; /* Affinity must be the same on all columns */
120614 }
120615 if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){
@@ -119657,11 +120617,11 @@
120617 }
120618 if( pDestCol->notNull && !pSrcCol->notNull ){
120619 return 0; /* tab2 must be NOT NULL if tab1 is */
120620 }
120621 /* Default values for second and subsequent columns need to match. */
120622 if( (pDestCol->colFlags & COLFLAG_GENERATED)==0 && i>0 ){
120623 assert( pDestCol->pDflt==0 || pDestCol->pDflt->op==TK_SPAN );
120624 assert( pSrcCol->pDflt==0 || pSrcCol->pDflt->op==TK_SPAN );
120625 if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0)
120626 || (pDestCol->pDflt && strcmp(pDestCol->pDflt->u.zToken,
120627 pSrcCol->pDflt->u.zToken)!=0)
@@ -120342,10 +121302,11 @@
121302 /* Version 3.28.0 and later */
121303 int (*stmt_isexplain)(sqlite3_stmt*);
121304 int (*value_frombind)(sqlite3_value*);
121305 /* Version 3.30.0 and later */
121306 int (*drop_modules)(sqlite3*,const char**);
121307 sqlite3_int64 (*hard_heap_limit64)(sqlite3_int64);
121308 };
121309
121310 /*
121311 ** This is the function signature used for all extension entry points. It
121312 ** is also defined in the file "loadext.c".
@@ -120636,10 +121597,11 @@
121597 /* Version 3.28.0 and later */
121598 #define sqlite3_stmt_isexplain sqlite3_api->isexplain
121599 #define sqlite3_value_frombind sqlite3_api->frombind
121600 /* Version 3.30.0 and later */
121601 #define sqlite3_drop_modules sqlite3_api->drop_modules
121602 #define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64
121603 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
121604
121605 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
121606 /* This case when the file really is being compiled as a loadable
121607 ** extension */
@@ -121108,10 +122070,12 @@
122070 #ifndef SQLITE_OMIT_VIRTUALTABLE
122071 sqlite3_drop_modules,
122072 #else
122073 0,
122074 #endif
122075 /* Version 3.31.0 and later */
122076 sqlite3_hard_heap_limit64,
122077 };
122078
122079 /*
122080 ** Attempt to load an SQLite extension library contained in the file
122081 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -121530,38 +122494,39 @@
122494 #define PragTyp_DEFAULT_CACHE_SIZE 11
122495 #define PragTyp_ENCODING 12
122496 #define PragTyp_FOREIGN_KEY_CHECK 13
122497 #define PragTyp_FOREIGN_KEY_LIST 14
122498 #define PragTyp_FUNCTION_LIST 15
122499 #define PragTyp_HARD_HEAP_LIMIT 16
122500 #define PragTyp_INCREMENTAL_VACUUM 17
122501 #define PragTyp_INDEX_INFO 18
122502 #define PragTyp_INDEX_LIST 19
122503 #define PragTyp_INTEGRITY_CHECK 20
122504 #define PragTyp_JOURNAL_MODE 21
122505 #define PragTyp_JOURNAL_SIZE_LIMIT 22
122506 #define PragTyp_LOCK_PROXY_FILE 23
122507 #define PragTyp_LOCKING_MODE 24
122508 #define PragTyp_PAGE_COUNT 25
122509 #define PragTyp_MMAP_SIZE 26
122510 #define PragTyp_MODULE_LIST 27
122511 #define PragTyp_OPTIMIZE 28
122512 #define PragTyp_PAGE_SIZE 29
122513 #define PragTyp_PRAGMA_LIST 30
122514 #define PragTyp_SECURE_DELETE 31
122515 #define PragTyp_SHRINK_MEMORY 32
122516 #define PragTyp_SOFT_HEAP_LIMIT 33
122517 #define PragTyp_SYNCHRONOUS 34
122518 #define PragTyp_TABLE_INFO 35
122519 #define PragTyp_TEMP_STORE 36
122520 #define PragTyp_TEMP_STORE_DIRECTORY 37
122521 #define PragTyp_THREADS 38
122522 #define PragTyp_WAL_AUTOCHECKPOINT 39
122523 #define PragTyp_WAL_CHECKPOINT 40
122524 #define PragTyp_ACTIVATE_EXTENSIONS 41
122525 #define PragTyp_KEY 42
122526 #define PragTyp_LOCK_STATUS 43
122527 #define PragTyp_STATS 44
122528
122529 /* Property flags associated with various pragma. */
122530 #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
122531 #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
122532 #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -121828,10 +122793,15 @@
122793 /* ePragFlg: */ PragFlg_Result0,
122794 /* ColNames: */ 41, 2,
122795 /* iArg: */ 0 },
122796 #endif
122797 #endif
122798 {/* zName: */ "hard_heap_limit",
122799 /* ePragTyp: */ PragTyp_HARD_HEAP_LIMIT,
122800 /* ePragFlg: */ PragFlg_Result0,
122801 /* ColNames: */ 0, 0,
122802 /* iArg: */ 0 },
122803 #if defined(SQLITE_HAS_CODEC)
122804 {/* zName: */ "hexkey",
122805 /* ePragTyp: */ PragTyp_KEY,
122806 /* ePragFlg: */ 0,
122807 /* ColNames: */ 0, 0,
@@ -121905,15 +122875,10 @@
122875 {/* zName: */ "legacy_alter_table",
122876 /* ePragTyp: */ PragTyp_FLAG,
122877 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
122878 /* ColNames: */ 0, 0,
122879 /* iArg: */ SQLITE_LegacyAlter },
 
 
 
 
 
122880 #endif
122881 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE
122882 {/* zName: */ "lock_proxy_file",
122883 /* ePragTyp: */ PragTyp_LOCK_PROXY_FILE,
122884 /* ePragFlg: */ PragFlg_NoColumns1,
@@ -123252,29 +124217,38 @@
124217 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
124218 pParse->nMem = 7;
124219 sqlite3CodeVerifySchema(pParse, iTabDb);
124220 sqlite3ViewGetColumnNames(pParse, pTab);
124221 for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
124222 int isHidden = 0;
124223 if( pCol->colFlags & COLFLAG_NOINSERT ){
124224 if( pPragma->iArg==0 ){
124225 nHidden++;
124226 continue;
124227 }
124228 if( pCol->colFlags & COLFLAG_VIRTUAL ){
124229 isHidden = 2; /* GENERATED ALWAYS AS ... VIRTUAL */
124230 }else if( pCol->colFlags & COLFLAG_STORED ){
124231 isHidden = 3; /* GENERATED ALWAYS AS ... STORED */
124232 }else{ assert( pCol->colFlags & COLFLAG_HIDDEN );
124233 isHidden = 1; /* HIDDEN */
124234 }
124235 }
124236 if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
124237 k = 0;
124238 }else if( pPk==0 ){
124239 k = 1;
124240 }else{
124241 for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
124242 }
124243 assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN || isHidden>=2 );
124244 sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? "issisii" : "issisi",
124245 i-nHidden,
124246 pCol->zName,
124247 sqlite3ColumnType(pCol,""),
124248 pCol->notNull ? 1 : 0,
124249 pCol->pDflt && isHidden<2 ? pCol->pDflt->u.zToken : 0,
124250 k,
124251 isHidden);
124252 }
124253 }
124254 }
@@ -123729,11 +124703,11 @@
124703 assert( sqlite3NoTempsInRange(pParse,1,7+j) );
124704 sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
124705 loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
124706 if( !isQuick ){
124707 /* Sanity check on record header decoding */
124708 sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nNVCol-1,3);
124709 sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
124710 }
124711 /* Verify that all NOT NULL columns really are NOT NULL */
124712 for(j=0; j<pTab->nCol; j++){
124713 char *zErr;
@@ -124231,10 +125205,31 @@
125205 sqlite3_soft_heap_limit64(N);
125206 }
125207 returnSingleInt(v, sqlite3_soft_heap_limit64(-1));
125208 break;
125209 }
125210
125211 /*
125212 ** PRAGMA hard_heap_limit
125213 ** PRAGMA hard_heap_limit = N
125214 **
125215 ** Invoke sqlite3_hard_heap_limit64() to query or set the hard heap
125216 ** limit. The hard heap limit can be activated or lowered by this
125217 ** pragma, but not raised or deactivated. Only the
125218 ** sqlite3_hard_heap_limit64() C-language API can raise or deactivate
125219 ** the hard heap limit. This allows an application to set a heap limit
125220 ** constraint that cannot be relaxed by an untrusted SQL script.
125221 */
125222 case PragTyp_HARD_HEAP_LIMIT: {
125223 sqlite3_int64 N;
125224 if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){
125225 sqlite3_int64 iPrior = sqlite3_hard_heap_limit64(-1);
125226 if( N>0 && (iPrior==0 || iPrior>N) ) sqlite3_hard_heap_limit64(N);
125227 }
125228 returnSingleInt(v, sqlite3_hard_heap_limit64(-1));
125229 break;
125230 }
125231
125232 /*
125233 ** PRAGMA threads
125234 ** PRAGMA threads = N
125235 **
@@ -124724,10 +125719,22 @@
125719 for(p=pIndex->pTable->pIndex; p; p=p->pNext){
125720 if( p->tnum==pIndex->tnum && p!=pIndex ) return 1;
125721 }
125722 return 0;
125723 }
125724
125725 /* forward declaration */
125726 static int sqlite3Prepare(
125727 sqlite3 *db, /* Database handle. */
125728 const char *zSql, /* UTF-8 encoded SQL statement. */
125729 int nBytes, /* Length of zSql in bytes. */
125730 u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
125731 Vdbe *pReprepare, /* VM being reprepared */
125732 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
125733 const char **pzTail /* OUT: End of parsed string */
125734 );
125735
125736
125737 /*
125738 ** This is the callback routine for the code that initializes the
125739 ** database. See sqlite3Init() below for additional information.
125740 ** This routine is also called from the OP_ParseSchema opcode of the VDBE.
@@ -124774,11 +125781,12 @@
125781 assert( db->init.busy );
125782 db->init.iDb = iDb;
125783 db->init.newTnum = sqlite3Atoi(argv[3]);
125784 db->init.orphanTrigger = 0;
125785 db->init.azInit = argv;
125786 pStmt = 0;
125787 TESTONLY(rcp = ) sqlite3Prepare(db, argv[4], -1, 0, 0, &pStmt, 0);
125788 rc = db->errCode;
125789 assert( (rc&0xFF)==(rcp&0xFF) );
125790 db->init.iDb = saved_iDb;
125791 /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */
125792 if( SQLITE_OK!=rc ){
@@ -125195,10 +126203,11 @@
126203 sqlite3DbFree(db, pParse->aLabel);
126204 sqlite3ExprListDelete(db, pParse->pConstExpr);
126205 if( db ){
126206 assert( db->lookaside.bDisable >= pParse->disableLookaside );
126207 db->lookaside.bDisable -= pParse->disableLookaside;
126208 db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue;
126209 }
126210 pParse->disableLookaside = 0;
126211 }
126212
126213 /*
@@ -125228,11 +126237,11 @@
126237 /* For a long-term use prepared statement avoid the use of
126238 ** lookaside memory.
126239 */
126240 if( prepFlags & SQLITE_PREPARE_PERSISTENT ){
126241 sParse.disableLookaside++;
126242 DisableLookaside;
126243 }
126244 sParse.disableVtab = (prepFlags & SQLITE_PREPARE_NO_VTAB)!=0;
126245
126246 /* Check to verify that it is possible to get a read lock on all
126247 ** database schemas. The inability to get a read lock indicates that
@@ -125255,20 +126264,22 @@
126264 **
126265 ** Note that setting READ_UNCOMMITTED overrides most lock detection,
126266 ** but it does *not* override schema lock detection, so this all still
126267 ** works even if READ_UNCOMMITTED is set.
126268 */
126269 if( !db->noSharedCache ){
126270 for(i=0; i<db->nDb; i++) {
126271 Btree *pBt = db->aDb[i].pBt;
126272 if( pBt ){
126273 assert( sqlite3BtreeHoldsMutex(pBt) );
126274 rc = sqlite3BtreeSchemaLocked(pBt);
126275 if( rc ){
126276 const char *zDb = db->aDb[i].zDbSName;
126277 sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
126278 testcase( db->flags & SQLITE_ReadUncommit );
126279 goto end_prepare;
126280 }
126281 }
126282 }
126283 }
126284
126285 sqlite3VtabUnlockList(db);
@@ -125295,52 +126306,28 @@
126306 }else{
126307 sqlite3RunParser(&sParse, zSql, &zErrMsg);
126308 }
126309 assert( 0==sParse.nQueryLoop );
126310
126311 if( sParse.rc==SQLITE_DONE ){
126312 sParse.rc = SQLITE_OK;
126313 }
126314 if( sParse.checkSchema ){
126315 schemaIsValid(&sParse);
126316 }
 
 
 
126317 if( pzTail ){
126318 *pzTail = sParse.zTail;
126319 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126320
126321 if( db->init.busy==0 ){
126322 sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);
126323 }
126324 if( db->mallocFailed ){
126325 sParse.rc = SQLITE_NOMEM_BKPT;
126326 }
126327 rc = sParse.rc;
126328 if( rc!=SQLITE_OK ){
126329 if( sParse.pVdbe ) sqlite3VdbeFinalize(sParse.pVdbe);
126330 assert(!(*ppStmt));
126331 }else{
126332 *ppStmt = (sqlite3_stmt*)sParse.pVdbe;
126333 }
@@ -125708,13 +126695,13 @@
126695 sqlite3ExprDelete(db, p->pLimit);
126696 #ifndef SQLITE_OMIT_WINDOWFUNC
126697 if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){
126698 sqlite3WindowListDelete(db, p->pWinDefn);
126699 }
 
 
126700 assert( p->pWin==0 );
126701 #endif
126702 if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);
126703 if( bFree ) sqlite3DbFreeNN(db, p);
126704 p = pPrior;
126705 bFree = 1;
126706 }
126707 }
@@ -125993,28 +126980,28 @@
126980 ** NULL t2 row will be inserted whenever t1.x!=5. If we do not
126981 ** defer the handling of t1.x=5, it will be processed immediately
126982 ** after the t1 loop and rows with t1.x!=5 will never appear in
126983 ** the output, which is incorrect.
126984 */
126985 SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){
126986 while( p ){
126987 ExprSetProperty(p, EP_FromJoin);
126988 assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
126989 ExprSetVVAProperty(p, EP_NoReduce);
126990 p->iRightJoinTable = (i16)iTable;
126991 if( p->op==TK_FUNCTION && p->x.pList ){
126992 int i;
126993 for(i=0; i<p->x.pList->nExpr; i++){
126994 sqlite3SetJoinExpr(p->x.pList->a[i].pExpr, iTable);
126995 }
126996 }
126997 sqlite3SetJoinExpr(p->pLeft, iTable);
126998 p = p->pRight;
126999 }
127000 }
127001
127002 /* Undo the work of sqlite3SetJoinExpr(). In the expression p, convert every
127003 ** term that is marked with EP_FromJoin and iRightJoinTable==iTable into
127004 ** an ordinary term that omits the EP_FromJoin mark.
127005 **
127006 ** This happens when a LEFT JOIN is simplified into an ordinary JOIN.
127007 */
@@ -126097,11 +127084,11 @@
127084
127085 /* Add the ON clause to the end of the WHERE clause, connected by
127086 ** an AND operator.
127087 */
127088 if( pRight->pOn ){
127089 if( isOuter ) sqlite3SetJoinExpr(pRight->pOn, pRight->iCursor);
127090 p->pWhere = sqlite3ExprAnd(pParse, p->pWhere, pRight->pOn);
127091 pRight->pOn = 0;
127092 }
127093
127094 /* Create extra terms on the WHERE clause for each column named
@@ -126277,10 +127264,11 @@
127264 memset(pKI->aSortFlags, 0, pKI->nKeyField); /* Makes OP_Jump testable */
127265 sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
127266 testcase( pKI->nAllField > pKI->nKeyField+2 );
127267 pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat,
127268 pKI->nAllField-pKI->nKeyField-1);
127269 pOp = 0; /* Ensure pOp not used after sqltie3VdbeAddOp3() */
127270 addrJmp = sqlite3VdbeCurrentAddr(v);
127271 sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
127272 pSort->labelBkOut = sqlite3VdbeMakeLabel(pParse);
127273 pSort->regReturn = ++pParse->nMem;
127274 sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
@@ -126639,10 +127627,11 @@
127627 sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);
127628 pOp = sqlite3VdbeGetOp(v, pDistinct->addrTnct);
127629 pOp->opcode = OP_Null;
127630 pOp->p1 = 1;
127631 pOp->p2 = regPrev;
127632 pOp = 0; /* Ensure pOp is not used after sqlite3VdbeAddOp() */
127633
127634 iJump = sqlite3VdbeCurrentAddr(v) + nResultCol;
127635 for(i=0; i<nResultCol; i++){
127636 CollSeq *pColl = sqlite3ExprCollSeq(pParse, p->pEList->a[i].pExpr);
127637 if( i<nResultCol-1 ){
@@ -129111,10 +130100,18 @@
130100 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
130101 substSelect(pSubst, pExpr->x.pSelect, 1);
130102 }else{
130103 substExprList(pSubst, pExpr->x.pList);
130104 }
130105 #ifndef SQLITE_OMIT_WINDOWFUNC
130106 if( ExprHasProperty(pExpr, EP_WinFunc) ){
130107 Window *pWin = pExpr->y.pWin;
130108 pWin->pFilter = substExpr(pSubst, pWin->pFilter);
130109 substExprList(pSubst, pWin->pPartition);
130110 substExprList(pSubst, pWin->pOrderBy);
130111 }
130112 #endif
130113 }
130114 return pExpr;
130115 }
130116 static void substExprList(
130117 SubstContext *pSubst, /* Description of the substitution */
@@ -129653,11 +130650,11 @@
130650 pSub->pOrderBy = 0;
130651 }
130652 pWhere = pSub->pWhere;
130653 pSub->pWhere = 0;
130654 if( isLeftJoin>0 ){
130655 sqlite3SetJoinExpr(pWhere, iNewParent);
130656 }
130657 pParent->pWhere = sqlite3ExprAnd(pParse, pWhere, pParent->pWhere);
130658 if( db->mallocFailed==0 ){
130659 SubstContext x;
130660 x.pParse = pParse;
@@ -129770,18 +130767,18 @@
130767 assert( pRight!=0 );
130768 assert( pLeft!=0 );
130769 if( pRight->op==TK_COLUMN
130770 && !ExprHasProperty(pRight, EP_FixedCol)
130771 && sqlite3ExprIsConstant(pLeft)
130772 && sqlite3IsBinary(sqlite3ExprCompareCollSeq(pConst->pParse,pExpr))
130773 ){
130774 constInsert(pConst, pRight, pLeft);
130775 }else
130776 if( pLeft->op==TK_COLUMN
130777 && !ExprHasProperty(pLeft, EP_FixedCol)
130778 && sqlite3ExprIsConstant(pRight)
130779 && sqlite3IsBinary(sqlite3ExprCompareCollSeq(pConst->pParse,pExpr))
130780 ){
130781 constInsert(pConst, pLeft, pRight);
130782 }
130783 }
130784
@@ -130266,10 +131263,13 @@
131263 sqlite3 *db = pParse->db;
131264 struct Cte *pCte; /* Matched CTE (or NULL if no match) */
131265 With *pWith; /* WITH clause that pCte belongs to */
131266
131267 assert( pFrom->pTab==0 );
131268 if( pParse->nErr ){
131269 return SQLITE_ERROR;
131270 }
131271
131272 pCte = searchWith(pParse->pWith, pFrom, &pWith);
131273 if( pCte ){
131274 Table *pTab;
131275 ExprList *pEList;
@@ -131327,11 +132327,11 @@
132327 #ifndef SQLITE_OMIT_WINDOWFUNC
132328 if( sqlite3WindowRewrite(pParse, p) ){
132329 goto select_end;
132330 }
132331 #if SELECTTRACE_ENABLED
132332 if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){
132333 SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n"));
132334 sqlite3TreeViewSelect(0, p, 0);
132335 }
132336 #endif
132337 #endif /* SQLITE_OMIT_WINDOWFUNC */
@@ -133864,11 +134864,11 @@
134864 int onError, /* How to handle constraint errors */
134865 ExprList *pOrderBy, /* ORDER BY clause. May be null */
134866 Expr *pLimit, /* LIMIT clause. May be null */
134867 Upsert *pUpsert /* ON CONFLICT clause, or null */
134868 ){
134869 int i, j, k; /* Loop counters */
134870 Table *pTab; /* The table to be updated */
134871 int addrTop = 0; /* VDBE instruction address of the start of the loop */
134872 WhereInfo *pWInfo; /* Information about the WHERE clause */
134873 Vdbe *v; /* The virtual database engine */
134874 Index *pIdx; /* For looping over indices */
@@ -134006,10 +135006,14 @@
135006 sNC.pParse = pParse;
135007 sNC.pSrcList = pTabList;
135008 sNC.uNC.pUpsert = pUpsert;
135009 sNC.ncFlags = NC_UUpsert;
135010
135011 /* Begin generating code. */
135012 v = sqlite3GetVdbe(pParse);
135013 if( v==0 ) goto update_cleanup;
135014
135015 /* Resolve the column names in all the expressions of the
135016 ** of the UPDATE statement. Also find the column index
135017 ** for each column to be updated in the pChanges array. For each
135018 ** column to be updated, make sure we have authorization to change
135019 ** that column.
@@ -134025,10 +135029,20 @@
135029 chngRowid = 1;
135030 pRowidExpr = pChanges->a[i].pExpr;
135031 }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){
135032 chngPk = 1;
135033 }
135034 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
135035 else if( pTab->aCol[j].colFlags & COLFLAG_GENERATED ){
135036 testcase( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL );
135037 testcase( pTab->aCol[j].colFlags & COLFLAG_STORED );
135038 sqlite3ErrorMsg(pParse,
135039 "cannot UPDATE generated column \"%s\"",
135040 pTab->aCol[j].zName);
135041 goto update_cleanup;
135042 }
135043 #endif
135044 aXRef[j] = i;
135045 break;
135046 }
135047 }
135048 if( j>=pTab->nCol ){
@@ -134058,10 +135072,37 @@
135072 }
135073 assert( (chngRowid & chngPk)==0 );
135074 assert( chngRowid==0 || chngRowid==1 );
135075 assert( chngPk==0 || chngPk==1 );
135076 chngKey = chngRowid + chngPk;
135077
135078 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
135079 /* Mark generated columns as changing if their generator expressions
135080 ** reference any changing column. The actual aXRef[] value for
135081 ** generated expressions is not used, other than to check to see that it
135082 ** is non-negative, so the value of aXRef[] for generated columns can be
135083 ** set to any non-negative number. We use 99999 so that the value is
135084 ** obvious when looking at aXRef[] in a symbolic debugger.
135085 */
135086 if( pTab->tabFlags & TF_HasGenerated ){
135087 int bProgress;
135088 testcase( pTab->tabFlags & TF_HasVirtual );
135089 testcase( pTab->tabFlags & TF_HasStored );
135090 do{
135091 bProgress = 0;
135092 for(i=0; i<pTab->nCol; i++){
135093 if( aXRef[i]>=0 ) continue;
135094 if( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 ) continue;
135095 if( sqlite3ExprReferencesUpdatedColumn(pTab->aCol[i].pDflt,
135096 aXRef, chngRowid) ){
135097 aXRef[i] = 99999;
135098 bProgress = 1;
135099 }
135100 }
135101 }while( bProgress );
135102 }
135103 #endif
135104
135105 /* The SET expressions are not actually used inside the WHERE loop.
135106 ** So reset the colUsed mask. Unless this is a virtual table. In that
135107 ** case, set all bits of the colUsed mask (to ensure that the virtual
135108 ** table implementation makes all columns available).
@@ -134103,13 +135144,10 @@
135144 /* If REPLACE conflict resolution might be invoked, open cursors on all
135145 ** indexes in case they are needed to delete records. */
135146 memset(aToOpen, 1, nIdx+1);
135147 }
135148
 
 
 
135149 if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
135150 sqlite3BeginWriteOperation(pParse, pTrigger || hasFK, iDb);
135151
135152 /* Allocate required registers. */
135153 if( !IsVirtual(pTab) ){
@@ -134259,11 +135297,12 @@
135297 ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change
135298 ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table
135299 ** is not required) and leave the PK fields in the array of registers. */
135300 for(i=0; i<nPk; i++){
135301 assert( pPk->aiColumn[i]>=0 );
135302 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,
135303 pPk->aiColumn[i], iPk+i);
135304 }
135305 if( eOnePass ){
135306 if( addrOpen ) sqlite3VdbeChangeToNoop(v, addrOpen);
135307 nKey = nPk;
135308 regKey = iPk;
@@ -134340,18 +135379,20 @@
135379 u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);
135380 oldmask |= sqlite3TriggerColmask(pParse,
135381 pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError
135382 );
135383 for(i=0; i<pTab->nCol; i++){
135384 u32 colFlags = pTab->aCol[i].colFlags;
135385 k = sqlite3TableColumnToStorage(pTab, i) + regOld;
135386 if( oldmask==0xffffffff
135387 || (i<32 && (oldmask & MASKBIT32(i))!=0)
135388 || (colFlags & COLFLAG_PRIMKEY)!=0
135389 ){
135390 testcase( oldmask!=0xffffffff && i==31 );
135391 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, k);
135392 }else{
135393 sqlite3VdbeAddOp2(v, OP_Null, 0, k);
135394 }
135395 }
135396 if( chngRowid==0 && pPk==0 ){
135397 sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);
135398 }
@@ -134371,31 +135412,40 @@
135412 ** be used eliminates some redundant opcodes.
135413 */
135414 newmask = sqlite3TriggerColmask(
135415 pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError
135416 );
135417 for(i=0, k=regNew; i<pTab->nCol; i++, k++){
135418 if( i==pTab->iPKey ){
135419 sqlite3VdbeAddOp2(v, OP_Null, 0, k);
135420 }else if( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)!=0 ){
135421 if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ) k--;
135422 }else{
135423 j = aXRef[i];
135424 if( j>=0 ){
135425 sqlite3ExprCode(pParse, pChanges->a[j].pExpr, k);
135426 }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){
135427 /* This branch loads the value of a column that will not be changed
135428 ** into a register. This is done if there are no BEFORE triggers, or
135429 ** if there are one or more BEFORE triggers that use this value via
135430 ** a new.* reference in a trigger program.
135431 */
135432 testcase( i==31 );
135433 testcase( i==32 );
135434 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, k);
135435 }else{
135436 sqlite3VdbeAddOp2(v, OP_Null, 0, k);
135437 }
135438 }
135439 }
135440 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
135441 if( pTab->tabFlags & TF_HasGenerated ){
135442 testcase( pTab->tabFlags & TF_HasVirtual );
135443 testcase( pTab->tabFlags & TF_HasStored );
135444 sqlite3ComputeGeneratedColumns(pParse, regNew, pTab);
135445 }
135446 #endif
135447
135448 /* Fire any BEFORE UPDATE triggers. This happens before constraints are
135449 ** verified. One could argue that this is wrong.
135450 */
135451 if( tmask&TRIGGER_BEFORE ){
@@ -134424,15 +135474,24 @@
135474 ** in case this has happened. Only unmodified columns are reloaded.
135475 ** The values computed for modified columns use the values before the
135476 ** BEFORE trigger runs. See test case trigger1-18.0 (added 2018-04-26)
135477 ** for an example.
135478 */
135479 for(i=0, k=regNew; i<pTab->nCol; i++, k++){
135480 if( pTab->aCol[i].colFlags & COLFLAG_GENERATED ){
135481 if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ) k--;
135482 }else if( aXRef[i]<0 && i!=pTab->iPKey ){
135483 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, k);
135484 }
135485 }
135486 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
135487 if( pTab->tabFlags & TF_HasGenerated ){
135488 testcase( pTab->tabFlags & TF_HasVirtual );
135489 testcase( pTab->tabFlags & TF_HasStored );
135490 sqlite3ComputeGeneratedColumns(pParse, regNew, pTab);
135491 }
135492 #endif
135493 }
135494
135495 if( !isView ){
135496 /* Do constraint checks. */
135497 assert( regOldRowid>0 );
@@ -134634,10 +135693,11 @@
135693 pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0,0,WHERE_ONEPASS_DESIRED,0);
135694 if( pWInfo==0 ) return;
135695
135696 /* Populate the argument registers. */
135697 for(i=0; i<pTab->nCol; i++){
135698 assert( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 );
135699 if( aXRef[i]>=0 ){
135700 sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);
135701 }else{
135702 sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i);
135703 sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG);/* Enable sqlite3_vtab_nochange() */
@@ -134944,11 +136004,11 @@
136004 int iPk = pParse->nMem+1;
136005 pParse->nMem += nPk;
136006 for(i=0; i<nPk; i++){
136007 int k;
136008 assert( pPk->aiColumn[i]>=0 );
136009 k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]);
136010 sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i);
136011 VdbeComment((v, "%s.%s", pIdx->zName,
136012 pTab->aCol[pPk->aiColumn[i]].zName));
136013 }
136014 sqlite3VdbeVerifyAbortable(v, OE_Abort);
@@ -135702,16 +136762,16 @@
136762 ** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously
136763 ** by multiple threads. It is thread-safe.
136764 */
136765 SQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3 *db){
136766 VTable *p = db->pDisconnect;
 
136767
136768 assert( sqlite3BtreeHoldsAllMutexes(db) );
136769 assert( sqlite3_mutex_held(db->mutex) );
136770
136771 if( p ){
136772 db->pDisconnect = 0;
136773 sqlite3ExpirePreparedStatements(db, 0);
136774 do {
136775 VTable *pNext = p->pNext;
136776 sqlite3VtabUnlock(p);
136777 p = pNext;
@@ -136021,11 +137081,11 @@
137081 *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
137082 sqlite3VtabUnlock(pVTable);
137083 rc = SQLITE_ERROR;
137084 }else{
137085 int iCol;
137086 u16 oooHidden = 0;
137087 /* If everything went according to plan, link the new VTable structure
137088 ** into the linked list headed by pTab->pVTable. Then loop through the
137089 ** columns of the table to see if any of them contain the token "hidden".
137090 ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from
137091 ** the type string. */
@@ -137017,11 +138077,10 @@
138077 #define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
138078 #define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
138079 #define TERM_LIKE 0x400 /* The original LIKE operator */
138080 #define TERM_IS 0x800 /* Term.pExpr is an IS operator */
138081 #define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
 
138082
138083 /*
138084 ** An instance of the WhereScan object is used as an iterator for locating
138085 ** terms in the WHERE clause that are useful to the query planner.
138086 */
@@ -138125,11 +139184,11 @@
139184 static int codeCursorHintCheckExpr(Walker *pWalker, Expr *pExpr){
139185 struct CCurHint *pHint = pWalker->u.pCCurHint;
139186 assert( pHint->pIdx!=0 );
139187 if( pExpr->op==TK_COLUMN
139188 && pExpr->iTable==pHint->iTabCur
139189 && sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn)<0
139190 ){
139191 pWalker->eCode = 1;
139192 }
139193 return WRC_Continue;
139194 }
@@ -138193,11 +139252,11 @@
139252 sqlite3ExprCode(pWalker->pParse, pExpr, reg);
139253 pExpr->op = TK_REGISTER;
139254 pExpr->iTable = reg;
139255 }else if( pHint->pIdx!=0 ){
139256 pExpr->iTable = pHint->iIdxCur;
139257 pExpr->iColumn = sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn);
139258 assert( pExpr->iColumn>=0 );
139259 }
139260 }else if( pExpr->op==TK_AGG_FUNCTION ){
139261 /* An aggregate function in the WHERE clause of a query means this must
139262 ** be a correlated sub-query, and expression pExpr is an aggregate from
@@ -138356,12 +139415,16 @@
139415 Table *pTab = pIdx->pTable;
139416 int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));
139417 if( ai ){
139418 ai[0] = pTab->nCol;
139419 for(i=0; i<pIdx->nColumn-1; i++){
139420 int x1, x2;
139421 assert( pIdx->aiColumn[i]<pTab->nCol );
139422 x1 = pIdx->aiColumn[i];
139423 x2 = sqlite3TableColumnToStorage(pTab, x1);
139424 testcase( x1!=x2 );
139425 if( x1>=0 ) ai[x2+1] = i+1;
139426 }
139427 sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY);
139428 }
139429 }
139430 }
@@ -138408,10 +139471,11 @@
139471 typedef struct IdxExprTrans {
139472 Expr *pIdxExpr; /* The index expression */
139473 int iTabCur; /* The cursor of the corresponding table */
139474 int iIdxCur; /* The cursor for the index */
139475 int iIdxCol; /* The column for the index */
139476 int iTabCol; /* The column for the table */
139477 } IdxExprTrans;
139478
139479 /* The walker node callback used to transform matching expressions into
139480 ** a reference to an index column for an index on an expression.
139481 **
@@ -138430,37 +139494,73 @@
139494 }else{
139495 return WRC_Continue;
139496 }
139497 }
139498
139499 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
139500 /* A walker node callback that translates a column reference to a table
139501 ** into a corresponding column reference of an index.
139502 */
139503 static int whereIndexExprTransColumn(Walker *p, Expr *pExpr){
139504 if( pExpr->op==TK_COLUMN ){
139505 IdxExprTrans *pX = p->u.pIdxTrans;
139506 if( pExpr->iTable==pX->iTabCur && pExpr->iColumn==pX->iTabCol ){
139507 pExpr->iTable = pX->iIdxCur;
139508 pExpr->iColumn = pX->iIdxCol;
139509 pExpr->y.pTab = 0;
139510 }
139511 }
139512 return WRC_Continue;
139513 }
139514 #endif /* SQLITE_OMIT_GENERATED_COLUMNS */
139515
139516 /*
139517 ** For an indexes on expression X, locate every instance of expression X
139518 ** in pExpr and change that subexpression into a reference to the appropriate
139519 ** column of the index.
139520 **
139521 ** 2019-10-24: Updated to also translate references to a VIRTUAL column in
139522 ** the table into references to the corresponding (stored) column of the
139523 ** index.
139524 */
139525 static void whereIndexExprTrans(
139526 Index *pIdx, /* The Index */
139527 int iTabCur, /* Cursor of the table that is being indexed */
139528 int iIdxCur, /* Cursor of the index itself */
139529 WhereInfo *pWInfo /* Transform expressions in this WHERE clause */
139530 ){
139531 int iIdxCol; /* Column number of the index */
139532 ExprList *aColExpr; /* Expressions that are indexed */
139533 Table *pTab;
139534 Walker w;
139535 IdxExprTrans x;
139536 aColExpr = pIdx->aColExpr;
139537 if( aColExpr==0 && !pIdx->bHasVCol ){
139538 /* The index does not reference any expressions or virtual columns
139539 ** so no translations are needed. */
139540 return;
139541 }
139542 pTab = pIdx->pTable;
139543 memset(&w, 0, sizeof(w));
 
139544 w.u.pIdxTrans = &x;
139545 x.iTabCur = iTabCur;
139546 x.iIdxCur = iIdxCur;
139547 for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){
139548 i16 iRef = pIdx->aiColumn[iIdxCol];
139549 if( iRef==XN_EXPR ){
139550 assert( aColExpr->a[iIdxCol].pExpr!=0 );
139551 x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;
139552 w.xExprCallback = whereIndexExprTransNode;
139553 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
139554 }else if( iRef>=0 && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0 ){
139555 x.iTabCol = iRef;
139556 w.xExprCallback = whereIndexExprTransColumn;
139557 #endif /* SQLITE_OMIT_GENERATED_COLUMNS */
139558 }else{
139559 continue;
139560 }
139561 x.iIdxCol = iIdxCol;
 
139562 sqlite3WalkExpr(&w, pWInfo->pWhere);
139563 sqlite3WalkExprList(&w, pWInfo->pOrderBy);
139564 sqlite3WalkExprList(&w, pWInfo->pResultSet);
139565 }
139566 }
@@ -138607,13 +139707,16 @@
139707 pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;
139708 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
139709 iIn = pLevel->u.in.nIn;
139710 for(j=nConstraint-1; j>=0; j--){
139711 pTerm = pLoop->aLTerm[j];
139712 if( (pTerm->eOperator & WO_IN)!=0 ) iIn--;
139713 if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
139714 disableTerm(pLevel, pTerm);
139715 }else if( (pTerm->eOperator & WO_IN)!=0
139716 && sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1
139717 ){
139718 Expr *pCompare; /* The comparison operator */
139719 Expr *pRight; /* RHS of the comparison */
139720 VdbeOp *pOp; /* Opcode to access the value of the IN constraint */
139721
139722 /* Reload the constraint value into reg[iReg+j+2]. The same value
@@ -138620,12 +139723,12 @@
139723 ** was loaded into the same register prior to the OP_VFilter, but
139724 ** the xFilter implementation might have changed the datatype or
139725 ** encoding of the value in the register, so it *must* be reloaded. */
139726 assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );
139727 if( !db->mallocFailed ){
139728 assert( iIn>=0 && iIn<pLevel->u.in.nIn );
139729 pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[iIn].addrInTop);
139730 assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );
139731 assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );
139732 assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );
139733 testcase( pOp->opcode==OP_Rowid );
139734 sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
@@ -138645,10 +139748,11 @@
139748 pCompare->pLeft = 0;
139749 sqlite3ExprDelete(db, pCompare);
139750 }
139751 }
139752 }
139753 assert( iIn==0 || db->mallocFailed );
139754 /* These registers need to be preserved in case there is an IN operator
139755 ** loop. So we could deallocate the registers here (and potentially
139756 ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems
139757 ** simpler and safer to simply not reuse the registers.
139758 **
@@ -139124,44 +140228,57 @@
140228 }
140229 }else if( iCur!=iIdxCur ){
140230 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
140231 iRowidReg = sqlite3GetTempRange(pParse, pPk->nKeyCol);
140232 for(j=0; j<pPk->nKeyCol; j++){
140233 k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[j]);
140234 sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j);
140235 }
140236 sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,
140237 iRowidReg, pPk->nKeyCol); VdbeCoverage(v);
140238 }
140239
140240 if( pLevel->iLeftJoin==0 ){
140241 /* If pIdx is an index on one or more expressions, then look through
140242 ** all the expressions in pWInfo and try to transform matching expressions
140243 ** into reference to index columns. Also attempt to translate references
140244 ** to virtual columns in the table into references to (stored) columns
140245 ** of the index.
140246 **
140247 ** Do not do this for the RHS of a LEFT JOIN. This is because the
140248 ** expression may be evaluated after OP_NullRow has been executed on
140249 ** the cursor. In this case it is important to do the full evaluation,
140250 ** as the result of the expression may not be NULL, even if all table
140251 ** column values are. https://www.sqlite.org/src/info/7fa8049685b50b5a
140252 **
140253 ** Also, do not do this when processing one index an a multi-index
140254 ** OR clause, since the transformation will become invalid once we
140255 ** move forward to the next index.
140256 ** https://sqlite.org/src/info/4e8e4857d32d401f
140257 */
140258 if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){
140259 whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
140260 }
140261
140262 /* If a partial index is driving the loop, try to eliminate WHERE clause
140263 ** terms from the query that must be true due to the WHERE clause of
140264 ** the partial index.
140265 **
140266 ** 2019-11-02 ticket 623eff57e76d45f6: This optimization does not work
140267 ** for a LEFT JOIN.
140268 */
140269 if( pIdx->pPartIdxWhere ){
140270 whereApplyPartialIndexConstraints(pIdx->pPartIdxWhere, iCur, pWC);
140271 }
140272 }else{
140273 testcase( pIdx->pPartIdxWhere );
140274 /* The following assert() is not a requirement, merely an observation:
140275 ** The OR-optimization doesn't work for the right hand table of
140276 ** a LEFT JOIN: */
140277 assert( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 );
140278 }
140279
140280 /* Record the instruction used to terminate the loop. */
140281 if( pLoop->wsFlags & WHERE_ONEROW ){
140282 pLevel->op = OP_Noop;
140283 }else if( bRev ){
140284 pLevel->op = OP_Prev;
@@ -139384,11 +140501,11 @@
140501
140502 /* Read the PK into an array of temp registers. */
140503 r = sqlite3GetTempRange(pParse, nPk);
140504 for(iPk=0; iPk<nPk; iPk++){
140505 int iCol = pPk->aiColumn[iPk];
140506 sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol,r+iPk);
140507 }
140508
140509 /* Check if the temp table already contains this key. If so,
140510 ** the row has already been included in the result set and
140511 ** can be ignored (by jumping past the Gosub below). Otherwise,
@@ -139749,43 +140866,18 @@
140866 }
140867
140868 /*
140869 ** Commute a comparison operator. Expressions of the form "X op Y"
140870 ** are converted into "Y op X".
 
 
 
 
 
 
 
 
 
 
 
 
 
140871 */
140872 static u16 exprCommute(Parse *pParse, Expr *pExpr){
140873 if( pExpr->pLeft->op==TK_VECTOR
140874 || pExpr->pRight->op==TK_VECTOR
140875 || sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight) !=
140876 sqlite3BinaryCompareCollSeq(pParse, pExpr->pRight, pExpr->pLeft)
140877 ){
140878 pExpr->flags ^= EP_Commuted;
 
 
 
 
 
 
 
 
 
 
 
 
140879 }
140880 SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
140881 if( pExpr->op>=TK_GT ){
140882 assert( TK_LT==TK_GT+2 );
140883 assert( TK_GE==TK_LE+2 );
@@ -139792,11 +140884,11 @@
140884 assert( TK_GT>TK_EQ );
140885 assert( TK_GT<TK_LE );
140886 assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );
140887 pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;
140888 }
140889 return 0;
140890 }
140891
140892 /*
140893 ** Translate from TK_xx operator to WO_xx bitmask.
140894 */
@@ -140570,11 +141662,11 @@
141662 if( aff1!=aff2
141663 && (!sqlite3IsNumericAffinity(aff1) || !sqlite3IsNumericAffinity(aff2))
141664 ){
141665 return 0;
141666 }
141667 pColl = sqlite3ExprCompareCollSeq(pParse, pExpr);
141668 if( sqlite3IsBinary(pColl) ) return 1;
141669 return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight);
141670 }
141671
141672 /*
@@ -141259,10 +142351,13 @@
142351 pColRef->iColumn = k++;
142352 pColRef->y.pTab = pTab;
142353 pRhs = sqlite3PExpr(pParse, TK_UPLUS,
142354 sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);
142355 pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);
142356 if( pItem->fg.jointype & JT_LEFT ){
142357 sqlite3SetJoinExpr(pTerm, pItem->iCursor);
142358 }
142359 whereClauseInsert(pWC, pTerm, TERM_DYNAMIC);
142360 }
142361 }
142362
142363 /************** End of whereexpr.c *******************************************/
@@ -141546,12 +142641,11 @@
142641 pX = pTerm->pExpr;
142642 if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){
142643 continue;
142644 }
142645 assert(pX->pLeft);
142646 pColl = sqlite3ExprCompareCollSeq(pParse, pX);
 
142647 if( pColl==0 ) pColl = pParse->db->pDfltColl;
142648 if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){
142649 continue;
142650 }
142651 }
@@ -142068,12 +143162,12 @@
143162 testcase( iCol==BMS );
143163 if( (idxCols & cMask)==0 ){
143164 Expr *pX = pTerm->pExpr;
143165 idxCols |= cMask;
143166 pIdx->aiColumn[n] = pTerm->u.leftColumn;
143167 pColl = sqlite3ExprCompareCollSeq(pParse, pX);
143168 pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : sqlite3StrBINARY;
143169 n++;
143170 }
143171 }
143172 }
143173 assert( (u32)n==pLoop->u.btree.nEq );
@@ -144069,11 +145163,10 @@
145163 pWhere = pWhere->pRight;
145164 }
145165 if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
145166 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
145167 Expr *pExpr;
 
145168 pExpr = pTerm->pExpr;
145169 if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
145170 && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
145171 ){
145172 return 1;
@@ -144532,11 +145625,11 @@
145625 if( iCons>=0 && iCons<pIdxInfo->nConstraint ){
145626 CollSeq *pC = 0;
145627 int iTerm = pIdxInfo->aConstraint[iCons].iTermOffset;
145628 Expr *pX = pHidden->pWC->a[iTerm].pExpr;
145629 if( pX->pLeft ){
145630 pC = sqlite3ExprCompareCollSeq(pHidden->pParse, pX);
145631 }
145632 zRet = (pC ? pC->zName : sqlite3StrBINARY);
145633 }
145634 return zRet;
145635 }
@@ -144965,11 +146058,13 @@
146058 if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue;
146059 }else{
146060 pLoop = pLast;
146061 }
146062 if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
146063 if( pLoop->u.vtab.isOrdered && (wctrlFlags & WHERE_DISTINCTBY)==0 ){
146064 obSat = obDone;
146065 }
146066 break;
146067 }else if( wctrlFlags & WHERE_DISTINCTBY ){
146068 pLoop->u.btree.nDistinctCol = 0;
146069 }
146070 iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
@@ -146283,11 +147378,17 @@
147378 };
147379 sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op);
147380 assert( pTabItem->iCursor==pLevel->iTabCur );
147381 testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS-1 );
147382 testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS );
147383 if( pWInfo->eOnePass==ONEPASS_OFF
147384 && pTab->nCol<BMS
147385 && (pTab->tabFlags & (TF_HasGenerated|TF_WithoutRowid))==0
147386 ){
147387 /* If we know that only a prefix of the record will be used,
147388 ** it is advantageous to reduce the "column count" field in
147389 ** the P4 operand of the OP_OpenRead/Write opcode. */
147390 Bitmask b = pTabItem->colUsed;
147391 int n = 0;
147392 for(; b; b=b>>1, n++){}
147393 sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(n), P4_INT32);
147394 assert( n<=pTab->nCol );
@@ -146645,12 +147746,15 @@
147746 assert( pIdx->pTable==pTab );
147747 if( !HasRowid(pTab) ){
147748 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
147749 x = pPk->aiColumn[x];
147750 assert( x>=0 );
147751 }else{
147752 testcase( x!=sqlite3StorageColumnToTable(pTab,x) );
147753 x = sqlite3StorageColumnToTable(pTab,x);
147754 }
147755 x = sqlite3TableColumnToIndex(pIdx, x);
147756 if( x>=0 ){
147757 pOp->p2 = x;
147758 pOp->p1 = pLevel->iIdxCur;
147759 OpcodeRewriteTrace(db, k, pOp);
147760 }
@@ -147583,11 +148687,11 @@
148687 ** are invoked in the correct order as described under "SELECT REWRITING"
148688 ** at the top of this file.
148689 */
148690 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
148691 int rc = SQLITE_OK;
148692 if( p->pWin && p->pPrior==0 && (p->selFlags & SF_WinRewrite)==0 ){
148693 Vdbe *v = sqlite3GetVdbe(pParse);
148694 sqlite3 *db = pParse->db;
148695 Select *pSub = 0; /* The subquery */
148696 SrcList *pSrc = p->pSrc;
148697 Expr *pWhere = p->pWhere;
@@ -147608,10 +148712,11 @@
148712 p->pSrc = 0;
148713 p->pWhere = 0;
148714 p->pGroupBy = 0;
148715 p->pHaving = 0;
148716 p->selFlags &= ~SF_Aggregate;
148717 p->selFlags |= SF_WinRewrite;
148718
148719 /* Create the ORDER BY clause for the sub-select. This is the concatenation
148720 ** of the window PARTITION and ORDER BY clauses. Then, if this makes it
148721 ** redundant, remove the ORDER BY from the parent SELECT. */
148722 pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);
@@ -147923,12 +149028,12 @@
149028 ** to be processed as part of SELECT statement pSel). The window is linked
149029 ** in if either (a) there are no other windows already linked to this
149030 ** SELECT, or (b) the windows already linked use a compatible window frame.
149031 */
149032 SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin){
149033 if( pSel!=0
149034 && (0==pSel->pWin || 0==sqlite3WindowCompare(0, pSel->pWin, pWin, 0))
149035 ){
149036 pWin->pNextWin = pSel->pWin;
149037 if( pSel->pWin ){
149038 pSel->pWin->ppThis = &pWin->pNextWin;
149039 }
@@ -149725,12 +150830,13 @@
150830 /*
150831 ** Disable lookaside memory allocation for objects that might be
150832 ** shared across database connections.
150833 */
150834 static void disableLookaside(Parse *pParse){
150835 sqlite3 *db = pParse->db;
150836 pParse->disableLookaside++;
150837 DisableLookaside;
150838 }
150839
150840
150841 /*
150842 ** For a compound SELECT statement, make sure p->pPrior->pNext==p for
@@ -149890,32 +150996,32 @@
150996 #ifndef INTERFACE
150997 # define INTERFACE 1
150998 #endif
150999 /************* Begin control #defines *****************************************/
151000 #define YYCODETYPE unsigned short int
151001 #define YYNOCODE 310
151002 #define YYACTIONTYPE unsigned short int
151003 #define YYWILDCARD 100
151004 #define sqlite3ParserTOKENTYPE Token
151005 typedef union {
151006 int yyinit;
151007 sqlite3ParserTOKENTYPE yy0;
151008 SrcList* yy47;
151009 u8 yy58;
151010 struct FrameBound yy77;
151011 With* yy131;
151012 int yy192;
151013 Expr* yy202;
151014 struct {int value; int mask;} yy207;
151015 struct TrigEvent yy230;
151016 ExprList* yy242;
151017 Window* yy303;
151018 Upsert* yy318;
151019 const char* yy436;
151020 TriggerStep* yy447;
151021 Select* yy539;
151022 IdList* yy600;
151023 } YYMINORTYPE;
151024 #ifndef YYSTACKDEPTH
151025 #define YYSTACKDEPTH 100
151026 #endif
151027 #define sqlite3ParserARG_SDECL
@@ -149927,21 +151033,21 @@
151033 #define sqlite3ParserCTX_PDECL ,Parse *pParse
151034 #define sqlite3ParserCTX_PARAM ,pParse
151035 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
151036 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
151037 #define YYFALLBACK 1
151038 #define YYNSTATE 550
151039 #define YYNRULE 385
151040 #define YYNTOKEN 181
151041 #define YY_MAX_SHIFT 549
151042 #define YY_MIN_SHIFTREDUCE 800
151043 #define YY_MAX_SHIFTREDUCE 1184
151044 #define YY_ERROR_ACTION 1185
151045 #define YY_ACCEPT_ACTION 1186
151046 #define YY_NO_ACTION 1187
151047 #define YY_MIN_REDUCE 1188
151048 #define YY_MAX_REDUCE 1572
151049 /************* End control #defines *******************************************/
151050 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
151051
151052 /* Define the yytestcase() macro to be a no-op if is not already defined
151053 ** otherwise.
@@ -150004,577 +151110,585 @@
151110 ** yy_reduce_ofst[] For each state, the offset into yy_action for
151111 ** shifting non-terminals after a reduce.
151112 ** yy_default[] Default action for each state.
151113 **
151114 *********** Begin parsing tables **********************************************/
151115 #define YY_ACTTAB_COUNT (1958)
151116 static const YYACTIONTYPE yy_action[] = {
151117 /* 0 */ 544, 1219, 544, 449, 1257, 544, 1236, 544, 114, 111,
151118 /* 10 */ 211, 544, 1534, 544, 1257, 521, 114, 111, 211, 390,
151119 /* 20 */ 1229, 342, 42, 42, 42, 42, 1222, 42, 42, 71,
151120 /* 30 */ 71, 934, 1221, 71, 71, 71, 71, 1459, 1490, 935,
151121 /* 40 */ 817, 451, 6, 121, 122, 112, 1162, 1162, 1003, 1006,
151122 /* 50 */ 996, 996, 119, 119, 120, 120, 120, 120, 1540, 390,
151123 /* 60 */ 1355, 1514, 549, 2, 1190, 194, 526, 434, 143, 291,
151124 /* 70 */ 526, 136, 526, 369, 261, 502, 272, 383, 1270, 525,
151125 /* 80 */ 501, 491, 164, 121, 122, 112, 1162, 1162, 1003, 1006,
151126 /* 90 */ 996, 996, 119, 119, 120, 120, 120, 120, 1355, 440,
151127 /* 100 */ 1511, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151128 /* 110 */ 115, 422, 266, 266, 266, 266, 1495, 356, 1497, 433,
151129 /* 120 */ 355, 1495, 515, 522, 1482, 541, 1111, 541, 1111, 390,
151130 /* 130 */ 403, 241, 208, 114, 111, 211, 98, 290, 535, 221,
151131 /* 140 */ 1026, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151132 /* 150 */ 115, 422, 1139, 121, 122, 112, 1162, 1162, 1003, 1006,
151133 /* 160 */ 996, 996, 119, 119, 120, 120, 120, 120, 404, 426,
151134 /* 170 */ 117, 117, 116, 116, 116, 115, 422, 1415, 466, 123,
151135 /* 180 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151136 /* 190 */ 422, 116, 116, 116, 115, 422, 538, 538, 538, 390,
151137 /* 200 */ 503, 120, 120, 120, 120, 113, 1048, 1139, 1140, 1141,
151138 /* 210 */ 1048, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151139 /* 220 */ 115, 422, 1458, 121, 122, 112, 1162, 1162, 1003, 1006,
151140 /* 230 */ 996, 996, 119, 119, 120, 120, 120, 120, 390, 442,
151141 /* 240 */ 314, 83, 461, 81, 357, 380, 1139, 80, 118, 118,
151142 /* 250 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 179,
151143 /* 260 */ 432, 422, 121, 122, 112, 1162, 1162, 1003, 1006, 996,
151144 /* 270 */ 996, 119, 119, 120, 120, 120, 120, 432, 431, 266,
151145 /* 280 */ 266, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151146 /* 290 */ 115, 422, 541, 1106, 900, 504, 1139, 114, 111, 211,
151147 /* 300 */ 1428, 1139, 1140, 1141, 206, 489, 1106, 390, 447, 1106,
151148 /* 310 */ 543, 328, 120, 120, 120, 120, 298, 1428, 1430, 17,
151149 /* 320 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151150 /* 330 */ 422, 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996,
151151 /* 340 */ 119, 119, 120, 120, 120, 120, 390, 1355, 432, 1139,
151152 /* 350 */ 480, 1139, 1140, 1141, 993, 993, 1004, 1007, 443, 118,
151153 /* 360 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422,
151154 /* 370 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151155 /* 380 */ 119, 120, 120, 120, 120, 1051, 1051, 463, 1428, 118,
151156 /* 390 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422,
151157 /* 400 */ 1139, 449, 544, 1423, 1139, 1140, 1141, 233, 963, 1139,
151158 /* 410 */ 479, 476, 475, 171, 358, 390, 164, 405, 412, 839,
151159 /* 420 */ 474, 164, 185, 332, 71, 71, 1240, 997, 118, 118,
151160 /* 430 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 121,
151161 /* 440 */ 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119, 119,
151162 /* 450 */ 120, 120, 120, 120, 390, 1139, 1140, 1141, 832, 12,
151163 /* 460 */ 313, 507, 163, 354, 1139, 1140, 1141, 114, 111, 211,
151164 /* 470 */ 506, 290, 535, 544, 276, 180, 290, 535, 121, 122,
151165 /* 480 */ 112, 1162, 1162, 1003, 1006, 996, 996, 119, 119, 120,
151166 /* 490 */ 120, 120, 120, 343, 482, 71, 71, 118, 118, 118,
151167 /* 500 */ 118, 117, 117, 116, 116, 116, 115, 422, 1139, 209,
151168 /* 510 */ 409, 521, 1139, 1106, 1568, 376, 252, 269, 340, 485,
151169 /* 520 */ 335, 484, 238, 390, 511, 362, 1106, 1124, 331, 1106,
151170 /* 530 */ 191, 407, 286, 32, 455, 441, 118, 118, 118, 118,
151171 /* 540 */ 117, 117, 116, 116, 116, 115, 422, 121, 122, 112,
151172 /* 550 */ 1162, 1162, 1003, 1006, 996, 996, 119, 119, 120, 120,
151173 /* 560 */ 120, 120, 390, 1139, 1140, 1141, 984, 1139, 1140, 1141,
151174 /* 570 */ 1139, 233, 490, 1489, 479, 476, 475, 6, 163, 544,
151175 /* 580 */ 510, 544, 115, 422, 474, 5, 121, 122, 112, 1162,
151176 /* 590 */ 1162, 1003, 1006, 996, 996, 119, 119, 120, 120, 120,
151177 /* 600 */ 120, 13, 13, 13, 13, 118, 118, 118, 118, 117,
151178 /* 610 */ 117, 116, 116, 116, 115, 422, 401, 500, 406, 544,
151179 /* 620 */ 1483, 542, 1139, 889, 889, 1139, 1140, 1141, 1470, 1139,
151180 /* 630 */ 275, 390, 805, 806, 807, 968, 420, 420, 420, 16,
151181 /* 640 */ 16, 55, 55, 1239, 118, 118, 118, 118, 117, 117,
151182 /* 650 */ 116, 116, 116, 115, 422, 121, 122, 112, 1162, 1162,
151183 /* 660 */ 1003, 1006, 996, 996, 119, 119, 120, 120, 120, 120,
151184 /* 670 */ 390, 1186, 1, 1, 549, 2, 1190, 1139, 1140, 1141,
151185 /* 680 */ 194, 291, 895, 136, 1139, 1140, 1141, 894, 519, 1489,
151186 /* 690 */ 1270, 3, 378, 6, 121, 122, 112, 1162, 1162, 1003,
151187 /* 700 */ 1006, 996, 996, 119, 119, 120, 120, 120, 120, 855,
151188 /* 710 */ 544, 921, 544, 118, 118, 118, 118, 117, 117, 116,
151189 /* 720 */ 116, 116, 115, 422, 266, 266, 1089, 1566, 1139, 1518,
151190 /* 730 */ 1566, 1190, 13, 13, 13, 13, 291, 541, 136, 390,
151191 /* 740 */ 483, 419, 418, 963, 342, 1270, 466, 408, 856, 279,
151192 /* 750 */ 140, 221, 118, 118, 118, 118, 117, 117, 116, 116,
151193 /* 760 */ 116, 115, 422, 121, 122, 112, 1162, 1162, 1003, 1006,
151194 /* 770 */ 996, 996, 119, 119, 120, 120, 120, 120, 544, 266,
151195 /* 780 */ 266, 426, 390, 1139, 1140, 1141, 1169, 827, 1169, 466,
151196 /* 790 */ 429, 145, 541, 1143, 399, 313, 437, 301, 835, 1487,
151197 /* 800 */ 71, 71, 410, 6, 1087, 471, 221, 100, 112, 1162,
151198 /* 810 */ 1162, 1003, 1006, 996, 996, 119, 119, 120, 120, 120,
151199 /* 820 */ 120, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151200 /* 830 */ 115, 422, 237, 1422, 544, 449, 426, 287, 983, 544,
151201 /* 840 */ 236, 235, 234, 827, 97, 527, 427, 1262, 1262, 1143,
151202 /* 850 */ 492, 306, 428, 835, 974, 544, 71, 71, 973, 1238,
151203 /* 860 */ 544, 51, 51, 300, 118, 118, 118, 118, 117, 117,
151204 /* 870 */ 116, 116, 116, 115, 422, 194, 103, 70, 70, 266,
151205 /* 880 */ 266, 544, 71, 71, 266, 266, 30, 389, 342, 973,
151206 /* 890 */ 973, 975, 541, 526, 1106, 326, 390, 541, 493, 395,
151207 /* 900 */ 1467, 195, 528, 13, 13, 1355, 240, 1106, 277, 280,
151208 /* 910 */ 1106, 280, 303, 455, 305, 331, 390, 31, 188, 417,
151209 /* 920 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151210 /* 930 */ 119, 120, 120, 120, 120, 142, 390, 363, 455, 983,
151211 /* 940 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151212 /* 950 */ 119, 120, 120, 120, 120, 974, 321, 1139, 324, 973,
151213 /* 960 */ 121, 110, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151214 /* 970 */ 119, 120, 120, 120, 120, 462, 375, 1182, 118, 118,
151215 /* 980 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1139,
151216 /* 990 */ 973, 973, 975, 304, 9, 364, 244, 360, 118, 118,
151217 /* 1000 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 312,
151218 /* 1010 */ 544, 342, 1139, 1140, 1141, 299, 290, 535, 118, 118,
151219 /* 1020 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1260,
151220 /* 1030 */ 1260, 1160, 13, 13, 278, 419, 418, 466, 390, 920,
151221 /* 1040 */ 260, 260, 289, 1166, 1139, 1140, 1141, 189, 1168, 266,
151222 /* 1050 */ 266, 466, 388, 541, 1183, 544, 1167, 263, 144, 487,
151223 /* 1060 */ 919, 544, 541, 122, 112, 1162, 1162, 1003, 1006, 996,
151224 /* 1070 */ 996, 119, 119, 120, 120, 120, 120, 71, 71, 1139,
151225 /* 1080 */ 1169, 1269, 1169, 13, 13, 895, 1067, 1160, 544, 466,
151226 /* 1090 */ 894, 107, 536, 1488, 4, 1265, 1106, 6, 523, 1046,
151227 /* 1100 */ 12, 1068, 1089, 1567, 311, 453, 1567, 518, 539, 1106,
151228 /* 1110 */ 56, 56, 1106, 1486, 421, 1355, 1069, 6, 343, 285,
151229 /* 1120 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151230 /* 1130 */ 422, 423, 1268, 319, 1139, 1140, 1141, 875, 266, 266,
151231 /* 1140 */ 1274, 107, 536, 533, 4, 1485, 293, 876, 1208, 6,
151232 /* 1150 */ 210, 541, 541, 164, 1539, 494, 414, 864, 539, 267,
151233 /* 1160 */ 267, 1211, 396, 509, 497, 204, 266, 266, 394, 529,
151234 /* 1170 */ 8, 983, 541, 517, 544, 919, 456, 105, 105, 541,
151235 /* 1180 */ 1087, 423, 266, 266, 106, 415, 423, 546, 545, 266,
151236 /* 1190 */ 266, 973, 516, 533, 1370, 541, 15, 15, 266, 266,
151237 /* 1200 */ 454, 1117, 541, 266, 266, 1067, 1369, 513, 290, 535,
151238 /* 1210 */ 544, 541, 512, 97, 442, 314, 541, 544, 919, 125,
151239 /* 1220 */ 1068, 983, 973, 973, 975, 976, 27, 105, 105, 399,
151240 /* 1230 */ 341, 1508, 44, 44, 106, 1069, 423, 546, 545, 57,
151241 /* 1240 */ 57, 973, 341, 1508, 107, 536, 544, 4, 460, 399,
151242 /* 1250 */ 214, 1117, 457, 294, 375, 1088, 532, 297, 544, 537,
151243 /* 1260 */ 396, 539, 290, 535, 104, 244, 102, 524, 58, 58,
151244 /* 1270 */ 544, 109, 973, 973, 975, 976, 27, 1513, 1128, 425,
151245 /* 1280 */ 59, 59, 270, 237, 423, 138, 95, 373, 373, 372,
151246 /* 1290 */ 255, 370, 60, 60, 814, 1177, 533, 544, 273, 544,
151247 /* 1300 */ 1160, 842, 387, 386, 544, 1306, 544, 215, 210, 296,
151248 /* 1310 */ 513, 846, 544, 265, 208, 514, 1305, 295, 274, 61,
151249 /* 1320 */ 61, 62, 62, 436, 983, 1159, 45, 45, 46, 46,
151250 /* 1330 */ 105, 105, 1183, 919, 47, 47, 1473, 106, 544, 423,
151251 /* 1340 */ 546, 545, 218, 544, 973, 934, 1084, 217, 544, 377,
151252 /* 1350 */ 395, 107, 536, 935, 4, 156, 1160, 842, 158, 544,
151253 /* 1360 */ 49, 49, 141, 544, 38, 50, 50, 544, 539, 307,
151254 /* 1370 */ 63, 63, 544, 1447, 216, 973, 973, 975, 976, 27,
151255 /* 1380 */ 444, 64, 64, 544, 1446, 65, 65, 544, 524, 14,
151256 /* 1390 */ 14, 423, 458, 544, 66, 66, 310, 544, 316, 97,
151257 /* 1400 */ 1033, 544, 960, 533, 268, 127, 127, 544, 391, 67,
151258 /* 1410 */ 67, 544, 977, 290, 535, 52, 52, 513, 544, 68,
151259 /* 1420 */ 68, 1293, 512, 69, 69, 397, 165, 854, 853, 53,
151260 /* 1430 */ 53, 983, 965, 151, 151, 243, 430, 105, 105, 199,
151261 /* 1440 */ 152, 152, 448, 1302, 106, 243, 423, 546, 545, 1128,
151262 /* 1450 */ 425, 973, 320, 270, 861, 862, 1033, 220, 373, 373,
151263 /* 1460 */ 372, 255, 370, 450, 323, 814, 243, 544, 977, 544,
151264 /* 1470 */ 107, 536, 544, 4, 544, 937, 938, 325, 215, 1045,
151265 /* 1480 */ 296, 1045, 973, 973, 975, 976, 27, 539, 295, 76,
151266 /* 1490 */ 76, 54, 54, 327, 72, 72, 128, 128, 1502, 1253,
151267 /* 1500 */ 107, 536, 544, 4, 1044, 544, 1044, 531, 1237, 544,
151268 /* 1510 */ 423, 544, 315, 334, 544, 97, 544, 539, 217, 544,
151269 /* 1520 */ 472, 1527, 533, 239, 73, 73, 156, 129, 129, 158,
151270 /* 1530 */ 467, 130, 130, 126, 126, 344, 150, 150, 149, 149,
151271 /* 1540 */ 423, 134, 134, 329, 1029, 216, 97, 239, 928, 345,
151272 /* 1550 */ 983, 243, 533, 1314, 339, 544, 105, 105, 899, 1354,
151273 /* 1560 */ 544, 1289, 258, 106, 338, 423, 546, 545, 544, 1300,
151274 /* 1570 */ 973, 892, 99, 536, 109, 4, 544, 133, 133, 391,
151275 /* 1580 */ 983, 197, 131, 131, 290, 535, 105, 105, 530, 539,
151276 /* 1590 */ 132, 132, 1360, 106, 1218, 423, 546, 545, 75, 75,
151277 /* 1600 */ 973, 973, 973, 975, 976, 27, 544, 430, 825, 1210,
151278 /* 1610 */ 893, 139, 423, 109, 544, 1199, 1198, 1200, 1521, 544,
151279 /* 1620 */ 201, 544, 11, 374, 533, 1286, 347, 349, 77, 77,
151280 /* 1630 */ 1339, 973, 973, 975, 976, 27, 74, 74, 351, 213,
151281 /* 1640 */ 435, 43, 43, 48, 48, 302, 477, 309, 1347, 382,
151282 /* 1650 */ 353, 452, 983, 337, 1236, 1419, 1418, 205, 105, 105,
151283 /* 1660 */ 192, 367, 193, 534, 1524, 106, 1177, 423, 546, 545,
151284 /* 1670 */ 247, 167, 973, 270, 1466, 200, 1464, 1174, 373, 373,
151285 /* 1680 */ 372, 255, 370, 398, 79, 814, 83, 82, 1424, 446,
151286 /* 1690 */ 161, 177, 169, 95, 1336, 438, 172, 173, 215, 174,
151287 /* 1700 */ 296, 175, 35, 973, 973, 975, 976, 27, 295, 1344,
151288 /* 1710 */ 439, 470, 223, 36, 379, 445, 1413, 381, 459, 1350,
151289 /* 1720 */ 181, 227, 88, 465, 259, 229, 1435, 318, 186, 468,
151290 /* 1730 */ 322, 230, 384, 1201, 231, 486, 1256, 1255, 217, 411,
151291 /* 1740 */ 1254, 1247, 90, 846, 206, 413, 156, 505, 1538, 158,
151292 /* 1750 */ 1225, 1537, 283, 1507, 1226, 336, 385, 284, 1224, 496,
151293 /* 1760 */ 1536, 1297, 94, 346, 348, 216, 1246, 499, 1298, 245,
151294 /* 1770 */ 246, 1296, 416, 350, 1493, 124, 1492, 10, 524, 361,
151295 /* 1780 */ 1399, 101, 96, 288, 508, 253, 1134, 1207, 34, 1295,
151296 /* 1790 */ 547, 254, 256, 257, 392, 548, 1196, 1191, 359, 391,
151297 /* 1800 */ 1279, 1278, 196, 365, 290, 535, 366, 352, 1451, 1321,
151298 /* 1810 */ 1320, 1452, 153, 137, 281, 154, 801, 424, 155, 1450,
151299 /* 1820 */ 1449, 198, 292, 202, 203, 78, 212, 430, 271, 135,
151300 /* 1830 */ 1043, 1041, 957, 168, 219, 157, 170, 878, 308, 222,
151301 /* 1840 */ 1057, 176, 159, 961, 400, 84, 402, 178, 85, 86,
151302 /* 1850 */ 87, 166, 160, 393, 1060, 224, 225, 1056, 146, 18,
151303 /* 1860 */ 226, 317, 1049, 1171, 243, 464, 182, 228, 37, 183,
151304 /* 1870 */ 816, 469, 338, 232, 330, 481, 184, 89, 844, 19,
151305 /* 1880 */ 20, 92, 473, 478, 333, 91, 162, 857, 147, 488,
151306 /* 1890 */ 282, 1122, 148, 1009, 927, 1092, 39, 93, 40, 495,
151307 /* 1900 */ 1093, 187, 498, 207, 262, 264, 922, 242, 1108, 109,
151308 /* 1910 */ 1112, 1110, 1096, 33, 21, 1116, 520, 1024, 22, 23,
151309 /* 1920 */ 24, 1115, 25, 190, 97, 1010, 1008, 26, 1012, 1066,
151310 /* 1930 */ 248, 7, 1065, 249, 1013, 28, 41, 888, 978, 826,
151311 /* 1940 */ 108, 29, 250, 540, 251, 1529, 371, 368, 1129, 1187,
151312 /* 1950 */ 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1528,
151313 };
151314 static const YYCODETYPE yy_lookahead[] = {
151315 /* 0 */ 189, 211, 189, 189, 218, 189, 220, 189, 267, 268,
151316 /* 10 */ 269, 189, 210, 189, 228, 189, 267, 268, 269, 19,
151317 /* 20 */ 218, 189, 211, 212, 211, 212, 211, 211, 212, 211,
151318 /* 30 */ 212, 31, 211, 211, 212, 211, 212, 288, 300, 39,
151319 /* 40 */ 21, 189, 304, 43, 44, 45, 46, 47, 48, 49,
151320 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 225, 19,
151321 /* 60 */ 189, 183, 184, 185, 186, 189, 248, 263, 236, 191,
151322 /* 70 */ 248, 193, 248, 197, 208, 257, 262, 201, 200, 257,
151323 /* 80 */ 200, 257, 81, 43, 44, 45, 46, 47, 48, 49,
151324 /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 189, 80,
151325 /* 100 */ 189, 101, 102, 103, 104, 105, 106, 107, 108, 109,
151326 /* 110 */ 110, 111, 234, 235, 234, 235, 305, 306, 305, 118,
151327 /* 120 */ 307, 305, 306, 297, 298, 247, 86, 247, 88, 19,
151328 /* 130 */ 259, 251, 252, 267, 268, 269, 26, 136, 137, 261,
151329 /* 140 */ 121, 101, 102, 103, 104, 105, 106, 107, 108, 109,
151330 /* 150 */ 110, 111, 59, 43, 44, 45, 46, 47, 48, 49,
151331 /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 259, 291,
151332 /* 170 */ 105, 106, 107, 108, 109, 110, 111, 158, 189, 69,
151333 /* 180 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
151334 /* 190 */ 111, 107, 108, 109, 110, 111, 205, 206, 207, 19,
151335 /* 200 */ 19, 54, 55, 56, 57, 58, 29, 114, 115, 116,
151336 /* 210 */ 33, 101, 102, 103, 104, 105, 106, 107, 108, 109,
151337 /* 220 */ 110, 111, 233, 43, 44, 45, 46, 47, 48, 49,
151338 /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 126,
151339 /* 240 */ 127, 148, 65, 24, 214, 200, 59, 67, 101, 102,
151340 /* 250 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 22,
151341 /* 260 */ 189, 111, 43, 44, 45, 46, 47, 48, 49, 50,
151342 /* 270 */ 51, 52, 53, 54, 55, 56, 57, 206, 207, 234,
151343 /* 280 */ 235, 101, 102, 103, 104, 105, 106, 107, 108, 109,
151344 /* 290 */ 110, 111, 247, 76, 107, 114, 59, 267, 268, 269,
151345 /* 300 */ 189, 114, 115, 116, 162, 163, 89, 19, 263, 92,
151346 /* 310 */ 189, 23, 54, 55, 56, 57, 189, 206, 207, 22,
151347 /* 320 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
151348 /* 330 */ 111, 43, 44, 45, 46, 47, 48, 49, 50, 51,
151349 /* 340 */ 52, 53, 54, 55, 56, 57, 19, 189, 277, 59,
151350 /* 350 */ 23, 114, 115, 116, 46, 47, 48, 49, 61, 101,
151351 /* 360 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
151352 /* 370 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
151353 /* 380 */ 53, 54, 55, 56, 57, 125, 126, 127, 277, 101,
151354 /* 390 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
151355 /* 400 */ 59, 189, 189, 276, 114, 115, 116, 117, 73, 59,
151356 /* 410 */ 120, 121, 122, 72, 214, 19, 81, 259, 19, 23,
151357 /* 420 */ 130, 81, 72, 24, 211, 212, 221, 119, 101, 102,
151358 /* 430 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 43,
151359 /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
151360 /* 450 */ 54, 55, 56, 57, 19, 114, 115, 116, 23, 208,
151361 /* 460 */ 125, 248, 189, 189, 114, 115, 116, 267, 268, 269,
151362 /* 470 */ 189, 136, 137, 189, 262, 22, 136, 137, 43, 44,
151363 /* 480 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
151364 /* 490 */ 55, 56, 57, 189, 95, 211, 212, 101, 102, 103,
151365 /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 59, 189,
151366 /* 510 */ 111, 189, 59, 76, 294, 295, 117, 118, 119, 120,
151367 /* 520 */ 121, 122, 123, 19, 87, 189, 89, 23, 129, 92,
151368 /* 530 */ 279, 227, 248, 22, 189, 284, 101, 102, 103, 104,
151369 /* 540 */ 105, 106, 107, 108, 109, 110, 111, 43, 44, 45,
151370 /* 550 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
151371 /* 560 */ 56, 57, 19, 114, 115, 116, 23, 114, 115, 116,
151372 /* 570 */ 59, 117, 299, 300, 120, 121, 122, 304, 189, 189,
151373 /* 580 */ 143, 189, 110, 111, 130, 22, 43, 44, 45, 46,
151374 /* 590 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
151375 /* 600 */ 57, 211, 212, 211, 212, 101, 102, 103, 104, 105,
151376 /* 610 */ 106, 107, 108, 109, 110, 111, 226, 189, 226, 189,
151377 /* 620 */ 298, 132, 59, 134, 135, 114, 115, 116, 189, 59,
151378 /* 630 */ 285, 19, 7, 8, 9, 23, 205, 206, 207, 211,
151379 /* 640 */ 212, 211, 212, 221, 101, 102, 103, 104, 105, 106,
151380 /* 650 */ 107, 108, 109, 110, 111, 43, 44, 45, 46, 47,
151381 /* 660 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
151382 /* 670 */ 19, 181, 182, 183, 184, 185, 186, 114, 115, 116,
151383 /* 680 */ 189, 191, 133, 193, 114, 115, 116, 138, 299, 300,
151384 /* 690 */ 200, 22, 201, 304, 43, 44, 45, 46, 47, 48,
151385 /* 700 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 35,
151386 /* 710 */ 189, 141, 189, 101, 102, 103, 104, 105, 106, 107,
151387 /* 720 */ 108, 109, 110, 111, 234, 235, 22, 23, 59, 184,
151388 /* 730 */ 26, 186, 211, 212, 211, 212, 191, 247, 193, 19,
151389 /* 740 */ 66, 105, 106, 73, 189, 200, 189, 226, 74, 226,
151390 /* 750 */ 22, 261, 101, 102, 103, 104, 105, 106, 107, 108,
151391 /* 760 */ 109, 110, 111, 43, 44, 45, 46, 47, 48, 49,
151392 /* 770 */ 50, 51, 52, 53, 54, 55, 56, 57, 189, 234,
151393 /* 780 */ 235, 291, 19, 114, 115, 116, 150, 59, 152, 189,
151394 /* 790 */ 233, 236, 247, 59, 189, 125, 126, 127, 59, 300,
151395 /* 800 */ 211, 212, 128, 304, 100, 19, 261, 156, 45, 46,
151396 /* 810 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
151397 /* 820 */ 57, 101, 102, 103, 104, 105, 106, 107, 108, 109,
151398 /* 830 */ 110, 111, 46, 233, 189, 189, 291, 248, 99, 189,
151399 /* 840 */ 125, 126, 127, 115, 26, 200, 289, 230, 231, 115,
151400 /* 850 */ 200, 16, 189, 114, 115, 189, 211, 212, 119, 221,
151401 /* 860 */ 189, 211, 212, 258, 101, 102, 103, 104, 105, 106,
151402 /* 870 */ 107, 108, 109, 110, 111, 189, 156, 211, 212, 234,
151403 /* 880 */ 235, 189, 211, 212, 234, 235, 22, 201, 189, 150,
151404 /* 890 */ 151, 152, 247, 248, 76, 16, 19, 247, 248, 113,
151405 /* 900 */ 189, 24, 257, 211, 212, 189, 26, 89, 262, 223,
151406 /* 910 */ 92, 225, 77, 189, 79, 129, 19, 53, 226, 248,
151407 /* 920 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
151408 /* 930 */ 53, 54, 55, 56, 57, 236, 19, 271, 189, 99,
151409 /* 940 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
151410 /* 950 */ 53, 54, 55, 56, 57, 115, 77, 59, 79, 119,
151411 /* 960 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
151412 /* 970 */ 53, 54, 55, 56, 57, 259, 22, 23, 101, 102,
151413 /* 980 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 59,
151414 /* 990 */ 150, 151, 152, 158, 22, 244, 24, 246, 101, 102,
151415 /* 1000 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 285,
151416 /* 1010 */ 189, 189, 114, 115, 116, 200, 136, 137, 101, 102,
151417 /* 1020 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 230,
151418 /* 1030 */ 231, 59, 211, 212, 285, 105, 106, 189, 19, 141,
151419 /* 1040 */ 234, 235, 239, 113, 114, 115, 116, 226, 118, 234,
151420 /* 1050 */ 235, 189, 249, 247, 100, 189, 126, 23, 236, 107,
151421 /* 1060 */ 26, 189, 247, 44, 45, 46, 47, 48, 49, 50,
151422 /* 1070 */ 51, 52, 53, 54, 55, 56, 57, 211, 212, 59,
151423 /* 1080 */ 150, 233, 152, 211, 212, 133, 12, 115, 189, 189,
151424 /* 1090 */ 138, 19, 20, 300, 22, 233, 76, 304, 226, 11,
151425 /* 1100 */ 208, 27, 22, 23, 200, 19, 26, 87, 36, 89,
151426 /* 1110 */ 211, 212, 92, 300, 248, 189, 42, 304, 189, 250,
151427 /* 1120 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
151428 /* 1130 */ 111, 59, 200, 233, 114, 115, 116, 63, 234, 235,
151429 /* 1140 */ 235, 19, 20, 71, 22, 300, 189, 73, 200, 304,
151430 /* 1150 */ 116, 247, 247, 81, 23, 200, 227, 26, 36, 234,
151431 /* 1160 */ 235, 203, 204, 143, 200, 26, 234, 235, 194, 200,
151432 /* 1170 */ 48, 99, 247, 66, 189, 141, 284, 105, 106, 247,
151433 /* 1180 */ 100, 59, 234, 235, 112, 259, 114, 115, 116, 234,
151434 /* 1190 */ 235, 119, 85, 71, 266, 247, 211, 212, 234, 235,
151435 /* 1200 */ 114, 94, 247, 234, 235, 12, 266, 85, 136, 137,
151436 /* 1210 */ 189, 247, 90, 26, 126, 127, 247, 189, 26, 22,
151437 /* 1220 */ 27, 99, 150, 151, 152, 153, 154, 105, 106, 189,
151438 /* 1230 */ 302, 303, 211, 212, 112, 42, 114, 115, 116, 211,
151439 /* 1240 */ 212, 119, 302, 303, 19, 20, 189, 22, 274, 189,
151440 /* 1250 */ 15, 144, 278, 189, 22, 23, 63, 189, 189, 203,
151441 /* 1260 */ 204, 36, 136, 137, 155, 24, 157, 143, 211, 212,
151442 /* 1270 */ 189, 26, 150, 151, 152, 153, 154, 0, 1, 2,
151443 /* 1280 */ 211, 212, 5, 46, 59, 161, 147, 10, 11, 12,
151444 /* 1290 */ 13, 14, 211, 212, 17, 60, 71, 189, 258, 189,
151445 /* 1300 */ 59, 59, 105, 106, 189, 189, 189, 30, 116, 32,
151446 /* 1310 */ 85, 124, 189, 251, 252, 90, 189, 40, 258, 211,
151447 /* 1320 */ 212, 211, 212, 189, 99, 26, 211, 212, 211, 212,
151448 /* 1330 */ 105, 106, 100, 141, 211, 212, 189, 112, 189, 114,
151449 /* 1340 */ 115, 116, 24, 189, 119, 31, 23, 70, 189, 26,
151450 /* 1350 */ 113, 19, 20, 39, 22, 78, 115, 115, 81, 189,
151451 /* 1360 */ 211, 212, 22, 189, 24, 211, 212, 189, 36, 189,
151452 /* 1370 */ 211, 212, 189, 189, 97, 150, 151, 152, 153, 154,
151453 /* 1380 */ 127, 211, 212, 189, 189, 211, 212, 189, 143, 211,
151454 /* 1390 */ 212, 59, 189, 189, 211, 212, 23, 189, 189, 26,
151455 /* 1400 */ 59, 189, 149, 71, 22, 211, 212, 189, 131, 211,
151456 /* 1410 */ 212, 189, 59, 136, 137, 211, 212, 85, 189, 211,
151457 /* 1420 */ 212, 253, 90, 211, 212, 292, 293, 118, 119, 211,
151458 /* 1430 */ 212, 99, 23, 211, 212, 26, 159, 105, 106, 140,
151459 /* 1440 */ 211, 212, 23, 189, 112, 26, 114, 115, 116, 1,
151460 /* 1450 */ 2, 119, 189, 5, 7, 8, 115, 139, 10, 11,
151461 /* 1460 */ 12, 13, 14, 23, 189, 17, 26, 189, 115, 189,
151462 /* 1470 */ 19, 20, 189, 22, 189, 83, 84, 189, 30, 150,
151463 /* 1480 */ 32, 152, 150, 151, 152, 153, 154, 36, 40, 211,
151464 /* 1490 */ 212, 211, 212, 189, 211, 212, 211, 212, 309, 189,
151465 /* 1500 */ 19, 20, 189, 22, 150, 189, 152, 231, 189, 189,
151466 /* 1510 */ 59, 189, 23, 189, 189, 26, 189, 36, 70, 189,
151467 /* 1520 */ 23, 139, 71, 26, 211, 212, 78, 211, 212, 81,
151468 /* 1530 */ 281, 211, 212, 211, 212, 189, 211, 212, 211, 212,
151469 /* 1540 */ 59, 211, 212, 23, 23, 97, 26, 26, 23, 189,
151470 /* 1550 */ 99, 26, 71, 189, 119, 189, 105, 106, 107, 189,
151471 /* 1560 */ 189, 189, 280, 112, 129, 114, 115, 116, 189, 189,
151472 /* 1570 */ 119, 23, 19, 20, 26, 22, 189, 211, 212, 131,
151473 /* 1580 */ 99, 237, 211, 212, 136, 137, 105, 106, 189, 36,
151474 /* 1590 */ 211, 212, 189, 112, 189, 114, 115, 116, 211, 212,
151475 /* 1600 */ 119, 150, 151, 152, 153, 154, 189, 159, 23, 189,
151476 /* 1610 */ 23, 26, 59, 26, 189, 189, 189, 189, 189, 189,
151477 /* 1620 */ 209, 189, 238, 187, 71, 250, 250, 250, 211, 212,
151478 /* 1630 */ 241, 150, 151, 152, 153, 154, 211, 212, 250, 290,
151479 /* 1640 */ 254, 211, 212, 211, 212, 254, 215, 286, 241, 241,
151480 /* 1650 */ 254, 286, 99, 214, 220, 214, 214, 224, 105, 106,
151481 /* 1660 */ 244, 240, 244, 273, 192, 112, 60, 114, 115, 116,
151482 /* 1670 */ 139, 290, 119, 5, 196, 238, 196, 38, 10, 11,
151483 /* 1680 */ 12, 13, 14, 196, 287, 17, 148, 287, 276, 113,
151484 /* 1690 */ 43, 22, 229, 147, 241, 18, 232, 232, 30, 232,
151485 /* 1700 */ 32, 232, 264, 150, 151, 152, 153, 154, 40, 265,
151486 /* 1710 */ 196, 18, 195, 264, 241, 241, 241, 265, 196, 229,
151487 /* 1720 */ 229, 195, 155, 62, 196, 195, 283, 282, 22, 216,
151488 /* 1730 */ 196, 195, 216, 196, 195, 113, 213, 213, 70, 64,
151489 /* 1740 */ 213, 222, 22, 124, 162, 111, 78, 142, 219, 81,
151490 /* 1750 */ 215, 219, 275, 303, 213, 213, 216, 275, 213, 216,
151491 /* 1760 */ 213, 256, 113, 255, 255, 97, 222, 216, 256, 196,
151492 /* 1770 */ 91, 256, 82, 255, 308, 146, 308, 22, 143, 196,
151493 /* 1780 */ 270, 155, 145, 272, 144, 25, 13, 199, 26, 256,
151494 /* 1790 */ 198, 190, 190, 6, 296, 188, 188, 188, 244, 131,
151495 /* 1800 */ 245, 245, 243, 242, 136, 137, 241, 255, 208, 260,
151496 /* 1810 */ 260, 208, 202, 217, 217, 202, 4, 3, 202, 208,
151497 /* 1820 */ 208, 22, 160, 209, 209, 208, 15, 159, 98, 16,
151498 /* 1830 */ 23, 23, 137, 148, 24, 128, 140, 20, 16, 142,
151499 /* 1840 */ 1, 140, 128, 149, 61, 53, 37, 148, 53, 53,
151500 /* 1850 */ 53, 293, 128, 296, 114, 34, 139, 1, 5, 22,
151501 /* 1860 */ 113, 158, 68, 75, 26, 41, 68, 139, 24, 113,
151502 /* 1870 */ 20, 19, 129, 123, 23, 96, 22, 22, 59, 22,
151503 /* 1880 */ 22, 147, 67, 67, 24, 22, 37, 28, 23, 22,
151504 /* 1890 */ 67, 23, 23, 23, 114, 23, 22, 26, 22, 24,
151505 /* 1900 */ 23, 22, 24, 139, 23, 23, 141, 34, 88, 26,
151506 /* 1910 */ 75, 86, 23, 22, 34, 75, 24, 23, 34, 34,
151507 /* 1920 */ 34, 93, 34, 26, 26, 23, 23, 34, 23, 23,
151508 /* 1930 */ 26, 44, 23, 22, 11, 22, 22, 133, 23, 23,
151509 /* 1940 */ 22, 22, 139, 26, 139, 139, 15, 23, 1, 310,
151510 /* 1950 */ 310, 310, 310, 310, 310, 310, 310, 139, 310, 310,
151511 /* 1960 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151512 /* 1970 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151513 /* 1980 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151514 /* 1990 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151515 /* 2000 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151516 /* 2010 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151517 /* 2020 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151518 /* 2030 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151519 /* 2040 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151520 /* 2050 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151521 /* 2060 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151522 /* 2070 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151523 /* 2080 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151524 /* 2090 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151525 /* 2100 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151526 /* 2110 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151527 /* 2120 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151528 /* 2130 */ 310, 310, 310, 310, 310, 310, 310, 310, 310,
151529 };
151530 #define YY_SHIFT_COUNT (549)
151531 #define YY_SHIFT_MIN (0)
151532 #define YY_SHIFT_MAX (1947)
151533 static const unsigned short int yy_shift_ofst[] = {
151534 /* 0 */ 1448, 1277, 1668, 1072, 1072, 340, 1122, 1225, 1332, 1481,
151535 /* 10 */ 1481, 1481, 335, 0, 0, 180, 897, 1481, 1481, 1481,
151536 /* 20 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151537 /* 30 */ 930, 930, 1020, 1020, 290, 1, 340, 340, 340, 340,
151538 /* 40 */ 340, 340, 40, 110, 219, 288, 327, 396, 435, 504,
151539 /* 50 */ 543, 612, 651, 720, 877, 897, 897, 897, 897, 897,
151540 /* 60 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897,
151541 /* 70 */ 897, 897, 897, 917, 897, 1019, 763, 763, 1451, 1481,
151542 /* 80 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151543 /* 90 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151544 /* 100 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151545 /* 110 */ 1481, 1481, 1553, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151546 /* 120 */ 1481, 1481, 1481, 1481, 1481, 1481, 147, 258, 258, 258,
151547 /* 130 */ 258, 258, 79, 65, 84, 449, 19, 786, 449, 636,
151548 /* 140 */ 636, 449, 880, 880, 880, 880, 113, 142, 142, 472,
151549 /* 150 */ 150, 1958, 1958, 399, 399, 399, 93, 237, 341, 237,
151550 /* 160 */ 237, 1074, 1074, 437, 350, 704, 1080, 449, 449, 449,
151551 /* 170 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449,
151552 /* 180 */ 449, 449, 449, 449, 449, 449, 449, 449, 818, 818,
151553 /* 190 */ 449, 1088, 217, 217, 734, 734, 1124, 1126, 1958, 1958,
151554 /* 200 */ 1958, 739, 840, 840, 453, 454, 511, 187, 563, 570,
151555 /* 210 */ 898, 669, 449, 449, 449, 449, 449, 449, 449, 449,
151556 /* 220 */ 449, 670, 449, 449, 449, 449, 449, 449, 449, 449,
151557 /* 230 */ 449, 449, 449, 449, 674, 674, 674, 449, 449, 449,
151558 /* 240 */ 449, 1034, 449, 449, 449, 972, 1107, 449, 449, 1193,
151559 /* 250 */ 449, 449, 449, 449, 449, 449, 449, 449, 260, 177,
151560 /* 260 */ 489, 1241, 1241, 1241, 1241, 1192, 489, 489, 952, 1197,
151561 /* 270 */ 625, 1235, 1139, 181, 181, 1086, 1139, 1139, 1086, 1187,
151562 /* 280 */ 1131, 1237, 1314, 1314, 1314, 181, 1245, 1245, 1109, 1299,
151563 /* 290 */ 549, 1340, 1606, 1531, 1531, 1639, 1639, 1531, 1538, 1576,
151564 /* 300 */ 1669, 1647, 1546, 1677, 1677, 1677, 1677, 1531, 1693, 1546,
151565 /* 310 */ 1546, 1576, 1669, 1647, 1647, 1546, 1531, 1693, 1567, 1661,
151566 /* 320 */ 1531, 1693, 1706, 1531, 1693, 1531, 1693, 1706, 1622, 1622,
151567 /* 330 */ 1622, 1675, 1720, 1720, 1706, 1622, 1619, 1622, 1675, 1622,
151568 /* 340 */ 1622, 1582, 1706, 1634, 1634, 1706, 1605, 1649, 1605, 1649,
151569 /* 350 */ 1605, 1649, 1605, 1649, 1531, 1679, 1679, 1690, 1690, 1629,
151570 /* 360 */ 1635, 1755, 1531, 1626, 1629, 1637, 1640, 1546, 1760, 1762,
151571 /* 370 */ 1773, 1773, 1787, 1787, 1787, 1958, 1958, 1958, 1958, 1958,
151572 /* 380 */ 1958, 1958, 1958, 1958, 1958, 1958, 1958, 1958, 1958, 1958,
151573 /* 390 */ 308, 835, 954, 1232, 879, 715, 728, 1323, 864, 1318,
151574 /* 400 */ 1253, 1373, 297, 1409, 1419, 1440, 1489, 1497, 1520, 1242,
151575 /* 410 */ 1309, 1447, 1435, 1341, 1521, 1525, 1392, 1548, 1329, 1354,
151576 /* 420 */ 1585, 1587, 1353, 1382, 1812, 1814, 1799, 1662, 1811, 1730,
151577 /* 430 */ 1813, 1807, 1808, 1695, 1685, 1707, 1810, 1696, 1817, 1697,
151578 /* 440 */ 1822, 1839, 1701, 1694, 1714, 1783, 1809, 1699, 1792, 1795,
151579 /* 450 */ 1796, 1797, 1724, 1740, 1821, 1717, 1856, 1853, 1837, 1747,
151580 /* 460 */ 1703, 1794, 1838, 1798, 1788, 1824, 1728, 1756, 1844, 1850,
151581 /* 470 */ 1852, 1743, 1750, 1854, 1815, 1855, 1857, 1851, 1858, 1816,
151582 /* 480 */ 1819, 1860, 1779, 1859, 1863, 1823, 1849, 1865, 1734, 1867,
151583 /* 490 */ 1868, 1869, 1870, 1871, 1872, 1874, 1875, 1877, 1876, 1878,
151584 /* 500 */ 1764, 1881, 1882, 1780, 1873, 1879, 1765, 1883, 1880, 1884,
151585 /* 510 */ 1885, 1886, 1820, 1835, 1825, 1887, 1840, 1828, 1888, 1889,
151586 /* 520 */ 1891, 1892, 1897, 1898, 1893, 1894, 1883, 1902, 1903, 1905,
151587 /* 530 */ 1906, 1904, 1909, 1911, 1923, 1913, 1914, 1915, 1916, 1918,
151588 /* 540 */ 1919, 1917, 1804, 1803, 1805, 1806, 1818, 1924, 1931, 1947,
151589 };
151590 #define YY_REDUCE_COUNT (389)
151591 #define YY_REDUCE_MIN (-262)
151592 #define YY_REDUCE_MAX (1617)
151593 static const short yy_reduce_ofst[] = {
151594 /* 0 */ 490, -122, 545, 645, 650, -120, -189, -187, -184, -182,
151595 /* 10 */ -178, -176, 45, 30, 200, -251, -134, 390, 392, 521,
151596 /* 20 */ 523, 213, 692, 821, 284, 589, 872, 666, 671, 866,
151597 /* 30 */ 71, 111, 273, 389, 686, 815, 904, 932, 948, 955,
151598 /* 40 */ 964, 969, -259, -259, -259, -259, -259, -259, -259, -259,
151599 /* 50 */ -259, -259, -259, -259, -259, -259, -259, -259, -259, -259,
151600 /* 60 */ -259, -259, -259, -259, -259, -259, -259, -259, -259, -259,
151601 /* 70 */ -259, -259, -259, -259, -259, -259, -259, -259, 428, 430,
151602 /* 80 */ 899, 985, 1021, 1028, 1057, 1069, 1081, 1108, 1110, 1115,
151603 /* 90 */ 1117, 1123, 1149, 1154, 1159, 1170, 1174, 1178, 1183, 1194,
151604 /* 100 */ 1198, 1204, 1208, 1212, 1218, 1222, 1229, 1278, 1280, 1283,
151605 /* 110 */ 1285, 1313, 1316, 1320, 1322, 1325, 1327, 1330, 1366, 1371,
151606 /* 120 */ 1379, 1387, 1417, 1425, 1430, 1432, -259, -259, -259, -259,
151607 /* 130 */ -259, -259, -259, -259, -259, 557, 974, -214, -174, -9,
151608 /* 140 */ 431, -124, 806, 925, 806, 925, 251, 928, 940, -259,
151609 /* 150 */ -259, -259, -259, -198, -198, -198, 127, -186, -168, 212,
151610 /* 160 */ 646, 617, 799, -262, 555, 220, 220, 491, 605, 1040,
151611 /* 170 */ 1060, 699, -11, 600, 848, 862, 345, -129, 724, -91,
151612 /* 180 */ 158, 749, 716, 900, 304, 822, 929, 926, 499, 793,
151613 /* 190 */ 322, 892, 813, 845, 958, 1056, 751, 905, 1133, 1062,
151614 /* 200 */ 803, -210, -185, -179, -148, -167, -89, 121, 274, 281,
151615 /* 210 */ 320, 336, 439, 663, 711, 957, 1064, 1068, 1116, 1127,
151616 /* 220 */ 1134, -196, 1147, 1180, 1184, 1195, 1203, 1209, 1254, 1263,
151617 /* 230 */ 1275, 1288, 1304, 1310, 205, 422, 638, 1319, 1324, 1346,
151618 /* 240 */ 1360, 1168, 1364, 1370, 1372, 869, 1189, 1380, 1399, 1276,
151619 /* 250 */ 1403, 121, 1405, 1420, 1426, 1427, 1428, 1429, 1249, 1282,
151620 /* 260 */ 1344, 1375, 1376, 1377, 1388, 1168, 1344, 1344, 1384, 1411,
151621 /* 270 */ 1436, 1349, 1389, 1386, 1391, 1361, 1407, 1408, 1365, 1431,
151622 /* 280 */ 1433, 1434, 1439, 1441, 1442, 1396, 1416, 1418, 1390, 1421,
151623 /* 290 */ 1437, 1472, 1381, 1478, 1480, 1397, 1400, 1487, 1412, 1444,
151624 /* 300 */ 1438, 1463, 1453, 1464, 1465, 1467, 1469, 1514, 1517, 1473,
151625 /* 310 */ 1474, 1452, 1449, 1490, 1491, 1475, 1522, 1526, 1443, 1445,
151626 /* 320 */ 1528, 1530, 1513, 1534, 1536, 1537, 1539, 1516, 1523, 1524,
151627 /* 330 */ 1527, 1519, 1529, 1532, 1540, 1541, 1535, 1542, 1544, 1545,
151628 /* 340 */ 1547, 1450, 1543, 1477, 1482, 1551, 1505, 1508, 1512, 1509,
151629 /* 350 */ 1515, 1518, 1533, 1552, 1573, 1466, 1468, 1549, 1550, 1555,
151630 /* 360 */ 1554, 1510, 1583, 1511, 1556, 1559, 1561, 1565, 1588, 1592,
151631 /* 370 */ 1601, 1602, 1607, 1608, 1609, 1498, 1557, 1558, 1610, 1600,
151632 /* 380 */ 1603, 1611, 1612, 1613, 1596, 1597, 1614, 1615, 1617, 1616,
151633 };
151634 static const YYACTIONTYPE yy_default[] = {
151635 /* 0 */ 1572, 1572, 1572, 1408, 1185, 1294, 1185, 1185, 1185, 1408,
151636 /* 10 */ 1408, 1408, 1185, 1324, 1324, 1461, 1216, 1185, 1185, 1185,
151637 /* 20 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1407, 1185, 1185,
151638 /* 30 */ 1185, 1185, 1491, 1491, 1185, 1185, 1185, 1185, 1185, 1185,
151639 /* 40 */ 1185, 1185, 1185, 1333, 1185, 1185, 1185, 1185, 1185, 1185,
151640 /* 50 */ 1409, 1410, 1185, 1185, 1185, 1460, 1462, 1425, 1343, 1342,
151641 /* 60 */ 1341, 1340, 1443, 1311, 1338, 1331, 1335, 1403, 1404, 1402,
151642 /* 70 */ 1406, 1410, 1409, 1185, 1334, 1374, 1388, 1373, 1185, 1185,
151643 /* 80 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151644 /* 90 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151645 /* 100 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151646 /* 110 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151647 /* 120 */ 1185, 1185, 1185, 1185, 1185, 1185, 1382, 1387, 1393, 1386,
151648 /* 130 */ 1383, 1376, 1375, 1377, 1378, 1185, 1206, 1258, 1185, 1185,
151649 /* 140 */ 1185, 1185, 1479, 1478, 1185, 1185, 1216, 1368, 1367, 1379,
151650 /* 150 */ 1380, 1390, 1389, 1468, 1526, 1525, 1426, 1185, 1185, 1185,
151651 /* 160 */ 1185, 1185, 1185, 1491, 1185, 1185, 1185, 1185, 1185, 1185,
151652 /* 170 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151653 /* 180 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1491, 1491,
151654 /* 190 */ 1185, 1216, 1491, 1491, 1212, 1212, 1318, 1185, 1474, 1294,
151655 /* 200 */ 1285, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151656 /* 210 */ 1185, 1185, 1185, 1185, 1185, 1465, 1463, 1185, 1185, 1185,
151657 /* 220 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151658 /* 230 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151659 /* 240 */ 1185, 1185, 1185, 1185, 1185, 1290, 1185, 1185, 1185, 1185,
151660 /* 250 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1520, 1185, 1438,
151661 /* 260 */ 1272, 1290, 1290, 1290, 1290, 1292, 1273, 1271, 1284, 1217,
151662 /* 270 */ 1192, 1564, 1337, 1313, 1313, 1561, 1337, 1337, 1561, 1233,
151663 /* 280 */ 1542, 1228, 1324, 1324, 1324, 1313, 1318, 1318, 1405, 1291,
151664 /* 290 */ 1284, 1185, 1564, 1299, 1299, 1563, 1563, 1299, 1426, 1346,
151665 /* 300 */ 1352, 1261, 1337, 1267, 1267, 1267, 1267, 1299, 1203, 1337,
151666 /* 310 */ 1337, 1346, 1352, 1261, 1261, 1337, 1299, 1203, 1442, 1558,
151667 /* 320 */ 1299, 1203, 1416, 1299, 1203, 1299, 1203, 1416, 1259, 1259,
151668 /* 330 */ 1259, 1248, 1185, 1185, 1416, 1259, 1233, 1259, 1248, 1259,
151669 /* 340 */ 1259, 1509, 1416, 1420, 1420, 1416, 1317, 1312, 1317, 1312,
151670 /* 350 */ 1317, 1312, 1317, 1312, 1299, 1501, 1501, 1327, 1327, 1332,
151671 /* 360 */ 1318, 1411, 1299, 1185, 1332, 1330, 1328, 1337, 1209, 1251,
151672 /* 370 */ 1523, 1523, 1519, 1519, 1519, 1569, 1569, 1474, 1535, 1216,
151673 /* 380 */ 1216, 1216, 1216, 1535, 1235, 1235, 1217, 1217, 1216, 1535,
151674 /* 390 */ 1185, 1185, 1185, 1185, 1185, 1185, 1530, 1185, 1427, 1303,
151675 /* 400 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151676 /* 410 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151677 /* 420 */ 1185, 1185, 1185, 1357, 1185, 1188, 1471, 1185, 1185, 1469,
151678 /* 430 */ 1185, 1185, 1185, 1185, 1185, 1185, 1304, 1185, 1185, 1185,
151679 /* 440 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151680 /* 450 */ 1185, 1185, 1185, 1185, 1185, 1560, 1185, 1185, 1185, 1185,
151681 /* 460 */ 1185, 1185, 1441, 1440, 1185, 1185, 1301, 1185, 1185, 1185,
151682 /* 470 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151683 /* 480 */ 1231, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151684 /* 490 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151685 /* 500 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1329, 1185, 1185,
151686 /* 510 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151687 /* 520 */ 1185, 1185, 1506, 1319, 1185, 1185, 1551, 1185, 1185, 1185,
151688 /* 530 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151689 /* 540 */ 1185, 1546, 1275, 1359, 1185, 1358, 1362, 1185, 1197, 1185,
151690 };
151691 /********** End of lemon-generated parsing tables *****************************/
151692
151693 /* The next table maps tokens (terminal symbols) into fallback tokens.
151694 ** If a construct like the following:
@@ -150685,10 +151799,12 @@
151799 59, /* UNBOUNDED => ID */
151800 59, /* EXCLUDE => ID */
151801 59, /* GROUPS => ID */
151802 59, /* OTHERS => ID */
151803 59, /* TIES => ID */
151804 59, /* GENERATED => ID */
151805 59, /* ALWAYS => ID */
151806 59, /* REINDEX => ID */
151807 59, /* RENAME => ID */
151808 59, /* CTIME_KW => ID */
151809 0, /* ANY => nothing */
151810 0, /* BITAND => nothing */
@@ -150951,222 +152067,225 @@
152067 /* 90 */ "UNBOUNDED",
152068 /* 91 */ "EXCLUDE",
152069 /* 92 */ "GROUPS",
152070 /* 93 */ "OTHERS",
152071 /* 94 */ "TIES",
152072 /* 95 */ "GENERATED",
152073 /* 96 */ "ALWAYS",
152074 /* 97 */ "REINDEX",
152075 /* 98 */ "RENAME",
152076 /* 99 */ "CTIME_KW",
152077 /* 100 */ "ANY",
152078 /* 101 */ "BITAND",
152079 /* 102 */ "BITOR",
152080 /* 103 */ "LSHIFT",
152081 /* 104 */ "RSHIFT",
152082 /* 105 */ "PLUS",
152083 /* 106 */ "MINUS",
152084 /* 107 */ "STAR",
152085 /* 108 */ "SLASH",
152086 /* 109 */ "REM",
152087 /* 110 */ "CONCAT",
152088 /* 111 */ "COLLATE",
152089 /* 112 */ "BITNOT",
152090 /* 113 */ "ON",
152091 /* 114 */ "INDEXED",
152092 /* 115 */ "STRING",
152093 /* 116 */ "JOIN_KW",
152094 /* 117 */ "CONSTRAINT",
152095 /* 118 */ "DEFAULT",
152096 /* 119 */ "NULL",
152097 /* 120 */ "PRIMARY",
152098 /* 121 */ "UNIQUE",
152099 /* 122 */ "CHECK",
152100 /* 123 */ "REFERENCES",
152101 /* 124 */ "AUTOINCR",
152102 /* 125 */ "INSERT",
152103 /* 126 */ "DELETE",
152104 /* 127 */ "UPDATE",
152105 /* 128 */ "SET",
152106 /* 129 */ "DEFERRABLE",
152107 /* 130 */ "FOREIGN",
152108 /* 131 */ "DROP",
152109 /* 132 */ "UNION",
152110 /* 133 */ "ALL",
152111 /* 134 */ "EXCEPT",
152112 /* 135 */ "INTERSECT",
152113 /* 136 */ "SELECT",
152114 /* 137 */ "VALUES",
152115 /* 138 */ "DISTINCT",
152116 /* 139 */ "DOT",
152117 /* 140 */ "FROM",
152118 /* 141 */ "JOIN",
152119 /* 142 */ "USING",
152120 /* 143 */ "ORDER",
152121 /* 144 */ "GROUP",
152122 /* 145 */ "HAVING",
152123 /* 146 */ "LIMIT",
152124 /* 147 */ "WHERE",
152125 /* 148 */ "INTO",
152126 /* 149 */ "NOTHING",
152127 /* 150 */ "FLOAT",
152128 /* 151 */ "BLOB",
152129 /* 152 */ "INTEGER",
152130 /* 153 */ "VARIABLE",
152131 /* 154 */ "CASE",
152132 /* 155 */ "WHEN",
152133 /* 156 */ "THEN",
152134 /* 157 */ "ELSE",
152135 /* 158 */ "INDEX",
152136 /* 159 */ "ALTER",
152137 /* 160 */ "ADD",
152138 /* 161 */ "WINDOW",
152139 /* 162 */ "OVER",
152140 /* 163 */ "FILTER",
152141 /* 164 */ "COLUMN",
152142 /* 165 */ "AGG_FUNCTION",
152143 /* 166 */ "AGG_COLUMN",
152144 /* 167 */ "TRUEFALSE",
152145 /* 168 */ "ISNOT",
152146 /* 169 */ "FUNCTION",
152147 /* 170 */ "UMINUS",
152148 /* 171 */ "UPLUS",
152149 /* 172 */ "TRUTH",
152150 /* 173 */ "REGISTER",
152151 /* 174 */ "VECTOR",
152152 /* 175 */ "SELECT_COLUMN",
152153 /* 176 */ "IF_NULL_ROW",
152154 /* 177 */ "ASTERISK",
152155 /* 178 */ "SPAN",
152156 /* 179 */ "SPACE",
152157 /* 180 */ "ILLEGAL",
152158 /* 181 */ "input",
152159 /* 182 */ "cmdlist",
152160 /* 183 */ "ecmd",
152161 /* 184 */ "cmdx",
152162 /* 185 */ "explain",
152163 /* 186 */ "cmd",
152164 /* 187 */ "transtype",
152165 /* 188 */ "trans_opt",
152166 /* 189 */ "nm",
152167 /* 190 */ "savepoint_opt",
152168 /* 191 */ "create_table",
152169 /* 192 */ "create_table_args",
152170 /* 193 */ "createkw",
152171 /* 194 */ "temp",
152172 /* 195 */ "ifnotexists",
152173 /* 196 */ "dbnm",
152174 /* 197 */ "columnlist",
152175 /* 198 */ "conslist_opt",
152176 /* 199 */ "table_options",
152177 /* 200 */ "select",
152178 /* 201 */ "columnname",
152179 /* 202 */ "carglist",
152180 /* 203 */ "typetoken",
152181 /* 204 */ "typename",
152182 /* 205 */ "signed",
152183 /* 206 */ "plus_num",
152184 /* 207 */ "minus_num",
152185 /* 208 */ "scanpt",
152186 /* 209 */ "scantok",
152187 /* 210 */ "ccons",
152188 /* 211 */ "term",
152189 /* 212 */ "expr",
152190 /* 213 */ "onconf",
152191 /* 214 */ "sortorder",
152192 /* 215 */ "autoinc",
152193 /* 216 */ "eidlist_opt",
152194 /* 217 */ "refargs",
152195 /* 218 */ "defer_subclause",
152196 /* 219 */ "generated",
152197 /* 220 */ "refarg",
152198 /* 221 */ "refact",
152199 /* 222 */ "init_deferred_pred_opt",
152200 /* 223 */ "conslist",
152201 /* 224 */ "tconscomma",
152202 /* 225 */ "tcons",
152203 /* 226 */ "sortlist",
152204 /* 227 */ "eidlist",
152205 /* 228 */ "defer_subclause_opt",
152206 /* 229 */ "orconf",
152207 /* 230 */ "resolvetype",
152208 /* 231 */ "raisetype",
152209 /* 232 */ "ifexists",
152210 /* 233 */ "fullname",
152211 /* 234 */ "selectnowith",
152212 /* 235 */ "oneselect",
152213 /* 236 */ "wqlist",
152214 /* 237 */ "multiselect_op",
152215 /* 238 */ "distinct",
152216 /* 239 */ "selcollist",
152217 /* 240 */ "from",
152218 /* 241 */ "where_opt",
152219 /* 242 */ "groupby_opt",
152220 /* 243 */ "having_opt",
152221 /* 244 */ "orderby_opt",
152222 /* 245 */ "limit_opt",
152223 /* 246 */ "window_clause",
152224 /* 247 */ "values",
152225 /* 248 */ "nexprlist",
152226 /* 249 */ "sclp",
152227 /* 250 */ "as",
152228 /* 251 */ "seltablist",
152229 /* 252 */ "stl_prefix",
152230 /* 253 */ "joinop",
152231 /* 254 */ "indexed_opt",
152232 /* 255 */ "on_opt",
152233 /* 256 */ "using_opt",
152234 /* 257 */ "exprlist",
152235 /* 258 */ "xfullname",
152236 /* 259 */ "idlist",
152237 /* 260 */ "nulls",
152238 /* 261 */ "with",
152239 /* 262 */ "setlist",
152240 /* 263 */ "insert_cmd",
152241 /* 264 */ "idlist_opt",
152242 /* 265 */ "upsert",
152243 /* 266 */ "filter_over",
152244 /* 267 */ "likeop",
152245 /* 268 */ "between_op",
152246 /* 269 */ "in_op",
152247 /* 270 */ "paren_exprlist",
152248 /* 271 */ "case_operand",
152249 /* 272 */ "case_exprlist",
152250 /* 273 */ "case_else",
152251 /* 274 */ "uniqueflag",
152252 /* 275 */ "collate",
152253 /* 276 */ "vinto",
152254 /* 277 */ "nmnum",
152255 /* 278 */ "trigger_decl",
152256 /* 279 */ "trigger_cmd_list",
152257 /* 280 */ "trigger_time",
152258 /* 281 */ "trigger_event",
152259 /* 282 */ "foreach_clause",
152260 /* 283 */ "when_clause",
152261 /* 284 */ "trigger_cmd",
152262 /* 285 */ "trnm",
152263 /* 286 */ "tridxby",
152264 /* 287 */ "database_kw_opt",
152265 /* 288 */ "key_opt",
152266 /* 289 */ "add_column_fullname",
152267 /* 290 */ "kwcolumn_opt",
152268 /* 291 */ "create_vtab",
152269 /* 292 */ "vtabarglist",
152270 /* 293 */ "vtabarg",
152271 /* 294 */ "vtabargtoken",
152272 /* 295 */ "lp",
152273 /* 296 */ "anylist",
152274 /* 297 */ "windowdefn_list",
152275 /* 298 */ "windowdefn",
152276 /* 299 */ "window",
152277 /* 300 */ "frame_opt",
152278 /* 301 */ "part_opt",
152279 /* 302 */ "filter_clause",
152280 /* 303 */ "over_clause",
152281 /* 304 */ "range_or_rows",
152282 /* 305 */ "frame_bound",
152283 /* 306 */ "frame_bound_s",
152284 /* 307 */ "frame_bound_e",
152285 /* 308 */ "frame_exclude_opt",
152286 /* 309 */ "frame_exclude",
152287 };
152288 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
152289
152290 #ifndef NDEBUG
152291 /* For tracing reduce actions, the names of all rules are required.
@@ -151213,348 +152332,352 @@
152332 /* 38 */ "ccons ::= UNIQUE onconf",
152333 /* 39 */ "ccons ::= CHECK LP expr RP",
152334 /* 40 */ "ccons ::= REFERENCES nm eidlist_opt refargs",
152335 /* 41 */ "ccons ::= defer_subclause",
152336 /* 42 */ "ccons ::= COLLATE ID|STRING",
152337 /* 43 */ "generated ::= LP expr RP",
152338 /* 44 */ "generated ::= LP expr RP ID",
152339 /* 45 */ "autoinc ::=",
152340 /* 46 */ "autoinc ::= AUTOINCR",
152341 /* 47 */ "refargs ::=",
152342 /* 48 */ "refargs ::= refargs refarg",
152343 /* 49 */ "refarg ::= MATCH nm",
152344 /* 50 */ "refarg ::= ON INSERT refact",
152345 /* 51 */ "refarg ::= ON DELETE refact",
152346 /* 52 */ "refarg ::= ON UPDATE refact",
152347 /* 53 */ "refact ::= SET NULL",
152348 /* 54 */ "refact ::= SET DEFAULT",
152349 /* 55 */ "refact ::= CASCADE",
152350 /* 56 */ "refact ::= RESTRICT",
152351 /* 57 */ "refact ::= NO ACTION",
152352 /* 58 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
152353 /* 59 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
152354 /* 60 */ "init_deferred_pred_opt ::=",
152355 /* 61 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
152356 /* 62 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
152357 /* 63 */ "conslist_opt ::=",
152358 /* 64 */ "tconscomma ::= COMMA",
152359 /* 65 */ "tcons ::= CONSTRAINT nm",
152360 /* 66 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf",
152361 /* 67 */ "tcons ::= UNIQUE LP sortlist RP onconf",
152362 /* 68 */ "tcons ::= CHECK LP expr RP onconf",
152363 /* 69 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt",
152364 /* 70 */ "defer_subclause_opt ::=",
152365 /* 71 */ "onconf ::=",
152366 /* 72 */ "onconf ::= ON CONFLICT resolvetype",
152367 /* 73 */ "orconf ::=",
152368 /* 74 */ "orconf ::= OR resolvetype",
152369 /* 75 */ "resolvetype ::= IGNORE",
152370 /* 76 */ "resolvetype ::= REPLACE",
152371 /* 77 */ "cmd ::= DROP TABLE ifexists fullname",
152372 /* 78 */ "ifexists ::= IF EXISTS",
152373 /* 79 */ "ifexists ::=",
152374 /* 80 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
152375 /* 81 */ "cmd ::= DROP VIEW ifexists fullname",
152376 /* 82 */ "cmd ::= select",
152377 /* 83 */ "select ::= WITH wqlist selectnowith",
152378 /* 84 */ "select ::= WITH RECURSIVE wqlist selectnowith",
152379 /* 85 */ "select ::= selectnowith",
152380 /* 86 */ "selectnowith ::= selectnowith multiselect_op oneselect",
152381 /* 87 */ "multiselect_op ::= UNION",
152382 /* 88 */ "multiselect_op ::= UNION ALL",
152383 /* 89 */ "multiselect_op ::= EXCEPT|INTERSECT",
152384 /* 90 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
152385 /* 91 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt",
152386 /* 92 */ "values ::= VALUES LP nexprlist RP",
152387 /* 93 */ "values ::= values COMMA LP nexprlist RP",
152388 /* 94 */ "distinct ::= DISTINCT",
152389 /* 95 */ "distinct ::= ALL",
152390 /* 96 */ "distinct ::=",
152391 /* 97 */ "sclp ::=",
152392 /* 98 */ "selcollist ::= sclp scanpt expr scanpt as",
152393 /* 99 */ "selcollist ::= sclp scanpt STAR",
152394 /* 100 */ "selcollist ::= sclp scanpt nm DOT STAR",
152395 /* 101 */ "as ::= AS nm",
152396 /* 102 */ "as ::=",
152397 /* 103 */ "from ::=",
152398 /* 104 */ "from ::= FROM seltablist",
152399 /* 105 */ "stl_prefix ::= seltablist joinop",
152400 /* 106 */ "stl_prefix ::=",
152401 /* 107 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
152402 /* 108 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
152403 /* 109 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
152404 /* 110 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
152405 /* 111 */ "dbnm ::=",
152406 /* 112 */ "dbnm ::= DOT nm",
152407 /* 113 */ "fullname ::= nm",
152408 /* 114 */ "fullname ::= nm DOT nm",
152409 /* 115 */ "xfullname ::= nm",
152410 /* 116 */ "xfullname ::= nm DOT nm",
152411 /* 117 */ "xfullname ::= nm DOT nm AS nm",
152412 /* 118 */ "xfullname ::= nm AS nm",
152413 /* 119 */ "joinop ::= COMMA|JOIN",
152414 /* 120 */ "joinop ::= JOIN_KW JOIN",
152415 /* 121 */ "joinop ::= JOIN_KW nm JOIN",
152416 /* 122 */ "joinop ::= JOIN_KW nm nm JOIN",
152417 /* 123 */ "on_opt ::= ON expr",
152418 /* 124 */ "on_opt ::=",
152419 /* 125 */ "indexed_opt ::=",
152420 /* 126 */ "indexed_opt ::= INDEXED BY nm",
152421 /* 127 */ "indexed_opt ::= NOT INDEXED",
152422 /* 128 */ "using_opt ::= USING LP idlist RP",
152423 /* 129 */ "using_opt ::=",
152424 /* 130 */ "orderby_opt ::=",
152425 /* 131 */ "orderby_opt ::= ORDER BY sortlist",
152426 /* 132 */ "sortlist ::= sortlist COMMA expr sortorder nulls",
152427 /* 133 */ "sortlist ::= expr sortorder nulls",
152428 /* 134 */ "sortorder ::= ASC",
152429 /* 135 */ "sortorder ::= DESC",
152430 /* 136 */ "sortorder ::=",
152431 /* 137 */ "nulls ::= NULLS FIRST",
152432 /* 138 */ "nulls ::= NULLS LAST",
152433 /* 139 */ "nulls ::=",
152434 /* 140 */ "groupby_opt ::=",
152435 /* 141 */ "groupby_opt ::= GROUP BY nexprlist",
152436 /* 142 */ "having_opt ::=",
152437 /* 143 */ "having_opt ::= HAVING expr",
152438 /* 144 */ "limit_opt ::=",
152439 /* 145 */ "limit_opt ::= LIMIT expr",
152440 /* 146 */ "limit_opt ::= LIMIT expr OFFSET expr",
152441 /* 147 */ "limit_opt ::= LIMIT expr COMMA expr",
152442 /* 148 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
152443 /* 149 */ "where_opt ::=",
152444 /* 150 */ "where_opt ::= WHERE expr",
152445 /* 151 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
152446 /* 152 */ "setlist ::= setlist COMMA nm EQ expr",
152447 /* 153 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
152448 /* 154 */ "setlist ::= nm EQ expr",
152449 /* 155 */ "setlist ::= LP idlist RP EQ expr",
152450 /* 156 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
152451 /* 157 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
152452 /* 158 */ "upsert ::=",
152453 /* 159 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
152454 /* 160 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
152455 /* 161 */ "upsert ::= ON CONFLICT DO NOTHING",
152456 /* 162 */ "insert_cmd ::= INSERT orconf",
152457 /* 163 */ "insert_cmd ::= REPLACE",
152458 /* 164 */ "idlist_opt ::=",
152459 /* 165 */ "idlist_opt ::= LP idlist RP",
152460 /* 166 */ "idlist ::= idlist COMMA nm",
152461 /* 167 */ "idlist ::= nm",
152462 /* 168 */ "expr ::= LP expr RP",
152463 /* 169 */ "expr ::= ID|INDEXED",
152464 /* 170 */ "expr ::= JOIN_KW",
152465 /* 171 */ "expr ::= nm DOT nm",
152466 /* 172 */ "expr ::= nm DOT nm DOT nm",
152467 /* 173 */ "term ::= NULL|FLOAT|BLOB",
152468 /* 174 */ "term ::= STRING",
152469 /* 175 */ "term ::= INTEGER",
152470 /* 176 */ "expr ::= VARIABLE",
152471 /* 177 */ "expr ::= expr COLLATE ID|STRING",
152472 /* 178 */ "expr ::= CAST LP expr AS typetoken RP",
152473 /* 179 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
152474 /* 180 */ "expr ::= ID|INDEXED LP STAR RP",
152475 /* 181 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over",
152476 /* 182 */ "expr ::= ID|INDEXED LP STAR RP filter_over",
152477 /* 183 */ "term ::= CTIME_KW",
152478 /* 184 */ "expr ::= LP nexprlist COMMA expr RP",
152479 /* 185 */ "expr ::= expr AND expr",
152480 /* 186 */ "expr ::= expr OR expr",
152481 /* 187 */ "expr ::= expr LT|GT|GE|LE expr",
152482 /* 188 */ "expr ::= expr EQ|NE expr",
152483 /* 189 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
152484 /* 190 */ "expr ::= expr PLUS|MINUS expr",
152485 /* 191 */ "expr ::= expr STAR|SLASH|REM expr",
152486 /* 192 */ "expr ::= expr CONCAT expr",
152487 /* 193 */ "likeop ::= NOT LIKE_KW|MATCH",
152488 /* 194 */ "expr ::= expr likeop expr",
152489 /* 195 */ "expr ::= expr likeop expr ESCAPE expr",
152490 /* 196 */ "expr ::= expr ISNULL|NOTNULL",
152491 /* 197 */ "expr ::= expr NOT NULL",
152492 /* 198 */ "expr ::= expr IS expr",
152493 /* 199 */ "expr ::= expr IS NOT expr",
152494 /* 200 */ "expr ::= NOT expr",
152495 /* 201 */ "expr ::= BITNOT expr",
152496 /* 202 */ "expr ::= PLUS|MINUS expr",
152497 /* 203 */ "between_op ::= BETWEEN",
152498 /* 204 */ "between_op ::= NOT BETWEEN",
152499 /* 205 */ "expr ::= expr between_op expr AND expr",
152500 /* 206 */ "in_op ::= IN",
152501 /* 207 */ "in_op ::= NOT IN",
152502 /* 208 */ "expr ::= expr in_op LP exprlist RP",
152503 /* 209 */ "expr ::= LP select RP",
152504 /* 210 */ "expr ::= expr in_op LP select RP",
152505 /* 211 */ "expr ::= expr in_op nm dbnm paren_exprlist",
152506 /* 212 */ "expr ::= EXISTS LP select RP",
152507 /* 213 */ "expr ::= CASE case_operand case_exprlist case_else END",
152508 /* 214 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
152509 /* 215 */ "case_exprlist ::= WHEN expr THEN expr",
152510 /* 216 */ "case_else ::= ELSE expr",
152511 /* 217 */ "case_else ::=",
152512 /* 218 */ "case_operand ::= expr",
152513 /* 219 */ "case_operand ::=",
152514 /* 220 */ "exprlist ::=",
152515 /* 221 */ "nexprlist ::= nexprlist COMMA expr",
152516 /* 222 */ "nexprlist ::= expr",
152517 /* 223 */ "paren_exprlist ::=",
152518 /* 224 */ "paren_exprlist ::= LP exprlist RP",
152519 /* 225 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
152520 /* 226 */ "uniqueflag ::= UNIQUE",
152521 /* 227 */ "uniqueflag ::=",
152522 /* 228 */ "eidlist_opt ::=",
152523 /* 229 */ "eidlist_opt ::= LP eidlist RP",
152524 /* 230 */ "eidlist ::= eidlist COMMA nm collate sortorder",
152525 /* 231 */ "eidlist ::= nm collate sortorder",
152526 /* 232 */ "collate ::=",
152527 /* 233 */ "collate ::= COLLATE ID|STRING",
152528 /* 234 */ "cmd ::= DROP INDEX ifexists fullname",
152529 /* 235 */ "cmd ::= VACUUM vinto",
152530 /* 236 */ "cmd ::= VACUUM nm vinto",
152531 /* 237 */ "vinto ::= INTO expr",
152532 /* 238 */ "vinto ::=",
152533 /* 239 */ "cmd ::= PRAGMA nm dbnm",
152534 /* 240 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
152535 /* 241 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
152536 /* 242 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
152537 /* 243 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
152538 /* 244 */ "plus_num ::= PLUS INTEGER|FLOAT",
152539 /* 245 */ "minus_num ::= MINUS INTEGER|FLOAT",
152540 /* 246 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
152541 /* 247 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
152542 /* 248 */ "trigger_time ::= BEFORE|AFTER",
152543 /* 249 */ "trigger_time ::= INSTEAD OF",
152544 /* 250 */ "trigger_time ::=",
152545 /* 251 */ "trigger_event ::= DELETE|INSERT",
152546 /* 252 */ "trigger_event ::= UPDATE",
152547 /* 253 */ "trigger_event ::= UPDATE OF idlist",
152548 /* 254 */ "when_clause ::=",
152549 /* 255 */ "when_clause ::= WHEN expr",
152550 /* 256 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
152551 /* 257 */ "trigger_cmd_list ::= trigger_cmd SEMI",
152552 /* 258 */ "trnm ::= nm DOT nm",
152553 /* 259 */ "tridxby ::= INDEXED BY nm",
152554 /* 260 */ "tridxby ::= NOT INDEXED",
152555 /* 261 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
152556 /* 262 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
152557 /* 263 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
152558 /* 264 */ "trigger_cmd ::= scanpt select scanpt",
152559 /* 265 */ "expr ::= RAISE LP IGNORE RP",
152560 /* 266 */ "expr ::= RAISE LP raisetype COMMA nm RP",
152561 /* 267 */ "raisetype ::= ROLLBACK",
152562 /* 268 */ "raisetype ::= ABORT",
152563 /* 269 */ "raisetype ::= FAIL",
152564 /* 270 */ "cmd ::= DROP TRIGGER ifexists fullname",
152565 /* 271 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
152566 /* 272 */ "cmd ::= DETACH database_kw_opt expr",
152567 /* 273 */ "key_opt ::=",
152568 /* 274 */ "key_opt ::= KEY expr",
152569 /* 275 */ "cmd ::= REINDEX",
152570 /* 276 */ "cmd ::= REINDEX nm dbnm",
152571 /* 277 */ "cmd ::= ANALYZE",
152572 /* 278 */ "cmd ::= ANALYZE nm dbnm",
152573 /* 279 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
152574 /* 280 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
152575 /* 281 */ "add_column_fullname ::= fullname",
152576 /* 282 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
152577 /* 283 */ "cmd ::= create_vtab",
152578 /* 284 */ "cmd ::= create_vtab LP vtabarglist RP",
152579 /* 285 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
152580 /* 286 */ "vtabarg ::=",
152581 /* 287 */ "vtabargtoken ::= ANY",
152582 /* 288 */ "vtabargtoken ::= lp anylist RP",
152583 /* 289 */ "lp ::= LP",
152584 /* 290 */ "with ::= WITH wqlist",
152585 /* 291 */ "with ::= WITH RECURSIVE wqlist",
152586 /* 292 */ "wqlist ::= nm eidlist_opt AS LP select RP",
152587 /* 293 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
152588 /* 294 */ "windowdefn_list ::= windowdefn",
152589 /* 295 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
152590 /* 296 */ "windowdefn ::= nm AS LP window RP",
152591 /* 297 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
152592 /* 298 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
152593 /* 299 */ "window ::= ORDER BY sortlist frame_opt",
152594 /* 300 */ "window ::= nm ORDER BY sortlist frame_opt",
152595 /* 301 */ "window ::= frame_opt",
152596 /* 302 */ "window ::= nm frame_opt",
152597 /* 303 */ "frame_opt ::=",
152598 /* 304 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
152599 /* 305 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
152600 /* 306 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
152601 /* 307 */ "frame_bound_s ::= frame_bound",
152602 /* 308 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
152603 /* 309 */ "frame_bound_e ::= frame_bound",
152604 /* 310 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
152605 /* 311 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
152606 /* 312 */ "frame_bound ::= CURRENT ROW",
152607 /* 313 */ "frame_exclude_opt ::=",
152608 /* 314 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
152609 /* 315 */ "frame_exclude ::= NO OTHERS",
152610 /* 316 */ "frame_exclude ::= CURRENT ROW",
152611 /* 317 */ "frame_exclude ::= GROUP|TIES",
152612 /* 318 */ "window_clause ::= WINDOW windowdefn_list",
152613 /* 319 */ "filter_over ::= filter_clause over_clause",
152614 /* 320 */ "filter_over ::= over_clause",
152615 /* 321 */ "filter_over ::= filter_clause",
152616 /* 322 */ "over_clause ::= OVER LP window RP",
152617 /* 323 */ "over_clause ::= OVER nm",
152618 /* 324 */ "filter_clause ::= FILTER LP WHERE expr RP",
152619 /* 325 */ "input ::= cmdlist",
152620 /* 326 */ "cmdlist ::= cmdlist ecmd",
152621 /* 327 */ "cmdlist ::= ecmd",
152622 /* 328 */ "ecmd ::= SEMI",
152623 /* 329 */ "ecmd ::= cmdx SEMI",
152624 /* 330 */ "ecmd ::= explain cmdx",
152625 /* 331 */ "trans_opt ::=",
152626 /* 332 */ "trans_opt ::= TRANSACTION",
152627 /* 333 */ "trans_opt ::= TRANSACTION nm",
152628 /* 334 */ "savepoint_opt ::= SAVEPOINT",
152629 /* 335 */ "savepoint_opt ::=",
152630 /* 336 */ "cmd ::= create_table create_table_args",
152631 /* 337 */ "columnlist ::= columnlist COMMA columnname carglist",
152632 /* 338 */ "columnlist ::= columnname carglist",
152633 /* 339 */ "nm ::= ID|INDEXED",
152634 /* 340 */ "nm ::= STRING",
152635 /* 341 */ "nm ::= JOIN_KW",
152636 /* 342 */ "typetoken ::= typename",
152637 /* 343 */ "typename ::= ID|STRING",
152638 /* 344 */ "signed ::= plus_num",
152639 /* 345 */ "signed ::= minus_num",
152640 /* 346 */ "carglist ::= carglist ccons",
152641 /* 347 */ "carglist ::=",
152642 /* 348 */ "ccons ::= NULL onconf",
152643 /* 349 */ "ccons ::= GENERATED ALWAYS AS generated",
152644 /* 350 */ "ccons ::= AS generated",
152645 /* 351 */ "conslist_opt ::= COMMA conslist",
152646 /* 352 */ "conslist ::= conslist tconscomma tcons",
152647 /* 353 */ "conslist ::= tcons",
152648 /* 354 */ "tconscomma ::=",
152649 /* 355 */ "defer_subclause_opt ::= defer_subclause",
152650 /* 356 */ "resolvetype ::= raisetype",
152651 /* 357 */ "selectnowith ::= oneselect",
152652 /* 358 */ "oneselect ::= values",
152653 /* 359 */ "sclp ::= selcollist COMMA",
152654 /* 360 */ "as ::= ID|STRING",
152655 /* 361 */ "expr ::= term",
152656 /* 362 */ "likeop ::= LIKE_KW|MATCH",
152657 /* 363 */ "exprlist ::= nexprlist",
152658 /* 364 */ "nmnum ::= plus_num",
152659 /* 365 */ "nmnum ::= nm",
152660 /* 366 */ "nmnum ::= ON",
152661 /* 367 */ "nmnum ::= DELETE",
152662 /* 368 */ "nmnum ::= DEFAULT",
152663 /* 369 */ "plus_num ::= INTEGER|FLOAT",
152664 /* 370 */ "foreach_clause ::=",
152665 /* 371 */ "foreach_clause ::= FOR EACH ROW",
152666 /* 372 */ "trnm ::= nm",
152667 /* 373 */ "tridxby ::=",
152668 /* 374 */ "database_kw_opt ::= DATABASE",
152669 /* 375 */ "database_kw_opt ::=",
152670 /* 376 */ "kwcolumn_opt ::=",
152671 /* 377 */ "kwcolumn_opt ::= COLUMNKW",
152672 /* 378 */ "vtabarglist ::= vtabarg",
152673 /* 379 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
152674 /* 380 */ "vtabarg ::= vtabarg vtabargtoken",
152675 /* 381 */ "anylist ::=",
152676 /* 382 */ "anylist ::= anylist LP anylist RP",
152677 /* 383 */ "anylist ::= anylist ANY",
152678 /* 384 */ "with ::=",
152679 };
152680 #endif /* NDEBUG */
152681
152682
152683 #if YYSTACKDEPTH<=0
@@ -151676,102 +152799,102 @@
152799 ** Note: during a reduce, the only symbols destroyed are those
152800 ** which appear on the RHS of the rule, but which are *not* used
152801 ** inside the C code.
152802 */
152803 /********* Begin destructor definitions ***************************************/
152804 case 200: /* select */
152805 case 234: /* selectnowith */
152806 case 235: /* oneselect */
152807 case 247: /* values */
152808 {
152809 sqlite3SelectDelete(pParse->db, (yypminor->yy539));
152810 }
152811 break;
152812 case 211: /* term */
152813 case 212: /* expr */
152814 case 241: /* where_opt */
152815 case 243: /* having_opt */
152816 case 255: /* on_opt */
152817 case 271: /* case_operand */
152818 case 273: /* case_else */
152819 case 276: /* vinto */
152820 case 283: /* when_clause */
152821 case 288: /* key_opt */
152822 case 302: /* filter_clause */
152823 {
152824 sqlite3ExprDelete(pParse->db, (yypminor->yy202));
152825 }
152826 break;
152827 case 216: /* eidlist_opt */
152828 case 226: /* sortlist */
152829 case 227: /* eidlist */
152830 case 239: /* selcollist */
152831 case 242: /* groupby_opt */
152832 case 244: /* orderby_opt */
152833 case 248: /* nexprlist */
152834 case 249: /* sclp */
152835 case 257: /* exprlist */
152836 case 262: /* setlist */
152837 case 270: /* paren_exprlist */
152838 case 272: /* case_exprlist */
152839 case 301: /* part_opt */
152840 {
152841 sqlite3ExprListDelete(pParse->db, (yypminor->yy242));
152842 }
152843 break;
152844 case 233: /* fullname */
152845 case 240: /* from */
152846 case 251: /* seltablist */
152847 case 252: /* stl_prefix */
152848 case 258: /* xfullname */
152849 {
152850 sqlite3SrcListDelete(pParse->db, (yypminor->yy47));
152851 }
152852 break;
152853 case 236: /* wqlist */
152854 {
152855 sqlite3WithDelete(pParse->db, (yypminor->yy131));
152856 }
152857 break;
152858 case 246: /* window_clause */
152859 case 297: /* windowdefn_list */
152860 {
152861 sqlite3WindowListDelete(pParse->db, (yypminor->yy303));
152862 }
152863 break;
152864 case 256: /* using_opt */
152865 case 259: /* idlist */
152866 case 264: /* idlist_opt */
152867 {
152868 sqlite3IdListDelete(pParse->db, (yypminor->yy600));
152869 }
152870 break;
152871 case 266: /* filter_over */
152872 case 298: /* windowdefn */
152873 case 299: /* window */
152874 case 300: /* frame_opt */
152875 case 303: /* over_clause */
152876 {
152877 sqlite3WindowDelete(pParse->db, (yypminor->yy303));
152878 }
152879 break;
152880 case 279: /* trigger_cmd_list */
152881 case 284: /* trigger_cmd */
152882 {
152883 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy447));
152884 }
152885 break;
152886 case 281: /* trigger_event */
152887 {
152888 sqlite3IdListDelete(pParse->db, (yypminor->yy230).b);
152889 }
152890 break;
152891 case 305: /* frame_bound */
152892 case 306: /* frame_bound_s */
152893 case 307: /* frame_bound_e */
152894 {
152895 sqlite3ExprDelete(pParse->db, (yypminor->yy77).pExpr);
152896 }
152897 break;
152898 /********* End destructor definitions *****************************************/
152899 default: break; /* If no destructor action specified: do nothing */
152900 }
@@ -152058,391 +153181,395 @@
153181 }
153182
153183 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
153184 ** of that rule */
153185 static const YYCODETYPE yyRuleInfoLhs[] = {
153186 185, /* (0) explain ::= EXPLAIN */
153187 185, /* (1) explain ::= EXPLAIN QUERY PLAN */
153188 184, /* (2) cmdx ::= cmd */
153189 186, /* (3) cmd ::= BEGIN transtype trans_opt */
153190 187, /* (4) transtype ::= */
153191 187, /* (5) transtype ::= DEFERRED */
153192 187, /* (6) transtype ::= IMMEDIATE */
153193 187, /* (7) transtype ::= EXCLUSIVE */
153194 186, /* (8) cmd ::= COMMIT|END trans_opt */
153195 186, /* (9) cmd ::= ROLLBACK trans_opt */
153196 186, /* (10) cmd ::= SAVEPOINT nm */
153197 186, /* (11) cmd ::= RELEASE savepoint_opt nm */
153198 186, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
153199 191, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
153200 193, /* (14) createkw ::= CREATE */
153201 195, /* (15) ifnotexists ::= */
153202 195, /* (16) ifnotexists ::= IF NOT EXISTS */
153203 194, /* (17) temp ::= TEMP */
153204 194, /* (18) temp ::= */
153205 192, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
153206 192, /* (20) create_table_args ::= AS select */
153207 199, /* (21) table_options ::= */
153208 199, /* (22) table_options ::= WITHOUT nm */
153209 201, /* (23) columnname ::= nm typetoken */
153210 203, /* (24) typetoken ::= */
153211 203, /* (25) typetoken ::= typename LP signed RP */
153212 203, /* (26) typetoken ::= typename LP signed COMMA signed RP */
153213 204, /* (27) typename ::= typename ID|STRING */
153214 208, /* (28) scanpt ::= */
153215 209, /* (29) scantok ::= */
153216 210, /* (30) ccons ::= CONSTRAINT nm */
153217 210, /* (31) ccons ::= DEFAULT scantok term */
153218 210, /* (32) ccons ::= DEFAULT LP expr RP */
153219 210, /* (33) ccons ::= DEFAULT PLUS scantok term */
153220 210, /* (34) ccons ::= DEFAULT MINUS scantok term */
153221 210, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
153222 210, /* (36) ccons ::= NOT NULL onconf */
153223 210, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
153224 210, /* (38) ccons ::= UNIQUE onconf */
153225 210, /* (39) ccons ::= CHECK LP expr RP */
153226 210, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
153227 210, /* (41) ccons ::= defer_subclause */
153228 210, /* (42) ccons ::= COLLATE ID|STRING */
153229 219, /* (43) generated ::= LP expr RP */
153230 219, /* (44) generated ::= LP expr RP ID */
153231 215, /* (45) autoinc ::= */
153232 215, /* (46) autoinc ::= AUTOINCR */
153233 217, /* (47) refargs ::= */
153234 217, /* (48) refargs ::= refargs refarg */
153235 220, /* (49) refarg ::= MATCH nm */
153236 220, /* (50) refarg ::= ON INSERT refact */
153237 220, /* (51) refarg ::= ON DELETE refact */
153238 220, /* (52) refarg ::= ON UPDATE refact */
153239 221, /* (53) refact ::= SET NULL */
153240 221, /* (54) refact ::= SET DEFAULT */
153241 221, /* (55) refact ::= CASCADE */
153242 221, /* (56) refact ::= RESTRICT */
153243 221, /* (57) refact ::= NO ACTION */
153244 218, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
153245 218, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
153246 222, /* (60) init_deferred_pred_opt ::= */
153247 222, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */
153248 222, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
153249 198, /* (63) conslist_opt ::= */
153250 224, /* (64) tconscomma ::= COMMA */
153251 225, /* (65) tcons ::= CONSTRAINT nm */
153252 225, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
153253 225, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */
153254 225, /* (68) tcons ::= CHECK LP expr RP onconf */
153255 225, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
153256 228, /* (70) defer_subclause_opt ::= */
153257 213, /* (71) onconf ::= */
153258 213, /* (72) onconf ::= ON CONFLICT resolvetype */
153259 229, /* (73) orconf ::= */
153260 229, /* (74) orconf ::= OR resolvetype */
153261 230, /* (75) resolvetype ::= IGNORE */
153262 230, /* (76) resolvetype ::= REPLACE */
153263 186, /* (77) cmd ::= DROP TABLE ifexists fullname */
153264 232, /* (78) ifexists ::= IF EXISTS */
153265 232, /* (79) ifexists ::= */
153266 186, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
153267 186, /* (81) cmd ::= DROP VIEW ifexists fullname */
153268 186, /* (82) cmd ::= select */
153269 200, /* (83) select ::= WITH wqlist selectnowith */
153270 200, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */
153271 200, /* (85) select ::= selectnowith */
153272 234, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */
153273 237, /* (87) multiselect_op ::= UNION */
153274 237, /* (88) multiselect_op ::= UNION ALL */
153275 237, /* (89) multiselect_op ::= EXCEPT|INTERSECT */
153276 235, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
153277 235, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
153278 247, /* (92) values ::= VALUES LP nexprlist RP */
153279 247, /* (93) values ::= values COMMA LP nexprlist RP */
153280 238, /* (94) distinct ::= DISTINCT */
153281 238, /* (95) distinct ::= ALL */
153282 238, /* (96) distinct ::= */
153283 249, /* (97) sclp ::= */
153284 239, /* (98) selcollist ::= sclp scanpt expr scanpt as */
153285 239, /* (99) selcollist ::= sclp scanpt STAR */
153286 239, /* (100) selcollist ::= sclp scanpt nm DOT STAR */
153287 250, /* (101) as ::= AS nm */
153288 250, /* (102) as ::= */
153289 240, /* (103) from ::= */
153290 240, /* (104) from ::= FROM seltablist */
153291 252, /* (105) stl_prefix ::= seltablist joinop */
153292 252, /* (106) stl_prefix ::= */
153293 251, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
153294 251, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
153295 251, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
153296 251, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
153297 196, /* (111) dbnm ::= */
153298 196, /* (112) dbnm ::= DOT nm */
153299 233, /* (113) fullname ::= nm */
153300 233, /* (114) fullname ::= nm DOT nm */
153301 258, /* (115) xfullname ::= nm */
153302 258, /* (116) xfullname ::= nm DOT nm */
153303 258, /* (117) xfullname ::= nm DOT nm AS nm */
153304 258, /* (118) xfullname ::= nm AS nm */
153305 253, /* (119) joinop ::= COMMA|JOIN */
153306 253, /* (120) joinop ::= JOIN_KW JOIN */
153307 253, /* (121) joinop ::= JOIN_KW nm JOIN */
153308 253, /* (122) joinop ::= JOIN_KW nm nm JOIN */
153309 255, /* (123) on_opt ::= ON expr */
153310 255, /* (124) on_opt ::= */
153311 254, /* (125) indexed_opt ::= */
153312 254, /* (126) indexed_opt ::= INDEXED BY nm */
153313 254, /* (127) indexed_opt ::= NOT INDEXED */
153314 256, /* (128) using_opt ::= USING LP idlist RP */
153315 256, /* (129) using_opt ::= */
153316 244, /* (130) orderby_opt ::= */
153317 244, /* (131) orderby_opt ::= ORDER BY sortlist */
153318 226, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */
153319 226, /* (133) sortlist ::= expr sortorder nulls */
153320 214, /* (134) sortorder ::= ASC */
153321 214, /* (135) sortorder ::= DESC */
153322 214, /* (136) sortorder ::= */
153323 260, /* (137) nulls ::= NULLS FIRST */
153324 260, /* (138) nulls ::= NULLS LAST */
153325 260, /* (139) nulls ::= */
153326 242, /* (140) groupby_opt ::= */
153327 242, /* (141) groupby_opt ::= GROUP BY nexprlist */
153328 243, /* (142) having_opt ::= */
153329 243, /* (143) having_opt ::= HAVING expr */
153330 245, /* (144) limit_opt ::= */
153331 245, /* (145) limit_opt ::= LIMIT expr */
153332 245, /* (146) limit_opt ::= LIMIT expr OFFSET expr */
153333 245, /* (147) limit_opt ::= LIMIT expr COMMA expr */
153334 186, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
153335 241, /* (149) where_opt ::= */
153336 241, /* (150) where_opt ::= WHERE expr */
153337 186, /* (151) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
153338 262, /* (152) setlist ::= setlist COMMA nm EQ expr */
153339 262, /* (153) setlist ::= setlist COMMA LP idlist RP EQ expr */
153340 262, /* (154) setlist ::= nm EQ expr */
153341 262, /* (155) setlist ::= LP idlist RP EQ expr */
153342 186, /* (156) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
153343 186, /* (157) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
153344 265, /* (158) upsert ::= */
153345 265, /* (159) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
153346 265, /* (160) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
153347 265, /* (161) upsert ::= ON CONFLICT DO NOTHING */
153348 263, /* (162) insert_cmd ::= INSERT orconf */
153349 263, /* (163) insert_cmd ::= REPLACE */
153350 264, /* (164) idlist_opt ::= */
153351 264, /* (165) idlist_opt ::= LP idlist RP */
153352 259, /* (166) idlist ::= idlist COMMA nm */
153353 259, /* (167) idlist ::= nm */
153354 212, /* (168) expr ::= LP expr RP */
153355 212, /* (169) expr ::= ID|INDEXED */
153356 212, /* (170) expr ::= JOIN_KW */
153357 212, /* (171) expr ::= nm DOT nm */
153358 212, /* (172) expr ::= nm DOT nm DOT nm */
153359 211, /* (173) term ::= NULL|FLOAT|BLOB */
153360 211, /* (174) term ::= STRING */
153361 211, /* (175) term ::= INTEGER */
153362 212, /* (176) expr ::= VARIABLE */
153363 212, /* (177) expr ::= expr COLLATE ID|STRING */
153364 212, /* (178) expr ::= CAST LP expr AS typetoken RP */
153365 212, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP */
153366 212, /* (180) expr ::= ID|INDEXED LP STAR RP */
153367 212, /* (181) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
153368 212, /* (182) expr ::= ID|INDEXED LP STAR RP filter_over */
153369 211, /* (183) term ::= CTIME_KW */
153370 212, /* (184) expr ::= LP nexprlist COMMA expr RP */
153371 212, /* (185) expr ::= expr AND expr */
153372 212, /* (186) expr ::= expr OR expr */
153373 212, /* (187) expr ::= expr LT|GT|GE|LE expr */
153374 212, /* (188) expr ::= expr EQ|NE expr */
153375 212, /* (189) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
153376 212, /* (190) expr ::= expr PLUS|MINUS expr */
153377 212, /* (191) expr ::= expr STAR|SLASH|REM expr */
153378 212, /* (192) expr ::= expr CONCAT expr */
153379 267, /* (193) likeop ::= NOT LIKE_KW|MATCH */
153380 212, /* (194) expr ::= expr likeop expr */
153381 212, /* (195) expr ::= expr likeop expr ESCAPE expr */
153382 212, /* (196) expr ::= expr ISNULL|NOTNULL */
153383 212, /* (197) expr ::= expr NOT NULL */
153384 212, /* (198) expr ::= expr IS expr */
153385 212, /* (199) expr ::= expr IS NOT expr */
153386 212, /* (200) expr ::= NOT expr */
153387 212, /* (201) expr ::= BITNOT expr */
153388 212, /* (202) expr ::= PLUS|MINUS expr */
153389 268, /* (203) between_op ::= BETWEEN */
153390 268, /* (204) between_op ::= NOT BETWEEN */
153391 212, /* (205) expr ::= expr between_op expr AND expr */
153392 269, /* (206) in_op ::= IN */
153393 269, /* (207) in_op ::= NOT IN */
153394 212, /* (208) expr ::= expr in_op LP exprlist RP */
153395 212, /* (209) expr ::= LP select RP */
153396 212, /* (210) expr ::= expr in_op LP select RP */
153397 212, /* (211) expr ::= expr in_op nm dbnm paren_exprlist */
153398 212, /* (212) expr ::= EXISTS LP select RP */
153399 212, /* (213) expr ::= CASE case_operand case_exprlist case_else END */
153400 272, /* (214) case_exprlist ::= case_exprlist WHEN expr THEN expr */
153401 272, /* (215) case_exprlist ::= WHEN expr THEN expr */
153402 273, /* (216) case_else ::= ELSE expr */
153403 273, /* (217) case_else ::= */
153404 271, /* (218) case_operand ::= expr */
153405 271, /* (219) case_operand ::= */
153406 257, /* (220) exprlist ::= */
153407 248, /* (221) nexprlist ::= nexprlist COMMA expr */
153408 248, /* (222) nexprlist ::= expr */
153409 270, /* (223) paren_exprlist ::= */
153410 270, /* (224) paren_exprlist ::= LP exprlist RP */
153411 186, /* (225) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
153412 274, /* (226) uniqueflag ::= UNIQUE */
153413 274, /* (227) uniqueflag ::= */
153414 216, /* (228) eidlist_opt ::= */
153415 216, /* (229) eidlist_opt ::= LP eidlist RP */
153416 227, /* (230) eidlist ::= eidlist COMMA nm collate sortorder */
153417 227, /* (231) eidlist ::= nm collate sortorder */
153418 275, /* (232) collate ::= */
153419 275, /* (233) collate ::= COLLATE ID|STRING */
153420 186, /* (234) cmd ::= DROP INDEX ifexists fullname */
153421 186, /* (235) cmd ::= VACUUM vinto */
153422 186, /* (236) cmd ::= VACUUM nm vinto */
153423 276, /* (237) vinto ::= INTO expr */
153424 276, /* (238) vinto ::= */
153425 186, /* (239) cmd ::= PRAGMA nm dbnm */
153426 186, /* (240) cmd ::= PRAGMA nm dbnm EQ nmnum */
153427 186, /* (241) cmd ::= PRAGMA nm dbnm LP nmnum RP */
153428 186, /* (242) cmd ::= PRAGMA nm dbnm EQ minus_num */
153429 186, /* (243) cmd ::= PRAGMA nm dbnm LP minus_num RP */
153430 206, /* (244) plus_num ::= PLUS INTEGER|FLOAT */
153431 207, /* (245) minus_num ::= MINUS INTEGER|FLOAT */
153432 186, /* (246) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
153433 278, /* (247) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
153434 280, /* (248) trigger_time ::= BEFORE|AFTER */
153435 280, /* (249) trigger_time ::= INSTEAD OF */
153436 280, /* (250) trigger_time ::= */
153437 281, /* (251) trigger_event ::= DELETE|INSERT */
153438 281, /* (252) trigger_event ::= UPDATE */
153439 281, /* (253) trigger_event ::= UPDATE OF idlist */
153440 283, /* (254) when_clause ::= */
153441 283, /* (255) when_clause ::= WHEN expr */
153442 279, /* (256) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
153443 279, /* (257) trigger_cmd_list ::= trigger_cmd SEMI */
153444 285, /* (258) trnm ::= nm DOT nm */
153445 286, /* (259) tridxby ::= INDEXED BY nm */
153446 286, /* (260) tridxby ::= NOT INDEXED */
153447 284, /* (261) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
153448 284, /* (262) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
153449 284, /* (263) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
153450 284, /* (264) trigger_cmd ::= scanpt select scanpt */
153451 212, /* (265) expr ::= RAISE LP IGNORE RP */
153452 212, /* (266) expr ::= RAISE LP raisetype COMMA nm RP */
153453 231, /* (267) raisetype ::= ROLLBACK */
153454 231, /* (268) raisetype ::= ABORT */
153455 231, /* (269) raisetype ::= FAIL */
153456 186, /* (270) cmd ::= DROP TRIGGER ifexists fullname */
153457 186, /* (271) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
153458 186, /* (272) cmd ::= DETACH database_kw_opt expr */
153459 288, /* (273) key_opt ::= */
153460 288, /* (274) key_opt ::= KEY expr */
153461 186, /* (275) cmd ::= REINDEX */
153462 186, /* (276) cmd ::= REINDEX nm dbnm */
153463 186, /* (277) cmd ::= ANALYZE */
153464 186, /* (278) cmd ::= ANALYZE nm dbnm */
153465 186, /* (279) cmd ::= ALTER TABLE fullname RENAME TO nm */
153466 186, /* (280) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
153467 289, /* (281) add_column_fullname ::= fullname */
153468 186, /* (282) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
153469 186, /* (283) cmd ::= create_vtab */
153470 186, /* (284) cmd ::= create_vtab LP vtabarglist RP */
153471 291, /* (285) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
153472 293, /* (286) vtabarg ::= */
153473 294, /* (287) vtabargtoken ::= ANY */
153474 294, /* (288) vtabargtoken ::= lp anylist RP */
153475 295, /* (289) lp ::= LP */
153476 261, /* (290) with ::= WITH wqlist */
153477 261, /* (291) with ::= WITH RECURSIVE wqlist */
153478 236, /* (292) wqlist ::= nm eidlist_opt AS LP select RP */
153479 236, /* (293) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
153480 297, /* (294) windowdefn_list ::= windowdefn */
153481 297, /* (295) windowdefn_list ::= windowdefn_list COMMA windowdefn */
153482 298, /* (296) windowdefn ::= nm AS LP window RP */
153483 299, /* (297) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
153484 299, /* (298) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
153485 299, /* (299) window ::= ORDER BY sortlist frame_opt */
153486 299, /* (300) window ::= nm ORDER BY sortlist frame_opt */
153487 299, /* (301) window ::= frame_opt */
153488 299, /* (302) window ::= nm frame_opt */
153489 300, /* (303) frame_opt ::= */
153490 300, /* (304) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
153491 300, /* (305) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
153492 304, /* (306) range_or_rows ::= RANGE|ROWS|GROUPS */
153493 306, /* (307) frame_bound_s ::= frame_bound */
153494 306, /* (308) frame_bound_s ::= UNBOUNDED PRECEDING */
153495 307, /* (309) frame_bound_e ::= frame_bound */
153496 307, /* (310) frame_bound_e ::= UNBOUNDED FOLLOWING */
153497 305, /* (311) frame_bound ::= expr PRECEDING|FOLLOWING */
153498 305, /* (312) frame_bound ::= CURRENT ROW */
153499 308, /* (313) frame_exclude_opt ::= */
153500 308, /* (314) frame_exclude_opt ::= EXCLUDE frame_exclude */
153501 309, /* (315) frame_exclude ::= NO OTHERS */
153502 309, /* (316) frame_exclude ::= CURRENT ROW */
153503 309, /* (317) frame_exclude ::= GROUP|TIES */
153504 246, /* (318) window_clause ::= WINDOW windowdefn_list */
153505 266, /* (319) filter_over ::= filter_clause over_clause */
153506 266, /* (320) filter_over ::= over_clause */
153507 266, /* (321) filter_over ::= filter_clause */
153508 303, /* (322) over_clause ::= OVER LP window RP */
153509 303, /* (323) over_clause ::= OVER nm */
153510 302, /* (324) filter_clause ::= FILTER LP WHERE expr RP */
153511 181, /* (325) input ::= cmdlist */
153512 182, /* (326) cmdlist ::= cmdlist ecmd */
153513 182, /* (327) cmdlist ::= ecmd */
153514 183, /* (328) ecmd ::= SEMI */
153515 183, /* (329) ecmd ::= cmdx SEMI */
153516 183, /* (330) ecmd ::= explain cmdx */
153517 188, /* (331) trans_opt ::= */
153518 188, /* (332) trans_opt ::= TRANSACTION */
153519 188, /* (333) trans_opt ::= TRANSACTION nm */
153520 190, /* (334) savepoint_opt ::= SAVEPOINT */
153521 190, /* (335) savepoint_opt ::= */
153522 186, /* (336) cmd ::= create_table create_table_args */
153523 197, /* (337) columnlist ::= columnlist COMMA columnname carglist */
153524 197, /* (338) columnlist ::= columnname carglist */
153525 189, /* (339) nm ::= ID|INDEXED */
153526 189, /* (340) nm ::= STRING */
153527 189, /* (341) nm ::= JOIN_KW */
153528 203, /* (342) typetoken ::= typename */
153529 204, /* (343) typename ::= ID|STRING */
153530 205, /* (344) signed ::= plus_num */
153531 205, /* (345) signed ::= minus_num */
153532 202, /* (346) carglist ::= carglist ccons */
153533 202, /* (347) carglist ::= */
153534 210, /* (348) ccons ::= NULL onconf */
153535 210, /* (349) ccons ::= GENERATED ALWAYS AS generated */
153536 210, /* (350) ccons ::= AS generated */
153537 198, /* (351) conslist_opt ::= COMMA conslist */
153538 223, /* (352) conslist ::= conslist tconscomma tcons */
153539 223, /* (353) conslist ::= tcons */
153540 224, /* (354) tconscomma ::= */
153541 228, /* (355) defer_subclause_opt ::= defer_subclause */
153542 230, /* (356) resolvetype ::= raisetype */
153543 234, /* (357) selectnowith ::= oneselect */
153544 235, /* (358) oneselect ::= values */
153545 249, /* (359) sclp ::= selcollist COMMA */
153546 250, /* (360) as ::= ID|STRING */
153547 212, /* (361) expr ::= term */
153548 267, /* (362) likeop ::= LIKE_KW|MATCH */
153549 257, /* (363) exprlist ::= nexprlist */
153550 277, /* (364) nmnum ::= plus_num */
153551 277, /* (365) nmnum ::= nm */
153552 277, /* (366) nmnum ::= ON */
153553 277, /* (367) nmnum ::= DELETE */
153554 277, /* (368) nmnum ::= DEFAULT */
153555 206, /* (369) plus_num ::= INTEGER|FLOAT */
153556 282, /* (370) foreach_clause ::= */
153557 282, /* (371) foreach_clause ::= FOR EACH ROW */
153558 285, /* (372) trnm ::= nm */
153559 286, /* (373) tridxby ::= */
153560 287, /* (374) database_kw_opt ::= DATABASE */
153561 287, /* (375) database_kw_opt ::= */
153562 290, /* (376) kwcolumn_opt ::= */
153563 290, /* (377) kwcolumn_opt ::= COLUMNKW */
153564 292, /* (378) vtabarglist ::= vtabarg */
153565 292, /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */
153566 293, /* (380) vtabarg ::= vtabarg vtabargtoken */
153567 296, /* (381) anylist ::= */
153568 296, /* (382) anylist ::= anylist LP anylist RP */
153569 296, /* (383) anylist ::= anylist ANY */
153570 261, /* (384) with ::= */
153571 };
153572
153573 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
153574 ** of symbols on the right-hand side of that rule. */
153575 static const signed char yyRuleInfoNRhs[] = {
@@ -152487,348 +153614,352 @@
153614 -2, /* (38) ccons ::= UNIQUE onconf */
153615 -4, /* (39) ccons ::= CHECK LP expr RP */
153616 -4, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
153617 -1, /* (41) ccons ::= defer_subclause */
153618 -2, /* (42) ccons ::= COLLATE ID|STRING */
153619 -3, /* (43) generated ::= LP expr RP */
153620 -4, /* (44) generated ::= LP expr RP ID */
153621 0, /* (45) autoinc ::= */
153622 -1, /* (46) autoinc ::= AUTOINCR */
153623 0, /* (47) refargs ::= */
153624 -2, /* (48) refargs ::= refargs refarg */
153625 -2, /* (49) refarg ::= MATCH nm */
153626 -3, /* (50) refarg ::= ON INSERT refact */
153627 -3, /* (51) refarg ::= ON DELETE refact */
153628 -3, /* (52) refarg ::= ON UPDATE refact */
153629 -2, /* (53) refact ::= SET NULL */
153630 -2, /* (54) refact ::= SET DEFAULT */
153631 -1, /* (55) refact ::= CASCADE */
153632 -1, /* (56) refact ::= RESTRICT */
153633 -2, /* (57) refact ::= NO ACTION */
153634 -3, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
153635 -2, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
153636 0, /* (60) init_deferred_pred_opt ::= */
153637 -2, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */
153638 -2, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
153639 0, /* (63) conslist_opt ::= */
153640 -1, /* (64) tconscomma ::= COMMA */
153641 -2, /* (65) tcons ::= CONSTRAINT nm */
153642 -7, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
153643 -5, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */
153644 -5, /* (68) tcons ::= CHECK LP expr RP onconf */
153645 -10, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
153646 0, /* (70) defer_subclause_opt ::= */
153647 0, /* (71) onconf ::= */
153648 -3, /* (72) onconf ::= ON CONFLICT resolvetype */
153649 0, /* (73) orconf ::= */
153650 -2, /* (74) orconf ::= OR resolvetype */
153651 -1, /* (75) resolvetype ::= IGNORE */
153652 -1, /* (76) resolvetype ::= REPLACE */
153653 -4, /* (77) cmd ::= DROP TABLE ifexists fullname */
153654 -2, /* (78) ifexists ::= IF EXISTS */
153655 0, /* (79) ifexists ::= */
153656 -9, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
153657 -4, /* (81) cmd ::= DROP VIEW ifexists fullname */
153658 -1, /* (82) cmd ::= select */
153659 -3, /* (83) select ::= WITH wqlist selectnowith */
153660 -4, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */
153661 -1, /* (85) select ::= selectnowith */
153662 -3, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */
153663 -1, /* (87) multiselect_op ::= UNION */
153664 -2, /* (88) multiselect_op ::= UNION ALL */
153665 -1, /* (89) multiselect_op ::= EXCEPT|INTERSECT */
153666 -9, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
153667 -10, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
153668 -4, /* (92) values ::= VALUES LP nexprlist RP */
153669 -5, /* (93) values ::= values COMMA LP nexprlist RP */
153670 -1, /* (94) distinct ::= DISTINCT */
153671 -1, /* (95) distinct ::= ALL */
153672 0, /* (96) distinct ::= */
153673 0, /* (97) sclp ::= */
153674 -5, /* (98) selcollist ::= sclp scanpt expr scanpt as */
153675 -3, /* (99) selcollist ::= sclp scanpt STAR */
153676 -5, /* (100) selcollist ::= sclp scanpt nm DOT STAR */
153677 -2, /* (101) as ::= AS nm */
153678 0, /* (102) as ::= */
153679 0, /* (103) from ::= */
153680 -2, /* (104) from ::= FROM seltablist */
153681 -2, /* (105) stl_prefix ::= seltablist joinop */
153682 0, /* (106) stl_prefix ::= */
153683 -7, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
153684 -9, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
153685 -7, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
153686 -7, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
153687 0, /* (111) dbnm ::= */
153688 -2, /* (112) dbnm ::= DOT nm */
153689 -1, /* (113) fullname ::= nm */
153690 -3, /* (114) fullname ::= nm DOT nm */
153691 -1, /* (115) xfullname ::= nm */
153692 -3, /* (116) xfullname ::= nm DOT nm */
153693 -5, /* (117) xfullname ::= nm DOT nm AS nm */
153694 -3, /* (118) xfullname ::= nm AS nm */
153695 -1, /* (119) joinop ::= COMMA|JOIN */
153696 -2, /* (120) joinop ::= JOIN_KW JOIN */
153697 -3, /* (121) joinop ::= JOIN_KW nm JOIN */
153698 -4, /* (122) joinop ::= JOIN_KW nm nm JOIN */
153699 -2, /* (123) on_opt ::= ON expr */
153700 0, /* (124) on_opt ::= */
153701 0, /* (125) indexed_opt ::= */
153702 -3, /* (126) indexed_opt ::= INDEXED BY nm */
153703 -2, /* (127) indexed_opt ::= NOT INDEXED */
153704 -4, /* (128) using_opt ::= USING LP idlist RP */
153705 0, /* (129) using_opt ::= */
153706 0, /* (130) orderby_opt ::= */
153707 -3, /* (131) orderby_opt ::= ORDER BY sortlist */
153708 -5, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */
153709 -3, /* (133) sortlist ::= expr sortorder nulls */
153710 -1, /* (134) sortorder ::= ASC */
153711 -1, /* (135) sortorder ::= DESC */
153712 0, /* (136) sortorder ::= */
153713 -2, /* (137) nulls ::= NULLS FIRST */
153714 -2, /* (138) nulls ::= NULLS LAST */
153715 0, /* (139) nulls ::= */
153716 0, /* (140) groupby_opt ::= */
153717 -3, /* (141) groupby_opt ::= GROUP BY nexprlist */
153718 0, /* (142) having_opt ::= */
153719 -2, /* (143) having_opt ::= HAVING expr */
153720 0, /* (144) limit_opt ::= */
153721 -2, /* (145) limit_opt ::= LIMIT expr */
153722 -4, /* (146) limit_opt ::= LIMIT expr OFFSET expr */
153723 -4, /* (147) limit_opt ::= LIMIT expr COMMA expr */
153724 -6, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
153725 0, /* (149) where_opt ::= */
153726 -2, /* (150) where_opt ::= WHERE expr */
153727 -8, /* (151) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
153728 -5, /* (152) setlist ::= setlist COMMA nm EQ expr */
153729 -7, /* (153) setlist ::= setlist COMMA LP idlist RP EQ expr */
153730 -3, /* (154) setlist ::= nm EQ expr */
153731 -5, /* (155) setlist ::= LP idlist RP EQ expr */
153732 -7, /* (156) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
153733 -7, /* (157) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
153734 0, /* (158) upsert ::= */
153735 -11, /* (159) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
153736 -8, /* (160) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
153737 -4, /* (161) upsert ::= ON CONFLICT DO NOTHING */
153738 -2, /* (162) insert_cmd ::= INSERT orconf */
153739 -1, /* (163) insert_cmd ::= REPLACE */
153740 0, /* (164) idlist_opt ::= */
153741 -3, /* (165) idlist_opt ::= LP idlist RP */
153742 -3, /* (166) idlist ::= idlist COMMA nm */
153743 -1, /* (167) idlist ::= nm */
153744 -3, /* (168) expr ::= LP expr RP */
153745 -1, /* (169) expr ::= ID|INDEXED */
153746 -1, /* (170) expr ::= JOIN_KW */
153747 -3, /* (171) expr ::= nm DOT nm */
153748 -5, /* (172) expr ::= nm DOT nm DOT nm */
153749 -1, /* (173) term ::= NULL|FLOAT|BLOB */
153750 -1, /* (174) term ::= STRING */
153751 -1, /* (175) term ::= INTEGER */
153752 -1, /* (176) expr ::= VARIABLE */
153753 -3, /* (177) expr ::= expr COLLATE ID|STRING */
153754 -6, /* (178) expr ::= CAST LP expr AS typetoken RP */
153755 -5, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP */
153756 -4, /* (180) expr ::= ID|INDEXED LP STAR RP */
153757 -6, /* (181) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
153758 -5, /* (182) expr ::= ID|INDEXED LP STAR RP filter_over */
153759 -1, /* (183) term ::= CTIME_KW */
153760 -5, /* (184) expr ::= LP nexprlist COMMA expr RP */
153761 -3, /* (185) expr ::= expr AND expr */
153762 -3, /* (186) expr ::= expr OR expr */
153763 -3, /* (187) expr ::= expr LT|GT|GE|LE expr */
153764 -3, /* (188) expr ::= expr EQ|NE expr */
153765 -3, /* (189) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
153766 -3, /* (190) expr ::= expr PLUS|MINUS expr */
153767 -3, /* (191) expr ::= expr STAR|SLASH|REM expr */
153768 -3, /* (192) expr ::= expr CONCAT expr */
153769 -2, /* (193) likeop ::= NOT LIKE_KW|MATCH */
153770 -3, /* (194) expr ::= expr likeop expr */
153771 -5, /* (195) expr ::= expr likeop expr ESCAPE expr */
153772 -2, /* (196) expr ::= expr ISNULL|NOTNULL */
153773 -3, /* (197) expr ::= expr NOT NULL */
153774 -3, /* (198) expr ::= expr IS expr */
153775 -4, /* (199) expr ::= expr IS NOT expr */
153776 -2, /* (200) expr ::= NOT expr */
153777 -2, /* (201) expr ::= BITNOT expr */
153778 -2, /* (202) expr ::= PLUS|MINUS expr */
153779 -1, /* (203) between_op ::= BETWEEN */
153780 -2, /* (204) between_op ::= NOT BETWEEN */
153781 -5, /* (205) expr ::= expr between_op expr AND expr */
153782 -1, /* (206) in_op ::= IN */
153783 -2, /* (207) in_op ::= NOT IN */
153784 -5, /* (208) expr ::= expr in_op LP exprlist RP */
153785 -3, /* (209) expr ::= LP select RP */
153786 -5, /* (210) expr ::= expr in_op LP select RP */
153787 -5, /* (211) expr ::= expr in_op nm dbnm paren_exprlist */
153788 -4, /* (212) expr ::= EXISTS LP select RP */
153789 -5, /* (213) expr ::= CASE case_operand case_exprlist case_else END */
153790 -5, /* (214) case_exprlist ::= case_exprlist WHEN expr THEN expr */
153791 -4, /* (215) case_exprlist ::= WHEN expr THEN expr */
153792 -2, /* (216) case_else ::= ELSE expr */
153793 0, /* (217) case_else ::= */
153794 -1, /* (218) case_operand ::= expr */
153795 0, /* (219) case_operand ::= */
153796 0, /* (220) exprlist ::= */
153797 -3, /* (221) nexprlist ::= nexprlist COMMA expr */
153798 -1, /* (222) nexprlist ::= expr */
153799 0, /* (223) paren_exprlist ::= */
153800 -3, /* (224) paren_exprlist ::= LP exprlist RP */
153801 -12, /* (225) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
153802 -1, /* (226) uniqueflag ::= UNIQUE */
153803 0, /* (227) uniqueflag ::= */
153804 0, /* (228) eidlist_opt ::= */
153805 -3, /* (229) eidlist_opt ::= LP eidlist RP */
153806 -5, /* (230) eidlist ::= eidlist COMMA nm collate sortorder */
153807 -3, /* (231) eidlist ::= nm collate sortorder */
153808 0, /* (232) collate ::= */
153809 -2, /* (233) collate ::= COLLATE ID|STRING */
153810 -4, /* (234) cmd ::= DROP INDEX ifexists fullname */
153811 -2, /* (235) cmd ::= VACUUM vinto */
153812 -3, /* (236) cmd ::= VACUUM nm vinto */
153813 -2, /* (237) vinto ::= INTO expr */
153814 0, /* (238) vinto ::= */
153815 -3, /* (239) cmd ::= PRAGMA nm dbnm */
153816 -5, /* (240) cmd ::= PRAGMA nm dbnm EQ nmnum */
153817 -6, /* (241) cmd ::= PRAGMA nm dbnm LP nmnum RP */
153818 -5, /* (242) cmd ::= PRAGMA nm dbnm EQ minus_num */
153819 -6, /* (243) cmd ::= PRAGMA nm dbnm LP minus_num RP */
153820 -2, /* (244) plus_num ::= PLUS INTEGER|FLOAT */
153821 -2, /* (245) minus_num ::= MINUS INTEGER|FLOAT */
153822 -5, /* (246) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
153823 -11, /* (247) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
153824 -1, /* (248) trigger_time ::= BEFORE|AFTER */
153825 -2, /* (249) trigger_time ::= INSTEAD OF */
153826 0, /* (250) trigger_time ::= */
153827 -1, /* (251) trigger_event ::= DELETE|INSERT */
153828 -1, /* (252) trigger_event ::= UPDATE */
153829 -3, /* (253) trigger_event ::= UPDATE OF idlist */
153830 0, /* (254) when_clause ::= */
153831 -2, /* (255) when_clause ::= WHEN expr */
153832 -3, /* (256) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
153833 -2, /* (257) trigger_cmd_list ::= trigger_cmd SEMI */
153834 -3, /* (258) trnm ::= nm DOT nm */
153835 -3, /* (259) tridxby ::= INDEXED BY nm */
153836 -2, /* (260) tridxby ::= NOT INDEXED */
153837 -8, /* (261) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
153838 -8, /* (262) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
153839 -6, /* (263) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
153840 -3, /* (264) trigger_cmd ::= scanpt select scanpt */
153841 -4, /* (265) expr ::= RAISE LP IGNORE RP */
153842 -6, /* (266) expr ::= RAISE LP raisetype COMMA nm RP */
153843 -1, /* (267) raisetype ::= ROLLBACK */
153844 -1, /* (268) raisetype ::= ABORT */
153845 -1, /* (269) raisetype ::= FAIL */
153846 -4, /* (270) cmd ::= DROP TRIGGER ifexists fullname */
153847 -6, /* (271) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
153848 -3, /* (272) cmd ::= DETACH database_kw_opt expr */
153849 0, /* (273) key_opt ::= */
153850 -2, /* (274) key_opt ::= KEY expr */
153851 -1, /* (275) cmd ::= REINDEX */
153852 -3, /* (276) cmd ::= REINDEX nm dbnm */
153853 -1, /* (277) cmd ::= ANALYZE */
153854 -3, /* (278) cmd ::= ANALYZE nm dbnm */
153855 -6, /* (279) cmd ::= ALTER TABLE fullname RENAME TO nm */
153856 -7, /* (280) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
153857 -1, /* (281) add_column_fullname ::= fullname */
153858 -8, /* (282) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
153859 -1, /* (283) cmd ::= create_vtab */
153860 -4, /* (284) cmd ::= create_vtab LP vtabarglist RP */
153861 -8, /* (285) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
153862 0, /* (286) vtabarg ::= */
153863 -1, /* (287) vtabargtoken ::= ANY */
153864 -3, /* (288) vtabargtoken ::= lp anylist RP */
153865 -1, /* (289) lp ::= LP */
153866 -2, /* (290) with ::= WITH wqlist */
153867 -3, /* (291) with ::= WITH RECURSIVE wqlist */
153868 -6, /* (292) wqlist ::= nm eidlist_opt AS LP select RP */
153869 -8, /* (293) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
153870 -1, /* (294) windowdefn_list ::= windowdefn */
153871 -3, /* (295) windowdefn_list ::= windowdefn_list COMMA windowdefn */
153872 -5, /* (296) windowdefn ::= nm AS LP window RP */
153873 -5, /* (297) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
153874 -6, /* (298) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
153875 -4, /* (299) window ::= ORDER BY sortlist frame_opt */
153876 -5, /* (300) window ::= nm ORDER BY sortlist frame_opt */
153877 -1, /* (301) window ::= frame_opt */
153878 -2, /* (302) window ::= nm frame_opt */
153879 0, /* (303) frame_opt ::= */
153880 -3, /* (304) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
153881 -6, /* (305) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
153882 -1, /* (306) range_or_rows ::= RANGE|ROWS|GROUPS */
153883 -1, /* (307) frame_bound_s ::= frame_bound */
153884 -2, /* (308) frame_bound_s ::= UNBOUNDED PRECEDING */
153885 -1, /* (309) frame_bound_e ::= frame_bound */
153886 -2, /* (310) frame_bound_e ::= UNBOUNDED FOLLOWING */
153887 -2, /* (311) frame_bound ::= expr PRECEDING|FOLLOWING */
153888 -2, /* (312) frame_bound ::= CURRENT ROW */
153889 0, /* (313) frame_exclude_opt ::= */
153890 -2, /* (314) frame_exclude_opt ::= EXCLUDE frame_exclude */
153891 -2, /* (315) frame_exclude ::= NO OTHERS */
153892 -2, /* (316) frame_exclude ::= CURRENT ROW */
153893 -1, /* (317) frame_exclude ::= GROUP|TIES */
153894 -2, /* (318) window_clause ::= WINDOW windowdefn_list */
153895 -2, /* (319) filter_over ::= filter_clause over_clause */
153896 -1, /* (320) filter_over ::= over_clause */
153897 -1, /* (321) filter_over ::= filter_clause */
153898 -4, /* (322) over_clause ::= OVER LP window RP */
153899 -2, /* (323) over_clause ::= OVER nm */
153900 -5, /* (324) filter_clause ::= FILTER LP WHERE expr RP */
153901 -1, /* (325) input ::= cmdlist */
153902 -2, /* (326) cmdlist ::= cmdlist ecmd */
153903 -1, /* (327) cmdlist ::= ecmd */
153904 -1, /* (328) ecmd ::= SEMI */
153905 -2, /* (329) ecmd ::= cmdx SEMI */
153906 -2, /* (330) ecmd ::= explain cmdx */
153907 0, /* (331) trans_opt ::= */
153908 -1, /* (332) trans_opt ::= TRANSACTION */
153909 -2, /* (333) trans_opt ::= TRANSACTION nm */
153910 -1, /* (334) savepoint_opt ::= SAVEPOINT */
153911 0, /* (335) savepoint_opt ::= */
153912 -2, /* (336) cmd ::= create_table create_table_args */
153913 -4, /* (337) columnlist ::= columnlist COMMA columnname carglist */
153914 -2, /* (338) columnlist ::= columnname carglist */
153915 -1, /* (339) nm ::= ID|INDEXED */
153916 -1, /* (340) nm ::= STRING */
153917 -1, /* (341) nm ::= JOIN_KW */
153918 -1, /* (342) typetoken ::= typename */
153919 -1, /* (343) typename ::= ID|STRING */
153920 -1, /* (344) signed ::= plus_num */
153921 -1, /* (345) signed ::= minus_num */
153922 -2, /* (346) carglist ::= carglist ccons */
153923 0, /* (347) carglist ::= */
153924 -2, /* (348) ccons ::= NULL onconf */
153925 -4, /* (349) ccons ::= GENERATED ALWAYS AS generated */
153926 -2, /* (350) ccons ::= AS generated */
153927 -2, /* (351) conslist_opt ::= COMMA conslist */
153928 -3, /* (352) conslist ::= conslist tconscomma tcons */
153929 -1, /* (353) conslist ::= tcons */
153930 0, /* (354) tconscomma ::= */
153931 -1, /* (355) defer_subclause_opt ::= defer_subclause */
153932 -1, /* (356) resolvetype ::= raisetype */
153933 -1, /* (357) selectnowith ::= oneselect */
153934 -1, /* (358) oneselect ::= values */
153935 -2, /* (359) sclp ::= selcollist COMMA */
153936 -1, /* (360) as ::= ID|STRING */
153937 -1, /* (361) expr ::= term */
153938 -1, /* (362) likeop ::= LIKE_KW|MATCH */
153939 -1, /* (363) exprlist ::= nexprlist */
153940 -1, /* (364) nmnum ::= plus_num */
153941 -1, /* (365) nmnum ::= nm */
153942 -1, /* (366) nmnum ::= ON */
153943 -1, /* (367) nmnum ::= DELETE */
153944 -1, /* (368) nmnum ::= DEFAULT */
153945 -1, /* (369) plus_num ::= INTEGER|FLOAT */
153946 0, /* (370) foreach_clause ::= */
153947 -3, /* (371) foreach_clause ::= FOR EACH ROW */
153948 -1, /* (372) trnm ::= nm */
153949 0, /* (373) tridxby ::= */
153950 -1, /* (374) database_kw_opt ::= DATABASE */
153951 0, /* (375) database_kw_opt ::= */
153952 0, /* (376) kwcolumn_opt ::= */
153953 -1, /* (377) kwcolumn_opt ::= COLUMNKW */
153954 -1, /* (378) vtabarglist ::= vtabarg */
153955 -3, /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */
153956 -2, /* (380) vtabarg ::= vtabarg vtabargtoken */
153957 0, /* (381) anylist ::= */
153958 -4, /* (382) anylist ::= anylist LP anylist RP */
153959 -2, /* (383) anylist ::= anylist ANY */
153960 0, /* (384) with ::= */
153961 };
153962
153963 static void yy_accept(yyParser*); /* Forward Declaration */
153964
153965 /*
@@ -152921,20 +154052,20 @@
154052 break;
154053 case 2: /* cmdx ::= cmd */
154054 { sqlite3FinishCoding(pParse); }
154055 break;
154056 case 3: /* cmd ::= BEGIN transtype trans_opt */
154057 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy192);}
154058 break;
154059 case 4: /* transtype ::= */
154060 {yymsp[1].minor.yy192 = TK_DEFERRED;}
154061 break;
154062 case 5: /* transtype ::= DEFERRED */
154063 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
154064 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
154065 case 306: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==306);
154066 {yymsp[0].minor.yy192 = yymsp[0].major; /*A-overwrites-X*/}
154067 break;
154068 case 8: /* cmd ::= COMMIT|END trans_opt */
154069 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
154070 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
154071 break;
@@ -152953,61 +154084,61 @@
154084 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
154085 }
154086 break;
154087 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
154088 {
154089 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy192,0,0,yymsp[-2].minor.yy192);
154090 }
154091 break;
154092 case 14: /* createkw ::= CREATE */
154093 {disableLookaside(pParse);}
154094 break;
154095 case 15: /* ifnotexists ::= */
154096 case 18: /* temp ::= */ yytestcase(yyruleno==18);
154097 case 21: /* table_options ::= */ yytestcase(yyruleno==21);
154098 case 45: /* autoinc ::= */ yytestcase(yyruleno==45);
154099 case 60: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==60);
154100 case 70: /* defer_subclause_opt ::= */ yytestcase(yyruleno==70);
154101 case 79: /* ifexists ::= */ yytestcase(yyruleno==79);
154102 case 96: /* distinct ::= */ yytestcase(yyruleno==96);
154103 case 232: /* collate ::= */ yytestcase(yyruleno==232);
154104 {yymsp[1].minor.yy192 = 0;}
154105 break;
154106 case 16: /* ifnotexists ::= IF NOT EXISTS */
154107 {yymsp[-2].minor.yy192 = 1;}
154108 break;
154109 case 17: /* temp ::= TEMP */
154110 case 46: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==46);
154111 {yymsp[0].minor.yy192 = 1;}
154112 break;
154113 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
154114 {
154115 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy192,0);
154116 }
154117 break;
154118 case 20: /* create_table_args ::= AS select */
154119 {
154120 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy539);
154121 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy539);
154122 }
154123 break;
154124 case 22: /* table_options ::= WITHOUT nm */
154125 {
154126 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
154127 yymsp[-1].minor.yy192 = TF_WithoutRowid | TF_NoVisibleRowid;
154128 }else{
154129 yymsp[-1].minor.yy192 = 0;
154130 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
154131 }
154132 }
154133 break;
154134 case 23: /* columnname ::= nm typetoken */
154135 {sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
154136 break;
154137 case 24: /* typetoken ::= */
154138 case 63: /* conslist_opt ::= */ yytestcase(yyruleno==63);
154139 case 102: /* as ::= */ yytestcase(yyruleno==102);
154140 {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
154141 break;
154142 case 25: /* typetoken ::= typename LP signed RP */
154143 {
154144 yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
@@ -153022,35 +154153,35 @@
154153 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
154154 break;
154155 case 28: /* scanpt ::= */
154156 {
154157 assert( yyLookahead!=YYNOCODE );
154158 yymsp[1].minor.yy436 = yyLookaheadToken.z;
154159 }
154160 break;
154161 case 29: /* scantok ::= */
154162 {
154163 assert( yyLookahead!=YYNOCODE );
154164 yymsp[1].minor.yy0 = yyLookaheadToken;
154165 }
154166 break;
154167 case 30: /* ccons ::= CONSTRAINT nm */
154168 case 65: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==65);
154169 {pParse->constraintName = yymsp[0].minor.yy0;}
154170 break;
154171 case 31: /* ccons ::= DEFAULT scantok term */
154172 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy202,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
154173 break;
154174 case 32: /* ccons ::= DEFAULT LP expr RP */
154175 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy202,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
154176 break;
154177 case 33: /* ccons ::= DEFAULT PLUS scantok term */
154178 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy202,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
154179 break;
154180 case 34: /* ccons ::= DEFAULT MINUS scantok term */
154181 {
154182 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy202, 0);
154183 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
154184 }
154185 break;
154186 case 35: /* ccons ::= DEFAULT scantok ID|INDEXED */
154187 {
@@ -153061,319 +154192,325 @@
154192 }
154193 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
154194 }
154195 break;
154196 case 36: /* ccons ::= NOT NULL onconf */
154197 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy192);}
154198 break;
154199 case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
154200 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy192,yymsp[0].minor.yy192,yymsp[-2].minor.yy192);}
154201 break;
154202 case 38: /* ccons ::= UNIQUE onconf */
154203 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy192,0,0,0,0,
154204 SQLITE_IDXTYPE_UNIQUE);}
154205 break;
154206 case 39: /* ccons ::= CHECK LP expr RP */
154207 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy202);}
154208 break;
154209 case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */
154210 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy242,yymsp[0].minor.yy192);}
154211 break;
154212 case 41: /* ccons ::= defer_subclause */
154213 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy192);}
154214 break;
154215 case 42: /* ccons ::= COLLATE ID|STRING */
154216 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
154217 break;
154218 case 43: /* generated ::= LP expr RP */
154219 {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy202,0);}
154220 break;
154221 case 44: /* generated ::= LP expr RP ID */
154222 {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy202,&yymsp[0].minor.yy0);}
154223 break;
154224 case 47: /* refargs ::= */
154225 { yymsp[1].minor.yy192 = OE_None*0x0101; /* EV: R-19803-45884 */}
154226 break;
154227 case 48: /* refargs ::= refargs refarg */
154228 { yymsp[-1].minor.yy192 = (yymsp[-1].minor.yy192 & ~yymsp[0].minor.yy207.mask) | yymsp[0].minor.yy207.value; }
154229 break;
154230 case 49: /* refarg ::= MATCH nm */
154231 { yymsp[-1].minor.yy207.value = 0; yymsp[-1].minor.yy207.mask = 0x000000; }
154232 break;
154233 case 50: /* refarg ::= ON INSERT refact */
154234 { yymsp[-2].minor.yy207.value = 0; yymsp[-2].minor.yy207.mask = 0x000000; }
154235 break;
154236 case 51: /* refarg ::= ON DELETE refact */
154237 { yymsp[-2].minor.yy207.value = yymsp[0].minor.yy192; yymsp[-2].minor.yy207.mask = 0x0000ff; }
154238 break;
154239 case 52: /* refarg ::= ON UPDATE refact */
154240 { yymsp[-2].minor.yy207.value = yymsp[0].minor.yy192<<8; yymsp[-2].minor.yy207.mask = 0x00ff00; }
154241 break;
154242 case 53: /* refact ::= SET NULL */
154243 { yymsp[-1].minor.yy192 = OE_SetNull; /* EV: R-33326-45252 */}
154244 break;
154245 case 54: /* refact ::= SET DEFAULT */
154246 { yymsp[-1].minor.yy192 = OE_SetDflt; /* EV: R-33326-45252 */}
154247 break;
154248 case 55: /* refact ::= CASCADE */
154249 { yymsp[0].minor.yy192 = OE_Cascade; /* EV: R-33326-45252 */}
154250 break;
154251 case 56: /* refact ::= RESTRICT */
154252 { yymsp[0].minor.yy192 = OE_Restrict; /* EV: R-33326-45252 */}
154253 break;
154254 case 57: /* refact ::= NO ACTION */
154255 { yymsp[-1].minor.yy192 = OE_None; /* EV: R-33326-45252 */}
154256 break;
154257 case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
154258 {yymsp[-2].minor.yy192 = 0;}
154259 break;
154260 case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
154261 case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74);
154262 case 162: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==162);
154263 {yymsp[-1].minor.yy192 = yymsp[0].minor.yy192;}
154264 break;
154265 case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
154266 case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78);
154267 case 204: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==204);
154268 case 207: /* in_op ::= NOT IN */ yytestcase(yyruleno==207);
154269 case 233: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==233);
154270 {yymsp[-1].minor.yy192 = 1;}
154271 break;
154272 case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
154273 {yymsp[-1].minor.yy192 = 0;}
154274 break;
154275 case 64: /* tconscomma ::= COMMA */
154276 {pParse->constraintName.n = 0;}
154277 break;
154278 case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
154279 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy242,yymsp[0].minor.yy192,yymsp[-2].minor.yy192,0);}
154280 break;
154281 case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */
154282 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy242,yymsp[0].minor.yy192,0,0,0,0,
154283 SQLITE_IDXTYPE_UNIQUE);}
154284 break;
154285 case 68: /* tcons ::= CHECK LP expr RP onconf */
154286 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy202);}
154287 break;
154288 case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
154289 {
154290 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy242, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy242, yymsp[-1].minor.yy192);
154291 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy192);
154292 }
154293 break;
154294 case 71: /* onconf ::= */
154295 case 73: /* orconf ::= */ yytestcase(yyruleno==73);
154296 {yymsp[1].minor.yy192 = OE_Default;}
154297 break;
154298 case 72: /* onconf ::= ON CONFLICT resolvetype */
154299 {yymsp[-2].minor.yy192 = yymsp[0].minor.yy192;}
154300 break;
154301 case 75: /* resolvetype ::= IGNORE */
154302 {yymsp[0].minor.yy192 = OE_Ignore;}
154303 break;
154304 case 76: /* resolvetype ::= REPLACE */
154305 case 163: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==163);
154306 {yymsp[0].minor.yy192 = OE_Replace;}
154307 break;
154308 case 77: /* cmd ::= DROP TABLE ifexists fullname */
154309 {
154310 sqlite3DropTable(pParse, yymsp[0].minor.yy47, 0, yymsp[-1].minor.yy192);
154311 }
154312 break;
154313 case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
154314 {
154315 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy242, yymsp[0].minor.yy539, yymsp[-7].minor.yy192, yymsp[-5].minor.yy192);
154316 }
154317 break;
154318 case 81: /* cmd ::= DROP VIEW ifexists fullname */
154319 {
154320 sqlite3DropTable(pParse, yymsp[0].minor.yy47, 1, yymsp[-1].minor.yy192);
154321 }
154322 break;
154323 case 82: /* cmd ::= select */
154324 {
154325 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
154326 sqlite3Select(pParse, yymsp[0].minor.yy539, &dest);
154327 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy539);
154328 }
154329 break;
154330 case 83: /* select ::= WITH wqlist selectnowith */
154331 {
154332 Select *p = yymsp[0].minor.yy539;
154333 if( p ){
154334 p->pWith = yymsp[-1].minor.yy131;
154335 parserDoubleLinkSelect(pParse, p);
154336 }else{
154337 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy131);
154338 }
154339 yymsp[-2].minor.yy539 = p;
154340 }
154341 break;
154342 case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */
154343 {
154344 Select *p = yymsp[0].minor.yy539;
154345 if( p ){
154346 p->pWith = yymsp[-1].minor.yy131;
154347 parserDoubleLinkSelect(pParse, p);
154348 }else{
154349 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy131);
154350 }
154351 yymsp[-3].minor.yy539 = p;
154352 }
154353 break;
154354 case 85: /* select ::= selectnowith */
154355 {
154356 Select *p = yymsp[0].minor.yy539;
154357 if( p ){
154358 parserDoubleLinkSelect(pParse, p);
154359 }
154360 yymsp[0].minor.yy539 = p; /*A-overwrites-X*/
154361 }
154362 break;
154363 case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */
154364 {
154365 Select *pRhs = yymsp[0].minor.yy539;
154366 Select *pLhs = yymsp[-2].minor.yy539;
154367 if( pRhs && pRhs->pPrior ){
154368 SrcList *pFrom;
154369 Token x;
154370 x.n = 0;
154371 parserDoubleLinkSelect(pParse, pRhs);
154372 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
154373 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
154374 }
154375 if( pRhs ){
154376 pRhs->op = (u8)yymsp[-1].minor.yy192;
154377 pRhs->pPrior = pLhs;
154378 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
154379 pRhs->selFlags &= ~SF_MultiValue;
154380 if( yymsp[-1].minor.yy192!=TK_ALL ) pParse->hasCompound = 1;
154381 }else{
154382 sqlite3SelectDelete(pParse->db, pLhs);
154383 }
154384 yymsp[-2].minor.yy539 = pRhs;
154385 }
154386 break;
154387 case 87: /* multiselect_op ::= UNION */
154388 case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89);
154389 {yymsp[0].minor.yy192 = yymsp[0].major; /*A-overwrites-OP*/}
154390 break;
154391 case 88: /* multiselect_op ::= UNION ALL */
154392 {yymsp[-1].minor.yy192 = TK_ALL;}
154393 break;
154394 case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
154395 {
154396 yymsp[-8].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy242,yymsp[-5].minor.yy47,yymsp[-4].minor.yy202,yymsp[-3].minor.yy242,yymsp[-2].minor.yy202,yymsp[-1].minor.yy242,yymsp[-7].minor.yy192,yymsp[0].minor.yy202);
154397 }
154398 break;
154399 case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
154400 {
154401 yymsp[-9].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy242,yymsp[-6].minor.yy47,yymsp[-5].minor.yy202,yymsp[-4].minor.yy242,yymsp[-3].minor.yy202,yymsp[-1].minor.yy242,yymsp[-8].minor.yy192,yymsp[0].minor.yy202);
154402 if( yymsp[-9].minor.yy539 ){
154403 yymsp[-9].minor.yy539->pWinDefn = yymsp[-2].minor.yy303;
154404 }else{
154405 sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy303);
154406 }
154407 }
154408 break;
154409 case 92: /* values ::= VALUES LP nexprlist RP */
154410 {
154411 yymsp[-3].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy242,0,0,0,0,0,SF_Values,0);
154412 }
154413 break;
154414 case 93: /* values ::= values COMMA LP nexprlist RP */
154415 {
154416 Select *pRight, *pLeft = yymsp[-4].minor.yy539;
154417 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy242,0,0,0,0,0,SF_Values|SF_MultiValue,0);
154418 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
154419 if( pRight ){
154420 pRight->op = TK_ALL;
154421 pRight->pPrior = pLeft;
154422 yymsp[-4].minor.yy539 = pRight;
154423 }else{
154424 yymsp[-4].minor.yy539 = pLeft;
154425 }
154426 }
154427 break;
154428 case 94: /* distinct ::= DISTINCT */
154429 {yymsp[0].minor.yy192 = SF_Distinct;}
154430 break;
154431 case 95: /* distinct ::= ALL */
154432 {yymsp[0].minor.yy192 = SF_All;}
154433 break;
154434 case 97: /* sclp ::= */
154435 case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130);
154436 case 140: /* groupby_opt ::= */ yytestcase(yyruleno==140);
154437 case 220: /* exprlist ::= */ yytestcase(yyruleno==220);
154438 case 223: /* paren_exprlist ::= */ yytestcase(yyruleno==223);
154439 case 228: /* eidlist_opt ::= */ yytestcase(yyruleno==228);
154440 {yymsp[1].minor.yy242 = 0;}
154441 break;
154442 case 98: /* selcollist ::= sclp scanpt expr scanpt as */
154443 {
154444 yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy242, yymsp[-2].minor.yy202);
154445 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy242, &yymsp[0].minor.yy0, 1);
154446 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy242,yymsp[-3].minor.yy436,yymsp[-1].minor.yy436);
154447 }
154448 break;
154449 case 99: /* selcollist ::= sclp scanpt STAR */
154450 {
154451 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
154452 yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy242, p);
154453 }
154454 break;
154455 case 100: /* selcollist ::= sclp scanpt nm DOT STAR */
154456 {
154457 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
154458 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
154459 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
154460 yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, pDot);
154461 }
154462 break;
154463 case 101: /* as ::= AS nm */
154464 case 112: /* dbnm ::= DOT nm */ yytestcase(yyruleno==112);
154465 case 244: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==244);
154466 case 245: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==245);
154467 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
154468 break;
154469 case 103: /* from ::= */
154470 {yymsp[1].minor.yy47 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy47));}
154471 break;
154472 case 104: /* from ::= FROM seltablist */
154473 {
154474 yymsp[-1].minor.yy47 = yymsp[0].minor.yy47;
154475 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy47);
154476 }
154477 break;
154478 case 105: /* stl_prefix ::= seltablist joinop */
154479 {
154480 if( ALWAYS(yymsp[-1].minor.yy47 && yymsp[-1].minor.yy47->nSrc>0) ) yymsp[-1].minor.yy47->a[yymsp[-1].minor.yy47->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy192;
154481 }
154482 break;
154483 case 106: /* stl_prefix ::= */
154484 {yymsp[1].minor.yy47 = 0;}
154485 break;
154486 case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
154487 {
154488 yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600);
154489 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy47, &yymsp[-2].minor.yy0);
154490 }
154491 break;
154492 case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
154493 {
154494 yymsp[-8].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy47,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600);
154495 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy47, yymsp[-4].minor.yy242);
154496 }
154497 break;
154498 case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
154499 {
154500 yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy539,yymsp[-1].minor.yy202,yymsp[0].minor.yy600);
154501 }
154502 break;
154503 case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
154504 {
154505 if( yymsp[-6].minor.yy47==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy202==0 && yymsp[0].minor.yy600==0 ){
154506 yymsp[-6].minor.yy47 = yymsp[-4].minor.yy47;
154507 }else if( yymsp[-4].minor.yy47->nSrc==1 ){
154508 yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600);
154509 if( yymsp[-6].minor.yy47 ){
154510 struct SrcList_item *pNew = &yymsp[-6].minor.yy47->a[yymsp[-6].minor.yy47->nSrc-1];
154511 struct SrcList_item *pOld = yymsp[-4].minor.yy47->a;
154512 pNew->zName = pOld->zName;
154513 pNew->zDatabase = pOld->zDatabase;
154514 pNew->pSelect = pOld->pSelect;
154515 if( pOld->fg.isTabFunc ){
154516 pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -153382,946 +154519,951 @@
154519 pNew->fg.isTabFunc = 1;
154520 }
154521 pOld->zName = pOld->zDatabase = 0;
154522 pOld->pSelect = 0;
154523 }
154524 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy47);
154525 }else{
154526 Select *pSubquery;
154527 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy47);
154528 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy47,0,0,0,0,SF_NestedFrom,0);
154529 yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy202,yymsp[0].minor.yy600);
154530 }
154531 }
154532 break;
154533 case 111: /* dbnm ::= */
154534 case 125: /* indexed_opt ::= */ yytestcase(yyruleno==125);
154535 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
154536 break;
154537 case 113: /* fullname ::= nm */
154538 {
154539 yylhsminor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
154540 if( IN_RENAME_OBJECT && yylhsminor.yy47 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy47->a[0].zName, &yymsp[0].minor.yy0);
154541 }
154542 yymsp[0].minor.yy47 = yylhsminor.yy47;
154543 break;
154544 case 114: /* fullname ::= nm DOT nm */
154545 {
154546 yylhsminor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
154547 if( IN_RENAME_OBJECT && yylhsminor.yy47 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy47->a[0].zName, &yymsp[0].minor.yy0);
154548 }
154549 yymsp[-2].minor.yy47 = yylhsminor.yy47;
154550 break;
154551 case 115: /* xfullname ::= nm */
154552 {yymsp[0].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
154553 break;
154554 case 116: /* xfullname ::= nm DOT nm */
154555 {yymsp[-2].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
154556 break;
154557 case 117: /* xfullname ::= nm DOT nm AS nm */
154558 {
154559 yymsp[-4].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
154560 if( yymsp[-4].minor.yy47 ) yymsp[-4].minor.yy47->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
154561 }
154562 break;
154563 case 118: /* xfullname ::= nm AS nm */
154564 {
154565 yymsp[-2].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
154566 if( yymsp[-2].minor.yy47 ) yymsp[-2].minor.yy47->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
154567 }
154568 break;
154569 case 119: /* joinop ::= COMMA|JOIN */
154570 { yymsp[0].minor.yy192 = JT_INNER; }
154571 break;
154572 case 120: /* joinop ::= JOIN_KW JOIN */
154573 {yymsp[-1].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
154574 break;
154575 case 121: /* joinop ::= JOIN_KW nm JOIN */
154576 {yymsp[-2].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
154577 break;
154578 case 122: /* joinop ::= JOIN_KW nm nm JOIN */
154579 {yymsp[-3].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
154580 break;
154581 case 123: /* on_opt ::= ON expr */
154582 case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143);
154583 case 150: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==150);
154584 case 216: /* case_else ::= ELSE expr */ yytestcase(yyruleno==216);
154585 case 237: /* vinto ::= INTO expr */ yytestcase(yyruleno==237);
154586 {yymsp[-1].minor.yy202 = yymsp[0].minor.yy202;}
154587 break;
154588 case 124: /* on_opt ::= */
154589 case 142: /* having_opt ::= */ yytestcase(yyruleno==142);
154590 case 144: /* limit_opt ::= */ yytestcase(yyruleno==144);
154591 case 149: /* where_opt ::= */ yytestcase(yyruleno==149);
154592 case 217: /* case_else ::= */ yytestcase(yyruleno==217);
154593 case 219: /* case_operand ::= */ yytestcase(yyruleno==219);
154594 case 238: /* vinto ::= */ yytestcase(yyruleno==238);
154595 {yymsp[1].minor.yy202 = 0;}
154596 break;
154597 case 126: /* indexed_opt ::= INDEXED BY nm */
154598 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
154599 break;
154600 case 127: /* indexed_opt ::= NOT INDEXED */
154601 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
154602 break;
154603 case 128: /* using_opt ::= USING LP idlist RP */
154604 {yymsp[-3].minor.yy600 = yymsp[-1].minor.yy600;}
154605 break;
154606 case 129: /* using_opt ::= */
154607 case 164: /* idlist_opt ::= */ yytestcase(yyruleno==164);
154608 {yymsp[1].minor.yy600 = 0;}
154609 break;
154610 case 131: /* orderby_opt ::= ORDER BY sortlist */
154611 case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141);
154612 {yymsp[-2].minor.yy242 = yymsp[0].minor.yy242;}
154613 break;
154614 case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */
154615 {
154616 yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242,yymsp[-2].minor.yy202);
154617 sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy242,yymsp[-1].minor.yy192,yymsp[0].minor.yy192);
154618 }
154619 break;
154620 case 133: /* sortlist ::= expr sortorder nulls */
154621 {
154622 yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy202); /*A-overwrites-Y*/
154623 sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy242,yymsp[-1].minor.yy192,yymsp[0].minor.yy192);
154624 }
154625 break;
154626 case 134: /* sortorder ::= ASC */
154627 {yymsp[0].minor.yy192 = SQLITE_SO_ASC;}
154628 break;
154629 case 135: /* sortorder ::= DESC */
154630 {yymsp[0].minor.yy192 = SQLITE_SO_DESC;}
154631 break;
154632 case 136: /* sortorder ::= */
154633 case 139: /* nulls ::= */ yytestcase(yyruleno==139);
154634 {yymsp[1].minor.yy192 = SQLITE_SO_UNDEFINED;}
154635 break;
154636 case 137: /* nulls ::= NULLS FIRST */
154637 {yymsp[-1].minor.yy192 = SQLITE_SO_ASC;}
154638 break;
154639 case 138: /* nulls ::= NULLS LAST */
154640 {yymsp[-1].minor.yy192 = SQLITE_SO_DESC;}
154641 break;
154642 case 145: /* limit_opt ::= LIMIT expr */
154643 {yymsp[-1].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy202,0);}
154644 break;
154645 case 146: /* limit_opt ::= LIMIT expr OFFSET expr */
154646 {yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);}
154647 break;
154648 case 147: /* limit_opt ::= LIMIT expr COMMA expr */
154649 {yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy202,yymsp[-2].minor.yy202);}
154650 break;
154651 case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
154652 {
154653 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy47, &yymsp[-1].minor.yy0);
154654 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy47,yymsp[0].minor.yy202,0,0);
154655 }
154656 break;
154657 case 151: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
154658 {
154659 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy47, &yymsp[-3].minor.yy0);
154660 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy242,"set list");
154661 sqlite3Update(pParse,yymsp[-4].minor.yy47,yymsp[-1].minor.yy242,yymsp[0].minor.yy202,yymsp[-5].minor.yy192,0,0,0);
154662 }
154663 break;
154664 case 152: /* setlist ::= setlist COMMA nm EQ expr */
154665 {
154666 yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy242, yymsp[0].minor.yy202);
154667 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy242, &yymsp[-2].minor.yy0, 1);
154668 }
154669 break;
154670 case 153: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
154671 {
154672 yymsp[-6].minor.yy242 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy242, yymsp[-3].minor.yy600, yymsp[0].minor.yy202);
154673 }
154674 break;
154675 case 154: /* setlist ::= nm EQ expr */
154676 {
154677 yylhsminor.yy242 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy202);
154678 sqlite3ExprListSetName(pParse, yylhsminor.yy242, &yymsp[-2].minor.yy0, 1);
154679 }
154680 yymsp[-2].minor.yy242 = yylhsminor.yy242;
154681 break;
154682 case 155: /* setlist ::= LP idlist RP EQ expr */
154683 {
154684 yymsp[-4].minor.yy242 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy600, yymsp[0].minor.yy202);
154685 }
154686 break;
154687 case 156: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
154688 {
154689 sqlite3Insert(pParse, yymsp[-3].minor.yy47, yymsp[-1].minor.yy539, yymsp[-2].minor.yy600, yymsp[-5].minor.yy192, yymsp[0].minor.yy318);
154690 }
154691 break;
154692 case 157: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
154693 {
154694 sqlite3Insert(pParse, yymsp[-3].minor.yy47, 0, yymsp[-2].minor.yy600, yymsp[-5].minor.yy192, 0);
154695 }
154696 break;
154697 case 158: /* upsert ::= */
154698 { yymsp[1].minor.yy318 = 0; }
154699 break;
154700 case 159: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
154701 { yymsp[-10].minor.yy318 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy242,yymsp[-5].minor.yy202,yymsp[-1].minor.yy242,yymsp[0].minor.yy202);}
154702 break;
154703 case 160: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
154704 { yymsp[-7].minor.yy318 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy242,yymsp[-2].minor.yy202,0,0); }
154705 break;
154706 case 161: /* upsert ::= ON CONFLICT DO NOTHING */
154707 { yymsp[-3].minor.yy318 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
154708 break;
154709 case 165: /* idlist_opt ::= LP idlist RP */
154710 {yymsp[-2].minor.yy600 = yymsp[-1].minor.yy600;}
154711 break;
154712 case 166: /* idlist ::= idlist COMMA nm */
154713 {yymsp[-2].minor.yy600 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy600,&yymsp[0].minor.yy0);}
154714 break;
154715 case 167: /* idlist ::= nm */
154716 {yymsp[0].minor.yy600 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
154717 break;
154718 case 168: /* expr ::= LP expr RP */
154719 {yymsp[-2].minor.yy202 = yymsp[-1].minor.yy202;}
154720 break;
154721 case 169: /* expr ::= ID|INDEXED */
154722 case 170: /* expr ::= JOIN_KW */ yytestcase(yyruleno==170);
154723 {yymsp[0].minor.yy202=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
154724 break;
154725 case 171: /* expr ::= nm DOT nm */
154726 {
154727 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
154728 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
154729 if( IN_RENAME_OBJECT ){
154730 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
154731 sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
154732 }
154733 yylhsminor.yy202 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
154734 }
154735 yymsp[-2].minor.yy202 = yylhsminor.yy202;
154736 break;
154737 case 172: /* expr ::= nm DOT nm DOT nm */
154738 {
154739 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
154740 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
154741 Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
154742 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
154743 if( IN_RENAME_OBJECT ){
154744 sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
154745 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
154746 }
154747 yylhsminor.yy202 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
154748 }
154749 yymsp[-4].minor.yy202 = yylhsminor.yy202;
154750 break;
154751 case 173: /* term ::= NULL|FLOAT|BLOB */
154752 case 174: /* term ::= STRING */ yytestcase(yyruleno==174);
154753 {yymsp[0].minor.yy202=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
154754 break;
154755 case 175: /* term ::= INTEGER */
154756 {
154757 yylhsminor.yy202 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
154758 }
154759 yymsp[0].minor.yy202 = yylhsminor.yy202;
154760 break;
154761 case 176: /* expr ::= VARIABLE */
154762 {
154763 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
154764 u32 n = yymsp[0].minor.yy0.n;
154765 yymsp[0].minor.yy202 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
154766 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy202, n);
154767 }else{
154768 /* When doing a nested parse, one can include terms in an expression
154769 ** that look like this: #1 #2 ... These terms refer to registers
154770 ** in the virtual machine. #N is the N-th register. */
154771 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
154772 assert( t.n>=2 );
154773 if( pParse->nested==0 ){
154774 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
154775 yymsp[0].minor.yy202 = 0;
154776 }else{
154777 yymsp[0].minor.yy202 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
154778 if( yymsp[0].minor.yy202 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy202->iTable);
154779 }
154780 }
154781 }
154782 break;
154783 case 177: /* expr ::= expr COLLATE ID|STRING */
154784 {
154785 yymsp[-2].minor.yy202 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy202, &yymsp[0].minor.yy0, 1);
154786 }
154787 break;
154788 case 178: /* expr ::= CAST LP expr AS typetoken RP */
154789 {
154790 yymsp[-5].minor.yy202 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
154791 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy202, yymsp[-3].minor.yy202, 0);
154792 }
154793 break;
154794 case 179: /* expr ::= ID|INDEXED LP distinct exprlist RP */
154795 {
154796 yylhsminor.yy202 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy242, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy192);
154797 }
154798 yymsp[-4].minor.yy202 = yylhsminor.yy202;
154799 break;
154800 case 180: /* expr ::= ID|INDEXED LP STAR RP */
154801 {
154802 yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
154803 }
154804 yymsp[-3].minor.yy202 = yylhsminor.yy202;
154805 break;
154806 case 181: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
154807 {
154808 yylhsminor.yy202 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy242, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy192);
154809 sqlite3WindowAttach(pParse, yylhsminor.yy202, yymsp[0].minor.yy303);
154810 }
154811 yymsp[-5].minor.yy202 = yylhsminor.yy202;
154812 break;
154813 case 182: /* expr ::= ID|INDEXED LP STAR RP filter_over */
154814 {
154815 yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
154816 sqlite3WindowAttach(pParse, yylhsminor.yy202, yymsp[0].minor.yy303);
154817 }
154818 yymsp[-4].minor.yy202 = yylhsminor.yy202;
154819 break;
154820 case 183: /* term ::= CTIME_KW */
154821 {
154822 yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
154823 }
154824 yymsp[0].minor.yy202 = yylhsminor.yy202;
154825 break;
154826 case 184: /* expr ::= LP nexprlist COMMA expr RP */
154827 {
154828 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy242, yymsp[-1].minor.yy202);
154829 yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
154830 if( yymsp[-4].minor.yy202 ){
154831 yymsp[-4].minor.yy202->x.pList = pList;
154832 if( ALWAYS(pList->nExpr) ){
154833 yymsp[-4].minor.yy202->flags |= pList->a[0].pExpr->flags & EP_Propagate;
154834 }
154835 }else{
154836 sqlite3ExprListDelete(pParse->db, pList);
154837 }
154838 }
154839 break;
154840 case 185: /* expr ::= expr AND expr */
154841 {yymsp[-2].minor.yy202=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);}
154842 break;
154843 case 186: /* expr ::= expr OR expr */
154844 case 187: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==187);
154845 case 188: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==188);
154846 case 189: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==189);
154847 case 190: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==190);
154848 case 191: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==191);
154849 case 192: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==192);
154850 {yymsp[-2].minor.yy202=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);}
154851 break;
154852 case 193: /* likeop ::= NOT LIKE_KW|MATCH */
154853 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
154854 break;
154855 case 194: /* expr ::= expr likeop expr */
154856 {
154857 ExprList *pList;
154858 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
154859 yymsp[-1].minor.yy0.n &= 0x7fffffff;
154860 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy202);
154861 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy202);
154862 yymsp[-2].minor.yy202 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
154863 if( bNot ) yymsp[-2].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy202, 0);
154864 if( yymsp[-2].minor.yy202 ) yymsp[-2].minor.yy202->flags |= EP_InfixFunc;
154865 }
154866 break;
154867 case 195: /* expr ::= expr likeop expr ESCAPE expr */
154868 {
154869 ExprList *pList;
154870 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
154871 yymsp[-3].minor.yy0.n &= 0x7fffffff;
154872 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202);
154873 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy202);
154874 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy202);
154875 yymsp[-4].minor.yy202 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
154876 if( bNot ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0);
154877 if( yymsp[-4].minor.yy202 ) yymsp[-4].minor.yy202->flags |= EP_InfixFunc;
154878 }
154879 break;
154880 case 196: /* expr ::= expr ISNULL|NOTNULL */
154881 {yymsp[-1].minor.yy202 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy202,0);}
154882 break;
154883 case 197: /* expr ::= expr NOT NULL */
154884 {yymsp[-2].minor.yy202 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy202,0);}
154885 break;
154886 case 198: /* expr ::= expr IS expr */
154887 {
154888 yymsp[-2].minor.yy202 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);
154889 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy202, yymsp[-2].minor.yy202, TK_ISNULL);
154890 }
154891 break;
154892 case 199: /* expr ::= expr IS NOT expr */
154893 {
154894 yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy202,yymsp[0].minor.yy202);
154895 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy202, yymsp[-3].minor.yy202, TK_NOTNULL);
154896 }
154897 break;
154898 case 200: /* expr ::= NOT expr */
154899 case 201: /* expr ::= BITNOT expr */ yytestcase(yyruleno==201);
154900 {yymsp[-1].minor.yy202 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy202, 0);/*A-overwrites-B*/}
154901 break;
154902 case 202: /* expr ::= PLUS|MINUS expr */
154903 {
154904 yymsp[-1].minor.yy202 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy202, 0);
154905 /*A-overwrites-B*/
154906 }
154907 break;
154908 case 203: /* between_op ::= BETWEEN */
154909 case 206: /* in_op ::= IN */ yytestcase(yyruleno==206);
154910 {yymsp[0].minor.yy192 = 0;}
154911 break;
154912 case 205: /* expr ::= expr between_op expr AND expr */
154913 {
154914 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202);
154915 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy202);
154916 yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy202, 0);
154917 if( yymsp[-4].minor.yy202 ){
154918 yymsp[-4].minor.yy202->x.pList = pList;
154919 }else{
154920 sqlite3ExprListDelete(pParse->db, pList);
154921 }
154922 if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0);
154923 }
154924 break;
154925 case 208: /* expr ::= expr in_op LP exprlist RP */
154926 {
154927 if( yymsp[-1].minor.yy242==0 ){
154928 /* Expressions of the form
154929 **
154930 ** expr1 IN ()
154931 ** expr1 NOT IN ()
154932 **
154933 ** simplify to constants 0 (false) and 1 (true), respectively,
154934 ** regardless of the value of expr1.
154935 */
154936 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy202);
154937 yymsp[-4].minor.yy202 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy192 ? "1" : "0");
154938 }else{
154939 yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0);
154940 if( yymsp[-4].minor.yy202 ){
154941 yymsp[-4].minor.yy202->x.pList = yymsp[-1].minor.yy242;
154942 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy202);
154943 }else{
154944 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy242);
154945 }
154946 if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0);
154947 }
154948 }
154949 break;
154950 case 209: /* expr ::= LP select RP */
154951 {
154952 yymsp[-2].minor.yy202 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
154953 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy202, yymsp[-1].minor.yy539);
154954 }
154955 break;
154956 case 210: /* expr ::= expr in_op LP select RP */
154957 {
154958 yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0);
154959 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy202, yymsp[-1].minor.yy539);
154960 if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0);
154961 }
154962 break;
154963 case 211: /* expr ::= expr in_op nm dbnm paren_exprlist */
154964 {
154965 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
154966 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
154967 if( yymsp[0].minor.yy242 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy242);
154968 yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0);
154969 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy202, pSelect);
154970 if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0);
154971 }
154972 break;
154973 case 212: /* expr ::= EXISTS LP select RP */
154974 {
154975 Expr *p;
154976 p = yymsp[-3].minor.yy202 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
154977 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy539);
154978 }
154979 break;
154980 case 213: /* expr ::= CASE case_operand case_exprlist case_else END */
154981 {
154982 yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy202, 0);
154983 if( yymsp[-4].minor.yy202 ){
154984 yymsp[-4].minor.yy202->x.pList = yymsp[-1].minor.yy202 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy242,yymsp[-1].minor.yy202) : yymsp[-2].minor.yy242;
154985 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy202);
154986 }else{
154987 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy242);
154988 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy202);
154989 }
154990 }
154991 break;
154992 case 214: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
154993 {
154994 yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, yymsp[-2].minor.yy202);
154995 yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, yymsp[0].minor.yy202);
154996 }
154997 break;
154998 case 215: /* case_exprlist ::= WHEN expr THEN expr */
154999 {
155000 yymsp[-3].minor.yy242 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202);
155001 yymsp[-3].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy242, yymsp[0].minor.yy202);
155002 }
155003 break;
155004 case 218: /* case_operand ::= expr */
155005 {yymsp[0].minor.yy202 = yymsp[0].minor.yy202; /*A-overwrites-X*/}
155006 break;
155007 case 221: /* nexprlist ::= nexprlist COMMA expr */
155008 {yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy242,yymsp[0].minor.yy202);}
155009 break;
155010 case 222: /* nexprlist ::= expr */
155011 {yymsp[0].minor.yy242 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy202); /*A-overwrites-Y*/}
155012 break;
155013 case 224: /* paren_exprlist ::= LP exprlist RP */
155014 case 229: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==229);
155015 {yymsp[-2].minor.yy242 = yymsp[-1].minor.yy242;}
155016 break;
155017 case 225: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
155018 {
155019 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
155020 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy242, yymsp[-10].minor.yy192,
155021 &yymsp[-11].minor.yy0, yymsp[0].minor.yy202, SQLITE_SO_ASC, yymsp[-8].minor.yy192, SQLITE_IDXTYPE_APPDEF);
155022 if( IN_RENAME_OBJECT && pParse->pNewIndex ){
155023 sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
155024 }
155025 }
155026 break;
155027 case 226: /* uniqueflag ::= UNIQUE */
155028 case 268: /* raisetype ::= ABORT */ yytestcase(yyruleno==268);
155029 {yymsp[0].minor.yy192 = OE_Abort;}
155030 break;
155031 case 227: /* uniqueflag ::= */
155032 {yymsp[1].minor.yy192 = OE_None;}
155033 break;
155034 case 230: /* eidlist ::= eidlist COMMA nm collate sortorder */
155035 {
155036 yymsp[-4].minor.yy242 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy242, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy192, yymsp[0].minor.yy192);
155037 }
155038 break;
155039 case 231: /* eidlist ::= nm collate sortorder */
155040 {
155041 yymsp[-2].minor.yy242 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy192, yymsp[0].minor.yy192); /*A-overwrites-Y*/
155042 }
155043 break;
155044 case 234: /* cmd ::= DROP INDEX ifexists fullname */
155045 {sqlite3DropIndex(pParse, yymsp[0].minor.yy47, yymsp[-1].minor.yy192);}
155046 break;
155047 case 235: /* cmd ::= VACUUM vinto */
155048 {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy202);}
155049 break;
155050 case 236: /* cmd ::= VACUUM nm vinto */
155051 {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy202);}
155052 break;
155053 case 239: /* cmd ::= PRAGMA nm dbnm */
155054 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
155055 break;
155056 case 240: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
155057 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
155058 break;
155059 case 241: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
155060 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
155061 break;
155062 case 242: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
155063 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
155064 break;
155065 case 243: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
155066 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
155067 break;
155068 case 246: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
155069 {
155070 Token all;
155071 all.z = yymsp[-3].minor.yy0.z;
155072 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
155073 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy447, &all);
155074 }
155075 break;
155076 case 247: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
155077 {
155078 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy192, yymsp[-4].minor.yy230.a, yymsp[-4].minor.yy230.b, yymsp[-2].minor.yy47, yymsp[0].minor.yy202, yymsp[-10].minor.yy192, yymsp[-8].minor.yy192);
155079 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
155080 }
155081 break;
155082 case 248: /* trigger_time ::= BEFORE|AFTER */
155083 { yymsp[0].minor.yy192 = yymsp[0].major; /*A-overwrites-X*/ }
155084 break;
155085 case 249: /* trigger_time ::= INSTEAD OF */
155086 { yymsp[-1].minor.yy192 = TK_INSTEAD;}
155087 break;
155088 case 250: /* trigger_time ::= */
155089 { yymsp[1].minor.yy192 = TK_BEFORE; }
155090 break;
155091 case 251: /* trigger_event ::= DELETE|INSERT */
155092 case 252: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==252);
155093 {yymsp[0].minor.yy230.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy230.b = 0;}
155094 break;
155095 case 253: /* trigger_event ::= UPDATE OF idlist */
155096 {yymsp[-2].minor.yy230.a = TK_UPDATE; yymsp[-2].minor.yy230.b = yymsp[0].minor.yy600;}
155097 break;
155098 case 254: /* when_clause ::= */
155099 case 273: /* key_opt ::= */ yytestcase(yyruleno==273);
155100 { yymsp[1].minor.yy202 = 0; }
155101 break;
155102 case 255: /* when_clause ::= WHEN expr */
155103 case 274: /* key_opt ::= KEY expr */ yytestcase(yyruleno==274);
155104 { yymsp[-1].minor.yy202 = yymsp[0].minor.yy202; }
155105 break;
155106 case 256: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
155107 {
155108 assert( yymsp[-2].minor.yy447!=0 );
155109 yymsp[-2].minor.yy447->pLast->pNext = yymsp[-1].minor.yy447;
155110 yymsp[-2].minor.yy447->pLast = yymsp[-1].minor.yy447;
155111 }
155112 break;
155113 case 257: /* trigger_cmd_list ::= trigger_cmd SEMI */
155114 {
155115 assert( yymsp[-1].minor.yy447!=0 );
155116 yymsp[-1].minor.yy447->pLast = yymsp[-1].minor.yy447;
155117 }
155118 break;
155119 case 258: /* trnm ::= nm DOT nm */
155120 {
155121 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
155122 sqlite3ErrorMsg(pParse,
155123 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
155124 "statements within triggers");
155125 }
155126 break;
155127 case 259: /* tridxby ::= INDEXED BY nm */
155128 {
155129 sqlite3ErrorMsg(pParse,
155130 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
155131 "within triggers");
155132 }
155133 break;
155134 case 260: /* tridxby ::= NOT INDEXED */
155135 {
155136 sqlite3ErrorMsg(pParse,
155137 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
155138 "within triggers");
155139 }
155140 break;
155141 case 261: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
155142 {yylhsminor.yy447 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy242, yymsp[-1].minor.yy202, yymsp[-6].minor.yy192, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy436);}
155143 yymsp[-7].minor.yy447 = yylhsminor.yy447;
155144 break;
155145 case 262: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
155146 {
155147 yylhsminor.yy447 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy600,yymsp[-2].minor.yy539,yymsp[-6].minor.yy192,yymsp[-1].minor.yy318,yymsp[-7].minor.yy436,yymsp[0].minor.yy436);/*yylhsminor.yy447-overwrites-yymsp[-6].minor.yy192*/
155148 }
155149 yymsp[-7].minor.yy447 = yylhsminor.yy447;
155150 break;
155151 case 263: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
155152 {yylhsminor.yy447 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy202, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy436);}
155153 yymsp[-5].minor.yy447 = yylhsminor.yy447;
155154 break;
155155 case 264: /* trigger_cmd ::= scanpt select scanpt */
155156 {yylhsminor.yy447 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy539, yymsp[-2].minor.yy436, yymsp[0].minor.yy436); /*yylhsminor.yy447-overwrites-yymsp[-1].minor.yy539*/}
155157 yymsp[-2].minor.yy447 = yylhsminor.yy447;
155158 break;
155159 case 265: /* expr ::= RAISE LP IGNORE RP */
155160 {
155161 yymsp[-3].minor.yy202 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
155162 if( yymsp[-3].minor.yy202 ){
155163 yymsp[-3].minor.yy202->affExpr = OE_Ignore;
155164 }
155165 }
155166 break;
155167 case 266: /* expr ::= RAISE LP raisetype COMMA nm RP */
155168 {
155169 yymsp[-5].minor.yy202 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
155170 if( yymsp[-5].minor.yy202 ) {
155171 yymsp[-5].minor.yy202->affExpr = (char)yymsp[-3].minor.yy192;
155172 }
155173 }
155174 break;
155175 case 267: /* raisetype ::= ROLLBACK */
155176 {yymsp[0].minor.yy192 = OE_Rollback;}
155177 break;
155178 case 269: /* raisetype ::= FAIL */
155179 {yymsp[0].minor.yy192 = OE_Fail;}
155180 break;
155181 case 270: /* cmd ::= DROP TRIGGER ifexists fullname */
155182 {
155183 sqlite3DropTrigger(pParse,yymsp[0].minor.yy47,yymsp[-1].minor.yy192);
155184 }
155185 break;
155186 case 271: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
155187 {
155188 sqlite3Attach(pParse, yymsp[-3].minor.yy202, yymsp[-1].minor.yy202, yymsp[0].minor.yy202);
155189 }
155190 break;
155191 case 272: /* cmd ::= DETACH database_kw_opt expr */
155192 {
155193 sqlite3Detach(pParse, yymsp[0].minor.yy202);
155194 }
155195 break;
155196 case 275: /* cmd ::= REINDEX */
155197 {sqlite3Reindex(pParse, 0, 0);}
155198 break;
155199 case 276: /* cmd ::= REINDEX nm dbnm */
155200 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
155201 break;
155202 case 277: /* cmd ::= ANALYZE */
155203 {sqlite3Analyze(pParse, 0, 0);}
155204 break;
155205 case 278: /* cmd ::= ANALYZE nm dbnm */
155206 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
155207 break;
155208 case 279: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
155209 {
155210 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy47,&yymsp[0].minor.yy0);
155211 }
155212 break;
155213 case 280: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
155214 {
155215 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
155216 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
155217 }
155218 break;
155219 case 281: /* add_column_fullname ::= fullname */
155220 {
155221 disableLookaside(pParse);
155222 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy47);
155223 }
155224 break;
155225 case 282: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
155226 {
155227 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy47, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
155228 }
155229 break;
155230 case 283: /* cmd ::= create_vtab */
155231 {sqlite3VtabFinishParse(pParse,0);}
155232 break;
155233 case 284: /* cmd ::= create_vtab LP vtabarglist RP */
155234 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
155235 break;
155236 case 285: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
155237 {
155238 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy192);
155239 }
155240 break;
155241 case 286: /* vtabarg ::= */
155242 {sqlite3VtabArgInit(pParse);}
155243 break;
155244 case 287: /* vtabargtoken ::= ANY */
155245 case 288: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==288);
155246 case 289: /* lp ::= LP */ yytestcase(yyruleno==289);
155247 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
155248 break;
155249 case 290: /* with ::= WITH wqlist */
155250 case 291: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==291);
155251 { sqlite3WithPush(pParse, yymsp[0].minor.yy131, 1); }
155252 break;
155253 case 292: /* wqlist ::= nm eidlist_opt AS LP select RP */
155254 {
155255 yymsp[-5].minor.yy131 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy242, yymsp[-1].minor.yy539); /*A-overwrites-X*/
155256 }
155257 break;
155258 case 293: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
155259 {
155260 yymsp[-7].minor.yy131 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy131, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy242, yymsp[-1].minor.yy539);
155261 }
155262 break;
155263 case 294: /* windowdefn_list ::= windowdefn */
155264 { yylhsminor.yy303 = yymsp[0].minor.yy303; }
155265 yymsp[0].minor.yy303 = yylhsminor.yy303;
155266 break;
155267 case 295: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
155268 {
155269 assert( yymsp[0].minor.yy303!=0 );
155270 sqlite3WindowChain(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy303);
155271 yymsp[0].minor.yy303->pNextWin = yymsp[-2].minor.yy303;
155272 yylhsminor.yy303 = yymsp[0].minor.yy303;
155273 }
155274 yymsp[-2].minor.yy303 = yylhsminor.yy303;
155275 break;
155276 case 296: /* windowdefn ::= nm AS LP window RP */
155277 {
155278 if( ALWAYS(yymsp[-1].minor.yy303) ){
155279 yymsp[-1].minor.yy303->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
155280 }
155281 yylhsminor.yy303 = yymsp[-1].minor.yy303;
155282 }
155283 yymsp[-4].minor.yy303 = yylhsminor.yy303;
155284 break;
155285 case 297: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
155286 {
155287 yymsp[-4].minor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy242, yymsp[-1].minor.yy242, 0);
155288 }
155289 break;
155290 case 298: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
155291 {
155292 yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy242, yymsp[-1].minor.yy242, &yymsp[-5].minor.yy0);
155293 }
155294 yymsp[-5].minor.yy303 = yylhsminor.yy303;
155295 break;
155296 case 299: /* window ::= ORDER BY sortlist frame_opt */
155297 {
155298 yymsp[-3].minor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, yymsp[-1].minor.yy242, 0);
155299 }
155300 break;
155301 case 300: /* window ::= nm ORDER BY sortlist frame_opt */
155302 {
155303 yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, yymsp[-1].minor.yy242, &yymsp[-4].minor.yy0);
155304 }
155305 yymsp[-4].minor.yy303 = yylhsminor.yy303;
155306 break;
155307 case 301: /* window ::= frame_opt */
155308 case 320: /* filter_over ::= over_clause */ yytestcase(yyruleno==320);
155309 {
155310 yylhsminor.yy303 = yymsp[0].minor.yy303;
155311 }
155312 yymsp[0].minor.yy303 = yylhsminor.yy303;
155313 break;
155314 case 302: /* window ::= nm frame_opt */
155315 {
155316 yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, 0, &yymsp[-1].minor.yy0);
155317 }
155318 yymsp[-1].minor.yy303 = yylhsminor.yy303;
155319 break;
155320 case 303: /* frame_opt ::= */
155321 {
155322 yymsp[1].minor.yy303 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
155323 }
155324 break;
155325 case 304: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
155326 {
155327 yylhsminor.yy303 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy192, yymsp[-1].minor.yy77.eType, yymsp[-1].minor.yy77.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy58);
155328 }
155329 yymsp[-2].minor.yy303 = yylhsminor.yy303;
155330 break;
155331 case 305: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
155332 {
155333 yylhsminor.yy303 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy192, yymsp[-3].minor.yy77.eType, yymsp[-3].minor.yy77.pExpr, yymsp[-1].minor.yy77.eType, yymsp[-1].minor.yy77.pExpr, yymsp[0].minor.yy58);
155334 }
155335 yymsp[-5].minor.yy303 = yylhsminor.yy303;
155336 break;
155337 case 307: /* frame_bound_s ::= frame_bound */
155338 case 309: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==309);
155339 {yylhsminor.yy77 = yymsp[0].minor.yy77;}
155340 yymsp[0].minor.yy77 = yylhsminor.yy77;
155341 break;
155342 case 308: /* frame_bound_s ::= UNBOUNDED PRECEDING */
155343 case 310: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==310);
155344 case 312: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==312);
155345 {yylhsminor.yy77.eType = yymsp[-1].major; yylhsminor.yy77.pExpr = 0;}
155346 yymsp[-1].minor.yy77 = yylhsminor.yy77;
155347 break;
155348 case 311: /* frame_bound ::= expr PRECEDING|FOLLOWING */
155349 {yylhsminor.yy77.eType = yymsp[0].major; yylhsminor.yy77.pExpr = yymsp[-1].minor.yy202;}
155350 yymsp[-1].minor.yy77 = yylhsminor.yy77;
155351 break;
155352 case 313: /* frame_exclude_opt ::= */
155353 {yymsp[1].minor.yy58 = 0;}
155354 break;
155355 case 314: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
155356 {yymsp[-1].minor.yy58 = yymsp[0].minor.yy58;}
155357 break;
155358 case 315: /* frame_exclude ::= NO OTHERS */
155359 case 316: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==316);
155360 {yymsp[-1].minor.yy58 = yymsp[-1].major; /*A-overwrites-X*/}
155361 break;
155362 case 317: /* frame_exclude ::= GROUP|TIES */
155363 {yymsp[0].minor.yy58 = yymsp[0].major; /*A-overwrites-X*/}
155364 break;
155365 case 318: /* window_clause ::= WINDOW windowdefn_list */
155366 { yymsp[-1].minor.yy303 = yymsp[0].minor.yy303; }
155367 break;
155368 case 319: /* filter_over ::= filter_clause over_clause */
155369 {
155370 yymsp[0].minor.yy303->pFilter = yymsp[-1].minor.yy202;
155371 yylhsminor.yy303 = yymsp[0].minor.yy303;
155372 }
155373 yymsp[-1].minor.yy303 = yylhsminor.yy303;
155374 break;
155375 case 321: /* filter_over ::= filter_clause */
155376 {
155377 yylhsminor.yy303 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
155378 if( yylhsminor.yy303 ){
155379 yylhsminor.yy303->eFrmType = TK_FILTER;
155380 yylhsminor.yy303->pFilter = yymsp[0].minor.yy202;
155381 }else{
155382 sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy202);
155383 }
155384 }
155385 yymsp[0].minor.yy303 = yylhsminor.yy303;
155386 break;
155387 case 322: /* over_clause ::= OVER LP window RP */
155388 {
155389 yymsp[-3].minor.yy303 = yymsp[-1].minor.yy303;
155390 assert( yymsp[-3].minor.yy303!=0 );
155391 }
155392 break;
155393 case 323: /* over_clause ::= OVER nm */
155394 {
155395 yymsp[-1].minor.yy303 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
155396 if( yymsp[-1].minor.yy303 ){
155397 yymsp[-1].minor.yy303->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
155398 }
155399 }
155400 break;
155401 case 324: /* filter_clause ::= FILTER LP WHERE expr RP */
155402 { yymsp[-4].minor.yy202 = yymsp[-1].minor.yy202; }
155403 break;
155404 default:
155405 /* (325) input ::= cmdlist */ yytestcase(yyruleno==325);
155406 /* (326) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==326);
155407 /* (327) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=327);
155408 /* (328) ecmd ::= SEMI */ yytestcase(yyruleno==328);
155409 /* (329) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==329);
155410 /* (330) ecmd ::= explain cmdx */ yytestcase(yyruleno==330);
155411 /* (331) trans_opt ::= */ yytestcase(yyruleno==331);
155412 /* (332) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==332);
155413 /* (333) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==333);
155414 /* (334) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==334);
155415 /* (335) savepoint_opt ::= */ yytestcase(yyruleno==335);
155416 /* (336) cmd ::= create_table create_table_args */ yytestcase(yyruleno==336);
155417 /* (337) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==337);
155418 /* (338) columnlist ::= columnname carglist */ yytestcase(yyruleno==338);
155419 /* (339) nm ::= ID|INDEXED */ yytestcase(yyruleno==339);
155420 /* (340) nm ::= STRING */ yytestcase(yyruleno==340);
155421 /* (341) nm ::= JOIN_KW */ yytestcase(yyruleno==341);
155422 /* (342) typetoken ::= typename */ yytestcase(yyruleno==342);
155423 /* (343) typename ::= ID|STRING */ yytestcase(yyruleno==343);
155424 /* (344) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=344);
155425 /* (345) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=345);
155426 /* (346) carglist ::= carglist ccons */ yytestcase(yyruleno==346);
155427 /* (347) carglist ::= */ yytestcase(yyruleno==347);
155428 /* (348) ccons ::= NULL onconf */ yytestcase(yyruleno==348);
155429 /* (349) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==349);
155430 /* (350) ccons ::= AS generated */ yytestcase(yyruleno==350);
155431 /* (351) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==351);
155432 /* (352) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==352);
155433 /* (353) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=353);
155434 /* (354) tconscomma ::= */ yytestcase(yyruleno==354);
155435 /* (355) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=355);
155436 /* (356) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=356);
155437 /* (357) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=357);
155438 /* (358) oneselect ::= values */ yytestcase(yyruleno==358);
155439 /* (359) sclp ::= selcollist COMMA */ yytestcase(yyruleno==359);
155440 /* (360) as ::= ID|STRING */ yytestcase(yyruleno==360);
155441 /* (361) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=361);
155442 /* (362) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==362);
155443 /* (363) exprlist ::= nexprlist */ yytestcase(yyruleno==363);
155444 /* (364) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=364);
155445 /* (365) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=365);
155446 /* (366) nmnum ::= ON */ yytestcase(yyruleno==366);
155447 /* (367) nmnum ::= DELETE */ yytestcase(yyruleno==367);
155448 /* (368) nmnum ::= DEFAULT */ yytestcase(yyruleno==368);
155449 /* (369) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==369);
155450 /* (370) foreach_clause ::= */ yytestcase(yyruleno==370);
155451 /* (371) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==371);
155452 /* (372) trnm ::= nm */ yytestcase(yyruleno==372);
155453 /* (373) tridxby ::= */ yytestcase(yyruleno==373);
155454 /* (374) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==374);
155455 /* (375) database_kw_opt ::= */ yytestcase(yyruleno==375);
155456 /* (376) kwcolumn_opt ::= */ yytestcase(yyruleno==376);
155457 /* (377) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==377);
155458 /* (378) vtabarglist ::= vtabarg */ yytestcase(yyruleno==378);
155459 /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==379);
155460 /* (380) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==380);
155461 /* (381) anylist ::= */ yytestcase(yyruleno==381);
155462 /* (382) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==382);
155463 /* (383) anylist ::= anylist ANY */ yytestcase(yyruleno==383);
155464 /* (384) with ::= */ yytestcase(yyruleno==384);
155465 break;
155466 /********** End reduce actions ************************************************/
155467 };
155468 assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
155469 yygoto = yyRuleInfoLhs[yyruleno];
@@ -154613,12 +155755,12 @@
155755 #ifdef YYFALLBACK
155756 assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) );
155757 return yyFallback[iToken];
155758 #else
155759 (void)iToken;
 
155760 return 0;
155761 #endif
155762 }
155763
155764 /************** End of parse.c ***********************************************/
155765 /************** Begin file tokenize.c ****************************************/
155766 /*
@@ -154779,24 +155921,24 @@
155921 ** might be implemented more directly using a hand-written hash table.
155922 ** But by using this automatically generated code, the size of the code
155923 ** is substantially reduced. This is important for embedded applications
155924 ** on platforms with limited memory.
155925 */
155926 /* Hash score: 227 */
155927 /* zKWText[] encodes 984 bytes of keyword text in 648 bytes */
155928 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
155929 /* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYISNULLSAVEPOINTERSECT */
155930 /* IESNOTNULLIKEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTS */
155931 /* CONSTRAINTOFFSETRIGGERANGENERATEDETACHAVINGLOBEGINNEREFERENCES */
155932 /* UNIQUERYWITHOUTERELEASEATTACHBETWEENOTHINGROUPSCASCADEFAULT */
155933 /* CASECOLLATECREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZE */
155934 /* PRAGMABORTUPDATEVALUESVIRTUALWAYSWHENWHERECURSIVEAFTERENAMEAND */
155935 /* EFERREDISTINCTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */
155936 /* CURRENT_TIMESTAMPARTITIONDROPRECEDINGFAILASTFILTEREPLACEFIRST */
155937 /* FOLLOWINGFROMFULLIMITIFORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */
155938 /* UNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBYINITIALLYPRIMARY */
155939 static const char zKWText[647] = {
155940 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
155941 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
155942 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
155943 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
155944 'E','R','R','A','B','L','E','L','S','E','X','C','L','U','D','E','L','E',
@@ -154803,97 +155945,100 @@
155945 'T','E','M','P','O','R','A','R','Y','I','S','N','U','L','L','S','A','V',
155946 'E','P','O','I','N','T','E','R','S','E','C','T','I','E','S','N','O','T',
155947 'N','U','L','L','I','K','E','X','C','E','P','T','R','A','N','S','A','C',
155948 'T','I','O','N','A','T','U','R','A','L','T','E','R','A','I','S','E','X',
155949 'C','L','U','S','I','V','E','X','I','S','T','S','C','O','N','S','T','R',
155950 'A','I','N','T','O','F','F','S','E','T','R','I','G','G','E','R','A','N',
155951 'G','E','N','E','R','A','T','E','D','E','T','A','C','H','A','V','I','N',
155952 'G','L','O','B','E','G','I','N','N','E','R','E','F','E','R','E','N','C',
155953 'E','S','U','N','I','Q','U','E','R','Y','W','I','T','H','O','U','T','E',
155954 'R','E','L','E','A','S','E','A','T','T','A','C','H','B','E','T','W','E',
155955 'E','N','O','T','H','I','N','G','R','O','U','P','S','C','A','S','C','A',
155956 'D','E','F','A','U','L','T','C','A','S','E','C','O','L','L','A','T','E',
155957 'C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A','T','E',
155958 'I','M','M','E','D','I','A','T','E','J','O','I','N','S','E','R','T','M',
155959 'A','T','C','H','P','L','A','N','A','L','Y','Z','E','P','R','A','G','M',
155960 'A','B','O','R','T','U','P','D','A','T','E','V','A','L','U','E','S','V',
155961 'I','R','T','U','A','L','W','A','Y','S','W','H','E','N','W','H','E','R',
155962 'E','C','U','R','S','I','V','E','A','F','T','E','R','E','N','A','M','E',
155963 'A','N','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','A',
155964 'U','T','O','I','N','C','R','E','M','E','N','T','C','A','S','T','C','O',
155965 'L','U','M','N','C','O','M','M','I','T','C','O','N','F','L','I','C','T',
155966 'C','R','O','S','S','C','U','R','R','E','N','T','_','T','I','M','E','S',
155967 'T','A','M','P','A','R','T','I','T','I','O','N','D','R','O','P','R','E',
155968 'C','E','D','I','N','G','F','A','I','L','A','S','T','F','I','L','T','E',
155969 'R','E','P','L','A','C','E','F','I','R','S','T','F','O','L','L','O','W',
155970 'I','N','G','F','R','O','M','F','U','L','L','I','M','I','T','I','F','O',
155971 'R','D','E','R','E','S','T','R','I','C','T','O','T','H','E','R','S','O',
155972 'V','E','R','I','G','H','T','R','O','L','L','B','A','C','K','R','O','W',
155973 'S','U','N','B','O','U','N','D','E','D','U','N','I','O','N','U','S','I',
155974 'N','G','V','A','C','U','U','M','V','I','E','W','I','N','D','O','W','B',
155975 'Y','I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R','Y',
155976 };
155977 /* aKWHash[i] is the hash value for the i-th keyword */
155978 static const unsigned char aKWHash[127] = {
155979 84, 102, 132, 82, 114, 29, 0, 0, 91, 0, 85, 72, 0,
155980 53, 35, 86, 15, 0, 42, 94, 54, 126, 133, 19, 0, 0,
155981 138, 0, 40, 128, 0, 22, 104, 0, 9, 0, 0, 122, 80,
155982 0, 78, 6, 0, 65, 99, 145, 0, 134, 112, 0, 0, 48,
155983 0, 100, 24, 0, 17, 0, 27, 70, 23, 26, 5, 60, 140,
155984 107, 121, 0, 73, 101, 71, 143, 61, 119, 74, 0, 49, 0,
155985 11, 41, 0, 110, 0, 0, 0, 106, 10, 108, 113, 124, 14,
155986 50, 123, 0, 89, 0, 18, 120, 142, 56, 129, 137, 88, 83,
155987 37, 30, 125, 0, 0, 105, 51, 130, 127, 0, 34, 0, 0,
155988 44, 0, 95, 38, 39, 0, 20, 45, 116, 90,
155989 };
155990 /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
155991 ** then the i-th keyword has no more hash collisions. Otherwise,
155992 ** the next keyword with the same hash is aKWHash[i]-1. */
155993 static const unsigned char aKWNext[145] = {
155994 0, 0, 0, 0, 4, 0, 43, 0, 0, 103, 111, 0, 0,
155995 0, 2, 0, 0, 141, 0, 0, 0, 13, 0, 0, 0, 0,
155996 139, 0, 0, 118, 52, 0, 0, 135, 12, 0, 0, 62, 0,
155997 136, 0, 131, 0, 0, 36, 0, 0, 28, 77, 0, 0, 0,
155998 0, 59, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
155999 0, 69, 0, 0, 0, 0, 0, 144, 3, 0, 58, 0, 1,
156000 75, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 64, 66,
156001 63, 0, 0, 0, 0, 46, 0, 16, 0, 115, 0, 0, 0,
156002 0, 0, 0, 0, 0, 0, 0, 81, 97, 0, 8, 0, 109,
156003 21, 7, 67, 0, 79, 93, 117, 0, 0, 68, 0, 0, 96,
156004 0, 55, 0, 76, 0, 92, 32, 33, 57, 25, 0, 98, 0,
156005 0, 87,
156006 };
156007 /* aKWLen[i] is the length (in bytes) of the i-th keyword */
156008 static const unsigned char aKWLen[145] = {
156009 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
156010 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7,
156011 6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4,
156012 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 10, 4, 6,
156013 2, 3, 7, 5, 9, 6, 6, 4, 5, 5, 10, 6, 5,
156014 7, 4, 5, 7, 6, 7, 7, 6, 5, 7, 3, 7, 4,
156015 7, 6, 12, 9, 4, 6, 5, 4, 7, 6, 5, 6, 6,
156016 7, 6, 4, 5, 9, 5, 6, 3, 8, 8, 2, 13, 2,
156017 2, 4, 6, 6, 8, 5, 17, 12, 7, 9, 4, 9, 4,
156018 4, 6, 7, 5, 9, 4, 4, 5, 2, 5, 8, 6, 4,
156019 5, 8, 4, 3, 9, 5, 5, 6, 4, 6, 2, 2, 9,
156020 3, 7,
156021 };
156022 /* aKWOffset[i] is the index into zKWText[] of the start of
156023 ** the text for the i-th keyword. */
156024 static const unsigned short int aKWOffset[145] = {
156025 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
156026 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
156027 86, 90, 90, 94, 99, 101, 105, 111, 119, 123, 123, 123, 126,
156028 129, 132, 137, 142, 146, 147, 152, 156, 160, 168, 174, 181, 184,
156029 184, 187, 189, 195, 198, 206, 211, 216, 219, 222, 226, 236, 239,
156030 244, 244, 248, 252, 259, 265, 271, 277, 277, 283, 284, 288, 295,
156031 299, 306, 312, 324, 333, 335, 341, 346, 348, 355, 360, 365, 371,
156032 377, 382, 388, 392, 395, 404, 408, 414, 416, 423, 424, 431, 433,
156033 435, 444, 448, 454, 460, 468, 473, 473, 473, 489, 498, 501, 510,
156034 513, 517, 522, 529, 534, 543, 547, 550, 555, 557, 561, 569, 575,
156035 578, 583, 591, 591, 595, 604, 609, 614, 620, 623, 626, 629, 631,
156036 636, 640,
156037 };
156038 /* aKWCode[i] is the parser symbol code for the i-th keyword */
156039 static const unsigned char aKWCode[145] = {
156040 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
156041 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
156042 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
156043 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
156044 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
@@ -154901,29 +156046,158 @@
156046 TK_ISNULL, TK_NULLS, TK_SAVEPOINT, TK_INTERSECT, TK_TIES,
156047 TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
156048 TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
156049 TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_CONSTRAINT,
156050 TK_INTO, TK_OFFSET, TK_OF, TK_SET, TK_TRIGGER,
156051 TK_RANGE, TK_GENERATED, TK_DETACH, TK_HAVING, TK_LIKE_KW,
156052 TK_BEGIN, TK_JOIN_KW, TK_REFERENCES, TK_UNIQUE, TK_QUERY,
156053 TK_WITHOUT, TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_ATTACH,
156054 TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP, TK_CASCADE,
156055 TK_ASC, TK_DEFAULT, TK_CASE, TK_COLLATE, TK_CREATE,
156056 TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_MATCH,
156057 TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT, TK_UPDATE,
156058 TK_VALUES, TK_VIRTUAL, TK_ALWAYS, TK_WHEN, TK_WHERE,
156059 TK_RECURSIVE, TK_AFTER, TK_RENAME, TK_AND, TK_DEFERRED,
156060 TK_DISTINCT, TK_IS, TK_AUTOINCR, TK_TO, TK_IN,
156061 TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW,
156062 TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT, TK_PARTITION, TK_DROP,
156063 TK_PRECEDING, TK_FAIL, TK_LAST, TK_FILTER, TK_REPLACE,
156064 TK_FIRST, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_LIMIT,
156065 TK_IF, TK_ORDER, TK_RESTRICT, TK_OTHERS, TK_OVER,
156066 TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNBOUNDED,
156067 TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_WINDOW,
156068 TK_DO, TK_BY, TK_INITIALLY, TK_ALL, TK_PRIMARY,
156069 };
156070 /* Hash table decoded:
156071 ** 0: INSERT
156072 ** 1: IS
156073 ** 2: ROLLBACK TRIGGER
156074 ** 3: IMMEDIATE
156075 ** 4: PARTITION
156076 ** 5: TEMP
156077 ** 6:
156078 ** 7:
156079 ** 8: VALUES WITHOUT
156080 ** 9:
156081 ** 10: MATCH
156082 ** 11: NOTHING
156083 ** 12:
156084 ** 13: OF
156085 ** 14: TIES IGNORE
156086 ** 15: PLAN
156087 ** 16: INSTEAD INDEXED
156088 ** 17:
156089 ** 18: TRANSACTION RIGHT
156090 ** 19: WHEN
156091 ** 20: SET HAVING
156092 ** 21: IF
156093 ** 22: ROWS
156094 ** 23: SELECT
156095 ** 24:
156096 ** 25:
156097 ** 26: VACUUM SAVEPOINT
156098 ** 27:
156099 ** 28: LIKE UNION VIRTUAL REFERENCES
156100 ** 29: RESTRICT
156101 ** 30:
156102 ** 31: THEN REGEXP
156103 ** 32: TO
156104 ** 33:
156105 ** 34: BEFORE
156106 ** 35:
156107 ** 36:
156108 ** 37: FOLLOWING COLLATE CASCADE
156109 ** 38: CREATE
156110 ** 39:
156111 ** 40: CASE REINDEX
156112 ** 41: EACH
156113 ** 42:
156114 ** 43: QUERY
156115 ** 44: AND ADD
156116 ** 45: PRIMARY ANALYZE
156117 ** 46:
156118 ** 47: ROW ASC DETACH
156119 ** 48: CURRENT_TIME CURRENT_DATE
156120 ** 49:
156121 ** 50:
156122 ** 51: EXCLUSIVE TEMPORARY
156123 ** 52:
156124 ** 53: DEFERRED
156125 ** 54: DEFERRABLE
156126 ** 55:
156127 ** 56: DATABASE
156128 ** 57:
156129 ** 58: DELETE VIEW GENERATED
156130 ** 59: ATTACH
156131 ** 60: END
156132 ** 61: EXCLUDE
156133 ** 62: ESCAPE DESC
156134 ** 63: GLOB
156135 ** 64: WINDOW ELSE
156136 ** 65: COLUMN
156137 ** 66: FIRST
156138 ** 67:
156139 ** 68: GROUPS ALL
156140 ** 69: DISTINCT DROP KEY
156141 ** 70: BETWEEN
156142 ** 71: INITIALLY
156143 ** 72: BEGIN
156144 ** 73: FILTER CHECK ACTION
156145 ** 74: GROUP INDEX
156146 ** 75:
156147 ** 76: EXISTS DEFAULT
156148 ** 77:
156149 ** 78: FOR CURRENT_TIMESTAMP
156150 ** 79: EXCEPT
156151 ** 80:
156152 ** 81: CROSS
156153 ** 82:
156154 ** 83:
156155 ** 84:
156156 ** 85: CAST
156157 ** 86: FOREIGN AUTOINCREMENT
156158 ** 87: COMMIT
156159 ** 88: CURRENT AFTER ALTER
156160 ** 89: FULL FAIL CONFLICT
156161 ** 90: EXPLAIN
156162 ** 91: CONSTRAINT
156163 ** 92: FROM ALWAYS
156164 ** 93:
156165 ** 94: ABORT
156166 ** 95:
156167 ** 96: AS DO
156168 ** 97: REPLACE WITH RELEASE
156169 ** 98: BY RENAME
156170 ** 99: RANGE RAISE
156171 ** 100: OTHERS
156172 ** 101: USING NULLS
156173 ** 102: PRAGMA
156174 ** 103: JOIN ISNULL OFFSET
156175 ** 104: NOT
156176 ** 105: OR LAST LEFT
156177 ** 106: LIMIT
156178 ** 107:
156179 ** 108:
156180 ** 109: IN
156181 ** 110: INTO
156182 ** 111: OVER RECURSIVE
156183 ** 112: ORDER OUTER
156184 ** 113:
156185 ** 114: INTERSECT UNBOUNDED
156186 ** 115:
156187 ** 116:
156188 ** 117: ON
156189 ** 118:
156190 ** 119: WHERE
156191 ** 120: NO INNER
156192 ** 121: NULL
156193 ** 122:
156194 ** 123: TABLE
156195 ** 124: NATURAL NOTNULL
156196 ** 125: PRECEDING
156197 ** 126: UPDATE UNIQUE
156198 */
156199 /* Check to see if z[0..n-1] is a keyword. If it is, write the
156200 ** parser symbol code for that keyword into *pType. Always
156201 ** return the integer n (the length of the token). */
156202 static int keywordCode(const char *z, int n, int *pType){
156203 int i, j;
@@ -154994,98 +156268,100 @@
156268 testcase( i==50 ); /* INTO */
156269 testcase( i==51 ); /* OFFSET */
156270 testcase( i==52 ); /* OF */
156271 testcase( i==53 ); /* SET */
156272 testcase( i==54 ); /* TRIGGER */
156273 testcase( i==55 ); /* RANGE */
156274 testcase( i==56 ); /* GENERATED */
156275 testcase( i==57 ); /* DETACH */
156276 testcase( i==58 ); /* HAVING */
156277 testcase( i==59 ); /* GLOB */
156278 testcase( i==60 ); /* BEGIN */
156279 testcase( i==61 ); /* INNER */
156280 testcase( i==62 ); /* REFERENCES */
156281 testcase( i==63 ); /* UNIQUE */
156282 testcase( i==64 ); /* QUERY */
156283 testcase( i==65 ); /* WITHOUT */
156284 testcase( i==66 ); /* WITH */
156285 testcase( i==67 ); /* OUTER */
156286 testcase( i==68 ); /* RELEASE */
156287 testcase( i==69 ); /* ATTACH */
156288 testcase( i==70 ); /* BETWEEN */
156289 testcase( i==71 ); /* NOTHING */
156290 testcase( i==72 ); /* GROUPS */
156291 testcase( i==73 ); /* GROUP */
156292 testcase( i==74 ); /* CASCADE */
156293 testcase( i==75 ); /* ASC */
156294 testcase( i==76 ); /* DEFAULT */
156295 testcase( i==77 ); /* CASE */
156296 testcase( i==78 ); /* COLLATE */
156297 testcase( i==79 ); /* CREATE */
156298 testcase( i==80 ); /* CURRENT_DATE */
156299 testcase( i==81 ); /* IMMEDIATE */
156300 testcase( i==82 ); /* JOIN */
156301 testcase( i==83 ); /* INSERT */
156302 testcase( i==84 ); /* MATCH */
156303 testcase( i==85 ); /* PLAN */
156304 testcase( i==86 ); /* ANALYZE */
156305 testcase( i==87 ); /* PRAGMA */
156306 testcase( i==88 ); /* ABORT */
156307 testcase( i==89 ); /* UPDATE */
156308 testcase( i==90 ); /* VALUES */
156309 testcase( i==91 ); /* VIRTUAL */
156310 testcase( i==92 ); /* ALWAYS */
156311 testcase( i==93 ); /* WHEN */
156312 testcase( i==94 ); /* WHERE */
156313 testcase( i==95 ); /* RECURSIVE */
156314 testcase( i==96 ); /* AFTER */
156315 testcase( i==97 ); /* RENAME */
156316 testcase( i==98 ); /* AND */
156317 testcase( i==99 ); /* DEFERRED */
156318 testcase( i==100 ); /* DISTINCT */
156319 testcase( i==101 ); /* IS */
156320 testcase( i==102 ); /* AUTOINCREMENT */
156321 testcase( i==103 ); /* TO */
156322 testcase( i==104 ); /* IN */
156323 testcase( i==105 ); /* CAST */
156324 testcase( i==106 ); /* COLUMN */
156325 testcase( i==107 ); /* COMMIT */
156326 testcase( i==108 ); /* CONFLICT */
156327 testcase( i==109 ); /* CROSS */
156328 testcase( i==110 ); /* CURRENT_TIMESTAMP */
156329 testcase( i==111 ); /* CURRENT_TIME */
156330 testcase( i==112 ); /* CURRENT */
156331 testcase( i==113 ); /* PARTITION */
156332 testcase( i==114 ); /* DROP */
156333 testcase( i==115 ); /* PRECEDING */
156334 testcase( i==116 ); /* FAIL */
156335 testcase( i==117 ); /* LAST */
156336 testcase( i==118 ); /* FILTER */
156337 testcase( i==119 ); /* REPLACE */
156338 testcase( i==120 ); /* FIRST */
156339 testcase( i==121 ); /* FOLLOWING */
156340 testcase( i==122 ); /* FROM */
156341 testcase( i==123 ); /* FULL */
156342 testcase( i==124 ); /* LIMIT */
156343 testcase( i==125 ); /* IF */
156344 testcase( i==126 ); /* ORDER */
156345 testcase( i==127 ); /* RESTRICT */
156346 testcase( i==128 ); /* OTHERS */
156347 testcase( i==129 ); /* OVER */
156348 testcase( i==130 ); /* RIGHT */
156349 testcase( i==131 ); /* ROLLBACK */
156350 testcase( i==132 ); /* ROWS */
156351 testcase( i==133 ); /* ROW */
156352 testcase( i==134 ); /* UNBOUNDED */
156353 testcase( i==135 ); /* UNION */
156354 testcase( i==136 ); /* USING */
156355 testcase( i==137 ); /* VACUUM */
156356 testcase( i==138 ); /* VIEW */
156357 testcase( i==139 ); /* WINDOW */
156358 testcase( i==140 ); /* DO */
156359 testcase( i==141 ); /* BY */
156360 testcase( i==142 ); /* INITIALLY */
156361 testcase( i==143 ); /* ALL */
156362 testcase( i==144 ); /* PRIMARY */
156363 *pType = aKWCode[i];
156364 break;
156365 }
156366 }
156367 return n;
@@ -155093,11 +156369,11 @@
156369 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
156370 int id = TK_ID;
156371 keywordCode((char*)z, n, &id);
156372 return id;
156373 }
156374 #define SQLITE_N_KEYWORD 145
156375 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
156376 if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
156377 *pzName = zKWText + aKWOffset[i];
156378 *pnName = aKWLen[i];
156379 return SQLITE_OK;
@@ -155720,11 +156996,11 @@
156996 int tokenType; /* type of current token */
156997 int prevType = 0; /* Previous non-whitespace token */
156998 int nParen; /* Number of nested levels of parentheses */
156999 int iStartIN; /* Start of RHS of IN operator in z[] */
157000 int nParenAtIN; /* Value of nParent at start of RHS of IN operator */
157001 u32 j; /* Bytes of normalized SQL generated so far */
157002 sqlite3_str *pStr; /* The normalized SQL string under construction */
157003
157004 db = sqlite3VdbeDb(pVdbe);
157005 tokenType = -1;
157006 nParen = iStartIN = nParenAtIN = 0;
@@ -155764,11 +157040,11 @@
157040 sqlite3_str_append(pStr, "(", 1);
157041 break;
157042 }
157043 case TK_RP: {
157044 if( iStartIN>0 && nParen==nParenAtIN ){
157045 assert( pStr->nChar>=(u32)iStartIN );
157046 pStr->nChar = iStartIN+1;
157047 sqlite3_str_append(pStr, "?,?,?", 5);
157048 iStartIN = 0;
157049 }
157050 nParen--;
@@ -156933,10 +158209,11 @@
158209 }
158210 db->lookaside.pStart = pStart;
158211 db->lookaside.pInit = 0;
158212 db->lookaside.pFree = 0;
158213 db->lookaside.sz = (u16)sz;
158214 db->lookaside.szTrue = (u16)sz;
158215 if( pStart ){
158216 int i;
158217 LookasideSlot *p;
158218 assert( sz > (int)sizeof(LookasideSlot*) );
158219 db->lookaside.nSlot = cnt;
@@ -156951,10 +158228,11 @@
158228 db->lookaside.bMalloced = pBuf==0 ?1:0;
158229 }else{
158230 db->lookaside.pStart = db;
158231 db->lookaside.pEnd = db;
158232 db->lookaside.bDisable = 1;
158233 db->lookaside.sz = 0;
158234 db->lookaside.bMalloced = 0;
158235 db->lookaside.nSlot = 0;
158236 }
158237 #endif /* SQLITE_OMIT_LOOKASIDE */
158238 return SQLITE_OK;
@@ -157067,10 +158345,11 @@
158345 { SQLITE_DBCONFIG_WRITABLE_SCHEMA, SQLITE_WriteSchema|
158346 SQLITE_NoSchemaError },
158347 { SQLITE_DBCONFIG_LEGACY_ALTER_TABLE, SQLITE_LegacyAlter },
158348 { SQLITE_DBCONFIG_DQS_DDL, SQLITE_DqsDDL },
158349 { SQLITE_DBCONFIG_DQS_DML, SQLITE_DqsDML },
158350 { SQLITE_DBCONFIG_LEGACY_FILE_FORMAT, SQLITE_LegacyFileFmt },
158351 };
158352 unsigned int i;
158353 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
158354 for(i=0; i<ArraySize(aFlagOp); i++){
158355 if( aFlagOp[i].op==op ){
@@ -157605,10 +158884,11 @@
158884 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
158885 case SQLITE_CANTOPEN_NOTEMPDIR: zName = "SQLITE_CANTOPEN_NOTEMPDIR";break;
158886 case SQLITE_CANTOPEN_ISDIR: zName = "SQLITE_CANTOPEN_ISDIR"; break;
158887 case SQLITE_CANTOPEN_FULLPATH: zName = "SQLITE_CANTOPEN_FULLPATH"; break;
158888 case SQLITE_CANTOPEN_CONVPATH: zName = "SQLITE_CANTOPEN_CONVPATH"; break;
158889 case SQLITE_CANTOPEN_SYMLINK: zName = "SQLITE_CANTOPEN_SYMLINK"; break;
158890 case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break;
158891 case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break;
158892 case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break;
158893 case SQLITE_TOOBIG: zName = "SQLITE_TOOBIG"; break;
158894 case SQLITE_CONSTRAINT: zName = "SQLITE_CONSTRAINT"; break;
@@ -159282,10 +160562,11 @@
160562 db->errMask = 0xff;
160563 db->nDb = 2;
160564 db->magic = SQLITE_MAGIC_BUSY;
160565 db->aDb = db->aDbStatic;
160566 db->lookaside.bDisable = 1;
160567 db->lookaside.sz = 0;
160568
160569 assert( sizeof(db->aLimit)==sizeof(aHardLimit) );
160570 memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
160571 db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS;
160572 db->autoCommit = 1;
@@ -160401,10 +161682,29 @@
161682 va_end(ap);
161683 #endif /* SQLITE_UNTESTABLE */
161684 return rc;
161685 }
161686
161687 #ifdef SQLITE_DEBUG
161688 /*
161689 ** This routine appears inside assert() statements only.
161690 **
161691 ** Return the number of URI parameters that follow the filename.
161692 */
161693 SQLITE_PRIVATE int sqlite3UriCount(const char *z){
161694 int n = 0;
161695 if( z==0 ) return 0;
161696 z += strlen(z)+1;
161697 while( z[0] ){
161698 z += strlen(z)+1;
161699 z += strlen(z)+1;
161700 n++;
161701 }
161702 return n;
161703 }
161704 #endif /* SQLITE_DEBUG */
161705
161706 /*
161707 ** This is a utility routine, useful to VFS implementations, that checks
161708 ** to see if a database file was a URI that contained a specific query
161709 ** parameter, and if so obtains the value of the query parameter.
161710 **
@@ -161883,16 +163183,26 @@
163183 */
163184 int inTransaction; /* True after xBegin but before xCommit/xRollback */
163185 int mxSavepoint; /* Largest valid xSavepoint integer */
163186 #endif
163187
163188 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
163189 /* True to disable the incremental doclist optimization. This is controled
163190 ** by special insert command 'test-no-incr-doclist'. */
163191 int bNoIncrDoclist;
163192
163193 /* Number of segments in a level */
163194 int nMergeCount;
163195 #endif
163196 };
163197
163198 /* Macro to find the number of segments to merge */
163199 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
163200 # define MergeCount(P) ((P)->nMergeCount)
163201 #else
163202 # define MergeCount(P) FTS3_MERGE_COUNT
163203 #endif
163204
163205 /*
163206 ** When the core wants to read from the virtual table, it creates a
163207 ** virtual table cursor (an instance of the following structure) using
163208 ** the xOpen method. Cursors are destroyed using the xClose method.
@@ -162153,10 +163463,11 @@
163463
163464 /* fts3.c */
163465 SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...);
163466 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
163467 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
163468 SQLITE_PRIVATE int sqlite3Fts3GetVarintBounded(const char*,const char*,sqlite3_int64*);
163469 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
163470 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
163471 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
163472 SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
163473 SQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);
@@ -162315,10 +163626,36 @@
163626 GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *v, 4);
163627 b = (a & 0x0FFFFFFF );
163628
163629 for(shift=28; shift<=63; shift+=7){
163630 u64 c = *p++;
163631 b += (c&0x7F) << shift;
163632 if( (c & 0x80)==0 ) break;
163633 }
163634 *v = b;
163635 return (int)(p - pStart);
163636 }
163637
163638 /*
163639 ** Read a 64-bit variable-length integer from memory starting at p[0] and
163640 ** not extending past pEnd[-1].
163641 ** Return the number of bytes read, or 0 on error.
163642 ** The value is stored in *v.
163643 */
163644 SQLITE_PRIVATE int sqlite3Fts3GetVarintBounded(
163645 const char *pBuf,
163646 const char *pEnd,
163647 sqlite_int64 *v
163648 ){
163649 const unsigned char *p = (const unsigned char*)pBuf;
163650 const unsigned char *pStart = p;
163651 const unsigned char *pX = (const unsigned char*)pEnd;
163652 u64 b = 0;
163653 int shift;
163654 for(shift=0; shift<=63; shift+=7){
163655 u64 c = p<pX ? *p : 0;
163656 p++;
163657 b += (c&0x7F) << shift;
163658 if( (c & 0x80)==0 ) break;
163659 }
163660 *v = b;
163661 return (int)(p - pStart);
@@ -163416,10 +164753,14 @@
164753
164754 /* Figure out the page-size for the database. This is required in order to
164755 ** estimate the cost of loading large doclists from the database. */
164756 fts3DatabasePageSize(&rc, p);
164757 p->nNodeSize = p->nPgsz-35;
164758
164759 #if defined(SQLITE_DEBUG)||defined(SQLITE_TEST)
164760 p->nMergeCount = FTS3_MERGE_COUNT;
164761 #endif
164762
164763 /* Declare the table schema to SQLite. */
164764 fts3DeclareVtab(&rc, p);
164765
164766 fts3_init_out:
@@ -163924,11 +165265,17 @@
165265
165266 if( rc==SQLITE_OK ){
165267 rc = sqlite3Fts3ReadBlock(p, piLeaf?*piLeaf:*piLeaf2, &zBlob, &nBlob, 0);
165268 }
165269 if( rc==SQLITE_OK ){
165270 int iNewHeight = 0;
165271 fts3GetVarint32(zBlob, &iNewHeight);
165272 if( iNewHeight>=iHeight ){
165273 rc = FTS_CORRUPT_VTAB;
165274 }else{
165275 rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, piLeaf2);
165276 }
165277 }
165278 sqlite3_free(zBlob);
165279 }
165280
165281 return rc;
@@ -164411,19 +165758,20 @@
165758 int bDescIdx, /* True for descending docids */
165759 sqlite3_int64 *piPrev, /* IN/OUT: Previous value written to list */
165760 int *pbFirst, /* IN/OUT: True after first int written */
165761 sqlite3_int64 iVal /* Write this value to the list */
165762 ){
165763 sqlite3_uint64 iWrite;
165764 if( bDescIdx==0 || *pbFirst==0 ){
165765 assert_fts3_nc( *pbFirst==0 || iVal>=*piPrev );
165766 iWrite = iVal - *piPrev;
165767 }else{
165768 assert_fts3_nc( *piPrev>=iVal );
165769 iWrite = *piPrev - iVal;
165770 }
165771 assert( *pbFirst || *piPrev==0 );
165772 assert_fts3_nc( *pbFirst==0 || iWrite>0 );
 
165773 *pp += sqlite3Fts3PutVarint(*pp, iWrite);
165774 *piPrev = iVal;
165775 *pbFirst = 1;
165776 }
165777
@@ -166267,11 +167615,11 @@
167615 ** tokens or prefix tokens that cannot use a prefix-index. */
167616 int bHaveIncr = 0;
167617 int bIncrOk = (bOptOk
167618 && pCsr->bDesc==pTab->bDescIdx
167619 && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0
167620 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
167621 && pTab->bNoIncrDoclist==0
167622 #endif
167623 );
167624 for(i=0; bIncrOk==1 && i<p->nToken; i++){
167625 Fts3PhraseToken *pToken = &p->aToken[i];
@@ -166789,16 +168137,17 @@
168137 const char *a;
168138
168139 rc = sqlite3Fts3SelectDoctotal(p, &pStmt);
168140 if( rc!=SQLITE_OK ) return rc;
168141 a = sqlite3_column_blob(pStmt, 0);
168142 testcase( a==0 ); /* If %_stat.value set to X'' */
168143 if( a ){
168144 pEnd = &a[sqlite3_column_bytes(pStmt, 0)];
168145 a += sqlite3Fts3GetVarintBounded(a, pEnd, &nDoc);
168146 while( a<pEnd ){
168147 a += sqlite3Fts3GetVarintBounded(a, pEnd, &nByte);
168148 }
168149 }
168150 if( nDoc==0 || nByte==0 ){
168151 sqlite3_reset(pStmt);
168152 return FTS_CORRUPT_VTAB;
168153 }
@@ -171232,11 +172581,13 @@
172581 return rc;
172582 }
172583
172584 sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);
172585 if( SQLITE_ROW==sqlite3_step(pStmt) ){
172586 if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB
172587 && sqlite3_column_bytes(pStmt, 0)==sizeof(*pp)
172588 ){
172589 memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));
172590 }
172591 }
172592
172593 return sqlite3_finalize(pStmt);
@@ -172081,11 +173432,11 @@
173432 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
173433
173434 /* #include <string.h> */
173435 /* #include <assert.h> */
173436 /* #include <stdlib.h> */
173437 /* #include <stdio.h> */
173438
173439 #define FTS_MAX_APPENDABLE_HEIGHT 16
173440
173441 /*
173442 ** When full-text index nodes are loaded from disk, the buffer that they
@@ -172125,11 +173476,11 @@
173476 # define FTS3_NODE_CHUNKSIZE (4*1024)
173477 # define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)
173478 #endif
173479
173480 /*
173481 ** The values that may be meaningfully bound to the :1 parameter in
173482 ** statements SQL_REPLACE_STAT and SQL_SELECT_STAT.
173483 */
173484 #define FTS_STAT_DOCTOTAL 0
173485 #define FTS_STAT_INCRMERGEHINT 1
173486 #define FTS_STAT_AUTOINCRMERGE 2
@@ -173211,11 +174562,11 @@
174562 /* If iNext is FTS3_MERGE_COUNT, indicating that level iLevel is already
174563 ** full, merge all segments in level iLevel into a single iLevel+1
174564 ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,
174565 ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.
174566 */
174567 if( iNext>=MergeCount(p) ){
174568 fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel));
174569 rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);
174570 *piIdx = 0;
174571 }else{
174572 *piIdx = iNext;
@@ -173437,11 +174788,11 @@
174788 ** safe (no risk of overread) even if the node data is corrupted. */
174789 pNext += fts3GetVarint32(pNext, &nPrefix);
174790 pNext += fts3GetVarint32(pNext, &nSuffix);
174791 if( nSuffix<=0
174792 || (&pReader->aNode[pReader->nNode] - pNext)<nSuffix
174793 || nPrefix>pReader->nTerm
174794 ){
174795 return FTS_CORRUPT_VTAB;
174796 }
174797
174798 /* Both nPrefix and nSuffix were read by fts3GetVarint32() and so are
@@ -174087,10 +175438,15 @@
175438 int nPrefix; /* Number of bytes of prefix compression */
175439 int nSuffix; /* Suffix length */
175440
175441 nPrefix = fts3PrefixCompress(pTree->zTerm, pTree->nTerm, zTerm, nTerm);
175442 nSuffix = nTerm-nPrefix;
175443
175444 /* If nSuffix is zero or less, then zTerm/nTerm must be a prefix of
175445 ** pWriter->zTerm/pWriter->nTerm. i.e. must be equal to or less than when
175446 ** compared with BINARY collation. This indicates corruption. */
175447 if( nSuffix<=0 ) return FTS_CORRUPT_VTAB;
175448
175449 nReq += sqlite3Fts3VarintLen(nPrefix)+sqlite3Fts3VarintLen(nSuffix)+nSuffix;
175450 if( nReq<=p->nNodeSize || !pTree->zTerm ){
175451
175452 if( nReq>p->nNodeSize ){
@@ -174381,13 +175737,15 @@
175737 assert( nData+nReq<=pWriter->nSize );
175738
175739 /* Append the prefix-compressed term and doclist to the buffer. */
175740 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nPrefix);
175741 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nSuffix);
175742 assert( nSuffix>0 );
175743 memcpy(&pWriter->aData[nData], &zTerm[nPrefix], nSuffix);
175744 nData += nSuffix;
175745 nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nDoclist);
175746 assert( nDoclist>0 );
175747 memcpy(&pWriter->aData[nData], aDoclist, nDoclist);
175748 pWriter->nData = nData + nDoclist;
175749
175750 /* Save the current term so that it can be used to prefix-compress the next.
175751 ** If the isCopyTerm parameter is true, then the buffer pointed to by
@@ -174403,10 +175761,11 @@
175761 pWriter->nMalloc = nTerm*2;
175762 pWriter->zMalloc = zNew;
175763 pWriter->zTerm = zNew;
175764 }
175765 assert( pWriter->zTerm==pWriter->zMalloc );
175766 assert( nTerm>0 );
175767 memcpy(pWriter->zTerm, zTerm, nTerm);
175768 }else{
175769 pWriter->zTerm = (char *)zTerm;
175770 }
175771 pWriter->nTerm = nTerm;
@@ -174711,10 +176070,11 @@
176070 pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer);
176071 if( !pNew ) return SQLITE_NOMEM;
176072 pMsr->aBuffer = pNew;
176073 }
176074
176075 assert( nList>0 );
176076 memcpy(pMsr->aBuffer, pList, nList);
176077 return SQLITE_OK;
176078 }
176079
176080 SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
@@ -175024,18 +176384,16 @@
176384
176385 /* Calculate the 'docid' delta value to write into the merged
176386 ** doclist. */
176387 sqlite3_int64 iDelta;
176388 if( p->bDescIdx && nDoclist>0 ){
176389 if( iPrev<=iDocid ) return FTS_CORRUPT_VTAB;
176390 iDelta = iPrev - iDocid;
176391 }else{
176392 if( nDoclist>0 && iPrev>=iDocid ) return FTS_CORRUPT_VTAB;
176393 iDelta = iDocid - iPrev;
176394 }
 
 
 
 
176395
176396 nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
176397 if( nDoclist+nByte>pCsr->nBuffer ){
176398 char *aNew;
176399 pCsr->nBuffer = (nDoclist+nByte)*2;
@@ -175540,11 +176898,14 @@
176898 static int fts3DoOptimize(Fts3Table *p, int bReturnDone){
176899 int bSeenDone = 0;
176900 int rc;
176901 sqlite3_stmt *pAllLangid = 0;
176902
176903 rc = sqlite3Fts3PendingTermsFlush(p);
176904 if( rc==SQLITE_OK ){
176905 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
176906 }
176907 if( rc==SQLITE_OK ){
176908 int rc2;
176909 sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);
176910 sqlite3_bind_int(pAllLangid, 2, p->nIndex);
176911 while( sqlite3_step(pAllLangid)==SQLITE_ROW ){
@@ -175561,11 +176922,10 @@
176922 rc2 = sqlite3_reset(pAllLangid);
176923 if( rc==SQLITE_OK ) rc = rc2;
176924 }
176925
176926 sqlite3Fts3SegmentsClose(p);
 
176927
176928 return (rc==SQLITE_OK && bReturnDone && bSeenDone) ? SQLITE_DONE : rc;
176929 }
176930
176931 /*
@@ -175899,10 +177259,11 @@
177259 ** the current node of layer iLayer. Due to the prefix compression,
177260 ** the space required changes depending on which node the key is to
177261 ** be added to. */
177262 nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);
177263 nSuffix = nTerm - nPrefix;
177264 if(nSuffix<=0 ) return FTS_CORRUPT_VTAB;
177265 nSpace = sqlite3Fts3VarintLen(nPrefix);
177266 nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
177267
177268 if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){
177269 /* If the current node of layer iLayer contains zero keys, or if adding
@@ -176293,10 +177654,14 @@
177654 pWriter->nLeafData = pWriter->nLeafData * -1;
177655 }
177656 pWriter->bNoLeafData = (pWriter->nLeafData==0);
177657 nRoot = sqlite3_column_bytes(pSelect, 4);
177658 aRoot = sqlite3_column_blob(pSelect, 4);
177659 if( aRoot==0 ){
177660 sqlite3_reset(pSelect);
177661 return nRoot ? SQLITE_NOMEM : FTS_CORRUPT_VTAB;
177662 }
177663 }else{
177664 return sqlite3_reset(pSelect);
177665 }
177666
177667 /* Check for the zero-length marker in the %_segments table */
@@ -176328,10 +177693,14 @@
177693 /* It is possible to append to this segment. Set up the IncrmergeWriter
177694 ** object to do so. */
177695 int i;
177696 int nHeight = (int)aRoot[0];
177697 NodeWriter *pNode;
177698 if( nHeight<1 || nHeight>FTS_MAX_APPENDABLE_HEIGHT ){
177699 sqlite3_reset(pSelect);
177700 return FTS_CORRUPT_VTAB;
177701 }
177702
177703 pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;
177704 pWriter->iStart = iStart;
177705 pWriter->iEnd = iEnd;
177706 pWriter->iAbsLevel = iAbsLevel;
@@ -177006,12 +178375,19 @@
178375 if( rc==SQLITE_OK ){
178376 rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);
178377 }
178378 if( SQLITE_OK==rc && pCsr->nSegment==nSeg
178379 && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))
 
178380 ){
178381 int bEmpty = 0;
178382 rc = sqlite3Fts3SegReaderStep(p, pCsr);
178383 if( rc==SQLITE_OK ){
178384 bEmpty = 1;
178385 }else if( rc!=SQLITE_ROW ){
178386 sqlite3Fts3SegReaderFinish(pCsr);
178387 break;
178388 }
178389 if( bUseHint && iIdx>0 ){
178390 const char *zKey = pCsr->zTerm;
178391 int nKey = pCsr->nTerm;
178392 rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);
178393 }else{
@@ -177018,15 +178394,17 @@
178394 rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);
178395 }
178396
178397 if( rc==SQLITE_OK && pWriter->nLeafEst ){
178398 fts3LogMerge(nSeg, iAbsLevel);
178399 if( bEmpty==0 ){
178400 do {
178401 rc = fts3IncrmergeAppend(p, pWriter, pCsr);
178402 if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);
178403 if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;
178404 }while( rc==SQLITE_ROW );
178405 }
178406
178407 /* Update or delete the input segments */
178408 if( rc==SQLITE_OK ){
178409 nRem -= (1 + pWriter->nWork);
178410 rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);
@@ -177087,11 +178465,11 @@
178465 static int fts3DoIncrmerge(
178466 Fts3Table *p, /* FTS3 table handle */
178467 const char *zParam /* Nul-terminated string containing "A,B" */
178468 ){
178469 int rc;
178470 int nMin = (MergeCount(p) / 2);
178471 int nMerge = 0;
178472 const char *z = zParam;
178473
178474 /* Read the first integer value */
178475 nMerge = fts3Getint(&z);
@@ -177132,11 +178510,11 @@
178510 const char *zParam /* Nul-terminated string containing boolean */
178511 ){
178512 int rc = SQLITE_OK;
178513 sqlite3_stmt *pStmt = 0;
178514 p->nAutoincrmerge = fts3Getint(&zParam);
178515 if( p->nAutoincrmerge==1 || p->nAutoincrmerge>MergeCount(p) ){
178516 p->nAutoincrmerge = 8;
178517 }
178518 if( !p->bHasStat ){
178519 assert( p->bFts4==0 );
178520 sqlite3Fts3CreateStatTable(&rc, p);
@@ -177229,11 +178607,15 @@
178607 iPos = 0;
178608 if( iVal ){
178609 pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
178610 }else{
178611 pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
178612 if( p->bDescIdx ){
178613 iDocid -= iVal;
178614 }else{
178615 iDocid += iVal;
178616 }
178617 }
178618 }else{
178619 iPos += (iVal - 2);
178620 cksum = cksum ^ fts3ChecksumEntry(
178621 csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid,
@@ -177302,14 +178684,13 @@
178684 int iCol;
178685
178686 for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
178687 if( p->abNotindexed[iCol]==0 ){
178688 const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
 
178689 sqlite3_tokenizer_cursor *pT = 0;
178690
178691 rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, -1, &pT);
178692 while( rc==SQLITE_OK ){
178693 char const *zToken; /* Buffer containing token */
178694 int nToken = 0; /* Number of bytes in token */
178695 int iDum1 = 0, iDum2 = 0; /* Dummy variables */
178696 int iPos = 0; /* Position of token in zText */
@@ -177390,11 +178771,11 @@
178771 **
178772 ** Argument pVal contains the result of <expr>. Currently the only
178773 ** meaningful value to insert is the text 'optimize'.
178774 */
178775 static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){
178776 int rc = SQLITE_ERROR; /* Return Code */
178777 const char *zVal = (const char *)sqlite3_value_text(pVal);
178778 int nVal = sqlite3_value_bytes(pVal);
178779
178780 if( !zVal ){
178781 return SQLITE_NOMEM;
@@ -177406,25 +178787,31 @@
178787 rc = fts3DoIntegrityCheck(p);
178788 }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, "merge=", 6) ){
178789 rc = fts3DoIncrmerge(p, &zVal[6]);
178790 }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){
178791 rc = fts3DoAutoincrmerge(p, &zVal[10]);
178792 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
178793 }else{
178794 int v;
178795 if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
178796 v = atoi(&zVal[9]);
178797 if( v>=24 && v<=p->nPgsz-35 ) p->nNodeSize = v;
178798 rc = SQLITE_OK;
178799 }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
178800 v = atoi(&zVal[11]);
178801 if( v>=64 && v<=FTS3_MAX_PENDING_DATA ) p->nMaxPendingData = v;
178802 rc = SQLITE_OK;
178803 }else if( nVal>21 && 0==sqlite3_strnicmp(zVal,"test-no-incr-doclist=",21) ){
178804 p->bNoIncrDoclist = atoi(&zVal[21]);
178805 rc = SQLITE_OK;
178806 }else if( nVal>11 && 0==sqlite3_strnicmp(zVal,"mergecount=",11) ){
178807 v = atoi(&zVal[11]);
178808 if( v>=4 && v<=FTS3_MERGE_COUNT && (v&1)==0 ) p->nMergeCount = v;
178809 rc = SQLITE_OK;
178810 }
178811 #endif
 
 
178812 }
 
178813 return rc;
178814 }
178815
178816 #ifndef SQLITE_DISABLE_FTS4_DEFERRED
178817 /*
@@ -178825,29 +180212,41 @@
180212
180213 static int fts3MatchinfoSelectDoctotal(
180214 Fts3Table *pTab,
180215 sqlite3_stmt **ppStmt,
180216 sqlite3_int64 *pnDoc,
180217 const char **paLen,
180218 const char **ppEnd
180219 ){
180220 sqlite3_stmt *pStmt;
180221 const char *a;
180222 const char *pEnd;
180223 sqlite3_int64 nDoc;
180224 int n;
180225
180226
180227 if( !*ppStmt ){
180228 int rc = sqlite3Fts3SelectDoctotal(pTab, ppStmt);
180229 if( rc!=SQLITE_OK ) return rc;
180230 }
180231 pStmt = *ppStmt;
180232 assert( sqlite3_data_count(pStmt)==1 );
180233
180234 n = sqlite3_column_bytes(pStmt, 0);
180235 a = sqlite3_column_blob(pStmt, 0);
180236 if( a==0 ){
180237 return FTS_CORRUPT_VTAB;
180238 }
180239 pEnd = a + n;
180240 a += sqlite3Fts3GetVarintBounded(a, pEnd, &nDoc);
180241 if( nDoc<=0 || a>pEnd ){
180242 return FTS_CORRUPT_VTAB;
180243 }
180244 *pnDoc = nDoc;
180245
180246 if( paLen ) *paLen = a;
180247 if( ppEnd ) *ppEnd = pEnd;
180248 return SQLITE_OK;
180249 }
180250
180251 /*
180252 ** An instance of the following structure is used to store state while
@@ -179024,27 +180423,32 @@
180423 break;
180424
180425 case FTS3_MATCHINFO_NDOC:
180426 if( bGlobal ){
180427 sqlite3_int64 nDoc = 0;
180428 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0, 0);
180429 pInfo->aMatchinfo[0] = (u32)nDoc;
180430 }
180431 break;
180432
180433 case FTS3_MATCHINFO_AVGLENGTH:
180434 if( bGlobal ){
180435 sqlite3_int64 nDoc; /* Number of rows in table */
180436 const char *a; /* Aggregate column length array */
180437 const char *pEnd; /* First byte past end of length array */
180438
180439 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, &a, &pEnd);
180440 if( rc==SQLITE_OK ){
180441 int iCol;
180442 for(iCol=0; iCol<pInfo->nCol; iCol++){
180443 u32 iVal;
180444 sqlite3_int64 nToken;
180445 a += sqlite3Fts3GetVarint(a, &nToken);
180446 if( a>pEnd ){
180447 rc = SQLITE_CORRUPT_VTAB;
180448 break;
180449 }
180450 iVal = (u32)(((u32)(nToken&0xffffffff)+nDoc/2)/nDoc);
180451 pInfo->aMatchinfo[iCol] = iVal;
180452 }
180453 }
180454 }
@@ -179054,13 +180458,18 @@
180458 sqlite3_stmt *pSelectDocsize = 0;
180459 rc = sqlite3Fts3SelectDocsize(pTab, pCsr->iPrevId, &pSelectDocsize);
180460 if( rc==SQLITE_OK ){
180461 int iCol;
180462 const char *a = sqlite3_column_blob(pSelectDocsize, 0);
180463 const char *pEnd = a + sqlite3_column_bytes(pSelectDocsize, 0);
180464 for(iCol=0; iCol<pInfo->nCol; iCol++){
180465 sqlite3_int64 nToken;
180466 a += sqlite3Fts3GetVarintBounded(a, pEnd, &nToken);
180467 if( a>pEnd ){
180468 rc = SQLITE_CORRUPT_VTAB;
180469 break;
180470 }
180471 pInfo->aMatchinfo[iCol] = (u32)nToken;
180472 }
180473 }
180474 sqlite3_reset(pSelectDocsize);
180475 break;
@@ -179087,11 +180496,11 @@
180496 pExpr = pCsr->pExpr;
180497 rc = fts3ExprLoadDoclists(pCsr, 0, 0);
180498 if( rc!=SQLITE_OK ) break;
180499 if( bGlobal ){
180500 if( pCsr->pDeferred ){
180501 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc,0,0);
180502 if( rc!=SQLITE_OK ) break;
180503 }
180504 rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
180505 sqlite3Fts3EvalTestDeferred(pCsr, &rc);
180506 if( rc!=SQLITE_OK ) break;
@@ -180822,10 +182231,41 @@
182231 jsonInit(&s, pCtx);
182232 jsonRenderNode(pNode, &s, aReplace);
182233 jsonResult(&s);
182234 sqlite3_result_subtype(pCtx, JSON_SUBTYPE);
182235 }
182236
182237 /*
182238 ** Translate a single byte of Hex into an integer.
182239 ** This routine only works if h really is a valid hexadecimal
182240 ** character: 0..9a..fA..F
182241 */
182242 static u8 jsonHexToInt(int h){
182243 assert( (h>='0' && h<='9') || (h>='a' && h<='f') || (h>='A' && h<='F') );
182244 #ifdef SQLITE_EBCDIC
182245 h += 9*(1&~(h>>4));
182246 #else
182247 h += 9*(1&(h>>6));
182248 #endif
182249 return (u8)(h & 0xf);
182250 }
182251
182252 /*
182253 ** Convert a 4-byte hex string into an integer
182254 */
182255 static u32 jsonHexToInt4(const char *z){
182256 u32 v;
182257 assert( safe_isxdigit(z[0]) );
182258 assert( safe_isxdigit(z[1]) );
182259 assert( safe_isxdigit(z[2]) );
182260 assert( safe_isxdigit(z[3]) );
182261 v = (jsonHexToInt(z[0])<<12)
182262 + (jsonHexToInt(z[1])<<8)
182263 + (jsonHexToInt(z[2])<<4)
182264 + jsonHexToInt(z[3]);
182265 return v;
182266 }
182267
182268 /*
182269 ** Make the JsonNode the return value of the function.
182270 */
182271 static void jsonReturn(
@@ -180916,29 +182356,38 @@
182356 if( c!='\\' ){
182357 zOut[j++] = c;
182358 }else{
182359 c = z[++i];
182360 if( c=='u' ){
182361 u32 v = jsonHexToInt4(z+i+1);
182362 i += 4;
 
 
 
 
 
 
 
182363 if( v==0 ) break;
182364 if( v<=0x7f ){
182365 zOut[j++] = (char)v;
182366 }else if( v<=0x7ff ){
182367 zOut[j++] = (char)(0xc0 | (v>>6));
182368 zOut[j++] = 0x80 | (v&0x3f);
182369 }else{
182370 u32 vlo;
182371 if( (v&0xfc00)==0xd800
182372 && i<n-6
182373 && z[i+1]=='\\'
182374 && z[i+2]=='u'
182375 && ((vlo = jsonHexToInt4(z+i+3))&0xfc00)==0xdc00
182376 ){
182377 /* We have a surrogate pair */
182378 v = ((v&0x3ff)<<10) + (vlo&0x3ff) + 0x10000;
182379 i += 6;
182380 zOut[j++] = 0xf0 | (v>>18);
182381 zOut[j++] = 0x80 | ((v>>12)&0x3f);
182382 zOut[j++] = 0x80 | ((v>>6)&0x3f);
182383 zOut[j++] = 0x80 | (v&0x3f);
182384 }else{
182385 zOut[j++] = 0xe0 | (v>>12);
182386 zOut[j++] = 0x80 | ((v>>6)&0x3f);
182387 zOut[j++] = 0x80 | (v&0x3f);
182388 }
182389 }
182390 }else{
182391 if( c=='b' ){
182392 c = '\b';
182393 }else if( c=='f' ){
@@ -195928,11 +197377,11 @@
197377 **
197378 ******************************************************************************
197379 **
197380 ** This file contains an implementation of the "dbstat" virtual table.
197381 **
197382 ** The dbstat virtual table is used to extract low-level storage
197383 ** information from an SQLite database in order to implement the
197384 ** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script
197385 ** for an example implementation.
197386 **
197387 ** Additional information is available on the "dbstat.html" page of the
@@ -195972,90 +197421,98 @@
197421 ** the overflow pages associated with a cell will appear earlier in the
197422 ** sort-order than its child page:
197423 **
197424 ** '/1c2/000/' // Left-most child of 451st child of root
197425 */
197426 static const char zDbstatSchema[] =
197427 "CREATE TABLE x("
197428 " name TEXT," /* 0 Name of table or index */
197429 " path TEXT," /* 1 Path to page from root (NULL for agg) */
197430 " pageno INTEGER," /* 2 Page number (page count for aggregates) */
197431 " pagetype TEXT," /* 3 'internal', 'leaf', 'overflow', or NULL */
197432 " ncell INTEGER," /* 4 Cells on page (0 for overflow) */
197433 " payload INTEGER," /* 5 Bytes of payload on this page */
197434 " unused INTEGER," /* 6 Bytes of unused space on this page */
197435 " mx_payload INTEGER," /* 7 Largest payload size of all cells */
197436 " pgoffset INTEGER," /* 8 Offset of page in file (NULL for agg) */
197437 " pgsize INTEGER," /* 9 Size of the page (sum for aggregate) */
197438 " schema TEXT HIDDEN," /* 10 Database schema being analyzed */
197439 " aggregate BOOLEAN HIDDEN" /* 11 aggregate info for each table */
197440 ")"
197441 ;
197442
197443 /* Forward reference to data structured used in this module */
197444 typedef struct StatTable StatTable;
197445 typedef struct StatCursor StatCursor;
197446 typedef struct StatPage StatPage;
197447 typedef struct StatCell StatCell;
197448
197449 /* Size information for a single cell within a btree page */
197450 struct StatCell {
197451 int nLocal; /* Bytes of local payload */
197452 u32 iChildPg; /* Child node (or 0 if this is a leaf) */
197453 int nOvfl; /* Entries in aOvfl[] */
197454 u32 *aOvfl; /* Array of overflow page numbers */
197455 int nLastOvfl; /* Bytes of payload on final overflow page */
197456 int iOvfl; /* Iterates through aOvfl[] */
197457 };
197458
197459 /* Size information for a single btree page */
197460 struct StatPage {
197461 u32 iPgno; /* Page number */
197462 DbPage *pPg; /* Page content */
197463 int iCell; /* Current cell */
197464
197465 char *zPath; /* Path to this page */
197466
197467 /* Variables populated by statDecodePage(): */
197468 u8 flags; /* Copy of flags byte */
197469 int nCell; /* Number of cells on page */
197470 int nUnused; /* Number of unused bytes on page */
197471 StatCell *aCell; /* Array of parsed cells */
197472 u32 iRightChildPg; /* Right-child page number (or 0) */
197473 int nMxPayload; /* Largest payload of any cell on the page */
197474 };
197475
197476 /* The cursor for scanning the dbstat virtual table */
197477 struct StatCursor {
197478 sqlite3_vtab_cursor base; /* base class. MUST BE FIRST! */
197479 sqlite3_stmt *pStmt; /* Iterates through set of root pages */
197480 u8 isEof; /* After pStmt has returned SQLITE_DONE */
197481 u8 isAgg; /* Aggregate results for each table */
197482 int iDb; /* Schema used for this query */
197483
197484 StatPage aPage[32]; /* Pages in path to current page */
197485 int iPage; /* Current entry in aPage[] */
197486
197487 /* Values to return. */
197488 u32 iPageno; /* Value of 'pageno' column */
197489 char *zName; /* Value of 'name' column */
197490 char *zPath; /* Value of 'path' column */
 
197491 char *zPagetype; /* Value of 'pagetype' column */
197492 int nPage; /* Number of pages in current btree */
197493 int nCell; /* Value of 'ncell' column */
 
 
197494 int nMxPayload; /* Value of 'mx_payload' column */
197495 i64 nUnused; /* Value of 'unused' column */
197496 i64 nPayload; /* Value of 'payload' column */
197497 i64 iOffset; /* Value of 'pgOffset' column */
197498 i64 szPage; /* Value of 'pgSize' column */
197499 };
197500
197501 /* An instance of the DBSTAT virtual table */
197502 struct StatTable {
197503 sqlite3_vtab base; /* base class. MUST BE FIRST! */
197504 sqlite3 *db; /* Database connection that owns this vtab */
197505 int iDb; /* Index of database to analyze */
197506 };
197507
197508 #ifndef get2byte
197509 # define get2byte(x) ((x)[0]<<8 | (x)[1])
197510 #endif
197511
197512 /*
197513 ** Connect to or create a new DBSTAT virtual table.
197514 */
197515 static int statConnect(
197516 sqlite3 *db,
197517 void *pAux,
197518 int argc, const char *const*argv,
@@ -196075,11 +197532,11 @@
197532 return SQLITE_ERROR;
197533 }
197534 }else{
197535 iDb = 0;
197536 }
197537 rc = sqlite3_declare_vtab(db, zDbstatSchema);
197538 if( rc==SQLITE_OK ){
197539 pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable));
197540 if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;
197541 }
197542
@@ -196093,43 +197550,76 @@
197550 *ppVtab = (sqlite3_vtab*)pTab;
197551 return rc;
197552 }
197553
197554 /*
197555 ** Disconnect from or destroy the DBSTAT virtual table.
197556 */
197557 static int statDisconnect(sqlite3_vtab *pVtab){
197558 sqlite3_free(pVtab);
197559 return SQLITE_OK;
197560 }
197561
197562 /*
197563 ** Compute the best query strategy and return the result in idxNum.
 
 
197564 **
197565 ** idxNum-Bit Meaning
197566 ** ---------- ----------------------------------------------
197567 ** 0x01 There is a schema=? term in the WHERE clause
197568 ** 0x02 There is a name=? term in the WHERE clause
197569 ** 0x04 There is an aggregate=? term in the WHERE clause
197570 ** 0x08 Output should be ordered by name and path
197571 */
197572 static int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
197573 int i;
197574 int iSchema = -1;
197575 int iName = -1;
197576 int iAgg = -1;
197577
197578 /* Look for a valid schema=? constraint. If found, change the idxNum to
197579 ** 1 and request the value of that constraint be sent to xFilter. And
197580 ** lower the cost estimate to encourage the constrained version to be
197581 ** used.
197582 */
197583 for(i=0; i<pIdxInfo->nConstraint; i++){
 
 
197584 if( pIdxInfo->aConstraint[i].op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
197585 if( pIdxInfo->aConstraint[i].usable==0 ){
197586 /* Force DBSTAT table should always be the right-most table in a join */
197587 return SQLITE_CONSTRAINT;
197588 }
197589 switch( pIdxInfo->aConstraint[i].iColumn ){
197590 case 0: { /* name */
197591 iName = i;
197592 break;
197593 }
197594 case 10: { /* schema */
197595 iSchema = i;
197596 break;
197597 }
197598 case 11: { /* aggregate */
197599 iAgg = i;
197600 break;
197601 }
197602 }
197603 }
197604 i = 0;
197605 if( iSchema>=0 ){
197606 pIdxInfo->aConstraintUsage[iSchema].argvIndex = ++i;
197607 pIdxInfo->aConstraintUsage[iSchema].omit = 1;
197608 pIdxInfo->idxNum |= 0x01;
197609 }
197610 if( iName>=0 ){
197611 pIdxInfo->aConstraintUsage[iName].argvIndex = ++i;
197612 pIdxInfo->aConstraintUsage[iName].omit = 1;
197613 pIdxInfo->idxNum |= 0x02;
197614 }
197615 if( iAgg>=0 ){
197616 pIdxInfo->aConstraintUsage[iAgg].argvIndex = ++i;
197617 pIdxInfo->aConstraintUsage[iAgg].omit = 1;
197618 pIdxInfo->idxNum |= 0x04;
197619 }
197620 pIdxInfo->estimatedCost = 1.0;
197621
197622 /* Records are always returned in ascending order of (name, path).
197623 ** If this will satisfy the client, set the orderByConsumed flag so that
197624 ** SQLite does not do an external sort.
197625 */
@@ -196143,17 +197633,18 @@
197633 && pIdxInfo->aOrderBy[1].iColumn==1
197634 && pIdxInfo->aOrderBy[1].desc==0
197635 )
197636 ){
197637 pIdxInfo->orderByConsumed = 1;
197638 pIdxInfo->idxNum |= 0x08;
197639 }
197640
197641 return SQLITE_OK;
197642 }
197643
197644 /*
197645 ** Open a new DBSTAT cursor.
197646 */
197647 static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
197648 StatTable *pTab = (StatTable *)pVTab;
197649 StatCursor *pCsr;
197650
@@ -196198,27 +197689,41 @@
197689 pCsr->iPage = 0;
197690 sqlite3_free(pCsr->zPath);
197691 pCsr->zPath = 0;
197692 pCsr->isEof = 0;
197693 }
197694
197695 /* Resize the space-used counters inside of the cursor */
197696 static void statResetCounts(StatCursor *pCsr){
197697 pCsr->nCell = 0;
197698 pCsr->nMxPayload = 0;
197699 pCsr->nUnused = 0;
197700 pCsr->nPayload = 0;
197701 pCsr->szPage = 0;
197702 pCsr->nPage = 0;
197703 }
197704
197705 /*
197706 ** Close a DBSTAT cursor.
197707 */
197708 static int statClose(sqlite3_vtab_cursor *pCursor){
197709 StatCursor *pCsr = (StatCursor *)pCursor;
197710 statResetCsr(pCsr);
197711 sqlite3_finalize(pCsr->pStmt);
197712 sqlite3_free(pCsr);
197713 return SQLITE_OK;
197714 }
197715
197716 /*
197717 ** For a single cell on a btree page, compute the number of bytes of
197718 ** content (payload) stored on that page. That is to say, compute the
197719 ** number of bytes of content not found on overflow pages.
197720 */
197721 static int getLocalPayload(
197722 int nUsable, /* Usable bytes per page */
197723 u8 flags, /* Page flags */
197724 int nTotal /* Total record (payload) size */
 
197725 ){
197726 int nLocal;
197727 int nMinLocal;
197728 int nMaxLocal;
197729
@@ -196230,13 +197735,16 @@
197735 nMaxLocal = (nUsable - 12) * 64 / 255 - 23;
197736 }
197737
197738 nLocal = nMinLocal + (nTotal - nMinLocal) % (nUsable - 4);
197739 if( nLocal>nMaxLocal ) nLocal = nMinLocal;
197740 return nLocal;
197741 }
197742
197743 /* Populate the StatPage object with information about the all
197744 ** cells found on the page currently under analysis.
197745 */
197746 static int statDecodePage(Btree *pBt, StatPage *p){
197747 int nUnused;
197748 int iOff;
197749 int nHdr;
197750 int isLeaf;
@@ -196303,11 +197811,11 @@
197811 if( p->flags==0x0D ){
197812 u64 dummy;
197813 iOff += sqlite3GetVarint(&aData[iOff], &dummy);
197814 }
197815 if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload;
197816 nLocal = getLocalPayload(nUsable, p->flags, nPayload);
197817 if( nLocal<0 ) goto statPageIsCorrupt;
197818 pCell->nLocal = nLocal;
197819 assert( nPayload>=(u32)nLocal );
197820 assert( nLocal<=(nUsable-35) );
197821 if( nPayload>(u32)nLocal ){
@@ -196353,27 +197861,29 @@
197861 Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;
197862 Pager *pPager = sqlite3BtreePager(pBt);
197863 sqlite3_file *fd;
197864 sqlite3_int64 x[2];
197865
197866 /* If connected to a ZIPVFS backend, find the page size and
197867 ** offset from ZIPVFS.
 
 
 
 
197868 */
197869 fd = sqlite3PagerFile(pPager);
197870 x[0] = pCsr->iPageno;
197871 if( sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){
197872 pCsr->iOffset = x[0];
197873 pCsr->szPage += x[1];
197874 }else{
197875 /* Not ZIPVFS: The default page size and offset */
197876 pCsr->szPage += sqlite3BtreeGetPageSize(pBt);
197877 pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1);
197878 }
197879 }
197880
197881 /*
197882 ** Move a DBSTAT cursor to the next entry. Normally, the next
197883 ** entry will be the next page, but in aggregated mode (pCsr->isAgg!=0),
197884 ** the next entry is the next btree.
197885 */
197886 static int statNext(sqlite3_vtab_cursor *pCursor){
197887 int rc;
197888 int nPayload;
197889 char *z;
@@ -196385,10 +197895,12 @@
197895 sqlite3_free(pCsr->zPath);
197896 pCsr->zPath = 0;
197897
197898 statNextRestart:
197899 if( pCsr->aPage[0].pPg==0 ){
197900 /* Start measuring space on the next btree */
197901 statResetCounts(pCsr);
197902 rc = sqlite3_step(pCsr->pStmt);
197903 if( rc==SQLITE_ROW ){
197904 int nPage;
197905 u32 iRoot = (u32)sqlite3_column_int64(pCsr->pStmt, 1);
197906 sqlite3PagerPagecount(pPager, &nPage);
@@ -196397,57 +197909,65 @@
197909 return sqlite3_reset(pCsr->pStmt);
197910 }
197911 rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg, 0);
197912 pCsr->aPage[0].iPgno = iRoot;
197913 pCsr->aPage[0].iCell = 0;
197914 if( !pCsr->isAgg ){
197915 pCsr->aPage[0].zPath = z = sqlite3_mprintf("/");
197916 if( z==0 ) rc = SQLITE_NOMEM_BKPT;
197917 }
197918 pCsr->iPage = 0;
197919 pCsr->nPage = 1;
197920 }else{
197921 pCsr->isEof = 1;
197922 return sqlite3_reset(pCsr->pStmt);
197923 }
197924 }else{
197925 /* Continue analyzing the btree previously started */
 
197926 StatPage *p = &pCsr->aPage[pCsr->iPage];
197927 if( !pCsr->isAgg ) statResetCounts(pCsr);
197928 while( p->iCell<p->nCell ){
197929 StatCell *pCell = &p->aCell[p->iCell];
197930 while( pCell->iOvfl<pCell->nOvfl ){
197931 int nUsable, iOvfl;
197932 sqlite3BtreeEnter(pBt);
197933 nUsable = sqlite3BtreeGetPageSize(pBt) -
197934 sqlite3BtreeGetReserveNoMutex(pBt);
197935 sqlite3BtreeLeave(pBt);
197936 pCsr->nPage++;
197937 statSizeAndOffset(pCsr);
 
 
 
 
 
 
197938 if( pCell->iOvfl<pCell->nOvfl-1 ){
197939 pCsr->nPayload += nUsable - 4;
 
197940 }else{
197941 pCsr->nPayload += pCell->nLastOvfl;
197942 pCsr->nUnused += nUsable - 4 - pCell->nLastOvfl;
197943 }
197944 iOvfl = pCell->iOvfl;
197945 pCell->iOvfl++;
197946 if( !pCsr->isAgg ){
197947 pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);
197948 pCsr->iPageno = pCell->aOvfl[iOvfl];
197949 pCsr->zPagetype = "overflow";
197950 pCsr->zPath = z = sqlite3_mprintf(
197951 "%s%.3x+%.6x", p->zPath, p->iCell, iOvfl
197952 );
197953 return z==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK;
197954 }
197955 }
197956 if( p->iRightChildPg ) break;
197957 p->iCell++;
197958 }
197959
197960 if( !p->iRightChildPg || p->iCell>p->nCell ){
197961 statClearPage(p);
197962 if( pCsr->iPage>0 ){
197963 pCsr->iPage--;
197964 }else if( pCsr->isAgg ){
197965 /* label-statNext-done: When computing aggregate space usage over
197966 ** an entire btree, this is the exit point from this function */
197967 return SQLITE_OK;
197968 }
197969 goto statNextRestart; /* Tail recursion */
197970 }
197971 pCsr->iPage++;
197972 if( pCsr->iPage>=ArraySize(pCsr->aPage) ){
197973 statResetCsr(pCsr);
@@ -196459,14 +197979,17 @@
197979 p[1].iPgno = p->iRightChildPg;
197980 }else{
197981 p[1].iPgno = p->aCell[p->iCell].iChildPg;
197982 }
197983 rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg, 0);
197984 pCsr->nPage++;
197985 p[1].iCell = 0;
197986 if( !pCsr->isAgg ){
197987 p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell);
197988 if( z==0 ) rc = SQLITE_NOMEM_BKPT;
197989 }
197990 p->iCell++;
 
197991 }
197992
197993
197994 /* Populate the StatCursor fields with the values to be returned
197995 ** by the xColumn() and xRowid() methods.
@@ -196492,20 +198015,27 @@
198015 break;
198016 default:
198017 pCsr->zPagetype = "corrupted";
198018 break;
198019 }
198020 pCsr->nCell += p->nCell;
198021 pCsr->nUnused += p->nUnused;
198022 if( p->nMxPayload>pCsr->nMxPayload ) pCsr->nMxPayload = p->nMxPayload;
198023 if( !pCsr->isAgg ){
198024 pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath);
198025 if( z==0 ) rc = SQLITE_NOMEM_BKPT;
198026 }
198027 nPayload = 0;
198028 for(i=0; i<p->nCell; i++){
198029 nPayload += p->aCell[i].nLocal;
198030 }
198031 pCsr->nPayload += nPayload;
198032
198033 /* If computing aggregate space usage by btree, continue with the
198034 ** next page. The loop will exit via the return at label-statNext-done
198035 */
198036 if( pCsr->isAgg ) goto statNextRestart;
198037 }
198038 }
198039
198040 return rc;
198041 }
@@ -196513,40 +198043,67 @@
198043 static int statEof(sqlite3_vtab_cursor *pCursor){
198044 StatCursor *pCsr = (StatCursor *)pCursor;
198045 return pCsr->isEof;
198046 }
198047
198048 /* Initialize a cursor according to the query plan idxNum using the
198049 ** arguments in argv[0]. See statBestIndex() for a description of the
198050 ** meaning of the bits in idxNum.
198051 */
198052 static int statFilter(
198053 sqlite3_vtab_cursor *pCursor,
198054 int idxNum, const char *idxStr,
198055 int argc, sqlite3_value **argv
198056 ){
198057 StatCursor *pCsr = (StatCursor *)pCursor;
198058 StatTable *pTab = (StatTable*)(pCursor->pVtab);
198059 sqlite3_str *pSql; /* Query of btrees to analyze */
198060 char *zSql; /* String value of pSql */
198061 int iArg = 0; /* Count of argv[] parameters used so far */
198062 int rc = SQLITE_OK; /* Result of this operation */
198063 const char *zName = 0; /* Only provide analysis of this table */
198064
198065 statResetCsr(pCsr);
198066 sqlite3_finalize(pCsr->pStmt);
198067 pCsr->pStmt = 0;
198068 if( idxNum & 0x01 ){
198069 /* schema=? constraint is present. Get its value */
198070 const char *zDbase = (const char*)sqlite3_value_text(argv[iArg++]);
198071 pCsr->iDb = sqlite3FindDbName(pTab->db, zDbase);
198072 if( pCsr->iDb<0 ){
198073 sqlite3_free(pCursor->pVtab->zErrMsg);
198074 pCursor->pVtab->zErrMsg = sqlite3_mprintf("no such schema: %s", zDbase);
198075 return pCursor->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM_BKPT;
198076 }
198077 }else{
198078 pCsr->iDb = pTab->iDb;
198079 }
198080 if( idxNum & 0x02 ){
198081 /* name=? constraint is present */
198082 zName = (const char*)sqlite3_value_text(argv[iArg++]);
198083 }
198084 if( idxNum & 0x04 ){
198085 /* aggregate=? constraint is present */
198086 pCsr->isAgg = sqlite3_value_double(argv[iArg++])!=0.0;
198087 }else{
198088 pCsr->isAgg = 0;
198089 }
198090 pSql = sqlite3_str_new(pTab->db);
198091 sqlite3_str_appendf(pSql,
198092 "SELECT * FROM ("
198093 "SELECT 'sqlite_master' AS name,1 AS rootpage,'table' AS type"
198094 " UNION ALL "
198095 "SELECT name,rootpage,type"
198096 " FROM \"%w\".sqlite_master WHERE rootpage!=0)",
198097 pTab->db->aDb[pCsr->iDb].zDbSName);
198098 if( zName ){
198099 sqlite3_str_appendf(pSql, "WHERE name=%Q", zName);
198100 }
198101 if( idxNum & 0x08 ){
198102 sqlite3_str_appendf(pSql, " ORDER BY name");
198103 }
198104 zSql = sqlite3_str_finish(pSql);
198105 if( zSql==0 ){
198106 return SQLITE_NOMEM_BKPT;
198107 }else{
198108 rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);
198109 sqlite3_free(zSql);
@@ -196567,17 +198124,25 @@
198124 switch( i ){
198125 case 0: /* name */
198126 sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_TRANSIENT);
198127 break;
198128 case 1: /* path */
198129 if( !pCsr->isAgg ){
198130 sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT);
198131 }
198132 break;
198133 case 2: /* pageno */
198134 if( pCsr->isAgg ){
198135 sqlite3_result_int64(ctx, pCsr->nPage);
198136 }else{
198137 sqlite3_result_int64(ctx, pCsr->iPageno);
198138 }
198139 break;
198140 case 3: /* pagetype */
198141 if( !pCsr->isAgg ){
198142 sqlite3_result_text(ctx, pCsr->zPagetype, -1, SQLITE_STATIC);
198143 }
198144 break;
198145 case 4: /* ncell */
198146 sqlite3_result_int(ctx, pCsr->nCell);
198147 break;
198148 case 5: /* payload */
@@ -196588,20 +198153,26 @@
198153 break;
198154 case 7: /* mx_payload */
198155 sqlite3_result_int(ctx, pCsr->nMxPayload);
198156 break;
198157 case 8: /* pgoffset */
198158 if( !pCsr->isAgg ){
198159 sqlite3_result_int64(ctx, pCsr->iOffset);
198160 }
198161 break;
198162 case 9: /* pgsize */
198163 sqlite3_result_int(ctx, pCsr->szPage);
198164 break;
198165 case 10: { /* schema */
198166 sqlite3 *db = sqlite3_context_db_handle(ctx);
198167 int iDb = pCsr->iDb;
198168 sqlite3_result_text(ctx, db->aDb[iDb].zDbSName, -1, SQLITE_STATIC);
198169 break;
198170 }
198171 default: { /* aggregate */
198172 sqlite3_result_int(ctx, pCsr->isAgg);
198173 break;
198174 }
198175 }
198176 return SQLITE_OK;
198177 }
198178
@@ -203188,10 +204759,15 @@
204759 ** less than 32. If it is set to anything large than that, an #error
204760 ** directive in fts5_index.c will cause the build to fail.
204761 */
204762 #define FTS5_MAX_PREFIX_INDEXES 31
204763
204764 /*
204765 ** Maximum segments permitted in a single index
204766 */
204767 #define FTS5_MAX_SEGMENT 2000
204768
204769 #define FTS5_DEFAULT_NEARDIST 10
204770 #define FTS5_DEFAULT_RANK "bm25"
204771
204772 /* Name of rank and rowid columns */
204773 #define FTS5_RANK_NAME "rank"
@@ -203544,10 +205120,15 @@
205120 /*
205121 ** Close an iterator opened by sqlite3Fts5IndexQuery().
205122 */
205123 static void sqlite3Fts5IterClose(Fts5IndexIter*);
205124
205125 /*
205126 ** Close the reader blob handle, if it is open.
205127 */
205128 static void sqlite3Fts5IndexCloseReader(Fts5Index*);
205129
205130 /*
205131 ** This interface is used by the fts5vocab module.
205132 */
205133 static const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*);
205134 static int sqlite3Fts5IterNextScan(Fts5IndexIter*);
@@ -205420,12 +207001,12 @@
207001 #ifdef fts5YYFALLBACK
207002 assert( iToken<(int)(sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])) );
207003 return fts5yyFallback[iToken];
207004 #else
207005 (void)iToken;
 
207006 return 0;
207007 #endif
207008 }
207009
207010 /*
207011 ** 2014 May 31
207012 **
@@ -206570,11 +208151,11 @@
208151 #define FTS5_DEFAULT_USERMERGE 4
208152 #define FTS5_DEFAULT_CRISISMERGE 16
208153 #define FTS5_DEFAULT_HASHSIZE (1024*1024)
208154
208155 /* Maximum allowed page size */
208156 #define FTS5_MAX_PAGE_SIZE (64*1024)
208157
208158 static int fts5_iswhitespace(char x){
208159 return (x==' ');
208160 }
208161
@@ -207375,11 +208956,11 @@
208956 if( 0==sqlite3_stricmp(zKey, "pgsz") ){
208957 int pgsz = 0;
208958 if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){
208959 pgsz = sqlite3_value_int(pVal);
208960 }
208961 if( pgsz<32 || pgsz>FTS5_MAX_PAGE_SIZE ){
208962 *pbBadkey = 1;
208963 }else{
208964 pConfig->pgsz = pgsz;
208965 }
208966 }
@@ -207428,10 +209009,11 @@
209009 }
209010 if( nCrisisMerge<0 ){
209011 *pbBadkey = 1;
209012 }else{
209013 if( nCrisisMerge<=1 ) nCrisisMerge = FTS5_DEFAULT_CRISISMERGE;
209014 if( nCrisisMerge>=FTS5_MAX_SEGMENT ) nCrisisMerge = FTS5_MAX_SEGMENT-1;
209015 pConfig->nCrisisMerge = nCrisisMerge;
209016 }
209017 }
209018
209019 else if( 0==sqlite3_stricmp(zKey, "rank") ){
@@ -211199,15 +212781,10 @@
212781 )
212782
212783 #define FTS5_SEGMENT_ROWID(segid, pgno) fts5_dri(segid, 0, 0, pgno)
212784 #define FTS5_DLIDX_ROWID(segid, height, pgno) fts5_dri(segid, 1, height, pgno)
212785
 
 
 
 
 
212786 #ifdef SQLITE_DEBUG
212787 static int sqlite3Fts5Corrupt() { return SQLITE_CORRUPT_VTAB; }
212788 #endif
212789
212790
@@ -211579,11 +213156,11 @@
213156 }
213157
213158 /*
213159 ** Close the read-only blob handle, if it is open.
213160 */
213161 static void sqlite3Fts5IndexCloseReader(Fts5Index *p){
213162 if( p->pReader ){
213163 sqlite3_blob *pReader = p->pReader;
213164 p->pReader = 0;
213165 sqlite3_blob_close(pReader);
213166 }
@@ -211608,11 +213185,11 @@
213185 p->pReader = 0;
213186 rc = sqlite3_blob_reopen(pBlob, iRowid);
213187 assert( p->pReader==0 );
213188 p->pReader = pBlob;
213189 if( rc!=SQLITE_OK ){
213190 sqlite3Fts5IndexCloseReader(p);
213191 }
213192 if( rc==SQLITE_ABORT ) rc = SQLITE_OK;
213193 }
213194
213195 /* If the blob handle is not open at this point, open it and seek
@@ -216169,11 +217746,11 @@
217746 ** Commit data to disk.
217747 */
217748 static int sqlite3Fts5IndexSync(Fts5Index *p){
217749 assert( p->rc==SQLITE_OK );
217750 fts5IndexFlush(p);
217751 sqlite3Fts5IndexCloseReader(p);
217752 return fts5IndexReturn(p);
217753 }
217754
217755 /*
217756 ** Discard any data stored in the in-memory hash tables. Do not write it
@@ -216180,11 +217757,11 @@
217757 ** to the database. Additionally, assume that the contents of the %_data
217758 ** table may have changed on disk. So any in-memory caches of %_data
217759 ** records must be invalidated.
217760 */
217761 static int sqlite3Fts5IndexRollback(Fts5Index *p){
217762 sqlite3Fts5IndexCloseReader(p);
217763 fts5IndexDiscardData(p);
217764 fts5StructureInvalidate(p);
217765 /* assert( p->rc==SQLITE_OK ); */
217766 return SQLITE_OK;
217767 }
@@ -216195,10 +217772,11 @@
217772 ** and the initial version of the "averages" record (a zero-byte blob).
217773 */
217774 static int sqlite3Fts5IndexReinit(Fts5Index *p){
217775 Fts5Structure s;
217776 fts5StructureInvalidate(p);
217777 fts5IndexDiscardData(p);
217778 memset(&s, 0, sizeof(Fts5Structure));
217779 fts5DataWrite(p, FTS5_AVERAGES_ROWID, (const u8*)"", 0);
217780 fts5StructureWrite(p, &s);
217781 return fts5IndexReturn(p);
217782 }
@@ -216282,10 +217860,11 @@
217860 int n = 0;
217861 int i;
217862 for(i=0; i<nChar; i++){
217863 if( n>=nByte ) return 0; /* Input contains fewer than nChar chars */
217864 if( (unsigned char)p[n++]>=0xc0 ){
217865 if( n>=nByte ) break;
217866 while( (p[n] & 0xc0)==0x80 ){
217867 n++;
217868 if( n>=nByte ) break;
217869 }
217870 }
@@ -216420,11 +217999,11 @@
217999 }
218000
218001 if( p->rc ){
218002 sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
218003 pRet = 0;
218004 sqlite3Fts5IndexCloseReader(p);
218005 }
218006
218007 *ppIter = (Fts5IndexIter*)pRet;
218008 sqlite3Fts5BufferFree(&buf);
218009 }
@@ -216493,11 +218072,11 @@
218072 static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){
218073 if( pIndexIter ){
218074 Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
218075 Fts5Index *pIndex = pIter->pIndex;
218076 fts5MultiIterFree(pIter);
218077 sqlite3Fts5IndexCloseReader(pIndex);
218078 }
218079 }
218080
218081 /*
218082 ** Read and decode the "averages" record from the database.
@@ -216850,11 +218429,12 @@
218429 int iDlidxPrevLeaf = pSeg->pgnoLast;
218430
218431 if( pSeg->pgnoFirst==0 ) return;
218432
218433 fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf(
218434 "SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d "
218435 "ORDER BY 1, 2",
218436 pConfig->zDb, pConfig->zName, pSeg->iSegid
218437 ));
218438
218439 /* Iterate through the b-tree hierarchy. */
218440 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
@@ -218296,10 +219876,11 @@
219876 if( CsrFlagTest(pCsr, FTS5CSR_FREE_ZRANK) ){
219877 sqlite3_free(pCsr->zRank);
219878 sqlite3_free(pCsr->zRankArgs);
219879 }
219880
219881 sqlite3Fts5IndexCloseReader(pTab->p.pIndex);
219882 memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan - (u8*)pCsr));
219883 }
219884
219885
219886 /*
@@ -220265,11 +221846,11 @@
221846 int nArg, /* Number of args */
221847 sqlite3_value **apUnused /* Function arguments */
221848 ){
221849 assert( nArg==0 );
221850 UNUSED_PARAM2(nArg, apUnused);
221851 sqlite3_result_text(pCtx, "fts5: 2019-11-20 12:07:40 2575a68c3965e72f2ab211d933012442755afe6a9b7de9e9e50cdd2155fd1ec8", -1, SQLITE_TRANSIENT);
221852 }
221853
221854 /*
221855 ** Return true if zName is the extension on one of the shadow tables used
221856 ** by this module.
@@ -220958,10 +222539,12 @@
222539 ** Delete all entries in the FTS5 index.
222540 */
222541 static int sqlite3Fts5StorageDeleteAll(Fts5Storage *p){
222542 Fts5Config *pConfig = p->pConfig;
222543 int rc;
222544
222545 p->bTotalsValid = 0;
222546
222547 /* Delete the contents of the %_data and %_docsize tables. */
222548 rc = fts5ExecPrintf(pConfig->db, 0,
222549 "DELETE FROM %Q.'%q_data';"
222550 "DELETE FROM %Q.'%q_idx';",
@@ -225033,12 +226616,12 @@
226616 }
226617 #endif /* SQLITE_CORE */
226618 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
226619
226620 /************** End of stmt.c ************************************************/
226621 #if __LINE__!=226621
226622 #undef SQLITE_SOURCE_ID
226623 #define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9alt2"
226624 #endif
226625 /* Return the source-id for this library */
226626 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
226627 /************************** End of sqlite3.c ******************************/
226628
+65 -24
--- 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.30.0"
127
-#define SQLITE_VERSION_NUMBER 3030000
128
-#define SQLITE_SOURCE_ID "2019-10-04 15:03:17 c20a35336432025445f9f7e289d0cc3e4003fb17f45a4ce74c6269c407c6e09f"
126
+#define SQLITE_VERSION "3.31.0"
127
+#define SQLITE_VERSION_NUMBER 3031000
128
+#define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9f49b"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -514,10 +514,11 @@
514514
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
515515
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
516516
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
517517
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
518518
#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
519
+#define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8))
519520
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
520521
#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
521522
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
522523
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
523524
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -566,10 +567,11 @@
566567
#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
567568
#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
568569
#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
569570
#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
570571
#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
572
+#define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */
571573
572574
/* Reserved: 0x00F00000 */
573575
574576
/*
575577
** CAPI3REF: Device Characteristics
@@ -1404,10 +1406,11 @@
14041406
** SQLite.
14051407
*/
14061408
#define SQLITE_ACCESS_EXISTS 0
14071409
#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
14081410
#define SQLITE_ACCESS_READ 2 /* Unused */
1411
+#define SQLITE_ACCESS_SYMLINK 3 /* Test if file is symbolic link */
14091412
14101413
/*
14111414
** CAPI3REF: Flags for the xShmLock VFS method
14121415
**
14131416
** These integer constants define the various locking operations
@@ -1740,10 +1743,11 @@
17401743
** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
17411744
** interpreted as a boolean, which enables or disables the collection of
17421745
** memory allocation statistics. ^(When memory allocation statistics are
17431746
** disabled, the following SQLite interfaces become non-operational:
17441747
** <ul>
1748
+** <li> [sqlite3_hard_heap_limit64()]
17451749
** <li> [sqlite3_memory_used()]
17461750
** <li> [sqlite3_memory_highwater()]
17471751
** <li> [sqlite3_soft_heap_limit64()]
17481752
** <li> [sqlite3_status64()]
17491753
** </ul>)^
@@ -2257,10 +2261,32 @@
22572261
** the legacy [double-quoted string literal] misfeature for DDL statements,
22582262
** such as CREATE TABLE and CREATE INDEX. The
22592263
** default value of this setting is determined by the [-DSQLITE_DQS]
22602264
** compile-time option.
22612265
** </dd>
2266
+**
2267
+** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]]
2268
+** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</td>
2269
+** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates
2270
+** the legacy file format flag. When activated, this flag causes all newly
2271
+** created database file to have a schema format version number (the 4-byte
2272
+** integer found at offset 44 into the database header) of 1. This in turn
2273
+** means that the resulting database file will be readable and writable by
2274
+** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting,
2275
+** newly created databases are generally not understandable by SQLite versions
2276
+** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there
2277
+** is now scarcely any need to generated database files that are compatible
2278
+** all the way back to version 3.0.0, and so this setting is of little
2279
+** practical use, but is provided so that SQLite can continue to claim the
2280
+** ability to generate new database files that are compatible with version
2281
+** 3.0.0.
2282
+** <p>Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on,
2283
+** the [VACUUM] command will fail with an obscure error when attempting to
2284
+** process a table with generated columns and a descending index. This is
2285
+** not considered a bug since SQLite versions 3.3.0 and earlier do not support
2286
+** either generated columns or decending indexes.
2287
+** </dd>
22622288
** </dl>
22632289
*/
22642290
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
22652291
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
22662292
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -2275,11 +2301,12 @@
22752301
#define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
22762302
#define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
22772303
#define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
22782304
#define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
22792305
#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2280
-#define SQLITE_DBCONFIG_MAX 1015 /* Largest DBCONFIG */
2306
+#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2307
+#define SQLITE_DBCONFIG_MAX 1016 /* Largest DBCONFIG */
22812308
22822309
/*
22832310
** CAPI3REF: Enable Or Disable Extended Result Codes
22842311
** METHOD: sqlite3
22852312
**
@@ -6113,10 +6140,13 @@
61136140
*/
61146141
SQLITE_API int sqlite3_db_release_memory(sqlite3*);
61156142
61166143
/*
61176144
** CAPI3REF: Impose A Limit On Heap Size
6145
+**
6146
+** These interfaces impose limits on the amount of heap memory that will be
6147
+** by all database connections within a single process.
61186148
**
61196149
** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
61206150
** soft limit on the amount of heap memory that may be allocated by SQLite.
61216151
** ^SQLite strives to keep heap memory utilization below the soft heap
61226152
** limit by reducing the number of pages held in the page cache
@@ -6124,24 +6154,45 @@
61246154
** ^The soft heap limit is "soft" because even though SQLite strives to stay
61256155
** below the limit, it will exceed the limit rather than generate
61266156
** an [SQLITE_NOMEM] error. In other words, the soft heap limit
61276157
** is advisory only.
61286158
**
6129
-** ^The return value from sqlite3_soft_heap_limit64() is the size of
6130
-** the soft heap limit prior to the call, or negative in the case of an
6159
+** ^The sqlite3_hard_heap_limit64(N) interface sets a hard upper bound of
6160
+** N bytes on the amount of memory that will be allocated. ^The
6161
+** sqlite3_hard_heap_limit64(N) interface is similar to
6162
+** sqlite3_soft_heap_limit64(N) except that memory allocations will fail
6163
+** when the hard heap limit is reached.
6164
+**
6165
+** ^The return value from both sqlite3_soft_heap_limit64() and
6166
+** sqlite3_hard_heap_limit64() is the size of
6167
+** the heap limit prior to the call, or negative in the case of an
61316168
** error. ^If the argument N is negative
6132
-** then no change is made to the soft heap limit. Hence, the current
6133
-** size of the soft heap limit can be determined by invoking
6134
-** sqlite3_soft_heap_limit64() with a negative argument.
6169
+** then no change is made to the heap limit. Hence, the current
6170
+** size of heap limits can be determined by invoking
6171
+** sqlite3_soft_heap_limit64(-1) or sqlite3_hard_heap_limit(-1).
61356172
**
6136
-** ^If the argument N is zero then the soft heap limit is disabled.
6173
+** ^Setting the heap limits to zero disables the heap limiter mechanism.
61376174
**
6138
-** ^(The soft heap limit is not enforced in the current implementation
6175
+** ^The soft heap limit may not be greater than the hard heap limit.
6176
+** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N)
6177
+** is invoked with a value of N that is greater than the hard heap limit,
6178
+** the the soft heap limit is set to the value of the hard heap limit.
6179
+** ^The soft heap limit is automatically enabled whenever the hard heap
6180
+** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and
6181
+** the soft heap limit is outside the range of 1..N, then the soft heap
6182
+** limit is set to N. ^Invoking sqlite3_soft_heap_limit64(0) when the
6183
+** hard heap limit is enabled makes the soft heap limit equal to the
6184
+** hard heap limit.
6185
+**
6186
+** The memory allocation limits can also be adjusted using
6187
+** [PRAGMA soft_heap_limit] and [PRAGMA hard_heap_limit].
6188
+**
6189
+** ^(The heap limits are not enforced in the current implementation
61396190
** if one or more of following conditions are true:
61406191
**
61416192
** <ul>
6142
-** <li> The soft heap limit is set to zero.
6193
+** <li> The limit value is set to zero.
61436194
** <li> Memory accounting is disabled using a combination of the
61446195
** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
61456196
** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
61466197
** <li> An alternative page cache implementation is specified using
61476198
** [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).
@@ -6148,25 +6199,15 @@
61486199
** <li> The page cache allocates from its own memory pool supplied
61496200
** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
61506201
** from the heap.
61516202
** </ul>)^
61526203
**
6153
-** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]),
6154
-** the soft heap limit is enforced
6155
-** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]
6156
-** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT],
6157
-** the soft heap limit is enforced on every memory allocation. Without
6158
-** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced
6159
-** when memory is allocated by the page cache. Testing suggests that because
6160
-** the page cache is the predominate memory user in SQLite, most
6161
-** applications will achieve adequate soft heap limit enforcement without
6162
-** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
6163
-**
6164
-** The circumstances under which SQLite will enforce the soft heap limit may
6204
+** The circumstances under which SQLite will enforce the heap limits may
61656205
** changes in future releases of SQLite.
61666206
*/
61676207
SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
6208
+SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
61686209
61696210
/*
61706211
** CAPI3REF: Deprecated Soft Heap Limit Interface
61716212
** DEPRECATED
61726213
**
61736214
--- 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-10-04 15:03:17 c20a35336432025445f9f7e289d0cc3e4003fb17f45a4ce74c6269c407c6e09f"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -514,10 +514,11 @@
514 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
515 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
516 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
517 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
518 #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
 
519 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
520 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
521 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
522 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
523 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -566,10 +567,11 @@
566 #define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
567 #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
568 #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
569 #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
570 #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
 
571
572 /* Reserved: 0x00F00000 */
573
574 /*
575 ** CAPI3REF: Device Characteristics
@@ -1404,10 +1406,11 @@
1404 ** SQLite.
1405 */
1406 #define SQLITE_ACCESS_EXISTS 0
1407 #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
1408 #define SQLITE_ACCESS_READ 2 /* Unused */
 
1409
1410 /*
1411 ** CAPI3REF: Flags for the xShmLock VFS method
1412 **
1413 ** These integer constants define the various locking operations
@@ -1740,10 +1743,11 @@
1740 ** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
1741 ** interpreted as a boolean, which enables or disables the collection of
1742 ** memory allocation statistics. ^(When memory allocation statistics are
1743 ** disabled, the following SQLite interfaces become non-operational:
1744 ** <ul>
 
1745 ** <li> [sqlite3_memory_used()]
1746 ** <li> [sqlite3_memory_highwater()]
1747 ** <li> [sqlite3_soft_heap_limit64()]
1748 ** <li> [sqlite3_status64()]
1749 ** </ul>)^
@@ -2257,10 +2261,32 @@
2257 ** the legacy [double-quoted string literal] misfeature for DDL statements,
2258 ** such as CREATE TABLE and CREATE INDEX. The
2259 ** default value of this setting is determined by the [-DSQLITE_DQS]
2260 ** compile-time option.
2261 ** </dd>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2262 ** </dl>
2263 */
2264 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2265 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2266 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -2275,11 +2301,12 @@
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 **
@@ -6113,10 +6140,13 @@
6113 */
6114 SQLITE_API int sqlite3_db_release_memory(sqlite3*);
6115
6116 /*
6117 ** CAPI3REF: Impose A Limit On Heap Size
 
 
 
6118 **
6119 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
6120 ** soft limit on the amount of heap memory that may be allocated by SQLite.
6121 ** ^SQLite strives to keep heap memory utilization below the soft heap
6122 ** limit by reducing the number of pages held in the page cache
@@ -6124,24 +6154,45 @@
6124 ** ^The soft heap limit is "soft" because even though SQLite strives to stay
6125 ** below the limit, it will exceed the limit rather than generate
6126 ** an [SQLITE_NOMEM] error. In other words, the soft heap limit
6127 ** is advisory only.
6128 **
6129 ** ^The return value from sqlite3_soft_heap_limit64() is the size of
6130 ** the soft heap limit prior to the call, or negative in the case of an
 
 
 
 
 
 
 
6131 ** error. ^If the argument N is negative
6132 ** then no change is made to the soft heap limit. Hence, the current
6133 ** size of the soft heap limit can be determined by invoking
6134 ** sqlite3_soft_heap_limit64() with a negative argument.
6135 **
6136 ** ^If the argument N is zero then the soft heap limit is disabled.
6137 **
6138 ** ^(The soft heap limit is not enforced in the current implementation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6139 ** if one or more of following conditions are true:
6140 **
6141 ** <ul>
6142 ** <li> The soft heap limit is set to zero.
6143 ** <li> Memory accounting is disabled using a combination of the
6144 ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
6145 ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
6146 ** <li> An alternative page cache implementation is specified using
6147 ** [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).
@@ -6148,25 +6199,15 @@
6148 ** <li> The page cache allocates from its own memory pool supplied
6149 ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
6150 ** from the heap.
6151 ** </ul>)^
6152 **
6153 ** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]),
6154 ** the soft heap limit is enforced
6155 ** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]
6156 ** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT],
6157 ** the soft heap limit is enforced on every memory allocation. Without
6158 ** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced
6159 ** when memory is allocated by the page cache. Testing suggests that because
6160 ** the page cache is the predominate memory user in SQLite, most
6161 ** applications will achieve adequate soft heap limit enforcement without
6162 ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
6163 **
6164 ** The circumstances under which SQLite will enforce the soft heap limit may
6165 ** changes in future releases of SQLite.
6166 */
6167 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
 
6168
6169 /*
6170 ** CAPI3REF: Deprecated Soft Heap Limit Interface
6171 ** DEPRECATED
6172 **
6173
--- 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.31.0"
127 #define SQLITE_VERSION_NUMBER 3031000
128 #define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9f49b"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -514,10 +514,11 @@
514 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
515 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
516 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
517 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
518 #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
519 #define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8))
520 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
521 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
522 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
523 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
524 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -566,10 +567,11 @@
567 #define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
568 #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
569 #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
570 #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
571 #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
572 #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */
573
574 /* Reserved: 0x00F00000 */
575
576 /*
577 ** CAPI3REF: Device Characteristics
@@ -1404,10 +1406,11 @@
1406 ** SQLite.
1407 */
1408 #define SQLITE_ACCESS_EXISTS 0
1409 #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
1410 #define SQLITE_ACCESS_READ 2 /* Unused */
1411 #define SQLITE_ACCESS_SYMLINK 3 /* Test if file is symbolic link */
1412
1413 /*
1414 ** CAPI3REF: Flags for the xShmLock VFS method
1415 **
1416 ** These integer constants define the various locking operations
@@ -1740,10 +1743,11 @@
1743 ** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
1744 ** interpreted as a boolean, which enables or disables the collection of
1745 ** memory allocation statistics. ^(When memory allocation statistics are
1746 ** disabled, the following SQLite interfaces become non-operational:
1747 ** <ul>
1748 ** <li> [sqlite3_hard_heap_limit64()]
1749 ** <li> [sqlite3_memory_used()]
1750 ** <li> [sqlite3_memory_highwater()]
1751 ** <li> [sqlite3_soft_heap_limit64()]
1752 ** <li> [sqlite3_status64()]
1753 ** </ul>)^
@@ -2257,10 +2261,32 @@
2261 ** the legacy [double-quoted string literal] misfeature for DDL statements,
2262 ** such as CREATE TABLE and CREATE INDEX. The
2263 ** default value of this setting is determined by the [-DSQLITE_DQS]
2264 ** compile-time option.
2265 ** </dd>
2266 **
2267 ** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]]
2268 ** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</td>
2269 ** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates
2270 ** the legacy file format flag. When activated, this flag causes all newly
2271 ** created database file to have a schema format version number (the 4-byte
2272 ** integer found at offset 44 into the database header) of 1. This in turn
2273 ** means that the resulting database file will be readable and writable by
2274 ** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting,
2275 ** newly created databases are generally not understandable by SQLite versions
2276 ** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there
2277 ** is now scarcely any need to generated database files that are compatible
2278 ** all the way back to version 3.0.0, and so this setting is of little
2279 ** practical use, but is provided so that SQLite can continue to claim the
2280 ** ability to generate new database files that are compatible with version
2281 ** 3.0.0.
2282 ** <p>Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on,
2283 ** the [VACUUM] command will fail with an obscure error when attempting to
2284 ** process a table with generated columns and a descending index. This is
2285 ** not considered a bug since SQLite versions 3.3.0 and earlier do not support
2286 ** either generated columns or decending indexes.
2287 ** </dd>
2288 ** </dl>
2289 */
2290 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2291 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2292 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -2275,11 +2301,12 @@
2301 #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
2302 #define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */
2303 #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
2304 #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
2305 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2306 #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2307 #define SQLITE_DBCONFIG_MAX 1016 /* Largest DBCONFIG */
2308
2309 /*
2310 ** CAPI3REF: Enable Or Disable Extended Result Codes
2311 ** METHOD: sqlite3
2312 **
@@ -6113,10 +6140,13 @@
6140 */
6141 SQLITE_API int sqlite3_db_release_memory(sqlite3*);
6142
6143 /*
6144 ** CAPI3REF: Impose A Limit On Heap Size
6145 **
6146 ** These interfaces impose limits on the amount of heap memory that will be
6147 ** by all database connections within a single process.
6148 **
6149 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
6150 ** soft limit on the amount of heap memory that may be allocated by SQLite.
6151 ** ^SQLite strives to keep heap memory utilization below the soft heap
6152 ** limit by reducing the number of pages held in the page cache
@@ -6124,24 +6154,45 @@
6154 ** ^The soft heap limit is "soft" because even though SQLite strives to stay
6155 ** below the limit, it will exceed the limit rather than generate
6156 ** an [SQLITE_NOMEM] error. In other words, the soft heap limit
6157 ** is advisory only.
6158 **
6159 ** ^The sqlite3_hard_heap_limit64(N) interface sets a hard upper bound of
6160 ** N bytes on the amount of memory that will be allocated. ^The
6161 ** sqlite3_hard_heap_limit64(N) interface is similar to
6162 ** sqlite3_soft_heap_limit64(N) except that memory allocations will fail
6163 ** when the hard heap limit is reached.
6164 **
6165 ** ^The return value from both sqlite3_soft_heap_limit64() and
6166 ** sqlite3_hard_heap_limit64() is the size of
6167 ** the heap limit prior to the call, or negative in the case of an
6168 ** error. ^If the argument N is negative
6169 ** then no change is made to the heap limit. Hence, the current
6170 ** size of heap limits can be determined by invoking
6171 ** sqlite3_soft_heap_limit64(-1) or sqlite3_hard_heap_limit(-1).
6172 **
6173 ** ^Setting the heap limits to zero disables the heap limiter mechanism.
6174 **
6175 ** ^The soft heap limit may not be greater than the hard heap limit.
6176 ** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N)
6177 ** is invoked with a value of N that is greater than the hard heap limit,
6178 ** the the soft heap limit is set to the value of the hard heap limit.
6179 ** ^The soft heap limit is automatically enabled whenever the hard heap
6180 ** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and
6181 ** the soft heap limit is outside the range of 1..N, then the soft heap
6182 ** limit is set to N. ^Invoking sqlite3_soft_heap_limit64(0) when the
6183 ** hard heap limit is enabled makes the soft heap limit equal to the
6184 ** hard heap limit.
6185 **
6186 ** The memory allocation limits can also be adjusted using
6187 ** [PRAGMA soft_heap_limit] and [PRAGMA hard_heap_limit].
6188 **
6189 ** ^(The heap limits are not enforced in the current implementation
6190 ** if one or more of following conditions are true:
6191 **
6192 ** <ul>
6193 ** <li> The limit value is set to zero.
6194 ** <li> Memory accounting is disabled using a combination of the
6195 ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
6196 ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
6197 ** <li> An alternative page cache implementation is specified using
6198 ** [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).
@@ -6148,25 +6199,15 @@
6199 ** <li> The page cache allocates from its own memory pool supplied
6200 ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
6201 ** from the heap.
6202 ** </ul>)^
6203 **
6204 ** The circumstances under which SQLite will enforce the heap limits may
 
 
 
 
 
 
 
 
 
 
 
6205 ** changes in future releases of SQLite.
6206 */
6207 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
6208 SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
6209
6210 /*
6211 ** CAPI3REF: Deprecated Soft Heap Limit Interface
6212 ** DEPRECATED
6213 **
6214

Keyboard Shortcuts

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