Fossil SCM

Update the built-in SQLite to the lastest 3.25.0 alpha version due to improved error message processing in that version. 3.25.0 also includes support for window functions, but we do not (yet) use that feature in Fossil.

drh 2018-07-14 15:12 trunk
Commit d66f322457dce8a860ba586eadf5c4c72fc10d1238f85d95092b1529a8328d61
4 files changed +2 -1 +13 -3 +7290 -2982 +103 -25
+2 -1
--- src/main.c
+++ src/main.c
@@ -529,11 +529,12 @@
529529
if( iCode==SQLITE_READONLY_DIRECTORY ){
530530
zErrmsg = "database is in a read-only directory";
531531
}
532532
#endif
533533
blob_init(&msg, 0, 0);
534
- blob_appendf(&msg, "%s: %s", fossil_sqlite_return_code_name(iCode), zErrmsg);
534
+ blob_appendf(&msg, "%s(%d): %s",
535
+ fossil_sqlite_return_code_name(iCode), iCode, zErrmsg);
535536
if( g.db ){
536537
for(p=sqlite3_next_stmt(g.db, 0); p; p=sqlite3_next_stmt(g.db,p)){
537538
const char *zSql;
538539
if( !sqlite3_stmt_busy(p) ) continue;
539540
zSql = sqlite3_sql(p);
540541
--- src/main.c
+++ src/main.c
@@ -529,11 +529,12 @@
529 if( iCode==SQLITE_READONLY_DIRECTORY ){
530 zErrmsg = "database is in a read-only directory";
531 }
532 #endif
533 blob_init(&msg, 0, 0);
534 blob_appendf(&msg, "%s: %s", fossil_sqlite_return_code_name(iCode), zErrmsg);
 
535 if( g.db ){
536 for(p=sqlite3_next_stmt(g.db, 0); p; p=sqlite3_next_stmt(g.db,p)){
537 const char *zSql;
538 if( !sqlite3_stmt_busy(p) ) continue;
539 zSql = sqlite3_sql(p);
540
--- src/main.c
+++ src/main.c
@@ -529,11 +529,12 @@
529 if( iCode==SQLITE_READONLY_DIRECTORY ){
530 zErrmsg = "database is in a read-only directory";
531 }
532 #endif
533 blob_init(&msg, 0, 0);
534 blob_appendf(&msg, "%s(%d): %s",
535 fossil_sqlite_return_code_name(iCode), iCode, zErrmsg);
536 if( g.db ){
537 for(p=sqlite3_next_stmt(g.db, 0); p; p=sqlite3_next_stmt(g.db,p)){
538 const char *zSql;
539 if( !sqlite3_stmt_busy(p) ) continue;
540 zSql = sqlite3_sql(p);
541
+13 -3
--- src/shell.c
+++ src/shell.c
@@ -9533,12 +9533,20 @@
95339533
}else if( aiType && aiType[i]==SQLITE_INTEGER ){
95349534
utf8_printf(p->out,"%s", azArg[i]);
95359535
}else if( aiType && aiType[i]==SQLITE_FLOAT ){
95369536
char z[50];
95379537
double r = sqlite3_column_double(p->pStmt, i);
9538
- sqlite3_snprintf(50,z,"%!.20g", r);
9539
- raw_printf(p->out, "%s", z);
9538
+ sqlite3_uint64 ur;
9539
+ memcpy(&ur,&r,sizeof(r));
9540
+ if( ur==0x7ff0000000000000LL ){
9541
+ raw_printf(p->out, "1e999");
9542
+ }else if( ur==0xfff0000000000000LL ){
9543
+ raw_printf(p->out, "-1e999");
9544
+ }else{
9545
+ sqlite3_snprintf(50,z,"%!.20g", r);
9546
+ raw_printf(p->out, "%s", z);
9547
+ }
95409548
}else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
95419549
const void *pBlob = sqlite3_column_blob(p->pStmt, i);
95429550
int nBlob = sqlite3_column_bytes(p->pStmt, i);
95439551
output_hex_blob(p->out, pBlob, nBlob);
95449552
}else if( isNumber(azArg[i], 0) ){
@@ -13354,11 +13362,12 @@
1335413362
1335513363
if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
1335613364
const char *zLike = 0;
1335713365
int i;
1335813366
int savedShowHeader = p->showHeader;
13359
- ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines);
13367
+ int savedShellFlags = p->shellFlgs;
13368
+ ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines|SHFLG_Echo);
1336013369
for(i=1; i<nArg; i++){
1336113370
if( azArg[i][0]=='-' ){
1336213371
const char *z = azArg[i]+1;
1336313372
if( z[0]=='-' ) z++;
1336413373
if( strcmp(z,"preserve-rowids")==0 ){
@@ -13436,10 +13445,11 @@
1343613445
}
1343713446
sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0);
1343813447
sqlite3_exec(p->db, "RELEASE dump;", 0, 0, 0);
1343913448
raw_printf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n");
1344013449
p->showHeader = savedShowHeader;
13450
+ p->shellFlgs = savedShellFlags;
1344113451
}else
1344213452
1344313453
if( c=='e' && strncmp(azArg[0], "echo", n)==0 ){
1344413454
if( nArg==2 ){
1344513455
setOrClearFlag(p, SHFLG_Echo, azArg[1]);
1344613456
--- src/shell.c
+++ src/shell.c
@@ -9533,12 +9533,20 @@
9533 }else if( aiType && aiType[i]==SQLITE_INTEGER ){
9534 utf8_printf(p->out,"%s", azArg[i]);
9535 }else if( aiType && aiType[i]==SQLITE_FLOAT ){
9536 char z[50];
9537 double r = sqlite3_column_double(p->pStmt, i);
9538 sqlite3_snprintf(50,z,"%!.20g", r);
9539 raw_printf(p->out, "%s", z);
 
 
 
 
 
 
 
 
9540 }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
9541 const void *pBlob = sqlite3_column_blob(p->pStmt, i);
9542 int nBlob = sqlite3_column_bytes(p->pStmt, i);
9543 output_hex_blob(p->out, pBlob, nBlob);
9544 }else if( isNumber(azArg[i], 0) ){
@@ -13354,11 +13362,12 @@
13354
13355 if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
13356 const char *zLike = 0;
13357 int i;
13358 int savedShowHeader = p->showHeader;
13359 ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines);
 
13360 for(i=1; i<nArg; i++){
13361 if( azArg[i][0]=='-' ){
13362 const char *z = azArg[i]+1;
13363 if( z[0]=='-' ) z++;
13364 if( strcmp(z,"preserve-rowids")==0 ){
@@ -13436,10 +13445,11 @@
13436 }
13437 sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0);
13438 sqlite3_exec(p->db, "RELEASE dump;", 0, 0, 0);
13439 raw_printf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n");
13440 p->showHeader = savedShowHeader;
 
13441 }else
13442
13443 if( c=='e' && strncmp(azArg[0], "echo", n)==0 ){
13444 if( nArg==2 ){
13445 setOrClearFlag(p, SHFLG_Echo, azArg[1]);
13446
--- src/shell.c
+++ src/shell.c
@@ -9533,12 +9533,20 @@
9533 }else if( aiType && aiType[i]==SQLITE_INTEGER ){
9534 utf8_printf(p->out,"%s", azArg[i]);
9535 }else if( aiType && aiType[i]==SQLITE_FLOAT ){
9536 char z[50];
9537 double r = sqlite3_column_double(p->pStmt, i);
9538 sqlite3_uint64 ur;
9539 memcpy(&ur,&r,sizeof(r));
9540 if( ur==0x7ff0000000000000LL ){
9541 raw_printf(p->out, "1e999");
9542 }else if( ur==0xfff0000000000000LL ){
9543 raw_printf(p->out, "-1e999");
9544 }else{
9545 sqlite3_snprintf(50,z,"%!.20g", r);
9546 raw_printf(p->out, "%s", z);
9547 }
9548 }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
9549 const void *pBlob = sqlite3_column_blob(p->pStmt, i);
9550 int nBlob = sqlite3_column_bytes(p->pStmt, i);
9551 output_hex_blob(p->out, pBlob, nBlob);
9552 }else if( isNumber(azArg[i], 0) ){
@@ -13354,11 +13362,12 @@
13362
13363 if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
13364 const char *zLike = 0;
13365 int i;
13366 int savedShowHeader = p->showHeader;
13367 int savedShellFlags = p->shellFlgs;
13368 ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines|SHFLG_Echo);
13369 for(i=1; i<nArg; i++){
13370 if( azArg[i][0]=='-' ){
13371 const char *z = azArg[i]+1;
13372 if( z[0]=='-' ) z++;
13373 if( strcmp(z,"preserve-rowids")==0 ){
@@ -13436,10 +13445,11 @@
13445 }
13446 sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0);
13447 sqlite3_exec(p->db, "RELEASE dump;", 0, 0, 0);
13448 raw_printf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n");
13449 p->showHeader = savedShowHeader;
13450 p->shellFlgs = savedShellFlags;
13451 }else
13452
13453 if( c=='e' && strncmp(azArg[0], "echo", n)==0 ){
13454 if( nArg==2 ){
13455 setOrClearFlag(p, SHFLG_Echo, azArg[1]);
13456
+7290 -2982
--- 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.24.0. By combining all the individual C code files into this
3
+** version 3.25.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.
@@ -1148,13 +1148,13 @@
11481148
**
11491149
** See also: [sqlite3_libversion()],
11501150
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11511151
** [sqlite_version()] and [sqlite_source_id()].
11521152
*/
1153
-#define SQLITE_VERSION "3.24.0"
1154
-#define SQLITE_VERSION_NUMBER 3024000
1155
-#define SQLITE_SOURCE_ID "2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca"
1153
+#define SQLITE_VERSION "3.25.0"
1154
+#define SQLITE_VERSION_NUMBER 3025000
1155
+#define SQLITE_SOURCE_ID "2018-07-13 20:28:54 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb36212426b1"
11561156
11571157
/*
11581158
** CAPI3REF: Run-Time Library Version Numbers
11591159
** KEYWORDS: sqlite3_version sqlite3_sourceid
11601160
**
@@ -1536,10 +1536,11 @@
15361536
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
15371537
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
15381538
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
15391539
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
15401540
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
1541
+#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
15411542
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
15421543
#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
15431544
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
15441545
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
15451546
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -3146,10 +3147,16 @@
31463147
** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
31473148
** [VACUUM] in order to reset a database back to an empty database
31483149
** with no schema and no content. The following process works even for
31493150
** a badly corrupted database file:
31503151
** <ol>
3152
+** <li> If the database connection is newly opened, make sure it has read the
3153
+** database schema by preparing then discarding some query against the
3154
+** database, or calling sqlite3_table_column_metadata(), ignoring any
3155
+** errors. This step is only necessary if the application desires to keep
3156
+** the database in WAL mode after the reset if it was in WAL mode before
3157
+** the reset.
31513158
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
31523159
** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
31533160
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
31543161
** </ol>
31553162
** Because resetting a database is destructive and irreversible, the
@@ -4379,16 +4386,27 @@
43794386
**
43804387
** ^If the most recent sqlite3_* API call associated with
43814388
** [database connection] D failed, then the sqlite3_errcode(D) interface
43824389
** returns the numeric [result code] or [extended result code] for that
43834390
** API call.
4384
-** If the most recent API call was successful,
4385
-** then the return value from sqlite3_errcode() is undefined.
43864391
** ^The sqlite3_extended_errcode()
43874392
** interface is the same except that it always returns the
43884393
** [extended result code] even when extended result codes are
43894394
** disabled.
4395
+**
4396
+** The values returned by sqlite3_errcode() and/or
4397
+** sqlite3_extended_errcode() might change with each API call.
4398
+** Except, there are some interfaces that are guaranteed to never
4399
+** change the value of the error code. The error-code preserving
4400
+** interfaces are:
4401
+**
4402
+** <ul>
4403
+** <li> sqlite3_errcode()
4404
+** <li> sqlite3_extended_errcode()
4405
+** <li> sqlite3_errmsg()
4406
+** <li> sqlite3_errmsg16()
4407
+** </ul>
43904408
**
43914409
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
43924410
** text that describes the error, as either UTF-8 or UTF-16 respectively.
43934411
** ^(Memory to hold the error message string is managed internally.
43944412
** The application does not need to worry about freeing the result.
@@ -5539,15 +5557,29 @@
55395557
** [sqlite3_finalize()] is called. ^The memory space used to hold strings
55405558
** and BLOBs is freed automatically. Do not pass the pointers returned
55415559
** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
55425560
** [sqlite3_free()].
55435561
**
5544
-** ^(If a memory allocation error occurs during the evaluation of any
5545
-** of these routines, a default value is returned. The default value
5546
-** is either the integer 0, the floating point number 0.0, or a NULL
5547
-** pointer. Subsequent calls to [sqlite3_errcode()] will return
5548
-** [SQLITE_NOMEM].)^
5562
+** As long as the input parameters are correct, these routines will only
5563
+** fail if an out-of-memory error occurs during a format conversion.
5564
+** Only the following subset of interfaces are subject to out-of-memory
5565
+** errors:
5566
+**
5567
+** <ul>
5568
+** <li> sqlite3_column_blob()
5569
+** <li> sqlite3_column_text()
5570
+** <li> sqlite3_column_text16()
5571
+** <li> sqlite3_column_bytes()
5572
+** <li> sqlite3_column_bytes16()
5573
+** </ul>
5574
+**
5575
+** If an out-of-memory error occurs, then the return value from these
5576
+** routines is the same as if the column had contained an SQL NULL value.
5577
+** Valid SQL NULL returns can be distinguished from out-of-memory errors
5578
+** by invoking the [sqlite3_errcode()] immediately after the suspect
5579
+** return value is obtained and before any
5580
+** other SQLite interface is called on the same [database connection].
55495581
*/
55505582
SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
55515583
SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
55525584
SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
55535585
SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
@@ -5620,15 +5652,17 @@
56205652
** KEYWORDS: {application-defined SQL functions}
56215653
** METHOD: sqlite3
56225654
**
56235655
** ^These functions (collectively known as "function creation routines")
56245656
** are used to add SQL functions or aggregates or to redefine the behavior
5625
-** of existing SQL functions or aggregates. The only differences between
5626
-** these routines are the text encoding expected for
5627
-** the second parameter (the name of the function being created)
5628
-** and the presence or absence of a destructor callback for
5629
-** the application data pointer.
5657
+** of existing SQL functions or aggregates. The only differences between
5658
+** the three "sqlite3_create_function*" routines are the text encoding
5659
+** expected for the second parameter (the name of the function being
5660
+** created) and the presence or absence of a destructor callback for
5661
+** the application data pointer. Function sqlite3_create_window_function()
5662
+** is similar, but allows the user to supply the extra callback functions
5663
+** needed by [aggregate window functions].
56305664
**
56315665
** ^The first parameter is the [database connection] to which the SQL
56325666
** function is to be added. ^If an application uses more than one database
56335667
** connection then application-defined SQL functions must be added
56345668
** to each database connection separately.
@@ -5670,28 +5704,38 @@
56705704
** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
56715705
**
56725706
** ^(The fifth parameter is an arbitrary pointer. The implementation of the
56735707
** function can gain access to this pointer using [sqlite3_user_data()].)^
56745708
**
5675
-** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are
5709
+** ^The sixth, seventh and eighth parameters passed to the three
5710
+** "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are
56765711
** pointers to C-language functions that implement the SQL function or
56775712
** aggregate. ^A scalar SQL function requires an implementation of the xFunc
56785713
** callback only; NULL pointers must be passed as the xStep and xFinal
56795714
** parameters. ^An aggregate SQL function requires an implementation of xStep
56805715
** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
56815716
** SQL function or aggregate, pass NULL pointers for all three function
56825717
** callbacks.
56835718
**
5684
-** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,
5685
-** then it is destructor for the application data pointer.
5686
-** The destructor is invoked when the function is deleted, either by being
5687
-** overloaded or when the database connection closes.)^
5688
-** ^The destructor is also invoked if the call to
5689
-** sqlite3_create_function_v2() fails.
5690
-** ^When the destructor callback of the tenth parameter is invoked, it
5691
-** is passed a single argument which is a copy of the application data
5692
-** pointer which was the fifth parameter to sqlite3_create_function_v2().
5719
+** ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue
5720
+** and xInverse) passed to sqlite3_create_window_function are pointers to
5721
+** C-lanugage callbacks that implement the new function. xStep and xFinal
5722
+** must both be non-NULL. xValue and xInverse may either both be NULL, in
5723
+** which case a regular aggregate function is created, or must both be
5724
+** non-NULL, in which case the new function may be used as either an aggregate
5725
+** or aggregate window function. More details regarding the implementation
5726
+** of aggregate window functions are
5727
+** [user-defined window functions|available here].
5728
+**
5729
+** ^(If the final parameter to sqlite3_create_function_v2() or
5730
+** sqlite3_create_window_function() is not NULL, then it is destructor for
5731
+** the application data pointer. The destructor is invoked when the function
5732
+** is deleted, either by being overloaded or when the database connection
5733
+** closes.)^ ^The destructor is also invoked if the call to
5734
+** sqlite3_create_function_v2() fails. ^When the destructor callback is
5735
+** invoked, it is passed a single argument which is a copy of the application
5736
+** data pointer which was the fifth parameter to sqlite3_create_function_v2().
56935737
**
56945738
** ^It is permitted to register multiple implementations of the same
56955739
** functions with the same name but with either differing numbers of
56965740
** arguments or differing preferred text encodings. ^SQLite will use
56975741
** the implementation that most closely matches the way in which the
@@ -5739,10 +5783,22 @@
57395783
void *pApp,
57405784
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
57415785
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
57425786
void (*xFinal)(sqlite3_context*),
57435787
void(*xDestroy)(void*)
5788
+);
5789
+SQLITE_API int sqlite3_create_window_function(
5790
+ sqlite3 *db,
5791
+ const char *zFunctionName,
5792
+ int nArg,
5793
+ int eTextRep,
5794
+ void *pApp,
5795
+ void (*xStep)(sqlite3_context*,int,sqlite3_value**),
5796
+ void (*xFinal)(sqlite3_context*),
5797
+ void (*xValue)(sqlite3_context*),
5798
+ void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
5799
+ void(*xDestroy)(void*)
57445800
);
57455801
57465802
/*
57475803
** CAPI3REF: Text Encodings
57485804
**
@@ -5882,10 +5938,32 @@
58825938
** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
58835939
** or [sqlite3_value_text16()].
58845940
**
58855941
** These routines must be called from the same thread as
58865942
** the SQL function that supplied the [sqlite3_value*] parameters.
5943
+**
5944
+** As long as the input parameter is correct, these routines can only
5945
+** fail if an out-of-memory error occurs during a format conversion.
5946
+** Only the following subset of interfaces are subject to out-of-memory
5947
+** errors:
5948
+**
5949
+** <ul>
5950
+** <li> sqlite3_value_blob()
5951
+** <li> sqlite3_value_text()
5952
+** <li> sqlite3_value_text16()
5953
+** <li> sqlite3_value_text16le()
5954
+** <li> sqlite3_value_text16be()
5955
+** <li> sqlite3_value_bytes()
5956
+** <li> sqlite3_value_bytes16()
5957
+** </ul>
5958
+**
5959
+** If an out-of-memory error occurs, then the return value from these
5960
+** routines is the same as if the column had contained an SQL NULL value.
5961
+** Valid SQL NULL returns can be distinguished from out-of-memory errors
5962
+** by invoking the [sqlite3_errcode()] immediately after the suspect
5963
+** return value is obtained and before any
5964
+** other SQLite interface is called on the same [database connection].
58875965
*/
58885966
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
58895967
SQLITE_API double sqlite3_value_double(sqlite3_value*);
58905968
SQLITE_API int sqlite3_value_int(sqlite3_value*);
58915969
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
@@ -12877,10 +12955,21 @@
1287712955
#endif
1287812956
#if defined(NDEBUG) && defined(SQLITE_DEBUG)
1287912957
# undef NDEBUG
1288012958
#endif
1288112959
12960
+/* SQLITE_DEBUG_COLUMNCACHE is synomous with SQLITE_DEBUG. The
12961
+** SQLITE_DEBUG_COLUMNCACHE symbol only exists to provide a convenient
12962
+** way to search for all code that deals with verifying correct behavior
12963
+** of the column cache.
12964
+*/
12965
+#ifdef SQLITE_DEBUG
12966
+# define SQLITE_DEBUG_COLUMNCACHE 1
12967
+#else
12968
+# undef SQLIT_DEBUG_COLUMNCACHE
12969
+#endif
12970
+
1288212971
/*
1288312972
** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
1288412973
*/
1288512974
#if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)
1288612975
# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
@@ -13214,98 +13303,108 @@
1321413303
#define TK_RAISE 71
1321513304
#define TK_RECURSIVE 72
1321613305
#define TK_REPLACE 73
1321713306
#define TK_RESTRICT 74
1321813307
#define TK_ROW 75
13219
-#define TK_TRIGGER 76
13220
-#define TK_VACUUM 77
13221
-#define TK_VIEW 78
13222
-#define TK_VIRTUAL 79
13223
-#define TK_WITH 80
13224
-#define TK_REINDEX 81
13225
-#define TK_RENAME 82
13226
-#define TK_CTIME_KW 83
13227
-#define TK_ANY 84
13228
-#define TK_BITAND 85
13229
-#define TK_BITOR 86
13230
-#define TK_LSHIFT 87
13231
-#define TK_RSHIFT 88
13232
-#define TK_PLUS 89
13233
-#define TK_MINUS 90
13234
-#define TK_STAR 91
13235
-#define TK_SLASH 92
13236
-#define TK_REM 93
13237
-#define TK_CONCAT 94
13238
-#define TK_COLLATE 95
13239
-#define TK_BITNOT 96
13240
-#define TK_ON 97
13241
-#define TK_INDEXED 98
13242
-#define TK_STRING 99
13243
-#define TK_JOIN_KW 100
13244
-#define TK_CONSTRAINT 101
13245
-#define TK_DEFAULT 102
13246
-#define TK_NULL 103
13247
-#define TK_PRIMARY 104
13248
-#define TK_UNIQUE 105
13249
-#define TK_CHECK 106
13250
-#define TK_REFERENCES 107
13251
-#define TK_AUTOINCR 108
13252
-#define TK_INSERT 109
13253
-#define TK_DELETE 110
13254
-#define TK_UPDATE 111
13255
-#define TK_SET 112
13256
-#define TK_DEFERRABLE 113
13257
-#define TK_FOREIGN 114
13258
-#define TK_DROP 115
13259
-#define TK_UNION 116
13260
-#define TK_ALL 117
13261
-#define TK_EXCEPT 118
13262
-#define TK_INTERSECT 119
13263
-#define TK_SELECT 120
13264
-#define TK_VALUES 121
13265
-#define TK_DISTINCT 122
13266
-#define TK_DOT 123
13267
-#define TK_FROM 124
13268
-#define TK_JOIN 125
13269
-#define TK_USING 126
13270
-#define TK_ORDER 127
13271
-#define TK_GROUP 128
13272
-#define TK_HAVING 129
13273
-#define TK_LIMIT 130
13274
-#define TK_WHERE 131
13275
-#define TK_INTO 132
13276
-#define TK_NOTHING 133
13277
-#define TK_FLOAT 134
13278
-#define TK_BLOB 135
13279
-#define TK_INTEGER 136
13280
-#define TK_VARIABLE 137
13281
-#define TK_CASE 138
13282
-#define TK_WHEN 139
13283
-#define TK_THEN 140
13284
-#define TK_ELSE 141
13285
-#define TK_INDEX 142
13286
-#define TK_ALTER 143
13287
-#define TK_ADD 144
13288
-#define TK_TRUEFALSE 145
13289
-#define TK_ISNOT 146
13290
-#define TK_FUNCTION 147
13291
-#define TK_COLUMN 148
13292
-#define TK_AGG_FUNCTION 149
13293
-#define TK_AGG_COLUMN 150
13294
-#define TK_UMINUS 151
13295
-#define TK_UPLUS 152
13296
-#define TK_TRUTH 153
13297
-#define TK_REGISTER 154
13298
-#define TK_VECTOR 155
13299
-#define TK_SELECT_COLUMN 156
13300
-#define TK_IF_NULL_ROW 157
13301
-#define TK_ASTERISK 158
13302
-#define TK_SPAN 159
13303
-#define TK_END_OF_FILE 160
13304
-#define TK_UNCLOSED_STRING 161
13305
-#define TK_SPACE 162
13306
-#define TK_ILLEGAL 163
13308
+#define TK_ROWS 76
13309
+#define TK_TRIGGER 77
13310
+#define TK_VACUUM 78
13311
+#define TK_VIEW 79
13312
+#define TK_VIRTUAL 80
13313
+#define TK_WITH 81
13314
+#define TK_CURRENT 82
13315
+#define TK_FOLLOWING 83
13316
+#define TK_PARTITION 84
13317
+#define TK_PRECEDING 85
13318
+#define TK_RANGE 86
13319
+#define TK_UNBOUNDED 87
13320
+#define TK_REINDEX 88
13321
+#define TK_RENAME 89
13322
+#define TK_CTIME_KW 90
13323
+#define TK_ANY 91
13324
+#define TK_BITAND 92
13325
+#define TK_BITOR 93
13326
+#define TK_LSHIFT 94
13327
+#define TK_RSHIFT 95
13328
+#define TK_PLUS 96
13329
+#define TK_MINUS 97
13330
+#define TK_STAR 98
13331
+#define TK_SLASH 99
13332
+#define TK_REM 100
13333
+#define TK_CONCAT 101
13334
+#define TK_COLLATE 102
13335
+#define TK_BITNOT 103
13336
+#define TK_ON 104
13337
+#define TK_INDEXED 105
13338
+#define TK_STRING 106
13339
+#define TK_JOIN_KW 107
13340
+#define TK_CONSTRAINT 108
13341
+#define TK_DEFAULT 109
13342
+#define TK_NULL 110
13343
+#define TK_PRIMARY 111
13344
+#define TK_UNIQUE 112
13345
+#define TK_CHECK 113
13346
+#define TK_REFERENCES 114
13347
+#define TK_AUTOINCR 115
13348
+#define TK_INSERT 116
13349
+#define TK_DELETE 117
13350
+#define TK_UPDATE 118
13351
+#define TK_SET 119
13352
+#define TK_DEFERRABLE 120
13353
+#define TK_FOREIGN 121
13354
+#define TK_DROP 122
13355
+#define TK_UNION 123
13356
+#define TK_ALL 124
13357
+#define TK_EXCEPT 125
13358
+#define TK_INTERSECT 126
13359
+#define TK_SELECT 127
13360
+#define TK_VALUES 128
13361
+#define TK_DISTINCT 129
13362
+#define TK_DOT 130
13363
+#define TK_FROM 131
13364
+#define TK_JOIN 132
13365
+#define TK_USING 133
13366
+#define TK_ORDER 134
13367
+#define TK_GROUP 135
13368
+#define TK_HAVING 136
13369
+#define TK_LIMIT 137
13370
+#define TK_WHERE 138
13371
+#define TK_INTO 139
13372
+#define TK_NOTHING 140
13373
+#define TK_FLOAT 141
13374
+#define TK_BLOB 142
13375
+#define TK_INTEGER 143
13376
+#define TK_VARIABLE 144
13377
+#define TK_CASE 145
13378
+#define TK_WHEN 146
13379
+#define TK_THEN 147
13380
+#define TK_ELSE 148
13381
+#define TK_INDEX 149
13382
+#define TK_ALTER 150
13383
+#define TK_ADD 151
13384
+#define TK_WINDOW 152
13385
+#define TK_OVER 153
13386
+#define TK_FILTER 154
13387
+#define TK_TRUEFALSE 155
13388
+#define TK_ISNOT 156
13389
+#define TK_FUNCTION 157
13390
+#define TK_COLUMN 158
13391
+#define TK_AGG_FUNCTION 159
13392
+#define TK_AGG_COLUMN 160
13393
+#define TK_UMINUS 161
13394
+#define TK_UPLUS 162
13395
+#define TK_TRUTH 163
13396
+#define TK_REGISTER 164
13397
+#define TK_VECTOR 165
13398
+#define TK_SELECT_COLUMN 166
13399
+#define TK_IF_NULL_ROW 167
13400
+#define TK_ASTERISK 168
13401
+#define TK_SPAN 169
13402
+#define TK_END_OF_FILE 170
13403
+#define TK_UNCLOSED_STRING 171
13404
+#define TK_SPACE 172
13405
+#define TK_ILLEGAL 173
1330713406
1330813407
/* The token codes above must all fit in 8 bits */
1330913408
#define TKFLG_MASK 0xff
1331013409
1331113410
/* Flags that can be added to a token code when it is not
@@ -13891,12 +13990,39 @@
1389113990
typedef struct Upsert Upsert;
1389213991
typedef struct VTable VTable;
1389313992
typedef struct VtabCtx VtabCtx;
1389413993
typedef struct Walker Walker;
1389513994
typedef struct WhereInfo WhereInfo;
13995
+typedef struct Window Window;
1389613996
typedef struct With With;
1389713997
13998
+
13999
+/*
14000
+** The bitmask datatype defined below is used for various optimizations.
14001
+**
14002
+** Changing this from a 64-bit to a 32-bit type limits the number of
14003
+** tables in a join to 32 instead of 64. But it also reduces the size
14004
+** of the library by 738 bytes on ix86.
14005
+*/
14006
+#ifdef SQLITE_BITMASK_TYPE
14007
+ typedef SQLITE_BITMASK_TYPE Bitmask;
14008
+#else
14009
+ typedef u64 Bitmask;
14010
+#endif
14011
+
14012
+/*
14013
+** The number of bits in a Bitmask. "BMS" means "BitMask Size".
14014
+*/
14015
+#define BMS ((int)(sizeof(Bitmask)*8))
14016
+
14017
+/*
14018
+** A bit in a Bitmask
14019
+*/
14020
+#define MASKBIT(n) (((Bitmask)1)<<(n))
14021
+#define MASKBIT32(n) (((unsigned int)1)<<(n))
14022
+#define ALLBITS ((Bitmask)-1)
14023
+
1389814024
/* A VList object records a mapping between parameters/variables/wildcards
1389914025
** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer
1390014026
** variable number associated with that parameter. See the format description
1390114027
** on the sqlite3VListAdd() routine for more information. A VList is really
1390214028
** just an array of integers.
@@ -13988,11 +14114,11 @@
1398814114
SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int);
1398914115
SQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree*);
1399014116
SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p);
1399114117
SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
1399214118
SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);
13993
-SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int);
14119
+SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int,int*);
1399414120
SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
1399514121
SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*, int);
1399614122
SQLITE_PRIVATE int sqlite3BtreeCommit(Btree*);
1399714123
SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int,int);
1399814124
SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);
@@ -14211,10 +14337,13 @@
1421114337
};
1421214338
1421314339
SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
1421414340
int flags, int seekResult);
1421514341
SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
14342
+#ifndef SQLITE_OMIT_WINDOWFUNC
14343
+SQLITE_PRIVATE void sqlite3BtreeSkipNext(BtCursor*);
14344
+#endif
1421614345
SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
1421714346
SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
1421814347
SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
1421914348
SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
1422014349
SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
@@ -14378,11 +14507,12 @@
1437814507
#ifdef VDBE_PROFILE
1437914508
u32 cnt; /* Number of times this instruction was executed */
1438014509
u64 cycles; /* Total time spent executing this instruction */
1438114510
#endif
1438214511
#ifdef SQLITE_VDBE_COVERAGE
14383
- int iSrcLine; /* Source-code line that generated this opcode */
14512
+ u32 iSrcLine; /* Source-code line that generated this opcode
14513
+ ** with flags in the upper 8 bits */
1438414514
#endif
1438514515
};
1438614516
typedef struct VdbeOp VdbeOp;
1438714517
1438814518
@@ -14479,122 +14609,122 @@
1447914609
/* See the tool/mkopcodeh.tcl script for details */
1448014610
#define OP_Savepoint 0
1448114611
#define OP_AutoCommit 1
1448214612
#define OP_Transaction 2
1448314613
#define OP_SorterNext 3 /* jump */
14484
-#define OP_PrevIfOpen 4 /* jump */
14485
-#define OP_NextIfOpen 5 /* jump */
14486
-#define OP_Prev 6 /* jump */
14487
-#define OP_Next 7 /* jump */
14488
-#define OP_Checkpoint 8
14489
-#define OP_JournalMode 9
14490
-#define OP_Vacuum 10
14491
-#define OP_VFilter 11 /* jump, synopsis: iplan=r[P3] zplan='P4' */
14492
-#define OP_VUpdate 12 /* synopsis: data=r[P3@P2] */
14493
-#define OP_Goto 13 /* jump */
14494
-#define OP_Gosub 14 /* jump */
14495
-#define OP_InitCoroutine 15 /* jump */
14496
-#define OP_Yield 16 /* jump */
14497
-#define OP_MustBeInt 17 /* jump */
14498
-#define OP_Jump 18 /* jump */
14614
+#define OP_Prev 4 /* jump */
14615
+#define OP_Next 5 /* jump */
14616
+#define OP_Checkpoint 6
14617
+#define OP_JournalMode 7
14618
+#define OP_Vacuum 8
14619
+#define OP_VFilter 9 /* jump, synopsis: iplan=r[P3] zplan='P4' */
14620
+#define OP_VUpdate 10 /* synopsis: data=r[P3@P2] */
14621
+#define OP_Goto 11 /* jump */
14622
+#define OP_Gosub 12 /* jump */
14623
+#define OP_InitCoroutine 13 /* jump */
14624
+#define OP_Yield 14 /* jump */
14625
+#define OP_MustBeInt 15 /* jump */
14626
+#define OP_Jump 16 /* jump */
14627
+#define OP_Once 17 /* jump */
14628
+#define OP_If 18 /* jump */
1449914629
#define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */
14500
-#define OP_Once 20 /* jump */
14501
-#define OP_If 21 /* jump */
14502
-#define OP_IfNot 22 /* jump */
14503
-#define OP_IfNullRow 23 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
14504
-#define OP_SeekLT 24 /* jump, synopsis: key=r[P3@P4] */
14505
-#define OP_SeekLE 25 /* jump, synopsis: key=r[P3@P4] */
14506
-#define OP_SeekGE 26 /* jump, synopsis: key=r[P3@P4] */
14507
-#define OP_SeekGT 27 /* jump, synopsis: key=r[P3@P4] */
14508
-#define OP_NoConflict 28 /* jump, synopsis: key=r[P3@P4] */
14509
-#define OP_NotFound 29 /* jump, synopsis: key=r[P3@P4] */
14510
-#define OP_Found 30 /* jump, synopsis: key=r[P3@P4] */
14511
-#define OP_SeekRowid 31 /* jump, synopsis: intkey=r[P3] */
14512
-#define OP_NotExists 32 /* jump, synopsis: intkey=r[P3] */
14513
-#define OP_Last 33 /* jump */
14514
-#define OP_IfSmaller 34 /* jump */
14515
-#define OP_SorterSort 35 /* jump */
14516
-#define OP_Sort 36 /* jump */
14517
-#define OP_Rewind 37 /* jump */
14518
-#define OP_IdxLE 38 /* jump, synopsis: key=r[P3@P4] */
14519
-#define OP_IdxGT 39 /* jump, synopsis: key=r[P3@P4] */
14520
-#define OP_IdxLT 40 /* jump, synopsis: key=r[P3@P4] */
14521
-#define OP_IdxGE 41 /* jump, synopsis: key=r[P3@P4] */
14522
-#define OP_RowSetRead 42 /* jump, synopsis: r[P3]=rowset(P1) */
14630
+#define OP_IfNot 20 /* jump */
14631
+#define OP_IfNullRow 21 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
14632
+#define OP_SeekLT 22 /* jump, synopsis: key=r[P3@P4] */
14633
+#define OP_SeekLE 23 /* jump, synopsis: key=r[P3@P4] */
14634
+#define OP_SeekGE 24 /* jump, synopsis: key=r[P3@P4] */
14635
+#define OP_SeekGT 25 /* jump, synopsis: key=r[P3@P4] */
14636
+#define OP_IfNoHope 26 /* jump, synopsis: key=r[P3@P4] */
14637
+#define OP_NoConflict 27 /* jump, synopsis: key=r[P3@P4] */
14638
+#define OP_NotFound 28 /* jump, synopsis: key=r[P3@P4] */
14639
+#define OP_Found 29 /* jump, synopsis: key=r[P3@P4] */
14640
+#define OP_SeekRowid 30 /* jump, synopsis: intkey=r[P3] */
14641
+#define OP_NotExists 31 /* jump, synopsis: intkey=r[P3] */
14642
+#define OP_Last 32 /* jump */
14643
+#define OP_IfSmaller 33 /* jump */
14644
+#define OP_SorterSort 34 /* jump */
14645
+#define OP_Sort 35 /* jump */
14646
+#define OP_Rewind 36 /* jump */
14647
+#define OP_IdxLE 37 /* jump, synopsis: key=r[P3@P4] */
14648
+#define OP_IdxGT 38 /* jump, synopsis: key=r[P3@P4] */
14649
+#define OP_IdxLT 39 /* jump, synopsis: key=r[P3@P4] */
14650
+#define OP_IdxGE 40 /* jump, synopsis: key=r[P3@P4] */
14651
+#define OP_RowSetRead 41 /* jump, synopsis: r[P3]=rowset(P1) */
14652
+#define OP_RowSetTest 42 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
1452314653
#define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
1452414654
#define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
14525
-#define OP_RowSetTest 45 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
14526
-#define OP_Program 46 /* jump */
14527
-#define OP_FkIfZero 47 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
14528
-#define OP_IfPos 48 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
14529
-#define OP_IfNotZero 49 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
14655
+#define OP_Program 45 /* jump */
14656
+#define OP_FkIfZero 46 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
14657
+#define OP_IfPos 47 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
14658
+#define OP_IfNotZero 48 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
14659
+#define OP_DecrJumpZero 49 /* jump, synopsis: if (--r[P1])==0 goto P2 */
1453014660
#define OP_IsNull 50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
1453114661
#define OP_NotNull 51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
1453214662
#define OP_Ne 52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
1453314663
#define OP_Eq 53 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
1453414664
#define OP_Gt 54 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
1453514665
#define OP_Le 55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
1453614666
#define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
1453714667
#define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
1453814668
#define OP_ElseNotEq 58 /* jump, same as TK_ESCAPE */
14539
-#define OP_DecrJumpZero 59 /* jump, synopsis: if (--r[P1])==0 goto P2 */
14540
-#define OP_IncrVacuum 60 /* jump */
14541
-#define OP_VNext 61 /* jump */
14542
-#define OP_Init 62 /* jump, synopsis: Start at P2 */
14543
-#define OP_Return 63
14544
-#define OP_EndCoroutine 64
14545
-#define OP_HaltIfNull 65 /* synopsis: if r[P3]=null halt */
14546
-#define OP_Halt 66
14547
-#define OP_Integer 67 /* synopsis: r[P2]=P1 */
14548
-#define OP_Int64 68 /* synopsis: r[P2]=P4 */
14549
-#define OP_String 69 /* synopsis: r[P2]='P4' (len=P1) */
14550
-#define OP_Null 70 /* synopsis: r[P2..P3]=NULL */
14551
-#define OP_SoftNull 71 /* synopsis: r[P1]=NULL */
14552
-#define OP_Blob 72 /* synopsis: r[P2]=P4 (len=P1) */
14553
-#define OP_Variable 73 /* synopsis: r[P2]=parameter(P1,P4) */
14554
-#define OP_Move 74 /* synopsis: r[P2@P3]=r[P1@P3] */
14555
-#define OP_Copy 75 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
14556
-#define OP_SCopy 76 /* synopsis: r[P2]=r[P1] */
14557
-#define OP_IntCopy 77 /* synopsis: r[P2]=r[P1] */
14558
-#define OP_ResultRow 78 /* synopsis: output=r[P1@P2] */
14559
-#define OP_CollSeq 79
14560
-#define OP_AddImm 80 /* synopsis: r[P1]=r[P1]+P2 */
14561
-#define OP_RealAffinity 81
14562
-#define OP_Cast 82 /* synopsis: affinity(r[P1]) */
14563
-#define OP_Permutation 83
14564
-#define OP_Compare 84 /* synopsis: r[P1@P3] <-> r[P2@P3] */
14565
-#define OP_BitAnd 85 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
14566
-#define OP_BitOr 86 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
14567
-#define OP_ShiftLeft 87 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
14568
-#define OP_ShiftRight 88 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
14569
-#define OP_Add 89 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
14570
-#define OP_Subtract 90 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
14571
-#define OP_Multiply 91 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
14572
-#define OP_Divide 92 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
14573
-#define OP_Remainder 93 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
14574
-#define OP_Concat 94 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
14575
-#define OP_IsTrue 95 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
14576
-#define OP_BitNot 96 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
14577
-#define OP_Offset 97 /* synopsis: r[P3] = sqlite_offset(P1) */
14578
-#define OP_Column 98 /* synopsis: r[P3]=PX */
14579
-#define OP_String8 99 /* same as TK_STRING, synopsis: r[P2]='P4' */
14580
-#define OP_Affinity 100 /* synopsis: affinity(r[P1@P2]) */
14581
-#define OP_MakeRecord 101 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
14582
-#define OP_Count 102 /* synopsis: r[P2]=count() */
14583
-#define OP_ReadCookie 103
14584
-#define OP_SetCookie 104
14585
-#define OP_ReopenIdx 105 /* synopsis: root=P2 iDb=P3 */
14586
-#define OP_OpenRead 106 /* synopsis: root=P2 iDb=P3 */
14587
-#define OP_OpenWrite 107 /* synopsis: root=P2 iDb=P3 */
14588
-#define OP_OpenDup 108
14589
-#define OP_OpenAutoindex 109 /* synopsis: nColumn=P2 */
14590
-#define OP_OpenEphemeral 110 /* synopsis: nColumn=P2 */
14591
-#define OP_SorterOpen 111
14592
-#define OP_SequenceTest 112 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
14593
-#define OP_OpenPseudo 113 /* synopsis: P3 columns in r[P2] */
14594
-#define OP_Close 114
14595
-#define OP_ColumnsUsed 115
14669
+#define OP_IncrVacuum 59 /* jump */
14670
+#define OP_VNext 60 /* jump */
14671
+#define OP_Init 61 /* jump, synopsis: Start at P2 */
14672
+#define OP_Return 62
14673
+#define OP_EndCoroutine 63
14674
+#define OP_HaltIfNull 64 /* synopsis: if r[P3]=null halt */
14675
+#define OP_Halt 65
14676
+#define OP_Integer 66 /* synopsis: r[P2]=P1 */
14677
+#define OP_Int64 67 /* synopsis: r[P2]=P4 */
14678
+#define OP_String 68 /* synopsis: r[P2]='P4' (len=P1) */
14679
+#define OP_Null 69 /* synopsis: r[P2..P3]=NULL */
14680
+#define OP_SoftNull 70 /* synopsis: r[P1]=NULL */
14681
+#define OP_Blob 71 /* synopsis: r[P2]=P4 (len=P1) */
14682
+#define OP_Variable 72 /* synopsis: r[P2]=parameter(P1,P4) */
14683
+#define OP_Move 73 /* synopsis: r[P2@P3]=r[P1@P3] */
14684
+#define OP_Copy 74 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
14685
+#define OP_SCopy 75 /* synopsis: r[P2]=r[P1] */
14686
+#define OP_IntCopy 76 /* synopsis: r[P2]=r[P1] */
14687
+#define OP_ResultRow 77 /* synopsis: output=r[P1@P2] */
14688
+#define OP_CollSeq 78
14689
+#define OP_AddImm 79 /* synopsis: r[P1]=r[P1]+P2 */
14690
+#define OP_RealAffinity 80
14691
+#define OP_Cast 81 /* synopsis: affinity(r[P1]) */
14692
+#define OP_Permutation 82
14693
+#define OP_Compare 83 /* synopsis: r[P1@P3] <-> r[P2@P3] */
14694
+#define OP_IsTrue 84 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
14695
+#define OP_Offset 85 /* synopsis: r[P3] = sqlite_offset(P1) */
14696
+#define OP_Column 86 /* synopsis: r[P3]=PX */
14697
+#define OP_Affinity 87 /* synopsis: affinity(r[P1@P2]) */
14698
+#define OP_MakeRecord 88 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
14699
+#define OP_Count 89 /* synopsis: r[P2]=count() */
14700
+#define OP_ReadCookie 90
14701
+#define OP_SetCookie 91
14702
+#define OP_BitAnd 92 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
14703
+#define OP_BitOr 93 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
14704
+#define OP_ShiftLeft 94 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
14705
+#define OP_ShiftRight 95 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
14706
+#define OP_Add 96 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
14707
+#define OP_Subtract 97 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
14708
+#define OP_Multiply 98 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
14709
+#define OP_Divide 99 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
14710
+#define OP_Remainder 100 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
14711
+#define OP_Concat 101 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
14712
+#define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
14713
+#define OP_BitNot 103 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
14714
+#define OP_OpenRead 104 /* synopsis: root=P2 iDb=P3 */
14715
+#define OP_OpenWrite 105 /* synopsis: root=P2 iDb=P3 */
14716
+#define OP_String8 106 /* same as TK_STRING, synopsis: r[P2]='P4' */
14717
+#define OP_OpenDup 107
14718
+#define OP_OpenAutoindex 108 /* synopsis: nColumn=P2 */
14719
+#define OP_OpenEphemeral 109 /* synopsis: nColumn=P2 */
14720
+#define OP_SorterOpen 110
14721
+#define OP_SequenceTest 111 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
14722
+#define OP_OpenPseudo 112 /* synopsis: P3 columns in r[P2] */
14723
+#define OP_Close 113
14724
+#define OP_ColumnsUsed 114
14725
+#define OP_SeekHit 115 /* synopsis: seekHit=P2 */
1459614726
#define OP_Sequence 116 /* synopsis: r[P2]=cursor[P1].ctr++ */
1459714727
#define OP_NewRowid 117 /* synopsis: r[P2]=rowid */
1459814728
#define OP_Insert 118 /* synopsis: intkey=r[P3] data=r[P2] */
1459914729
#define OP_InsertInt 119 /* synopsis: intkey=P3 data=r[P2] */
1460014730
#define OP_Delete 120
@@ -14609,48 +14739,52 @@
1460914739
#define OP_IdxInsert 129 /* synopsis: key=r[P2] */
1461014740
#define OP_IdxDelete 130 /* synopsis: key=r[P2@P3] */
1461114741
#define OP_DeferredSeek 131 /* synopsis: Move P3 to P1.rowid if needed */
1461214742
#define OP_IdxRowid 132 /* synopsis: r[P2]=rowid */
1461314743
#define OP_Destroy 133
14614
-#define OP_Real 134 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
14615
-#define OP_Clear 135
14616
-#define OP_ResetSorter 136
14617
-#define OP_CreateBtree 137 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
14618
-#define OP_SqlExec 138
14619
-#define OP_ParseSchema 139
14620
-#define OP_LoadAnalysis 140
14621
-#define OP_DropTable 141
14744
+#define OP_Clear 134
14745
+#define OP_ResetSorter 135
14746
+#define OP_CreateBtree 136 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
14747
+#define OP_SqlExec 137
14748
+#define OP_ParseSchema 138
14749
+#define OP_LoadAnalysis 139
14750
+#define OP_DropTable 140
14751
+#define OP_Real 141 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
1462214752
#define OP_DropIndex 142
1462314753
#define OP_DropTrigger 143
1462414754
#define OP_IntegrityCk 144
1462514755
#define OP_RowSetAdd 145 /* synopsis: rowset(P1)=r[P2] */
1462614756
#define OP_Param 146
1462714757
#define OP_FkCounter 147 /* synopsis: fkctr[P1]+=P2 */
1462814758
#define OP_MemMax 148 /* synopsis: r[P1]=max(r[P1],r[P2]) */
1462914759
#define OP_OffsetLimit 149 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
14630
-#define OP_AggStep0 150 /* synopsis: accum=r[P3] step(r[P2@P5]) */
14760
+#define OP_AggInverse 150 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
1463114761
#define OP_AggStep 151 /* synopsis: accum=r[P3] step(r[P2@P5]) */
14632
-#define OP_AggFinal 152 /* synopsis: accum=r[P1] N=P2 */
14633
-#define OP_Expire 153
14634
-#define OP_TableLock 154 /* synopsis: iDb=P1 root=P2 write=P3 */
14635
-#define OP_VBegin 155
14636
-#define OP_VCreate 156
14637
-#define OP_VDestroy 157
14638
-#define OP_VOpen 158
14639
-#define OP_VColumn 159 /* synopsis: r[P3]=vcolumn(P2) */
14640
-#define OP_VRename 160
14641
-#define OP_Pagecount 161
14642
-#define OP_MaxPgcnt 162
14643
-#define OP_PureFunc0 163
14644
-#define OP_Function0 164 /* synopsis: r[P3]=func(r[P2@P5]) */
14645
-#define OP_PureFunc 165
14646
-#define OP_Function 166 /* synopsis: r[P3]=func(r[P2@P5]) */
14647
-#define OP_Trace 167
14648
-#define OP_CursorHint 168
14649
-#define OP_Noop 169
14650
-#define OP_Explain 170
14651
-#define OP_Abortable 171
14762
+#define OP_AggStep1 152 /* synopsis: accum=r[P3] step(r[P2@P5]) */
14763
+#define OP_AggValue 153 /* synopsis: r[P3]=value N=P2 */
14764
+#define OP_AggFinal 154 /* synopsis: accum=r[P1] N=P2 */
14765
+#define OP_Expire 155
14766
+#define OP_TableLock 156 /* synopsis: iDb=P1 root=P2 write=P3 */
14767
+#define OP_VBegin 157
14768
+#define OP_VCreate 158
14769
+#define OP_VDestroy 159
14770
+#define OP_VOpen 160
14771
+#define OP_VColumn 161 /* synopsis: r[P3]=vcolumn(P2) */
14772
+#define OP_VRename 162
14773
+#define OP_Pagecount 163
14774
+#define OP_MaxPgcnt 164
14775
+#define OP_PureFunc0 165
14776
+#define OP_Function0 166 /* synopsis: r[P3]=func(r[P2@P5]) */
14777
+#define OP_PureFunc 167
14778
+#define OP_Function 168 /* synopsis: r[P3]=func(r[P2@P5]) */
14779
+#define OP_Trace 169
14780
+#define OP_CursorHint 170
14781
+#define OP_SetTabCol 171
14782
+#define OP_VerifyTabCol 172
14783
+#define OP_Noop 173
14784
+#define OP_Explain 174
14785
+#define OP_Abortable 175
1465214786
1465314787
/* Properties such as "out2" or "jump" that are specified in
1465414788
** comments following the "case" for each opcode in the vdbe.c
1465514789
** are encoded into bitvectors as follows:
1465614790
*/
@@ -14659,40 +14793,41 @@
1465914793
#define OPFLG_IN2 0x04 /* in2: P2 is an input */
1466014794
#define OPFLG_IN3 0x08 /* in3: P3 is an input */
1466114795
#define OPFLG_OUT2 0x10 /* out2: P2 is an output */
1466214796
#define OPFLG_OUT3 0x20 /* out3: P3 is an output */
1466314797
#define OPFLG_INITIALIZER {\
14664
-/* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\
14665
-/* 8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\
14666
-/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x01,\
14798
+/* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\
14799
+/* 8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\
14800
+/* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x01, 0x09, 0x09,\
1466714801
/* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
14668
-/* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
14669
-/* 40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\
14802
+/* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
14803
+/* 40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\
1467014804
/* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
14671
-/* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x02,\
14672
-/* 64 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\
14673
-/* 72 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
14674
-/* 80 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x26, 0x26, 0x26,\
14675
-/* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x12,\
14676
-/* 96 */ 0x12, 0x20, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10,\
14677
-/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
14805
+/* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02,\
14806
+/* 64 */ 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10,\
14807
+/* 72 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x02,\
14808
+/* 80 */ 0x02, 0x02, 0x00, 0x00, 0x12, 0x20, 0x00, 0x00,\
14809
+/* 88 */ 0x00, 0x10, 0x10, 0x00, 0x26, 0x26, 0x26, 0x26,\
14810
+/* 96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\
14811
+/* 104 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
1467814812
/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
1467914813
/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
14680
-/* 128 */ 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
14681
-/* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
14814
+/* 128 */ 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
14815
+/* 136 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
1468214816
/* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00,\
1468314817
/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
14684
-/* 160 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
14685
-/* 168 */ 0x00, 0x00, 0x00, 0x00,}
14818
+/* 160 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
14819
+/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
14820
+}
1468614821
1468714822
/* The sqlite3P2Values() routine is able to run faster if it knows
1468814823
** the value of the largest JUMP opcode. The smaller the maximum
1468914824
** JUMP opcode the better, so the mkopcodeh.tcl script that
1469014825
** generated this include file strives to group all JUMP opcodes
1469114826
** together near the beginning of the list.
1469214827
*/
14693
-#define SQLITE_MX_JUMP_OPCODE 62 /* Maximum JUMP opcode */
14828
+#define SQLITE_MX_JUMP_OPCODE 61 /* Maximum JUMP opcode */
1469414829
1469514830
/************** End of opcodes.h *********************************************/
1469614831
/************** Continuing where we left off in vdbe.h ***********************/
1469714832
1469814833
/*
@@ -14786,10 +14921,11 @@
1478614921
SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
1478714922
#ifndef SQLITE_OMIT_TRACE
1478814923
SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*);
1478914924
#endif
1479014925
SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
14926
+SQLITE_PRIVATE int sqlite3BlobCompare(const Mem*, const Mem*);
1479114927
1479214928
SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);
1479314929
SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
1479414930
SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int);
1479514931
SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*);
@@ -14841,35 +14977,68 @@
1484114977
**
1484214978
** VdbeCoverageAlwaysTaken(v) // Previous branch is always taken
1484314979
**
1484414980
** VdbeCoverageNeverTaken(v) // Previous branch is never taken
1484514981
**
14982
+** VdbeCoverageNeverNull(v) // Previous three-way branch is only
14983
+** // taken on the first two ways. The
14984
+** // NULL option is not possible
14985
+**
14986
+** VdbeCoverageEqNe(v) // Previous OP_Jump is only interested
14987
+** // in distingishing equal and not-equal.
14988
+**
1484614989
** Every VDBE branch operation must be tagged with one of the macros above.
1484714990
** If not, then when "make test" is run with -DSQLITE_VDBE_COVERAGE and
1484814991
** -DSQLITE_DEBUG then an ALWAYS() will fail in the vdbeTakeBranch()
1484914992
** routine in vdbe.c, alerting the developer to the missed tag.
14993
+**
14994
+** During testing, the test application will invoke
14995
+** sqlite3_test_control(SQLITE_TESTCTRL_VDBE_COVERAGE,...) to set a callback
14996
+** routine that is invoked as each bytecode branch is taken. The callback
14997
+** contains the sqlite3.c source line number ov the VdbeCoverage macro and
14998
+** flags to indicate whether or not the branch was taken. The test application
14999
+** is responsible for keeping track of this and reporting byte-code branches
15000
+** that are never taken.
15001
+**
15002
+** See the VdbeBranchTaken() macro and vdbeTakeBranch() function in the
15003
+** vdbe.c source file for additional information.
1485015004
*/
1485115005
#ifdef SQLITE_VDBE_COVERAGE
1485215006
SQLITE_PRIVATE void sqlite3VdbeSetLineNumber(Vdbe*,int);
1485315007
# define VdbeCoverage(v) sqlite3VdbeSetLineNumber(v,__LINE__)
1485415008
# define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__)
14855
-# define VdbeCoverageAlwaysTaken(v) sqlite3VdbeSetLineNumber(v,2);
14856
-# define VdbeCoverageNeverTaken(v) sqlite3VdbeSetLineNumber(v,1);
15009
+# define VdbeCoverageAlwaysTaken(v) \
15010
+ sqlite3VdbeSetLineNumber(v,__LINE__|0x5000000);
15011
+# define VdbeCoverageNeverTaken(v) \
15012
+ sqlite3VdbeSetLineNumber(v,__LINE__|0x6000000);
15013
+# define VdbeCoverageNeverNull(v) \
15014
+ sqlite3VdbeSetLineNumber(v,__LINE__|0x4000000);
15015
+# define VdbeCoverageNeverNullIf(v,x) \
15016
+ if(x)sqlite3VdbeSetLineNumber(v,__LINE__|0x4000000);
15017
+# define VdbeCoverageEqNe(v) \
15018
+ sqlite3VdbeSetLineNumber(v,__LINE__|0x8000000);
1485715019
# define VDBE_OFFSET_LINENO(x) (__LINE__+x)
1485815020
#else
1485915021
# define VdbeCoverage(v)
1486015022
# define VdbeCoverageIf(v,x)
1486115023
# define VdbeCoverageAlwaysTaken(v)
1486215024
# define VdbeCoverageNeverTaken(v)
15025
+# define VdbeCoverageNeverNull(v)
15026
+# define VdbeCoverageNeverNullIf(v,x)
15027
+# define VdbeCoverageEqNe(v)
1486315028
# define VDBE_OFFSET_LINENO(x) 0
1486415029
#endif
1486515030
1486615031
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
1486715032
SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
1486815033
#else
1486915034
# define sqlite3VdbeScanStatus(a,b,c,d,e)
1487015035
#endif
15036
+
15037
+#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
15038
+SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, VdbeOp*);
15039
+#endif
1487115040
1487215041
#endif /* SQLITE_VDBE_H */
1487315042
1487415043
/************** End of vdbe.h ************************************************/
1487515044
/************** Continuing where we left off in sqliteInt.h ******************/
@@ -16082,10 +16251,11 @@
1608216251
#define SQLITE_CursorHints 0x0400 /* Add OP_CursorHint opcodes */
1608316252
#define SQLITE_Stat34 0x0800 /* Use STAT3 or STAT4 data */
1608416253
/* TH3 expects the Stat34 ^^^^^^ value to be 0x0800. Don't change it */
1608516254
#define SQLITE_PushDown 0x1000 /* The push-down optimization */
1608616255
#define SQLITE_SimplifyJoin 0x2000 /* Convert LEFT JOIN to JOIN */
16256
+#define SQLITE_SkipScan 0x4000 /* Skip-scans */
1608716257
#define SQLITE_AllOpts 0xffff /* All optimizations */
1608816258
1608916259
/*
1609016260
** Macros for testing whether or not optimizations are enabled or disabled.
1609116261
*/
@@ -16120,15 +16290,17 @@
1612016290
** The u.pHash field is used by the global built-ins. The u.pDestructor
1612116291
** field is used by per-connection app-def functions.
1612216292
*/
1612316293
struct FuncDef {
1612416294
i8 nArg; /* Number of arguments. -1 means unlimited */
16125
- u16 funcFlags; /* Some combination of SQLITE_FUNC_* */
16295
+ u32 funcFlags; /* Some combination of SQLITE_FUNC_* */
1612616296
void *pUserData; /* User data parameter */
1612716297
FuncDef *pNext; /* Next function with same name */
1612816298
void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
1612916299
void (*xFinalize)(sqlite3_context*); /* Agg finalizer */
16300
+ void (*xValue)(sqlite3_context*); /* Current agg value */
16301
+ void (*xInverse)(sqlite3_context*,int,sqlite3_value**); /* inverse agg-step */
1613016302
const char *zName; /* SQL name of the function. */
1613116303
union {
1613216304
FuncDef *pHash; /* Next with a different name but the same hash */
1613316305
FuncDestructor *pDestructor; /* Reference counted destructor function */
1613416306
} u;
@@ -16181,10 +16353,12 @@
1618116353
#define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */
1618216354
#define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
1618316355
** single query - might change over time */
1618416356
#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
1618516357
#define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */
16358
+#define SQLITE_FUNC_WINDOW 0x10000 /* Built-in window-only function */
16359
+#define SQLITE_FUNC_WINDOW_SIZE 0x20000 /* Requires partition size as arg. */
1618616360
1618716361
/*
1618816362
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
1618916363
** used to create the initializers for the FuncDef structures.
1619016364
**
@@ -16214,10 +16388,16 @@
1621416388
** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
1621516389
** Used to create an aggregate function definition implemented by
1621616390
** the C functions xStep and xFinal. The first four parameters
1621716391
** are interpreted in the same way as the first 4 parameters to
1621816392
** FUNCTION().
16393
+**
16394
+** WFUNCTION(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)
16395
+** Used to create an aggregate function definition implemented by
16396
+** the C functions xStep and xFinal. The first four parameters
16397
+** are interpreted in the same way as the first 4 parameters to
16398
+** FUNCTION().
1621916399
**
1622016400
** LIKEFUNC(zName, nArg, pArg, flags)
1622116401
** Used to create a scalar function definition of a function zName
1622216402
** that accepts nArg arguments and is implemented by a call to C
1622316403
** function likeFunc. Argument pArg is cast to a (void *) and made
@@ -16225,35 +16405,39 @@
1622516405
** FuncDef.flags variable is set to the value passed as the flags
1622616406
** parameter.
1622716407
*/
1622816408
#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
1622916409
{nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
16230
- SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
16410
+ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
1623116411
#define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
1623216412
{nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
16233
- SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
16413
+ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
1623416414
#define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \
1623516415
{nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \
16236
- 0, 0, xFunc, 0, #zName, {0} }
16416
+ 0, 0, xFunc, 0, 0, 0, #zName, {0} }
1623716417
#define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \
1623816418
{nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
16239
- (void*)&sqlite3Config, 0, xFunc, 0, #zName, {0} }
16419
+ (void*)&sqlite3Config, 0, xFunc, 0, 0, 0, #zName, {0} }
1624016420
#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
1624116421
{nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
16242
- SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
16422
+ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
1624316423
#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
1624416424
{nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
16245
- pArg, 0, xFunc, 0, #zName, }
16425
+ pArg, 0, xFunc, 0, 0, 0, #zName, }
1624616426
#define LIKEFUNC(zName, nArg, arg, flags) \
1624716427
{nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
16248
- (void *)arg, 0, likeFunc, 0, #zName, {0} }
16249
-#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \
16428
+ (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
16429
+#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue) \
1625016430
{nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \
16251
- SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName, {0}}
16431
+ SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,0,#zName, {0}}
1625216432
#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \
1625316433
{nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
16254
- SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName, {0}}
16434
+ SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xFinal,0,#zName, {0}}
16435
+
16436
+#define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
16437
+ {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
16438
+ SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}}
1625516439
1625616440
/*
1625716441
** All current savepoints are stored in a linked list starting at
1625816442
** sqlite3.pSavepoint. The first element in the list is the most recently
1625916443
** opened savepoint. Savepoints are added to the list by the vdbe
@@ -16735,10 +16919,11 @@
1673516919
tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
1673616920
IndexSample *aSample; /* Samples of the left-most key */
1673716921
tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */
1673816922
tRowcnt nRowEst0; /* Non-logarithmic number of rows in the index */
1673916923
#endif
16924
+ Bitmask colNotIdxed; /* 0 for unindexed columns in pTab */
1674016925
};
1674116926
1674216927
/*
1674316928
** Allowed values for Index.idxType
1674416929
*/
@@ -16950,10 +17135,13 @@
1695017135
** TK_COLUMN: the value of p5 for OP_Column
1695117136
** TK_AGG_FUNCTION: nesting depth */
1695217137
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
1695317138
Table *pTab; /* Table for TK_COLUMN expressions. Can be NULL
1695417139
** for a column of an index on an expression */
17140
+#ifndef SQLITE_OMIT_WINDOWFUNC
17141
+ Window *pWin; /* Window definition for window functions */
17142
+#endif
1695517143
};
1695617144
1695717145
/*
1695817146
** The following are the meanings of bits in the Expr.flags field.
1695917147
*/
@@ -17080,35 +17268,10 @@
1708017268
int idx; /* Index in some Table.aCol[] of a column named zName */
1708117269
} *a;
1708217270
int nId; /* Number of identifiers on the list */
1708317271
};
1708417272
17085
-/*
17086
-** The bitmask datatype defined below is used for various optimizations.
17087
-**
17088
-** Changing this from a 64-bit to a 32-bit type limits the number of
17089
-** tables in a join to 32 instead of 64. But it also reduces the size
17090
-** of the library by 738 bytes on ix86.
17091
-*/
17092
-#ifdef SQLITE_BITMASK_TYPE
17093
- typedef SQLITE_BITMASK_TYPE Bitmask;
17094
-#else
17095
- typedef u64 Bitmask;
17096
-#endif
17097
-
17098
-/*
17099
-** The number of bits in a Bitmask. "BMS" means "BitMask Size".
17100
-*/
17101
-#define BMS ((int)(sizeof(Bitmask)*8))
17102
-
17103
-/*
17104
-** A bit in a Bitmask
17105
-*/
17106
-#define MASKBIT(n) (((Bitmask)1)<<(n))
17107
-#define MASKBIT32(n) (((unsigned int)1)<<(n))
17108
-#define ALLBITS ((Bitmask)-1)
17109
-
1711017273
/*
1711117274
** The following structure describes the FROM clause of a SELECT statement.
1711217275
** Each table or subquery in the FROM clause is a separate element of
1711317276
** the SrcList.a[] array.
1711417277
**
@@ -17236,10 +17399,11 @@
1723617399
} uNC;
1723717400
NameContext *pNext; /* Next outer name context. NULL for outermost */
1723817401
int nRef; /* Number of names resolved by this context */
1723917402
int nErr; /* Number of errors encountered while resolving names */
1724017403
u16 ncFlags; /* Zero or more NC_* flags defined below */
17404
+ Select *pWinSelect; /* SELECT statement for any window functions */
1724117405
};
1724217406
1724317407
/*
1724417408
** Allowed values for the NameContext, ncFlags field.
1724517409
**
@@ -17258,10 +17422,11 @@
1725817422
#define NC_UEList 0x0080 /* True if uNC.pEList is used */
1725917423
#define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */
1726017424
#define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */
1726117425
#define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
1726217426
#define NC_Complex 0x2000 /* True if a function or subquery seen */
17427
+#define NC_AllowWin 0x4000 /* Window functions are allowed here */
1726317428
1726417429
/*
1726517430
** An instance of the following object describes a single ON CONFLICT
1726617431
** clause in an upsert.
1726717432
**
@@ -17312,13 +17477,11 @@
1731217477
ExprList *pEList; /* The fields of the result */
1731317478
u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
1731417479
LogEst nSelectRow; /* Estimated number of result rows */
1731517480
u32 selFlags; /* Various SF_* values */
1731617481
int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */
17317
-#if SELECTTRACE_ENABLED
17318
- char zSelName[12]; /* Symbolic name of this SELECT use for debugging */
17319
-#endif
17482
+ u32 selId; /* Unique identifier number for this SELECT */
1732017483
int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */
1732117484
SrcList *pSrc; /* The FROM clause */
1732217485
Expr *pWhere; /* The WHERE clause */
1732317486
ExprList *pGroupBy; /* The GROUP BY clause */
1732417487
Expr *pHaving; /* The HAVING clause */
@@ -17325,10 +17488,14 @@
1732517488
ExprList *pOrderBy; /* The ORDER BY clause */
1732617489
Select *pPrior; /* Prior select in a compound select statement */
1732717490
Select *pNext; /* Next select to the left in a compound */
1732817491
Expr *pLimit; /* LIMIT expression. NULL means not used. */
1732917492
With *pWith; /* WITH clause attached to this select. Or NULL. */
17493
+#ifndef SQLITE_OMIT_WINDOWFUNC
17494
+ Window *pWin; /* List of window functions */
17495
+ Window *pWinDefn; /* List of named window definitions */
17496
+#endif
1733017497
};
1733117498
1733217499
/*
1733317500
** Allowed values for Select.selFlags. The "SF" prefix stands for
1733417501
** "Select Flag".
@@ -17571,13 +17738,11 @@
1757117738
yDbMask writeMask; /* Start a write transaction on these databases */
1757217739
yDbMask cookieMask; /* Bitmask of schema verified databases */
1757317740
int regRowid; /* Register holding rowid of CREATE TABLE entry */
1757417741
int regRoot; /* Register holding root page number for new objects */
1757517742
int nMaxArg; /* Max args passed to user function by sub-program */
17576
-#if SELECTTRACE_ENABLED
17577
- int nSelect; /* Number of SELECT statements seen */
17578
-#endif
17743
+ int nSelect; /* Number of SELECT stmts. Counter for Select.selId */
1757917744
#ifndef SQLITE_OMIT_SHARED_CACHE
1758017745
int nTableLock; /* Number of locks in aTableLock */
1758117746
TableLock *aTableLock; /* Required table locks for shared-cache mode */
1758217747
#endif
1758317748
AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
@@ -17887,11 +18052,11 @@
1788718052
#endif
1788818053
#ifdef SQLITE_VDBE_COVERAGE
1788918054
/* The following callback (if not NULL) is invoked on every VDBE branch
1789018055
** operation. Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE.
1789118056
*/
17892
- void (*xVdbeBranch)(void*,int iSrcLine,u8 eThis,u8 eMx); /* Callback */
18057
+ void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */
1789318058
void *pVdbeBranchArg; /* 1st argument */
1789418059
#endif
1789518060
#ifndef SQLITE_UNTESTABLE
1789618061
int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
1789718062
#endif
@@ -17938,10 +18103,11 @@
1793818103
int *aiCol; /* array of column indexes */
1793918104
struct IdxCover *pIdxCover; /* Check for index coverage */
1794018105
struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */
1794118106
ExprList *pGroupBy; /* GROUP BY clause */
1794218107
Select *pSelect; /* HAVING to WHERE clause ctx */
18108
+ struct WindowRewrite *pRewrite; /* Window rewrite context */
1794318109
} u;
1794418110
};
1794518111
1794618112
/* Forward declarations */
1794718113
SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -17988,10 +18154,72 @@
1798818154
int iLevel; /* Which level of the tree we are on */
1798918155
u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */
1799018156
};
1799118157
#endif /* SQLITE_DEBUG */
1799218158
18159
+/*
18160
+** This object is used in varioius ways, all related to window functions
18161
+**
18162
+** (1) A single instance of this structure is attached to the
18163
+** the Expr.pWin field for each window function in an expression tree.
18164
+** This object holds the information contained in the OVER clause,
18165
+** plus additional fields used during code generation.
18166
+**
18167
+** (2) All window functions in a single SELECT form a linked-list
18168
+** attached to Select.pWin. The Window.pFunc and Window.pExpr
18169
+** fields point back to the expression that is the window function.
18170
+**
18171
+** (3) The terms of the WINDOW clause of a SELECT are instances of this
18172
+** object on a linked list attached to Select.pWinDefn.
18173
+**
18174
+** The uses (1) and (2) are really the same Window object that just happens
18175
+** to be accessible in two different ways. Use (3) is are separate objects.
18176
+*/
18177
+struct Window {
18178
+ char *zName; /* Name of window (may be NULL) */
18179
+ ExprList *pPartition; /* PARTITION BY clause */
18180
+ ExprList *pOrderBy; /* ORDER BY clause */
18181
+ u8 eType; /* TK_RANGE or TK_ROWS */
18182
+ u8 eStart; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
18183
+ u8 eEnd; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
18184
+ Expr *pStart; /* Expression for "<expr> PRECEDING" */
18185
+ Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
18186
+ Window *pNextWin; /* Next window function belonging to this SELECT */
18187
+ Expr *pFilter; /* The FILTER expression */
18188
+ FuncDef *pFunc; /* The function */
18189
+ int iEphCsr; /* Partition buffer or Peer buffer */
18190
+ int regAccum;
18191
+ int regResult;
18192
+ int csrApp; /* Function cursor (used by min/max) */
18193
+ int regApp; /* Function register (also used by min/max) */
18194
+ int regPart; /* First in a set of registers holding PARTITION BY
18195
+ ** and ORDER BY values for the window */
18196
+ Expr *pOwner; /* Expression object this window is attached to */
18197
+ int nBufferCol; /* Number of columns in buffer table */
18198
+ int iArgCol; /* Offset of first argument for this function */
18199
+};
18200
+
18201
+#ifndef SQLITE_OMIT_WINDOWFUNC
18202
+SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3*, Window*);
18203
+SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p);
18204
+SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*);
18205
+SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*);
18206
+SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*);
18207
+SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*);
18208
+SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);
18209
+SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*);
18210
+SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*);
18211
+SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*);
18212
+SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p);
18213
+SQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p);
18214
+SQLITE_PRIVATE void sqlite3WindowFunctions(void);
18215
+#else
18216
+# define sqlite3WindowDelete(a,b)
18217
+# define sqlite3WindowFunctions()
18218
+# define sqlite3WindowAttach(a,b,c)
18219
+#endif
18220
+
1799318221
/*
1799418222
** Assuming zIn points to the first byte of a UTF-8 character,
1799518223
** advance zIn to point to the first byte of the next UTF-8 character.
1799618224
*/
1799718225
#define SQLITE_SKIP_UTF8(zIn) { \
@@ -18202,10 +18430,14 @@
1820218430
SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
1820318431
SQLITE_PRIVATE void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);
1820418432
SQLITE_PRIVATE void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
1820518433
SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
1820618434
SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView*, const With*, u8);
18435
+#ifndef SQLITE_OMIT_WINDOWFUNC
18436
+SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView*, const Window*, u8);
18437
+SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8);
18438
+#endif
1820718439
#endif
1820818440
1820918441
1821018442
SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*);
1821118443
SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);
@@ -18457,15 +18689,10 @@
1845718689
SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
1845818690
SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
1845918691
SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
1846018692
SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
1846118693
SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
18462
-#if SELECTTRACE_ENABLED
18463
-SQLITE_PRIVATE void sqlite3SelectSetName(Select*,const char*);
18464
-#else
18465
-# define sqlite3SelectSetName(A,B)
18466
-#endif
1846718694
SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int);
1846818695
SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
1846918696
SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);
1847018697
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
1847118698
SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
@@ -18695,16 +18922,21 @@
1869518922
SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
1869618923
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);
1869718924
SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo*);
1869818925
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo*);
1869918926
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);
18927
+SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList(Parse*, ExprList*, int, int);
18928
+
1870018929
#ifdef SQLITE_DEBUG
1870118930
SQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo*);
1870218931
#endif
1870318932
SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
1870418933
void (*)(sqlite3_context*,int,sqlite3_value **),
18705
- void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
18934
+ void (*)(sqlite3_context*,int,sqlite3_value **),
18935
+ void (*)(sqlite3_context*),
18936
+ void (*)(sqlite3_context*),
18937
+ void (*)(sqlite3_context*,int,sqlite3_value **),
1870618938
FuncDestructor *pDestructor
1870718939
);
1870818940
SQLITE_PRIVATE void sqlite3NoopDestructor(void*);
1870918941
SQLITE_PRIVATE void sqlite3OomFault(sqlite3*);
1871018942
SQLITE_PRIVATE void sqlite3OomClear(sqlite3*);
@@ -18741,10 +18973,11 @@
1874118973
#ifndef SQLITE_AMALGAMATION
1874218974
SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64), Parse*);
1874318975
SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*));
1874418976
#endif
1874518977
SQLITE_PRIVATE void sqlite3Parser(void*, int, Token);
18978
+SQLITE_PRIVATE int sqlite3ParserFallback(int);
1874618979
#ifdef YYTRACKMAXSTACKDEPTH
1874718980
SQLITE_PRIVATE int sqlite3ParserStackPeak(void*);
1874818981
#endif
1874918982
1875018983
SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3*);
@@ -19441,10 +19674,11 @@
1944119674
u8 wrFlag; /* The wrFlag argument to sqlite3BtreeCursor() */
1944219675
#endif
1944319676
Bool isEphemeral:1; /* True for an ephemeral table */
1944419677
Bool useRandomRowid:1; /* Generate new record numbers semi-randomly */
1944519678
Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
19679
+ Bool seekHit:1; /* See the OP_SeekHit and OP_IfNoHope opcodes */
1944619680
Btree *pBtx; /* Separate file holding temporary table */
1944719681
i64 seqCount; /* Sequence counter */
1944819682
int *aAltMap; /* Mapping from table to index column numbers */
1944919683
1945019684
/* Cached OP_Column parse information is only valid if cacheStatus matches
@@ -19564,11 +19798,15 @@
1956419798
u32 uTemp; /* Transient storage for serial_type in OP_MakeRecord */
1956519799
sqlite3 *db; /* The associated database connection */
1956619800
void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
1956719801
#ifdef SQLITE_DEBUG
1956819802
Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
19569
- void *pFiller; /* So that sizeof(Mem) is a multiple of 8 */
19803
+ u16 mScopyFlags; /* flags value immediately after the shallow copy */
19804
+#endif
19805
+#ifdef SQLITE_DEBUG_COLUMNCACHE
19806
+ u32 iTabColHash; /* Hash of table.column that is origin of this value */
19807
+ u32 iPadding; /* sqlite3_value objects must be 8-byte aligned */
1957019808
#endif
1957119809
};
1957219810
1957319811
/*
1957419812
** Size of struct Mem not including the Mem.zMalloc member or anything that
@@ -19804,13 +20042,10 @@
1980420042
SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...);
1980520043
SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);
1980620044
void sqliteVdbePopStack(Vdbe*,int);
1980720045
SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, int*);
1980820046
SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
19809
-#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
19810
-SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, Op*);
19811
-#endif
1981220047
SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
1981320048
SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
1981420049
SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int, u32*);
1981520050
SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
1981620051
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
@@ -19851,10 +20086,13 @@
1985120086
SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
1985220087
SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem*,u8,u8);
1985320088
SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);
1985420089
SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
1985520090
SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
20091
+#ifndef SQLITE_OMIT_WINDOWFUNC
20092
+SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*);
20093
+#endif
1985620094
SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
1985720095
SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
1985820096
SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int n);
1985920097
SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
1986020098
SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
@@ -21953,13 +22191,16 @@
2195322191
2195422192
/*
2195522193
** Unregister a VFS so that it is no longer accessible.
2195622194
*/
2195722195
SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
21958
-#if SQLITE_THREADSAFE
21959
- sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
22196
+ MUTEX_LOGIC(sqlite3_mutex *mutex;)
22197
+#ifndef SQLITE_OMIT_AUTOINIT
22198
+ int rc = sqlite3_initialize();
22199
+ if( rc ) return rc;
2196022200
#endif
22201
+ MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )
2196122202
sqlite3_mutex_enter(mutex);
2196222203
vfsUnlink(pVfs);
2196322204
sqlite3_mutex_leave(mutex);
2196422205
return SQLITE_OK;
2196522206
}
@@ -27984,25 +28225,17 @@
2798428225
sqlite3TreeViewWith(pView, p->pWith, 1);
2798528226
cnt = 1;
2798628227
sqlite3TreeViewPush(pView, 1);
2798728228
}
2798828229
do{
27989
-#if SELECTTRACE_ENABLED
27990
- sqlite3TreeViewLine(pView,
27991
- "SELECT%s%s (%s/%p) selFlags=0x%x nSelectRow=%d",
27992
- ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
27993
- ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""),
27994
- p->zSelName, p, p->selFlags,
27995
- (int)p->nSelectRow
27996
- );
27997
-#else
27998
- sqlite3TreeViewLine(pView, "SELECT%s%s (0x%p) selFlags=0x%x nSelectRow=%d",
27999
- ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
28000
- ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""), p, p->selFlags,
28001
- (int)p->nSelectRow
28002
- );
28003
-#endif
28230
+ sqlite3TreeViewLine(pView,
28231
+ "SELECT%s%s (%u/%p) selFlags=0x%x nSelectRow=%d",
28232
+ ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
28233
+ ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""),
28234
+ p->selId, p, p->selFlags,
28235
+ (int)p->nSelectRow
28236
+ );
2800428237
if( cnt++ ) sqlite3TreeViewPop(pView);
2800528238
if( p->pPrior ){
2800628239
n = 1000;
2800728240
}else{
2800828241
n = 0;
@@ -28010,12 +28243,27 @@
2801028243
if( p->pWhere ) n++;
2801128244
if( p->pGroupBy ) n++;
2801228245
if( p->pHaving ) n++;
2801328246
if( p->pOrderBy ) n++;
2801428247
if( p->pLimit ) n++;
28248
+#ifndef SQLITE_OMIT_WINDOWFUNC
28249
+ if( p->pWin ) n++;
28250
+ if( p->pWinDefn ) n++;
28251
+#endif
2801528252
}
2801628253
sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, "result-set");
28254
+#ifndef SQLITE_OMIT_WINDOWFUNC
28255
+ if( p->pWin ){
28256
+ Window *pX;
28257
+ pView = sqlite3TreeViewPush(pView, (n--)>0);
28258
+ sqlite3TreeViewLine(pView, "window-functions");
28259
+ for(pX=p->pWin; pX; pX=pX->pNextWin){
28260
+ sqlite3TreeViewWinFunc(pView, pX, pX->pNextWin!=0);
28261
+ }
28262
+ sqlite3TreeViewPop(pView);
28263
+ }
28264
+#endif
2801728265
if( p->pSrc && p->pSrc->nSrc ){
2801828266
int i;
2801928267
pView = sqlite3TreeViewPush(pView, (n--)>0);
2802028268
sqlite3TreeViewLine(pView, "FROM");
2802128269
for(i=0; i<p->pSrc->nSrc; i++){
@@ -28061,10 +28309,20 @@
2806128309
if( p->pHaving ){
2806228310
sqlite3TreeViewItem(pView, "HAVING", (n--)>0);
2806328311
sqlite3TreeViewExpr(pView, p->pHaving, 0);
2806428312
sqlite3TreeViewPop(pView);
2806528313
}
28314
+#ifndef SQLITE_OMIT_WINDOWFUNC
28315
+ if( p->pWinDefn ){
28316
+ Window *pX;
28317
+ sqlite3TreeViewItem(pView, "WINDOW", (n--)>0);
28318
+ for(pX=p->pWinDefn; pX; pX=pX->pNextWin){
28319
+ sqlite3TreeViewWindow(pView, pX, pX->pNextWin!=0);
28320
+ }
28321
+ sqlite3TreeViewPop(pView);
28322
+ }
28323
+#endif
2806628324
if( p->pOrderBy ){
2806728325
sqlite3TreeViewExprList(pView, p->pOrderBy, (n--)>0, "ORDERBY");
2806828326
}
2806928327
if( p->pLimit ){
2807028328
sqlite3TreeViewItem(pView, "LIMIT", (n--)>0);
@@ -28088,10 +28346,87 @@
2808828346
p = p->pPrior;
2808928347
}while( p!=0 );
2809028348
sqlite3TreeViewPop(pView);
2809128349
}
2809228350
28351
+#ifndef SQLITE_OMIT_WINDOWFUNC
28352
+/*
28353
+** Generate a description of starting or stopping bounds
28354
+*/
28355
+SQLITE_PRIVATE void sqlite3TreeViewBound(
28356
+ TreeView *pView, /* View context */
28357
+ u8 eBound, /* UNBOUNDED, CURRENT, PRECEDING, FOLLOWING */
28358
+ Expr *pExpr, /* Value for PRECEDING or FOLLOWING */
28359
+ u8 moreToFollow /* True if more to follow */
28360
+){
28361
+ switch( eBound ){
28362
+ case TK_UNBOUNDED: {
28363
+ sqlite3TreeViewItem(pView, "UNBOUNDED", moreToFollow);
28364
+ sqlite3TreeViewPop(pView);
28365
+ break;
28366
+ }
28367
+ case TK_CURRENT: {
28368
+ sqlite3TreeViewItem(pView, "CURRENT", moreToFollow);
28369
+ sqlite3TreeViewPop(pView);
28370
+ break;
28371
+ }
28372
+ case TK_PRECEDING: {
28373
+ sqlite3TreeViewItem(pView, "PRECEDING", moreToFollow);
28374
+ sqlite3TreeViewExpr(pView, pExpr, 0);
28375
+ sqlite3TreeViewPop(pView);
28376
+ break;
28377
+ }
28378
+ case TK_FOLLOWING: {
28379
+ sqlite3TreeViewItem(pView, "FOLLOWING", moreToFollow);
28380
+ sqlite3TreeViewExpr(pView, pExpr, 0);
28381
+ sqlite3TreeViewPop(pView);
28382
+ break;
28383
+ }
28384
+ }
28385
+}
28386
+#endif /* SQLITE_OMIT_WINDOWFUNC */
28387
+
28388
+#ifndef SQLITE_OMIT_WINDOWFUNC
28389
+/*
28390
+** Generate a human-readable explanation for a Window object
28391
+*/
28392
+SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u8 more){
28393
+ pView = sqlite3TreeViewPush(pView, more);
28394
+ if( pWin->zName ){
28395
+ sqlite3TreeViewLine(pView, "OVER %s", pWin->zName);
28396
+ }else{
28397
+ sqlite3TreeViewLine(pView, "OVER");
28398
+ }
28399
+ if( pWin->pPartition ){
28400
+ sqlite3TreeViewExprList(pView, pWin->pPartition, 1, "PARTITION-BY");
28401
+ }
28402
+ if( pWin->pOrderBy ){
28403
+ sqlite3TreeViewExprList(pView, pWin->pOrderBy, 1, "ORDER-BY");
28404
+ }
28405
+ if( pWin->eType ){
28406
+ sqlite3TreeViewItem(pView, pWin->eType==TK_RANGE ? "RANGE" : "ROWS", 0);
28407
+ sqlite3TreeViewBound(pView, pWin->eStart, pWin->pStart, 1);
28408
+ sqlite3TreeViewBound(pView, pWin->eEnd, pWin->pEnd, 0);
28409
+ sqlite3TreeViewPop(pView);
28410
+ }
28411
+ sqlite3TreeViewPop(pView);
28412
+}
28413
+#endif /* SQLITE_OMIT_WINDOWFUNC */
28414
+
28415
+#ifndef SQLITE_OMIT_WINDOWFUNC
28416
+/*
28417
+** Generate a human-readable explanation for a Window Function object
28418
+*/
28419
+SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView *pView, const Window *pWin, u8 more){
28420
+ pView = sqlite3TreeViewPush(pView, more);
28421
+ sqlite3TreeViewLine(pView, "WINFUNC %s(%d)",
28422
+ pWin->pFunc->zName, pWin->pFunc->nArg);
28423
+ sqlite3TreeViewWindow(pView, pWin, 0);
28424
+ sqlite3TreeViewPop(pView);
28425
+}
28426
+#endif /* SQLITE_OMIT_WINDOWFUNC */
28427
+
2809328428
/*
2809428429
** Generate a human-readable explanation of an expression tree.
2809528430
*/
2809628431
SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){
2809728432
const char *zBinOp = 0; /* Binary operator */
@@ -28238,24 +28573,36 @@
2823828573
}
2823928574
2824028575
case TK_AGG_FUNCTION:
2824128576
case TK_FUNCTION: {
2824228577
ExprList *pFarg; /* List of function arguments */
28578
+ Window *pWin;
2824328579
if( ExprHasProperty(pExpr, EP_TokenOnly) ){
2824428580
pFarg = 0;
28581
+ pWin = 0;
2824528582
}else{
2824628583
pFarg = pExpr->x.pList;
28584
+#ifndef SQLITE_OMIT_WINDOWFUNC
28585
+ pWin = pExpr->pWin;
28586
+#else
28587
+ pWin = 0;
28588
+#endif
2824728589
}
2824828590
if( pExpr->op==TK_AGG_FUNCTION ){
2824928591
sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q",
2825028592
pExpr->op2, pExpr->u.zToken);
2825128593
}else{
2825228594
sqlite3TreeViewLine(pView, "FUNCTION %Q", pExpr->u.zToken);
2825328595
}
2825428596
if( pFarg ){
28255
- sqlite3TreeViewExprList(pView, pFarg, 0, 0);
28597
+ sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);
2825628598
}
28599
+#ifndef SQLITe_OMIT_WINDOWFUNC
28600
+ if( pWin ){
28601
+ sqlite3TreeViewWindow(pView, pWin, 0);
28602
+ }
28603
+#endif
2825728604
break;
2825828605
}
2825928606
#ifndef SQLITE_OMIT_SUBQUERY
2826028607
case TK_EXISTS: {
2826128608
sqlite3TreeViewLine(pView, "EXISTS-expr flags=0x%x", pExpr->flags);
@@ -31283,122 +31630,122 @@
3128331630
static const char *const azName[] = {
3128431631
/* 0 */ "Savepoint" OpHelp(""),
3128531632
/* 1 */ "AutoCommit" OpHelp(""),
3128631633
/* 2 */ "Transaction" OpHelp(""),
3128731634
/* 3 */ "SorterNext" OpHelp(""),
31288
- /* 4 */ "PrevIfOpen" OpHelp(""),
31289
- /* 5 */ "NextIfOpen" OpHelp(""),
31290
- /* 6 */ "Prev" OpHelp(""),
31291
- /* 7 */ "Next" OpHelp(""),
31292
- /* 8 */ "Checkpoint" OpHelp(""),
31293
- /* 9 */ "JournalMode" OpHelp(""),
31294
- /* 10 */ "Vacuum" OpHelp(""),
31295
- /* 11 */ "VFilter" OpHelp("iplan=r[P3] zplan='P4'"),
31296
- /* 12 */ "VUpdate" OpHelp("data=r[P3@P2]"),
31297
- /* 13 */ "Goto" OpHelp(""),
31298
- /* 14 */ "Gosub" OpHelp(""),
31299
- /* 15 */ "InitCoroutine" OpHelp(""),
31300
- /* 16 */ "Yield" OpHelp(""),
31301
- /* 17 */ "MustBeInt" OpHelp(""),
31302
- /* 18 */ "Jump" OpHelp(""),
31635
+ /* 4 */ "Prev" OpHelp(""),
31636
+ /* 5 */ "Next" OpHelp(""),
31637
+ /* 6 */ "Checkpoint" OpHelp(""),
31638
+ /* 7 */ "JournalMode" OpHelp(""),
31639
+ /* 8 */ "Vacuum" OpHelp(""),
31640
+ /* 9 */ "VFilter" OpHelp("iplan=r[P3] zplan='P4'"),
31641
+ /* 10 */ "VUpdate" OpHelp("data=r[P3@P2]"),
31642
+ /* 11 */ "Goto" OpHelp(""),
31643
+ /* 12 */ "Gosub" OpHelp(""),
31644
+ /* 13 */ "InitCoroutine" OpHelp(""),
31645
+ /* 14 */ "Yield" OpHelp(""),
31646
+ /* 15 */ "MustBeInt" OpHelp(""),
31647
+ /* 16 */ "Jump" OpHelp(""),
31648
+ /* 17 */ "Once" OpHelp(""),
31649
+ /* 18 */ "If" OpHelp(""),
3130331650
/* 19 */ "Not" OpHelp("r[P2]= !r[P1]"),
31304
- /* 20 */ "Once" OpHelp(""),
31305
- /* 21 */ "If" OpHelp(""),
31306
- /* 22 */ "IfNot" OpHelp(""),
31307
- /* 23 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"),
31308
- /* 24 */ "SeekLT" OpHelp("key=r[P3@P4]"),
31309
- /* 25 */ "SeekLE" OpHelp("key=r[P3@P4]"),
31310
- /* 26 */ "SeekGE" OpHelp("key=r[P3@P4]"),
31311
- /* 27 */ "SeekGT" OpHelp("key=r[P3@P4]"),
31312
- /* 28 */ "NoConflict" OpHelp("key=r[P3@P4]"),
31313
- /* 29 */ "NotFound" OpHelp("key=r[P3@P4]"),
31314
- /* 30 */ "Found" OpHelp("key=r[P3@P4]"),
31315
- /* 31 */ "SeekRowid" OpHelp("intkey=r[P3]"),
31316
- /* 32 */ "NotExists" OpHelp("intkey=r[P3]"),
31317
- /* 33 */ "Last" OpHelp(""),
31318
- /* 34 */ "IfSmaller" OpHelp(""),
31319
- /* 35 */ "SorterSort" OpHelp(""),
31320
- /* 36 */ "Sort" OpHelp(""),
31321
- /* 37 */ "Rewind" OpHelp(""),
31322
- /* 38 */ "IdxLE" OpHelp("key=r[P3@P4]"),
31323
- /* 39 */ "IdxGT" OpHelp("key=r[P3@P4]"),
31324
- /* 40 */ "IdxLT" OpHelp("key=r[P3@P4]"),
31325
- /* 41 */ "IdxGE" OpHelp("key=r[P3@P4]"),
31326
- /* 42 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
31651
+ /* 20 */ "IfNot" OpHelp(""),
31652
+ /* 21 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"),
31653
+ /* 22 */ "SeekLT" OpHelp("key=r[P3@P4]"),
31654
+ /* 23 */ "SeekLE" OpHelp("key=r[P3@P4]"),
31655
+ /* 24 */ "SeekGE" OpHelp("key=r[P3@P4]"),
31656
+ /* 25 */ "SeekGT" OpHelp("key=r[P3@P4]"),
31657
+ /* 26 */ "IfNoHope" OpHelp("key=r[P3@P4]"),
31658
+ /* 27 */ "NoConflict" OpHelp("key=r[P3@P4]"),
31659
+ /* 28 */ "NotFound" OpHelp("key=r[P3@P4]"),
31660
+ /* 29 */ "Found" OpHelp("key=r[P3@P4]"),
31661
+ /* 30 */ "SeekRowid" OpHelp("intkey=r[P3]"),
31662
+ /* 31 */ "NotExists" OpHelp("intkey=r[P3]"),
31663
+ /* 32 */ "Last" OpHelp(""),
31664
+ /* 33 */ "IfSmaller" OpHelp(""),
31665
+ /* 34 */ "SorterSort" OpHelp(""),
31666
+ /* 35 */ "Sort" OpHelp(""),
31667
+ /* 36 */ "Rewind" OpHelp(""),
31668
+ /* 37 */ "IdxLE" OpHelp("key=r[P3@P4]"),
31669
+ /* 38 */ "IdxGT" OpHelp("key=r[P3@P4]"),
31670
+ /* 39 */ "IdxLT" OpHelp("key=r[P3@P4]"),
31671
+ /* 40 */ "IdxGE" OpHelp("key=r[P3@P4]"),
31672
+ /* 41 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
31673
+ /* 42 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
3132731674
/* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
3132831675
/* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
31329
- /* 45 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
31330
- /* 46 */ "Program" OpHelp(""),
31331
- /* 47 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
31332
- /* 48 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
31333
- /* 49 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
31676
+ /* 45 */ "Program" OpHelp(""),
31677
+ /* 46 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
31678
+ /* 47 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
31679
+ /* 48 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
31680
+ /* 49 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
3133431681
/* 50 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
3133531682
/* 51 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
3133631683
/* 52 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
3133731684
/* 53 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
3133831685
/* 54 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
3133931686
/* 55 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
3134031687
/* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
3134131688
/* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
3134231689
/* 58 */ "ElseNotEq" OpHelp(""),
31343
- /* 59 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
31344
- /* 60 */ "IncrVacuum" OpHelp(""),
31345
- /* 61 */ "VNext" OpHelp(""),
31346
- /* 62 */ "Init" OpHelp("Start at P2"),
31347
- /* 63 */ "Return" OpHelp(""),
31348
- /* 64 */ "EndCoroutine" OpHelp(""),
31349
- /* 65 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
31350
- /* 66 */ "Halt" OpHelp(""),
31351
- /* 67 */ "Integer" OpHelp("r[P2]=P1"),
31352
- /* 68 */ "Int64" OpHelp("r[P2]=P4"),
31353
- /* 69 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
31354
- /* 70 */ "Null" OpHelp("r[P2..P3]=NULL"),
31355
- /* 71 */ "SoftNull" OpHelp("r[P1]=NULL"),
31356
- /* 72 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
31357
- /* 73 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
31358
- /* 74 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
31359
- /* 75 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
31360
- /* 76 */ "SCopy" OpHelp("r[P2]=r[P1]"),
31361
- /* 77 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
31362
- /* 78 */ "ResultRow" OpHelp("output=r[P1@P2]"),
31363
- /* 79 */ "CollSeq" OpHelp(""),
31364
- /* 80 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
31365
- /* 81 */ "RealAffinity" OpHelp(""),
31366
- /* 82 */ "Cast" OpHelp("affinity(r[P1])"),
31367
- /* 83 */ "Permutation" OpHelp(""),
31368
- /* 84 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
31369
- /* 85 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
31370
- /* 86 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
31371
- /* 87 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
31372
- /* 88 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
31373
- /* 89 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
31374
- /* 90 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
31375
- /* 91 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
31376
- /* 92 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
31377
- /* 93 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
31378
- /* 94 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
31379
- /* 95 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
31380
- /* 96 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
31381
- /* 97 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
31382
- /* 98 */ "Column" OpHelp("r[P3]=PX"),
31383
- /* 99 */ "String8" OpHelp("r[P2]='P4'"),
31384
- /* 100 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
31385
- /* 101 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
31386
- /* 102 */ "Count" OpHelp("r[P2]=count()"),
31387
- /* 103 */ "ReadCookie" OpHelp(""),
31388
- /* 104 */ "SetCookie" OpHelp(""),
31389
- /* 105 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
31390
- /* 106 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
31391
- /* 107 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
31392
- /* 108 */ "OpenDup" OpHelp(""),
31393
- /* 109 */ "OpenAutoindex" OpHelp("nColumn=P2"),
31394
- /* 110 */ "OpenEphemeral" OpHelp("nColumn=P2"),
31395
- /* 111 */ "SorterOpen" OpHelp(""),
31396
- /* 112 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
31397
- /* 113 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
31398
- /* 114 */ "Close" OpHelp(""),
31399
- /* 115 */ "ColumnsUsed" OpHelp(""),
31690
+ /* 59 */ "IncrVacuum" OpHelp(""),
31691
+ /* 60 */ "VNext" OpHelp(""),
31692
+ /* 61 */ "Init" OpHelp("Start at P2"),
31693
+ /* 62 */ "Return" OpHelp(""),
31694
+ /* 63 */ "EndCoroutine" OpHelp(""),
31695
+ /* 64 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
31696
+ /* 65 */ "Halt" OpHelp(""),
31697
+ /* 66 */ "Integer" OpHelp("r[P2]=P1"),
31698
+ /* 67 */ "Int64" OpHelp("r[P2]=P4"),
31699
+ /* 68 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
31700
+ /* 69 */ "Null" OpHelp("r[P2..P3]=NULL"),
31701
+ /* 70 */ "SoftNull" OpHelp("r[P1]=NULL"),
31702
+ /* 71 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
31703
+ /* 72 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
31704
+ /* 73 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
31705
+ /* 74 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
31706
+ /* 75 */ "SCopy" OpHelp("r[P2]=r[P1]"),
31707
+ /* 76 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
31708
+ /* 77 */ "ResultRow" OpHelp("output=r[P1@P2]"),
31709
+ /* 78 */ "CollSeq" OpHelp(""),
31710
+ /* 79 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
31711
+ /* 80 */ "RealAffinity" OpHelp(""),
31712
+ /* 81 */ "Cast" OpHelp("affinity(r[P1])"),
31713
+ /* 82 */ "Permutation" OpHelp(""),
31714
+ /* 83 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
31715
+ /* 84 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
31716
+ /* 85 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
31717
+ /* 86 */ "Column" OpHelp("r[P3]=PX"),
31718
+ /* 87 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
31719
+ /* 88 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
31720
+ /* 89 */ "Count" OpHelp("r[P2]=count()"),
31721
+ /* 90 */ "ReadCookie" OpHelp(""),
31722
+ /* 91 */ "SetCookie" OpHelp(""),
31723
+ /* 92 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
31724
+ /* 93 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
31725
+ /* 94 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
31726
+ /* 95 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
31727
+ /* 96 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
31728
+ /* 97 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
31729
+ /* 98 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
31730
+ /* 99 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
31731
+ /* 100 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
31732
+ /* 101 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
31733
+ /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
31734
+ /* 103 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
31735
+ /* 104 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
31736
+ /* 105 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
31737
+ /* 106 */ "String8" OpHelp("r[P2]='P4'"),
31738
+ /* 107 */ "OpenDup" OpHelp(""),
31739
+ /* 108 */ "OpenAutoindex" OpHelp("nColumn=P2"),
31740
+ /* 109 */ "OpenEphemeral" OpHelp("nColumn=P2"),
31741
+ /* 110 */ "SorterOpen" OpHelp(""),
31742
+ /* 111 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
31743
+ /* 112 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
31744
+ /* 113 */ "Close" OpHelp(""),
31745
+ /* 114 */ "ColumnsUsed" OpHelp(""),
31746
+ /* 115 */ "SeekHit" OpHelp("seekHit=P2"),
3140031747
/* 116 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
3140131748
/* 117 */ "NewRowid" OpHelp("r[P2]=rowid"),
3140231749
/* 118 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
3140331750
/* 119 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
3140431751
/* 120 */ "Delete" OpHelp(""),
@@ -31413,48 +31760,52 @@
3141331760
/* 129 */ "IdxInsert" OpHelp("key=r[P2]"),
3141431761
/* 130 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
3141531762
/* 131 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
3141631763
/* 132 */ "IdxRowid" OpHelp("r[P2]=rowid"),
3141731764
/* 133 */ "Destroy" OpHelp(""),
31418
- /* 134 */ "Real" OpHelp("r[P2]=P4"),
31419
- /* 135 */ "Clear" OpHelp(""),
31420
- /* 136 */ "ResetSorter" OpHelp(""),
31421
- /* 137 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
31422
- /* 138 */ "SqlExec" OpHelp(""),
31423
- /* 139 */ "ParseSchema" OpHelp(""),
31424
- /* 140 */ "LoadAnalysis" OpHelp(""),
31425
- /* 141 */ "DropTable" OpHelp(""),
31765
+ /* 134 */ "Clear" OpHelp(""),
31766
+ /* 135 */ "ResetSorter" OpHelp(""),
31767
+ /* 136 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
31768
+ /* 137 */ "SqlExec" OpHelp(""),
31769
+ /* 138 */ "ParseSchema" OpHelp(""),
31770
+ /* 139 */ "LoadAnalysis" OpHelp(""),
31771
+ /* 140 */ "DropTable" OpHelp(""),
31772
+ /* 141 */ "Real" OpHelp("r[P2]=P4"),
3142631773
/* 142 */ "DropIndex" OpHelp(""),
3142731774
/* 143 */ "DropTrigger" OpHelp(""),
3142831775
/* 144 */ "IntegrityCk" OpHelp(""),
3142931776
/* 145 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
3143031777
/* 146 */ "Param" OpHelp(""),
3143131778
/* 147 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
3143231779
/* 148 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
3143331780
/* 149 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
31434
- /* 150 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
31781
+ /* 150 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
3143531782
/* 151 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
31436
- /* 152 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
31437
- /* 153 */ "Expire" OpHelp(""),
31438
- /* 154 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
31439
- /* 155 */ "VBegin" OpHelp(""),
31440
- /* 156 */ "VCreate" OpHelp(""),
31441
- /* 157 */ "VDestroy" OpHelp(""),
31442
- /* 158 */ "VOpen" OpHelp(""),
31443
- /* 159 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
31444
- /* 160 */ "VRename" OpHelp(""),
31445
- /* 161 */ "Pagecount" OpHelp(""),
31446
- /* 162 */ "MaxPgcnt" OpHelp(""),
31447
- /* 163 */ "PureFunc0" OpHelp(""),
31448
- /* 164 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
31449
- /* 165 */ "PureFunc" OpHelp(""),
31450
- /* 166 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
31451
- /* 167 */ "Trace" OpHelp(""),
31452
- /* 168 */ "CursorHint" OpHelp(""),
31453
- /* 169 */ "Noop" OpHelp(""),
31454
- /* 170 */ "Explain" OpHelp(""),
31455
- /* 171 */ "Abortable" OpHelp(""),
31783
+ /* 152 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
31784
+ /* 153 */ "AggValue" OpHelp("r[P3]=value N=P2"),
31785
+ /* 154 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
31786
+ /* 155 */ "Expire" OpHelp(""),
31787
+ /* 156 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
31788
+ /* 157 */ "VBegin" OpHelp(""),
31789
+ /* 158 */ "VCreate" OpHelp(""),
31790
+ /* 159 */ "VDestroy" OpHelp(""),
31791
+ /* 160 */ "VOpen" OpHelp(""),
31792
+ /* 161 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
31793
+ /* 162 */ "VRename" OpHelp(""),
31794
+ /* 163 */ "Pagecount" OpHelp(""),
31795
+ /* 164 */ "MaxPgcnt" OpHelp(""),
31796
+ /* 165 */ "PureFunc0" OpHelp(""),
31797
+ /* 166 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
31798
+ /* 167 */ "PureFunc" OpHelp(""),
31799
+ /* 168 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
31800
+ /* 169 */ "Trace" OpHelp(""),
31801
+ /* 170 */ "CursorHint" OpHelp(""),
31802
+ /* 171 */ "SetTabCol" OpHelp(""),
31803
+ /* 172 */ "VerifyTabCol" OpHelp(""),
31804
+ /* 173 */ "Noop" OpHelp(""),
31805
+ /* 174 */ "Explain" OpHelp(""),
31806
+ /* 175 */ "Abortable" OpHelp(""),
3145631807
};
3145731808
return azName[i];
3145831809
}
3145931810
#endif
3146031811
@@ -58091,53 +58442,56 @@
5809158442
return (iPage*HASHTABLE_HASH_1) & (HASHTABLE_NSLOT-1);
5809258443
}
5809358444
static int walNextHash(int iPriorHash){
5809458445
return (iPriorHash+1)&(HASHTABLE_NSLOT-1);
5809558446
}
58447
+
58448
+/*
58449
+** An instance of the WalHashLoc object is used to describe the location
58450
+** of a page hash table in the wal-index. This becomes the return value
58451
+** from walHashGet().
58452
+*/
58453
+typedef struct WalHashLoc WalHashLoc;
58454
+struct WalHashLoc {
58455
+ volatile ht_slot *aHash; /* Start of the wal-index hash table */
58456
+ volatile u32 *aPgno; /* aPgno[1] is the page of first frame indexed */
58457
+ u32 iZero; /* One less than the frame number of first indexed*/
58458
+};
5809658459
5809758460
/*
5809858461
** Return pointers to the hash table and page number array stored on
5809958462
** page iHash of the wal-index. The wal-index is broken into 32KB pages
5810058463
** numbered starting from 0.
5810158464
**
58102
-** Set output variable *paHash to point to the start of the hash table
58103
-** in the wal-index file. Set *piZero to one less than the frame
58465
+** Set output variable pLoc->aHash to point to the start of the hash table
58466
+** in the wal-index file. Set pLoc->iZero to one less than the frame
5810458467
** number of the first frame indexed by this hash table. If a
5810558468
** slot in the hash table is set to N, it refers to frame number
58106
-** (*piZero+N) in the log.
58469
+** (pLoc->iZero+N) in the log.
5810758470
**
58108
-** Finally, set *paPgno so that *paPgno[1] is the page number of the
58109
-** first frame indexed by the hash table, frame (*piZero+1).
58471
+** Finally, set pLoc->aPgno so that pLoc->aPgno[1] is the page number of the
58472
+** first frame indexed by the hash table, frame (pLoc->iZero+1).
5811058473
*/
5811158474
static int walHashGet(
5811258475
Wal *pWal, /* WAL handle */
5811358476
int iHash, /* Find the iHash'th table */
58114
- volatile ht_slot **paHash, /* OUT: Pointer to hash index */
58115
- volatile u32 **paPgno, /* OUT: Pointer to page number array */
58116
- u32 *piZero /* OUT: Frame associated with *paPgno[0] */
58477
+ WalHashLoc *pLoc /* OUT: Hash table location */
5811758478
){
5811858479
int rc; /* Return code */
58119
- volatile u32 *aPgno;
5812058480
58121
- rc = walIndexPage(pWal, iHash, &aPgno);
58481
+ rc = walIndexPage(pWal, iHash, &pLoc->aPgno);
5812258482
assert( rc==SQLITE_OK || iHash>0 );
5812358483
5812458484
if( rc==SQLITE_OK ){
58125
- u32 iZero;
58126
- volatile ht_slot *aHash;
58127
-
58128
- aHash = (volatile ht_slot *)&aPgno[HASHTABLE_NPAGE];
58485
+ pLoc->aHash = (volatile ht_slot *)&pLoc->aPgno[HASHTABLE_NPAGE];
5812958486
if( iHash==0 ){
58130
- aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];
58131
- iZero = 0;
58487
+ pLoc->aPgno = &pLoc->aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];
58488
+ pLoc->iZero = 0;
5813258489
}else{
58133
- iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;
58490
+ pLoc->iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;
5813458491
}
58135
-
58136
- *paPgno = &aPgno[-1];
58137
- *paHash = aHash;
58138
- *piZero = iZero;
58492
+ pLoc->aPgno = &pLoc->aPgno[-1];
5813958493
}
5814058494
return rc;
5814158495
}
5814258496
5814358497
/*
@@ -58179,13 +58533,11 @@
5817958533
** updated. Any later hash tables will be automatically cleared when
5818058534
** pWal->hdr.mxFrame advances to the point where those hash tables are
5818158535
** actually needed.
5818258536
*/
5818358537
static void walCleanupHash(Wal *pWal){
58184
- volatile ht_slot *aHash = 0; /* Pointer to hash table to clear */
58185
- volatile u32 *aPgno = 0; /* Page number array for hash table */
58186
- u32 iZero = 0; /* frame == (aHash[x]+iZero) */
58538
+ WalHashLoc sLoc; /* Hash table location */
5818758539
int iLimit = 0; /* Zero values greater than this */
5818858540
int nByte; /* Number of bytes to zero in aPgno[] */
5818958541
int i; /* Used to iterate through aHash[] */
5819058542
5819158543
assert( pWal->writeLock );
@@ -58199,41 +58551,41 @@
5819958551
** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
5820058552
** that the page said hash-table and array reside on is already mapped.
5820158553
*/
5820258554
assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
5820358555
assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
58204
- walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &aHash, &aPgno, &iZero);
58556
+ walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
5820558557
5820658558
/* Zero all hash-table entries that correspond to frame numbers greater
5820758559
** than pWal->hdr.mxFrame.
5820858560
*/
58209
- iLimit = pWal->hdr.mxFrame - iZero;
58561
+ iLimit = pWal->hdr.mxFrame - sLoc.iZero;
5821058562
assert( iLimit>0 );
5821158563
for(i=0; i<HASHTABLE_NSLOT; i++){
58212
- if( aHash[i]>iLimit ){
58213
- aHash[i] = 0;
58564
+ if( sLoc.aHash[i]>iLimit ){
58565
+ sLoc.aHash[i] = 0;
5821458566
}
5821558567
}
5821658568
5821758569
/* Zero the entries in the aPgno array that correspond to frames with
5821858570
** frame numbers greater than pWal->hdr.mxFrame.
5821958571
*/
58220
- nByte = (int)((char *)aHash - (char *)&aPgno[iLimit+1]);
58221
- memset((void *)&aPgno[iLimit+1], 0, nByte);
58572
+ nByte = (int)((char *)sLoc.aHash - (char *)&sLoc.aPgno[iLimit+1]);
58573
+ memset((void *)&sLoc.aPgno[iLimit+1], 0, nByte);
5822258574
5822358575
#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
5822458576
/* Verify that the every entry in the mapping region is still reachable
5822558577
** via the hash table even after the cleanup.
5822658578
*/
5822758579
if( iLimit ){
5822858580
int j; /* Loop counter */
5822958581
int iKey; /* Hash key */
5823058582
for(j=1; j<=iLimit; j++){
58231
- for(iKey=walHash(aPgno[j]); aHash[iKey]; iKey=walNextHash(iKey)){
58232
- if( aHash[iKey]==j ) break;
58583
+ for(iKey=walHash(sLoc.aPgno[j]);sLoc.aHash[iKey];iKey=walNextHash(iKey)){
58584
+ if( sLoc.aHash[iKey]==j ) break;
5823358585
}
58234
- assert( aHash[iKey]==j );
58586
+ assert( sLoc.aHash[iKey]==j );
5823558587
}
5823658588
}
5823758589
#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
5823858590
}
5823958591
@@ -58242,62 +58594,61 @@
5824258594
** Set an entry in the wal-index that will map database page number
5824358595
** pPage into WAL frame iFrame.
5824458596
*/
5824558597
static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
5824658598
int rc; /* Return code */
58247
- u32 iZero = 0; /* One less than frame number of aPgno[1] */
58248
- volatile u32 *aPgno = 0; /* Page number array */
58249
- volatile ht_slot *aHash = 0; /* Hash table */
58599
+ WalHashLoc sLoc; /* Wal-index hash table location */
5825058600
58251
- rc = walHashGet(pWal, walFramePage(iFrame), &aHash, &aPgno, &iZero);
58601
+ rc = walHashGet(pWal, walFramePage(iFrame), &sLoc);
5825258602
5825358603
/* Assuming the wal-index file was successfully mapped, populate the
5825458604
** page number array and hash table entry.
5825558605
*/
5825658606
if( rc==SQLITE_OK ){
5825758607
int iKey; /* Hash table key */
5825858608
int idx; /* Value to write to hash-table slot */
5825958609
int nCollide; /* Number of hash collisions */
5826058610
58261
- idx = iFrame - iZero;
58611
+ idx = iFrame - sLoc.iZero;
5826258612
assert( idx <= HASHTABLE_NSLOT/2 + 1 );
5826358613
5826458614
/* If this is the first entry to be added to this hash-table, zero the
5826558615
** entire hash table and aPgno[] array before proceeding.
5826658616
*/
5826758617
if( idx==1 ){
58268
- int nByte = (int)((u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1]);
58269
- memset((void*)&aPgno[1], 0, nByte);
58618
+ int nByte = (int)((u8 *)&sLoc.aHash[HASHTABLE_NSLOT]
58619
+ - (u8 *)&sLoc.aPgno[1]);
58620
+ memset((void*)&sLoc.aPgno[1], 0, nByte);
5827058621
}
5827158622
5827258623
/* If the entry in aPgno[] is already set, then the previous writer
5827358624
** must have exited unexpectedly in the middle of a transaction (after
5827458625
** writing one or more dirty pages to the WAL to free up memory).
5827558626
** Remove the remnants of that writers uncommitted transaction from
5827658627
** the hash-table before writing any new entries.
5827758628
*/
58278
- if( aPgno[idx] ){
58629
+ if( sLoc.aPgno[idx] ){
5827958630
walCleanupHash(pWal);
58280
- assert( !aPgno[idx] );
58631
+ assert( !sLoc.aPgno[idx] );
5828158632
}
5828258633
5828358634
/* Write the aPgno[] array entry and the hash-table slot. */
5828458635
nCollide = idx;
58285
- for(iKey=walHash(iPage); aHash[iKey]; iKey=walNextHash(iKey)){
58636
+ for(iKey=walHash(iPage); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
5828658637
if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;
5828758638
}
58288
- aPgno[idx] = iPage;
58289
- aHash[iKey] = (ht_slot)idx;
58639
+ sLoc.aPgno[idx] = iPage;
58640
+ sLoc.aHash[iKey] = (ht_slot)idx;
5829058641
5829158642
#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
5829258643
/* Verify that the number of entries in the hash table exactly equals
5829358644
** the number of entries in the mapping region.
5829458645
*/
5829558646
{
5829658647
int i; /* Loop counter */
5829758648
int nEntry = 0; /* Number of entries in the hash table */
58298
- for(i=0; i<HASHTABLE_NSLOT; i++){ if( aHash[i] ) nEntry++; }
58649
+ for(i=0; i<HASHTABLE_NSLOT; i++){ if( sLoc.aHash[i] ) nEntry++; }
5829958650
assert( nEntry==idx );
5830058651
}
5830158652
5830258653
/* Verify that the every entry in the mapping region is reachable
5830358654
** via the hash table. This turns out to be a really, really expensive
@@ -58305,14 +58656,16 @@
5830558656
** iteration.
5830658657
*/
5830758658
if( (idx&0x3ff)==0 ){
5830858659
int i; /* Loop counter */
5830958660
for(i=1; i<=idx; i++){
58310
- for(iKey=walHash(aPgno[i]); aHash[iKey]; iKey=walNextHash(iKey)){
58311
- if( aHash[iKey]==i ) break;
58661
+ for(iKey=walHash(sLoc.aPgno[i]);
58662
+ sLoc.aHash[iKey];
58663
+ iKey=walNextHash(iKey)){
58664
+ if( sLoc.aHash[iKey]==i ) break;
5831258665
}
58313
- assert( aHash[iKey]==i );
58666
+ assert( sLoc.aHash[iKey]==i );
5831458667
}
5831558668
}
5831658669
#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
5831758670
}
5831858671
@@ -58846,37 +59199,35 @@
5884659199
if( !aTmp ){
5884759200
rc = SQLITE_NOMEM_BKPT;
5884859201
}
5884959202
5885059203
for(i=walFramePage(nBackfill+1); rc==SQLITE_OK && i<nSegment; i++){
58851
- volatile ht_slot *aHash;
58852
- u32 iZero;
58853
- volatile u32 *aPgno;
59204
+ WalHashLoc sLoc;
5885459205
58855
- rc = walHashGet(pWal, i, &aHash, &aPgno, &iZero);
59206
+ rc = walHashGet(pWal, i, &sLoc);
5885659207
if( rc==SQLITE_OK ){
5885759208
int j; /* Counter variable */
5885859209
int nEntry; /* Number of entries in this segment */
5885959210
ht_slot *aIndex; /* Sorted index for this segment */
5886059211
58861
- aPgno++;
59212
+ sLoc.aPgno++;
5886259213
if( (i+1)==nSegment ){
58863
- nEntry = (int)(iLast - iZero);
59214
+ nEntry = (int)(iLast - sLoc.iZero);
5886459215
}else{
58865
- nEntry = (int)((u32*)aHash - (u32*)aPgno);
59216
+ nEntry = (int)((u32*)sLoc.aHash - (u32*)sLoc.aPgno);
5886659217
}
58867
- aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[iZero];
58868
- iZero++;
59218
+ aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[sLoc.iZero];
59219
+ sLoc.iZero++;
5886959220
5887059221
for(j=0; j<nEntry; j++){
5887159222
aIndex[j] = (ht_slot)j;
5887259223
}
58873
- walMergesort((u32 *)aPgno, aTmp, aIndex, &nEntry);
58874
- p->aSegment[i].iZero = iZero;
59224
+ walMergesort((u32 *)sLoc.aPgno, aTmp, aIndex, &nEntry);
59225
+ p->aSegment[i].iZero = sLoc.iZero;
5887559226
p->aSegment[i].nEntry = nEntry;
5887659227
p->aSegment[i].aIndex = aIndex;
58877
- p->aSegment[i].aPgno = (u32 *)aPgno;
59228
+ p->aSegment[i].aPgno = (u32 *)sLoc.aPgno;
5887859229
}
5887959230
}
5888059231
sqlite3_free(aTmp);
5888159232
5888259233
if( rc!=SQLITE_OK ){
@@ -59885,20 +60236,18 @@
5988560236
if( pBuf1==0 || pBuf2==0 ){
5988660237
rc = SQLITE_NOMEM;
5988760238
}else{
5988860239
u32 i = pInfo->nBackfillAttempted;
5988960240
for(i=pInfo->nBackfillAttempted; i>pInfo->nBackfill; i--){
59890
- volatile ht_slot *dummy;
59891
- volatile u32 *aPgno; /* Array of page numbers */
59892
- u32 iZero; /* Frame corresponding to aPgno[0] */
60241
+ WalHashLoc sLoc; /* Hash table location */
5989360242
u32 pgno; /* Page number in db file */
5989460243
i64 iDbOff; /* Offset of db file entry */
5989560244
i64 iWalOff; /* Offset of wal file entry */
5989660245
59897
- rc = walHashGet(pWal, walFramePage(i), &dummy, &aPgno, &iZero);
60246
+ rc = walHashGet(pWal, walFramePage(i), &sLoc);
5989860247
if( rc!=SQLITE_OK ) break;
59899
- pgno = aPgno[i-iZero];
60248
+ pgno = sLoc.aPgno[i-sLoc.iZero];
5990060249
iDbOff = (i64)(pgno-1) * szPage;
5990160250
5990260251
if( iDbOff+szPage<=szDb ){
5990360252
iWalOff = walFrameOffset(i, szPage) + WAL_FRAME_HDRSIZE;
5990460253
rc = sqlite3OsRead(pWal->pWalFd, pBuf1, szPage, iWalOff);
@@ -60095,25 +60444,24 @@
6009560444
** This condition filters out entries that were added to the hash
6009660445
** table after the current read-transaction had started.
6009760446
*/
6009860447
iMinHash = walFramePage(pWal->minFrame);
6009960448
for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){
60100
- volatile ht_slot *aHash; /* Pointer to hash table */
60101
- volatile u32 *aPgno; /* Pointer to array of page numbers */
60102
- u32 iZero; /* Frame number corresponding to aPgno[0] */
60449
+ WalHashLoc sLoc; /* Hash table location */
6010360450
int iKey; /* Hash slot index */
6010460451
int nCollide; /* Number of hash collisions remaining */
6010560452
int rc; /* Error code */
6010660453
60107
- rc = walHashGet(pWal, iHash, &aHash, &aPgno, &iZero);
60454
+ rc = walHashGet(pWal, iHash, &sLoc);
6010860455
if( rc!=SQLITE_OK ){
6010960456
return rc;
6011060457
}
6011160458
nCollide = HASHTABLE_NSLOT;
60112
- for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){
60113
- u32 iFrame = aHash[iKey] + iZero;
60114
- if( iFrame<=iLast && iFrame>=pWal->minFrame && aPgno[aHash[iKey]]==pgno ){
60459
+ for(iKey=walHash(pgno); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
60460
+ u32 iFrame = sLoc.aHash[iKey] + sLoc.iZero;
60461
+ if( iFrame<=iLast && iFrame>=pWal->minFrame
60462
+ && sLoc.aPgno[sLoc.aHash[iKey]]==pgno ){
6011560463
assert( iFrame>iRead || CORRUPT_DB );
6011660464
iRead = iFrame;
6011760465
}
6011860466
if( (nCollide--)==0 ){
6011960467
return SQLITE_CORRUPT_BKPT;
@@ -65329,11 +65677,11 @@
6532965677
** One or the other of the two processes must give way or there can be
6533065678
** no progress. By returning SQLITE_BUSY and not invoking the busy callback
6533165679
** when A already has a read lock, we encourage A to give up and let B
6533265680
** proceed.
6533365681
*/
65334
-SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag){
65682
+SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){
6533565683
BtShared *pBt = p->pBt;
6533665684
int rc = SQLITE_OK;
6533765685
6533865686
sqlite3BtreeEnter(p);
6533965687
btreeIntegrity(p);
@@ -65404,10 +65752,15 @@
6540465752
rc = SQLITE_READONLY;
6540565753
}else{
6540665754
rc = sqlite3PagerBegin(pBt->pPager,wrflag>1,sqlite3TempInMemory(p->db));
6540765755
if( rc==SQLITE_OK ){
6540865756
rc = newDatabase(pBt);
65757
+ }else if( rc==SQLITE_BUSY_SNAPSHOT && pBt->inTransaction==TRANS_NONE ){
65758
+ /* if there was no transaction opened when this function was
65759
+ ** called and SQLITE_BUSY_SNAPSHOT is returned, change the error
65760
+ ** code to SQLITE_BUSY. */
65761
+ rc = SQLITE_BUSY;
6540965762
}
6541065763
}
6541165764
}
6541265765
6541365766
if( rc!=SQLITE_OK ){
@@ -65455,18 +65808,22 @@
6545565808
}
6545665809
}
6545765810
}
6545865811
}
6545965812
65460
-
6546165813
trans_begun:
65462
- if( rc==SQLITE_OK && wrflag ){
65463
- /* This call makes sure that the pager has the correct number of
65464
- ** open savepoints. If the second parameter is greater than 0 and
65465
- ** the sub-journal is not already open, then it will be opened here.
65466
- */
65467
- rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);
65814
+ if( rc==SQLITE_OK ){
65815
+ if( pSchemaVersion ){
65816
+ *pSchemaVersion = get4byte(&pBt->pPage1->aData[40]);
65817
+ }
65818
+ if( wrflag ){
65819
+ /* This call makes sure that the pager has the correct number of
65820
+ ** open savepoints. If the second parameter is greater than 0 and
65821
+ ** the sub-journal is not already open, then it will be opened here.
65822
+ */
65823
+ rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);
65824
+ }
6546865825
}
6546965826
6547065827
btreeIntegrity(p);
6547165828
sqlite3BtreeLeave(p);
6547265829
return rc;
@@ -67209,10 +67566,27 @@
6720967566
rc = SQLITE_OK;
6721067567
}
6721167568
return rc;
6721267569
}
6721367570
67571
+/*
67572
+** This function is a no-op if cursor pCur does not point to a valid row.
67573
+** Otherwise, if pCur is valid, configure it so that the next call to
67574
+** sqlite3BtreeNext() is a no-op.
67575
+*/
67576
+#ifndef SQLITE_OMIT_WINDOWFUNC
67577
+SQLITE_PRIVATE void sqlite3BtreeSkipNext(BtCursor *pCur){
67578
+ /* We believe that the cursor must always be in the valid state when
67579
+ ** this routine is called, but the proof is difficult, so we add an
67580
+ ** ALWaYS() test just in case we are wrong. */
67581
+ if( ALWAYS(pCur->eState==CURSOR_VALID) ){
67582
+ pCur->eState = CURSOR_SKIPNEXT;
67583
+ pCur->skipNext = 1;
67584
+ }
67585
+}
67586
+#endif /* SQLITE_OMIT_WINDOWFUNC */
67587
+
6721467588
/* Move the cursor to the last entry in the table. Return SQLITE_OK
6721567589
** on success. Set *pRes to 0 if the cursor actually points to something
6721667590
** or set *pRes to 1 if the table is empty.
6721767591
*/
6721867592
SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
@@ -67613,11 +67987,20 @@
6761367987
}
6761467988
}
6761567989
6761667990
pPage = pCur->pPage;
6761767991
idx = ++pCur->ix;
67618
- assert( pPage->isInit );
67992
+ if( !pPage->isInit ){
67993
+ /* The only known way for this to happen is for there to be a
67994
+ ** recursive SQL function that does a DELETE operation as part of a
67995
+ ** SELECT which deletes content out from under an active cursor
67996
+ ** in a corrupt database file where the table being DELETE-ed from
67997
+ ** has pages in common with the table being queried. See TH3
67998
+ ** module cov1/btree78.test testcase 220 (2018-06-08) for an
67999
+ ** example. */
68000
+ return SQLITE_CORRUPT_BKPT;
68001
+ }
6761968002
6762068003
/* If the database file is corrupt, it is possible for the value of idx
6762168004
** to be invalid here. This can only occur if a second cursor modifies
6762268005
** the page while cursor pCur is holding a reference to it. Which can
6762368006
** only happen if the database is corrupt in such a way as to link the
@@ -72113,15 +72496,15 @@
7211372496
** WAL connection, even if the version fields are currently set to 2.
7211472497
*/
7211572498
pBt->btsFlags &= ~BTS_NO_WAL;
7211672499
if( iVersion==1 ) pBt->btsFlags |= BTS_NO_WAL;
7211772500
72118
- rc = sqlite3BtreeBeginTrans(pBtree, 0);
72501
+ rc = sqlite3BtreeBeginTrans(pBtree, 0, 0);
7211972502
if( rc==SQLITE_OK ){
7212072503
u8 *aData = pBt->pPage1->aData;
7212172504
if( aData[18]!=(u8)iVersion || aData[19]!=(u8)iVersion ){
72122
- rc = sqlite3BtreeBeginTrans(pBtree, 2);
72505
+ rc = sqlite3BtreeBeginTrans(pBtree, 2, 0);
7212372506
if( rc==SQLITE_OK ){
7212472507
rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
7212572508
if( rc==SQLITE_OK ){
7212672509
aData[18] = (u8)iVersion;
7212772510
aData[19] = (u8)iVersion;
@@ -72557,11 +72940,11 @@
7255772940
/* If there is no open read-transaction on the source database, open
7255872941
** one now. If a transaction is opened here, then it will be closed
7255972942
** before this function exits.
7256072943
*/
7256172944
if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){
72562
- rc = sqlite3BtreeBeginTrans(p->pSrc, 0);
72945
+ rc = sqlite3BtreeBeginTrans(p->pSrc, 0, 0);
7256372946
bCloseTrans = 1;
7256472947
}
7256572948
7256672949
/* If the destination database has not yet been locked (i.e. if this
7256772950
** is the first call to backup_step() for the current backup operation),
@@ -72573,14 +72956,14 @@
7257372956
rc = SQLITE_NOMEM;
7257472957
}
7257572958
7257672959
/* Lock the destination database, if it is not locked already. */
7257772960
if( SQLITE_OK==rc && p->bDestLocked==0
72578
- && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2))
72961
+ && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2,
72962
+ (int*)&p->iDestSchema))
7257972963
){
7258072964
p->bDestLocked = 1;
72581
- sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);
7258272965
}
7258372966
7258472967
/* Do not allow backup if the destination database is in WAL mode
7258572968
** and the page sizes are different between source and destination */
7258672969
pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);
@@ -73393,10 +73776,39 @@
7339373776
if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
7339473777
memcpy(pMem, &t, sizeof(t));
7339573778
return ctx.isError;
7339673779
}
7339773780
73781
+/*
73782
+** Memory cell pAccum contains the context of an aggregate function.
73783
+** This routine calls the xValue method for that function and stores
73784
+** the results in memory cell pMem.
73785
+**
73786
+** SQLITE_ERROR is returned if xValue() reports an error. SQLITE_OK
73787
+** otherwise.
73788
+*/
73789
+#ifndef SQLITE_OMIT_WINDOWFUNC
73790
+SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem *pAccum, Mem *pOut, FuncDef *pFunc){
73791
+ sqlite3_context ctx;
73792
+ Mem t;
73793
+ assert( pFunc!=0 );
73794
+ assert( pFunc->xValue!=0 );
73795
+ assert( (pAccum->flags & MEM_Null)!=0 || pFunc==pAccum->u.pDef );
73796
+ assert( pAccum->db==0 || sqlite3_mutex_held(pAccum->db->mutex) );
73797
+ memset(&ctx, 0, sizeof(ctx));
73798
+ memset(&t, 0, sizeof(t));
73799
+ t.flags = MEM_Null;
73800
+ t.db = pAccum->db;
73801
+ sqlite3VdbeMemSetNull(pOut);
73802
+ ctx.pOut = pOut;
73803
+ ctx.pMem = pAccum;
73804
+ ctx.pFunc = pFunc;
73805
+ pFunc->xValue(&ctx);
73806
+ return ctx.isError;
73807
+}
73808
+#endif /* SQLITE_OMIT_WINDOWFUNC */
73809
+
7339873810
/*
7339973811
** If the memory cell contains a value that must be freed by
7340073812
** invoking the external callback in Mem.xDel, then this routine
7340173813
** will free that value. It also sets Mem.flags to MEM_Null.
7340273814
**
@@ -73864,15 +74276,32 @@
7386474276
SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
7386574277
int i;
7386674278
Mem *pX;
7386774279
for(i=0, pX=pVdbe->aMem; i<pVdbe->nMem; i++, pX++){
7386874280
if( pX->pScopyFrom==pMem ){
73869
- pX->flags |= MEM_Undefined;
74281
+ /* If pX is marked as a shallow copy of pMem, then verify that
74282
+ ** no significant changes have been made to pX since the OP_SCopy.
74283
+ ** A significant change would indicated a missed call to this
74284
+ ** function for pX. Minor changes, such as adding or removing a
74285
+ ** dual type, are allowed, as long as the underlying value is the
74286
+ ** same. */
74287
+ u16 mFlags = pMem->flags & pX->flags & pX->mScopyFlags;
74288
+ assert( (mFlags&MEM_Int)==0 || pMem->u.i==pX->u.i );
74289
+ assert( (mFlags&MEM_Real)==0 || pMem->u.r==pX->u.r );
74290
+ assert( (mFlags&MEM_Str)==0 || (pMem->n==pX->n && pMem->z==pX->z) );
74291
+ assert( (mFlags&MEM_Blob)==0 || sqlite3BlobCompare(pMem,pX)==0 );
74292
+
74293
+ /* pMem is the register that is changing. But also mark pX as
74294
+ ** undefined so that we can quickly detect the shallow-copy error */
74295
+ pX->flags = MEM_Undefined;
7387074296
pX->pScopyFrom = 0;
7387174297
}
7387274298
}
7387374299
pMem->pScopyFrom = 0;
74300
+#ifdef SQLITE_DEBUG_COLUMN_CACHE
74301
+ pMem->iTabColHash = 0;
74302
+#endif
7387474303
}
7387574304
#endif /* SQLITE_DEBUG */
7387674305
7387774306
7387874307
/*
@@ -73889,10 +74318,13 @@
7388974318
SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
7389074319
assert( (pFrom->flags & MEM_RowSet)==0 );
7389174320
assert( pTo->db==pFrom->db );
7389274321
if( VdbeMemDynamic(pTo) ){ vdbeClrCopy(pTo,pFrom,srcType); return; }
7389374322
memcpy(pTo, pFrom, MEMCELLSIZE);
74323
+#ifdef SQLITE_DEBUG_COLUMNCACHE
74324
+ pTo->iTabColHash = pFrom->iTabColHash;
74325
+#endif
7389474326
if( (pFrom->flags&MEM_Static)==0 ){
7389574327
pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
7389674328
assert( srcType==MEM_Ephem || srcType==MEM_Static );
7389774329
pTo->flags |= srcType;
7389874330
}
@@ -73906,10 +74338,13 @@
7390674338
int rc = SQLITE_OK;
7390774339
7390874340
assert( (pFrom->flags & MEM_RowSet)==0 );
7390974341
if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);
7391074342
memcpy(pTo, pFrom, MEMCELLSIZE);
74343
+#ifdef SQLITE_DEBUG_COLUMNCACHE
74344
+ pTo->iTabColHash = pFrom->iTabColHash;
74345
+#endif
7391174346
pTo->flags &= ~MEM_Dyn;
7391274347
if( pTo->flags&(MEM_Str|MEM_Blob) ){
7391374348
if( 0==(pFrom->flags&MEM_Static) ){
7391474349
pTo->flags |= MEM_Ephem;
7391574350
rc = sqlite3VdbeMemMakeWriteable(pTo);
@@ -75510,22 +75945,20 @@
7551075945
p->readOnly = 0;
7551175946
p->bIsReader = 1;
7551275947
break;
7551375948
}
7551475949
case OP_Next:
75515
- case OP_NextIfOpen:
7551675950
case OP_SorterNext: {
7551775951
pOp->p4.xAdvance = sqlite3BtreeNext;
7551875952
pOp->p4type = P4_ADVANCE;
7551975953
/* The code generator never codes any of these opcodes as a jump
7552075954
** to a label. They are always coded as a jump backwards to a
7552175955
** known address */
7552275956
assert( pOp->p2>=0 );
7552375957
break;
7552475958
}
75525
- case OP_Prev:
75526
- case OP_PrevIfOpen: {
75959
+ case OP_Prev: {
7552775960
pOp->p4.xAdvance = sqlite3BtreePrevious;
7552875961
pOp->p4type = P4_ADVANCE;
7552975962
/* The code generator never codes any of these opcodes as a jump
7553075963
** to a label. They are always coded as a jump backwards to a
7553175964
** known address */
@@ -76436,11 +76869,11 @@
7643676869
7643776870
#if defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
7643876871
/*
7643976872
** Print a single opcode. This routine is used for debugging only.
7644076873
*/
76441
-SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){
76874
+SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE *pOut, int pc, VdbeOp *pOp){
7644276875
char *zP4;
7644376876
char zPtr[50];
7644476877
char zCom[100];
7644576878
static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-13s %.2X %s\n";
7644676879
if( pOut==0 ) pOut = stdout;
@@ -76469,10 +76902,13 @@
7646976902
p->db = db;
7647076903
p->flags = flags;
7647176904
p->szMalloc = 0;
7647276905
#ifdef SQLITE_DEBUG
7647376906
p->pScopyFrom = 0;
76907
+#endif
76908
+#ifdef SQLITE_DEBUG_COLUMNCACHE
76909
+ p->iTabColHash = 0;
7647476910
#endif
7647576911
p++;
7647676912
}
7647776913
}
7647876914
@@ -78735,11 +79171,11 @@
7873579171
/*
7873679172
** Compare two blobs. Return negative, zero, or positive if the first
7873779173
** is less than, equal to, or greater than the second, respectively.
7873879174
** If one blob is a prefix of the other, then the shorter is the lessor.
7873979175
*/
78740
-static SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){
79176
+SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){
7874179177
int c;
7874279178
int n1 = pB1->n;
7874379179
int n2 = pB2->n;
7874479180
7874579181
/* It is possible to have a Blob value that has some non-zero content
@@ -78950,11 +79386,11 @@
7895079386
int i; /* Index of next field to compare */
7895179387
u32 szHdr1; /* Size of record header in bytes */
7895279388
u32 idx1; /* Offset of first type in header */
7895379389
int rc = 0; /* Return value */
7895479390
Mem *pRhs = pPKey2->aMem; /* Next field of pPKey2 to compare */
78955
- KeyInfo *pKeyInfo = pPKey2->pKeyInfo;
79391
+ KeyInfo *pKeyInfo;
7895679392
const unsigned char *aKey1 = (const unsigned char *)pKey1;
7895779393
Mem mem1;
7895879394
7895979395
/* If bSkip is true, then the caller has already determined that the first
7896079396
** two elements in the keys are equal. Fix the various stack variables so
@@ -79045,11 +79481,11 @@
7904579481
testcase( (d1+mem1.n)==(unsigned)nKey1 );
7904679482
testcase( (d1+mem1.n+1)==(unsigned)nKey1 );
7904779483
if( (d1+mem1.n) > (unsigned)nKey1 ){
7904879484
pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
7904979485
return 0; /* Corruption */
79050
- }else if( pKeyInfo->aColl[i] ){
79486
+ }else if( (pKeyInfo = pPKey2->pKeyInfo)->aColl[i] ){
7905179487
mem1.enc = pKeyInfo->enc;
7905279488
mem1.db = pKeyInfo->db;
7905379489
mem1.flags = MEM_Str;
7905479490
mem1.z = (char*)&aKey1[d1];
7905579491
rc = vdbeCompareMemString(
@@ -79096,23 +79532,24 @@
7909679532
serial_type = aKey1[idx1];
7909779533
rc = (serial_type!=0);
7909879534
}
7909979535
7910079536
if( rc!=0 ){
79101
- if( pKeyInfo->aSortOrder[i] ){
79537
+ if( pPKey2->pKeyInfo->aSortOrder[i] ){
7910279538
rc = -rc;
7910379539
}
7910479540
assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );
7910579541
assert( mem1.szMalloc==0 ); /* See comment below */
7910679542
return rc;
7910779543
}
7910879544
7910979545
i++;
79546
+ if( i==pPKey2->nField ) break;
7911079547
pRhs++;
7911179548
d1 += sqlite3VdbeSerialTypeLen(serial_type);
7911279549
idx1 += sqlite3VarintLen(serial_type);
79113
- }while( idx1<(unsigned)szHdr1 && i<pPKey2->nField && d1<=(unsigned)nKey1 );
79550
+ }while( idx1<(unsigned)szHdr1 && d1<=(unsigned)nKey1 );
7911479551
7911579552
/* No memory allocation is ever used on mem1. Prove this using
7911679553
** the following assert(). If the assert() fails, it indicates a
7911779554
** memory leak and a need to call sqlite3VdbeMemRelease(&mem1). */
7911879555
assert( mem1.szMalloc==0 );
@@ -79120,11 +79557,11 @@
7912079557
/* rc==0 here means that one or both of the keys ran out of fields and
7912179558
** all the fields up to that point were equal. Return the default_rc
7912279559
** value. */
7912379560
assert( CORRUPT_DB
7912479561
|| vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, pPKey2->default_rc)
79125
- || pKeyInfo->db->mallocFailed
79562
+ || pPKey2->pKeyInfo->db->mallocFailed
7912679563
);
7912779564
pPKey2->eqSeen = 1;
7912879565
return pPKey2->default_rc;
7912979566
}
7913079567
SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
@@ -79446,11 +79883,11 @@
7944679883
sqlite3VdbeMemInit(&m, db, 0);
7944779884
rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);
7944879885
if( rc ){
7944979886
return rc;
7945079887
}
79451
- *res = sqlite3VdbeRecordCompare(m.n, m.z, pUnpacked);
79888
+ *res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, pUnpacked, 0);
7945279889
sqlite3VdbeMemRelease(&m);
7945379890
return SQLITE_OK;
7945479891
}
7945579892
7945679893
/*
@@ -80642,11 +81079,14 @@
8064281079
/* .uTemp = */ (u32)0,
8064381080
/* .db = */ (sqlite3*)0,
8064481081
/* .xDel = */ (void(*)(void*))0,
8064581082
#ifdef SQLITE_DEBUG
8064681083
/* .pScopyFrom = */ (Mem*)0,
80647
- /* .pFiller = */ (void*)0,
81084
+ /* .mScopyFlags= */ 0,
81085
+#endif
81086
+#ifdef SQLITE_DEBUG_COLUMNCACHE
81087
+ /* .iTabColHash= */ 0,
8064881088
#endif
8064981089
};
8065081090
return &nullMem;
8065181091
}
8065281092
@@ -81866,10 +82306,22 @@
8186682306
# define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)
8186782307
#else
8186882308
# define memAboutToChange(P,M)
8186982309
#endif
8187082310
82311
+/*
82312
+** Given a cursor number and a column for a table or index, compute a
82313
+** hash value for use in the Mem.iTabColHash value. The iTabColHash
82314
+** column is only used for verification - it is omitted from production
82315
+** builds. Collisions are harmless in the sense that the correct answer
82316
+** still results. The only harm of collisions is that they can potential
82317
+** reduce column-cache error detection during SQLITE_DEBUG builds.
82318
+**
82319
+** No valid hash should be 0.
82320
+*/
82321
+#define TableColumnHash(T,C) (((u32)(T)<<16)^(u32)(C+2))
82322
+
8187182323
/*
8187282324
** The following global variable is incremented every time a cursor
8187382325
** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test
8187482326
** procedures use this information to make sure that indices are
8187582327
** working correctly. This variable has no function other than to
@@ -81952,36 +82404,60 @@
8195282404
/*
8195382405
** Invoke the VDBE coverage callback, if that callback is defined. This
8195482406
** feature is used for test suite validation only and does not appear an
8195582407
** production builds.
8195682408
**
81957
-** M is an integer, 2 or 3, that indices how many different ways the
81958
-** branch can go. It is usually 2. "I" is the direction the branch
81959
-** goes. 0 means falls through. 1 means branch is taken. 2 means the
81960
-** second alternative branch is taken.
82409
+** M is an integer between 2 and 4. 2 indicates a ordinary two-way
82410
+** branch (I=0 means fall through and I=1 means taken). 3 indicates
82411
+** a 3-way branch where the third way is when one of the operands is
82412
+** NULL. 4 indicates the OP_Jump instruction which has three destinations
82413
+** depending on whether the first operand is less than, equal to, or greater
82414
+** than the second.
8196182415
**
8196282416
** iSrcLine is the source code line (from the __LINE__ macro) that
81963
-** generated the VDBE instruction. This instrumentation assumes that all
81964
-** source code is in a single file (the amalgamation). Special values 1
81965
-** and 2 for the iSrcLine parameter mean that this particular branch is
81966
-** always taken or never taken, respectively.
82417
+** generated the VDBE instruction combined with flag bits. The source
82418
+** code line number is in the lower 24 bits of iSrcLine and the upper
82419
+** 8 bytes are flags. The lower three bits of the flags indicate
82420
+** values for I that should never occur. For example, if the branch is
82421
+** always taken, the flags should be 0x05 since the fall-through and
82422
+** alternate branch are never taken. If a branch is never taken then
82423
+** flags should be 0x06 since only the fall-through approach is allowed.
82424
+**
82425
+** Bit 0x04 of the flags indicates an OP_Jump opcode that is only
82426
+** interested in equal or not-equal. In other words, I==0 and I==2
82427
+** should be treated the same.
82428
+**
82429
+** Since only a line number is retained, not the filename, this macro
82430
+** only works for amalgamation builds. But that is ok, since these macros
82431
+** should be no-ops except for special builds used to measure test coverage.
8196782432
*/
8196882433
#if !defined(SQLITE_VDBE_COVERAGE)
8196982434
# define VdbeBranchTaken(I,M)
8197082435
#else
8197182436
# define VdbeBranchTaken(I,M) vdbeTakeBranch(pOp->iSrcLine,I,M)
81972
- static void vdbeTakeBranch(int iSrcLine, u8 I, u8 M){
81973
- if( iSrcLine<=2 && ALWAYS(iSrcLine>0) ){
81974
- M = iSrcLine;
81975
- /* Assert the truth of VdbeCoverageAlwaysTaken() and
81976
- ** VdbeCoverageNeverTaken() */
81977
- assert( (M & I)==I );
81978
- }else{
81979
- if( sqlite3GlobalConfig.xVdbeBranch==0 ) return; /*NO_TEST*/
81980
- sqlite3GlobalConfig.xVdbeBranch(sqlite3GlobalConfig.pVdbeBranchArg,
81981
- iSrcLine,I,M);
81982
- }
82437
+ static void vdbeTakeBranch(u32 iSrcLine, u8 I, u8 M){
82438
+ u8 mNever;
82439
+ assert( I<=2 ); /* 0: fall through, 1: taken, 2: alternate taken */
82440
+ assert( M<=4 ); /* 2: two-way branch, 3: three-way branch, 4: OP_Jump */
82441
+ assert( I<M ); /* I can only be 2 if M is 3 or 4 */
82442
+ /* Transform I from a integer [0,1,2] into a bitmask of [1,2,4] */
82443
+ I = 1<<I;
82444
+ /* The upper 8 bits of iSrcLine are flags. The lower three bits of
82445
+ ** the flags indicate directions that the branch can never go. If
82446
+ ** a branch really does go in one of those directions, assert right
82447
+ ** away. */
82448
+ mNever = iSrcLine >> 24;
82449
+ assert( (I & mNever)==0 );
82450
+ if( sqlite3GlobalConfig.xVdbeBranch==0 ) return; /*NO_TEST*/
82451
+ I |= mNever;
82452
+ if( M==2 ) I |= 0x04;
82453
+ if( M==4 ){
82454
+ I |= 0x08;
82455
+ if( (mNever&0x08)!=0 && (I&0x05)!=0) I |= 0x05; /*NO_TEST*/
82456
+ }
82457
+ sqlite3GlobalConfig.xVdbeBranch(sqlite3GlobalConfig.pVdbeBranchArg,
82458
+ iSrcLine&0xffffff, I, M);
8198382459
}
8198482460
#endif
8198582461
8198682462
/*
8198782463
** Convert the given register into a string if it isn't one
@@ -83062,10 +83538,13 @@
8306283538
pOut = out2Prerelease(p, pOp);
8306383539
cnt = pOp->p3-pOp->p2;
8306483540
assert( pOp->p3<=(p->nMem+1 - p->nCursor) );
8306583541
pOut->flags = nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null;
8306683542
pOut->n = 0;
83543
+#ifdef SQLITE_DEBUG
83544
+ pOut->uTemp = 0;
83545
+#endif
8306783546
while( cnt>0 ){
8306883547
pOut++;
8306983548
memAboutToChange(p, pOut);
8307083549
sqlite3VdbeMemSetNull(pOut);
8307183550
pOut->flags = nullFlag;
@@ -83183,14 +83662,16 @@
8318383662
n = pOp->p3;
8318483663
pIn1 = &aMem[pOp->p1];
8318583664
pOut = &aMem[pOp->p2];
8318683665
assert( pOut!=pIn1 );
8318783666
while( 1 ){
83667
+ memAboutToChange(p, pOut);
8318883668
sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
8318983669
Deephemeralize(pOut);
8319083670
#ifdef SQLITE_DEBUG
8319183671
pOut->pScopyFrom = 0;
83672
+ pOut->iTabColHash = 0;
8319283673
#endif
8319383674
REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);
8319483675
if( (n--)==0 ) break;
8319583676
pOut++;
8319683677
pIn1++;
@@ -83215,11 +83696,12 @@
8321583696
pIn1 = &aMem[pOp->p1];
8321683697
pOut = &aMem[pOp->p2];
8321783698
assert( pOut!=pIn1 );
8321883699
sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
8321983700
#ifdef SQLITE_DEBUG
83220
- if( pOut->pScopyFrom==0 ) pOut->pScopyFrom = pIn1;
83701
+ pOut->pScopyFrom = pIn1;
83702
+ pOut->mScopyFlags = pIn1->flags;
8322183703
#endif
8322283704
break;
8322383705
}
8322483706
8322583707
/* Opcode: IntCopy P1 P2 * * *
@@ -84063,15 +84545,15 @@
8406384545
** in the most recent OP_Compare instruction the P1 vector was less than
8406484546
** equal to, or greater than the P2 vector, respectively.
8406584547
*/
8406684548
case OP_Jump: { /* jump */
8406784549
if( iCompare<0 ){
84068
- VdbeBranchTaken(0,3); pOp = &aOp[pOp->p1 - 1];
84550
+ VdbeBranchTaken(0,4); pOp = &aOp[pOp->p1 - 1];
8406984551
}else if( iCompare==0 ){
84070
- VdbeBranchTaken(1,3); pOp = &aOp[pOp->p2 - 1];
84552
+ VdbeBranchTaken(1,4); pOp = &aOp[pOp->p2 - 1];
8407184553
}else{
84072
- VdbeBranchTaken(2,3); pOp = &aOp[pOp->p3 - 1];
84554
+ VdbeBranchTaken(2,4); pOp = &aOp[pOp->p3 - 1];
8407384555
}
8407484556
break;
8407584557
}
8407684558
8407784559
/* Opcode: And P1 P2 P3 * *
@@ -84164,11 +84646,11 @@
8416484646
}
8416584647
break;
8416684648
}
8416784649
8416884650
/* Opcode: BitNot P1 P2 * * *
84169
-** Synopsis: r[P1]= ~r[P1]
84651
+** Synopsis: r[P2]= ~r[P1]
8417084652
**
8417184653
** Interpret the content of register P1 as an integer. Store the
8417284654
** ones-complement of the P1 value into register P2. If P1 holds
8417384655
** a NULL then store a NULL in P2.
8417484656
*/
@@ -85121,12 +85603,11 @@
8512185603
** halts. The sqlite3_step() wrapper function might then reprepare the
8512285604
** statement and rerun it from the beginning.
8512385605
*/
8512485606
case OP_Transaction: {
8512585607
Btree *pBt;
85126
- int iMeta;
85127
- int iGen;
85608
+ int iMeta = 0;
8512885609
8512985610
assert( p->bIsReader );
8513085611
assert( p->readOnly==0 || pOp->p2==0 );
8513185612
assert( pOp->p1>=0 && pOp->p1<db->nDb );
8513285613
assert( DbMaskTest(p->btreeMask, pOp->p1) );
@@ -85135,11 +85616,11 @@
8513585616
goto abort_due_to_error;
8513685617
}
8513785618
pBt = db->aDb[pOp->p1].pBt;
8513885619
8513985620
if( pBt ){
85140
- rc = sqlite3BtreeBeginTrans(pBt, pOp->p2);
85621
+ rc = sqlite3BtreeBeginTrans(pBt, pOp->p2, &iMeta);
8514185622
testcase( rc==SQLITE_BUSY_SNAPSHOT );
8514285623
testcase( rc==SQLITE_BUSY_RECOVERY );
8514385624
if( rc!=SQLITE_OK ){
8514485625
if( (rc&0xff)==SQLITE_BUSY ){
8514585626
p->pc = (int)(pOp - aOp);
@@ -85168,23 +85649,21 @@
8516885649
** counter. If the statement transaction needs to be rolled back,
8516985650
** the value of this counter needs to be restored too. */
8517085651
p->nStmtDefCons = db->nDeferredCons;
8517185652
p->nStmtDefImmCons = db->nDeferredImmCons;
8517285653
}
85173
-
85174
- /* Gather the schema version number for checking:
85654
+ }
85655
+ assert( pOp->p5==0 || pOp->p4type==P4_INT32 );
85656
+ if( pOp->p5
85657
+ && (iMeta!=pOp->p3
85658
+ || db->aDb[pOp->p1].pSchema->iGeneration!=pOp->p4.i)
85659
+ ){
85660
+ /*
8517585661
** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema
8517685662
** version is checked to ensure that the schema has not changed since the
8517785663
** SQL statement was prepared.
8517885664
*/
85179
- sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta);
85180
- iGen = db->aDb[pOp->p1].pSchema->iGeneration;
85181
- }else{
85182
- iGen = iMeta = 0;
85183
- }
85184
- assert( pOp->p5==0 || pOp->p4type==P4_INT32 );
85185
- if( pOp->p5 && (iMeta!=pOp->p3 || iGen!=pOp->p4.i) ){
8518685665
sqlite3DbFree(db, p->zErrMsg);
8518785666
p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed");
8518885667
/* If the schema-cookie from the database file matches the cookie
8518985668
** stored with the in-memory representation of the schema, do
8519085669
** not reload the schema from the database file.
@@ -85289,63 +85768,82 @@
8528985768
** temporary tables, and P3>1 means used the corresponding attached
8529085769
** database. Give the new cursor an identifier of P1. The P1
8529185770
** values need not be contiguous but all P1 values should be small integers.
8529285771
** It is an error for P1 to be negative.
8529385772
**
85294
-** If P5!=0 then use the content of register P2 as the root page, not
85295
-** the value of P2 itself.
85296
-**
85297
-** There will be a read lock on the database whenever there is an
85298
-** open cursor. If the database was unlocked prior to this instruction
85299
-** then a read lock is acquired as part of this instruction. A read
85300
-** lock allows other processes to read the database but prohibits
85301
-** any other process from modifying the database. The read lock is
85302
-** released when all cursors are closed. If this instruction attempts
85303
-** to get a read lock but fails, the script terminates with an
85304
-** SQLITE_BUSY error code.
85773
+** Allowed P5 bits:
85774
+** <ul>
85775
+** <li> <b>0x02 OPFLAG_SEEKEQ</b>: This cursor will only be used for
85776
+** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT
85777
+** of OP_SeekLE/OP_IdxGT)
85778
+** </ul>
8530585779
**
8530685780
** The P4 value may be either an integer (P4_INT32) or a pointer to
8530785781
** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
85308
-** structure, then said structure defines the content and collating
85309
-** sequence of the index being opened. Otherwise, if P4 is an integer
85310
-** value, it is set to the number of columns in the table.
85782
+** object, then table being opened must be an [index b-tree] where the
85783
+** KeyInfo object defines the content and collating
85784
+** sequence of that index b-tree. Otherwise, if P4 is an integer
85785
+** value, then the table being opened must be a [table b-tree] with a
85786
+** number of columns no less than the value of P4.
8531185787
**
8531285788
** See also: OpenWrite, ReopenIdx
8531385789
*/
8531485790
/* Opcode: ReopenIdx P1 P2 P3 P4 P5
8531585791
** Synopsis: root=P2 iDb=P3
8531685792
**
85317
-** The ReopenIdx opcode works exactly like ReadOpen except that it first
85318
-** checks to see if the cursor on P1 is already open with a root page
85319
-** number of P2 and if it is this opcode becomes a no-op. In other words,
85793
+** The ReopenIdx opcode works like OP_OpenRead except that it first
85794
+** checks to see if the cursor on P1 is already open on the same
85795
+** b-tree and if it is this opcode becomes a no-op. In other words,
8532085796
** if the cursor is already open, do not reopen it.
8532185797
**
85322
-** The ReopenIdx opcode may only be used with P5==0 and with P4 being
85323
-** a P4_KEYINFO object. Furthermore, the P3 value must be the same as
85324
-** every other ReopenIdx or OpenRead for the same cursor number.
85798
+** The ReopenIdx opcode may only be used with P5==0 or P5==OPFLAG_SEEKEQ
85799
+** and with P4 being a P4_KEYINFO object. Furthermore, the P3 value must
85800
+** be the same as every other ReopenIdx or OpenRead for the same cursor
85801
+** number.
8532585802
**
85326
-** See the OpenRead opcode documentation for additional information.
85803
+** Allowed P5 bits:
85804
+** <ul>
85805
+** <li> <b>0x02 OPFLAG_SEEKEQ</b>: This cursor will only be used for
85806
+** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT
85807
+** of OP_SeekLE/OP_IdxGT)
85808
+** </ul>
85809
+**
85810
+** See also: OP_OpenRead, OP_OpenWrite
8532785811
*/
8532885812
/* Opcode: OpenWrite P1 P2 P3 P4 P5
8532985813
** Synopsis: root=P2 iDb=P3
8533085814
**
8533185815
** Open a read/write cursor named P1 on the table or index whose root
85332
-** page is P2. Or if P5!=0 use the content of register P2 to find the
85333
-** root page.
85816
+** page is P2 (or whose root page is held in register P2 if the
85817
+** OPFLAG_P2ISREG bit is set in P5 - see below).
8533485818
**
8533585819
** The P4 value may be either an integer (P4_INT32) or a pointer to
8533685820
** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
85337
-** structure, then said structure defines the content and collating
85338
-** sequence of the index being opened. Otherwise, if P4 is an integer
85339
-** value, it is set to the number of columns in the table, or to the
85340
-** largest index of any column of the table that is actually used.
85341
-**
85342
-** This instruction works just like OpenRead except that it opens the cursor
85343
-** in read/write mode. For a given table, there can be one or more read-only
85344
-** cursors or a single read/write cursor but not both.
85345
-**
85346
-** See also OpenRead.
85821
+** object, then table being opened must be an [index b-tree] where the
85822
+** KeyInfo object defines the content and collating
85823
+** sequence of that index b-tree. Otherwise, if P4 is an integer
85824
+** value, then the table being opened must be a [table b-tree] with a
85825
+** number of columns no less than the value of P4.
85826
+**
85827
+** Allowed P5 bits:
85828
+** <ul>
85829
+** <li> <b>0x02 OPFLAG_SEEKEQ</b>: This cursor will only be used for
85830
+** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT
85831
+** of OP_SeekLE/OP_IdxGT)
85832
+** <li> <b>0x08 OPFLAG_FORDELETE</b>: This cursor is used only to seek
85833
+** and subsequently delete entries in an index btree. This is a
85834
+** hint to the storage engine that the storage engine is allowed to
85835
+** ignore. The hint is not used by the official SQLite b*tree storage
85836
+** engine, but is used by COMDB2.
85837
+** <li> <b>0x10 OPFLAG_P2ISREG</b>: Use the content of register P2
85838
+** as the root page, not the value of P2 itself.
85839
+** </ul>
85840
+**
85841
+** This instruction works like OpenRead except that it opens the cursor
85842
+** in read/write mode.
85843
+**
85844
+** See also: OP_OpenRead, OP_ReopenIdx
8534785845
*/
8534885846
case OP_ReopenIdx: {
8534985847
int nField;
8535085848
KeyInfo *pKeyInfo;
8535185849
int p2;
@@ -85397,10 +85895,11 @@
8539785895
wrFlag = 0;
8539885896
}
8539985897
if( pOp->p5 & OPFLAG_P2ISREG ){
8540085898
assert( p2>0 );
8540185899
assert( p2<=(p->nMem+1 - p->nCursor) );
85900
+ assert( pOp->opcode==OP_OpenWrite );
8540285901
pIn2 = &aMem[p2];
8540385902
assert( memIsValid(pIn2) );
8540485903
assert( (pIn2->flags & MEM_Int)!=0 );
8540585904
sqlite3VdbeMemIntegerify(pIn2);
8540685905
p2 = (int)pIn2->u.i;
@@ -85525,11 +86024,11 @@
8552586024
pCx->nullRow = 1;
8552686025
pCx->isEphemeral = 1;
8552786026
rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
8552886027
BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags);
8552986028
if( rc==SQLITE_OK ){
85530
- rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1);
86029
+ rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
8553186030
}
8553286031
if( rc==SQLITE_OK ){
8553386032
/* If a transient index is required, create it by calling
8553486033
** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
8553586034
** opening it. If a transient table is required, just use the
@@ -85932,10 +86431,29 @@
8593286431
assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
8593386432
pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */
8593486433
}
8593586434
break;
8593686435
}
86436
+
86437
+/* Opcode: SeekHit P1 P2 * * *
86438
+** Synopsis: seekHit=P2
86439
+**
86440
+** Set the seekHit flag on cursor P1 to the value in P2.
86441
+** The seekHit flag is used by the IfNoHope opcode.
86442
+**
86443
+** P1 must be a valid b-tree cursor. P2 must be a boolean value,
86444
+** either 0 or 1.
86445
+*/
86446
+case OP_SeekHit: {
86447
+ VdbeCursor *pC;
86448
+ assert( pOp->p1>=0 && pOp->p1<p->nCursor );
86449
+ pC = p->apCsr[pOp->p1];
86450
+ assert( pC!=0 );
86451
+ assert( pOp->p2==0 || pOp->p2==1 );
86452
+ pC->seekHit = pOp->p2 & 1;
86453
+ break;
86454
+}
8593786455
8593886456
/* Opcode: Found P1 P2 P3 P4 *
8593986457
** Synopsis: key=r[P3@P4]
8594086458
**
8594186459
** If P4==0 then register P3 holds a blob constructed by MakeRecord. If
@@ -85967,11 +86485,38 @@
8596786485
**
8596886486
** This operation leaves the cursor in a state where it cannot be
8596986487
** advanced in either direction. In other words, the Next and Prev
8597086488
** opcodes do not work after this operation.
8597186489
**
85972
-** See also: Found, NotExists, NoConflict
86490
+** See also: Found, NotExists, NoConflict, IfNoHope
86491
+*/
86492
+/* Opcode: IfNoHope P1 P2 P3 P4 *
86493
+** Synopsis: key=r[P3@P4]
86494
+**
86495
+** Register P3 is the first of P4 registers that form an unpacked
86496
+** record.
86497
+**
86498
+** Cursor P1 is on an index btree. If the seekHit flag is set on P1, then
86499
+** this opcode is a no-op. But if the seekHit flag of P1 is clear, then
86500
+** check to see if there is any entry in P1 that matches the
86501
+** prefix identified by P3 and P4. If no entry matches the prefix,
86502
+** jump to P2. Otherwise fall through.
86503
+**
86504
+** This opcode behaves like OP_NotFound if the seekHit
86505
+** flag is clear and it behaves like OP_Noop if the seekHit flag is set.
86506
+**
86507
+** This opcode is used in IN clause processing for a multi-column key.
86508
+** If an IN clause is attached to an element of the key other than the
86509
+** left-most element, and if there are no matches on the most recent
86510
+** seek over the whole key, then it might be that one of the key element
86511
+** to the left is prohibiting a match, and hence there is "no hope" of
86512
+** any match regardless of how many IN clause elements are checked.
86513
+** In such a case, we abandon the IN clause search early, using this
86514
+** opcode. The opcode name comes from the fact that the
86515
+** jump is taken if there is "no hope" of achieving a match.
86516
+**
86517
+** See also: NotFound, SeekHit
8597386518
*/
8597486519
/* Opcode: NoConflict P1 P2 P3 P4 *
8597586520
** Synopsis: key=r[P3@P4]
8597686521
**
8597786522
** If P4==0 then register P3 holds a blob constructed by MakeRecord. If
@@ -85992,10 +86537,18 @@
8599286537
** advanced in either direction. In other words, the Next and Prev
8599386538
** opcodes do not work after this operation.
8599486539
**
8599586540
** See also: NotFound, Found, NotExists
8599686541
*/
86542
+case OP_IfNoHope: { /* jump, in3 */
86543
+ VdbeCursor *pC;
86544
+ assert( pOp->p1>=0 && pOp->p1<p->nCursor );
86545
+ pC = p->apCsr[pOp->p1];
86546
+ assert( pC!=0 );
86547
+ if( pC->seekHit ) break;
86548
+ /* Fall through into OP_NotFound */
86549
+}
8599786550
case OP_NoConflict: /* jump, in3 */
8599886551
case OP_NotFound: /* jump, in3 */
8599986552
case OP_Found: { /* jump, in3 */
8600086553
int alreadyExists;
8600186554
int takeJump;
@@ -86140,11 +86693,11 @@
8614086693
assert( pIn3->flags & MEM_Int );
8614186694
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8614286695
pC = p->apCsr[pOp->p1];
8614386696
assert( pC!=0 );
8614486697
#ifdef SQLITE_DEBUG
86145
- pC->seekOp = 0;
86698
+ pC->seekOp = OP_SeekRowid;
8614686699
#endif
8614786700
assert( pC->isTable );
8614886701
assert( pC->eCurType==CURTYPE_BTREE );
8614986702
pCrsr = pC->uc.pCursor;
8615086703
assert( pCrsr!=0 );
@@ -86794,10 +87347,13 @@
8679487347
pC->cacheStatus = CACHE_STALE;
8679587348
if( pC->eCurType==CURTYPE_BTREE ){
8679687349
assert( pC->uc.pCursor!=0 );
8679787350
sqlite3BtreeClearCursor(pC->uc.pCursor);
8679887351
}
87352
+#ifdef SQLITE_DEBUG
87353
+ if( pC->seekOp==0 ) pC->seekOp = OP_NullRow;
87354
+#endif
8679987355
break;
8680087356
}
8680187357
8680287358
/* Opcode: SeekEnd P1 * * * *
8680387359
**
@@ -86912,17 +87468,21 @@
8691287468
sqlite3_search_count--;
8691387469
#endif
8691487470
p->aCounter[SQLITE_STMTSTATUS_SORT]++;
8691587471
/* Fall through into OP_Rewind */
8691687472
}
86917
-/* Opcode: Rewind P1 P2 * * *
87473
+/* Opcode: Rewind P1 P2 * * P5
8691887474
**
8691987475
** The next use of the Rowid or Column or Next instruction for P1
8692087476
** will refer to the first entry in the database table or index.
8692187477
** If the table or index is empty, jump immediately to P2.
8692287478
** If the table or index is not empty, fall through to the following
8692387479
** instruction.
87480
+**
87481
+** If P5 is non-zero and the table is not empty, then the "skip-next"
87482
+** flag is set on the cursor so that the next OP_Next instruction
87483
+** executed on it is a no-op.
8692487484
**
8692587485
** This opcode leaves the cursor configured to move in forward order,
8692687486
** from the beginning toward the end. In other words, the cursor is
8692787487
** configured to use Next, not Prev.
8692887488
*/
@@ -86944,10 +87504,13 @@
8694487504
}else{
8694587505
assert( pC->eCurType==CURTYPE_BTREE );
8694687506
pCrsr = pC->uc.pCursor;
8694787507
assert( pCrsr );
8694887508
rc = sqlite3BtreeFirst(pCrsr, &res);
87509
+#ifndef SQLITE_OMIT_WINDOWFUNC
87510
+ if( pOp->p5 ) sqlite3BtreeSkipNext(pCrsr);
87511
+#endif
8694987512
pC->deferredMoveto = 0;
8695087513
pC->cacheStatus = CACHE_STALE;
8695187514
}
8695287515
if( rc ) goto abort_due_to_error;
8695387516
pC->nullRow = (u8)res;
@@ -86980,16 +87543,11 @@
8698087543
** sqlite3BtreeNext().
8698187544
**
8698287545
** If P5 is positive and the jump is taken, then event counter
8698387546
** number P5-1 in the prepared statement is incremented.
8698487547
**
86985
-** See also: Prev, NextIfOpen
86986
-*/
86987
-/* Opcode: NextIfOpen P1 P2 P3 P4 P5
86988
-**
86989
-** This opcode works just like Next except that if cursor P1 is not
86990
-** open it behaves a no-op.
87548
+** See also: Prev
8699187549
*/
8699287550
/* Opcode: Prev P1 P2 P3 P4 P5
8699387551
**
8699487552
** Back up cursor P1 so that it points to the previous key/data pair in its
8699587553
** table or index. If there is no previous key/value pairs then fall through
@@ -87013,15 +87571,10 @@
8701387571
** sqlite3BtreePrevious().
8701487572
**
8701587573
** If P5 is positive and the jump is taken, then event counter
8701687574
** number P5-1 in the prepared statement is incremented.
8701787575
*/
87018
-/* Opcode: PrevIfOpen P1 P2 P3 P4 P5
87019
-**
87020
-** This opcode works just like Prev except that if cursor P1 is not
87021
-** open it behaves a no-op.
87022
-*/
8702387576
/* Opcode: SorterNext P1 P2 * * P5
8702487577
**
8702587578
** This opcode works just like OP_Next except that P1 must be a
8702687579
** sorter object for which the OP_SorterSort opcode has been
8702787580
** invoked. This opcode advances the cursor to the next sorted
@@ -87032,14 +87585,10 @@
8703287585
8703387586
pC = p->apCsr[pOp->p1];
8703487587
assert( isSorter(pC) );
8703587588
rc = sqlite3VdbeSorterNext(db, pC);
8703687589
goto next_tail;
87037
-case OP_PrevIfOpen: /* jump */
87038
-case OP_NextIfOpen: /* jump */
87039
- if( p->apCsr[pOp->p1]==0 ) break;
87040
- /* Fall through */
8704187590
case OP_Prev: /* jump */
8704287591
case OP_Next: /* jump */
8704387592
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8704487593
assert( pOp->p5<ArraySize(p->aCounter) );
8704587594
pC = p->apCsr[pOp->p1];
@@ -87046,21 +87595,21 @@
8704687595
assert( pC!=0 );
8704787596
assert( pC->deferredMoveto==0 );
8704887597
assert( pC->eCurType==CURTYPE_BTREE );
8704987598
assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );
8705087599
assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );
87051
- assert( pOp->opcode!=OP_NextIfOpen || pOp->p4.xAdvance==sqlite3BtreeNext );
87052
- assert( pOp->opcode!=OP_PrevIfOpen || pOp->p4.xAdvance==sqlite3BtreePrevious);
8705387600
87054
- /* The Next opcode is only used after SeekGT, SeekGE, and Rewind.
87601
+ /* The Next opcode is only used after SeekGT, SeekGE, Rewind, and Found.
8705587602
** The Prev opcode is only used after SeekLT, SeekLE, and Last. */
87056
- assert( pOp->opcode!=OP_Next || pOp->opcode!=OP_NextIfOpen
87603
+ assert( pOp->opcode!=OP_Next
8705787604
|| pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
87058
- || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found);
87059
- assert( pOp->opcode!=OP_Prev || pOp->opcode!=OP_PrevIfOpen
87605
+ || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
87606
+ || pC->seekOp==OP_NullRow);
87607
+ assert( pOp->opcode!=OP_Prev
8706087608
|| pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
87061
- || pC->seekOp==OP_Last );
87609
+ || pC->seekOp==OP_Last
87610
+ || pC->seekOp==OP_NullRow);
8706287611
8706387612
rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
8706487613
next_tail:
8706587614
pC->cacheStatus = CACHE_STALE;
8706687615
VdbeBranchTaken(rc==SQLITE_OK,2);
@@ -88125,28 +88674,39 @@
8812588674
if( pIn1->u.i==0 ) goto jump_to_p2;
8812688675
break;
8812788676
}
8812888677
8812988678
88130
-/* Opcode: AggStep0 * P2 P3 P4 P5
88679
+/* Opcode: AggStep * P2 P3 P4 P5
8813188680
** Synopsis: accum=r[P3] step(r[P2@P5])
8813288681
**
88133
-** Execute the step function for an aggregate. The
88134
-** function has P5 arguments. P4 is a pointer to the FuncDef
88135
-** structure that specifies the function. Register P3 is the
88682
+** Execute the xStep function for an aggregate.
88683
+** The function has P5 arguments. P4 is a pointer to the
88684
+** FuncDef structure that specifies the function. Register P3 is the
88685
+** accumulator.
88686
+**
88687
+** The P5 arguments are taken from register P2 and its
88688
+** successors.
88689
+*/
88690
+/* Opcode: AggInverse * P2 P3 P4 P5
88691
+** Synopsis: accum=r[P3] inverse(r[P2@P5])
88692
+**
88693
+** Execute the xInverse function for an aggregate.
88694
+** The function has P5 arguments. P4 is a pointer to the
88695
+** FuncDef structure that specifies the function. Register P3 is the
8813688696
** accumulator.
8813788697
**
8813888698
** The P5 arguments are taken from register P2 and its
8813988699
** successors.
8814088700
*/
88141
-/* Opcode: AggStep * P2 P3 P4 P5
88701
+/* Opcode: AggStep1 P1 P2 P3 P4 P5
8814288702
** Synopsis: accum=r[P3] step(r[P2@P5])
8814388703
**
88144
-** Execute the step function for an aggregate. The
88145
-** function has P5 arguments. P4 is a pointer to an sqlite3_context
88146
-** object that is used to run the function. Register P3 is
88147
-** as the accumulator.
88704
+** Execute the xStep (if P1==0) or xInverse (if P1!=0) function for an
88705
+** aggregate. The function has P5 arguments. P4 is a pointer to the
88706
+** FuncDef structure that specifies the function. Register P3 is the
88707
+** accumulator.
8814888708
**
8814988709
** The P5 arguments are taken from register P2 and its
8815088710
** successors.
8815188711
**
8815288712
** This opcode is initially coded as OP_AggStep0. On first evaluation,
@@ -88153,11 +88713,12 @@
8815388713
** the FuncDef stored in P4 is converted into an sqlite3_context and
8815488714
** the opcode is changed. In this way, the initialization of the
8815588715
** sqlite3_context only happens once, instead of on each call to the
8815688716
** step function.
8815788717
*/
88158
-case OP_AggStep0: {
88718
+case OP_AggInverse:
88719
+case OP_AggStep: {
8815988720
int n;
8816088721
sqlite3_context *pCtx;
8816188722
8816288723
assert( pOp->p4type==P4_FUNCDEF );
8816388724
n = pOp->p5;
@@ -88176,21 +88737,36 @@
8817688737
pCtx->skipFlag = 0;
8817788738
pCtx->isError = 0;
8817888739
pCtx->argc = n;
8817988740
pOp->p4type = P4_FUNCCTX;
8818088741
pOp->p4.pCtx = pCtx;
88181
- pOp->opcode = OP_AggStep;
88742
+
88743
+ /* OP_AggInverse must have P1==1 and OP_AggStep must have P1==0 */
88744
+ assert( pOp->p1==(pOp->opcode==OP_AggInverse) );
88745
+
88746
+ pOp->opcode = OP_AggStep1;
8818288747
/* Fall through into OP_AggStep */
8818388748
}
88184
-case OP_AggStep: {
88749
+case OP_AggStep1: {
8818588750
int i;
8818688751
sqlite3_context *pCtx;
8818788752
Mem *pMem;
8818888753
8818988754
assert( pOp->p4type==P4_FUNCCTX );
8819088755
pCtx = pOp->p4.pCtx;
8819188756
pMem = &aMem[pOp->p3];
88757
+
88758
+#ifdef SQLITE_DEBUG
88759
+ if( pOp->p1 ){
88760
+ /* This is an OP_AggInverse call. Verify that xStep has always
88761
+ ** been called at least once prior to any xInverse call. */
88762
+ assert( pMem->uTemp==0x1122e0e3 );
88763
+ }else{
88764
+ /* This is an OP_AggStep call. Mark it as such. */
88765
+ pMem->uTemp = 0x1122e0e3;
88766
+ }
88767
+#endif
8819288768
8819388769
/* If this function is inside of a trigger, the register array in aMem[]
8819488770
** might change from one evaluation to the next. The next block of code
8819588771
** checks to see if the register array has changed, and if so it
8819688772
** reinitializes the relavant parts of the sqlite3_context object */
@@ -88208,11 +88784,17 @@
8820888784
8820988785
pMem->n++;
8821088786
assert( pCtx->pOut->flags==MEM_Null );
8821188787
assert( pCtx->isError==0 );
8821288788
assert( pCtx->skipFlag==0 );
88789
+#ifndef SQLITE_OMIT_WINDOWFUNC
88790
+ if( pOp->p1 ){
88791
+ (pCtx->pFunc->xInverse)(pCtx,pCtx->argc,pCtx->argv);
88792
+ }else
88793
+#endif
8821388794
(pCtx->pFunc->xSFunc)(pCtx,pCtx->argc,pCtx->argv); /* IMP: R-24505-23230 */
88795
+
8821488796
if( pCtx->isError ){
8821588797
if( pCtx->isError>0 ){
8821688798
sqlite3VdbeError(p, "%s", sqlite3_value_text(pCtx->pOut));
8821788799
rc = pCtx->isError;
8821888800
}
@@ -88233,26 +88815,50 @@
8823388815
}
8823488816
8823588817
/* Opcode: AggFinal P1 P2 * P4 *
8823688818
** Synopsis: accum=r[P1] N=P2
8823788819
**
88238
-** Execute the finalizer function for an aggregate. P1 is
88239
-** the memory location that is the accumulator for the aggregate.
88820
+** P1 is the memory location that is the accumulator for an aggregate
88821
+** or window function. Execute the finalizer function
88822
+** for an aggregate and store the result in P1.
88823
+**
88824
+** P2 is the number of arguments that the step function takes and
88825
+** P4 is a pointer to the FuncDef for this function. The P2
88826
+** argument is not used by this opcode. It is only there to disambiguate
88827
+** functions that can take varying numbers of arguments. The
88828
+** P4 argument is only needed for the case where
88829
+** the step function was not previously called.
88830
+*/
88831
+/* Opcode: AggValue * P2 P3 P4 *
88832
+** Synopsis: r[P3]=value N=P2
88833
+**
88834
+** Invoke the xValue() function and store the result in register P3.
8824088835
**
8824188836
** P2 is the number of arguments that the step function takes and
8824288837
** P4 is a pointer to the FuncDef for this function. The P2
8824388838
** argument is not used by this opcode. It is only there to disambiguate
8824488839
** functions that can take varying numbers of arguments. The
88245
-** P4 argument is only needed for the degenerate case where
88840
+** P4 argument is only needed for the case where
8824688841
** the step function was not previously called.
8824788842
*/
88843
+case OP_AggValue:
8824888844
case OP_AggFinal: {
8824988845
Mem *pMem;
8825088846
assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
88847
+ assert( pOp->p3==0 || pOp->opcode==OP_AggValue );
8825188848
pMem = &aMem[pOp->p1];
8825288849
assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
88253
- rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
88850
+#ifndef SQLITE_OMIT_WINDOWFUNC
88851
+ if( pOp->p3 ){
88852
+ rc = sqlite3VdbeMemAggValue(pMem, &aMem[pOp->p3], pOp->p4.pFunc);
88853
+ pMem = &aMem[pOp->p3];
88854
+ }else
88855
+#endif
88856
+ {
88857
+ rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
88858
+ }
88859
+
8825488860
if( rc ){
8825588861
sqlite3VdbeError(p, "%s", sqlite3_value_text(pMem));
8825688862
goto abort_due_to_error;
8825788863
}
8825888864
sqlite3VdbeChangeEncoding(pMem, encoding);
@@ -88843,10 +89449,11 @@
8884389449
8884489450
assert( pOp->p2==1 || pOp->p5==OE_Fail || pOp->p5==OE_Rollback
8884589451
|| pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
8884689452
);
8884789453
assert( p->readOnly==0 );
89454
+ if( db->mallocFailed ) goto no_mem;
8884889455
sqlite3VdbeIncrWriteCounter(p, 0);
8884989456
pVtab = pOp->p4.pVtab->pVtab;
8885089457
if( pVtab==0 || NEVER(pVtab->pModule==0) ){
8885189458
rc = SQLITE_LOCKED;
8885289459
goto abort_due_to_error;
@@ -89176,10 +89783,38 @@
8917689783
case OP_Abortable: {
8917789784
sqlite3VdbeAssertAbortable(p);
8917889785
break;
8917989786
}
8918089787
#endif
89788
+
89789
+#ifdef SQLITE_DEBUG_COLUMNCACHE
89790
+/* Opcode: SetTabCol P1 P2 P3 * *
89791
+**
89792
+** Set a flag in register REG[P3] indicating that it holds the value
89793
+** of column P2 from the table on cursor P1. This flag is checked
89794
+** by a subsequent VerifyTabCol opcode.
89795
+**
89796
+** This opcode only appears SQLITE_DEBUG builds. It is used to verify
89797
+** that the expression table column cache is working correctly.
89798
+*/
89799
+case OP_SetTabCol: {
89800
+ aMem[pOp->p3].iTabColHash = TableColumnHash(pOp->p1,pOp->p2);
89801
+ break;
89802
+}
89803
+/* Opcode: VerifyTabCol P1 P2 P3 * *
89804
+**
89805
+** Verify that register REG[P3] contains the value of column P2 from
89806
+** cursor P1. Assert() if this is not the case.
89807
+**
89808
+** This opcode only appears SQLITE_DEBUG builds. It is used to verify
89809
+** that the expression table column cache is working correctly.
89810
+*/
89811
+case OP_VerifyTabCol: {
89812
+ assert( aMem[pOp->p3].iTabColHash == TableColumnHash(pOp->p1,pOp->p2) );
89813
+ break;
89814
+}
89815
+#endif
8918189816
8918289817
/* Opcode: Noop * * * * *
8918389818
**
8918489819
** Do nothing. This instruction is often useful as a jump
8918589820
** destination.
@@ -93052,10 +93687,18 @@
9305293687
}else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
9305393688
if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
9305493689
}else if( pExpr->x.pList ){
9305593690
if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
9305693691
}
93692
+#ifndef SQLITE_OMIT_WINDOWFUNC
93693
+ if( !ExprHasProperty(pExpr, EP_Reduced) && pExpr->pWin ){
93694
+ Window *pWin = pExpr->pWin;
93695
+ if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
93696
+ if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
93697
+ if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
93698
+ }
93699
+#endif
9305793700
}
9305893701
break;
9305993702
}
9306093703
return WRC_Continue;
9306193704
}
@@ -93916,15 +94559,44 @@
9391694559
** in an index. */
9391794560
notValid(pParse, pNC, "non-deterministic functions",
9391894561
NC_IdxExpr|NC_PartIdx);
9391994562
}
9392094563
}
93921
- if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
94564
+
94565
+#ifndef SQLITE_OMIT_WINDOWFUNC
94566
+ assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
94567
+ || (pDef->xValue==0 && pDef->xInverse==0)
94568
+ || (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
94569
+ );
94570
+ if( pDef && pDef->xValue==0 && pExpr->pWin ){
94571
+ sqlite3ErrorMsg(pParse,
94572
+ "%.*s() may not be used as a window function", nId, zId
94573
+ );
94574
+ pNC->nErr++;
94575
+ }else if(
94576
+ (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
94577
+ || (is_agg && (pDef->funcFlags & SQLITE_FUNC_WINDOW) && !pExpr->pWin)
94578
+ || (is_agg && pExpr->pWin && (pNC->ncFlags & NC_AllowWin)==0)
94579
+ ){
94580
+ const char *zType;
94581
+ if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->pWin ){
94582
+ zType = "window";
94583
+ }else{
94584
+ zType = "aggregate";
94585
+ }
94586
+ sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()", zType, nId,zId);
94587
+ pNC->nErr++;
94588
+ is_agg = 0;
94589
+ }
94590
+#else
94591
+ if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
9392294592
sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
9392394593
pNC->nErr++;
9392494594
is_agg = 0;
93925
- }else if( no_such_func && pParse->db->init.busy==0
94595
+ }
94596
+#endif
94597
+ else if( no_such_func && pParse->db->init.busy==0
9392694598
#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
9392794599
&& pParse->explain==0
9392894600
#endif
9392994601
){
9393094602
sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
@@ -93932,28 +94604,52 @@
9393294604
}else if( wrong_num_args ){
9393394605
sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
9393494606
nId, zId);
9393594607
pNC->nErr++;
9393694608
}
93937
- if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg;
94609
+ if( is_agg ){
94610
+#ifndef SQLITE_OMIT_WINDOWFUNC
94611
+ pNC->ncFlags &= ~(pExpr->pWin ? NC_AllowWin : NC_AllowAgg);
94612
+#else
94613
+ pNC->ncFlags &= ~NC_AllowAgg;
94614
+#endif
94615
+ }
9393894616
sqlite3WalkExprList(pWalker, pList);
9393994617
if( is_agg ){
93940
- NameContext *pNC2 = pNC;
93941
- pExpr->op = TK_AGG_FUNCTION;
93942
- pExpr->op2 = 0;
93943
- while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){
93944
- pExpr->op2++;
93945
- pNC2 = pNC2->pNext;
93946
- }
93947
- assert( pDef!=0 );
93948
- if( pNC2 ){
93949
- assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
93950
- testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
93951
- pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
93952
-
93953
- }
93954
- pNC->ncFlags |= NC_AllowAgg;
94618
+#ifndef SQLITE_OMIT_WINDOWFUNC
94619
+ if( pExpr->pWin ){
94620
+ Select *pSel = pNC->pWinSelect;
94621
+ sqlite3WalkExprList(pWalker, pExpr->pWin->pPartition);
94622
+ sqlite3WalkExprList(pWalker, pExpr->pWin->pOrderBy);
94623
+ sqlite3WalkExpr(pWalker, pExpr->pWin->pFilter);
94624
+ sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->pWin, pDef);
94625
+ if( 0==pSel->pWin
94626
+ || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->pWin)
94627
+ ){
94628
+ pExpr->pWin->pNextWin = pSel->pWin;
94629
+ pSel->pWin = pExpr->pWin;
94630
+ }
94631
+ pNC->ncFlags |= NC_AllowWin;
94632
+ }else
94633
+#endif /* SQLITE_OMIT_WINDOWFUNC */
94634
+ {
94635
+ NameContext *pNC2 = pNC;
94636
+ pExpr->op = TK_AGG_FUNCTION;
94637
+ pExpr->op2 = 0;
94638
+ while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){
94639
+ pExpr->op2++;
94640
+ pNC2 = pNC2->pNext;
94641
+ }
94642
+ assert( pDef!=0 );
94643
+ if( pNC2 ){
94644
+ assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
94645
+ testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
94646
+ pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
94647
+
94648
+ }
94649
+ pNC->ncFlags |= NC_AllowAgg;
94650
+ }
9395594651
}
9395694652
/* FIX ME: Compute pExpr->affinity based on the expected return
9395794653
** type of the function
9395894654
*/
9395994655
return WRC_Prune;
@@ -94350,10 +95046,23 @@
9435095046
if( sqlite3ResolveExprNames(pNC, pE) ){
9435195047
return 1;
9435295048
}
9435395049
for(j=0; j<pSelect->pEList->nExpr; j++){
9435495050
if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
95051
+#ifndef SQLITE_OMIT_WINDOWFUNC
95052
+ if( pE->pWin ){
95053
+ /* Since this window function is being changed into a reference
95054
+ ** to the same window function the result set, remove the instance
95055
+ ** of this window function from the Select.pWin list. */
95056
+ Window **pp;
95057
+ for(pp=&pSelect->pWin; *pp; pp=&(*pp)->pNextWin){
95058
+ if( *pp==pE->pWin ){
95059
+ *pp = (*pp)->pNextWin;
95060
+ }
95061
+ }
95062
+ }
95063
+#endif
9435595064
pItem->u.x.iOrderByCol = j+1;
9435695065
}
9435795066
}
9435895067
}
9435995068
return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -94406,10 +95115,11 @@
9440695115
/* Resolve the expressions in the LIMIT and OFFSET clauses. These
9440795116
** are not allowed to refer to any names, so pass an empty NameContext.
9440895117
*/
9440995118
memset(&sNC, 0, sizeof(sNC));
9441095119
sNC.pParse = pParse;
95120
+ sNC.pWinSelect = p;
9441195121
if( sqlite3ResolveExprNames(&sNC, p->pLimit) ){
9441295122
return WRC_Abort;
9441395123
}
9441495124
9441595125
/* If the SF_Converted flags is set, then this Select object was
@@ -94454,16 +95164,17 @@
9445495164
}
9445595165
9445695166
/* Set up the local name-context to pass to sqlite3ResolveExprNames() to
9445795167
** resolve the result-set expression list.
9445895168
*/
94459
- sNC.ncFlags = NC_AllowAgg;
95169
+ sNC.ncFlags = NC_AllowAgg|NC_AllowWin;
9446095170
sNC.pSrcList = p->pSrc;
9446195171
sNC.pNext = pOuterNC;
9446295172
9446395173
/* Resolve names in the result set. */
9446495174
if( sqlite3ResolveExprListNames(&sNC, p->pEList) ) return WRC_Abort;
95175
+ sNC.ncFlags &= ~NC_AllowWin;
9446595176
9446695177
/* If there are no aggregate functions in the result-set, and no GROUP BY
9446795178
** expression, do not allow aggregates in any of the other expressions.
9446895179
*/
9446995180
assert( (p->selFlags & SF_Aggregate)==0 );
@@ -94508,11 +95219,11 @@
9450895219
9450995220
/* The ORDER BY and GROUP BY clauses may not refer to terms in
9451095221
** outer queries
9451195222
*/
9451295223
sNC.pNext = 0;
94513
- sNC.ncFlags |= NC_AllowAgg;
95224
+ sNC.ncFlags |= NC_AllowAgg|NC_AllowWin;
9451495225
9451595226
/* If this is a converted compound query, move the ORDER BY clause from
9451695227
** the sub-query back to the parent query. At this point each term
9451795228
** within the ORDER BY clause has been transformed to an integer value.
9451895229
** These integers will be replaced by copies of the corresponding result
@@ -94539,10 +95250,11 @@
9453995250
return WRC_Abort;
9454095251
}
9454195252
if( db->mallocFailed ){
9454295253
return WRC_Abort;
9454395254
}
95255
+ sNC.ncFlags &= ~NC_AllowWin;
9454495256
9454595257
/* Resolve the GROUP BY clause. At the same time, make sure
9454695258
** the GROUP BY clause does not contain aggregate functions.
9454795259
*/
9454895260
if( pGroupBy ){
@@ -95809,10 +96521,13 @@
9580996521
}else if( ExprHasProperty(p, EP_xIsSelect) ){
9581096522
sqlite3SelectDelete(db, p->x.pSelect);
9581196523
}else{
9581296524
sqlite3ExprListDelete(db, p->x.pList);
9581396525
}
96526
+ if( !ExprHasProperty(p, EP_Reduced) ){
96527
+ sqlite3WindowDelete(db, p->pWin);
96528
+ }
9581496529
}
9581596530
if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
9581696531
if( !ExprHasProperty(p, EP_Static) ){
9581796532
sqlite3DbFreeNN(db, p);
9581896533
}
@@ -95857,11 +96572,11 @@
9585796572
** return value with EP_Reduced|EP_TokenOnly.
9585896573
**
9585996574
** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size
9586096575
** (unreduced) Expr objects as they or originally constructed by the parser.
9586196576
** During expression analysis, extra information is computed and moved into
95862
-** later parts of teh Expr object and that extra information might get chopped
96577
+** later parts of the Expr object and that extra information might get chopped
9586396578
** off if the expression is reduced. Note also that it does not work to
9586496579
** make an EXPRDUP_REDUCE copy of a reduced expression. It is only legal
9586596580
** to reduce a pristine expression tree from the parser. The implementation
9586696581
** of dupedExprStructSize() contain multiple assert() statements that attempt
9586796582
** to enforce this constraint.
@@ -95869,11 +96584,15 @@
9586996584
static int dupedExprStructSize(Expr *p, int flags){
9587096585
int nSize;
9587196586
assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */
9587296587
assert( EXPR_FULLSIZE<=0xfff );
9587396588
assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );
95874
- if( 0==flags || p->op==TK_SELECT_COLUMN ){
96589
+ if( 0==flags || p->op==TK_SELECT_COLUMN
96590
+#ifndef SQLITE_OMIT_WINDOWFUNC
96591
+ || p->pWin
96592
+#endif
96593
+ ){
9587596594
nSize = EXPR_FULLSIZE;
9587696595
}else{
9587796596
assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
9587896597
assert( !ExprHasProperty(p, EP_FromJoin) );
9587996598
assert( !ExprHasProperty(p, EP_MemToken) );
@@ -96009,10 +96728,17 @@
9600996728
}
9601096729
if( pzBuffer ){
9601196730
*pzBuffer = zAlloc;
9601296731
}
9601396732
}else{
96733
+#ifndef SQLITE_OMIT_WINDOWFUNC
96734
+ if( ExprHasProperty(p, EP_Reduced|EP_TokenOnly) ){
96735
+ pNew->pWin = 0;
96736
+ }else{
96737
+ pNew->pWin = sqlite3WindowDup(db, pNew, p->pWin);
96738
+ }
96739
+#endif /* SQLITE_OMIT_WINDOWFUNC */
9601496740
if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
9601596741
if( pNew->op==TK_SELECT_COLUMN ){
9601696742
pNew->pLeft = p->pLeft;
9601796743
assert( p->iColumn==0 || p->pRight==0 );
9601896744
assert( p->pRight==0 || p->pRight==p->pLeft );
@@ -96215,11 +96941,15 @@
9621596941
pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
9621696942
pNew->addrOpenEphm[0] = -1;
9621796943
pNew->addrOpenEphm[1] = -1;
9621896944
pNew->nSelectRow = p->nSelectRow;
9621996945
pNew->pWith = withDup(db, p->pWith);
96220
- sqlite3SelectSetName(pNew, p->zSelName);
96946
+#ifndef SQLITE_OMIT_WINDOWFUNC
96947
+ pNew->pWin = 0;
96948
+ pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
96949
+#endif
96950
+ pNew->selId = p->selId;
9622196951
*pp = pNew;
9622296952
pp = &pNew->pPrior;
9622396953
pNext = pNew;
9622496954
}
9622596955
@@ -97945,10 +98675,17 @@
9794598675
#ifndef NDEBUG
9794698676
for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){
9794798677
assert( p->iTable!=iTab || p->iColumn!=iCol );
9794898678
}
9794998679
#endif
98680
+
98681
+#ifdef SQLITE_DEBUG_COLUMNCACHE
98682
+ /* Add a SetTabCol opcode for run-time verification that the column
98683
+ ** cache is working correctly.
98684
+ */
98685
+ sqlite3VdbeAddOp3(pParse->pVdbe, OP_SetTabCol, iTab, iCol, iReg);
98686
+#endif
9795098687
9795198688
/* If the cache is already full, delete the least recently used entry */
9795298689
if( pParse->nColCache>=SQLITE_N_COLCACHE ){
9795398690
minLru = 0x7fffffff;
9795498691
idxLru = -1;
@@ -98119,10 +98856,13 @@
9811998856
9812098857
for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){
9812198858
if( p->iTable==iTable && p->iColumn==iColumn ){
9812298859
p->lru = pParse->iCacheCnt++;
9812398860
sqlite3ExprCachePinRegister(pParse, p->iReg);
98861
+#ifdef SQLITE_DEBUG_COLUMNCACHE
98862
+ sqlite3VdbeAddOp3(v, OP_VerifyTabCol, iTable, iColumn, p->iReg);
98863
+#endif
9812498864
return p->iReg;
9812598865
}
9812698866
}
9812798867
assert( v!=0 );
9812898868
sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
@@ -98523,10 +99263,16 @@
9852399263
u32 constMask = 0; /* Mask of function arguments that are constant */
9852499264
int i; /* Loop counter */
9852599265
sqlite3 *db = pParse->db; /* The database connection */
9852699266
u8 enc = ENC(db); /* The text encoding used by this database */
9852799267
CollSeq *pColl = 0; /* A collating sequence */
99268
+
99269
+#ifndef SQLITE_OMIT_WINDOWFUNC
99270
+ if( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) && pExpr->pWin ){
99271
+ return pExpr->pWin->regResult;
99272
+ }
99273
+#endif
9852899274
9852999275
if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
9853099276
/* SQL functions can be expensive. So try to move constant functions
9853199277
** out of the inner loop, even if that means an extra OP_Copy. */
9853299278
return sqlite3ExprCodeAtInit(pParse, pExpr, -1);
@@ -99663,10 +100409,25 @@
99663100409
if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
99664100410
if( pA->iColumn!=pB->iColumn ) return 2;
99665100411
if( pA->iTable!=pB->iTable
99666100412
&& (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
99667100413
}
100414
+#ifndef SQLITE_OMIT_WINDOWFUNC
100415
+ /* Justification for the assert():
100416
+ ** window functions have p->op==TK_FUNCTION but aggregate functions
100417
+ ** have p->op==TK_AGG_FUNCTION. So any comparison between an aggregate
100418
+ ** function and a window function should have failed before reaching
100419
+ ** this point. And, it is not possible to have a window function and
100420
+ ** a scalar function with the same name and number of arguments. So
100421
+ ** if we reach this point, either A and B both window functions or
100422
+ ** neither are a window functions. */
100423
+ assert( (pA->pWin==0)==(pB->pWin==0) );
100424
+
100425
+ if( pA->pWin!=0 ){
100426
+ if( sqlite3WindowCompare(pParse,pA->pWin,pB->pWin)!=0 ) return 2;
100427
+ }
100428
+#endif
99668100429
}
99669100430
return 0;
99670100431
}
99671100432
99672100433
/*
@@ -100342,11 +101103,11 @@
100342101103
*/
100343101104
do {
100344101105
zCsr += len;
100345101106
len = sqlite3GetToken(zCsr, &token);
100346101107
} while( token==TK_SPACE );
100347
- assert( len>0 );
101108
+ assert( len>0 || !*zCsr );
100348101109
} while( token!=TK_LP && token!=TK_USING );
100349101110
100350101111
zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", (int)(((u8*)tname.z) - zSql),
100351101112
zSql, zTableName, tname.z+tname.n);
100352101113
sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);
@@ -100410,11 +101171,11 @@
100410101171
}
100411101172
sqlite3DbFree(db, zParent);
100412101173
}
100413101174
}
100414101175
100415
- zResult = sqlite3MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput),
101176
+ zResult = sqlite3MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput);
100416101177
sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);
100417101178
sqlite3DbFree(db, zOutput);
100418101179
}
100419101180
#endif
100420101181
@@ -100466,11 +101227,11 @@
100466101227
*/
100467101228
do {
100468101229
zCsr += len;
100469101230
len = sqlite3GetToken(zCsr, &token);
100470101231
}while( token==TK_SPACE );
100471
- assert( len>0 );
101232
+ assert( len>0 || !*zCsr );
100472101233
100473101234
/* Variable 'dist' stores the number of tokens read since the most
100474101235
** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN
100475101236
** token is read and 'dist' equals 2, the condition stated above
100476101237
** to be met.
@@ -101564,10 +102325,11 @@
101564102325
SQLITE_UTF8, /* funcFlags */
101565102326
0, /* pUserData */
101566102327
0, /* pNext */
101567102328
statInit, /* xSFunc */
101568102329
0, /* xFinalize */
102330
+ 0, 0, /* xValue, xInverse */
101569102331
"stat_init", /* zName */
101570102332
{0}
101571102333
};
101572102334
101573102335
#ifdef SQLITE_ENABLE_STAT4
@@ -101880,10 +102642,11 @@
101880102642
SQLITE_UTF8, /* funcFlags */
101881102643
0, /* pUserData */
101882102644
0, /* pNext */
101883102645
statPush, /* xSFunc */
101884102646
0, /* xFinalize */
102647
+ 0, 0, /* xValue, xInverse */
101885102648
"stat_push", /* zName */
101886102649
{0}
101887102650
};
101888102651
101889102652
#define STAT_GET_STAT1 0 /* "stat" column of stat1 table */
@@ -102031,10 +102794,11 @@
102031102794
SQLITE_UTF8, /* funcFlags */
102032102795
0, /* pUserData */
102033102796
0, /* pNext */
102034102797
statGet, /* xSFunc */
102035102798
0, /* xFinalize */
102799
+ 0, 0, /* xValue, xInverse */
102036102800
"stat_get", /* zName */
102037102801
{0}
102038102802
};
102039102803
102040102804
static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
@@ -102350,14 +103114,11 @@
102350103114
VdbeCoverage(v);
102351103115
callStatGet(v, regStat4, STAT_GET_NEQ, regEq);
102352103116
callStatGet(v, regStat4, STAT_GET_NLT, regLt);
102353103117
callStatGet(v, regStat4, STAT_GET_NDLT, regDLt);
102354103118
sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);
102355
- /* We know that the regSampleRowid row exists because it was read by
102356
- ** the previous loop. Thus the not-found jump of seekOp will never
102357
- ** be taken */
102358
- VdbeCoverageNeverTaken(v);
103119
+ VdbeCoverage(v);
102359103120
#ifdef SQLITE_ENABLE_STAT3
102360103121
sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, 0, regSample);
102361103122
#else
102362103123
for(i=0; i<nCol; i++){
102363103124
sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
@@ -103432,10 +104193,11 @@
103432104193
SQLITE_UTF8, /* funcFlags */
103433104194
0, /* pUserData */
103434104195
0, /* pNext */
103435104196
detachFunc, /* xSFunc */
103436104197
0, /* xFinalize */
104198
+ 0, 0, /* xValue, xInverse */
103437104199
"sqlite_detach", /* zName */
103438104200
{0}
103439104201
};
103440104202
codeAttach(pParse, SQLITE_DETACH, &detach_func, pDbname, 0, 0, pDbname);
103441104203
}
@@ -103451,10 +104213,11 @@
103451104213
SQLITE_UTF8, /* funcFlags */
103452104214
0, /* pUserData */
103453104215
0, /* pNext */
103454104216
attachFunc, /* xSFunc */
103455104217
0, /* xFinalize */
104218
+ 0, 0, /* xValue, xInverse */
103456104219
"sqlite_attach", /* zName */
103457104220
{0}
103458104221
};
103459104222
codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);
103460104223
}
@@ -105613,10 +106376,35 @@
105613106376
*/
105614106377
static int hasColumn(const i16 *aiCol, int nCol, int x){
105615106378
while( nCol-- > 0 ) if( x==*(aiCol++) ) return 1;
105616106379
return 0;
105617106380
}
106381
+
106382
+/* Recompute the colNotIdxed field of the Index.
106383
+**
106384
+** colNotIdxed is a bitmask that has a 0 bit representing each indexed
106385
+** columns that are within the first 63 columns of the table. The
106386
+** high-order bit of colNotIdxed is always 1. All unindexed columns
106387
+** of the table have a 1.
106388
+**
106389
+** The colNotIdxed mask is AND-ed with the SrcList.a[].colUsed mask
106390
+** to determine if the index is covering index.
106391
+*/
106392
+static void recomputeColumnsNotIndexed(Index *pIdx){
106393
+ Bitmask m = 0;
106394
+ int j;
106395
+ for(j=pIdx->nColumn-1; j>=0; j--){
106396
+ int x = pIdx->aiColumn[j];
106397
+ if( x>=0 ){
106398
+ testcase( x==BMS-1 );
106399
+ testcase( x==BMS-2 );
106400
+ if( x<BMS-1 ) m |= MASKBIT(x);
106401
+ }
106402
+ }
106403
+ pIdx->colNotIdxed = ~m;
106404
+ assert( (pIdx->colNotIdxed>>63)==1 );
106405
+}
105618106406
105619106407
/*
105620106408
** This routine runs at the end of parsing a CREATE TABLE statement that
105621106409
** has a WITHOUT ROWID clause. The job of this routine is to convert both
105622106410
** internal schema data structures and the generated VDBE code so that they
@@ -105682,11 +106470,11 @@
105682106470
if( pList==0 ) return;
105683106471
pList->a[0].sortOrder = pParse->iPkSortOrder;
105684106472
assert( pParse->pNewTable==pTab );
105685106473
sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
105686106474
SQLITE_IDXTYPE_PRIMARYKEY);
105687
- if( db->mallocFailed ) return;
106475
+ if( db->mallocFailed || pParse->nErr ) return;
105688106476
pPk = sqlite3PrimaryKeyIndex(pTab);
105689106477
pTab->iPKey = -1;
105690106478
}else{
105691106479
pPk = sqlite3PrimaryKeyIndex(pTab);
105692106480
@@ -105762,10 +106550,11 @@
105762106550
assert( pPk->nColumn==j );
105763106551
assert( pTab->nCol==j );
105764106552
}else{
105765106553
pPk->nColumn = pTab->nCol;
105766106554
}
106555
+ recomputeColumnsNotIndexed(pPk);
105767106556
}
105768106557
105769106558
/*
105770106559
** This routine is called to report the final ")" that terminates
105771106560
** a CREATE TABLE statement.
@@ -106212,10 +107001,15 @@
106212107001
db->lookaside.bDisable--;
106213107002
} else {
106214107003
nErr++;
106215107004
}
106216107005
pTable->pSchema->schemaFlags |= DB_UnresetViews;
107006
+ if( db->mallocFailed ){
107007
+ sqlite3DeleteColumnNames(db, pTable);
107008
+ pTable->aCol = 0;
107009
+ pTable->nCol = 0;
107010
+ }
106217107011
#endif /* SQLITE_OMIT_VIEW */
106218107012
return nErr;
106219107013
}
106220107014
#endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */
106221107015
@@ -107195,10 +107989,11 @@
107195107989
107196107990
/* If this index contains every column of its table, then mark
107197107991
** it as a covering index */
107198107992
assert( HasRowid(pTab)
107199107993
|| pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 );
107994
+ recomputeColumnsNotIndexed(pIndex);
107200107995
if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){
107201107996
pIndex->isCovering = 1;
107202107997
for(j=0; j<pTab->nCol; j++){
107203107998
if( j==pTab->iPKey ) continue;
107204107999
if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue;
@@ -111366,18 +112161,44 @@
111366112161
p->cnt++;
111367112162
if( type==SQLITE_INTEGER ){
111368112163
i64 v = sqlite3_value_int64(argv[0]);
111369112164
p->rSum += v;
111370112165
if( (p->approx|p->overflow)==0 && sqlite3AddInt64(&p->iSum, v) ){
111371
- p->overflow = 1;
112166
+ p->approx = p->overflow = 1;
111372112167
}
111373112168
}else{
111374112169
p->rSum += sqlite3_value_double(argv[0]);
111375112170
p->approx = 1;
111376112171
}
111377112172
}
111378112173
}
112174
+#ifndef SQLITE_OMIT_WINDOWFUNC
112175
+static void sumInverse(sqlite3_context *context, int argc, sqlite3_value**argv){
112176
+ SumCtx *p;
112177
+ int type;
112178
+ assert( argc==1 );
112179
+ UNUSED_PARAMETER(argc);
112180
+ p = sqlite3_aggregate_context(context, sizeof(*p));
112181
+ type = sqlite3_value_numeric_type(argv[0]);
112182
+ /* p is always non-NULL because sumStep() will have been called first
112183
+ ** to initialize it */
112184
+ if( ALWAYS(p) && type!=SQLITE_NULL ){
112185
+ assert( p->cnt>0 );
112186
+ p->cnt--;
112187
+ assert( type==SQLITE_INTEGER || p->approx );
112188
+ if( type==SQLITE_INTEGER && p->approx==0 ){
112189
+ i64 v = sqlite3_value_int64(argv[0]);
112190
+ p->rSum -= v;
112191
+ p->iSum -= v;
112192
+ }else{
112193
+ p->rSum -= sqlite3_value_double(argv[0]);
112194
+ }
112195
+ }
112196
+}
112197
+#else
112198
+# define sumInverse 0
112199
+#endif /* SQLITE_OMIT_WINDOWFUNC */
111379112200
static void sumFinalize(sqlite3_context *context){
111380112201
SumCtx *p;
111381112202
p = sqlite3_aggregate_context(context, 0);
111382112203
if( p && p->cnt>0 ){
111383112204
if( p->overflow ){
@@ -111408,10 +112229,13 @@
111408112229
** count() aggregate function.
111409112230
*/
111410112231
typedef struct CountCtx CountCtx;
111411112232
struct CountCtx {
111412112233
i64 n;
112234
+#ifdef SQLITE_DEBUG
112235
+ int bInverse; /* True if xInverse() ever called */
112236
+#endif
111413112237
};
111414112238
111415112239
/*
111416112240
** Routines to implement the count() aggregate function.
111417112241
*/
@@ -111425,19 +112249,34 @@
111425112249
#ifndef SQLITE_OMIT_DEPRECATED
111426112250
/* The sqlite3_aggregate_count() function is deprecated. But just to make
111427112251
** sure it still operates correctly, verify that its count agrees with our
111428112252
** internal count when using count(*) and when the total count can be
111429112253
** expressed as a 32-bit integer. */
111430
- assert( argc==1 || p==0 || p->n>0x7fffffff
112254
+ assert( argc==1 || p==0 || p->n>0x7fffffff || p->bInverse
111431112255
|| p->n==sqlite3_aggregate_count(context) );
111432112256
#endif
111433112257
}
111434112258
static void countFinalize(sqlite3_context *context){
111435112259
CountCtx *p;
111436112260
p = sqlite3_aggregate_context(context, 0);
111437112261
sqlite3_result_int64(context, p ? p->n : 0);
111438112262
}
112263
+#ifndef SQLITE_OMIT_WINDOWFUNC
112264
+static void countInverse(sqlite3_context *ctx, int argc, sqlite3_value **argv){
112265
+ CountCtx *p;
112266
+ p = sqlite3_aggregate_context(ctx, sizeof(*p));
112267
+ /* p is always non-NULL since countStep() will have been called first */
112268
+ if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && ALWAYS(p) ){
112269
+ p->n--;
112270
+#ifdef SQLITE_DEBUG
112271
+ p->bInverse = 1;
112272
+#endif
112273
+ }
112274
+}
112275
+#else
112276
+# define countInverse 0
112277
+#endif /* SQLITE_OMIT_WINDOWFUNC */
111439112278
111440112279
/*
111441112280
** Routines to implement min() and max() aggregate functions.
111442112281
*/
111443112282
static void minmaxStep(
@@ -111450,11 +112289,11 @@
111450112289
UNUSED_PARAMETER(NotUsed);
111451112290
111452112291
pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));
111453112292
if( !pBest ) return;
111454112293
111455
- if( sqlite3_value_type(argv[0])==SQLITE_NULL ){
112294
+ if( sqlite3_value_type(pArg)==SQLITE_NULL ){
111456112295
if( pBest->flags ) sqlite3SkipAccumulatorLoad(context);
111457112296
}else if( pBest->flags ){
111458112297
int max;
111459112298
int cmp;
111460112299
CollSeq *pColl = sqlite3GetFuncCollSeq(context);
@@ -111476,20 +112315,30 @@
111476112315
}else{
111477112316
pBest->db = sqlite3_context_db_handle(context);
111478112317
sqlite3VdbeMemCopy(pBest, pArg);
111479112318
}
111480112319
}
111481
-static void minMaxFinalize(sqlite3_context *context){
112320
+static void minMaxValueFinalize(sqlite3_context *context, int bValue){
111482112321
sqlite3_value *pRes;
111483112322
pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);
111484112323
if( pRes ){
111485112324
if( pRes->flags ){
111486112325
sqlite3_result_value(context, pRes);
111487112326
}
111488
- sqlite3VdbeMemRelease(pRes);
112327
+ if( bValue==0 ) sqlite3VdbeMemRelease(pRes);
111489112328
}
111490112329
}
112330
+#ifndef SQLITE_OMIT_WINDOWFUNC
112331
+static void minMaxValue(sqlite3_context *context){
112332
+ minMaxValueFinalize(context, 1);
112333
+}
112334
+#else
112335
+# define minMaxValue 0
112336
+#endif /* SQLITE_OMIT_WINDOWFUNC */
112337
+static void minMaxFinalize(sqlite3_context *context){
112338
+ minMaxValueFinalize(context, 0);
112339
+}
111491112340
111492112341
/*
111493112342
** group_concat(EXPR, ?SEPARATOR?)
111494112343
*/
111495112344
static void groupConcatStep(
@@ -111522,10 +112371,42 @@
111522112371
zVal = (char*)sqlite3_value_text(argv[0]);
111523112372
nVal = sqlite3_value_bytes(argv[0]);
111524112373
if( zVal ) sqlite3_str_append(pAccum, zVal, nVal);
111525112374
}
111526112375
}
112376
+#ifndef SQLITE_OMIT_WINDOWFUNC
112377
+static void groupConcatInverse(
112378
+ sqlite3_context *context,
112379
+ int argc,
112380
+ sqlite3_value **argv
112381
+){
112382
+ int n;
112383
+ StrAccum *pAccum;
112384
+ assert( argc==1 || argc==2 );
112385
+ if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
112386
+ pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
112387
+ /* pAccum is always non-NULL since groupConcatStep() will have always
112388
+ ** run frist to initialize it */
112389
+ if( ALWAYS(pAccum) ){
112390
+ n = sqlite3_value_bytes(argv[0]);
112391
+ if( argc==2 ){
112392
+ n += sqlite3_value_bytes(argv[1]);
112393
+ }else{
112394
+ n++;
112395
+ }
112396
+ if( n>=(int)pAccum->nChar ){
112397
+ pAccum->nChar = 0;
112398
+ }else{
112399
+ pAccum->nChar -= n;
112400
+ memmove(pAccum->zText, &pAccum->zText[n], pAccum->nChar);
112401
+ }
112402
+ if( pAccum->nChar==0 ) pAccum->mxAlloc = 0;
112403
+ }
112404
+}
112405
+#else
112406
+# define groupConcatInverse 0
112407
+#endif /* SQLITE_OMIT_WINDOWFUNC */
111527112408
static void groupConcatFinalize(sqlite3_context *context){
111528112409
StrAccum *pAccum;
111529112410
pAccum = sqlite3_aggregate_context(context, 0);
111530112411
if( pAccum ){
111531112412
if( pAccum->accError==SQLITE_TOOBIG ){
@@ -111536,10 +112417,28 @@
111536112417
sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1,
111537112418
sqlite3_free);
111538112419
}
111539112420
}
111540112421
}
112422
+#ifndef SQLITE_OMIT_WINDOWFUNC
112423
+static void groupConcatValue(sqlite3_context *context){
112424
+ sqlite3_str *pAccum;
112425
+ pAccum = (sqlite3_str*)sqlite3_aggregate_context(context, 0);
112426
+ if( pAccum ){
112427
+ if( pAccum->accError==SQLITE_TOOBIG ){
112428
+ sqlite3_result_error_toobig(context);
112429
+ }else if( pAccum->accError==SQLITE_NOMEM ){
112430
+ sqlite3_result_error_nomem(context);
112431
+ }else{
112432
+ const char *zText = sqlite3_str_value(pAccum);
112433
+ sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT);
112434
+ }
112435
+ }
112436
+}
112437
+#else
112438
+# define groupConcatValue 0
112439
+#endif /* SQLITE_OMIT_WINDOWFUNC */
111541112440
111542112441
/*
111543112442
** This routine does per-connection function registration. Most
111544112443
** of the built-in functions above are part of the global function set.
111545112444
** This routine only deals with those that are not global.
@@ -111573,14 +112472,14 @@
111573112472
if( caseSensitive ){
111574112473
pInfo = (struct compareInfo*)&likeInfoAlt;
111575112474
}else{
111576112475
pInfo = (struct compareInfo*)&likeInfoNorm;
111577112476
}
111578
- sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);
111579
- sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);
112477
+ sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0, 0, 0);
112478
+ sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0, 0, 0);
111580112479
sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8,
111581
- (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0);
112480
+ (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0, 0, 0);
111582112481
setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);
111583112482
setLikeOptFlag(db, "like",
111584112483
caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);
111585112484
}
111586112485
@@ -111685,15 +112584,15 @@
111685112584
FUNCTION(rtrim, 2, 2, 0, trimFunc ),
111686112585
FUNCTION(trim, 1, 3, 0, trimFunc ),
111687112586
FUNCTION(trim, 2, 3, 0, trimFunc ),
111688112587
FUNCTION(min, -1, 0, 1, minmaxFunc ),
111689112588
FUNCTION(min, 0, 0, 1, 0 ),
111690
- AGGREGATE2(min, 1, 0, 1, minmaxStep, minMaxFinalize,
112589
+ WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
111691112590
SQLITE_FUNC_MINMAX ),
111692112591
FUNCTION(max, -1, 1, 1, minmaxFunc ),
111693112592
FUNCTION(max, 0, 1, 1, 0 ),
111694
- AGGREGATE2(max, 1, 1, 1, minmaxStep, minMaxFinalize,
112593
+ WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
111695112594
SQLITE_FUNC_MINMAX ),
111696112595
FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
111697112596
FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
111698112597
FUNCTION(instr, 2, 0, 0, instrFunc ),
111699112598
FUNCTION(printf, -1, 0, 0, printfFunc ),
@@ -111720,18 +112619,21 @@
111720112619
VFUNCTION(total_changes, 0, 0, 0, total_changes ),
111721112620
FUNCTION(replace, 3, 0, 0, replaceFunc ),
111722112621
FUNCTION(zeroblob, 1, 0, 0, zeroblobFunc ),
111723112622
FUNCTION(substr, 2, 0, 0, substrFunc ),
111724112623
FUNCTION(substr, 3, 0, 0, substrFunc ),
111725
- AGGREGATE(sum, 1, 0, 0, sumStep, sumFinalize ),
111726
- AGGREGATE(total, 1, 0, 0, sumStep, totalFinalize ),
111727
- AGGREGATE(avg, 1, 0, 0, sumStep, avgFinalize ),
111728
- AGGREGATE2(count, 0, 0, 0, countStep, countFinalize,
111729
- SQLITE_FUNC_COUNT ),
111730
- AGGREGATE(count, 1, 0, 0, countStep, countFinalize ),
111731
- AGGREGATE(group_concat, 1, 0, 0, groupConcatStep, groupConcatFinalize),
111732
- AGGREGATE(group_concat, 2, 0, 0, groupConcatStep, groupConcatFinalize),
112624
+ WAGGREGATE(sum, 1,0,0, sumStep, sumFinalize, sumFinalize, sumInverse, 0),
112625
+ WAGGREGATE(total, 1,0,0, sumStep,totalFinalize,totalFinalize,sumInverse, 0),
112626
+ WAGGREGATE(avg, 1,0,0, sumStep, avgFinalize, avgFinalize, sumInverse, 0),
112627
+ WAGGREGATE(count, 0,0,0, countStep,
112628
+ countFinalize, countFinalize, countInverse, SQLITE_FUNC_COUNT ),
112629
+ WAGGREGATE(count, 1,0,0, countStep,
112630
+ countFinalize, countFinalize, countInverse, 0 ),
112631
+ WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep,
112632
+ groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
112633
+ WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep,
112634
+ groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
111733112635
111734112636
LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
111735112637
#ifdef SQLITE_CASE_SENSITIVE_LIKE
111736112638
LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
111737112639
LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
@@ -111747,10 +112649,11 @@
111747112649
FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQLITE_FUNC_COALESCE),
111748112650
};
111749112651
#ifndef SQLITE_OMIT_ALTERTABLE
111750112652
sqlite3AlterFunctions();
111751112653
#endif
112654
+ sqlite3WindowFunctions();
111752112655
#if defined(SQLITE_ENABLE_STAT3) || defined(SQLITE_ENABLE_STAT4)
111753112656
sqlite3AnalyzeFunctions();
111754112657
#endif
111755112658
sqlite3RegisterDateTimeFunctions();
111756112659
sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));
@@ -114738,10 +115641,11 @@
114738115641
** the following conflict logic if it does not. */
114739115642
VdbeNoopComment((v, "uniqueness check for ROWID"));
114740115643
sqlite3VdbeVerifyAbortable(v, onError);
114741115644
sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);
114742115645
VdbeCoverage(v);
115646
+ sqlite3ExprCachePush(pParse);
114743115647
114744115648
switch( onError ){
114745115649
default: {
114746115650
onError = OE_Abort;
114747115651
/* Fall thru into the next case */
@@ -114814,10 +115718,11 @@
114814115718
testcase( onError==OE_Ignore );
114815115719
sqlite3VdbeGoto(v, ignoreDest);
114816115720
break;
114817115721
}
114818115722
}
115723
+ sqlite3ExprCachePop(pParse);
114819115724
sqlite3VdbeResolveLabel(v, addrRowidOk);
114820115725
if( sAddr.ipkTop ){
114821115726
sAddr.ipkBtm = sqlite3VdbeAddOp0(v, OP_Goto);
114822115727
sqlite3VdbeJumpHere(v, sAddr.ipkTop-1);
114823115728
}
@@ -114835,23 +115740,23 @@
114835115740
int regR; /* Range of registers holding conflicting PK */
114836115741
int iThisCur; /* Cursor for this UNIQUE index */
114837115742
int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */
114838115743
114839115744
if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */
115745
+ if( bAffinityDone==0 ){
115746
+ sqlite3TableAffinity(v, pTab, regNewData+1);
115747
+ bAffinityDone = 1;
115748
+ }
114840115749
if( pUpIdx==pIdx ){
114841115750
addrUniqueOk = sAddr.upsertBtm;
114842115751
upsertBypass = sqlite3VdbeGoto(v, 0);
114843115752
VdbeComment((v, "Skip upsert subroutine"));
114844115753
sqlite3VdbeResolveLabel(v, sAddr.upsertTop2);
114845115754
}else{
114846115755
addrUniqueOk = sqlite3VdbeMakeLabel(v);
114847115756
}
114848115757
VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName));
114849
- if( bAffinityDone==0 ){
114850
- sqlite3TableAffinity(v, pTab, regNewData+1);
114851
- bAffinityDone = 1;
114852
- }
114853115758
iThisCur = iIdxCur+ix;
114854115759
114855115760
114856115761
/* Skip partial indices for which the WHERE clause is not true */
114857115762
if( pIdx->pPartIdxWhere ){
@@ -119458,10 +120363,15 @@
119458120363
}
119459120364
assert( pParse->nMem>=8+j );
119460120365
assert( sqlite3NoTempsInRange(pParse,1,7+j) );
119461120366
sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
119462120367
loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
120368
+ if( !isQuick ){
120369
+ /* Sanity check on record header decoding */
120370
+ sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3);
120371
+ sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
120372
+ }
119463120373
/* Verify that all NOT NULL columns really are NOT NULL */
119464120374
for(j=0; j<pTab->nCol; j++){
119465120375
char *zErr;
119466120376
int jmp2;
119467120377
if( j==pTab->iPKey ) continue;
@@ -119500,13 +120410,10 @@
119500120410
sqlite3ExprCachePop(pParse);
119501120411
}
119502120412
sqlite3ExprListDelete(db, pCheck);
119503120413
}
119504120414
if( !isQuick ){ /* Omit the remaining tests for quick_check */
119505
- /* Sanity check on record header decoding */
119506
- sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3);
119507
- sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
119508120415
/* Validate index entries for the current row */
119509120416
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
119510120417
int jmp2, jmp3, jmp4, jmp5;
119511120418
int ckUniq = sqlite3VdbeMakeLabel(v);
119512120419
if( pPk==pIdx ) continue;
@@ -120573,11 +121480,11 @@
120573121480
/* If there is not already a read-only (or read-write) transaction opened
120574121481
** on the b-tree database, open one now. If a transaction is opened, it
120575121482
** will be closed before this function returns. */
120576121483
sqlite3BtreeEnter(pDb->pBt);
120577121484
if( !sqlite3BtreeIsInReadTrans(pDb->pBt) ){
120578
- rc = sqlite3BtreeBeginTrans(pDb->pBt, 0);
121485
+ rc = sqlite3BtreeBeginTrans(pDb->pBt, 0, 0);
120579121486
if( rc!=SQLITE_OK ){
120580121487
sqlite3SetString(pzErrMsg, db, sqlite3ErrStr(rc));
120581121488
goto initone_error_out;
120582121489
}
120583121490
openedTransaction = 1;
@@ -120818,11 +121725,11 @@
120818121725
120819121726
/* If there is not already a read-only (or read-write) transaction opened
120820121727
** on the b-tree database, open one now. If a transaction is opened, it
120821121728
** will be closed immediately after reading the meta-value. */
120822121729
if( !sqlite3BtreeIsInReadTrans(pBt) ){
120823
- rc = sqlite3BtreeBeginTrans(pBt, 0);
121730
+ rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
120824121731
if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){
120825121732
sqlite3OomFault(db);
120826121733
}
120827121734
if( rc!=SQLITE_OK ) return;
120828121735
openedTransaction = 1;
@@ -121315,11 +122222,11 @@
121315122222
*/
121316122223
#if SELECTTRACE_ENABLED
121317122224
/***/ int sqlite3SelectTrace = 0;
121318122225
# define SELECTTRACE(K,P,S,X) \
121319122226
if(sqlite3SelectTrace&(K)) \
121320
- sqlite3DebugPrintf("%s/%d/%p: ",(S)->zSelName,(P)->addrExplain,(S)),\
122227
+ sqlite3DebugPrintf("%u/%d/%p: ",(S)->selId,(P)->addrExplain,(S)),\
121321122228
sqlite3DebugPrintf X
121322122229
#else
121323122230
# define SELECTTRACE(K,P,S,X)
121324122231
#endif
121325122232
@@ -121390,10 +122297,15 @@
121390122297
sqlite3ExprDelete(db, p->pWhere);
121391122298
sqlite3ExprListDelete(db, p->pGroupBy);
121392122299
sqlite3ExprDelete(db, p->pHaving);
121393122300
sqlite3ExprListDelete(db, p->pOrderBy);
121394122301
sqlite3ExprDelete(db, p->pLimit);
122302
+#ifndef SQLITE_OMIT_WINDOWFUNC
122303
+ if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){
122304
+ sqlite3WindowListDelete(db, p->pWinDefn);
122305
+ }
122306
+#endif
121395122307
if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);
121396122308
if( bFree ) sqlite3DbFreeNN(db, p);
121397122309
p = pPrior;
121398122310
bFree = 1;
121399122311
}
@@ -121440,13 +122352,11 @@
121440122352
pNew->pEList = pEList;
121441122353
pNew->op = TK_SELECT;
121442122354
pNew->selFlags = selFlags;
121443122355
pNew->iLimit = 0;
121444122356
pNew->iOffset = 0;
121445
-#if SELECTTRACE_ENABLED
121446
- pNew->zSelName[0] = 0;
121447
-#endif
122357
+ pNew->selId = ++pParse->nSelect;
121448122358
pNew->addrOpenEphm[0] = -1;
121449122359
pNew->addrOpenEphm[1] = -1;
121450122360
pNew->nSelectRow = 0;
121451122361
if( pSrc==0 ) pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*pSrc));
121452122362
pNew->pSrc = pSrc;
@@ -121456,10 +122366,14 @@
121456122366
pNew->pOrderBy = pOrderBy;
121457122367
pNew->pPrior = 0;
121458122368
pNew->pNext = 0;
121459122369
pNew->pLimit = pLimit;
121460122370
pNew->pWith = 0;
122371
+#ifndef SQLITE_OMIT_WINDOWFUNC
122372
+ pNew->pWin = 0;
122373
+ pNew->pWinDefn = 0;
122374
+#endif
121461122375
if( pParse->db->mallocFailed ) {
121462122376
clearSelect(pParse->db, pNew, pNew!=&standin);
121463122377
pNew = 0;
121464122378
}else{
121465122379
assert( pNew->pSrc!=0 || pParse->nErr>0 );
@@ -121466,21 +122380,10 @@
121466122380
}
121467122381
assert( pNew!=&standin );
121468122382
return pNew;
121469122383
}
121470122384
121471
-#if SELECTTRACE_ENABLED
121472
-/*
121473
-** Set the name of a Select object
121474
-*/
121475
-SQLITE_PRIVATE void sqlite3SelectSetName(Select *p, const char *zName){
121476
- if( p && zName ){
121477
- sqlite3_snprintf(sizeof(p->zSelName), p->zSelName, "%s", zName);
121478
- }
121479
-}
121480
-#endif
121481
-
121482122385
121483122386
/*
121484122387
** Delete the given Select structure and all of its substructures.
121485122388
*/
121486122389
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){
@@ -121823,18 +122726,10 @@
121823122726
}
121824122727
}
121825122728
return 0;
121826122729
}
121827122730
121828
-/* Forward reference */
121829
-static KeyInfo *keyInfoFromExprList(
121830
- Parse *pParse, /* Parsing context */
121831
- ExprList *pList, /* Form the KeyInfo object from this ExprList */
121832
- int iStart, /* Begin with this column of pList */
121833
- int nExtra /* Add this many extra columns to the end */
121834
-);
121835
-
121836122731
/*
121837122732
** An instance of this object holds information (beyond pParse and pSelect)
121838122733
** needed to load the next result row that is to be added to the sorter.
121839122734
*/
121840122735
typedef struct RowLoadInfo RowLoadInfo;
@@ -121972,11 +122867,11 @@
121972122867
pOp->p2 = nKey + nData;
121973122868
pKI = pOp->p4.pKeyInfo;
121974122869
memset(pKI->aSortOrder, 0, pKI->nKeyField); /* Makes OP_Jump testable */
121975122870
sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
121976122871
testcase( pKI->nAllField > pKI->nKeyField+2 );
121977
- pOp->p4.pKeyInfo = keyInfoFromExprList(pParse, pSort->pOrderBy, nOBSat,
122872
+ pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat,
121978122873
pKI->nAllField-pKI->nKeyField-1);
121979122874
addrJmp = sqlite3VdbeCurrentAddr(v);
121980122875
sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
121981122876
pSort->labelBkOut = sqlite3VdbeMakeLabel(v);
121982122877
pSort->regReturn = ++pParse->nMem;
@@ -122642,11 +123537,11 @@
122642123537
**
122643123538
** Space to hold the KeyInfo structure is obtained from malloc. The calling
122644123539
** function is responsible for seeing that this structure is eventually
122645123540
** freed.
122646123541
*/
122647
-static KeyInfo *keyInfoFromExprList(
123542
+SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList(
122648123543
Parse *pParse, /* Parsing context */
122649123544
ExprList *pList, /* Form the KeyInfo object from this ExprList */
122650123545
int iStart, /* Begin with this column of pList */
122651123546
int nExtra /* Add this many extra columns to the end */
122652123547
){
@@ -124970,10 +125865,14 @@
124970125865
** The subquery may not be an aggregate that uses the built-in min() or
124971125866
** or max() functions. (Without this restriction, a query like:
124972125867
** "SELECT x FROM (SELECT max(y), x FROM t1)" would not necessarily
124973125868
** return the value X for which Y was maximal.)
124974125869
**
125870
+** (25) If either the subquery or the parent query contains a window
125871
+** function in the select list or ORDER BY clause, flattening
125872
+** is not attempted.
125873
+**
124975125874
**
124976125875
** In this routine, the "p" parameter is a pointer to the outer query.
124977125876
** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query
124978125877
** uses aggregates.
124979125878
**
@@ -125012,10 +125911,14 @@
125012125911
assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );
125013125912
pSubitem = &pSrc->a[iFrom];
125014125913
iParent = pSubitem->iCursor;
125015125914
pSub = pSubitem->pSelect;
125016125915
assert( pSub!=0 );
125916
+
125917
+#ifndef SQLITE_OMIT_WINDOWFUNC
125918
+ if( p->pWin || pSub->pWin ) return 0; /* Restriction (25) */
125919
+#endif
125017125920
125018125921
pSubSrc = pSub->pSrc;
125019125922
assert( pSubSrc );
125020125923
/* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,
125021125924
** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET
@@ -125123,12 +126026,12 @@
125123126026
** restriction (17d3)
125124126027
*/
125125126028
assert( (p->selFlags & SF_Recursive)==0 || pSub->pPrior==0 );
125126126029
125127126030
/***** If we reach this point, flattening is permitted. *****/
125128
- SELECTTRACE(1,pParse,p,("flatten %s.%p from term %d\n",
125129
- pSub->zSelName, pSub, iFrom));
126031
+ SELECTTRACE(1,pParse,p,("flatten %u.%p from term %d\n",
126032
+ pSub->selId, pSub, iFrom));
125130126033
125131126034
/* Authorize the subquery */
125132126035
pParse->zAuthContext = pSubitem->zName;
125133126036
TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);
125134126037
testcase( i==SQLITE_DENY );
@@ -125175,11 +126078,10 @@
125175126078
p->pOrderBy = 0;
125176126079
p->pSrc = 0;
125177126080
p->pPrior = 0;
125178126081
p->pLimit = 0;
125179126082
pNew = sqlite3SelectDup(db, p, 0);
125180
- sqlite3SelectSetName(pNew, pSub->zSelName);
125181126083
p->pLimit = pLimit;
125182126084
p->pOrderBy = pOrderBy;
125183126085
p->pSrc = pSrc;
125184126086
p->op = TK_ALL;
125185126087
if( pNew==0 ){
@@ -125188,11 +126090,11 @@
125188126090
pNew->pPrior = pPrior;
125189126091
if( pPrior ) pPrior->pNext = pNew;
125190126092
pNew->pNext = p;
125191126093
p->pPrior = pNew;
125192126094
SELECTTRACE(2,pParse,p,("compound-subquery flattener"
125193
- " creates %s.%p as peer\n",pNew->zSelName, pNew));
126095
+ " creates %u as peer\n",pNew->selId));
125194126096
}
125195126097
if( db->mallocFailed ) return 1;
125196126098
}
125197126099
125198126100
/* Begin flattening the iFrom-th entry of the FROM clause
@@ -125403,11 +126305,11 @@
125403126305
** to suppress it. **)
125404126306
**
125405126307
** (2) The inner query is the recursive part of a common table expression.
125406126308
**
125407126309
** (3) The inner query has a LIMIT clause (since the changes to the WHERE
125408
-** close would change the meaning of the LIMIT).
126310
+** clause would change the meaning of the LIMIT).
125409126311
**
125410126312
** (4) The inner query is the right operand of a LEFT JOIN and the
125411126313
** expression to be pushed down does not come from the ON clause
125412126314
** on that LEFT JOIN.
125413126315
**
@@ -125421,10 +126323,14 @@
125421126323
** LEFT JOIN (SELECT 8 AS c3 UNION ALL SELECT 9) AS cc ON (b2=2);
125422126324
**
125423126325
** The correct answer is three rows: (1,1,NULL),(2,2,8),(2,2,9).
125424126326
** But if the (b2=2) term were to be pushed down into the bb subquery,
125425126327
** then the (1,1,NULL) row would be suppressed.
126328
+**
126329
+** (6) The inner query features one or more window-functions (since
126330
+** changes to the WHERE clause of the inner query could change the
126331
+** window over which window functions are calculated).
125426126332
**
125427126333
** Return 0 if no changes are made and non-zero if one or more WHERE clause
125428126334
** terms are duplicated into the subquery.
125429126335
*/
125430126336
static int pushDownWhereTerms(
@@ -125436,10 +126342,14 @@
125436126342
){
125437126343
Expr *pNew;
125438126344
int nChng = 0;
125439126345
if( pWhere==0 ) return 0;
125440126346
if( pSubq->selFlags & SF_Recursive ) return 0; /* restriction (2) */
126347
+
126348
+#ifndef SQLITE_OMIT_WINDOWFUNC
126349
+ if( pSubq->pWin ) return 0; /* restriction (6) */
126350
+#endif
125441126351
125442126352
#ifdef SQLITE_DEBUG
125443126353
/* Only the first term of a compound can have a WITH clause. But make
125444126354
** sure no other terms are marked SF_Recursive in case something changes
125445126355
** in the future.
@@ -125881,10 +126791,39 @@
125881126791
}
125882126792
}
125883126793
#else
125884126794
#define selectPopWith 0
125885126795
#endif
126796
+
126797
+/*
126798
+** The SrcList_item structure passed as the second argument represents a
126799
+** sub-query in the FROM clause of a SELECT statement. This function
126800
+** allocates and populates the SrcList_item.pTab object. If successful,
126801
+** SQLITE_OK is returned. Otherwise, if an OOM error is encountered,
126802
+** SQLITE_NOMEM.
126803
+*/
126804
+SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse *pParse, struct SrcList_item *pFrom){
126805
+ Select *pSel = pFrom->pSelect;
126806
+ Table *pTab;
126807
+
126808
+ assert( pSel );
126809
+ pFrom->pTab = pTab = sqlite3DbMallocZero(pParse->db, sizeof(Table));
126810
+ if( pTab==0 ) return SQLITE_NOMEM;
126811
+ pTab->nTabRef = 1;
126812
+ if( pFrom->zAlias ){
126813
+ pTab->zName = sqlite3DbStrDup(pParse->db, pFrom->zAlias);
126814
+ }else{
126815
+ pTab->zName = sqlite3MPrintf(pParse->db, "subquery_%u", pSel->selId);
126816
+ }
126817
+ while( pSel->pPrior ){ pSel = pSel->pPrior; }
126818
+ sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);
126819
+ pTab->iPKey = -1;
126820
+ pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
126821
+ pTab->tabFlags |= TF_Ephemeral;
126822
+
126823
+ return SQLITE_OK;
126824
+}
125886126825
125887126826
/*
125888126827
** This routine is a Walker callback for "expanding" a SELECT statement.
125889126828
** "Expanding" means to do the following:
125890126829
**
@@ -125954,23 +126893,11 @@
125954126893
Select *pSel = pFrom->pSelect;
125955126894
/* A sub-query in the FROM clause of a SELECT */
125956126895
assert( pSel!=0 );
125957126896
assert( pFrom->pTab==0 );
125958126897
if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;
125959
- pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
125960
- if( pTab==0 ) return WRC_Abort;
125961
- pTab->nTabRef = 1;
125962
- if( pFrom->zAlias ){
125963
- pTab->zName = sqlite3DbStrDup(db, pFrom->zAlias);
125964
- }else{
125965
- pTab->zName = sqlite3MPrintf(db, "subquery_%p", (void*)pTab);
125966
- }
125967
- while( pSel->pPrior ){ pSel = pSel->pPrior; }
125968
- sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);
125969
- pTab->iPKey = -1;
125970
- pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
125971
- pTab->tabFlags |= TF_Ephemeral;
126898
+ if( sqlite3ExpandSubquery(pParse, pFrom) ) return WRC_Abort;
125972126899
#endif
125973126900
}else{
125974126901
/* An ordinary table or view name in the FROM clause */
125975126902
assert( pFrom->pTab==0 );
125976126903
pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom);
@@ -125989,11 +126916,10 @@
125989126916
if( IsVirtual(pTab) || pTab->pSelect ){
125990126917
i16 nCol;
125991126918
if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;
125992126919
assert( pFrom->pSelect==0 );
125993126920
pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);
125994
- sqlite3SelectSetName(pFrom->pSelect, pTab->zName);
125995126921
nCol = pTab->nCol;
125996126922
pTab->nCol = -1;
125997126923
sqlite3WalkSelect(pWalker, pFrom->pSelect);
125998126924
pTab->nCol = nCol;
125999126925
}
@@ -126267,11 +127193,11 @@
126267127193
int i;
126268127194
SrcList *pTabList;
126269127195
struct SrcList_item *pFrom;
126270127196
126271127197
assert( p->selFlags & SF_Resolved );
126272
- assert( (p->selFlags & SF_HasTypeInfo)==0 );
127198
+ if( p->selFlags & SF_HasTypeInfo ) return;
126273127199
p->selFlags |= SF_HasTypeInfo;
126274127200
pParse = pWalker->pParse;
126275127201
pTabList = p->pSrc;
126276127202
for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
126277127203
Table *pTab = pFrom->pTab;
@@ -126370,11 +127296,11 @@
126370127296
if( pE->x.pList==0 || pE->x.pList->nExpr!=1 ){
126371127297
sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one "
126372127298
"argument");
126373127299
pFunc->iDistinct = -1;
126374127300
}else{
126375
- KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pE->x.pList, 0, 0);
127301
+ KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pE->x.pList,0,0);
126376127302
sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc->iDistinct, 0, 0,
126377127303
(char*)pKeyInfo, P4_KEYINFO);
126378127304
}
126379127305
}
126380127306
}
@@ -126393,16 +127319,22 @@
126393127319
assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
126394127320
sqlite3VdbeAddOp2(v, OP_AggFinal, pF->iMem, pList ? pList->nExpr : 0);
126395127321
sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
126396127322
}
126397127323
}
127324
+
126398127325
126399127326
/*
126400127327
** Update the accumulator memory cells for an aggregate based on
126401127328
** the current cursor position.
127329
+**
127330
+** If regAcc is non-zero and there are no min() or max() aggregates
127331
+** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator
127332
+** registers i register regAcc contains 0. The caller will take care
127333
+** of setting and clearing regAcc.
126402127334
*/
126403
-static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
127335
+static void updateAccumulator(Parse *pParse, int regAcc, AggInfo *pAggInfo){
126404127336
Vdbe *v = pParse->pVdbe;
126405127337
int i;
126406127338
int regHit = 0;
126407127339
int addrHitTest = 0;
126408127340
struct AggInfo_func *pF;
@@ -126441,11 +127373,11 @@
126441127373
pColl = pParse->db->pDfltColl;
126442127374
}
126443127375
if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem;
126444127376
sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ);
126445127377
}
126446
- sqlite3VdbeAddOp3(v, OP_AggStep0, 0, regAgg, pF->iMem);
127378
+ sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, pF->iMem);
126447127379
sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
126448127380
sqlite3VdbeChangeP5(v, (u8)nArg);
126449127381
sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);
126450127382
sqlite3ReleaseTempRange(pParse, regAgg, nArg);
126451127383
if( addrNext ){
@@ -126462,10 +127394,13 @@
126462127394
** text or blob value. See ticket [883034dcb5].
126463127395
**
126464127396
** Another solution would be to change the OP_SCopy used to copy cached
126465127397
** values to an OP_Copy.
126466127398
*/
127399
+ if( regHit==0 && pAggInfo->nAccumulator ){
127400
+ regHit = regAcc;
127401
+ }
126467127402
if( regHit ){
126468127403
addrHitTest = sqlite3VdbeAddOp1(v, OP_If, regHit); VdbeCoverage(v);
126469127404
}
126470127405
sqlite3ExprCacheClear(pParse);
126471127406
for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){
@@ -126735,18 +127670,14 @@
126735127670
sqlite3ExprListDelete(db, p->pOrderBy);
126736127671
p->pOrderBy = 0;
126737127672
p->selFlags &= ~SF_Distinct;
126738127673
}
126739127674
sqlite3SelectPrep(pParse, p, 0);
126740
- memset(&sSort, 0, sizeof(sSort));
126741
- sSort.pOrderBy = p->pOrderBy;
126742
- pTabList = p->pSrc;
126743127675
if( pParse->nErr || db->mallocFailed ){
126744127676
goto select_end;
126745127677
}
126746127678
assert( p->pEList!=0 );
126747
- isAgg = (p->selFlags & SF_Aggregate)!=0;
126748127679
#if SELECTTRACE_ENABLED
126749127680
if( sqlite3SelectTrace & 0x104 ){
126750127681
SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
126751127682
sqlite3TreeViewSelect(0, p, 0);
126752127683
}
@@ -126754,10 +127685,26 @@
126754127685
126755127686
if( pDest->eDest==SRT_Output ){
126756127687
generateColumnNames(pParse, p);
126757127688
}
126758127689
127690
+#ifndef SQLITE_OMIT_WINDOWFUNC
127691
+ if( sqlite3WindowRewrite(pParse, p) ){
127692
+ goto select_end;
127693
+ }
127694
+#if SELECTTRACE_ENABLED
127695
+ if( sqlite3SelectTrace & 0x108 ){
127696
+ SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n"));
127697
+ sqlite3TreeViewSelect(0, p, 0);
127698
+ }
127699
+#endif
127700
+#endif /* SQLITE_OMIT_WINDOWFUNC */
127701
+ pTabList = p->pSrc;
127702
+ isAgg = (p->selFlags & SF_Aggregate)!=0;
127703
+ memset(&sSort, 0, sizeof(sSort));
127704
+ sSort.pOrderBy = p->pOrderBy;
127705
+
126759127706
/* Try to various optimizations (flattening subqueries, and strength
126760127707
** reduction of join operators) in the FROM clause up into the main query
126761127708
*/
126762127709
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
126763127710
for(i=0; !p->pPrior && i<pTabList->nSrc; i++){
@@ -126960,11 +127907,11 @@
126960127907
pItem->regReturn = ++pParse->nMem;
126961127908
sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->regReturn, 0, addrTop);
126962127909
VdbeComment((v, "%s", pItem->pTab->zName));
126963127910
pItem->addrFillSub = addrTop;
126964127911
sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn);
126965
- ExplainQueryPlan((pParse, 1, "CO-ROUTINE 0x%p", pSub));
127912
+ ExplainQueryPlan((pParse, 1, "CO-ROUTINE %u", pSub->selId));
126966127913
sqlite3Select(pParse, pSub, &dest);
126967127914
pItem->pTab->nRowLogEst = pSub->nSelectRow;
126968127915
pItem->fg.viaCoroutine = 1;
126969127916
pItem->regResult = dest.iSdst;
126970127917
sqlite3VdbeEndCoroutine(v, pItem->regReturn);
@@ -126999,11 +127946,11 @@
126999127946
sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
127000127947
assert( pPrior->pSelect!=0 );
127001127948
pSub->nSelectRow = pPrior->pSelect->nSelectRow;
127002127949
}else{
127003127950
sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
127004
- ExplainQueryPlan((pParse, 1, "MATERIALIZE 0x%p", pSub));
127951
+ ExplainQueryPlan((pParse, 1, "MATERIALIZE %u", pSub->selId));
127005127952
sqlite3Select(pParse, pSub, &dest);
127006127953
}
127007127954
pItem->pTab->nRowLogEst = pSub->nSelectRow;
127008127955
if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);
127009127956
retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);
@@ -127083,11 +128030,12 @@
127083128030
** not needed. The sSort.addrSortIndex variable is used to facilitate
127084128031
** that change.
127085128032
*/
127086128033
if( sSort.pOrderBy ){
127087128034
KeyInfo *pKeyInfo;
127088
- pKeyInfo = keyInfoFromExprList(pParse, sSort.pOrderBy, 0, pEList->nExpr);
128035
+ pKeyInfo = sqlite3KeyInfoFromExprList(
128036
+ pParse, sSort.pOrderBy, 0, pEList->nExpr);
127089128037
sSort.iECursor = pParse->nTab++;
127090128038
sSort.addrSortIndex =
127091128039
sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
127092128040
sSort.iECursor, sSort.pOrderBy->nExpr+1+pEList->nExpr, 0,
127093128041
(char*)pKeyInfo, P4_KEYINFO
@@ -127117,24 +128065,31 @@
127117128065
/* Open an ephemeral index to use for the distinct set.
127118128066
*/
127119128067
if( p->selFlags & SF_Distinct ){
127120128068
sDistinct.tabTnct = pParse->nTab++;
127121128069
sDistinct.addrTnct = sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
127122
- sDistinct.tabTnct, 0, 0,
127123
- (char*)keyInfoFromExprList(pParse, p->pEList,0,0),
127124
- P4_KEYINFO);
128070
+ sDistinct.tabTnct, 0, 0,
128071
+ (char*)sqlite3KeyInfoFromExprList(pParse, p->pEList,0,0),
128072
+ P4_KEYINFO);
127125128073
sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
127126128074
sDistinct.eTnctType = WHERE_DISTINCT_UNORDERED;
127127128075
}else{
127128128076
sDistinct.eTnctType = WHERE_DISTINCT_NOOP;
127129128077
}
127130128078
127131128079
if( !isAgg && pGroupBy==0 ){
127132128080
/* No aggregate functions and no GROUP BY clause */
127133
- u16 wctrlFlags = (sDistinct.isTnct ? WHERE_WANT_DISTINCT : 0);
128081
+ u16 wctrlFlags = (sDistinct.isTnct ? WHERE_WANT_DISTINCT : 0)
128082
+ | (p->selFlags & SF_FixedLimit);
128083
+#ifndef SQLITE_OMIT_WINDOWFUNC
128084
+ Window *pWin = p->pWin; /* Master window object (or NULL) */
128085
+ if( pWin ){
128086
+ sqlite3WindowCodeInit(pParse, pWin);
128087
+ }
128088
+#endif
127134128089
assert( WHERE_USE_LIMIT==SF_FixedLimit );
127135
- wctrlFlags |= p->selFlags & SF_FixedLimit;
128090
+
127136128091
127137128092
/* Begin the database scan. */
127138128093
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
127139128094
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, sSort.pOrderBy,
127140128095
p->pEList, wctrlFlags, p->nSelectRow);
@@ -127159,19 +128114,40 @@
127159128114
*/
127160128115
if( sSort.addrSortIndex>=0 && sSort.pOrderBy==0 ){
127161128116
sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex);
127162128117
}
127163128118
127164
- /* Use the standard inner loop. */
127165128119
assert( p->pEList==pEList );
127166
- selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest,
127167
- sqlite3WhereContinueLabel(pWInfo),
127168
- sqlite3WhereBreakLabel(pWInfo));
128120
+#ifndef SQLITE_OMIT_WINDOWFUNC
128121
+ if( pWin ){
128122
+ int addrGosub = sqlite3VdbeMakeLabel(v);
128123
+ int iCont = sqlite3VdbeMakeLabel(v);
128124
+ int iBreak = sqlite3VdbeMakeLabel(v);
128125
+ int regGosub = ++pParse->nMem;
127169128126
127170
- /* End the database scan loop.
127171
- */
127172
- sqlite3WhereEnd(pWInfo);
128127
+ sqlite3WindowCodeStep(pParse, p, pWInfo, regGosub, addrGosub);
128128
+
128129
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak);
128130
+ sqlite3VdbeResolveLabel(v, addrGosub);
128131
+ VdbeNoopComment((v, "inner-loop subroutine"));
128132
+ selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest, iCont, iBreak);
128133
+ sqlite3VdbeResolveLabel(v, iCont);
128134
+ sqlite3VdbeAddOp1(v, OP_Return, regGosub);
128135
+ VdbeComment((v, "end inner-loop subroutine"));
128136
+ sqlite3VdbeResolveLabel(v, iBreak);
128137
+ }else
128138
+#endif /* SQLITE_OMIT_WINDOWFUNC */
128139
+ {
128140
+ /* Use the standard inner loop. */
128141
+ selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest,
128142
+ sqlite3WhereContinueLabel(pWInfo),
128143
+ sqlite3WhereBreakLabel(pWInfo));
128144
+
128145
+ /* End the database scan loop.
128146
+ */
128147
+ sqlite3WhereEnd(pWInfo);
128148
+ }
127173128149
}else{
127174128150
/* This case when there exist aggregate functions or a GROUP BY clause
127175128151
** or both */
127176128152
NameContext sNC; /* Name context for processing aggregate information */
127177128153
int iAMem; /* First Mem address for storing current GROUP BY */
@@ -127296,11 +128272,11 @@
127296128272
** implement it. Allocate that sorting index now. If it turns out
127297128273
** that we do not need it after all, the OP_SorterOpen instruction
127298128274
** will be converted into a Noop.
127299128275
*/
127300128276
sAggInfo.sortingIdx = pParse->nTab++;
127301
- pKeyInfo = keyInfoFromExprList(pParse, pGroupBy, 0, sAggInfo.nColumn);
128277
+ pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pGroupBy,0,sAggInfo.nColumn);
127302128278
addrSortingIdx = sqlite3VdbeAddOp4(v, OP_SorterOpen,
127303128279
sAggInfo.sortingIdx, sAggInfo.nSortingColumn,
127304128280
0, (char*)pKeyInfo, P4_KEYINFO);
127305128281
127306128282
/* Initialize memory locations used by GROUP BY aggregate processing
@@ -127315,12 +128291,10 @@
127315128291
pParse->nMem += pGroupBy->nExpr;
127316128292
iBMem = pParse->nMem + 1;
127317128293
pParse->nMem += pGroupBy->nExpr;
127318128294
sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag);
127319128295
VdbeComment((v, "clear abort flag"));
127320
- sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);
127321
- VdbeComment((v, "indicate accumulator empty"));
127322128296
sqlite3VdbeAddOp3(v, OP_Null, 0, iAMem, iAMem+pGroupBy->nExpr-1);
127323128297
127324128298
/* Begin a loop that will extract all source rows in GROUP BY order.
127325128299
** This might involve two separate loops with an OP_Sort in between, or
127326128300
** it might be a single loop that uses an index to extract information
@@ -127449,11 +128423,11 @@
127449128423
127450128424
/* Update the aggregate accumulators based on the content of
127451128425
** the current row
127452128426
*/
127453128427
sqlite3VdbeJumpHere(v, addr1);
127454
- updateAccumulator(pParse, &sAggInfo);
128428
+ updateAccumulator(pParse, iUseFlag, &sAggInfo);
127455128429
sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);
127456128430
VdbeComment((v, "indicate data in accumulator"));
127457128431
127458128432
/* End of the loop
127459128433
*/
@@ -127501,10 +128475,12 @@
127501128475
127502128476
/* Generate a subroutine that will reset the group-by accumulator
127503128477
*/
127504128478
sqlite3VdbeResolveLabel(v, addrReset);
127505128479
resetAccumulator(pParse, &sAggInfo);
128480
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);
128481
+ VdbeComment((v, "indicate accumulator empty"));
127506128482
sqlite3VdbeAddOp1(v, OP_Return, regReset);
127507128483
127508128484
} /* endif pGroupBy. Begin aggregate queries without GROUP BY: */
127509128485
else {
127510128486
#ifndef SQLITE_OMIT_BTREECOUNT
@@ -127566,10 +128542,27 @@
127566128542
sqlite3VdbeAddOp1(v, OP_Close, iCsr);
127567128543
explainSimpleCount(pParse, pTab, pBest);
127568128544
}else
127569128545
#endif /* SQLITE_OMIT_BTREECOUNT */
127570128546
{
128547
+ int regAcc = 0; /* "populate accumulators" flag */
128548
+
128549
+ /* If there are accumulator registers but no min() or max() functions,
128550
+ ** allocate register regAcc. Register regAcc will contain 0 the first
128551
+ ** time the inner loop runs, and 1 thereafter. The code generated
128552
+ ** by updateAccumulator() only updates the accumulator registers if
128553
+ ** regAcc contains 0. */
128554
+ if( sAggInfo.nAccumulator ){
128555
+ for(i=0; i<sAggInfo.nFunc; i++){
128556
+ if( sAggInfo.aFunc[i].pFunc->funcFlags&SQLITE_FUNC_NEEDCOLL ) break;
128557
+ }
128558
+ if( i==sAggInfo.nFunc ){
128559
+ regAcc = ++pParse->nMem;
128560
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, regAcc);
128561
+ }
128562
+ }
128563
+
127571128564
/* This case runs if the aggregate has no GROUP BY clause. The
127572128565
** processing is much simpler since there is only a single row
127573128566
** of output.
127574128567
*/
127575128568
assert( p->pGroupBy==0 );
@@ -127587,11 +128580,12 @@
127587128580
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMaxOrderBy,
127588128581
0, minMaxFlag, 0);
127589128582
if( pWInfo==0 ){
127590128583
goto select_end;
127591128584
}
127592
- updateAccumulator(pParse, &sAggInfo);
128585
+ updateAccumulator(pParse, regAcc, &sAggInfo);
128586
+ if( regAcc ) sqlite3VdbeAddOp2(v, OP_Integer, 1, regAcc);
127593128587
if( sqlite3WhereIsOrdered(pWInfo)>0 ){
127594128588
sqlite3VdbeGoto(v, sqlite3WhereBreakLabel(pWInfo));
127595128589
VdbeComment((v, "%s() by index",
127596128590
(minMaxFlag==WHERE_ORDERBY_MIN?"min":"max")));
127597128591
}
@@ -129520,11 +130514,11 @@
129520130514
/* Top of the update loop */
129521130515
if( eOnePass!=ONEPASS_OFF ){
129522130516
if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){
129523130517
assert( pPk );
129524130518
sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey,nKey);
129525
- VdbeCoverageNeverTaken(v);
130519
+ VdbeCoverage(v);
129526130520
}
129527130521
if( eOnePass!=ONEPASS_SINGLE ){
129528130522
labelContinue = sqlite3VdbeMakeLabel(v);
129529130523
}
129530130524
sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
@@ -130423,11 +131417,11 @@
130423131417
** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,
130424131418
** to ensure that we do not try to change the page-size on a WAL database.
130425131419
*/
130426131420
rc = execSql(db, pzErrMsg, "BEGIN");
130427131421
if( rc!=SQLITE_OK ) goto end_of_vacuum;
130428
- rc = sqlite3BtreeBeginTrans(pMain, 2);
131422
+ rc = sqlite3BtreeBeginTrans(pMain, 2, 0);
130429131423
if( rc!=SQLITE_OK ) goto end_of_vacuum;
130430131424
130431131425
/* Do not attempt to change the page size for a WAL database */
130432131426
if( sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain))
130433131427
==PAGER_JOURNALMODE_WAL ){
@@ -131932,10 +132926,12 @@
131932132926
struct {
131933132927
int nIn; /* Number of entries in aInLoop[] */
131934132928
struct InLoop {
131935132929
int iCur; /* The VDBE cursor used by this IN operator */
131936132930
int addrInTop; /* Top of the IN loop */
132931
+ int iBase; /* Base register of multi-key index record */
132932
+ int nPrefix; /* Number of prior entires in the key */
131937132933
u8 eEndLoopOp; /* IN Loop terminator. OP_Next or OP_Prev */
131938132934
} *aInLoop; /* Information about each nested IN operator */
131939132935
} in; /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */
131940132936
Index *pCovidx; /* Possible covering index for WHERE_MULTI_OR */
131941132937
} u;
@@ -132170,10 +133166,11 @@
132170133166
*/
132171133167
struct WhereClause {
132172133168
WhereInfo *pWInfo; /* WHERE clause processing context */
132173133169
WhereClause *pOuter; /* Outer conjunction */
132174133170
u8 op; /* Split operator. TK_AND or TK_OR */
133171
+ u8 hasOr; /* True if any a[].eOperator is WO_OR */
132175133172
int nTerm; /* Number of terms */
132176133173
int nSlot; /* Number of entries in a[] */
132177133174
WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
132178133175
#if defined(SQLITE_SMALL_STACK)
132179133176
WhereTerm aStatic[1]; /* Initial static space for a[] */
@@ -132343,10 +133340,11 @@
132343133340
/* whereexpr.c: */
132344133341
SQLITE_PRIVATE void sqlite3WhereClauseInit(WhereClause*,WhereInfo*);
132345133342
SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause*);
132346133343
SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause*,Expr*,u8);
132347133344
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*);
133345
+SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet*, Expr*);
132348133346
SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*);
132349133347
SQLITE_PRIVATE void sqlite3WhereExprAnalyze(SrcList*, WhereClause*);
132350133348
SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*);
132351133349
132352133350
@@ -132405,10 +133403,11 @@
132405133403
#define WHERE_MULTI_OR 0x00002000 /* OR using multiple indices */
132406133404
#define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
132407133405
#define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
132408133406
#define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
132409133407
#define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
133408
+#define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
132410133409
132411133410
/************** End of whereInt.h ********************************************/
132412133411
/************** Continuing where we left off in wherecode.c ******************/
132413133412
132414133413
#ifndef SQLITE_OMIT_EXPLAIN
@@ -132539,11 +133538,11 @@
132539133538
|| (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
132540133539
132541133540
sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
132542133541
sqlite3_str_appendall(&str, isSearch ? "SEARCH" : "SCAN");
132543133542
if( pItem->pSelect ){
132544
- sqlite3_str_appendf(&str, " SUBQUERY 0x%p", pItem->pSelect);
133543
+ sqlite3_str_appendf(&str, " SUBQUERY %u", pItem->pSelect->selId);
132545133544
}else{
132546133545
sqlite3_str_appendf(&str, " TABLE %s", pItem->zName);
132547133546
}
132548133547
132549133548
if( pItem->zAlias ){
@@ -132980,11 +133979,18 @@
132980133979
pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut);
132981133980
}
132982133981
sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v);
132983133982
if( i==iEq ){
132984133983
pIn->iCur = iTab;
132985
- pIn->eEndLoopOp = bRev ? OP_PrevIfOpen : OP_NextIfOpen;
133984
+ pIn->eEndLoopOp = bRev ? OP_Prev : OP_Next;
133985
+ if( iEq>0 && (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){
133986
+ pIn->iBase = iReg - i;
133987
+ pIn->nPrefix = i;
133988
+ pLoop->wsFlags |= WHERE_IN_EARLYOUT;
133989
+ }else{
133990
+ pIn->nPrefix = 0;
133991
+ }
132986133992
}else{
132987133993
pIn->eEndLoopOp = OP_Noop;
132988133994
}
132989133995
pIn++;
132990133996
}
@@ -133624,11 +134630,11 @@
133624134630
if( pTabItem->fg.viaCoroutine ){
133625134631
int regYield = pTabItem->regReturn;
133626134632
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
133627134633
pLevel->p2 = sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk);
133628134634
VdbeCoverage(v);
133629
- VdbeComment((v, "next row of \"%s\"", pTabItem->pTab->zName));
134635
+ VdbeComment((v, "next row of %s", pTabItem->pTab->zName));
133630134636
pLevel->op = OP_Goto;
133631134637
}else
133632134638
133633134639
#ifndef SQLITE_OMIT_VIRTUALTABLE
133634134640
if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){
@@ -134047,10 +135053,13 @@
134047135053
if( pLoop->nSkip>0 && nConstraint==pLoop->nSkip ){
134048135054
/* The skip-scan logic inside the call to codeAllEqualityConstraints()
134049135055
** above has already left the cursor sitting on the correct row,
134050135056
** so no further seeking is needed */
134051135057
}else{
135058
+ if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
135059
+ sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur);
135060
+ }
134052135061
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
134053135062
assert( op!=0 );
134054135063
sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
134055135064
VdbeCoverage(v);
134056135065
VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind );
@@ -134109,10 +135118,14 @@
134109135118
testcase( op==OP_IdxGT ); VdbeCoverageIf(v, op==OP_IdxGT );
134110135119
testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE );
134111135120
testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
134112135121
testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
134113135122
}
135123
+
135124
+ if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
135125
+ sqlite3VdbeAddOp2(v, OP_SeekHit, iIdxCur, 1);
135126
+ }
134114135127
134115135128
/* Seek the table cursor, if required */
134116135129
if( omitTable ){
134117135130
/* pIdx is a covering index. No need to access the main table. */
134118135131
}else if( HasRowid(pIdx->pTable) ){
@@ -134882,15 +135895,17 @@
134882135895
if( c==wc[3] && z[cnt]!=0 ) cnt++;
134883135896
}
134884135897
134885135898
/* The optimization is possible only if (1) the pattern does not begin
134886135899
** with a wildcard and if (2) the non-wildcard prefix does not end with
134887
- ** an (illegal 0xff) character. The second condition is necessary so
135900
+ ** an (illegal 0xff) character, or (3) the pattern does not consist of
135901
+ ** a single escape character. The second condition is necessary so
134888135902
** that we can increment the prefix key to find an upper bound for the
134889
- ** range search.
134890
- */
134891
- if( cnt!=0 && 255!=(u8)z[cnt-1] ){
135903
+ ** range search. The third is because the caller assumes that the pattern
135904
+ ** consists of at least one character after all escapes have been
135905
+ ** removed. */
135906
+ if( cnt!=0 && 255!=(u8)z[cnt-1] && (cnt>1 || z[0]!=wc[3]) ){
134892135907
Expr *pPrefix;
134893135908
134894135909
/* A "complete" match if the pattern ends with "*" or "%" */
134895135910
*pisComplete = c==wc[0] && z[cnt+1]==0;
134896135911
@@ -135298,11 +136313,16 @@
135298136313
/*
135299136314
** Record the set of tables that satisfy case 3. The set might be
135300136315
** empty.
135301136316
*/
135302136317
pOrInfo->indexable = indexable;
135303
- pTerm->eOperator = indexable==0 ? 0 : WO_OR;
136318
+ if( indexable ){
136319
+ pTerm->eOperator = WO_OR;
136320
+ pWC->hasOr = 1;
136321
+ }else{
136322
+ pTerm->eOperator = WO_OR;
136323
+ }
135304136324
135305136325
/* For a two-way OR, attempt to implementation case 2.
135306136326
*/
135307136327
if( indexable && pOrWc->nTerm==2 ){
135308136328
int iOne = 0;
@@ -135637,11 +136657,11 @@
135637136657
pTerm->prereqRight = 0;
135638136658
}else{
135639136659
pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
135640136660
}
135641136661
pMaskSet->bVarSelect = 0;
135642
- prereqAll = sqlite3WhereExprUsage(pMaskSet, pExpr);
136662
+ prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);
135643136663
if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;
135644136664
if( ExprHasProperty(pExpr, EP_FromJoin) ){
135645136665
Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
135646136666
prereqAll |= x;
135647136667
extraRight = x-1; /* ON clause terms may not be used with an index
@@ -136030,10 +137050,11 @@
136030137050
SQLITE_PRIVATE void sqlite3WhereClauseInit(
136031137051
WhereClause *pWC, /* The WhereClause to be initialized */
136032137052
WhereInfo *pWInfo /* The WHERE processing context */
136033137053
){
136034137054
pWC->pWInfo = pWInfo;
137055
+ pWC->hasOr = 0;
136035137056
pWC->pOuter = 0;
136036137057
pWC->nTerm = 0;
136037137058
pWC->nSlot = ArraySize(pWC->aStatic);
136038137059
pWC->a = pWC->aStatic;
136039137060
}
@@ -136066,29 +137087,33 @@
136066137087
/*
136067137088
** These routines walk (recursively) an expression tree and generate
136068137089
** a bitmask indicating which tables are used in that expression
136069137090
** tree.
136070137091
*/
136071
-SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
137092
+SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
136072137093
Bitmask mask;
136073
- if( p==0 ) return 0;
136074137094
if( p->op==TK_COLUMN ){
136075137095
return sqlite3WhereGetMask(pMaskSet, p->iTable);
137096
+ }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
137097
+ assert( p->op!=TK_IF_NULL_ROW );
137098
+ return 0;
136076137099
}
136077137100
mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
136078
- assert( !ExprHasProperty(p, EP_TokenOnly) );
136079
- if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft);
137101
+ if( p->pLeft ) mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);
136080137102
if( p->pRight ){
136081
- mask |= sqlite3WhereExprUsage(pMaskSet, p->pRight);
137103
+ mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pRight);
136082137104
assert( p->x.pList==0 );
136083137105
}else if( ExprHasProperty(p, EP_xIsSelect) ){
136084137106
if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1;
136085137107
mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
136086137108
}else if( p->x.pList ){
136087137109
mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
136088137110
}
136089137111
return mask;
137112
+}
137113
+SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
137114
+ return p ? sqlite3WhereExprUsageNN(pMaskSet,p) : 0;
136090137115
}
136091137116
SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet *pMaskSet, ExprList *pList){
136092137117
int i;
136093137118
Bitmask mask = 0;
136094137119
if( pList ){
@@ -136970,11 +137995,11 @@
136970137995
int regYield = pTabItem->regReturn;
136971137996
addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);
136972137997
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
136973137998
addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield);
136974137999
VdbeCoverage(v);
136975
- VdbeComment((v, "next row of \"%s\"", pTabItem->pTab->zName));
138000
+ VdbeComment((v, "next row of %s", pTabItem->pTab->zName));
136976138001
}else{
136977138002
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);
136978138003
}
136979138004
if( pPartial ){
136980138005
iContinue = sqlite3VdbeMakeLabel(v);
@@ -138611,11 +139636,10 @@
138611139636
|| (pNew->wsFlags & WHERE_SKIPSCAN)!=0
138612139637
);
138613139638
138614139639
if( eOp & WO_IN ){
138615139640
Expr *pExpr = pTerm->pExpr;
138616
- pNew->wsFlags |= WHERE_COLUMN_IN;
138617139641
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
138618139642
/* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */
138619139643
int i;
138620139644
nIn = 46; assert( 46==sqlite3LogEst(25) );
138621139645
@@ -138631,10 +139655,46 @@
138631139655
/* "x IN (value, value, ...)" */
138632139656
nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
138633139657
assert( nIn>0 ); /* RHS always has 2 or more terms... The parser
138634139658
** changes "x IN (?)" into "x=?". */
138635139659
}
139660
+ if( pProbe->hasStat1 ){
139661
+ LogEst M, logK, safetyMargin;
139662
+ /* Let:
139663
+ ** N = the total number of rows in the table
139664
+ ** K = the number of entries on the RHS of the IN operator
139665
+ ** M = the number of rows in the table that match terms to the
139666
+ ** to the left in the same index. If the IN operator is on
139667
+ ** the left-most index column, M==N.
139668
+ **
139669
+ ** Given the definitions above, it is better to omit the IN operator
139670
+ ** from the index lookup and instead do a scan of the M elements,
139671
+ ** testing each scanned row against the IN operator separately, if:
139672
+ **
139673
+ ** M*log(K) < K*log(N)
139674
+ **
139675
+ ** Our estimates for M, K, and N might be inaccurate, so we build in
139676
+ ** a safety margin of 2 (LogEst: 10) that favors using the IN operator
139677
+ ** with the index, as using an index has better worst-case behavior.
139678
+ ** If we do not have real sqlite_stat1 data, always prefer to use
139679
+ ** the index.
139680
+ */
139681
+ M = pProbe->aiRowLogEst[saved_nEq];
139682
+ logK = estLog(nIn);
139683
+ safetyMargin = 10; /* TUNING: extra weight for indexed IN */
139684
+ if( M + logK + safetyMargin < nIn + rLogSize ){
139685
+ WHERETRACE(0x40,
139686
+ ("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n",
139687
+ saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
139688
+ continue;
139689
+ }else{
139690
+ WHERETRACE(0x40,
139691
+ ("IN operator preferred on column %d of \"%s\" (%d>=%d)\n",
139692
+ saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
139693
+ }
139694
+ }
139695
+ pNew->wsFlags |= WHERE_COLUMN_IN;
138636139696
}else if( eOp & (WO_EQ|WO_IS) ){
138637139697
int iCol = pProbe->aiColumn[saved_nEq];
138638139698
pNew->wsFlags |= WHERE_COLUMN_EQ;
138639139699
assert( saved_nEq==pNew->u.btree.nEq );
138640139700
if( iCol==XN_ROWID
@@ -138797,10 +139857,11 @@
138797139857
** more expensive. */
138798139858
assert( 42==sqlite3LogEst(18) );
138799139859
if( saved_nEq==saved_nSkip
138800139860
&& saved_nEq+1<pProbe->nKeyCol
138801139861
&& pProbe->noSkipScan==0
139862
+ && OptimizationEnabled(db, SQLITE_SkipScan)
138802139863
&& pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */
138803139864
&& (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
138804139865
){
138805139866
LogEst nIter;
138806139867
pNew->u.btree.nEq++;
@@ -138860,28 +139921,10 @@
138860139921
}
138861139922
}
138862139923
return 0;
138863139924
}
138864139925
138865
-/*
138866
-** Return a bitmask where 1s indicate that the corresponding column of
138867
-** the table is used by an index. Only the first 63 columns are considered.
138868
-*/
138869
-static Bitmask columnsInIndex(Index *pIdx){
138870
- Bitmask m = 0;
138871
- int j;
138872
- for(j=pIdx->nColumn-1; j>=0; j--){
138873
- int x = pIdx->aiColumn[j];
138874
- if( x>=0 ){
138875
- testcase( x==BMS-1 );
138876
- testcase( x==BMS-2 );
138877
- if( x<BMS-1 ) m |= MASKBIT(x);
138878
- }
138879
- }
138880
- return m;
138881
-}
138882
-
138883139926
/* Check to see if a partial index with pPartIndexWhere can be used
138884139927
** in the current query. Return true if it can be and false if not.
138885139928
*/
138886139929
static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
138887139930
int i;
@@ -139093,11 +140136,11 @@
139093140136
Bitmask m;
139094140137
if( pProbe->isCovering ){
139095140138
pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
139096140139
m = 0;
139097140140
}else{
139098
- m = pSrc->colUsed & ~columnsInIndex(pProbe);
140141
+ m = pSrc->colUsed & pProbe->colNotIdxed;
139099140142
pNew->wsFlags = (m==0) ? (WHERE_IDX_ONLY|WHERE_INDEXED) : WHERE_INDEXED;
139100140143
}
139101140144
139102140145
/* Full scan via index */
139103140146
if( b
@@ -139660,11 +140703,11 @@
139660140703
}else
139661140704
#endif /* SQLITE_OMIT_VIRTUALTABLE */
139662140705
{
139663140706
rc = whereLoopAddBtree(pBuilder, mPrereq);
139664140707
}
139665
- if( rc==SQLITE_OK ){
140708
+ if( rc==SQLITE_OK && pBuilder->pWC->hasOr ){
139666140709
rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
139667140710
}
139668140711
mPrior |= pNew->maskSelf;
139669140712
if( rc || db->mallocFailed ) break;
139670140713
}
@@ -140496,11 +141539,11 @@
140496141539
testcase( pTerm->eOperator & WO_IS );
140497141540
pLoop->aLTerm[j] = pTerm;
140498141541
}
140499141542
if( j!=pIdx->nKeyCol ) continue;
140500141543
pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED;
140501
- if( pIdx->isCovering || (pItem->colUsed & ~columnsInIndex(pIdx))==0 ){
141544
+ if( pIdx->isCovering || (pItem->colUsed & pIdx->colNotIdxed)==0 ){
140502141545
pLoop->wsFlags |= WHERE_IDX_ONLY;
140503141546
}
140504141547
pLoop->nLTerm = j;
140505141548
pLoop->u.btree.nEq = j;
140506141549
pLoop->u.btree.pIndex = pIdx;
@@ -141176,10 +142219,30 @@
141176142219
whereInfoFree(db, pWInfo);
141177142220
}
141178142221
return 0;
141179142222
}
141180142223
142224
+/*
142225
+** Part of sqlite3WhereEnd() will rewrite opcodes to reference the
142226
+** index rather than the main table. In SQLITE_DEBUG mode, we want
142227
+** to trace those changes if PRAGMA vdbe_addoptrace=on. This routine
142228
+** does that.
142229
+*/
142230
+#ifndef SQLITE_DEBUG
142231
+# define OpcodeRewriteTrace(D,K,P) /* no-op */
142232
+#else
142233
+# define OpcodeRewriteTrace(D,K,P) sqlite3WhereOpcodeRewriteTrace(D,K,P)
142234
+ static void sqlite3WhereOpcodeRewriteTrace(
142235
+ sqlite3 *db,
142236
+ int pc,
142237
+ VdbeOp *pOp
142238
+ ){
142239
+ if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;
142240
+ sqlite3VdbePrintOp(0, pc, pOp);
142241
+ }
142242
+#endif
142243
+
141181142244
/*
141182142245
** Generate the end of the WHERE loop. See comments on
141183142246
** sqlite3WhereBegin() for additional information.
141184142247
*/
141185142248
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
@@ -141243,14 +142306,21 @@
141243142306
int j;
141244142307
sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
141245142308
for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
141246142309
sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
141247142310
if( pIn->eEndLoopOp!=OP_Noop ){
142311
+ if( pIn->nPrefix ){
142312
+ assert( pLoop->wsFlags & WHERE_IN_EARLYOUT );
142313
+ sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,
142314
+ sqlite3VdbeCurrentAddr(v)+2,
142315
+ pIn->iBase, pIn->nPrefix);
142316
+ VdbeCoverage(v);
142317
+ }
141248142318
sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
141249142319
VdbeCoverage(v);
141250
- VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
141251
- VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
142320
+ VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Prev);
142321
+ VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Next);
141252142322
}
141253142323
sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
141254142324
}
141255142325
}
141256142326
sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
@@ -141337,10 +142407,15 @@
141337142407
&& (pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable))
141338142408
&& !db->mallocFailed
141339142409
){
141340142410
last = sqlite3VdbeCurrentAddr(v);
141341142411
k = pLevel->addrBody;
142412
+#ifdef SQLITE_DEBUG
142413
+ if( db->flags & SQLITE_VdbeAddopTrace ){
142414
+ printf("TRANSLATE opcodes in range %d..%d\n", k, last-1);
142415
+ }
142416
+#endif
141342142417
pOp = sqlite3VdbeGetOp(v, k);
141343142418
for(; k<last; k++, pOp++){
141344142419
if( pOp->p1!=pLevel->iTabCur ) continue;
141345142420
if( pOp->opcode==OP_Column
141346142421
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
@@ -141356,20 +142431,26 @@
141356142431
}
141357142432
x = sqlite3ColumnOfIndex(pIdx, x);
141358142433
if( x>=0 ){
141359142434
pOp->p2 = x;
141360142435
pOp->p1 = pLevel->iIdxCur;
142436
+ OpcodeRewriteTrace(db, k, pOp);
141361142437
}
141362142438
assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0
141363142439
|| pWInfo->eOnePass );
141364142440
}else if( pOp->opcode==OP_Rowid ){
141365142441
pOp->p1 = pLevel->iIdxCur;
141366142442
pOp->opcode = OP_IdxRowid;
142443
+ OpcodeRewriteTrace(db, k, pOp);
141367142444
}else if( pOp->opcode==OP_IfNullRow ){
141368142445
pOp->p1 = pLevel->iIdxCur;
142446
+ OpcodeRewriteTrace(db, k, pOp);
141369142447
}
141370142448
}
142449
+#ifdef SQLITE_DEBUG
142450
+ if( db->flags & SQLITE_VdbeAddopTrace ) printf("TRANSLATE complete\n");
142451
+#endif
141371142452
}
141372142453
}
141373142454
141374142455
/* Final cleanup
141375142456
*/
@@ -141377,10 +142458,2262 @@
141377142458
whereInfoFree(db, pWInfo);
141378142459
return;
141379142460
}
141380142461
141381142462
/************** End of where.c ***********************************************/
142463
+/************** Begin file window.c ******************************************/
142464
+/*
142465
+** 2018 May 08
142466
+**
142467
+** The author disclaims copyright to this source code. In place of
142468
+** a legal notice, here is a blessing:
142469
+**
142470
+** May you do good and not evil.
142471
+** May you find forgiveness for yourself and forgive others.
142472
+** May you share freely, never taking more than you give.
142473
+**
142474
+*************************************************************************
142475
+*/
142476
+/* #include "sqliteInt.h" */
142477
+
142478
+#ifndef SQLITE_OMIT_WINDOWFUNC
142479
+
142480
+/*
142481
+** SELECT REWRITING
142482
+**
142483
+** Any SELECT statement that contains one or more window functions in
142484
+** either the select list or ORDER BY clause (the only two places window
142485
+** functions may be used) is transformed by function sqlite3WindowRewrite()
142486
+** in order to support window function processing. For example, with the
142487
+** schema:
142488
+**
142489
+** CREATE TABLE t1(a, b, c, d, e, f, g);
142490
+**
142491
+** the statement:
142492
+**
142493
+** SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM t1 ORDER BY e;
142494
+**
142495
+** is transformed to:
142496
+**
142497
+** SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM (
142498
+** SELECT a, e, c, d, b FROM t1 ORDER BY c, d
142499
+** ) ORDER BY e;
142500
+**
142501
+** The flattening optimization is disabled when processing this transformed
142502
+** SELECT statement. This allows the implementation of the window function
142503
+** (in this case max()) to process rows sorted in order of (c, d), which
142504
+** makes things easier for obvious reasons. More generally:
142505
+**
142506
+** * FROM, WHERE, GROUP BY and HAVING clauses are all moved to
142507
+** the sub-query.
142508
+**
142509
+** * ORDER BY, LIMIT and OFFSET remain part of the parent query.
142510
+**
142511
+** * Terminals from each of the expression trees that make up the
142512
+** select-list and ORDER BY expressions in the parent query are
142513
+** selected by the sub-query. For the purposes of the transformation,
142514
+** terminals are column references and aggregate functions.
142515
+**
142516
+** If there is more than one window function in the SELECT that uses
142517
+** the same window declaration (the OVER bit), then a single scan may
142518
+** be used to process more than one window function. For example:
142519
+**
142520
+** SELECT max(b) OVER (PARTITION BY c ORDER BY d),
142521
+** min(e) OVER (PARTITION BY c ORDER BY d)
142522
+** FROM t1;
142523
+**
142524
+** is transformed in the same way as the example above. However:
142525
+**
142526
+** SELECT max(b) OVER (PARTITION BY c ORDER BY d),
142527
+** min(e) OVER (PARTITION BY a ORDER BY b)
142528
+** FROM t1;
142529
+**
142530
+** Must be transformed to:
142531
+**
142532
+** SELECT max(b) OVER (PARTITION BY c ORDER BY d) FROM (
142533
+** SELECT e, min(e) OVER (PARTITION BY a ORDER BY b), c, d, b FROM
142534
+** SELECT a, e, c, d, b FROM t1 ORDER BY a, b
142535
+** ) ORDER BY c, d
142536
+** ) ORDER BY e;
142537
+**
142538
+** so that both min() and max() may process rows in the order defined by
142539
+** their respective window declarations.
142540
+**
142541
+** INTERFACE WITH SELECT.C
142542
+**
142543
+** When processing the rewritten SELECT statement, code in select.c calls
142544
+** sqlite3WhereBegin() to begin iterating through the results of the
142545
+** sub-query, which is always implemented as a co-routine. It then calls
142546
+** sqlite3WindowCodeStep() to process rows and finish the scan by calling
142547
+** sqlite3WhereEnd().
142548
+**
142549
+** sqlite3WindowCodeStep() generates VM code so that, for each row returned
142550
+** by the sub-query a sub-routine (OP_Gosub) coded by select.c is invoked.
142551
+** When the sub-routine is invoked:
142552
+**
142553
+** * The results of all window-functions for the row are stored
142554
+** in the associated Window.regResult registers.
142555
+**
142556
+** * The required terminal values are stored in the current row of
142557
+** temp table Window.iEphCsr.
142558
+**
142559
+** In some cases, depending on the window frame and the specific window
142560
+** functions invoked, sqlite3WindowCodeStep() caches each entire partition
142561
+** in a temp table before returning any rows. In other cases it does not.
142562
+** This detail is encapsulated within this file, the code generated by
142563
+** select.c is the same in either case.
142564
+**
142565
+** BUILT-IN WINDOW FUNCTIONS
142566
+**
142567
+** This implementation features the following built-in window functions:
142568
+**
142569
+** row_number()
142570
+** rank()
142571
+** dense_rank()
142572
+** percent_rank()
142573
+** cume_dist()
142574
+** ntile(N)
142575
+** lead(expr [, offset [, default]])
142576
+** lag(expr [, offset [, default]])
142577
+** first_value(expr)
142578
+** last_value(expr)
142579
+** nth_value(expr, N)
142580
+**
142581
+** These are the same built-in window functions supported by Postgres.
142582
+** Although the behaviour of aggregate window functions (functions that
142583
+** can be used as either aggregates or window funtions) allows them to
142584
+** be implemented using an API, built-in window functions are much more
142585
+** esoteric. Additionally, some window functions (e.g. nth_value())
142586
+** may only be implemented by caching the entire partition in memory.
142587
+** As such, some built-in window functions use the same API as aggregate
142588
+** window functions and some are implemented directly using VDBE
142589
+** instructions. Additionally, for those functions that use the API, the
142590
+** window frame is sometimes modified before the SELECT statement is
142591
+** rewritten. For example, regardless of the specified window frame, the
142592
+** row_number() function always uses:
142593
+**
142594
+** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142595
+**
142596
+** See sqlite3WindowUpdate() for details.
142597
+**
142598
+** As well as some of the built-in window functions, aggregate window
142599
+** functions min() and max() are implemented using VDBE instructions if
142600
+** the start of the window frame is declared as anything other than
142601
+** UNBOUNDED PRECEDING.
142602
+*/
142603
+
142604
+/*
142605
+** Implementation of built-in window function row_number(). Assumes that the
142606
+** window frame has been coerced to:
142607
+**
142608
+** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142609
+*/
142610
+static void row_numberStepFunc(
142611
+ sqlite3_context *pCtx,
142612
+ int nArg,
142613
+ sqlite3_value **apArg
142614
+){
142615
+ i64 *p = (i64*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142616
+ if( p ) (*p)++;
142617
+ UNUSED_PARAMETER(nArg);
142618
+ UNUSED_PARAMETER(apArg);
142619
+}
142620
+static void row_numberValueFunc(sqlite3_context *pCtx){
142621
+ i64 *p = (i64*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142622
+ sqlite3_result_int64(pCtx, (p ? *p : 0));
142623
+}
142624
+
142625
+/*
142626
+** Context object type used by rank(), dense_rank(), percent_rank() and
142627
+** cume_dist().
142628
+*/
142629
+struct CallCount {
142630
+ i64 nValue;
142631
+ i64 nStep;
142632
+ i64 nTotal;
142633
+};
142634
+
142635
+/*
142636
+** Implementation of built-in window function dense_rank(). Assumes that
142637
+** the window frame has been set to:
142638
+**
142639
+** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142640
+*/
142641
+static void dense_rankStepFunc(
142642
+ sqlite3_context *pCtx,
142643
+ int nArg,
142644
+ sqlite3_value **apArg
142645
+){
142646
+ struct CallCount *p;
142647
+ p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142648
+ if( p ) p->nStep = 1;
142649
+ UNUSED_PARAMETER(nArg);
142650
+ UNUSED_PARAMETER(apArg);
142651
+}
142652
+static void dense_rankValueFunc(sqlite3_context *pCtx){
142653
+ struct CallCount *p;
142654
+ p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142655
+ if( p ){
142656
+ if( p->nStep ){
142657
+ p->nValue++;
142658
+ p->nStep = 0;
142659
+ }
142660
+ sqlite3_result_int64(pCtx, p->nValue);
142661
+ }
142662
+}
142663
+
142664
+/*
142665
+** Implementation of built-in window function rank(). Assumes that
142666
+** the window frame has been set to:
142667
+**
142668
+** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142669
+*/
142670
+static void rankStepFunc(
142671
+ sqlite3_context *pCtx,
142672
+ int nArg,
142673
+ sqlite3_value **apArg
142674
+){
142675
+ struct CallCount *p;
142676
+ p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142677
+ if( p ){
142678
+ p->nStep++;
142679
+ if( p->nValue==0 ){
142680
+ p->nValue = p->nStep;
142681
+ }
142682
+ }
142683
+ UNUSED_PARAMETER(nArg);
142684
+ UNUSED_PARAMETER(apArg);
142685
+}
142686
+static void rankValueFunc(sqlite3_context *pCtx){
142687
+ struct CallCount *p;
142688
+ p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142689
+ if( p ){
142690
+ sqlite3_result_int64(pCtx, p->nValue);
142691
+ p->nValue = 0;
142692
+ }
142693
+}
142694
+
142695
+/*
142696
+** Implementation of built-in window function percent_rank(). Assumes that
142697
+** the window frame has been set to:
142698
+**
142699
+** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142700
+*/
142701
+static void percent_rankStepFunc(
142702
+ sqlite3_context *pCtx,
142703
+ int nArg,
142704
+ sqlite3_value **apArg
142705
+){
142706
+ struct CallCount *p;
142707
+ UNUSED_PARAMETER(nArg); assert( nArg==1 );
142708
+
142709
+ p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142710
+ if( p ){
142711
+ if( p->nTotal==0 ){
142712
+ p->nTotal = sqlite3_value_int64(apArg[0]);
142713
+ }
142714
+ p->nStep++;
142715
+ if( p->nValue==0 ){
142716
+ p->nValue = p->nStep;
142717
+ }
142718
+ }
142719
+}
142720
+static void percent_rankValueFunc(sqlite3_context *pCtx){
142721
+ struct CallCount *p;
142722
+ p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142723
+ if( p ){
142724
+ if( p->nTotal>1 ){
142725
+ double r = (double)(p->nValue-1) / (double)(p->nTotal-1);
142726
+ sqlite3_result_double(pCtx, r);
142727
+ }else{
142728
+ sqlite3_result_double(pCtx, 0.0);
142729
+ }
142730
+ p->nValue = 0;
142731
+ }
142732
+}
142733
+
142734
+/*
142735
+** Implementation of built-in window function cume_dist(). Assumes that
142736
+** the window frame has been set to:
142737
+**
142738
+** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142739
+*/
142740
+static void cume_distStepFunc(
142741
+ sqlite3_context *pCtx,
142742
+ int nArg,
142743
+ sqlite3_value **apArg
142744
+){
142745
+ struct CallCount *p;
142746
+ assert( nArg==1 ); UNUSED_PARAMETER(nArg);
142747
+
142748
+ p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142749
+ if( p ){
142750
+ if( p->nTotal==0 ){
142751
+ p->nTotal = sqlite3_value_int64(apArg[0]);
142752
+ }
142753
+ p->nStep++;
142754
+ }
142755
+}
142756
+static void cume_distValueFunc(sqlite3_context *pCtx){
142757
+ struct CallCount *p;
142758
+ p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142759
+ if( p && p->nTotal ){
142760
+ double r = (double)(p->nStep) / (double)(p->nTotal);
142761
+ sqlite3_result_double(pCtx, r);
142762
+ }
142763
+}
142764
+
142765
+/*
142766
+** Context object for ntile() window function.
142767
+*/
142768
+struct NtileCtx {
142769
+ i64 nTotal; /* Total rows in partition */
142770
+ i64 nParam; /* Parameter passed to ntile(N) */
142771
+ i64 iRow; /* Current row */
142772
+};
142773
+
142774
+/*
142775
+** Implementation of ntile(). This assumes that the window frame has
142776
+** been coerced to:
142777
+**
142778
+** ROWS UNBOUNDED PRECEDING AND CURRENT ROW
142779
+*/
142780
+static void ntileStepFunc(
142781
+ sqlite3_context *pCtx,
142782
+ int nArg,
142783
+ sqlite3_value **apArg
142784
+){
142785
+ struct NtileCtx *p;
142786
+ assert( nArg==2 ); UNUSED_PARAMETER(nArg);
142787
+ p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142788
+ if( p ){
142789
+ if( p->nTotal==0 ){
142790
+ p->nParam = sqlite3_value_int64(apArg[0]);
142791
+ p->nTotal = sqlite3_value_int64(apArg[1]);
142792
+ if( p->nParam<=0 ){
142793
+ sqlite3_result_error(
142794
+ pCtx, "argument of ntile must be a positive integer", -1
142795
+ );
142796
+ }
142797
+ }
142798
+ p->iRow++;
142799
+ }
142800
+}
142801
+static void ntileValueFunc(sqlite3_context *pCtx){
142802
+ struct NtileCtx *p;
142803
+ p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142804
+ if( p && p->nParam>0 ){
142805
+ int nSize = (p->nTotal / p->nParam);
142806
+ if( nSize==0 ){
142807
+ sqlite3_result_int64(pCtx, p->iRow);
142808
+ }else{
142809
+ i64 nLarge = p->nTotal - p->nParam*nSize;
142810
+ i64 iSmall = nLarge*(nSize+1);
142811
+ i64 iRow = p->iRow-1;
142812
+
142813
+ assert( (nLarge*(nSize+1) + (p->nParam-nLarge)*nSize)==p->nTotal );
142814
+
142815
+ if( iRow<iSmall ){
142816
+ sqlite3_result_int64(pCtx, 1 + iRow/(nSize+1));
142817
+ }else{
142818
+ sqlite3_result_int64(pCtx, 1 + nLarge + (iRow-iSmall)/nSize);
142819
+ }
142820
+ }
142821
+ }
142822
+}
142823
+
142824
+/*
142825
+** Context object for last_value() window function.
142826
+*/
142827
+struct LastValueCtx {
142828
+ sqlite3_value *pVal;
142829
+ int nVal;
142830
+};
142831
+
142832
+/*
142833
+** Implementation of last_value().
142834
+*/
142835
+static void last_valueStepFunc(
142836
+ sqlite3_context *pCtx,
142837
+ int nArg,
142838
+ sqlite3_value **apArg
142839
+){
142840
+ struct LastValueCtx *p;
142841
+ UNUSED_PARAMETER(nArg);
142842
+ p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142843
+ if( p ){
142844
+ sqlite3_value_free(p->pVal);
142845
+ p->pVal = sqlite3_value_dup(apArg[0]);
142846
+ if( p->pVal==0 ){
142847
+ sqlite3_result_error_nomem(pCtx);
142848
+ }else{
142849
+ p->nVal++;
142850
+ }
142851
+ }
142852
+}
142853
+static void last_valueInvFunc(
142854
+ sqlite3_context *pCtx,
142855
+ int nArg,
142856
+ sqlite3_value **apArg
142857
+){
142858
+ struct LastValueCtx *p;
142859
+ UNUSED_PARAMETER(nArg);
142860
+ UNUSED_PARAMETER(apArg);
142861
+ p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142862
+ if( ALWAYS(p) ){
142863
+ p->nVal--;
142864
+ if( p->nVal==0 ){
142865
+ sqlite3_value_free(p->pVal);
142866
+ p->pVal = 0;
142867
+ }
142868
+ }
142869
+}
142870
+static void last_valueValueFunc(sqlite3_context *pCtx){
142871
+ struct LastValueCtx *p;
142872
+ p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142873
+ if( p && p->pVal ){
142874
+ sqlite3_result_value(pCtx, p->pVal);
142875
+ }
142876
+}
142877
+static void last_valueFinalizeFunc(sqlite3_context *pCtx){
142878
+ struct LastValueCtx *p;
142879
+ p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142880
+ if( p && p->pVal ){
142881
+ sqlite3_result_value(pCtx, p->pVal);
142882
+ sqlite3_value_free(p->pVal);
142883
+ p->pVal = 0;
142884
+ }
142885
+}
142886
+
142887
+/*
142888
+** Static names for the built-in window function names. These static
142889
+** names are used, rather than string literals, so that FuncDef objects
142890
+** can be associated with a particular window function by direct
142891
+** comparison of the zName pointer. Example:
142892
+**
142893
+** if( pFuncDef->zName==row_valueName ){ ... }
142894
+*/
142895
+static const char row_numberName[] = "row_number";
142896
+static const char dense_rankName[] = "dense_rank";
142897
+static const char rankName[] = "rank";
142898
+static const char percent_rankName[] = "percent_rank";
142899
+static const char cume_distName[] = "cume_dist";
142900
+static const char ntileName[] = "ntile";
142901
+static const char last_valueName[] = "last_value";
142902
+static const char nth_valueName[] = "nth_value";
142903
+static const char first_valueName[] = "first_value";
142904
+static const char leadName[] = "lead";
142905
+static const char lagName[] = "lag";
142906
+
142907
+/*
142908
+** No-op implementations of xStep() and xFinalize(). Used as place-holders
142909
+** for built-in window functions that never call those interfaces.
142910
+**
142911
+** The noopValueFunc() is called but is expected to do nothing. The
142912
+** noopStepFunc() is never called, and so it is marked with NO_TEST to
142913
+** let the test coverage routine know not to expect this function to be
142914
+** invoked.
142915
+*/
142916
+static void noopStepFunc( /*NO_TEST*/
142917
+ sqlite3_context *p, /*NO_TEST*/
142918
+ int n, /*NO_TEST*/
142919
+ sqlite3_value **a /*NO_TEST*/
142920
+){ /*NO_TEST*/
142921
+ UNUSED_PARAMETER(p); /*NO_TEST*/
142922
+ UNUSED_PARAMETER(n); /*NO_TEST*/
142923
+ UNUSED_PARAMETER(a); /*NO_TEST*/
142924
+ assert(0); /*NO_TEST*/
142925
+} /*NO_TEST*/
142926
+static void noopValueFunc(sqlite3_context *p){ UNUSED_PARAMETER(p); /*no-op*/ }
142927
+
142928
+/* Window functions that use all window interfaces: xStep, xFinal,
142929
+** xValue, and xInverse */
142930
+#define WINDOWFUNCALL(name,nArg,extra) { \
142931
+ nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \
142932
+ name ## StepFunc, name ## FinalizeFunc, name ## ValueFunc, \
142933
+ name ## InvFunc, name ## Name, {0} \
142934
+}
142935
+
142936
+/* Window functions that are implemented using bytecode and thus have
142937
+** no-op routines for their methods */
142938
+#define WINDOWFUNCNOOP(name,nArg,extra) { \
142939
+ nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \
142940
+ noopStepFunc, noopValueFunc, noopValueFunc, \
142941
+ noopStepFunc, name ## Name, {0} \
142942
+}
142943
+
142944
+/* Window functions that use all window interfaces: xStep, the
142945
+** same routine for xFinalize and xValue and which never call
142946
+** xInverse. */
142947
+#define WINDOWFUNCX(name,nArg,extra) { \
142948
+ nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \
142949
+ name ## StepFunc, name ## ValueFunc, name ## ValueFunc, \
142950
+ noopStepFunc, name ## Name, {0} \
142951
+}
142952
+
142953
+
142954
+/*
142955
+** Register those built-in window functions that are not also aggregates.
142956
+*/
142957
+SQLITE_PRIVATE void sqlite3WindowFunctions(void){
142958
+ static FuncDef aWindowFuncs[] = {
142959
+ WINDOWFUNCX(row_number, 0, 0),
142960
+ WINDOWFUNCX(dense_rank, 0, 0),
142961
+ WINDOWFUNCX(rank, 0, 0),
142962
+ WINDOWFUNCX(percent_rank, 0, SQLITE_FUNC_WINDOW_SIZE),
142963
+ WINDOWFUNCX(cume_dist, 0, SQLITE_FUNC_WINDOW_SIZE),
142964
+ WINDOWFUNCX(ntile, 1, SQLITE_FUNC_WINDOW_SIZE),
142965
+ WINDOWFUNCALL(last_value, 1, 0),
142966
+ WINDOWFUNCNOOP(nth_value, 2, 0),
142967
+ WINDOWFUNCNOOP(first_value, 1, 0),
142968
+ WINDOWFUNCNOOP(lead, 1, 0),
142969
+ WINDOWFUNCNOOP(lead, 2, 0),
142970
+ WINDOWFUNCNOOP(lead, 3, 0),
142971
+ WINDOWFUNCNOOP(lag, 1, 0),
142972
+ WINDOWFUNCNOOP(lag, 2, 0),
142973
+ WINDOWFUNCNOOP(lag, 3, 0),
142974
+ };
142975
+ sqlite3InsertBuiltinFuncs(aWindowFuncs, ArraySize(aWindowFuncs));
142976
+}
142977
+
142978
+/*
142979
+** This function is called immediately after resolving the function name
142980
+** for a window function within a SELECT statement. Argument pList is a
142981
+** linked list of WINDOW definitions for the current SELECT statement.
142982
+** Argument pFunc is the function definition just resolved and pWin
142983
+** is the Window object representing the associated OVER clause. This
142984
+** function updates the contents of pWin as follows:
142985
+**
142986
+** * If the OVER clause refered to a named window (as in "max(x) OVER win"),
142987
+** search list pList for a matching WINDOW definition, and update pWin
142988
+** accordingly. If no such WINDOW clause can be found, leave an error
142989
+** in pParse.
142990
+**
142991
+** * If the function is a built-in window function that requires the
142992
+** window to be coerced (see "BUILT-IN WINDOW FUNCTIONS" at the top
142993
+** of this file), pWin is updated here.
142994
+*/
142995
+SQLITE_PRIVATE void sqlite3WindowUpdate(
142996
+ Parse *pParse,
142997
+ Window *pList, /* List of named windows for this SELECT */
142998
+ Window *pWin, /* Window frame to update */
142999
+ FuncDef *pFunc /* Window function definition */
143000
+){
143001
+ if( pWin->zName && pWin->eType==0 ){
143002
+ Window *p;
143003
+ for(p=pList; p; p=p->pNextWin){
143004
+ if( sqlite3StrICmp(p->zName, pWin->zName)==0 ) break;
143005
+ }
143006
+ if( p==0 ){
143007
+ sqlite3ErrorMsg(pParse, "no such window: %s", pWin->zName);
143008
+ return;
143009
+ }
143010
+ pWin->pPartition = sqlite3ExprListDup(pParse->db, p->pPartition, 0);
143011
+ pWin->pOrderBy = sqlite3ExprListDup(pParse->db, p->pOrderBy, 0);
143012
+ pWin->pStart = sqlite3ExprDup(pParse->db, p->pStart, 0);
143013
+ pWin->pEnd = sqlite3ExprDup(pParse->db, p->pEnd, 0);
143014
+ pWin->eStart = p->eStart;
143015
+ pWin->eEnd = p->eEnd;
143016
+ pWin->eType = p->eType;
143017
+ }
143018
+ if( pFunc->funcFlags & SQLITE_FUNC_WINDOW ){
143019
+ sqlite3 *db = pParse->db;
143020
+ if( pWin->pFilter ){
143021
+ sqlite3ErrorMsg(pParse,
143022
+ "FILTER clause may only be used with aggregate window functions"
143023
+ );
143024
+ }else
143025
+ if( pFunc->zName==row_numberName || pFunc->zName==ntileName ){
143026
+ sqlite3ExprDelete(db, pWin->pStart);
143027
+ sqlite3ExprDelete(db, pWin->pEnd);
143028
+ pWin->pStart = pWin->pEnd = 0;
143029
+ pWin->eType = TK_ROWS;
143030
+ pWin->eStart = TK_UNBOUNDED;
143031
+ pWin->eEnd = TK_CURRENT;
143032
+ }else
143033
+
143034
+ if( pFunc->zName==dense_rankName || pFunc->zName==rankName
143035
+ || pFunc->zName==percent_rankName || pFunc->zName==cume_distName
143036
+ ){
143037
+ sqlite3ExprDelete(db, pWin->pStart);
143038
+ sqlite3ExprDelete(db, pWin->pEnd);
143039
+ pWin->pStart = pWin->pEnd = 0;
143040
+ pWin->eType = TK_RANGE;
143041
+ pWin->eStart = TK_UNBOUNDED;
143042
+ pWin->eEnd = TK_CURRENT;
143043
+ }
143044
+ }
143045
+ pWin->pFunc = pFunc;
143046
+}
143047
+
143048
+/*
143049
+** Context object passed through sqlite3WalkExprList() to
143050
+** selectWindowRewriteExprCb() by selectWindowRewriteEList().
143051
+*/
143052
+typedef struct WindowRewrite WindowRewrite;
143053
+struct WindowRewrite {
143054
+ Window *pWin;
143055
+ SrcList *pSrc;
143056
+ ExprList *pSub;
143057
+ Select *pSubSelect; /* Current sub-select, if any */
143058
+};
143059
+
143060
+/*
143061
+** Callback function used by selectWindowRewriteEList(). If necessary,
143062
+** this function appends to the output expression-list and updates
143063
+** expression (*ppExpr) in place.
143064
+*/
143065
+static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){
143066
+ struct WindowRewrite *p = pWalker->u.pRewrite;
143067
+ Parse *pParse = pWalker->pParse;
143068
+
143069
+ /* If this function is being called from within a scalar sub-select
143070
+ ** that used by the SELECT statement being processed, only process
143071
+ ** TK_COLUMN expressions that refer to it (the outer SELECT). Do
143072
+ ** not process aggregates or window functions at all, as they belong
143073
+ ** to the scalar sub-select. */
143074
+ if( p->pSubSelect ){
143075
+ if( pExpr->op!=TK_COLUMN ){
143076
+ return WRC_Continue;
143077
+ }else{
143078
+ int nSrc = p->pSrc->nSrc;
143079
+ int i;
143080
+ for(i=0; i<nSrc; i++){
143081
+ if( pExpr->iTable==p->pSrc->a[i].iCursor ) break;
143082
+ }
143083
+ if( i==nSrc ) return WRC_Continue;
143084
+ }
143085
+ }
143086
+
143087
+ switch( pExpr->op ){
143088
+
143089
+ case TK_FUNCTION:
143090
+ if( pExpr->pWin==0 ){
143091
+ break;
143092
+ }else{
143093
+ Window *pWin;
143094
+ for(pWin=p->pWin; pWin; pWin=pWin->pNextWin){
143095
+ if( pExpr->pWin==pWin ){
143096
+ assert( pWin->pOwner==pExpr );
143097
+ return WRC_Prune;
143098
+ }
143099
+ }
143100
+ }
143101
+ /* Fall through. */
143102
+
143103
+ case TK_AGG_FUNCTION:
143104
+ case TK_COLUMN: {
143105
+ Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0);
143106
+ p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup);
143107
+ if( p->pSub ){
143108
+ assert( ExprHasProperty(pExpr, EP_Static)==0 );
143109
+ ExprSetProperty(pExpr, EP_Static);
143110
+ sqlite3ExprDelete(pParse->db, pExpr);
143111
+ ExprClearProperty(pExpr, EP_Static);
143112
+ memset(pExpr, 0, sizeof(Expr));
143113
+
143114
+ pExpr->op = TK_COLUMN;
143115
+ pExpr->iColumn = p->pSub->nExpr-1;
143116
+ pExpr->iTable = p->pWin->iEphCsr;
143117
+ }
143118
+
143119
+ break;
143120
+ }
143121
+
143122
+ default: /* no-op */
143123
+ break;
143124
+ }
143125
+
143126
+ return WRC_Continue;
143127
+}
143128
+static int selectWindowRewriteSelectCb(Walker *pWalker, Select *pSelect){
143129
+ struct WindowRewrite *p = pWalker->u.pRewrite;
143130
+ Select *pSave = p->pSubSelect;
143131
+ if( pSave==pSelect ){
143132
+ return WRC_Continue;
143133
+ }else{
143134
+ p->pSubSelect = pSelect;
143135
+ sqlite3WalkSelect(pWalker, pSelect);
143136
+ p->pSubSelect = pSave;
143137
+ }
143138
+ return WRC_Prune;
143139
+}
143140
+
143141
+
143142
+/*
143143
+** Iterate through each expression in expression-list pEList. For each:
143144
+**
143145
+** * TK_COLUMN,
143146
+** * aggregate function, or
143147
+** * window function with a Window object that is not a member of the
143148
+** Window list passed as the second argument (pWin).
143149
+**
143150
+** Append the node to output expression-list (*ppSub). And replace it
143151
+** with a TK_COLUMN that reads the (N-1)th element of table
143152
+** pWin->iEphCsr, where N is the number of elements in (*ppSub) after
143153
+** appending the new one.
143154
+*/
143155
+static void selectWindowRewriteEList(
143156
+ Parse *pParse,
143157
+ Window *pWin,
143158
+ SrcList *pSrc,
143159
+ ExprList *pEList, /* Rewrite expressions in this list */
143160
+ ExprList **ppSub /* IN/OUT: Sub-select expression-list */
143161
+){
143162
+ Walker sWalker;
143163
+ WindowRewrite sRewrite;
143164
+
143165
+ memset(&sWalker, 0, sizeof(Walker));
143166
+ memset(&sRewrite, 0, sizeof(WindowRewrite));
143167
+
143168
+ sRewrite.pSub = *ppSub;
143169
+ sRewrite.pWin = pWin;
143170
+ sRewrite.pSrc = pSrc;
143171
+
143172
+ sWalker.pParse = pParse;
143173
+ sWalker.xExprCallback = selectWindowRewriteExprCb;
143174
+ sWalker.xSelectCallback = selectWindowRewriteSelectCb;
143175
+ sWalker.u.pRewrite = &sRewrite;
143176
+
143177
+ (void)sqlite3WalkExprList(&sWalker, pEList);
143178
+
143179
+ *ppSub = sRewrite.pSub;
143180
+}
143181
+
143182
+/*
143183
+** Append a copy of each expression in expression-list pAppend to
143184
+** expression list pList. Return a pointer to the result list.
143185
+*/
143186
+static ExprList *exprListAppendList(
143187
+ Parse *pParse, /* Parsing context */
143188
+ ExprList *pList, /* List to which to append. Might be NULL */
143189
+ ExprList *pAppend /* List of values to append. Might be NULL */
143190
+){
143191
+ if( pAppend ){
143192
+ int i;
143193
+ int nInit = pList ? pList->nExpr : 0;
143194
+ for(i=0; i<pAppend->nExpr; i++){
143195
+ Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);
143196
+ pList = sqlite3ExprListAppend(pParse, pList, pDup);
143197
+ if( pList ) pList->a[nInit+i].sortOrder = pAppend->a[i].sortOrder;
143198
+ }
143199
+ }
143200
+ return pList;
143201
+}
143202
+
143203
+/*
143204
+** If the SELECT statement passed as the second argument does not invoke
143205
+** any SQL window functions, this function is a no-op. Otherwise, it
143206
+** rewrites the SELECT statement so that window function xStep functions
143207
+** are invoked in the correct order as described under "SELECT REWRITING"
143208
+** at the top of this file.
143209
+*/
143210
+SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
143211
+ int rc = SQLITE_OK;
143212
+ if( p->pWin ){
143213
+ Vdbe *v = sqlite3GetVdbe(pParse);
143214
+ sqlite3 *db = pParse->db;
143215
+ Select *pSub = 0; /* The subquery */
143216
+ SrcList *pSrc = p->pSrc;
143217
+ Expr *pWhere = p->pWhere;
143218
+ ExprList *pGroupBy = p->pGroupBy;
143219
+ Expr *pHaving = p->pHaving;
143220
+ ExprList *pSort = 0;
143221
+
143222
+ ExprList *pSublist = 0; /* Expression list for sub-query */
143223
+ Window *pMWin = p->pWin; /* Master window object */
143224
+ Window *pWin; /* Window object iterator */
143225
+
143226
+ p->pSrc = 0;
143227
+ p->pWhere = 0;
143228
+ p->pGroupBy = 0;
143229
+ p->pHaving = 0;
143230
+
143231
+ /* Create the ORDER BY clause for the sub-select. This is the concatenation
143232
+ ** of the window PARTITION and ORDER BY clauses. Then, if this makes it
143233
+ ** redundant, remove the ORDER BY from the parent SELECT. */
143234
+ pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);
143235
+ pSort = exprListAppendList(pParse, pSort, pMWin->pOrderBy);
143236
+ if( pSort && p->pOrderBy ){
143237
+ if( sqlite3ExprListCompare(pSort, p->pOrderBy, -1)==0 ){
143238
+ sqlite3ExprListDelete(db, p->pOrderBy);
143239
+ p->pOrderBy = 0;
143240
+ }
143241
+ }
143242
+
143243
+ /* Assign a cursor number for the ephemeral table used to buffer rows.
143244
+ ** The OpenEphemeral instruction is coded later, after it is known how
143245
+ ** many columns the table will have. */
143246
+ pMWin->iEphCsr = pParse->nTab++;
143247
+
143248
+ selectWindowRewriteEList(pParse, pMWin, pSrc, p->pEList, &pSublist);
143249
+ selectWindowRewriteEList(pParse, pMWin, pSrc, p->pOrderBy, &pSublist);
143250
+ pMWin->nBufferCol = (pSublist ? pSublist->nExpr : 0);
143251
+
143252
+ /* Append the PARTITION BY and ORDER BY expressions to the to the
143253
+ ** sub-select expression list. They are required to figure out where
143254
+ ** boundaries for partitions and sets of peer rows lie. */
143255
+ pSublist = exprListAppendList(pParse, pSublist, pMWin->pPartition);
143256
+ pSublist = exprListAppendList(pParse, pSublist, pMWin->pOrderBy);
143257
+
143258
+ /* Append the arguments passed to each window function to the
143259
+ ** sub-select expression list. Also allocate two registers for each
143260
+ ** window function - one for the accumulator, another for interim
143261
+ ** results. */
143262
+ for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143263
+ pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);
143264
+ pSublist = exprListAppendList(pParse, pSublist, pWin->pOwner->x.pList);
143265
+ if( pWin->pFilter ){
143266
+ Expr *pFilter = sqlite3ExprDup(db, pWin->pFilter, 0);
143267
+ pSublist = sqlite3ExprListAppend(pParse, pSublist, pFilter);
143268
+ }
143269
+ pWin->regAccum = ++pParse->nMem;
143270
+ pWin->regResult = ++pParse->nMem;
143271
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
143272
+ }
143273
+
143274
+ /* If there is no ORDER BY or PARTITION BY clause, and the window
143275
+ ** function accepts zero arguments, and there are no other columns
143276
+ ** selected (e.g. "SELECT row_number() OVER () FROM t1"), it is possible
143277
+ ** that pSublist is still NULL here. Add a constant expression here to
143278
+ ** keep everything legal in this case.
143279
+ */
143280
+ if( pSublist==0 ){
143281
+ pSublist = sqlite3ExprListAppend(pParse, 0,
143282
+ sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0)
143283
+ );
143284
+ }
143285
+
143286
+ pSub = sqlite3SelectNew(
143287
+ pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0
143288
+ );
143289
+ p->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
143290
+ assert( p->pSrc || db->mallocFailed );
143291
+ if( p->pSrc ){
143292
+ p->pSrc->a[0].pSelect = pSub;
143293
+ sqlite3SrcListAssignCursors(pParse, p->pSrc);
143294
+ if( sqlite3ExpandSubquery(pParse, &p->pSrc->a[0]) ){
143295
+ rc = SQLITE_NOMEM;
143296
+ }else{
143297
+ pSub->selFlags |= SF_Expanded;
143298
+ p->selFlags &= ~SF_Aggregate;
143299
+ sqlite3SelectPrep(pParse, pSub, 0);
143300
+ }
143301
+
143302
+ sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, pSublist->nExpr);
143303
+ }else{
143304
+ sqlite3SelectDelete(db, pSub);
143305
+ }
143306
+ if( db->mallocFailed ) rc = SQLITE_NOMEM;
143307
+ }
143308
+
143309
+ return rc;
143310
+}
143311
+
143312
+/*
143313
+** Free the Window object passed as the second argument.
143314
+*/
143315
+SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3 *db, Window *p){
143316
+ if( p ){
143317
+ sqlite3ExprDelete(db, p->pFilter);
143318
+ sqlite3ExprListDelete(db, p->pPartition);
143319
+ sqlite3ExprListDelete(db, p->pOrderBy);
143320
+ sqlite3ExprDelete(db, p->pEnd);
143321
+ sqlite3ExprDelete(db, p->pStart);
143322
+ sqlite3DbFree(db, p->zName);
143323
+ sqlite3DbFree(db, p);
143324
+ }
143325
+}
143326
+
143327
+/*
143328
+** Free the linked list of Window objects starting at the second argument.
143329
+*/
143330
+SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p){
143331
+ while( p ){
143332
+ Window *pNext = p->pNextWin;
143333
+ sqlite3WindowDelete(db, p);
143334
+ p = pNext;
143335
+ }
143336
+}
143337
+
143338
+/*
143339
+** The argument expression is an PRECEDING or FOLLOWING offset. The
143340
+** value should be a non-negative integer. If the value is not a
143341
+** constant, change it to NULL. The fact that it is then a non-negative
143342
+** integer will be caught later. But it is important not to leave
143343
+** variable values in the expression tree.
143344
+*/
143345
+static Expr *sqlite3WindowOffsetExpr(Parse *pParse, Expr *pExpr){
143346
+ if( 0==sqlite3ExprIsConstant(pExpr) ){
143347
+ sqlite3ExprDelete(pParse->db, pExpr);
143348
+ pExpr = sqlite3ExprAlloc(pParse->db, TK_NULL, 0, 0);
143349
+ }
143350
+ return pExpr;
143351
+}
143352
+
143353
+/*
143354
+** Allocate and return a new Window object describing a Window Definition.
143355
+*/
143356
+SQLITE_PRIVATE Window *sqlite3WindowAlloc(
143357
+ Parse *pParse, /* Parsing context */
143358
+ int eType, /* Frame type. TK_RANGE or TK_ROWS */
143359
+ int eStart, /* Start type: CURRENT, PRECEDING, FOLLOWING, UNBOUNDED */
143360
+ Expr *pStart, /* Start window size if TK_PRECEDING or FOLLOWING */
143361
+ int eEnd, /* End type: CURRENT, FOLLOWING, TK_UNBOUNDED, PRECEDING */
143362
+ Expr *pEnd /* End window size if TK_FOLLOWING or PRECEDING */
143363
+){
143364
+ Window *pWin = 0;
143365
+
143366
+ /* Parser assures the following: */
143367
+ assert( eType==TK_RANGE || eType==TK_ROWS );
143368
+ assert( eStart==TK_CURRENT || eStart==TK_PRECEDING
143369
+ || eStart==TK_UNBOUNDED || eStart==TK_FOLLOWING );
143370
+ assert( eEnd==TK_CURRENT || eEnd==TK_FOLLOWING
143371
+ || eEnd==TK_UNBOUNDED || eEnd==TK_PRECEDING );
143372
+ assert( (eStart==TK_PRECEDING || eStart==TK_FOLLOWING)==(pStart!=0) );
143373
+ assert( (eEnd==TK_FOLLOWING || eEnd==TK_PRECEDING)==(pEnd!=0) );
143374
+
143375
+
143376
+ /* If a frame is declared "RANGE" (not "ROWS"), then it may not use
143377
+ ** either "<expr> PRECEDING" or "<expr> FOLLOWING".
143378
+ */
143379
+ if( eType==TK_RANGE && (pStart!=0 || pEnd!=0) ){
143380
+ sqlite3ErrorMsg(pParse, "RANGE must use only UNBOUNDED or CURRENT ROW");
143381
+ goto windowAllocErr;
143382
+ }
143383
+
143384
+ /* Additionally, the
143385
+ ** starting boundary type may not occur earlier in the following list than
143386
+ ** the ending boundary type:
143387
+ **
143388
+ ** UNBOUNDED PRECEDING
143389
+ ** <expr> PRECEDING
143390
+ ** CURRENT ROW
143391
+ ** <expr> FOLLOWING
143392
+ ** UNBOUNDED FOLLOWING
143393
+ **
143394
+ ** The parser ensures that "UNBOUNDED PRECEDING" cannot be used as an ending
143395
+ ** boundary, and than "UNBOUNDED FOLLOWING" cannot be used as a starting
143396
+ ** frame boundary.
143397
+ */
143398
+ if( (eStart==TK_CURRENT && eEnd==TK_PRECEDING)
143399
+ || (eStart==TK_FOLLOWING && (eEnd==TK_PRECEDING || eEnd==TK_CURRENT))
143400
+ ){
143401
+ sqlite3ErrorMsg(pParse, "unsupported frame delimiter for ROWS");
143402
+ goto windowAllocErr;
143403
+ }
143404
+
143405
+ pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
143406
+ if( pWin==0 ) goto windowAllocErr;
143407
+ pWin->eType = eType;
143408
+ pWin->eStart = eStart;
143409
+ pWin->eEnd = eEnd;
143410
+ pWin->pEnd = sqlite3WindowOffsetExpr(pParse, pEnd);
143411
+ pWin->pStart = sqlite3WindowOffsetExpr(pParse, pStart);
143412
+ return pWin;
143413
+
143414
+windowAllocErr:
143415
+ sqlite3ExprDelete(pParse->db, pEnd);
143416
+ sqlite3ExprDelete(pParse->db, pStart);
143417
+ return 0;
143418
+}
143419
+
143420
+/*
143421
+** Attach window object pWin to expression p.
143422
+*/
143423
+SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
143424
+ if( p ){
143425
+ if( pWin ){
143426
+ p->pWin = pWin;
143427
+ pWin->pOwner = p;
143428
+ if( p->flags & EP_Distinct ){
143429
+ sqlite3ErrorMsg(pParse,
143430
+ "DISTINCT is not supported for window functions");
143431
+ }
143432
+ }
143433
+ }else{
143434
+ sqlite3WindowDelete(pParse->db, pWin);
143435
+ }
143436
+}
143437
+
143438
+/*
143439
+** Return 0 if the two window objects are identical, or non-zero otherwise.
143440
+** Identical window objects can be processed in a single scan.
143441
+*/
143442
+SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2){
143443
+ if( p1->eType!=p2->eType ) return 1;
143444
+ if( p1->eStart!=p2->eStart ) return 1;
143445
+ if( p1->eEnd!=p2->eEnd ) return 1;
143446
+ if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
143447
+ if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1;
143448
+ if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1;
143449
+ if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1;
143450
+ return 0;
143451
+}
143452
+
143453
+
143454
+/*
143455
+** This is called by code in select.c before it calls sqlite3WhereBegin()
143456
+** to begin iterating through the sub-query results. It is used to allocate
143457
+** and initialize registers and cursors used by sqlite3WindowCodeStep().
143458
+*/
143459
+SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse *pParse, Window *pMWin){
143460
+ Window *pWin;
143461
+ Vdbe *v = sqlite3GetVdbe(pParse);
143462
+ int nPart = (pMWin->pPartition ? pMWin->pPartition->nExpr : 0);
143463
+ nPart += (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
143464
+ if( nPart ){
143465
+ pMWin->regPart = pParse->nMem+1;
143466
+ pParse->nMem += nPart;
143467
+ sqlite3VdbeAddOp3(v, OP_Null, 0, pMWin->regPart, pMWin->regPart+nPart-1);
143468
+ }
143469
+
143470
+ for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143471
+ FuncDef *p = pWin->pFunc;
143472
+ if( (p->funcFlags & SQLITE_FUNC_MINMAX) && pWin->eStart!=TK_UNBOUNDED ){
143473
+ /* The inline versions of min() and max() require a single ephemeral
143474
+ ** table and 3 registers. The registers are used as follows:
143475
+ **
143476
+ ** regApp+0: slot to copy min()/max() argument to for MakeRecord
143477
+ ** regApp+1: integer value used to ensure keys are unique
143478
+ ** regApp+2: output of MakeRecord
143479
+ */
143480
+ ExprList *pList = pWin->pOwner->x.pList;
143481
+ KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0);
143482
+ pWin->csrApp = pParse->nTab++;
143483
+ pWin->regApp = pParse->nMem+1;
143484
+ pParse->nMem += 3;
143485
+ if( pKeyInfo && pWin->pFunc->zName[1]=='i' ){
143486
+ assert( pKeyInfo->aSortOrder[0]==0 );
143487
+ pKeyInfo->aSortOrder[0] = 1;
143488
+ }
143489
+ sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2);
143490
+ sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);
143491
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
143492
+ }
143493
+ else if( p->zName==nth_valueName || p->zName==first_valueName ){
143494
+ /* Allocate two registers at pWin->regApp. These will be used to
143495
+ ** store the start and end index of the current frame. */
143496
+ assert( pMWin->iEphCsr );
143497
+ pWin->regApp = pParse->nMem+1;
143498
+ pWin->csrApp = pParse->nTab++;
143499
+ pParse->nMem += 2;
143500
+ sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
143501
+ }
143502
+ else if( p->zName==leadName || p->zName==lagName ){
143503
+ assert( pMWin->iEphCsr );
143504
+ pWin->csrApp = pParse->nTab++;
143505
+ sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
143506
+ }
143507
+ }
143508
+}
143509
+
143510
+/*
143511
+** A "PRECEDING <expr>" (eCond==0) or "FOLLOWING <expr>" (eCond==1) or the
143512
+** value of the second argument to nth_value() (eCond==2) has just been
143513
+** evaluated and the result left in register reg. This function generates VM
143514
+** code to check that the value is a non-negative integer and throws an
143515
+** exception if it is not.
143516
+*/
143517
+static void windowCheckIntValue(Parse *pParse, int reg, int eCond){
143518
+ static const char *azErr[] = {
143519
+ "frame starting offset must be a non-negative integer",
143520
+ "frame ending offset must be a non-negative integer",
143521
+ "second argument to nth_value must be a positive integer"
143522
+ };
143523
+ static int aOp[] = { OP_Ge, OP_Ge, OP_Gt };
143524
+ Vdbe *v = sqlite3GetVdbe(pParse);
143525
+ int regZero = sqlite3GetTempReg(pParse);
143526
+ assert( eCond==0 || eCond==1 || eCond==2 );
143527
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, regZero);
143528
+ sqlite3VdbeAddOp2(v, OP_MustBeInt, reg, sqlite3VdbeCurrentAddr(v)+2);
143529
+ VdbeCoverageIf(v, eCond==0);
143530
+ VdbeCoverageIf(v, eCond==1);
143531
+ VdbeCoverageIf(v, eCond==2);
143532
+ sqlite3VdbeAddOp3(v, aOp[eCond], regZero, sqlite3VdbeCurrentAddr(v)+2, reg);
143533
+ VdbeCoverageNeverNullIf(v, eCond==0);
143534
+ VdbeCoverageNeverNullIf(v, eCond==1);
143535
+ VdbeCoverageNeverNullIf(v, eCond==2);
143536
+ sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_ERROR, OE_Abort);
143537
+ sqlite3VdbeAppendP4(v, (void*)azErr[eCond], P4_STATIC);
143538
+ sqlite3ReleaseTempReg(pParse, regZero);
143539
+}
143540
+
143541
+/*
143542
+** Return the number of arguments passed to the window-function associated
143543
+** with the object passed as the only argument to this function.
143544
+*/
143545
+static int windowArgCount(Window *pWin){
143546
+ ExprList *pList = pWin->pOwner->x.pList;
143547
+ return (pList ? pList->nExpr : 0);
143548
+}
143549
+
143550
+/*
143551
+** Generate VM code to invoke either xStep() (if bInverse is 0) or
143552
+** xInverse (if bInverse is non-zero) for each window function in the
143553
+** linked list starting at pMWin. Or, for built-in window functions
143554
+** that do not use the standard function API, generate the required
143555
+** inline VM code.
143556
+**
143557
+** If argument csr is greater than or equal to 0, then argument reg is
143558
+** the first register in an array of registers guaranteed to be large
143559
+** enough to hold the array of arguments for each function. In this case
143560
+** the arguments are extracted from the current row of csr into the
143561
+** array of registers before invoking OP_AggStep or OP_AggInverse
143562
+**
143563
+** Or, if csr is less than zero, then the array of registers at reg is
143564
+** already populated with all columns from the current row of the sub-query.
143565
+**
143566
+** If argument regPartSize is non-zero, then it is a register containing the
143567
+** number of rows in the current partition.
143568
+*/
143569
+static void windowAggStep(
143570
+ Parse *pParse,
143571
+ Window *pMWin, /* Linked list of window functions */
143572
+ int csr, /* Read arguments from this cursor */
143573
+ int bInverse, /* True to invoke xInverse instead of xStep */
143574
+ int reg, /* Array of registers */
143575
+ int regPartSize /* Register containing size of partition */
143576
+){
143577
+ Vdbe *v = sqlite3GetVdbe(pParse);
143578
+ Window *pWin;
143579
+ for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143580
+ int flags = pWin->pFunc->funcFlags;
143581
+ int regArg;
143582
+ int nArg = windowArgCount(pWin);
143583
+
143584
+ if( csr>=0 ){
143585
+ int i;
143586
+ for(i=0; i<nArg; i++){
143587
+ sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
143588
+ }
143589
+ regArg = reg;
143590
+ if( flags & SQLITE_FUNC_WINDOW_SIZE ){
143591
+ if( nArg==0 ){
143592
+ regArg = regPartSize;
143593
+ }else{
143594
+ sqlite3VdbeAddOp2(v, OP_SCopy, regPartSize, reg+nArg);
143595
+ }
143596
+ nArg++;
143597
+ }
143598
+ }else{
143599
+ assert( !(flags & SQLITE_FUNC_WINDOW_SIZE) );
143600
+ regArg = reg + pWin->iArgCol;
143601
+ }
143602
+
143603
+ if( (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
143604
+ && pWin->eStart!=TK_UNBOUNDED
143605
+ ){
143606
+ int addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regArg);
143607
+ VdbeCoverage(v);
143608
+ if( bInverse==0 ){
143609
+ sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1, 1);
143610
+ sqlite3VdbeAddOp2(v, OP_SCopy, regArg, pWin->regApp);
143611
+ sqlite3VdbeAddOp3(v, OP_MakeRecord, pWin->regApp, 2, pWin->regApp+2);
143612
+ sqlite3VdbeAddOp2(v, OP_IdxInsert, pWin->csrApp, pWin->regApp+2);
143613
+ }else{
143614
+ sqlite3VdbeAddOp4Int(v, OP_SeekGE, pWin->csrApp, 0, regArg, 1);
143615
+ VdbeCoverageNeverTaken(v);
143616
+ sqlite3VdbeAddOp1(v, OP_Delete, pWin->csrApp);
143617
+ sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
143618
+ }
143619
+ sqlite3VdbeJumpHere(v, addrIsNull);
143620
+ }else if( pWin->regApp ){
143621
+ assert( pWin->pFunc->zName==nth_valueName
143622
+ || pWin->pFunc->zName==first_valueName
143623
+ );
143624
+ assert( bInverse==0 || bInverse==1 );
143625
+ sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1);
143626
+ }else if( pWin->pFunc->zName==leadName
143627
+ || pWin->pFunc->zName==lagName
143628
+ ){
143629
+ /* no-op */
143630
+ }else{
143631
+ int addrIf = 0;
143632
+ if( pWin->pFilter ){
143633
+ int regTmp;
143634
+ assert( nArg==0 || nArg==pWin->pOwner->x.pList->nExpr );
143635
+ assert( nArg || pWin->pOwner->x.pList==0 );
143636
+ if( csr>0 ){
143637
+ regTmp = sqlite3GetTempReg(pParse);
143638
+ sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp);
143639
+ }else{
143640
+ regTmp = regArg + nArg;
143641
+ }
143642
+ addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1);
143643
+ VdbeCoverage(v);
143644
+ if( csr>0 ){
143645
+ sqlite3ReleaseTempReg(pParse, regTmp);
143646
+ }
143647
+ }
143648
+ if( pWin->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
143649
+ CollSeq *pColl;
143650
+ assert( nArg>0 );
143651
+ pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr);
143652
+ sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
143653
+ }
143654
+ sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep,
143655
+ bInverse, regArg, pWin->regAccum);
143656
+ sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
143657
+ sqlite3VdbeChangeP5(v, (u8)nArg);
143658
+ if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
143659
+ }
143660
+ }
143661
+}
143662
+
143663
+/*
143664
+** Generate VM code to invoke either xValue() (bFinal==0) or xFinalize()
143665
+** (bFinal==1) for each window function in the linked list starting at
143666
+** pMWin. Or, for built-in window-functions that do not use the standard
143667
+** API, generate the equivalent VM code.
143668
+*/
143669
+static void windowAggFinal(Parse *pParse, Window *pMWin, int bFinal){
143670
+ Vdbe *v = sqlite3GetVdbe(pParse);
143671
+ Window *pWin;
143672
+
143673
+ for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143674
+ if( (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
143675
+ && pWin->eStart!=TK_UNBOUNDED
143676
+ ){
143677
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
143678
+ sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);
143679
+ VdbeCoverage(v);
143680
+ sqlite3VdbeAddOp3(v, OP_Column, pWin->csrApp, 0, pWin->regResult);
143681
+ sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
143682
+ if( bFinal ){
143683
+ sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);
143684
+ }
143685
+ }else if( pWin->regApp ){
143686
+ }else{
143687
+ if( bFinal ){
143688
+ sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, windowArgCount(pWin));
143689
+ sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
143690
+ sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
143691
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
143692
+ }else{
143693
+ sqlite3VdbeAddOp3(v, OP_AggValue, pWin->regAccum, windowArgCount(pWin),
143694
+ pWin->regResult);
143695
+ sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
143696
+ }
143697
+ }
143698
+ }
143699
+}
143700
+
143701
+/*
143702
+** This function generates VM code to invoke the sub-routine at address
143703
+** lblFlushPart once for each partition with the entire partition cached in
143704
+** the Window.iEphCsr temp table.
143705
+*/
143706
+static void windowPartitionCache(
143707
+ Parse *pParse,
143708
+ Select *p, /* The rewritten SELECT statement */
143709
+ WhereInfo *pWInfo, /* WhereInfo to call WhereEnd() on */
143710
+ int regFlushPart, /* Register to use with Gosub lblFlushPart */
143711
+ int lblFlushPart, /* Subroutine to Gosub to */
143712
+ int *pRegSize /* OUT: Register containing partition size */
143713
+){
143714
+ Window *pMWin = p->pWin;
143715
+ Vdbe *v = sqlite3GetVdbe(pParse);
143716
+ int iSubCsr = p->pSrc->a[0].iCursor;
143717
+ int nSub = p->pSrc->a[0].pTab->nCol;
143718
+ int k;
143719
+
143720
+ int reg = pParse->nMem+1;
143721
+ int regRecord = reg+nSub;
143722
+ int regRowid = regRecord+1;
143723
+
143724
+ *pRegSize = regRowid;
143725
+ pParse->nMem += nSub + 2;
143726
+
143727
+ /* Load the column values for the row returned by the sub-select
143728
+ ** into an array of registers starting at reg. */
143729
+ for(k=0; k<nSub; k++){
143730
+ sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
143731
+ }
143732
+ sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, nSub, regRecord);
143733
+
143734
+ /* Check if this is the start of a new partition. If so, call the
143735
+ ** flush_partition sub-routine. */
143736
+ if( pMWin->pPartition ){
143737
+ int addr;
143738
+ ExprList *pPart = pMWin->pPartition;
143739
+ int nPart = pPart->nExpr;
143740
+ int regNewPart = reg + pMWin->nBufferCol;
143741
+ KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
143742
+
143743
+ addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);
143744
+ sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
143745
+ sqlite3VdbeAddOp3(v, OP_Jump, addr+2, addr+4, addr+2);
143746
+ VdbeCoverageEqNe(v);
143747
+ sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);
143748
+ sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
143749
+ VdbeComment((v, "call flush_partition"));
143750
+ }
143751
+
143752
+ /* Buffer the current row in the ephemeral table. */
143753
+ sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
143754
+ sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);
143755
+
143756
+ /* End of the input loop */
143757
+ sqlite3WhereEnd(pWInfo);
143758
+
143759
+ /* Invoke "flush_partition" to deal with the final (or only) partition */
143760
+ sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
143761
+ VdbeComment((v, "call flush_partition"));
143762
+}
143763
+
143764
+/*
143765
+** Invoke the sub-routine at regGosub (generated by code in select.c) to
143766
+** return the current row of Window.iEphCsr. If all window functions are
143767
+** aggregate window functions that use the standard API, a single
143768
+** OP_Gosub instruction is all that this routine generates. Extra VM code
143769
+** for per-row processing is only generated for the following built-in window
143770
+** functions:
143771
+**
143772
+** nth_value()
143773
+** first_value()
143774
+** lag()
143775
+** lead()
143776
+*/
143777
+static void windowReturnOneRow(
143778
+ Parse *pParse,
143779
+ Window *pMWin,
143780
+ int regGosub,
143781
+ int addrGosub
143782
+){
143783
+ Vdbe *v = sqlite3GetVdbe(pParse);
143784
+ Window *pWin;
143785
+ for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143786
+ FuncDef *pFunc = pWin->pFunc;
143787
+ if( pFunc->zName==nth_valueName
143788
+ || pFunc->zName==first_valueName
143789
+ ){
143790
+ int csr = pWin->csrApp;
143791
+ int lbl = sqlite3VdbeMakeLabel(v);
143792
+ int tmpReg = sqlite3GetTempReg(pParse);
143793
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
143794
+
143795
+ if( pFunc->zName==nth_valueName ){
143796
+ sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+1,tmpReg);
143797
+ windowCheckIntValue(pParse, tmpReg, 2);
143798
+ }else{
143799
+ sqlite3VdbeAddOp2(v, OP_Integer, 1, tmpReg);
143800
+ }
143801
+ sqlite3VdbeAddOp3(v, OP_Add, tmpReg, pWin->regApp, tmpReg);
143802
+ sqlite3VdbeAddOp3(v, OP_Gt, pWin->regApp+1, lbl, tmpReg);
143803
+ VdbeCoverageNeverNull(v);
143804
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, 0, tmpReg);
143805
+ VdbeCoverageNeverTaken(v);
143806
+ sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
143807
+ sqlite3VdbeResolveLabel(v, lbl);
143808
+ sqlite3ReleaseTempReg(pParse, tmpReg);
143809
+ }
143810
+ else if( pFunc->zName==leadName || pFunc->zName==lagName ){
143811
+ int nArg = pWin->pOwner->x.pList->nExpr;
143812
+ int iEph = pMWin->iEphCsr;
143813
+ int csr = pWin->csrApp;
143814
+ int lbl = sqlite3VdbeMakeLabel(v);
143815
+ int tmpReg = sqlite3GetTempReg(pParse);
143816
+
143817
+ if( nArg<3 ){
143818
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
143819
+ }else{
143820
+ sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+2, pWin->regResult);
143821
+ }
143822
+ sqlite3VdbeAddOp2(v, OP_Rowid, iEph, tmpReg);
143823
+ if( nArg<2 ){
143824
+ int val = (pFunc->zName==leadName ? 1 : -1);
143825
+ sqlite3VdbeAddOp2(v, OP_AddImm, tmpReg, val);
143826
+ }else{
143827
+ int op = (pFunc->zName==leadName ? OP_Add : OP_Subtract);
143828
+ int tmpReg2 = sqlite3GetTempReg(pParse);
143829
+ sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+1, tmpReg2);
143830
+ sqlite3VdbeAddOp3(v, op, tmpReg2, tmpReg, tmpReg);
143831
+ sqlite3ReleaseTempReg(pParse, tmpReg2);
143832
+ }
143833
+
143834
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, lbl, tmpReg);
143835
+ VdbeCoverage(v);
143836
+ sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
143837
+ sqlite3VdbeResolveLabel(v, lbl);
143838
+ sqlite3ReleaseTempReg(pParse, tmpReg);
143839
+ }
143840
+ }
143841
+ sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
143842
+}
143843
+
143844
+/*
143845
+** Invoke the code generated by windowReturnOneRow() and, optionally, the
143846
+** xInverse() function for each window function, for one or more rows
143847
+** from the Window.iEphCsr temp table. This routine generates VM code
143848
+** similar to:
143849
+**
143850
+** while( regCtr>0 ){
143851
+** regCtr--;
143852
+** windowReturnOneRow()
143853
+** if( bInverse ){
143854
+** AggInverse
143855
+** }
143856
+** Next (Window.iEphCsr)
143857
+** }
143858
+*/
143859
+static void windowReturnRows(
143860
+ Parse *pParse,
143861
+ Window *pMWin, /* List of window functions */
143862
+ int regCtr, /* Register containing number of rows */
143863
+ int regGosub, /* Register for Gosub addrGosub */
143864
+ int addrGosub, /* Address of sub-routine for ReturnOneRow */
143865
+ int regInvArg, /* Array of registers for xInverse args */
143866
+ int regInvSize /* Register containing size of partition */
143867
+){
143868
+ int addr;
143869
+ Vdbe *v = sqlite3GetVdbe(pParse);
143870
+ windowAggFinal(pParse, pMWin, 0);
143871
+ addr = sqlite3VdbeAddOp3(v, OP_IfPos, regCtr, sqlite3VdbeCurrentAddr(v)+2 ,1);
143872
+ VdbeCoverage(v);
143873
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, 0);
143874
+ windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);
143875
+ if( regInvArg ){
143876
+ windowAggStep(pParse, pMWin, pMWin->iEphCsr, 1, regInvArg, regInvSize);
143877
+ }
143878
+ sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, addr);
143879
+ VdbeCoverage(v);
143880
+ sqlite3VdbeJumpHere(v, addr+1); /* The OP_Goto */
143881
+}
143882
+
143883
+/*
143884
+** Generate code to set the accumulator register for each window function
143885
+** in the linked list passed as the second argument to NULL. And perform
143886
+** any equivalent initialization required by any built-in window functions
143887
+** in the list.
143888
+*/
143889
+static int windowInitAccum(Parse *pParse, Window *pMWin){
143890
+ Vdbe *v = sqlite3GetVdbe(pParse);
143891
+ int regArg;
143892
+ int nArg = 0;
143893
+ Window *pWin;
143894
+ for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143895
+ FuncDef *pFunc = pWin->pFunc;
143896
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
143897
+ nArg = MAX(nArg, windowArgCount(pWin));
143898
+ if( pFunc->zName==nth_valueName
143899
+ || pFunc->zName==first_valueName
143900
+ ){
143901
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp);
143902
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
143903
+ }
143904
+
143905
+ if( (pFunc->funcFlags & SQLITE_FUNC_MINMAX) && pWin->csrApp ){
143906
+ assert( pWin->eStart!=TK_UNBOUNDED );
143907
+ sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);
143908
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
143909
+ }
143910
+ }
143911
+ regArg = pParse->nMem+1;
143912
+ pParse->nMem += nArg;
143913
+ return regArg;
143914
+}
143915
+
143916
+
143917
+/*
143918
+** This function does the work of sqlite3WindowCodeStep() for all "ROWS"
143919
+** window frame types except for "BETWEEN UNBOUNDED PRECEDING AND CURRENT
143920
+** ROW". Pseudo-code for each follows.
143921
+**
143922
+** ROWS BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING
143923
+**
143924
+** ...
143925
+** if( new partition ){
143926
+** Gosub flush_partition
143927
+** }
143928
+** Insert (record in eph-table)
143929
+** sqlite3WhereEnd()
143930
+** Gosub flush_partition
143931
+**
143932
+** flush_partition:
143933
+** Once {
143934
+** OpenDup (iEphCsr -> csrStart)
143935
+** OpenDup (iEphCsr -> csrEnd)
143936
+** }
143937
+** regStart = <expr1> // PRECEDING expression
143938
+** regEnd = <expr2> // FOLLOWING expression
143939
+** if( regStart<0 || regEnd<0 ){ error! }
143940
+** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
143941
+** Next(csrEnd) // if EOF skip Aggstep
143942
+** Aggstep (csrEnd)
143943
+** if( (regEnd--)<=0 ){
143944
+** AggFinal (xValue)
143945
+** Gosub addrGosub
143946
+** Next(csr) // if EOF goto flush_partition_done
143947
+** if( (regStart--)<=0 ){
143948
+** AggInverse (csrStart)
143949
+** Next(csrStart)
143950
+** }
143951
+** }
143952
+** flush_partition_done:
143953
+** ResetSorter (csr)
143954
+** Return
143955
+**
143956
+** ROWS BETWEEN <expr> PRECEDING AND CURRENT ROW
143957
+** ROWS BETWEEN CURRENT ROW AND <expr> FOLLOWING
143958
+** ROWS BETWEEN UNBOUNDED PRECEDING AND <expr> FOLLOWING
143959
+**
143960
+** These are similar to the above. For "CURRENT ROW", intialize the
143961
+** register to 0. For "UNBOUNDED PRECEDING" to infinity.
143962
+**
143963
+** ROWS BETWEEN <expr> PRECEDING AND UNBOUNDED FOLLOWING
143964
+** ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
143965
+**
143966
+** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
143967
+** while( 1 ){
143968
+** Next(csrEnd) // Exit while(1) at EOF
143969
+** Aggstep (csrEnd)
143970
+** }
143971
+** while( 1 ){
143972
+** AggFinal (xValue)
143973
+** Gosub addrGosub
143974
+** Next(csr) // if EOF goto flush_partition_done
143975
+** if( (regStart--)<=0 ){
143976
+** AggInverse (csrStart)
143977
+** Next(csrStart)
143978
+** }
143979
+** }
143980
+**
143981
+** For the "CURRENT ROW AND UNBOUNDED FOLLOWING" case, the final if()
143982
+** condition is always true (as if regStart were initialized to 0).
143983
+**
143984
+** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
143985
+**
143986
+** This is the only RANGE case handled by this routine. It modifies the
143987
+** second while( 1 ) loop in "ROWS BETWEEN CURRENT ... UNBOUNDED..." to
143988
+** be:
143989
+**
143990
+** while( 1 ){
143991
+** AggFinal (xValue)
143992
+** while( 1 ){
143993
+** regPeer++
143994
+** Gosub addrGosub
143995
+** Next(csr) // if EOF goto flush_partition_done
143996
+** if( new peer ) break;
143997
+** }
143998
+** while( (regPeer--)>0 ){
143999
+** AggInverse (csrStart)
144000
+** Next(csrStart)
144001
+** }
144002
+** }
144003
+**
144004
+** ROWS BETWEEN <expr> FOLLOWING AND <expr> FOLLOWING
144005
+**
144006
+** regEnd = regEnd - regStart
144007
+** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
144008
+** Aggstep (csrEnd)
144009
+** Next(csrEnd) // if EOF fall-through
144010
+** if( (regEnd--)<=0 ){
144011
+** if( (regStart--)<=0 ){
144012
+** AggFinal (xValue)
144013
+** Gosub addrGosub
144014
+** Next(csr) // if EOF goto flush_partition_done
144015
+** }
144016
+** AggInverse (csrStart)
144017
+** Next (csrStart)
144018
+** }
144019
+**
144020
+** ROWS BETWEEN <expr> PRECEDING AND <expr> PRECEDING
144021
+**
144022
+** Replace the bit after "Rewind" in the above with:
144023
+**
144024
+** if( (regEnd--)<=0 ){
144025
+** AggStep (csrEnd)
144026
+** Next (csrEnd)
144027
+** }
144028
+** AggFinal (xValue)
144029
+** Gosub addrGosub
144030
+** Next(csr) // if EOF goto flush_partition_done
144031
+** if( (regStart--)<=0 ){
144032
+** AggInverse (csr2)
144033
+** Next (csr2)
144034
+** }
144035
+**
144036
+*/
144037
+static void windowCodeRowExprStep(
144038
+ Parse *pParse,
144039
+ Select *p,
144040
+ WhereInfo *pWInfo,
144041
+ int regGosub,
144042
+ int addrGosub
144043
+){
144044
+ Window *pMWin = p->pWin;
144045
+ Vdbe *v = sqlite3GetVdbe(pParse);
144046
+ int regFlushPart; /* Register for "Gosub flush_partition" */
144047
+ int lblFlushPart; /* Label for "Gosub flush_partition" */
144048
+ int lblFlushDone; /* Label for "Gosub flush_partition_done" */
144049
+
144050
+ int regArg;
144051
+ int addr;
144052
+ int csrStart = pParse->nTab++;
144053
+ int csrEnd = pParse->nTab++;
144054
+ int regStart; /* Value of <expr> PRECEDING */
144055
+ int regEnd; /* Value of <expr> FOLLOWING */
144056
+ int addrGoto;
144057
+ int addrTop;
144058
+ int addrIfPos1 = 0;
144059
+ int addrIfPos2 = 0;
144060
+ int regSize = 0;
144061
+
144062
+ assert( pMWin->eStart==TK_PRECEDING
144063
+ || pMWin->eStart==TK_CURRENT
144064
+ || pMWin->eStart==TK_FOLLOWING
144065
+ || pMWin->eStart==TK_UNBOUNDED
144066
+ );
144067
+ assert( pMWin->eEnd==TK_FOLLOWING
144068
+ || pMWin->eEnd==TK_CURRENT
144069
+ || pMWin->eEnd==TK_UNBOUNDED
144070
+ || pMWin->eEnd==TK_PRECEDING
144071
+ );
144072
+
144073
+ /* Allocate register and label for the "flush_partition" sub-routine. */
144074
+ regFlushPart = ++pParse->nMem;
144075
+ lblFlushPart = sqlite3VdbeMakeLabel(v);
144076
+ lblFlushDone = sqlite3VdbeMakeLabel(v);
144077
+
144078
+ regStart = ++pParse->nMem;
144079
+ regEnd = ++pParse->nMem;
144080
+
144081
+ windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);
144082
+
144083
+ addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
144084
+
144085
+ /* Start of "flush_partition" */
144086
+ sqlite3VdbeResolveLabel(v, lblFlushPart);
144087
+ sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+3);
144088
+ VdbeCoverage(v);
144089
+ VdbeComment((v, "Flush_partition subroutine"));
144090
+ sqlite3VdbeAddOp2(v, OP_OpenDup, csrStart, pMWin->iEphCsr);
144091
+ sqlite3VdbeAddOp2(v, OP_OpenDup, csrEnd, pMWin->iEphCsr);
144092
+
144093
+ /* If either regStart or regEnd are not non-negative integers, throw
144094
+ ** an exception. */
144095
+ if( pMWin->pStart ){
144096
+ sqlite3ExprCode(pParse, pMWin->pStart, regStart);
144097
+ windowCheckIntValue(pParse, regStart, 0);
144098
+ }
144099
+ if( pMWin->pEnd ){
144100
+ sqlite3ExprCode(pParse, pMWin->pEnd, regEnd);
144101
+ windowCheckIntValue(pParse, regEnd, 1);
144102
+ }
144103
+
144104
+ /* If this is "ROWS <expr1> FOLLOWING AND ROWS <expr2> FOLLOWING", do:
144105
+ **
144106
+ ** if( regEnd<regStart ){
144107
+ ** // The frame always consists of 0 rows
144108
+ ** regStart = regSize;
144109
+ ** }
144110
+ ** regEnd = regEnd - regStart;
144111
+ */
144112
+ if( pMWin->pEnd && pMWin->eStart==TK_FOLLOWING ){
144113
+ assert( pMWin->pStart!=0 );
144114
+ assert( pMWin->eEnd==TK_FOLLOWING );
144115
+ sqlite3VdbeAddOp3(v, OP_Ge, regStart, sqlite3VdbeCurrentAddr(v)+2, regEnd);
144116
+ VdbeCoverageNeverNull(v);
144117
+ sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);
144118
+ sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regEnd);
144119
+ }
144120
+
144121
+ if( pMWin->pStart && pMWin->eEnd==TK_PRECEDING ){
144122
+ assert( pMWin->pEnd!=0 );
144123
+ assert( pMWin->eStart==TK_PRECEDING );
144124
+ sqlite3VdbeAddOp3(v, OP_Le, regStart, sqlite3VdbeCurrentAddr(v)+3, regEnd);
144125
+ VdbeCoverageNeverNull(v);
144126
+ sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);
144127
+ sqlite3VdbeAddOp2(v, OP_Copy, regSize, regEnd);
144128
+ }
144129
+
144130
+ /* Initialize the accumulator register for each window function to NULL */
144131
+ regArg = windowInitAccum(pParse, pMWin);
144132
+
144133
+ sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblFlushDone);
144134
+ VdbeCoverage(v);
144135
+ sqlite3VdbeAddOp2(v, OP_Rewind, csrStart, lblFlushDone);
144136
+ VdbeCoverageNeverTaken(v);
144137
+ sqlite3VdbeChangeP5(v, 1);
144138
+ sqlite3VdbeAddOp2(v, OP_Rewind, csrEnd, lblFlushDone);
144139
+ VdbeCoverageNeverTaken(v);
144140
+ sqlite3VdbeChangeP5(v, 1);
144141
+
144142
+ /* Invoke AggStep function for each window function using the row that
144143
+ ** csrEnd currently points to. Or, if csrEnd is already at EOF,
144144
+ ** do nothing. */
144145
+ addrTop = sqlite3VdbeCurrentAddr(v);
144146
+ if( pMWin->eEnd==TK_PRECEDING ){
144147
+ addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
144148
+ VdbeCoverage(v);
144149
+ }
144150
+ sqlite3VdbeAddOp2(v, OP_Next, csrEnd, sqlite3VdbeCurrentAddr(v)+2);
144151
+ VdbeCoverage(v);
144152
+ addr = sqlite3VdbeAddOp0(v, OP_Goto);
144153
+ windowAggStep(pParse, pMWin, csrEnd, 0, regArg, regSize);
144154
+ if( pMWin->eEnd==TK_UNBOUNDED ){
144155
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
144156
+ sqlite3VdbeJumpHere(v, addr);
144157
+ addrTop = sqlite3VdbeCurrentAddr(v);
144158
+ }else{
144159
+ sqlite3VdbeJumpHere(v, addr);
144160
+ if( pMWin->eEnd==TK_PRECEDING ){
144161
+ sqlite3VdbeJumpHere(v, addrIfPos1);
144162
+ }
144163
+ }
144164
+
144165
+ if( pMWin->eEnd==TK_FOLLOWING ){
144166
+ addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
144167
+ VdbeCoverage(v);
144168
+ }
144169
+ if( pMWin->eStart==TK_FOLLOWING ){
144170
+ addrIfPos2 = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
144171
+ VdbeCoverage(v);
144172
+ }
144173
+ windowAggFinal(pParse, pMWin, 0);
144174
+ windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);
144175
+ sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)+2);
144176
+ VdbeCoverage(v);
144177
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, lblFlushDone);
144178
+ if( pMWin->eStart==TK_FOLLOWING ){
144179
+ sqlite3VdbeJumpHere(v, addrIfPos2);
144180
+ }
144181
+
144182
+ if( pMWin->eStart==TK_CURRENT
144183
+ || pMWin->eStart==TK_PRECEDING
144184
+ || pMWin->eStart==TK_FOLLOWING
144185
+ ){
144186
+ int lblSkipInverse = sqlite3VdbeMakeLabel(v);;
144187
+ if( pMWin->eStart==TK_PRECEDING ){
144188
+ sqlite3VdbeAddOp3(v, OP_IfPos, regStart, lblSkipInverse, 1);
144189
+ VdbeCoverage(v);
144190
+ }
144191
+ if( pMWin->eStart==TK_FOLLOWING ){
144192
+ sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+2);
144193
+ VdbeCoverage(v);
144194
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, lblSkipInverse);
144195
+ }else{
144196
+ sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+1);
144197
+ VdbeCoverageAlwaysTaken(v);
144198
+ }
144199
+ windowAggStep(pParse, pMWin, csrStart, 1, regArg, regSize);
144200
+ sqlite3VdbeResolveLabel(v, lblSkipInverse);
144201
+ }
144202
+ if( pMWin->eEnd==TK_FOLLOWING ){
144203
+ sqlite3VdbeJumpHere(v, addrIfPos1);
144204
+ }
144205
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
144206
+
144207
+ /* flush_partition_done: */
144208
+ sqlite3VdbeResolveLabel(v, lblFlushDone);
144209
+ sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
144210
+ sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
144211
+ VdbeComment((v, "end flush_partition subroutine"));
144212
+
144213
+ /* Jump to here to skip over flush_partition */
144214
+ sqlite3VdbeJumpHere(v, addrGoto);
144215
+}
144216
+
144217
+/*
144218
+** This function does the work of sqlite3WindowCodeStep() for cases that
144219
+** would normally be handled by windowCodeDefaultStep() when there are
144220
+** one or more built-in window-functions that require the entire partition
144221
+** to be cached in a temp table before any rows can be returned. Additionally.
144222
+** "RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" is always handled by
144223
+** this function.
144224
+**
144225
+** Pseudo-code corresponding to the VM code generated by this function
144226
+** for each type of window follows.
144227
+**
144228
+** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144229
+**
144230
+** flush_partition:
144231
+** Once {
144232
+** OpenDup (iEphCsr -> csrLead)
144233
+** }
144234
+** Integer ctr 0
144235
+** foreach row (csrLead){
144236
+** if( new peer ){
144237
+** AggFinal (xValue)
144238
+** for(i=0; i<ctr; i++){
144239
+** Gosub addrGosub
144240
+** Next iEphCsr
144241
+** }
144242
+** Integer ctr 0
144243
+** }
144244
+** AggStep (csrLead)
144245
+** Incr ctr
144246
+** }
144247
+**
144248
+** AggFinal (xFinalize)
144249
+** for(i=0; i<ctr; i++){
144250
+** Gosub addrGosub
144251
+** Next iEphCsr
144252
+** }
144253
+**
144254
+** ResetSorter (csr)
144255
+** Return
144256
+**
144257
+** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144258
+**
144259
+** As above, except that the "if( new peer )" branch is always taken.
144260
+**
144261
+** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
144262
+**
144263
+** As above, except that each of the for() loops becomes:
144264
+**
144265
+** for(i=0; i<ctr; i++){
144266
+** Gosub addrGosub
144267
+** AggInverse (iEphCsr)
144268
+** Next iEphCsr
144269
+** }
144270
+**
144271
+** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
144272
+**
144273
+** flush_partition:
144274
+** Once {
144275
+** OpenDup (iEphCsr -> csrLead)
144276
+** }
144277
+** foreach row (csrLead) {
144278
+** AggStep (csrLead)
144279
+** }
144280
+** foreach row (iEphCsr) {
144281
+** Gosub addrGosub
144282
+** }
144283
+**
144284
+** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
144285
+**
144286
+** flush_partition:
144287
+** Once {
144288
+** OpenDup (iEphCsr -> csrLead)
144289
+** }
144290
+** foreach row (csrLead){
144291
+** AggStep (csrLead)
144292
+** }
144293
+** Rewind (csrLead)
144294
+** Integer ctr 0
144295
+** foreach row (csrLead){
144296
+** if( new peer ){
144297
+** AggFinal (xValue)
144298
+** for(i=0; i<ctr; i++){
144299
+** Gosub addrGosub
144300
+** AggInverse (iEphCsr)
144301
+** Next iEphCsr
144302
+** }
144303
+** Integer ctr 0
144304
+** }
144305
+** Incr ctr
144306
+** }
144307
+**
144308
+** AggFinal (xFinalize)
144309
+** for(i=0; i<ctr; i++){
144310
+** Gosub addrGosub
144311
+** Next iEphCsr
144312
+** }
144313
+**
144314
+** ResetSorter (csr)
144315
+** Return
144316
+*/
144317
+static void windowCodeCacheStep(
144318
+ Parse *pParse,
144319
+ Select *p,
144320
+ WhereInfo *pWInfo,
144321
+ int regGosub,
144322
+ int addrGosub
144323
+){
144324
+ Window *pMWin = p->pWin;
144325
+ Vdbe *v = sqlite3GetVdbe(pParse);
144326
+ int k;
144327
+ int addr;
144328
+ ExprList *pPart = pMWin->pPartition;
144329
+ ExprList *pOrderBy = pMWin->pOrderBy;
144330
+ int nPeer = pOrderBy ? pOrderBy->nExpr : 0;
144331
+ int regNewPeer;
144332
+
144333
+ int addrGoto; /* Address of Goto used to jump flush_par.. */
144334
+ int addrNext; /* Jump here for next iteration of loop */
144335
+ int regFlushPart;
144336
+ int lblFlushPart;
144337
+ int csrLead;
144338
+ int regCtr;
144339
+ int regArg; /* Register array to martial function args */
144340
+ int regSize;
144341
+ int lblEmpty;
144342
+ int bReverse = pMWin->pOrderBy && pMWin->eStart==TK_CURRENT
144343
+ && pMWin->eEnd==TK_UNBOUNDED;
144344
+
144345
+ assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
144346
+ || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED)
144347
+ || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT)
144348
+ || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED)
144349
+ );
144350
+
144351
+ lblEmpty = sqlite3VdbeMakeLabel(v);
144352
+ regNewPeer = pParse->nMem+1;
144353
+ pParse->nMem += nPeer;
144354
+
144355
+ /* Allocate register and label for the "flush_partition" sub-routine. */
144356
+ regFlushPart = ++pParse->nMem;
144357
+ lblFlushPart = sqlite3VdbeMakeLabel(v);
144358
+
144359
+ csrLead = pParse->nTab++;
144360
+ regCtr = ++pParse->nMem;
144361
+
144362
+ windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);
144363
+ addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
144364
+
144365
+ /* Start of "flush_partition" */
144366
+ sqlite3VdbeResolveLabel(v, lblFlushPart);
144367
+ sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+2);
144368
+ VdbeCoverage(v);
144369
+ sqlite3VdbeAddOp2(v, OP_OpenDup, csrLead, pMWin->iEphCsr);
144370
+
144371
+ /* Initialize the accumulator register for each window function to NULL */
144372
+ regArg = windowInitAccum(pParse, pMWin);
144373
+
144374
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, regCtr);
144375
+ sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);
144376
+ VdbeCoverage(v);
144377
+ sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblEmpty);
144378
+ VdbeCoverageNeverTaken(v);
144379
+
144380
+ if( bReverse ){
144381
+ int addr2 = sqlite3VdbeCurrentAddr(v);
144382
+ windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);
144383
+ sqlite3VdbeAddOp2(v, OP_Next, csrLead, addr2);
144384
+ VdbeCoverage(v);
144385
+ sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);
144386
+ VdbeCoverageNeverTaken(v);
144387
+ }
144388
+ addrNext = sqlite3VdbeCurrentAddr(v);
144389
+
144390
+ if( pOrderBy && (pMWin->eEnd==TK_CURRENT || pMWin->eStart==TK_CURRENT) ){
144391
+ int bCurrent = (pMWin->eStart==TK_CURRENT);
144392
+ int addrJump = 0; /* Address of OP_Jump below */
144393
+ if( pMWin->eType==TK_RANGE ){
144394
+ int iOff = pMWin->nBufferCol + (pPart ? pPart->nExpr : 0);
144395
+ int regPeer = pMWin->regPart + (pPart ? pPart->nExpr : 0);
144396
+ KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
144397
+ for(k=0; k<nPeer; k++){
144398
+ sqlite3VdbeAddOp3(v, OP_Column, csrLead, iOff+k, regNewPeer+k);
144399
+ }
144400
+ addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
144401
+ sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
144402
+ addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
144403
+ VdbeCoverage(v);
144404
+ sqlite3VdbeAddOp3(v, OP_Copy, regNewPeer, regPeer, nPeer-1);
144405
+ }
144406
+
144407
+ windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub,
144408
+ (bCurrent ? regArg : 0), (bCurrent ? regSize : 0)
144409
+ );
144410
+ if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
144411
+ }
144412
+
144413
+ if( bReverse==0 ){
144414
+ windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);
144415
+ }
144416
+ sqlite3VdbeAddOp2(v, OP_AddImm, regCtr, 1);
144417
+ sqlite3VdbeAddOp2(v, OP_Next, csrLead, addrNext);
144418
+ VdbeCoverage(v);
144419
+
144420
+ windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub, 0, 0);
144421
+
144422
+ sqlite3VdbeResolveLabel(v, lblEmpty);
144423
+ sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
144424
+ sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
144425
+
144426
+ /* Jump to here to skip over flush_partition */
144427
+ sqlite3VdbeJumpHere(v, addrGoto);
144428
+}
144429
+
144430
+
144431
+/*
144432
+** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144433
+**
144434
+** ...
144435
+** if( new partition ){
144436
+** AggFinal (xFinalize)
144437
+** Gosub addrGosub
144438
+** ResetSorter eph-table
144439
+** }
144440
+** else if( new peer ){
144441
+** AggFinal (xValue)
144442
+** Gosub addrGosub
144443
+** ResetSorter eph-table
144444
+** }
144445
+** AggStep
144446
+** Insert (record into eph-table)
144447
+** sqlite3WhereEnd()
144448
+** AggFinal (xFinalize)
144449
+** Gosub addrGosub
144450
+**
144451
+** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
144452
+**
144453
+** As above, except take no action for a "new peer". Invoke
144454
+** the sub-routine once only for each partition.
144455
+**
144456
+** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
144457
+**
144458
+** As above, except that the "new peer" condition is handled in the
144459
+** same way as "new partition" (so there is no "else if" block).
144460
+**
144461
+** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144462
+**
144463
+** As above, except assume every row is a "new peer".
144464
+*/
144465
+static void windowCodeDefaultStep(
144466
+ Parse *pParse,
144467
+ Select *p,
144468
+ WhereInfo *pWInfo,
144469
+ int regGosub,
144470
+ int addrGosub
144471
+){
144472
+ Window *pMWin = p->pWin;
144473
+ Vdbe *v = sqlite3GetVdbe(pParse);
144474
+ int k;
144475
+ int iSubCsr = p->pSrc->a[0].iCursor;
144476
+ int nSub = p->pSrc->a[0].pTab->nCol;
144477
+ int reg = pParse->nMem+1;
144478
+ int regRecord = reg+nSub;
144479
+ int regRowid = regRecord+1;
144480
+ int addr;
144481
+ ExprList *pPart = pMWin->pPartition;
144482
+ ExprList *pOrderBy = pMWin->pOrderBy;
144483
+
144484
+ assert( pMWin->eType==TK_RANGE
144485
+ || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
144486
+ );
144487
+
144488
+ assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
144489
+ || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED)
144490
+ || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT)
144491
+ || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED && !pOrderBy)
144492
+ );
144493
+
144494
+ if( pMWin->eEnd==TK_UNBOUNDED ){
144495
+ pOrderBy = 0;
144496
+ }
144497
+
144498
+ pParse->nMem += nSub + 2;
144499
+
144500
+ /* Load the individual column values of the row returned by
144501
+ ** the sub-select into an array of registers. */
144502
+ for(k=0; k<nSub; k++){
144503
+ sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
144504
+ }
144505
+
144506
+ /* Check if this is the start of a new partition or peer group. */
144507
+ if( pPart || pOrderBy ){
144508
+ int nPart = (pPart ? pPart->nExpr : 0);
144509
+ int addrGoto = 0;
144510
+ int addrJump = 0;
144511
+ int nPeer = (pOrderBy ? pOrderBy->nExpr : 0);
144512
+
144513
+ if( pPart ){
144514
+ int regNewPart = reg + pMWin->nBufferCol;
144515
+ KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
144516
+ addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);
144517
+ sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
144518
+ addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
144519
+ VdbeCoverageEqNe(v);
144520
+ windowAggFinal(pParse, pMWin, 1);
144521
+ if( pOrderBy ){
144522
+ addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
144523
+ }
144524
+ }
144525
+
144526
+ if( pOrderBy ){
144527
+ int regNewPeer = reg + pMWin->nBufferCol + nPart;
144528
+ int regPeer = pMWin->regPart + nPart;
144529
+
144530
+ if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
144531
+ if( pMWin->eType==TK_RANGE ){
144532
+ KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
144533
+ addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
144534
+ sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
144535
+ addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
144536
+ VdbeCoverage(v);
144537
+ }else{
144538
+ addrJump = 0;
144539
+ }
144540
+ windowAggFinal(pParse, pMWin, pMWin->eStart==TK_CURRENT);
144541
+ if( addrGoto ) sqlite3VdbeJumpHere(v, addrGoto);
144542
+ }
144543
+
144544
+ sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);
144545
+ VdbeCoverage(v);
144546
+ sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
144547
+ sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);
144548
+ VdbeCoverage(v);
144549
+
144550
+ sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
144551
+ sqlite3VdbeAddOp3(
144552
+ v, OP_Copy, reg+pMWin->nBufferCol, pMWin->regPart, nPart+nPeer-1
144553
+ );
144554
+
144555
+ if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
144556
+ }
144557
+
144558
+ /* Invoke step function for window functions */
144559
+ windowAggStep(pParse, pMWin, -1, 0, reg, 0);
144560
+
144561
+ /* Buffer the current row in the ephemeral table. */
144562
+ if( pMWin->nBufferCol>0 ){
144563
+ sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, pMWin->nBufferCol, regRecord);
144564
+ }else{
144565
+ sqlite3VdbeAddOp2(v, OP_Blob, 0, regRecord);
144566
+ sqlite3VdbeAppendP4(v, (void*)"", 0);
144567
+ }
144568
+ sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
144569
+ sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);
144570
+
144571
+ /* End the database scan loop. */
144572
+ sqlite3WhereEnd(pWInfo);
144573
+
144574
+ windowAggFinal(pParse, pMWin, 1);
144575
+ sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);
144576
+ VdbeCoverage(v);
144577
+ sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
144578
+ sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);
144579
+ VdbeCoverage(v);
144580
+}
144581
+
144582
+/*
144583
+** Allocate and return a duplicate of the Window object indicated by the
144584
+** third argument. Set the Window.pOwner field of the new object to
144585
+** pOwner.
144586
+*/
144587
+SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){
144588
+ Window *pNew = 0;
144589
+ if( p ){
144590
+ pNew = sqlite3DbMallocZero(db, sizeof(Window));
144591
+ if( pNew ){
144592
+ pNew->zName = sqlite3DbStrDup(db, p->zName);
144593
+ pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
144594
+ pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
144595
+ pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
144596
+ pNew->eType = p->eType;
144597
+ pNew->eEnd = p->eEnd;
144598
+ pNew->eStart = p->eStart;
144599
+ pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);
144600
+ pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);
144601
+ pNew->pOwner = pOwner;
144602
+ }
144603
+ }
144604
+ return pNew;
144605
+}
144606
+
144607
+/*
144608
+** Return a copy of the linked list of Window objects passed as the
144609
+** second argument.
144610
+*/
144611
+SQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p){
144612
+ Window *pWin;
144613
+ Window *pRet = 0;
144614
+ Window **pp = &pRet;
144615
+
144616
+ for(pWin=p; pWin; pWin=pWin->pNextWin){
144617
+ *pp = sqlite3WindowDup(db, 0, pWin);
144618
+ if( *pp==0 ) break;
144619
+ pp = &((*pp)->pNextWin);
144620
+ }
144621
+
144622
+ return pRet;
144623
+}
144624
+
144625
+/*
144626
+** sqlite3WhereBegin() has already been called for the SELECT statement
144627
+** passed as the second argument when this function is invoked. It generates
144628
+** code to populate the Window.regResult register for each window function and
144629
+** invoke the sub-routine at instruction addrGosub once for each row.
144630
+** This function calls sqlite3WhereEnd() before returning.
144631
+*/
144632
+SQLITE_PRIVATE void sqlite3WindowCodeStep(
144633
+ Parse *pParse, /* Parse context */
144634
+ Select *p, /* Rewritten SELECT statement */
144635
+ WhereInfo *pWInfo, /* Context returned by sqlite3WhereBegin() */
144636
+ int regGosub, /* Register for OP_Gosub */
144637
+ int addrGosub /* OP_Gosub here to return each row */
144638
+){
144639
+ Window *pMWin = p->pWin;
144640
+
144641
+ /* There are three different functions that may be used to do the work
144642
+ ** of this one, depending on the window frame and the specific built-in
144643
+ ** window functions used (if any).
144644
+ **
144645
+ ** windowCodeRowExprStep() handles all "ROWS" window frames, except for:
144646
+ **
144647
+ ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144648
+ **
144649
+ ** The exception is because windowCodeRowExprStep() implements all window
144650
+ ** frame types by caching the entire partition in a temp table, and
144651
+ ** "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" is easy enough to
144652
+ ** implement without such a cache.
144653
+ **
144654
+ ** windowCodeCacheStep() is used for:
144655
+ **
144656
+ ** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
144657
+ **
144658
+ ** It is also used for anything not handled by windowCodeRowExprStep()
144659
+ ** that invokes a built-in window function that requires the entire
144660
+ ** partition to be cached in a temp table before any rows are returned
144661
+ ** (e.g. nth_value() or percent_rank()).
144662
+ **
144663
+ ** Finally, assuming there is no built-in window function that requires
144664
+ ** the partition to be cached, windowCodeDefaultStep() is used for:
144665
+ **
144666
+ ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144667
+ ** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
144668
+ ** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
144669
+ ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144670
+ **
144671
+ ** windowCodeDefaultStep() is the only one of the three functions that
144672
+ ** does not cache each partition in a temp table before beginning to
144673
+ ** return rows.
144674
+ */
144675
+ if( pMWin->eType==TK_ROWS
144676
+ && (pMWin->eStart!=TK_UNBOUNDED||pMWin->eEnd!=TK_CURRENT||!pMWin->pOrderBy)
144677
+ ){
144678
+ VdbeModuleComment((pParse->pVdbe, "Begin RowExprStep()"));
144679
+ windowCodeRowExprStep(pParse, p, pWInfo, regGosub, addrGosub);
144680
+ }else{
144681
+ Window *pWin;
144682
+ int bCache = 0; /* True to use CacheStep() */
144683
+
144684
+ if( pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED ){
144685
+ bCache = 1;
144686
+ }else{
144687
+ for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
144688
+ FuncDef *pFunc = pWin->pFunc;
144689
+ if( (pFunc->funcFlags & SQLITE_FUNC_WINDOW_SIZE)
144690
+ || (pFunc->zName==nth_valueName)
144691
+ || (pFunc->zName==first_valueName)
144692
+ || (pFunc->zName==leadName)
144693
+ || (pFunc->zName==lagName)
144694
+ ){
144695
+ bCache = 1;
144696
+ break;
144697
+ }
144698
+ }
144699
+ }
144700
+
144701
+ /* Otherwise, call windowCodeDefaultStep(). */
144702
+ if( bCache ){
144703
+ VdbeModuleComment((pParse->pVdbe, "Begin CacheStep()"));
144704
+ windowCodeCacheStep(pParse, p, pWInfo, regGosub, addrGosub);
144705
+ }else{
144706
+ VdbeModuleComment((pParse->pVdbe, "Begin DefaultStep()"));
144707
+ windowCodeDefaultStep(pParse, p, pWInfo, regGosub, addrGosub);
144708
+ }
144709
+ }
144710
+}
144711
+
144712
+#endif /* SQLITE_OMIT_WINDOWFUNC */
144713
+
144714
+/************** End of window.c **********************************************/
141382144715
/************** Begin file parse.c *******************************************/
141383144716
/*
141384144717
** 2000-05-29
141385144718
**
141386144719
** The author disclaims copyright to this source code. In place of
@@ -141453,10 +144786,12 @@
141453144786
** UPDATE ON (a,b,c)
141454144787
**
141455144788
** Then the "b" IdList records the list "a,b,c".
141456144789
*/
141457144790
struct TrigEvent { int a; IdList * b; };
144791
+
144792
+struct FrameBound { int eType; Expr *pExpr; };
141458144793
141459144794
/*
141460144795
** Disable lookaside memory allocation for objects that might be
141461144796
** shared across database connections.
141462144797
*/
@@ -141607,30 +144942,32 @@
141607144942
*/
141608144943
#ifndef INTERFACE
141609144944
# define INTERFACE 1
141610144945
#endif
141611144946
/************* Begin control #defines *****************************************/
141612
-#define YYCODETYPE unsigned char
141613
-#define YYNOCODE 255
144947
+#define YYCODETYPE unsigned short int
144948
+#define YYNOCODE 277
141614144949
#define YYACTIONTYPE unsigned short int
141615
-#define YYWILDCARD 84
144950
+#define YYWILDCARD 91
141616144951
#define sqlite3ParserTOKENTYPE Token
141617144952
typedef union {
141618144953
int yyinit;
141619144954
sqlite3ParserTOKENTYPE yy0;
141620
- const char* yy36;
141621
- TriggerStep* yy47;
141622
- With* yy91;
141623
- struct {int value; int mask;} yy107;
141624
- Expr* yy182;
141625
- Upsert* yy198;
141626
- ExprList* yy232;
141627
- struct TrigEvent yy300;
141628
- Select* yy399;
141629
- SrcList* yy427;
141630
- int yy502;
141631
- IdList* yy510;
144955
+ Expr* yy18;
144956
+ struct TrigEvent yy34;
144957
+ IdList* yy48;
144958
+ int yy70;
144959
+ struct {int value; int mask;} yy111;
144960
+ struct FrameBound yy119;
144961
+ SrcList* yy135;
144962
+ TriggerStep* yy207;
144963
+ Window* yy327;
144964
+ Upsert* yy340;
144965
+ const char* yy392;
144966
+ ExprList* yy420;
144967
+ With* yy449;
144968
+ Select* yy489;
141632144969
} YYMINORTYPE;
141633144970
#ifndef YYSTACKDEPTH
141634144971
#define YYSTACKDEPTH 100
141635144972
#endif
141636144973
#define sqlite3ParserARG_SDECL
@@ -141642,22 +144979,23 @@
141642144979
#define sqlite3ParserCTX_PDECL ,Parse *pParse
141643144980
#define sqlite3ParserCTX_PARAM ,pParse
141644144981
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
141645144982
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
141646144983
#define YYFALLBACK 1
141647
-#define YYNSTATE 490
141648
-#define YYNRULE 341
141649
-#define YYNTOKEN 145
141650
-#define YY_MAX_SHIFT 489
141651
-#define YY_MIN_SHIFTREDUCE 705
141652
-#define YY_MAX_SHIFTREDUCE 1045
141653
-#define YY_ERROR_ACTION 1046
141654
-#define YY_ACCEPT_ACTION 1047
141655
-#define YY_NO_ACTION 1048
141656
-#define YY_MIN_REDUCE 1049
141657
-#define YY_MAX_REDUCE 1389
144984
+#define YYNSTATE 516
144985
+#define YYNRULE 365
144986
+#define YYNTOKEN 155
144987
+#define YY_MAX_SHIFT 515
144988
+#define YY_MIN_SHIFTREDUCE 750
144989
+#define YY_MAX_SHIFTREDUCE 1114
144990
+#define YY_ERROR_ACTION 1115
144991
+#define YY_ACCEPT_ACTION 1116
144992
+#define YY_NO_ACTION 1117
144993
+#define YY_MIN_REDUCE 1118
144994
+#define YY_MAX_REDUCE 1482
141658144995
/************* End control #defines *******************************************/
144996
+#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
141659144997
141660144998
/* Define the yytestcase() macro to be a no-op if is not already defined
141661144999
** otherwise.
141662145000
**
141663145001
** Applications can choose to define yytestcase() in the %include section
@@ -141718,507 +145056,570 @@
141718145056
** yy_reduce_ofst[] For each state, the offset into yy_action for
141719145057
** shifting non-terminals after a reduce.
141720145058
** yy_default[] Default action for each state.
141721145059
**
141722145060
*********** Begin parsing tables **********************************************/
141723
-#define YY_ACTTAB_COUNT (1657)
145061
+#define YY_ACTTAB_COUNT (2009)
141724145062
static const YYACTIONTYPE yy_action[] = {
141725
- /* 0 */ 349, 99, 96, 185, 99, 96, 185, 233, 1047, 1,
141726
- /* 10 */ 1, 489, 2, 1051, 484, 477, 477, 477, 260, 351,
141727
- /* 20 */ 121, 1310, 1120, 1120, 1178, 1115, 1094, 1128, 380, 380,
141728
- /* 30 */ 380, 835, 454, 410, 1115, 59, 59, 1357, 425, 836,
141729
- /* 40 */ 710, 711, 712, 106, 107, 97, 1023, 1023, 900, 903,
141730
- /* 50 */ 892, 892, 104, 104, 105, 105, 105, 105, 346, 238,
141731
- /* 60 */ 238, 99, 96, 185, 238, 238, 889, 889, 901, 904,
141732
- /* 70 */ 460, 481, 351, 99, 96, 185, 481, 347, 1177, 82,
141733
- /* 80 */ 388, 214, 182, 23, 194, 103, 103, 103, 103, 102,
141734
- /* 90 */ 102, 101, 101, 101, 100, 381, 106, 107, 97, 1023,
141735
- /* 100 */ 1023, 900, 903, 892, 892, 104, 104, 105, 105, 105,
141736
- /* 110 */ 105, 10, 385, 484, 24, 484, 1333, 489, 2, 1051,
141737
- /* 120 */ 335, 1043, 108, 893, 260, 351, 121, 99, 96, 185,
141738
- /* 130 */ 100, 381, 386, 1128, 59, 59, 59, 59, 103, 103,
141739
- /* 140 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 106,
141740
- /* 150 */ 107, 97, 1023, 1023, 900, 903, 892, 892, 104, 104,
141741
- /* 160 */ 105, 105, 105, 105, 360, 238, 238, 170, 170, 467,
141742
- /* 170 */ 455, 467, 464, 67, 381, 329, 169, 481, 351, 343,
141743
- /* 180 */ 338, 400, 1044, 68, 101, 101, 101, 100, 381, 393,
141744
- /* 190 */ 194, 103, 103, 103, 103, 102, 102, 101, 101, 101,
141745
- /* 200 */ 100, 381, 106, 107, 97, 1023, 1023, 900, 903, 892,
141746
- /* 210 */ 892, 104, 104, 105, 105, 105, 105, 483, 385, 103,
141747
- /* 220 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381,
141748
- /* 230 */ 268, 351, 946, 946, 422, 296, 102, 102, 101, 101,
141749
- /* 240 */ 101, 100, 381, 861, 103, 103, 103, 103, 102, 102,
141750
- /* 250 */ 101, 101, 101, 100, 381, 106, 107, 97, 1023, 1023,
141751
- /* 260 */ 900, 903, 892, 892, 104, 104, 105, 105, 105, 105,
141752
- /* 270 */ 484, 983, 1383, 206, 1353, 1383, 438, 435, 434, 281,
141753
- /* 280 */ 396, 269, 1089, 941, 351, 1002, 433, 861, 743, 401,
141754
- /* 290 */ 282, 57, 57, 482, 145, 791, 791, 103, 103, 103,
141755
- /* 300 */ 103, 102, 102, 101, 101, 101, 100, 381, 106, 107,
141756
- /* 310 */ 97, 1023, 1023, 900, 903, 892, 892, 104, 104, 105,
141757
- /* 320 */ 105, 105, 105, 281, 1002, 1003, 1004, 206, 879, 319,
141758
- /* 330 */ 438, 435, 434, 981, 259, 474, 360, 351, 1118, 1118,
141759
- /* 340 */ 433, 736, 379, 378, 872, 1002, 1356, 322, 871, 766,
141760
- /* 350 */ 103, 103, 103, 103, 102, 102, 101, 101, 101, 100,
141761
- /* 360 */ 381, 106, 107, 97, 1023, 1023, 900, 903, 892, 892,
141762
- /* 370 */ 104, 104, 105, 105, 105, 105, 484, 801, 484, 871,
141763
- /* 380 */ 871, 873, 401, 282, 1002, 1003, 1004, 1030, 360, 1030,
141764
- /* 390 */ 351, 983, 1384, 213, 880, 1384, 145, 59, 59, 59,
141765
- /* 400 */ 59, 1002, 244, 103, 103, 103, 103, 102, 102, 101,
141766
- /* 410 */ 101, 101, 100, 381, 106, 107, 97, 1023, 1023, 900,
141767
- /* 420 */ 903, 892, 892, 104, 104, 105, 105, 105, 105, 274,
141768
- /* 430 */ 484, 110, 467, 479, 467, 444, 259, 474, 232, 232,
141769
- /* 440 */ 1002, 1003, 1004, 351, 210, 335, 982, 866, 1385, 336,
141770
- /* 450 */ 481, 59, 59, 981, 245, 307, 103, 103, 103, 103,
141771
- /* 460 */ 102, 102, 101, 101, 101, 100, 381, 106, 107, 97,
141772
- /* 470 */ 1023, 1023, 900, 903, 892, 892, 104, 104, 105, 105,
141773
- /* 480 */ 105, 105, 453, 459, 484, 408, 377, 259, 474, 271,
141774
- /* 490 */ 183, 273, 209, 208, 207, 356, 351, 307, 178, 177,
141775
- /* 500 */ 127, 1006, 1098, 14, 14, 43, 43, 1044, 425, 103,
141776
- /* 510 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381,
141777
- /* 520 */ 106, 107, 97, 1023, 1023, 900, 903, 892, 892, 104,
141778
- /* 530 */ 104, 105, 105, 105, 105, 294, 1132, 408, 160, 484,
141779
- /* 540 */ 408, 1006, 129, 962, 1209, 239, 239, 481, 307, 425,
141780
- /* 550 */ 1309, 1097, 351, 235, 243, 272, 820, 481, 963, 425,
141781
- /* 560 */ 11, 11, 103, 103, 103, 103, 102, 102, 101, 101,
141782
- /* 570 */ 101, 100, 381, 964, 362, 1002, 106, 107, 97, 1023,
141783
- /* 580 */ 1023, 900, 903, 892, 892, 104, 104, 105, 105, 105,
141784
- /* 590 */ 105, 1275, 161, 126, 777, 289, 1209, 292, 1072, 357,
141785
- /* 600 */ 1209, 1127, 476, 357, 778, 425, 247, 425, 351, 248,
141786
- /* 610 */ 414, 364, 414, 171, 1002, 1003, 1004, 84, 103, 103,
141787
- /* 620 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 1002,
141788
- /* 630 */ 184, 484, 106, 107, 97, 1023, 1023, 900, 903, 892,
141789
- /* 640 */ 892, 104, 104, 105, 105, 105, 105, 1123, 1209, 287,
141790
- /* 650 */ 484, 1209, 11, 11, 179, 820, 259, 474, 307, 237,
141791
- /* 660 */ 182, 351, 321, 365, 414, 308, 367, 366, 1002, 1003,
141792
- /* 670 */ 1004, 44, 44, 87, 103, 103, 103, 103, 102, 102,
141793
- /* 680 */ 101, 101, 101, 100, 381, 106, 107, 97, 1023, 1023,
141794
- /* 690 */ 900, 903, 892, 892, 104, 104, 105, 105, 105, 105,
141795
- /* 700 */ 246, 368, 280, 128, 10, 358, 146, 796, 835, 258,
141796
- /* 710 */ 1020, 88, 795, 86, 351, 421, 836, 943, 376, 348,
141797
- /* 720 */ 191, 943, 1318, 267, 308, 279, 456, 103, 103, 103,
141798
- /* 730 */ 103, 102, 102, 101, 101, 101, 100, 381, 106, 95,
141799
- /* 740 */ 97, 1023, 1023, 900, 903, 892, 892, 104, 104, 105,
141800
- /* 750 */ 105, 105, 105, 420, 249, 238, 238, 238, 238, 79,
141801
- /* 760 */ 375, 125, 305, 29, 262, 978, 351, 481, 337, 481,
141802
- /* 770 */ 756, 755, 304, 278, 415, 15, 81, 940, 1126, 940,
141803
- /* 780 */ 103, 103, 103, 103, 102, 102, 101, 101, 101, 100,
141804
- /* 790 */ 381, 107, 97, 1023, 1023, 900, 903, 892, 892, 104,
141805
- /* 800 */ 104, 105, 105, 105, 105, 457, 263, 484, 174, 484,
141806
- /* 810 */ 238, 238, 863, 407, 402, 216, 216, 351, 409, 193,
141807
- /* 820 */ 283, 216, 481, 81, 763, 764, 266, 5, 13, 13,
141808
- /* 830 */ 34, 34, 103, 103, 103, 103, 102, 102, 101, 101,
141809
- /* 840 */ 101, 100, 381, 97, 1023, 1023, 900, 903, 892, 892,
141810
- /* 850 */ 104, 104, 105, 105, 105, 105, 93, 475, 1002, 4,
141811
- /* 860 */ 403, 1002, 340, 431, 1002, 297, 212, 1277, 81, 746,
141812
- /* 870 */ 1163, 152, 926, 478, 166, 212, 757, 829, 930, 939,
141813
- /* 880 */ 216, 939, 858, 103, 103, 103, 103, 102, 102, 101,
141814
- /* 890 */ 101, 101, 100, 381, 238, 238, 382, 1002, 1003, 1004,
141815
- /* 900 */ 1002, 1003, 1004, 1002, 1003, 1004, 481, 439, 472, 746,
141816
- /* 910 */ 105, 105, 105, 105, 98, 758, 1162, 145, 930, 412,
141817
- /* 920 */ 879, 406, 793, 81, 395, 89, 90, 91, 105, 105,
141818
- /* 930 */ 105, 105, 1323, 92, 484, 382, 486, 485, 240, 275,
141819
- /* 940 */ 871, 103, 103, 103, 103, 102, 102, 101, 101, 101,
141820
- /* 950 */ 100, 381, 1096, 371, 355, 45, 45, 259, 474, 103,
141821
- /* 960 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381,
141822
- /* 970 */ 1150, 871, 871, 873, 874, 21, 1332, 991, 384, 730,
141823
- /* 980 */ 722, 242, 123, 1298, 124, 875, 333, 333, 332, 227,
141824
- /* 990 */ 330, 991, 384, 719, 256, 242, 484, 391, 413, 1297,
141825
- /* 1000 */ 333, 333, 332, 227, 330, 748, 187, 719, 265, 470,
141826
- /* 1010 */ 1279, 1002, 484, 417, 391, 390, 264, 11, 11, 284,
141827
- /* 1020 */ 187, 732, 265, 93, 475, 875, 4, 1279, 1281, 419,
141828
- /* 1030 */ 264, 369, 416, 11, 11, 1159, 288, 484, 399, 1346,
141829
- /* 1040 */ 478, 379, 378, 291, 484, 293, 189, 250, 295, 1027,
141830
- /* 1050 */ 1002, 1003, 1004, 190, 1029, 1111, 140, 188, 11, 11,
141831
- /* 1060 */ 189, 732, 1028, 382, 923, 46, 46, 190, 1095, 230,
141832
- /* 1070 */ 140, 188, 462, 93, 475, 472, 4, 300, 309, 391,
141833
- /* 1080 */ 373, 6, 1069, 217, 739, 310, 1030, 879, 1030, 1171,
141834
- /* 1090 */ 478, 352, 1279, 90, 91, 800, 259, 474, 1208, 484,
141835
- /* 1100 */ 92, 1268, 382, 486, 485, 352, 1002, 871, 879, 426,
141836
- /* 1110 */ 259, 474, 172, 382, 238, 238, 1146, 170, 1021, 389,
141837
- /* 1120 */ 47, 47, 1157, 739, 872, 472, 481, 469, 871, 350,
141838
- /* 1130 */ 1214, 83, 475, 389, 4, 1078, 1071, 879, 871, 871,
141839
- /* 1140 */ 873, 874, 21, 90, 91, 1002, 1003, 1004, 478, 251,
141840
- /* 1150 */ 92, 251, 382, 486, 485, 443, 370, 871, 1021, 871,
141841
- /* 1160 */ 871, 873, 224, 241, 306, 441, 301, 440, 211, 1060,
141842
- /* 1170 */ 820, 382, 822, 447, 299, 1059, 484, 1061, 1143, 962,
141843
- /* 1180 */ 430, 796, 484, 472, 1340, 312, 795, 465, 871, 871,
141844
- /* 1190 */ 873, 874, 21, 314, 963, 879, 316, 59, 59, 1002,
141845
- /* 1200 */ 9, 90, 91, 48, 48, 238, 238, 210, 92, 964,
141846
- /* 1210 */ 382, 486, 485, 176, 334, 871, 242, 481, 1193, 238,
141847
- /* 1220 */ 238, 333, 333, 332, 227, 330, 394, 270, 719, 277,
141848
- /* 1230 */ 471, 481, 467, 466, 484, 145, 217, 1201, 1002, 1003,
141849
- /* 1240 */ 1004, 187, 3, 265, 184, 445, 871, 871, 873, 874,
141850
- /* 1250 */ 21, 264, 1337, 450, 1051, 39, 39, 392, 356, 260,
141851
- /* 1260 */ 342, 121, 468, 411, 436, 821, 180, 1094, 1128, 820,
141852
- /* 1270 */ 303, 1021, 1272, 1271, 299, 259, 474, 238, 238, 1002,
141853
- /* 1280 */ 473, 189, 484, 318, 327, 238, 238, 484, 190, 481,
141854
- /* 1290 */ 446, 140, 188, 1343, 238, 238, 1038, 481, 148, 175,
141855
- /* 1300 */ 238, 238, 484, 49, 49, 219, 481, 484, 35, 35,
141856
- /* 1310 */ 1317, 1021, 481, 484, 1035, 484, 1315, 484, 1002, 1003,
141857
- /* 1320 */ 1004, 484, 66, 36, 36, 194, 352, 484, 38, 38,
141858
- /* 1330 */ 484, 259, 474, 69, 50, 50, 51, 51, 52, 52,
141859
- /* 1340 */ 359, 484, 12, 12, 484, 1198, 484, 158, 53, 53,
141860
- /* 1350 */ 405, 112, 112, 385, 389, 484, 26, 484, 143, 484,
141861
- /* 1360 */ 150, 484, 54, 54, 397, 40, 40, 55, 55, 484,
141862
- /* 1370 */ 79, 484, 153, 1190, 484, 154, 56, 56, 41, 41,
141863
- /* 1380 */ 58, 58, 133, 133, 484, 398, 484, 429, 484, 155,
141864
- /* 1390 */ 134, 134, 135, 135, 484, 63, 63, 484, 341, 484,
141865
- /* 1400 */ 339, 484, 196, 484, 156, 42, 42, 113, 113, 60,
141866
- /* 1410 */ 60, 484, 404, 484, 27, 114, 114, 1204, 115, 115,
141867
- /* 1420 */ 111, 111, 132, 132, 131, 131, 1266, 418, 484, 162,
141868
- /* 1430 */ 484, 200, 119, 119, 118, 118, 484, 74, 424, 484,
141869
- /* 1440 */ 1286, 484, 231, 484, 202, 484, 167, 286, 427, 116,
141870
- /* 1450 */ 116, 117, 117, 290, 203, 442, 1062, 62, 62, 204,
141871
- /* 1460 */ 64, 64, 61, 61, 33, 33, 37, 37, 344, 372,
141872
- /* 1470 */ 1114, 1105, 748, 1113, 374, 1112, 254, 458, 1086, 255,
141873
- /* 1480 */ 345, 1085, 302, 1084, 1355, 78, 1154, 311, 1104, 449,
141874
- /* 1490 */ 452, 1155, 1153, 218, 7, 313, 315, 320, 1152, 85,
141875
- /* 1500 */ 1252, 317, 109, 80, 463, 225, 461, 1068, 25, 487,
141876
- /* 1510 */ 997, 323, 257, 226, 229, 228, 1136, 324, 325, 326,
141877
- /* 1520 */ 488, 136, 1057, 1052, 1302, 1303, 1301, 706, 1300, 137,
141878
- /* 1530 */ 122, 138, 383, 173, 1082, 261, 186, 252, 1081, 65,
141879
- /* 1540 */ 387, 120, 938, 936, 855, 353, 149, 1079, 139, 151,
141880
- /* 1550 */ 192, 780, 195, 276, 952, 157, 141, 361, 70, 363,
141881
- /* 1560 */ 859, 159, 71, 72, 142, 73, 955, 354, 147, 197,
141882
- /* 1570 */ 198, 951, 130, 16, 199, 285, 216, 1032, 201, 423,
141883
- /* 1580 */ 164, 944, 163, 28, 721, 428, 304, 165, 205, 759,
141884
- /* 1590 */ 75, 432, 298, 17, 18, 437, 76, 253, 878, 144,
141885
- /* 1600 */ 877, 906, 77, 986, 30, 448, 987, 31, 451, 181,
141886
- /* 1610 */ 234, 236, 168, 828, 823, 89, 910, 921, 81, 907,
141887
- /* 1620 */ 215, 905, 909, 961, 960, 19, 221, 20, 220, 22,
141888
- /* 1630 */ 32, 331, 876, 731, 94, 790, 794, 8, 992, 222,
141889
- /* 1640 */ 480, 328, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
141890
- /* 1650 */ 223, 1048, 1048, 1048, 1048, 1348, 1347,
145063
+ /* 0 */ 510, 423, 364, 105, 102, 196, 14, 244, 1116, 1,
145064
+ /* 10 */ 1, 515, 2, 1120, 510, 361, 1247, 362, 271, 366,
145065
+ /* 20 */ 127, 37, 37, 1378, 105, 102, 196, 1197, 178, 472,
145066
+ /* 30 */ 1246, 880, 1184, 1163, 423, 37, 37, 1189, 1189, 881,
145067
+ /* 40 */ 353, 1184, 425, 112, 113, 103, 1092, 1092, 944, 947,
145068
+ /* 50 */ 937, 937, 110, 110, 111, 111, 111, 111, 278, 249,
145069
+ /* 60 */ 249, 249, 249, 105, 102, 196, 510, 105, 102, 196,
145070
+ /* 70 */ 1071, 254, 507, 177, 507, 1187, 1187, 491, 415, 225,
145071
+ /* 80 */ 193, 105, 102, 196, 510, 205, 906, 65, 65, 318,
145072
+ /* 90 */ 249, 249, 109, 109, 109, 109, 108, 108, 107, 107,
145073
+ /* 100 */ 107, 106, 396, 507, 258, 15, 15, 394, 393, 249,
145074
+ /* 110 */ 249, 1413, 366, 1408, 400, 1096, 1071, 1072, 1073, 377,
145075
+ /* 120 */ 1098, 178, 507, 493, 492, 1411, 1407, 396, 1097, 292,
145076
+ /* 130 */ 411, 280, 366, 365, 134, 152, 112, 113, 103, 1092,
145077
+ /* 140 */ 1092, 944, 947, 937, 937, 110, 110, 111, 111, 111,
145078
+ /* 150 */ 111, 1450, 1099, 262, 1099, 262, 112, 113, 103, 1092,
145079
+ /* 160 */ 1092, 944, 947, 937, 937, 110, 110, 111, 111, 111,
145080
+ /* 170 */ 111, 107, 107, 107, 106, 396, 1049, 486, 1047, 509,
145081
+ /* 180 */ 73, 270, 500, 416, 293, 109, 109, 109, 109, 108,
145082
+ /* 190 */ 108, 107, 107, 107, 106, 396, 366, 111, 111, 111,
145083
+ /* 200 */ 111, 104, 330, 89, 486, 109, 109, 109, 109, 108,
145084
+ /* 210 */ 108, 107, 107, 107, 106, 396, 111, 111, 111, 111,
145085
+ /* 220 */ 112, 113, 103, 1092, 1092, 944, 947, 937, 937, 110,
145086
+ /* 230 */ 110, 111, 111, 111, 111, 109, 109, 109, 109, 108,
145087
+ /* 240 */ 108, 107, 107, 107, 106, 396, 114, 108, 108, 107,
145088
+ /* 250 */ 107, 107, 106, 396, 109, 109, 109, 109, 108, 108,
145089
+ /* 260 */ 107, 107, 107, 106, 396, 394, 393, 106, 396, 109,
145090
+ /* 270 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 396,
145091
+ /* 280 */ 217, 487, 1400, 453, 450, 449, 510, 1278, 423, 366,
145092
+ /* 290 */ 503, 503, 503, 448, 74, 1071, 109, 109, 109, 109,
145093
+ /* 300 */ 108, 108, 107, 107, 107, 106, 396, 37, 37, 1401,
145094
+ /* 310 */ 1099, 440, 1099, 112, 113, 103, 1092, 1092, 944, 947,
145095
+ /* 320 */ 937, 937, 110, 110, 111, 111, 111, 111, 1426, 515,
145096
+ /* 330 */ 2, 1120, 934, 934, 945, 948, 271, 1071, 127, 477,
145097
+ /* 340 */ 924, 1071, 1072, 1073, 217, 1197, 906, 453, 450, 449,
145098
+ /* 350 */ 388, 167, 510, 1377, 152, 379, 917, 448, 259, 510,
145099
+ /* 360 */ 916, 285, 109, 109, 109, 109, 108, 108, 107, 107,
145100
+ /* 370 */ 107, 106, 396, 15, 15, 429, 846, 249, 249, 224,
145101
+ /* 380 */ 15, 15, 366, 1071, 1072, 1073, 307, 382, 1071, 292,
145102
+ /* 390 */ 507, 916, 916, 918, 384, 27, 938, 1411, 484, 408,
145103
+ /* 400 */ 270, 500, 508, 205, 836, 836, 112, 113, 103, 1092,
145104
+ /* 410 */ 1092, 944, 947, 937, 937, 110, 110, 111, 111, 111,
145105
+ /* 420 */ 111, 1430, 282, 1120, 284, 1071, 28, 510, 271, 318,
145106
+ /* 430 */ 127, 1422, 400, 385, 1071, 1072, 1073, 1197, 159, 235,
145107
+ /* 440 */ 252, 317, 456, 312, 455, 222, 784, 375, 65, 65,
145108
+ /* 450 */ 332, 310, 194, 243, 243, 109, 109, 109, 109, 108,
145109
+ /* 460 */ 108, 107, 107, 107, 106, 396, 507, 257, 510, 249,
145110
+ /* 470 */ 249, 1071, 1072, 1073, 136, 366, 335, 924, 440, 788,
145111
+ /* 480 */ 270, 500, 507, 1446, 493, 473, 319, 1071, 429, 65,
145112
+ /* 490 */ 65, 1158, 784, 917, 283, 205, 510, 916, 440, 112,
145113
+ /* 500 */ 113, 103, 1092, 1092, 944, 947, 937, 937, 110, 110,
145114
+ /* 510 */ 111, 111, 111, 111, 279, 1027, 1476, 15, 15, 1476,
145115
+ /* 520 */ 403, 510, 383, 1071, 400, 493, 1404, 1386, 916, 916,
145116
+ /* 530 */ 918, 261, 463, 1071, 1072, 1073, 173, 1421, 510, 1071,
145117
+ /* 540 */ 1343, 510, 45, 45, 168, 990, 990, 437, 109, 109,
145118
+ /* 550 */ 109, 109, 108, 108, 107, 107, 107, 106, 396, 63,
145119
+ /* 560 */ 63, 510, 15, 15, 249, 249, 375, 510, 366, 1071,
145120
+ /* 570 */ 1072, 1073, 781, 5, 401, 355, 488, 507, 464, 3,
145121
+ /* 580 */ 291, 1071, 65, 65, 1025, 1071, 1072, 1073, 65, 65,
145122
+ /* 590 */ 350, 1112, 112, 113, 103, 1092, 1092, 944, 947, 937,
145123
+ /* 600 */ 937, 110, 110, 111, 111, 111, 111, 249, 249, 510,
145124
+ /* 610 */ 1071, 1042, 867, 395, 395, 395, 1071, 336, 493, 490,
145125
+ /* 620 */ 507, 1041, 1006, 318, 493, 505, 178, 1071, 1072, 1073,
145126
+ /* 630 */ 65, 65, 1071, 255, 344, 421, 273, 1007, 358, 290,
145127
+ /* 640 */ 88, 109, 109, 109, 109, 108, 108, 107, 107, 107,
145128
+ /* 650 */ 106, 396, 1008, 510, 375, 1071, 1071, 1072, 1073, 1113,
145129
+ /* 660 */ 510, 366, 1071, 1072, 1073, 1056, 493, 462, 133, 1478,
145130
+ /* 670 */ 351, 249, 249, 822, 65, 65, 152, 440, 1071, 1072,
145131
+ /* 680 */ 1073, 65, 65, 823, 507, 112, 113, 103, 1092, 1092,
145132
+ /* 690 */ 944, 947, 937, 937, 110, 110, 111, 111, 111, 111,
145133
+ /* 700 */ 274, 1071, 1072, 1073, 407, 866, 471, 1219, 1027, 1477,
145134
+ /* 710 */ 478, 767, 1477, 406, 1195, 1347, 1138, 392, 465, 1196,
145135
+ /* 720 */ 987, 256, 270, 500, 987, 445, 1075, 18, 18, 793,
145136
+ /* 730 */ 406, 405, 1347, 1349, 109, 109, 109, 109, 108, 108,
145137
+ /* 740 */ 107, 107, 107, 106, 396, 510, 249, 249, 249, 249,
145138
+ /* 750 */ 249, 249, 221, 510, 366, 251, 435, 246, 925, 507,
145139
+ /* 760 */ 865, 507, 468, 507, 318, 429, 49, 49, 494, 9,
145140
+ /* 770 */ 414, 228, 802, 1075, 50, 50, 277, 1025, 112, 113,
145141
+ /* 780 */ 103, 1092, 1092, 944, 947, 937, 937, 110, 110, 111,
145142
+ /* 790 */ 111, 111, 111, 1006, 249, 249, 510, 406, 1345, 1347,
145143
+ /* 800 */ 249, 249, 967, 454, 1141, 372, 1090, 507, 1007, 135,
145144
+ /* 810 */ 371, 803, 440, 507, 220, 219, 218, 17, 17, 1423,
145145
+ /* 820 */ 460, 510, 440, 1008, 510, 1232, 310, 109, 109, 109,
145146
+ /* 830 */ 109, 108, 108, 107, 107, 107, 106, 396, 510, 1336,
145147
+ /* 840 */ 510, 195, 39, 39, 497, 51, 51, 366, 510, 485,
145148
+ /* 850 */ 1278, 911, 6, 1090, 1192, 985, 386, 260, 221, 52,
145149
+ /* 860 */ 52, 53, 53, 1439, 298, 510, 865, 366, 510, 54,
145150
+ /* 870 */ 54, 112, 113, 103, 1092, 1092, 944, 947, 937, 937,
145151
+ /* 880 */ 110, 110, 111, 111, 111, 111, 55, 55, 865, 40,
145152
+ /* 890 */ 40, 112, 113, 103, 1092, 1092, 944, 947, 937, 937,
145153
+ /* 900 */ 110, 110, 111, 111, 111, 111, 250, 250, 755, 756,
145154
+ /* 910 */ 757, 510, 95, 510, 93, 510, 371, 510, 380, 507,
145155
+ /* 920 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
145156
+ /* 930 */ 396, 510, 41, 41, 43, 43, 44, 44, 56, 56,
145157
+ /* 940 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
145158
+ /* 950 */ 396, 510, 57, 57, 510, 1231, 510, 370, 510, 410,
145159
+ /* 960 */ 510, 416, 293, 510, 1291, 510, 1290, 510, 190, 195,
145160
+ /* 970 */ 510, 319, 58, 58, 1391, 16, 16, 59, 59, 118,
145161
+ /* 980 */ 118, 60, 60, 458, 46, 46, 61, 61, 62, 62,
145162
+ /* 990 */ 510, 47, 47, 1201, 865, 91, 510, 474, 510, 461,
145163
+ /* 1000 */ 510, 461, 510, 228, 510, 507, 510, 390, 510, 841,
145164
+ /* 1010 */ 510, 64, 64, 1449, 840, 366, 811, 140, 140, 141,
145165
+ /* 1020 */ 141, 69, 69, 48, 48, 119, 119, 66, 66, 120,
145166
+ /* 1030 */ 120, 121, 121, 510, 434, 366, 510, 431, 1090, 112,
145167
+ /* 1040 */ 113, 103, 1092, 1092, 944, 947, 937, 937, 110, 110,
145168
+ /* 1050 */ 111, 111, 111, 111, 117, 117, 510, 139, 139, 112,
145169
+ /* 1060 */ 113, 103, 1092, 1092, 944, 947, 937, 937, 110, 110,
145170
+ /* 1070 */ 111, 111, 111, 111, 305, 427, 116, 138, 138, 510,
145171
+ /* 1080 */ 86, 510, 131, 475, 510, 1090, 350, 1026, 109, 109,
145172
+ /* 1090 */ 109, 109, 108, 108, 107, 107, 107, 106, 396, 510,
145173
+ /* 1100 */ 125, 125, 124, 124, 510, 122, 122, 510, 109, 109,
145174
+ /* 1110 */ 109, 109, 108, 108, 107, 107, 107, 106, 396, 777,
145175
+ /* 1120 */ 123, 123, 502, 372, 510, 68, 68, 510, 70, 70,
145176
+ /* 1130 */ 1089, 510, 286, 14, 1278, 300, 1278, 303, 270, 500,
145177
+ /* 1140 */ 373, 153, 841, 94, 202, 67, 67, 840, 38, 38,
145178
+ /* 1150 */ 189, 188, 42, 42, 1278, 1113, 248, 193, 269, 880,
145179
+ /* 1160 */ 132, 428, 33, 366, 418, 1366, 777, 881, 182, 363,
145180
+ /* 1170 */ 1022, 289, 908, 352, 88, 227, 422, 424, 294, 227,
145181
+ /* 1180 */ 227, 88, 446, 366, 19, 223, 903, 112, 113, 103,
145182
+ /* 1190 */ 1092, 1092, 944, 947, 937, 937, 110, 110, 111, 111,
145183
+ /* 1200 */ 111, 111, 381, 308, 436, 430, 88, 112, 101, 103,
145184
+ /* 1210 */ 1092, 1092, 944, 947, 937, 937, 110, 110, 111, 111,
145185
+ /* 1220 */ 111, 111, 391, 417, 791, 801, 800, 808, 809, 970,
145186
+ /* 1230 */ 874, 974, 223, 227, 920, 185, 109, 109, 109, 109,
145187
+ /* 1240 */ 108, 108, 107, 107, 107, 106, 396, 984, 838, 984,
145188
+ /* 1250 */ 204, 96, 983, 1365, 983, 432, 109, 109, 109, 109,
145189
+ /* 1260 */ 108, 108, 107, 107, 107, 106, 396, 316, 295, 775,
145190
+ /* 1270 */ 1228, 791, 130, 299, 1167, 302, 366, 315, 974, 1166,
145191
+ /* 1280 */ 304, 920, 306, 496, 1180, 1164, 1165, 311, 320, 321,
145192
+ /* 1290 */ 1240, 267, 1277, 1215, 1226, 495, 366, 1283, 1147, 1140,
145193
+ /* 1300 */ 1129, 113, 103, 1092, 1092, 944, 947, 937, 937, 110,
145194
+ /* 1310 */ 110, 111, 111, 111, 111, 1128, 441, 241, 183, 1130,
145195
+ /* 1320 */ 1212, 1433, 103, 1092, 1092, 944, 947, 937, 937, 110,
145196
+ /* 1330 */ 110, 111, 111, 111, 111, 349, 323, 325, 327, 288,
145197
+ /* 1340 */ 426, 191, 187, 99, 501, 409, 4, 499, 314, 109,
145198
+ /* 1350 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 396,
145199
+ /* 1360 */ 504, 13, 1163, 1262, 451, 1340, 281, 329, 1339, 109,
145200
+ /* 1370 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 396,
145201
+ /* 1380 */ 1270, 357, 1436, 397, 230, 342, 1107, 186, 1385, 1383,
145202
+ /* 1390 */ 1104, 374, 420, 99, 501, 498, 4, 165, 30, 72,
145203
+ /* 1400 */ 75, 155, 1267, 149, 157, 152, 86, 1259, 412, 160,
145204
+ /* 1410 */ 504, 413, 161, 162, 924, 163, 444, 207, 356, 31,
145205
+ /* 1420 */ 97, 97, 8, 354, 1273, 419, 1334, 98, 169, 397,
145206
+ /* 1430 */ 512, 511, 433, 397, 916, 211, 80, 242, 1354, 439,
145207
+ /* 1440 */ 297, 213, 174, 301, 442, 498, 1131, 214, 215, 359,
145208
+ /* 1450 */ 457, 270, 500, 387, 360, 1183, 482, 1182, 1174, 793,
145209
+ /* 1460 */ 1181, 481, 476, 1154, 924, 916, 916, 918, 919, 25,
145210
+ /* 1470 */ 97, 97, 1155, 313, 1173, 1153, 265, 98, 1448, 397,
145211
+ /* 1480 */ 512, 511, 467, 389, 916, 266, 470, 1223, 99, 501,
145212
+ /* 1490 */ 85, 4, 1224, 229, 480, 489, 332, 331, 322, 181,
145213
+ /* 1500 */ 1402, 11, 1320, 334, 92, 504, 115, 129, 337, 99,
145214
+ /* 1510 */ 501, 324, 4, 1222, 1221, 916, 916, 918, 919, 25,
145215
+ /* 1520 */ 1425, 1060, 399, 326, 328, 253, 504, 1205, 397, 338,
145216
+ /* 1530 */ 348, 348, 347, 238, 345, 87, 339, 764, 479, 340,
145217
+ /* 1540 */ 498, 268, 236, 341, 1137, 29, 1066, 237, 513, 397,
145218
+ /* 1550 */ 198, 482, 276, 240, 514, 239, 483, 1126, 1121, 924,
145219
+ /* 1560 */ 275, 498, 154, 142, 1370, 97, 97, 368, 369, 143,
145220
+ /* 1570 */ 1371, 751, 98, 144, 397, 512, 511, 398, 184, 916,
145221
+ /* 1580 */ 924, 272, 1369, 1368, 128, 197, 97, 97, 845, 1151,
145222
+ /* 1590 */ 200, 1150, 263, 98, 71, 397, 512, 511, 201, 1148,
145223
+ /* 1600 */ 916, 146, 402, 126, 982, 980, 900, 156, 199, 203,
145224
+ /* 1610 */ 916, 916, 918, 919, 25, 145, 158, 825, 996, 206,
145225
+ /* 1620 */ 287, 99, 501, 164, 4, 147, 376, 904, 378, 76,
145226
+ /* 1630 */ 166, 916, 916, 918, 919, 25, 77, 78, 504, 79,
145227
+ /* 1640 */ 148, 999, 367, 208, 209, 995, 137, 270, 500, 20,
145228
+ /* 1650 */ 210, 296, 227, 1101, 438, 212, 988, 170, 171, 32,
145229
+ /* 1660 */ 766, 397, 443, 315, 216, 447, 452, 172, 81, 21,
145230
+ /* 1670 */ 404, 309, 22, 498, 82, 264, 150, 804, 179, 83,
145231
+ /* 1680 */ 459, 151, 180, 950, 482, 1030, 34, 84, 1031, 481,
145232
+ /* 1690 */ 466, 35, 924, 192, 469, 245, 247, 873, 97, 97,
145233
+ /* 1700 */ 175, 226, 96, 868, 1044, 98, 1048, 397, 512, 511,
145234
+ /* 1710 */ 1060, 399, 916, 23, 253, 10, 1046, 1035, 7, 348,
145235
+ /* 1720 */ 348, 347, 238, 345, 333, 176, 764, 88, 965, 24,
145236
+ /* 1730 */ 951, 99, 501, 949, 4, 954, 953, 1005, 1004, 198,
145237
+ /* 1740 */ 232, 276, 231, 916, 916, 918, 919, 25, 504, 275,
145238
+ /* 1750 */ 26, 36, 506, 921, 776, 100, 835, 839, 12, 233,
145239
+ /* 1760 */ 234, 90, 501, 343, 4, 346, 1441, 1440, 1061, 1117,
145240
+ /* 1770 */ 1117, 397, 1117, 1117, 1117, 1117, 1117, 1117, 504, 200,
145241
+ /* 1780 */ 1117, 1117, 1117, 498, 1117, 1117, 1117, 201, 1117, 1117,
145242
+ /* 1790 */ 146, 1117, 1117, 1117, 1117, 1117, 1117, 199, 1117, 1117,
145243
+ /* 1800 */ 1117, 397, 924, 1117, 1117, 1117, 1117, 1117, 97, 97,
145244
+ /* 1810 */ 1117, 1117, 1117, 498, 1117, 98, 1117, 397, 512, 511,
145245
+ /* 1820 */ 1117, 1117, 916, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145246
+ /* 1830 */ 1117, 367, 924, 1117, 1117, 1117, 270, 500, 97, 97,
145247
+ /* 1840 */ 1117, 1117, 1117, 1117, 1117, 98, 1117, 397, 512, 511,
145248
+ /* 1850 */ 1117, 1117, 916, 916, 916, 918, 919, 25, 1117, 404,
145249
+ /* 1860 */ 1117, 1117, 1117, 253, 1117, 1117, 1117, 1117, 348, 348,
145250
+ /* 1870 */ 347, 238, 345, 1117, 1117, 764, 1117, 1117, 1117, 1117,
145251
+ /* 1880 */ 1117, 1117, 1117, 916, 916, 918, 919, 25, 198, 1117,
145252
+ /* 1890 */ 276, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 275, 1117,
145253
+ /* 1900 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145254
+ /* 1910 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145255
+ /* 1920 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 200, 1117,
145256
+ /* 1930 */ 1117, 1117, 1117, 1117, 1117, 1117, 201, 1117, 1117, 146,
145257
+ /* 1940 */ 1117, 1117, 1117, 1117, 1117, 1117, 199, 1117, 1117, 1117,
145258
+ /* 1950 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145259
+ /* 1960 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145260
+ /* 1970 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145261
+ /* 1980 */ 367, 1117, 1117, 1117, 1117, 270, 500, 1117, 1117, 1117,
145262
+ /* 1990 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145263
+ /* 2000 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 404,
141891145264
};
141892145265
static const YYCODETYPE yy_lookahead[] = {
141893
- /* 0 */ 174, 226, 227, 228, 226, 227, 228, 172, 145, 146,
141894
- /* 10 */ 147, 148, 149, 150, 153, 169, 170, 171, 155, 19,
141895
- /* 20 */ 157, 246, 192, 193, 177, 181, 182, 164, 169, 170,
141896
- /* 30 */ 171, 31, 164, 153, 190, 174, 175, 187, 153, 39,
141897
- /* 40 */ 7, 8, 9, 43, 44, 45, 46, 47, 48, 49,
141898
- /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 174, 196,
141899
- /* 60 */ 197, 226, 227, 228, 196, 197, 46, 47, 48, 49,
141900
- /* 70 */ 209, 208, 19, 226, 227, 228, 208, 174, 177, 26,
141901
- /* 80 */ 195, 213, 214, 22, 221, 85, 86, 87, 88, 89,
141902
- /* 90 */ 90, 91, 92, 93, 94, 95, 43, 44, 45, 46,
141903
- /* 100 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
141904
- /* 110 */ 57, 172, 249, 153, 53, 153, 147, 148, 149, 150,
141905
- /* 120 */ 22, 23, 69, 103, 155, 19, 157, 226, 227, 228,
141906
- /* 130 */ 94, 95, 247, 164, 174, 175, 174, 175, 85, 86,
141907
- /* 140 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 43,
141908
- /* 150 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
141909
- /* 160 */ 54, 55, 56, 57, 153, 196, 197, 153, 153, 209,
141910
- /* 170 */ 210, 209, 210, 67, 95, 161, 237, 208, 19, 165,
141911
- /* 180 */ 165, 242, 84, 24, 91, 92, 93, 94, 95, 223,
141912
- /* 190 */ 221, 85, 86, 87, 88, 89, 90, 91, 92, 93,
141913
- /* 200 */ 94, 95, 43, 44, 45, 46, 47, 48, 49, 50,
141914
- /* 210 */ 51, 52, 53, 54, 55, 56, 57, 153, 249, 85,
141915
- /* 220 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
141916
- /* 230 */ 219, 19, 109, 110, 111, 23, 89, 90, 91, 92,
141917
- /* 240 */ 93, 94, 95, 73, 85, 86, 87, 88, 89, 90,
141918
- /* 250 */ 91, 92, 93, 94, 95, 43, 44, 45, 46, 47,
141919
- /* 260 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
141920
- /* 270 */ 153, 22, 23, 101, 173, 26, 104, 105, 106, 109,
141921
- /* 280 */ 110, 111, 181, 11, 19, 59, 114, 73, 23, 110,
141922
- /* 290 */ 111, 174, 175, 116, 80, 118, 119, 85, 86, 87,
141923
- /* 300 */ 88, 89, 90, 91, 92, 93, 94, 95, 43, 44,
141924
- /* 310 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
141925
- /* 320 */ 55, 56, 57, 109, 98, 99, 100, 101, 83, 153,
141926
- /* 330 */ 104, 105, 106, 84, 120, 121, 153, 19, 192, 193,
141927
- /* 340 */ 114, 23, 89, 90, 99, 59, 23, 230, 103, 26,
141928
- /* 350 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
141929
- /* 360 */ 95, 43, 44, 45, 46, 47, 48, 49, 50, 51,
141930
- /* 370 */ 52, 53, 54, 55, 56, 57, 153, 91, 153, 134,
141931
- /* 380 */ 135, 136, 110, 111, 98, 99, 100, 134, 153, 136,
141932
- /* 390 */ 19, 22, 23, 26, 23, 26, 80, 174, 175, 174,
141933
- /* 400 */ 175, 59, 219, 85, 86, 87, 88, 89, 90, 91,
141934
- /* 410 */ 92, 93, 94, 95, 43, 44, 45, 46, 47, 48,
141935
- /* 420 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 16,
141936
- /* 430 */ 153, 22, 209, 210, 209, 210, 120, 121, 196, 197,
141937
- /* 440 */ 98, 99, 100, 19, 46, 22, 23, 23, 252, 253,
141938
- /* 450 */ 208, 174, 175, 84, 219, 153, 85, 86, 87, 88,
141939
- /* 460 */ 89, 90, 91, 92, 93, 94, 95, 43, 44, 45,
141940
- /* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
141941
- /* 480 */ 56, 57, 153, 153, 153, 153, 209, 120, 121, 76,
141942
- /* 490 */ 153, 78, 109, 110, 111, 97, 19, 153, 89, 90,
141943
- /* 500 */ 198, 59, 183, 174, 175, 174, 175, 84, 153, 85,
141944
- /* 510 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
141945
- /* 520 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
141946
- /* 530 */ 53, 54, 55, 56, 57, 16, 197, 153, 22, 153,
141947
- /* 540 */ 153, 99, 198, 12, 153, 196, 197, 208, 153, 153,
141948
- /* 550 */ 195, 183, 19, 23, 222, 142, 26, 208, 27, 153,
141949
- /* 560 */ 174, 175, 85, 86, 87, 88, 89, 90, 91, 92,
141950
- /* 570 */ 93, 94, 95, 42, 188, 59, 43, 44, 45, 46,
141951
- /* 580 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
141952
- /* 590 */ 57, 195, 22, 198, 63, 76, 153, 78, 167, 168,
141953
- /* 600 */ 153, 195, 167, 168, 73, 153, 222, 153, 19, 222,
141954
- /* 610 */ 153, 220, 153, 24, 98, 99, 100, 140, 85, 86,
141955
- /* 620 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 59,
141956
- /* 630 */ 100, 153, 43, 44, 45, 46, 47, 48, 49, 50,
141957
- /* 640 */ 51, 52, 53, 54, 55, 56, 57, 195, 153, 195,
141958
- /* 650 */ 153, 153, 174, 175, 26, 125, 120, 121, 153, 213,
141959
- /* 660 */ 214, 19, 153, 220, 153, 153, 188, 220, 98, 99,
141960
- /* 670 */ 100, 174, 175, 140, 85, 86, 87, 88, 89, 90,
141961
- /* 680 */ 91, 92, 93, 94, 95, 43, 44, 45, 46, 47,
145266
+ /* 0 */ 163, 163, 184, 238, 239, 240, 182, 182, 155, 156,
145267
+ /* 10 */ 157, 158, 159, 160, 163, 184, 187, 184, 165, 19,
145268
+ /* 20 */ 167, 184, 185, 258, 238, 239, 240, 174, 163, 174,
145269
+ /* 30 */ 187, 31, 191, 192, 163, 184, 185, 202, 203, 39,
145270
+ /* 40 */ 175, 200, 163, 43, 44, 45, 46, 47, 48, 49,
145271
+ /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 174, 206,
145272
+ /* 60 */ 207, 206, 207, 238, 239, 240, 163, 238, 239, 240,
145273
+ /* 70 */ 59, 233, 219, 249, 219, 202, 203, 174, 254, 224,
145274
+ /* 80 */ 225, 238, 239, 240, 163, 232, 73, 184, 185, 163,
145275
+ /* 90 */ 206, 207, 92, 93, 94, 95, 96, 97, 98, 99,
145276
+ /* 100 */ 100, 101, 102, 219, 233, 184, 185, 96, 97, 206,
145277
+ /* 110 */ 207, 274, 19, 276, 261, 104, 105, 106, 107, 198,
145278
+ /* 120 */ 109, 163, 219, 220, 221, 274, 275, 102, 117, 116,
145279
+ /* 130 */ 117, 118, 19, 175, 208, 81, 43, 44, 45, 46,
145280
+ /* 140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
145281
+ /* 150 */ 57, 197, 141, 195, 143, 197, 43, 44, 45, 46,
145282
+ /* 160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
145283
+ /* 170 */ 57, 98, 99, 100, 101, 102, 83, 163, 85, 163,
145284
+ /* 180 */ 67, 127, 128, 117, 118, 92, 93, 94, 95, 96,
145285
+ /* 190 */ 97, 98, 99, 100, 101, 102, 19, 54, 55, 56,
145286
+ /* 200 */ 57, 58, 163, 26, 163, 92, 93, 94, 95, 96,
145287
+ /* 210 */ 97, 98, 99, 100, 101, 102, 54, 55, 56, 57,
145288
+ /* 220 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
145289
+ /* 230 */ 53, 54, 55, 56, 57, 92, 93, 94, 95, 96,
145290
+ /* 240 */ 97, 98, 99, 100, 101, 102, 69, 96, 97, 98,
145291
+ /* 250 */ 99, 100, 101, 102, 92, 93, 94, 95, 96, 97,
145292
+ /* 260 */ 98, 99, 100, 101, 102, 96, 97, 101, 102, 92,
145293
+ /* 270 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
145294
+ /* 280 */ 108, 267, 268, 111, 112, 113, 163, 163, 163, 19,
145295
+ /* 290 */ 179, 180, 181, 121, 24, 59, 92, 93, 94, 95,
145296
+ /* 300 */ 96, 97, 98, 99, 100, 101, 102, 184, 185, 268,
145297
+ /* 310 */ 141, 163, 143, 43, 44, 45, 46, 47, 48, 49,
145298
+ /* 320 */ 50, 51, 52, 53, 54, 55, 56, 57, 157, 158,
145299
+ /* 330 */ 159, 160, 46, 47, 48, 49, 165, 59, 167, 163,
145300
+ /* 340 */ 90, 105, 106, 107, 108, 174, 73, 111, 112, 113,
145301
+ /* 350 */ 19, 22, 163, 205, 81, 231, 106, 121, 233, 163,
145302
+ /* 360 */ 110, 16, 92, 93, 94, 95, 96, 97, 98, 99,
145303
+ /* 370 */ 100, 101, 102, 184, 185, 163, 98, 206, 207, 26,
145304
+ /* 380 */ 184, 185, 19, 105, 106, 107, 23, 198, 59, 116,
145305
+ /* 390 */ 219, 141, 142, 143, 198, 22, 110, 274, 275, 234,
145306
+ /* 400 */ 127, 128, 123, 232, 125, 126, 43, 44, 45, 46,
145307
+ /* 410 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
145308
+ /* 420 */ 57, 158, 77, 160, 79, 59, 53, 163, 165, 163,
145309
+ /* 430 */ 167, 163, 261, 102, 105, 106, 107, 174, 72, 108,
145310
+ /* 440 */ 109, 110, 111, 112, 113, 114, 59, 163, 184, 185,
145311
+ /* 450 */ 22, 120, 163, 206, 207, 92, 93, 94, 95, 96,
145312
+ /* 460 */ 97, 98, 99, 100, 101, 102, 219, 255, 163, 206,
145313
+ /* 470 */ 207, 105, 106, 107, 208, 19, 163, 90, 163, 23,
145314
+ /* 480 */ 127, 128, 219, 183, 220, 221, 163, 59, 163, 184,
145315
+ /* 490 */ 185, 191, 105, 106, 149, 232, 163, 110, 163, 43,
145316
+ /* 500 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
145317
+ /* 510 */ 54, 55, 56, 57, 230, 22, 23, 184, 185, 26,
145318
+ /* 520 */ 205, 163, 199, 59, 261, 220, 221, 163, 141, 142,
145319
+ /* 530 */ 143, 198, 174, 105, 106, 107, 72, 269, 163, 59,
145320
+ /* 540 */ 205, 163, 184, 185, 22, 116, 117, 118, 92, 93,
145321
+ /* 550 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 184,
145322
+ /* 560 */ 185, 163, 184, 185, 206, 207, 163, 163, 19, 105,
145323
+ /* 570 */ 106, 107, 23, 22, 259, 174, 198, 219, 220, 22,
145324
+ /* 580 */ 255, 59, 184, 185, 91, 105, 106, 107, 184, 185,
145325
+ /* 590 */ 22, 23, 43, 44, 45, 46, 47, 48, 49, 50,
145326
+ /* 600 */ 51, 52, 53, 54, 55, 56, 57, 206, 207, 163,
145327
+ /* 610 */ 59, 76, 132, 179, 180, 181, 59, 242, 220, 221,
145328
+ /* 620 */ 219, 86, 12, 163, 220, 221, 163, 105, 106, 107,
145329
+ /* 630 */ 184, 185, 59, 230, 171, 234, 163, 27, 175, 174,
145330
+ /* 640 */ 26, 92, 93, 94, 95, 96, 97, 98, 99, 100,
145331
+ /* 650 */ 101, 102, 42, 163, 163, 59, 105, 106, 107, 91,
145332
+ /* 660 */ 163, 19, 105, 106, 107, 23, 220, 221, 208, 264,
145333
+ /* 670 */ 265, 206, 207, 63, 184, 185, 81, 163, 105, 106,
145334
+ /* 680 */ 107, 184, 185, 73, 219, 43, 44, 45, 46, 47,
141962145335
/* 690 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
141963
- /* 700 */ 243, 189, 243, 198, 172, 250, 251, 117, 31, 201,
141964
- /* 710 */ 26, 139, 122, 141, 19, 220, 39, 29, 220, 211,
141965
- /* 720 */ 24, 33, 153, 164, 153, 164, 19, 85, 86, 87,
141966
- /* 730 */ 88, 89, 90, 91, 92, 93, 94, 95, 43, 44,
141967
- /* 740 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
141968
- /* 750 */ 55, 56, 57, 65, 243, 196, 197, 196, 197, 131,
141969
- /* 760 */ 189, 22, 103, 24, 153, 23, 19, 208, 26, 208,
141970
- /* 770 */ 102, 103, 113, 23, 242, 22, 26, 134, 164, 136,
141971
- /* 780 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
141972
- /* 790 */ 95, 44, 45, 46, 47, 48, 49, 50, 51, 52,
141973
- /* 800 */ 53, 54, 55, 56, 57, 98, 153, 153, 124, 153,
141974
- /* 810 */ 196, 197, 23, 23, 61, 26, 26, 19, 23, 123,
141975
- /* 820 */ 23, 26, 208, 26, 7, 8, 153, 22, 174, 175,
141976
- /* 830 */ 174, 175, 85, 86, 87, 88, 89, 90, 91, 92,
141977
- /* 840 */ 93, 94, 95, 45, 46, 47, 48, 49, 50, 51,
141978
- /* 850 */ 52, 53, 54, 55, 56, 57, 19, 20, 59, 22,
141979
- /* 860 */ 111, 59, 164, 23, 59, 23, 26, 153, 26, 59,
141980
- /* 870 */ 153, 72, 23, 36, 72, 26, 35, 23, 59, 134,
141981
- /* 880 */ 26, 136, 133, 85, 86, 87, 88, 89, 90, 91,
141982
- /* 890 */ 92, 93, 94, 95, 196, 197, 59, 98, 99, 100,
141983
- /* 900 */ 98, 99, 100, 98, 99, 100, 208, 66, 71, 99,
141984
- /* 910 */ 54, 55, 56, 57, 58, 74, 153, 80, 99, 19,
141985
- /* 920 */ 83, 223, 23, 26, 153, 26, 89, 90, 54, 55,
141986
- /* 930 */ 56, 57, 153, 96, 153, 98, 99, 100, 22, 153,
141987
- /* 940 */ 103, 85, 86, 87, 88, 89, 90, 91, 92, 93,
141988
- /* 950 */ 94, 95, 183, 112, 158, 174, 175, 120, 121, 85,
141989
- /* 960 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
141990
- /* 970 */ 215, 134, 135, 136, 137, 138, 0, 1, 2, 23,
141991
- /* 980 */ 21, 5, 26, 153, 22, 59, 10, 11, 12, 13,
141992
- /* 990 */ 14, 1, 2, 17, 212, 5, 153, 153, 98, 153,
141993
- /* 1000 */ 10, 11, 12, 13, 14, 108, 30, 17, 32, 193,
141994
- /* 1010 */ 153, 59, 153, 153, 170, 171, 40, 174, 175, 153,
141995
- /* 1020 */ 30, 59, 32, 19, 20, 99, 22, 170, 171, 233,
141996
- /* 1030 */ 40, 188, 236, 174, 175, 153, 153, 153, 79, 123,
141997
- /* 1040 */ 36, 89, 90, 153, 153, 153, 70, 188, 153, 97,
141998
- /* 1050 */ 98, 99, 100, 77, 102, 153, 80, 81, 174, 175,
141999
- /* 1060 */ 70, 99, 110, 59, 105, 174, 175, 77, 153, 238,
142000
- /* 1070 */ 80, 81, 188, 19, 20, 71, 22, 153, 153, 235,
142001
- /* 1080 */ 19, 22, 164, 24, 59, 153, 134, 83, 136, 153,
142002
- /* 1090 */ 36, 115, 235, 89, 90, 91, 120, 121, 153, 153,
142003
- /* 1100 */ 96, 142, 98, 99, 100, 115, 59, 103, 83, 239,
142004
- /* 1110 */ 120, 121, 199, 59, 196, 197, 153, 153, 59, 143,
142005
- /* 1120 */ 174, 175, 153, 98, 99, 71, 208, 153, 103, 165,
142006
- /* 1130 */ 153, 19, 20, 143, 22, 153, 153, 83, 134, 135,
142007
- /* 1140 */ 136, 137, 138, 89, 90, 98, 99, 100, 36, 185,
142008
- /* 1150 */ 96, 187, 98, 99, 100, 91, 95, 103, 99, 134,
142009
- /* 1160 */ 135, 136, 101, 102, 103, 104, 105, 106, 107, 153,
142010
- /* 1170 */ 26, 59, 125, 164, 113, 153, 153, 153, 212, 12,
142011
- /* 1180 */ 19, 117, 153, 71, 153, 212, 122, 164, 134, 135,
142012
- /* 1190 */ 136, 137, 138, 212, 27, 83, 212, 174, 175, 59,
142013
- /* 1200 */ 200, 89, 90, 174, 175, 196, 197, 46, 96, 42,
142014
- /* 1210 */ 98, 99, 100, 172, 151, 103, 5, 208, 203, 196,
142015
- /* 1220 */ 197, 10, 11, 12, 13, 14, 216, 216, 17, 244,
142016
- /* 1230 */ 63, 208, 209, 210, 153, 80, 24, 203, 98, 99,
142017
- /* 1240 */ 100, 30, 22, 32, 100, 164, 134, 135, 136, 137,
142018
- /* 1250 */ 138, 40, 148, 164, 150, 174, 175, 102, 97, 155,
142019
- /* 1260 */ 203, 157, 164, 244, 178, 125, 186, 182, 164, 125,
142020
- /* 1270 */ 177, 59, 177, 177, 113, 120, 121, 196, 197, 59,
142021
- /* 1280 */ 232, 70, 153, 216, 202, 196, 197, 153, 77, 208,
142022
- /* 1290 */ 209, 80, 81, 156, 196, 197, 60, 208, 248, 200,
142023
- /* 1300 */ 196, 197, 153, 174, 175, 123, 208, 153, 174, 175,
142024
- /* 1310 */ 160, 99, 208, 153, 38, 153, 160, 153, 98, 99,
142025
- /* 1320 */ 100, 153, 245, 174, 175, 221, 115, 153, 174, 175,
142026
- /* 1330 */ 153, 120, 121, 245, 174, 175, 174, 175, 174, 175,
142027
- /* 1340 */ 160, 153, 174, 175, 153, 225, 153, 22, 174, 175,
142028
- /* 1350 */ 97, 174, 175, 249, 143, 153, 224, 153, 43, 153,
142029
- /* 1360 */ 191, 153, 174, 175, 18, 174, 175, 174, 175, 153,
142030
- /* 1370 */ 131, 153, 194, 203, 153, 194, 174, 175, 174, 175,
142031
- /* 1380 */ 174, 175, 174, 175, 153, 160, 153, 18, 153, 194,
142032
- /* 1390 */ 174, 175, 174, 175, 153, 174, 175, 153, 225, 153,
142033
- /* 1400 */ 203, 153, 159, 153, 194, 174, 175, 174, 175, 174,
142034
- /* 1410 */ 175, 153, 203, 153, 224, 174, 175, 191, 174, 175,
142035
- /* 1420 */ 174, 175, 174, 175, 174, 175, 203, 160, 153, 191,
142036
- /* 1430 */ 153, 159, 174, 175, 174, 175, 153, 139, 62, 153,
142037
- /* 1440 */ 241, 153, 160, 153, 159, 153, 22, 240, 179, 174,
142038
- /* 1450 */ 175, 174, 175, 160, 159, 97, 160, 174, 175, 159,
142039
- /* 1460 */ 174, 175, 174, 175, 174, 175, 174, 175, 179, 64,
142040
- /* 1470 */ 176, 184, 108, 176, 95, 176, 234, 126, 176, 234,
142041
- /* 1480 */ 179, 178, 176, 176, 176, 97, 218, 217, 184, 179,
142042
- /* 1490 */ 179, 218, 218, 160, 22, 217, 217, 160, 218, 139,
142043
- /* 1500 */ 229, 217, 130, 129, 127, 25, 128, 163, 26, 162,
142044
- /* 1510 */ 13, 206, 231, 154, 6, 154, 207, 205, 204, 203,
142045
- /* 1520 */ 152, 166, 152, 152, 172, 172, 172, 4, 172, 166,
142046
- /* 1530 */ 180, 166, 3, 22, 172, 144, 15, 180, 172, 172,
142047
- /* 1540 */ 82, 16, 23, 23, 121, 254, 132, 172, 112, 124,
142048
- /* 1550 */ 24, 20, 126, 16, 1, 124, 112, 61, 53, 37,
142049
- /* 1560 */ 133, 132, 53, 53, 112, 53, 98, 254, 251, 34,
142050
- /* 1570 */ 123, 1, 5, 22, 97, 142, 26, 75, 123, 41,
142051
- /* 1580 */ 97, 68, 68, 24, 20, 19, 113, 22, 107, 28,
142052
- /* 1590 */ 22, 67, 23, 22, 22, 67, 22, 67, 23, 37,
142053
- /* 1600 */ 23, 23, 26, 23, 22, 24, 23, 22, 24, 123,
142054
- /* 1610 */ 23, 23, 22, 98, 125, 26, 11, 23, 26, 23,
142055
- /* 1620 */ 34, 23, 23, 23, 23, 34, 22, 34, 26, 22,
142056
- /* 1630 */ 22, 15, 23, 23, 22, 117, 23, 22, 1, 123,
142057
- /* 1640 */ 26, 23, 255, 255, 255, 255, 255, 255, 255, 255,
142058
- /* 1650 */ 123, 255, 255, 255, 255, 123, 123, 255, 255, 255,
142059
- /* 1660 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142060
- /* 1670 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142061
- /* 1680 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142062
- /* 1690 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142063
- /* 1700 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142064
- /* 1710 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142065
- /* 1720 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142066
- /* 1730 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142067
- /* 1740 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142068
- /* 1750 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142069
- /* 1760 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142070
- /* 1770 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142071
- /* 1780 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142072
- /* 1790 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142073
- /* 1800 */ 255, 255,
142074
-};
142075
-#define YY_SHIFT_COUNT (489)
145336
+ /* 700 */ 163, 105, 106, 107, 109, 132, 163, 226, 22, 23,
145337
+ /* 710 */ 220, 21, 26, 163, 174, 163, 174, 220, 174, 205,
145338
+ /* 720 */ 29, 230, 127, 128, 33, 19, 59, 184, 185, 115,
145339
+ /* 730 */ 180, 181, 180, 181, 92, 93, 94, 95, 96, 97,
145340
+ /* 740 */ 98, 99, 100, 101, 102, 163, 206, 207, 206, 207,
145341
+ /* 750 */ 206, 207, 46, 163, 19, 22, 65, 23, 23, 219,
145342
+ /* 760 */ 26, 219, 174, 219, 163, 163, 184, 185, 174, 22,
145343
+ /* 770 */ 80, 24, 35, 106, 184, 185, 163, 91, 43, 44,
145344
+ /* 780 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
145345
+ /* 790 */ 55, 56, 57, 12, 206, 207, 163, 247, 163, 247,
145346
+ /* 800 */ 206, 207, 112, 66, 177, 178, 59, 219, 27, 208,
145347
+ /* 810 */ 104, 74, 163, 219, 116, 117, 118, 184, 185, 153,
145348
+ /* 820 */ 154, 163, 163, 42, 163, 163, 120, 92, 93, 94,
145349
+ /* 830 */ 95, 96, 97, 98, 99, 100, 101, 102, 163, 149,
145350
+ /* 840 */ 163, 107, 184, 185, 63, 184, 185, 19, 163, 270,
145351
+ /* 850 */ 163, 23, 273, 106, 205, 11, 119, 255, 46, 184,
145352
+ /* 860 */ 185, 184, 185, 130, 205, 163, 132, 19, 163, 184,
145353
+ /* 870 */ 185, 43, 44, 45, 46, 47, 48, 49, 50, 51,
145354
+ /* 880 */ 52, 53, 54, 55, 56, 57, 184, 185, 26, 184,
145355
+ /* 890 */ 185, 43, 44, 45, 46, 47, 48, 49, 50, 51,
145356
+ /* 900 */ 52, 53, 54, 55, 56, 57, 206, 207, 7, 8,
145357
+ /* 910 */ 9, 163, 146, 163, 148, 163, 104, 163, 231, 219,
145358
+ /* 920 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
145359
+ /* 930 */ 102, 163, 184, 185, 184, 185, 184, 185, 184, 185,
145360
+ /* 940 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
145361
+ /* 950 */ 102, 163, 184, 185, 163, 163, 163, 168, 163, 163,
145362
+ /* 960 */ 163, 117, 118, 163, 237, 163, 237, 163, 26, 107,
145363
+ /* 970 */ 163, 163, 184, 185, 163, 184, 185, 184, 185, 184,
145364
+ /* 980 */ 185, 184, 185, 98, 184, 185, 184, 185, 184, 185,
145365
+ /* 990 */ 163, 184, 185, 207, 132, 147, 163, 19, 163, 272,
145366
+ /* 1000 */ 163, 272, 163, 24, 163, 219, 163, 199, 163, 124,
145367
+ /* 1010 */ 163, 184, 185, 23, 129, 19, 26, 184, 185, 184,
145368
+ /* 1020 */ 185, 184, 185, 184, 185, 184, 185, 184, 185, 184,
145369
+ /* 1030 */ 185, 184, 185, 163, 245, 19, 163, 248, 59, 43,
145370
+ /* 1040 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
145371
+ /* 1050 */ 54, 55, 56, 57, 184, 185, 163, 184, 185, 43,
145372
+ /* 1060 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
145373
+ /* 1070 */ 54, 55, 56, 57, 16, 19, 22, 184, 185, 163,
145374
+ /* 1080 */ 138, 163, 22, 105, 163, 106, 22, 23, 92, 93,
145375
+ /* 1090 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 163,
145376
+ /* 1100 */ 184, 185, 184, 185, 163, 184, 185, 163, 92, 93,
145377
+ /* 1110 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 59,
145378
+ /* 1120 */ 184, 185, 177, 178, 163, 184, 185, 163, 184, 185,
145379
+ /* 1130 */ 26, 163, 163, 182, 163, 77, 163, 79, 127, 128,
145380
+ /* 1140 */ 262, 263, 124, 147, 24, 184, 185, 129, 184, 185,
145381
+ /* 1150 */ 96, 97, 184, 185, 163, 91, 224, 225, 211, 31,
145382
+ /* 1160 */ 22, 105, 24, 19, 118, 163, 106, 39, 24, 222,
145383
+ /* 1170 */ 23, 23, 23, 26, 26, 26, 23, 23, 23, 26,
145384
+ /* 1180 */ 26, 26, 23, 19, 22, 26, 140, 43, 44, 45,
145385
+ /* 1190 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
145386
+ /* 1200 */ 56, 57, 231, 23, 231, 254, 26, 43, 44, 45,
145387
+ /* 1210 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
145388
+ /* 1220 */ 56, 57, 231, 61, 59, 109, 110, 7, 8, 23,
145389
+ /* 1230 */ 23, 59, 26, 26, 59, 131, 92, 93, 94, 95,
145390
+ /* 1240 */ 96, 97, 98, 99, 100, 101, 102, 141, 23, 143,
145391
+ /* 1250 */ 130, 26, 141, 163, 143, 163, 92, 93, 94, 95,
145392
+ /* 1260 */ 96, 97, 98, 99, 100, 101, 102, 110, 163, 23,
145393
+ /* 1270 */ 163, 106, 26, 163, 193, 163, 19, 120, 106, 193,
145394
+ /* 1280 */ 163, 106, 163, 203, 163, 163, 193, 163, 163, 163,
145395
+ /* 1290 */ 163, 223, 163, 163, 163, 163, 19, 163, 163, 163,
145396
+ /* 1300 */ 163, 44, 45, 46, 47, 48, 49, 50, 51, 52,
145397
+ /* 1310 */ 53, 54, 55, 56, 57, 163, 251, 250, 209, 163,
145398
+ /* 1320 */ 223, 163, 45, 46, 47, 48, 49, 50, 51, 52,
145399
+ /* 1330 */ 53, 54, 55, 56, 57, 161, 223, 223, 223, 256,
145400
+ /* 1340 */ 256, 196, 182, 19, 20, 227, 22, 244, 187, 92,
145401
+ /* 1350 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
145402
+ /* 1360 */ 36, 210, 192, 213, 188, 187, 227, 227, 187, 92,
145403
+ /* 1370 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
145404
+ /* 1380 */ 213, 213, 166, 59, 130, 212, 60, 210, 170, 170,
145405
+ /* 1390 */ 38, 170, 104, 19, 20, 71, 22, 22, 235, 257,
145406
+ /* 1400 */ 257, 260, 236, 43, 201, 81, 138, 213, 18, 204,
145407
+ /* 1410 */ 36, 170, 204, 204, 90, 204, 18, 169, 236, 235,
145408
+ /* 1420 */ 96, 97, 48, 213, 201, 213, 213, 103, 201, 105,
145409
+ /* 1430 */ 106, 107, 170, 59, 110, 169, 146, 170, 253, 62,
145410
+ /* 1440 */ 252, 169, 22, 170, 189, 71, 170, 169, 169, 189,
145411
+ /* 1450 */ 104, 127, 128, 64, 189, 186, 82, 186, 194, 115,
145412
+ /* 1460 */ 186, 87, 133, 188, 90, 141, 142, 143, 144, 145,
145413
+ /* 1470 */ 96, 97, 186, 186, 194, 186, 246, 103, 186, 105,
145414
+ /* 1480 */ 106, 107, 189, 102, 110, 246, 189, 229, 19, 20,
145415
+ /* 1490 */ 104, 22, 229, 170, 84, 134, 22, 271, 228, 217,
145416
+ /* 1500 */ 269, 22, 241, 170, 146, 36, 137, 152, 217, 19,
145417
+ /* 1510 */ 20, 228, 22, 229, 229, 141, 142, 143, 144, 145,
145418
+ /* 1520 */ 0, 1, 2, 228, 228, 5, 36, 218, 59, 216,
145419
+ /* 1530 */ 10, 11, 12, 13, 14, 136, 215, 17, 135, 214,
145420
+ /* 1540 */ 71, 243, 25, 213, 173, 26, 13, 164, 172, 59,
145421
+ /* 1550 */ 30, 82, 32, 6, 162, 164, 87, 162, 162, 90,
145422
+ /* 1560 */ 40, 71, 263, 176, 182, 96, 97, 266, 266, 176,
145423
+ /* 1570 */ 182, 4, 103, 176, 105, 106, 107, 3, 22, 110,
145424
+ /* 1580 */ 90, 151, 182, 182, 190, 15, 96, 97, 98, 182,
145425
+ /* 1590 */ 70, 182, 190, 103, 182, 105, 106, 107, 78, 182,
145426
+ /* 1600 */ 110, 81, 89, 16, 23, 23, 128, 139, 88, 24,
145427
+ /* 1610 */ 141, 142, 143, 144, 145, 119, 131, 20, 1, 133,
145428
+ /* 1620 */ 16, 19, 20, 131, 22, 119, 61, 140, 37, 53,
145429
+ /* 1630 */ 139, 141, 142, 143, 144, 145, 53, 53, 36, 53,
145430
+ /* 1640 */ 119, 105, 122, 34, 130, 1, 5, 127, 128, 22,
145431
+ /* 1650 */ 104, 149, 26, 75, 41, 130, 68, 68, 104, 24,
145432
+ /* 1660 */ 20, 59, 19, 120, 114, 67, 67, 22, 22, 22,
145433
+ /* 1670 */ 150, 23, 22, 71, 22, 67, 37, 28, 23, 138,
145434
+ /* 1680 */ 22, 153, 23, 23, 82, 23, 22, 26, 23, 87,
145435
+ /* 1690 */ 24, 22, 90, 130, 24, 23, 23, 105, 96, 97,
145436
+ /* 1700 */ 22, 34, 26, 132, 85, 103, 75, 105, 106, 107,
145437
+ /* 1710 */ 1, 2, 110, 34, 5, 34, 83, 23, 44, 10,
145438
+ /* 1720 */ 11, 12, 13, 14, 24, 26, 17, 26, 23, 34,
145439
+ /* 1730 */ 23, 19, 20, 23, 22, 11, 23, 23, 23, 30,
145440
+ /* 1740 */ 22, 32, 26, 141, 142, 143, 144, 145, 36, 40,
145441
+ /* 1750 */ 22, 22, 26, 23, 23, 22, 124, 23, 22, 130,
145442
+ /* 1760 */ 130, 19, 20, 23, 22, 15, 130, 130, 1, 277,
145443
+ /* 1770 */ 277, 59, 277, 277, 277, 277, 277, 277, 36, 70,
145444
+ /* 1780 */ 277, 277, 277, 71, 277, 277, 277, 78, 277, 277,
145445
+ /* 1790 */ 81, 277, 277, 277, 277, 277, 277, 88, 277, 277,
145446
+ /* 1800 */ 277, 59, 90, 277, 277, 277, 277, 277, 96, 97,
145447
+ /* 1810 */ 277, 277, 277, 71, 277, 103, 277, 105, 106, 107,
145448
+ /* 1820 */ 277, 277, 110, 277, 277, 277, 277, 277, 277, 277,
145449
+ /* 1830 */ 277, 122, 90, 277, 277, 277, 127, 128, 96, 97,
145450
+ /* 1840 */ 277, 277, 277, 277, 277, 103, 277, 105, 106, 107,
145451
+ /* 1850 */ 277, 277, 110, 141, 142, 143, 144, 145, 277, 150,
145452
+ /* 1860 */ 277, 277, 277, 5, 277, 277, 277, 277, 10, 11,
145453
+ /* 1870 */ 12, 13, 14, 277, 277, 17, 277, 277, 277, 277,
145454
+ /* 1880 */ 277, 277, 277, 141, 142, 143, 144, 145, 30, 277,
145455
+ /* 1890 */ 32, 277, 277, 277, 277, 277, 277, 277, 40, 277,
145456
+ /* 1900 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145457
+ /* 1910 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145458
+ /* 1920 */ 277, 277, 277, 277, 277, 277, 277, 277, 70, 277,
145459
+ /* 1930 */ 277, 277, 277, 277, 277, 277, 78, 277, 277, 81,
145460
+ /* 1940 */ 277, 277, 277, 277, 277, 277, 88, 277, 277, 277,
145461
+ /* 1950 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145462
+ /* 1960 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145463
+ /* 1970 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145464
+ /* 1980 */ 122, 277, 277, 277, 277, 127, 128, 277, 277, 277,
145465
+ /* 1990 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145466
+ /* 2000 */ 277, 277, 277, 277, 277, 277, 277, 277, 150, 277,
145467
+ /* 2010 */ 277, 277, 277, 277, 277, 277, 277, 277, 277,
145468
+};
145469
+#define YY_SHIFT_COUNT (515)
142076145470
#define YY_SHIFT_MIN (0)
142077
-#define YY_SHIFT_MAX (1637)
145471
+#define YY_SHIFT_MAX (1858)
142078145472
static const unsigned short int yy_shift_ofst[] = {
142079
- /* 0 */ 990, 976, 1211, 837, 837, 316, 1054, 1054, 1054, 1054,
142080
- /* 10 */ 214, 0, 0, 106, 642, 1054, 1054, 1054, 1054, 1054,
142081
- /* 20 */ 1054, 1054, 1054, 952, 952, 226, 1155, 316, 316, 316,
142082
- /* 30 */ 316, 316, 316, 53, 159, 212, 265, 318, 371, 424,
142083
- /* 40 */ 477, 533, 589, 642, 642, 642, 642, 642, 642, 642,
142084
- /* 50 */ 642, 642, 642, 642, 642, 642, 642, 642, 642, 642,
142085
- /* 60 */ 695, 642, 747, 798, 798, 1004, 1054, 1054, 1054, 1054,
142086
- /* 70 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
142087
- /* 80 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
142088
- /* 90 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1112, 1054, 1054,
142089
- /* 100 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
142090
- /* 110 */ 1054, 856, 874, 874, 874, 874, 874, 134, 147, 93,
142091
- /* 120 */ 342, 959, 1161, 253, 253, 342, 367, 367, 367, 367,
142092
- /* 130 */ 179, 36, 79, 1657, 1657, 1657, 1061, 1061, 1061, 516,
142093
- /* 140 */ 799, 516, 516, 531, 531, 802, 249, 369, 342, 342,
142094
- /* 150 */ 342, 342, 342, 342, 342, 342, 342, 342, 342, 342,
142095
- /* 160 */ 342, 342, 342, 342, 342, 342, 342, 342, 342, 272,
142096
- /* 170 */ 442, 442, 536, 1657, 1657, 1657, 1025, 245, 245, 570,
142097
- /* 180 */ 172, 286, 805, 1047, 1140, 1220, 342, 342, 342, 342,
142098
- /* 190 */ 342, 342, 342, 342, 170, 342, 342, 342, 342, 342,
142099
- /* 200 */ 342, 342, 342, 342, 342, 342, 342, 841, 841, 841,
142100
- /* 210 */ 342, 342, 342, 342, 530, 342, 342, 342, 1059, 342,
142101
- /* 220 */ 342, 1167, 342, 342, 342, 342, 342, 342, 342, 342,
142102
- /* 230 */ 123, 688, 177, 1212, 1212, 1212, 1212, 1144, 177, 177,
142103
- /* 240 */ 1064, 409, 33, 628, 707, 707, 900, 628, 628, 900,
142104
- /* 250 */ 897, 323, 398, 677, 677, 677, 707, 572, 684, 590,
142105
- /* 260 */ 739, 1236, 1182, 1182, 1276, 1276, 1182, 1253, 1325, 1315,
142106
- /* 270 */ 1239, 1346, 1346, 1346, 1346, 1182, 1369, 1239, 1239, 1253,
142107
- /* 280 */ 1325, 1315, 1315, 1239, 1182, 1369, 1298, 1376, 1182, 1369,
142108
- /* 290 */ 1424, 1182, 1369, 1182, 1369, 1424, 1358, 1358, 1358, 1405,
142109
- /* 300 */ 1424, 1358, 1364, 1358, 1405, 1358, 1358, 1424, 1379, 1379,
142110
- /* 310 */ 1424, 1351, 1388, 1351, 1388, 1351, 1388, 1351, 1388, 1182,
142111
- /* 320 */ 1472, 1182, 1360, 1372, 1377, 1374, 1378, 1239, 1480, 1482,
142112
- /* 330 */ 1497, 1497, 1508, 1508, 1508, 1657, 1657, 1657, 1657, 1657,
142113
- /* 340 */ 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657,
142114
- /* 350 */ 1657, 20, 413, 98, 423, 519, 383, 962, 742, 61,
142115
- /* 360 */ 696, 749, 750, 753, 789, 790, 795, 797, 840, 842,
142116
- /* 370 */ 810, 668, 817, 659, 819, 849, 854, 899, 643, 745,
142117
- /* 380 */ 956, 926, 916, 1523, 1529, 1511, 1391, 1521, 1458, 1525,
142118
- /* 390 */ 1519, 1520, 1423, 1414, 1436, 1526, 1425, 1531, 1426, 1537,
142119
- /* 400 */ 1553, 1431, 1427, 1444, 1496, 1522, 1429, 1505, 1509, 1510,
142120
- /* 410 */ 1512, 1452, 1468, 1535, 1447, 1570, 1567, 1551, 1477, 1433,
142121
- /* 420 */ 1513, 1550, 1514, 1502, 1538, 1455, 1483, 1559, 1564, 1566,
142122
- /* 430 */ 1473, 1481, 1565, 1524, 1568, 1571, 1569, 1572, 1528, 1561,
142123
- /* 440 */ 1574, 1530, 1562, 1575, 1577, 1578, 1576, 1580, 1582, 1581,
142124
- /* 450 */ 1583, 1585, 1584, 1486, 1587, 1588, 1515, 1586, 1590, 1489,
142125
- /* 460 */ 1589, 1591, 1592, 1593, 1594, 1596, 1598, 1589, 1599, 1600,
142126
- /* 470 */ 1602, 1601, 1604, 1605, 1607, 1608, 1609, 1610, 1612, 1613,
142127
- /* 480 */ 1615, 1614, 1518, 1516, 1527, 1532, 1533, 1618, 1616, 1637,
142128
-};
142129
-#define YY_REDUCE_COUNT (350)
142130
-#define YY_REDUCE_MIN (-225)
142131
-#define YY_REDUCE_MAX (1375)
145473
+ /* 0 */ 1709, 1520, 1858, 1324, 1324, 54, 1374, 1469, 1602, 1712,
145474
+ /* 10 */ 1712, 1712, 1712, 1712, 273, 0, 0, 113, 1016, 1712,
145475
+ /* 20 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 11, 11, 236,
145476
+ /* 30 */ 595, 54, 54, 54, 54, 54, 54, 93, 177, 270,
145477
+ /* 40 */ 363, 456, 549, 642, 735, 828, 848, 996, 1144, 1016,
145478
+ /* 50 */ 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
145479
+ /* 60 */ 1016, 1016, 1016, 1016, 1016, 1016, 1164, 1016, 1257, 1277,
145480
+ /* 70 */ 1277, 1490, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
145481
+ /* 80 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
145482
+ /* 90 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
145483
+ /* 100 */ 1712, 1712, 1712, 1742, 1712, 1712, 1712, 1712, 1712, 1712,
145484
+ /* 110 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 143, 162, 162,
145485
+ /* 120 */ 162, 162, 162, 204, 151, 73, 596, 690, 706, 596,
145486
+ /* 130 */ 169, 169, 596, 353, 353, 353, 353, 66, 166, 25,
145487
+ /* 140 */ 2009, 2009, 331, 331, 331, 329, 366, 329, 329, 610,
145488
+ /* 150 */ 610, 428, 464, 493, 686, 596, 596, 596, 596, 596,
145489
+ /* 160 */ 596, 596, 596, 596, 596, 596, 596, 596, 596, 596,
145490
+ /* 170 */ 596, 596, 596, 596, 596, 596, 596, 844, 667, 666,
145491
+ /* 180 */ 666, 535, 667, 1011, 2009, 2009, 2009, 387, 250, 250,
145492
+ /* 190 */ 522, 172, 278, 551, 480, 573, 557, 596, 596, 596,
145493
+ /* 200 */ 596, 596, 596, 596, 596, 13, 596, 596, 596, 596,
145494
+ /* 210 */ 596, 596, 596, 596, 596, 596, 596, 596, 737, 737,
145495
+ /* 220 */ 737, 596, 596, 596, 596, 734, 596, 596, 596, 747,
145496
+ /* 230 */ 596, 596, 781, 596, 596, 596, 596, 596, 596, 596,
145497
+ /* 240 */ 596, 429, 691, 279, 979, 979, 979, 979, 862, 279,
145498
+ /* 250 */ 279, 885, 1054, 901, 942, 978, 978, 1056, 942, 942,
145499
+ /* 260 */ 1056, 614, 990, 812, 1128, 1128, 1128, 978, 766, 1104,
145500
+ /* 270 */ 1018, 1138, 1326, 1254, 1254, 1352, 1352, 1254, 1288, 1375,
145501
+ /* 280 */ 1360, 1268, 1390, 1390, 1390, 1390, 1254, 1398, 1268, 1268,
145502
+ /* 290 */ 1288, 1375, 1360, 1360, 1268, 1254, 1398, 1290, 1377, 1254,
145503
+ /* 300 */ 1398, 1420, 1254, 1398, 1254, 1398, 1420, 1346, 1346, 1346,
145504
+ /* 310 */ 1389, 1420, 1346, 1344, 1346, 1389, 1346, 1346, 1420, 1381,
145505
+ /* 320 */ 1381, 1420, 1329, 1386, 1329, 1386, 1329, 1386, 1329, 1386,
145506
+ /* 330 */ 1254, 1361, 1410, 1474, 1479, 1254, 1358, 1369, 1361, 1355,
145507
+ /* 340 */ 1399, 1403, 1268, 1517, 1519, 1533, 1533, 1547, 1547, 1547,
145508
+ /* 350 */ 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
145509
+ /* 360 */ 2009, 2009, 2009, 2009, 2009, 2009, 286, 345, 568, 1064,
145510
+ /* 370 */ 1058, 698, 1060, 1147, 373, 1120, 1046, 1148, 1162, 1149,
145511
+ /* 380 */ 1153, 1154, 1155, 1159, 1180, 1165, 1116, 1220, 1157, 1172,
145512
+ /* 390 */ 1206, 1207, 1225, 1106, 1111, 1246, 1175, 733, 1567, 1574,
145513
+ /* 400 */ 1556, 1430, 1570, 1513, 1587, 1581, 1582, 1478, 1468, 1496,
145514
+ /* 410 */ 1585, 1485, 1597, 1486, 1604, 1617, 1492, 1487, 1506, 1565,
145515
+ /* 420 */ 1591, 1491, 1576, 1583, 1584, 1586, 1521, 1536, 1609, 1514,
145516
+ /* 430 */ 1644, 1641, 1627, 1546, 1502, 1588, 1626, 1589, 1578, 1613,
145517
+ /* 440 */ 1525, 1554, 1635, 1640, 1643, 1543, 1550, 1645, 1598, 1646,
145518
+ /* 450 */ 1647, 1648, 1650, 1599, 1649, 1652, 1608, 1639, 1655, 1541,
145519
+ /* 460 */ 1658, 1528, 1659, 1660, 1661, 1662, 1664, 1666, 1665, 1669,
145520
+ /* 470 */ 1670, 1563, 1672, 1673, 1592, 1667, 1678, 1571, 1676, 1679,
145521
+ /* 480 */ 1681, 1619, 1631, 1633, 1674, 1694, 1700, 1699, 1701, 1695,
145522
+ /* 490 */ 1705, 1707, 1710, 1676, 1713, 1714, 1716, 1715, 1718, 1724,
145523
+ /* 500 */ 1728, 1729, 1730, 1731, 1733, 1734, 1736, 1726, 1632, 1629,
145524
+ /* 510 */ 1630, 1636, 1637, 1740, 1750, 1767,
145525
+};
145526
+#define YY_REDUCE_COUNT (365)
145527
+#define YY_REDUCE_MIN (-235)
145528
+#define YY_REDUCE_MAX (1417)
142132145529
static const short yy_reduce_ofst[] = {
142133
- /* 0 */ -137, -31, 1104, 1023, 1081, -132, -40, -38, 223, 225,
142134
- /* 10 */ 698, -153, -99, -225, -165, 386, 478, 843, 859, -139,
142135
- /* 20 */ 884, 117, 277, 844, 857, 964, 559, 561, 614, 918,
142136
- /* 30 */ 1009, 1089, 1098, -222, -222, -222, -222, -222, -222, -222,
142137
- /* 40 */ -222, -222, -222, -222, -222, -222, -222, -222, -222, -222,
142138
- /* 50 */ -222, -222, -222, -222, -222, -222, -222, -222, -222, -222,
142139
- /* 60 */ -222, -222, -222, -222, -222, 329, 331, 497, 654, 656,
142140
- /* 70 */ 781, 891, 946, 1029, 1129, 1134, 1149, 1154, 1160, 1162,
142141
- /* 80 */ 1164, 1168, 1174, 1177, 1188, 1191, 1193, 1202, 1204, 1206,
142142
- /* 90 */ 1208, 1216, 1218, 1221, 1231, 1233, 1235, 1241, 1244, 1246,
142143
- /* 100 */ 1248, 1250, 1258, 1260, 1275, 1277, 1283, 1286, 1288, 1290,
142144
- /* 110 */ 1292, -222, -222, -222, -222, -222, -222, -222, -222, -222,
142145
- /* 120 */ -115, 796, -156, -154, -141, 14, 242, 349, 242, 349,
142146
- /* 130 */ -61, -222, -222, -222, -222, -222, 101, 101, 101, 332,
142147
- /* 140 */ 302, 384, 387, -170, 146, 344, 196, 196, 15, 11,
142148
- /* 150 */ 183, 235, 395, 355, 396, 406, 452, 457, 391, 459,
142149
- /* 160 */ 443, 447, 511, 495, 454, 512, 505, 571, 498, 532,
142150
- /* 170 */ 431, 435, 339, 455, 446, 508, -174, -116, -97, -120,
142151
- /* 180 */ -150, 64, 176, 330, 337, 509, 569, 611, 653, 673,
142152
- /* 190 */ 714, 717, 763, 771, -34, 779, 786, 830, 846, 860,
142153
- /* 200 */ 866, 882, 883, 890, 892, 895, 902, 319, 368, 769,
142154
- /* 210 */ 915, 924, 925, 932, 755, 936, 945, 963, 782, 969,
142155
- /* 220 */ 974, 816, 977, 64, 982, 983, 1016, 1022, 1024, 1031,
142156
- /* 230 */ 870, 831, 913, 966, 973, 981, 984, 755, 913, 913,
142157
- /* 240 */ 1000, 1041, 1063, 1015, 1010, 1011, 985, 1034, 1057, 1019,
142158
- /* 250 */ 1086, 1080, 1085, 1093, 1095, 1096, 1067, 1048, 1082, 1099,
142159
- /* 260 */ 1137, 1050, 1150, 1156, 1077, 1088, 1180, 1120, 1132, 1169,
142160
- /* 270 */ 1170, 1178, 1181, 1195, 1210, 1225, 1243, 1197, 1209, 1173,
142161
- /* 280 */ 1190, 1226, 1238, 1223, 1267, 1272, 1199, 1207, 1282, 1285,
142162
- /* 290 */ 1269, 1293, 1295, 1296, 1300, 1289, 1294, 1297, 1299, 1287,
142163
- /* 300 */ 1301, 1302, 1303, 1306, 1304, 1307, 1308, 1310, 1242, 1245,
142164
- /* 310 */ 1311, 1268, 1270, 1273, 1278, 1274, 1279, 1280, 1284, 1333,
142165
- /* 320 */ 1271, 1337, 1281, 1309, 1305, 1312, 1314, 1316, 1344, 1347,
142166
- /* 330 */ 1359, 1361, 1368, 1370, 1371, 1291, 1313, 1317, 1355, 1352,
142167
- /* 340 */ 1353, 1354, 1356, 1363, 1350, 1357, 1362, 1366, 1367, 1375,
142168
- /* 350 */ 1365,
145530
+ /* 0 */ -147, 171, 263, -97, 358, -145, -149, -163, 123, 264,
145531
+ /* 10 */ 305, 398, 404, 446, 401, -171, -157, -235, -175, -79,
145532
+ /* 20 */ 189, 196, 333, 490, 378, 375, 497, 550, 552, -42,
145533
+ /* 30 */ -116, 465, 540, 542, 544, 588, 594, -214, -214, -214,
145534
+ /* 40 */ -214, -214, -214, -214, -214, -214, -214, -214, -214, -214,
145535
+ /* 50 */ -214, -214, -214, -214, -214, -214, -214, -214, -214, -214,
145536
+ /* 60 */ -214, -214, -214, -214, -214, -214, -214, -214, -214, -214,
145537
+ /* 70 */ -214, 543, 582, 590, 633, 658, 661, 675, 677, 685,
145538
+ /* 80 */ 702, 705, 748, 750, 752, 754, 768, 788, 791, 793,
145539
+ /* 90 */ 795, 797, 800, 802, 804, 807, 827, 833, 835, 837,
145540
+ /* 100 */ 839, 841, 843, 845, 847, 870, 873, 893, 916, 918,
145541
+ /* 110 */ 921, 936, 941, 944, 961, 964, 968, -214, -214, -214,
145542
+ /* 120 */ -214, -214, -214, -214, -214, -214, 315, 789, -159, 14,
145543
+ /* 130 */ 111, 434, 463, 247, 700, 247, 700, -176, -214, -214,
145544
+ /* 140 */ -214, -214, 300, 300, 300, -162, -74, -129, 125, -165,
145545
+ /* 150 */ -127, 268, 266, 405, 405, -135, 284, 403, 491, 460,
145546
+ /* 160 */ 148, 335, 514, 649, 212, 124, 325, 687, 971, 602,
145547
+ /* 170 */ 973, 659, 323, 601, 808, 991, 41, 951, 627, 727,
145548
+ /* 180 */ 729, 579, 945, 786, 878, 932, 947, -182, -169, -167,
145549
+ /* 190 */ -121, -46, 16, 39, 176, 289, 313, 364, 473, 537,
145550
+ /* 200 */ 613, 635, 662, 792, 796, 165, 811, 969, 1002, 1090,
145551
+ /* 210 */ 1092, 1105, 1107, 1110, 1112, 1117, 1119, 1121, 1081, 1086,
145552
+ /* 220 */ 1093, 1122, 1124, 1125, 1126, 481, 1127, 1129, 1130, 1068,
145553
+ /* 230 */ 1131, 1132, 1080, 1134, 16, 1135, 1136, 1137, 1152, 1156,
145554
+ /* 240 */ 1158, 1065, 1067, 1109, 1097, 1113, 1114, 1115, 481, 1109,
145555
+ /* 250 */ 1109, 1151, 1160, 1174, 1150, 1118, 1139, 1083, 1167, 1168,
145556
+ /* 260 */ 1084, 1176, 1145, 1170, 1161, 1178, 1181, 1140, 1103, 1173,
145557
+ /* 270 */ 1177, 1216, 1141, 1218, 1219, 1142, 1143, 1221, 1166, 1163,
145558
+ /* 280 */ 1203, 1194, 1205, 1208, 1209, 1211, 1241, 1248, 1210, 1212,
145559
+ /* 290 */ 1182, 1184, 1223, 1227, 1213, 1262, 1266, 1185, 1188, 1267,
145560
+ /* 300 */ 1272, 1255, 1273, 1278, 1276, 1279, 1260, 1269, 1271, 1274,
145561
+ /* 310 */ 1264, 1265, 1286, 1275, 1287, 1280, 1289, 1292, 1293, 1230,
145562
+ /* 320 */ 1239, 1297, 1258, 1270, 1263, 1283, 1284, 1295, 1285, 1296,
145563
+ /* 330 */ 1323, 1282, 1226, 1231, 1261, 1333, 1298, 1309, 1291, 1313,
145564
+ /* 340 */ 1321, 1325, 1330, 1371, 1376, 1383, 1391, 1392, 1395, 1396,
145565
+ /* 350 */ 1301, 1302, 1299, 1387, 1382, 1388, 1400, 1401, 1393, 1394,
145566
+ /* 360 */ 1402, 1407, 1409, 1412, 1417, 1397,
142169145567
};
142170145568
static const YYACTIONTYPE yy_default[] = {
142171
- /* 0 */ 1389, 1389, 1389, 1261, 1046, 1151, 1261, 1261, 1261, 1261,
142172
- /* 10 */ 1046, 1181, 1181, 1312, 1077, 1046, 1046, 1046, 1046, 1046,
142173
- /* 20 */ 1046, 1260, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142174
- /* 30 */ 1046, 1046, 1046, 1187, 1046, 1046, 1046, 1046, 1262, 1263,
142175
- /* 40 */ 1046, 1046, 1046, 1311, 1313, 1197, 1196, 1195, 1194, 1294,
142176
- /* 50 */ 1168, 1192, 1185, 1189, 1256, 1257, 1255, 1259, 1262, 1263,
142177
- /* 60 */ 1046, 1188, 1226, 1240, 1225, 1046, 1046, 1046, 1046, 1046,
142178
- /* 70 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142179
- /* 80 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142180
- /* 90 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142181
- /* 100 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142182
- /* 110 */ 1046, 1234, 1239, 1246, 1238, 1235, 1228, 1227, 1229, 1230,
142183
- /* 120 */ 1046, 1067, 1116, 1046, 1046, 1046, 1329, 1328, 1046, 1046,
142184
- /* 130 */ 1077, 1231, 1232, 1243, 1242, 1241, 1319, 1345, 1344, 1046,
142185
- /* 140 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142186
- /* 150 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142187
- /* 160 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1077,
142188
- /* 170 */ 1073, 1073, 1046, 1324, 1151, 1142, 1046, 1046, 1046, 1046,
142189
- /* 180 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1316, 1314, 1046,
142190
- /* 190 */ 1276, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142191
- /* 200 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142192
- /* 210 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1147, 1046,
142193
- /* 220 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1339,
142194
- /* 230 */ 1046, 1289, 1130, 1147, 1147, 1147, 1147, 1149, 1131, 1129,
142195
- /* 240 */ 1141, 1077, 1053, 1191, 1170, 1170, 1378, 1191, 1191, 1378,
142196
- /* 250 */ 1091, 1359, 1088, 1181, 1181, 1181, 1170, 1258, 1148, 1141,
142197
- /* 260 */ 1046, 1381, 1156, 1156, 1380, 1380, 1156, 1200, 1206, 1119,
142198
- /* 270 */ 1191, 1125, 1125, 1125, 1125, 1156, 1064, 1191, 1191, 1200,
142199
- /* 280 */ 1206, 1119, 1119, 1191, 1156, 1064, 1293, 1375, 1156, 1064,
142200
- /* 290 */ 1269, 1156, 1064, 1156, 1064, 1269, 1117, 1117, 1117, 1106,
142201
- /* 300 */ 1269, 1117, 1091, 1117, 1106, 1117, 1117, 1269, 1273, 1273,
142202
- /* 310 */ 1269, 1174, 1169, 1174, 1169, 1174, 1169, 1174, 1169, 1156,
142203
- /* 320 */ 1264, 1156, 1046, 1186, 1175, 1184, 1182, 1191, 1070, 1109,
142204
- /* 330 */ 1342, 1342, 1338, 1338, 1338, 1386, 1386, 1324, 1354, 1077,
142205
- /* 340 */ 1077, 1077, 1077, 1354, 1093, 1093, 1077, 1077, 1077, 1077,
142206
- /* 350 */ 1354, 1046, 1046, 1046, 1046, 1046, 1046, 1349, 1046, 1278,
142207
- /* 360 */ 1160, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142208
- /* 370 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142209
- /* 380 */ 1046, 1046, 1211, 1046, 1049, 1321, 1046, 1046, 1320, 1046,
142210
- /* 390 */ 1046, 1046, 1046, 1046, 1046, 1161, 1046, 1046, 1046, 1046,
142211
- /* 400 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142212
- /* 410 */ 1046, 1046, 1046, 1046, 1377, 1046, 1046, 1046, 1046, 1046,
142213
- /* 420 */ 1046, 1292, 1291, 1046, 1046, 1158, 1046, 1046, 1046, 1046,
142214
- /* 430 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142215
- /* 440 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142216
- /* 450 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142217
- /* 460 */ 1183, 1046, 1176, 1046, 1046, 1046, 1046, 1368, 1046, 1046,
142218
- /* 470 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142219
- /* 480 */ 1046, 1363, 1133, 1213, 1046, 1212, 1216, 1046, 1058, 1046,
145569
+ /* 0 */ 1482, 1482, 1482, 1329, 1115, 1220, 1115, 1115, 1115, 1329,
145570
+ /* 10 */ 1329, 1329, 1329, 1329, 1115, 1250, 1250, 1380, 1146, 1115,
145571
+ /* 20 */ 1115, 1115, 1115, 1115, 1115, 1328, 1115, 1115, 1115, 1115,
145572
+ /* 30 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1256, 1115,
145573
+ /* 40 */ 1115, 1115, 1115, 1115, 1330, 1331, 1115, 1115, 1115, 1379,
145574
+ /* 50 */ 1381, 1266, 1265, 1264, 1263, 1362, 1237, 1261, 1254, 1258,
145575
+ /* 60 */ 1324, 1325, 1323, 1327, 1330, 1331, 1115, 1257, 1295, 1309,
145576
+ /* 70 */ 1294, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145577
+ /* 80 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145578
+ /* 90 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145579
+ /* 100 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145580
+ /* 110 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1303, 1308, 1314,
145581
+ /* 120 */ 1307, 1304, 1297, 1296, 1298, 1299, 1115, 1136, 1185, 1115,
145582
+ /* 130 */ 1115, 1115, 1115, 1397, 1396, 1115, 1115, 1146, 1300, 1301,
145583
+ /* 140 */ 1311, 1310, 1387, 1438, 1437, 1115, 1115, 1115, 1115, 1115,
145584
+ /* 150 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145585
+ /* 160 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145586
+ /* 170 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1146, 1142, 1420,
145587
+ /* 180 */ 1420, 1406, 1142, 1115, 1392, 1220, 1211, 1115, 1115, 1115,
145588
+ /* 190 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1384, 1382,
145589
+ /* 200 */ 1115, 1344, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145590
+ /* 210 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145591
+ /* 220 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1216,
145592
+ /* 230 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145593
+ /* 240 */ 1432, 1115, 1357, 1199, 1216, 1216, 1216, 1216, 1218, 1200,
145594
+ /* 250 */ 1198, 1210, 1146, 1122, 1260, 1239, 1239, 1471, 1260, 1260,
145595
+ /* 260 */ 1471, 1160, 1452, 1157, 1250, 1250, 1250, 1239, 1326, 1217,
145596
+ /* 270 */ 1210, 1115, 1474, 1225, 1225, 1473, 1473, 1225, 1269, 1275,
145597
+ /* 280 */ 1188, 1260, 1194, 1194, 1194, 1194, 1225, 1133, 1260, 1260,
145598
+ /* 290 */ 1269, 1275, 1188, 1188, 1260, 1225, 1133, 1361, 1468, 1225,
145599
+ /* 300 */ 1133, 1337, 1225, 1133, 1225, 1133, 1337, 1186, 1186, 1186,
145600
+ /* 310 */ 1175, 1337, 1186, 1160, 1186, 1175, 1186, 1186, 1337, 1341,
145601
+ /* 320 */ 1341, 1337, 1243, 1238, 1243, 1238, 1243, 1238, 1243, 1238,
145602
+ /* 330 */ 1225, 1244, 1405, 1115, 1332, 1225, 1115, 1255, 1244, 1418,
145603
+ /* 340 */ 1253, 1251, 1260, 1139, 1178, 1435, 1435, 1431, 1431, 1431,
145604
+ /* 350 */ 1479, 1479, 1392, 1447, 1146, 1146, 1146, 1146, 1447, 1162,
145605
+ /* 360 */ 1162, 1146, 1146, 1146, 1146, 1447, 1115, 1115, 1115, 1115,
145606
+ /* 370 */ 1115, 1115, 1442, 1115, 1346, 1229, 1115, 1115, 1115, 1115,
145607
+ /* 380 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145608
+ /* 390 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1280, 1115, 1118,
145609
+ /* 400 */ 1389, 1115, 1115, 1388, 1115, 1115, 1115, 1115, 1115, 1115,
145610
+ /* 410 */ 1230, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145611
+ /* 420 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1470,
145612
+ /* 430 */ 1115, 1115, 1115, 1115, 1115, 1115, 1360, 1359, 1115, 1115,
145613
+ /* 440 */ 1227, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145614
+ /* 450 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145615
+ /* 460 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145616
+ /* 470 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1252, 1115,
145617
+ /* 480 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1419, 1245, 1115,
145618
+ /* 490 */ 1115, 1115, 1115, 1461, 1115, 1115, 1115, 1115, 1115, 1115,
145619
+ /* 500 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1456, 1202, 1282,
145620
+ /* 510 */ 1115, 1281, 1285, 1115, 1127, 1115,
142220145621
};
142221145622
/********** End of lemon-generated parsing tables *****************************/
142222145623
142223145624
/* The next table maps tokens (terminal symbols) into fallback tokens.
142224145625
** If a construct like the following:
@@ -142310,15 +145711,22 @@
142310145711
59, /* RAISE => ID */
142311145712
59, /* RECURSIVE => ID */
142312145713
59, /* REPLACE => ID */
142313145714
59, /* RESTRICT => ID */
142314145715
59, /* ROW => ID */
145716
+ 59, /* ROWS => ID */
142315145717
59, /* TRIGGER => ID */
142316145718
59, /* VACUUM => ID */
142317145719
59, /* VIEW => ID */
142318145720
59, /* VIRTUAL => ID */
142319145721
59, /* WITH => ID */
145722
+ 59, /* CURRENT => ID */
145723
+ 59, /* FOLLOWING => ID */
145724
+ 59, /* PARTITION => ID */
145725
+ 59, /* PRECEDING => ID */
145726
+ 59, /* RANGE => ID */
145727
+ 59, /* UNBOUNDED => ID */
142320145728
59, /* REINDEX => ID */
142321145729
59, /* RENAME => ID */
142322145730
59, /* CTIME_KW => ID */
142323145731
};
142324145732
#endif /* YYFALLBACK */
@@ -142481,189 +145889,211 @@
142481145889
/* 71 */ "RAISE",
142482145890
/* 72 */ "RECURSIVE",
142483145891
/* 73 */ "REPLACE",
142484145892
/* 74 */ "RESTRICT",
142485145893
/* 75 */ "ROW",
142486
- /* 76 */ "TRIGGER",
142487
- /* 77 */ "VACUUM",
142488
- /* 78 */ "VIEW",
142489
- /* 79 */ "VIRTUAL",
142490
- /* 80 */ "WITH",
142491
- /* 81 */ "REINDEX",
142492
- /* 82 */ "RENAME",
142493
- /* 83 */ "CTIME_KW",
142494
- /* 84 */ "ANY",
142495
- /* 85 */ "BITAND",
142496
- /* 86 */ "BITOR",
142497
- /* 87 */ "LSHIFT",
142498
- /* 88 */ "RSHIFT",
142499
- /* 89 */ "PLUS",
142500
- /* 90 */ "MINUS",
142501
- /* 91 */ "STAR",
142502
- /* 92 */ "SLASH",
142503
- /* 93 */ "REM",
142504
- /* 94 */ "CONCAT",
142505
- /* 95 */ "COLLATE",
142506
- /* 96 */ "BITNOT",
142507
- /* 97 */ "ON",
142508
- /* 98 */ "INDEXED",
142509
- /* 99 */ "STRING",
142510
- /* 100 */ "JOIN_KW",
142511
- /* 101 */ "CONSTRAINT",
142512
- /* 102 */ "DEFAULT",
142513
- /* 103 */ "NULL",
142514
- /* 104 */ "PRIMARY",
142515
- /* 105 */ "UNIQUE",
142516
- /* 106 */ "CHECK",
142517
- /* 107 */ "REFERENCES",
142518
- /* 108 */ "AUTOINCR",
142519
- /* 109 */ "INSERT",
142520
- /* 110 */ "DELETE",
142521
- /* 111 */ "UPDATE",
142522
- /* 112 */ "SET",
142523
- /* 113 */ "DEFERRABLE",
142524
- /* 114 */ "FOREIGN",
142525
- /* 115 */ "DROP",
142526
- /* 116 */ "UNION",
142527
- /* 117 */ "ALL",
142528
- /* 118 */ "EXCEPT",
142529
- /* 119 */ "INTERSECT",
142530
- /* 120 */ "SELECT",
142531
- /* 121 */ "VALUES",
142532
- /* 122 */ "DISTINCT",
142533
- /* 123 */ "DOT",
142534
- /* 124 */ "FROM",
142535
- /* 125 */ "JOIN",
142536
- /* 126 */ "USING",
142537
- /* 127 */ "ORDER",
142538
- /* 128 */ "GROUP",
142539
- /* 129 */ "HAVING",
142540
- /* 130 */ "LIMIT",
142541
- /* 131 */ "WHERE",
142542
- /* 132 */ "INTO",
142543
- /* 133 */ "NOTHING",
142544
- /* 134 */ "FLOAT",
142545
- /* 135 */ "BLOB",
142546
- /* 136 */ "INTEGER",
142547
- /* 137 */ "VARIABLE",
142548
- /* 138 */ "CASE",
142549
- /* 139 */ "WHEN",
142550
- /* 140 */ "THEN",
142551
- /* 141 */ "ELSE",
142552
- /* 142 */ "INDEX",
142553
- /* 143 */ "ALTER",
142554
- /* 144 */ "ADD",
142555
- /* 145 */ "input",
142556
- /* 146 */ "cmdlist",
142557
- /* 147 */ "ecmd",
142558
- /* 148 */ "cmdx",
142559
- /* 149 */ "explain",
142560
- /* 150 */ "cmd",
142561
- /* 151 */ "transtype",
142562
- /* 152 */ "trans_opt",
142563
- /* 153 */ "nm",
142564
- /* 154 */ "savepoint_opt",
142565
- /* 155 */ "create_table",
142566
- /* 156 */ "create_table_args",
142567
- /* 157 */ "createkw",
142568
- /* 158 */ "temp",
142569
- /* 159 */ "ifnotexists",
142570
- /* 160 */ "dbnm",
142571
- /* 161 */ "columnlist",
142572
- /* 162 */ "conslist_opt",
142573
- /* 163 */ "table_options",
142574
- /* 164 */ "select",
142575
- /* 165 */ "columnname",
142576
- /* 166 */ "carglist",
142577
- /* 167 */ "typetoken",
142578
- /* 168 */ "typename",
142579
- /* 169 */ "signed",
142580
- /* 170 */ "plus_num",
142581
- /* 171 */ "minus_num",
142582
- /* 172 */ "scanpt",
142583
- /* 173 */ "ccons",
142584
- /* 174 */ "term",
142585
- /* 175 */ "expr",
142586
- /* 176 */ "onconf",
142587
- /* 177 */ "sortorder",
142588
- /* 178 */ "autoinc",
142589
- /* 179 */ "eidlist_opt",
142590
- /* 180 */ "refargs",
142591
- /* 181 */ "defer_subclause",
142592
- /* 182 */ "refarg",
142593
- /* 183 */ "refact",
142594
- /* 184 */ "init_deferred_pred_opt",
142595
- /* 185 */ "conslist",
142596
- /* 186 */ "tconscomma",
142597
- /* 187 */ "tcons",
142598
- /* 188 */ "sortlist",
142599
- /* 189 */ "eidlist",
142600
- /* 190 */ "defer_subclause_opt",
142601
- /* 191 */ "orconf",
142602
- /* 192 */ "resolvetype",
142603
- /* 193 */ "raisetype",
142604
- /* 194 */ "ifexists",
142605
- /* 195 */ "fullname",
142606
- /* 196 */ "selectnowith",
142607
- /* 197 */ "oneselect",
142608
- /* 198 */ "wqlist",
142609
- /* 199 */ "multiselect_op",
142610
- /* 200 */ "distinct",
142611
- /* 201 */ "selcollist",
142612
- /* 202 */ "from",
142613
- /* 203 */ "where_opt",
142614
- /* 204 */ "groupby_opt",
142615
- /* 205 */ "having_opt",
142616
- /* 206 */ "orderby_opt",
142617
- /* 207 */ "limit_opt",
142618
- /* 208 */ "values",
142619
- /* 209 */ "nexprlist",
142620
- /* 210 */ "exprlist",
142621
- /* 211 */ "sclp",
142622
- /* 212 */ "as",
142623
- /* 213 */ "seltablist",
142624
- /* 214 */ "stl_prefix",
142625
- /* 215 */ "joinop",
142626
- /* 216 */ "indexed_opt",
142627
- /* 217 */ "on_opt",
142628
- /* 218 */ "using_opt",
142629
- /* 219 */ "xfullname",
142630
- /* 220 */ "idlist",
142631
- /* 221 */ "with",
142632
- /* 222 */ "setlist",
142633
- /* 223 */ "insert_cmd",
142634
- /* 224 */ "idlist_opt",
142635
- /* 225 */ "upsert",
142636
- /* 226 */ "likeop",
142637
- /* 227 */ "between_op",
142638
- /* 228 */ "in_op",
142639
- /* 229 */ "paren_exprlist",
142640
- /* 230 */ "case_operand",
142641
- /* 231 */ "case_exprlist",
142642
- /* 232 */ "case_else",
142643
- /* 233 */ "uniqueflag",
142644
- /* 234 */ "collate",
142645
- /* 235 */ "nmnum",
142646
- /* 236 */ "trigger_decl",
142647
- /* 237 */ "trigger_cmd_list",
142648
- /* 238 */ "trigger_time",
142649
- /* 239 */ "trigger_event",
142650
- /* 240 */ "foreach_clause",
142651
- /* 241 */ "when_clause",
142652
- /* 242 */ "trigger_cmd",
142653
- /* 243 */ "trnm",
142654
- /* 244 */ "tridxby",
142655
- /* 245 */ "database_kw_opt",
142656
- /* 246 */ "key_opt",
142657
- /* 247 */ "add_column_fullname",
142658
- /* 248 */ "kwcolumn_opt",
142659
- /* 249 */ "create_vtab",
142660
- /* 250 */ "vtabarglist",
142661
- /* 251 */ "vtabarg",
142662
- /* 252 */ "vtabargtoken",
142663
- /* 253 */ "lp",
142664
- /* 254 */ "anylist",
145894
+ /* 76 */ "ROWS",
145895
+ /* 77 */ "TRIGGER",
145896
+ /* 78 */ "VACUUM",
145897
+ /* 79 */ "VIEW",
145898
+ /* 80 */ "VIRTUAL",
145899
+ /* 81 */ "WITH",
145900
+ /* 82 */ "CURRENT",
145901
+ /* 83 */ "FOLLOWING",
145902
+ /* 84 */ "PARTITION",
145903
+ /* 85 */ "PRECEDING",
145904
+ /* 86 */ "RANGE",
145905
+ /* 87 */ "UNBOUNDED",
145906
+ /* 88 */ "REINDEX",
145907
+ /* 89 */ "RENAME",
145908
+ /* 90 */ "CTIME_KW",
145909
+ /* 91 */ "ANY",
145910
+ /* 92 */ "BITAND",
145911
+ /* 93 */ "BITOR",
145912
+ /* 94 */ "LSHIFT",
145913
+ /* 95 */ "RSHIFT",
145914
+ /* 96 */ "PLUS",
145915
+ /* 97 */ "MINUS",
145916
+ /* 98 */ "STAR",
145917
+ /* 99 */ "SLASH",
145918
+ /* 100 */ "REM",
145919
+ /* 101 */ "CONCAT",
145920
+ /* 102 */ "COLLATE",
145921
+ /* 103 */ "BITNOT",
145922
+ /* 104 */ "ON",
145923
+ /* 105 */ "INDEXED",
145924
+ /* 106 */ "STRING",
145925
+ /* 107 */ "JOIN_KW",
145926
+ /* 108 */ "CONSTRAINT",
145927
+ /* 109 */ "DEFAULT",
145928
+ /* 110 */ "NULL",
145929
+ /* 111 */ "PRIMARY",
145930
+ /* 112 */ "UNIQUE",
145931
+ /* 113 */ "CHECK",
145932
+ /* 114 */ "REFERENCES",
145933
+ /* 115 */ "AUTOINCR",
145934
+ /* 116 */ "INSERT",
145935
+ /* 117 */ "DELETE",
145936
+ /* 118 */ "UPDATE",
145937
+ /* 119 */ "SET",
145938
+ /* 120 */ "DEFERRABLE",
145939
+ /* 121 */ "FOREIGN",
145940
+ /* 122 */ "DROP",
145941
+ /* 123 */ "UNION",
145942
+ /* 124 */ "ALL",
145943
+ /* 125 */ "EXCEPT",
145944
+ /* 126 */ "INTERSECT",
145945
+ /* 127 */ "SELECT",
145946
+ /* 128 */ "VALUES",
145947
+ /* 129 */ "DISTINCT",
145948
+ /* 130 */ "DOT",
145949
+ /* 131 */ "FROM",
145950
+ /* 132 */ "JOIN",
145951
+ /* 133 */ "USING",
145952
+ /* 134 */ "ORDER",
145953
+ /* 135 */ "GROUP",
145954
+ /* 136 */ "HAVING",
145955
+ /* 137 */ "LIMIT",
145956
+ /* 138 */ "WHERE",
145957
+ /* 139 */ "INTO",
145958
+ /* 140 */ "NOTHING",
145959
+ /* 141 */ "FLOAT",
145960
+ /* 142 */ "BLOB",
145961
+ /* 143 */ "INTEGER",
145962
+ /* 144 */ "VARIABLE",
145963
+ /* 145 */ "CASE",
145964
+ /* 146 */ "WHEN",
145965
+ /* 147 */ "THEN",
145966
+ /* 148 */ "ELSE",
145967
+ /* 149 */ "INDEX",
145968
+ /* 150 */ "ALTER",
145969
+ /* 151 */ "ADD",
145970
+ /* 152 */ "WINDOW",
145971
+ /* 153 */ "OVER",
145972
+ /* 154 */ "FILTER",
145973
+ /* 155 */ "input",
145974
+ /* 156 */ "cmdlist",
145975
+ /* 157 */ "ecmd",
145976
+ /* 158 */ "cmdx",
145977
+ /* 159 */ "explain",
145978
+ /* 160 */ "cmd",
145979
+ /* 161 */ "transtype",
145980
+ /* 162 */ "trans_opt",
145981
+ /* 163 */ "nm",
145982
+ /* 164 */ "savepoint_opt",
145983
+ /* 165 */ "create_table",
145984
+ /* 166 */ "create_table_args",
145985
+ /* 167 */ "createkw",
145986
+ /* 168 */ "temp",
145987
+ /* 169 */ "ifnotexists",
145988
+ /* 170 */ "dbnm",
145989
+ /* 171 */ "columnlist",
145990
+ /* 172 */ "conslist_opt",
145991
+ /* 173 */ "table_options",
145992
+ /* 174 */ "select",
145993
+ /* 175 */ "columnname",
145994
+ /* 176 */ "carglist",
145995
+ /* 177 */ "typetoken",
145996
+ /* 178 */ "typename",
145997
+ /* 179 */ "signed",
145998
+ /* 180 */ "plus_num",
145999
+ /* 181 */ "minus_num",
146000
+ /* 182 */ "scanpt",
146001
+ /* 183 */ "ccons",
146002
+ /* 184 */ "term",
146003
+ /* 185 */ "expr",
146004
+ /* 186 */ "onconf",
146005
+ /* 187 */ "sortorder",
146006
+ /* 188 */ "autoinc",
146007
+ /* 189 */ "eidlist_opt",
146008
+ /* 190 */ "refargs",
146009
+ /* 191 */ "defer_subclause",
146010
+ /* 192 */ "refarg",
146011
+ /* 193 */ "refact",
146012
+ /* 194 */ "init_deferred_pred_opt",
146013
+ /* 195 */ "conslist",
146014
+ /* 196 */ "tconscomma",
146015
+ /* 197 */ "tcons",
146016
+ /* 198 */ "sortlist",
146017
+ /* 199 */ "eidlist",
146018
+ /* 200 */ "defer_subclause_opt",
146019
+ /* 201 */ "orconf",
146020
+ /* 202 */ "resolvetype",
146021
+ /* 203 */ "raisetype",
146022
+ /* 204 */ "ifexists",
146023
+ /* 205 */ "fullname",
146024
+ /* 206 */ "selectnowith",
146025
+ /* 207 */ "oneselect",
146026
+ /* 208 */ "wqlist",
146027
+ /* 209 */ "multiselect_op",
146028
+ /* 210 */ "distinct",
146029
+ /* 211 */ "selcollist",
146030
+ /* 212 */ "from",
146031
+ /* 213 */ "where_opt",
146032
+ /* 214 */ "groupby_opt",
146033
+ /* 215 */ "having_opt",
146034
+ /* 216 */ "windowdefn_opt",
146035
+ /* 217 */ "orderby_opt",
146036
+ /* 218 */ "limit_opt",
146037
+ /* 219 */ "values",
146038
+ /* 220 */ "nexprlist",
146039
+ /* 221 */ "exprlist",
146040
+ /* 222 */ "sclp",
146041
+ /* 223 */ "as",
146042
+ /* 224 */ "seltablist",
146043
+ /* 225 */ "stl_prefix",
146044
+ /* 226 */ "joinop",
146045
+ /* 227 */ "indexed_opt",
146046
+ /* 228 */ "on_opt",
146047
+ /* 229 */ "using_opt",
146048
+ /* 230 */ "xfullname",
146049
+ /* 231 */ "idlist",
146050
+ /* 232 */ "with",
146051
+ /* 233 */ "setlist",
146052
+ /* 234 */ "insert_cmd",
146053
+ /* 235 */ "idlist_opt",
146054
+ /* 236 */ "upsert",
146055
+ /* 237 */ "over_opt",
146056
+ /* 238 */ "likeop",
146057
+ /* 239 */ "between_op",
146058
+ /* 240 */ "in_op",
146059
+ /* 241 */ "paren_exprlist",
146060
+ /* 242 */ "case_operand",
146061
+ /* 243 */ "case_exprlist",
146062
+ /* 244 */ "case_else",
146063
+ /* 245 */ "uniqueflag",
146064
+ /* 246 */ "collate",
146065
+ /* 247 */ "nmnum",
146066
+ /* 248 */ "trigger_decl",
146067
+ /* 249 */ "trigger_cmd_list",
146068
+ /* 250 */ "trigger_time",
146069
+ /* 251 */ "trigger_event",
146070
+ /* 252 */ "foreach_clause",
146071
+ /* 253 */ "when_clause",
146072
+ /* 254 */ "trigger_cmd",
146073
+ /* 255 */ "trnm",
146074
+ /* 256 */ "tridxby",
146075
+ /* 257 */ "database_kw_opt",
146076
+ /* 258 */ "key_opt",
146077
+ /* 259 */ "add_column_fullname",
146078
+ /* 260 */ "kwcolumn_opt",
146079
+ /* 261 */ "create_vtab",
146080
+ /* 262 */ "vtabarglist",
146081
+ /* 263 */ "vtabarg",
146082
+ /* 264 */ "vtabargtoken",
146083
+ /* 265 */ "lp",
146084
+ /* 266 */ "anylist",
146085
+ /* 267 */ "windowdefn_list",
146086
+ /* 268 */ "windowdefn",
146087
+ /* 269 */ "window",
146088
+ /* 270 */ "frame_opt",
146089
+ /* 271 */ "part_opt",
146090
+ /* 272 */ "filter_opt",
146091
+ /* 273 */ "range_or_rows",
146092
+ /* 274 */ "frame_bound",
146093
+ /* 275 */ "frame_bound_s",
146094
+ /* 276 */ "frame_bound_e",
142665146095
};
142666146096
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
142667146097
142668146098
#ifndef NDEBUG
142669146099
/* For tracing reduce actions, the names of all rules are required.
@@ -142754,11 +146184,11 @@
142754146184
/* 82 */ "select ::= selectnowith",
142755146185
/* 83 */ "selectnowith ::= selectnowith multiselect_op oneselect",
142756146186
/* 84 */ "multiselect_op ::= UNION",
142757146187
/* 85 */ "multiselect_op ::= UNION ALL",
142758146188
/* 86 */ "multiselect_op ::= EXCEPT|INTERSECT",
142759
- /* 87 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
146189
+ /* 87 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt windowdefn_opt orderby_opt limit_opt",
142760146190
/* 88 */ "values ::= VALUES LP nexprlist RP",
142761146191
/* 89 */ "values ::= values COMMA LP exprlist RP",
142762146192
/* 90 */ "distinct ::= DISTINCT",
142763146193
/* 91 */ "distinct ::= ALL",
142764146194
/* 92 */ "distinct ::=",
@@ -142839,12 +146269,12 @@
142839146269
/* 167 */ "term ::= STRING",
142840146270
/* 168 */ "term ::= INTEGER",
142841146271
/* 169 */ "expr ::= VARIABLE",
142842146272
/* 170 */ "expr ::= expr COLLATE ID|STRING",
142843146273
/* 171 */ "expr ::= CAST LP expr AS typetoken RP",
142844
- /* 172 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
142845
- /* 173 */ "expr ::= ID|INDEXED LP STAR RP",
146274
+ /* 172 */ "expr ::= ID|INDEXED LP distinct exprlist RP over_opt",
146275
+ /* 173 */ "expr ::= ID|INDEXED LP STAR RP over_opt",
142846146276
/* 174 */ "term ::= CTIME_KW",
142847146277
/* 175 */ "expr ::= LP nexprlist COMMA expr RP",
142848146278
/* 176 */ "expr ::= expr AND expr",
142849146279
/* 177 */ "expr ::= expr OR expr",
142850146280
/* 178 */ "expr ::= expr LT|GT|GE|LE expr",
@@ -142860,158 +146290,182 @@
142860146290
/* 188 */ "expr ::= expr NOT NULL",
142861146291
/* 189 */ "expr ::= expr IS expr",
142862146292
/* 190 */ "expr ::= expr IS NOT expr",
142863146293
/* 191 */ "expr ::= NOT expr",
142864146294
/* 192 */ "expr ::= BITNOT expr",
142865
- /* 193 */ "expr ::= MINUS expr",
142866
- /* 194 */ "expr ::= PLUS expr",
142867
- /* 195 */ "between_op ::= BETWEEN",
142868
- /* 196 */ "between_op ::= NOT BETWEEN",
142869
- /* 197 */ "expr ::= expr between_op expr AND expr",
142870
- /* 198 */ "in_op ::= IN",
142871
- /* 199 */ "in_op ::= NOT IN",
142872
- /* 200 */ "expr ::= expr in_op LP exprlist RP",
142873
- /* 201 */ "expr ::= LP select RP",
142874
- /* 202 */ "expr ::= expr in_op LP select RP",
142875
- /* 203 */ "expr ::= expr in_op nm dbnm paren_exprlist",
142876
- /* 204 */ "expr ::= EXISTS LP select RP",
142877
- /* 205 */ "expr ::= CASE case_operand case_exprlist case_else END",
142878
- /* 206 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
142879
- /* 207 */ "case_exprlist ::= WHEN expr THEN expr",
142880
- /* 208 */ "case_else ::= ELSE expr",
142881
- /* 209 */ "case_else ::=",
142882
- /* 210 */ "case_operand ::= expr",
142883
- /* 211 */ "case_operand ::=",
142884
- /* 212 */ "exprlist ::=",
142885
- /* 213 */ "nexprlist ::= nexprlist COMMA expr",
142886
- /* 214 */ "nexprlist ::= expr",
142887
- /* 215 */ "paren_exprlist ::=",
142888
- /* 216 */ "paren_exprlist ::= LP exprlist RP",
142889
- /* 217 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
142890
- /* 218 */ "uniqueflag ::= UNIQUE",
142891
- /* 219 */ "uniqueflag ::=",
142892
- /* 220 */ "eidlist_opt ::=",
142893
- /* 221 */ "eidlist_opt ::= LP eidlist RP",
142894
- /* 222 */ "eidlist ::= eidlist COMMA nm collate sortorder",
142895
- /* 223 */ "eidlist ::= nm collate sortorder",
142896
- /* 224 */ "collate ::=",
142897
- /* 225 */ "collate ::= COLLATE ID|STRING",
142898
- /* 226 */ "cmd ::= DROP INDEX ifexists fullname",
142899
- /* 227 */ "cmd ::= VACUUM",
142900
- /* 228 */ "cmd ::= VACUUM nm",
142901
- /* 229 */ "cmd ::= PRAGMA nm dbnm",
142902
- /* 230 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
142903
- /* 231 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
142904
- /* 232 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
142905
- /* 233 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
142906
- /* 234 */ "plus_num ::= PLUS INTEGER|FLOAT",
142907
- /* 235 */ "minus_num ::= MINUS INTEGER|FLOAT",
142908
- /* 236 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
142909
- /* 237 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
142910
- /* 238 */ "trigger_time ::= BEFORE|AFTER",
142911
- /* 239 */ "trigger_time ::= INSTEAD OF",
142912
- /* 240 */ "trigger_time ::=",
142913
- /* 241 */ "trigger_event ::= DELETE|INSERT",
142914
- /* 242 */ "trigger_event ::= UPDATE",
142915
- /* 243 */ "trigger_event ::= UPDATE OF idlist",
142916
- /* 244 */ "when_clause ::=",
142917
- /* 245 */ "when_clause ::= WHEN expr",
142918
- /* 246 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
142919
- /* 247 */ "trigger_cmd_list ::= trigger_cmd SEMI",
142920
- /* 248 */ "trnm ::= nm DOT nm",
142921
- /* 249 */ "tridxby ::= INDEXED BY nm",
142922
- /* 250 */ "tridxby ::= NOT INDEXED",
142923
- /* 251 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
142924
- /* 252 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
142925
- /* 253 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
142926
- /* 254 */ "trigger_cmd ::= scanpt select scanpt",
142927
- /* 255 */ "expr ::= RAISE LP IGNORE RP",
142928
- /* 256 */ "expr ::= RAISE LP raisetype COMMA nm RP",
142929
- /* 257 */ "raisetype ::= ROLLBACK",
142930
- /* 258 */ "raisetype ::= ABORT",
142931
- /* 259 */ "raisetype ::= FAIL",
142932
- /* 260 */ "cmd ::= DROP TRIGGER ifexists fullname",
142933
- /* 261 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
142934
- /* 262 */ "cmd ::= DETACH database_kw_opt expr",
142935
- /* 263 */ "key_opt ::=",
142936
- /* 264 */ "key_opt ::= KEY expr",
142937
- /* 265 */ "cmd ::= REINDEX",
142938
- /* 266 */ "cmd ::= REINDEX nm dbnm",
142939
- /* 267 */ "cmd ::= ANALYZE",
142940
- /* 268 */ "cmd ::= ANALYZE nm dbnm",
142941
- /* 269 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
142942
- /* 270 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
142943
- /* 271 */ "add_column_fullname ::= fullname",
142944
- /* 272 */ "cmd ::= create_vtab",
142945
- /* 273 */ "cmd ::= create_vtab LP vtabarglist RP",
142946
- /* 274 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
142947
- /* 275 */ "vtabarg ::=",
142948
- /* 276 */ "vtabargtoken ::= ANY",
142949
- /* 277 */ "vtabargtoken ::= lp anylist RP",
142950
- /* 278 */ "lp ::= LP",
142951
- /* 279 */ "with ::= WITH wqlist",
142952
- /* 280 */ "with ::= WITH RECURSIVE wqlist",
142953
- /* 281 */ "wqlist ::= nm eidlist_opt AS LP select RP",
142954
- /* 282 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
142955
- /* 283 */ "input ::= cmdlist",
142956
- /* 284 */ "cmdlist ::= cmdlist ecmd",
142957
- /* 285 */ "cmdlist ::= ecmd",
142958
- /* 286 */ "ecmd ::= SEMI",
142959
- /* 287 */ "ecmd ::= cmdx SEMI",
142960
- /* 288 */ "ecmd ::= explain cmdx",
142961
- /* 289 */ "trans_opt ::=",
142962
- /* 290 */ "trans_opt ::= TRANSACTION",
142963
- /* 291 */ "trans_opt ::= TRANSACTION nm",
142964
- /* 292 */ "savepoint_opt ::= SAVEPOINT",
142965
- /* 293 */ "savepoint_opt ::=",
142966
- /* 294 */ "cmd ::= create_table create_table_args",
142967
- /* 295 */ "columnlist ::= columnlist COMMA columnname carglist",
142968
- /* 296 */ "columnlist ::= columnname carglist",
142969
- /* 297 */ "nm ::= ID|INDEXED",
142970
- /* 298 */ "nm ::= STRING",
142971
- /* 299 */ "nm ::= JOIN_KW",
142972
- /* 300 */ "typetoken ::= typename",
142973
- /* 301 */ "typename ::= ID|STRING",
142974
- /* 302 */ "signed ::= plus_num",
142975
- /* 303 */ "signed ::= minus_num",
142976
- /* 304 */ "carglist ::= carglist ccons",
142977
- /* 305 */ "carglist ::=",
142978
- /* 306 */ "ccons ::= NULL onconf",
142979
- /* 307 */ "conslist_opt ::= COMMA conslist",
142980
- /* 308 */ "conslist ::= conslist tconscomma tcons",
142981
- /* 309 */ "conslist ::= tcons",
142982
- /* 310 */ "tconscomma ::=",
142983
- /* 311 */ "defer_subclause_opt ::= defer_subclause",
142984
- /* 312 */ "resolvetype ::= raisetype",
142985
- /* 313 */ "selectnowith ::= oneselect",
142986
- /* 314 */ "oneselect ::= values",
142987
- /* 315 */ "sclp ::= selcollist COMMA",
142988
- /* 316 */ "as ::= ID|STRING",
142989
- /* 317 */ "expr ::= term",
142990
- /* 318 */ "likeop ::= LIKE_KW|MATCH",
142991
- /* 319 */ "exprlist ::= nexprlist",
142992
- /* 320 */ "nmnum ::= plus_num",
142993
- /* 321 */ "nmnum ::= nm",
142994
- /* 322 */ "nmnum ::= ON",
142995
- /* 323 */ "nmnum ::= DELETE",
142996
- /* 324 */ "nmnum ::= DEFAULT",
142997
- /* 325 */ "plus_num ::= INTEGER|FLOAT",
142998
- /* 326 */ "foreach_clause ::=",
142999
- /* 327 */ "foreach_clause ::= FOR EACH ROW",
143000
- /* 328 */ "trnm ::= nm",
143001
- /* 329 */ "tridxby ::=",
143002
- /* 330 */ "database_kw_opt ::= DATABASE",
143003
- /* 331 */ "database_kw_opt ::=",
143004
- /* 332 */ "kwcolumn_opt ::=",
143005
- /* 333 */ "kwcolumn_opt ::= COLUMNKW",
143006
- /* 334 */ "vtabarglist ::= vtabarg",
143007
- /* 335 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
143008
- /* 336 */ "vtabarg ::= vtabarg vtabargtoken",
143009
- /* 337 */ "anylist ::=",
143010
- /* 338 */ "anylist ::= anylist LP anylist RP",
143011
- /* 339 */ "anylist ::= anylist ANY",
143012
- /* 340 */ "with ::=",
146295
+ /* 193 */ "expr ::= PLUS|MINUS expr",
146296
+ /* 194 */ "between_op ::= BETWEEN",
146297
+ /* 195 */ "between_op ::= NOT BETWEEN",
146298
+ /* 196 */ "expr ::= expr between_op expr AND expr",
146299
+ /* 197 */ "in_op ::= IN",
146300
+ /* 198 */ "in_op ::= NOT IN",
146301
+ /* 199 */ "expr ::= expr in_op LP exprlist RP",
146302
+ /* 200 */ "expr ::= LP select RP",
146303
+ /* 201 */ "expr ::= expr in_op LP select RP",
146304
+ /* 202 */ "expr ::= expr in_op nm dbnm paren_exprlist",
146305
+ /* 203 */ "expr ::= EXISTS LP select RP",
146306
+ /* 204 */ "expr ::= CASE case_operand case_exprlist case_else END",
146307
+ /* 205 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
146308
+ /* 206 */ "case_exprlist ::= WHEN expr THEN expr",
146309
+ /* 207 */ "case_else ::= ELSE expr",
146310
+ /* 208 */ "case_else ::=",
146311
+ /* 209 */ "case_operand ::= expr",
146312
+ /* 210 */ "case_operand ::=",
146313
+ /* 211 */ "exprlist ::=",
146314
+ /* 212 */ "nexprlist ::= nexprlist COMMA expr",
146315
+ /* 213 */ "nexprlist ::= expr",
146316
+ /* 214 */ "paren_exprlist ::=",
146317
+ /* 215 */ "paren_exprlist ::= LP exprlist RP",
146318
+ /* 216 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
146319
+ /* 217 */ "uniqueflag ::= UNIQUE",
146320
+ /* 218 */ "uniqueflag ::=",
146321
+ /* 219 */ "eidlist_opt ::=",
146322
+ /* 220 */ "eidlist_opt ::= LP eidlist RP",
146323
+ /* 221 */ "eidlist ::= eidlist COMMA nm collate sortorder",
146324
+ /* 222 */ "eidlist ::= nm collate sortorder",
146325
+ /* 223 */ "collate ::=",
146326
+ /* 224 */ "collate ::= COLLATE ID|STRING",
146327
+ /* 225 */ "cmd ::= DROP INDEX ifexists fullname",
146328
+ /* 226 */ "cmd ::= VACUUM",
146329
+ /* 227 */ "cmd ::= VACUUM nm",
146330
+ /* 228 */ "cmd ::= PRAGMA nm dbnm",
146331
+ /* 229 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
146332
+ /* 230 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
146333
+ /* 231 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
146334
+ /* 232 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
146335
+ /* 233 */ "plus_num ::= PLUS INTEGER|FLOAT",
146336
+ /* 234 */ "minus_num ::= MINUS INTEGER|FLOAT",
146337
+ /* 235 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
146338
+ /* 236 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
146339
+ /* 237 */ "trigger_time ::= BEFORE|AFTER",
146340
+ /* 238 */ "trigger_time ::= INSTEAD OF",
146341
+ /* 239 */ "trigger_time ::=",
146342
+ /* 240 */ "trigger_event ::= DELETE|INSERT",
146343
+ /* 241 */ "trigger_event ::= UPDATE",
146344
+ /* 242 */ "trigger_event ::= UPDATE OF idlist",
146345
+ /* 243 */ "when_clause ::=",
146346
+ /* 244 */ "when_clause ::= WHEN expr",
146347
+ /* 245 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
146348
+ /* 246 */ "trigger_cmd_list ::= trigger_cmd SEMI",
146349
+ /* 247 */ "trnm ::= nm DOT nm",
146350
+ /* 248 */ "tridxby ::= INDEXED BY nm",
146351
+ /* 249 */ "tridxby ::= NOT INDEXED",
146352
+ /* 250 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
146353
+ /* 251 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
146354
+ /* 252 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
146355
+ /* 253 */ "trigger_cmd ::= scanpt select scanpt",
146356
+ /* 254 */ "expr ::= RAISE LP IGNORE RP",
146357
+ /* 255 */ "expr ::= RAISE LP raisetype COMMA nm RP",
146358
+ /* 256 */ "raisetype ::= ROLLBACK",
146359
+ /* 257 */ "raisetype ::= ABORT",
146360
+ /* 258 */ "raisetype ::= FAIL",
146361
+ /* 259 */ "cmd ::= DROP TRIGGER ifexists fullname",
146362
+ /* 260 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
146363
+ /* 261 */ "cmd ::= DETACH database_kw_opt expr",
146364
+ /* 262 */ "key_opt ::=",
146365
+ /* 263 */ "key_opt ::= KEY expr",
146366
+ /* 264 */ "cmd ::= REINDEX",
146367
+ /* 265 */ "cmd ::= REINDEX nm dbnm",
146368
+ /* 266 */ "cmd ::= ANALYZE",
146369
+ /* 267 */ "cmd ::= ANALYZE nm dbnm",
146370
+ /* 268 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
146371
+ /* 269 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
146372
+ /* 270 */ "add_column_fullname ::= fullname",
146373
+ /* 271 */ "cmd ::= create_vtab",
146374
+ /* 272 */ "cmd ::= create_vtab LP vtabarglist RP",
146375
+ /* 273 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
146376
+ /* 274 */ "vtabarg ::=",
146377
+ /* 275 */ "vtabargtoken ::= ANY",
146378
+ /* 276 */ "vtabargtoken ::= lp anylist RP",
146379
+ /* 277 */ "lp ::= LP",
146380
+ /* 278 */ "with ::= WITH wqlist",
146381
+ /* 279 */ "with ::= WITH RECURSIVE wqlist",
146382
+ /* 280 */ "wqlist ::= nm eidlist_opt AS LP select RP",
146383
+ /* 281 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
146384
+ /* 282 */ "windowdefn_list ::= windowdefn",
146385
+ /* 283 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
146386
+ /* 284 */ "windowdefn ::= nm AS window",
146387
+ /* 285 */ "window ::= LP part_opt orderby_opt frame_opt RP",
146388
+ /* 286 */ "part_opt ::= PARTITION BY exprlist",
146389
+ /* 287 */ "part_opt ::=",
146390
+ /* 288 */ "frame_opt ::=",
146391
+ /* 289 */ "frame_opt ::= range_or_rows frame_bound_s",
146392
+ /* 290 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e",
146393
+ /* 291 */ "range_or_rows ::= RANGE",
146394
+ /* 292 */ "range_or_rows ::= ROWS",
146395
+ /* 293 */ "frame_bound_s ::= frame_bound",
146396
+ /* 294 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
146397
+ /* 295 */ "frame_bound_e ::= frame_bound",
146398
+ /* 296 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
146399
+ /* 297 */ "frame_bound ::= expr PRECEDING",
146400
+ /* 298 */ "frame_bound ::= CURRENT ROW",
146401
+ /* 299 */ "frame_bound ::= expr FOLLOWING",
146402
+ /* 300 */ "windowdefn_opt ::=",
146403
+ /* 301 */ "windowdefn_opt ::= WINDOW windowdefn_list",
146404
+ /* 302 */ "over_opt ::=",
146405
+ /* 303 */ "over_opt ::= filter_opt OVER window",
146406
+ /* 304 */ "over_opt ::= filter_opt OVER nm",
146407
+ /* 305 */ "filter_opt ::=",
146408
+ /* 306 */ "filter_opt ::= FILTER LP WHERE expr RP",
146409
+ /* 307 */ "input ::= cmdlist",
146410
+ /* 308 */ "cmdlist ::= cmdlist ecmd",
146411
+ /* 309 */ "cmdlist ::= ecmd",
146412
+ /* 310 */ "ecmd ::= SEMI",
146413
+ /* 311 */ "ecmd ::= cmdx SEMI",
146414
+ /* 312 */ "ecmd ::= explain cmdx",
146415
+ /* 313 */ "trans_opt ::=",
146416
+ /* 314 */ "trans_opt ::= TRANSACTION",
146417
+ /* 315 */ "trans_opt ::= TRANSACTION nm",
146418
+ /* 316 */ "savepoint_opt ::= SAVEPOINT",
146419
+ /* 317 */ "savepoint_opt ::=",
146420
+ /* 318 */ "cmd ::= create_table create_table_args",
146421
+ /* 319 */ "columnlist ::= columnlist COMMA columnname carglist",
146422
+ /* 320 */ "columnlist ::= columnname carglist",
146423
+ /* 321 */ "nm ::= ID|INDEXED",
146424
+ /* 322 */ "nm ::= STRING",
146425
+ /* 323 */ "nm ::= JOIN_KW",
146426
+ /* 324 */ "typetoken ::= typename",
146427
+ /* 325 */ "typename ::= ID|STRING",
146428
+ /* 326 */ "signed ::= plus_num",
146429
+ /* 327 */ "signed ::= minus_num",
146430
+ /* 328 */ "carglist ::= carglist ccons",
146431
+ /* 329 */ "carglist ::=",
146432
+ /* 330 */ "ccons ::= NULL onconf",
146433
+ /* 331 */ "conslist_opt ::= COMMA conslist",
146434
+ /* 332 */ "conslist ::= conslist tconscomma tcons",
146435
+ /* 333 */ "conslist ::= tcons",
146436
+ /* 334 */ "tconscomma ::=",
146437
+ /* 335 */ "defer_subclause_opt ::= defer_subclause",
146438
+ /* 336 */ "resolvetype ::= raisetype",
146439
+ /* 337 */ "selectnowith ::= oneselect",
146440
+ /* 338 */ "oneselect ::= values",
146441
+ /* 339 */ "sclp ::= selcollist COMMA",
146442
+ /* 340 */ "as ::= ID|STRING",
146443
+ /* 341 */ "expr ::= term",
146444
+ /* 342 */ "likeop ::= LIKE_KW|MATCH",
146445
+ /* 343 */ "exprlist ::= nexprlist",
146446
+ /* 344 */ "nmnum ::= plus_num",
146447
+ /* 345 */ "nmnum ::= nm",
146448
+ /* 346 */ "nmnum ::= ON",
146449
+ /* 347 */ "nmnum ::= DELETE",
146450
+ /* 348 */ "nmnum ::= DEFAULT",
146451
+ /* 349 */ "plus_num ::= INTEGER|FLOAT",
146452
+ /* 350 */ "foreach_clause ::=",
146453
+ /* 351 */ "foreach_clause ::= FOR EACH ROW",
146454
+ /* 352 */ "trnm ::= nm",
146455
+ /* 353 */ "tridxby ::=",
146456
+ /* 354 */ "database_kw_opt ::= DATABASE",
146457
+ /* 355 */ "database_kw_opt ::=",
146458
+ /* 356 */ "kwcolumn_opt ::=",
146459
+ /* 357 */ "kwcolumn_opt ::= COLUMNKW",
146460
+ /* 358 */ "vtabarglist ::= vtabarg",
146461
+ /* 359 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
146462
+ /* 360 */ "vtabarg ::= vtabarg vtabargtoken",
146463
+ /* 361 */ "anylist ::=",
146464
+ /* 362 */ "anylist ::= anylist LP anylist RP",
146465
+ /* 363 */ "anylist ::= anylist ANY",
146466
+ /* 364 */ "with ::=",
143013146467
};
143014146468
#endif /* NDEBUG */
143015146469
143016146470
143017146471
#if YYSTACKDEPTH<=0
@@ -143133,77 +146587,100 @@
143133146587
** Note: during a reduce, the only symbols destroyed are those
143134146588
** which appear on the RHS of the rule, but which are *not* used
143135146589
** inside the C code.
143136146590
*/
143137146591
/********* Begin destructor definitions ***************************************/
143138
- case 164: /* select */
143139
- case 196: /* selectnowith */
143140
- case 197: /* oneselect */
143141
- case 208: /* values */
143142
-{
143143
-sqlite3SelectDelete(pParse->db, (yypminor->yy399));
143144
-}
143145
- break;
143146
- case 174: /* term */
143147
- case 175: /* expr */
143148
- case 203: /* where_opt */
143149
- case 205: /* having_opt */
143150
- case 217: /* on_opt */
143151
- case 230: /* case_operand */
143152
- case 232: /* case_else */
143153
- case 241: /* when_clause */
143154
- case 246: /* key_opt */
143155
-{
143156
-sqlite3ExprDelete(pParse->db, (yypminor->yy182));
143157
-}
143158
- break;
143159
- case 179: /* eidlist_opt */
143160
- case 188: /* sortlist */
143161
- case 189: /* eidlist */
143162
- case 201: /* selcollist */
143163
- case 204: /* groupby_opt */
143164
- case 206: /* orderby_opt */
143165
- case 209: /* nexprlist */
143166
- case 210: /* exprlist */
143167
- case 211: /* sclp */
143168
- case 222: /* setlist */
143169
- case 229: /* paren_exprlist */
143170
- case 231: /* case_exprlist */
143171
-{
143172
-sqlite3ExprListDelete(pParse->db, (yypminor->yy232));
143173
-}
143174
- break;
143175
- case 195: /* fullname */
143176
- case 202: /* from */
143177
- case 213: /* seltablist */
143178
- case 214: /* stl_prefix */
143179
- case 219: /* xfullname */
143180
-{
143181
-sqlite3SrcListDelete(pParse->db, (yypminor->yy427));
143182
-}
143183
- break;
143184
- case 198: /* wqlist */
143185
-{
143186
-sqlite3WithDelete(pParse->db, (yypminor->yy91));
143187
-}
143188
- break;
143189
- case 218: /* using_opt */
143190
- case 220: /* idlist */
143191
- case 224: /* idlist_opt */
143192
-{
143193
-sqlite3IdListDelete(pParse->db, (yypminor->yy510));
143194
-}
143195
- break;
143196
- case 237: /* trigger_cmd_list */
143197
- case 242: /* trigger_cmd */
143198
-{
143199
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy47));
143200
-}
143201
- break;
143202
- case 239: /* trigger_event */
143203
-{
143204
-sqlite3IdListDelete(pParse->db, (yypminor->yy300).b);
146592
+ case 174: /* select */
146593
+ case 206: /* selectnowith */
146594
+ case 207: /* oneselect */
146595
+ case 219: /* values */
146596
+{
146597
+sqlite3SelectDelete(pParse->db, (yypminor->yy489));
146598
+}
146599
+ break;
146600
+ case 184: /* term */
146601
+ case 185: /* expr */
146602
+ case 213: /* where_opt */
146603
+ case 215: /* having_opt */
146604
+ case 228: /* on_opt */
146605
+ case 242: /* case_operand */
146606
+ case 244: /* case_else */
146607
+ case 253: /* when_clause */
146608
+ case 258: /* key_opt */
146609
+ case 272: /* filter_opt */
146610
+{
146611
+sqlite3ExprDelete(pParse->db, (yypminor->yy18));
146612
+}
146613
+ break;
146614
+ case 189: /* eidlist_opt */
146615
+ case 198: /* sortlist */
146616
+ case 199: /* eidlist */
146617
+ case 211: /* selcollist */
146618
+ case 214: /* groupby_opt */
146619
+ case 217: /* orderby_opt */
146620
+ case 220: /* nexprlist */
146621
+ case 221: /* exprlist */
146622
+ case 222: /* sclp */
146623
+ case 233: /* setlist */
146624
+ case 241: /* paren_exprlist */
146625
+ case 243: /* case_exprlist */
146626
+ case 271: /* part_opt */
146627
+{
146628
+sqlite3ExprListDelete(pParse->db, (yypminor->yy420));
146629
+}
146630
+ break;
146631
+ case 205: /* fullname */
146632
+ case 212: /* from */
146633
+ case 224: /* seltablist */
146634
+ case 225: /* stl_prefix */
146635
+ case 230: /* xfullname */
146636
+{
146637
+sqlite3SrcListDelete(pParse->db, (yypminor->yy135));
146638
+}
146639
+ break;
146640
+ case 208: /* wqlist */
146641
+{
146642
+sqlite3WithDelete(pParse->db, (yypminor->yy449));
146643
+}
146644
+ break;
146645
+ case 216: /* windowdefn_opt */
146646
+ case 267: /* windowdefn_list */
146647
+{
146648
+sqlite3WindowListDelete(pParse->db, (yypminor->yy327));
146649
+}
146650
+ break;
146651
+ case 229: /* using_opt */
146652
+ case 231: /* idlist */
146653
+ case 235: /* idlist_opt */
146654
+{
146655
+sqlite3IdListDelete(pParse->db, (yypminor->yy48));
146656
+}
146657
+ break;
146658
+ case 237: /* over_opt */
146659
+ case 268: /* windowdefn */
146660
+ case 269: /* window */
146661
+ case 270: /* frame_opt */
146662
+{
146663
+sqlite3WindowDelete(pParse->db, (yypminor->yy327));
146664
+}
146665
+ break;
146666
+ case 249: /* trigger_cmd_list */
146667
+ case 254: /* trigger_cmd */
146668
+{
146669
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy207));
146670
+}
146671
+ break;
146672
+ case 251: /* trigger_event */
146673
+{
146674
+sqlite3IdListDelete(pParse->db, (yypminor->yy34).b);
146675
+}
146676
+ break;
146677
+ case 274: /* frame_bound */
146678
+ case 275: /* frame_bound_s */
146679
+ case 276: /* frame_bound_e */
146680
+{
146681
+sqlite3ExprDelete(pParse->db, (yypminor->yy119).pExpr);
143205146682
}
143206146683
break;
143207146684
/********* End destructor definitions *****************************************/
143208146685
default: break; /* If no destructor action specified: do nothing */
143209146686
}
@@ -143325,15 +146802,15 @@
143325146802
yycoverage[stateno][iLookAhead] = 1;
143326146803
#endif
143327146804
do{
143328146805
i = yy_shift_ofst[stateno];
143329146806
assert( i>=0 );
143330
- assert( i+YYNTOKEN<=(int)sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) );
146807
+ /* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */
143331146808
assert( iLookAhead!=YYNOCODE );
143332146809
assert( iLookAhead < YYNTOKEN );
143333146810
i += iLookAhead;
143334
- if( yy_lookahead[i]!=iLookAhead ){
146811
+ if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){
143335146812
#ifdef YYFALLBACK
143336146813
YYCODETYPE iFallback; /* Fallback token */
143337146814
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
143338146815
&& (iFallback = yyFallback[iLookAhead])!=0 ){
143339146816
#ifndef NDEBUG
@@ -143355,10 +146832,11 @@
143355146832
j>=0 &&
143356146833
#endif
143357146834
#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
143358146835
j<YY_ACTTAB_COUNT &&
143359146836
#endif
146837
+ j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) &&
143360146838
yy_lookahead[j]==YYWILDCARD && iLookAhead>0
143361146839
){
143362146840
#ifndef NDEBUG
143363146841
if( yyTraceFILE ){
143364146842
fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
@@ -143497,351 +146975,375 @@
143497146975
*/
143498146976
static const struct {
143499146977
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
143500146978
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
143501146979
} yyRuleInfo[] = {
143502
- { 149, -1 }, /* (0) explain ::= EXPLAIN */
143503
- { 149, -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */
143504
- { 148, -1 }, /* (2) cmdx ::= cmd */
143505
- { 150, -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */
143506
- { 151, 0 }, /* (4) transtype ::= */
143507
- { 151, -1 }, /* (5) transtype ::= DEFERRED */
143508
- { 151, -1 }, /* (6) transtype ::= IMMEDIATE */
143509
- { 151, -1 }, /* (7) transtype ::= EXCLUSIVE */
143510
- { 150, -2 }, /* (8) cmd ::= COMMIT|END trans_opt */
143511
- { 150, -2 }, /* (9) cmd ::= ROLLBACK trans_opt */
143512
- { 150, -2 }, /* (10) cmd ::= SAVEPOINT nm */
143513
- { 150, -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */
143514
- { 150, -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
143515
- { 155, -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
143516
- { 157, -1 }, /* (14) createkw ::= CREATE */
143517
- { 159, 0 }, /* (15) ifnotexists ::= */
143518
- { 159, -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */
143519
- { 158, -1 }, /* (17) temp ::= TEMP */
143520
- { 158, 0 }, /* (18) temp ::= */
143521
- { 156, -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
143522
- { 156, -2 }, /* (20) create_table_args ::= AS select */
143523
- { 163, 0 }, /* (21) table_options ::= */
143524
- { 163, -2 }, /* (22) table_options ::= WITHOUT nm */
143525
- { 165, -2 }, /* (23) columnname ::= nm typetoken */
143526
- { 167, 0 }, /* (24) typetoken ::= */
143527
- { 167, -4 }, /* (25) typetoken ::= typename LP signed RP */
143528
- { 167, -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */
143529
- { 168, -2 }, /* (27) typename ::= typename ID|STRING */
143530
- { 172, 0 }, /* (28) scanpt ::= */
143531
- { 173, -2 }, /* (29) ccons ::= CONSTRAINT nm */
143532
- { 173, -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */
143533
- { 173, -4 }, /* (31) ccons ::= DEFAULT LP expr RP */
143534
- { 173, -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */
143535
- { 173, -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */
143536
- { 173, -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
143537
- { 173, -3 }, /* (35) ccons ::= NOT NULL onconf */
143538
- { 173, -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
143539
- { 173, -2 }, /* (37) ccons ::= UNIQUE onconf */
143540
- { 173, -4 }, /* (38) ccons ::= CHECK LP expr RP */
143541
- { 173, -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
143542
- { 173, -1 }, /* (40) ccons ::= defer_subclause */
143543
- { 173, -2 }, /* (41) ccons ::= COLLATE ID|STRING */
143544
- { 178, 0 }, /* (42) autoinc ::= */
143545
- { 178, -1 }, /* (43) autoinc ::= AUTOINCR */
143546
- { 180, 0 }, /* (44) refargs ::= */
143547
- { 180, -2 }, /* (45) refargs ::= refargs refarg */
143548
- { 182, -2 }, /* (46) refarg ::= MATCH nm */
143549
- { 182, -3 }, /* (47) refarg ::= ON INSERT refact */
143550
- { 182, -3 }, /* (48) refarg ::= ON DELETE refact */
143551
- { 182, -3 }, /* (49) refarg ::= ON UPDATE refact */
143552
- { 183, -2 }, /* (50) refact ::= SET NULL */
143553
- { 183, -2 }, /* (51) refact ::= SET DEFAULT */
143554
- { 183, -1 }, /* (52) refact ::= CASCADE */
143555
- { 183, -1 }, /* (53) refact ::= RESTRICT */
143556
- { 183, -2 }, /* (54) refact ::= NO ACTION */
143557
- { 181, -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
143558
- { 181, -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
143559
- { 184, 0 }, /* (57) init_deferred_pred_opt ::= */
143560
- { 184, -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
143561
- { 184, -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
143562
- { 162, 0 }, /* (60) conslist_opt ::= */
143563
- { 186, -1 }, /* (61) tconscomma ::= COMMA */
143564
- { 187, -2 }, /* (62) tcons ::= CONSTRAINT nm */
143565
- { 187, -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
143566
- { 187, -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
143567
- { 187, -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */
143568
- { 187, -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
143569
- { 190, 0 }, /* (67) defer_subclause_opt ::= */
143570
- { 176, 0 }, /* (68) onconf ::= */
143571
- { 176, -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */
143572
- { 191, 0 }, /* (70) orconf ::= */
143573
- { 191, -2 }, /* (71) orconf ::= OR resolvetype */
143574
- { 192, -1 }, /* (72) resolvetype ::= IGNORE */
143575
- { 192, -1 }, /* (73) resolvetype ::= REPLACE */
143576
- { 150, -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
143577
- { 194, -2 }, /* (75) ifexists ::= IF EXISTS */
143578
- { 194, 0 }, /* (76) ifexists ::= */
143579
- { 150, -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
143580
- { 150, -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
143581
- { 150, -1 }, /* (79) cmd ::= select */
143582
- { 164, -3 }, /* (80) select ::= WITH wqlist selectnowith */
143583
- { 164, -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
143584
- { 164, -1 }, /* (82) select ::= selectnowith */
143585
- { 196, -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
143586
- { 199, -1 }, /* (84) multiselect_op ::= UNION */
143587
- { 199, -2 }, /* (85) multiselect_op ::= UNION ALL */
143588
- { 199, -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
143589
- { 197, -9 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
143590
- { 208, -4 }, /* (88) values ::= VALUES LP nexprlist RP */
143591
- { 208, -5 }, /* (89) values ::= values COMMA LP exprlist RP */
143592
- { 200, -1 }, /* (90) distinct ::= DISTINCT */
143593
- { 200, -1 }, /* (91) distinct ::= ALL */
143594
- { 200, 0 }, /* (92) distinct ::= */
143595
- { 211, 0 }, /* (93) sclp ::= */
143596
- { 201, -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
143597
- { 201, -3 }, /* (95) selcollist ::= sclp scanpt STAR */
143598
- { 201, -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
143599
- { 212, -2 }, /* (97) as ::= AS nm */
143600
- { 212, 0 }, /* (98) as ::= */
143601
- { 202, 0 }, /* (99) from ::= */
143602
- { 202, -2 }, /* (100) from ::= FROM seltablist */
143603
- { 214, -2 }, /* (101) stl_prefix ::= seltablist joinop */
143604
- { 214, 0 }, /* (102) stl_prefix ::= */
143605
- { 213, -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
143606
- { 213, -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
143607
- { 213, -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
143608
- { 213, -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
143609
- { 160, 0 }, /* (107) dbnm ::= */
143610
- { 160, -2 }, /* (108) dbnm ::= DOT nm */
143611
- { 195, -1 }, /* (109) fullname ::= nm */
143612
- { 195, -3 }, /* (110) fullname ::= nm DOT nm */
143613
- { 219, -1 }, /* (111) xfullname ::= nm */
143614
- { 219, -3 }, /* (112) xfullname ::= nm DOT nm */
143615
- { 219, -5 }, /* (113) xfullname ::= nm DOT nm AS nm */
143616
- { 219, -3 }, /* (114) xfullname ::= nm AS nm */
143617
- { 215, -1 }, /* (115) joinop ::= COMMA|JOIN */
143618
- { 215, -2 }, /* (116) joinop ::= JOIN_KW JOIN */
143619
- { 215, -3 }, /* (117) joinop ::= JOIN_KW nm JOIN */
143620
- { 215, -4 }, /* (118) joinop ::= JOIN_KW nm nm JOIN */
143621
- { 217, -2 }, /* (119) on_opt ::= ON expr */
143622
- { 217, 0 }, /* (120) on_opt ::= */
143623
- { 216, 0 }, /* (121) indexed_opt ::= */
143624
- { 216, -3 }, /* (122) indexed_opt ::= INDEXED BY nm */
143625
- { 216, -2 }, /* (123) indexed_opt ::= NOT INDEXED */
143626
- { 218, -4 }, /* (124) using_opt ::= USING LP idlist RP */
143627
- { 218, 0 }, /* (125) using_opt ::= */
143628
- { 206, 0 }, /* (126) orderby_opt ::= */
143629
- { 206, -3 }, /* (127) orderby_opt ::= ORDER BY sortlist */
143630
- { 188, -4 }, /* (128) sortlist ::= sortlist COMMA expr sortorder */
143631
- { 188, -2 }, /* (129) sortlist ::= expr sortorder */
143632
- { 177, -1 }, /* (130) sortorder ::= ASC */
143633
- { 177, -1 }, /* (131) sortorder ::= DESC */
143634
- { 177, 0 }, /* (132) sortorder ::= */
143635
- { 204, 0 }, /* (133) groupby_opt ::= */
143636
- { 204, -3 }, /* (134) groupby_opt ::= GROUP BY nexprlist */
143637
- { 205, 0 }, /* (135) having_opt ::= */
143638
- { 205, -2 }, /* (136) having_opt ::= HAVING expr */
143639
- { 207, 0 }, /* (137) limit_opt ::= */
143640
- { 207, -2 }, /* (138) limit_opt ::= LIMIT expr */
143641
- { 207, -4 }, /* (139) limit_opt ::= LIMIT expr OFFSET expr */
143642
- { 207, -4 }, /* (140) limit_opt ::= LIMIT expr COMMA expr */
143643
- { 150, -6 }, /* (141) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
143644
- { 203, 0 }, /* (142) where_opt ::= */
143645
- { 203, -2 }, /* (143) where_opt ::= WHERE expr */
143646
- { 150, -8 }, /* (144) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
143647
- { 222, -5 }, /* (145) setlist ::= setlist COMMA nm EQ expr */
143648
- { 222, -7 }, /* (146) setlist ::= setlist COMMA LP idlist RP EQ expr */
143649
- { 222, -3 }, /* (147) setlist ::= nm EQ expr */
143650
- { 222, -5 }, /* (148) setlist ::= LP idlist RP EQ expr */
143651
- { 150, -7 }, /* (149) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
143652
- { 150, -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
143653
- { 225, 0 }, /* (151) upsert ::= */
143654
- { 225, -11 }, /* (152) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
143655
- { 225, -8 }, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
143656
- { 225, -4 }, /* (154) upsert ::= ON CONFLICT DO NOTHING */
143657
- { 223, -2 }, /* (155) insert_cmd ::= INSERT orconf */
143658
- { 223, -1 }, /* (156) insert_cmd ::= REPLACE */
143659
- { 224, 0 }, /* (157) idlist_opt ::= */
143660
- { 224, -3 }, /* (158) idlist_opt ::= LP idlist RP */
143661
- { 220, -3 }, /* (159) idlist ::= idlist COMMA nm */
143662
- { 220, -1 }, /* (160) idlist ::= nm */
143663
- { 175, -3 }, /* (161) expr ::= LP expr RP */
143664
- { 175, -1 }, /* (162) expr ::= ID|INDEXED */
143665
- { 175, -1 }, /* (163) expr ::= JOIN_KW */
143666
- { 175, -3 }, /* (164) expr ::= nm DOT nm */
143667
- { 175, -5 }, /* (165) expr ::= nm DOT nm DOT nm */
143668
- { 174, -1 }, /* (166) term ::= NULL|FLOAT|BLOB */
143669
- { 174, -1 }, /* (167) term ::= STRING */
143670
- { 174, -1 }, /* (168) term ::= INTEGER */
143671
- { 175, -1 }, /* (169) expr ::= VARIABLE */
143672
- { 175, -3 }, /* (170) expr ::= expr COLLATE ID|STRING */
143673
- { 175, -6 }, /* (171) expr ::= CAST LP expr AS typetoken RP */
143674
- { 175, -5 }, /* (172) expr ::= ID|INDEXED LP distinct exprlist RP */
143675
- { 175, -4 }, /* (173) expr ::= ID|INDEXED LP STAR RP */
143676
- { 174, -1 }, /* (174) term ::= CTIME_KW */
143677
- { 175, -5 }, /* (175) expr ::= LP nexprlist COMMA expr RP */
143678
- { 175, -3 }, /* (176) expr ::= expr AND expr */
143679
- { 175, -3 }, /* (177) expr ::= expr OR expr */
143680
- { 175, -3 }, /* (178) expr ::= expr LT|GT|GE|LE expr */
143681
- { 175, -3 }, /* (179) expr ::= expr EQ|NE expr */
143682
- { 175, -3 }, /* (180) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
143683
- { 175, -3 }, /* (181) expr ::= expr PLUS|MINUS expr */
143684
- { 175, -3 }, /* (182) expr ::= expr STAR|SLASH|REM expr */
143685
- { 175, -3 }, /* (183) expr ::= expr CONCAT expr */
143686
- { 226, -2 }, /* (184) likeop ::= NOT LIKE_KW|MATCH */
143687
- { 175, -3 }, /* (185) expr ::= expr likeop expr */
143688
- { 175, -5 }, /* (186) expr ::= expr likeop expr ESCAPE expr */
143689
- { 175, -2 }, /* (187) expr ::= expr ISNULL|NOTNULL */
143690
- { 175, -3 }, /* (188) expr ::= expr NOT NULL */
143691
- { 175, -3 }, /* (189) expr ::= expr IS expr */
143692
- { 175, -4 }, /* (190) expr ::= expr IS NOT expr */
143693
- { 175, -2 }, /* (191) expr ::= NOT expr */
143694
- { 175, -2 }, /* (192) expr ::= BITNOT expr */
143695
- { 175, -2 }, /* (193) expr ::= MINUS expr */
143696
- { 175, -2 }, /* (194) expr ::= PLUS expr */
143697
- { 227, -1 }, /* (195) between_op ::= BETWEEN */
143698
- { 227, -2 }, /* (196) between_op ::= NOT BETWEEN */
143699
- { 175, -5 }, /* (197) expr ::= expr between_op expr AND expr */
143700
- { 228, -1 }, /* (198) in_op ::= IN */
143701
- { 228, -2 }, /* (199) in_op ::= NOT IN */
143702
- { 175, -5 }, /* (200) expr ::= expr in_op LP exprlist RP */
143703
- { 175, -3 }, /* (201) expr ::= LP select RP */
143704
- { 175, -5 }, /* (202) expr ::= expr in_op LP select RP */
143705
- { 175, -5 }, /* (203) expr ::= expr in_op nm dbnm paren_exprlist */
143706
- { 175, -4 }, /* (204) expr ::= EXISTS LP select RP */
143707
- { 175, -5 }, /* (205) expr ::= CASE case_operand case_exprlist case_else END */
143708
- { 231, -5 }, /* (206) case_exprlist ::= case_exprlist WHEN expr THEN expr */
143709
- { 231, -4 }, /* (207) case_exprlist ::= WHEN expr THEN expr */
143710
- { 232, -2 }, /* (208) case_else ::= ELSE expr */
143711
- { 232, 0 }, /* (209) case_else ::= */
143712
- { 230, -1 }, /* (210) case_operand ::= expr */
143713
- { 230, 0 }, /* (211) case_operand ::= */
143714
- { 210, 0 }, /* (212) exprlist ::= */
143715
- { 209, -3 }, /* (213) nexprlist ::= nexprlist COMMA expr */
143716
- { 209, -1 }, /* (214) nexprlist ::= expr */
143717
- { 229, 0 }, /* (215) paren_exprlist ::= */
143718
- { 229, -3 }, /* (216) paren_exprlist ::= LP exprlist RP */
143719
- { 150, -12 }, /* (217) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
143720
- { 233, -1 }, /* (218) uniqueflag ::= UNIQUE */
143721
- { 233, 0 }, /* (219) uniqueflag ::= */
143722
- { 179, 0 }, /* (220) eidlist_opt ::= */
143723
- { 179, -3 }, /* (221) eidlist_opt ::= LP eidlist RP */
143724
- { 189, -5 }, /* (222) eidlist ::= eidlist COMMA nm collate sortorder */
143725
- { 189, -3 }, /* (223) eidlist ::= nm collate sortorder */
143726
- { 234, 0 }, /* (224) collate ::= */
143727
- { 234, -2 }, /* (225) collate ::= COLLATE ID|STRING */
143728
- { 150, -4 }, /* (226) cmd ::= DROP INDEX ifexists fullname */
143729
- { 150, -1 }, /* (227) cmd ::= VACUUM */
143730
- { 150, -2 }, /* (228) cmd ::= VACUUM nm */
143731
- { 150, -3 }, /* (229) cmd ::= PRAGMA nm dbnm */
143732
- { 150, -5 }, /* (230) cmd ::= PRAGMA nm dbnm EQ nmnum */
143733
- { 150, -6 }, /* (231) cmd ::= PRAGMA nm dbnm LP nmnum RP */
143734
- { 150, -5 }, /* (232) cmd ::= PRAGMA nm dbnm EQ minus_num */
143735
- { 150, -6 }, /* (233) cmd ::= PRAGMA nm dbnm LP minus_num RP */
143736
- { 170, -2 }, /* (234) plus_num ::= PLUS INTEGER|FLOAT */
143737
- { 171, -2 }, /* (235) minus_num ::= MINUS INTEGER|FLOAT */
143738
- { 150, -5 }, /* (236) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
143739
- { 236, -11 }, /* (237) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
143740
- { 238, -1 }, /* (238) trigger_time ::= BEFORE|AFTER */
143741
- { 238, -2 }, /* (239) trigger_time ::= INSTEAD OF */
143742
- { 238, 0 }, /* (240) trigger_time ::= */
143743
- { 239, -1 }, /* (241) trigger_event ::= DELETE|INSERT */
143744
- { 239, -1 }, /* (242) trigger_event ::= UPDATE */
143745
- { 239, -3 }, /* (243) trigger_event ::= UPDATE OF idlist */
143746
- { 241, 0 }, /* (244) when_clause ::= */
143747
- { 241, -2 }, /* (245) when_clause ::= WHEN expr */
143748
- { 237, -3 }, /* (246) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
143749
- { 237, -2 }, /* (247) trigger_cmd_list ::= trigger_cmd SEMI */
143750
- { 243, -3 }, /* (248) trnm ::= nm DOT nm */
143751
- { 244, -3 }, /* (249) tridxby ::= INDEXED BY nm */
143752
- { 244, -2 }, /* (250) tridxby ::= NOT INDEXED */
143753
- { 242, -8 }, /* (251) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
143754
- { 242, -8 }, /* (252) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
143755
- { 242, -6 }, /* (253) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
143756
- { 242, -3 }, /* (254) trigger_cmd ::= scanpt select scanpt */
143757
- { 175, -4 }, /* (255) expr ::= RAISE LP IGNORE RP */
143758
- { 175, -6 }, /* (256) expr ::= RAISE LP raisetype COMMA nm RP */
143759
- { 193, -1 }, /* (257) raisetype ::= ROLLBACK */
143760
- { 193, -1 }, /* (258) raisetype ::= ABORT */
143761
- { 193, -1 }, /* (259) raisetype ::= FAIL */
143762
- { 150, -4 }, /* (260) cmd ::= DROP TRIGGER ifexists fullname */
143763
- { 150, -6 }, /* (261) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
143764
- { 150, -3 }, /* (262) cmd ::= DETACH database_kw_opt expr */
143765
- { 246, 0 }, /* (263) key_opt ::= */
143766
- { 246, -2 }, /* (264) key_opt ::= KEY expr */
143767
- { 150, -1 }, /* (265) cmd ::= REINDEX */
143768
- { 150, -3 }, /* (266) cmd ::= REINDEX nm dbnm */
143769
- { 150, -1 }, /* (267) cmd ::= ANALYZE */
143770
- { 150, -3 }, /* (268) cmd ::= ANALYZE nm dbnm */
143771
- { 150, -6 }, /* (269) cmd ::= ALTER TABLE fullname RENAME TO nm */
143772
- { 150, -7 }, /* (270) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
143773
- { 247, -1 }, /* (271) add_column_fullname ::= fullname */
143774
- { 150, -1 }, /* (272) cmd ::= create_vtab */
143775
- { 150, -4 }, /* (273) cmd ::= create_vtab LP vtabarglist RP */
143776
- { 249, -8 }, /* (274) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
143777
- { 251, 0 }, /* (275) vtabarg ::= */
143778
- { 252, -1 }, /* (276) vtabargtoken ::= ANY */
143779
- { 252, -3 }, /* (277) vtabargtoken ::= lp anylist RP */
143780
- { 253, -1 }, /* (278) lp ::= LP */
143781
- { 221, -2 }, /* (279) with ::= WITH wqlist */
143782
- { 221, -3 }, /* (280) with ::= WITH RECURSIVE wqlist */
143783
- { 198, -6 }, /* (281) wqlist ::= nm eidlist_opt AS LP select RP */
143784
- { 198, -8 }, /* (282) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
143785
- { 145, -1 }, /* (283) input ::= cmdlist */
143786
- { 146, -2 }, /* (284) cmdlist ::= cmdlist ecmd */
143787
- { 146, -1 }, /* (285) cmdlist ::= ecmd */
143788
- { 147, -1 }, /* (286) ecmd ::= SEMI */
143789
- { 147, -2 }, /* (287) ecmd ::= cmdx SEMI */
143790
- { 147, -2 }, /* (288) ecmd ::= explain cmdx */
143791
- { 152, 0 }, /* (289) trans_opt ::= */
143792
- { 152, -1 }, /* (290) trans_opt ::= TRANSACTION */
143793
- { 152, -2 }, /* (291) trans_opt ::= TRANSACTION nm */
143794
- { 154, -1 }, /* (292) savepoint_opt ::= SAVEPOINT */
143795
- { 154, 0 }, /* (293) savepoint_opt ::= */
143796
- { 150, -2 }, /* (294) cmd ::= create_table create_table_args */
143797
- { 161, -4 }, /* (295) columnlist ::= columnlist COMMA columnname carglist */
143798
- { 161, -2 }, /* (296) columnlist ::= columnname carglist */
143799
- { 153, -1 }, /* (297) nm ::= ID|INDEXED */
143800
- { 153, -1 }, /* (298) nm ::= STRING */
143801
- { 153, -1 }, /* (299) nm ::= JOIN_KW */
143802
- { 167, -1 }, /* (300) typetoken ::= typename */
143803
- { 168, -1 }, /* (301) typename ::= ID|STRING */
143804
- { 169, -1 }, /* (302) signed ::= plus_num */
143805
- { 169, -1 }, /* (303) signed ::= minus_num */
143806
- { 166, -2 }, /* (304) carglist ::= carglist ccons */
143807
- { 166, 0 }, /* (305) carglist ::= */
143808
- { 173, -2 }, /* (306) ccons ::= NULL onconf */
143809
- { 162, -2 }, /* (307) conslist_opt ::= COMMA conslist */
143810
- { 185, -3 }, /* (308) conslist ::= conslist tconscomma tcons */
143811
- { 185, -1 }, /* (309) conslist ::= tcons */
143812
- { 186, 0 }, /* (310) tconscomma ::= */
143813
- { 190, -1 }, /* (311) defer_subclause_opt ::= defer_subclause */
143814
- { 192, -1 }, /* (312) resolvetype ::= raisetype */
143815
- { 196, -1 }, /* (313) selectnowith ::= oneselect */
143816
- { 197, -1 }, /* (314) oneselect ::= values */
143817
- { 211, -2 }, /* (315) sclp ::= selcollist COMMA */
143818
- { 212, -1 }, /* (316) as ::= ID|STRING */
143819
- { 175, -1 }, /* (317) expr ::= term */
143820
- { 226, -1 }, /* (318) likeop ::= LIKE_KW|MATCH */
143821
- { 210, -1 }, /* (319) exprlist ::= nexprlist */
143822
- { 235, -1 }, /* (320) nmnum ::= plus_num */
143823
- { 235, -1 }, /* (321) nmnum ::= nm */
143824
- { 235, -1 }, /* (322) nmnum ::= ON */
143825
- { 235, -1 }, /* (323) nmnum ::= DELETE */
143826
- { 235, -1 }, /* (324) nmnum ::= DEFAULT */
143827
- { 170, -1 }, /* (325) plus_num ::= INTEGER|FLOAT */
143828
- { 240, 0 }, /* (326) foreach_clause ::= */
143829
- { 240, -3 }, /* (327) foreach_clause ::= FOR EACH ROW */
143830
- { 243, -1 }, /* (328) trnm ::= nm */
143831
- { 244, 0 }, /* (329) tridxby ::= */
143832
- { 245, -1 }, /* (330) database_kw_opt ::= DATABASE */
143833
- { 245, 0 }, /* (331) database_kw_opt ::= */
143834
- { 248, 0 }, /* (332) kwcolumn_opt ::= */
143835
- { 248, -1 }, /* (333) kwcolumn_opt ::= COLUMNKW */
143836
- { 250, -1 }, /* (334) vtabarglist ::= vtabarg */
143837
- { 250, -3 }, /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */
143838
- { 251, -2 }, /* (336) vtabarg ::= vtabarg vtabargtoken */
143839
- { 254, 0 }, /* (337) anylist ::= */
143840
- { 254, -4 }, /* (338) anylist ::= anylist LP anylist RP */
143841
- { 254, -2 }, /* (339) anylist ::= anylist ANY */
143842
- { 221, 0 }, /* (340) with ::= */
146980
+ { 159, -1 }, /* (0) explain ::= EXPLAIN */
146981
+ { 159, -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */
146982
+ { 158, -1 }, /* (2) cmdx ::= cmd */
146983
+ { 160, -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */
146984
+ { 161, 0 }, /* (4) transtype ::= */
146985
+ { 161, -1 }, /* (5) transtype ::= DEFERRED */
146986
+ { 161, -1 }, /* (6) transtype ::= IMMEDIATE */
146987
+ { 161, -1 }, /* (7) transtype ::= EXCLUSIVE */
146988
+ { 160, -2 }, /* (8) cmd ::= COMMIT|END trans_opt */
146989
+ { 160, -2 }, /* (9) cmd ::= ROLLBACK trans_opt */
146990
+ { 160, -2 }, /* (10) cmd ::= SAVEPOINT nm */
146991
+ { 160, -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */
146992
+ { 160, -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
146993
+ { 165, -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
146994
+ { 167, -1 }, /* (14) createkw ::= CREATE */
146995
+ { 169, 0 }, /* (15) ifnotexists ::= */
146996
+ { 169, -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */
146997
+ { 168, -1 }, /* (17) temp ::= TEMP */
146998
+ { 168, 0 }, /* (18) temp ::= */
146999
+ { 166, -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
147000
+ { 166, -2 }, /* (20) create_table_args ::= AS select */
147001
+ { 173, 0 }, /* (21) table_options ::= */
147002
+ { 173, -2 }, /* (22) table_options ::= WITHOUT nm */
147003
+ { 175, -2 }, /* (23) columnname ::= nm typetoken */
147004
+ { 177, 0 }, /* (24) typetoken ::= */
147005
+ { 177, -4 }, /* (25) typetoken ::= typename LP signed RP */
147006
+ { 177, -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */
147007
+ { 178, -2 }, /* (27) typename ::= typename ID|STRING */
147008
+ { 182, 0 }, /* (28) scanpt ::= */
147009
+ { 183, -2 }, /* (29) ccons ::= CONSTRAINT nm */
147010
+ { 183, -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */
147011
+ { 183, -4 }, /* (31) ccons ::= DEFAULT LP expr RP */
147012
+ { 183, -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */
147013
+ { 183, -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */
147014
+ { 183, -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
147015
+ { 183, -3 }, /* (35) ccons ::= NOT NULL onconf */
147016
+ { 183, -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
147017
+ { 183, -2 }, /* (37) ccons ::= UNIQUE onconf */
147018
+ { 183, -4 }, /* (38) ccons ::= CHECK LP expr RP */
147019
+ { 183, -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
147020
+ { 183, -1 }, /* (40) ccons ::= defer_subclause */
147021
+ { 183, -2 }, /* (41) ccons ::= COLLATE ID|STRING */
147022
+ { 188, 0 }, /* (42) autoinc ::= */
147023
+ { 188, -1 }, /* (43) autoinc ::= AUTOINCR */
147024
+ { 190, 0 }, /* (44) refargs ::= */
147025
+ { 190, -2 }, /* (45) refargs ::= refargs refarg */
147026
+ { 192, -2 }, /* (46) refarg ::= MATCH nm */
147027
+ { 192, -3 }, /* (47) refarg ::= ON INSERT refact */
147028
+ { 192, -3 }, /* (48) refarg ::= ON DELETE refact */
147029
+ { 192, -3 }, /* (49) refarg ::= ON UPDATE refact */
147030
+ { 193, -2 }, /* (50) refact ::= SET NULL */
147031
+ { 193, -2 }, /* (51) refact ::= SET DEFAULT */
147032
+ { 193, -1 }, /* (52) refact ::= CASCADE */
147033
+ { 193, -1 }, /* (53) refact ::= RESTRICT */
147034
+ { 193, -2 }, /* (54) refact ::= NO ACTION */
147035
+ { 191, -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
147036
+ { 191, -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
147037
+ { 194, 0 }, /* (57) init_deferred_pred_opt ::= */
147038
+ { 194, -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
147039
+ { 194, -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
147040
+ { 172, 0 }, /* (60) conslist_opt ::= */
147041
+ { 196, -1 }, /* (61) tconscomma ::= COMMA */
147042
+ { 197, -2 }, /* (62) tcons ::= CONSTRAINT nm */
147043
+ { 197, -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
147044
+ { 197, -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
147045
+ { 197, -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */
147046
+ { 197, -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
147047
+ { 200, 0 }, /* (67) defer_subclause_opt ::= */
147048
+ { 186, 0 }, /* (68) onconf ::= */
147049
+ { 186, -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */
147050
+ { 201, 0 }, /* (70) orconf ::= */
147051
+ { 201, -2 }, /* (71) orconf ::= OR resolvetype */
147052
+ { 202, -1 }, /* (72) resolvetype ::= IGNORE */
147053
+ { 202, -1 }, /* (73) resolvetype ::= REPLACE */
147054
+ { 160, -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
147055
+ { 204, -2 }, /* (75) ifexists ::= IF EXISTS */
147056
+ { 204, 0 }, /* (76) ifexists ::= */
147057
+ { 160, -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
147058
+ { 160, -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
147059
+ { 160, -1 }, /* (79) cmd ::= select */
147060
+ { 174, -3 }, /* (80) select ::= WITH wqlist selectnowith */
147061
+ { 174, -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
147062
+ { 174, -1 }, /* (82) select ::= selectnowith */
147063
+ { 206, -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
147064
+ { 209, -1 }, /* (84) multiselect_op ::= UNION */
147065
+ { 209, -2 }, /* (85) multiselect_op ::= UNION ALL */
147066
+ { 209, -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
147067
+ { 207, -10 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt windowdefn_opt orderby_opt limit_opt */
147068
+ { 219, -4 }, /* (88) values ::= VALUES LP nexprlist RP */
147069
+ { 219, -5 }, /* (89) values ::= values COMMA LP exprlist RP */
147070
+ { 210, -1 }, /* (90) distinct ::= DISTINCT */
147071
+ { 210, -1 }, /* (91) distinct ::= ALL */
147072
+ { 210, 0 }, /* (92) distinct ::= */
147073
+ { 222, 0 }, /* (93) sclp ::= */
147074
+ { 211, -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
147075
+ { 211, -3 }, /* (95) selcollist ::= sclp scanpt STAR */
147076
+ { 211, -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
147077
+ { 223, -2 }, /* (97) as ::= AS nm */
147078
+ { 223, 0 }, /* (98) as ::= */
147079
+ { 212, 0 }, /* (99) from ::= */
147080
+ { 212, -2 }, /* (100) from ::= FROM seltablist */
147081
+ { 225, -2 }, /* (101) stl_prefix ::= seltablist joinop */
147082
+ { 225, 0 }, /* (102) stl_prefix ::= */
147083
+ { 224, -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
147084
+ { 224, -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
147085
+ { 224, -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
147086
+ { 224, -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
147087
+ { 170, 0 }, /* (107) dbnm ::= */
147088
+ { 170, -2 }, /* (108) dbnm ::= DOT nm */
147089
+ { 205, -1 }, /* (109) fullname ::= nm */
147090
+ { 205, -3 }, /* (110) fullname ::= nm DOT nm */
147091
+ { 230, -1 }, /* (111) xfullname ::= nm */
147092
+ { 230, -3 }, /* (112) xfullname ::= nm DOT nm */
147093
+ { 230, -5 }, /* (113) xfullname ::= nm DOT nm AS nm */
147094
+ { 230, -3 }, /* (114) xfullname ::= nm AS nm */
147095
+ { 226, -1 }, /* (115) joinop ::= COMMA|JOIN */
147096
+ { 226, -2 }, /* (116) joinop ::= JOIN_KW JOIN */
147097
+ { 226, -3 }, /* (117) joinop ::= JOIN_KW nm JOIN */
147098
+ { 226, -4 }, /* (118) joinop ::= JOIN_KW nm nm JOIN */
147099
+ { 228, -2 }, /* (119) on_opt ::= ON expr */
147100
+ { 228, 0 }, /* (120) on_opt ::= */
147101
+ { 227, 0 }, /* (121) indexed_opt ::= */
147102
+ { 227, -3 }, /* (122) indexed_opt ::= INDEXED BY nm */
147103
+ { 227, -2 }, /* (123) indexed_opt ::= NOT INDEXED */
147104
+ { 229, -4 }, /* (124) using_opt ::= USING LP idlist RP */
147105
+ { 229, 0 }, /* (125) using_opt ::= */
147106
+ { 217, 0 }, /* (126) orderby_opt ::= */
147107
+ { 217, -3 }, /* (127) orderby_opt ::= ORDER BY sortlist */
147108
+ { 198, -4 }, /* (128) sortlist ::= sortlist COMMA expr sortorder */
147109
+ { 198, -2 }, /* (129) sortlist ::= expr sortorder */
147110
+ { 187, -1 }, /* (130) sortorder ::= ASC */
147111
+ { 187, -1 }, /* (131) sortorder ::= DESC */
147112
+ { 187, 0 }, /* (132) sortorder ::= */
147113
+ { 214, 0 }, /* (133) groupby_opt ::= */
147114
+ { 214, -3 }, /* (134) groupby_opt ::= GROUP BY nexprlist */
147115
+ { 215, 0 }, /* (135) having_opt ::= */
147116
+ { 215, -2 }, /* (136) having_opt ::= HAVING expr */
147117
+ { 218, 0 }, /* (137) limit_opt ::= */
147118
+ { 218, -2 }, /* (138) limit_opt ::= LIMIT expr */
147119
+ { 218, -4 }, /* (139) limit_opt ::= LIMIT expr OFFSET expr */
147120
+ { 218, -4 }, /* (140) limit_opt ::= LIMIT expr COMMA expr */
147121
+ { 160, -6 }, /* (141) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
147122
+ { 213, 0 }, /* (142) where_opt ::= */
147123
+ { 213, -2 }, /* (143) where_opt ::= WHERE expr */
147124
+ { 160, -8 }, /* (144) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
147125
+ { 233, -5 }, /* (145) setlist ::= setlist COMMA nm EQ expr */
147126
+ { 233, -7 }, /* (146) setlist ::= setlist COMMA LP idlist RP EQ expr */
147127
+ { 233, -3 }, /* (147) setlist ::= nm EQ expr */
147128
+ { 233, -5 }, /* (148) setlist ::= LP idlist RP EQ expr */
147129
+ { 160, -7 }, /* (149) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
147130
+ { 160, -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
147131
+ { 236, 0 }, /* (151) upsert ::= */
147132
+ { 236, -11 }, /* (152) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
147133
+ { 236, -8 }, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
147134
+ { 236, -4 }, /* (154) upsert ::= ON CONFLICT DO NOTHING */
147135
+ { 234, -2 }, /* (155) insert_cmd ::= INSERT orconf */
147136
+ { 234, -1 }, /* (156) insert_cmd ::= REPLACE */
147137
+ { 235, 0 }, /* (157) idlist_opt ::= */
147138
+ { 235, -3 }, /* (158) idlist_opt ::= LP idlist RP */
147139
+ { 231, -3 }, /* (159) idlist ::= idlist COMMA nm */
147140
+ { 231, -1 }, /* (160) idlist ::= nm */
147141
+ { 185, -3 }, /* (161) expr ::= LP expr RP */
147142
+ { 185, -1 }, /* (162) expr ::= ID|INDEXED */
147143
+ { 185, -1 }, /* (163) expr ::= JOIN_KW */
147144
+ { 185, -3 }, /* (164) expr ::= nm DOT nm */
147145
+ { 185, -5 }, /* (165) expr ::= nm DOT nm DOT nm */
147146
+ { 184, -1 }, /* (166) term ::= NULL|FLOAT|BLOB */
147147
+ { 184, -1 }, /* (167) term ::= STRING */
147148
+ { 184, -1 }, /* (168) term ::= INTEGER */
147149
+ { 185, -1 }, /* (169) expr ::= VARIABLE */
147150
+ { 185, -3 }, /* (170) expr ::= expr COLLATE ID|STRING */
147151
+ { 185, -6 }, /* (171) expr ::= CAST LP expr AS typetoken RP */
147152
+ { 185, -6 }, /* (172) expr ::= ID|INDEXED LP distinct exprlist RP over_opt */
147153
+ { 185, -5 }, /* (173) expr ::= ID|INDEXED LP STAR RP over_opt */
147154
+ { 184, -1 }, /* (174) term ::= CTIME_KW */
147155
+ { 185, -5 }, /* (175) expr ::= LP nexprlist COMMA expr RP */
147156
+ { 185, -3 }, /* (176) expr ::= expr AND expr */
147157
+ { 185, -3 }, /* (177) expr ::= expr OR expr */
147158
+ { 185, -3 }, /* (178) expr ::= expr LT|GT|GE|LE expr */
147159
+ { 185, -3 }, /* (179) expr ::= expr EQ|NE expr */
147160
+ { 185, -3 }, /* (180) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
147161
+ { 185, -3 }, /* (181) expr ::= expr PLUS|MINUS expr */
147162
+ { 185, -3 }, /* (182) expr ::= expr STAR|SLASH|REM expr */
147163
+ { 185, -3 }, /* (183) expr ::= expr CONCAT expr */
147164
+ { 238, -2 }, /* (184) likeop ::= NOT LIKE_KW|MATCH */
147165
+ { 185, -3 }, /* (185) expr ::= expr likeop expr */
147166
+ { 185, -5 }, /* (186) expr ::= expr likeop expr ESCAPE expr */
147167
+ { 185, -2 }, /* (187) expr ::= expr ISNULL|NOTNULL */
147168
+ { 185, -3 }, /* (188) expr ::= expr NOT NULL */
147169
+ { 185, -3 }, /* (189) expr ::= expr IS expr */
147170
+ { 185, -4 }, /* (190) expr ::= expr IS NOT expr */
147171
+ { 185, -2 }, /* (191) expr ::= NOT expr */
147172
+ { 185, -2 }, /* (192) expr ::= BITNOT expr */
147173
+ { 185, -2 }, /* (193) expr ::= PLUS|MINUS expr */
147174
+ { 239, -1 }, /* (194) between_op ::= BETWEEN */
147175
+ { 239, -2 }, /* (195) between_op ::= NOT BETWEEN */
147176
+ { 185, -5 }, /* (196) expr ::= expr between_op expr AND expr */
147177
+ { 240, -1 }, /* (197) in_op ::= IN */
147178
+ { 240, -2 }, /* (198) in_op ::= NOT IN */
147179
+ { 185, -5 }, /* (199) expr ::= expr in_op LP exprlist RP */
147180
+ { 185, -3 }, /* (200) expr ::= LP select RP */
147181
+ { 185, -5 }, /* (201) expr ::= expr in_op LP select RP */
147182
+ { 185, -5 }, /* (202) expr ::= expr in_op nm dbnm paren_exprlist */
147183
+ { 185, -4 }, /* (203) expr ::= EXISTS LP select RP */
147184
+ { 185, -5 }, /* (204) expr ::= CASE case_operand case_exprlist case_else END */
147185
+ { 243, -5 }, /* (205) case_exprlist ::= case_exprlist WHEN expr THEN expr */
147186
+ { 243, -4 }, /* (206) case_exprlist ::= WHEN expr THEN expr */
147187
+ { 244, -2 }, /* (207) case_else ::= ELSE expr */
147188
+ { 244, 0 }, /* (208) case_else ::= */
147189
+ { 242, -1 }, /* (209) case_operand ::= expr */
147190
+ { 242, 0 }, /* (210) case_operand ::= */
147191
+ { 221, 0 }, /* (211) exprlist ::= */
147192
+ { 220, -3 }, /* (212) nexprlist ::= nexprlist COMMA expr */
147193
+ { 220, -1 }, /* (213) nexprlist ::= expr */
147194
+ { 241, 0 }, /* (214) paren_exprlist ::= */
147195
+ { 241, -3 }, /* (215) paren_exprlist ::= LP exprlist RP */
147196
+ { 160, -12 }, /* (216) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
147197
+ { 245, -1 }, /* (217) uniqueflag ::= UNIQUE */
147198
+ { 245, 0 }, /* (218) uniqueflag ::= */
147199
+ { 189, 0 }, /* (219) eidlist_opt ::= */
147200
+ { 189, -3 }, /* (220) eidlist_opt ::= LP eidlist RP */
147201
+ { 199, -5 }, /* (221) eidlist ::= eidlist COMMA nm collate sortorder */
147202
+ { 199, -3 }, /* (222) eidlist ::= nm collate sortorder */
147203
+ { 246, 0 }, /* (223) collate ::= */
147204
+ { 246, -2 }, /* (224) collate ::= COLLATE ID|STRING */
147205
+ { 160, -4 }, /* (225) cmd ::= DROP INDEX ifexists fullname */
147206
+ { 160, -1 }, /* (226) cmd ::= VACUUM */
147207
+ { 160, -2 }, /* (227) cmd ::= VACUUM nm */
147208
+ { 160, -3 }, /* (228) cmd ::= PRAGMA nm dbnm */
147209
+ { 160, -5 }, /* (229) cmd ::= PRAGMA nm dbnm EQ nmnum */
147210
+ { 160, -6 }, /* (230) cmd ::= PRAGMA nm dbnm LP nmnum RP */
147211
+ { 160, -5 }, /* (231) cmd ::= PRAGMA nm dbnm EQ minus_num */
147212
+ { 160, -6 }, /* (232) cmd ::= PRAGMA nm dbnm LP minus_num RP */
147213
+ { 180, -2 }, /* (233) plus_num ::= PLUS INTEGER|FLOAT */
147214
+ { 181, -2 }, /* (234) minus_num ::= MINUS INTEGER|FLOAT */
147215
+ { 160, -5 }, /* (235) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
147216
+ { 248, -11 }, /* (236) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
147217
+ { 250, -1 }, /* (237) trigger_time ::= BEFORE|AFTER */
147218
+ { 250, -2 }, /* (238) trigger_time ::= INSTEAD OF */
147219
+ { 250, 0 }, /* (239) trigger_time ::= */
147220
+ { 251, -1 }, /* (240) trigger_event ::= DELETE|INSERT */
147221
+ { 251, -1 }, /* (241) trigger_event ::= UPDATE */
147222
+ { 251, -3 }, /* (242) trigger_event ::= UPDATE OF idlist */
147223
+ { 253, 0 }, /* (243) when_clause ::= */
147224
+ { 253, -2 }, /* (244) when_clause ::= WHEN expr */
147225
+ { 249, -3 }, /* (245) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
147226
+ { 249, -2 }, /* (246) trigger_cmd_list ::= trigger_cmd SEMI */
147227
+ { 255, -3 }, /* (247) trnm ::= nm DOT nm */
147228
+ { 256, -3 }, /* (248) tridxby ::= INDEXED BY nm */
147229
+ { 256, -2 }, /* (249) tridxby ::= NOT INDEXED */
147230
+ { 254, -8 }, /* (250) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
147231
+ { 254, -8 }, /* (251) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
147232
+ { 254, -6 }, /* (252) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
147233
+ { 254, -3 }, /* (253) trigger_cmd ::= scanpt select scanpt */
147234
+ { 185, -4 }, /* (254) expr ::= RAISE LP IGNORE RP */
147235
+ { 185, -6 }, /* (255) expr ::= RAISE LP raisetype COMMA nm RP */
147236
+ { 203, -1 }, /* (256) raisetype ::= ROLLBACK */
147237
+ { 203, -1 }, /* (257) raisetype ::= ABORT */
147238
+ { 203, -1 }, /* (258) raisetype ::= FAIL */
147239
+ { 160, -4 }, /* (259) cmd ::= DROP TRIGGER ifexists fullname */
147240
+ { 160, -6 }, /* (260) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
147241
+ { 160, -3 }, /* (261) cmd ::= DETACH database_kw_opt expr */
147242
+ { 258, 0 }, /* (262) key_opt ::= */
147243
+ { 258, -2 }, /* (263) key_opt ::= KEY expr */
147244
+ { 160, -1 }, /* (264) cmd ::= REINDEX */
147245
+ { 160, -3 }, /* (265) cmd ::= REINDEX nm dbnm */
147246
+ { 160, -1 }, /* (266) cmd ::= ANALYZE */
147247
+ { 160, -3 }, /* (267) cmd ::= ANALYZE nm dbnm */
147248
+ { 160, -6 }, /* (268) cmd ::= ALTER TABLE fullname RENAME TO nm */
147249
+ { 160, -7 }, /* (269) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
147250
+ { 259, -1 }, /* (270) add_column_fullname ::= fullname */
147251
+ { 160, -1 }, /* (271) cmd ::= create_vtab */
147252
+ { 160, -4 }, /* (272) cmd ::= create_vtab LP vtabarglist RP */
147253
+ { 261, -8 }, /* (273) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
147254
+ { 263, 0 }, /* (274) vtabarg ::= */
147255
+ { 264, -1 }, /* (275) vtabargtoken ::= ANY */
147256
+ { 264, -3 }, /* (276) vtabargtoken ::= lp anylist RP */
147257
+ { 265, -1 }, /* (277) lp ::= LP */
147258
+ { 232, -2 }, /* (278) with ::= WITH wqlist */
147259
+ { 232, -3 }, /* (279) with ::= WITH RECURSIVE wqlist */
147260
+ { 208, -6 }, /* (280) wqlist ::= nm eidlist_opt AS LP select RP */
147261
+ { 208, -8 }, /* (281) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
147262
+ { 267, -1 }, /* (282) windowdefn_list ::= windowdefn */
147263
+ { 267, -3 }, /* (283) windowdefn_list ::= windowdefn_list COMMA windowdefn */
147264
+ { 268, -3 }, /* (284) windowdefn ::= nm AS window */
147265
+ { 269, -5 }, /* (285) window ::= LP part_opt orderby_opt frame_opt RP */
147266
+ { 271, -3 }, /* (286) part_opt ::= PARTITION BY exprlist */
147267
+ { 271, 0 }, /* (287) part_opt ::= */
147268
+ { 270, 0 }, /* (288) frame_opt ::= */
147269
+ { 270, -2 }, /* (289) frame_opt ::= range_or_rows frame_bound_s */
147270
+ { 270, -5 }, /* (290) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
147271
+ { 273, -1 }, /* (291) range_or_rows ::= RANGE */
147272
+ { 273, -1 }, /* (292) range_or_rows ::= ROWS */
147273
+ { 275, -1 }, /* (293) frame_bound_s ::= frame_bound */
147274
+ { 275, -2 }, /* (294) frame_bound_s ::= UNBOUNDED PRECEDING */
147275
+ { 276, -1 }, /* (295) frame_bound_e ::= frame_bound */
147276
+ { 276, -2 }, /* (296) frame_bound_e ::= UNBOUNDED FOLLOWING */
147277
+ { 274, -2 }, /* (297) frame_bound ::= expr PRECEDING */
147278
+ { 274, -2 }, /* (298) frame_bound ::= CURRENT ROW */
147279
+ { 274, -2 }, /* (299) frame_bound ::= expr FOLLOWING */
147280
+ { 216, 0 }, /* (300) windowdefn_opt ::= */
147281
+ { 216, -2 }, /* (301) windowdefn_opt ::= WINDOW windowdefn_list */
147282
+ { 237, 0 }, /* (302) over_opt ::= */
147283
+ { 237, -3 }, /* (303) over_opt ::= filter_opt OVER window */
147284
+ { 237, -3 }, /* (304) over_opt ::= filter_opt OVER nm */
147285
+ { 272, 0 }, /* (305) filter_opt ::= */
147286
+ { 272, -5 }, /* (306) filter_opt ::= FILTER LP WHERE expr RP */
147287
+ { 155, -1 }, /* (307) input ::= cmdlist */
147288
+ { 156, -2 }, /* (308) cmdlist ::= cmdlist ecmd */
147289
+ { 156, -1 }, /* (309) cmdlist ::= ecmd */
147290
+ { 157, -1 }, /* (310) ecmd ::= SEMI */
147291
+ { 157, -2 }, /* (311) ecmd ::= cmdx SEMI */
147292
+ { 157, -2 }, /* (312) ecmd ::= explain cmdx */
147293
+ { 162, 0 }, /* (313) trans_opt ::= */
147294
+ { 162, -1 }, /* (314) trans_opt ::= TRANSACTION */
147295
+ { 162, -2 }, /* (315) trans_opt ::= TRANSACTION nm */
147296
+ { 164, -1 }, /* (316) savepoint_opt ::= SAVEPOINT */
147297
+ { 164, 0 }, /* (317) savepoint_opt ::= */
147298
+ { 160, -2 }, /* (318) cmd ::= create_table create_table_args */
147299
+ { 171, -4 }, /* (319) columnlist ::= columnlist COMMA columnname carglist */
147300
+ { 171, -2 }, /* (320) columnlist ::= columnname carglist */
147301
+ { 163, -1 }, /* (321) nm ::= ID|INDEXED */
147302
+ { 163, -1 }, /* (322) nm ::= STRING */
147303
+ { 163, -1 }, /* (323) nm ::= JOIN_KW */
147304
+ { 177, -1 }, /* (324) typetoken ::= typename */
147305
+ { 178, -1 }, /* (325) typename ::= ID|STRING */
147306
+ { 179, -1 }, /* (326) signed ::= plus_num */
147307
+ { 179, -1 }, /* (327) signed ::= minus_num */
147308
+ { 176, -2 }, /* (328) carglist ::= carglist ccons */
147309
+ { 176, 0 }, /* (329) carglist ::= */
147310
+ { 183, -2 }, /* (330) ccons ::= NULL onconf */
147311
+ { 172, -2 }, /* (331) conslist_opt ::= COMMA conslist */
147312
+ { 195, -3 }, /* (332) conslist ::= conslist tconscomma tcons */
147313
+ { 195, -1 }, /* (333) conslist ::= tcons */
147314
+ { 196, 0 }, /* (334) tconscomma ::= */
147315
+ { 200, -1 }, /* (335) defer_subclause_opt ::= defer_subclause */
147316
+ { 202, -1 }, /* (336) resolvetype ::= raisetype */
147317
+ { 206, -1 }, /* (337) selectnowith ::= oneselect */
147318
+ { 207, -1 }, /* (338) oneselect ::= values */
147319
+ { 222, -2 }, /* (339) sclp ::= selcollist COMMA */
147320
+ { 223, -1 }, /* (340) as ::= ID|STRING */
147321
+ { 185, -1 }, /* (341) expr ::= term */
147322
+ { 238, -1 }, /* (342) likeop ::= LIKE_KW|MATCH */
147323
+ { 221, -1 }, /* (343) exprlist ::= nexprlist */
147324
+ { 247, -1 }, /* (344) nmnum ::= plus_num */
147325
+ { 247, -1 }, /* (345) nmnum ::= nm */
147326
+ { 247, -1 }, /* (346) nmnum ::= ON */
147327
+ { 247, -1 }, /* (347) nmnum ::= DELETE */
147328
+ { 247, -1 }, /* (348) nmnum ::= DEFAULT */
147329
+ { 180, -1 }, /* (349) plus_num ::= INTEGER|FLOAT */
147330
+ { 252, 0 }, /* (350) foreach_clause ::= */
147331
+ { 252, -3 }, /* (351) foreach_clause ::= FOR EACH ROW */
147332
+ { 255, -1 }, /* (352) trnm ::= nm */
147333
+ { 256, 0 }, /* (353) tridxby ::= */
147334
+ { 257, -1 }, /* (354) database_kw_opt ::= DATABASE */
147335
+ { 257, 0 }, /* (355) database_kw_opt ::= */
147336
+ { 260, 0 }, /* (356) kwcolumn_opt ::= */
147337
+ { 260, -1 }, /* (357) kwcolumn_opt ::= COLUMNKW */
147338
+ { 262, -1 }, /* (358) vtabarglist ::= vtabarg */
147339
+ { 262, -3 }, /* (359) vtabarglist ::= vtabarglist COMMA vtabarg */
147340
+ { 263, -2 }, /* (360) vtabarg ::= vtabarg vtabargtoken */
147341
+ { 266, 0 }, /* (361) anylist ::= */
147342
+ { 266, -4 }, /* (362) anylist ::= anylist LP anylist RP */
147343
+ { 266, -2 }, /* (363) anylist ::= anylist ANY */
147344
+ { 232, 0 }, /* (364) with ::= */
143843147345
};
143844147346
143845147347
static void yy_accept(yyParser*); /* Forward Declaration */
143846147348
143847147349
/*
@@ -143934,19 +147436,19 @@
143934147436
break;
143935147437
case 2: /* cmdx ::= cmd */
143936147438
{ sqlite3FinishCoding(pParse); }
143937147439
break;
143938147440
case 3: /* cmd ::= BEGIN transtype trans_opt */
143939
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy502);}
147441
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy70);}
143940147442
break;
143941147443
case 4: /* transtype ::= */
143942
-{yymsp[1].minor.yy502 = TK_DEFERRED;}
147444
+{yymsp[1].minor.yy70 = TK_DEFERRED;}
143943147445
break;
143944147446
case 5: /* transtype ::= DEFERRED */
143945147447
case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
143946147448
case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
143947
-{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/}
147449
+{yymsp[0].minor.yy70 = yymsp[0].major; /*A-overwrites-X*/}
143948147450
break;
143949147451
case 8: /* cmd ::= COMMIT|END trans_opt */
143950147452
case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
143951147453
{sqlite3EndTransaction(pParse,yymsp[-1].major);}
143952147454
break;
@@ -143965,11 +147467,11 @@
143965147467
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
143966147468
}
143967147469
break;
143968147470
case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
143969147471
{
143970
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy502,0,0,yymsp[-2].minor.yy502);
147472
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy70,0,0,yymsp[-2].minor.yy70);
143971147473
}
143972147474
break;
143973147475
case 14: /* createkw ::= CREATE */
143974147476
{disableLookaside(pParse);}
143975147477
break;
@@ -143979,37 +147481,37 @@
143979147481
case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
143980147482
case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
143981147483
case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
143982147484
case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
143983147485
case 92: /* distinct ::= */ yytestcase(yyruleno==92);
143984
- case 224: /* collate ::= */ yytestcase(yyruleno==224);
143985
-{yymsp[1].minor.yy502 = 0;}
147486
+ case 223: /* collate ::= */ yytestcase(yyruleno==223);
147487
+{yymsp[1].minor.yy70 = 0;}
143986147488
break;
143987147489
case 16: /* ifnotexists ::= IF NOT EXISTS */
143988
-{yymsp[-2].minor.yy502 = 1;}
147490
+{yymsp[-2].minor.yy70 = 1;}
143989147491
break;
143990147492
case 17: /* temp ::= TEMP */
143991147493
case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
143992
-{yymsp[0].minor.yy502 = 1;}
147494
+{yymsp[0].minor.yy70 = 1;}
143993147495
break;
143994147496
case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
143995147497
{
143996
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy502,0);
147498
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy70,0);
143997147499
}
143998147500
break;
143999147501
case 20: /* create_table_args ::= AS select */
144000147502
{
144001
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy399);
144002
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
147503
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy489);
147504
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy489);
144003147505
}
144004147506
break;
144005147507
case 22: /* table_options ::= WITHOUT nm */
144006147508
{
144007147509
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
144008
- yymsp[-1].minor.yy502 = TF_WithoutRowid | TF_NoVisibleRowid;
147510
+ yymsp[-1].minor.yy70 = TF_WithoutRowid | TF_NoVisibleRowid;
144009147511
}else{
144010
- yymsp[-1].minor.yy502 = 0;
147512
+ yymsp[-1].minor.yy70 = 0;
144011147513
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
144012147514
}
144013147515
}
144014147516
break;
144015147517
case 23: /* columnname ::= nm typetoken */
@@ -144034,30 +147536,30 @@
144034147536
{yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
144035147537
break;
144036147538
case 28: /* scanpt ::= */
144037147539
{
144038147540
assert( yyLookahead!=YYNOCODE );
144039
- yymsp[1].minor.yy36 = yyLookaheadToken.z;
147541
+ yymsp[1].minor.yy392 = yyLookaheadToken.z;
144040147542
}
144041147543
break;
144042147544
case 29: /* ccons ::= CONSTRAINT nm */
144043147545
case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
144044147546
{pParse->constraintName = yymsp[0].minor.yy0;}
144045147547
break;
144046147548
case 30: /* ccons ::= DEFAULT scanpt term scanpt */
144047
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy36,yymsp[0].minor.yy36);}
147549
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy18,yymsp[-2].minor.yy392,yymsp[0].minor.yy392);}
144048147550
break;
144049147551
case 31: /* ccons ::= DEFAULT LP expr RP */
144050
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
147552
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy18,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
144051147553
break;
144052147554
case 32: /* ccons ::= DEFAULT PLUS term scanpt */
144053
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);}
147555
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy18,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy392);}
144054147556
break;
144055147557
case 33: /* ccons ::= DEFAULT MINUS term scanpt */
144056147558
{
144057
- Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy182, 0);
144058
- sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);
147559
+ Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy18, 0);
147560
+ sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy392);
144059147561
}
144060147562
break;
144061147563
case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */
144062147564
{
144063147565
Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
@@ -144067,612 +147569,595 @@
144067147569
}
144068147570
sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
144069147571
}
144070147572
break;
144071147573
case 35: /* ccons ::= NOT NULL onconf */
144072
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy502);}
147574
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy70);}
144073147575
break;
144074147576
case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
144075
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy502,yymsp[0].minor.yy502,yymsp[-2].minor.yy502);}
147577
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy70,yymsp[0].minor.yy70,yymsp[-2].minor.yy70);}
144076147578
break;
144077147579
case 37: /* ccons ::= UNIQUE onconf */
144078
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy502,0,0,0,0,
147580
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy70,0,0,0,0,
144079147581
SQLITE_IDXTYPE_UNIQUE);}
144080147582
break;
144081147583
case 38: /* ccons ::= CHECK LP expr RP */
144082
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy182);}
147584
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy18);}
144083147585
break;
144084147586
case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
144085
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy232,yymsp[0].minor.yy502);}
147587
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy420,yymsp[0].minor.yy70);}
144086147588
break;
144087147589
case 40: /* ccons ::= defer_subclause */
144088
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy502);}
147590
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy70);}
144089147591
break;
144090147592
case 41: /* ccons ::= COLLATE ID|STRING */
144091147593
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
144092147594
break;
144093147595
case 44: /* refargs ::= */
144094
-{ yymsp[1].minor.yy502 = OE_None*0x0101; /* EV: R-19803-45884 */}
147596
+{ yymsp[1].minor.yy70 = OE_None*0x0101; /* EV: R-19803-45884 */}
144095147597
break;
144096147598
case 45: /* refargs ::= refargs refarg */
144097
-{ yymsp[-1].minor.yy502 = (yymsp[-1].minor.yy502 & ~yymsp[0].minor.yy107.mask) | yymsp[0].minor.yy107.value; }
147599
+{ yymsp[-1].minor.yy70 = (yymsp[-1].minor.yy70 & ~yymsp[0].minor.yy111.mask) | yymsp[0].minor.yy111.value; }
144098147600
break;
144099147601
case 46: /* refarg ::= MATCH nm */
144100
-{ yymsp[-1].minor.yy107.value = 0; yymsp[-1].minor.yy107.mask = 0x000000; }
147602
+{ yymsp[-1].minor.yy111.value = 0; yymsp[-1].minor.yy111.mask = 0x000000; }
144101147603
break;
144102147604
case 47: /* refarg ::= ON INSERT refact */
144103
-{ yymsp[-2].minor.yy107.value = 0; yymsp[-2].minor.yy107.mask = 0x000000; }
147605
+{ yymsp[-2].minor.yy111.value = 0; yymsp[-2].minor.yy111.mask = 0x000000; }
144104147606
break;
144105147607
case 48: /* refarg ::= ON DELETE refact */
144106
-{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502; yymsp[-2].minor.yy107.mask = 0x0000ff; }
147608
+{ yymsp[-2].minor.yy111.value = yymsp[0].minor.yy70; yymsp[-2].minor.yy111.mask = 0x0000ff; }
144107147609
break;
144108147610
case 49: /* refarg ::= ON UPDATE refact */
144109
-{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502<<8; yymsp[-2].minor.yy107.mask = 0x00ff00; }
147611
+{ yymsp[-2].minor.yy111.value = yymsp[0].minor.yy70<<8; yymsp[-2].minor.yy111.mask = 0x00ff00; }
144110147612
break;
144111147613
case 50: /* refact ::= SET NULL */
144112
-{ yymsp[-1].minor.yy502 = OE_SetNull; /* EV: R-33326-45252 */}
147614
+{ yymsp[-1].minor.yy70 = OE_SetNull; /* EV: R-33326-45252 */}
144113147615
break;
144114147616
case 51: /* refact ::= SET DEFAULT */
144115
-{ yymsp[-1].minor.yy502 = OE_SetDflt; /* EV: R-33326-45252 */}
147617
+{ yymsp[-1].minor.yy70 = OE_SetDflt; /* EV: R-33326-45252 */}
144116147618
break;
144117147619
case 52: /* refact ::= CASCADE */
144118
-{ yymsp[0].minor.yy502 = OE_Cascade; /* EV: R-33326-45252 */}
147620
+{ yymsp[0].minor.yy70 = OE_Cascade; /* EV: R-33326-45252 */}
144119147621
break;
144120147622
case 53: /* refact ::= RESTRICT */
144121
-{ yymsp[0].minor.yy502 = OE_Restrict; /* EV: R-33326-45252 */}
147623
+{ yymsp[0].minor.yy70 = OE_Restrict; /* EV: R-33326-45252 */}
144122147624
break;
144123147625
case 54: /* refact ::= NO ACTION */
144124
-{ yymsp[-1].minor.yy502 = OE_None; /* EV: R-33326-45252 */}
147626
+{ yymsp[-1].minor.yy70 = OE_None; /* EV: R-33326-45252 */}
144125147627
break;
144126147628
case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
144127
-{yymsp[-2].minor.yy502 = 0;}
147629
+{yymsp[-2].minor.yy70 = 0;}
144128147630
break;
144129147631
case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
144130147632
case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
144131147633
case 155: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==155);
144132
-{yymsp[-1].minor.yy502 = yymsp[0].minor.yy502;}
147634
+{yymsp[-1].minor.yy70 = yymsp[0].minor.yy70;}
144133147635
break;
144134147636
case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
144135147637
case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
144136
- case 196: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==196);
144137
- case 199: /* in_op ::= NOT IN */ yytestcase(yyruleno==199);
144138
- case 225: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==225);
144139
-{yymsp[-1].minor.yy502 = 1;}
147638
+ case 195: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==195);
147639
+ case 198: /* in_op ::= NOT IN */ yytestcase(yyruleno==198);
147640
+ case 224: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==224);
147641
+{yymsp[-1].minor.yy70 = 1;}
144140147642
break;
144141147643
case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
144142
-{yymsp[-1].minor.yy502 = 0;}
147644
+{yymsp[-1].minor.yy70 = 0;}
144143147645
break;
144144147646
case 61: /* tconscomma ::= COMMA */
144145147647
{pParse->constraintName.n = 0;}
144146147648
break;
144147147649
case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
144148
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy232,yymsp[0].minor.yy502,yymsp[-2].minor.yy502,0);}
147650
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy420,yymsp[0].minor.yy70,yymsp[-2].minor.yy70,0);}
144149147651
break;
144150147652
case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
144151
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy232,yymsp[0].minor.yy502,0,0,0,0,
147653
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy420,yymsp[0].minor.yy70,0,0,0,0,
144152147654
SQLITE_IDXTYPE_UNIQUE);}
144153147655
break;
144154147656
case 65: /* tcons ::= CHECK LP expr RP onconf */
144155
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy182);}
147657
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy18);}
144156147658
break;
144157147659
case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
144158147660
{
144159
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy232, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy502);
144160
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy502);
147661
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy420, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy420, yymsp[-1].minor.yy70);
147662
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy70);
144161147663
}
144162147664
break;
144163147665
case 68: /* onconf ::= */
144164147666
case 70: /* orconf ::= */ yytestcase(yyruleno==70);
144165
-{yymsp[1].minor.yy502 = OE_Default;}
147667
+{yymsp[1].minor.yy70 = OE_Default;}
144166147668
break;
144167147669
case 69: /* onconf ::= ON CONFLICT resolvetype */
144168
-{yymsp[-2].minor.yy502 = yymsp[0].minor.yy502;}
147670
+{yymsp[-2].minor.yy70 = yymsp[0].minor.yy70;}
144169147671
break;
144170147672
case 72: /* resolvetype ::= IGNORE */
144171
-{yymsp[0].minor.yy502 = OE_Ignore;}
147673
+{yymsp[0].minor.yy70 = OE_Ignore;}
144172147674
break;
144173147675
case 73: /* resolvetype ::= REPLACE */
144174147676
case 156: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==156);
144175
-{yymsp[0].minor.yy502 = OE_Replace;}
147677
+{yymsp[0].minor.yy70 = OE_Replace;}
144176147678
break;
144177147679
case 74: /* cmd ::= DROP TABLE ifexists fullname */
144178147680
{
144179
- sqlite3DropTable(pParse, yymsp[0].minor.yy427, 0, yymsp[-1].minor.yy502);
147681
+ sqlite3DropTable(pParse, yymsp[0].minor.yy135, 0, yymsp[-1].minor.yy70);
144180147682
}
144181147683
break;
144182147684
case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
144183147685
{
144184
- sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[0].minor.yy399, yymsp[-7].minor.yy502, yymsp[-5].minor.yy502);
147686
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy420, yymsp[0].minor.yy489, yymsp[-7].minor.yy70, yymsp[-5].minor.yy70);
144185147687
}
144186147688
break;
144187147689
case 78: /* cmd ::= DROP VIEW ifexists fullname */
144188147690
{
144189
- sqlite3DropTable(pParse, yymsp[0].minor.yy427, 1, yymsp[-1].minor.yy502);
147691
+ sqlite3DropTable(pParse, yymsp[0].minor.yy135, 1, yymsp[-1].minor.yy70);
144190147692
}
144191147693
break;
144192147694
case 79: /* cmd ::= select */
144193147695
{
144194147696
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
144195
- sqlite3Select(pParse, yymsp[0].minor.yy399, &dest);
144196
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
147697
+ sqlite3Select(pParse, yymsp[0].minor.yy489, &dest);
147698
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy489);
144197147699
}
144198147700
break;
144199147701
case 80: /* select ::= WITH wqlist selectnowith */
144200147702
{
144201
- Select *p = yymsp[0].minor.yy399;
147703
+ Select *p = yymsp[0].minor.yy489;
144202147704
if( p ){
144203
- p->pWith = yymsp[-1].minor.yy91;
147705
+ p->pWith = yymsp[-1].minor.yy449;
144204147706
parserDoubleLinkSelect(pParse, p);
144205147707
}else{
144206
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
147708
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy449);
144207147709
}
144208
- yymsp[-2].minor.yy399 = p;
147710
+ yymsp[-2].minor.yy489 = p;
144209147711
}
144210147712
break;
144211147713
case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */
144212147714
{
144213
- Select *p = yymsp[0].minor.yy399;
147715
+ Select *p = yymsp[0].minor.yy489;
144214147716
if( p ){
144215
- p->pWith = yymsp[-1].minor.yy91;
147717
+ p->pWith = yymsp[-1].minor.yy449;
144216147718
parserDoubleLinkSelect(pParse, p);
144217147719
}else{
144218
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
147720
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy449);
144219147721
}
144220
- yymsp[-3].minor.yy399 = p;
147722
+ yymsp[-3].minor.yy489 = p;
144221147723
}
144222147724
break;
144223147725
case 82: /* select ::= selectnowith */
144224147726
{
144225
- Select *p = yymsp[0].minor.yy399;
147727
+ Select *p = yymsp[0].minor.yy489;
144226147728
if( p ){
144227147729
parserDoubleLinkSelect(pParse, p);
144228147730
}
144229
- yymsp[0].minor.yy399 = p; /*A-overwrites-X*/
147731
+ yymsp[0].minor.yy489 = p; /*A-overwrites-X*/
144230147732
}
144231147733
break;
144232147734
case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */
144233147735
{
144234
- Select *pRhs = yymsp[0].minor.yy399;
144235
- Select *pLhs = yymsp[-2].minor.yy399;
147736
+ Select *pRhs = yymsp[0].minor.yy489;
147737
+ Select *pLhs = yymsp[-2].minor.yy489;
144236147738
if( pRhs && pRhs->pPrior ){
144237147739
SrcList *pFrom;
144238147740
Token x;
144239147741
x.n = 0;
144240147742
parserDoubleLinkSelect(pParse, pRhs);
144241147743
pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
144242147744
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
144243147745
}
144244147746
if( pRhs ){
144245
- pRhs->op = (u8)yymsp[-1].minor.yy502;
147747
+ pRhs->op = (u8)yymsp[-1].minor.yy70;
144246147748
pRhs->pPrior = pLhs;
144247147749
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
144248147750
pRhs->selFlags &= ~SF_MultiValue;
144249
- if( yymsp[-1].minor.yy502!=TK_ALL ) pParse->hasCompound = 1;
147751
+ if( yymsp[-1].minor.yy70!=TK_ALL ) pParse->hasCompound = 1;
144250147752
}else{
144251147753
sqlite3SelectDelete(pParse->db, pLhs);
144252147754
}
144253
- yymsp[-2].minor.yy399 = pRhs;
147755
+ yymsp[-2].minor.yy489 = pRhs;
144254147756
}
144255147757
break;
144256147758
case 84: /* multiselect_op ::= UNION */
144257147759
case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
144258
-{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-OP*/}
147760
+{yymsp[0].minor.yy70 = yymsp[0].major; /*A-overwrites-OP*/}
144259147761
break;
144260147762
case 85: /* multiselect_op ::= UNION ALL */
144261
-{yymsp[-1].minor.yy502 = TK_ALL;}
147763
+{yymsp[-1].minor.yy70 = TK_ALL;}
144262147764
break;
144263
- case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
144264
-{
144265
-#if SELECTTRACE_ENABLED
144266
- Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
144267
-#endif
144268
- yymsp[-8].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy232,yymsp[-5].minor.yy427,yymsp[-4].minor.yy182,yymsp[-3].minor.yy232,yymsp[-2].minor.yy182,yymsp[-1].minor.yy232,yymsp[-7].minor.yy502,yymsp[0].minor.yy182);
144269
-#if SELECTTRACE_ENABLED
144270
- /* Populate the Select.zSelName[] string that is used to help with
144271
- ** query planner debugging, to differentiate between multiple Select
144272
- ** objects in a complex query.
144273
- **
144274
- ** If the SELECT keyword is immediately followed by a C-style comment
144275
- ** then extract the first few alphanumeric characters from within that
144276
- ** comment to be the zSelName value. Otherwise, the label is #N where
144277
- ** is an integer that is incremented with each SELECT statement seen.
144278
- */
144279
- if( yymsp[-8].minor.yy399!=0 ){
144280
- const char *z = s.z+6;
144281
- int i;
144282
- sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->zSelName,"#%d",++pParse->nSelect);
144283
- while( z[0]==' ' ) z++;
144284
- if( z[0]=='/' && z[1]=='*' ){
144285
- z += 2;
144286
- while( z[0]==' ' ) z++;
144287
- for(i=0; sqlite3Isalnum(z[i]); i++){}
144288
- sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->zSelName, "%.*s", i, z);
144289
- }
144290
- }
144291
-#endif /* SELECTRACE_ENABLED */
147765
+ case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt windowdefn_opt orderby_opt limit_opt */
147766
+{
147767
+ yymsp[-9].minor.yy489 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy420,yymsp[-6].minor.yy135,yymsp[-5].minor.yy18,yymsp[-4].minor.yy420,yymsp[-3].minor.yy18,yymsp[-1].minor.yy420,yymsp[-8].minor.yy70,yymsp[0].minor.yy18);
147768
+#ifndef SQLITE_OMIT_WINDOWFUNC
147769
+ if( yymsp[-9].minor.yy489 ){
147770
+ yymsp[-9].minor.yy489->pWinDefn = yymsp[-2].minor.yy327;
147771
+ }else{
147772
+ sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy327);
147773
+ }
147774
+#endif /* SQLITE_OMIT_WINDOWFUNC */
144292147775
}
144293147776
break;
144294147777
case 88: /* values ::= VALUES LP nexprlist RP */
144295147778
{
144296
- yymsp[-3].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values,0);
147779
+ yymsp[-3].minor.yy489 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy420,0,0,0,0,0,SF_Values,0);
144297147780
}
144298147781
break;
144299147782
case 89: /* values ::= values COMMA LP exprlist RP */
144300147783
{
144301
- Select *pRight, *pLeft = yymsp[-4].minor.yy399;
144302
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values|SF_MultiValue,0);
147784
+ Select *pRight, *pLeft = yymsp[-4].minor.yy489;
147785
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy420,0,0,0,0,0,SF_Values|SF_MultiValue,0);
144303147786
if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
144304147787
if( pRight ){
144305147788
pRight->op = TK_ALL;
144306147789
pRight->pPrior = pLeft;
144307
- yymsp[-4].minor.yy399 = pRight;
147790
+ yymsp[-4].minor.yy489 = pRight;
144308147791
}else{
144309
- yymsp[-4].minor.yy399 = pLeft;
147792
+ yymsp[-4].minor.yy489 = pLeft;
144310147793
}
144311147794
}
144312147795
break;
144313147796
case 90: /* distinct ::= DISTINCT */
144314
-{yymsp[0].minor.yy502 = SF_Distinct;}
147797
+{yymsp[0].minor.yy70 = SF_Distinct;}
144315147798
break;
144316147799
case 91: /* distinct ::= ALL */
144317
-{yymsp[0].minor.yy502 = SF_All;}
147800
+{yymsp[0].minor.yy70 = SF_All;}
144318147801
break;
144319147802
case 93: /* sclp ::= */
144320147803
case 126: /* orderby_opt ::= */ yytestcase(yyruleno==126);
144321147804
case 133: /* groupby_opt ::= */ yytestcase(yyruleno==133);
144322
- case 212: /* exprlist ::= */ yytestcase(yyruleno==212);
144323
- case 215: /* paren_exprlist ::= */ yytestcase(yyruleno==215);
144324
- case 220: /* eidlist_opt ::= */ yytestcase(yyruleno==220);
144325
-{yymsp[1].minor.yy232 = 0;}
147805
+ case 211: /* exprlist ::= */ yytestcase(yyruleno==211);
147806
+ case 214: /* paren_exprlist ::= */ yytestcase(yyruleno==214);
147807
+ case 219: /* eidlist_opt ::= */ yytestcase(yyruleno==219);
147808
+{yymsp[1].minor.yy420 = 0;}
144326147809
break;
144327147810
case 94: /* selcollist ::= sclp scanpt expr scanpt as */
144328147811
{
144329
- yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
144330
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[0].minor.yy0, 1);
144331
- sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy232,yymsp[-3].minor.yy36,yymsp[-1].minor.yy36);
147812
+ yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy420, yymsp[-2].minor.yy18);
147813
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy420, &yymsp[0].minor.yy0, 1);
147814
+ sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy420,yymsp[-3].minor.yy392,yymsp[-1].minor.yy392);
144332147815
}
144333147816
break;
144334147817
case 95: /* selcollist ::= sclp scanpt STAR */
144335147818
{
144336147819
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
144337
- yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy232, p);
147820
+ yymsp[-2].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy420, p);
144338147821
}
144339147822
break;
144340147823
case 96: /* selcollist ::= sclp scanpt nm DOT STAR */
144341147824
{
144342147825
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
144343147826
Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
144344147827
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
144345
- yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, pDot);
147828
+ yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, pDot);
144346147829
}
144347147830
break;
144348147831
case 97: /* as ::= AS nm */
144349147832
case 108: /* dbnm ::= DOT nm */ yytestcase(yyruleno==108);
144350
- case 234: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==234);
144351
- case 235: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==235);
147833
+ case 233: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==233);
147834
+ case 234: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==234);
144352147835
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
144353147836
break;
144354147837
case 99: /* from ::= */
144355
-{yymsp[1].minor.yy427 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy427));}
147838
+{yymsp[1].minor.yy135 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy135));}
144356147839
break;
144357147840
case 100: /* from ::= FROM seltablist */
144358147841
{
144359
- yymsp[-1].minor.yy427 = yymsp[0].minor.yy427;
144360
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy427);
147842
+ yymsp[-1].minor.yy135 = yymsp[0].minor.yy135;
147843
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy135);
144361147844
}
144362147845
break;
144363147846
case 101: /* stl_prefix ::= seltablist joinop */
144364147847
{
144365
- if( ALWAYS(yymsp[-1].minor.yy427 && yymsp[-1].minor.yy427->nSrc>0) ) yymsp[-1].minor.yy427->a[yymsp[-1].minor.yy427->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy502;
147848
+ if( ALWAYS(yymsp[-1].minor.yy135 && yymsp[-1].minor.yy135->nSrc>0) ) yymsp[-1].minor.yy135->a[yymsp[-1].minor.yy135->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy70;
144366147849
}
144367147850
break;
144368147851
case 102: /* stl_prefix ::= */
144369
-{yymsp[1].minor.yy427 = 0;}
147852
+{yymsp[1].minor.yy135 = 0;}
144370147853
break;
144371147854
case 103: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
144372147855
{
144373
- yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
144374
- sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy427, &yymsp[-2].minor.yy0);
147856
+ yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
147857
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy135, &yymsp[-2].minor.yy0);
144375147858
}
144376147859
break;
144377147860
case 104: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
144378147861
{
144379
- yymsp[-8].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy427,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
144380
- sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy427, yymsp[-4].minor.yy232);
147862
+ yymsp[-8].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy135,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
147863
+ sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy135, yymsp[-4].minor.yy420);
144381147864
}
144382147865
break;
144383147866
case 105: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
144384147867
{
144385
- yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy399,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
147868
+ yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy489,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
144386147869
}
144387147870
break;
144388147871
case 106: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
144389147872
{
144390
- if( yymsp[-6].minor.yy427==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy182==0 && yymsp[0].minor.yy510==0 ){
144391
- yymsp[-6].minor.yy427 = yymsp[-4].minor.yy427;
144392
- }else if( yymsp[-4].minor.yy427->nSrc==1 ){
144393
- yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
144394
- if( yymsp[-6].minor.yy427 ){
144395
- struct SrcList_item *pNew = &yymsp[-6].minor.yy427->a[yymsp[-6].minor.yy427->nSrc-1];
144396
- struct SrcList_item *pOld = yymsp[-4].minor.yy427->a;
147873
+ if( yymsp[-6].minor.yy135==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy18==0 && yymsp[0].minor.yy48==0 ){
147874
+ yymsp[-6].minor.yy135 = yymsp[-4].minor.yy135;
147875
+ }else if( yymsp[-4].minor.yy135->nSrc==1 ){
147876
+ yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
147877
+ if( yymsp[-6].minor.yy135 ){
147878
+ struct SrcList_item *pNew = &yymsp[-6].minor.yy135->a[yymsp[-6].minor.yy135->nSrc-1];
147879
+ struct SrcList_item *pOld = yymsp[-4].minor.yy135->a;
144397147880
pNew->zName = pOld->zName;
144398147881
pNew->zDatabase = pOld->zDatabase;
144399147882
pNew->pSelect = pOld->pSelect;
144400147883
pOld->zName = pOld->zDatabase = 0;
144401147884
pOld->pSelect = 0;
144402147885
}
144403
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy427);
147886
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy135);
144404147887
}else{
144405147888
Select *pSubquery;
144406
- sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy427);
144407
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy427,0,0,0,0,SF_NestedFrom,0);
144408
- yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
147889
+ sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy135);
147890
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy135,0,0,0,0,SF_NestedFrom,0);
147891
+ yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
144409147892
}
144410147893
}
144411147894
break;
144412147895
case 107: /* dbnm ::= */
144413147896
case 121: /* indexed_opt ::= */ yytestcase(yyruleno==121);
144414147897
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
144415147898
break;
144416147899
case 109: /* fullname ::= nm */
144417147900
case 111: /* xfullname ::= nm */ yytestcase(yyruleno==111);
144418
-{yymsp[0].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
147901
+{yymsp[0].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
144419147902
break;
144420147903
case 110: /* fullname ::= nm DOT nm */
144421147904
case 112: /* xfullname ::= nm DOT nm */ yytestcase(yyruleno==112);
144422
-{yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
147905
+{yymsp[-2].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
144423147906
break;
144424147907
case 113: /* xfullname ::= nm DOT nm AS nm */
144425147908
{
144426
- yymsp[-4].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
144427
- if( yymsp[-4].minor.yy427 ) yymsp[-4].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
147909
+ yymsp[-4].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
147910
+ if( yymsp[-4].minor.yy135 ) yymsp[-4].minor.yy135->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
144428147911
}
144429147912
break;
144430147913
case 114: /* xfullname ::= nm AS nm */
144431147914
{
144432
- yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
144433
- if( yymsp[-2].minor.yy427 ) yymsp[-2].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
147915
+ yymsp[-2].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
147916
+ if( yymsp[-2].minor.yy135 ) yymsp[-2].minor.yy135->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
144434147917
}
144435147918
break;
144436147919
case 115: /* joinop ::= COMMA|JOIN */
144437
-{ yymsp[0].minor.yy502 = JT_INNER; }
147920
+{ yymsp[0].minor.yy70 = JT_INNER; }
144438147921
break;
144439147922
case 116: /* joinop ::= JOIN_KW JOIN */
144440
-{yymsp[-1].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
147923
+{yymsp[-1].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
144441147924
break;
144442147925
case 117: /* joinop ::= JOIN_KW nm JOIN */
144443
-{yymsp[-2].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
147926
+{yymsp[-2].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
144444147927
break;
144445147928
case 118: /* joinop ::= JOIN_KW nm nm JOIN */
144446
-{yymsp[-3].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
147929
+{yymsp[-3].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
144447147930
break;
144448147931
case 119: /* on_opt ::= ON expr */
144449147932
case 136: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==136);
144450147933
case 143: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==143);
144451
- case 208: /* case_else ::= ELSE expr */ yytestcase(yyruleno==208);
144452
-{yymsp[-1].minor.yy182 = yymsp[0].minor.yy182;}
147934
+ case 207: /* case_else ::= ELSE expr */ yytestcase(yyruleno==207);
147935
+{yymsp[-1].minor.yy18 = yymsp[0].minor.yy18;}
144453147936
break;
144454147937
case 120: /* on_opt ::= */
144455147938
case 135: /* having_opt ::= */ yytestcase(yyruleno==135);
144456147939
case 137: /* limit_opt ::= */ yytestcase(yyruleno==137);
144457147940
case 142: /* where_opt ::= */ yytestcase(yyruleno==142);
144458
- case 209: /* case_else ::= */ yytestcase(yyruleno==209);
144459
- case 211: /* case_operand ::= */ yytestcase(yyruleno==211);
144460
-{yymsp[1].minor.yy182 = 0;}
147941
+ case 208: /* case_else ::= */ yytestcase(yyruleno==208);
147942
+ case 210: /* case_operand ::= */ yytestcase(yyruleno==210);
147943
+{yymsp[1].minor.yy18 = 0;}
144461147944
break;
144462147945
case 122: /* indexed_opt ::= INDEXED BY nm */
144463147946
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
144464147947
break;
144465147948
case 123: /* indexed_opt ::= NOT INDEXED */
144466147949
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
144467147950
break;
144468147951
case 124: /* using_opt ::= USING LP idlist RP */
144469
-{yymsp[-3].minor.yy510 = yymsp[-1].minor.yy510;}
147952
+{yymsp[-3].minor.yy48 = yymsp[-1].minor.yy48;}
144470147953
break;
144471147954
case 125: /* using_opt ::= */
144472147955
case 157: /* idlist_opt ::= */ yytestcase(yyruleno==157);
144473
-{yymsp[1].minor.yy510 = 0;}
147956
+{yymsp[1].minor.yy48 = 0;}
144474147957
break;
144475147958
case 127: /* orderby_opt ::= ORDER BY sortlist */
144476147959
case 134: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==134);
144477
-{yymsp[-2].minor.yy232 = yymsp[0].minor.yy232;}
147960
+{yymsp[-2].minor.yy420 = yymsp[0].minor.yy420;}
144478147961
break;
144479147962
case 128: /* sortlist ::= sortlist COMMA expr sortorder */
144480147963
{
144481
- yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232,yymsp[-1].minor.yy182);
144482
- sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy232,yymsp[0].minor.yy502);
147964
+ yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy420,yymsp[-1].minor.yy18);
147965
+ sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy420,yymsp[0].minor.yy70);
144483147966
}
144484147967
break;
144485147968
case 129: /* sortlist ::= expr sortorder */
144486147969
{
144487
- yymsp[-1].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy182); /*A-overwrites-Y*/
144488
- sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy232,yymsp[0].minor.yy502);
147970
+ yymsp[-1].minor.yy420 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy18); /*A-overwrites-Y*/
147971
+ sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy420,yymsp[0].minor.yy70);
144489147972
}
144490147973
break;
144491147974
case 130: /* sortorder ::= ASC */
144492
-{yymsp[0].minor.yy502 = SQLITE_SO_ASC;}
147975
+{yymsp[0].minor.yy70 = SQLITE_SO_ASC;}
144493147976
break;
144494147977
case 131: /* sortorder ::= DESC */
144495
-{yymsp[0].minor.yy502 = SQLITE_SO_DESC;}
147978
+{yymsp[0].minor.yy70 = SQLITE_SO_DESC;}
144496147979
break;
144497147980
case 132: /* sortorder ::= */
144498
-{yymsp[1].minor.yy502 = SQLITE_SO_UNDEFINED;}
147981
+{yymsp[1].minor.yy70 = SQLITE_SO_UNDEFINED;}
144499147982
break;
144500147983
case 138: /* limit_opt ::= LIMIT expr */
144501
-{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,0);}
147984
+{yymsp[-1].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy18,0);}
144502147985
break;
144503147986
case 139: /* limit_opt ::= LIMIT expr OFFSET expr */
144504
-{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
147987
+{yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);}
144505147988
break;
144506147989
case 140: /* limit_opt ::= LIMIT expr COMMA expr */
144507
-{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,yymsp[-2].minor.yy182);}
147990
+{yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy18,yymsp[-2].minor.yy18);}
144508147991
break;
144509147992
case 141: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
144510147993
{
144511
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy427, &yymsp[-1].minor.yy0);
144512
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy427,yymsp[0].minor.yy182,0,0);
147994
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy135, &yymsp[-1].minor.yy0);
147995
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy135,yymsp[0].minor.yy18,0,0);
144513147996
}
144514147997
break;
144515147998
case 144: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
144516147999
{
144517
- sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy427, &yymsp[-3].minor.yy0);
144518
- sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy232,"set list");
144519
- sqlite3Update(pParse,yymsp[-4].minor.yy427,yymsp[-1].minor.yy232,yymsp[0].minor.yy182,yymsp[-5].minor.yy502,0,0,0);
148000
+ sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy135, &yymsp[-3].minor.yy0);
148001
+ sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy420,"set list");
148002
+ sqlite3Update(pParse,yymsp[-4].minor.yy135,yymsp[-1].minor.yy420,yymsp[0].minor.yy18,yymsp[-5].minor.yy70,0,0,0);
144520148003
}
144521148004
break;
144522148005
case 145: /* setlist ::= setlist COMMA nm EQ expr */
144523148006
{
144524
- yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
144525
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, 1);
148007
+ yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy420, yymsp[0].minor.yy18);
148008
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy420, &yymsp[-2].minor.yy0, 1);
144526148009
}
144527148010
break;
144528148011
case 146: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
144529148012
{
144530
- yymsp[-6].minor.yy232 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy232, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
148013
+ yymsp[-6].minor.yy420 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy420, yymsp[-3].minor.yy48, yymsp[0].minor.yy18);
144531148014
}
144532148015
break;
144533148016
case 147: /* setlist ::= nm EQ expr */
144534148017
{
144535
- yylhsminor.yy232 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy182);
144536
- sqlite3ExprListSetName(pParse, yylhsminor.yy232, &yymsp[-2].minor.yy0, 1);
148018
+ yylhsminor.yy420 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy18);
148019
+ sqlite3ExprListSetName(pParse, yylhsminor.yy420, &yymsp[-2].minor.yy0, 1);
144537148020
}
144538
- yymsp[-2].minor.yy232 = yylhsminor.yy232;
148021
+ yymsp[-2].minor.yy420 = yylhsminor.yy420;
144539148022
break;
144540148023
case 148: /* setlist ::= LP idlist RP EQ expr */
144541148024
{
144542
- yymsp[-4].minor.yy232 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
148025
+ yymsp[-4].minor.yy420 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy48, yymsp[0].minor.yy18);
144543148026
}
144544148027
break;
144545148028
case 149: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
144546148029
{
144547
- sqlite3Insert(pParse, yymsp[-3].minor.yy427, yymsp[-1].minor.yy399, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, yymsp[0].minor.yy198);
148030
+ sqlite3Insert(pParse, yymsp[-3].minor.yy135, yymsp[-1].minor.yy489, yymsp[-2].minor.yy48, yymsp[-5].minor.yy70, yymsp[0].minor.yy340);
144548148031
}
144549148032
break;
144550148033
case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
144551148034
{
144552
- sqlite3Insert(pParse, yymsp[-3].minor.yy427, 0, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, 0);
148035
+ sqlite3Insert(pParse, yymsp[-3].minor.yy135, 0, yymsp[-2].minor.yy48, yymsp[-5].minor.yy70, 0);
144553148036
}
144554148037
break;
144555148038
case 151: /* upsert ::= */
144556
-{ yymsp[1].minor.yy198 = 0; }
148039
+{ yymsp[1].minor.yy340 = 0; }
144557148040
break;
144558148041
case 152: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
144559
-{ yymsp[-10].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy232,yymsp[-5].minor.yy182,yymsp[-1].minor.yy232,yymsp[0].minor.yy182);}
148042
+{ yymsp[-10].minor.yy340 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy420,yymsp[-5].minor.yy18,yymsp[-1].minor.yy420,yymsp[0].minor.yy18);}
144560148043
break;
144561148044
case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
144562
-{ yymsp[-7].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy232,yymsp[-2].minor.yy182,0,0); }
148045
+{ yymsp[-7].minor.yy340 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy420,yymsp[-2].minor.yy18,0,0); }
144563148046
break;
144564148047
case 154: /* upsert ::= ON CONFLICT DO NOTHING */
144565
-{ yymsp[-3].minor.yy198 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
148048
+{ yymsp[-3].minor.yy340 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
144566148049
break;
144567148050
case 158: /* idlist_opt ::= LP idlist RP */
144568
-{yymsp[-2].minor.yy510 = yymsp[-1].minor.yy510;}
148051
+{yymsp[-2].minor.yy48 = yymsp[-1].minor.yy48;}
144569148052
break;
144570148053
case 159: /* idlist ::= idlist COMMA nm */
144571
-{yymsp[-2].minor.yy510 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy510,&yymsp[0].minor.yy0);}
148054
+{yymsp[-2].minor.yy48 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy48,&yymsp[0].minor.yy0);}
144572148055
break;
144573148056
case 160: /* idlist ::= nm */
144574
-{yymsp[0].minor.yy510 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
148057
+{yymsp[0].minor.yy48 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
144575148058
break;
144576148059
case 161: /* expr ::= LP expr RP */
144577
-{yymsp[-2].minor.yy182 = yymsp[-1].minor.yy182;}
148060
+{yymsp[-2].minor.yy18 = yymsp[-1].minor.yy18;}
144578148061
break;
144579148062
case 162: /* expr ::= ID|INDEXED */
144580148063
case 163: /* expr ::= JOIN_KW */ yytestcase(yyruleno==163);
144581
-{yymsp[0].minor.yy182=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
148064
+{yymsp[0].minor.yy18=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
144582148065
break;
144583148066
case 164: /* expr ::= nm DOT nm */
144584148067
{
144585148068
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
144586148069
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
144587
- yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
148070
+ yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
144588148071
}
144589
- yymsp[-2].minor.yy182 = yylhsminor.yy182;
148072
+ yymsp[-2].minor.yy18 = yylhsminor.yy18;
144590148073
break;
144591148074
case 165: /* expr ::= nm DOT nm DOT nm */
144592148075
{
144593148076
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
144594148077
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
144595148078
Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
144596148079
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
144597
- yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
148080
+ yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
144598148081
}
144599
- yymsp[-4].minor.yy182 = yylhsminor.yy182;
148082
+ yymsp[-4].minor.yy18 = yylhsminor.yy18;
144600148083
break;
144601148084
case 166: /* term ::= NULL|FLOAT|BLOB */
144602148085
case 167: /* term ::= STRING */ yytestcase(yyruleno==167);
144603
-{yymsp[0].minor.yy182=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
148086
+{yymsp[0].minor.yy18=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
144604148087
break;
144605148088
case 168: /* term ::= INTEGER */
144606148089
{
144607
- yylhsminor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
148090
+ yylhsminor.yy18 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
144608148091
}
144609
- yymsp[0].minor.yy182 = yylhsminor.yy182;
148092
+ yymsp[0].minor.yy18 = yylhsminor.yy18;
144610148093
break;
144611148094
case 169: /* expr ::= VARIABLE */
144612148095
{
144613148096
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
144614148097
u32 n = yymsp[0].minor.yy0.n;
144615
- yymsp[0].minor.yy182 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
144616
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy182, n);
148098
+ yymsp[0].minor.yy18 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
148099
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy18, n);
144617148100
}else{
144618148101
/* When doing a nested parse, one can include terms in an expression
144619148102
** that look like this: #1 #2 ... These terms refer to registers
144620148103
** in the virtual machine. #N is the N-th register. */
144621148104
Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
144622148105
assert( t.n>=2 );
144623148106
if( pParse->nested==0 ){
144624148107
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
144625
- yymsp[0].minor.yy182 = 0;
148108
+ yymsp[0].minor.yy18 = 0;
144626148109
}else{
144627
- yymsp[0].minor.yy182 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
144628
- if( yymsp[0].minor.yy182 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy182->iTable);
148110
+ yymsp[0].minor.yy18 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
148111
+ if( yymsp[0].minor.yy18 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy18->iTable);
144629148112
}
144630148113
}
144631148114
}
144632148115
break;
144633148116
case 170: /* expr ::= expr COLLATE ID|STRING */
144634148117
{
144635
- yymsp[-2].minor.yy182 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy182, &yymsp[0].minor.yy0, 1);
148118
+ yymsp[-2].minor.yy18 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy18, &yymsp[0].minor.yy0, 1);
144636148119
}
144637148120
break;
144638148121
case 171: /* expr ::= CAST LP expr AS typetoken RP */
144639148122
{
144640
- yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
144641
- sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy182, yymsp[-3].minor.yy182, 0);
144642
-}
144643
- break;
144644
- case 172: /* expr ::= ID|INDEXED LP distinct exprlist RP */
144645
-{
144646
- if( yymsp[-1].minor.yy232 && yymsp[-1].minor.yy232->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
144647
- sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
144648
- }
144649
- yylhsminor.yy182 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy232, &yymsp[-4].minor.yy0);
144650
- if( yymsp[-2].minor.yy502==SF_Distinct && yylhsminor.yy182 ){
144651
- yylhsminor.yy182->flags |= EP_Distinct;
144652
- }
144653
-}
144654
- yymsp[-4].minor.yy182 = yylhsminor.yy182;
144655
- break;
144656
- case 173: /* expr ::= ID|INDEXED LP STAR RP */
144657
-{
144658
- yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
144659
-}
144660
- yymsp[-3].minor.yy182 = yylhsminor.yy182;
148123
+ yymsp[-5].minor.yy18 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
148124
+ sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy18, yymsp[-3].minor.yy18, 0);
148125
+}
148126
+ break;
148127
+ case 172: /* expr ::= ID|INDEXED LP distinct exprlist RP over_opt */
148128
+{
148129
+ if( yymsp[-2].minor.yy420 && yymsp[-2].minor.yy420->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
148130
+ sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-5].minor.yy0);
148131
+ }
148132
+ yylhsminor.yy18 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy420, &yymsp[-5].minor.yy0);
148133
+ if( yymsp[-3].minor.yy70==SF_Distinct && yylhsminor.yy18 ){
148134
+ yylhsminor.yy18->flags |= EP_Distinct;
148135
+ }
148136
+ sqlite3WindowAttach(pParse, yylhsminor.yy18, yymsp[0].minor.yy327);
148137
+}
148138
+ yymsp[-5].minor.yy18 = yylhsminor.yy18;
148139
+ break;
148140
+ case 173: /* expr ::= ID|INDEXED LP STAR RP over_opt */
148141
+{
148142
+ yylhsminor.yy18 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0);
148143
+ sqlite3WindowAttach(pParse, yylhsminor.yy18, yymsp[0].minor.yy327);
148144
+}
148145
+ yymsp[-4].minor.yy18 = yylhsminor.yy18;
144661148146
break;
144662148147
case 174: /* term ::= CTIME_KW */
144663148148
{
144664
- yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
148149
+ yylhsminor.yy18 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
144665148150
}
144666
- yymsp[0].minor.yy182 = yylhsminor.yy182;
148151
+ yymsp[0].minor.yy18 = yylhsminor.yy18;
144667148152
break;
144668148153
case 175: /* expr ::= LP nexprlist COMMA expr RP */
144669148154
{
144670
- ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy232, yymsp[-1].minor.yy182);
144671
- yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
144672
- if( yymsp[-4].minor.yy182 ){
144673
- yymsp[-4].minor.yy182->x.pList = pList;
148155
+ ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy420, yymsp[-1].minor.yy18);
148156
+ yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
148157
+ if( yymsp[-4].minor.yy18 ){
148158
+ yymsp[-4].minor.yy18->x.pList = pList;
144674148159
}else{
144675148160
sqlite3ExprListDelete(pParse->db, pList);
144676148161
}
144677148162
}
144678148163
break;
@@ -144682,99 +148167,99 @@
144682148167
case 179: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==179);
144683148168
case 180: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==180);
144684148169
case 181: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==181);
144685148170
case 182: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==182);
144686148171
case 183: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==183);
144687
-{yymsp[-2].minor.yy182=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
148172
+{yymsp[-2].minor.yy18=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);}
144688148173
break;
144689148174
case 184: /* likeop ::= NOT LIKE_KW|MATCH */
144690148175
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
144691148176
break;
144692148177
case 185: /* expr ::= expr likeop expr */
144693148178
{
144694148179
ExprList *pList;
144695148180
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
144696148181
yymsp[-1].minor.yy0.n &= 0x7fffffff;
144697
- pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy182);
144698
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy182);
144699
- yymsp[-2].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
144700
- if( bNot ) yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy182, 0);
144701
- if( yymsp[-2].minor.yy182 ) yymsp[-2].minor.yy182->flags |= EP_InfixFunc;
148182
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy18);
148183
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy18);
148184
+ yymsp[-2].minor.yy18 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
148185
+ if( bNot ) yymsp[-2].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy18, 0);
148186
+ if( yymsp[-2].minor.yy18 ) yymsp[-2].minor.yy18->flags |= EP_InfixFunc;
144702148187
}
144703148188
break;
144704148189
case 186: /* expr ::= expr likeop expr ESCAPE expr */
144705148190
{
144706148191
ExprList *pList;
144707148192
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
144708148193
yymsp[-3].minor.yy0.n &= 0x7fffffff;
144709
- pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
144710
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy182);
144711
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
144712
- yymsp[-4].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
144713
- if( bNot ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
144714
- if( yymsp[-4].minor.yy182 ) yymsp[-4].minor.yy182->flags |= EP_InfixFunc;
148194
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
148195
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy18);
148196
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy18);
148197
+ yymsp[-4].minor.yy18 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
148198
+ if( bNot ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
148199
+ if( yymsp[-4].minor.yy18 ) yymsp[-4].minor.yy18->flags |= EP_InfixFunc;
144715148200
}
144716148201
break;
144717148202
case 187: /* expr ::= expr ISNULL|NOTNULL */
144718
-{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy182,0);}
148203
+{yymsp[-1].minor.yy18 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy18,0);}
144719148204
break;
144720148205
case 188: /* expr ::= expr NOT NULL */
144721
-{yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy182,0);}
148206
+{yymsp[-2].minor.yy18 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy18,0);}
144722148207
break;
144723148208
case 189: /* expr ::= expr IS expr */
144724148209
{
144725
- yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);
144726
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-2].minor.yy182, TK_ISNULL);
148210
+ yymsp[-2].minor.yy18 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);
148211
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy18, yymsp[-2].minor.yy18, TK_ISNULL);
144727148212
}
144728148213
break;
144729148214
case 190: /* expr ::= expr IS NOT expr */
144730148215
{
144731
- yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy182,yymsp[0].minor.yy182);
144732
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-3].minor.yy182, TK_NOTNULL);
148216
+ yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy18,yymsp[0].minor.yy18);
148217
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy18, yymsp[-3].minor.yy18, TK_NOTNULL);
144733148218
}
144734148219
break;
144735148220
case 191: /* expr ::= NOT expr */
144736148221
case 192: /* expr ::= BITNOT expr */ yytestcase(yyruleno==192);
144737
-{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy182, 0);/*A-overwrites-B*/}
144738
- break;
144739
- case 193: /* expr ::= MINUS expr */
144740
-{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy182, 0);}
144741
- break;
144742
- case 194: /* expr ::= PLUS expr */
144743
-{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy182, 0);}
144744
- break;
144745
- case 195: /* between_op ::= BETWEEN */
144746
- case 198: /* in_op ::= IN */ yytestcase(yyruleno==198);
144747
-{yymsp[0].minor.yy502 = 0;}
144748
- break;
144749
- case 197: /* expr ::= expr between_op expr AND expr */
144750
-{
144751
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
144752
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
144753
- yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy182, 0);
144754
- if( yymsp[-4].minor.yy182 ){
144755
- yymsp[-4].minor.yy182->x.pList = pList;
148222
+{yymsp[-1].minor.yy18 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy18, 0);/*A-overwrites-B*/}
148223
+ break;
148224
+ case 193: /* expr ::= PLUS|MINUS expr */
148225
+{
148226
+ yymsp[-1].minor.yy18 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy18, 0);
148227
+ /*A-overwrites-B*/
148228
+}
148229
+ break;
148230
+ case 194: /* between_op ::= BETWEEN */
148231
+ case 197: /* in_op ::= IN */ yytestcase(yyruleno==197);
148232
+{yymsp[0].minor.yy70 = 0;}
148233
+ break;
148234
+ case 196: /* expr ::= expr between_op expr AND expr */
148235
+{
148236
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
148237
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy18);
148238
+ yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy18, 0);
148239
+ if( yymsp[-4].minor.yy18 ){
148240
+ yymsp[-4].minor.yy18->x.pList = pList;
144756148241
}else{
144757148242
sqlite3ExprListDelete(pParse->db, pList);
144758148243
}
144759
- if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
148244
+ if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
144760148245
}
144761148246
break;
144762
- case 200: /* expr ::= expr in_op LP exprlist RP */
148247
+ case 199: /* expr ::= expr in_op LP exprlist RP */
144763148248
{
144764
- if( yymsp[-1].minor.yy232==0 ){
148249
+ if( yymsp[-1].minor.yy420==0 ){
144765148250
/* Expressions of the form
144766148251
**
144767148252
** expr1 IN ()
144768148253
** expr1 NOT IN ()
144769148254
**
144770148255
** simplify to constants 0 (false) and 1 (true), respectively,
144771148256
** regardless of the value of expr1.
144772148257
*/
144773
- sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy182);
144774
- yymsp[-4].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy502],1);
144775
- }else if( yymsp[-1].minor.yy232->nExpr==1 ){
148258
+ sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy18);
148259
+ yymsp[-4].minor.yy18 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy70],1);
148260
+ }else if( yymsp[-1].minor.yy420->nExpr==1 ){
144776148261
/* Expressions of the form:
144777148262
**
144778148263
** expr1 IN (?1)
144779148264
** expr1 NOT IN (?2)
144780148265
**
@@ -144787,396 +148272,506 @@
144787148272
** But, the RHS of the == or <> is marked with the EP_Generic flag
144788148273
** so that it may not contribute to the computation of comparison
144789148274
** affinity or the collating sequence to use for comparison. Otherwise,
144790148275
** the semantics would be subtly different from IN or NOT IN.
144791148276
*/
144792
- Expr *pRHS = yymsp[-1].minor.yy232->a[0].pExpr;
144793
- yymsp[-1].minor.yy232->a[0].pExpr = 0;
144794
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
148277
+ Expr *pRHS = yymsp[-1].minor.yy420->a[0].pExpr;
148278
+ yymsp[-1].minor.yy420->a[0].pExpr = 0;
148279
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy420);
144795148280
/* pRHS cannot be NULL because a malloc error would have been detected
144796148281
** before now and control would have never reached this point */
144797148282
if( ALWAYS(pRHS) ){
144798148283
pRHS->flags &= ~EP_Collate;
144799148284
pRHS->flags |= EP_Generic;
144800148285
}
144801
- yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_NE : TK_EQ, yymsp[-4].minor.yy182, pRHS);
144802
- }else{
144803
- yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
144804
- if( yymsp[-4].minor.yy182 ){
144805
- yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy232;
144806
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
144807
- }else{
144808
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
144809
- }
144810
- if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
144811
- }
144812
- }
144813
- break;
144814
- case 201: /* expr ::= LP select RP */
144815
-{
144816
- yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
144817
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy182, yymsp[-1].minor.yy399);
144818
- }
144819
- break;
144820
- case 202: /* expr ::= expr in_op LP select RP */
144821
-{
144822
- yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
144823
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, yymsp[-1].minor.yy399);
144824
- if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
144825
- }
144826
- break;
144827
- case 203: /* expr ::= expr in_op nm dbnm paren_exprlist */
148286
+ yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, yymsp[-3].minor.yy70 ? TK_NE : TK_EQ, yymsp[-4].minor.yy18, pRHS);
148287
+ }else{
148288
+ yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy18, 0);
148289
+ if( yymsp[-4].minor.yy18 ){
148290
+ yymsp[-4].minor.yy18->x.pList = yymsp[-1].minor.yy420;
148291
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy18);
148292
+ }else{
148293
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy420);
148294
+ }
148295
+ if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
148296
+ }
148297
+ }
148298
+ break;
148299
+ case 200: /* expr ::= LP select RP */
148300
+{
148301
+ yymsp[-2].minor.yy18 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
148302
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy18, yymsp[-1].minor.yy489);
148303
+ }
148304
+ break;
148305
+ case 201: /* expr ::= expr in_op LP select RP */
148306
+{
148307
+ yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy18, 0);
148308
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy18, yymsp[-1].minor.yy489);
148309
+ if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
148310
+ }
148311
+ break;
148312
+ case 202: /* expr ::= expr in_op nm dbnm paren_exprlist */
144828148313
{
144829148314
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
144830148315
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
144831
- if( yymsp[0].minor.yy232 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy232);
144832
- yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
144833
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, pSelect);
144834
- if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
148316
+ if( yymsp[0].minor.yy420 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy420);
148317
+ yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy18, 0);
148318
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy18, pSelect);
148319
+ if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
144835148320
}
144836148321
break;
144837
- case 204: /* expr ::= EXISTS LP select RP */
148322
+ case 203: /* expr ::= EXISTS LP select RP */
144838148323
{
144839148324
Expr *p;
144840
- p = yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
144841
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy399);
144842
- }
144843
- break;
144844
- case 205: /* expr ::= CASE case_operand case_exprlist case_else END */
144845
-{
144846
- yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy182, 0);
144847
- if( yymsp[-4].minor.yy182 ){
144848
- yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy182 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[-1].minor.yy182) : yymsp[-2].minor.yy232;
144849
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
144850
- }else{
144851
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy232);
144852
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy182);
144853
- }
144854
-}
144855
- break;
144856
- case 206: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
144857
-{
144858
- yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
144859
- yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
144860
-}
144861
- break;
144862
- case 207: /* case_exprlist ::= WHEN expr THEN expr */
144863
-{
144864
- yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
144865
- yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232, yymsp[0].minor.yy182);
144866
-}
144867
- break;
144868
- case 210: /* case_operand ::= expr */
144869
-{yymsp[0].minor.yy182 = yymsp[0].minor.yy182; /*A-overwrites-X*/}
144870
- break;
144871
- case 213: /* nexprlist ::= nexprlist COMMA expr */
144872
-{yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[0].minor.yy182);}
144873
- break;
144874
- case 214: /* nexprlist ::= expr */
144875
-{yymsp[0].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy182); /*A-overwrites-Y*/}
144876
- break;
144877
- case 216: /* paren_exprlist ::= LP exprlist RP */
144878
- case 221: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==221);
144879
-{yymsp[-2].minor.yy232 = yymsp[-1].minor.yy232;}
144880
- break;
144881
- case 217: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
148325
+ p = yymsp[-3].minor.yy18 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
148326
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy489);
148327
+ }
148328
+ break;
148329
+ case 204: /* expr ::= CASE case_operand case_exprlist case_else END */
148330
+{
148331
+ yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy18, 0);
148332
+ if( yymsp[-4].minor.yy18 ){
148333
+ yymsp[-4].minor.yy18->x.pList = yymsp[-1].minor.yy18 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy420,yymsp[-1].minor.yy18) : yymsp[-2].minor.yy420;
148334
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy18);
148335
+ }else{
148336
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy420);
148337
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy18);
148338
+ }
148339
+}
148340
+ break;
148341
+ case 205: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
148342
+{
148343
+ yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, yymsp[-2].minor.yy18);
148344
+ yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, yymsp[0].minor.yy18);
148345
+}
148346
+ break;
148347
+ case 206: /* case_exprlist ::= WHEN expr THEN expr */
148348
+{
148349
+ yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
148350
+ yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy420, yymsp[0].minor.yy18);
148351
+}
148352
+ break;
148353
+ case 209: /* case_operand ::= expr */
148354
+{yymsp[0].minor.yy18 = yymsp[0].minor.yy18; /*A-overwrites-X*/}
148355
+ break;
148356
+ case 212: /* nexprlist ::= nexprlist COMMA expr */
148357
+{yymsp[-2].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy420,yymsp[0].minor.yy18);}
148358
+ break;
148359
+ case 213: /* nexprlist ::= expr */
148360
+{yymsp[0].minor.yy420 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy18); /*A-overwrites-Y*/}
148361
+ break;
148362
+ case 215: /* paren_exprlist ::= LP exprlist RP */
148363
+ case 220: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==220);
148364
+{yymsp[-2].minor.yy420 = yymsp[-1].minor.yy420;}
148365
+ break;
148366
+ case 216: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
144882148367
{
144883148368
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
144884
- sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy232, yymsp[-10].minor.yy502,
144885
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy182, SQLITE_SO_ASC, yymsp[-8].minor.yy502, SQLITE_IDXTYPE_APPDEF);
144886
-}
144887
- break;
144888
- case 218: /* uniqueflag ::= UNIQUE */
144889
- case 258: /* raisetype ::= ABORT */ yytestcase(yyruleno==258);
144890
-{yymsp[0].minor.yy502 = OE_Abort;}
144891
- break;
144892
- case 219: /* uniqueflag ::= */
144893
-{yymsp[1].minor.yy502 = OE_None;}
144894
- break;
144895
- case 222: /* eidlist ::= eidlist COMMA nm collate sortorder */
144896
-{
144897
- yymsp[-4].minor.yy232 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502);
144898
-}
144899
- break;
144900
- case 223: /* eidlist ::= nm collate sortorder */
144901
-{
144902
- yymsp[-2].minor.yy232 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); /*A-overwrites-Y*/
144903
-}
144904
- break;
144905
- case 226: /* cmd ::= DROP INDEX ifexists fullname */
144906
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy427, yymsp[-1].minor.yy502);}
144907
- break;
144908
- case 227: /* cmd ::= VACUUM */
148369
+ sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy420, yymsp[-10].minor.yy70,
148370
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy18, SQLITE_SO_ASC, yymsp[-8].minor.yy70, SQLITE_IDXTYPE_APPDEF);
148371
+}
148372
+ break;
148373
+ case 217: /* uniqueflag ::= UNIQUE */
148374
+ case 257: /* raisetype ::= ABORT */ yytestcase(yyruleno==257);
148375
+{yymsp[0].minor.yy70 = OE_Abort;}
148376
+ break;
148377
+ case 218: /* uniqueflag ::= */
148378
+{yymsp[1].minor.yy70 = OE_None;}
148379
+ break;
148380
+ case 221: /* eidlist ::= eidlist COMMA nm collate sortorder */
148381
+{
148382
+ yymsp[-4].minor.yy420 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy420, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy70, yymsp[0].minor.yy70);
148383
+}
148384
+ break;
148385
+ case 222: /* eidlist ::= nm collate sortorder */
148386
+{
148387
+ yymsp[-2].minor.yy420 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy70, yymsp[0].minor.yy70); /*A-overwrites-Y*/
148388
+}
148389
+ break;
148390
+ case 225: /* cmd ::= DROP INDEX ifexists fullname */
148391
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy135, yymsp[-1].minor.yy70);}
148392
+ break;
148393
+ case 226: /* cmd ::= VACUUM */
144909148394
{sqlite3Vacuum(pParse,0);}
144910148395
break;
144911
- case 228: /* cmd ::= VACUUM nm */
148396
+ case 227: /* cmd ::= VACUUM nm */
144912148397
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
144913148398
break;
144914
- case 229: /* cmd ::= PRAGMA nm dbnm */
148399
+ case 228: /* cmd ::= PRAGMA nm dbnm */
144915148400
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
144916148401
break;
144917
- case 230: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
148402
+ case 229: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
144918148403
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
144919148404
break;
144920
- case 231: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
148405
+ case 230: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
144921148406
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
144922148407
break;
144923
- case 232: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
148408
+ case 231: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
144924148409
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
144925148410
break;
144926
- case 233: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
148411
+ case 232: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
144927148412
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
144928148413
break;
144929
- case 236: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
148414
+ case 235: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
144930148415
{
144931148416
Token all;
144932148417
all.z = yymsp[-3].minor.yy0.z;
144933148418
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
144934
- sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy47, &all);
148419
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy207, &all);
144935148420
}
144936148421
break;
144937
- case 237: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
148422
+ case 236: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
144938148423
{
144939
- sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy502, yymsp[-4].minor.yy300.a, yymsp[-4].minor.yy300.b, yymsp[-2].minor.yy427, yymsp[0].minor.yy182, yymsp[-10].minor.yy502, yymsp[-8].minor.yy502);
148424
+ sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy70, yymsp[-4].minor.yy34.a, yymsp[-4].minor.yy34.b, yymsp[-2].minor.yy135, yymsp[0].minor.yy18, yymsp[-10].minor.yy70, yymsp[-8].minor.yy70);
144940148425
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
144941148426
}
144942148427
break;
144943
- case 238: /* trigger_time ::= BEFORE|AFTER */
144944
-{ yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/ }
144945
- break;
144946
- case 239: /* trigger_time ::= INSTEAD OF */
144947
-{ yymsp[-1].minor.yy502 = TK_INSTEAD;}
144948
- break;
144949
- case 240: /* trigger_time ::= */
144950
-{ yymsp[1].minor.yy502 = TK_BEFORE; }
144951
- break;
144952
- case 241: /* trigger_event ::= DELETE|INSERT */
144953
- case 242: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==242);
144954
-{yymsp[0].minor.yy300.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy300.b = 0;}
144955
- break;
144956
- case 243: /* trigger_event ::= UPDATE OF idlist */
144957
-{yymsp[-2].minor.yy300.a = TK_UPDATE; yymsp[-2].minor.yy300.b = yymsp[0].minor.yy510;}
144958
- break;
144959
- case 244: /* when_clause ::= */
144960
- case 263: /* key_opt ::= */ yytestcase(yyruleno==263);
144961
-{ yymsp[1].minor.yy182 = 0; }
144962
- break;
144963
- case 245: /* when_clause ::= WHEN expr */
144964
- case 264: /* key_opt ::= KEY expr */ yytestcase(yyruleno==264);
144965
-{ yymsp[-1].minor.yy182 = yymsp[0].minor.yy182; }
144966
- break;
144967
- case 246: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
144968
-{
144969
- assert( yymsp[-2].minor.yy47!=0 );
144970
- yymsp[-2].minor.yy47->pLast->pNext = yymsp[-1].minor.yy47;
144971
- yymsp[-2].minor.yy47->pLast = yymsp[-1].minor.yy47;
144972
-}
144973
- break;
144974
- case 247: /* trigger_cmd_list ::= trigger_cmd SEMI */
144975
-{
144976
- assert( yymsp[-1].minor.yy47!=0 );
144977
- yymsp[-1].minor.yy47->pLast = yymsp[-1].minor.yy47;
144978
-}
144979
- break;
144980
- case 248: /* trnm ::= nm DOT nm */
148428
+ case 237: /* trigger_time ::= BEFORE|AFTER */
148429
+{ yymsp[0].minor.yy70 = yymsp[0].major; /*A-overwrites-X*/ }
148430
+ break;
148431
+ case 238: /* trigger_time ::= INSTEAD OF */
148432
+{ yymsp[-1].minor.yy70 = TK_INSTEAD;}
148433
+ break;
148434
+ case 239: /* trigger_time ::= */
148435
+{ yymsp[1].minor.yy70 = TK_BEFORE; }
148436
+ break;
148437
+ case 240: /* trigger_event ::= DELETE|INSERT */
148438
+ case 241: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==241);
148439
+{yymsp[0].minor.yy34.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy34.b = 0;}
148440
+ break;
148441
+ case 242: /* trigger_event ::= UPDATE OF idlist */
148442
+{yymsp[-2].minor.yy34.a = TK_UPDATE; yymsp[-2].minor.yy34.b = yymsp[0].minor.yy48;}
148443
+ break;
148444
+ case 243: /* when_clause ::= */
148445
+ case 262: /* key_opt ::= */ yytestcase(yyruleno==262);
148446
+ case 305: /* filter_opt ::= */ yytestcase(yyruleno==305);
148447
+{ yymsp[1].minor.yy18 = 0; }
148448
+ break;
148449
+ case 244: /* when_clause ::= WHEN expr */
148450
+ case 263: /* key_opt ::= KEY expr */ yytestcase(yyruleno==263);
148451
+{ yymsp[-1].minor.yy18 = yymsp[0].minor.yy18; }
148452
+ break;
148453
+ case 245: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
148454
+{
148455
+ assert( yymsp[-2].minor.yy207!=0 );
148456
+ yymsp[-2].minor.yy207->pLast->pNext = yymsp[-1].minor.yy207;
148457
+ yymsp[-2].minor.yy207->pLast = yymsp[-1].minor.yy207;
148458
+}
148459
+ break;
148460
+ case 246: /* trigger_cmd_list ::= trigger_cmd SEMI */
148461
+{
148462
+ assert( yymsp[-1].minor.yy207!=0 );
148463
+ yymsp[-1].minor.yy207->pLast = yymsp[-1].minor.yy207;
148464
+}
148465
+ break;
148466
+ case 247: /* trnm ::= nm DOT nm */
144981148467
{
144982148468
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
144983148469
sqlite3ErrorMsg(pParse,
144984148470
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
144985148471
"statements within triggers");
144986148472
}
144987148473
break;
144988
- case 249: /* tridxby ::= INDEXED BY nm */
148474
+ case 248: /* tridxby ::= INDEXED BY nm */
144989148475
{
144990148476
sqlite3ErrorMsg(pParse,
144991148477
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
144992148478
"within triggers");
144993148479
}
144994148480
break;
144995
- case 250: /* tridxby ::= NOT INDEXED */
148481
+ case 249: /* tridxby ::= NOT INDEXED */
144996148482
{
144997148483
sqlite3ErrorMsg(pParse,
144998148484
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
144999148485
"within triggers");
145000148486
}
145001148487
break;
145002
- case 251: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
145003
-{yylhsminor.yy47 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy182, yymsp[-6].minor.yy502, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy36);}
145004
- yymsp[-7].minor.yy47 = yylhsminor.yy47;
145005
- break;
145006
- case 252: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
145007
-{
145008
- yylhsminor.yy47 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy510,yymsp[-2].minor.yy399,yymsp[-6].minor.yy502,yymsp[-1].minor.yy198,yymsp[-7].minor.yy36,yymsp[0].minor.yy36);/*yylhsminor.yy47-overwrites-yymsp[-6].minor.yy502*/
145009
-}
145010
- yymsp[-7].minor.yy47 = yylhsminor.yy47;
145011
- break;
145012
- case 253: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
145013
-{yylhsminor.yy47 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy182, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy36);}
145014
- yymsp[-5].minor.yy47 = yylhsminor.yy47;
145015
- break;
145016
- case 254: /* trigger_cmd ::= scanpt select scanpt */
145017
-{yylhsminor.yy47 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy399, yymsp[-2].minor.yy36, yymsp[0].minor.yy36); /*yylhsminor.yy47-overwrites-yymsp[-1].minor.yy399*/}
145018
- yymsp[-2].minor.yy47 = yylhsminor.yy47;
145019
- break;
145020
- case 255: /* expr ::= RAISE LP IGNORE RP */
145021
-{
145022
- yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
145023
- if( yymsp[-3].minor.yy182 ){
145024
- yymsp[-3].minor.yy182->affinity = OE_Ignore;
145025
- }
145026
-}
145027
- break;
145028
- case 256: /* expr ::= RAISE LP raisetype COMMA nm RP */
145029
-{
145030
- yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
145031
- if( yymsp[-5].minor.yy182 ) {
145032
- yymsp[-5].minor.yy182->affinity = (char)yymsp[-3].minor.yy502;
145033
- }
145034
-}
145035
- break;
145036
- case 257: /* raisetype ::= ROLLBACK */
145037
-{yymsp[0].minor.yy502 = OE_Rollback;}
145038
- break;
145039
- case 259: /* raisetype ::= FAIL */
145040
-{yymsp[0].minor.yy502 = OE_Fail;}
145041
- break;
145042
- case 260: /* cmd ::= DROP TRIGGER ifexists fullname */
145043
-{
145044
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy427,yymsp[-1].minor.yy502);
145045
-}
145046
- break;
145047
- case 261: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
145048
-{
145049
- sqlite3Attach(pParse, yymsp[-3].minor.yy182, yymsp[-1].minor.yy182, yymsp[0].minor.yy182);
145050
-}
145051
- break;
145052
- case 262: /* cmd ::= DETACH database_kw_opt expr */
145053
-{
145054
- sqlite3Detach(pParse, yymsp[0].minor.yy182);
145055
-}
145056
- break;
145057
- case 265: /* cmd ::= REINDEX */
148488
+ case 250: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
148489
+{yylhsminor.yy207 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy420, yymsp[-1].minor.yy18, yymsp[-6].minor.yy70, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy392);}
148490
+ yymsp[-7].minor.yy207 = yylhsminor.yy207;
148491
+ break;
148492
+ case 251: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
148493
+{
148494
+ yylhsminor.yy207 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy48,yymsp[-2].minor.yy489,yymsp[-6].minor.yy70,yymsp[-1].minor.yy340,yymsp[-7].minor.yy392,yymsp[0].minor.yy392);/*yylhsminor.yy207-overwrites-yymsp[-6].minor.yy70*/
148495
+}
148496
+ yymsp[-7].minor.yy207 = yylhsminor.yy207;
148497
+ break;
148498
+ case 252: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
148499
+{yylhsminor.yy207 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy18, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy392);}
148500
+ yymsp[-5].minor.yy207 = yylhsminor.yy207;
148501
+ break;
148502
+ case 253: /* trigger_cmd ::= scanpt select scanpt */
148503
+{yylhsminor.yy207 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy489, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); /*yylhsminor.yy207-overwrites-yymsp[-1].minor.yy489*/}
148504
+ yymsp[-2].minor.yy207 = yylhsminor.yy207;
148505
+ break;
148506
+ case 254: /* expr ::= RAISE LP IGNORE RP */
148507
+{
148508
+ yymsp[-3].minor.yy18 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
148509
+ if( yymsp[-3].minor.yy18 ){
148510
+ yymsp[-3].minor.yy18->affinity = OE_Ignore;
148511
+ }
148512
+}
148513
+ break;
148514
+ case 255: /* expr ::= RAISE LP raisetype COMMA nm RP */
148515
+{
148516
+ yymsp[-5].minor.yy18 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
148517
+ if( yymsp[-5].minor.yy18 ) {
148518
+ yymsp[-5].minor.yy18->affinity = (char)yymsp[-3].minor.yy70;
148519
+ }
148520
+}
148521
+ break;
148522
+ case 256: /* raisetype ::= ROLLBACK */
148523
+{yymsp[0].minor.yy70 = OE_Rollback;}
148524
+ break;
148525
+ case 258: /* raisetype ::= FAIL */
148526
+{yymsp[0].minor.yy70 = OE_Fail;}
148527
+ break;
148528
+ case 259: /* cmd ::= DROP TRIGGER ifexists fullname */
148529
+{
148530
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy135,yymsp[-1].minor.yy70);
148531
+}
148532
+ break;
148533
+ case 260: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
148534
+{
148535
+ sqlite3Attach(pParse, yymsp[-3].minor.yy18, yymsp[-1].minor.yy18, yymsp[0].minor.yy18);
148536
+}
148537
+ break;
148538
+ case 261: /* cmd ::= DETACH database_kw_opt expr */
148539
+{
148540
+ sqlite3Detach(pParse, yymsp[0].minor.yy18);
148541
+}
148542
+ break;
148543
+ case 264: /* cmd ::= REINDEX */
145058148544
{sqlite3Reindex(pParse, 0, 0);}
145059148545
break;
145060
- case 266: /* cmd ::= REINDEX nm dbnm */
148546
+ case 265: /* cmd ::= REINDEX nm dbnm */
145061148547
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
145062148548
break;
145063
- case 267: /* cmd ::= ANALYZE */
148549
+ case 266: /* cmd ::= ANALYZE */
145064148550
{sqlite3Analyze(pParse, 0, 0);}
145065148551
break;
145066
- case 268: /* cmd ::= ANALYZE nm dbnm */
148552
+ case 267: /* cmd ::= ANALYZE nm dbnm */
145067148553
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
145068148554
break;
145069
- case 269: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
148555
+ case 268: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
145070148556
{
145071
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy427,&yymsp[0].minor.yy0);
148557
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy135,&yymsp[0].minor.yy0);
145072148558
}
145073148559
break;
145074
- case 270: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
148560
+ case 269: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
145075148561
{
145076148562
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
145077148563
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
145078148564
}
145079148565
break;
145080
- case 271: /* add_column_fullname ::= fullname */
148566
+ case 270: /* add_column_fullname ::= fullname */
145081148567
{
145082148568
disableLookaside(pParse);
145083
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy427);
148569
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy135);
145084148570
}
145085148571
break;
145086
- case 272: /* cmd ::= create_vtab */
148572
+ case 271: /* cmd ::= create_vtab */
145087148573
{sqlite3VtabFinishParse(pParse,0);}
145088148574
break;
145089
- case 273: /* cmd ::= create_vtab LP vtabarglist RP */
148575
+ case 272: /* cmd ::= create_vtab LP vtabarglist RP */
145090148576
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
145091148577
break;
145092
- case 274: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
148578
+ case 273: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
145093148579
{
145094
- sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy502);
148580
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy70);
145095148581
}
145096148582
break;
145097
- case 275: /* vtabarg ::= */
148583
+ case 274: /* vtabarg ::= */
145098148584
{sqlite3VtabArgInit(pParse);}
145099148585
break;
145100
- case 276: /* vtabargtoken ::= ANY */
145101
- case 277: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==277);
145102
- case 278: /* lp ::= LP */ yytestcase(yyruleno==278);
148586
+ case 275: /* vtabargtoken ::= ANY */
148587
+ case 276: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==276);
148588
+ case 277: /* lp ::= LP */ yytestcase(yyruleno==277);
145103148589
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
145104148590
break;
145105
- case 279: /* with ::= WITH wqlist */
145106
- case 280: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==280);
145107
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy91, 1); }
145108
- break;
145109
- case 281: /* wqlist ::= nm eidlist_opt AS LP select RP */
145110
-{
145111
- yymsp[-5].minor.yy91 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399); /*A-overwrites-X*/
145112
-}
145113
- break;
145114
- case 282: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
145115
-{
145116
- yymsp[-7].minor.yy91 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy91, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399);
145117
-}
148591
+ case 278: /* with ::= WITH wqlist */
148592
+ case 279: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==279);
148593
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy449, 1); }
148594
+ break;
148595
+ case 280: /* wqlist ::= nm eidlist_opt AS LP select RP */
148596
+{
148597
+ yymsp[-5].minor.yy449 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489); /*A-overwrites-X*/
148598
+}
148599
+ break;
148600
+ case 281: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
148601
+{
148602
+ yymsp[-7].minor.yy449 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy449, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489);
148603
+}
148604
+ break;
148605
+ case 282: /* windowdefn_list ::= windowdefn */
148606
+{ yylhsminor.yy327 = yymsp[0].minor.yy327; }
148607
+ yymsp[0].minor.yy327 = yylhsminor.yy327;
148608
+ break;
148609
+ case 283: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
148610
+{
148611
+ assert( yymsp[0].minor.yy327!=0 );
148612
+ yymsp[0].minor.yy327->pNextWin = yymsp[-2].minor.yy327;
148613
+ yylhsminor.yy327 = yymsp[0].minor.yy327;
148614
+}
148615
+ yymsp[-2].minor.yy327 = yylhsminor.yy327;
148616
+ break;
148617
+ case 284: /* windowdefn ::= nm AS window */
148618
+{
148619
+ if( ALWAYS(yymsp[0].minor.yy327) ){
148620
+ yymsp[0].minor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[-2].minor.yy0.z, yymsp[-2].minor.yy0.n);
148621
+ }
148622
+ yylhsminor.yy327 = yymsp[0].minor.yy327;
148623
+}
148624
+ yymsp[-2].minor.yy327 = yylhsminor.yy327;
148625
+ break;
148626
+ case 285: /* window ::= LP part_opt orderby_opt frame_opt RP */
148627
+{
148628
+ yymsp[-4].minor.yy327 = yymsp[-1].minor.yy327;
148629
+ if( ALWAYS(yymsp[-4].minor.yy327) ){
148630
+ yymsp[-4].minor.yy327->pPartition = yymsp[-3].minor.yy420;
148631
+ yymsp[-4].minor.yy327->pOrderBy = yymsp[-2].minor.yy420;
148632
+ }
148633
+}
148634
+ break;
148635
+ case 286: /* part_opt ::= PARTITION BY exprlist */
148636
+{ yymsp[-2].minor.yy420 = yymsp[0].minor.yy420; }
148637
+ break;
148638
+ case 287: /* part_opt ::= */
148639
+{ yymsp[1].minor.yy420 = 0; }
148640
+ break;
148641
+ case 288: /* frame_opt ::= */
148642
+{
148643
+ yymsp[1].minor.yy327 = sqlite3WindowAlloc(pParse, TK_RANGE, TK_UNBOUNDED, 0, TK_CURRENT, 0);
148644
+}
148645
+ break;
148646
+ case 289: /* frame_opt ::= range_or_rows frame_bound_s */
148647
+{
148648
+ yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-1].minor.yy70, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr, TK_CURRENT, 0);
148649
+}
148650
+ yymsp[-1].minor.yy327 = yylhsminor.yy327;
148651
+ break;
148652
+ case 290: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
148653
+{
148654
+ yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy119.eType, yymsp[-2].minor.yy119.pExpr, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr);
148655
+}
148656
+ yymsp[-4].minor.yy327 = yylhsminor.yy327;
148657
+ break;
148658
+ case 291: /* range_or_rows ::= RANGE */
148659
+{ yymsp[0].minor.yy70 = TK_RANGE; }
148660
+ break;
148661
+ case 292: /* range_or_rows ::= ROWS */
148662
+{ yymsp[0].minor.yy70 = TK_ROWS; }
148663
+ break;
148664
+ case 293: /* frame_bound_s ::= frame_bound */
148665
+ case 295: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==295);
148666
+{ yylhsminor.yy119 = yymsp[0].minor.yy119; }
148667
+ yymsp[0].minor.yy119 = yylhsminor.yy119;
148668
+ break;
148669
+ case 294: /* frame_bound_s ::= UNBOUNDED PRECEDING */
148670
+ case 296: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==296);
148671
+{yymsp[-1].minor.yy119.eType = TK_UNBOUNDED; yymsp[-1].minor.yy119.pExpr = 0;}
148672
+ break;
148673
+ case 297: /* frame_bound ::= expr PRECEDING */
148674
+{ yylhsminor.yy119.eType = TK_PRECEDING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
148675
+ yymsp[-1].minor.yy119 = yylhsminor.yy119;
148676
+ break;
148677
+ case 298: /* frame_bound ::= CURRENT ROW */
148678
+{ yymsp[-1].minor.yy119.eType = TK_CURRENT ; yymsp[-1].minor.yy119.pExpr = 0; }
148679
+ break;
148680
+ case 299: /* frame_bound ::= expr FOLLOWING */
148681
+{ yylhsminor.yy119.eType = TK_FOLLOWING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
148682
+ yymsp[-1].minor.yy119 = yylhsminor.yy119;
148683
+ break;
148684
+ case 300: /* windowdefn_opt ::= */
148685
+ case 302: /* over_opt ::= */ yytestcase(yyruleno==302);
148686
+{ yymsp[1].minor.yy327 = 0; }
148687
+ break;
148688
+ case 301: /* windowdefn_opt ::= WINDOW windowdefn_list */
148689
+{ yymsp[-1].minor.yy327 = yymsp[0].minor.yy327; }
148690
+ break;
148691
+ case 303: /* over_opt ::= filter_opt OVER window */
148692
+{
148693
+ yylhsminor.yy327 = yymsp[0].minor.yy327;
148694
+ assert( yylhsminor.yy327!=0 );
148695
+ yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
148696
+}
148697
+ yymsp[-2].minor.yy327 = yylhsminor.yy327;
148698
+ break;
148699
+ case 304: /* over_opt ::= filter_opt OVER nm */
148700
+{
148701
+ yylhsminor.yy327 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
148702
+ if( yylhsminor.yy327 ){
148703
+ yylhsminor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
148704
+ yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
148705
+ }else{
148706
+ sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy18);
148707
+ }
148708
+}
148709
+ yymsp[-2].minor.yy327 = yylhsminor.yy327;
148710
+ break;
148711
+ case 306: /* filter_opt ::= FILTER LP WHERE expr RP */
148712
+{ yymsp[-4].minor.yy18 = yymsp[-1].minor.yy18; }
145118148713
break;
145119148714
default:
145120
- /* (283) input ::= cmdlist */ yytestcase(yyruleno==283);
145121
- /* (284) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==284);
145122
- /* (285) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=285);
145123
- /* (286) ecmd ::= SEMI */ yytestcase(yyruleno==286);
145124
- /* (287) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==287);
145125
- /* (288) ecmd ::= explain cmdx */ yytestcase(yyruleno==288);
145126
- /* (289) trans_opt ::= */ yytestcase(yyruleno==289);
145127
- /* (290) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==290);
145128
- /* (291) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==291);
145129
- /* (292) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==292);
145130
- /* (293) savepoint_opt ::= */ yytestcase(yyruleno==293);
145131
- /* (294) cmd ::= create_table create_table_args */ yytestcase(yyruleno==294);
145132
- /* (295) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==295);
145133
- /* (296) columnlist ::= columnname carglist */ yytestcase(yyruleno==296);
145134
- /* (297) nm ::= ID|INDEXED */ yytestcase(yyruleno==297);
145135
- /* (298) nm ::= STRING */ yytestcase(yyruleno==298);
145136
- /* (299) nm ::= JOIN_KW */ yytestcase(yyruleno==299);
145137
- /* (300) typetoken ::= typename */ yytestcase(yyruleno==300);
145138
- /* (301) typename ::= ID|STRING */ yytestcase(yyruleno==301);
145139
- /* (302) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=302);
145140
- /* (303) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=303);
145141
- /* (304) carglist ::= carglist ccons */ yytestcase(yyruleno==304);
145142
- /* (305) carglist ::= */ yytestcase(yyruleno==305);
145143
- /* (306) ccons ::= NULL onconf */ yytestcase(yyruleno==306);
145144
- /* (307) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==307);
145145
- /* (308) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==308);
145146
- /* (309) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=309);
145147
- /* (310) tconscomma ::= */ yytestcase(yyruleno==310);
145148
- /* (311) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=311);
145149
- /* (312) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=312);
145150
- /* (313) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=313);
145151
- /* (314) oneselect ::= values */ yytestcase(yyruleno==314);
145152
- /* (315) sclp ::= selcollist COMMA */ yytestcase(yyruleno==315);
145153
- /* (316) as ::= ID|STRING */ yytestcase(yyruleno==316);
145154
- /* (317) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=317);
145155
- /* (318) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==318);
145156
- /* (319) exprlist ::= nexprlist */ yytestcase(yyruleno==319);
145157
- /* (320) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=320);
145158
- /* (321) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=321);
145159
- /* (322) nmnum ::= ON */ yytestcase(yyruleno==322);
145160
- /* (323) nmnum ::= DELETE */ yytestcase(yyruleno==323);
145161
- /* (324) nmnum ::= DEFAULT */ yytestcase(yyruleno==324);
145162
- /* (325) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==325);
145163
- /* (326) foreach_clause ::= */ yytestcase(yyruleno==326);
145164
- /* (327) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==327);
145165
- /* (328) trnm ::= nm */ yytestcase(yyruleno==328);
145166
- /* (329) tridxby ::= */ yytestcase(yyruleno==329);
145167
- /* (330) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==330);
145168
- /* (331) database_kw_opt ::= */ yytestcase(yyruleno==331);
145169
- /* (332) kwcolumn_opt ::= */ yytestcase(yyruleno==332);
145170
- /* (333) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==333);
145171
- /* (334) vtabarglist ::= vtabarg */ yytestcase(yyruleno==334);
145172
- /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==335);
145173
- /* (336) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==336);
145174
- /* (337) anylist ::= */ yytestcase(yyruleno==337);
145175
- /* (338) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==338);
145176
- /* (339) anylist ::= anylist ANY */ yytestcase(yyruleno==339);
145177
- /* (340) with ::= */ yytestcase(yyruleno==340);
148715
+ /* (307) input ::= cmdlist */ yytestcase(yyruleno==307);
148716
+ /* (308) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==308);
148717
+ /* (309) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=309);
148718
+ /* (310) ecmd ::= SEMI */ yytestcase(yyruleno==310);
148719
+ /* (311) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==311);
148720
+ /* (312) ecmd ::= explain cmdx */ yytestcase(yyruleno==312);
148721
+ /* (313) trans_opt ::= */ yytestcase(yyruleno==313);
148722
+ /* (314) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==314);
148723
+ /* (315) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==315);
148724
+ /* (316) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==316);
148725
+ /* (317) savepoint_opt ::= */ yytestcase(yyruleno==317);
148726
+ /* (318) cmd ::= create_table create_table_args */ yytestcase(yyruleno==318);
148727
+ /* (319) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==319);
148728
+ /* (320) columnlist ::= columnname carglist */ yytestcase(yyruleno==320);
148729
+ /* (321) nm ::= ID|INDEXED */ yytestcase(yyruleno==321);
148730
+ /* (322) nm ::= STRING */ yytestcase(yyruleno==322);
148731
+ /* (323) nm ::= JOIN_KW */ yytestcase(yyruleno==323);
148732
+ /* (324) typetoken ::= typename */ yytestcase(yyruleno==324);
148733
+ /* (325) typename ::= ID|STRING */ yytestcase(yyruleno==325);
148734
+ /* (326) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=326);
148735
+ /* (327) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=327);
148736
+ /* (328) carglist ::= carglist ccons */ yytestcase(yyruleno==328);
148737
+ /* (329) carglist ::= */ yytestcase(yyruleno==329);
148738
+ /* (330) ccons ::= NULL onconf */ yytestcase(yyruleno==330);
148739
+ /* (331) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==331);
148740
+ /* (332) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==332);
148741
+ /* (333) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=333);
148742
+ /* (334) tconscomma ::= */ yytestcase(yyruleno==334);
148743
+ /* (335) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=335);
148744
+ /* (336) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=336);
148745
+ /* (337) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=337);
148746
+ /* (338) oneselect ::= values */ yytestcase(yyruleno==338);
148747
+ /* (339) sclp ::= selcollist COMMA */ yytestcase(yyruleno==339);
148748
+ /* (340) as ::= ID|STRING */ yytestcase(yyruleno==340);
148749
+ /* (341) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=341);
148750
+ /* (342) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==342);
148751
+ /* (343) exprlist ::= nexprlist */ yytestcase(yyruleno==343);
148752
+ /* (344) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=344);
148753
+ /* (345) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=345);
148754
+ /* (346) nmnum ::= ON */ yytestcase(yyruleno==346);
148755
+ /* (347) nmnum ::= DELETE */ yytestcase(yyruleno==347);
148756
+ /* (348) nmnum ::= DEFAULT */ yytestcase(yyruleno==348);
148757
+ /* (349) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==349);
148758
+ /* (350) foreach_clause ::= */ yytestcase(yyruleno==350);
148759
+ /* (351) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==351);
148760
+ /* (352) trnm ::= nm */ yytestcase(yyruleno==352);
148761
+ /* (353) tridxby ::= */ yytestcase(yyruleno==353);
148762
+ /* (354) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==354);
148763
+ /* (355) database_kw_opt ::= */ yytestcase(yyruleno==355);
148764
+ /* (356) kwcolumn_opt ::= */ yytestcase(yyruleno==356);
148765
+ /* (357) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==357);
148766
+ /* (358) vtabarglist ::= vtabarg */ yytestcase(yyruleno==358);
148767
+ /* (359) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==359);
148768
+ /* (360) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==360);
148769
+ /* (361) anylist ::= */ yytestcase(yyruleno==361);
148770
+ /* (362) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==362);
148771
+ /* (363) anylist ::= anylist ANY */ yytestcase(yyruleno==363);
148772
+ /* (364) with ::= */ yytestcase(yyruleno==364);
145178148773
break;
145179148774
/********** End reduce actions ************************************************/
145180148775
};
145181148776
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
145182148777
yygoto = yyRuleInfo[yyruleno].lhs;
@@ -145458,10 +149053,25 @@
145458149053
fprintf(yyTraceFILE,"]\n");
145459149054
}
145460149055
#endif
145461149056
return;
145462149057
}
149058
+
149059
+/*
149060
+** Return the fallback token corresponding to canonical token iToken, or
149061
+** 0 if iToken has no fallback.
149062
+*/
149063
+SQLITE_PRIVATE int sqlite3ParserFallback(int iToken){
149064
+#ifdef YYFALLBACK
149065
+ if( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ){
149066
+ return yyFallback[iToken];
149067
+ }
149068
+#else
149069
+ (void)iToken;
149070
+#endif
149071
+ return 0;
149072
+}
145463149073
145464149074
/************** End of parse.c ***********************************************/
145465149075
/************** Begin file tokenize.c ****************************************/
145466149076
/*
145467149077
** 2001 September 15
@@ -145517,15 +149127,16 @@
145517149127
#define CC_COMMA 23 /* ',' */
145518149128
#define CC_AND 24 /* '&' */
145519149129
#define CC_TILDA 25 /* '~' */
145520149130
#define CC_DOT 26 /* '.' */
145521149131
#define CC_ILLEGAL 27 /* Illegal character */
149132
+#define CC_NUL 28 /* 0x00 */
145522149133
145523149134
static const unsigned char aiClass[] = {
145524149135
#ifdef SQLITE_ASCII
145525149136
/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
145526
-/* 0x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 7, 7, 27, 7, 7, 27, 27,
149137
+/* 0x */ 28, 27, 27, 27, 27, 27, 27, 27, 27, 7, 7, 27, 7, 7, 27, 27,
145527149138
/* 1x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
145528149139
/* 2x */ 7, 15, 8, 5, 4, 22, 24, 8, 17, 18, 21, 20, 23, 11, 26, 16,
145529149140
/* 3x */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 19, 12, 14, 13, 6,
145530149141
/* 4x */ 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
145531149142
/* 5x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 9, 27, 27, 27, 1,
@@ -145620,23 +149231,24 @@
145620149231
** might be implemented more directly using a hand-written hash table.
145621149232
** But by using this automatically generated code, the size of the code
145622149233
** is substantially reduced. This is important for embedded applications
145623149234
** on platforms with limited memory.
145624149235
*/
145625
-/* Hash score: 185 */
145626
-/* zKWText[] encodes 845 bytes of keyword text in 561 bytes */
149236
+/* Hash score: 208 */
149237
+/* zKWText[] encodes 923 bytes of keyword text in 614 bytes */
145627149238
/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
145628149239
/* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
145629149240
/* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
145630
-/* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE */
145631
-/* BETWEENOTHINGLOBYCASCADELETECASECOLLATECREATECURRENT_DATE */
145632
-/* DETACHIMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTVALUES */
145633
-/* VIRTUALIMITWHENOTNULLWHERENAMEAFTEREPLACEANDEFAULT */
145634
-/* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */
145635
-/* RIMARYDEFERREDISTINCTDORDERESTRICTDROPFAILFROMFULLIFISNULL */
145636
-/* RIGHTROLLBACKROWUNIONUSINGVACUUMVIEWINITIALLY */
145637
-static const char zKWText[560] = {
149241
+/* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERANGEBETWEEN */
149242
+/* OTHINGLOBYCASCADELETECASECOLLATECREATECURRENT_DATEDETACH */
149243
+/* IMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMIT */
149244
+/* WHENOTNULLWHERECURSIVEAFTERENAMEANDEFAULTAUTOINCREMENTCAST */
149245
+/* COLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMPARTITIONDEFERRED */
149246
+/* ISTINCTDROPRECEDINGFAILFILTEREPLACEFOLLOWINGFROMFULLIFISNULL */
149247
+/* ORDERESTRICTOVERIGHTROLLBACKROWSUNBOUNDEDUNIONUSINGVACUUMVIEW */
149248
+/* INDOWINITIALLYPRIMARY */
149249
+static const char zKWText[613] = {
145638149250
'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
145639149251
'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
145640149252
'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
145641149253
'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
145642149254
'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
@@ -145645,88 +149257,94 @@
145645149257
'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
145646149258
'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
145647149259
'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
145648149260
'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
145649149261
'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
145650
- 'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E',
145651
- 'B','E','T','W','E','E','N','O','T','H','I','N','G','L','O','B','Y','C',
145652
- 'A','S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L',
145653
- 'A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D',
145654
- 'A','T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E',
145655
- 'J','O','I','N','S','E','R','T','L','I','K','E','M','A','T','C','H','P',
145656
- 'L','A','N','A','L','Y','Z','E','P','R','A','G','M','A','B','O','R','T',
145657
- 'V','A','L','U','E','S','V','I','R','T','U','A','L','I','M','I','T','W',
145658
- 'H','E','N','O','T','N','U','L','L','W','H','E','R','E','N','A','M','E',
145659
- 'A','F','T','E','R','E','P','L','A','C','E','A','N','D','E','F','A','U',
145660
- 'L','T','A','U','T','O','I','N','C','R','E','M','E','N','T','C','A','S',
145661
- 'T','C','O','L','U','M','N','C','O','M','M','I','T','C','O','N','F','L',
145662
- 'I','C','T','C','R','O','S','S','C','U','R','R','E','N','T','_','T','I',
145663
- 'M','E','S','T','A','M','P','R','I','M','A','R','Y','D','E','F','E','R',
145664
- 'R','E','D','I','S','T','I','N','C','T','D','O','R','D','E','R','E','S',
145665
- 'T','R','I','C','T','D','R','O','P','F','A','I','L','F','R','O','M','F',
145666
- 'U','L','L','I','F','I','S','N','U','L','L','R','I','G','H','T','R','O',
145667
- 'L','L','B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N',
145668
- 'G','V','A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L',
145669
- 'L','Y',
149262
+ 'T','E','B','E','G','I','N','N','E','R','A','N','G','E','B','E','T','W',
149263
+ 'E','E','N','O','T','H','I','N','G','L','O','B','Y','C','A','S','C','A',
149264
+ 'D','E','L','E','T','E','C','A','S','E','C','O','L','L','A','T','E','C',
149265
+ 'R','E','A','T','E','C','U','R','R','E','N','T','_','D','A','T','E','D',
149266
+ 'E','T','A','C','H','I','M','M','E','D','I','A','T','E','J','O','I','N',
149267
+ 'S','E','R','T','L','I','K','E','M','A','T','C','H','P','L','A','N','A',
149268
+ 'L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U',
149269
+ 'E','S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','O',
149270
+ 'T','N','U','L','L','W','H','E','R','E','C','U','R','S','I','V','E','A',
149271
+ 'F','T','E','R','E','N','A','M','E','A','N','D','E','F','A','U','L','T',
149272
+ 'A','U','T','O','I','N','C','R','E','M','E','N','T','C','A','S','T','C',
149273
+ 'O','L','U','M','N','C','O','M','M','I','T','C','O','N','F','L','I','C',
149274
+ 'T','C','R','O','S','S','C','U','R','R','E','N','T','_','T','I','M','E',
149275
+ 'S','T','A','M','P','A','R','T','I','T','I','O','N','D','E','F','E','R',
149276
+ 'R','E','D','I','S','T','I','N','C','T','D','R','O','P','R','E','C','E',
149277
+ 'D','I','N','G','F','A','I','L','F','I','L','T','E','R','E','P','L','A',
149278
+ 'C','E','F','O','L','L','O','W','I','N','G','F','R','O','M','F','U','L',
149279
+ 'L','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T','R',
149280
+ 'I','C','T','O','V','E','R','I','G','H','T','R','O','L','L','B','A','C',
149281
+ 'K','R','O','W','S','U','N','B','O','U','N','D','E','D','U','N','I','O',
149282
+ 'N','U','S','I','N','G','V','A','C','U','U','M','V','I','E','W','I','N',
149283
+ 'D','O','W','I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R',
149284
+ 'Y',
145670149285
};
145671149286
/* aKWHash[i] is the hash value for the i-th keyword */
145672149287
static const unsigned char aKWHash[127] = {
145673
- 74, 108, 119, 72, 0, 45, 0, 0, 81, 0, 76, 61, 0,
145674
- 42, 12, 77, 15, 0, 118, 84, 54, 116, 0, 19, 0, 0,
145675
- 123, 0, 121, 111, 0, 22, 96, 0, 9, 0, 0, 68, 69,
145676
- 0, 67, 6, 0, 48, 93, 105, 0, 120, 104, 0, 0, 44,
145677
- 0, 106, 24, 0, 17, 0, 124, 53, 23, 0, 5, 62, 25,
145678
- 99, 0, 0, 126, 112, 60, 125, 57, 28, 55, 0, 94, 0,
145679
- 103, 26, 0, 102, 0, 0, 0, 98, 95, 100, 91, 115, 14,
145680
- 39, 114, 0, 80, 0, 109, 92, 90, 32, 0, 122, 79, 117,
145681
- 86, 46, 83, 0, 0, 97, 40, 59, 110, 0, 36, 0, 0,
145682
- 29, 0, 89, 87, 88, 0, 20, 85, 0, 56,
149288
+ 74, 109, 124, 72, 106, 45, 0, 0, 81, 0, 76, 61, 0,
149289
+ 42, 12, 77, 15, 0, 123, 84, 54, 118, 125, 19, 0, 0,
149290
+ 130, 0, 128, 121, 0, 22, 96, 0, 9, 0, 0, 115, 69,
149291
+ 0, 67, 6, 0, 48, 93, 136, 0, 126, 104, 0, 0, 44,
149292
+ 0, 107, 24, 0, 17, 0, 131, 53, 23, 0, 5, 62, 132,
149293
+ 99, 0, 0, 135, 110, 60, 134, 57, 113, 55, 0, 94, 0,
149294
+ 103, 26, 0, 102, 0, 0, 0, 98, 95, 100, 105, 117, 14,
149295
+ 39, 116, 0, 80, 0, 133, 114, 92, 59, 0, 129, 79, 119,
149296
+ 86, 46, 83, 0, 0, 97, 40, 122, 120, 0, 127, 0, 0,
149297
+ 29, 0, 89, 87, 88, 0, 20, 85, 111, 56,
145683149298
};
145684149299
/* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
145685149300
** then the i-th keyword has no more hash collisions. Otherwise,
145686149301
** the next keyword with the same hash is aKWHash[i]-1. */
145687
-static const unsigned char aKWNext[126] = {
149302
+static const unsigned char aKWNext[136] = {
145688149303
0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
145689149304
0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
145690149305
0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
145691149306
0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
145692
- 0, 43, 3, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
149307
+ 0, 43, 3, 47, 0, 0, 32, 0, 0, 0, 0, 0, 0,
145693149308
0, 1, 64, 0, 0, 65, 0, 41, 0, 38, 0, 0, 0,
145694
- 0, 0, 49, 75, 0, 0, 30, 0, 58, 0, 0, 63, 31,
145695
- 52, 16, 34, 10, 0, 0, 0, 0, 0, 0, 0, 11, 70,
145696
- 78, 0, 8, 0, 18, 51, 0, 107, 101, 0, 113, 0, 73,
145697
- 27, 37, 71, 82, 0, 35, 66, 0, 0,
149309
+ 0, 0, 49, 75, 0, 0, 30, 0, 58, 0, 0, 0, 31,
149310
+ 63, 16, 34, 10, 0, 0, 0, 0, 0, 0, 0, 11, 70,
149311
+ 91, 0, 0, 8, 0, 108, 0, 101, 28, 52, 68, 0, 112,
149312
+ 0, 73, 51, 0, 90, 27, 37, 0, 71, 36, 82, 0, 35,
149313
+ 66, 25, 18, 0, 0, 78,
145698149314
};
145699149315
/* aKWLen[i] is the length (in bytes) of the i-th keyword */
145700
-static const unsigned char aKWLen[126] = {
149316
+static const unsigned char aKWLen[136] = {
145701149317
7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
145702149318
7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
145703149319
11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
145704149320
4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
145705
- 6, 6, 5, 6, 5, 5, 9, 7, 7, 4, 2, 7, 3,
149321
+ 6, 6, 5, 6, 5, 5, 5, 7, 7, 4, 2, 7, 3,
145706149322
6, 4, 7, 6, 12, 6, 9, 4, 6, 4, 5, 4, 7,
145707
- 6, 5, 6, 7, 5, 4, 7, 3, 2, 4, 5, 6, 5,
145708
- 7, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5, 17, 12,
145709
- 7, 8, 8, 2, 2, 5, 8, 4, 4, 4, 4, 2, 6,
145710
- 5, 8, 3, 5, 5, 6, 4, 9, 3,
149323
+ 6, 5, 6, 7, 5, 4, 7, 3, 2, 4, 5, 9, 5,
149324
+ 6, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5, 17, 12,
149325
+ 7, 9, 8, 8, 2, 4, 9, 4, 6, 7, 9, 4, 4,
149326
+ 2, 6, 5, 8, 4, 5, 8, 4, 3, 9, 5, 5, 6,
149327
+ 4, 6, 2, 9, 3, 7,
145711149328
};
145712149329
/* aKWOffset[i] is the index into zKWText[] of the start of
145713149330
** the text for the i-th keyword. */
145714
-static const unsigned short int aKWOffset[126] = {
149331
+static const unsigned short int aKWOffset[136] = {
145715149332
0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
145716149333
36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
145717149334
86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
145718149335
159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
145719
- 199, 204, 209, 212, 218, 221, 225, 234, 240, 246, 249, 251, 252,
145720
- 256, 262, 266, 273, 279, 291, 297, 306, 308, 314, 318, 323, 325,
145721
- 332, 337, 342, 348, 354, 359, 362, 362, 362, 365, 369, 372, 378,
145722
- 382, 389, 391, 398, 400, 402, 411, 415, 421, 427, 435, 440, 440,
145723
- 456, 463, 470, 471, 478, 479, 483, 491, 495, 499, 503, 507, 509,
145724
- 515, 520, 528, 531, 536, 541, 547, 551, 556,
149336
+ 199, 204, 209, 212, 218, 221, 225, 230, 236, 242, 245, 247, 248,
149337
+ 252, 258, 262, 269, 275, 287, 293, 302, 304, 310, 314, 319, 321,
149338
+ 328, 333, 338, 344, 350, 355, 358, 358, 358, 361, 365, 368, 377,
149339
+ 381, 387, 389, 396, 398, 400, 409, 413, 419, 425, 433, 438, 438,
149340
+ 438, 454, 463, 470, 471, 478, 481, 490, 494, 499, 506, 515, 519,
149341
+ 523, 525, 531, 535, 543, 546, 551, 559, 559, 563, 572, 577, 582,
149342
+ 588, 591, 594, 597, 602, 606,
145725149343
};
145726149344
/* aKWCode[i] is the parser symbol code for the i-th keyword */
145727
-static const unsigned char aKWCode[126] = {
149345
+static const unsigned char aKWCode[136] = {
145728149346
TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
145729149347
TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
145730149348
TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
145731149349
TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
145732149350
TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
@@ -145734,25 +149352,27 @@
145734149352
TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
145735149353
TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
145736149354
TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
145737149355
TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
145738149356
TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
145739
- TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RECURSIVE, TK_BETWEEN,
149357
+ TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RANGE, TK_BETWEEN,
145740149358
TK_NOTHING, TK_LIKE_KW, TK_BY, TK_CASCADE, TK_ASC,
145741149359
TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW,
145742149360
TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_LIKE_KW,
145743149361
TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT,
145744149362
TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_NOTNULL,
145745
- TK_NOT, TK_NO, TK_NULL, TK_WHERE, TK_RENAME,
145746
- TK_AFTER, TK_REPLACE, TK_AND, TK_DEFAULT, TK_AUTOINCR,
149363
+ TK_NOT, TK_NO, TK_NULL, TK_WHERE, TK_RECURSIVE,
149364
+ TK_AFTER, TK_RENAME, TK_AND, TK_DEFAULT, TK_AUTOINCR,
145747149365
TK_TO, TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT,
145748
- TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_PRIMARY,
145749
- TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DO, TK_ORDER,
145750
- TK_RESTRICT, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW,
145751
- TK_IF, TK_ISNULL, TK_JOIN_KW, TK_ROLLBACK, TK_ROW,
145752
- TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY,
145753
- TK_ALL,
149366
+ TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT,
149367
+ TK_PARTITION, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP,
149368
+ TK_PRECEDING, TK_FAIL, TK_FILTER, TK_REPLACE, TK_FOLLOWING,
149369
+ TK_FROM, TK_JOIN_KW, TK_IF, TK_ISNULL, TK_ORDER,
149370
+ TK_RESTRICT, TK_OVER, TK_JOIN_KW, TK_ROLLBACK, TK_ROWS,
149371
+ TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING, TK_VACUUM,
149372
+ TK_VIEW, TK_WINDOW, TK_DO, TK_INITIALLY, TK_ALL,
149373
+ TK_PRIMARY,
145754149374
};
145755149375
/* Check to see if z[0..n-1] is a keyword. If it is, write the
145756149376
** parser symbol code for that keyword into *pType. Always
145757149377
** return the integer n (the length of the token). */
145758149378
static int keywordCode(const char *z, int n, int *pType){
@@ -145827,11 +149447,11 @@
145827149447
testcase( i==53 ); /* HAVING */
145828149448
testcase( i==54 ); /* GROUP */
145829149449
testcase( i==55 ); /* UPDATE */
145830149450
testcase( i==56 ); /* BEGIN */
145831149451
testcase( i==57 ); /* INNER */
145832
- testcase( i==58 ); /* RECURSIVE */
149452
+ testcase( i==58 ); /* RANGE */
145833149453
testcase( i==59 ); /* BETWEEN */
145834149454
testcase( i==60 ); /* NOTHING */
145835149455
testcase( i==61 ); /* GLOB */
145836149456
testcase( i==62 ); /* BY */
145837149457
testcase( i==63 ); /* CASCADE */
@@ -145858,13 +149478,13 @@
145858149478
testcase( i==84 ); /* NOTNULL */
145859149479
testcase( i==85 ); /* NOT */
145860149480
testcase( i==86 ); /* NO */
145861149481
testcase( i==87 ); /* NULL */
145862149482
testcase( i==88 ); /* WHERE */
145863
- testcase( i==89 ); /* RENAME */
149483
+ testcase( i==89 ); /* RECURSIVE */
145864149484
testcase( i==90 ); /* AFTER */
145865
- testcase( i==91 ); /* REPLACE */
149485
+ testcase( i==91 ); /* RENAME */
145866149486
testcase( i==92 ); /* AND */
145867149487
testcase( i==93 ); /* DEFAULT */
145868149488
testcase( i==94 ); /* AUTOINCREMENT */
145869149489
testcase( i==95 ); /* TO */
145870149490
testcase( i==96 ); /* IN */
@@ -145873,32 +149493,42 @@
145873149493
testcase( i==99 ); /* COMMIT */
145874149494
testcase( i==100 ); /* CONFLICT */
145875149495
testcase( i==101 ); /* CROSS */
145876149496
testcase( i==102 ); /* CURRENT_TIMESTAMP */
145877149497
testcase( i==103 ); /* CURRENT_TIME */
145878
- testcase( i==104 ); /* PRIMARY */
145879
- testcase( i==105 ); /* DEFERRED */
145880
- testcase( i==106 ); /* DISTINCT */
145881
- testcase( i==107 ); /* IS */
145882
- testcase( i==108 ); /* DO */
145883
- testcase( i==109 ); /* ORDER */
145884
- testcase( i==110 ); /* RESTRICT */
145885
- testcase( i==111 ); /* DROP */
145886
- testcase( i==112 ); /* FAIL */
145887
- testcase( i==113 ); /* FROM */
145888
- testcase( i==114 ); /* FULL */
145889
- testcase( i==115 ); /* IF */
145890
- testcase( i==116 ); /* ISNULL */
145891
- testcase( i==117 ); /* RIGHT */
145892
- testcase( i==118 ); /* ROLLBACK */
145893
- testcase( i==119 ); /* ROW */
145894
- testcase( i==120 ); /* UNION */
145895
- testcase( i==121 ); /* USING */
145896
- testcase( i==122 ); /* VACUUM */
145897
- testcase( i==123 ); /* VIEW */
145898
- testcase( i==124 ); /* INITIALLY */
145899
- testcase( i==125 ); /* ALL */
149498
+ testcase( i==104 ); /* CURRENT */
149499
+ testcase( i==105 ); /* PARTITION */
149500
+ testcase( i==106 ); /* DEFERRED */
149501
+ testcase( i==107 ); /* DISTINCT */
149502
+ testcase( i==108 ); /* IS */
149503
+ testcase( i==109 ); /* DROP */
149504
+ testcase( i==110 ); /* PRECEDING */
149505
+ testcase( i==111 ); /* FAIL */
149506
+ testcase( i==112 ); /* FILTER */
149507
+ testcase( i==113 ); /* REPLACE */
149508
+ testcase( i==114 ); /* FOLLOWING */
149509
+ testcase( i==115 ); /* FROM */
149510
+ testcase( i==116 ); /* FULL */
149511
+ testcase( i==117 ); /* IF */
149512
+ testcase( i==118 ); /* ISNULL */
149513
+ testcase( i==119 ); /* ORDER */
149514
+ testcase( i==120 ); /* RESTRICT */
149515
+ testcase( i==121 ); /* OVER */
149516
+ testcase( i==122 ); /* RIGHT */
149517
+ testcase( i==123 ); /* ROLLBACK */
149518
+ testcase( i==124 ); /* ROWS */
149519
+ testcase( i==125 ); /* ROW */
149520
+ testcase( i==126 ); /* UNBOUNDED */
149521
+ testcase( i==127 ); /* UNION */
149522
+ testcase( i==128 ); /* USING */
149523
+ testcase( i==129 ); /* VACUUM */
149524
+ testcase( i==130 ); /* VIEW */
149525
+ testcase( i==131 ); /* WINDOW */
149526
+ testcase( i==132 ); /* DO */
149527
+ testcase( i==133 ); /* INITIALLY */
149528
+ testcase( i==134 ); /* ALL */
149529
+ testcase( i==135 ); /* PRIMARY */
145900149530
*pType = aKWCode[i];
145901149531
break;
145902149532
}
145903149533
}
145904149534
return n;
@@ -145906,11 +149536,11 @@
145906149536
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
145907149537
int id = TK_ID;
145908149538
keywordCode((char*)z, n, &id);
145909149539
return id;
145910149540
}
145911
-#define SQLITE_N_KEYWORD 126
149541
+#define SQLITE_N_KEYWORD 136
145912149542
SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
145913149543
if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
145914149544
*pzName = zKWText + aKWOffset[i];
145915149545
*pnName = aKWLen[i];
145916149546
return SQLITE_OK;
@@ -145965,10 +149595,86 @@
145965149595
/* Make the IdChar function accessible from ctime.c */
145966149596
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
145967149597
SQLITE_PRIVATE int sqlite3IsIdChar(u8 c){ return IdChar(c); }
145968149598
#endif
145969149599
149600
+#ifndef SQLITE_OMIT_WINDOWFUNC
149601
+/*
149602
+** Return the id of the next token in string (*pz). Before returning, set
149603
+** (*pz) to point to the byte following the parsed token.
149604
+*/
149605
+static int getToken(const unsigned char **pz){
149606
+ const unsigned char *z = *pz;
149607
+ int t; /* Token type to return */
149608
+ do {
149609
+ z += sqlite3GetToken(z, &t);
149610
+ }while( t==TK_SPACE );
149611
+ if( t==TK_ID
149612
+ || t==TK_STRING
149613
+ || t==TK_JOIN_KW
149614
+ || t==TK_WINDOW
149615
+ || t==TK_OVER
149616
+ || sqlite3ParserFallback(t)==TK_ID
149617
+ ){
149618
+ t = TK_ID;
149619
+ }
149620
+ *pz = z;
149621
+ return t;
149622
+}
149623
+
149624
+/*
149625
+** The following three functions are called immediately after the tokenizer
149626
+** reads the keywords WINDOW, OVER and FILTER, respectively, to determine
149627
+** whether the token should be treated as a keyword or an SQL identifier.
149628
+** This cannot be handled by the usual lemon %fallback method, due to
149629
+** the ambiguity in some constructions. e.g.
149630
+**
149631
+** SELECT sum(x) OVER ...
149632
+**
149633
+** In the above, "OVER" might be a keyword, or it might be an alias for the
149634
+** sum(x) expression. If a "%fallback ID OVER" directive were added to
149635
+** grammar, then SQLite would always treat "OVER" as an alias, making it
149636
+** impossible to call a window-function without a FILTER clause.
149637
+**
149638
+** WINDOW is treated as a keyword if:
149639
+**
149640
+** * the following token is an identifier, or a keyword that can fallback
149641
+** to being an identifier, and
149642
+** * the token after than one is TK_AS.
149643
+**
149644
+** OVER is a keyword if:
149645
+**
149646
+** * the previous token was TK_RP, and
149647
+** * the next token is either TK_LP or an identifier.
149648
+**
149649
+** FILTER is a keyword if:
149650
+**
149651
+** * the previous token was TK_RP, and
149652
+** * the next token is TK_LP.
149653
+*/
149654
+static int analyzeWindowKeyword(const unsigned char *z){
149655
+ int t;
149656
+ t = getToken(&z);
149657
+ if( t!=TK_ID ) return TK_ID;
149658
+ t = getToken(&z);
149659
+ if( t!=TK_AS ) return TK_ID;
149660
+ return TK_WINDOW;
149661
+}
149662
+static int analyzeOverKeyword(const unsigned char *z, int lastToken){
149663
+ if( lastToken==TK_RP ){
149664
+ int t = getToken(&z);
149665
+ if( t==TK_LP || t==TK_ID ) return TK_OVER;
149666
+ }
149667
+ return TK_ID;
149668
+}
149669
+static int analyzeFilterKeyword(const unsigned char *z, int lastToken){
149670
+ if( lastToken==TK_RP && getToken(&z)==TK_LP ){
149671
+ return TK_FILTER;
149672
+ }
149673
+ return TK_ID;
149674
+}
149675
+#endif /* SQLITE_OMIT_WINDOWFUNC */
145970149676
145971149677
/*
145972149678
** Return the length (in bytes) of the token that begins at z[0].
145973149679
** Store the token type in *tokenType before returning.
145974149680
*/
@@ -146233,10 +149939,14 @@
146233149939
}
146234149940
case CC_ID: {
146235149941
i = 1;
146236149942
break;
146237149943
}
149944
+ case CC_NUL: {
149945
+ *tokenType = TK_ILLEGAL;
149946
+ return 0;
149947
+ }
146238149948
default: {
146239149949
*tokenType = TK_ILLEGAL;
146240149950
return 1;
146241149951
}
146242149952
}
@@ -146286,51 +149996,68 @@
146286149996
assert( pParse->pNewTable==0 );
146287149997
assert( pParse->pNewTrigger==0 );
146288149998
assert( pParse->nVar==0 );
146289149999
assert( pParse->pVList==0 );
146290150000
while( 1 ){
146291
- if( zSql[0]!=0 ){
146292
- n = sqlite3GetToken((u8*)zSql, &tokenType);
146293
- mxSqlLen -= n;
146294
- if( mxSqlLen<0 ){
146295
- pParse->rc = SQLITE_TOOBIG;
146296
- break;
146297
- }
146298
- }else{
146299
- /* Upon reaching the end of input, call the parser two more times
146300
- ** with tokens TK_SEMI and 0, in that order. */
146301
- if( lastTokenParsed==TK_SEMI ){
146302
- tokenType = 0;
146303
- }else if( lastTokenParsed==0 ){
146304
- break;
146305
- }else{
146306
- tokenType = TK_SEMI;
146307
- }
146308
- n = 0;
146309
- }
150001
+ n = sqlite3GetToken((u8*)zSql, &tokenType);
150002
+ mxSqlLen -= n;
150003
+ if( mxSqlLen<0 ){
150004
+ pParse->rc = SQLITE_TOOBIG;
150005
+ break;
150006
+ }
150007
+#ifndef SQLITE_OMIT_WINDOWFUNC
150008
+ if( tokenType>=TK_WINDOW ){
150009
+ assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER
150010
+ || tokenType==TK_ILLEGAL || tokenType==TK_WINDOW
150011
+ );
150012
+#else
146310150013
if( tokenType>=TK_SPACE ){
146311150014
assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );
150015
+#endif /* SQLITE_OMIT_WINDOWFUNC */
146312150016
if( db->u1.isInterrupted ){
146313150017
pParse->rc = SQLITE_INTERRUPT;
146314150018
break;
146315150019
}
146316
- if( tokenType==TK_ILLEGAL ){
150020
+ if( tokenType==TK_SPACE ){
150021
+ zSql += n;
150022
+ continue;
150023
+ }
150024
+ if( zSql[0]==0 ){
150025
+ /* Upon reaching the end of input, call the parser two more times
150026
+ ** with tokens TK_SEMI and 0, in that order. */
150027
+ if( lastTokenParsed==TK_SEMI ){
150028
+ tokenType = 0;
150029
+ }else if( lastTokenParsed==0 ){
150030
+ break;
150031
+ }else{
150032
+ tokenType = TK_SEMI;
150033
+ }
150034
+ n = 0;
150035
+#ifndef SQLITE_OMIT_WINDOWFUNC
150036
+ }else if( tokenType==TK_WINDOW ){
150037
+ assert( n==6 );
150038
+ tokenType = analyzeWindowKeyword((const u8*)&zSql[6]);
150039
+ }else if( tokenType==TK_OVER ){
150040
+ assert( n==4 );
150041
+ tokenType = analyzeOverKeyword((const u8*)&zSql[4], lastTokenParsed);
150042
+ }else if( tokenType==TK_FILTER ){
150043
+ assert( n==6 );
150044
+ tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
150045
+#endif /* SQLITE_OMIT_WINDOWFUNC */
150046
+ }else{
146317150047
sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql);
146318150048
break;
146319150049
}
146320
- zSql += n;
146321
- }else{
146322
- pParse->sLastToken.z = zSql;
146323
- pParse->sLastToken.n = n;
146324
- sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
146325
- lastTokenParsed = tokenType;
146326
- zSql += n;
146327
- if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
146328
- }
150050
+ }
150051
+ pParse->sLastToken.z = zSql;
150052
+ pParse->sLastToken.n = n;
150053
+ sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
150054
+ lastTokenParsed = tokenType;
150055
+ zSql += n;
150056
+ if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
146329150057
}
146330150058
assert( nErr==0 );
146331
- pParse->zTail = zSql;
146332150059
#ifdef YYTRACKMAXSTACKDEPTH
146333150060
sqlite3_mutex_enter(sqlite3MallocMutex());
146334150061
sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK,
146335150062
sqlite3ParserStackPeak(pEngine)
146336150063
);
@@ -146348,14 +150075,16 @@
146348150075
pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
146349150076
}
146350150077
assert( pzErrMsg!=0 );
146351150078
if( pParse->zErrMsg ){
146352150079
*pzErrMsg = pParse->zErrMsg;
146353
- sqlite3_log(pParse->rc, "%s", *pzErrMsg);
150080
+ sqlite3_log(pParse->rc, "%s in \"%s\"",
150081
+ *pzErrMsg, pParse->zTail);
146354150082
pParse->zErrMsg = 0;
146355150083
nErr++;
146356150084
}
150085
+ pParse->zTail = zSql;
146357150086
if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){
146358150087
sqlite3VdbeDelete(pParse->pVdbe);
146359150088
pParse->pVdbe = 0;
146360150089
}
146361150090
#ifndef SQLITE_OMIT_SHARED_CACHE
@@ -148467,23 +152196,27 @@
148467152196
int enc,
148468152197
void *pUserData,
148469152198
void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
148470152199
void (*xStep)(sqlite3_context*,int,sqlite3_value **),
148471152200
void (*xFinal)(sqlite3_context*),
152201
+ void (*xValue)(sqlite3_context*),
152202
+ void (*xInverse)(sqlite3_context*,int,sqlite3_value **),
148472152203
FuncDestructor *pDestructor
148473152204
){
148474152205
FuncDef *p;
148475152206
int nName;
148476152207
int extraFlags;
148477152208
148478152209
assert( sqlite3_mutex_held(db->mutex) );
148479
- if( zFunctionName==0 ||
148480
- (xSFunc && (xFinal || xStep)) ||
148481
- (!xSFunc && (xFinal && !xStep)) ||
148482
- (!xSFunc && (!xFinal && xStep)) ||
148483
- (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) ||
148484
- (255<(nName = sqlite3Strlen30( zFunctionName))) ){
152210
+ assert( xValue==0 || xSFunc==0 );
152211
+ if( zFunctionName==0 /* Must have a valid name */
152212
+ || (xSFunc!=0 && xFinal!=0) /* Not both xSFunc and xFinal */
152213
+ || ((xFinal==0)!=(xStep==0)) /* Both or neither of xFinal and xStep */
152214
+ || ((xValue==0)!=(xInverse==0)) /* Both or neither of xValue, xInverse */
152215
+ || (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG)
152216
+ || (255<(nName = sqlite3Strlen30( zFunctionName)))
152217
+ ){
148485152218
return SQLITE_MISUSE_BKPT;
148486152219
}
148487152220
148488152221
assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
148489152222
extraFlags = enc & SQLITE_DETERMINISTIC;
@@ -148500,14 +152233,14 @@
148500152233
if( enc==SQLITE_UTF16 ){
148501152234
enc = SQLITE_UTF16NATIVE;
148502152235
}else if( enc==SQLITE_ANY ){
148503152236
int rc;
148504152237
rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8|extraFlags,
148505
- pUserData, xSFunc, xStep, xFinal, pDestructor);
152238
+ pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
148506152239
if( rc==SQLITE_OK ){
148507152240
rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE|extraFlags,
148508
- pUserData, xSFunc, xStep, xFinal, pDestructor);
152241
+ pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
148509152242
}
148510152243
if( rc!=SQLITE_OK ){
148511152244
return rc;
148512152245
}
148513152246
enc = SQLITE_UTF16BE;
@@ -148520,11 +152253,11 @@
148520152253
** and there are active VMs, then return SQLITE_BUSY. If a function
148521152254
** is being overridden/deleted but there are no active VMs, allow the
148522152255
** operation to continue but invalidate all precompiled statements.
148523152256
*/
148524152257
p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 0);
148525
- if( p && (p->funcFlags & SQLITE_FUNC_ENCMASK)==enc && p->nArg==nArg ){
152258
+ if( p && (p->funcFlags & SQLITE_FUNC_ENCMASK)==(u32)enc && p->nArg==nArg ){
148526152259
if( db->nVdbeActive ){
148527152260
sqlite3ErrorWithMsg(db, SQLITE_BUSY,
148528152261
"unable to delete/modify user-function due to active statements");
148529152262
assert( !db->mallocFailed );
148530152263
return SQLITE_BUSY;
@@ -148549,42 +152282,36 @@
148549152282
p->u.pDestructor = pDestructor;
148550152283
p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags;
148551152284
testcase( p->funcFlags & SQLITE_DETERMINISTIC );
148552152285
p->xSFunc = xSFunc ? xSFunc : xStep;
148553152286
p->xFinalize = xFinal;
152287
+ p->xValue = xValue;
152288
+ p->xInverse = xInverse;
148554152289
p->pUserData = pUserData;
148555152290
p->nArg = (u16)nArg;
148556152291
return SQLITE_OK;
148557152292
}
148558152293
148559152294
/*
148560
-** Create new user functions.
152295
+** Worker function used by utf-8 APIs that create new functions:
152296
+**
152297
+** sqlite3_create_function()
152298
+** sqlite3_create_function_v2()
152299
+** sqlite3_create_window_function()
148561152300
*/
148562
-SQLITE_API int sqlite3_create_function(
152301
+static int createFunctionApi(
148563152302
sqlite3 *db,
148564152303
const char *zFunc,
148565152304
int nArg,
148566152305
int enc,
148567152306
void *p,
148568
- void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
148569
- void (*xStep)(sqlite3_context*,int,sqlite3_value **),
148570
- void (*xFinal)(sqlite3_context*)
148571
-){
148572
- return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xSFunc, xStep,
148573
- xFinal, 0);
148574
-}
148575
-
148576
-SQLITE_API int sqlite3_create_function_v2(
148577
- sqlite3 *db,
148578
- const char *zFunc,
148579
- int nArg,
148580
- int enc,
148581
- void *p,
148582
- void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
148583
- void (*xStep)(sqlite3_context*,int,sqlite3_value **),
152307
+ void (*xSFunc)(sqlite3_context*,int,sqlite3_value**),
152308
+ void (*xStep)(sqlite3_context*,int,sqlite3_value**),
148584152309
void (*xFinal)(sqlite3_context*),
148585
- void (*xDestroy)(void *)
152310
+ void (*xValue)(sqlite3_context*),
152311
+ void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
152312
+ void(*xDestroy)(void*)
148586152313
){
148587152314
int rc = SQLITE_ERROR;
148588152315
FuncDestructor *pArg = 0;
148589152316
148590152317
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -148602,11 +152329,13 @@
148602152329
}
148603152330
pArg->nRef = 0;
148604152331
pArg->xDestroy = xDestroy;
148605152332
pArg->pUserData = p;
148606152333
}
148607
- rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p, xSFunc, xStep, xFinal, pArg);
152334
+ rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p,
152335
+ xSFunc, xStep, xFinal, xValue, xInverse, pArg
152336
+ );
148608152337
if( pArg && pArg->nRef==0 ){
148609152338
assert( rc!=SQLITE_OK );
148610152339
xDestroy(p);
148611152340
sqlite3_free(pArg);
148612152341
}
@@ -148614,10 +152343,56 @@
148614152343
out:
148615152344
rc = sqlite3ApiExit(db, rc);
148616152345
sqlite3_mutex_leave(db->mutex);
148617152346
return rc;
148618152347
}
152348
+
152349
+/*
152350
+** Create new user functions.
152351
+*/
152352
+SQLITE_API int sqlite3_create_function(
152353
+ sqlite3 *db,
152354
+ const char *zFunc,
152355
+ int nArg,
152356
+ int enc,
152357
+ void *p,
152358
+ void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
152359
+ void (*xStep)(sqlite3_context*,int,sqlite3_value **),
152360
+ void (*xFinal)(sqlite3_context*)
152361
+){
152362
+ return createFunctionApi(db, zFunc, nArg, enc, p, xSFunc, xStep,
152363
+ xFinal, 0, 0, 0);
152364
+}
152365
+SQLITE_API int sqlite3_create_function_v2(
152366
+ sqlite3 *db,
152367
+ const char *zFunc,
152368
+ int nArg,
152369
+ int enc,
152370
+ void *p,
152371
+ void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
152372
+ void (*xStep)(sqlite3_context*,int,sqlite3_value **),
152373
+ void (*xFinal)(sqlite3_context*),
152374
+ void (*xDestroy)(void *)
152375
+){
152376
+ return createFunctionApi(db, zFunc, nArg, enc, p, xSFunc, xStep,
152377
+ xFinal, 0, 0, xDestroy);
152378
+}
152379
+SQLITE_API int sqlite3_create_window_function(
152380
+ sqlite3 *db,
152381
+ const char *zFunc,
152382
+ int nArg,
152383
+ int enc,
152384
+ void *p,
152385
+ void (*xStep)(sqlite3_context*,int,sqlite3_value **),
152386
+ void (*xFinal)(sqlite3_context*),
152387
+ void (*xValue)(sqlite3_context*),
152388
+ void (*xInverse)(sqlite3_context*,int,sqlite3_value **),
152389
+ void (*xDestroy)(void *)
152390
+){
152391
+ return createFunctionApi(db, zFunc, nArg, enc, p, 0, xStep,
152392
+ xFinal, xValue, xInverse, xDestroy);
152393
+}
148619152394
148620152395
#ifndef SQLITE_OMIT_UTF16
148621152396
SQLITE_API int sqlite3_create_function16(
148622152397
sqlite3 *db,
148623152398
const void *zFunctionName,
@@ -148635,11 +152410,11 @@
148635152410
if( !sqlite3SafetyCheckOk(db) || zFunctionName==0 ) return SQLITE_MISUSE_BKPT;
148636152411
#endif
148637152412
sqlite3_mutex_enter(db->mutex);
148638152413
assert( !db->mallocFailed );
148639152414
zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);
148640
- rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xSFunc,xStep,xFinal,0);
152415
+ rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xSFunc,xStep,xFinal,0,0,0);
148641152416
sqlite3DbFree(db, zFunc8);
148642152417
rc = sqlite3ApiExit(db, rc);
148643152418
sqlite3_mutex_leave(db->mutex);
148644152419
return rc;
148645152420
}
@@ -150712,11 +154487,12 @@
150712154487
** Set the VDBE coverage callback function to xCallback with context
150713154488
** pointer ptr.
150714154489
*/
150715154490
case SQLITE_TESTCTRL_VDBE_COVERAGE: {
150716154491
#ifdef SQLITE_VDBE_COVERAGE
150717
- typedef void (*branch_callback)(void*,int,u8,u8);
154492
+ typedef void (*branch_callback)(void*,unsigned int,
154493
+ unsigned char,unsigned char);
150718154494
sqlite3GlobalConfig.xVdbeBranch = va_arg(ap,branch_callback);
150719154495
sqlite3GlobalConfig.pVdbeBranchArg = va_arg(ap,void*);
150720154496
#endif
150721154497
break;
150722154498
}
@@ -150899,11 +154675,11 @@
150899154675
if( db->autoCommit==0 ){
150900154676
int iDb = sqlite3FindDbName(db, zDb);
150901154677
if( iDb==0 || iDb>1 ){
150902154678
Btree *pBt = db->aDb[iDb].pBt;
150903154679
if( 0==sqlite3BtreeIsInTrans(pBt) ){
150904
- rc = sqlite3BtreeBeginTrans(pBt, 0);
154680
+ rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
150905154681
if( rc==SQLITE_OK ){
150906154682
rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
150907154683
}
150908154684
}
150909154685
}
@@ -150937,11 +154713,11 @@
150937154713
if( iDb==0 || iDb>1 ){
150938154714
Btree *pBt = db->aDb[iDb].pBt;
150939154715
if( 0==sqlite3BtreeIsInReadTrans(pBt) ){
150940154716
rc = sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), pSnapshot);
150941154717
if( rc==SQLITE_OK ){
150942
- rc = sqlite3BtreeBeginTrans(pBt, 0);
154718
+ rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
150943154719
sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), 0);
150944154720
}
150945154721
}
150946154722
}
150947154723
}
@@ -150969,11 +154745,11 @@
150969154745
sqlite3_mutex_enter(db->mutex);
150970154746
iDb = sqlite3FindDbName(db, zDb);
150971154747
if( iDb==0 || iDb>1 ){
150972154748
Btree *pBt = db->aDb[iDb].pBt;
150973154749
if( 0==sqlite3BtreeIsInReadTrans(pBt) ){
150974
- rc = sqlite3BtreeBeginTrans(pBt, 0);
154750
+ rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
150975154751
if( rc==SQLITE_OK ){
150976154752
rc = sqlite3PagerSnapshotRecover(sqlite3BtreePager(pBt));
150977154753
sqlite3BtreeCommit(pBt);
150978154754
}
150979154755
}
@@ -182309,11 +186085,11 @@
182309186085
DbpageTable *pTab = (DbpageTable *)pVtab;
182310186086
sqlite3 *db = pTab->db;
182311186087
int i;
182312186088
for(i=0; i<db->nDb; i++){
182313186089
Btree *pBt = db->aDb[i].pBt;
182314
- if( pBt ) sqlite3BtreeBeginTrans(pBt, 1);
186090
+ if( pBt ) sqlite3BtreeBeginTrans(pBt, 1, 0);
182315186091
}
182316186092
return SQLITE_OK;
182317186093
}
182318186094
182319186095
@@ -189536,29 +193312,79 @@
189536193312
pStr->pCtx = ctx;
189537193313
}
189538193314
jsonAppendValue(pStr, argv[0]);
189539193315
}
189540193316
}
189541
-static void jsonArrayFinal(sqlite3_context *ctx){
193317
+static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){
189542193318
JsonString *pStr;
189543193319
pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
189544193320
if( pStr ){
189545193321
pStr->pCtx = ctx;
189546193322
jsonAppendChar(pStr, ']');
189547193323
if( pStr->bErr ){
189548193324
if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);
189549193325
assert( pStr->bStatic );
189550
- }else{
193326
+ }else if( isFinal ){
189551193327
sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,
189552193328
pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);
189553193329
pStr->bStatic = 1;
193330
+ }else{
193331
+ sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, SQLITE_TRANSIENT);
193332
+ pStr->nUsed--;
189554193333
}
189555193334
}else{
189556193335
sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC);
189557193336
}
189558193337
sqlite3_result_subtype(ctx, JSON_SUBTYPE);
189559193338
}
193339
+static void jsonArrayValue(sqlite3_context *ctx){
193340
+ jsonArrayCompute(ctx, 0);
193341
+}
193342
+static void jsonArrayFinal(sqlite3_context *ctx){
193343
+ jsonArrayCompute(ctx, 1);
193344
+}
193345
+
193346
+#ifndef SQLITE_OMIT_WINDOWFUNC
193347
+/*
193348
+** This method works for both json_group_array() and json_group_object().
193349
+** It works by removing the first element of the group by searching forward
193350
+** to the first comma (",") that is not within a string and deleting all
193351
+** text through that comma.
193352
+*/
193353
+static void jsonGroupInverse(
193354
+ sqlite3_context *ctx,
193355
+ int argc,
193356
+ sqlite3_value **argv
193357
+){
193358
+ int i;
193359
+ int inStr = 0;
193360
+ char *z;
193361
+ JsonString *pStr;
193362
+ UNUSED_PARAM(argc);
193363
+ UNUSED_PARAM(argv);
193364
+ pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
193365
+#ifdef NEVER
193366
+ /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will
193367
+ ** always have been called to initalize it */
193368
+ if( NEVER(!pStr) ) return;
193369
+#endif
193370
+ z = pStr->zBuf;
193371
+ for(i=1; z[i]!=',' || inStr; i++){
193372
+ assert( i<pStr->nUsed );
193373
+ if( z[i]=='"' ){
193374
+ inStr = !inStr;
193375
+ }else if( z[i]=='\\' ){
193376
+ i++;
193377
+ }
193378
+ }
193379
+ pStr->nUsed -= i;
193380
+ memmove(&z[1], &z[i+1], pStr->nUsed-1);
193381
+}
193382
+#else
193383
+# define jsonGroupInverse 0
193384
+#endif
193385
+
189560193386
189561193387
/*
189562193388
** json_group_obj(NAME,VALUE)
189563193389
**
189564193390
** Return a JSON object composed of all names and values in the aggregate.
@@ -189586,28 +193412,38 @@
189586193412
jsonAppendString(pStr, z, n);
189587193413
jsonAppendChar(pStr, ':');
189588193414
jsonAppendValue(pStr, argv[1]);
189589193415
}
189590193416
}
189591
-static void jsonObjectFinal(sqlite3_context *ctx){
193417
+static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){
189592193418
JsonString *pStr;
189593193419
pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
189594193420
if( pStr ){
189595193421
jsonAppendChar(pStr, '}');
189596193422
if( pStr->bErr ){
189597193423
if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);
189598193424
assert( pStr->bStatic );
189599
- }else{
193425
+ }else if( isFinal ){
189600193426
sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,
189601193427
pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);
189602193428
pStr->bStatic = 1;
193429
+ }else{
193430
+ sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, SQLITE_TRANSIENT);
193431
+ pStr->nUsed--;
189603193432
}
189604193433
}else{
189605193434
sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC);
189606193435
}
189607193436
sqlite3_result_subtype(ctx, JSON_SUBTYPE);
189608193437
}
193438
+static void jsonObjectValue(sqlite3_context *ctx){
193439
+ jsonObjectCompute(ctx, 0);
193440
+}
193441
+static void jsonObjectFinal(sqlite3_context *ctx){
193442
+ jsonObjectCompute(ctx, 1);
193443
+}
193444
+
189609193445
189610193446
189611193447
#ifndef SQLITE_OMIT_VIRTUALTABLE
189612193448
/****************************************************************************
189613193449
** The json_each virtual table
@@ -190111,13 +193947,16 @@
190111193947
static const struct {
190112193948
const char *zName;
190113193949
int nArg;
190114193950
void (*xStep)(sqlite3_context*,int,sqlite3_value**);
190115193951
void (*xFinal)(sqlite3_context*);
193952
+ void (*xValue)(sqlite3_context*);
190116193953
} aAgg[] = {
190117
- { "json_group_array", 1, jsonArrayStep, jsonArrayFinal },
190118
- { "json_group_object", 2, jsonObjectStep, jsonObjectFinal },
193954
+ { "json_group_array", 1,
193955
+ jsonArrayStep, jsonArrayFinal, jsonArrayValue },
193956
+ { "json_group_object", 2,
193957
+ jsonObjectStep, jsonObjectFinal, jsonObjectValue },
190119193958
};
190120193959
#ifndef SQLITE_OMIT_VIRTUALTABLE
190121193960
static const struct {
190122193961
const char *zName;
190123193962
sqlite3_module *pModule;
@@ -190131,13 +193970,14 @@
190131193970
SQLITE_UTF8 | SQLITE_DETERMINISTIC,
190132193971
(void*)&aFunc[i].flag,
190133193972
aFunc[i].xFunc, 0, 0);
190134193973
}
190135193974
for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
190136
- rc = sqlite3_create_function(db, aAgg[i].zName, aAgg[i].nArg,
193975
+ rc = sqlite3_create_window_function(db, aAgg[i].zName, aAgg[i].nArg,
190137193976
SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
190138
- 0, aAgg[i].xStep, aAgg[i].xFinal);
193977
+ aAgg[i].xStep, aAgg[i].xFinal,
193978
+ aAgg[i].xValue, jsonGroupInverse, 0);
190139193979
}
190140193980
#ifndef SQLITE_OMIT_VIRTUALTABLE
190141193981
for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
190142193982
rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
190143193983
}
@@ -191539,13 +195379,16 @@
191539195379
191540195380
191541195381
/**************************************************************************
191542195382
** Interface to automatically generated code in fts5_unicode2.c.
191543195383
*/
191544
-static int sqlite3Fts5UnicodeIsalnum(int c);
191545195384
static int sqlite3Fts5UnicodeIsdiacritic(int c);
191546195385
static int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);
195386
+
195387
+static int sqlite3Fts5UnicodeCatParse(const char*, u8*);
195388
+static int sqlite3Fts5UnicodeCategory(int iCode);
195389
+static void sqlite3Fts5UnicodeAscii(u8*, u8*);
191547195390
/*
191548195391
** End of interface to code in fts5_unicode2.c.
191549195392
**************************************************************************/
191550195393
191551195394
#endif
@@ -191717,10 +195560,11 @@
191717195560
#define fts5YY_ACCEPT_ACTION 81
191718195561
#define fts5YY_NO_ACTION 82
191719195562
#define fts5YY_MIN_REDUCE 83
191720195563
#define fts5YY_MAX_REDUCE 110
191721195564
/************* End control #defines *******************************************/
195565
+#define fts5YY_NLOOKAHEAD ((int)(sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0])))
191722195566
191723195567
/* Define the fts5yytestcase() macro to be a no-op if is not already defined
191724195568
** otherwise.
191725195569
**
191726195570
** Applications can choose to define fts5yytestcase() in the %include section
@@ -192276,15 +196120,15 @@
192276196120
fts5yycoverage[stateno][iLookAhead] = 1;
192277196121
#endif
192278196122
do{
192279196123
i = fts5yy_shift_ofst[stateno];
192280196124
assert( i>=0 );
192281
- assert( i+fts5YYNFTS5TOKEN<=(int)sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0]) );
196125
+ /* assert( i+fts5YYNFTS5TOKEN<=(int)fts5YY_NLOOKAHEAD ); */
192282196126
assert( iLookAhead!=fts5YYNOCODE );
192283196127
assert( iLookAhead < fts5YYNFTS5TOKEN );
192284196128
i += iLookAhead;
192285
- if( fts5yy_lookahead[i]!=iLookAhead ){
196129
+ if( i>=fts5YY_NLOOKAHEAD || fts5yy_lookahead[i]!=iLookAhead ){
192286196130
#ifdef fts5YYFALLBACK
192287196131
fts5YYCODETYPE iFallback; /* Fallback token */
192288196132
if( iLookAhead<sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])
192289196133
&& (iFallback = fts5yyFallback[iLookAhead])!=0 ){
192290196134
#ifndef NDEBUG
@@ -192306,10 +196150,11 @@
192306196150
j>=0 &&
192307196151
#endif
192308196152
#if fts5YY_SHIFT_MAX+fts5YYWILDCARD>=fts5YY_ACTTAB_COUNT
192309196153
j<fts5YY_ACTTAB_COUNT &&
192310196154
#endif
196155
+ j<(int)(sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0])) &&
192311196156
fts5yy_lookahead[j]==fts5YYWILDCARD && iLookAhead>0
192312196157
){
192313196158
#ifndef NDEBUG
192314196159
if( fts5yyTraceFILE ){
192315196160
fprintf(fts5yyTraceFILE, "%sWILDCARD %s => %s\n",
@@ -192986,10 +196831,25 @@
192986196831
fprintf(fts5yyTraceFILE,"]\n");
192987196832
}
192988196833
#endif
192989196834
return;
192990196835
}
196836
+
196837
+/*
196838
+** Return the fallback token corresponding to canonical token iToken, or
196839
+** 0 if iToken has no fallback.
196840
+*/
196841
+static int sqlite3Fts5ParserFallback(int iToken){
196842
+#ifdef fts5YYFALLBACK
196843
+ if( iToken<(int)(sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])) ){
196844
+ return fts5yyFallback[iToken];
196845
+ }
196846
+#else
196847
+ (void)iToken;
196848
+#endif
196849
+ return 0;
196850
+}
192991196851
192992196852
/*
192993196853
** 2014 May 31
192994196854
**
192995196855
** The author disclaims copyright to this source code. In place of
@@ -195097,10 +198957,11 @@
195097198957
static void sqlite3Fts5Parser(void*, int, Fts5Token, Fts5Parse*);
195098198958
#ifndef NDEBUG
195099198959
/* #include <stdio.h> */
195100198960
static void sqlite3Fts5ParserTrace(FILE*, char*);
195101198961
#endif
198962
+static int sqlite3Fts5ParserFallback(int);
195102198963
195103198964
195104198965
struct Fts5Expr {
195105198966
Fts5Index *pIndex;
195106198967
Fts5Config *pConfig;
@@ -197601,18 +201462,23 @@
197601201462
sqlite3_context *pCtx, /* Function call context */
197602201463
int nArg, /* Number of args */
197603201464
sqlite3_value **apVal /* Function arguments */
197604201465
){
197605201466
int iCode;
201467
+ u8 aArr[32];
197606201468
if( nArg!=1 ){
197607201469
sqlite3_result_error(pCtx,
197608201470
"wrong number of arguments to function fts5_isalnum", -1
197609201471
);
197610201472
return;
197611201473
}
201474
+ memset(aArr, 0, sizeof(aArr));
201475
+ sqlite3Fts5UnicodeCatParse("L*", aArr);
201476
+ sqlite3Fts5UnicodeCatParse("N*", aArr);
201477
+ sqlite3Fts5UnicodeCatParse("Co", aArr);
197612201478
iCode = sqlite3_value_int(apVal[0]);
197613
- sqlite3_result_int(pCtx, sqlite3Fts5UnicodeIsalnum(iCode));
201479
+ sqlite3_result_int(pCtx, aArr[sqlite3Fts5UnicodeCategory(iCode)]);
197614201480
}
197615201481
197616201482
static void fts5ExprFold(
197617201483
sqlite3_context *pCtx, /* Function call context */
197618201484
int nArg, /* Number of args */
@@ -197652,14 +201518,16 @@
197652201518
for(i=0; rc==SQLITE_OK && i<ArraySize(aFunc); i++){
197653201519
struct Fts5ExprFunc *p = &aFunc[i];
197654201520
rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0);
197655201521
}
197656201522
197657
- /* Avoid a warning indicating that sqlite3Fts5ParserTrace() is unused */
201523
+ /* Avoid warnings indicating that sqlite3Fts5ParserTrace() and
201524
+ ** sqlite3Fts5ParserFallback() are unused */
197658201525
#ifndef NDEBUG
197659201526
(void)sqlite3Fts5ParserTrace;
197660201527
#endif
201528
+ (void)sqlite3Fts5ParserFallback;
197661201529
197662201530
return rc;
197663201531
}
197664201532
197665201533
/*
@@ -207583,11 +211451,11 @@
207583211451
int nArg, /* Number of args */
207584211452
sqlite3_value **apUnused /* Function arguments */
207585211453
){
207586211454
assert( nArg==0 );
207587211455
UNUSED_PARAM2(nArg, apUnused);
207588
- sqlite3_result_text(pCtx, "fts5: 2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca", -1, SQLITE_TRANSIENT);
211456
+ sqlite3_result_text(pCtx, "fts5: 2018-07-13 20:28:54 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb36212426b1", -1, SQLITE_TRANSIENT);
207589211457
}
207590211458
207591211459
static int fts5Init(sqlite3 *db){
207592211460
static const sqlite3_module fts5Mod = {
207593211461
/* iVersion */ 2,
@@ -209071,10 +212939,12 @@
209071212939
char *aFold; /* Buffer to fold text into */
209072212940
int nFold; /* Size of aFold[] in bytes */
209073212941
int bRemoveDiacritic; /* True if remove_diacritics=1 is set */
209074212942
int nException;
209075212943
int *aiException;
212944
+
212945
+ unsigned char aCategory[32]; /* True for token char categories */
209076212946
};
209077212947
209078212948
static int fts5UnicodeAddExceptions(
209079212949
Unicode61Tokenizer *p, /* Tokenizer object */
209080212950
const char *z, /* Characters to treat as exceptions */
@@ -209095,11 +212965,11 @@
209095212965
int bToken;
209096212966
READ_UTF8(zCsr, zTerm, iCode);
209097212967
if( iCode<128 ){
209098212968
p->aTokenChar[iCode] = (unsigned char)bTokenChars;
209099212969
}else{
209100
- bToken = sqlite3Fts5UnicodeIsalnum(iCode);
212970
+ bToken = p->aCategory[sqlite3Fts5UnicodeCategory(iCode)];
209101212971
assert( (bToken==0 || bToken==1) );
209102212972
assert( (bTokenChars==0 || bTokenChars==1) );
209103212973
if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){
209104212974
int i;
209105212975
for(i=0; i<nNew; i++){
@@ -209155,10 +213025,25 @@
209155213025
sqlite3_free(p->aFold);
209156213026
sqlite3_free(p);
209157213027
}
209158213028
return;
209159213029
}
213030
+
213031
+static int unicodeSetCategories(Unicode61Tokenizer *p, const char *zCat){
213032
+ const char *z = zCat;
213033
+
213034
+ while( *z ){
213035
+ while( *z==' ' || *z=='\t' ) z++;
213036
+ if( *z && sqlite3Fts5UnicodeCatParse(z, p->aCategory) ){
213037
+ return SQLITE_ERROR;
213038
+ }
213039
+ while( *z!=' ' && *z!='\t' && *z!='\0' ) z++;
213040
+ }
213041
+
213042
+ sqlite3Fts5UnicodeAscii(p->aCategory, p->aTokenChar);
213043
+ return SQLITE_OK;
213044
+}
209160213045
209161213046
/*
209162213047
** Create a "unicode61" tokenizer.
209163213048
*/
209164213049
static int fts5UnicodeCreate(
@@ -209174,19 +213059,32 @@
209174213059
if( nArg%2 ){
209175213060
rc = SQLITE_ERROR;
209176213061
}else{
209177213062
p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer));
209178213063
if( p ){
213064
+ const char *zCat = "L* N* Co";
209179213065
int i;
209180213066
memset(p, 0, sizeof(Unicode61Tokenizer));
209181
- memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar));
213067
+
209182213068
p->bRemoveDiacritic = 1;
209183213069
p->nFold = 64;
209184213070
p->aFold = sqlite3_malloc(p->nFold * sizeof(char));
209185213071
if( p->aFold==0 ){
209186213072
rc = SQLITE_NOMEM;
209187213073
}
213074
+
213075
+ /* Search for a "categories" argument */
213076
+ for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
213077
+ if( 0==sqlite3_stricmp(azArg[i], "categories") ){
213078
+ zCat = azArg[i+1];
213079
+ }
213080
+ }
213081
+
213082
+ if( rc==SQLITE_OK ){
213083
+ rc = unicodeSetCategories(p, zCat);
213084
+ }
213085
+
209188213086
for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
209189213087
const char *zArg = azArg[i+1];
209190213088
if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){
209191213089
if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1] ){
209192213090
rc = SQLITE_ERROR;
@@ -209196,14 +213094,18 @@
209196213094
if( 0==sqlite3_stricmp(azArg[i], "tokenchars") ){
209197213095
rc = fts5UnicodeAddExceptions(p, zArg, 1);
209198213096
}else
209199213097
if( 0==sqlite3_stricmp(azArg[i], "separators") ){
209200213098
rc = fts5UnicodeAddExceptions(p, zArg, 0);
213099
+ }else
213100
+ if( 0==sqlite3_stricmp(azArg[i], "categories") ){
213101
+ /* no-op */
209201213102
}else{
209202213103
rc = SQLITE_ERROR;
209203213104
}
209204213105
}
213106
+
209205213107
}else{
209206213108
rc = SQLITE_NOMEM;
209207213109
}
209208213110
if( rc!=SQLITE_OK ){
209209213111
fts5UnicodeDelete((Fts5Tokenizer*)p);
@@ -209218,12 +213120,14 @@
209218213120
** Return true if, for the purposes of tokenizing with the tokenizer
209219213121
** passed as the first argument, codepoint iCode is considered a token
209220213122
** character (not a separator).
209221213123
*/
209222213124
static int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){
209223
- assert( (sqlite3Fts5UnicodeIsalnum(iCode) & 0xFFFFFFFE)==0 );
209224
- return sqlite3Fts5UnicodeIsalnum(iCode) ^ fts5UnicodeIsException(p, iCode);
213125
+ return (
213126
+ p->aCategory[sqlite3Fts5UnicodeCategory(iCode)]
213127
+ ^ fts5UnicodeIsException(p, iCode)
213128
+ );
209225213129
}
209226213130
209227213131
static int fts5UnicodeTokenize(
209228213132
Fts5Tokenizer *pTokenizer,
209229213133
void *pCtx,
@@ -210095,139 +213999,10 @@
210095213999
*/
210096214000
210097214001
210098214002
/* #include <assert.h> */
210099214003
210100
-/*
210101
-** Return true if the argument corresponds to a unicode codepoint
210102
-** classified as either a letter or a number. Otherwise false.
210103
-**
210104
-** The results are undefined if the value passed to this function
210105
-** is less than zero.
210106
-*/
210107
-static int sqlite3Fts5UnicodeIsalnum(int c){
210108
- /* Each unsigned integer in the following array corresponds to a contiguous
210109
- ** range of unicode codepoints that are not either letters or numbers (i.e.
210110
- ** codepoints for which this function should return 0).
210111
- **
210112
- ** The most significant 22 bits in each 32-bit value contain the first
210113
- ** codepoint in the range. The least significant 10 bits are used to store
210114
- ** the size of the range (always at least 1). In other words, the value
210115
- ** ((C<<22) + N) represents a range of N codepoints starting with codepoint
210116
- ** C. It is not possible to represent a range larger than 1023 codepoints
210117
- ** using this format.
210118
- */
210119
- static const unsigned int aEntry[] = {
210120
- 0x00000030, 0x0000E807, 0x00016C06, 0x0001EC2F, 0x0002AC07,
210121
- 0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01,
210122
- 0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401,
210123
- 0x000BBC81, 0x000DD401, 0x000DF801, 0x000E1002, 0x000E1C01,
210124
- 0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163C01,
210125
- 0x00164437, 0x0017CC02, 0x00180005, 0x00181816, 0x00187802,
210126
- 0x00192C15, 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F,
210127
- 0x001B9C07, 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401,
210128
- 0x001CC01B, 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804,
210129
- 0x00206C09, 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403,
210130
- 0x00217801, 0x0023901B, 0x00240004, 0x0024E803, 0x0024F812,
210131
- 0x00254407, 0x00258804, 0x0025C001, 0x00260403, 0x0026F001,
210132
- 0x0026F807, 0x00271C02, 0x00272C03, 0x00275C01, 0x00278802,
210133
- 0x0027C802, 0x0027E802, 0x00280403, 0x0028F001, 0x0028F805,
210134
- 0x00291C02, 0x00292C03, 0x00294401, 0x0029C002, 0x0029D401,
210135
- 0x002A0403, 0x002AF001, 0x002AF808, 0x002B1C03, 0x002B2C03,
210136
- 0x002B8802, 0x002BC002, 0x002C0403, 0x002CF001, 0x002CF807,
210137
- 0x002D1C02, 0x002D2C03, 0x002D5802, 0x002D8802, 0x002DC001,
210138
- 0x002E0801, 0x002EF805, 0x002F1803, 0x002F2804, 0x002F5C01,
210139
- 0x002FCC08, 0x00300403, 0x0030F807, 0x00311803, 0x00312804,
210140
- 0x00315402, 0x00318802, 0x0031FC01, 0x00320802, 0x0032F001,
210141
- 0x0032F807, 0x00331803, 0x00332804, 0x00335402, 0x00338802,
210142
- 0x00340802, 0x0034F807, 0x00351803, 0x00352804, 0x00355C01,
210143
- 0x00358802, 0x0035E401, 0x00360802, 0x00372801, 0x00373C06,
210144
- 0x00375801, 0x00376008, 0x0037C803, 0x0038C401, 0x0038D007,
210145
- 0x0038FC01, 0x00391C09, 0x00396802, 0x003AC401, 0x003AD006,
210146
- 0x003AEC02, 0x003B2006, 0x003C041F, 0x003CD00C, 0x003DC417,
210147
- 0x003E340B, 0x003E6424, 0x003EF80F, 0x003F380D, 0x0040AC14,
210148
- 0x00412806, 0x00415804, 0x00417803, 0x00418803, 0x00419C07,
210149
- 0x0041C404, 0x0042080C, 0x00423C01, 0x00426806, 0x0043EC01,
210150
- 0x004D740C, 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001,
210151
- 0x005A6C02, 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802,
210152
- 0x005DC802, 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F,
210153
- 0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002,
210154
- 0x0066C011, 0x00672002, 0x00677822, 0x00685C05, 0x00687802,
210155
- 0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, 0x006AA006,
210156
- 0x006C0005, 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D,
210157
- 0x006F980E, 0x006FF004, 0x00709014, 0x0070EC05, 0x0071F802,
210158
- 0x00730008, 0x00734019, 0x0073B401, 0x0073C803, 0x00770027,
210159
- 0x0077F004, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403,
210160
- 0x007FB403, 0x007FF402, 0x00800065, 0x0081A806, 0x0081E805,
210161
- 0x00822805, 0x0082801A, 0x00834021, 0x00840002, 0x00840C04,
210162
- 0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401,
210163
- 0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005,
210164
- 0x00852804, 0x00853C01, 0x00864264, 0x00900027, 0x0091000B,
210165
- 0x0092704E, 0x00940200, 0x009C0475, 0x009E53B9, 0x00AD400A,
210166
- 0x00B39406, 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001,
210167
- 0x00B5FC01, 0x00B7804F, 0x00B8C00C, 0x00BA001A, 0x00BA6C59,
210168
- 0x00BC00D6, 0x00BFC00C, 0x00C00005, 0x00C02019, 0x00C0A807,
210169
- 0x00C0D802, 0x00C0F403, 0x00C26404, 0x00C28001, 0x00C3EC01,
210170
- 0x00C64002, 0x00C6580A, 0x00C70024, 0x00C8001F, 0x00C8A81E,
210171
- 0x00C94001, 0x00C98020, 0x00CA2827, 0x00CB003F, 0x00CC0100,
210172
- 0x01370040, 0x02924037, 0x0293F802, 0x02983403, 0x0299BC10,
210173
- 0x029A7C01, 0x029BC008, 0x029C0017, 0x029C8002, 0x029E2402,
210174
- 0x02A00801, 0x02A01801, 0x02A02C01, 0x02A08C09, 0x02A0D804,
210175
- 0x02A1D004, 0x02A20002, 0x02A2D011, 0x02A33802, 0x02A38012,
210176
- 0x02A3E003, 0x02A4980A, 0x02A51C0D, 0x02A57C01, 0x02A60004,
210177
- 0x02A6CC1B, 0x02A77802, 0x02A8A40E, 0x02A90C01, 0x02A93002,
210178
- 0x02A97004, 0x02A9DC03, 0x02A9EC01, 0x02AAC001, 0x02AAC803,
210179
- 0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07,
210180
- 0x02ABD402, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02,
210181
- 0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802,
210182
- 0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023, 0x03F95013,
210183
- 0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06,
210184
- 0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003,
210185
- 0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E, 0x040E7C01,
210186
- 0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01, 0x04280403,
210187
- 0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009,
210188
- 0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016, 0x04420003,
210189
- 0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, 0x04460003,
210190
- 0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004, 0x05BD442E,
210191
- 0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5, 0x07480046,
210192
- 0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401,
210193
- 0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401,
210194
- 0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064, 0x07C2800F,
210195
- 0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F, 0x07C4C03C,
210196
- 0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, 0x07C94002,
210197
- 0x07CC0021, 0x07CCC006, 0x07CCDC46, 0x07CE0014, 0x07CE8025,
210198
- 0x07CF1805, 0x07CF8011, 0x07D0003F, 0x07D10001, 0x07D108B6,
210199
- 0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018, 0x07D7EC46,
210200
- 0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401, 0x38008060,
210201
- 0x380400F0,
210202
- };
210203
- static const unsigned int aAscii[4] = {
210204
- 0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001,
210205
- };
210206
-
210207
- if( (unsigned int)c<128 ){
210208
- return ( (aAscii[c >> 5] & (1 << (c & 0x001F)))==0 );
210209
- }else if( (unsigned int)c<(1<<22) ){
210210
- unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;
210211
- int iRes = 0;
210212
- int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;
210213
- int iLo = 0;
210214
- while( iHi>=iLo ){
210215
- int iTest = (iHi + iLo) / 2;
210216
- if( key >= aEntry[iTest] ){
210217
- iRes = iTest;
210218
- iLo = iTest+1;
210219
- }else{
210220
- iHi = iTest-1;
210221
- }
210222
- }
210223
- assert( aEntry[0]<key );
210224
- assert( key>=aEntry[iRes] );
210225
- return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));
210226
- }
210227
- return 1;
210228
-}
210229214004
210230214005
210231214006
/*
210232214007
** If the argument is a codepoint corresponding to a lowercase letter
210233214008
** in the ASCII range with a diacritic added, return the codepoint
@@ -210435,10 +214210,543 @@
210435214210
ret = c + 40;
210436214211
}
210437214212
210438214213
return ret;
210439214214
}
214215
+
214216
+
214217
+#if 0
214218
+static int sqlite3Fts5UnicodeNCat(void) {
214219
+ return 32;
214220
+}
214221
+#endif
214222
+
214223
+static int sqlite3Fts5UnicodeCatParse(const char *zCat, u8 *aArray){
214224
+ aArray[0] = 1;
214225
+ switch( zCat[0] ){
214226
+ case 'C':
214227
+ switch( zCat[1] ){
214228
+ case 'c': aArray[1] = 1; break;
214229
+ case 'f': aArray[2] = 1; break;
214230
+ case 'n': aArray[3] = 1; break;
214231
+ case 's': aArray[4] = 1; break;
214232
+ case 'o': aArray[31] = 1; break;
214233
+ case '*':
214234
+ aArray[1] = 1;
214235
+ aArray[2] = 1;
214236
+ aArray[3] = 1;
214237
+ aArray[4] = 1;
214238
+ aArray[31] = 1;
214239
+ break;
214240
+ default: return 1; }
214241
+ break;
214242
+
214243
+ case 'L':
214244
+ switch( zCat[1] ){
214245
+ case 'l': aArray[5] = 1; break;
214246
+ case 'm': aArray[6] = 1; break;
214247
+ case 'o': aArray[7] = 1; break;
214248
+ case 't': aArray[8] = 1; break;
214249
+ case 'u': aArray[9] = 1; break;
214250
+ case 'C': aArray[30] = 1; break;
214251
+ case '*':
214252
+ aArray[5] = 1;
214253
+ aArray[6] = 1;
214254
+ aArray[7] = 1;
214255
+ aArray[8] = 1;
214256
+ aArray[9] = 1;
214257
+ aArray[30] = 1;
214258
+ break;
214259
+ default: return 1; }
214260
+ break;
214261
+
214262
+ case 'M':
214263
+ switch( zCat[1] ){
214264
+ case 'c': aArray[10] = 1; break;
214265
+ case 'e': aArray[11] = 1; break;
214266
+ case 'n': aArray[12] = 1; break;
214267
+ case '*':
214268
+ aArray[10] = 1;
214269
+ aArray[11] = 1;
214270
+ aArray[12] = 1;
214271
+ break;
214272
+ default: return 1; }
214273
+ break;
214274
+
214275
+ case 'N':
214276
+ switch( zCat[1] ){
214277
+ case 'd': aArray[13] = 1; break;
214278
+ case 'l': aArray[14] = 1; break;
214279
+ case 'o': aArray[15] = 1; break;
214280
+ case '*':
214281
+ aArray[13] = 1;
214282
+ aArray[14] = 1;
214283
+ aArray[15] = 1;
214284
+ break;
214285
+ default: return 1; }
214286
+ break;
214287
+
214288
+ case 'P':
214289
+ switch( zCat[1] ){
214290
+ case 'c': aArray[16] = 1; break;
214291
+ case 'd': aArray[17] = 1; break;
214292
+ case 'e': aArray[18] = 1; break;
214293
+ case 'f': aArray[19] = 1; break;
214294
+ case 'i': aArray[20] = 1; break;
214295
+ case 'o': aArray[21] = 1; break;
214296
+ case 's': aArray[22] = 1; break;
214297
+ case '*':
214298
+ aArray[16] = 1;
214299
+ aArray[17] = 1;
214300
+ aArray[18] = 1;
214301
+ aArray[19] = 1;
214302
+ aArray[20] = 1;
214303
+ aArray[21] = 1;
214304
+ aArray[22] = 1;
214305
+ break;
214306
+ default: return 1; }
214307
+ break;
214308
+
214309
+ case 'S':
214310
+ switch( zCat[1] ){
214311
+ case 'c': aArray[23] = 1; break;
214312
+ case 'k': aArray[24] = 1; break;
214313
+ case 'm': aArray[25] = 1; break;
214314
+ case 'o': aArray[26] = 1; break;
214315
+ case '*':
214316
+ aArray[23] = 1;
214317
+ aArray[24] = 1;
214318
+ aArray[25] = 1;
214319
+ aArray[26] = 1;
214320
+ break;
214321
+ default: return 1; }
214322
+ break;
214323
+
214324
+ case 'Z':
214325
+ switch( zCat[1] ){
214326
+ case 'l': aArray[27] = 1; break;
214327
+ case 'p': aArray[28] = 1; break;
214328
+ case 's': aArray[29] = 1; break;
214329
+ case '*':
214330
+ aArray[27] = 1;
214331
+ aArray[28] = 1;
214332
+ aArray[29] = 1;
214333
+ break;
214334
+ default: return 1; }
214335
+ break;
214336
+
214337
+ }
214338
+ return 0;
214339
+}
214340
+
214341
+static u16 aFts5UnicodeBlock[] = {
214342
+ 0, 1471, 1753, 1760, 1760, 1760, 1760, 1760, 1760, 1760,
214343
+ 1760, 1760, 1760, 1760, 1760, 1763, 1765,
214344
+ };
214345
+static u16 aFts5UnicodeMap[] = {
214346
+ 0, 32, 33, 36, 37, 40, 41, 42, 43, 44,
214347
+ 45, 46, 48, 58, 60, 63, 65, 91, 92, 93,
214348
+ 94, 95, 96, 97, 123, 124, 125, 126, 127, 160,
214349
+ 161, 162, 166, 167, 168, 169, 170, 171, 172, 173,
214350
+ 174, 175, 176, 177, 178, 180, 181, 182, 184, 185,
214351
+ 186, 187, 188, 191, 192, 215, 216, 223, 247, 248,
214352
+ 256, 312, 313, 329, 330, 377, 383, 385, 387, 388,
214353
+ 391, 394, 396, 398, 402, 403, 405, 406, 409, 412,
214354
+ 414, 415, 417, 418, 423, 427, 428, 431, 434, 436,
214355
+ 437, 440, 442, 443, 444, 446, 448, 452, 453, 454,
214356
+ 455, 456, 457, 458, 459, 460, 461, 477, 478, 496,
214357
+ 497, 498, 499, 500, 503, 505, 506, 564, 570, 572,
214358
+ 573, 575, 577, 580, 583, 584, 592, 660, 661, 688,
214359
+ 706, 710, 722, 736, 741, 748, 749, 750, 751, 768,
214360
+ 880, 884, 885, 886, 890, 891, 894, 900, 902, 903,
214361
+ 904, 908, 910, 912, 913, 931, 940, 975, 977, 978,
214362
+ 981, 984, 1008, 1012, 1014, 1015, 1018, 1020, 1021, 1072,
214363
+ 1120, 1154, 1155, 1160, 1162, 1217, 1231, 1232, 1329, 1369,
214364
+ 1370, 1377, 1417, 1418, 1423, 1425, 1470, 1471, 1472, 1473,
214365
+ 1475, 1476, 1478, 1479, 1488, 1520, 1523, 1536, 1542, 1545,
214366
+ 1547, 1548, 1550, 1552, 1563, 1566, 1568, 1600, 1601, 1611,
214367
+ 1632, 1642, 1646, 1648, 1649, 1748, 1749, 1750, 1757, 1758,
214368
+ 1759, 1765, 1767, 1769, 1770, 1774, 1776, 1786, 1789, 1791,
214369
+ 1792, 1807, 1808, 1809, 1810, 1840, 1869, 1958, 1969, 1984,
214370
+ 1994, 2027, 2036, 2038, 2039, 2042, 2048, 2070, 2074, 2075,
214371
+ 2084, 2085, 2088, 2089, 2096, 2112, 2137, 2142, 2208, 2210,
214372
+ 2276, 2304, 2307, 2308, 2362, 2363, 2364, 2365, 2366, 2369,
214373
+ 2377, 2381, 2382, 2384, 2385, 2392, 2402, 2404, 2406, 2416,
214374
+ 2417, 2418, 2425, 2433, 2434, 2437, 2447, 2451, 2474, 2482,
214375
+ 2486, 2492, 2493, 2494, 2497, 2503, 2507, 2509, 2510, 2519,
214376
+ 2524, 2527, 2530, 2534, 2544, 2546, 2548, 2554, 2555, 2561,
214377
+ 2563, 2565, 2575, 2579, 2602, 2610, 2613, 2616, 2620, 2622,
214378
+ 2625, 2631, 2635, 2641, 2649, 2654, 2662, 2672, 2674, 2677,
214379
+ 2689, 2691, 2693, 2703, 2707, 2730, 2738, 2741, 2748, 2749,
214380
+ 2750, 2753, 2759, 2761, 2763, 2765, 2768, 2784, 2786, 2790,
214381
+ 2800, 2801, 2817, 2818, 2821, 2831, 2835, 2858, 2866, 2869,
214382
+ 2876, 2877, 2878, 2879, 2880, 2881, 2887, 2891, 2893, 2902,
214383
+ 2903, 2908, 2911, 2914, 2918, 2928, 2929, 2930, 2946, 2947,
214384
+ 2949, 2958, 2962, 2969, 2972, 2974, 2979, 2984, 2990, 3006,
214385
+ 3008, 3009, 3014, 3018, 3021, 3024, 3031, 3046, 3056, 3059,
214386
+ 3065, 3066, 3073, 3077, 3086, 3090, 3114, 3125, 3133, 3134,
214387
+ 3137, 3142, 3146, 3157, 3160, 3168, 3170, 3174, 3192, 3199,
214388
+ 3202, 3205, 3214, 3218, 3242, 3253, 3260, 3261, 3262, 3263,
214389
+ 3264, 3270, 3271, 3274, 3276, 3285, 3294, 3296, 3298, 3302,
214390
+ 3313, 3330, 3333, 3342, 3346, 3389, 3390, 3393, 3398, 3402,
214391
+ 3405, 3406, 3415, 3424, 3426, 3430, 3440, 3449, 3450, 3458,
214392
+ 3461, 3482, 3507, 3517, 3520, 3530, 3535, 3538, 3542, 3544,
214393
+ 3570, 3572, 3585, 3633, 3634, 3636, 3647, 3648, 3654, 3655,
214394
+ 3663, 3664, 3674, 3713, 3716, 3719, 3722, 3725, 3732, 3737,
214395
+ 3745, 3749, 3751, 3754, 3757, 3761, 3762, 3764, 3771, 3773,
214396
+ 3776, 3782, 3784, 3792, 3804, 3840, 3841, 3844, 3859, 3860,
214397
+ 3861, 3864, 3866, 3872, 3882, 3892, 3893, 3894, 3895, 3896,
214398
+ 3897, 3898, 3899, 3900, 3901, 3902, 3904, 3913, 3953, 3967,
214399
+ 3968, 3973, 3974, 3976, 3981, 3993, 4030, 4038, 4039, 4046,
214400
+ 4048, 4053, 4057, 4096, 4139, 4141, 4145, 4146, 4152, 4153,
214401
+ 4155, 4157, 4159, 4160, 4170, 4176, 4182, 4184, 4186, 4190,
214402
+ 4193, 4194, 4197, 4199, 4206, 4209, 4213, 4226, 4227, 4229,
214403
+ 4231, 4237, 4238, 4239, 4240, 4250, 4253, 4254, 4256, 4295,
214404
+ 4301, 4304, 4347, 4348, 4349, 4682, 4688, 4696, 4698, 4704,
214405
+ 4746, 4752, 4786, 4792, 4800, 4802, 4808, 4824, 4882, 4888,
214406
+ 4957, 4960, 4969, 4992, 5008, 5024, 5120, 5121, 5741, 5743,
214407
+ 5760, 5761, 5787, 5788, 5792, 5867, 5870, 5888, 5902, 5906,
214408
+ 5920, 5938, 5941, 5952, 5970, 5984, 5998, 6002, 6016, 6068,
214409
+ 6070, 6071, 6078, 6086, 6087, 6089, 6100, 6103, 6104, 6107,
214410
+ 6108, 6109, 6112, 6128, 6144, 6150, 6151, 6155, 6158, 6160,
214411
+ 6176, 6211, 6212, 6272, 6313, 6314, 6320, 6400, 6432, 6435,
214412
+ 6439, 6441, 6448, 6450, 6451, 6457, 6464, 6468, 6470, 6480,
214413
+ 6512, 6528, 6576, 6593, 6600, 6608, 6618, 6622, 6656, 6679,
214414
+ 6681, 6686, 6688, 6741, 6742, 6743, 6744, 6752, 6753, 6754,
214415
+ 6755, 6757, 6765, 6771, 6783, 6784, 6800, 6816, 6823, 6824,
214416
+ 6912, 6916, 6917, 6964, 6965, 6966, 6971, 6972, 6973, 6978,
214417
+ 6979, 6981, 6992, 7002, 7009, 7019, 7028, 7040, 7042, 7043,
214418
+ 7073, 7074, 7078, 7080, 7082, 7083, 7084, 7086, 7088, 7098,
214419
+ 7142, 7143, 7144, 7146, 7149, 7150, 7151, 7154, 7164, 7168,
214420
+ 7204, 7212, 7220, 7222, 7227, 7232, 7245, 7248, 7258, 7288,
214421
+ 7294, 7360, 7376, 7379, 7380, 7393, 7394, 7401, 7405, 7406,
214422
+ 7410, 7412, 7413, 7424, 7468, 7531, 7544, 7545, 7579, 7616,
214423
+ 7676, 7680, 7830, 7838, 7936, 7944, 7952, 7960, 7968, 7976,
214424
+ 7984, 7992, 8000, 8008, 8016, 8025, 8027, 8029, 8031, 8033,
214425
+ 8040, 8048, 8064, 8072, 8080, 8088, 8096, 8104, 8112, 8118,
214426
+ 8120, 8124, 8125, 8126, 8127, 8130, 8134, 8136, 8140, 8141,
214427
+ 8144, 8150, 8152, 8157, 8160, 8168, 8173, 8178, 8182, 8184,
214428
+ 8188, 8189, 8192, 8203, 8208, 8214, 8216, 8217, 8218, 8219,
214429
+ 8221, 8222, 8223, 8224, 8232, 8233, 8234, 8239, 8240, 8249,
214430
+ 8250, 8251, 8255, 8257, 8260, 8261, 8262, 8263, 8274, 8275,
214431
+ 8276, 8277, 8287, 8288, 8298, 8304, 8305, 8308, 8314, 8317,
214432
+ 8318, 8319, 8320, 8330, 8333, 8334, 8336, 8352, 8400, 8413,
214433
+ 8417, 8418, 8421, 8448, 8450, 8451, 8455, 8456, 8458, 8459,
214434
+ 8462, 8464, 8467, 8468, 8469, 8470, 8472, 8473, 8478, 8484,
214435
+ 8485, 8486, 8487, 8488, 8489, 8490, 8494, 8495, 8496, 8500,
214436
+ 8501, 8505, 8506, 8508, 8510, 8512, 8517, 8519, 8522, 8523,
214437
+ 8524, 8526, 8527, 8528, 8544, 8579, 8581, 8585, 8592, 8597,
214438
+ 8602, 8604, 8608, 8609, 8611, 8612, 8614, 8615, 8622, 8623,
214439
+ 8654, 8656, 8658, 8659, 8660, 8661, 8692, 8960, 8968, 8972,
214440
+ 8992, 8994, 9001, 9002, 9003, 9084, 9085, 9115, 9140, 9180,
214441
+ 9186, 9216, 9280, 9312, 9372, 9450, 9472, 9655, 9656, 9665,
214442
+ 9666, 9720, 9728, 9839, 9840, 9985, 10088, 10089, 10090, 10091,
214443
+ 10092, 10093, 10094, 10095, 10096, 10097, 10098, 10099, 10100, 10101,
214444
+ 10102, 10132, 10176, 10181, 10182, 10183, 10214, 10215, 10216, 10217,
214445
+ 10218, 10219, 10220, 10221, 10222, 10223, 10224, 10240, 10496, 10627,
214446
+ 10628, 10629, 10630, 10631, 10632, 10633, 10634, 10635, 10636, 10637,
214447
+ 10638, 10639, 10640, 10641, 10642, 10643, 10644, 10645, 10646, 10647,
214448
+ 10648, 10649, 10712, 10713, 10714, 10715, 10716, 10748, 10749, 10750,
214449
+ 11008, 11056, 11077, 11079, 11088, 11264, 11312, 11360, 11363, 11365,
214450
+ 11367, 11374, 11377, 11378, 11380, 11381, 11383, 11388, 11390, 11393,
214451
+ 11394, 11492, 11493, 11499, 11503, 11506, 11513, 11517, 11518, 11520,
214452
+ 11559, 11565, 11568, 11631, 11632, 11647, 11648, 11680, 11688, 11696,
214453
+ 11704, 11712, 11720, 11728, 11736, 11744, 11776, 11778, 11779, 11780,
214454
+ 11781, 11782, 11785, 11786, 11787, 11788, 11789, 11790, 11799, 11800,
214455
+ 11802, 11803, 11804, 11805, 11806, 11808, 11809, 11810, 11811, 11812,
214456
+ 11813, 11814, 11815, 11816, 11817, 11818, 11823, 11824, 11834, 11904,
214457
+ 11931, 12032, 12272, 12288, 12289, 12292, 12293, 12294, 12295, 12296,
214458
+ 12297, 12298, 12299, 12300, 12301, 12302, 12303, 12304, 12305, 12306,
214459
+ 12308, 12309, 12310, 12311, 12312, 12313, 12314, 12315, 12316, 12317,
214460
+ 12318, 12320, 12321, 12330, 12334, 12336, 12337, 12342, 12344, 12347,
214461
+ 12348, 12349, 12350, 12353, 12441, 12443, 12445, 12447, 12448, 12449,
214462
+ 12539, 12540, 12543, 12549, 12593, 12688, 12690, 12694, 12704, 12736,
214463
+ 12784, 12800, 12832, 12842, 12872, 12880, 12881, 12896, 12928, 12938,
214464
+ 12977, 12992, 13056, 13312, 19893, 19904, 19968, 40908, 40960, 40981,
214465
+ 40982, 42128, 42192, 42232, 42238, 42240, 42508, 42509, 42512, 42528,
214466
+ 42538, 42560, 42606, 42607, 42608, 42611, 42612, 42622, 42623, 42624,
214467
+ 42655, 42656, 42726, 42736, 42738, 42752, 42775, 42784, 42786, 42800,
214468
+ 42802, 42864, 42865, 42873, 42878, 42888, 42889, 42891, 42896, 42912,
214469
+ 43000, 43002, 43003, 43010, 43011, 43014, 43015, 43019, 43020, 43043,
214470
+ 43045, 43047, 43048, 43056, 43062, 43064, 43065, 43072, 43124, 43136,
214471
+ 43138, 43188, 43204, 43214, 43216, 43232, 43250, 43256, 43259, 43264,
214472
+ 43274, 43302, 43310, 43312, 43335, 43346, 43359, 43360, 43392, 43395,
214473
+ 43396, 43443, 43444, 43446, 43450, 43452, 43453, 43457, 43471, 43472,
214474
+ 43486, 43520, 43561, 43567, 43569, 43571, 43573, 43584, 43587, 43588,
214475
+ 43596, 43597, 43600, 43612, 43616, 43632, 43633, 43639, 43642, 43643,
214476
+ 43648, 43696, 43697, 43698, 43701, 43703, 43705, 43710, 43712, 43713,
214477
+ 43714, 43739, 43741, 43742, 43744, 43755, 43756, 43758, 43760, 43762,
214478
+ 43763, 43765, 43766, 43777, 43785, 43793, 43808, 43816, 43968, 44003,
214479
+ 44005, 44006, 44008, 44009, 44011, 44012, 44013, 44016, 44032, 55203,
214480
+ 55216, 55243, 55296, 56191, 56319, 57343, 57344, 63743, 63744, 64112,
214481
+ 64256, 64275, 64285, 64286, 64287, 64297, 64298, 64312, 64318, 64320,
214482
+ 64323, 64326, 64434, 64467, 64830, 64831, 64848, 64914, 65008, 65020,
214483
+ 65021, 65024, 65040, 65047, 65048, 65049, 65056, 65072, 65073, 65075,
214484
+ 65077, 65078, 65079, 65080, 65081, 65082, 65083, 65084, 65085, 65086,
214485
+ 65087, 65088, 65089, 65090, 65091, 65092, 65093, 65095, 65096, 65097,
214486
+ 65101, 65104, 65108, 65112, 65113, 65114, 65115, 65116, 65117, 65118,
214487
+ 65119, 65122, 65123, 65124, 65128, 65129, 65130, 65136, 65142, 65279,
214488
+ 65281, 65284, 65285, 65288, 65289, 65290, 65291, 65292, 65293, 65294,
214489
+ 65296, 65306, 65308, 65311, 65313, 65339, 65340, 65341, 65342, 65343,
214490
+ 65344, 65345, 65371, 65372, 65373, 65374, 65375, 65376, 65377, 65378,
214491
+ 65379, 65380, 65382, 65392, 65393, 65438, 65440, 65474, 65482, 65490,
214492
+ 65498, 65504, 65506, 65507, 65508, 65509, 65512, 65513, 65517, 65529,
214493
+ 65532, 0, 13, 40, 60, 63, 80, 128, 256, 263,
214494
+ 311, 320, 373, 377, 394, 400, 464, 509, 640, 672,
214495
+ 768, 800, 816, 833, 834, 842, 896, 927, 928, 968,
214496
+ 976, 977, 1024, 1064, 1104, 1184, 2048, 2056, 2058, 2103,
214497
+ 2108, 2111, 2135, 2136, 2304, 2326, 2335, 2336, 2367, 2432,
214498
+ 2494, 2560, 2561, 2565, 2572, 2576, 2581, 2585, 2616, 2623,
214499
+ 2624, 2640, 2656, 2685, 2687, 2816, 2873, 2880, 2904, 2912,
214500
+ 2936, 3072, 3680, 4096, 4097, 4098, 4099, 4152, 4167, 4178,
214501
+ 4198, 4224, 4226, 4227, 4272, 4275, 4279, 4281, 4283, 4285,
214502
+ 4286, 4304, 4336, 4352, 4355, 4391, 4396, 4397, 4406, 4416,
214503
+ 4480, 4482, 4483, 4531, 4534, 4543, 4545, 4549, 4560, 5760,
214504
+ 5803, 5804, 5805, 5806, 5808, 5814, 5815, 5824, 8192, 9216,
214505
+ 9328, 12288, 26624, 28416, 28496, 28497, 28559, 28563, 45056, 53248,
214506
+ 53504, 53545, 53605, 53607, 53610, 53613, 53619, 53627, 53635, 53637,
214507
+ 53644, 53674, 53678, 53760, 53826, 53829, 54016, 54112, 54272, 54298,
214508
+ 54324, 54350, 54358, 54376, 54402, 54428, 54430, 54434, 54437, 54441,
214509
+ 54446, 54454, 54459, 54461, 54469, 54480, 54506, 54532, 54535, 54541,
214510
+ 54550, 54558, 54584, 54587, 54592, 54598, 54602, 54610, 54636, 54662,
214511
+ 54688, 54714, 54740, 54766, 54792, 54818, 54844, 54870, 54896, 54922,
214512
+ 54952, 54977, 54978, 55003, 55004, 55010, 55035, 55036, 55061, 55062,
214513
+ 55068, 55093, 55094, 55119, 55120, 55126, 55151, 55152, 55177, 55178,
214514
+ 55184, 55209, 55210, 55235, 55236, 55242, 55246, 60928, 60933, 60961,
214515
+ 60964, 60967, 60969, 60980, 60985, 60987, 60994, 60999, 61001, 61003,
214516
+ 61005, 61009, 61012, 61015, 61017, 61019, 61021, 61023, 61025, 61028,
214517
+ 61031, 61036, 61044, 61049, 61054, 61056, 61067, 61089, 61093, 61099,
214518
+ 61168, 61440, 61488, 61600, 61617, 61633, 61649, 61696, 61712, 61744,
214519
+ 61808, 61926, 61968, 62016, 62032, 62208, 62256, 62263, 62336, 62368,
214520
+ 62406, 62432, 62464, 62528, 62530, 62713, 62720, 62784, 62800, 62971,
214521
+ 63045, 63104, 63232, 0, 42710, 42752, 46900, 46912, 47133, 63488,
214522
+ 1, 32, 256, 0, 65533,
214523
+ };
214524
+static u16 aFts5UnicodeData[] = {
214525
+ 1025, 61, 117, 55, 117, 54, 50, 53, 57, 53,
214526
+ 49, 85, 333, 85, 121, 85, 841, 54, 53, 50,
214527
+ 56, 48, 56, 837, 54, 57, 50, 57, 1057, 61,
214528
+ 53, 151, 58, 53, 56, 58, 39, 52, 57, 34,
214529
+ 58, 56, 58, 57, 79, 56, 37, 85, 56, 47,
214530
+ 39, 51, 111, 53, 745, 57, 233, 773, 57, 261,
214531
+ 1822, 37, 542, 37, 1534, 222, 69, 73, 37, 126,
214532
+ 126, 73, 69, 137, 37, 73, 37, 105, 101, 73,
214533
+ 37, 73, 37, 190, 158, 37, 126, 126, 73, 37,
214534
+ 126, 94, 37, 39, 94, 69, 135, 41, 40, 37,
214535
+ 41, 40, 37, 41, 40, 37, 542, 37, 606, 37,
214536
+ 41, 40, 37, 126, 73, 37, 1886, 197, 73, 37,
214537
+ 73, 69, 126, 105, 37, 286, 2181, 39, 869, 582,
214538
+ 152, 390, 472, 166, 248, 38, 56, 38, 568, 3596,
214539
+ 158, 38, 56, 94, 38, 101, 53, 88, 41, 53,
214540
+ 105, 41, 73, 37, 553, 297, 1125, 94, 37, 105,
214541
+ 101, 798, 133, 94, 57, 126, 94, 37, 1641, 1541,
214542
+ 1118, 58, 172, 75, 1790, 478, 37, 2846, 1225, 38,
214543
+ 213, 1253, 53, 49, 55, 1452, 49, 44, 53, 76,
214544
+ 53, 76, 53, 44, 871, 103, 85, 162, 121, 85,
214545
+ 55, 85, 90, 364, 53, 85, 1031, 38, 327, 684,
214546
+ 333, 149, 71, 44, 3175, 53, 39, 236, 34, 58,
214547
+ 204, 70, 76, 58, 140, 71, 333, 103, 90, 39,
214548
+ 469, 34, 39, 44, 967, 876, 2855, 364, 39, 333,
214549
+ 1063, 300, 70, 58, 117, 38, 711, 140, 38, 300,
214550
+ 38, 108, 38, 172, 501, 807, 108, 53, 39, 359,
214551
+ 876, 108, 42, 1735, 44, 42, 44, 39, 106, 268,
214552
+ 138, 44, 74, 39, 236, 327, 76, 85, 333, 53,
214553
+ 38, 199, 231, 44, 74, 263, 71, 711, 231, 39,
214554
+ 135, 44, 39, 106, 140, 74, 74, 44, 39, 42,
214555
+ 71, 103, 76, 333, 71, 87, 207, 58, 55, 76,
214556
+ 42, 199, 71, 711, 231, 71, 71, 71, 44, 106,
214557
+ 76, 76, 108, 44, 135, 39, 333, 76, 103, 44,
214558
+ 76, 42, 295, 103, 711, 231, 71, 167, 44, 39,
214559
+ 106, 172, 76, 42, 74, 44, 39, 71, 76, 333,
214560
+ 53, 55, 44, 74, 263, 71, 711, 231, 71, 167,
214561
+ 44, 39, 42, 44, 42, 140, 74, 74, 44, 44,
214562
+ 42, 71, 103, 76, 333, 58, 39, 207, 44, 39,
214563
+ 199, 103, 135, 71, 39, 71, 71, 103, 391, 74,
214564
+ 44, 74, 106, 106, 44, 39, 42, 333, 111, 218,
214565
+ 55, 58, 106, 263, 103, 743, 327, 167, 39, 108,
214566
+ 138, 108, 140, 76, 71, 71, 76, 333, 239, 58,
214567
+ 74, 263, 103, 743, 327, 167, 44, 39, 42, 44,
214568
+ 170, 44, 74, 74, 76, 74, 39, 71, 76, 333,
214569
+ 71, 74, 263, 103, 1319, 39, 106, 140, 106, 106,
214570
+ 44, 39, 42, 71, 76, 333, 207, 58, 199, 74,
214571
+ 583, 775, 295, 39, 231, 44, 106, 108, 44, 266,
214572
+ 74, 53, 1543, 44, 71, 236, 55, 199, 38, 268,
214573
+ 53, 333, 85, 71, 39, 71, 39, 39, 135, 231,
214574
+ 103, 39, 39, 71, 135, 44, 71, 204, 76, 39,
214575
+ 167, 38, 204, 333, 135, 39, 122, 501, 58, 53,
214576
+ 122, 76, 218, 333, 335, 58, 44, 58, 44, 58,
214577
+ 44, 54, 50, 54, 50, 74, 263, 1159, 460, 42,
214578
+ 172, 53, 76, 167, 364, 1164, 282, 44, 218, 90,
214579
+ 181, 154, 85, 1383, 74, 140, 42, 204, 42, 76,
214580
+ 74, 76, 39, 333, 213, 199, 74, 76, 135, 108,
214581
+ 39, 106, 71, 234, 103, 140, 423, 44, 74, 76,
214582
+ 202, 44, 39, 42, 333, 106, 44, 90, 1225, 41,
214583
+ 41, 1383, 53, 38, 10631, 135, 231, 39, 135, 1319,
214584
+ 135, 1063, 135, 231, 39, 135, 487, 1831, 135, 2151,
214585
+ 108, 309, 655, 519, 346, 2727, 49, 19847, 85, 551,
214586
+ 61, 839, 54, 50, 2407, 117, 110, 423, 135, 108,
214587
+ 583, 108, 85, 583, 76, 423, 103, 76, 1671, 76,
214588
+ 42, 236, 266, 44, 74, 364, 117, 38, 117, 55,
214589
+ 39, 44, 333, 335, 213, 49, 149, 108, 61, 333,
214590
+ 1127, 38, 1671, 1319, 44, 39, 2247, 935, 108, 138,
214591
+ 76, 106, 74, 44, 202, 108, 58, 85, 333, 967,
214592
+ 167, 1415, 554, 231, 74, 333, 47, 1114, 743, 76,
214593
+ 106, 85, 1703, 42, 44, 42, 236, 44, 42, 44,
214594
+ 74, 268, 202, 332, 44, 333, 333, 245, 38, 213,
214595
+ 140, 42, 1511, 44, 42, 172, 42, 44, 170, 44,
214596
+ 74, 231, 333, 245, 346, 300, 314, 76, 42, 967,
214597
+ 42, 140, 74, 76, 42, 44, 74, 71, 333, 1415,
214598
+ 44, 42, 76, 106, 44, 42, 108, 74, 149, 1159,
214599
+ 266, 268, 74, 76, 181, 333, 103, 333, 967, 198,
214600
+ 85, 277, 108, 53, 428, 42, 236, 135, 44, 135,
214601
+ 74, 44, 71, 1413, 2022, 421, 38, 1093, 1190, 1260,
214602
+ 140, 4830, 261, 3166, 261, 265, 197, 201, 261, 265,
214603
+ 261, 265, 197, 201, 261, 41, 41, 41, 94, 229,
214604
+ 265, 453, 261, 264, 261, 264, 261, 264, 165, 69,
214605
+ 137, 40, 56, 37, 120, 101, 69, 137, 40, 120,
214606
+ 133, 69, 137, 120, 261, 169, 120, 101, 69, 137,
214607
+ 40, 88, 381, 162, 209, 85, 52, 51, 54, 84,
214608
+ 51, 54, 52, 277, 59, 60, 162, 61, 309, 52,
214609
+ 51, 149, 80, 117, 57, 54, 50, 373, 57, 53,
214610
+ 48, 341, 61, 162, 194, 47, 38, 207, 121, 54,
214611
+ 50, 38, 335, 121, 54, 50, 422, 855, 428, 139,
214612
+ 44, 107, 396, 90, 41, 154, 41, 90, 37, 105,
214613
+ 69, 105, 37, 58, 41, 90, 57, 169, 218, 41,
214614
+ 58, 41, 58, 41, 58, 137, 58, 37, 137, 37,
214615
+ 135, 37, 90, 69, 73, 185, 94, 101, 58, 57,
214616
+ 90, 37, 58, 527, 1134, 94, 142, 47, 185, 186,
214617
+ 89, 154, 57, 90, 57, 90, 57, 250, 57, 1018,
214618
+ 89, 90, 57, 58, 57, 1018, 8601, 282, 153, 666,
214619
+ 89, 250, 54, 50, 2618, 57, 986, 825, 1306, 217,
214620
+ 602, 1274, 378, 1935, 2522, 719, 5882, 57, 314, 57,
214621
+ 1754, 281, 3578, 57, 4634, 3322, 54, 50, 54, 50,
214622
+ 54, 50, 54, 50, 54, 50, 54, 50, 54, 50,
214623
+ 975, 1434, 185, 54, 50, 1017, 54, 50, 54, 50,
214624
+ 54, 50, 54, 50, 54, 50, 537, 8218, 4217, 54,
214625
+ 50, 54, 50, 54, 50, 54, 50, 54, 50, 54,
214626
+ 50, 54, 50, 54, 50, 54, 50, 54, 50, 54,
214627
+ 50, 2041, 54, 50, 54, 50, 1049, 54, 50, 8281,
214628
+ 1562, 697, 90, 217, 346, 1513, 1509, 126, 73, 69,
214629
+ 254, 105, 37, 94, 37, 94, 165, 70, 105, 37,
214630
+ 3166, 37, 218, 158, 108, 94, 149, 47, 85, 1221,
214631
+ 37, 37, 1799, 38, 53, 44, 743, 231, 231, 231,
214632
+ 231, 231, 231, 231, 231, 1036, 85, 52, 51, 52,
214633
+ 51, 117, 52, 51, 53, 52, 51, 309, 49, 85,
214634
+ 49, 53, 52, 51, 85, 52, 51, 54, 50, 54,
214635
+ 50, 54, 50, 54, 50, 181, 38, 341, 81, 858,
214636
+ 2874, 6874, 410, 61, 117, 58, 38, 39, 46, 54,
214637
+ 50, 54, 50, 54, 50, 54, 50, 54, 50, 90,
214638
+ 54, 50, 54, 50, 54, 50, 54, 50, 49, 54,
214639
+ 82, 58, 302, 140, 74, 49, 166, 90, 110, 38,
214640
+ 39, 53, 90, 2759, 76, 88, 70, 39, 49, 2887,
214641
+ 53, 102, 39, 1319, 3015, 90, 143, 346, 871, 1178,
214642
+ 519, 1018, 335, 986, 271, 58, 495, 1050, 335, 1274,
214643
+ 495, 2042, 8218, 39, 39, 2074, 39, 39, 679, 38,
214644
+ 36583, 1786, 1287, 198, 85, 8583, 38, 117, 519, 333,
214645
+ 71, 1502, 39, 44, 107, 53, 332, 53, 38, 798,
214646
+ 44, 2247, 334, 76, 213, 760, 294, 88, 478, 69,
214647
+ 2014, 38, 261, 190, 350, 38, 88, 158, 158, 382,
214648
+ 70, 37, 231, 44, 103, 44, 135, 44, 743, 74,
214649
+ 76, 42, 154, 207, 90, 55, 58, 1671, 149, 74,
214650
+ 1607, 522, 44, 85, 333, 588, 199, 117, 39, 333,
214651
+ 903, 268, 85, 743, 364, 74, 53, 935, 108, 42,
214652
+ 1511, 44, 74, 140, 74, 44, 138, 437, 38, 333,
214653
+ 85, 1319, 204, 74, 76, 74, 76, 103, 44, 263,
214654
+ 44, 42, 333, 149, 519, 38, 199, 122, 39, 42,
214655
+ 1543, 44, 39, 108, 71, 76, 167, 76, 39, 44,
214656
+ 39, 71, 38, 85, 359, 42, 76, 74, 85, 39,
214657
+ 70, 42, 44, 199, 199, 199, 231, 231, 1127, 74,
214658
+ 44, 74, 44, 74, 53, 42, 44, 333, 39, 39,
214659
+ 743, 1575, 36, 68, 68, 36, 63, 63, 11719, 3399,
214660
+ 229, 165, 39, 44, 327, 57, 423, 167, 39, 71,
214661
+ 71, 3463, 536, 11623, 54, 50, 2055, 1735, 391, 55,
214662
+ 58, 524, 245, 54, 50, 53, 236, 53, 81, 80,
214663
+ 54, 50, 54, 50, 54, 50, 54, 50, 54, 50,
214664
+ 54, 50, 54, 50, 54, 50, 85, 54, 50, 149,
214665
+ 112, 117, 149, 49, 54, 50, 54, 50, 54, 50,
214666
+ 117, 57, 49, 121, 53, 55, 85, 167, 4327, 34,
214667
+ 117, 55, 117, 54, 50, 53, 57, 53, 49, 85,
214668
+ 333, 85, 121, 85, 841, 54, 53, 50, 56, 48,
214669
+ 56, 837, 54, 57, 50, 57, 54, 50, 53, 54,
214670
+ 50, 85, 327, 38, 1447, 70, 999, 199, 199, 199,
214671
+ 103, 87, 57, 56, 58, 87, 58, 153, 90, 98,
214672
+ 90, 391, 839, 615, 71, 487, 455, 3943, 117, 1455,
214673
+ 314, 1710, 143, 570, 47, 410, 1466, 44, 935, 1575,
214674
+ 999, 143, 551, 46, 263, 46, 967, 53, 1159, 263,
214675
+ 53, 174, 1289, 1285, 2503, 333, 199, 39, 1415, 71,
214676
+ 39, 743, 53, 271, 711, 207, 53, 839, 53, 1799,
214677
+ 71, 39, 108, 76, 140, 135, 103, 871, 108, 44,
214678
+ 271, 309, 935, 79, 53, 1735, 245, 711, 271, 615,
214679
+ 271, 2343, 1007, 42, 44, 42, 1703, 492, 245, 655,
214680
+ 333, 76, 42, 1447, 106, 140, 74, 76, 85, 34,
214681
+ 149, 807, 333, 108, 1159, 172, 42, 268, 333, 149,
214682
+ 76, 42, 1543, 106, 300, 74, 135, 149, 333, 1383,
214683
+ 44, 42, 44, 74, 204, 42, 44, 333, 28135, 3182,
214684
+ 149, 34279, 18215, 2215, 39, 1482, 140, 422, 71, 7898,
214685
+ 1274, 1946, 74, 108, 122, 202, 258, 268, 90, 236,
214686
+ 986, 140, 1562, 2138, 108, 58, 2810, 591, 841, 837,
214687
+ 841, 229, 581, 841, 837, 41, 73, 41, 73, 137,
214688
+ 265, 133, 37, 229, 357, 841, 837, 73, 137, 265,
214689
+ 233, 837, 73, 137, 169, 41, 233, 837, 841, 837,
214690
+ 841, 837, 841, 837, 841, 837, 841, 837, 841, 901,
214691
+ 809, 57, 805, 57, 197, 809, 57, 805, 57, 197,
214692
+ 809, 57, 805, 57, 197, 809, 57, 805, 57, 197,
214693
+ 809, 57, 805, 57, 197, 94, 1613, 135, 871, 71,
214694
+ 39, 39, 327, 135, 39, 39, 39, 39, 39, 39,
214695
+ 103, 71, 39, 39, 39, 39, 39, 39, 71, 39,
214696
+ 135, 231, 135, 135, 39, 327, 551, 103, 167, 551,
214697
+ 89, 1434, 3226, 506, 474, 506, 506, 367, 1018, 1946,
214698
+ 1402, 954, 1402, 314, 90, 1082, 218, 2266, 666, 1210,
214699
+ 186, 570, 2042, 58, 5850, 154, 2010, 154, 794, 2266,
214700
+ 378, 2266, 3738, 39, 39, 39, 39, 39, 39, 17351,
214701
+ 34, 3074, 7692, 63, 63,
214702
+ };
214703
+
214704
+static int sqlite3Fts5UnicodeCategory(int iCode) {
214705
+ int iRes = -1;
214706
+ int iHi;
214707
+ int iLo;
214708
+ int ret;
214709
+ u16 iKey;
214710
+
214711
+ if( iCode>=(1<<20) ){
214712
+ return 0;
214713
+ }
214714
+ iLo = aFts5UnicodeBlock[(iCode>>16)];
214715
+ iHi = aFts5UnicodeBlock[1+(iCode>>16)];
214716
+ iKey = (iCode & 0xFFFF);
214717
+ while( iHi>iLo ){
214718
+ int iTest = (iHi + iLo) / 2;
214719
+ assert( iTest>=iLo && iTest<iHi );
214720
+ if( iKey>=aFts5UnicodeMap[iTest] ){
214721
+ iRes = iTest;
214722
+ iLo = iTest+1;
214723
+ }else{
214724
+ iHi = iTest;
214725
+ }
214726
+ }
214727
+
214728
+ if( iRes<0 ) return 0;
214729
+ if( iKey>=(aFts5UnicodeMap[iRes]+(aFts5UnicodeData[iRes]>>5)) ) return 0;
214730
+ ret = aFts5UnicodeData[iRes] & 0x1F;
214731
+ if( ret!=30 ) return ret;
214732
+ return ((iKey - aFts5UnicodeMap[iRes]) & 0x01) ? 5 : 9;
214733
+}
214734
+
214735
+static void sqlite3Fts5UnicodeAscii(u8 *aArray, u8 *aAscii){
214736
+ int i = 0;
214737
+ int iTbl = 0;
214738
+ while( i<128 ){
214739
+ int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];
214740
+ int n = (aFts5UnicodeData[iTbl] >> 5) + i;
214741
+ for(; i<128 && i<n; i++){
214742
+ aAscii[i] = bToken;
214743
+ }
214744
+ iTbl++;
214745
+ }
214746
+}
214747
+
210440214748
210441214749
/*
210442214750
** 2015 May 30
210443214751
**
210444214752
** The author disclaims copyright to this source code. In place of
@@ -211853,12 +216161,12 @@
211853216161
}
211854216162
#endif /* SQLITE_CORE */
211855216163
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
211856216164
211857216165
/************** End of stmt.c ************************************************/
211858
-#if __LINE__!=211858
216166
+#if __LINE__!=216166
211859216167
#undef SQLITE_SOURCE_ID
211860
-#define SQLITE_SOURCE_ID "2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199aalt2"
216168
+#define SQLITE_SOURCE_ID "2018-07-13 20:28:54 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb362124alt2"
211861216169
#endif
211862216170
/* Return the source-id for this library */
211863216171
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
211864216172
/************************** End of sqlite3.c ******************************/
211865216173
--- 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.24.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.
@@ -1148,13 +1148,13 @@
1148 **
1149 ** See also: [sqlite3_libversion()],
1150 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1151 ** [sqlite_version()] and [sqlite_source_id()].
1152 */
1153 #define SQLITE_VERSION "3.24.0"
1154 #define SQLITE_VERSION_NUMBER 3024000
1155 #define SQLITE_SOURCE_ID "2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca"
1156
1157 /*
1158 ** CAPI3REF: Run-Time Library Version Numbers
1159 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1160 **
@@ -1536,10 +1536,11 @@
1536 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1537 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1538 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
1539 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
1540 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
 
1541 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
1542 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
1543 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
1544 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
1545 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -3146,10 +3147,16 @@
3146 ** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
3147 ** [VACUUM] in order to reset a database back to an empty database
3148 ** with no schema and no content. The following process works even for
3149 ** a badly corrupted database file:
3150 ** <ol>
 
 
 
 
 
 
3151 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
3152 ** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
3153 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
3154 ** </ol>
3155 ** Because resetting a database is destructive and irreversible, the
@@ -4379,16 +4386,27 @@
4379 **
4380 ** ^If the most recent sqlite3_* API call associated with
4381 ** [database connection] D failed, then the sqlite3_errcode(D) interface
4382 ** returns the numeric [result code] or [extended result code] for that
4383 ** API call.
4384 ** If the most recent API call was successful,
4385 ** then the return value from sqlite3_errcode() is undefined.
4386 ** ^The sqlite3_extended_errcode()
4387 ** interface is the same except that it always returns the
4388 ** [extended result code] even when extended result codes are
4389 ** disabled.
 
 
 
 
 
 
 
 
 
 
 
 
 
4390 **
4391 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
4392 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
4393 ** ^(Memory to hold the error message string is managed internally.
4394 ** The application does not need to worry about freeing the result.
@@ -5539,15 +5557,29 @@
5539 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
5540 ** and BLOBs is freed automatically. Do not pass the pointers returned
5541 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
5542 ** [sqlite3_free()].
5543 **
5544 ** ^(If a memory allocation error occurs during the evaluation of any
5545 ** of these routines, a default value is returned. The default value
5546 ** is either the integer 0, the floating point number 0.0, or a NULL
5547 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
5548 ** [SQLITE_NOMEM].)^
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5549 */
5550 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
5551 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
5552 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
5553 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
@@ -5620,15 +5652,17 @@
5620 ** KEYWORDS: {application-defined SQL functions}
5621 ** METHOD: sqlite3
5622 **
5623 ** ^These functions (collectively known as "function creation routines")
5624 ** are used to add SQL functions or aggregates or to redefine the behavior
5625 ** of existing SQL functions or aggregates. The only differences between
5626 ** these routines are the text encoding expected for
5627 ** the second parameter (the name of the function being created)
5628 ** and the presence or absence of a destructor callback for
5629 ** the application data pointer.
 
 
5630 **
5631 ** ^The first parameter is the [database connection] to which the SQL
5632 ** function is to be added. ^If an application uses more than one database
5633 ** connection then application-defined SQL functions must be added
5634 ** to each database connection separately.
@@ -5670,28 +5704,38 @@
5670 ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
5671 **
5672 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
5673 ** function can gain access to this pointer using [sqlite3_user_data()].)^
5674 **
5675 ** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are
 
5676 ** pointers to C-language functions that implement the SQL function or
5677 ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
5678 ** callback only; NULL pointers must be passed as the xStep and xFinal
5679 ** parameters. ^An aggregate SQL function requires an implementation of xStep
5680 ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
5681 ** SQL function or aggregate, pass NULL pointers for all three function
5682 ** callbacks.
5683 **
5684 ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,
5685 ** then it is destructor for the application data pointer.
5686 ** The destructor is invoked when the function is deleted, either by being
5687 ** overloaded or when the database connection closes.)^
5688 ** ^The destructor is also invoked if the call to
5689 ** sqlite3_create_function_v2() fails.
5690 ** ^When the destructor callback of the tenth parameter is invoked, it
5691 ** is passed a single argument which is a copy of the application data
5692 ** pointer which was the fifth parameter to sqlite3_create_function_v2().
 
 
 
 
 
 
 
 
 
5693 **
5694 ** ^It is permitted to register multiple implementations of the same
5695 ** functions with the same name but with either differing numbers of
5696 ** arguments or differing preferred text encodings. ^SQLite will use
5697 ** the implementation that most closely matches the way in which the
@@ -5739,10 +5783,22 @@
5739 void *pApp,
5740 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
5741 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
5742 void (*xFinal)(sqlite3_context*),
5743 void(*xDestroy)(void*)
 
 
 
 
 
 
 
 
 
 
 
 
5744 );
5745
5746 /*
5747 ** CAPI3REF: Text Encodings
5748 **
@@ -5882,10 +5938,32 @@
5882 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
5883 ** or [sqlite3_value_text16()].
5884 **
5885 ** These routines must be called from the same thread as
5886 ** the SQL function that supplied the [sqlite3_value*] parameters.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5887 */
5888 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
5889 SQLITE_API double sqlite3_value_double(sqlite3_value*);
5890 SQLITE_API int sqlite3_value_int(sqlite3_value*);
5891 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
@@ -12877,10 +12955,21 @@
12877 #endif
12878 #if defined(NDEBUG) && defined(SQLITE_DEBUG)
12879 # undef NDEBUG
12880 #endif
12881
 
 
 
 
 
 
 
 
 
 
 
12882 /*
12883 ** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
12884 */
12885 #if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)
12886 # define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
@@ -13214,98 +13303,108 @@
13214 #define TK_RAISE 71
13215 #define TK_RECURSIVE 72
13216 #define TK_REPLACE 73
13217 #define TK_RESTRICT 74
13218 #define TK_ROW 75
13219 #define TK_TRIGGER 76
13220 #define TK_VACUUM 77
13221 #define TK_VIEW 78
13222 #define TK_VIRTUAL 79
13223 #define TK_WITH 80
13224 #define TK_REINDEX 81
13225 #define TK_RENAME 82
13226 #define TK_CTIME_KW 83
13227 #define TK_ANY 84
13228 #define TK_BITAND 85
13229 #define TK_BITOR 86
13230 #define TK_LSHIFT 87
13231 #define TK_RSHIFT 88
13232 #define TK_PLUS 89
13233 #define TK_MINUS 90
13234 #define TK_STAR 91
13235 #define TK_SLASH 92
13236 #define TK_REM 93
13237 #define TK_CONCAT 94
13238 #define TK_COLLATE 95
13239 #define TK_BITNOT 96
13240 #define TK_ON 97
13241 #define TK_INDEXED 98
13242 #define TK_STRING 99
13243 #define TK_JOIN_KW 100
13244 #define TK_CONSTRAINT 101
13245 #define TK_DEFAULT 102
13246 #define TK_NULL 103
13247 #define TK_PRIMARY 104
13248 #define TK_UNIQUE 105
13249 #define TK_CHECK 106
13250 #define TK_REFERENCES 107
13251 #define TK_AUTOINCR 108
13252 #define TK_INSERT 109
13253 #define TK_DELETE 110
13254 #define TK_UPDATE 111
13255 #define TK_SET 112
13256 #define TK_DEFERRABLE 113
13257 #define TK_FOREIGN 114
13258 #define TK_DROP 115
13259 #define TK_UNION 116
13260 #define TK_ALL 117
13261 #define TK_EXCEPT 118
13262 #define TK_INTERSECT 119
13263 #define TK_SELECT 120
13264 #define TK_VALUES 121
13265 #define TK_DISTINCT 122
13266 #define TK_DOT 123
13267 #define TK_FROM 124
13268 #define TK_JOIN 125
13269 #define TK_USING 126
13270 #define TK_ORDER 127
13271 #define TK_GROUP 128
13272 #define TK_HAVING 129
13273 #define TK_LIMIT 130
13274 #define TK_WHERE 131
13275 #define TK_INTO 132
13276 #define TK_NOTHING 133
13277 #define TK_FLOAT 134
13278 #define TK_BLOB 135
13279 #define TK_INTEGER 136
13280 #define TK_VARIABLE 137
13281 #define TK_CASE 138
13282 #define TK_WHEN 139
13283 #define TK_THEN 140
13284 #define TK_ELSE 141
13285 #define TK_INDEX 142
13286 #define TK_ALTER 143
13287 #define TK_ADD 144
13288 #define TK_TRUEFALSE 145
13289 #define TK_ISNOT 146
13290 #define TK_FUNCTION 147
13291 #define TK_COLUMN 148
13292 #define TK_AGG_FUNCTION 149
13293 #define TK_AGG_COLUMN 150
13294 #define TK_UMINUS 151
13295 #define TK_UPLUS 152
13296 #define TK_TRUTH 153
13297 #define TK_REGISTER 154
13298 #define TK_VECTOR 155
13299 #define TK_SELECT_COLUMN 156
13300 #define TK_IF_NULL_ROW 157
13301 #define TK_ASTERISK 158
13302 #define TK_SPAN 159
13303 #define TK_END_OF_FILE 160
13304 #define TK_UNCLOSED_STRING 161
13305 #define TK_SPACE 162
13306 #define TK_ILLEGAL 163
 
 
 
 
 
 
 
 
 
 
13307
13308 /* The token codes above must all fit in 8 bits */
13309 #define TKFLG_MASK 0xff
13310
13311 /* Flags that can be added to a token code when it is not
@@ -13891,12 +13990,39 @@
13891 typedef struct Upsert Upsert;
13892 typedef struct VTable VTable;
13893 typedef struct VtabCtx VtabCtx;
13894 typedef struct Walker Walker;
13895 typedef struct WhereInfo WhereInfo;
 
13896 typedef struct With With;
13897
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13898 /* A VList object records a mapping between parameters/variables/wildcards
13899 ** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer
13900 ** variable number associated with that parameter. See the format description
13901 ** on the sqlite3VListAdd() routine for more information. A VList is really
13902 ** just an array of integers.
@@ -13988,11 +14114,11 @@
13988 SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int);
13989 SQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree*);
13990 SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p);
13991 SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
13992 SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);
13993 SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int);
13994 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
13995 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*, int);
13996 SQLITE_PRIVATE int sqlite3BtreeCommit(Btree*);
13997 SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int,int);
13998 SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);
@@ -14211,10 +14337,13 @@
14211 };
14212
14213 SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
14214 int flags, int seekResult);
14215 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
 
 
 
14216 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
14217 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
14218 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
14219 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
14220 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
@@ -14378,11 +14507,12 @@
14378 #ifdef VDBE_PROFILE
14379 u32 cnt; /* Number of times this instruction was executed */
14380 u64 cycles; /* Total time spent executing this instruction */
14381 #endif
14382 #ifdef SQLITE_VDBE_COVERAGE
14383 int iSrcLine; /* Source-code line that generated this opcode */
 
14384 #endif
14385 };
14386 typedef struct VdbeOp VdbeOp;
14387
14388
@@ -14479,122 +14609,122 @@
14479 /* See the tool/mkopcodeh.tcl script for details */
14480 #define OP_Savepoint 0
14481 #define OP_AutoCommit 1
14482 #define OP_Transaction 2
14483 #define OP_SorterNext 3 /* jump */
14484 #define OP_PrevIfOpen 4 /* jump */
14485 #define OP_NextIfOpen 5 /* jump */
14486 #define OP_Prev 6 /* jump */
14487 #define OP_Next 7 /* jump */
14488 #define OP_Checkpoint 8
14489 #define OP_JournalMode 9
14490 #define OP_Vacuum 10
14491 #define OP_VFilter 11 /* jump, synopsis: iplan=r[P3] zplan='P4' */
14492 #define OP_VUpdate 12 /* synopsis: data=r[P3@P2] */
14493 #define OP_Goto 13 /* jump */
14494 #define OP_Gosub 14 /* jump */
14495 #define OP_InitCoroutine 15 /* jump */
14496 #define OP_Yield 16 /* jump */
14497 #define OP_MustBeInt 17 /* jump */
14498 #define OP_Jump 18 /* jump */
14499 #define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */
14500 #define OP_Once 20 /* jump */
14501 #define OP_If 21 /* jump */
14502 #define OP_IfNot 22 /* jump */
14503 #define OP_IfNullRow 23 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
14504 #define OP_SeekLT 24 /* jump, synopsis: key=r[P3@P4] */
14505 #define OP_SeekLE 25 /* jump, synopsis: key=r[P3@P4] */
14506 #define OP_SeekGE 26 /* jump, synopsis: key=r[P3@P4] */
14507 #define OP_SeekGT 27 /* jump, synopsis: key=r[P3@P4] */
14508 #define OP_NoConflict 28 /* jump, synopsis: key=r[P3@P4] */
14509 #define OP_NotFound 29 /* jump, synopsis: key=r[P3@P4] */
14510 #define OP_Found 30 /* jump, synopsis: key=r[P3@P4] */
14511 #define OP_SeekRowid 31 /* jump, synopsis: intkey=r[P3] */
14512 #define OP_NotExists 32 /* jump, synopsis: intkey=r[P3] */
14513 #define OP_Last 33 /* jump */
14514 #define OP_IfSmaller 34 /* jump */
14515 #define OP_SorterSort 35 /* jump */
14516 #define OP_Sort 36 /* jump */
14517 #define OP_Rewind 37 /* jump */
14518 #define OP_IdxLE 38 /* jump, synopsis: key=r[P3@P4] */
14519 #define OP_IdxGT 39 /* jump, synopsis: key=r[P3@P4] */
14520 #define OP_IdxLT 40 /* jump, synopsis: key=r[P3@P4] */
14521 #define OP_IdxGE 41 /* jump, synopsis: key=r[P3@P4] */
14522 #define OP_RowSetRead 42 /* jump, synopsis: r[P3]=rowset(P1) */
14523 #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
14524 #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
14525 #define OP_RowSetTest 45 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
14526 #define OP_Program 46 /* jump */
14527 #define OP_FkIfZero 47 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
14528 #define OP_IfPos 48 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
14529 #define OP_IfNotZero 49 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
14530 #define OP_IsNull 50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
14531 #define OP_NotNull 51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
14532 #define OP_Ne 52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
14533 #define OP_Eq 53 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
14534 #define OP_Gt 54 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
14535 #define OP_Le 55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
14536 #define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
14537 #define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
14538 #define OP_ElseNotEq 58 /* jump, same as TK_ESCAPE */
14539 #define OP_DecrJumpZero 59 /* jump, synopsis: if (--r[P1])==0 goto P2 */
14540 #define OP_IncrVacuum 60 /* jump */
14541 #define OP_VNext 61 /* jump */
14542 #define OP_Init 62 /* jump, synopsis: Start at P2 */
14543 #define OP_Return 63
14544 #define OP_EndCoroutine 64
14545 #define OP_HaltIfNull 65 /* synopsis: if r[P3]=null halt */
14546 #define OP_Halt 66
14547 #define OP_Integer 67 /* synopsis: r[P2]=P1 */
14548 #define OP_Int64 68 /* synopsis: r[P2]=P4 */
14549 #define OP_String 69 /* synopsis: r[P2]='P4' (len=P1) */
14550 #define OP_Null 70 /* synopsis: r[P2..P3]=NULL */
14551 #define OP_SoftNull 71 /* synopsis: r[P1]=NULL */
14552 #define OP_Blob 72 /* synopsis: r[P2]=P4 (len=P1) */
14553 #define OP_Variable 73 /* synopsis: r[P2]=parameter(P1,P4) */
14554 #define OP_Move 74 /* synopsis: r[P2@P3]=r[P1@P3] */
14555 #define OP_Copy 75 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
14556 #define OP_SCopy 76 /* synopsis: r[P2]=r[P1] */
14557 #define OP_IntCopy 77 /* synopsis: r[P2]=r[P1] */
14558 #define OP_ResultRow 78 /* synopsis: output=r[P1@P2] */
14559 #define OP_CollSeq 79
14560 #define OP_AddImm 80 /* synopsis: r[P1]=r[P1]+P2 */
14561 #define OP_RealAffinity 81
14562 #define OP_Cast 82 /* synopsis: affinity(r[P1]) */
14563 #define OP_Permutation 83
14564 #define OP_Compare 84 /* synopsis: r[P1@P3] <-> r[P2@P3] */
14565 #define OP_BitAnd 85 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
14566 #define OP_BitOr 86 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
14567 #define OP_ShiftLeft 87 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
14568 #define OP_ShiftRight 88 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
14569 #define OP_Add 89 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
14570 #define OP_Subtract 90 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
14571 #define OP_Multiply 91 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
14572 #define OP_Divide 92 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
14573 #define OP_Remainder 93 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
14574 #define OP_Concat 94 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
14575 #define OP_IsTrue 95 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
14576 #define OP_BitNot 96 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
14577 #define OP_Offset 97 /* synopsis: r[P3] = sqlite_offset(P1) */
14578 #define OP_Column 98 /* synopsis: r[P3]=PX */
14579 #define OP_String8 99 /* same as TK_STRING, synopsis: r[P2]='P4' */
14580 #define OP_Affinity 100 /* synopsis: affinity(r[P1@P2]) */
14581 #define OP_MakeRecord 101 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
14582 #define OP_Count 102 /* synopsis: r[P2]=count() */
14583 #define OP_ReadCookie 103
14584 #define OP_SetCookie 104
14585 #define OP_ReopenIdx 105 /* synopsis: root=P2 iDb=P3 */
14586 #define OP_OpenRead 106 /* synopsis: root=P2 iDb=P3 */
14587 #define OP_OpenWrite 107 /* synopsis: root=P2 iDb=P3 */
14588 #define OP_OpenDup 108
14589 #define OP_OpenAutoindex 109 /* synopsis: nColumn=P2 */
14590 #define OP_OpenEphemeral 110 /* synopsis: nColumn=P2 */
14591 #define OP_SorterOpen 111
14592 #define OP_SequenceTest 112 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
14593 #define OP_OpenPseudo 113 /* synopsis: P3 columns in r[P2] */
14594 #define OP_Close 114
14595 #define OP_ColumnsUsed 115
14596 #define OP_Sequence 116 /* synopsis: r[P2]=cursor[P1].ctr++ */
14597 #define OP_NewRowid 117 /* synopsis: r[P2]=rowid */
14598 #define OP_Insert 118 /* synopsis: intkey=r[P3] data=r[P2] */
14599 #define OP_InsertInt 119 /* synopsis: intkey=P3 data=r[P2] */
14600 #define OP_Delete 120
@@ -14609,48 +14739,52 @@
14609 #define OP_IdxInsert 129 /* synopsis: key=r[P2] */
14610 #define OP_IdxDelete 130 /* synopsis: key=r[P2@P3] */
14611 #define OP_DeferredSeek 131 /* synopsis: Move P3 to P1.rowid if needed */
14612 #define OP_IdxRowid 132 /* synopsis: r[P2]=rowid */
14613 #define OP_Destroy 133
14614 #define OP_Real 134 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
14615 #define OP_Clear 135
14616 #define OP_ResetSorter 136
14617 #define OP_CreateBtree 137 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
14618 #define OP_SqlExec 138
14619 #define OP_ParseSchema 139
14620 #define OP_LoadAnalysis 140
14621 #define OP_DropTable 141
14622 #define OP_DropIndex 142
14623 #define OP_DropTrigger 143
14624 #define OP_IntegrityCk 144
14625 #define OP_RowSetAdd 145 /* synopsis: rowset(P1)=r[P2] */
14626 #define OP_Param 146
14627 #define OP_FkCounter 147 /* synopsis: fkctr[P1]+=P2 */
14628 #define OP_MemMax 148 /* synopsis: r[P1]=max(r[P1],r[P2]) */
14629 #define OP_OffsetLimit 149 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
14630 #define OP_AggStep0 150 /* synopsis: accum=r[P3] step(r[P2@P5]) */
14631 #define OP_AggStep 151 /* synopsis: accum=r[P3] step(r[P2@P5]) */
14632 #define OP_AggFinal 152 /* synopsis: accum=r[P1] N=P2 */
14633 #define OP_Expire 153
14634 #define OP_TableLock 154 /* synopsis: iDb=P1 root=P2 write=P3 */
14635 #define OP_VBegin 155
14636 #define OP_VCreate 156
14637 #define OP_VDestroy 157
14638 #define OP_VOpen 158
14639 #define OP_VColumn 159 /* synopsis: r[P3]=vcolumn(P2) */
14640 #define OP_VRename 160
14641 #define OP_Pagecount 161
14642 #define OP_MaxPgcnt 162
14643 #define OP_PureFunc0 163
14644 #define OP_Function0 164 /* synopsis: r[P3]=func(r[P2@P5]) */
14645 #define OP_PureFunc 165
14646 #define OP_Function 166 /* synopsis: r[P3]=func(r[P2@P5]) */
14647 #define OP_Trace 167
14648 #define OP_CursorHint 168
14649 #define OP_Noop 169
14650 #define OP_Explain 170
14651 #define OP_Abortable 171
 
 
 
 
14652
14653 /* Properties such as "out2" or "jump" that are specified in
14654 ** comments following the "case" for each opcode in the vdbe.c
14655 ** are encoded into bitvectors as follows:
14656 */
@@ -14659,40 +14793,41 @@
14659 #define OPFLG_IN2 0x04 /* in2: P2 is an input */
14660 #define OPFLG_IN3 0x08 /* in3: P3 is an input */
14661 #define OPFLG_OUT2 0x10 /* out2: P2 is an output */
14662 #define OPFLG_OUT3 0x20 /* out3: P3 is an output */
14663 #define OPFLG_INITIALIZER {\
14664 /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\
14665 /* 8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\
14666 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x01,\
14667 /* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
14668 /* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
14669 /* 40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\
14670 /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
14671 /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x02,\
14672 /* 64 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\
14673 /* 72 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
14674 /* 80 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x26, 0x26, 0x26,\
14675 /* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x12,\
14676 /* 96 */ 0x12, 0x20, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10,\
14677 /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
14678 /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
14679 /* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
14680 /* 128 */ 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
14681 /* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
14682 /* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00,\
14683 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
14684 /* 160 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
14685 /* 168 */ 0x00, 0x00, 0x00, 0x00,}
 
14686
14687 /* The sqlite3P2Values() routine is able to run faster if it knows
14688 ** the value of the largest JUMP opcode. The smaller the maximum
14689 ** JUMP opcode the better, so the mkopcodeh.tcl script that
14690 ** generated this include file strives to group all JUMP opcodes
14691 ** together near the beginning of the list.
14692 */
14693 #define SQLITE_MX_JUMP_OPCODE 62 /* Maximum JUMP opcode */
14694
14695 /************** End of opcodes.h *********************************************/
14696 /************** Continuing where we left off in vdbe.h ***********************/
14697
14698 /*
@@ -14786,10 +14921,11 @@
14786 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
14787 #ifndef SQLITE_OMIT_TRACE
14788 SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*);
14789 #endif
14790 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
 
14791
14792 SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);
14793 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
14794 SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int);
14795 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*);
@@ -14841,35 +14977,68 @@
14841 **
14842 ** VdbeCoverageAlwaysTaken(v) // Previous branch is always taken
14843 **
14844 ** VdbeCoverageNeverTaken(v) // Previous branch is never taken
14845 **
 
 
 
 
 
 
 
14846 ** Every VDBE branch operation must be tagged with one of the macros above.
14847 ** If not, then when "make test" is run with -DSQLITE_VDBE_COVERAGE and
14848 ** -DSQLITE_DEBUG then an ALWAYS() will fail in the vdbeTakeBranch()
14849 ** routine in vdbe.c, alerting the developer to the missed tag.
 
 
 
 
 
 
 
 
 
 
 
14850 */
14851 #ifdef SQLITE_VDBE_COVERAGE
14852 SQLITE_PRIVATE void sqlite3VdbeSetLineNumber(Vdbe*,int);
14853 # define VdbeCoverage(v) sqlite3VdbeSetLineNumber(v,__LINE__)
14854 # define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__)
14855 # define VdbeCoverageAlwaysTaken(v) sqlite3VdbeSetLineNumber(v,2);
14856 # define VdbeCoverageNeverTaken(v) sqlite3VdbeSetLineNumber(v,1);
 
 
 
 
 
 
 
 
14857 # define VDBE_OFFSET_LINENO(x) (__LINE__+x)
14858 #else
14859 # define VdbeCoverage(v)
14860 # define VdbeCoverageIf(v,x)
14861 # define VdbeCoverageAlwaysTaken(v)
14862 # define VdbeCoverageNeverTaken(v)
 
 
 
14863 # define VDBE_OFFSET_LINENO(x) 0
14864 #endif
14865
14866 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
14867 SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
14868 #else
14869 # define sqlite3VdbeScanStatus(a,b,c,d,e)
14870 #endif
 
 
 
 
14871
14872 #endif /* SQLITE_VDBE_H */
14873
14874 /************** End of vdbe.h ************************************************/
14875 /************** Continuing where we left off in sqliteInt.h ******************/
@@ -16082,10 +16251,11 @@
16082 #define SQLITE_CursorHints 0x0400 /* Add OP_CursorHint opcodes */
16083 #define SQLITE_Stat34 0x0800 /* Use STAT3 or STAT4 data */
16084 /* TH3 expects the Stat34 ^^^^^^ value to be 0x0800. Don't change it */
16085 #define SQLITE_PushDown 0x1000 /* The push-down optimization */
16086 #define SQLITE_SimplifyJoin 0x2000 /* Convert LEFT JOIN to JOIN */
 
16087 #define SQLITE_AllOpts 0xffff /* All optimizations */
16088
16089 /*
16090 ** Macros for testing whether or not optimizations are enabled or disabled.
16091 */
@@ -16120,15 +16290,17 @@
16120 ** The u.pHash field is used by the global built-ins. The u.pDestructor
16121 ** field is used by per-connection app-def functions.
16122 */
16123 struct FuncDef {
16124 i8 nArg; /* Number of arguments. -1 means unlimited */
16125 u16 funcFlags; /* Some combination of SQLITE_FUNC_* */
16126 void *pUserData; /* User data parameter */
16127 FuncDef *pNext; /* Next function with same name */
16128 void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
16129 void (*xFinalize)(sqlite3_context*); /* Agg finalizer */
 
 
16130 const char *zName; /* SQL name of the function. */
16131 union {
16132 FuncDef *pHash; /* Next with a different name but the same hash */
16133 FuncDestructor *pDestructor; /* Reference counted destructor function */
16134 } u;
@@ -16181,10 +16353,12 @@
16181 #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */
16182 #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
16183 ** single query - might change over time */
16184 #define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
16185 #define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */
 
 
16186
16187 /*
16188 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
16189 ** used to create the initializers for the FuncDef structures.
16190 **
@@ -16214,10 +16388,16 @@
16214 ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
16215 ** Used to create an aggregate function definition implemented by
16216 ** the C functions xStep and xFinal. The first four parameters
16217 ** are interpreted in the same way as the first 4 parameters to
16218 ** FUNCTION().
 
 
 
 
 
 
16219 **
16220 ** LIKEFUNC(zName, nArg, pArg, flags)
16221 ** Used to create a scalar function definition of a function zName
16222 ** that accepts nArg arguments and is implemented by a call to C
16223 ** function likeFunc. Argument pArg is cast to a (void *) and made
@@ -16225,35 +16405,39 @@
16225 ** FuncDef.flags variable is set to the value passed as the flags
16226 ** parameter.
16227 */
16228 #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
16229 {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
16230 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
16231 #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
16232 {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
16233 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
16234 #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \
16235 {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \
16236 0, 0, xFunc, 0, #zName, {0} }
16237 #define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \
16238 {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
16239 (void*)&sqlite3Config, 0, xFunc, 0, #zName, {0} }
16240 #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
16241 {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
16242 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
16243 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
16244 {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
16245 pArg, 0, xFunc, 0, #zName, }
16246 #define LIKEFUNC(zName, nArg, arg, flags) \
16247 {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
16248 (void *)arg, 0, likeFunc, 0, #zName, {0} }
16249 #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \
16250 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \
16251 SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName, {0}}
16252 #define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \
16253 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
16254 SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName, {0}}
 
 
 
 
16255
16256 /*
16257 ** All current savepoints are stored in a linked list starting at
16258 ** sqlite3.pSavepoint. The first element in the list is the most recently
16259 ** opened savepoint. Savepoints are added to the list by the vdbe
@@ -16735,10 +16919,11 @@
16735 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
16736 IndexSample *aSample; /* Samples of the left-most key */
16737 tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */
16738 tRowcnt nRowEst0; /* Non-logarithmic number of rows in the index */
16739 #endif
 
16740 };
16741
16742 /*
16743 ** Allowed values for Index.idxType
16744 */
@@ -16950,10 +17135,13 @@
16950 ** TK_COLUMN: the value of p5 for OP_Column
16951 ** TK_AGG_FUNCTION: nesting depth */
16952 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
16953 Table *pTab; /* Table for TK_COLUMN expressions. Can be NULL
16954 ** for a column of an index on an expression */
 
 
 
16955 };
16956
16957 /*
16958 ** The following are the meanings of bits in the Expr.flags field.
16959 */
@@ -17080,35 +17268,10 @@
17080 int idx; /* Index in some Table.aCol[] of a column named zName */
17081 } *a;
17082 int nId; /* Number of identifiers on the list */
17083 };
17084
17085 /*
17086 ** The bitmask datatype defined below is used for various optimizations.
17087 **
17088 ** Changing this from a 64-bit to a 32-bit type limits the number of
17089 ** tables in a join to 32 instead of 64. But it also reduces the size
17090 ** of the library by 738 bytes on ix86.
17091 */
17092 #ifdef SQLITE_BITMASK_TYPE
17093 typedef SQLITE_BITMASK_TYPE Bitmask;
17094 #else
17095 typedef u64 Bitmask;
17096 #endif
17097
17098 /*
17099 ** The number of bits in a Bitmask. "BMS" means "BitMask Size".
17100 */
17101 #define BMS ((int)(sizeof(Bitmask)*8))
17102
17103 /*
17104 ** A bit in a Bitmask
17105 */
17106 #define MASKBIT(n) (((Bitmask)1)<<(n))
17107 #define MASKBIT32(n) (((unsigned int)1)<<(n))
17108 #define ALLBITS ((Bitmask)-1)
17109
17110 /*
17111 ** The following structure describes the FROM clause of a SELECT statement.
17112 ** Each table or subquery in the FROM clause is a separate element of
17113 ** the SrcList.a[] array.
17114 **
@@ -17236,10 +17399,11 @@
17236 } uNC;
17237 NameContext *pNext; /* Next outer name context. NULL for outermost */
17238 int nRef; /* Number of names resolved by this context */
17239 int nErr; /* Number of errors encountered while resolving names */
17240 u16 ncFlags; /* Zero or more NC_* flags defined below */
 
17241 };
17242
17243 /*
17244 ** Allowed values for the NameContext, ncFlags field.
17245 **
@@ -17258,10 +17422,11 @@
17258 #define NC_UEList 0x0080 /* True if uNC.pEList is used */
17259 #define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */
17260 #define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */
17261 #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
17262 #define NC_Complex 0x2000 /* True if a function or subquery seen */
 
17263
17264 /*
17265 ** An instance of the following object describes a single ON CONFLICT
17266 ** clause in an upsert.
17267 **
@@ -17312,13 +17477,11 @@
17312 ExprList *pEList; /* The fields of the result */
17313 u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
17314 LogEst nSelectRow; /* Estimated number of result rows */
17315 u32 selFlags; /* Various SF_* values */
17316 int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */
17317 #if SELECTTRACE_ENABLED
17318 char zSelName[12]; /* Symbolic name of this SELECT use for debugging */
17319 #endif
17320 int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */
17321 SrcList *pSrc; /* The FROM clause */
17322 Expr *pWhere; /* The WHERE clause */
17323 ExprList *pGroupBy; /* The GROUP BY clause */
17324 Expr *pHaving; /* The HAVING clause */
@@ -17325,10 +17488,14 @@
17325 ExprList *pOrderBy; /* The ORDER BY clause */
17326 Select *pPrior; /* Prior select in a compound select statement */
17327 Select *pNext; /* Next select to the left in a compound */
17328 Expr *pLimit; /* LIMIT expression. NULL means not used. */
17329 With *pWith; /* WITH clause attached to this select. Or NULL. */
 
 
 
 
17330 };
17331
17332 /*
17333 ** Allowed values for Select.selFlags. The "SF" prefix stands for
17334 ** "Select Flag".
@@ -17571,13 +17738,11 @@
17571 yDbMask writeMask; /* Start a write transaction on these databases */
17572 yDbMask cookieMask; /* Bitmask of schema verified databases */
17573 int regRowid; /* Register holding rowid of CREATE TABLE entry */
17574 int regRoot; /* Register holding root page number for new objects */
17575 int nMaxArg; /* Max args passed to user function by sub-program */
17576 #if SELECTTRACE_ENABLED
17577 int nSelect; /* Number of SELECT statements seen */
17578 #endif
17579 #ifndef SQLITE_OMIT_SHARED_CACHE
17580 int nTableLock; /* Number of locks in aTableLock */
17581 TableLock *aTableLock; /* Required table locks for shared-cache mode */
17582 #endif
17583 AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
@@ -17887,11 +18052,11 @@
17887 #endif
17888 #ifdef SQLITE_VDBE_COVERAGE
17889 /* The following callback (if not NULL) is invoked on every VDBE branch
17890 ** operation. Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE.
17891 */
17892 void (*xVdbeBranch)(void*,int iSrcLine,u8 eThis,u8 eMx); /* Callback */
17893 void *pVdbeBranchArg; /* 1st argument */
17894 #endif
17895 #ifndef SQLITE_UNTESTABLE
17896 int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
17897 #endif
@@ -17938,10 +18103,11 @@
17938 int *aiCol; /* array of column indexes */
17939 struct IdxCover *pIdxCover; /* Check for index coverage */
17940 struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */
17941 ExprList *pGroupBy; /* GROUP BY clause */
17942 Select *pSelect; /* HAVING to WHERE clause ctx */
 
17943 } u;
17944 };
17945
17946 /* Forward declarations */
17947 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -17988,10 +18154,72 @@
17988 int iLevel; /* Which level of the tree we are on */
17989 u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */
17990 };
17991 #endif /* SQLITE_DEBUG */
17992
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17993 /*
17994 ** Assuming zIn points to the first byte of a UTF-8 character,
17995 ** advance zIn to point to the first byte of the next UTF-8 character.
17996 */
17997 #define SQLITE_SKIP_UTF8(zIn) { \
@@ -18202,10 +18430,14 @@
18202 SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
18203 SQLITE_PRIVATE void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);
18204 SQLITE_PRIVATE void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
18205 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
18206 SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView*, const With*, u8);
 
 
 
 
18207 #endif
18208
18209
18210 SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*);
18211 SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);
@@ -18457,15 +18689,10 @@
18457 SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
18458 SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
18459 SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
18460 SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
18461 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
18462 #if SELECTTRACE_ENABLED
18463 SQLITE_PRIVATE void sqlite3SelectSetName(Select*,const char*);
18464 #else
18465 # define sqlite3SelectSetName(A,B)
18466 #endif
18467 SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int);
18468 SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
18469 SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);
18470 SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
18471 SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
@@ -18695,16 +18922,21 @@
18695 SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
18696 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);
18697 SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo*);
18698 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo*);
18699 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);
 
 
18700 #ifdef SQLITE_DEBUG
18701 SQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo*);
18702 #endif
18703 SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
18704 void (*)(sqlite3_context*,int,sqlite3_value **),
18705 void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
 
 
 
18706 FuncDestructor *pDestructor
18707 );
18708 SQLITE_PRIVATE void sqlite3NoopDestructor(void*);
18709 SQLITE_PRIVATE void sqlite3OomFault(sqlite3*);
18710 SQLITE_PRIVATE void sqlite3OomClear(sqlite3*);
@@ -18741,10 +18973,11 @@
18741 #ifndef SQLITE_AMALGAMATION
18742 SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64), Parse*);
18743 SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*));
18744 #endif
18745 SQLITE_PRIVATE void sqlite3Parser(void*, int, Token);
 
18746 #ifdef YYTRACKMAXSTACKDEPTH
18747 SQLITE_PRIVATE int sqlite3ParserStackPeak(void*);
18748 #endif
18749
18750 SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3*);
@@ -19441,10 +19674,11 @@
19441 u8 wrFlag; /* The wrFlag argument to sqlite3BtreeCursor() */
19442 #endif
19443 Bool isEphemeral:1; /* True for an ephemeral table */
19444 Bool useRandomRowid:1; /* Generate new record numbers semi-randomly */
19445 Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
 
19446 Btree *pBtx; /* Separate file holding temporary table */
19447 i64 seqCount; /* Sequence counter */
19448 int *aAltMap; /* Mapping from table to index column numbers */
19449
19450 /* Cached OP_Column parse information is only valid if cacheStatus matches
@@ -19564,11 +19798,15 @@
19564 u32 uTemp; /* Transient storage for serial_type in OP_MakeRecord */
19565 sqlite3 *db; /* The associated database connection */
19566 void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
19567 #ifdef SQLITE_DEBUG
19568 Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
19569 void *pFiller; /* So that sizeof(Mem) is a multiple of 8 */
 
 
 
 
19570 #endif
19571 };
19572
19573 /*
19574 ** Size of struct Mem not including the Mem.zMalloc member or anything that
@@ -19804,13 +20042,10 @@
19804 SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...);
19805 SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);
19806 void sqliteVdbePopStack(Vdbe*,int);
19807 SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, int*);
19808 SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
19809 #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
19810 SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, Op*);
19811 #endif
19812 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
19813 SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
19814 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int, u32*);
19815 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
19816 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
@@ -19851,10 +20086,13 @@
19851 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
19852 SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem*,u8,u8);
19853 SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);
19854 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
19855 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
 
 
 
19856 SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
19857 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
19858 SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int n);
19859 SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
19860 SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
@@ -21953,13 +22191,16 @@
21953
21954 /*
21955 ** Unregister a VFS so that it is no longer accessible.
21956 */
21957 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
21958 #if SQLITE_THREADSAFE
21959 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
 
 
21960 #endif
 
21961 sqlite3_mutex_enter(mutex);
21962 vfsUnlink(pVfs);
21963 sqlite3_mutex_leave(mutex);
21964 return SQLITE_OK;
21965 }
@@ -27984,25 +28225,17 @@
27984 sqlite3TreeViewWith(pView, p->pWith, 1);
27985 cnt = 1;
27986 sqlite3TreeViewPush(pView, 1);
27987 }
27988 do{
27989 #if SELECTTRACE_ENABLED
27990 sqlite3TreeViewLine(pView,
27991 "SELECT%s%s (%s/%p) selFlags=0x%x nSelectRow=%d",
27992 ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
27993 ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""),
27994 p->zSelName, p, p->selFlags,
27995 (int)p->nSelectRow
27996 );
27997 #else
27998 sqlite3TreeViewLine(pView, "SELECT%s%s (0x%p) selFlags=0x%x nSelectRow=%d",
27999 ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
28000 ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""), p, p->selFlags,
28001 (int)p->nSelectRow
28002 );
28003 #endif
28004 if( cnt++ ) sqlite3TreeViewPop(pView);
28005 if( p->pPrior ){
28006 n = 1000;
28007 }else{
28008 n = 0;
@@ -28010,12 +28243,27 @@
28010 if( p->pWhere ) n++;
28011 if( p->pGroupBy ) n++;
28012 if( p->pHaving ) n++;
28013 if( p->pOrderBy ) n++;
28014 if( p->pLimit ) n++;
 
 
 
 
28015 }
28016 sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, "result-set");
 
 
 
 
 
 
 
 
 
 
 
28017 if( p->pSrc && p->pSrc->nSrc ){
28018 int i;
28019 pView = sqlite3TreeViewPush(pView, (n--)>0);
28020 sqlite3TreeViewLine(pView, "FROM");
28021 for(i=0; i<p->pSrc->nSrc; i++){
@@ -28061,10 +28309,20 @@
28061 if( p->pHaving ){
28062 sqlite3TreeViewItem(pView, "HAVING", (n--)>0);
28063 sqlite3TreeViewExpr(pView, p->pHaving, 0);
28064 sqlite3TreeViewPop(pView);
28065 }
 
 
 
 
 
 
 
 
 
 
28066 if( p->pOrderBy ){
28067 sqlite3TreeViewExprList(pView, p->pOrderBy, (n--)>0, "ORDERBY");
28068 }
28069 if( p->pLimit ){
28070 sqlite3TreeViewItem(pView, "LIMIT", (n--)>0);
@@ -28088,10 +28346,87 @@
28088 p = p->pPrior;
28089 }while( p!=0 );
28090 sqlite3TreeViewPop(pView);
28091 }
28092
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28093 /*
28094 ** Generate a human-readable explanation of an expression tree.
28095 */
28096 SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){
28097 const char *zBinOp = 0; /* Binary operator */
@@ -28238,24 +28573,36 @@
28238 }
28239
28240 case TK_AGG_FUNCTION:
28241 case TK_FUNCTION: {
28242 ExprList *pFarg; /* List of function arguments */
 
28243 if( ExprHasProperty(pExpr, EP_TokenOnly) ){
28244 pFarg = 0;
 
28245 }else{
28246 pFarg = pExpr->x.pList;
 
 
 
 
 
28247 }
28248 if( pExpr->op==TK_AGG_FUNCTION ){
28249 sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q",
28250 pExpr->op2, pExpr->u.zToken);
28251 }else{
28252 sqlite3TreeViewLine(pView, "FUNCTION %Q", pExpr->u.zToken);
28253 }
28254 if( pFarg ){
28255 sqlite3TreeViewExprList(pView, pFarg, 0, 0);
28256 }
 
 
 
 
 
28257 break;
28258 }
28259 #ifndef SQLITE_OMIT_SUBQUERY
28260 case TK_EXISTS: {
28261 sqlite3TreeViewLine(pView, "EXISTS-expr flags=0x%x", pExpr->flags);
@@ -31283,122 +31630,122 @@
31283 static const char *const azName[] = {
31284 /* 0 */ "Savepoint" OpHelp(""),
31285 /* 1 */ "AutoCommit" OpHelp(""),
31286 /* 2 */ "Transaction" OpHelp(""),
31287 /* 3 */ "SorterNext" OpHelp(""),
31288 /* 4 */ "PrevIfOpen" OpHelp(""),
31289 /* 5 */ "NextIfOpen" OpHelp(""),
31290 /* 6 */ "Prev" OpHelp(""),
31291 /* 7 */ "Next" OpHelp(""),
31292 /* 8 */ "Checkpoint" OpHelp(""),
31293 /* 9 */ "JournalMode" OpHelp(""),
31294 /* 10 */ "Vacuum" OpHelp(""),
31295 /* 11 */ "VFilter" OpHelp("iplan=r[P3] zplan='P4'"),
31296 /* 12 */ "VUpdate" OpHelp("data=r[P3@P2]"),
31297 /* 13 */ "Goto" OpHelp(""),
31298 /* 14 */ "Gosub" OpHelp(""),
31299 /* 15 */ "InitCoroutine" OpHelp(""),
31300 /* 16 */ "Yield" OpHelp(""),
31301 /* 17 */ "MustBeInt" OpHelp(""),
31302 /* 18 */ "Jump" OpHelp(""),
31303 /* 19 */ "Not" OpHelp("r[P2]= !r[P1]"),
31304 /* 20 */ "Once" OpHelp(""),
31305 /* 21 */ "If" OpHelp(""),
31306 /* 22 */ "IfNot" OpHelp(""),
31307 /* 23 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"),
31308 /* 24 */ "SeekLT" OpHelp("key=r[P3@P4]"),
31309 /* 25 */ "SeekLE" OpHelp("key=r[P3@P4]"),
31310 /* 26 */ "SeekGE" OpHelp("key=r[P3@P4]"),
31311 /* 27 */ "SeekGT" OpHelp("key=r[P3@P4]"),
31312 /* 28 */ "NoConflict" OpHelp("key=r[P3@P4]"),
31313 /* 29 */ "NotFound" OpHelp("key=r[P3@P4]"),
31314 /* 30 */ "Found" OpHelp("key=r[P3@P4]"),
31315 /* 31 */ "SeekRowid" OpHelp("intkey=r[P3]"),
31316 /* 32 */ "NotExists" OpHelp("intkey=r[P3]"),
31317 /* 33 */ "Last" OpHelp(""),
31318 /* 34 */ "IfSmaller" OpHelp(""),
31319 /* 35 */ "SorterSort" OpHelp(""),
31320 /* 36 */ "Sort" OpHelp(""),
31321 /* 37 */ "Rewind" OpHelp(""),
31322 /* 38 */ "IdxLE" OpHelp("key=r[P3@P4]"),
31323 /* 39 */ "IdxGT" OpHelp("key=r[P3@P4]"),
31324 /* 40 */ "IdxLT" OpHelp("key=r[P3@P4]"),
31325 /* 41 */ "IdxGE" OpHelp("key=r[P3@P4]"),
31326 /* 42 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
31327 /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
31328 /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
31329 /* 45 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
31330 /* 46 */ "Program" OpHelp(""),
31331 /* 47 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
31332 /* 48 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
31333 /* 49 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
31334 /* 50 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
31335 /* 51 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
31336 /* 52 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
31337 /* 53 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
31338 /* 54 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
31339 /* 55 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
31340 /* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
31341 /* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
31342 /* 58 */ "ElseNotEq" OpHelp(""),
31343 /* 59 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
31344 /* 60 */ "IncrVacuum" OpHelp(""),
31345 /* 61 */ "VNext" OpHelp(""),
31346 /* 62 */ "Init" OpHelp("Start at P2"),
31347 /* 63 */ "Return" OpHelp(""),
31348 /* 64 */ "EndCoroutine" OpHelp(""),
31349 /* 65 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
31350 /* 66 */ "Halt" OpHelp(""),
31351 /* 67 */ "Integer" OpHelp("r[P2]=P1"),
31352 /* 68 */ "Int64" OpHelp("r[P2]=P4"),
31353 /* 69 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
31354 /* 70 */ "Null" OpHelp("r[P2..P3]=NULL"),
31355 /* 71 */ "SoftNull" OpHelp("r[P1]=NULL"),
31356 /* 72 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
31357 /* 73 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
31358 /* 74 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
31359 /* 75 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
31360 /* 76 */ "SCopy" OpHelp("r[P2]=r[P1]"),
31361 /* 77 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
31362 /* 78 */ "ResultRow" OpHelp("output=r[P1@P2]"),
31363 /* 79 */ "CollSeq" OpHelp(""),
31364 /* 80 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
31365 /* 81 */ "RealAffinity" OpHelp(""),
31366 /* 82 */ "Cast" OpHelp("affinity(r[P1])"),
31367 /* 83 */ "Permutation" OpHelp(""),
31368 /* 84 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
31369 /* 85 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
31370 /* 86 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
31371 /* 87 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
31372 /* 88 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
31373 /* 89 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
31374 /* 90 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
31375 /* 91 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
31376 /* 92 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
31377 /* 93 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
31378 /* 94 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
31379 /* 95 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
31380 /* 96 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
31381 /* 97 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
31382 /* 98 */ "Column" OpHelp("r[P3]=PX"),
31383 /* 99 */ "String8" OpHelp("r[P2]='P4'"),
31384 /* 100 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
31385 /* 101 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
31386 /* 102 */ "Count" OpHelp("r[P2]=count()"),
31387 /* 103 */ "ReadCookie" OpHelp(""),
31388 /* 104 */ "SetCookie" OpHelp(""),
31389 /* 105 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
31390 /* 106 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
31391 /* 107 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
31392 /* 108 */ "OpenDup" OpHelp(""),
31393 /* 109 */ "OpenAutoindex" OpHelp("nColumn=P2"),
31394 /* 110 */ "OpenEphemeral" OpHelp("nColumn=P2"),
31395 /* 111 */ "SorterOpen" OpHelp(""),
31396 /* 112 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
31397 /* 113 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
31398 /* 114 */ "Close" OpHelp(""),
31399 /* 115 */ "ColumnsUsed" OpHelp(""),
31400 /* 116 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
31401 /* 117 */ "NewRowid" OpHelp("r[P2]=rowid"),
31402 /* 118 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
31403 /* 119 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
31404 /* 120 */ "Delete" OpHelp(""),
@@ -31413,48 +31760,52 @@
31413 /* 129 */ "IdxInsert" OpHelp("key=r[P2]"),
31414 /* 130 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
31415 /* 131 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
31416 /* 132 */ "IdxRowid" OpHelp("r[P2]=rowid"),
31417 /* 133 */ "Destroy" OpHelp(""),
31418 /* 134 */ "Real" OpHelp("r[P2]=P4"),
31419 /* 135 */ "Clear" OpHelp(""),
31420 /* 136 */ "ResetSorter" OpHelp(""),
31421 /* 137 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
31422 /* 138 */ "SqlExec" OpHelp(""),
31423 /* 139 */ "ParseSchema" OpHelp(""),
31424 /* 140 */ "LoadAnalysis" OpHelp(""),
31425 /* 141 */ "DropTable" OpHelp(""),
31426 /* 142 */ "DropIndex" OpHelp(""),
31427 /* 143 */ "DropTrigger" OpHelp(""),
31428 /* 144 */ "IntegrityCk" OpHelp(""),
31429 /* 145 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
31430 /* 146 */ "Param" OpHelp(""),
31431 /* 147 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
31432 /* 148 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
31433 /* 149 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
31434 /* 150 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
31435 /* 151 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
31436 /* 152 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
31437 /* 153 */ "Expire" OpHelp(""),
31438 /* 154 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
31439 /* 155 */ "VBegin" OpHelp(""),
31440 /* 156 */ "VCreate" OpHelp(""),
31441 /* 157 */ "VDestroy" OpHelp(""),
31442 /* 158 */ "VOpen" OpHelp(""),
31443 /* 159 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
31444 /* 160 */ "VRename" OpHelp(""),
31445 /* 161 */ "Pagecount" OpHelp(""),
31446 /* 162 */ "MaxPgcnt" OpHelp(""),
31447 /* 163 */ "PureFunc0" OpHelp(""),
31448 /* 164 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
31449 /* 165 */ "PureFunc" OpHelp(""),
31450 /* 166 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
31451 /* 167 */ "Trace" OpHelp(""),
31452 /* 168 */ "CursorHint" OpHelp(""),
31453 /* 169 */ "Noop" OpHelp(""),
31454 /* 170 */ "Explain" OpHelp(""),
31455 /* 171 */ "Abortable" OpHelp(""),
 
 
 
 
31456 };
31457 return azName[i];
31458 }
31459 #endif
31460
@@ -58091,53 +58442,56 @@
58091 return (iPage*HASHTABLE_HASH_1) & (HASHTABLE_NSLOT-1);
58092 }
58093 static int walNextHash(int iPriorHash){
58094 return (iPriorHash+1)&(HASHTABLE_NSLOT-1);
58095 }
 
 
 
 
 
 
 
 
 
 
 
 
58096
58097 /*
58098 ** Return pointers to the hash table and page number array stored on
58099 ** page iHash of the wal-index. The wal-index is broken into 32KB pages
58100 ** numbered starting from 0.
58101 **
58102 ** Set output variable *paHash to point to the start of the hash table
58103 ** in the wal-index file. Set *piZero to one less than the frame
58104 ** number of the first frame indexed by this hash table. If a
58105 ** slot in the hash table is set to N, it refers to frame number
58106 ** (*piZero+N) in the log.
58107 **
58108 ** Finally, set *paPgno so that *paPgno[1] is the page number of the
58109 ** first frame indexed by the hash table, frame (*piZero+1).
58110 */
58111 static int walHashGet(
58112 Wal *pWal, /* WAL handle */
58113 int iHash, /* Find the iHash'th table */
58114 volatile ht_slot **paHash, /* OUT: Pointer to hash index */
58115 volatile u32 **paPgno, /* OUT: Pointer to page number array */
58116 u32 *piZero /* OUT: Frame associated with *paPgno[0] */
58117 ){
58118 int rc; /* Return code */
58119 volatile u32 *aPgno;
58120
58121 rc = walIndexPage(pWal, iHash, &aPgno);
58122 assert( rc==SQLITE_OK || iHash>0 );
58123
58124 if( rc==SQLITE_OK ){
58125 u32 iZero;
58126 volatile ht_slot *aHash;
58127
58128 aHash = (volatile ht_slot *)&aPgno[HASHTABLE_NPAGE];
58129 if( iHash==0 ){
58130 aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];
58131 iZero = 0;
58132 }else{
58133 iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;
58134 }
58135
58136 *paPgno = &aPgno[-1];
58137 *paHash = aHash;
58138 *piZero = iZero;
58139 }
58140 return rc;
58141 }
58142
58143 /*
@@ -58179,13 +58533,11 @@
58179 ** updated. Any later hash tables will be automatically cleared when
58180 ** pWal->hdr.mxFrame advances to the point where those hash tables are
58181 ** actually needed.
58182 */
58183 static void walCleanupHash(Wal *pWal){
58184 volatile ht_slot *aHash = 0; /* Pointer to hash table to clear */
58185 volatile u32 *aPgno = 0; /* Page number array for hash table */
58186 u32 iZero = 0; /* frame == (aHash[x]+iZero) */
58187 int iLimit = 0; /* Zero values greater than this */
58188 int nByte; /* Number of bytes to zero in aPgno[] */
58189 int i; /* Used to iterate through aHash[] */
58190
58191 assert( pWal->writeLock );
@@ -58199,41 +58551,41 @@
58199 ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
58200 ** that the page said hash-table and array reside on is already mapped.
58201 */
58202 assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
58203 assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
58204 walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &aHash, &aPgno, &iZero);
58205
58206 /* Zero all hash-table entries that correspond to frame numbers greater
58207 ** than pWal->hdr.mxFrame.
58208 */
58209 iLimit = pWal->hdr.mxFrame - iZero;
58210 assert( iLimit>0 );
58211 for(i=0; i<HASHTABLE_NSLOT; i++){
58212 if( aHash[i]>iLimit ){
58213 aHash[i] = 0;
58214 }
58215 }
58216
58217 /* Zero the entries in the aPgno array that correspond to frames with
58218 ** frame numbers greater than pWal->hdr.mxFrame.
58219 */
58220 nByte = (int)((char *)aHash - (char *)&aPgno[iLimit+1]);
58221 memset((void *)&aPgno[iLimit+1], 0, nByte);
58222
58223 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
58224 /* Verify that the every entry in the mapping region is still reachable
58225 ** via the hash table even after the cleanup.
58226 */
58227 if( iLimit ){
58228 int j; /* Loop counter */
58229 int iKey; /* Hash key */
58230 for(j=1; j<=iLimit; j++){
58231 for(iKey=walHash(aPgno[j]); aHash[iKey]; iKey=walNextHash(iKey)){
58232 if( aHash[iKey]==j ) break;
58233 }
58234 assert( aHash[iKey]==j );
58235 }
58236 }
58237 #endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
58238 }
58239
@@ -58242,62 +58594,61 @@
58242 ** Set an entry in the wal-index that will map database page number
58243 ** pPage into WAL frame iFrame.
58244 */
58245 static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
58246 int rc; /* Return code */
58247 u32 iZero = 0; /* One less than frame number of aPgno[1] */
58248 volatile u32 *aPgno = 0; /* Page number array */
58249 volatile ht_slot *aHash = 0; /* Hash table */
58250
58251 rc = walHashGet(pWal, walFramePage(iFrame), &aHash, &aPgno, &iZero);
58252
58253 /* Assuming the wal-index file was successfully mapped, populate the
58254 ** page number array and hash table entry.
58255 */
58256 if( rc==SQLITE_OK ){
58257 int iKey; /* Hash table key */
58258 int idx; /* Value to write to hash-table slot */
58259 int nCollide; /* Number of hash collisions */
58260
58261 idx = iFrame - iZero;
58262 assert( idx <= HASHTABLE_NSLOT/2 + 1 );
58263
58264 /* If this is the first entry to be added to this hash-table, zero the
58265 ** entire hash table and aPgno[] array before proceeding.
58266 */
58267 if( idx==1 ){
58268 int nByte = (int)((u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1]);
58269 memset((void*)&aPgno[1], 0, nByte);
 
58270 }
58271
58272 /* If the entry in aPgno[] is already set, then the previous writer
58273 ** must have exited unexpectedly in the middle of a transaction (after
58274 ** writing one or more dirty pages to the WAL to free up memory).
58275 ** Remove the remnants of that writers uncommitted transaction from
58276 ** the hash-table before writing any new entries.
58277 */
58278 if( aPgno[idx] ){
58279 walCleanupHash(pWal);
58280 assert( !aPgno[idx] );
58281 }
58282
58283 /* Write the aPgno[] array entry and the hash-table slot. */
58284 nCollide = idx;
58285 for(iKey=walHash(iPage); aHash[iKey]; iKey=walNextHash(iKey)){
58286 if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;
58287 }
58288 aPgno[idx] = iPage;
58289 aHash[iKey] = (ht_slot)idx;
58290
58291 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
58292 /* Verify that the number of entries in the hash table exactly equals
58293 ** the number of entries in the mapping region.
58294 */
58295 {
58296 int i; /* Loop counter */
58297 int nEntry = 0; /* Number of entries in the hash table */
58298 for(i=0; i<HASHTABLE_NSLOT; i++){ if( aHash[i] ) nEntry++; }
58299 assert( nEntry==idx );
58300 }
58301
58302 /* Verify that the every entry in the mapping region is reachable
58303 ** via the hash table. This turns out to be a really, really expensive
@@ -58305,14 +58656,16 @@
58305 ** iteration.
58306 */
58307 if( (idx&0x3ff)==0 ){
58308 int i; /* Loop counter */
58309 for(i=1; i<=idx; i++){
58310 for(iKey=walHash(aPgno[i]); aHash[iKey]; iKey=walNextHash(iKey)){
58311 if( aHash[iKey]==i ) break;
 
 
58312 }
58313 assert( aHash[iKey]==i );
58314 }
58315 }
58316 #endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
58317 }
58318
@@ -58846,37 +59199,35 @@
58846 if( !aTmp ){
58847 rc = SQLITE_NOMEM_BKPT;
58848 }
58849
58850 for(i=walFramePage(nBackfill+1); rc==SQLITE_OK && i<nSegment; i++){
58851 volatile ht_slot *aHash;
58852 u32 iZero;
58853 volatile u32 *aPgno;
58854
58855 rc = walHashGet(pWal, i, &aHash, &aPgno, &iZero);
58856 if( rc==SQLITE_OK ){
58857 int j; /* Counter variable */
58858 int nEntry; /* Number of entries in this segment */
58859 ht_slot *aIndex; /* Sorted index for this segment */
58860
58861 aPgno++;
58862 if( (i+1)==nSegment ){
58863 nEntry = (int)(iLast - iZero);
58864 }else{
58865 nEntry = (int)((u32*)aHash - (u32*)aPgno);
58866 }
58867 aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[iZero];
58868 iZero++;
58869
58870 for(j=0; j<nEntry; j++){
58871 aIndex[j] = (ht_slot)j;
58872 }
58873 walMergesort((u32 *)aPgno, aTmp, aIndex, &nEntry);
58874 p->aSegment[i].iZero = iZero;
58875 p->aSegment[i].nEntry = nEntry;
58876 p->aSegment[i].aIndex = aIndex;
58877 p->aSegment[i].aPgno = (u32 *)aPgno;
58878 }
58879 }
58880 sqlite3_free(aTmp);
58881
58882 if( rc!=SQLITE_OK ){
@@ -59885,20 +60236,18 @@
59885 if( pBuf1==0 || pBuf2==0 ){
59886 rc = SQLITE_NOMEM;
59887 }else{
59888 u32 i = pInfo->nBackfillAttempted;
59889 for(i=pInfo->nBackfillAttempted; i>pInfo->nBackfill; i--){
59890 volatile ht_slot *dummy;
59891 volatile u32 *aPgno; /* Array of page numbers */
59892 u32 iZero; /* Frame corresponding to aPgno[0] */
59893 u32 pgno; /* Page number in db file */
59894 i64 iDbOff; /* Offset of db file entry */
59895 i64 iWalOff; /* Offset of wal file entry */
59896
59897 rc = walHashGet(pWal, walFramePage(i), &dummy, &aPgno, &iZero);
59898 if( rc!=SQLITE_OK ) break;
59899 pgno = aPgno[i-iZero];
59900 iDbOff = (i64)(pgno-1) * szPage;
59901
59902 if( iDbOff+szPage<=szDb ){
59903 iWalOff = walFrameOffset(i, szPage) + WAL_FRAME_HDRSIZE;
59904 rc = sqlite3OsRead(pWal->pWalFd, pBuf1, szPage, iWalOff);
@@ -60095,25 +60444,24 @@
60095 ** This condition filters out entries that were added to the hash
60096 ** table after the current read-transaction had started.
60097 */
60098 iMinHash = walFramePage(pWal->minFrame);
60099 for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){
60100 volatile ht_slot *aHash; /* Pointer to hash table */
60101 volatile u32 *aPgno; /* Pointer to array of page numbers */
60102 u32 iZero; /* Frame number corresponding to aPgno[0] */
60103 int iKey; /* Hash slot index */
60104 int nCollide; /* Number of hash collisions remaining */
60105 int rc; /* Error code */
60106
60107 rc = walHashGet(pWal, iHash, &aHash, &aPgno, &iZero);
60108 if( rc!=SQLITE_OK ){
60109 return rc;
60110 }
60111 nCollide = HASHTABLE_NSLOT;
60112 for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){
60113 u32 iFrame = aHash[iKey] + iZero;
60114 if( iFrame<=iLast && iFrame>=pWal->minFrame && aPgno[aHash[iKey]]==pgno ){
 
60115 assert( iFrame>iRead || CORRUPT_DB );
60116 iRead = iFrame;
60117 }
60118 if( (nCollide--)==0 ){
60119 return SQLITE_CORRUPT_BKPT;
@@ -65329,11 +65677,11 @@
65329 ** One or the other of the two processes must give way or there can be
65330 ** no progress. By returning SQLITE_BUSY and not invoking the busy callback
65331 ** when A already has a read lock, we encourage A to give up and let B
65332 ** proceed.
65333 */
65334 SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag){
65335 BtShared *pBt = p->pBt;
65336 int rc = SQLITE_OK;
65337
65338 sqlite3BtreeEnter(p);
65339 btreeIntegrity(p);
@@ -65404,10 +65752,15 @@
65404 rc = SQLITE_READONLY;
65405 }else{
65406 rc = sqlite3PagerBegin(pBt->pPager,wrflag>1,sqlite3TempInMemory(p->db));
65407 if( rc==SQLITE_OK ){
65408 rc = newDatabase(pBt);
 
 
 
 
 
65409 }
65410 }
65411 }
65412
65413 if( rc!=SQLITE_OK ){
@@ -65455,18 +65808,22 @@
65455 }
65456 }
65457 }
65458 }
65459
65460
65461 trans_begun:
65462 if( rc==SQLITE_OK && wrflag ){
65463 /* This call makes sure that the pager has the correct number of
65464 ** open savepoints. If the second parameter is greater than 0 and
65465 ** the sub-journal is not already open, then it will be opened here.
65466 */
65467 rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);
 
 
 
 
 
65468 }
65469
65470 btreeIntegrity(p);
65471 sqlite3BtreeLeave(p);
65472 return rc;
@@ -67209,10 +67566,27 @@
67209 rc = SQLITE_OK;
67210 }
67211 return rc;
67212 }
67213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67214 /* Move the cursor to the last entry in the table. Return SQLITE_OK
67215 ** on success. Set *pRes to 0 if the cursor actually points to something
67216 ** or set *pRes to 1 if the table is empty.
67217 */
67218 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
@@ -67613,11 +67987,20 @@
67613 }
67614 }
67615
67616 pPage = pCur->pPage;
67617 idx = ++pCur->ix;
67618 assert( pPage->isInit );
 
 
 
 
 
 
 
 
 
67619
67620 /* If the database file is corrupt, it is possible for the value of idx
67621 ** to be invalid here. This can only occur if a second cursor modifies
67622 ** the page while cursor pCur is holding a reference to it. Which can
67623 ** only happen if the database is corrupt in such a way as to link the
@@ -72113,15 +72496,15 @@
72113 ** WAL connection, even if the version fields are currently set to 2.
72114 */
72115 pBt->btsFlags &= ~BTS_NO_WAL;
72116 if( iVersion==1 ) pBt->btsFlags |= BTS_NO_WAL;
72117
72118 rc = sqlite3BtreeBeginTrans(pBtree, 0);
72119 if( rc==SQLITE_OK ){
72120 u8 *aData = pBt->pPage1->aData;
72121 if( aData[18]!=(u8)iVersion || aData[19]!=(u8)iVersion ){
72122 rc = sqlite3BtreeBeginTrans(pBtree, 2);
72123 if( rc==SQLITE_OK ){
72124 rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
72125 if( rc==SQLITE_OK ){
72126 aData[18] = (u8)iVersion;
72127 aData[19] = (u8)iVersion;
@@ -72557,11 +72940,11 @@
72557 /* If there is no open read-transaction on the source database, open
72558 ** one now. If a transaction is opened here, then it will be closed
72559 ** before this function exits.
72560 */
72561 if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){
72562 rc = sqlite3BtreeBeginTrans(p->pSrc, 0);
72563 bCloseTrans = 1;
72564 }
72565
72566 /* If the destination database has not yet been locked (i.e. if this
72567 ** is the first call to backup_step() for the current backup operation),
@@ -72573,14 +72956,14 @@
72573 rc = SQLITE_NOMEM;
72574 }
72575
72576 /* Lock the destination database, if it is not locked already. */
72577 if( SQLITE_OK==rc && p->bDestLocked==0
72578 && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2))
 
72579 ){
72580 p->bDestLocked = 1;
72581 sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);
72582 }
72583
72584 /* Do not allow backup if the destination database is in WAL mode
72585 ** and the page sizes are different between source and destination */
72586 pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);
@@ -73393,10 +73776,39 @@
73393 if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
73394 memcpy(pMem, &t, sizeof(t));
73395 return ctx.isError;
73396 }
73397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73398 /*
73399 ** If the memory cell contains a value that must be freed by
73400 ** invoking the external callback in Mem.xDel, then this routine
73401 ** will free that value. It also sets Mem.flags to MEM_Null.
73402 **
@@ -73864,15 +74276,32 @@
73864 SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
73865 int i;
73866 Mem *pX;
73867 for(i=0, pX=pVdbe->aMem; i<pVdbe->nMem; i++, pX++){
73868 if( pX->pScopyFrom==pMem ){
73869 pX->flags |= MEM_Undefined;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73870 pX->pScopyFrom = 0;
73871 }
73872 }
73873 pMem->pScopyFrom = 0;
 
 
 
73874 }
73875 #endif /* SQLITE_DEBUG */
73876
73877
73878 /*
@@ -73889,10 +74318,13 @@
73889 SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
73890 assert( (pFrom->flags & MEM_RowSet)==0 );
73891 assert( pTo->db==pFrom->db );
73892 if( VdbeMemDynamic(pTo) ){ vdbeClrCopy(pTo,pFrom,srcType); return; }
73893 memcpy(pTo, pFrom, MEMCELLSIZE);
 
 
 
73894 if( (pFrom->flags&MEM_Static)==0 ){
73895 pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
73896 assert( srcType==MEM_Ephem || srcType==MEM_Static );
73897 pTo->flags |= srcType;
73898 }
@@ -73906,10 +74338,13 @@
73906 int rc = SQLITE_OK;
73907
73908 assert( (pFrom->flags & MEM_RowSet)==0 );
73909 if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);
73910 memcpy(pTo, pFrom, MEMCELLSIZE);
 
 
 
73911 pTo->flags &= ~MEM_Dyn;
73912 if( pTo->flags&(MEM_Str|MEM_Blob) ){
73913 if( 0==(pFrom->flags&MEM_Static) ){
73914 pTo->flags |= MEM_Ephem;
73915 rc = sqlite3VdbeMemMakeWriteable(pTo);
@@ -75510,22 +75945,20 @@
75510 p->readOnly = 0;
75511 p->bIsReader = 1;
75512 break;
75513 }
75514 case OP_Next:
75515 case OP_NextIfOpen:
75516 case OP_SorterNext: {
75517 pOp->p4.xAdvance = sqlite3BtreeNext;
75518 pOp->p4type = P4_ADVANCE;
75519 /* The code generator never codes any of these opcodes as a jump
75520 ** to a label. They are always coded as a jump backwards to a
75521 ** known address */
75522 assert( pOp->p2>=0 );
75523 break;
75524 }
75525 case OP_Prev:
75526 case OP_PrevIfOpen: {
75527 pOp->p4.xAdvance = sqlite3BtreePrevious;
75528 pOp->p4type = P4_ADVANCE;
75529 /* The code generator never codes any of these opcodes as a jump
75530 ** to a label. They are always coded as a jump backwards to a
75531 ** known address */
@@ -76436,11 +76869,11 @@
76436
76437 #if defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
76438 /*
76439 ** Print a single opcode. This routine is used for debugging only.
76440 */
76441 SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){
76442 char *zP4;
76443 char zPtr[50];
76444 char zCom[100];
76445 static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-13s %.2X %s\n";
76446 if( pOut==0 ) pOut = stdout;
@@ -76469,10 +76902,13 @@
76469 p->db = db;
76470 p->flags = flags;
76471 p->szMalloc = 0;
76472 #ifdef SQLITE_DEBUG
76473 p->pScopyFrom = 0;
 
 
 
76474 #endif
76475 p++;
76476 }
76477 }
76478
@@ -78735,11 +79171,11 @@
78735 /*
78736 ** Compare two blobs. Return negative, zero, or positive if the first
78737 ** is less than, equal to, or greater than the second, respectively.
78738 ** If one blob is a prefix of the other, then the shorter is the lessor.
78739 */
78740 static SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){
78741 int c;
78742 int n1 = pB1->n;
78743 int n2 = pB2->n;
78744
78745 /* It is possible to have a Blob value that has some non-zero content
@@ -78950,11 +79386,11 @@
78950 int i; /* Index of next field to compare */
78951 u32 szHdr1; /* Size of record header in bytes */
78952 u32 idx1; /* Offset of first type in header */
78953 int rc = 0; /* Return value */
78954 Mem *pRhs = pPKey2->aMem; /* Next field of pPKey2 to compare */
78955 KeyInfo *pKeyInfo = pPKey2->pKeyInfo;
78956 const unsigned char *aKey1 = (const unsigned char *)pKey1;
78957 Mem mem1;
78958
78959 /* If bSkip is true, then the caller has already determined that the first
78960 ** two elements in the keys are equal. Fix the various stack variables so
@@ -79045,11 +79481,11 @@
79045 testcase( (d1+mem1.n)==(unsigned)nKey1 );
79046 testcase( (d1+mem1.n+1)==(unsigned)nKey1 );
79047 if( (d1+mem1.n) > (unsigned)nKey1 ){
79048 pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
79049 return 0; /* Corruption */
79050 }else if( pKeyInfo->aColl[i] ){
79051 mem1.enc = pKeyInfo->enc;
79052 mem1.db = pKeyInfo->db;
79053 mem1.flags = MEM_Str;
79054 mem1.z = (char*)&aKey1[d1];
79055 rc = vdbeCompareMemString(
@@ -79096,23 +79532,24 @@
79096 serial_type = aKey1[idx1];
79097 rc = (serial_type!=0);
79098 }
79099
79100 if( rc!=0 ){
79101 if( pKeyInfo->aSortOrder[i] ){
79102 rc = -rc;
79103 }
79104 assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );
79105 assert( mem1.szMalloc==0 ); /* See comment below */
79106 return rc;
79107 }
79108
79109 i++;
 
79110 pRhs++;
79111 d1 += sqlite3VdbeSerialTypeLen(serial_type);
79112 idx1 += sqlite3VarintLen(serial_type);
79113 }while( idx1<(unsigned)szHdr1 && i<pPKey2->nField && d1<=(unsigned)nKey1 );
79114
79115 /* No memory allocation is ever used on mem1. Prove this using
79116 ** the following assert(). If the assert() fails, it indicates a
79117 ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1). */
79118 assert( mem1.szMalloc==0 );
@@ -79120,11 +79557,11 @@
79120 /* rc==0 here means that one or both of the keys ran out of fields and
79121 ** all the fields up to that point were equal. Return the default_rc
79122 ** value. */
79123 assert( CORRUPT_DB
79124 || vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, pPKey2->default_rc)
79125 || pKeyInfo->db->mallocFailed
79126 );
79127 pPKey2->eqSeen = 1;
79128 return pPKey2->default_rc;
79129 }
79130 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
@@ -79446,11 +79883,11 @@
79446 sqlite3VdbeMemInit(&m, db, 0);
79447 rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);
79448 if( rc ){
79449 return rc;
79450 }
79451 *res = sqlite3VdbeRecordCompare(m.n, m.z, pUnpacked);
79452 sqlite3VdbeMemRelease(&m);
79453 return SQLITE_OK;
79454 }
79455
79456 /*
@@ -80642,11 +81079,14 @@
80642 /* .uTemp = */ (u32)0,
80643 /* .db = */ (sqlite3*)0,
80644 /* .xDel = */ (void(*)(void*))0,
80645 #ifdef SQLITE_DEBUG
80646 /* .pScopyFrom = */ (Mem*)0,
80647 /* .pFiller = */ (void*)0,
 
 
 
80648 #endif
80649 };
80650 return &nullMem;
80651 }
80652
@@ -81866,10 +82306,22 @@
81866 # define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)
81867 #else
81868 # define memAboutToChange(P,M)
81869 #endif
81870
 
 
 
 
 
 
 
 
 
 
 
 
81871 /*
81872 ** The following global variable is incremented every time a cursor
81873 ** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test
81874 ** procedures use this information to make sure that indices are
81875 ** working correctly. This variable has no function other than to
@@ -81952,36 +82404,60 @@
81952 /*
81953 ** Invoke the VDBE coverage callback, if that callback is defined. This
81954 ** feature is used for test suite validation only and does not appear an
81955 ** production builds.
81956 **
81957 ** M is an integer, 2 or 3, that indices how many different ways the
81958 ** branch can go. It is usually 2. "I" is the direction the branch
81959 ** goes. 0 means falls through. 1 means branch is taken. 2 means the
81960 ** second alternative branch is taken.
 
 
81961 **
81962 ** iSrcLine is the source code line (from the __LINE__ macro) that
81963 ** generated the VDBE instruction. This instrumentation assumes that all
81964 ** source code is in a single file (the amalgamation). Special values 1
81965 ** and 2 for the iSrcLine parameter mean that this particular branch is
81966 ** always taken or never taken, respectively.
 
 
 
 
 
 
 
 
 
 
 
81967 */
81968 #if !defined(SQLITE_VDBE_COVERAGE)
81969 # define VdbeBranchTaken(I,M)
81970 #else
81971 # define VdbeBranchTaken(I,M) vdbeTakeBranch(pOp->iSrcLine,I,M)
81972 static void vdbeTakeBranch(int iSrcLine, u8 I, u8 M){
81973 if( iSrcLine<=2 && ALWAYS(iSrcLine>0) ){
81974 M = iSrcLine;
81975 /* Assert the truth of VdbeCoverageAlwaysTaken() and
81976 ** VdbeCoverageNeverTaken() */
81977 assert( (M & I)==I );
81978 }else{
81979 if( sqlite3GlobalConfig.xVdbeBranch==0 ) return; /*NO_TEST*/
81980 sqlite3GlobalConfig.xVdbeBranch(sqlite3GlobalConfig.pVdbeBranchArg,
81981 iSrcLine,I,M);
81982 }
 
 
 
 
 
 
 
 
 
 
 
81983 }
81984 #endif
81985
81986 /*
81987 ** Convert the given register into a string if it isn't one
@@ -83062,10 +83538,13 @@
83062 pOut = out2Prerelease(p, pOp);
83063 cnt = pOp->p3-pOp->p2;
83064 assert( pOp->p3<=(p->nMem+1 - p->nCursor) );
83065 pOut->flags = nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null;
83066 pOut->n = 0;
 
 
 
83067 while( cnt>0 ){
83068 pOut++;
83069 memAboutToChange(p, pOut);
83070 sqlite3VdbeMemSetNull(pOut);
83071 pOut->flags = nullFlag;
@@ -83183,14 +83662,16 @@
83183 n = pOp->p3;
83184 pIn1 = &aMem[pOp->p1];
83185 pOut = &aMem[pOp->p2];
83186 assert( pOut!=pIn1 );
83187 while( 1 ){
 
83188 sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
83189 Deephemeralize(pOut);
83190 #ifdef SQLITE_DEBUG
83191 pOut->pScopyFrom = 0;
 
83192 #endif
83193 REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);
83194 if( (n--)==0 ) break;
83195 pOut++;
83196 pIn1++;
@@ -83215,11 +83696,12 @@
83215 pIn1 = &aMem[pOp->p1];
83216 pOut = &aMem[pOp->p2];
83217 assert( pOut!=pIn1 );
83218 sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
83219 #ifdef SQLITE_DEBUG
83220 if( pOut->pScopyFrom==0 ) pOut->pScopyFrom = pIn1;
 
83221 #endif
83222 break;
83223 }
83224
83225 /* Opcode: IntCopy P1 P2 * * *
@@ -84063,15 +84545,15 @@
84063 ** in the most recent OP_Compare instruction the P1 vector was less than
84064 ** equal to, or greater than the P2 vector, respectively.
84065 */
84066 case OP_Jump: { /* jump */
84067 if( iCompare<0 ){
84068 VdbeBranchTaken(0,3); pOp = &aOp[pOp->p1 - 1];
84069 }else if( iCompare==0 ){
84070 VdbeBranchTaken(1,3); pOp = &aOp[pOp->p2 - 1];
84071 }else{
84072 VdbeBranchTaken(2,3); pOp = &aOp[pOp->p3 - 1];
84073 }
84074 break;
84075 }
84076
84077 /* Opcode: And P1 P2 P3 * *
@@ -84164,11 +84646,11 @@
84164 }
84165 break;
84166 }
84167
84168 /* Opcode: BitNot P1 P2 * * *
84169 ** Synopsis: r[P1]= ~r[P1]
84170 **
84171 ** Interpret the content of register P1 as an integer. Store the
84172 ** ones-complement of the P1 value into register P2. If P1 holds
84173 ** a NULL then store a NULL in P2.
84174 */
@@ -85121,12 +85603,11 @@
85121 ** halts. The sqlite3_step() wrapper function might then reprepare the
85122 ** statement and rerun it from the beginning.
85123 */
85124 case OP_Transaction: {
85125 Btree *pBt;
85126 int iMeta;
85127 int iGen;
85128
85129 assert( p->bIsReader );
85130 assert( p->readOnly==0 || pOp->p2==0 );
85131 assert( pOp->p1>=0 && pOp->p1<db->nDb );
85132 assert( DbMaskTest(p->btreeMask, pOp->p1) );
@@ -85135,11 +85616,11 @@
85135 goto abort_due_to_error;
85136 }
85137 pBt = db->aDb[pOp->p1].pBt;
85138
85139 if( pBt ){
85140 rc = sqlite3BtreeBeginTrans(pBt, pOp->p2);
85141 testcase( rc==SQLITE_BUSY_SNAPSHOT );
85142 testcase( rc==SQLITE_BUSY_RECOVERY );
85143 if( rc!=SQLITE_OK ){
85144 if( (rc&0xff)==SQLITE_BUSY ){
85145 p->pc = (int)(pOp - aOp);
@@ -85168,23 +85649,21 @@
85168 ** counter. If the statement transaction needs to be rolled back,
85169 ** the value of this counter needs to be restored too. */
85170 p->nStmtDefCons = db->nDeferredCons;
85171 p->nStmtDefImmCons = db->nDeferredImmCons;
85172 }
85173
85174 /* Gather the schema version number for checking:
 
 
 
 
 
85175 ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema
85176 ** version is checked to ensure that the schema has not changed since the
85177 ** SQL statement was prepared.
85178 */
85179 sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta);
85180 iGen = db->aDb[pOp->p1].pSchema->iGeneration;
85181 }else{
85182 iGen = iMeta = 0;
85183 }
85184 assert( pOp->p5==0 || pOp->p4type==P4_INT32 );
85185 if( pOp->p5 && (iMeta!=pOp->p3 || iGen!=pOp->p4.i) ){
85186 sqlite3DbFree(db, p->zErrMsg);
85187 p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed");
85188 /* If the schema-cookie from the database file matches the cookie
85189 ** stored with the in-memory representation of the schema, do
85190 ** not reload the schema from the database file.
@@ -85289,63 +85768,82 @@
85289 ** temporary tables, and P3>1 means used the corresponding attached
85290 ** database. Give the new cursor an identifier of P1. The P1
85291 ** values need not be contiguous but all P1 values should be small integers.
85292 ** It is an error for P1 to be negative.
85293 **
85294 ** If P5!=0 then use the content of register P2 as the root page, not
85295 ** the value of P2 itself.
85296 **
85297 ** There will be a read lock on the database whenever there is an
85298 ** open cursor. If the database was unlocked prior to this instruction
85299 ** then a read lock is acquired as part of this instruction. A read
85300 ** lock allows other processes to read the database but prohibits
85301 ** any other process from modifying the database. The read lock is
85302 ** released when all cursors are closed. If this instruction attempts
85303 ** to get a read lock but fails, the script terminates with an
85304 ** SQLITE_BUSY error code.
85305 **
85306 ** The P4 value may be either an integer (P4_INT32) or a pointer to
85307 ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
85308 ** structure, then said structure defines the content and collating
85309 ** sequence of the index being opened. Otherwise, if P4 is an integer
85310 ** value, it is set to the number of columns in the table.
 
 
85311 **
85312 ** See also: OpenWrite, ReopenIdx
85313 */
85314 /* Opcode: ReopenIdx P1 P2 P3 P4 P5
85315 ** Synopsis: root=P2 iDb=P3
85316 **
85317 ** The ReopenIdx opcode works exactly like ReadOpen except that it first
85318 ** checks to see if the cursor on P1 is already open with a root page
85319 ** number of P2 and if it is this opcode becomes a no-op. In other words,
85320 ** if the cursor is already open, do not reopen it.
85321 **
85322 ** The ReopenIdx opcode may only be used with P5==0 and with P4 being
85323 ** a P4_KEYINFO object. Furthermore, the P3 value must be the same as
85324 ** every other ReopenIdx or OpenRead for the same cursor number.
 
85325 **
85326 ** See the OpenRead opcode documentation for additional information.
 
 
 
 
 
 
 
85327 */
85328 /* Opcode: OpenWrite P1 P2 P3 P4 P5
85329 ** Synopsis: root=P2 iDb=P3
85330 **
85331 ** Open a read/write cursor named P1 on the table or index whose root
85332 ** page is P2. Or if P5!=0 use the content of register P2 to find the
85333 ** root page.
85334 **
85335 ** The P4 value may be either an integer (P4_INT32) or a pointer to
85336 ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
85337 ** structure, then said structure defines the content and collating
85338 ** sequence of the index being opened. Otherwise, if P4 is an integer
85339 ** value, it is set to the number of columns in the table, or to the
85340 ** largest index of any column of the table that is actually used.
85341 **
85342 ** This instruction works just like OpenRead except that it opens the cursor
85343 ** in read/write mode. For a given table, there can be one or more read-only
85344 ** cursors or a single read/write cursor but not both.
85345 **
85346 ** See also OpenRead.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85347 */
85348 case OP_ReopenIdx: {
85349 int nField;
85350 KeyInfo *pKeyInfo;
85351 int p2;
@@ -85397,10 +85895,11 @@
85397 wrFlag = 0;
85398 }
85399 if( pOp->p5 & OPFLAG_P2ISREG ){
85400 assert( p2>0 );
85401 assert( p2<=(p->nMem+1 - p->nCursor) );
 
85402 pIn2 = &aMem[p2];
85403 assert( memIsValid(pIn2) );
85404 assert( (pIn2->flags & MEM_Int)!=0 );
85405 sqlite3VdbeMemIntegerify(pIn2);
85406 p2 = (int)pIn2->u.i;
@@ -85525,11 +86024,11 @@
85525 pCx->nullRow = 1;
85526 pCx->isEphemeral = 1;
85527 rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
85528 BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags);
85529 if( rc==SQLITE_OK ){
85530 rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1);
85531 }
85532 if( rc==SQLITE_OK ){
85533 /* If a transient index is required, create it by calling
85534 ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
85535 ** opening it. If a transient table is required, just use the
@@ -85932,10 +86431,29 @@
85932 assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
85933 pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */
85934 }
85935 break;
85936 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85937
85938 /* Opcode: Found P1 P2 P3 P4 *
85939 ** Synopsis: key=r[P3@P4]
85940 **
85941 ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If
@@ -85967,11 +86485,38 @@
85967 **
85968 ** This operation leaves the cursor in a state where it cannot be
85969 ** advanced in either direction. In other words, the Next and Prev
85970 ** opcodes do not work after this operation.
85971 **
85972 ** See also: Found, NotExists, NoConflict
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85973 */
85974 /* Opcode: NoConflict P1 P2 P3 P4 *
85975 ** Synopsis: key=r[P3@P4]
85976 **
85977 ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If
@@ -85992,10 +86537,18 @@
85992 ** advanced in either direction. In other words, the Next and Prev
85993 ** opcodes do not work after this operation.
85994 **
85995 ** See also: NotFound, Found, NotExists
85996 */
 
 
 
 
 
 
 
 
85997 case OP_NoConflict: /* jump, in3 */
85998 case OP_NotFound: /* jump, in3 */
85999 case OP_Found: { /* jump, in3 */
86000 int alreadyExists;
86001 int takeJump;
@@ -86140,11 +86693,11 @@
86140 assert( pIn3->flags & MEM_Int );
86141 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
86142 pC = p->apCsr[pOp->p1];
86143 assert( pC!=0 );
86144 #ifdef SQLITE_DEBUG
86145 pC->seekOp = 0;
86146 #endif
86147 assert( pC->isTable );
86148 assert( pC->eCurType==CURTYPE_BTREE );
86149 pCrsr = pC->uc.pCursor;
86150 assert( pCrsr!=0 );
@@ -86794,10 +87347,13 @@
86794 pC->cacheStatus = CACHE_STALE;
86795 if( pC->eCurType==CURTYPE_BTREE ){
86796 assert( pC->uc.pCursor!=0 );
86797 sqlite3BtreeClearCursor(pC->uc.pCursor);
86798 }
 
 
 
86799 break;
86800 }
86801
86802 /* Opcode: SeekEnd P1 * * * *
86803 **
@@ -86912,17 +87468,21 @@
86912 sqlite3_search_count--;
86913 #endif
86914 p->aCounter[SQLITE_STMTSTATUS_SORT]++;
86915 /* Fall through into OP_Rewind */
86916 }
86917 /* Opcode: Rewind P1 P2 * * *
86918 **
86919 ** The next use of the Rowid or Column or Next instruction for P1
86920 ** will refer to the first entry in the database table or index.
86921 ** If the table or index is empty, jump immediately to P2.
86922 ** If the table or index is not empty, fall through to the following
86923 ** instruction.
 
 
 
 
86924 **
86925 ** This opcode leaves the cursor configured to move in forward order,
86926 ** from the beginning toward the end. In other words, the cursor is
86927 ** configured to use Next, not Prev.
86928 */
@@ -86944,10 +87504,13 @@
86944 }else{
86945 assert( pC->eCurType==CURTYPE_BTREE );
86946 pCrsr = pC->uc.pCursor;
86947 assert( pCrsr );
86948 rc = sqlite3BtreeFirst(pCrsr, &res);
 
 
 
86949 pC->deferredMoveto = 0;
86950 pC->cacheStatus = CACHE_STALE;
86951 }
86952 if( rc ) goto abort_due_to_error;
86953 pC->nullRow = (u8)res;
@@ -86980,16 +87543,11 @@
86980 ** sqlite3BtreeNext().
86981 **
86982 ** If P5 is positive and the jump is taken, then event counter
86983 ** number P5-1 in the prepared statement is incremented.
86984 **
86985 ** See also: Prev, NextIfOpen
86986 */
86987 /* Opcode: NextIfOpen P1 P2 P3 P4 P5
86988 **
86989 ** This opcode works just like Next except that if cursor P1 is not
86990 ** open it behaves a no-op.
86991 */
86992 /* Opcode: Prev P1 P2 P3 P4 P5
86993 **
86994 ** Back up cursor P1 so that it points to the previous key/data pair in its
86995 ** table or index. If there is no previous key/value pairs then fall through
@@ -87013,15 +87571,10 @@
87013 ** sqlite3BtreePrevious().
87014 **
87015 ** If P5 is positive and the jump is taken, then event counter
87016 ** number P5-1 in the prepared statement is incremented.
87017 */
87018 /* Opcode: PrevIfOpen P1 P2 P3 P4 P5
87019 **
87020 ** This opcode works just like Prev except that if cursor P1 is not
87021 ** open it behaves a no-op.
87022 */
87023 /* Opcode: SorterNext P1 P2 * * P5
87024 **
87025 ** This opcode works just like OP_Next except that P1 must be a
87026 ** sorter object for which the OP_SorterSort opcode has been
87027 ** invoked. This opcode advances the cursor to the next sorted
@@ -87032,14 +87585,10 @@
87032
87033 pC = p->apCsr[pOp->p1];
87034 assert( isSorter(pC) );
87035 rc = sqlite3VdbeSorterNext(db, pC);
87036 goto next_tail;
87037 case OP_PrevIfOpen: /* jump */
87038 case OP_NextIfOpen: /* jump */
87039 if( p->apCsr[pOp->p1]==0 ) break;
87040 /* Fall through */
87041 case OP_Prev: /* jump */
87042 case OP_Next: /* jump */
87043 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
87044 assert( pOp->p5<ArraySize(p->aCounter) );
87045 pC = p->apCsr[pOp->p1];
@@ -87046,21 +87595,21 @@
87046 assert( pC!=0 );
87047 assert( pC->deferredMoveto==0 );
87048 assert( pC->eCurType==CURTYPE_BTREE );
87049 assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );
87050 assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );
87051 assert( pOp->opcode!=OP_NextIfOpen || pOp->p4.xAdvance==sqlite3BtreeNext );
87052 assert( pOp->opcode!=OP_PrevIfOpen || pOp->p4.xAdvance==sqlite3BtreePrevious);
87053
87054 /* The Next opcode is only used after SeekGT, SeekGE, and Rewind.
87055 ** The Prev opcode is only used after SeekLT, SeekLE, and Last. */
87056 assert( pOp->opcode!=OP_Next || pOp->opcode!=OP_NextIfOpen
87057 || pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
87058 || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found);
87059 assert( pOp->opcode!=OP_Prev || pOp->opcode!=OP_PrevIfOpen
 
87060 || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
87061 || pC->seekOp==OP_Last );
 
87062
87063 rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
87064 next_tail:
87065 pC->cacheStatus = CACHE_STALE;
87066 VdbeBranchTaken(rc==SQLITE_OK,2);
@@ -88125,28 +88674,39 @@
88125 if( pIn1->u.i==0 ) goto jump_to_p2;
88126 break;
88127 }
88128
88129
88130 /* Opcode: AggStep0 * P2 P3 P4 P5
88131 ** Synopsis: accum=r[P3] step(r[P2@P5])
88132 **
88133 ** Execute the step function for an aggregate. The
88134 ** function has P5 arguments. P4 is a pointer to the FuncDef
88135 ** structure that specifies the function. Register P3 is the
 
 
 
 
 
 
 
 
 
 
 
88136 ** accumulator.
88137 **
88138 ** The P5 arguments are taken from register P2 and its
88139 ** successors.
88140 */
88141 /* Opcode: AggStep * P2 P3 P4 P5
88142 ** Synopsis: accum=r[P3] step(r[P2@P5])
88143 **
88144 ** Execute the step function for an aggregate. The
88145 ** function has P5 arguments. P4 is a pointer to an sqlite3_context
88146 ** object that is used to run the function. Register P3 is
88147 ** as the accumulator.
88148 **
88149 ** The P5 arguments are taken from register P2 and its
88150 ** successors.
88151 **
88152 ** This opcode is initially coded as OP_AggStep0. On first evaluation,
@@ -88153,11 +88713,12 @@
88153 ** the FuncDef stored in P4 is converted into an sqlite3_context and
88154 ** the opcode is changed. In this way, the initialization of the
88155 ** sqlite3_context only happens once, instead of on each call to the
88156 ** step function.
88157 */
88158 case OP_AggStep0: {
 
88159 int n;
88160 sqlite3_context *pCtx;
88161
88162 assert( pOp->p4type==P4_FUNCDEF );
88163 n = pOp->p5;
@@ -88176,21 +88737,36 @@
88176 pCtx->skipFlag = 0;
88177 pCtx->isError = 0;
88178 pCtx->argc = n;
88179 pOp->p4type = P4_FUNCCTX;
88180 pOp->p4.pCtx = pCtx;
88181 pOp->opcode = OP_AggStep;
 
 
 
 
88182 /* Fall through into OP_AggStep */
88183 }
88184 case OP_AggStep: {
88185 int i;
88186 sqlite3_context *pCtx;
88187 Mem *pMem;
88188
88189 assert( pOp->p4type==P4_FUNCCTX );
88190 pCtx = pOp->p4.pCtx;
88191 pMem = &aMem[pOp->p3];
 
 
 
 
 
 
 
 
 
 
 
88192
88193 /* If this function is inside of a trigger, the register array in aMem[]
88194 ** might change from one evaluation to the next. The next block of code
88195 ** checks to see if the register array has changed, and if so it
88196 ** reinitializes the relavant parts of the sqlite3_context object */
@@ -88208,11 +88784,17 @@
88208
88209 pMem->n++;
88210 assert( pCtx->pOut->flags==MEM_Null );
88211 assert( pCtx->isError==0 );
88212 assert( pCtx->skipFlag==0 );
 
 
 
 
 
88213 (pCtx->pFunc->xSFunc)(pCtx,pCtx->argc,pCtx->argv); /* IMP: R-24505-23230 */
 
88214 if( pCtx->isError ){
88215 if( pCtx->isError>0 ){
88216 sqlite3VdbeError(p, "%s", sqlite3_value_text(pCtx->pOut));
88217 rc = pCtx->isError;
88218 }
@@ -88233,26 +88815,50 @@
88233 }
88234
88235 /* Opcode: AggFinal P1 P2 * P4 *
88236 ** Synopsis: accum=r[P1] N=P2
88237 **
88238 ** Execute the finalizer function for an aggregate. P1 is
88239 ** the memory location that is the accumulator for the aggregate.
 
 
 
 
 
 
 
 
 
 
 
 
 
88240 **
88241 ** P2 is the number of arguments that the step function takes and
88242 ** P4 is a pointer to the FuncDef for this function. The P2
88243 ** argument is not used by this opcode. It is only there to disambiguate
88244 ** functions that can take varying numbers of arguments. The
88245 ** P4 argument is only needed for the degenerate case where
88246 ** the step function was not previously called.
88247 */
 
88248 case OP_AggFinal: {
88249 Mem *pMem;
88250 assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
 
88251 pMem = &aMem[pOp->p1];
88252 assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
88253 rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
 
 
 
 
 
 
 
 
 
88254 if( rc ){
88255 sqlite3VdbeError(p, "%s", sqlite3_value_text(pMem));
88256 goto abort_due_to_error;
88257 }
88258 sqlite3VdbeChangeEncoding(pMem, encoding);
@@ -88843,10 +89449,11 @@
88843
88844 assert( pOp->p2==1 || pOp->p5==OE_Fail || pOp->p5==OE_Rollback
88845 || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
88846 );
88847 assert( p->readOnly==0 );
 
88848 sqlite3VdbeIncrWriteCounter(p, 0);
88849 pVtab = pOp->p4.pVtab->pVtab;
88850 if( pVtab==0 || NEVER(pVtab->pModule==0) ){
88851 rc = SQLITE_LOCKED;
88852 goto abort_due_to_error;
@@ -89176,10 +89783,38 @@
89176 case OP_Abortable: {
89177 sqlite3VdbeAssertAbortable(p);
89178 break;
89179 }
89180 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89181
89182 /* Opcode: Noop * * * * *
89183 **
89184 ** Do nothing. This instruction is often useful as a jump
89185 ** destination.
@@ -93052,10 +93687,18 @@
93052 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
93053 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
93054 }else if( pExpr->x.pList ){
93055 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
93056 }
 
 
 
 
 
 
 
 
93057 }
93058 break;
93059 }
93060 return WRC_Continue;
93061 }
@@ -93916,15 +94559,44 @@
93916 ** in an index. */
93917 notValid(pParse, pNC, "non-deterministic functions",
93918 NC_IdxExpr|NC_PartIdx);
93919 }
93920 }
93921 if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93922 sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
93923 pNC->nErr++;
93924 is_agg = 0;
93925 }else if( no_such_func && pParse->db->init.busy==0
 
 
93926 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
93927 && pParse->explain==0
93928 #endif
93929 ){
93930 sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
@@ -93932,28 +94604,52 @@
93932 }else if( wrong_num_args ){
93933 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
93934 nId, zId);
93935 pNC->nErr++;
93936 }
93937 if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg;
 
 
 
 
 
 
93938 sqlite3WalkExprList(pWalker, pList);
93939 if( is_agg ){
93940 NameContext *pNC2 = pNC;
93941 pExpr->op = TK_AGG_FUNCTION;
93942 pExpr->op2 = 0;
93943 while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){
93944 pExpr->op2++;
93945 pNC2 = pNC2->pNext;
93946 }
93947 assert( pDef!=0 );
93948 if( pNC2 ){
93949 assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
93950 testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
93951 pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
93952
93953 }
93954 pNC->ncFlags |= NC_AllowAgg;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93955 }
93956 /* FIX ME: Compute pExpr->affinity based on the expected return
93957 ** type of the function
93958 */
93959 return WRC_Prune;
@@ -94350,10 +95046,23 @@
94350 if( sqlite3ResolveExprNames(pNC, pE) ){
94351 return 1;
94352 }
94353 for(j=0; j<pSelect->pEList->nExpr; j++){
94354 if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
 
 
 
 
 
 
 
 
 
 
 
 
 
94355 pItem->u.x.iOrderByCol = j+1;
94356 }
94357 }
94358 }
94359 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -94406,10 +95115,11 @@
94406 /* Resolve the expressions in the LIMIT and OFFSET clauses. These
94407 ** are not allowed to refer to any names, so pass an empty NameContext.
94408 */
94409 memset(&sNC, 0, sizeof(sNC));
94410 sNC.pParse = pParse;
 
94411 if( sqlite3ResolveExprNames(&sNC, p->pLimit) ){
94412 return WRC_Abort;
94413 }
94414
94415 /* If the SF_Converted flags is set, then this Select object was
@@ -94454,16 +95164,17 @@
94454 }
94455
94456 /* Set up the local name-context to pass to sqlite3ResolveExprNames() to
94457 ** resolve the result-set expression list.
94458 */
94459 sNC.ncFlags = NC_AllowAgg;
94460 sNC.pSrcList = p->pSrc;
94461 sNC.pNext = pOuterNC;
94462
94463 /* Resolve names in the result set. */
94464 if( sqlite3ResolveExprListNames(&sNC, p->pEList) ) return WRC_Abort;
 
94465
94466 /* If there are no aggregate functions in the result-set, and no GROUP BY
94467 ** expression, do not allow aggregates in any of the other expressions.
94468 */
94469 assert( (p->selFlags & SF_Aggregate)==0 );
@@ -94508,11 +95219,11 @@
94508
94509 /* The ORDER BY and GROUP BY clauses may not refer to terms in
94510 ** outer queries
94511 */
94512 sNC.pNext = 0;
94513 sNC.ncFlags |= NC_AllowAgg;
94514
94515 /* If this is a converted compound query, move the ORDER BY clause from
94516 ** the sub-query back to the parent query. At this point each term
94517 ** within the ORDER BY clause has been transformed to an integer value.
94518 ** These integers will be replaced by copies of the corresponding result
@@ -94539,10 +95250,11 @@
94539 return WRC_Abort;
94540 }
94541 if( db->mallocFailed ){
94542 return WRC_Abort;
94543 }
 
94544
94545 /* Resolve the GROUP BY clause. At the same time, make sure
94546 ** the GROUP BY clause does not contain aggregate functions.
94547 */
94548 if( pGroupBy ){
@@ -95809,10 +96521,13 @@
95809 }else if( ExprHasProperty(p, EP_xIsSelect) ){
95810 sqlite3SelectDelete(db, p->x.pSelect);
95811 }else{
95812 sqlite3ExprListDelete(db, p->x.pList);
95813 }
 
 
 
95814 }
95815 if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
95816 if( !ExprHasProperty(p, EP_Static) ){
95817 sqlite3DbFreeNN(db, p);
95818 }
@@ -95857,11 +96572,11 @@
95857 ** return value with EP_Reduced|EP_TokenOnly.
95858 **
95859 ** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size
95860 ** (unreduced) Expr objects as they or originally constructed by the parser.
95861 ** During expression analysis, extra information is computed and moved into
95862 ** later parts of teh Expr object and that extra information might get chopped
95863 ** off if the expression is reduced. Note also that it does not work to
95864 ** make an EXPRDUP_REDUCE copy of a reduced expression. It is only legal
95865 ** to reduce a pristine expression tree from the parser. The implementation
95866 ** of dupedExprStructSize() contain multiple assert() statements that attempt
95867 ** to enforce this constraint.
@@ -95869,11 +96584,15 @@
95869 static int dupedExprStructSize(Expr *p, int flags){
95870 int nSize;
95871 assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */
95872 assert( EXPR_FULLSIZE<=0xfff );
95873 assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );
95874 if( 0==flags || p->op==TK_SELECT_COLUMN ){
 
 
 
 
95875 nSize = EXPR_FULLSIZE;
95876 }else{
95877 assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
95878 assert( !ExprHasProperty(p, EP_FromJoin) );
95879 assert( !ExprHasProperty(p, EP_MemToken) );
@@ -96009,10 +96728,17 @@
96009 }
96010 if( pzBuffer ){
96011 *pzBuffer = zAlloc;
96012 }
96013 }else{
 
 
 
 
 
 
 
96014 if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
96015 if( pNew->op==TK_SELECT_COLUMN ){
96016 pNew->pLeft = p->pLeft;
96017 assert( p->iColumn==0 || p->pRight==0 );
96018 assert( p->pRight==0 || p->pRight==p->pLeft );
@@ -96215,11 +96941,15 @@
96215 pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
96216 pNew->addrOpenEphm[0] = -1;
96217 pNew->addrOpenEphm[1] = -1;
96218 pNew->nSelectRow = p->nSelectRow;
96219 pNew->pWith = withDup(db, p->pWith);
96220 sqlite3SelectSetName(pNew, p->zSelName);
 
 
 
 
96221 *pp = pNew;
96222 pp = &pNew->pPrior;
96223 pNext = pNew;
96224 }
96225
@@ -97945,10 +98675,17 @@
97945 #ifndef NDEBUG
97946 for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){
97947 assert( p->iTable!=iTab || p->iColumn!=iCol );
97948 }
97949 #endif
 
 
 
 
 
 
 
97950
97951 /* If the cache is already full, delete the least recently used entry */
97952 if( pParse->nColCache>=SQLITE_N_COLCACHE ){
97953 minLru = 0x7fffffff;
97954 idxLru = -1;
@@ -98119,10 +98856,13 @@
98119
98120 for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){
98121 if( p->iTable==iTable && p->iColumn==iColumn ){
98122 p->lru = pParse->iCacheCnt++;
98123 sqlite3ExprCachePinRegister(pParse, p->iReg);
 
 
 
98124 return p->iReg;
98125 }
98126 }
98127 assert( v!=0 );
98128 sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
@@ -98523,10 +99263,16 @@
98523 u32 constMask = 0; /* Mask of function arguments that are constant */
98524 int i; /* Loop counter */
98525 sqlite3 *db = pParse->db; /* The database connection */
98526 u8 enc = ENC(db); /* The text encoding used by this database */
98527 CollSeq *pColl = 0; /* A collating sequence */
 
 
 
 
 
 
98528
98529 if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
98530 /* SQL functions can be expensive. So try to move constant functions
98531 ** out of the inner loop, even if that means an extra OP_Copy. */
98532 return sqlite3ExprCodeAtInit(pParse, pExpr, -1);
@@ -99663,10 +100409,25 @@
99663 if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
99664 if( pA->iColumn!=pB->iColumn ) return 2;
99665 if( pA->iTable!=pB->iTable
99666 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
99667 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99668 }
99669 return 0;
99670 }
99671
99672 /*
@@ -100342,11 +101103,11 @@
100342 */
100343 do {
100344 zCsr += len;
100345 len = sqlite3GetToken(zCsr, &token);
100346 } while( token==TK_SPACE );
100347 assert( len>0 );
100348 } while( token!=TK_LP && token!=TK_USING );
100349
100350 zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", (int)(((u8*)tname.z) - zSql),
100351 zSql, zTableName, tname.z+tname.n);
100352 sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);
@@ -100410,11 +101171,11 @@
100410 }
100411 sqlite3DbFree(db, zParent);
100412 }
100413 }
100414
100415 zResult = sqlite3MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput),
100416 sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);
100417 sqlite3DbFree(db, zOutput);
100418 }
100419 #endif
100420
@@ -100466,11 +101227,11 @@
100466 */
100467 do {
100468 zCsr += len;
100469 len = sqlite3GetToken(zCsr, &token);
100470 }while( token==TK_SPACE );
100471 assert( len>0 );
100472
100473 /* Variable 'dist' stores the number of tokens read since the most
100474 ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN
100475 ** token is read and 'dist' equals 2, the condition stated above
100476 ** to be met.
@@ -101564,10 +102325,11 @@
101564 SQLITE_UTF8, /* funcFlags */
101565 0, /* pUserData */
101566 0, /* pNext */
101567 statInit, /* xSFunc */
101568 0, /* xFinalize */
 
101569 "stat_init", /* zName */
101570 {0}
101571 };
101572
101573 #ifdef SQLITE_ENABLE_STAT4
@@ -101880,10 +102642,11 @@
101880 SQLITE_UTF8, /* funcFlags */
101881 0, /* pUserData */
101882 0, /* pNext */
101883 statPush, /* xSFunc */
101884 0, /* xFinalize */
 
101885 "stat_push", /* zName */
101886 {0}
101887 };
101888
101889 #define STAT_GET_STAT1 0 /* "stat" column of stat1 table */
@@ -102031,10 +102794,11 @@
102031 SQLITE_UTF8, /* funcFlags */
102032 0, /* pUserData */
102033 0, /* pNext */
102034 statGet, /* xSFunc */
102035 0, /* xFinalize */
 
102036 "stat_get", /* zName */
102037 {0}
102038 };
102039
102040 static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
@@ -102350,14 +103114,11 @@
102350 VdbeCoverage(v);
102351 callStatGet(v, regStat4, STAT_GET_NEQ, regEq);
102352 callStatGet(v, regStat4, STAT_GET_NLT, regLt);
102353 callStatGet(v, regStat4, STAT_GET_NDLT, regDLt);
102354 sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);
102355 /* We know that the regSampleRowid row exists because it was read by
102356 ** the previous loop. Thus the not-found jump of seekOp will never
102357 ** be taken */
102358 VdbeCoverageNeverTaken(v);
102359 #ifdef SQLITE_ENABLE_STAT3
102360 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, 0, regSample);
102361 #else
102362 for(i=0; i<nCol; i++){
102363 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
@@ -103432,10 +104193,11 @@
103432 SQLITE_UTF8, /* funcFlags */
103433 0, /* pUserData */
103434 0, /* pNext */
103435 detachFunc, /* xSFunc */
103436 0, /* xFinalize */
 
103437 "sqlite_detach", /* zName */
103438 {0}
103439 };
103440 codeAttach(pParse, SQLITE_DETACH, &detach_func, pDbname, 0, 0, pDbname);
103441 }
@@ -103451,10 +104213,11 @@
103451 SQLITE_UTF8, /* funcFlags */
103452 0, /* pUserData */
103453 0, /* pNext */
103454 attachFunc, /* xSFunc */
103455 0, /* xFinalize */
 
103456 "sqlite_attach", /* zName */
103457 {0}
103458 };
103459 codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);
103460 }
@@ -105613,10 +106376,35 @@
105613 */
105614 static int hasColumn(const i16 *aiCol, int nCol, int x){
105615 while( nCol-- > 0 ) if( x==*(aiCol++) ) return 1;
105616 return 0;
105617 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105618
105619 /*
105620 ** This routine runs at the end of parsing a CREATE TABLE statement that
105621 ** has a WITHOUT ROWID clause. The job of this routine is to convert both
105622 ** internal schema data structures and the generated VDBE code so that they
@@ -105682,11 +106470,11 @@
105682 if( pList==0 ) return;
105683 pList->a[0].sortOrder = pParse->iPkSortOrder;
105684 assert( pParse->pNewTable==pTab );
105685 sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
105686 SQLITE_IDXTYPE_PRIMARYKEY);
105687 if( db->mallocFailed ) return;
105688 pPk = sqlite3PrimaryKeyIndex(pTab);
105689 pTab->iPKey = -1;
105690 }else{
105691 pPk = sqlite3PrimaryKeyIndex(pTab);
105692
@@ -105762,10 +106550,11 @@
105762 assert( pPk->nColumn==j );
105763 assert( pTab->nCol==j );
105764 }else{
105765 pPk->nColumn = pTab->nCol;
105766 }
 
105767 }
105768
105769 /*
105770 ** This routine is called to report the final ")" that terminates
105771 ** a CREATE TABLE statement.
@@ -106212,10 +107001,15 @@
106212 db->lookaside.bDisable--;
106213 } else {
106214 nErr++;
106215 }
106216 pTable->pSchema->schemaFlags |= DB_UnresetViews;
 
 
 
 
 
106217 #endif /* SQLITE_OMIT_VIEW */
106218 return nErr;
106219 }
106220 #endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */
106221
@@ -107195,10 +107989,11 @@
107195
107196 /* If this index contains every column of its table, then mark
107197 ** it as a covering index */
107198 assert( HasRowid(pTab)
107199 || pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 );
 
107200 if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){
107201 pIndex->isCovering = 1;
107202 for(j=0; j<pTab->nCol; j++){
107203 if( j==pTab->iPKey ) continue;
107204 if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue;
@@ -111366,18 +112161,44 @@
111366 p->cnt++;
111367 if( type==SQLITE_INTEGER ){
111368 i64 v = sqlite3_value_int64(argv[0]);
111369 p->rSum += v;
111370 if( (p->approx|p->overflow)==0 && sqlite3AddInt64(&p->iSum, v) ){
111371 p->overflow = 1;
111372 }
111373 }else{
111374 p->rSum += sqlite3_value_double(argv[0]);
111375 p->approx = 1;
111376 }
111377 }
111378 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111379 static void sumFinalize(sqlite3_context *context){
111380 SumCtx *p;
111381 p = sqlite3_aggregate_context(context, 0);
111382 if( p && p->cnt>0 ){
111383 if( p->overflow ){
@@ -111408,10 +112229,13 @@
111408 ** count() aggregate function.
111409 */
111410 typedef struct CountCtx CountCtx;
111411 struct CountCtx {
111412 i64 n;
 
 
 
111413 };
111414
111415 /*
111416 ** Routines to implement the count() aggregate function.
111417 */
@@ -111425,19 +112249,34 @@
111425 #ifndef SQLITE_OMIT_DEPRECATED
111426 /* The sqlite3_aggregate_count() function is deprecated. But just to make
111427 ** sure it still operates correctly, verify that its count agrees with our
111428 ** internal count when using count(*) and when the total count can be
111429 ** expressed as a 32-bit integer. */
111430 assert( argc==1 || p==0 || p->n>0x7fffffff
111431 || p->n==sqlite3_aggregate_count(context) );
111432 #endif
111433 }
111434 static void countFinalize(sqlite3_context *context){
111435 CountCtx *p;
111436 p = sqlite3_aggregate_context(context, 0);
111437 sqlite3_result_int64(context, p ? p->n : 0);
111438 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111439
111440 /*
111441 ** Routines to implement min() and max() aggregate functions.
111442 */
111443 static void minmaxStep(
@@ -111450,11 +112289,11 @@
111450 UNUSED_PARAMETER(NotUsed);
111451
111452 pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));
111453 if( !pBest ) return;
111454
111455 if( sqlite3_value_type(argv[0])==SQLITE_NULL ){
111456 if( pBest->flags ) sqlite3SkipAccumulatorLoad(context);
111457 }else if( pBest->flags ){
111458 int max;
111459 int cmp;
111460 CollSeq *pColl = sqlite3GetFuncCollSeq(context);
@@ -111476,20 +112315,30 @@
111476 }else{
111477 pBest->db = sqlite3_context_db_handle(context);
111478 sqlite3VdbeMemCopy(pBest, pArg);
111479 }
111480 }
111481 static void minMaxFinalize(sqlite3_context *context){
111482 sqlite3_value *pRes;
111483 pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);
111484 if( pRes ){
111485 if( pRes->flags ){
111486 sqlite3_result_value(context, pRes);
111487 }
111488 sqlite3VdbeMemRelease(pRes);
111489 }
111490 }
 
 
 
 
 
 
 
 
 
 
111491
111492 /*
111493 ** group_concat(EXPR, ?SEPARATOR?)
111494 */
111495 static void groupConcatStep(
@@ -111522,10 +112371,42 @@
111522 zVal = (char*)sqlite3_value_text(argv[0]);
111523 nVal = sqlite3_value_bytes(argv[0]);
111524 if( zVal ) sqlite3_str_append(pAccum, zVal, nVal);
111525 }
111526 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111527 static void groupConcatFinalize(sqlite3_context *context){
111528 StrAccum *pAccum;
111529 pAccum = sqlite3_aggregate_context(context, 0);
111530 if( pAccum ){
111531 if( pAccum->accError==SQLITE_TOOBIG ){
@@ -111536,10 +112417,28 @@
111536 sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1,
111537 sqlite3_free);
111538 }
111539 }
111540 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111541
111542 /*
111543 ** This routine does per-connection function registration. Most
111544 ** of the built-in functions above are part of the global function set.
111545 ** This routine only deals with those that are not global.
@@ -111573,14 +112472,14 @@
111573 if( caseSensitive ){
111574 pInfo = (struct compareInfo*)&likeInfoAlt;
111575 }else{
111576 pInfo = (struct compareInfo*)&likeInfoNorm;
111577 }
111578 sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);
111579 sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);
111580 sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8,
111581 (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0);
111582 setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);
111583 setLikeOptFlag(db, "like",
111584 caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);
111585 }
111586
@@ -111685,15 +112584,15 @@
111685 FUNCTION(rtrim, 2, 2, 0, trimFunc ),
111686 FUNCTION(trim, 1, 3, 0, trimFunc ),
111687 FUNCTION(trim, 2, 3, 0, trimFunc ),
111688 FUNCTION(min, -1, 0, 1, minmaxFunc ),
111689 FUNCTION(min, 0, 0, 1, 0 ),
111690 AGGREGATE2(min, 1, 0, 1, minmaxStep, minMaxFinalize,
111691 SQLITE_FUNC_MINMAX ),
111692 FUNCTION(max, -1, 1, 1, minmaxFunc ),
111693 FUNCTION(max, 0, 1, 1, 0 ),
111694 AGGREGATE2(max, 1, 1, 1, minmaxStep, minMaxFinalize,
111695 SQLITE_FUNC_MINMAX ),
111696 FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
111697 FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
111698 FUNCTION(instr, 2, 0, 0, instrFunc ),
111699 FUNCTION(printf, -1, 0, 0, printfFunc ),
@@ -111720,18 +112619,21 @@
111720 VFUNCTION(total_changes, 0, 0, 0, total_changes ),
111721 FUNCTION(replace, 3, 0, 0, replaceFunc ),
111722 FUNCTION(zeroblob, 1, 0, 0, zeroblobFunc ),
111723 FUNCTION(substr, 2, 0, 0, substrFunc ),
111724 FUNCTION(substr, 3, 0, 0, substrFunc ),
111725 AGGREGATE(sum, 1, 0, 0, sumStep, sumFinalize ),
111726 AGGREGATE(total, 1, 0, 0, sumStep, totalFinalize ),
111727 AGGREGATE(avg, 1, 0, 0, sumStep, avgFinalize ),
111728 AGGREGATE2(count, 0, 0, 0, countStep, countFinalize,
111729 SQLITE_FUNC_COUNT ),
111730 AGGREGATE(count, 1, 0, 0, countStep, countFinalize ),
111731 AGGREGATE(group_concat, 1, 0, 0, groupConcatStep, groupConcatFinalize),
111732 AGGREGATE(group_concat, 2, 0, 0, groupConcatStep, groupConcatFinalize),
 
 
 
111733
111734 LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
111735 #ifdef SQLITE_CASE_SENSITIVE_LIKE
111736 LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
111737 LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
@@ -111747,10 +112649,11 @@
111747 FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQLITE_FUNC_COALESCE),
111748 };
111749 #ifndef SQLITE_OMIT_ALTERTABLE
111750 sqlite3AlterFunctions();
111751 #endif
 
111752 #if defined(SQLITE_ENABLE_STAT3) || defined(SQLITE_ENABLE_STAT4)
111753 sqlite3AnalyzeFunctions();
111754 #endif
111755 sqlite3RegisterDateTimeFunctions();
111756 sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));
@@ -114738,10 +115641,11 @@
114738 ** the following conflict logic if it does not. */
114739 VdbeNoopComment((v, "uniqueness check for ROWID"));
114740 sqlite3VdbeVerifyAbortable(v, onError);
114741 sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);
114742 VdbeCoverage(v);
 
114743
114744 switch( onError ){
114745 default: {
114746 onError = OE_Abort;
114747 /* Fall thru into the next case */
@@ -114814,10 +115718,11 @@
114814 testcase( onError==OE_Ignore );
114815 sqlite3VdbeGoto(v, ignoreDest);
114816 break;
114817 }
114818 }
 
114819 sqlite3VdbeResolveLabel(v, addrRowidOk);
114820 if( sAddr.ipkTop ){
114821 sAddr.ipkBtm = sqlite3VdbeAddOp0(v, OP_Goto);
114822 sqlite3VdbeJumpHere(v, sAddr.ipkTop-1);
114823 }
@@ -114835,23 +115740,23 @@
114835 int regR; /* Range of registers holding conflicting PK */
114836 int iThisCur; /* Cursor for this UNIQUE index */
114837 int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */
114838
114839 if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */
 
 
 
 
114840 if( pUpIdx==pIdx ){
114841 addrUniqueOk = sAddr.upsertBtm;
114842 upsertBypass = sqlite3VdbeGoto(v, 0);
114843 VdbeComment((v, "Skip upsert subroutine"));
114844 sqlite3VdbeResolveLabel(v, sAddr.upsertTop2);
114845 }else{
114846 addrUniqueOk = sqlite3VdbeMakeLabel(v);
114847 }
114848 VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName));
114849 if( bAffinityDone==0 ){
114850 sqlite3TableAffinity(v, pTab, regNewData+1);
114851 bAffinityDone = 1;
114852 }
114853 iThisCur = iIdxCur+ix;
114854
114855
114856 /* Skip partial indices for which the WHERE clause is not true */
114857 if( pIdx->pPartIdxWhere ){
@@ -119458,10 +120363,15 @@
119458 }
119459 assert( pParse->nMem>=8+j );
119460 assert( sqlite3NoTempsInRange(pParse,1,7+j) );
119461 sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
119462 loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
 
 
 
 
 
119463 /* Verify that all NOT NULL columns really are NOT NULL */
119464 for(j=0; j<pTab->nCol; j++){
119465 char *zErr;
119466 int jmp2;
119467 if( j==pTab->iPKey ) continue;
@@ -119500,13 +120410,10 @@
119500 sqlite3ExprCachePop(pParse);
119501 }
119502 sqlite3ExprListDelete(db, pCheck);
119503 }
119504 if( !isQuick ){ /* Omit the remaining tests for quick_check */
119505 /* Sanity check on record header decoding */
119506 sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3);
119507 sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
119508 /* Validate index entries for the current row */
119509 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
119510 int jmp2, jmp3, jmp4, jmp5;
119511 int ckUniq = sqlite3VdbeMakeLabel(v);
119512 if( pPk==pIdx ) continue;
@@ -120573,11 +121480,11 @@
120573 /* If there is not already a read-only (or read-write) transaction opened
120574 ** on the b-tree database, open one now. If a transaction is opened, it
120575 ** will be closed before this function returns. */
120576 sqlite3BtreeEnter(pDb->pBt);
120577 if( !sqlite3BtreeIsInReadTrans(pDb->pBt) ){
120578 rc = sqlite3BtreeBeginTrans(pDb->pBt, 0);
120579 if( rc!=SQLITE_OK ){
120580 sqlite3SetString(pzErrMsg, db, sqlite3ErrStr(rc));
120581 goto initone_error_out;
120582 }
120583 openedTransaction = 1;
@@ -120818,11 +121725,11 @@
120818
120819 /* If there is not already a read-only (or read-write) transaction opened
120820 ** on the b-tree database, open one now. If a transaction is opened, it
120821 ** will be closed immediately after reading the meta-value. */
120822 if( !sqlite3BtreeIsInReadTrans(pBt) ){
120823 rc = sqlite3BtreeBeginTrans(pBt, 0);
120824 if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){
120825 sqlite3OomFault(db);
120826 }
120827 if( rc!=SQLITE_OK ) return;
120828 openedTransaction = 1;
@@ -121315,11 +122222,11 @@
121315 */
121316 #if SELECTTRACE_ENABLED
121317 /***/ int sqlite3SelectTrace = 0;
121318 # define SELECTTRACE(K,P,S,X) \
121319 if(sqlite3SelectTrace&(K)) \
121320 sqlite3DebugPrintf("%s/%d/%p: ",(S)->zSelName,(P)->addrExplain,(S)),\
121321 sqlite3DebugPrintf X
121322 #else
121323 # define SELECTTRACE(K,P,S,X)
121324 #endif
121325
@@ -121390,10 +122297,15 @@
121390 sqlite3ExprDelete(db, p->pWhere);
121391 sqlite3ExprListDelete(db, p->pGroupBy);
121392 sqlite3ExprDelete(db, p->pHaving);
121393 sqlite3ExprListDelete(db, p->pOrderBy);
121394 sqlite3ExprDelete(db, p->pLimit);
 
 
 
 
 
121395 if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);
121396 if( bFree ) sqlite3DbFreeNN(db, p);
121397 p = pPrior;
121398 bFree = 1;
121399 }
@@ -121440,13 +122352,11 @@
121440 pNew->pEList = pEList;
121441 pNew->op = TK_SELECT;
121442 pNew->selFlags = selFlags;
121443 pNew->iLimit = 0;
121444 pNew->iOffset = 0;
121445 #if SELECTTRACE_ENABLED
121446 pNew->zSelName[0] = 0;
121447 #endif
121448 pNew->addrOpenEphm[0] = -1;
121449 pNew->addrOpenEphm[1] = -1;
121450 pNew->nSelectRow = 0;
121451 if( pSrc==0 ) pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*pSrc));
121452 pNew->pSrc = pSrc;
@@ -121456,10 +122366,14 @@
121456 pNew->pOrderBy = pOrderBy;
121457 pNew->pPrior = 0;
121458 pNew->pNext = 0;
121459 pNew->pLimit = pLimit;
121460 pNew->pWith = 0;
 
 
 
 
121461 if( pParse->db->mallocFailed ) {
121462 clearSelect(pParse->db, pNew, pNew!=&standin);
121463 pNew = 0;
121464 }else{
121465 assert( pNew->pSrc!=0 || pParse->nErr>0 );
@@ -121466,21 +122380,10 @@
121466 }
121467 assert( pNew!=&standin );
121468 return pNew;
121469 }
121470
121471 #if SELECTTRACE_ENABLED
121472 /*
121473 ** Set the name of a Select object
121474 */
121475 SQLITE_PRIVATE void sqlite3SelectSetName(Select *p, const char *zName){
121476 if( p && zName ){
121477 sqlite3_snprintf(sizeof(p->zSelName), p->zSelName, "%s", zName);
121478 }
121479 }
121480 #endif
121481
121482
121483 /*
121484 ** Delete the given Select structure and all of its substructures.
121485 */
121486 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){
@@ -121823,18 +122726,10 @@
121823 }
121824 }
121825 return 0;
121826 }
121827
121828 /* Forward reference */
121829 static KeyInfo *keyInfoFromExprList(
121830 Parse *pParse, /* Parsing context */
121831 ExprList *pList, /* Form the KeyInfo object from this ExprList */
121832 int iStart, /* Begin with this column of pList */
121833 int nExtra /* Add this many extra columns to the end */
121834 );
121835
121836 /*
121837 ** An instance of this object holds information (beyond pParse and pSelect)
121838 ** needed to load the next result row that is to be added to the sorter.
121839 */
121840 typedef struct RowLoadInfo RowLoadInfo;
@@ -121972,11 +122867,11 @@
121972 pOp->p2 = nKey + nData;
121973 pKI = pOp->p4.pKeyInfo;
121974 memset(pKI->aSortOrder, 0, pKI->nKeyField); /* Makes OP_Jump testable */
121975 sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
121976 testcase( pKI->nAllField > pKI->nKeyField+2 );
121977 pOp->p4.pKeyInfo = keyInfoFromExprList(pParse, pSort->pOrderBy, nOBSat,
121978 pKI->nAllField-pKI->nKeyField-1);
121979 addrJmp = sqlite3VdbeCurrentAddr(v);
121980 sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
121981 pSort->labelBkOut = sqlite3VdbeMakeLabel(v);
121982 pSort->regReturn = ++pParse->nMem;
@@ -122642,11 +123537,11 @@
122642 **
122643 ** Space to hold the KeyInfo structure is obtained from malloc. The calling
122644 ** function is responsible for seeing that this structure is eventually
122645 ** freed.
122646 */
122647 static KeyInfo *keyInfoFromExprList(
122648 Parse *pParse, /* Parsing context */
122649 ExprList *pList, /* Form the KeyInfo object from this ExprList */
122650 int iStart, /* Begin with this column of pList */
122651 int nExtra /* Add this many extra columns to the end */
122652 ){
@@ -124970,10 +125865,14 @@
124970 ** The subquery may not be an aggregate that uses the built-in min() or
124971 ** or max() functions. (Without this restriction, a query like:
124972 ** "SELECT x FROM (SELECT max(y), x FROM t1)" would not necessarily
124973 ** return the value X for which Y was maximal.)
124974 **
 
 
 
 
124975 **
124976 ** In this routine, the "p" parameter is a pointer to the outer query.
124977 ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query
124978 ** uses aggregates.
124979 **
@@ -125012,10 +125911,14 @@
125012 assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );
125013 pSubitem = &pSrc->a[iFrom];
125014 iParent = pSubitem->iCursor;
125015 pSub = pSubitem->pSelect;
125016 assert( pSub!=0 );
 
 
 
 
125017
125018 pSubSrc = pSub->pSrc;
125019 assert( pSubSrc );
125020 /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,
125021 ** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET
@@ -125123,12 +126026,12 @@
125123 ** restriction (17d3)
125124 */
125125 assert( (p->selFlags & SF_Recursive)==0 || pSub->pPrior==0 );
125126
125127 /***** If we reach this point, flattening is permitted. *****/
125128 SELECTTRACE(1,pParse,p,("flatten %s.%p from term %d\n",
125129 pSub->zSelName, pSub, iFrom));
125130
125131 /* Authorize the subquery */
125132 pParse->zAuthContext = pSubitem->zName;
125133 TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);
125134 testcase( i==SQLITE_DENY );
@@ -125175,11 +126078,10 @@
125175 p->pOrderBy = 0;
125176 p->pSrc = 0;
125177 p->pPrior = 0;
125178 p->pLimit = 0;
125179 pNew = sqlite3SelectDup(db, p, 0);
125180 sqlite3SelectSetName(pNew, pSub->zSelName);
125181 p->pLimit = pLimit;
125182 p->pOrderBy = pOrderBy;
125183 p->pSrc = pSrc;
125184 p->op = TK_ALL;
125185 if( pNew==0 ){
@@ -125188,11 +126090,11 @@
125188 pNew->pPrior = pPrior;
125189 if( pPrior ) pPrior->pNext = pNew;
125190 pNew->pNext = p;
125191 p->pPrior = pNew;
125192 SELECTTRACE(2,pParse,p,("compound-subquery flattener"
125193 " creates %s.%p as peer\n",pNew->zSelName, pNew));
125194 }
125195 if( db->mallocFailed ) return 1;
125196 }
125197
125198 /* Begin flattening the iFrom-th entry of the FROM clause
@@ -125403,11 +126305,11 @@
125403 ** to suppress it. **)
125404 **
125405 ** (2) The inner query is the recursive part of a common table expression.
125406 **
125407 ** (3) The inner query has a LIMIT clause (since the changes to the WHERE
125408 ** close would change the meaning of the LIMIT).
125409 **
125410 ** (4) The inner query is the right operand of a LEFT JOIN and the
125411 ** expression to be pushed down does not come from the ON clause
125412 ** on that LEFT JOIN.
125413 **
@@ -125421,10 +126323,14 @@
125421 ** LEFT JOIN (SELECT 8 AS c3 UNION ALL SELECT 9) AS cc ON (b2=2);
125422 **
125423 ** The correct answer is three rows: (1,1,NULL),(2,2,8),(2,2,9).
125424 ** But if the (b2=2) term were to be pushed down into the bb subquery,
125425 ** then the (1,1,NULL) row would be suppressed.
 
 
 
 
125426 **
125427 ** Return 0 if no changes are made and non-zero if one or more WHERE clause
125428 ** terms are duplicated into the subquery.
125429 */
125430 static int pushDownWhereTerms(
@@ -125436,10 +126342,14 @@
125436 ){
125437 Expr *pNew;
125438 int nChng = 0;
125439 if( pWhere==0 ) return 0;
125440 if( pSubq->selFlags & SF_Recursive ) return 0; /* restriction (2) */
 
 
 
 
125441
125442 #ifdef SQLITE_DEBUG
125443 /* Only the first term of a compound can have a WITH clause. But make
125444 ** sure no other terms are marked SF_Recursive in case something changes
125445 ** in the future.
@@ -125881,10 +126791,39 @@
125881 }
125882 }
125883 #else
125884 #define selectPopWith 0
125885 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125886
125887 /*
125888 ** This routine is a Walker callback for "expanding" a SELECT statement.
125889 ** "Expanding" means to do the following:
125890 **
@@ -125954,23 +126893,11 @@
125954 Select *pSel = pFrom->pSelect;
125955 /* A sub-query in the FROM clause of a SELECT */
125956 assert( pSel!=0 );
125957 assert( pFrom->pTab==0 );
125958 if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;
125959 pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
125960 if( pTab==0 ) return WRC_Abort;
125961 pTab->nTabRef = 1;
125962 if( pFrom->zAlias ){
125963 pTab->zName = sqlite3DbStrDup(db, pFrom->zAlias);
125964 }else{
125965 pTab->zName = sqlite3MPrintf(db, "subquery_%p", (void*)pTab);
125966 }
125967 while( pSel->pPrior ){ pSel = pSel->pPrior; }
125968 sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);
125969 pTab->iPKey = -1;
125970 pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
125971 pTab->tabFlags |= TF_Ephemeral;
125972 #endif
125973 }else{
125974 /* An ordinary table or view name in the FROM clause */
125975 assert( pFrom->pTab==0 );
125976 pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom);
@@ -125989,11 +126916,10 @@
125989 if( IsVirtual(pTab) || pTab->pSelect ){
125990 i16 nCol;
125991 if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;
125992 assert( pFrom->pSelect==0 );
125993 pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);
125994 sqlite3SelectSetName(pFrom->pSelect, pTab->zName);
125995 nCol = pTab->nCol;
125996 pTab->nCol = -1;
125997 sqlite3WalkSelect(pWalker, pFrom->pSelect);
125998 pTab->nCol = nCol;
125999 }
@@ -126267,11 +127193,11 @@
126267 int i;
126268 SrcList *pTabList;
126269 struct SrcList_item *pFrom;
126270
126271 assert( p->selFlags & SF_Resolved );
126272 assert( (p->selFlags & SF_HasTypeInfo)==0 );
126273 p->selFlags |= SF_HasTypeInfo;
126274 pParse = pWalker->pParse;
126275 pTabList = p->pSrc;
126276 for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
126277 Table *pTab = pFrom->pTab;
@@ -126370,11 +127296,11 @@
126370 if( pE->x.pList==0 || pE->x.pList->nExpr!=1 ){
126371 sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one "
126372 "argument");
126373 pFunc->iDistinct = -1;
126374 }else{
126375 KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pE->x.pList, 0, 0);
126376 sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc->iDistinct, 0, 0,
126377 (char*)pKeyInfo, P4_KEYINFO);
126378 }
126379 }
126380 }
@@ -126393,16 +127319,22 @@
126393 assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
126394 sqlite3VdbeAddOp2(v, OP_AggFinal, pF->iMem, pList ? pList->nExpr : 0);
126395 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
126396 }
126397 }
 
126398
126399 /*
126400 ** Update the accumulator memory cells for an aggregate based on
126401 ** the current cursor position.
 
 
 
 
 
126402 */
126403 static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
126404 Vdbe *v = pParse->pVdbe;
126405 int i;
126406 int regHit = 0;
126407 int addrHitTest = 0;
126408 struct AggInfo_func *pF;
@@ -126441,11 +127373,11 @@
126441 pColl = pParse->db->pDfltColl;
126442 }
126443 if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem;
126444 sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ);
126445 }
126446 sqlite3VdbeAddOp3(v, OP_AggStep0, 0, regAgg, pF->iMem);
126447 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
126448 sqlite3VdbeChangeP5(v, (u8)nArg);
126449 sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);
126450 sqlite3ReleaseTempRange(pParse, regAgg, nArg);
126451 if( addrNext ){
@@ -126462,10 +127394,13 @@
126462 ** text or blob value. See ticket [883034dcb5].
126463 **
126464 ** Another solution would be to change the OP_SCopy used to copy cached
126465 ** values to an OP_Copy.
126466 */
 
 
 
126467 if( regHit ){
126468 addrHitTest = sqlite3VdbeAddOp1(v, OP_If, regHit); VdbeCoverage(v);
126469 }
126470 sqlite3ExprCacheClear(pParse);
126471 for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){
@@ -126735,18 +127670,14 @@
126735 sqlite3ExprListDelete(db, p->pOrderBy);
126736 p->pOrderBy = 0;
126737 p->selFlags &= ~SF_Distinct;
126738 }
126739 sqlite3SelectPrep(pParse, p, 0);
126740 memset(&sSort, 0, sizeof(sSort));
126741 sSort.pOrderBy = p->pOrderBy;
126742 pTabList = p->pSrc;
126743 if( pParse->nErr || db->mallocFailed ){
126744 goto select_end;
126745 }
126746 assert( p->pEList!=0 );
126747 isAgg = (p->selFlags & SF_Aggregate)!=0;
126748 #if SELECTTRACE_ENABLED
126749 if( sqlite3SelectTrace & 0x104 ){
126750 SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
126751 sqlite3TreeViewSelect(0, p, 0);
126752 }
@@ -126754,10 +127685,26 @@
126754
126755 if( pDest->eDest==SRT_Output ){
126756 generateColumnNames(pParse, p);
126757 }
126758
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126759 /* Try to various optimizations (flattening subqueries, and strength
126760 ** reduction of join operators) in the FROM clause up into the main query
126761 */
126762 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
126763 for(i=0; !p->pPrior && i<pTabList->nSrc; i++){
@@ -126960,11 +127907,11 @@
126960 pItem->regReturn = ++pParse->nMem;
126961 sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->regReturn, 0, addrTop);
126962 VdbeComment((v, "%s", pItem->pTab->zName));
126963 pItem->addrFillSub = addrTop;
126964 sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn);
126965 ExplainQueryPlan((pParse, 1, "CO-ROUTINE 0x%p", pSub));
126966 sqlite3Select(pParse, pSub, &dest);
126967 pItem->pTab->nRowLogEst = pSub->nSelectRow;
126968 pItem->fg.viaCoroutine = 1;
126969 pItem->regResult = dest.iSdst;
126970 sqlite3VdbeEndCoroutine(v, pItem->regReturn);
@@ -126999,11 +127946,11 @@
126999 sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
127000 assert( pPrior->pSelect!=0 );
127001 pSub->nSelectRow = pPrior->pSelect->nSelectRow;
127002 }else{
127003 sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
127004 ExplainQueryPlan((pParse, 1, "MATERIALIZE 0x%p", pSub));
127005 sqlite3Select(pParse, pSub, &dest);
127006 }
127007 pItem->pTab->nRowLogEst = pSub->nSelectRow;
127008 if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);
127009 retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);
@@ -127083,11 +128030,12 @@
127083 ** not needed. The sSort.addrSortIndex variable is used to facilitate
127084 ** that change.
127085 */
127086 if( sSort.pOrderBy ){
127087 KeyInfo *pKeyInfo;
127088 pKeyInfo = keyInfoFromExprList(pParse, sSort.pOrderBy, 0, pEList->nExpr);
 
127089 sSort.iECursor = pParse->nTab++;
127090 sSort.addrSortIndex =
127091 sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
127092 sSort.iECursor, sSort.pOrderBy->nExpr+1+pEList->nExpr, 0,
127093 (char*)pKeyInfo, P4_KEYINFO
@@ -127117,24 +128065,31 @@
127117 /* Open an ephemeral index to use for the distinct set.
127118 */
127119 if( p->selFlags & SF_Distinct ){
127120 sDistinct.tabTnct = pParse->nTab++;
127121 sDistinct.addrTnct = sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
127122 sDistinct.tabTnct, 0, 0,
127123 (char*)keyInfoFromExprList(pParse, p->pEList,0,0),
127124 P4_KEYINFO);
127125 sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
127126 sDistinct.eTnctType = WHERE_DISTINCT_UNORDERED;
127127 }else{
127128 sDistinct.eTnctType = WHERE_DISTINCT_NOOP;
127129 }
127130
127131 if( !isAgg && pGroupBy==0 ){
127132 /* No aggregate functions and no GROUP BY clause */
127133 u16 wctrlFlags = (sDistinct.isTnct ? WHERE_WANT_DISTINCT : 0);
 
 
 
 
 
 
 
127134 assert( WHERE_USE_LIMIT==SF_FixedLimit );
127135 wctrlFlags |= p->selFlags & SF_FixedLimit;
127136
127137 /* Begin the database scan. */
127138 SELECTTRACE(1,pParse,p,("WhereBegin\n"));
127139 pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, sSort.pOrderBy,
127140 p->pEList, wctrlFlags, p->nSelectRow);
@@ -127159,19 +128114,40 @@
127159 */
127160 if( sSort.addrSortIndex>=0 && sSort.pOrderBy==0 ){
127161 sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex);
127162 }
127163
127164 /* Use the standard inner loop. */
127165 assert( p->pEList==pEList );
127166 selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest,
127167 sqlite3WhereContinueLabel(pWInfo),
127168 sqlite3WhereBreakLabel(pWInfo));
 
 
 
127169
127170 /* End the database scan loop.
127171 */
127172 sqlite3WhereEnd(pWInfo);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127173 }else{
127174 /* This case when there exist aggregate functions or a GROUP BY clause
127175 ** or both */
127176 NameContext sNC; /* Name context for processing aggregate information */
127177 int iAMem; /* First Mem address for storing current GROUP BY */
@@ -127296,11 +128272,11 @@
127296 ** implement it. Allocate that sorting index now. If it turns out
127297 ** that we do not need it after all, the OP_SorterOpen instruction
127298 ** will be converted into a Noop.
127299 */
127300 sAggInfo.sortingIdx = pParse->nTab++;
127301 pKeyInfo = keyInfoFromExprList(pParse, pGroupBy, 0, sAggInfo.nColumn);
127302 addrSortingIdx = sqlite3VdbeAddOp4(v, OP_SorterOpen,
127303 sAggInfo.sortingIdx, sAggInfo.nSortingColumn,
127304 0, (char*)pKeyInfo, P4_KEYINFO);
127305
127306 /* Initialize memory locations used by GROUP BY aggregate processing
@@ -127315,12 +128291,10 @@
127315 pParse->nMem += pGroupBy->nExpr;
127316 iBMem = pParse->nMem + 1;
127317 pParse->nMem += pGroupBy->nExpr;
127318 sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag);
127319 VdbeComment((v, "clear abort flag"));
127320 sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);
127321 VdbeComment((v, "indicate accumulator empty"));
127322 sqlite3VdbeAddOp3(v, OP_Null, 0, iAMem, iAMem+pGroupBy->nExpr-1);
127323
127324 /* Begin a loop that will extract all source rows in GROUP BY order.
127325 ** This might involve two separate loops with an OP_Sort in between, or
127326 ** it might be a single loop that uses an index to extract information
@@ -127449,11 +128423,11 @@
127449
127450 /* Update the aggregate accumulators based on the content of
127451 ** the current row
127452 */
127453 sqlite3VdbeJumpHere(v, addr1);
127454 updateAccumulator(pParse, &sAggInfo);
127455 sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);
127456 VdbeComment((v, "indicate data in accumulator"));
127457
127458 /* End of the loop
127459 */
@@ -127501,10 +128475,12 @@
127501
127502 /* Generate a subroutine that will reset the group-by accumulator
127503 */
127504 sqlite3VdbeResolveLabel(v, addrReset);
127505 resetAccumulator(pParse, &sAggInfo);
 
 
127506 sqlite3VdbeAddOp1(v, OP_Return, regReset);
127507
127508 } /* endif pGroupBy. Begin aggregate queries without GROUP BY: */
127509 else {
127510 #ifndef SQLITE_OMIT_BTREECOUNT
@@ -127566,10 +128542,27 @@
127566 sqlite3VdbeAddOp1(v, OP_Close, iCsr);
127567 explainSimpleCount(pParse, pTab, pBest);
127568 }else
127569 #endif /* SQLITE_OMIT_BTREECOUNT */
127570 {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127571 /* This case runs if the aggregate has no GROUP BY clause. The
127572 ** processing is much simpler since there is only a single row
127573 ** of output.
127574 */
127575 assert( p->pGroupBy==0 );
@@ -127587,11 +128580,12 @@
127587 pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMaxOrderBy,
127588 0, minMaxFlag, 0);
127589 if( pWInfo==0 ){
127590 goto select_end;
127591 }
127592 updateAccumulator(pParse, &sAggInfo);
 
127593 if( sqlite3WhereIsOrdered(pWInfo)>0 ){
127594 sqlite3VdbeGoto(v, sqlite3WhereBreakLabel(pWInfo));
127595 VdbeComment((v, "%s() by index",
127596 (minMaxFlag==WHERE_ORDERBY_MIN?"min":"max")));
127597 }
@@ -129520,11 +130514,11 @@
129520 /* Top of the update loop */
129521 if( eOnePass!=ONEPASS_OFF ){
129522 if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){
129523 assert( pPk );
129524 sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey,nKey);
129525 VdbeCoverageNeverTaken(v);
129526 }
129527 if( eOnePass!=ONEPASS_SINGLE ){
129528 labelContinue = sqlite3VdbeMakeLabel(v);
129529 }
129530 sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
@@ -130423,11 +131417,11 @@
130423 ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,
130424 ** to ensure that we do not try to change the page-size on a WAL database.
130425 */
130426 rc = execSql(db, pzErrMsg, "BEGIN");
130427 if( rc!=SQLITE_OK ) goto end_of_vacuum;
130428 rc = sqlite3BtreeBeginTrans(pMain, 2);
130429 if( rc!=SQLITE_OK ) goto end_of_vacuum;
130430
130431 /* Do not attempt to change the page size for a WAL database */
130432 if( sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain))
130433 ==PAGER_JOURNALMODE_WAL ){
@@ -131932,10 +132926,12 @@
131932 struct {
131933 int nIn; /* Number of entries in aInLoop[] */
131934 struct InLoop {
131935 int iCur; /* The VDBE cursor used by this IN operator */
131936 int addrInTop; /* Top of the IN loop */
 
 
131937 u8 eEndLoopOp; /* IN Loop terminator. OP_Next or OP_Prev */
131938 } *aInLoop; /* Information about each nested IN operator */
131939 } in; /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */
131940 Index *pCovidx; /* Possible covering index for WHERE_MULTI_OR */
131941 } u;
@@ -132170,10 +133166,11 @@
132170 */
132171 struct WhereClause {
132172 WhereInfo *pWInfo; /* WHERE clause processing context */
132173 WhereClause *pOuter; /* Outer conjunction */
132174 u8 op; /* Split operator. TK_AND or TK_OR */
 
132175 int nTerm; /* Number of terms */
132176 int nSlot; /* Number of entries in a[] */
132177 WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
132178 #if defined(SQLITE_SMALL_STACK)
132179 WhereTerm aStatic[1]; /* Initial static space for a[] */
@@ -132343,10 +133340,11 @@
132343 /* whereexpr.c: */
132344 SQLITE_PRIVATE void sqlite3WhereClauseInit(WhereClause*,WhereInfo*);
132345 SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause*);
132346 SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause*,Expr*,u8);
132347 SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*);
 
132348 SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*);
132349 SQLITE_PRIVATE void sqlite3WhereExprAnalyze(SrcList*, WhereClause*);
132350 SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*);
132351
132352
@@ -132405,10 +133403,11 @@
132405 #define WHERE_MULTI_OR 0x00002000 /* OR using multiple indices */
132406 #define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
132407 #define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
132408 #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
132409 #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
 
132410
132411 /************** End of whereInt.h ********************************************/
132412 /************** Continuing where we left off in wherecode.c ******************/
132413
132414 #ifndef SQLITE_OMIT_EXPLAIN
@@ -132539,11 +133538,11 @@
132539 || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
132540
132541 sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
132542 sqlite3_str_appendall(&str, isSearch ? "SEARCH" : "SCAN");
132543 if( pItem->pSelect ){
132544 sqlite3_str_appendf(&str, " SUBQUERY 0x%p", pItem->pSelect);
132545 }else{
132546 sqlite3_str_appendf(&str, " TABLE %s", pItem->zName);
132547 }
132548
132549 if( pItem->zAlias ){
@@ -132980,11 +133979,18 @@
132980 pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut);
132981 }
132982 sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v);
132983 if( i==iEq ){
132984 pIn->iCur = iTab;
132985 pIn->eEndLoopOp = bRev ? OP_PrevIfOpen : OP_NextIfOpen;
 
 
 
 
 
 
 
132986 }else{
132987 pIn->eEndLoopOp = OP_Noop;
132988 }
132989 pIn++;
132990 }
@@ -133624,11 +134630,11 @@
133624 if( pTabItem->fg.viaCoroutine ){
133625 int regYield = pTabItem->regReturn;
133626 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
133627 pLevel->p2 = sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk);
133628 VdbeCoverage(v);
133629 VdbeComment((v, "next row of \"%s\"", pTabItem->pTab->zName));
133630 pLevel->op = OP_Goto;
133631 }else
133632
133633 #ifndef SQLITE_OMIT_VIRTUALTABLE
133634 if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){
@@ -134047,10 +135053,13 @@
134047 if( pLoop->nSkip>0 && nConstraint==pLoop->nSkip ){
134048 /* The skip-scan logic inside the call to codeAllEqualityConstraints()
134049 ** above has already left the cursor sitting on the correct row,
134050 ** so no further seeking is needed */
134051 }else{
 
 
 
134052 op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
134053 assert( op!=0 );
134054 sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
134055 VdbeCoverage(v);
134056 VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind );
@@ -134109,10 +135118,14 @@
134109 testcase( op==OP_IdxGT ); VdbeCoverageIf(v, op==OP_IdxGT );
134110 testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE );
134111 testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
134112 testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
134113 }
 
 
 
 
134114
134115 /* Seek the table cursor, if required */
134116 if( omitTable ){
134117 /* pIdx is a covering index. No need to access the main table. */
134118 }else if( HasRowid(pIdx->pTable) ){
@@ -134882,15 +135895,17 @@
134882 if( c==wc[3] && z[cnt]!=0 ) cnt++;
134883 }
134884
134885 /* The optimization is possible only if (1) the pattern does not begin
134886 ** with a wildcard and if (2) the non-wildcard prefix does not end with
134887 ** an (illegal 0xff) character. The second condition is necessary so
 
134888 ** that we can increment the prefix key to find an upper bound for the
134889 ** range search.
134890 */
134891 if( cnt!=0 && 255!=(u8)z[cnt-1] ){
 
134892 Expr *pPrefix;
134893
134894 /* A "complete" match if the pattern ends with "*" or "%" */
134895 *pisComplete = c==wc[0] && z[cnt+1]==0;
134896
@@ -135298,11 +136313,16 @@
135298 /*
135299 ** Record the set of tables that satisfy case 3. The set might be
135300 ** empty.
135301 */
135302 pOrInfo->indexable = indexable;
135303 pTerm->eOperator = indexable==0 ? 0 : WO_OR;
 
 
 
 
 
135304
135305 /* For a two-way OR, attempt to implementation case 2.
135306 */
135307 if( indexable && pOrWc->nTerm==2 ){
135308 int iOne = 0;
@@ -135637,11 +136657,11 @@
135637 pTerm->prereqRight = 0;
135638 }else{
135639 pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
135640 }
135641 pMaskSet->bVarSelect = 0;
135642 prereqAll = sqlite3WhereExprUsage(pMaskSet, pExpr);
135643 if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;
135644 if( ExprHasProperty(pExpr, EP_FromJoin) ){
135645 Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
135646 prereqAll |= x;
135647 extraRight = x-1; /* ON clause terms may not be used with an index
@@ -136030,10 +137050,11 @@
136030 SQLITE_PRIVATE void sqlite3WhereClauseInit(
136031 WhereClause *pWC, /* The WhereClause to be initialized */
136032 WhereInfo *pWInfo /* The WHERE processing context */
136033 ){
136034 pWC->pWInfo = pWInfo;
 
136035 pWC->pOuter = 0;
136036 pWC->nTerm = 0;
136037 pWC->nSlot = ArraySize(pWC->aStatic);
136038 pWC->a = pWC->aStatic;
136039 }
@@ -136066,29 +137087,33 @@
136066 /*
136067 ** These routines walk (recursively) an expression tree and generate
136068 ** a bitmask indicating which tables are used in that expression
136069 ** tree.
136070 */
136071 SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
136072 Bitmask mask;
136073 if( p==0 ) return 0;
136074 if( p->op==TK_COLUMN ){
136075 return sqlite3WhereGetMask(pMaskSet, p->iTable);
 
 
 
136076 }
136077 mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
136078 assert( !ExprHasProperty(p, EP_TokenOnly) );
136079 if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft);
136080 if( p->pRight ){
136081 mask |= sqlite3WhereExprUsage(pMaskSet, p->pRight);
136082 assert( p->x.pList==0 );
136083 }else if( ExprHasProperty(p, EP_xIsSelect) ){
136084 if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1;
136085 mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
136086 }else if( p->x.pList ){
136087 mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
136088 }
136089 return mask;
 
 
 
136090 }
136091 SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet *pMaskSet, ExprList *pList){
136092 int i;
136093 Bitmask mask = 0;
136094 if( pList ){
@@ -136970,11 +137995,11 @@
136970 int regYield = pTabItem->regReturn;
136971 addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);
136972 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
136973 addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield);
136974 VdbeCoverage(v);
136975 VdbeComment((v, "next row of \"%s\"", pTabItem->pTab->zName));
136976 }else{
136977 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);
136978 }
136979 if( pPartial ){
136980 iContinue = sqlite3VdbeMakeLabel(v);
@@ -138611,11 +139636,10 @@
138611 || (pNew->wsFlags & WHERE_SKIPSCAN)!=0
138612 );
138613
138614 if( eOp & WO_IN ){
138615 Expr *pExpr = pTerm->pExpr;
138616 pNew->wsFlags |= WHERE_COLUMN_IN;
138617 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
138618 /* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */
138619 int i;
138620 nIn = 46; assert( 46==sqlite3LogEst(25) );
138621
@@ -138631,10 +139655,46 @@
138631 /* "x IN (value, value, ...)" */
138632 nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
138633 assert( nIn>0 ); /* RHS always has 2 or more terms... The parser
138634 ** changes "x IN (?)" into "x=?". */
138635 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138636 }else if( eOp & (WO_EQ|WO_IS) ){
138637 int iCol = pProbe->aiColumn[saved_nEq];
138638 pNew->wsFlags |= WHERE_COLUMN_EQ;
138639 assert( saved_nEq==pNew->u.btree.nEq );
138640 if( iCol==XN_ROWID
@@ -138797,10 +139857,11 @@
138797 ** more expensive. */
138798 assert( 42==sqlite3LogEst(18) );
138799 if( saved_nEq==saved_nSkip
138800 && saved_nEq+1<pProbe->nKeyCol
138801 && pProbe->noSkipScan==0
 
138802 && pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */
138803 && (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
138804 ){
138805 LogEst nIter;
138806 pNew->u.btree.nEq++;
@@ -138860,28 +139921,10 @@
138860 }
138861 }
138862 return 0;
138863 }
138864
138865 /*
138866 ** Return a bitmask where 1s indicate that the corresponding column of
138867 ** the table is used by an index. Only the first 63 columns are considered.
138868 */
138869 static Bitmask columnsInIndex(Index *pIdx){
138870 Bitmask m = 0;
138871 int j;
138872 for(j=pIdx->nColumn-1; j>=0; j--){
138873 int x = pIdx->aiColumn[j];
138874 if( x>=0 ){
138875 testcase( x==BMS-1 );
138876 testcase( x==BMS-2 );
138877 if( x<BMS-1 ) m |= MASKBIT(x);
138878 }
138879 }
138880 return m;
138881 }
138882
138883 /* Check to see if a partial index with pPartIndexWhere can be used
138884 ** in the current query. Return true if it can be and false if not.
138885 */
138886 static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
138887 int i;
@@ -139093,11 +140136,11 @@
139093 Bitmask m;
139094 if( pProbe->isCovering ){
139095 pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
139096 m = 0;
139097 }else{
139098 m = pSrc->colUsed & ~columnsInIndex(pProbe);
139099 pNew->wsFlags = (m==0) ? (WHERE_IDX_ONLY|WHERE_INDEXED) : WHERE_INDEXED;
139100 }
139101
139102 /* Full scan via index */
139103 if( b
@@ -139660,11 +140703,11 @@
139660 }else
139661 #endif /* SQLITE_OMIT_VIRTUALTABLE */
139662 {
139663 rc = whereLoopAddBtree(pBuilder, mPrereq);
139664 }
139665 if( rc==SQLITE_OK ){
139666 rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
139667 }
139668 mPrior |= pNew->maskSelf;
139669 if( rc || db->mallocFailed ) break;
139670 }
@@ -140496,11 +141539,11 @@
140496 testcase( pTerm->eOperator & WO_IS );
140497 pLoop->aLTerm[j] = pTerm;
140498 }
140499 if( j!=pIdx->nKeyCol ) continue;
140500 pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED;
140501 if( pIdx->isCovering || (pItem->colUsed & ~columnsInIndex(pIdx))==0 ){
140502 pLoop->wsFlags |= WHERE_IDX_ONLY;
140503 }
140504 pLoop->nLTerm = j;
140505 pLoop->u.btree.nEq = j;
140506 pLoop->u.btree.pIndex = pIdx;
@@ -141176,10 +142219,30 @@
141176 whereInfoFree(db, pWInfo);
141177 }
141178 return 0;
141179 }
141180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141181 /*
141182 ** Generate the end of the WHERE loop. See comments on
141183 ** sqlite3WhereBegin() for additional information.
141184 */
141185 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
@@ -141243,14 +142306,21 @@
141243 int j;
141244 sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
141245 for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
141246 sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
141247 if( pIn->eEndLoopOp!=OP_Noop ){
 
 
 
 
 
 
 
141248 sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
141249 VdbeCoverage(v);
141250 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
141251 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
141252 }
141253 sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
141254 }
141255 }
141256 sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
@@ -141337,10 +142407,15 @@
141337 && (pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable))
141338 && !db->mallocFailed
141339 ){
141340 last = sqlite3VdbeCurrentAddr(v);
141341 k = pLevel->addrBody;
 
 
 
 
 
141342 pOp = sqlite3VdbeGetOp(v, k);
141343 for(; k<last; k++, pOp++){
141344 if( pOp->p1!=pLevel->iTabCur ) continue;
141345 if( pOp->opcode==OP_Column
141346 #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
@@ -141356,20 +142431,26 @@
141356 }
141357 x = sqlite3ColumnOfIndex(pIdx, x);
141358 if( x>=0 ){
141359 pOp->p2 = x;
141360 pOp->p1 = pLevel->iIdxCur;
 
141361 }
141362 assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0
141363 || pWInfo->eOnePass );
141364 }else if( pOp->opcode==OP_Rowid ){
141365 pOp->p1 = pLevel->iIdxCur;
141366 pOp->opcode = OP_IdxRowid;
 
141367 }else if( pOp->opcode==OP_IfNullRow ){
141368 pOp->p1 = pLevel->iIdxCur;
 
141369 }
141370 }
 
 
 
141371 }
141372 }
141373
141374 /* Final cleanup
141375 */
@@ -141377,10 +142458,2262 @@
141377 whereInfoFree(db, pWInfo);
141378 return;
141379 }
141380
141381 /************** End of where.c ***********************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141382 /************** Begin file parse.c *******************************************/
141383 /*
141384 ** 2000-05-29
141385 **
141386 ** The author disclaims copyright to this source code. In place of
@@ -141453,10 +144786,12 @@
141453 ** UPDATE ON (a,b,c)
141454 **
141455 ** Then the "b" IdList records the list "a,b,c".
141456 */
141457 struct TrigEvent { int a; IdList * b; };
 
 
141458
141459 /*
141460 ** Disable lookaside memory allocation for objects that might be
141461 ** shared across database connections.
141462 */
@@ -141607,30 +144942,32 @@
141607 */
141608 #ifndef INTERFACE
141609 # define INTERFACE 1
141610 #endif
141611 /************* Begin control #defines *****************************************/
141612 #define YYCODETYPE unsigned char
141613 #define YYNOCODE 255
141614 #define YYACTIONTYPE unsigned short int
141615 #define YYWILDCARD 84
141616 #define sqlite3ParserTOKENTYPE Token
141617 typedef union {
141618 int yyinit;
141619 sqlite3ParserTOKENTYPE yy0;
141620 const char* yy36;
141621 TriggerStep* yy47;
141622 With* yy91;
141623 struct {int value; int mask;} yy107;
141624 Expr* yy182;
141625 Upsert* yy198;
141626 ExprList* yy232;
141627 struct TrigEvent yy300;
141628 Select* yy399;
141629 SrcList* yy427;
141630 int yy502;
141631 IdList* yy510;
 
 
141632 } YYMINORTYPE;
141633 #ifndef YYSTACKDEPTH
141634 #define YYSTACKDEPTH 100
141635 #endif
141636 #define sqlite3ParserARG_SDECL
@@ -141642,22 +144979,23 @@
141642 #define sqlite3ParserCTX_PDECL ,Parse *pParse
141643 #define sqlite3ParserCTX_PARAM ,pParse
141644 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
141645 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
141646 #define YYFALLBACK 1
141647 #define YYNSTATE 490
141648 #define YYNRULE 341
141649 #define YYNTOKEN 145
141650 #define YY_MAX_SHIFT 489
141651 #define YY_MIN_SHIFTREDUCE 705
141652 #define YY_MAX_SHIFTREDUCE 1045
141653 #define YY_ERROR_ACTION 1046
141654 #define YY_ACCEPT_ACTION 1047
141655 #define YY_NO_ACTION 1048
141656 #define YY_MIN_REDUCE 1049
141657 #define YY_MAX_REDUCE 1389
141658 /************* End control #defines *******************************************/
 
141659
141660 /* Define the yytestcase() macro to be a no-op if is not already defined
141661 ** otherwise.
141662 **
141663 ** Applications can choose to define yytestcase() in the %include section
@@ -141718,507 +145056,570 @@
141718 ** yy_reduce_ofst[] For each state, the offset into yy_action for
141719 ** shifting non-terminals after a reduce.
141720 ** yy_default[] Default action for each state.
141721 **
141722 *********** Begin parsing tables **********************************************/
141723 #define YY_ACTTAB_COUNT (1657)
141724 static const YYACTIONTYPE yy_action[] = {
141725 /* 0 */ 349, 99, 96, 185, 99, 96, 185, 233, 1047, 1,
141726 /* 10 */ 1, 489, 2, 1051, 484, 477, 477, 477, 260, 351,
141727 /* 20 */ 121, 1310, 1120, 1120, 1178, 1115, 1094, 1128, 380, 380,
141728 /* 30 */ 380, 835, 454, 410, 1115, 59, 59, 1357, 425, 836,
141729 /* 40 */ 710, 711, 712, 106, 107, 97, 1023, 1023, 900, 903,
141730 /* 50 */ 892, 892, 104, 104, 105, 105, 105, 105, 346, 238,
141731 /* 60 */ 238, 99, 96, 185, 238, 238, 889, 889, 901, 904,
141732 /* 70 */ 460, 481, 351, 99, 96, 185, 481, 347, 1177, 82,
141733 /* 80 */ 388, 214, 182, 23, 194, 103, 103, 103, 103, 102,
141734 /* 90 */ 102, 101, 101, 101, 100, 381, 106, 107, 97, 1023,
141735 /* 100 */ 1023, 900, 903, 892, 892, 104, 104, 105, 105, 105,
141736 /* 110 */ 105, 10, 385, 484, 24, 484, 1333, 489, 2, 1051,
141737 /* 120 */ 335, 1043, 108, 893, 260, 351, 121, 99, 96, 185,
141738 /* 130 */ 100, 381, 386, 1128, 59, 59, 59, 59, 103, 103,
141739 /* 140 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 106,
141740 /* 150 */ 107, 97, 1023, 1023, 900, 903, 892, 892, 104, 104,
141741 /* 160 */ 105, 105, 105, 105, 360, 238, 238, 170, 170, 467,
141742 /* 170 */ 455, 467, 464, 67, 381, 329, 169, 481, 351, 343,
141743 /* 180 */ 338, 400, 1044, 68, 101, 101, 101, 100, 381, 393,
141744 /* 190 */ 194, 103, 103, 103, 103, 102, 102, 101, 101, 101,
141745 /* 200 */ 100, 381, 106, 107, 97, 1023, 1023, 900, 903, 892,
141746 /* 210 */ 892, 104, 104, 105, 105, 105, 105, 483, 385, 103,
141747 /* 220 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381,
141748 /* 230 */ 268, 351, 946, 946, 422, 296, 102, 102, 101, 101,
141749 /* 240 */ 101, 100, 381, 861, 103, 103, 103, 103, 102, 102,
141750 /* 250 */ 101, 101, 101, 100, 381, 106, 107, 97, 1023, 1023,
141751 /* 260 */ 900, 903, 892, 892, 104, 104, 105, 105, 105, 105,
141752 /* 270 */ 484, 983, 1383, 206, 1353, 1383, 438, 435, 434, 281,
141753 /* 280 */ 396, 269, 1089, 941, 351, 1002, 433, 861, 743, 401,
141754 /* 290 */ 282, 57, 57, 482, 145, 791, 791, 103, 103, 103,
141755 /* 300 */ 103, 102, 102, 101, 101, 101, 100, 381, 106, 107,
141756 /* 310 */ 97, 1023, 1023, 900, 903, 892, 892, 104, 104, 105,
141757 /* 320 */ 105, 105, 105, 281, 1002, 1003, 1004, 206, 879, 319,
141758 /* 330 */ 438, 435, 434, 981, 259, 474, 360, 351, 1118, 1118,
141759 /* 340 */ 433, 736, 379, 378, 872, 1002, 1356, 322, 871, 766,
141760 /* 350 */ 103, 103, 103, 103, 102, 102, 101, 101, 101, 100,
141761 /* 360 */ 381, 106, 107, 97, 1023, 1023, 900, 903, 892, 892,
141762 /* 370 */ 104, 104, 105, 105, 105, 105, 484, 801, 484, 871,
141763 /* 380 */ 871, 873, 401, 282, 1002, 1003, 1004, 1030, 360, 1030,
141764 /* 390 */ 351, 983, 1384, 213, 880, 1384, 145, 59, 59, 59,
141765 /* 400 */ 59, 1002, 244, 103, 103, 103, 103, 102, 102, 101,
141766 /* 410 */ 101, 101, 100, 381, 106, 107, 97, 1023, 1023, 900,
141767 /* 420 */ 903, 892, 892, 104, 104, 105, 105, 105, 105, 274,
141768 /* 430 */ 484, 110, 467, 479, 467, 444, 259, 474, 232, 232,
141769 /* 440 */ 1002, 1003, 1004, 351, 210, 335, 982, 866, 1385, 336,
141770 /* 450 */ 481, 59, 59, 981, 245, 307, 103, 103, 103, 103,
141771 /* 460 */ 102, 102, 101, 101, 101, 100, 381, 106, 107, 97,
141772 /* 470 */ 1023, 1023, 900, 903, 892, 892, 104, 104, 105, 105,
141773 /* 480 */ 105, 105, 453, 459, 484, 408, 377, 259, 474, 271,
141774 /* 490 */ 183, 273, 209, 208, 207, 356, 351, 307, 178, 177,
141775 /* 500 */ 127, 1006, 1098, 14, 14, 43, 43, 1044, 425, 103,
141776 /* 510 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381,
141777 /* 520 */ 106, 107, 97, 1023, 1023, 900, 903, 892, 892, 104,
141778 /* 530 */ 104, 105, 105, 105, 105, 294, 1132, 408, 160, 484,
141779 /* 540 */ 408, 1006, 129, 962, 1209, 239, 239, 481, 307, 425,
141780 /* 550 */ 1309, 1097, 351, 235, 243, 272, 820, 481, 963, 425,
141781 /* 560 */ 11, 11, 103, 103, 103, 103, 102, 102, 101, 101,
141782 /* 570 */ 101, 100, 381, 964, 362, 1002, 106, 107, 97, 1023,
141783 /* 580 */ 1023, 900, 903, 892, 892, 104, 104, 105, 105, 105,
141784 /* 590 */ 105, 1275, 161, 126, 777, 289, 1209, 292, 1072, 357,
141785 /* 600 */ 1209, 1127, 476, 357, 778, 425, 247, 425, 351, 248,
141786 /* 610 */ 414, 364, 414, 171, 1002, 1003, 1004, 84, 103, 103,
141787 /* 620 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 1002,
141788 /* 630 */ 184, 484, 106, 107, 97, 1023, 1023, 900, 903, 892,
141789 /* 640 */ 892, 104, 104, 105, 105, 105, 105, 1123, 1209, 287,
141790 /* 650 */ 484, 1209, 11, 11, 179, 820, 259, 474, 307, 237,
141791 /* 660 */ 182, 351, 321, 365, 414, 308, 367, 366, 1002, 1003,
141792 /* 670 */ 1004, 44, 44, 87, 103, 103, 103, 103, 102, 102,
141793 /* 680 */ 101, 101, 101, 100, 381, 106, 107, 97, 1023, 1023,
141794 /* 690 */ 900, 903, 892, 892, 104, 104, 105, 105, 105, 105,
141795 /* 700 */ 246, 368, 280, 128, 10, 358, 146, 796, 835, 258,
141796 /* 710 */ 1020, 88, 795, 86, 351, 421, 836, 943, 376, 348,
141797 /* 720 */ 191, 943, 1318, 267, 308, 279, 456, 103, 103, 103,
141798 /* 730 */ 103, 102, 102, 101, 101, 101, 100, 381, 106, 95,
141799 /* 740 */ 97, 1023, 1023, 900, 903, 892, 892, 104, 104, 105,
141800 /* 750 */ 105, 105, 105, 420, 249, 238, 238, 238, 238, 79,
141801 /* 760 */ 375, 125, 305, 29, 262, 978, 351, 481, 337, 481,
141802 /* 770 */ 756, 755, 304, 278, 415, 15, 81, 940, 1126, 940,
141803 /* 780 */ 103, 103, 103, 103, 102, 102, 101, 101, 101, 100,
141804 /* 790 */ 381, 107, 97, 1023, 1023, 900, 903, 892, 892, 104,
141805 /* 800 */ 104, 105, 105, 105, 105, 457, 263, 484, 174, 484,
141806 /* 810 */ 238, 238, 863, 407, 402, 216, 216, 351, 409, 193,
141807 /* 820 */ 283, 216, 481, 81, 763, 764, 266, 5, 13, 13,
141808 /* 830 */ 34, 34, 103, 103, 103, 103, 102, 102, 101, 101,
141809 /* 840 */ 101, 100, 381, 97, 1023, 1023, 900, 903, 892, 892,
141810 /* 850 */ 104, 104, 105, 105, 105, 105, 93, 475, 1002, 4,
141811 /* 860 */ 403, 1002, 340, 431, 1002, 297, 212, 1277, 81, 746,
141812 /* 870 */ 1163, 152, 926, 478, 166, 212, 757, 829, 930, 939,
141813 /* 880 */ 216, 939, 858, 103, 103, 103, 103, 102, 102, 101,
141814 /* 890 */ 101, 101, 100, 381, 238, 238, 382, 1002, 1003, 1004,
141815 /* 900 */ 1002, 1003, 1004, 1002, 1003, 1004, 481, 439, 472, 746,
141816 /* 910 */ 105, 105, 105, 105, 98, 758, 1162, 145, 930, 412,
141817 /* 920 */ 879, 406, 793, 81, 395, 89, 90, 91, 105, 105,
141818 /* 930 */ 105, 105, 1323, 92, 484, 382, 486, 485, 240, 275,
141819 /* 940 */ 871, 103, 103, 103, 103, 102, 102, 101, 101, 101,
141820 /* 950 */ 100, 381, 1096, 371, 355, 45, 45, 259, 474, 103,
141821 /* 960 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381,
141822 /* 970 */ 1150, 871, 871, 873, 874, 21, 1332, 991, 384, 730,
141823 /* 980 */ 722, 242, 123, 1298, 124, 875, 333, 333, 332, 227,
141824 /* 990 */ 330, 991, 384, 719, 256, 242, 484, 391, 413, 1297,
141825 /* 1000 */ 333, 333, 332, 227, 330, 748, 187, 719, 265, 470,
141826 /* 1010 */ 1279, 1002, 484, 417, 391, 390, 264, 11, 11, 284,
141827 /* 1020 */ 187, 732, 265, 93, 475, 875, 4, 1279, 1281, 419,
141828 /* 1030 */ 264, 369, 416, 11, 11, 1159, 288, 484, 399, 1346,
141829 /* 1040 */ 478, 379, 378, 291, 484, 293, 189, 250, 295, 1027,
141830 /* 1050 */ 1002, 1003, 1004, 190, 1029, 1111, 140, 188, 11, 11,
141831 /* 1060 */ 189, 732, 1028, 382, 923, 46, 46, 190, 1095, 230,
141832 /* 1070 */ 140, 188, 462, 93, 475, 472, 4, 300, 309, 391,
141833 /* 1080 */ 373, 6, 1069, 217, 739, 310, 1030, 879, 1030, 1171,
141834 /* 1090 */ 478, 352, 1279, 90, 91, 800, 259, 474, 1208, 484,
141835 /* 1100 */ 92, 1268, 382, 486, 485, 352, 1002, 871, 879, 426,
141836 /* 1110 */ 259, 474, 172, 382, 238, 238, 1146, 170, 1021, 389,
141837 /* 1120 */ 47, 47, 1157, 739, 872, 472, 481, 469, 871, 350,
141838 /* 1130 */ 1214, 83, 475, 389, 4, 1078, 1071, 879, 871, 871,
141839 /* 1140 */ 873, 874, 21, 90, 91, 1002, 1003, 1004, 478, 251,
141840 /* 1150 */ 92, 251, 382, 486, 485, 443, 370, 871, 1021, 871,
141841 /* 1160 */ 871, 873, 224, 241, 306, 441, 301, 440, 211, 1060,
141842 /* 1170 */ 820, 382, 822, 447, 299, 1059, 484, 1061, 1143, 962,
141843 /* 1180 */ 430, 796, 484, 472, 1340, 312, 795, 465, 871, 871,
141844 /* 1190 */ 873, 874, 21, 314, 963, 879, 316, 59, 59, 1002,
141845 /* 1200 */ 9, 90, 91, 48, 48, 238, 238, 210, 92, 964,
141846 /* 1210 */ 382, 486, 485, 176, 334, 871, 242, 481, 1193, 238,
141847 /* 1220 */ 238, 333, 333, 332, 227, 330, 394, 270, 719, 277,
141848 /* 1230 */ 471, 481, 467, 466, 484, 145, 217, 1201, 1002, 1003,
141849 /* 1240 */ 1004, 187, 3, 265, 184, 445, 871, 871, 873, 874,
141850 /* 1250 */ 21, 264, 1337, 450, 1051, 39, 39, 392, 356, 260,
141851 /* 1260 */ 342, 121, 468, 411, 436, 821, 180, 1094, 1128, 820,
141852 /* 1270 */ 303, 1021, 1272, 1271, 299, 259, 474, 238, 238, 1002,
141853 /* 1280 */ 473, 189, 484, 318, 327, 238, 238, 484, 190, 481,
141854 /* 1290 */ 446, 140, 188, 1343, 238, 238, 1038, 481, 148, 175,
141855 /* 1300 */ 238, 238, 484, 49, 49, 219, 481, 484, 35, 35,
141856 /* 1310 */ 1317, 1021, 481, 484, 1035, 484, 1315, 484, 1002, 1003,
141857 /* 1320 */ 1004, 484, 66, 36, 36, 194, 352, 484, 38, 38,
141858 /* 1330 */ 484, 259, 474, 69, 50, 50, 51, 51, 52, 52,
141859 /* 1340 */ 359, 484, 12, 12, 484, 1198, 484, 158, 53, 53,
141860 /* 1350 */ 405, 112, 112, 385, 389, 484, 26, 484, 143, 484,
141861 /* 1360 */ 150, 484, 54, 54, 397, 40, 40, 55, 55, 484,
141862 /* 1370 */ 79, 484, 153, 1190, 484, 154, 56, 56, 41, 41,
141863 /* 1380 */ 58, 58, 133, 133, 484, 398, 484, 429, 484, 155,
141864 /* 1390 */ 134, 134, 135, 135, 484, 63, 63, 484, 341, 484,
141865 /* 1400 */ 339, 484, 196, 484, 156, 42, 42, 113, 113, 60,
141866 /* 1410 */ 60, 484, 404, 484, 27, 114, 114, 1204, 115, 115,
141867 /* 1420 */ 111, 111, 132, 132, 131, 131, 1266, 418, 484, 162,
141868 /* 1430 */ 484, 200, 119, 119, 118, 118, 484, 74, 424, 484,
141869 /* 1440 */ 1286, 484, 231, 484, 202, 484, 167, 286, 427, 116,
141870 /* 1450 */ 116, 117, 117, 290, 203, 442, 1062, 62, 62, 204,
141871 /* 1460 */ 64, 64, 61, 61, 33, 33, 37, 37, 344, 372,
141872 /* 1470 */ 1114, 1105, 748, 1113, 374, 1112, 254, 458, 1086, 255,
141873 /* 1480 */ 345, 1085, 302, 1084, 1355, 78, 1154, 311, 1104, 449,
141874 /* 1490 */ 452, 1155, 1153, 218, 7, 313, 315, 320, 1152, 85,
141875 /* 1500 */ 1252, 317, 109, 80, 463, 225, 461, 1068, 25, 487,
141876 /* 1510 */ 997, 323, 257, 226, 229, 228, 1136, 324, 325, 326,
141877 /* 1520 */ 488, 136, 1057, 1052, 1302, 1303, 1301, 706, 1300, 137,
141878 /* 1530 */ 122, 138, 383, 173, 1082, 261, 186, 252, 1081, 65,
141879 /* 1540 */ 387, 120, 938, 936, 855, 353, 149, 1079, 139, 151,
141880 /* 1550 */ 192, 780, 195, 276, 952, 157, 141, 361, 70, 363,
141881 /* 1560 */ 859, 159, 71, 72, 142, 73, 955, 354, 147, 197,
141882 /* 1570 */ 198, 951, 130, 16, 199, 285, 216, 1032, 201, 423,
141883 /* 1580 */ 164, 944, 163, 28, 721, 428, 304, 165, 205, 759,
141884 /* 1590 */ 75, 432, 298, 17, 18, 437, 76, 253, 878, 144,
141885 /* 1600 */ 877, 906, 77, 986, 30, 448, 987, 31, 451, 181,
141886 /* 1610 */ 234, 236, 168, 828, 823, 89, 910, 921, 81, 907,
141887 /* 1620 */ 215, 905, 909, 961, 960, 19, 221, 20, 220, 22,
141888 /* 1630 */ 32, 331, 876, 731, 94, 790, 794, 8, 992, 222,
141889 /* 1640 */ 480, 328, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
141890 /* 1650 */ 223, 1048, 1048, 1048, 1048, 1348, 1347,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141891 };
141892 static const YYCODETYPE yy_lookahead[] = {
141893 /* 0 */ 174, 226, 227, 228, 226, 227, 228, 172, 145, 146,
141894 /* 10 */ 147, 148, 149, 150, 153, 169, 170, 171, 155, 19,
141895 /* 20 */ 157, 246, 192, 193, 177, 181, 182, 164, 169, 170,
141896 /* 30 */ 171, 31, 164, 153, 190, 174, 175, 187, 153, 39,
141897 /* 40 */ 7, 8, 9, 43, 44, 45, 46, 47, 48, 49,
141898 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 174, 196,
141899 /* 60 */ 197, 226, 227, 228, 196, 197, 46, 47, 48, 49,
141900 /* 70 */ 209, 208, 19, 226, 227, 228, 208, 174, 177, 26,
141901 /* 80 */ 195, 213, 214, 22, 221, 85, 86, 87, 88, 89,
141902 /* 90 */ 90, 91, 92, 93, 94, 95, 43, 44, 45, 46,
141903 /* 100 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
141904 /* 110 */ 57, 172, 249, 153, 53, 153, 147, 148, 149, 150,
141905 /* 120 */ 22, 23, 69, 103, 155, 19, 157, 226, 227, 228,
141906 /* 130 */ 94, 95, 247, 164, 174, 175, 174, 175, 85, 86,
141907 /* 140 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 43,
141908 /* 150 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
141909 /* 160 */ 54, 55, 56, 57, 153, 196, 197, 153, 153, 209,
141910 /* 170 */ 210, 209, 210, 67, 95, 161, 237, 208, 19, 165,
141911 /* 180 */ 165, 242, 84, 24, 91, 92, 93, 94, 95, 223,
141912 /* 190 */ 221, 85, 86, 87, 88, 89, 90, 91, 92, 93,
141913 /* 200 */ 94, 95, 43, 44, 45, 46, 47, 48, 49, 50,
141914 /* 210 */ 51, 52, 53, 54, 55, 56, 57, 153, 249, 85,
141915 /* 220 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
141916 /* 230 */ 219, 19, 109, 110, 111, 23, 89, 90, 91, 92,
141917 /* 240 */ 93, 94, 95, 73, 85, 86, 87, 88, 89, 90,
141918 /* 250 */ 91, 92, 93, 94, 95, 43, 44, 45, 46, 47,
141919 /* 260 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
141920 /* 270 */ 153, 22, 23, 101, 173, 26, 104, 105, 106, 109,
141921 /* 280 */ 110, 111, 181, 11, 19, 59, 114, 73, 23, 110,
141922 /* 290 */ 111, 174, 175, 116, 80, 118, 119, 85, 86, 87,
141923 /* 300 */ 88, 89, 90, 91, 92, 93, 94, 95, 43, 44,
141924 /* 310 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
141925 /* 320 */ 55, 56, 57, 109, 98, 99, 100, 101, 83, 153,
141926 /* 330 */ 104, 105, 106, 84, 120, 121, 153, 19, 192, 193,
141927 /* 340 */ 114, 23, 89, 90, 99, 59, 23, 230, 103, 26,
141928 /* 350 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
141929 /* 360 */ 95, 43, 44, 45, 46, 47, 48, 49, 50, 51,
141930 /* 370 */ 52, 53, 54, 55, 56, 57, 153, 91, 153, 134,
141931 /* 380 */ 135, 136, 110, 111, 98, 99, 100, 134, 153, 136,
141932 /* 390 */ 19, 22, 23, 26, 23, 26, 80, 174, 175, 174,
141933 /* 400 */ 175, 59, 219, 85, 86, 87, 88, 89, 90, 91,
141934 /* 410 */ 92, 93, 94, 95, 43, 44, 45, 46, 47, 48,
141935 /* 420 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 16,
141936 /* 430 */ 153, 22, 209, 210, 209, 210, 120, 121, 196, 197,
141937 /* 440 */ 98, 99, 100, 19, 46, 22, 23, 23, 252, 253,
141938 /* 450 */ 208, 174, 175, 84, 219, 153, 85, 86, 87, 88,
141939 /* 460 */ 89, 90, 91, 92, 93, 94, 95, 43, 44, 45,
141940 /* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
141941 /* 480 */ 56, 57, 153, 153, 153, 153, 209, 120, 121, 76,
141942 /* 490 */ 153, 78, 109, 110, 111, 97, 19, 153, 89, 90,
141943 /* 500 */ 198, 59, 183, 174, 175, 174, 175, 84, 153, 85,
141944 /* 510 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
141945 /* 520 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
141946 /* 530 */ 53, 54, 55, 56, 57, 16, 197, 153, 22, 153,
141947 /* 540 */ 153, 99, 198, 12, 153, 196, 197, 208, 153, 153,
141948 /* 550 */ 195, 183, 19, 23, 222, 142, 26, 208, 27, 153,
141949 /* 560 */ 174, 175, 85, 86, 87, 88, 89, 90, 91, 92,
141950 /* 570 */ 93, 94, 95, 42, 188, 59, 43, 44, 45, 46,
141951 /* 580 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
141952 /* 590 */ 57, 195, 22, 198, 63, 76, 153, 78, 167, 168,
141953 /* 600 */ 153, 195, 167, 168, 73, 153, 222, 153, 19, 222,
141954 /* 610 */ 153, 220, 153, 24, 98, 99, 100, 140, 85, 86,
141955 /* 620 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 59,
141956 /* 630 */ 100, 153, 43, 44, 45, 46, 47, 48, 49, 50,
141957 /* 640 */ 51, 52, 53, 54, 55, 56, 57, 195, 153, 195,
141958 /* 650 */ 153, 153, 174, 175, 26, 125, 120, 121, 153, 213,
141959 /* 660 */ 214, 19, 153, 220, 153, 153, 188, 220, 98, 99,
141960 /* 670 */ 100, 174, 175, 140, 85, 86, 87, 88, 89, 90,
141961 /* 680 */ 91, 92, 93, 94, 95, 43, 44, 45, 46, 47,
141962 /* 690 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
141963 /* 700 */ 243, 189, 243, 198, 172, 250, 251, 117, 31, 201,
141964 /* 710 */ 26, 139, 122, 141, 19, 220, 39, 29, 220, 211,
141965 /* 720 */ 24, 33, 153, 164, 153, 164, 19, 85, 86, 87,
141966 /* 730 */ 88, 89, 90, 91, 92, 93, 94, 95, 43, 44,
141967 /* 740 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
141968 /* 750 */ 55, 56, 57, 65, 243, 196, 197, 196, 197, 131,
141969 /* 760 */ 189, 22, 103, 24, 153, 23, 19, 208, 26, 208,
141970 /* 770 */ 102, 103, 113, 23, 242, 22, 26, 134, 164, 136,
141971 /* 780 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
141972 /* 790 */ 95, 44, 45, 46, 47, 48, 49, 50, 51, 52,
141973 /* 800 */ 53, 54, 55, 56, 57, 98, 153, 153, 124, 153,
141974 /* 810 */ 196, 197, 23, 23, 61, 26, 26, 19, 23, 123,
141975 /* 820 */ 23, 26, 208, 26, 7, 8, 153, 22, 174, 175,
141976 /* 830 */ 174, 175, 85, 86, 87, 88, 89, 90, 91, 92,
141977 /* 840 */ 93, 94, 95, 45, 46, 47, 48, 49, 50, 51,
141978 /* 850 */ 52, 53, 54, 55, 56, 57, 19, 20, 59, 22,
141979 /* 860 */ 111, 59, 164, 23, 59, 23, 26, 153, 26, 59,
141980 /* 870 */ 153, 72, 23, 36, 72, 26, 35, 23, 59, 134,
141981 /* 880 */ 26, 136, 133, 85, 86, 87, 88, 89, 90, 91,
141982 /* 890 */ 92, 93, 94, 95, 196, 197, 59, 98, 99, 100,
141983 /* 900 */ 98, 99, 100, 98, 99, 100, 208, 66, 71, 99,
141984 /* 910 */ 54, 55, 56, 57, 58, 74, 153, 80, 99, 19,
141985 /* 920 */ 83, 223, 23, 26, 153, 26, 89, 90, 54, 55,
141986 /* 930 */ 56, 57, 153, 96, 153, 98, 99, 100, 22, 153,
141987 /* 940 */ 103, 85, 86, 87, 88, 89, 90, 91, 92, 93,
141988 /* 950 */ 94, 95, 183, 112, 158, 174, 175, 120, 121, 85,
141989 /* 960 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
141990 /* 970 */ 215, 134, 135, 136, 137, 138, 0, 1, 2, 23,
141991 /* 980 */ 21, 5, 26, 153, 22, 59, 10, 11, 12, 13,
141992 /* 990 */ 14, 1, 2, 17, 212, 5, 153, 153, 98, 153,
141993 /* 1000 */ 10, 11, 12, 13, 14, 108, 30, 17, 32, 193,
141994 /* 1010 */ 153, 59, 153, 153, 170, 171, 40, 174, 175, 153,
141995 /* 1020 */ 30, 59, 32, 19, 20, 99, 22, 170, 171, 233,
141996 /* 1030 */ 40, 188, 236, 174, 175, 153, 153, 153, 79, 123,
141997 /* 1040 */ 36, 89, 90, 153, 153, 153, 70, 188, 153, 97,
141998 /* 1050 */ 98, 99, 100, 77, 102, 153, 80, 81, 174, 175,
141999 /* 1060 */ 70, 99, 110, 59, 105, 174, 175, 77, 153, 238,
142000 /* 1070 */ 80, 81, 188, 19, 20, 71, 22, 153, 153, 235,
142001 /* 1080 */ 19, 22, 164, 24, 59, 153, 134, 83, 136, 153,
142002 /* 1090 */ 36, 115, 235, 89, 90, 91, 120, 121, 153, 153,
142003 /* 1100 */ 96, 142, 98, 99, 100, 115, 59, 103, 83, 239,
142004 /* 1110 */ 120, 121, 199, 59, 196, 197, 153, 153, 59, 143,
142005 /* 1120 */ 174, 175, 153, 98, 99, 71, 208, 153, 103, 165,
142006 /* 1130 */ 153, 19, 20, 143, 22, 153, 153, 83, 134, 135,
142007 /* 1140 */ 136, 137, 138, 89, 90, 98, 99, 100, 36, 185,
142008 /* 1150 */ 96, 187, 98, 99, 100, 91, 95, 103, 99, 134,
142009 /* 1160 */ 135, 136, 101, 102, 103, 104, 105, 106, 107, 153,
142010 /* 1170 */ 26, 59, 125, 164, 113, 153, 153, 153, 212, 12,
142011 /* 1180 */ 19, 117, 153, 71, 153, 212, 122, 164, 134, 135,
142012 /* 1190 */ 136, 137, 138, 212, 27, 83, 212, 174, 175, 59,
142013 /* 1200 */ 200, 89, 90, 174, 175, 196, 197, 46, 96, 42,
142014 /* 1210 */ 98, 99, 100, 172, 151, 103, 5, 208, 203, 196,
142015 /* 1220 */ 197, 10, 11, 12, 13, 14, 216, 216, 17, 244,
142016 /* 1230 */ 63, 208, 209, 210, 153, 80, 24, 203, 98, 99,
142017 /* 1240 */ 100, 30, 22, 32, 100, 164, 134, 135, 136, 137,
142018 /* 1250 */ 138, 40, 148, 164, 150, 174, 175, 102, 97, 155,
142019 /* 1260 */ 203, 157, 164, 244, 178, 125, 186, 182, 164, 125,
142020 /* 1270 */ 177, 59, 177, 177, 113, 120, 121, 196, 197, 59,
142021 /* 1280 */ 232, 70, 153, 216, 202, 196, 197, 153, 77, 208,
142022 /* 1290 */ 209, 80, 81, 156, 196, 197, 60, 208, 248, 200,
142023 /* 1300 */ 196, 197, 153, 174, 175, 123, 208, 153, 174, 175,
142024 /* 1310 */ 160, 99, 208, 153, 38, 153, 160, 153, 98, 99,
142025 /* 1320 */ 100, 153, 245, 174, 175, 221, 115, 153, 174, 175,
142026 /* 1330 */ 153, 120, 121, 245, 174, 175, 174, 175, 174, 175,
142027 /* 1340 */ 160, 153, 174, 175, 153, 225, 153, 22, 174, 175,
142028 /* 1350 */ 97, 174, 175, 249, 143, 153, 224, 153, 43, 153,
142029 /* 1360 */ 191, 153, 174, 175, 18, 174, 175, 174, 175, 153,
142030 /* 1370 */ 131, 153, 194, 203, 153, 194, 174, 175, 174, 175,
142031 /* 1380 */ 174, 175, 174, 175, 153, 160, 153, 18, 153, 194,
142032 /* 1390 */ 174, 175, 174, 175, 153, 174, 175, 153, 225, 153,
142033 /* 1400 */ 203, 153, 159, 153, 194, 174, 175, 174, 175, 174,
142034 /* 1410 */ 175, 153, 203, 153, 224, 174, 175, 191, 174, 175,
142035 /* 1420 */ 174, 175, 174, 175, 174, 175, 203, 160, 153, 191,
142036 /* 1430 */ 153, 159, 174, 175, 174, 175, 153, 139, 62, 153,
142037 /* 1440 */ 241, 153, 160, 153, 159, 153, 22, 240, 179, 174,
142038 /* 1450 */ 175, 174, 175, 160, 159, 97, 160, 174, 175, 159,
142039 /* 1460 */ 174, 175, 174, 175, 174, 175, 174, 175, 179, 64,
142040 /* 1470 */ 176, 184, 108, 176, 95, 176, 234, 126, 176, 234,
142041 /* 1480 */ 179, 178, 176, 176, 176, 97, 218, 217, 184, 179,
142042 /* 1490 */ 179, 218, 218, 160, 22, 217, 217, 160, 218, 139,
142043 /* 1500 */ 229, 217, 130, 129, 127, 25, 128, 163, 26, 162,
142044 /* 1510 */ 13, 206, 231, 154, 6, 154, 207, 205, 204, 203,
142045 /* 1520 */ 152, 166, 152, 152, 172, 172, 172, 4, 172, 166,
142046 /* 1530 */ 180, 166, 3, 22, 172, 144, 15, 180, 172, 172,
142047 /* 1540 */ 82, 16, 23, 23, 121, 254, 132, 172, 112, 124,
142048 /* 1550 */ 24, 20, 126, 16, 1, 124, 112, 61, 53, 37,
142049 /* 1560 */ 133, 132, 53, 53, 112, 53, 98, 254, 251, 34,
142050 /* 1570 */ 123, 1, 5, 22, 97, 142, 26, 75, 123, 41,
142051 /* 1580 */ 97, 68, 68, 24, 20, 19, 113, 22, 107, 28,
142052 /* 1590 */ 22, 67, 23, 22, 22, 67, 22, 67, 23, 37,
142053 /* 1600 */ 23, 23, 26, 23, 22, 24, 23, 22, 24, 123,
142054 /* 1610 */ 23, 23, 22, 98, 125, 26, 11, 23, 26, 23,
142055 /* 1620 */ 34, 23, 23, 23, 23, 34, 22, 34, 26, 22,
142056 /* 1630 */ 22, 15, 23, 23, 22, 117, 23, 22, 1, 123,
142057 /* 1640 */ 26, 23, 255, 255, 255, 255, 255, 255, 255, 255,
142058 /* 1650 */ 123, 255, 255, 255, 255, 123, 123, 255, 255, 255,
142059 /* 1660 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142060 /* 1670 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142061 /* 1680 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142062 /* 1690 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142063 /* 1700 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142064 /* 1710 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142065 /* 1720 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142066 /* 1730 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142067 /* 1740 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142068 /* 1750 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142069 /* 1760 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142070 /* 1770 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142071 /* 1780 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142072 /* 1790 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
142073 /* 1800 */ 255, 255,
142074 };
142075 #define YY_SHIFT_COUNT (489)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142076 #define YY_SHIFT_MIN (0)
142077 #define YY_SHIFT_MAX (1637)
142078 static const unsigned short int yy_shift_ofst[] = {
142079 /* 0 */ 990, 976, 1211, 837, 837, 316, 1054, 1054, 1054, 1054,
142080 /* 10 */ 214, 0, 0, 106, 642, 1054, 1054, 1054, 1054, 1054,
142081 /* 20 */ 1054, 1054, 1054, 952, 952, 226, 1155, 316, 316, 316,
142082 /* 30 */ 316, 316, 316, 53, 159, 212, 265, 318, 371, 424,
142083 /* 40 */ 477, 533, 589, 642, 642, 642, 642, 642, 642, 642,
142084 /* 50 */ 642, 642, 642, 642, 642, 642, 642, 642, 642, 642,
142085 /* 60 */ 695, 642, 747, 798, 798, 1004, 1054, 1054, 1054, 1054,
142086 /* 70 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
142087 /* 80 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
142088 /* 90 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1112, 1054, 1054,
142089 /* 100 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
142090 /* 110 */ 1054, 856, 874, 874, 874, 874, 874, 134, 147, 93,
142091 /* 120 */ 342, 959, 1161, 253, 253, 342, 367, 367, 367, 367,
142092 /* 130 */ 179, 36, 79, 1657, 1657, 1657, 1061, 1061, 1061, 516,
142093 /* 140 */ 799, 516, 516, 531, 531, 802, 249, 369, 342, 342,
142094 /* 150 */ 342, 342, 342, 342, 342, 342, 342, 342, 342, 342,
142095 /* 160 */ 342, 342, 342, 342, 342, 342, 342, 342, 342, 272,
142096 /* 170 */ 442, 442, 536, 1657, 1657, 1657, 1025, 245, 245, 570,
142097 /* 180 */ 172, 286, 805, 1047, 1140, 1220, 342, 342, 342, 342,
142098 /* 190 */ 342, 342, 342, 342, 170, 342, 342, 342, 342, 342,
142099 /* 200 */ 342, 342, 342, 342, 342, 342, 342, 841, 841, 841,
142100 /* 210 */ 342, 342, 342, 342, 530, 342, 342, 342, 1059, 342,
142101 /* 220 */ 342, 1167, 342, 342, 342, 342, 342, 342, 342, 342,
142102 /* 230 */ 123, 688, 177, 1212, 1212, 1212, 1212, 1144, 177, 177,
142103 /* 240 */ 1064, 409, 33, 628, 707, 707, 900, 628, 628, 900,
142104 /* 250 */ 897, 323, 398, 677, 677, 677, 707, 572, 684, 590,
142105 /* 260 */ 739, 1236, 1182, 1182, 1276, 1276, 1182, 1253, 1325, 1315,
142106 /* 270 */ 1239, 1346, 1346, 1346, 1346, 1182, 1369, 1239, 1239, 1253,
142107 /* 280 */ 1325, 1315, 1315, 1239, 1182, 1369, 1298, 1376, 1182, 1369,
142108 /* 290 */ 1424, 1182, 1369, 1182, 1369, 1424, 1358, 1358, 1358, 1405,
142109 /* 300 */ 1424, 1358, 1364, 1358, 1405, 1358, 1358, 1424, 1379, 1379,
142110 /* 310 */ 1424, 1351, 1388, 1351, 1388, 1351, 1388, 1351, 1388, 1182,
142111 /* 320 */ 1472, 1182, 1360, 1372, 1377, 1374, 1378, 1239, 1480, 1482,
142112 /* 330 */ 1497, 1497, 1508, 1508, 1508, 1657, 1657, 1657, 1657, 1657,
142113 /* 340 */ 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657,
142114 /* 350 */ 1657, 20, 413, 98, 423, 519, 383, 962, 742, 61,
142115 /* 360 */ 696, 749, 750, 753, 789, 790, 795, 797, 840, 842,
142116 /* 370 */ 810, 668, 817, 659, 819, 849, 854, 899, 643, 745,
142117 /* 380 */ 956, 926, 916, 1523, 1529, 1511, 1391, 1521, 1458, 1525,
142118 /* 390 */ 1519, 1520, 1423, 1414, 1436, 1526, 1425, 1531, 1426, 1537,
142119 /* 400 */ 1553, 1431, 1427, 1444, 1496, 1522, 1429, 1505, 1509, 1510,
142120 /* 410 */ 1512, 1452, 1468, 1535, 1447, 1570, 1567, 1551, 1477, 1433,
142121 /* 420 */ 1513, 1550, 1514, 1502, 1538, 1455, 1483, 1559, 1564, 1566,
142122 /* 430 */ 1473, 1481, 1565, 1524, 1568, 1571, 1569, 1572, 1528, 1561,
142123 /* 440 */ 1574, 1530, 1562, 1575, 1577, 1578, 1576, 1580, 1582, 1581,
142124 /* 450 */ 1583, 1585, 1584, 1486, 1587, 1588, 1515, 1586, 1590, 1489,
142125 /* 460 */ 1589, 1591, 1592, 1593, 1594, 1596, 1598, 1589, 1599, 1600,
142126 /* 470 */ 1602, 1601, 1604, 1605, 1607, 1608, 1609, 1610, 1612, 1613,
142127 /* 480 */ 1615, 1614, 1518, 1516, 1527, 1532, 1533, 1618, 1616, 1637,
142128 };
142129 #define YY_REDUCE_COUNT (350)
142130 #define YY_REDUCE_MIN (-225)
142131 #define YY_REDUCE_MAX (1375)
 
 
 
142132 static const short yy_reduce_ofst[] = {
142133 /* 0 */ -137, -31, 1104, 1023, 1081, -132, -40, -38, 223, 225,
142134 /* 10 */ 698, -153, -99, -225, -165, 386, 478, 843, 859, -139,
142135 /* 20 */ 884, 117, 277, 844, 857, 964, 559, 561, 614, 918,
142136 /* 30 */ 1009, 1089, 1098, -222, -222, -222, -222, -222, -222, -222,
142137 /* 40 */ -222, -222, -222, -222, -222, -222, -222, -222, -222, -222,
142138 /* 50 */ -222, -222, -222, -222, -222, -222, -222, -222, -222, -222,
142139 /* 60 */ -222, -222, -222, -222, -222, 329, 331, 497, 654, 656,
142140 /* 70 */ 781, 891, 946, 1029, 1129, 1134, 1149, 1154, 1160, 1162,
142141 /* 80 */ 1164, 1168, 1174, 1177, 1188, 1191, 1193, 1202, 1204, 1206,
142142 /* 90 */ 1208, 1216, 1218, 1221, 1231, 1233, 1235, 1241, 1244, 1246,
142143 /* 100 */ 1248, 1250, 1258, 1260, 1275, 1277, 1283, 1286, 1288, 1290,
142144 /* 110 */ 1292, -222, -222, -222, -222, -222, -222, -222, -222, -222,
142145 /* 120 */ -115, 796, -156, -154, -141, 14, 242, 349, 242, 349,
142146 /* 130 */ -61, -222, -222, -222, -222, -222, 101, 101, 101, 332,
142147 /* 140 */ 302, 384, 387, -170, 146, 344, 196, 196, 15, 11,
142148 /* 150 */ 183, 235, 395, 355, 396, 406, 452, 457, 391, 459,
142149 /* 160 */ 443, 447, 511, 495, 454, 512, 505, 571, 498, 532,
142150 /* 170 */ 431, 435, 339, 455, 446, 508, -174, -116, -97, -120,
142151 /* 180 */ -150, 64, 176, 330, 337, 509, 569, 611, 653, 673,
142152 /* 190 */ 714, 717, 763, 771, -34, 779, 786, 830, 846, 860,
142153 /* 200 */ 866, 882, 883, 890, 892, 895, 902, 319, 368, 769,
142154 /* 210 */ 915, 924, 925, 932, 755, 936, 945, 963, 782, 969,
142155 /* 220 */ 974, 816, 977, 64, 982, 983, 1016, 1022, 1024, 1031,
142156 /* 230 */ 870, 831, 913, 966, 973, 981, 984, 755, 913, 913,
142157 /* 240 */ 1000, 1041, 1063, 1015, 1010, 1011, 985, 1034, 1057, 1019,
142158 /* 250 */ 1086, 1080, 1085, 1093, 1095, 1096, 1067, 1048, 1082, 1099,
142159 /* 260 */ 1137, 1050, 1150, 1156, 1077, 1088, 1180, 1120, 1132, 1169,
142160 /* 270 */ 1170, 1178, 1181, 1195, 1210, 1225, 1243, 1197, 1209, 1173,
142161 /* 280 */ 1190, 1226, 1238, 1223, 1267, 1272, 1199, 1207, 1282, 1285,
142162 /* 290 */ 1269, 1293, 1295, 1296, 1300, 1289, 1294, 1297, 1299, 1287,
142163 /* 300 */ 1301, 1302, 1303, 1306, 1304, 1307, 1308, 1310, 1242, 1245,
142164 /* 310 */ 1311, 1268, 1270, 1273, 1278, 1274, 1279, 1280, 1284, 1333,
142165 /* 320 */ 1271, 1337, 1281, 1309, 1305, 1312, 1314, 1316, 1344, 1347,
142166 /* 330 */ 1359, 1361, 1368, 1370, 1371, 1291, 1313, 1317, 1355, 1352,
142167 /* 340 */ 1353, 1354, 1356, 1363, 1350, 1357, 1362, 1366, 1367, 1375,
142168 /* 350 */ 1365,
 
142169 };
142170 static const YYACTIONTYPE yy_default[] = {
142171 /* 0 */ 1389, 1389, 1389, 1261, 1046, 1151, 1261, 1261, 1261, 1261,
142172 /* 10 */ 1046, 1181, 1181, 1312, 1077, 1046, 1046, 1046, 1046, 1046,
142173 /* 20 */ 1046, 1260, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142174 /* 30 */ 1046, 1046, 1046, 1187, 1046, 1046, 1046, 1046, 1262, 1263,
142175 /* 40 */ 1046, 1046, 1046, 1311, 1313, 1197, 1196, 1195, 1194, 1294,
142176 /* 50 */ 1168, 1192, 1185, 1189, 1256, 1257, 1255, 1259, 1262, 1263,
142177 /* 60 */ 1046, 1188, 1226, 1240, 1225, 1046, 1046, 1046, 1046, 1046,
142178 /* 70 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142179 /* 80 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142180 /* 90 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142181 /* 100 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142182 /* 110 */ 1046, 1234, 1239, 1246, 1238, 1235, 1228, 1227, 1229, 1230,
142183 /* 120 */ 1046, 1067, 1116, 1046, 1046, 1046, 1329, 1328, 1046, 1046,
142184 /* 130 */ 1077, 1231, 1232, 1243, 1242, 1241, 1319, 1345, 1344, 1046,
142185 /* 140 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142186 /* 150 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142187 /* 160 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1077,
142188 /* 170 */ 1073, 1073, 1046, 1324, 1151, 1142, 1046, 1046, 1046, 1046,
142189 /* 180 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1316, 1314, 1046,
142190 /* 190 */ 1276, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142191 /* 200 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142192 /* 210 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1147, 1046,
142193 /* 220 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1339,
142194 /* 230 */ 1046, 1289, 1130, 1147, 1147, 1147, 1147, 1149, 1131, 1129,
142195 /* 240 */ 1141, 1077, 1053, 1191, 1170, 1170, 1378, 1191, 1191, 1378,
142196 /* 250 */ 1091, 1359, 1088, 1181, 1181, 1181, 1170, 1258, 1148, 1141,
142197 /* 260 */ 1046, 1381, 1156, 1156, 1380, 1380, 1156, 1200, 1206, 1119,
142198 /* 270 */ 1191, 1125, 1125, 1125, 1125, 1156, 1064, 1191, 1191, 1200,
142199 /* 280 */ 1206, 1119, 1119, 1191, 1156, 1064, 1293, 1375, 1156, 1064,
142200 /* 290 */ 1269, 1156, 1064, 1156, 1064, 1269, 1117, 1117, 1117, 1106,
142201 /* 300 */ 1269, 1117, 1091, 1117, 1106, 1117, 1117, 1269, 1273, 1273,
142202 /* 310 */ 1269, 1174, 1169, 1174, 1169, 1174, 1169, 1174, 1169, 1156,
142203 /* 320 */ 1264, 1156, 1046, 1186, 1175, 1184, 1182, 1191, 1070, 1109,
142204 /* 330 */ 1342, 1342, 1338, 1338, 1338, 1386, 1386, 1324, 1354, 1077,
142205 /* 340 */ 1077, 1077, 1077, 1354, 1093, 1093, 1077, 1077, 1077, 1077,
142206 /* 350 */ 1354, 1046, 1046, 1046, 1046, 1046, 1046, 1349, 1046, 1278,
142207 /* 360 */ 1160, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142208 /* 370 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142209 /* 380 */ 1046, 1046, 1211, 1046, 1049, 1321, 1046, 1046, 1320, 1046,
142210 /* 390 */ 1046, 1046, 1046, 1046, 1046, 1161, 1046, 1046, 1046, 1046,
142211 /* 400 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142212 /* 410 */ 1046, 1046, 1046, 1046, 1377, 1046, 1046, 1046, 1046, 1046,
142213 /* 420 */ 1046, 1292, 1291, 1046, 1046, 1158, 1046, 1046, 1046, 1046,
142214 /* 430 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142215 /* 440 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142216 /* 450 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142217 /* 460 */ 1183, 1046, 1176, 1046, 1046, 1046, 1046, 1368, 1046, 1046,
142218 /* 470 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
142219 /* 480 */ 1046, 1363, 1133, 1213, 1046, 1212, 1216, 1046, 1058, 1046,
 
 
 
142220 };
142221 /********** End of lemon-generated parsing tables *****************************/
142222
142223 /* The next table maps tokens (terminal symbols) into fallback tokens.
142224 ** If a construct like the following:
@@ -142310,15 +145711,22 @@
142310 59, /* RAISE => ID */
142311 59, /* RECURSIVE => ID */
142312 59, /* REPLACE => ID */
142313 59, /* RESTRICT => ID */
142314 59, /* ROW => ID */
 
142315 59, /* TRIGGER => ID */
142316 59, /* VACUUM => ID */
142317 59, /* VIEW => ID */
142318 59, /* VIRTUAL => ID */
142319 59, /* WITH => ID */
 
 
 
 
 
 
142320 59, /* REINDEX => ID */
142321 59, /* RENAME => ID */
142322 59, /* CTIME_KW => ID */
142323 };
142324 #endif /* YYFALLBACK */
@@ -142481,189 +145889,211 @@
142481 /* 71 */ "RAISE",
142482 /* 72 */ "RECURSIVE",
142483 /* 73 */ "REPLACE",
142484 /* 74 */ "RESTRICT",
142485 /* 75 */ "ROW",
142486 /* 76 */ "TRIGGER",
142487 /* 77 */ "VACUUM",
142488 /* 78 */ "VIEW",
142489 /* 79 */ "VIRTUAL",
142490 /* 80 */ "WITH",
142491 /* 81 */ "REINDEX",
142492 /* 82 */ "RENAME",
142493 /* 83 */ "CTIME_KW",
142494 /* 84 */ "ANY",
142495 /* 85 */ "BITAND",
142496 /* 86 */ "BITOR",
142497 /* 87 */ "LSHIFT",
142498 /* 88 */ "RSHIFT",
142499 /* 89 */ "PLUS",
142500 /* 90 */ "MINUS",
142501 /* 91 */ "STAR",
142502 /* 92 */ "SLASH",
142503 /* 93 */ "REM",
142504 /* 94 */ "CONCAT",
142505 /* 95 */ "COLLATE",
142506 /* 96 */ "BITNOT",
142507 /* 97 */ "ON",
142508 /* 98 */ "INDEXED",
142509 /* 99 */ "STRING",
142510 /* 100 */ "JOIN_KW",
142511 /* 101 */ "CONSTRAINT",
142512 /* 102 */ "DEFAULT",
142513 /* 103 */ "NULL",
142514 /* 104 */ "PRIMARY",
142515 /* 105 */ "UNIQUE",
142516 /* 106 */ "CHECK",
142517 /* 107 */ "REFERENCES",
142518 /* 108 */ "AUTOINCR",
142519 /* 109 */ "INSERT",
142520 /* 110 */ "DELETE",
142521 /* 111 */ "UPDATE",
142522 /* 112 */ "SET",
142523 /* 113 */ "DEFERRABLE",
142524 /* 114 */ "FOREIGN",
142525 /* 115 */ "DROP",
142526 /* 116 */ "UNION",
142527 /* 117 */ "ALL",
142528 /* 118 */ "EXCEPT",
142529 /* 119 */ "INTERSECT",
142530 /* 120 */ "SELECT",
142531 /* 121 */ "VALUES",
142532 /* 122 */ "DISTINCT",
142533 /* 123 */ "DOT",
142534 /* 124 */ "FROM",
142535 /* 125 */ "JOIN",
142536 /* 126 */ "USING",
142537 /* 127 */ "ORDER",
142538 /* 128 */ "GROUP",
142539 /* 129 */ "HAVING",
142540 /* 130 */ "LIMIT",
142541 /* 131 */ "WHERE",
142542 /* 132 */ "INTO",
142543 /* 133 */ "NOTHING",
142544 /* 134 */ "FLOAT",
142545 /* 135 */ "BLOB",
142546 /* 136 */ "INTEGER",
142547 /* 137 */ "VARIABLE",
142548 /* 138 */ "CASE",
142549 /* 139 */ "WHEN",
142550 /* 140 */ "THEN",
142551 /* 141 */ "ELSE",
142552 /* 142 */ "INDEX",
142553 /* 143 */ "ALTER",
142554 /* 144 */ "ADD",
142555 /* 145 */ "input",
142556 /* 146 */ "cmdlist",
142557 /* 147 */ "ecmd",
142558 /* 148 */ "cmdx",
142559 /* 149 */ "explain",
142560 /* 150 */ "cmd",
142561 /* 151 */ "transtype",
142562 /* 152 */ "trans_opt",
142563 /* 153 */ "nm",
142564 /* 154 */ "savepoint_opt",
142565 /* 155 */ "create_table",
142566 /* 156 */ "create_table_args",
142567 /* 157 */ "createkw",
142568 /* 158 */ "temp",
142569 /* 159 */ "ifnotexists",
142570 /* 160 */ "dbnm",
142571 /* 161 */ "columnlist",
142572 /* 162 */ "conslist_opt",
142573 /* 163 */ "table_options",
142574 /* 164 */ "select",
142575 /* 165 */ "columnname",
142576 /* 166 */ "carglist",
142577 /* 167 */ "typetoken",
142578 /* 168 */ "typename",
142579 /* 169 */ "signed",
142580 /* 170 */ "plus_num",
142581 /* 171 */ "minus_num",
142582 /* 172 */ "scanpt",
142583 /* 173 */ "ccons",
142584 /* 174 */ "term",
142585 /* 175 */ "expr",
142586 /* 176 */ "onconf",
142587 /* 177 */ "sortorder",
142588 /* 178 */ "autoinc",
142589 /* 179 */ "eidlist_opt",
142590 /* 180 */ "refargs",
142591 /* 181 */ "defer_subclause",
142592 /* 182 */ "refarg",
142593 /* 183 */ "refact",
142594 /* 184 */ "init_deferred_pred_opt",
142595 /* 185 */ "conslist",
142596 /* 186 */ "tconscomma",
142597 /* 187 */ "tcons",
142598 /* 188 */ "sortlist",
142599 /* 189 */ "eidlist",
142600 /* 190 */ "defer_subclause_opt",
142601 /* 191 */ "orconf",
142602 /* 192 */ "resolvetype",
142603 /* 193 */ "raisetype",
142604 /* 194 */ "ifexists",
142605 /* 195 */ "fullname",
142606 /* 196 */ "selectnowith",
142607 /* 197 */ "oneselect",
142608 /* 198 */ "wqlist",
142609 /* 199 */ "multiselect_op",
142610 /* 200 */ "distinct",
142611 /* 201 */ "selcollist",
142612 /* 202 */ "from",
142613 /* 203 */ "where_opt",
142614 /* 204 */ "groupby_opt",
142615 /* 205 */ "having_opt",
142616 /* 206 */ "orderby_opt",
142617 /* 207 */ "limit_opt",
142618 /* 208 */ "values",
142619 /* 209 */ "nexprlist",
142620 /* 210 */ "exprlist",
142621 /* 211 */ "sclp",
142622 /* 212 */ "as",
142623 /* 213 */ "seltablist",
142624 /* 214 */ "stl_prefix",
142625 /* 215 */ "joinop",
142626 /* 216 */ "indexed_opt",
142627 /* 217 */ "on_opt",
142628 /* 218 */ "using_opt",
142629 /* 219 */ "xfullname",
142630 /* 220 */ "idlist",
142631 /* 221 */ "with",
142632 /* 222 */ "setlist",
142633 /* 223 */ "insert_cmd",
142634 /* 224 */ "idlist_opt",
142635 /* 225 */ "upsert",
142636 /* 226 */ "likeop",
142637 /* 227 */ "between_op",
142638 /* 228 */ "in_op",
142639 /* 229 */ "paren_exprlist",
142640 /* 230 */ "case_operand",
142641 /* 231 */ "case_exprlist",
142642 /* 232 */ "case_else",
142643 /* 233 */ "uniqueflag",
142644 /* 234 */ "collate",
142645 /* 235 */ "nmnum",
142646 /* 236 */ "trigger_decl",
142647 /* 237 */ "trigger_cmd_list",
142648 /* 238 */ "trigger_time",
142649 /* 239 */ "trigger_event",
142650 /* 240 */ "foreach_clause",
142651 /* 241 */ "when_clause",
142652 /* 242 */ "trigger_cmd",
142653 /* 243 */ "trnm",
142654 /* 244 */ "tridxby",
142655 /* 245 */ "database_kw_opt",
142656 /* 246 */ "key_opt",
142657 /* 247 */ "add_column_fullname",
142658 /* 248 */ "kwcolumn_opt",
142659 /* 249 */ "create_vtab",
142660 /* 250 */ "vtabarglist",
142661 /* 251 */ "vtabarg",
142662 /* 252 */ "vtabargtoken",
142663 /* 253 */ "lp",
142664 /* 254 */ "anylist",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142665 };
142666 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
142667
142668 #ifndef NDEBUG
142669 /* For tracing reduce actions, the names of all rules are required.
@@ -142754,11 +146184,11 @@
142754 /* 82 */ "select ::= selectnowith",
142755 /* 83 */ "selectnowith ::= selectnowith multiselect_op oneselect",
142756 /* 84 */ "multiselect_op ::= UNION",
142757 /* 85 */ "multiselect_op ::= UNION ALL",
142758 /* 86 */ "multiselect_op ::= EXCEPT|INTERSECT",
142759 /* 87 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
142760 /* 88 */ "values ::= VALUES LP nexprlist RP",
142761 /* 89 */ "values ::= values COMMA LP exprlist RP",
142762 /* 90 */ "distinct ::= DISTINCT",
142763 /* 91 */ "distinct ::= ALL",
142764 /* 92 */ "distinct ::=",
@@ -142839,12 +146269,12 @@
142839 /* 167 */ "term ::= STRING",
142840 /* 168 */ "term ::= INTEGER",
142841 /* 169 */ "expr ::= VARIABLE",
142842 /* 170 */ "expr ::= expr COLLATE ID|STRING",
142843 /* 171 */ "expr ::= CAST LP expr AS typetoken RP",
142844 /* 172 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
142845 /* 173 */ "expr ::= ID|INDEXED LP STAR RP",
142846 /* 174 */ "term ::= CTIME_KW",
142847 /* 175 */ "expr ::= LP nexprlist COMMA expr RP",
142848 /* 176 */ "expr ::= expr AND expr",
142849 /* 177 */ "expr ::= expr OR expr",
142850 /* 178 */ "expr ::= expr LT|GT|GE|LE expr",
@@ -142860,158 +146290,182 @@
142860 /* 188 */ "expr ::= expr NOT NULL",
142861 /* 189 */ "expr ::= expr IS expr",
142862 /* 190 */ "expr ::= expr IS NOT expr",
142863 /* 191 */ "expr ::= NOT expr",
142864 /* 192 */ "expr ::= BITNOT expr",
142865 /* 193 */ "expr ::= MINUS expr",
142866 /* 194 */ "expr ::= PLUS expr",
142867 /* 195 */ "between_op ::= BETWEEN",
142868 /* 196 */ "between_op ::= NOT BETWEEN",
142869 /* 197 */ "expr ::= expr between_op expr AND expr",
142870 /* 198 */ "in_op ::= IN",
142871 /* 199 */ "in_op ::= NOT IN",
142872 /* 200 */ "expr ::= expr in_op LP exprlist RP",
142873 /* 201 */ "expr ::= LP select RP",
142874 /* 202 */ "expr ::= expr in_op LP select RP",
142875 /* 203 */ "expr ::= expr in_op nm dbnm paren_exprlist",
142876 /* 204 */ "expr ::= EXISTS LP select RP",
142877 /* 205 */ "expr ::= CASE case_operand case_exprlist case_else END",
142878 /* 206 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
142879 /* 207 */ "case_exprlist ::= WHEN expr THEN expr",
142880 /* 208 */ "case_else ::= ELSE expr",
142881 /* 209 */ "case_else ::=",
142882 /* 210 */ "case_operand ::= expr",
142883 /* 211 */ "case_operand ::=",
142884 /* 212 */ "exprlist ::=",
142885 /* 213 */ "nexprlist ::= nexprlist COMMA expr",
142886 /* 214 */ "nexprlist ::= expr",
142887 /* 215 */ "paren_exprlist ::=",
142888 /* 216 */ "paren_exprlist ::= LP exprlist RP",
142889 /* 217 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
142890 /* 218 */ "uniqueflag ::= UNIQUE",
142891 /* 219 */ "uniqueflag ::=",
142892 /* 220 */ "eidlist_opt ::=",
142893 /* 221 */ "eidlist_opt ::= LP eidlist RP",
142894 /* 222 */ "eidlist ::= eidlist COMMA nm collate sortorder",
142895 /* 223 */ "eidlist ::= nm collate sortorder",
142896 /* 224 */ "collate ::=",
142897 /* 225 */ "collate ::= COLLATE ID|STRING",
142898 /* 226 */ "cmd ::= DROP INDEX ifexists fullname",
142899 /* 227 */ "cmd ::= VACUUM",
142900 /* 228 */ "cmd ::= VACUUM nm",
142901 /* 229 */ "cmd ::= PRAGMA nm dbnm",
142902 /* 230 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
142903 /* 231 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
142904 /* 232 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
142905 /* 233 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
142906 /* 234 */ "plus_num ::= PLUS INTEGER|FLOAT",
142907 /* 235 */ "minus_num ::= MINUS INTEGER|FLOAT",
142908 /* 236 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
142909 /* 237 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
142910 /* 238 */ "trigger_time ::= BEFORE|AFTER",
142911 /* 239 */ "trigger_time ::= INSTEAD OF",
142912 /* 240 */ "trigger_time ::=",
142913 /* 241 */ "trigger_event ::= DELETE|INSERT",
142914 /* 242 */ "trigger_event ::= UPDATE",
142915 /* 243 */ "trigger_event ::= UPDATE OF idlist",
142916 /* 244 */ "when_clause ::=",
142917 /* 245 */ "when_clause ::= WHEN expr",
142918 /* 246 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
142919 /* 247 */ "trigger_cmd_list ::= trigger_cmd SEMI",
142920 /* 248 */ "trnm ::= nm DOT nm",
142921 /* 249 */ "tridxby ::= INDEXED BY nm",
142922 /* 250 */ "tridxby ::= NOT INDEXED",
142923 /* 251 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
142924 /* 252 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
142925 /* 253 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
142926 /* 254 */ "trigger_cmd ::= scanpt select scanpt",
142927 /* 255 */ "expr ::= RAISE LP IGNORE RP",
142928 /* 256 */ "expr ::= RAISE LP raisetype COMMA nm RP",
142929 /* 257 */ "raisetype ::= ROLLBACK",
142930 /* 258 */ "raisetype ::= ABORT",
142931 /* 259 */ "raisetype ::= FAIL",
142932 /* 260 */ "cmd ::= DROP TRIGGER ifexists fullname",
142933 /* 261 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
142934 /* 262 */ "cmd ::= DETACH database_kw_opt expr",
142935 /* 263 */ "key_opt ::=",
142936 /* 264 */ "key_opt ::= KEY expr",
142937 /* 265 */ "cmd ::= REINDEX",
142938 /* 266 */ "cmd ::= REINDEX nm dbnm",
142939 /* 267 */ "cmd ::= ANALYZE",
142940 /* 268 */ "cmd ::= ANALYZE nm dbnm",
142941 /* 269 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
142942 /* 270 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
142943 /* 271 */ "add_column_fullname ::= fullname",
142944 /* 272 */ "cmd ::= create_vtab",
142945 /* 273 */ "cmd ::= create_vtab LP vtabarglist RP",
142946 /* 274 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
142947 /* 275 */ "vtabarg ::=",
142948 /* 276 */ "vtabargtoken ::= ANY",
142949 /* 277 */ "vtabargtoken ::= lp anylist RP",
142950 /* 278 */ "lp ::= LP",
142951 /* 279 */ "with ::= WITH wqlist",
142952 /* 280 */ "with ::= WITH RECURSIVE wqlist",
142953 /* 281 */ "wqlist ::= nm eidlist_opt AS LP select RP",
142954 /* 282 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
142955 /* 283 */ "input ::= cmdlist",
142956 /* 284 */ "cmdlist ::= cmdlist ecmd",
142957 /* 285 */ "cmdlist ::= ecmd",
142958 /* 286 */ "ecmd ::= SEMI",
142959 /* 287 */ "ecmd ::= cmdx SEMI",
142960 /* 288 */ "ecmd ::= explain cmdx",
142961 /* 289 */ "trans_opt ::=",
142962 /* 290 */ "trans_opt ::= TRANSACTION",
142963 /* 291 */ "trans_opt ::= TRANSACTION nm",
142964 /* 292 */ "savepoint_opt ::= SAVEPOINT",
142965 /* 293 */ "savepoint_opt ::=",
142966 /* 294 */ "cmd ::= create_table create_table_args",
142967 /* 295 */ "columnlist ::= columnlist COMMA columnname carglist",
142968 /* 296 */ "columnlist ::= columnname carglist",
142969 /* 297 */ "nm ::= ID|INDEXED",
142970 /* 298 */ "nm ::= STRING",
142971 /* 299 */ "nm ::= JOIN_KW",
142972 /* 300 */ "typetoken ::= typename",
142973 /* 301 */ "typename ::= ID|STRING",
142974 /* 302 */ "signed ::= plus_num",
142975 /* 303 */ "signed ::= minus_num",
142976 /* 304 */ "carglist ::= carglist ccons",
142977 /* 305 */ "carglist ::=",
142978 /* 306 */ "ccons ::= NULL onconf",
142979 /* 307 */ "conslist_opt ::= COMMA conslist",
142980 /* 308 */ "conslist ::= conslist tconscomma tcons",
142981 /* 309 */ "conslist ::= tcons",
142982 /* 310 */ "tconscomma ::=",
142983 /* 311 */ "defer_subclause_opt ::= defer_subclause",
142984 /* 312 */ "resolvetype ::= raisetype",
142985 /* 313 */ "selectnowith ::= oneselect",
142986 /* 314 */ "oneselect ::= values",
142987 /* 315 */ "sclp ::= selcollist COMMA",
142988 /* 316 */ "as ::= ID|STRING",
142989 /* 317 */ "expr ::= term",
142990 /* 318 */ "likeop ::= LIKE_KW|MATCH",
142991 /* 319 */ "exprlist ::= nexprlist",
142992 /* 320 */ "nmnum ::= plus_num",
142993 /* 321 */ "nmnum ::= nm",
142994 /* 322 */ "nmnum ::= ON",
142995 /* 323 */ "nmnum ::= DELETE",
142996 /* 324 */ "nmnum ::= DEFAULT",
142997 /* 325 */ "plus_num ::= INTEGER|FLOAT",
142998 /* 326 */ "foreach_clause ::=",
142999 /* 327 */ "foreach_clause ::= FOR EACH ROW",
143000 /* 328 */ "trnm ::= nm",
143001 /* 329 */ "tridxby ::=",
143002 /* 330 */ "database_kw_opt ::= DATABASE",
143003 /* 331 */ "database_kw_opt ::=",
143004 /* 332 */ "kwcolumn_opt ::=",
143005 /* 333 */ "kwcolumn_opt ::= COLUMNKW",
143006 /* 334 */ "vtabarglist ::= vtabarg",
143007 /* 335 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
143008 /* 336 */ "vtabarg ::= vtabarg vtabargtoken",
143009 /* 337 */ "anylist ::=",
143010 /* 338 */ "anylist ::= anylist LP anylist RP",
143011 /* 339 */ "anylist ::= anylist ANY",
143012 /* 340 */ "with ::=",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143013 };
143014 #endif /* NDEBUG */
143015
143016
143017 #if YYSTACKDEPTH<=0
@@ -143133,77 +146587,100 @@
143133 ** Note: during a reduce, the only symbols destroyed are those
143134 ** which appear on the RHS of the rule, but which are *not* used
143135 ** inside the C code.
143136 */
143137 /********* Begin destructor definitions ***************************************/
143138 case 164: /* select */
143139 case 196: /* selectnowith */
143140 case 197: /* oneselect */
143141 case 208: /* values */
143142 {
143143 sqlite3SelectDelete(pParse->db, (yypminor->yy399));
143144 }
143145 break;
143146 case 174: /* term */
143147 case 175: /* expr */
143148 case 203: /* where_opt */
143149 case 205: /* having_opt */
143150 case 217: /* on_opt */
143151 case 230: /* case_operand */
143152 case 232: /* case_else */
143153 case 241: /* when_clause */
143154 case 246: /* key_opt */
143155 {
143156 sqlite3ExprDelete(pParse->db, (yypminor->yy182));
143157 }
143158 break;
143159 case 179: /* eidlist_opt */
143160 case 188: /* sortlist */
143161 case 189: /* eidlist */
143162 case 201: /* selcollist */
143163 case 204: /* groupby_opt */
143164 case 206: /* orderby_opt */
143165 case 209: /* nexprlist */
143166 case 210: /* exprlist */
143167 case 211: /* sclp */
143168 case 222: /* setlist */
143169 case 229: /* paren_exprlist */
143170 case 231: /* case_exprlist */
143171 {
143172 sqlite3ExprListDelete(pParse->db, (yypminor->yy232));
143173 }
143174 break;
143175 case 195: /* fullname */
143176 case 202: /* from */
143177 case 213: /* seltablist */
143178 case 214: /* stl_prefix */
143179 case 219: /* xfullname */
143180 {
143181 sqlite3SrcListDelete(pParse->db, (yypminor->yy427));
143182 }
143183 break;
143184 case 198: /* wqlist */
143185 {
143186 sqlite3WithDelete(pParse->db, (yypminor->yy91));
143187 }
143188 break;
143189 case 218: /* using_opt */
143190 case 220: /* idlist */
143191 case 224: /* idlist_opt */
143192 {
143193 sqlite3IdListDelete(pParse->db, (yypminor->yy510));
143194 }
143195 break;
143196 case 237: /* trigger_cmd_list */
143197 case 242: /* trigger_cmd */
143198 {
143199 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy47));
143200 }
143201 break;
143202 case 239: /* trigger_event */
143203 {
143204 sqlite3IdListDelete(pParse->db, (yypminor->yy300).b);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143205 }
143206 break;
143207 /********* End destructor definitions *****************************************/
143208 default: break; /* If no destructor action specified: do nothing */
143209 }
@@ -143325,15 +146802,15 @@
143325 yycoverage[stateno][iLookAhead] = 1;
143326 #endif
143327 do{
143328 i = yy_shift_ofst[stateno];
143329 assert( i>=0 );
143330 assert( i+YYNTOKEN<=(int)sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) );
143331 assert( iLookAhead!=YYNOCODE );
143332 assert( iLookAhead < YYNTOKEN );
143333 i += iLookAhead;
143334 if( yy_lookahead[i]!=iLookAhead ){
143335 #ifdef YYFALLBACK
143336 YYCODETYPE iFallback; /* Fallback token */
143337 if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
143338 && (iFallback = yyFallback[iLookAhead])!=0 ){
143339 #ifndef NDEBUG
@@ -143355,10 +146832,11 @@
143355 j>=0 &&
143356 #endif
143357 #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
143358 j<YY_ACTTAB_COUNT &&
143359 #endif
 
143360 yy_lookahead[j]==YYWILDCARD && iLookAhead>0
143361 ){
143362 #ifndef NDEBUG
143363 if( yyTraceFILE ){
143364 fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
@@ -143497,351 +146975,375 @@
143497 */
143498 static const struct {
143499 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
143500 signed char nrhs; /* Negative of the number of RHS symbols in the rule */
143501 } yyRuleInfo[] = {
143502 { 149, -1 }, /* (0) explain ::= EXPLAIN */
143503 { 149, -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */
143504 { 148, -1 }, /* (2) cmdx ::= cmd */
143505 { 150, -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */
143506 { 151, 0 }, /* (4) transtype ::= */
143507 { 151, -1 }, /* (5) transtype ::= DEFERRED */
143508 { 151, -1 }, /* (6) transtype ::= IMMEDIATE */
143509 { 151, -1 }, /* (7) transtype ::= EXCLUSIVE */
143510 { 150, -2 }, /* (8) cmd ::= COMMIT|END trans_opt */
143511 { 150, -2 }, /* (9) cmd ::= ROLLBACK trans_opt */
143512 { 150, -2 }, /* (10) cmd ::= SAVEPOINT nm */
143513 { 150, -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */
143514 { 150, -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
143515 { 155, -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
143516 { 157, -1 }, /* (14) createkw ::= CREATE */
143517 { 159, 0 }, /* (15) ifnotexists ::= */
143518 { 159, -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */
143519 { 158, -1 }, /* (17) temp ::= TEMP */
143520 { 158, 0 }, /* (18) temp ::= */
143521 { 156, -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
143522 { 156, -2 }, /* (20) create_table_args ::= AS select */
143523 { 163, 0 }, /* (21) table_options ::= */
143524 { 163, -2 }, /* (22) table_options ::= WITHOUT nm */
143525 { 165, -2 }, /* (23) columnname ::= nm typetoken */
143526 { 167, 0 }, /* (24) typetoken ::= */
143527 { 167, -4 }, /* (25) typetoken ::= typename LP signed RP */
143528 { 167, -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */
143529 { 168, -2 }, /* (27) typename ::= typename ID|STRING */
143530 { 172, 0 }, /* (28) scanpt ::= */
143531 { 173, -2 }, /* (29) ccons ::= CONSTRAINT nm */
143532 { 173, -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */
143533 { 173, -4 }, /* (31) ccons ::= DEFAULT LP expr RP */
143534 { 173, -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */
143535 { 173, -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */
143536 { 173, -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
143537 { 173, -3 }, /* (35) ccons ::= NOT NULL onconf */
143538 { 173, -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
143539 { 173, -2 }, /* (37) ccons ::= UNIQUE onconf */
143540 { 173, -4 }, /* (38) ccons ::= CHECK LP expr RP */
143541 { 173, -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
143542 { 173, -1 }, /* (40) ccons ::= defer_subclause */
143543 { 173, -2 }, /* (41) ccons ::= COLLATE ID|STRING */
143544 { 178, 0 }, /* (42) autoinc ::= */
143545 { 178, -1 }, /* (43) autoinc ::= AUTOINCR */
143546 { 180, 0 }, /* (44) refargs ::= */
143547 { 180, -2 }, /* (45) refargs ::= refargs refarg */
143548 { 182, -2 }, /* (46) refarg ::= MATCH nm */
143549 { 182, -3 }, /* (47) refarg ::= ON INSERT refact */
143550 { 182, -3 }, /* (48) refarg ::= ON DELETE refact */
143551 { 182, -3 }, /* (49) refarg ::= ON UPDATE refact */
143552 { 183, -2 }, /* (50) refact ::= SET NULL */
143553 { 183, -2 }, /* (51) refact ::= SET DEFAULT */
143554 { 183, -1 }, /* (52) refact ::= CASCADE */
143555 { 183, -1 }, /* (53) refact ::= RESTRICT */
143556 { 183, -2 }, /* (54) refact ::= NO ACTION */
143557 { 181, -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
143558 { 181, -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
143559 { 184, 0 }, /* (57) init_deferred_pred_opt ::= */
143560 { 184, -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
143561 { 184, -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
143562 { 162, 0 }, /* (60) conslist_opt ::= */
143563 { 186, -1 }, /* (61) tconscomma ::= COMMA */
143564 { 187, -2 }, /* (62) tcons ::= CONSTRAINT nm */
143565 { 187, -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
143566 { 187, -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
143567 { 187, -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */
143568 { 187, -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
143569 { 190, 0 }, /* (67) defer_subclause_opt ::= */
143570 { 176, 0 }, /* (68) onconf ::= */
143571 { 176, -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */
143572 { 191, 0 }, /* (70) orconf ::= */
143573 { 191, -2 }, /* (71) orconf ::= OR resolvetype */
143574 { 192, -1 }, /* (72) resolvetype ::= IGNORE */
143575 { 192, -1 }, /* (73) resolvetype ::= REPLACE */
143576 { 150, -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
143577 { 194, -2 }, /* (75) ifexists ::= IF EXISTS */
143578 { 194, 0 }, /* (76) ifexists ::= */
143579 { 150, -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
143580 { 150, -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
143581 { 150, -1 }, /* (79) cmd ::= select */
143582 { 164, -3 }, /* (80) select ::= WITH wqlist selectnowith */
143583 { 164, -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
143584 { 164, -1 }, /* (82) select ::= selectnowith */
143585 { 196, -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
143586 { 199, -1 }, /* (84) multiselect_op ::= UNION */
143587 { 199, -2 }, /* (85) multiselect_op ::= UNION ALL */
143588 { 199, -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
143589 { 197, -9 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
143590 { 208, -4 }, /* (88) values ::= VALUES LP nexprlist RP */
143591 { 208, -5 }, /* (89) values ::= values COMMA LP exprlist RP */
143592 { 200, -1 }, /* (90) distinct ::= DISTINCT */
143593 { 200, -1 }, /* (91) distinct ::= ALL */
143594 { 200, 0 }, /* (92) distinct ::= */
143595 { 211, 0 }, /* (93) sclp ::= */
143596 { 201, -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
143597 { 201, -3 }, /* (95) selcollist ::= sclp scanpt STAR */
143598 { 201, -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
143599 { 212, -2 }, /* (97) as ::= AS nm */
143600 { 212, 0 }, /* (98) as ::= */
143601 { 202, 0 }, /* (99) from ::= */
143602 { 202, -2 }, /* (100) from ::= FROM seltablist */
143603 { 214, -2 }, /* (101) stl_prefix ::= seltablist joinop */
143604 { 214, 0 }, /* (102) stl_prefix ::= */
143605 { 213, -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
143606 { 213, -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
143607 { 213, -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
143608 { 213, -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
143609 { 160, 0 }, /* (107) dbnm ::= */
143610 { 160, -2 }, /* (108) dbnm ::= DOT nm */
143611 { 195, -1 }, /* (109) fullname ::= nm */
143612 { 195, -3 }, /* (110) fullname ::= nm DOT nm */
143613 { 219, -1 }, /* (111) xfullname ::= nm */
143614 { 219, -3 }, /* (112) xfullname ::= nm DOT nm */
143615 { 219, -5 }, /* (113) xfullname ::= nm DOT nm AS nm */
143616 { 219, -3 }, /* (114) xfullname ::= nm AS nm */
143617 { 215, -1 }, /* (115) joinop ::= COMMA|JOIN */
143618 { 215, -2 }, /* (116) joinop ::= JOIN_KW JOIN */
143619 { 215, -3 }, /* (117) joinop ::= JOIN_KW nm JOIN */
143620 { 215, -4 }, /* (118) joinop ::= JOIN_KW nm nm JOIN */
143621 { 217, -2 }, /* (119) on_opt ::= ON expr */
143622 { 217, 0 }, /* (120) on_opt ::= */
143623 { 216, 0 }, /* (121) indexed_opt ::= */
143624 { 216, -3 }, /* (122) indexed_opt ::= INDEXED BY nm */
143625 { 216, -2 }, /* (123) indexed_opt ::= NOT INDEXED */
143626 { 218, -4 }, /* (124) using_opt ::= USING LP idlist RP */
143627 { 218, 0 }, /* (125) using_opt ::= */
143628 { 206, 0 }, /* (126) orderby_opt ::= */
143629 { 206, -3 }, /* (127) orderby_opt ::= ORDER BY sortlist */
143630 { 188, -4 }, /* (128) sortlist ::= sortlist COMMA expr sortorder */
143631 { 188, -2 }, /* (129) sortlist ::= expr sortorder */
143632 { 177, -1 }, /* (130) sortorder ::= ASC */
143633 { 177, -1 }, /* (131) sortorder ::= DESC */
143634 { 177, 0 }, /* (132) sortorder ::= */
143635 { 204, 0 }, /* (133) groupby_opt ::= */
143636 { 204, -3 }, /* (134) groupby_opt ::= GROUP BY nexprlist */
143637 { 205, 0 }, /* (135) having_opt ::= */
143638 { 205, -2 }, /* (136) having_opt ::= HAVING expr */
143639 { 207, 0 }, /* (137) limit_opt ::= */
143640 { 207, -2 }, /* (138) limit_opt ::= LIMIT expr */
143641 { 207, -4 }, /* (139) limit_opt ::= LIMIT expr OFFSET expr */
143642 { 207, -4 }, /* (140) limit_opt ::= LIMIT expr COMMA expr */
143643 { 150, -6 }, /* (141) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
143644 { 203, 0 }, /* (142) where_opt ::= */
143645 { 203, -2 }, /* (143) where_opt ::= WHERE expr */
143646 { 150, -8 }, /* (144) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
143647 { 222, -5 }, /* (145) setlist ::= setlist COMMA nm EQ expr */
143648 { 222, -7 }, /* (146) setlist ::= setlist COMMA LP idlist RP EQ expr */
143649 { 222, -3 }, /* (147) setlist ::= nm EQ expr */
143650 { 222, -5 }, /* (148) setlist ::= LP idlist RP EQ expr */
143651 { 150, -7 }, /* (149) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
143652 { 150, -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
143653 { 225, 0 }, /* (151) upsert ::= */
143654 { 225, -11 }, /* (152) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
143655 { 225, -8 }, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
143656 { 225, -4 }, /* (154) upsert ::= ON CONFLICT DO NOTHING */
143657 { 223, -2 }, /* (155) insert_cmd ::= INSERT orconf */
143658 { 223, -1 }, /* (156) insert_cmd ::= REPLACE */
143659 { 224, 0 }, /* (157) idlist_opt ::= */
143660 { 224, -3 }, /* (158) idlist_opt ::= LP idlist RP */
143661 { 220, -3 }, /* (159) idlist ::= idlist COMMA nm */
143662 { 220, -1 }, /* (160) idlist ::= nm */
143663 { 175, -3 }, /* (161) expr ::= LP expr RP */
143664 { 175, -1 }, /* (162) expr ::= ID|INDEXED */
143665 { 175, -1 }, /* (163) expr ::= JOIN_KW */
143666 { 175, -3 }, /* (164) expr ::= nm DOT nm */
143667 { 175, -5 }, /* (165) expr ::= nm DOT nm DOT nm */
143668 { 174, -1 }, /* (166) term ::= NULL|FLOAT|BLOB */
143669 { 174, -1 }, /* (167) term ::= STRING */
143670 { 174, -1 }, /* (168) term ::= INTEGER */
143671 { 175, -1 }, /* (169) expr ::= VARIABLE */
143672 { 175, -3 }, /* (170) expr ::= expr COLLATE ID|STRING */
143673 { 175, -6 }, /* (171) expr ::= CAST LP expr AS typetoken RP */
143674 { 175, -5 }, /* (172) expr ::= ID|INDEXED LP distinct exprlist RP */
143675 { 175, -4 }, /* (173) expr ::= ID|INDEXED LP STAR RP */
143676 { 174, -1 }, /* (174) term ::= CTIME_KW */
143677 { 175, -5 }, /* (175) expr ::= LP nexprlist COMMA expr RP */
143678 { 175, -3 }, /* (176) expr ::= expr AND expr */
143679 { 175, -3 }, /* (177) expr ::= expr OR expr */
143680 { 175, -3 }, /* (178) expr ::= expr LT|GT|GE|LE expr */
143681 { 175, -3 }, /* (179) expr ::= expr EQ|NE expr */
143682 { 175, -3 }, /* (180) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
143683 { 175, -3 }, /* (181) expr ::= expr PLUS|MINUS expr */
143684 { 175, -3 }, /* (182) expr ::= expr STAR|SLASH|REM expr */
143685 { 175, -3 }, /* (183) expr ::= expr CONCAT expr */
143686 { 226, -2 }, /* (184) likeop ::= NOT LIKE_KW|MATCH */
143687 { 175, -3 }, /* (185) expr ::= expr likeop expr */
143688 { 175, -5 }, /* (186) expr ::= expr likeop expr ESCAPE expr */
143689 { 175, -2 }, /* (187) expr ::= expr ISNULL|NOTNULL */
143690 { 175, -3 }, /* (188) expr ::= expr NOT NULL */
143691 { 175, -3 }, /* (189) expr ::= expr IS expr */
143692 { 175, -4 }, /* (190) expr ::= expr IS NOT expr */
143693 { 175, -2 }, /* (191) expr ::= NOT expr */
143694 { 175, -2 }, /* (192) expr ::= BITNOT expr */
143695 { 175, -2 }, /* (193) expr ::= MINUS expr */
143696 { 175, -2 }, /* (194) expr ::= PLUS expr */
143697 { 227, -1 }, /* (195) between_op ::= BETWEEN */
143698 { 227, -2 }, /* (196) between_op ::= NOT BETWEEN */
143699 { 175, -5 }, /* (197) expr ::= expr between_op expr AND expr */
143700 { 228, -1 }, /* (198) in_op ::= IN */
143701 { 228, -2 }, /* (199) in_op ::= NOT IN */
143702 { 175, -5 }, /* (200) expr ::= expr in_op LP exprlist RP */
143703 { 175, -3 }, /* (201) expr ::= LP select RP */
143704 { 175, -5 }, /* (202) expr ::= expr in_op LP select RP */
143705 { 175, -5 }, /* (203) expr ::= expr in_op nm dbnm paren_exprlist */
143706 { 175, -4 }, /* (204) expr ::= EXISTS LP select RP */
143707 { 175, -5 }, /* (205) expr ::= CASE case_operand case_exprlist case_else END */
143708 { 231, -5 }, /* (206) case_exprlist ::= case_exprlist WHEN expr THEN expr */
143709 { 231, -4 }, /* (207) case_exprlist ::= WHEN expr THEN expr */
143710 { 232, -2 }, /* (208) case_else ::= ELSE expr */
143711 { 232, 0 }, /* (209) case_else ::= */
143712 { 230, -1 }, /* (210) case_operand ::= expr */
143713 { 230, 0 }, /* (211) case_operand ::= */
143714 { 210, 0 }, /* (212) exprlist ::= */
143715 { 209, -3 }, /* (213) nexprlist ::= nexprlist COMMA expr */
143716 { 209, -1 }, /* (214) nexprlist ::= expr */
143717 { 229, 0 }, /* (215) paren_exprlist ::= */
143718 { 229, -3 }, /* (216) paren_exprlist ::= LP exprlist RP */
143719 { 150, -12 }, /* (217) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
143720 { 233, -1 }, /* (218) uniqueflag ::= UNIQUE */
143721 { 233, 0 }, /* (219) uniqueflag ::= */
143722 { 179, 0 }, /* (220) eidlist_opt ::= */
143723 { 179, -3 }, /* (221) eidlist_opt ::= LP eidlist RP */
143724 { 189, -5 }, /* (222) eidlist ::= eidlist COMMA nm collate sortorder */
143725 { 189, -3 }, /* (223) eidlist ::= nm collate sortorder */
143726 { 234, 0 }, /* (224) collate ::= */
143727 { 234, -2 }, /* (225) collate ::= COLLATE ID|STRING */
143728 { 150, -4 }, /* (226) cmd ::= DROP INDEX ifexists fullname */
143729 { 150, -1 }, /* (227) cmd ::= VACUUM */
143730 { 150, -2 }, /* (228) cmd ::= VACUUM nm */
143731 { 150, -3 }, /* (229) cmd ::= PRAGMA nm dbnm */
143732 { 150, -5 }, /* (230) cmd ::= PRAGMA nm dbnm EQ nmnum */
143733 { 150, -6 }, /* (231) cmd ::= PRAGMA nm dbnm LP nmnum RP */
143734 { 150, -5 }, /* (232) cmd ::= PRAGMA nm dbnm EQ minus_num */
143735 { 150, -6 }, /* (233) cmd ::= PRAGMA nm dbnm LP minus_num RP */
143736 { 170, -2 }, /* (234) plus_num ::= PLUS INTEGER|FLOAT */
143737 { 171, -2 }, /* (235) minus_num ::= MINUS INTEGER|FLOAT */
143738 { 150, -5 }, /* (236) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
143739 { 236, -11 }, /* (237) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
143740 { 238, -1 }, /* (238) trigger_time ::= BEFORE|AFTER */
143741 { 238, -2 }, /* (239) trigger_time ::= INSTEAD OF */
143742 { 238, 0 }, /* (240) trigger_time ::= */
143743 { 239, -1 }, /* (241) trigger_event ::= DELETE|INSERT */
143744 { 239, -1 }, /* (242) trigger_event ::= UPDATE */
143745 { 239, -3 }, /* (243) trigger_event ::= UPDATE OF idlist */
143746 { 241, 0 }, /* (244) when_clause ::= */
143747 { 241, -2 }, /* (245) when_clause ::= WHEN expr */
143748 { 237, -3 }, /* (246) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
143749 { 237, -2 }, /* (247) trigger_cmd_list ::= trigger_cmd SEMI */
143750 { 243, -3 }, /* (248) trnm ::= nm DOT nm */
143751 { 244, -3 }, /* (249) tridxby ::= INDEXED BY nm */
143752 { 244, -2 }, /* (250) tridxby ::= NOT INDEXED */
143753 { 242, -8 }, /* (251) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
143754 { 242, -8 }, /* (252) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
143755 { 242, -6 }, /* (253) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
143756 { 242, -3 }, /* (254) trigger_cmd ::= scanpt select scanpt */
143757 { 175, -4 }, /* (255) expr ::= RAISE LP IGNORE RP */
143758 { 175, -6 }, /* (256) expr ::= RAISE LP raisetype COMMA nm RP */
143759 { 193, -1 }, /* (257) raisetype ::= ROLLBACK */
143760 { 193, -1 }, /* (258) raisetype ::= ABORT */
143761 { 193, -1 }, /* (259) raisetype ::= FAIL */
143762 { 150, -4 }, /* (260) cmd ::= DROP TRIGGER ifexists fullname */
143763 { 150, -6 }, /* (261) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
143764 { 150, -3 }, /* (262) cmd ::= DETACH database_kw_opt expr */
143765 { 246, 0 }, /* (263) key_opt ::= */
143766 { 246, -2 }, /* (264) key_opt ::= KEY expr */
143767 { 150, -1 }, /* (265) cmd ::= REINDEX */
143768 { 150, -3 }, /* (266) cmd ::= REINDEX nm dbnm */
143769 { 150, -1 }, /* (267) cmd ::= ANALYZE */
143770 { 150, -3 }, /* (268) cmd ::= ANALYZE nm dbnm */
143771 { 150, -6 }, /* (269) cmd ::= ALTER TABLE fullname RENAME TO nm */
143772 { 150, -7 }, /* (270) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
143773 { 247, -1 }, /* (271) add_column_fullname ::= fullname */
143774 { 150, -1 }, /* (272) cmd ::= create_vtab */
143775 { 150, -4 }, /* (273) cmd ::= create_vtab LP vtabarglist RP */
143776 { 249, -8 }, /* (274) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
143777 { 251, 0 }, /* (275) vtabarg ::= */
143778 { 252, -1 }, /* (276) vtabargtoken ::= ANY */
143779 { 252, -3 }, /* (277) vtabargtoken ::= lp anylist RP */
143780 { 253, -1 }, /* (278) lp ::= LP */
143781 { 221, -2 }, /* (279) with ::= WITH wqlist */
143782 { 221, -3 }, /* (280) with ::= WITH RECURSIVE wqlist */
143783 { 198, -6 }, /* (281) wqlist ::= nm eidlist_opt AS LP select RP */
143784 { 198, -8 }, /* (282) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
143785 { 145, -1 }, /* (283) input ::= cmdlist */
143786 { 146, -2 }, /* (284) cmdlist ::= cmdlist ecmd */
143787 { 146, -1 }, /* (285) cmdlist ::= ecmd */
143788 { 147, -1 }, /* (286) ecmd ::= SEMI */
143789 { 147, -2 }, /* (287) ecmd ::= cmdx SEMI */
143790 { 147, -2 }, /* (288) ecmd ::= explain cmdx */
143791 { 152, 0 }, /* (289) trans_opt ::= */
143792 { 152, -1 }, /* (290) trans_opt ::= TRANSACTION */
143793 { 152, -2 }, /* (291) trans_opt ::= TRANSACTION nm */
143794 { 154, -1 }, /* (292) savepoint_opt ::= SAVEPOINT */
143795 { 154, 0 }, /* (293) savepoint_opt ::= */
143796 { 150, -2 }, /* (294) cmd ::= create_table create_table_args */
143797 { 161, -4 }, /* (295) columnlist ::= columnlist COMMA columnname carglist */
143798 { 161, -2 }, /* (296) columnlist ::= columnname carglist */
143799 { 153, -1 }, /* (297) nm ::= ID|INDEXED */
143800 { 153, -1 }, /* (298) nm ::= STRING */
143801 { 153, -1 }, /* (299) nm ::= JOIN_KW */
143802 { 167, -1 }, /* (300) typetoken ::= typename */
143803 { 168, -1 }, /* (301) typename ::= ID|STRING */
143804 { 169, -1 }, /* (302) signed ::= plus_num */
143805 { 169, -1 }, /* (303) signed ::= minus_num */
143806 { 166, -2 }, /* (304) carglist ::= carglist ccons */
143807 { 166, 0 }, /* (305) carglist ::= */
143808 { 173, -2 }, /* (306) ccons ::= NULL onconf */
143809 { 162, -2 }, /* (307) conslist_opt ::= COMMA conslist */
143810 { 185, -3 }, /* (308) conslist ::= conslist tconscomma tcons */
143811 { 185, -1 }, /* (309) conslist ::= tcons */
143812 { 186, 0 }, /* (310) tconscomma ::= */
143813 { 190, -1 }, /* (311) defer_subclause_opt ::= defer_subclause */
143814 { 192, -1 }, /* (312) resolvetype ::= raisetype */
143815 { 196, -1 }, /* (313) selectnowith ::= oneselect */
143816 { 197, -1 }, /* (314) oneselect ::= values */
143817 { 211, -2 }, /* (315) sclp ::= selcollist COMMA */
143818 { 212, -1 }, /* (316) as ::= ID|STRING */
143819 { 175, -1 }, /* (317) expr ::= term */
143820 { 226, -1 }, /* (318) likeop ::= LIKE_KW|MATCH */
143821 { 210, -1 }, /* (319) exprlist ::= nexprlist */
143822 { 235, -1 }, /* (320) nmnum ::= plus_num */
143823 { 235, -1 }, /* (321) nmnum ::= nm */
143824 { 235, -1 }, /* (322) nmnum ::= ON */
143825 { 235, -1 }, /* (323) nmnum ::= DELETE */
143826 { 235, -1 }, /* (324) nmnum ::= DEFAULT */
143827 { 170, -1 }, /* (325) plus_num ::= INTEGER|FLOAT */
143828 { 240, 0 }, /* (326) foreach_clause ::= */
143829 { 240, -3 }, /* (327) foreach_clause ::= FOR EACH ROW */
143830 { 243, -1 }, /* (328) trnm ::= nm */
143831 { 244, 0 }, /* (329) tridxby ::= */
143832 { 245, -1 }, /* (330) database_kw_opt ::= DATABASE */
143833 { 245, 0 }, /* (331) database_kw_opt ::= */
143834 { 248, 0 }, /* (332) kwcolumn_opt ::= */
143835 { 248, -1 }, /* (333) kwcolumn_opt ::= COLUMNKW */
143836 { 250, -1 }, /* (334) vtabarglist ::= vtabarg */
143837 { 250, -3 }, /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */
143838 { 251, -2 }, /* (336) vtabarg ::= vtabarg vtabargtoken */
143839 { 254, 0 }, /* (337) anylist ::= */
143840 { 254, -4 }, /* (338) anylist ::= anylist LP anylist RP */
143841 { 254, -2 }, /* (339) anylist ::= anylist ANY */
143842 { 221, 0 }, /* (340) with ::= */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143843 };
143844
143845 static void yy_accept(yyParser*); /* Forward Declaration */
143846
143847 /*
@@ -143934,19 +147436,19 @@
143934 break;
143935 case 2: /* cmdx ::= cmd */
143936 { sqlite3FinishCoding(pParse); }
143937 break;
143938 case 3: /* cmd ::= BEGIN transtype trans_opt */
143939 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy502);}
143940 break;
143941 case 4: /* transtype ::= */
143942 {yymsp[1].minor.yy502 = TK_DEFERRED;}
143943 break;
143944 case 5: /* transtype ::= DEFERRED */
143945 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
143946 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
143947 {yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/}
143948 break;
143949 case 8: /* cmd ::= COMMIT|END trans_opt */
143950 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
143951 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
143952 break;
@@ -143965,11 +147467,11 @@
143965 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
143966 }
143967 break;
143968 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
143969 {
143970 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy502,0,0,yymsp[-2].minor.yy502);
143971 }
143972 break;
143973 case 14: /* createkw ::= CREATE */
143974 {disableLookaside(pParse);}
143975 break;
@@ -143979,37 +147481,37 @@
143979 case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
143980 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
143981 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
143982 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
143983 case 92: /* distinct ::= */ yytestcase(yyruleno==92);
143984 case 224: /* collate ::= */ yytestcase(yyruleno==224);
143985 {yymsp[1].minor.yy502 = 0;}
143986 break;
143987 case 16: /* ifnotexists ::= IF NOT EXISTS */
143988 {yymsp[-2].minor.yy502 = 1;}
143989 break;
143990 case 17: /* temp ::= TEMP */
143991 case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
143992 {yymsp[0].minor.yy502 = 1;}
143993 break;
143994 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
143995 {
143996 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy502,0);
143997 }
143998 break;
143999 case 20: /* create_table_args ::= AS select */
144000 {
144001 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy399);
144002 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
144003 }
144004 break;
144005 case 22: /* table_options ::= WITHOUT nm */
144006 {
144007 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
144008 yymsp[-1].minor.yy502 = TF_WithoutRowid | TF_NoVisibleRowid;
144009 }else{
144010 yymsp[-1].minor.yy502 = 0;
144011 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
144012 }
144013 }
144014 break;
144015 case 23: /* columnname ::= nm typetoken */
@@ -144034,30 +147536,30 @@
144034 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
144035 break;
144036 case 28: /* scanpt ::= */
144037 {
144038 assert( yyLookahead!=YYNOCODE );
144039 yymsp[1].minor.yy36 = yyLookaheadToken.z;
144040 }
144041 break;
144042 case 29: /* ccons ::= CONSTRAINT nm */
144043 case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
144044 {pParse->constraintName = yymsp[0].minor.yy0;}
144045 break;
144046 case 30: /* ccons ::= DEFAULT scanpt term scanpt */
144047 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy36,yymsp[0].minor.yy36);}
144048 break;
144049 case 31: /* ccons ::= DEFAULT LP expr RP */
144050 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
144051 break;
144052 case 32: /* ccons ::= DEFAULT PLUS term scanpt */
144053 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);}
144054 break;
144055 case 33: /* ccons ::= DEFAULT MINUS term scanpt */
144056 {
144057 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy182, 0);
144058 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);
144059 }
144060 break;
144061 case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */
144062 {
144063 Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
@@ -144067,612 +147569,595 @@
144067 }
144068 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
144069 }
144070 break;
144071 case 35: /* ccons ::= NOT NULL onconf */
144072 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy502);}
144073 break;
144074 case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
144075 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy502,yymsp[0].minor.yy502,yymsp[-2].minor.yy502);}
144076 break;
144077 case 37: /* ccons ::= UNIQUE onconf */
144078 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy502,0,0,0,0,
144079 SQLITE_IDXTYPE_UNIQUE);}
144080 break;
144081 case 38: /* ccons ::= CHECK LP expr RP */
144082 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy182);}
144083 break;
144084 case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
144085 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy232,yymsp[0].minor.yy502);}
144086 break;
144087 case 40: /* ccons ::= defer_subclause */
144088 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy502);}
144089 break;
144090 case 41: /* ccons ::= COLLATE ID|STRING */
144091 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
144092 break;
144093 case 44: /* refargs ::= */
144094 { yymsp[1].minor.yy502 = OE_None*0x0101; /* EV: R-19803-45884 */}
144095 break;
144096 case 45: /* refargs ::= refargs refarg */
144097 { yymsp[-1].minor.yy502 = (yymsp[-1].minor.yy502 & ~yymsp[0].minor.yy107.mask) | yymsp[0].minor.yy107.value; }
144098 break;
144099 case 46: /* refarg ::= MATCH nm */
144100 { yymsp[-1].minor.yy107.value = 0; yymsp[-1].minor.yy107.mask = 0x000000; }
144101 break;
144102 case 47: /* refarg ::= ON INSERT refact */
144103 { yymsp[-2].minor.yy107.value = 0; yymsp[-2].minor.yy107.mask = 0x000000; }
144104 break;
144105 case 48: /* refarg ::= ON DELETE refact */
144106 { yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502; yymsp[-2].minor.yy107.mask = 0x0000ff; }
144107 break;
144108 case 49: /* refarg ::= ON UPDATE refact */
144109 { yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502<<8; yymsp[-2].minor.yy107.mask = 0x00ff00; }
144110 break;
144111 case 50: /* refact ::= SET NULL */
144112 { yymsp[-1].minor.yy502 = OE_SetNull; /* EV: R-33326-45252 */}
144113 break;
144114 case 51: /* refact ::= SET DEFAULT */
144115 { yymsp[-1].minor.yy502 = OE_SetDflt; /* EV: R-33326-45252 */}
144116 break;
144117 case 52: /* refact ::= CASCADE */
144118 { yymsp[0].minor.yy502 = OE_Cascade; /* EV: R-33326-45252 */}
144119 break;
144120 case 53: /* refact ::= RESTRICT */
144121 { yymsp[0].minor.yy502 = OE_Restrict; /* EV: R-33326-45252 */}
144122 break;
144123 case 54: /* refact ::= NO ACTION */
144124 { yymsp[-1].minor.yy502 = OE_None; /* EV: R-33326-45252 */}
144125 break;
144126 case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
144127 {yymsp[-2].minor.yy502 = 0;}
144128 break;
144129 case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
144130 case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
144131 case 155: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==155);
144132 {yymsp[-1].minor.yy502 = yymsp[0].minor.yy502;}
144133 break;
144134 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
144135 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
144136 case 196: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==196);
144137 case 199: /* in_op ::= NOT IN */ yytestcase(yyruleno==199);
144138 case 225: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==225);
144139 {yymsp[-1].minor.yy502 = 1;}
144140 break;
144141 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
144142 {yymsp[-1].minor.yy502 = 0;}
144143 break;
144144 case 61: /* tconscomma ::= COMMA */
144145 {pParse->constraintName.n = 0;}
144146 break;
144147 case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
144148 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy232,yymsp[0].minor.yy502,yymsp[-2].minor.yy502,0);}
144149 break;
144150 case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
144151 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy232,yymsp[0].minor.yy502,0,0,0,0,
144152 SQLITE_IDXTYPE_UNIQUE);}
144153 break;
144154 case 65: /* tcons ::= CHECK LP expr RP onconf */
144155 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy182);}
144156 break;
144157 case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
144158 {
144159 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy232, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy502);
144160 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy502);
144161 }
144162 break;
144163 case 68: /* onconf ::= */
144164 case 70: /* orconf ::= */ yytestcase(yyruleno==70);
144165 {yymsp[1].minor.yy502 = OE_Default;}
144166 break;
144167 case 69: /* onconf ::= ON CONFLICT resolvetype */
144168 {yymsp[-2].minor.yy502 = yymsp[0].minor.yy502;}
144169 break;
144170 case 72: /* resolvetype ::= IGNORE */
144171 {yymsp[0].minor.yy502 = OE_Ignore;}
144172 break;
144173 case 73: /* resolvetype ::= REPLACE */
144174 case 156: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==156);
144175 {yymsp[0].minor.yy502 = OE_Replace;}
144176 break;
144177 case 74: /* cmd ::= DROP TABLE ifexists fullname */
144178 {
144179 sqlite3DropTable(pParse, yymsp[0].minor.yy427, 0, yymsp[-1].minor.yy502);
144180 }
144181 break;
144182 case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
144183 {
144184 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[0].minor.yy399, yymsp[-7].minor.yy502, yymsp[-5].minor.yy502);
144185 }
144186 break;
144187 case 78: /* cmd ::= DROP VIEW ifexists fullname */
144188 {
144189 sqlite3DropTable(pParse, yymsp[0].minor.yy427, 1, yymsp[-1].minor.yy502);
144190 }
144191 break;
144192 case 79: /* cmd ::= select */
144193 {
144194 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
144195 sqlite3Select(pParse, yymsp[0].minor.yy399, &dest);
144196 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
144197 }
144198 break;
144199 case 80: /* select ::= WITH wqlist selectnowith */
144200 {
144201 Select *p = yymsp[0].minor.yy399;
144202 if( p ){
144203 p->pWith = yymsp[-1].minor.yy91;
144204 parserDoubleLinkSelect(pParse, p);
144205 }else{
144206 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
144207 }
144208 yymsp[-2].minor.yy399 = p;
144209 }
144210 break;
144211 case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */
144212 {
144213 Select *p = yymsp[0].minor.yy399;
144214 if( p ){
144215 p->pWith = yymsp[-1].minor.yy91;
144216 parserDoubleLinkSelect(pParse, p);
144217 }else{
144218 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
144219 }
144220 yymsp[-3].minor.yy399 = p;
144221 }
144222 break;
144223 case 82: /* select ::= selectnowith */
144224 {
144225 Select *p = yymsp[0].minor.yy399;
144226 if( p ){
144227 parserDoubleLinkSelect(pParse, p);
144228 }
144229 yymsp[0].minor.yy399 = p; /*A-overwrites-X*/
144230 }
144231 break;
144232 case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */
144233 {
144234 Select *pRhs = yymsp[0].minor.yy399;
144235 Select *pLhs = yymsp[-2].minor.yy399;
144236 if( pRhs && pRhs->pPrior ){
144237 SrcList *pFrom;
144238 Token x;
144239 x.n = 0;
144240 parserDoubleLinkSelect(pParse, pRhs);
144241 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
144242 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
144243 }
144244 if( pRhs ){
144245 pRhs->op = (u8)yymsp[-1].minor.yy502;
144246 pRhs->pPrior = pLhs;
144247 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
144248 pRhs->selFlags &= ~SF_MultiValue;
144249 if( yymsp[-1].minor.yy502!=TK_ALL ) pParse->hasCompound = 1;
144250 }else{
144251 sqlite3SelectDelete(pParse->db, pLhs);
144252 }
144253 yymsp[-2].minor.yy399 = pRhs;
144254 }
144255 break;
144256 case 84: /* multiselect_op ::= UNION */
144257 case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
144258 {yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-OP*/}
144259 break;
144260 case 85: /* multiselect_op ::= UNION ALL */
144261 {yymsp[-1].minor.yy502 = TK_ALL;}
144262 break;
144263 case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
144264 {
144265 #if SELECTTRACE_ENABLED
144266 Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
144267 #endif
144268 yymsp[-8].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy232,yymsp[-5].minor.yy427,yymsp[-4].minor.yy182,yymsp[-3].minor.yy232,yymsp[-2].minor.yy182,yymsp[-1].minor.yy232,yymsp[-7].minor.yy502,yymsp[0].minor.yy182);
144269 #if SELECTTRACE_ENABLED
144270 /* Populate the Select.zSelName[] string that is used to help with
144271 ** query planner debugging, to differentiate between multiple Select
144272 ** objects in a complex query.
144273 **
144274 ** If the SELECT keyword is immediately followed by a C-style comment
144275 ** then extract the first few alphanumeric characters from within that
144276 ** comment to be the zSelName value. Otherwise, the label is #N where
144277 ** is an integer that is incremented with each SELECT statement seen.
144278 */
144279 if( yymsp[-8].minor.yy399!=0 ){
144280 const char *z = s.z+6;
144281 int i;
144282 sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->zSelName,"#%d",++pParse->nSelect);
144283 while( z[0]==' ' ) z++;
144284 if( z[0]=='/' && z[1]=='*' ){
144285 z += 2;
144286 while( z[0]==' ' ) z++;
144287 for(i=0; sqlite3Isalnum(z[i]); i++){}
144288 sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->zSelName, "%.*s", i, z);
144289 }
144290 }
144291 #endif /* SELECTRACE_ENABLED */
144292 }
144293 break;
144294 case 88: /* values ::= VALUES LP nexprlist RP */
144295 {
144296 yymsp[-3].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values,0);
144297 }
144298 break;
144299 case 89: /* values ::= values COMMA LP exprlist RP */
144300 {
144301 Select *pRight, *pLeft = yymsp[-4].minor.yy399;
144302 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values|SF_MultiValue,0);
144303 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
144304 if( pRight ){
144305 pRight->op = TK_ALL;
144306 pRight->pPrior = pLeft;
144307 yymsp[-4].minor.yy399 = pRight;
144308 }else{
144309 yymsp[-4].minor.yy399 = pLeft;
144310 }
144311 }
144312 break;
144313 case 90: /* distinct ::= DISTINCT */
144314 {yymsp[0].minor.yy502 = SF_Distinct;}
144315 break;
144316 case 91: /* distinct ::= ALL */
144317 {yymsp[0].minor.yy502 = SF_All;}
144318 break;
144319 case 93: /* sclp ::= */
144320 case 126: /* orderby_opt ::= */ yytestcase(yyruleno==126);
144321 case 133: /* groupby_opt ::= */ yytestcase(yyruleno==133);
144322 case 212: /* exprlist ::= */ yytestcase(yyruleno==212);
144323 case 215: /* paren_exprlist ::= */ yytestcase(yyruleno==215);
144324 case 220: /* eidlist_opt ::= */ yytestcase(yyruleno==220);
144325 {yymsp[1].minor.yy232 = 0;}
144326 break;
144327 case 94: /* selcollist ::= sclp scanpt expr scanpt as */
144328 {
144329 yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
144330 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[0].minor.yy0, 1);
144331 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy232,yymsp[-3].minor.yy36,yymsp[-1].minor.yy36);
144332 }
144333 break;
144334 case 95: /* selcollist ::= sclp scanpt STAR */
144335 {
144336 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
144337 yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy232, p);
144338 }
144339 break;
144340 case 96: /* selcollist ::= sclp scanpt nm DOT STAR */
144341 {
144342 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
144343 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
144344 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
144345 yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, pDot);
144346 }
144347 break;
144348 case 97: /* as ::= AS nm */
144349 case 108: /* dbnm ::= DOT nm */ yytestcase(yyruleno==108);
144350 case 234: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==234);
144351 case 235: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==235);
144352 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
144353 break;
144354 case 99: /* from ::= */
144355 {yymsp[1].minor.yy427 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy427));}
144356 break;
144357 case 100: /* from ::= FROM seltablist */
144358 {
144359 yymsp[-1].minor.yy427 = yymsp[0].minor.yy427;
144360 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy427);
144361 }
144362 break;
144363 case 101: /* stl_prefix ::= seltablist joinop */
144364 {
144365 if( ALWAYS(yymsp[-1].minor.yy427 && yymsp[-1].minor.yy427->nSrc>0) ) yymsp[-1].minor.yy427->a[yymsp[-1].minor.yy427->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy502;
144366 }
144367 break;
144368 case 102: /* stl_prefix ::= */
144369 {yymsp[1].minor.yy427 = 0;}
144370 break;
144371 case 103: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
144372 {
144373 yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
144374 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy427, &yymsp[-2].minor.yy0);
144375 }
144376 break;
144377 case 104: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
144378 {
144379 yymsp[-8].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy427,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
144380 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy427, yymsp[-4].minor.yy232);
144381 }
144382 break;
144383 case 105: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
144384 {
144385 yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy399,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
144386 }
144387 break;
144388 case 106: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
144389 {
144390 if( yymsp[-6].minor.yy427==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy182==0 && yymsp[0].minor.yy510==0 ){
144391 yymsp[-6].minor.yy427 = yymsp[-4].minor.yy427;
144392 }else if( yymsp[-4].minor.yy427->nSrc==1 ){
144393 yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
144394 if( yymsp[-6].minor.yy427 ){
144395 struct SrcList_item *pNew = &yymsp[-6].minor.yy427->a[yymsp[-6].minor.yy427->nSrc-1];
144396 struct SrcList_item *pOld = yymsp[-4].minor.yy427->a;
144397 pNew->zName = pOld->zName;
144398 pNew->zDatabase = pOld->zDatabase;
144399 pNew->pSelect = pOld->pSelect;
144400 pOld->zName = pOld->zDatabase = 0;
144401 pOld->pSelect = 0;
144402 }
144403 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy427);
144404 }else{
144405 Select *pSubquery;
144406 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy427);
144407 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy427,0,0,0,0,SF_NestedFrom,0);
144408 yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
144409 }
144410 }
144411 break;
144412 case 107: /* dbnm ::= */
144413 case 121: /* indexed_opt ::= */ yytestcase(yyruleno==121);
144414 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
144415 break;
144416 case 109: /* fullname ::= nm */
144417 case 111: /* xfullname ::= nm */ yytestcase(yyruleno==111);
144418 {yymsp[0].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
144419 break;
144420 case 110: /* fullname ::= nm DOT nm */
144421 case 112: /* xfullname ::= nm DOT nm */ yytestcase(yyruleno==112);
144422 {yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
144423 break;
144424 case 113: /* xfullname ::= nm DOT nm AS nm */
144425 {
144426 yymsp[-4].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
144427 if( yymsp[-4].minor.yy427 ) yymsp[-4].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
144428 }
144429 break;
144430 case 114: /* xfullname ::= nm AS nm */
144431 {
144432 yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
144433 if( yymsp[-2].minor.yy427 ) yymsp[-2].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
144434 }
144435 break;
144436 case 115: /* joinop ::= COMMA|JOIN */
144437 { yymsp[0].minor.yy502 = JT_INNER; }
144438 break;
144439 case 116: /* joinop ::= JOIN_KW JOIN */
144440 {yymsp[-1].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
144441 break;
144442 case 117: /* joinop ::= JOIN_KW nm JOIN */
144443 {yymsp[-2].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
144444 break;
144445 case 118: /* joinop ::= JOIN_KW nm nm JOIN */
144446 {yymsp[-3].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
144447 break;
144448 case 119: /* on_opt ::= ON expr */
144449 case 136: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==136);
144450 case 143: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==143);
144451 case 208: /* case_else ::= ELSE expr */ yytestcase(yyruleno==208);
144452 {yymsp[-1].minor.yy182 = yymsp[0].minor.yy182;}
144453 break;
144454 case 120: /* on_opt ::= */
144455 case 135: /* having_opt ::= */ yytestcase(yyruleno==135);
144456 case 137: /* limit_opt ::= */ yytestcase(yyruleno==137);
144457 case 142: /* where_opt ::= */ yytestcase(yyruleno==142);
144458 case 209: /* case_else ::= */ yytestcase(yyruleno==209);
144459 case 211: /* case_operand ::= */ yytestcase(yyruleno==211);
144460 {yymsp[1].minor.yy182 = 0;}
144461 break;
144462 case 122: /* indexed_opt ::= INDEXED BY nm */
144463 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
144464 break;
144465 case 123: /* indexed_opt ::= NOT INDEXED */
144466 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
144467 break;
144468 case 124: /* using_opt ::= USING LP idlist RP */
144469 {yymsp[-3].minor.yy510 = yymsp[-1].minor.yy510;}
144470 break;
144471 case 125: /* using_opt ::= */
144472 case 157: /* idlist_opt ::= */ yytestcase(yyruleno==157);
144473 {yymsp[1].minor.yy510 = 0;}
144474 break;
144475 case 127: /* orderby_opt ::= ORDER BY sortlist */
144476 case 134: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==134);
144477 {yymsp[-2].minor.yy232 = yymsp[0].minor.yy232;}
144478 break;
144479 case 128: /* sortlist ::= sortlist COMMA expr sortorder */
144480 {
144481 yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232,yymsp[-1].minor.yy182);
144482 sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy232,yymsp[0].minor.yy502);
144483 }
144484 break;
144485 case 129: /* sortlist ::= expr sortorder */
144486 {
144487 yymsp[-1].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy182); /*A-overwrites-Y*/
144488 sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy232,yymsp[0].minor.yy502);
144489 }
144490 break;
144491 case 130: /* sortorder ::= ASC */
144492 {yymsp[0].minor.yy502 = SQLITE_SO_ASC;}
144493 break;
144494 case 131: /* sortorder ::= DESC */
144495 {yymsp[0].minor.yy502 = SQLITE_SO_DESC;}
144496 break;
144497 case 132: /* sortorder ::= */
144498 {yymsp[1].minor.yy502 = SQLITE_SO_UNDEFINED;}
144499 break;
144500 case 138: /* limit_opt ::= LIMIT expr */
144501 {yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,0);}
144502 break;
144503 case 139: /* limit_opt ::= LIMIT expr OFFSET expr */
144504 {yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
144505 break;
144506 case 140: /* limit_opt ::= LIMIT expr COMMA expr */
144507 {yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,yymsp[-2].minor.yy182);}
144508 break;
144509 case 141: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
144510 {
144511 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy427, &yymsp[-1].minor.yy0);
144512 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy427,yymsp[0].minor.yy182,0,0);
144513 }
144514 break;
144515 case 144: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
144516 {
144517 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy427, &yymsp[-3].minor.yy0);
144518 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy232,"set list");
144519 sqlite3Update(pParse,yymsp[-4].minor.yy427,yymsp[-1].minor.yy232,yymsp[0].minor.yy182,yymsp[-5].minor.yy502,0,0,0);
144520 }
144521 break;
144522 case 145: /* setlist ::= setlist COMMA nm EQ expr */
144523 {
144524 yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
144525 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, 1);
144526 }
144527 break;
144528 case 146: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
144529 {
144530 yymsp[-6].minor.yy232 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy232, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
144531 }
144532 break;
144533 case 147: /* setlist ::= nm EQ expr */
144534 {
144535 yylhsminor.yy232 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy182);
144536 sqlite3ExprListSetName(pParse, yylhsminor.yy232, &yymsp[-2].minor.yy0, 1);
144537 }
144538 yymsp[-2].minor.yy232 = yylhsminor.yy232;
144539 break;
144540 case 148: /* setlist ::= LP idlist RP EQ expr */
144541 {
144542 yymsp[-4].minor.yy232 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
144543 }
144544 break;
144545 case 149: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
144546 {
144547 sqlite3Insert(pParse, yymsp[-3].minor.yy427, yymsp[-1].minor.yy399, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, yymsp[0].minor.yy198);
144548 }
144549 break;
144550 case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
144551 {
144552 sqlite3Insert(pParse, yymsp[-3].minor.yy427, 0, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, 0);
144553 }
144554 break;
144555 case 151: /* upsert ::= */
144556 { yymsp[1].minor.yy198 = 0; }
144557 break;
144558 case 152: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
144559 { yymsp[-10].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy232,yymsp[-5].minor.yy182,yymsp[-1].minor.yy232,yymsp[0].minor.yy182);}
144560 break;
144561 case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
144562 { yymsp[-7].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy232,yymsp[-2].minor.yy182,0,0); }
144563 break;
144564 case 154: /* upsert ::= ON CONFLICT DO NOTHING */
144565 { yymsp[-3].minor.yy198 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
144566 break;
144567 case 158: /* idlist_opt ::= LP idlist RP */
144568 {yymsp[-2].minor.yy510 = yymsp[-1].minor.yy510;}
144569 break;
144570 case 159: /* idlist ::= idlist COMMA nm */
144571 {yymsp[-2].minor.yy510 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy510,&yymsp[0].minor.yy0);}
144572 break;
144573 case 160: /* idlist ::= nm */
144574 {yymsp[0].minor.yy510 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
144575 break;
144576 case 161: /* expr ::= LP expr RP */
144577 {yymsp[-2].minor.yy182 = yymsp[-1].minor.yy182;}
144578 break;
144579 case 162: /* expr ::= ID|INDEXED */
144580 case 163: /* expr ::= JOIN_KW */ yytestcase(yyruleno==163);
144581 {yymsp[0].minor.yy182=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
144582 break;
144583 case 164: /* expr ::= nm DOT nm */
144584 {
144585 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
144586 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
144587 yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
144588 }
144589 yymsp[-2].minor.yy182 = yylhsminor.yy182;
144590 break;
144591 case 165: /* expr ::= nm DOT nm DOT nm */
144592 {
144593 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
144594 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
144595 Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
144596 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
144597 yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
144598 }
144599 yymsp[-4].minor.yy182 = yylhsminor.yy182;
144600 break;
144601 case 166: /* term ::= NULL|FLOAT|BLOB */
144602 case 167: /* term ::= STRING */ yytestcase(yyruleno==167);
144603 {yymsp[0].minor.yy182=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
144604 break;
144605 case 168: /* term ::= INTEGER */
144606 {
144607 yylhsminor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
144608 }
144609 yymsp[0].minor.yy182 = yylhsminor.yy182;
144610 break;
144611 case 169: /* expr ::= VARIABLE */
144612 {
144613 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
144614 u32 n = yymsp[0].minor.yy0.n;
144615 yymsp[0].minor.yy182 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
144616 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy182, n);
144617 }else{
144618 /* When doing a nested parse, one can include terms in an expression
144619 ** that look like this: #1 #2 ... These terms refer to registers
144620 ** in the virtual machine. #N is the N-th register. */
144621 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
144622 assert( t.n>=2 );
144623 if( pParse->nested==0 ){
144624 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
144625 yymsp[0].minor.yy182 = 0;
144626 }else{
144627 yymsp[0].minor.yy182 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
144628 if( yymsp[0].minor.yy182 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy182->iTable);
144629 }
144630 }
144631 }
144632 break;
144633 case 170: /* expr ::= expr COLLATE ID|STRING */
144634 {
144635 yymsp[-2].minor.yy182 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy182, &yymsp[0].minor.yy0, 1);
144636 }
144637 break;
144638 case 171: /* expr ::= CAST LP expr AS typetoken RP */
144639 {
144640 yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
144641 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy182, yymsp[-3].minor.yy182, 0);
144642 }
144643 break;
144644 case 172: /* expr ::= ID|INDEXED LP distinct exprlist RP */
144645 {
144646 if( yymsp[-1].minor.yy232 && yymsp[-1].minor.yy232->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
144647 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
144648 }
144649 yylhsminor.yy182 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy232, &yymsp[-4].minor.yy0);
144650 if( yymsp[-2].minor.yy502==SF_Distinct && yylhsminor.yy182 ){
144651 yylhsminor.yy182->flags |= EP_Distinct;
144652 }
144653 }
144654 yymsp[-4].minor.yy182 = yylhsminor.yy182;
144655 break;
144656 case 173: /* expr ::= ID|INDEXED LP STAR RP */
144657 {
144658 yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
144659 }
144660 yymsp[-3].minor.yy182 = yylhsminor.yy182;
 
 
144661 break;
144662 case 174: /* term ::= CTIME_KW */
144663 {
144664 yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
144665 }
144666 yymsp[0].minor.yy182 = yylhsminor.yy182;
144667 break;
144668 case 175: /* expr ::= LP nexprlist COMMA expr RP */
144669 {
144670 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy232, yymsp[-1].minor.yy182);
144671 yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
144672 if( yymsp[-4].minor.yy182 ){
144673 yymsp[-4].minor.yy182->x.pList = pList;
144674 }else{
144675 sqlite3ExprListDelete(pParse->db, pList);
144676 }
144677 }
144678 break;
@@ -144682,99 +148167,99 @@
144682 case 179: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==179);
144683 case 180: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==180);
144684 case 181: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==181);
144685 case 182: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==182);
144686 case 183: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==183);
144687 {yymsp[-2].minor.yy182=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
144688 break;
144689 case 184: /* likeop ::= NOT LIKE_KW|MATCH */
144690 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
144691 break;
144692 case 185: /* expr ::= expr likeop expr */
144693 {
144694 ExprList *pList;
144695 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
144696 yymsp[-1].minor.yy0.n &= 0x7fffffff;
144697 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy182);
144698 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy182);
144699 yymsp[-2].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
144700 if( bNot ) yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy182, 0);
144701 if( yymsp[-2].minor.yy182 ) yymsp[-2].minor.yy182->flags |= EP_InfixFunc;
144702 }
144703 break;
144704 case 186: /* expr ::= expr likeop expr ESCAPE expr */
144705 {
144706 ExprList *pList;
144707 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
144708 yymsp[-3].minor.yy0.n &= 0x7fffffff;
144709 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
144710 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy182);
144711 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
144712 yymsp[-4].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
144713 if( bNot ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
144714 if( yymsp[-4].minor.yy182 ) yymsp[-4].minor.yy182->flags |= EP_InfixFunc;
144715 }
144716 break;
144717 case 187: /* expr ::= expr ISNULL|NOTNULL */
144718 {yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy182,0);}
144719 break;
144720 case 188: /* expr ::= expr NOT NULL */
144721 {yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy182,0);}
144722 break;
144723 case 189: /* expr ::= expr IS expr */
144724 {
144725 yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);
144726 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-2].minor.yy182, TK_ISNULL);
144727 }
144728 break;
144729 case 190: /* expr ::= expr IS NOT expr */
144730 {
144731 yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy182,yymsp[0].minor.yy182);
144732 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-3].minor.yy182, TK_NOTNULL);
144733 }
144734 break;
144735 case 191: /* expr ::= NOT expr */
144736 case 192: /* expr ::= BITNOT expr */ yytestcase(yyruleno==192);
144737 {yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy182, 0);/*A-overwrites-B*/}
144738 break;
144739 case 193: /* expr ::= MINUS expr */
144740 {yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy182, 0);}
144741 break;
144742 case 194: /* expr ::= PLUS expr */
144743 {yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy182, 0);}
144744 break;
144745 case 195: /* between_op ::= BETWEEN */
144746 case 198: /* in_op ::= IN */ yytestcase(yyruleno==198);
144747 {yymsp[0].minor.yy502 = 0;}
144748 break;
144749 case 197: /* expr ::= expr between_op expr AND expr */
144750 {
144751 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
144752 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
144753 yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy182, 0);
144754 if( yymsp[-4].minor.yy182 ){
144755 yymsp[-4].minor.yy182->x.pList = pList;
144756 }else{
144757 sqlite3ExprListDelete(pParse->db, pList);
144758 }
144759 if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
144760 }
144761 break;
144762 case 200: /* expr ::= expr in_op LP exprlist RP */
144763 {
144764 if( yymsp[-1].minor.yy232==0 ){
144765 /* Expressions of the form
144766 **
144767 ** expr1 IN ()
144768 ** expr1 NOT IN ()
144769 **
144770 ** simplify to constants 0 (false) and 1 (true), respectively,
144771 ** regardless of the value of expr1.
144772 */
144773 sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy182);
144774 yymsp[-4].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy502],1);
144775 }else if( yymsp[-1].minor.yy232->nExpr==1 ){
144776 /* Expressions of the form:
144777 **
144778 ** expr1 IN (?1)
144779 ** expr1 NOT IN (?2)
144780 **
@@ -144787,396 +148272,506 @@
144787 ** But, the RHS of the == or <> is marked with the EP_Generic flag
144788 ** so that it may not contribute to the computation of comparison
144789 ** affinity or the collating sequence to use for comparison. Otherwise,
144790 ** the semantics would be subtly different from IN or NOT IN.
144791 */
144792 Expr *pRHS = yymsp[-1].minor.yy232->a[0].pExpr;
144793 yymsp[-1].minor.yy232->a[0].pExpr = 0;
144794 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
144795 /* pRHS cannot be NULL because a malloc error would have been detected
144796 ** before now and control would have never reached this point */
144797 if( ALWAYS(pRHS) ){
144798 pRHS->flags &= ~EP_Collate;
144799 pRHS->flags |= EP_Generic;
144800 }
144801 yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_NE : TK_EQ, yymsp[-4].minor.yy182, pRHS);
144802 }else{
144803 yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
144804 if( yymsp[-4].minor.yy182 ){
144805 yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy232;
144806 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
144807 }else{
144808 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
144809 }
144810 if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
144811 }
144812 }
144813 break;
144814 case 201: /* expr ::= LP select RP */
144815 {
144816 yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
144817 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy182, yymsp[-1].minor.yy399);
144818 }
144819 break;
144820 case 202: /* expr ::= expr in_op LP select RP */
144821 {
144822 yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
144823 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, yymsp[-1].minor.yy399);
144824 if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
144825 }
144826 break;
144827 case 203: /* expr ::= expr in_op nm dbnm paren_exprlist */
144828 {
144829 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
144830 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
144831 if( yymsp[0].minor.yy232 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy232);
144832 yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
144833 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, pSelect);
144834 if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
144835 }
144836 break;
144837 case 204: /* expr ::= EXISTS LP select RP */
144838 {
144839 Expr *p;
144840 p = yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
144841 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy399);
144842 }
144843 break;
144844 case 205: /* expr ::= CASE case_operand case_exprlist case_else END */
144845 {
144846 yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy182, 0);
144847 if( yymsp[-4].minor.yy182 ){
144848 yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy182 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[-1].minor.yy182) : yymsp[-2].minor.yy232;
144849 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
144850 }else{
144851 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy232);
144852 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy182);
144853 }
144854 }
144855 break;
144856 case 206: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
144857 {
144858 yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
144859 yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
144860 }
144861 break;
144862 case 207: /* case_exprlist ::= WHEN expr THEN expr */
144863 {
144864 yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
144865 yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232, yymsp[0].minor.yy182);
144866 }
144867 break;
144868 case 210: /* case_operand ::= expr */
144869 {yymsp[0].minor.yy182 = yymsp[0].minor.yy182; /*A-overwrites-X*/}
144870 break;
144871 case 213: /* nexprlist ::= nexprlist COMMA expr */
144872 {yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[0].minor.yy182);}
144873 break;
144874 case 214: /* nexprlist ::= expr */
144875 {yymsp[0].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy182); /*A-overwrites-Y*/}
144876 break;
144877 case 216: /* paren_exprlist ::= LP exprlist RP */
144878 case 221: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==221);
144879 {yymsp[-2].minor.yy232 = yymsp[-1].minor.yy232;}
144880 break;
144881 case 217: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
144882 {
144883 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
144884 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy232, yymsp[-10].minor.yy502,
144885 &yymsp[-11].minor.yy0, yymsp[0].minor.yy182, SQLITE_SO_ASC, yymsp[-8].minor.yy502, SQLITE_IDXTYPE_APPDEF);
144886 }
144887 break;
144888 case 218: /* uniqueflag ::= UNIQUE */
144889 case 258: /* raisetype ::= ABORT */ yytestcase(yyruleno==258);
144890 {yymsp[0].minor.yy502 = OE_Abort;}
144891 break;
144892 case 219: /* uniqueflag ::= */
144893 {yymsp[1].minor.yy502 = OE_None;}
144894 break;
144895 case 222: /* eidlist ::= eidlist COMMA nm collate sortorder */
144896 {
144897 yymsp[-4].minor.yy232 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502);
144898 }
144899 break;
144900 case 223: /* eidlist ::= nm collate sortorder */
144901 {
144902 yymsp[-2].minor.yy232 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); /*A-overwrites-Y*/
144903 }
144904 break;
144905 case 226: /* cmd ::= DROP INDEX ifexists fullname */
144906 {sqlite3DropIndex(pParse, yymsp[0].minor.yy427, yymsp[-1].minor.yy502);}
144907 break;
144908 case 227: /* cmd ::= VACUUM */
144909 {sqlite3Vacuum(pParse,0);}
144910 break;
144911 case 228: /* cmd ::= VACUUM nm */
144912 {sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
144913 break;
144914 case 229: /* cmd ::= PRAGMA nm dbnm */
144915 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
144916 break;
144917 case 230: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
144918 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
144919 break;
144920 case 231: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
144921 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
144922 break;
144923 case 232: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
144924 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
144925 break;
144926 case 233: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
144927 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
144928 break;
144929 case 236: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
144930 {
144931 Token all;
144932 all.z = yymsp[-3].minor.yy0.z;
144933 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
144934 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy47, &all);
144935 }
144936 break;
144937 case 237: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
144938 {
144939 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy502, yymsp[-4].minor.yy300.a, yymsp[-4].minor.yy300.b, yymsp[-2].minor.yy427, yymsp[0].minor.yy182, yymsp[-10].minor.yy502, yymsp[-8].minor.yy502);
144940 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
144941 }
144942 break;
144943 case 238: /* trigger_time ::= BEFORE|AFTER */
144944 { yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/ }
144945 break;
144946 case 239: /* trigger_time ::= INSTEAD OF */
144947 { yymsp[-1].minor.yy502 = TK_INSTEAD;}
144948 break;
144949 case 240: /* trigger_time ::= */
144950 { yymsp[1].minor.yy502 = TK_BEFORE; }
144951 break;
144952 case 241: /* trigger_event ::= DELETE|INSERT */
144953 case 242: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==242);
144954 {yymsp[0].minor.yy300.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy300.b = 0;}
144955 break;
144956 case 243: /* trigger_event ::= UPDATE OF idlist */
144957 {yymsp[-2].minor.yy300.a = TK_UPDATE; yymsp[-2].minor.yy300.b = yymsp[0].minor.yy510;}
144958 break;
144959 case 244: /* when_clause ::= */
144960 case 263: /* key_opt ::= */ yytestcase(yyruleno==263);
144961 { yymsp[1].minor.yy182 = 0; }
144962 break;
144963 case 245: /* when_clause ::= WHEN expr */
144964 case 264: /* key_opt ::= KEY expr */ yytestcase(yyruleno==264);
144965 { yymsp[-1].minor.yy182 = yymsp[0].minor.yy182; }
144966 break;
144967 case 246: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
144968 {
144969 assert( yymsp[-2].minor.yy47!=0 );
144970 yymsp[-2].minor.yy47->pLast->pNext = yymsp[-1].minor.yy47;
144971 yymsp[-2].minor.yy47->pLast = yymsp[-1].minor.yy47;
144972 }
144973 break;
144974 case 247: /* trigger_cmd_list ::= trigger_cmd SEMI */
144975 {
144976 assert( yymsp[-1].minor.yy47!=0 );
144977 yymsp[-1].minor.yy47->pLast = yymsp[-1].minor.yy47;
144978 }
144979 break;
144980 case 248: /* trnm ::= nm DOT nm */
 
144981 {
144982 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
144983 sqlite3ErrorMsg(pParse,
144984 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
144985 "statements within triggers");
144986 }
144987 break;
144988 case 249: /* tridxby ::= INDEXED BY nm */
144989 {
144990 sqlite3ErrorMsg(pParse,
144991 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
144992 "within triggers");
144993 }
144994 break;
144995 case 250: /* tridxby ::= NOT INDEXED */
144996 {
144997 sqlite3ErrorMsg(pParse,
144998 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
144999 "within triggers");
145000 }
145001 break;
145002 case 251: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
145003 {yylhsminor.yy47 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy182, yymsp[-6].minor.yy502, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy36);}
145004 yymsp[-7].minor.yy47 = yylhsminor.yy47;
145005 break;
145006 case 252: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
145007 {
145008 yylhsminor.yy47 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy510,yymsp[-2].minor.yy399,yymsp[-6].minor.yy502,yymsp[-1].minor.yy198,yymsp[-7].minor.yy36,yymsp[0].minor.yy36);/*yylhsminor.yy47-overwrites-yymsp[-6].minor.yy502*/
145009 }
145010 yymsp[-7].minor.yy47 = yylhsminor.yy47;
145011 break;
145012 case 253: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
145013 {yylhsminor.yy47 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy182, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy36);}
145014 yymsp[-5].minor.yy47 = yylhsminor.yy47;
145015 break;
145016 case 254: /* trigger_cmd ::= scanpt select scanpt */
145017 {yylhsminor.yy47 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy399, yymsp[-2].minor.yy36, yymsp[0].minor.yy36); /*yylhsminor.yy47-overwrites-yymsp[-1].minor.yy399*/}
145018 yymsp[-2].minor.yy47 = yylhsminor.yy47;
145019 break;
145020 case 255: /* expr ::= RAISE LP IGNORE RP */
145021 {
145022 yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
145023 if( yymsp[-3].minor.yy182 ){
145024 yymsp[-3].minor.yy182->affinity = OE_Ignore;
145025 }
145026 }
145027 break;
145028 case 256: /* expr ::= RAISE LP raisetype COMMA nm RP */
145029 {
145030 yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
145031 if( yymsp[-5].minor.yy182 ) {
145032 yymsp[-5].minor.yy182->affinity = (char)yymsp[-3].minor.yy502;
145033 }
145034 }
145035 break;
145036 case 257: /* raisetype ::= ROLLBACK */
145037 {yymsp[0].minor.yy502 = OE_Rollback;}
145038 break;
145039 case 259: /* raisetype ::= FAIL */
145040 {yymsp[0].minor.yy502 = OE_Fail;}
145041 break;
145042 case 260: /* cmd ::= DROP TRIGGER ifexists fullname */
145043 {
145044 sqlite3DropTrigger(pParse,yymsp[0].minor.yy427,yymsp[-1].minor.yy502);
145045 }
145046 break;
145047 case 261: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
145048 {
145049 sqlite3Attach(pParse, yymsp[-3].minor.yy182, yymsp[-1].minor.yy182, yymsp[0].minor.yy182);
145050 }
145051 break;
145052 case 262: /* cmd ::= DETACH database_kw_opt expr */
145053 {
145054 sqlite3Detach(pParse, yymsp[0].minor.yy182);
145055 }
145056 break;
145057 case 265: /* cmd ::= REINDEX */
145058 {sqlite3Reindex(pParse, 0, 0);}
145059 break;
145060 case 266: /* cmd ::= REINDEX nm dbnm */
145061 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
145062 break;
145063 case 267: /* cmd ::= ANALYZE */
145064 {sqlite3Analyze(pParse, 0, 0);}
145065 break;
145066 case 268: /* cmd ::= ANALYZE nm dbnm */
145067 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
145068 break;
145069 case 269: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
145070 {
145071 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy427,&yymsp[0].minor.yy0);
145072 }
145073 break;
145074 case 270: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
145075 {
145076 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
145077 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
145078 }
145079 break;
145080 case 271: /* add_column_fullname ::= fullname */
145081 {
145082 disableLookaside(pParse);
145083 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy427);
145084 }
145085 break;
145086 case 272: /* cmd ::= create_vtab */
145087 {sqlite3VtabFinishParse(pParse,0);}
145088 break;
145089 case 273: /* cmd ::= create_vtab LP vtabarglist RP */
145090 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
145091 break;
145092 case 274: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
145093 {
145094 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy502);
145095 }
145096 break;
145097 case 275: /* vtabarg ::= */
145098 {sqlite3VtabArgInit(pParse);}
145099 break;
145100 case 276: /* vtabargtoken ::= ANY */
145101 case 277: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==277);
145102 case 278: /* lp ::= LP */ yytestcase(yyruleno==278);
145103 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
145104 break;
145105 case 279: /* with ::= WITH wqlist */
145106 case 280: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==280);
145107 { sqlite3WithPush(pParse, yymsp[0].minor.yy91, 1); }
145108 break;
145109 case 281: /* wqlist ::= nm eidlist_opt AS LP select RP */
145110 {
145111 yymsp[-5].minor.yy91 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399); /*A-overwrites-X*/
145112 }
145113 break;
145114 case 282: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
145115 {
145116 yymsp[-7].minor.yy91 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy91, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399);
145117 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145118 break;
145119 default:
145120 /* (283) input ::= cmdlist */ yytestcase(yyruleno==283);
145121 /* (284) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==284);
145122 /* (285) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=285);
145123 /* (286) ecmd ::= SEMI */ yytestcase(yyruleno==286);
145124 /* (287) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==287);
145125 /* (288) ecmd ::= explain cmdx */ yytestcase(yyruleno==288);
145126 /* (289) trans_opt ::= */ yytestcase(yyruleno==289);
145127 /* (290) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==290);
145128 /* (291) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==291);
145129 /* (292) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==292);
145130 /* (293) savepoint_opt ::= */ yytestcase(yyruleno==293);
145131 /* (294) cmd ::= create_table create_table_args */ yytestcase(yyruleno==294);
145132 /* (295) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==295);
145133 /* (296) columnlist ::= columnname carglist */ yytestcase(yyruleno==296);
145134 /* (297) nm ::= ID|INDEXED */ yytestcase(yyruleno==297);
145135 /* (298) nm ::= STRING */ yytestcase(yyruleno==298);
145136 /* (299) nm ::= JOIN_KW */ yytestcase(yyruleno==299);
145137 /* (300) typetoken ::= typename */ yytestcase(yyruleno==300);
145138 /* (301) typename ::= ID|STRING */ yytestcase(yyruleno==301);
145139 /* (302) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=302);
145140 /* (303) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=303);
145141 /* (304) carglist ::= carglist ccons */ yytestcase(yyruleno==304);
145142 /* (305) carglist ::= */ yytestcase(yyruleno==305);
145143 /* (306) ccons ::= NULL onconf */ yytestcase(yyruleno==306);
145144 /* (307) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==307);
145145 /* (308) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==308);
145146 /* (309) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=309);
145147 /* (310) tconscomma ::= */ yytestcase(yyruleno==310);
145148 /* (311) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=311);
145149 /* (312) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=312);
145150 /* (313) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=313);
145151 /* (314) oneselect ::= values */ yytestcase(yyruleno==314);
145152 /* (315) sclp ::= selcollist COMMA */ yytestcase(yyruleno==315);
145153 /* (316) as ::= ID|STRING */ yytestcase(yyruleno==316);
145154 /* (317) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=317);
145155 /* (318) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==318);
145156 /* (319) exprlist ::= nexprlist */ yytestcase(yyruleno==319);
145157 /* (320) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=320);
145158 /* (321) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=321);
145159 /* (322) nmnum ::= ON */ yytestcase(yyruleno==322);
145160 /* (323) nmnum ::= DELETE */ yytestcase(yyruleno==323);
145161 /* (324) nmnum ::= DEFAULT */ yytestcase(yyruleno==324);
145162 /* (325) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==325);
145163 /* (326) foreach_clause ::= */ yytestcase(yyruleno==326);
145164 /* (327) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==327);
145165 /* (328) trnm ::= nm */ yytestcase(yyruleno==328);
145166 /* (329) tridxby ::= */ yytestcase(yyruleno==329);
145167 /* (330) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==330);
145168 /* (331) database_kw_opt ::= */ yytestcase(yyruleno==331);
145169 /* (332) kwcolumn_opt ::= */ yytestcase(yyruleno==332);
145170 /* (333) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==333);
145171 /* (334) vtabarglist ::= vtabarg */ yytestcase(yyruleno==334);
145172 /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==335);
145173 /* (336) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==336);
145174 /* (337) anylist ::= */ yytestcase(yyruleno==337);
145175 /* (338) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==338);
145176 /* (339) anylist ::= anylist ANY */ yytestcase(yyruleno==339);
145177 /* (340) with ::= */ yytestcase(yyruleno==340);
145178 break;
145179 /********** End reduce actions ************************************************/
145180 };
145181 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
145182 yygoto = yyRuleInfo[yyruleno].lhs;
@@ -145458,10 +149053,25 @@
145458 fprintf(yyTraceFILE,"]\n");
145459 }
145460 #endif
145461 return;
145462 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145463
145464 /************** End of parse.c ***********************************************/
145465 /************** Begin file tokenize.c ****************************************/
145466 /*
145467 ** 2001 September 15
@@ -145517,15 +149127,16 @@
145517 #define CC_COMMA 23 /* ',' */
145518 #define CC_AND 24 /* '&' */
145519 #define CC_TILDA 25 /* '~' */
145520 #define CC_DOT 26 /* '.' */
145521 #define CC_ILLEGAL 27 /* Illegal character */
 
145522
145523 static const unsigned char aiClass[] = {
145524 #ifdef SQLITE_ASCII
145525 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
145526 /* 0x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 7, 7, 27, 7, 7, 27, 27,
145527 /* 1x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
145528 /* 2x */ 7, 15, 8, 5, 4, 22, 24, 8, 17, 18, 21, 20, 23, 11, 26, 16,
145529 /* 3x */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 19, 12, 14, 13, 6,
145530 /* 4x */ 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
145531 /* 5x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 9, 27, 27, 27, 1,
@@ -145620,23 +149231,24 @@
145620 ** might be implemented more directly using a hand-written hash table.
145621 ** But by using this automatically generated code, the size of the code
145622 ** is substantially reduced. This is important for embedded applications
145623 ** on platforms with limited memory.
145624 */
145625 /* Hash score: 185 */
145626 /* zKWText[] encodes 845 bytes of keyword text in 561 bytes */
145627 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
145628 /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
145629 /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
145630 /* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE */
145631 /* BETWEENOTHINGLOBYCASCADELETECASECOLLATECREATECURRENT_DATE */
145632 /* DETACHIMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTVALUES */
145633 /* VIRTUALIMITWHENOTNULLWHERENAMEAFTEREPLACEANDEFAULT */
145634 /* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */
145635 /* RIMARYDEFERREDISTINCTDORDERESTRICTDROPFAILFROMFULLIFISNULL */
145636 /* RIGHTROLLBACKROWUNIONUSINGVACUUMVIEWINITIALLY */
145637 static const char zKWText[560] = {
 
145638 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
145639 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
145640 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
145641 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
145642 'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
@@ -145645,88 +149257,94 @@
145645 'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
145646 'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
145647 'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
145648 'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
145649 'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
145650 'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E',
145651 'B','E','T','W','E','E','N','O','T','H','I','N','G','L','O','B','Y','C',
145652 'A','S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L',
145653 'A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D',
145654 'A','T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E',
145655 'J','O','I','N','S','E','R','T','L','I','K','E','M','A','T','C','H','P',
145656 'L','A','N','A','L','Y','Z','E','P','R','A','G','M','A','B','O','R','T',
145657 'V','A','L','U','E','S','V','I','R','T','U','A','L','I','M','I','T','W',
145658 'H','E','N','O','T','N','U','L','L','W','H','E','R','E','N','A','M','E',
145659 'A','F','T','E','R','E','P','L','A','C','E','A','N','D','E','F','A','U',
145660 'L','T','A','U','T','O','I','N','C','R','E','M','E','N','T','C','A','S',
145661 'T','C','O','L','U','M','N','C','O','M','M','I','T','C','O','N','F','L',
145662 'I','C','T','C','R','O','S','S','C','U','R','R','E','N','T','_','T','I',
145663 'M','E','S','T','A','M','P','R','I','M','A','R','Y','D','E','F','E','R',
145664 'R','E','D','I','S','T','I','N','C','T','D','O','R','D','E','R','E','S',
145665 'T','R','I','C','T','D','R','O','P','F','A','I','L','F','R','O','M','F',
145666 'U','L','L','I','F','I','S','N','U','L','L','R','I','G','H','T','R','O',
145667 'L','L','B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N',
145668 'G','V','A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L',
145669 'L','Y',
 
 
 
145670 };
145671 /* aKWHash[i] is the hash value for the i-th keyword */
145672 static const unsigned char aKWHash[127] = {
145673 74, 108, 119, 72, 0, 45, 0, 0, 81, 0, 76, 61, 0,
145674 42, 12, 77, 15, 0, 118, 84, 54, 116, 0, 19, 0, 0,
145675 123, 0, 121, 111, 0, 22, 96, 0, 9, 0, 0, 68, 69,
145676 0, 67, 6, 0, 48, 93, 105, 0, 120, 104, 0, 0, 44,
145677 0, 106, 24, 0, 17, 0, 124, 53, 23, 0, 5, 62, 25,
145678 99, 0, 0, 126, 112, 60, 125, 57, 28, 55, 0, 94, 0,
145679 103, 26, 0, 102, 0, 0, 0, 98, 95, 100, 91, 115, 14,
145680 39, 114, 0, 80, 0, 109, 92, 90, 32, 0, 122, 79, 117,
145681 86, 46, 83, 0, 0, 97, 40, 59, 110, 0, 36, 0, 0,
145682 29, 0, 89, 87, 88, 0, 20, 85, 0, 56,
145683 };
145684 /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
145685 ** then the i-th keyword has no more hash collisions. Otherwise,
145686 ** the next keyword with the same hash is aKWHash[i]-1. */
145687 static const unsigned char aKWNext[126] = {
145688 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
145689 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
145690 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
145691 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
145692 0, 43, 3, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
145693 0, 1, 64, 0, 0, 65, 0, 41, 0, 38, 0, 0, 0,
145694 0, 0, 49, 75, 0, 0, 30, 0, 58, 0, 0, 63, 31,
145695 52, 16, 34, 10, 0, 0, 0, 0, 0, 0, 0, 11, 70,
145696 78, 0, 8, 0, 18, 51, 0, 107, 101, 0, 113, 0, 73,
145697 27, 37, 71, 82, 0, 35, 66, 0, 0,
 
145698 };
145699 /* aKWLen[i] is the length (in bytes) of the i-th keyword */
145700 static const unsigned char aKWLen[126] = {
145701 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
145702 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
145703 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
145704 4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
145705 6, 6, 5, 6, 5, 5, 9, 7, 7, 4, 2, 7, 3,
145706 6, 4, 7, 6, 12, 6, 9, 4, 6, 4, 5, 4, 7,
145707 6, 5, 6, 7, 5, 4, 7, 3, 2, 4, 5, 6, 5,
145708 7, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5, 17, 12,
145709 7, 8, 8, 2, 2, 5, 8, 4, 4, 4, 4, 2, 6,
145710 5, 8, 3, 5, 5, 6, 4, 9, 3,
 
145711 };
145712 /* aKWOffset[i] is the index into zKWText[] of the start of
145713 ** the text for the i-th keyword. */
145714 static const unsigned short int aKWOffset[126] = {
145715 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
145716 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
145717 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
145718 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
145719 199, 204, 209, 212, 218, 221, 225, 234, 240, 246, 249, 251, 252,
145720 256, 262, 266, 273, 279, 291, 297, 306, 308, 314, 318, 323, 325,
145721 332, 337, 342, 348, 354, 359, 362, 362, 362, 365, 369, 372, 378,
145722 382, 389, 391, 398, 400, 402, 411, 415, 421, 427, 435, 440, 440,
145723 456, 463, 470, 471, 478, 479, 483, 491, 495, 499, 503, 507, 509,
145724 515, 520, 528, 531, 536, 541, 547, 551, 556,
 
145725 };
145726 /* aKWCode[i] is the parser symbol code for the i-th keyword */
145727 static const unsigned char aKWCode[126] = {
145728 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
145729 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
145730 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
145731 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
145732 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
@@ -145734,25 +149352,27 @@
145734 TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
145735 TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
145736 TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
145737 TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
145738 TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
145739 TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RECURSIVE, TK_BETWEEN,
145740 TK_NOTHING, TK_LIKE_KW, TK_BY, TK_CASCADE, TK_ASC,
145741 TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW,
145742 TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_LIKE_KW,
145743 TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT,
145744 TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_NOTNULL,
145745 TK_NOT, TK_NO, TK_NULL, TK_WHERE, TK_RENAME,
145746 TK_AFTER, TK_REPLACE, TK_AND, TK_DEFAULT, TK_AUTOINCR,
145747 TK_TO, TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT,
145748 TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_PRIMARY,
145749 TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DO, TK_ORDER,
145750 TK_RESTRICT, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW,
145751 TK_IF, TK_ISNULL, TK_JOIN_KW, TK_ROLLBACK, TK_ROW,
145752 TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY,
145753 TK_ALL,
 
 
145754 };
145755 /* Check to see if z[0..n-1] is a keyword. If it is, write the
145756 ** parser symbol code for that keyword into *pType. Always
145757 ** return the integer n (the length of the token). */
145758 static int keywordCode(const char *z, int n, int *pType){
@@ -145827,11 +149447,11 @@
145827 testcase( i==53 ); /* HAVING */
145828 testcase( i==54 ); /* GROUP */
145829 testcase( i==55 ); /* UPDATE */
145830 testcase( i==56 ); /* BEGIN */
145831 testcase( i==57 ); /* INNER */
145832 testcase( i==58 ); /* RECURSIVE */
145833 testcase( i==59 ); /* BETWEEN */
145834 testcase( i==60 ); /* NOTHING */
145835 testcase( i==61 ); /* GLOB */
145836 testcase( i==62 ); /* BY */
145837 testcase( i==63 ); /* CASCADE */
@@ -145858,13 +149478,13 @@
145858 testcase( i==84 ); /* NOTNULL */
145859 testcase( i==85 ); /* NOT */
145860 testcase( i==86 ); /* NO */
145861 testcase( i==87 ); /* NULL */
145862 testcase( i==88 ); /* WHERE */
145863 testcase( i==89 ); /* RENAME */
145864 testcase( i==90 ); /* AFTER */
145865 testcase( i==91 ); /* REPLACE */
145866 testcase( i==92 ); /* AND */
145867 testcase( i==93 ); /* DEFAULT */
145868 testcase( i==94 ); /* AUTOINCREMENT */
145869 testcase( i==95 ); /* TO */
145870 testcase( i==96 ); /* IN */
@@ -145873,32 +149493,42 @@
145873 testcase( i==99 ); /* COMMIT */
145874 testcase( i==100 ); /* CONFLICT */
145875 testcase( i==101 ); /* CROSS */
145876 testcase( i==102 ); /* CURRENT_TIMESTAMP */
145877 testcase( i==103 ); /* CURRENT_TIME */
145878 testcase( i==104 ); /* PRIMARY */
145879 testcase( i==105 ); /* DEFERRED */
145880 testcase( i==106 ); /* DISTINCT */
145881 testcase( i==107 ); /* IS */
145882 testcase( i==108 ); /* DO */
145883 testcase( i==109 ); /* ORDER */
145884 testcase( i==110 ); /* RESTRICT */
145885 testcase( i==111 ); /* DROP */
145886 testcase( i==112 ); /* FAIL */
145887 testcase( i==113 ); /* FROM */
145888 testcase( i==114 ); /* FULL */
145889 testcase( i==115 ); /* IF */
145890 testcase( i==116 ); /* ISNULL */
145891 testcase( i==117 ); /* RIGHT */
145892 testcase( i==118 ); /* ROLLBACK */
145893 testcase( i==119 ); /* ROW */
145894 testcase( i==120 ); /* UNION */
145895 testcase( i==121 ); /* USING */
145896 testcase( i==122 ); /* VACUUM */
145897 testcase( i==123 ); /* VIEW */
145898 testcase( i==124 ); /* INITIALLY */
145899 testcase( i==125 ); /* ALL */
 
 
 
 
 
 
 
 
 
 
145900 *pType = aKWCode[i];
145901 break;
145902 }
145903 }
145904 return n;
@@ -145906,11 +149536,11 @@
145906 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
145907 int id = TK_ID;
145908 keywordCode((char*)z, n, &id);
145909 return id;
145910 }
145911 #define SQLITE_N_KEYWORD 126
145912 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
145913 if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
145914 *pzName = zKWText + aKWOffset[i];
145915 *pnName = aKWLen[i];
145916 return SQLITE_OK;
@@ -145965,10 +149595,86 @@
145965 /* Make the IdChar function accessible from ctime.c */
145966 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
145967 SQLITE_PRIVATE int sqlite3IsIdChar(u8 c){ return IdChar(c); }
145968 #endif
145969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145970
145971 /*
145972 ** Return the length (in bytes) of the token that begins at z[0].
145973 ** Store the token type in *tokenType before returning.
145974 */
@@ -146233,10 +149939,14 @@
146233 }
146234 case CC_ID: {
146235 i = 1;
146236 break;
146237 }
 
 
 
 
146238 default: {
146239 *tokenType = TK_ILLEGAL;
146240 return 1;
146241 }
146242 }
@@ -146286,51 +149996,68 @@
146286 assert( pParse->pNewTable==0 );
146287 assert( pParse->pNewTrigger==0 );
146288 assert( pParse->nVar==0 );
146289 assert( pParse->pVList==0 );
146290 while( 1 ){
146291 if( zSql[0]!=0 ){
146292 n = sqlite3GetToken((u8*)zSql, &tokenType);
146293 mxSqlLen -= n;
146294 if( mxSqlLen<0 ){
146295 pParse->rc = SQLITE_TOOBIG;
146296 break;
146297 }
146298 }else{
146299 /* Upon reaching the end of input, call the parser two more times
146300 ** with tokens TK_SEMI and 0, in that order. */
146301 if( lastTokenParsed==TK_SEMI ){
146302 tokenType = 0;
146303 }else if( lastTokenParsed==0 ){
146304 break;
146305 }else{
146306 tokenType = TK_SEMI;
146307 }
146308 n = 0;
146309 }
146310 if( tokenType>=TK_SPACE ){
146311 assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );
 
146312 if( db->u1.isInterrupted ){
146313 pParse->rc = SQLITE_INTERRUPT;
146314 break;
146315 }
146316 if( tokenType==TK_ILLEGAL ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146317 sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql);
146318 break;
146319 }
146320 zSql += n;
146321 }else{
146322 pParse->sLastToken.z = zSql;
146323 pParse->sLastToken.n = n;
146324 sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
146325 lastTokenParsed = tokenType;
146326 zSql += n;
146327 if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
146328 }
146329 }
146330 assert( nErr==0 );
146331 pParse->zTail = zSql;
146332 #ifdef YYTRACKMAXSTACKDEPTH
146333 sqlite3_mutex_enter(sqlite3MallocMutex());
146334 sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK,
146335 sqlite3ParserStackPeak(pEngine)
146336 );
@@ -146348,14 +150075,16 @@
146348 pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
146349 }
146350 assert( pzErrMsg!=0 );
146351 if( pParse->zErrMsg ){
146352 *pzErrMsg = pParse->zErrMsg;
146353 sqlite3_log(pParse->rc, "%s", *pzErrMsg);
 
146354 pParse->zErrMsg = 0;
146355 nErr++;
146356 }
 
146357 if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){
146358 sqlite3VdbeDelete(pParse->pVdbe);
146359 pParse->pVdbe = 0;
146360 }
146361 #ifndef SQLITE_OMIT_SHARED_CACHE
@@ -148467,23 +152196,27 @@
148467 int enc,
148468 void *pUserData,
148469 void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
148470 void (*xStep)(sqlite3_context*,int,sqlite3_value **),
148471 void (*xFinal)(sqlite3_context*),
 
 
148472 FuncDestructor *pDestructor
148473 ){
148474 FuncDef *p;
148475 int nName;
148476 int extraFlags;
148477
148478 assert( sqlite3_mutex_held(db->mutex) );
148479 if( zFunctionName==0 ||
148480 (xSFunc && (xFinal || xStep)) ||
148481 (!xSFunc && (xFinal && !xStep)) ||
148482 (!xSFunc && (!xFinal && xStep)) ||
148483 (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) ||
148484 (255<(nName = sqlite3Strlen30( zFunctionName))) ){
 
 
148485 return SQLITE_MISUSE_BKPT;
148486 }
148487
148488 assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
148489 extraFlags = enc & SQLITE_DETERMINISTIC;
@@ -148500,14 +152233,14 @@
148500 if( enc==SQLITE_UTF16 ){
148501 enc = SQLITE_UTF16NATIVE;
148502 }else if( enc==SQLITE_ANY ){
148503 int rc;
148504 rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8|extraFlags,
148505 pUserData, xSFunc, xStep, xFinal, pDestructor);
148506 if( rc==SQLITE_OK ){
148507 rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE|extraFlags,
148508 pUserData, xSFunc, xStep, xFinal, pDestructor);
148509 }
148510 if( rc!=SQLITE_OK ){
148511 return rc;
148512 }
148513 enc = SQLITE_UTF16BE;
@@ -148520,11 +152253,11 @@
148520 ** and there are active VMs, then return SQLITE_BUSY. If a function
148521 ** is being overridden/deleted but there are no active VMs, allow the
148522 ** operation to continue but invalidate all precompiled statements.
148523 */
148524 p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 0);
148525 if( p && (p->funcFlags & SQLITE_FUNC_ENCMASK)==enc && p->nArg==nArg ){
148526 if( db->nVdbeActive ){
148527 sqlite3ErrorWithMsg(db, SQLITE_BUSY,
148528 "unable to delete/modify user-function due to active statements");
148529 assert( !db->mallocFailed );
148530 return SQLITE_BUSY;
@@ -148549,42 +152282,36 @@
148549 p->u.pDestructor = pDestructor;
148550 p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags;
148551 testcase( p->funcFlags & SQLITE_DETERMINISTIC );
148552 p->xSFunc = xSFunc ? xSFunc : xStep;
148553 p->xFinalize = xFinal;
 
 
148554 p->pUserData = pUserData;
148555 p->nArg = (u16)nArg;
148556 return SQLITE_OK;
148557 }
148558
148559 /*
148560 ** Create new user functions.
 
 
 
 
148561 */
148562 SQLITE_API int sqlite3_create_function(
148563 sqlite3 *db,
148564 const char *zFunc,
148565 int nArg,
148566 int enc,
148567 void *p,
148568 void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
148569 void (*xStep)(sqlite3_context*,int,sqlite3_value **),
148570 void (*xFinal)(sqlite3_context*)
148571 ){
148572 return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xSFunc, xStep,
148573 xFinal, 0);
148574 }
148575
148576 SQLITE_API int sqlite3_create_function_v2(
148577 sqlite3 *db,
148578 const char *zFunc,
148579 int nArg,
148580 int enc,
148581 void *p,
148582 void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
148583 void (*xStep)(sqlite3_context*,int,sqlite3_value **),
148584 void (*xFinal)(sqlite3_context*),
148585 void (*xDestroy)(void *)
 
 
148586 ){
148587 int rc = SQLITE_ERROR;
148588 FuncDestructor *pArg = 0;
148589
148590 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -148602,11 +152329,13 @@
148602 }
148603 pArg->nRef = 0;
148604 pArg->xDestroy = xDestroy;
148605 pArg->pUserData = p;
148606 }
148607 rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p, xSFunc, xStep, xFinal, pArg);
 
 
148608 if( pArg && pArg->nRef==0 ){
148609 assert( rc!=SQLITE_OK );
148610 xDestroy(p);
148611 sqlite3_free(pArg);
148612 }
@@ -148614,10 +152343,56 @@
148614 out:
148615 rc = sqlite3ApiExit(db, rc);
148616 sqlite3_mutex_leave(db->mutex);
148617 return rc;
148618 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148619
148620 #ifndef SQLITE_OMIT_UTF16
148621 SQLITE_API int sqlite3_create_function16(
148622 sqlite3 *db,
148623 const void *zFunctionName,
@@ -148635,11 +152410,11 @@
148635 if( !sqlite3SafetyCheckOk(db) || zFunctionName==0 ) return SQLITE_MISUSE_BKPT;
148636 #endif
148637 sqlite3_mutex_enter(db->mutex);
148638 assert( !db->mallocFailed );
148639 zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);
148640 rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xSFunc,xStep,xFinal,0);
148641 sqlite3DbFree(db, zFunc8);
148642 rc = sqlite3ApiExit(db, rc);
148643 sqlite3_mutex_leave(db->mutex);
148644 return rc;
148645 }
@@ -150712,11 +154487,12 @@
150712 ** Set the VDBE coverage callback function to xCallback with context
150713 ** pointer ptr.
150714 */
150715 case SQLITE_TESTCTRL_VDBE_COVERAGE: {
150716 #ifdef SQLITE_VDBE_COVERAGE
150717 typedef void (*branch_callback)(void*,int,u8,u8);
 
150718 sqlite3GlobalConfig.xVdbeBranch = va_arg(ap,branch_callback);
150719 sqlite3GlobalConfig.pVdbeBranchArg = va_arg(ap,void*);
150720 #endif
150721 break;
150722 }
@@ -150899,11 +154675,11 @@
150899 if( db->autoCommit==0 ){
150900 int iDb = sqlite3FindDbName(db, zDb);
150901 if( iDb==0 || iDb>1 ){
150902 Btree *pBt = db->aDb[iDb].pBt;
150903 if( 0==sqlite3BtreeIsInTrans(pBt) ){
150904 rc = sqlite3BtreeBeginTrans(pBt, 0);
150905 if( rc==SQLITE_OK ){
150906 rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
150907 }
150908 }
150909 }
@@ -150937,11 +154713,11 @@
150937 if( iDb==0 || iDb>1 ){
150938 Btree *pBt = db->aDb[iDb].pBt;
150939 if( 0==sqlite3BtreeIsInReadTrans(pBt) ){
150940 rc = sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), pSnapshot);
150941 if( rc==SQLITE_OK ){
150942 rc = sqlite3BtreeBeginTrans(pBt, 0);
150943 sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), 0);
150944 }
150945 }
150946 }
150947 }
@@ -150969,11 +154745,11 @@
150969 sqlite3_mutex_enter(db->mutex);
150970 iDb = sqlite3FindDbName(db, zDb);
150971 if( iDb==0 || iDb>1 ){
150972 Btree *pBt = db->aDb[iDb].pBt;
150973 if( 0==sqlite3BtreeIsInReadTrans(pBt) ){
150974 rc = sqlite3BtreeBeginTrans(pBt, 0);
150975 if( rc==SQLITE_OK ){
150976 rc = sqlite3PagerSnapshotRecover(sqlite3BtreePager(pBt));
150977 sqlite3BtreeCommit(pBt);
150978 }
150979 }
@@ -182309,11 +186085,11 @@
182309 DbpageTable *pTab = (DbpageTable *)pVtab;
182310 sqlite3 *db = pTab->db;
182311 int i;
182312 for(i=0; i<db->nDb; i++){
182313 Btree *pBt = db->aDb[i].pBt;
182314 if( pBt ) sqlite3BtreeBeginTrans(pBt, 1);
182315 }
182316 return SQLITE_OK;
182317 }
182318
182319
@@ -189536,29 +193312,79 @@
189536 pStr->pCtx = ctx;
189537 }
189538 jsonAppendValue(pStr, argv[0]);
189539 }
189540 }
189541 static void jsonArrayFinal(sqlite3_context *ctx){
189542 JsonString *pStr;
189543 pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
189544 if( pStr ){
189545 pStr->pCtx = ctx;
189546 jsonAppendChar(pStr, ']');
189547 if( pStr->bErr ){
189548 if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);
189549 assert( pStr->bStatic );
189550 }else{
189551 sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,
189552 pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);
189553 pStr->bStatic = 1;
 
 
 
189554 }
189555 }else{
189556 sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC);
189557 }
189558 sqlite3_result_subtype(ctx, JSON_SUBTYPE);
189559 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189560
189561 /*
189562 ** json_group_obj(NAME,VALUE)
189563 **
189564 ** Return a JSON object composed of all names and values in the aggregate.
@@ -189586,28 +193412,38 @@
189586 jsonAppendString(pStr, z, n);
189587 jsonAppendChar(pStr, ':');
189588 jsonAppendValue(pStr, argv[1]);
189589 }
189590 }
189591 static void jsonObjectFinal(sqlite3_context *ctx){
189592 JsonString *pStr;
189593 pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
189594 if( pStr ){
189595 jsonAppendChar(pStr, '}');
189596 if( pStr->bErr ){
189597 if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);
189598 assert( pStr->bStatic );
189599 }else{
189600 sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,
189601 pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);
189602 pStr->bStatic = 1;
 
 
 
189603 }
189604 }else{
189605 sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC);
189606 }
189607 sqlite3_result_subtype(ctx, JSON_SUBTYPE);
189608 }
 
 
 
 
 
 
 
189609
189610
189611 #ifndef SQLITE_OMIT_VIRTUALTABLE
189612 /****************************************************************************
189613 ** The json_each virtual table
@@ -190111,13 +193947,16 @@
190111 static const struct {
190112 const char *zName;
190113 int nArg;
190114 void (*xStep)(sqlite3_context*,int,sqlite3_value**);
190115 void (*xFinal)(sqlite3_context*);
 
190116 } aAgg[] = {
190117 { "json_group_array", 1, jsonArrayStep, jsonArrayFinal },
190118 { "json_group_object", 2, jsonObjectStep, jsonObjectFinal },
 
 
190119 };
190120 #ifndef SQLITE_OMIT_VIRTUALTABLE
190121 static const struct {
190122 const char *zName;
190123 sqlite3_module *pModule;
@@ -190131,13 +193970,14 @@
190131 SQLITE_UTF8 | SQLITE_DETERMINISTIC,
190132 (void*)&aFunc[i].flag,
190133 aFunc[i].xFunc, 0, 0);
190134 }
190135 for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
190136 rc = sqlite3_create_function(db, aAgg[i].zName, aAgg[i].nArg,
190137 SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
190138 0, aAgg[i].xStep, aAgg[i].xFinal);
 
190139 }
190140 #ifndef SQLITE_OMIT_VIRTUALTABLE
190141 for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
190142 rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
190143 }
@@ -191539,13 +195379,16 @@
191539
191540
191541 /**************************************************************************
191542 ** Interface to automatically generated code in fts5_unicode2.c.
191543 */
191544 static int sqlite3Fts5UnicodeIsalnum(int c);
191545 static int sqlite3Fts5UnicodeIsdiacritic(int c);
191546 static int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);
 
 
 
 
191547 /*
191548 ** End of interface to code in fts5_unicode2.c.
191549 **************************************************************************/
191550
191551 #endif
@@ -191717,10 +195560,11 @@
191717 #define fts5YY_ACCEPT_ACTION 81
191718 #define fts5YY_NO_ACTION 82
191719 #define fts5YY_MIN_REDUCE 83
191720 #define fts5YY_MAX_REDUCE 110
191721 /************* End control #defines *******************************************/
 
191722
191723 /* Define the fts5yytestcase() macro to be a no-op if is not already defined
191724 ** otherwise.
191725 **
191726 ** Applications can choose to define fts5yytestcase() in the %include section
@@ -192276,15 +196120,15 @@
192276 fts5yycoverage[stateno][iLookAhead] = 1;
192277 #endif
192278 do{
192279 i = fts5yy_shift_ofst[stateno];
192280 assert( i>=0 );
192281 assert( i+fts5YYNFTS5TOKEN<=(int)sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0]) );
192282 assert( iLookAhead!=fts5YYNOCODE );
192283 assert( iLookAhead < fts5YYNFTS5TOKEN );
192284 i += iLookAhead;
192285 if( fts5yy_lookahead[i]!=iLookAhead ){
192286 #ifdef fts5YYFALLBACK
192287 fts5YYCODETYPE iFallback; /* Fallback token */
192288 if( iLookAhead<sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])
192289 && (iFallback = fts5yyFallback[iLookAhead])!=0 ){
192290 #ifndef NDEBUG
@@ -192306,10 +196150,11 @@
192306 j>=0 &&
192307 #endif
192308 #if fts5YY_SHIFT_MAX+fts5YYWILDCARD>=fts5YY_ACTTAB_COUNT
192309 j<fts5YY_ACTTAB_COUNT &&
192310 #endif
 
192311 fts5yy_lookahead[j]==fts5YYWILDCARD && iLookAhead>0
192312 ){
192313 #ifndef NDEBUG
192314 if( fts5yyTraceFILE ){
192315 fprintf(fts5yyTraceFILE, "%sWILDCARD %s => %s\n",
@@ -192986,10 +196831,25 @@
192986 fprintf(fts5yyTraceFILE,"]\n");
192987 }
192988 #endif
192989 return;
192990 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192991
192992 /*
192993 ** 2014 May 31
192994 **
192995 ** The author disclaims copyright to this source code. In place of
@@ -195097,10 +198957,11 @@
195097 static void sqlite3Fts5Parser(void*, int, Fts5Token, Fts5Parse*);
195098 #ifndef NDEBUG
195099 /* #include <stdio.h> */
195100 static void sqlite3Fts5ParserTrace(FILE*, char*);
195101 #endif
 
195102
195103
195104 struct Fts5Expr {
195105 Fts5Index *pIndex;
195106 Fts5Config *pConfig;
@@ -197601,18 +201462,23 @@
197601 sqlite3_context *pCtx, /* Function call context */
197602 int nArg, /* Number of args */
197603 sqlite3_value **apVal /* Function arguments */
197604 ){
197605 int iCode;
 
197606 if( nArg!=1 ){
197607 sqlite3_result_error(pCtx,
197608 "wrong number of arguments to function fts5_isalnum", -1
197609 );
197610 return;
197611 }
 
 
 
 
197612 iCode = sqlite3_value_int(apVal[0]);
197613 sqlite3_result_int(pCtx, sqlite3Fts5UnicodeIsalnum(iCode));
197614 }
197615
197616 static void fts5ExprFold(
197617 sqlite3_context *pCtx, /* Function call context */
197618 int nArg, /* Number of args */
@@ -197652,14 +201518,16 @@
197652 for(i=0; rc==SQLITE_OK && i<ArraySize(aFunc); i++){
197653 struct Fts5ExprFunc *p = &aFunc[i];
197654 rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0);
197655 }
197656
197657 /* Avoid a warning indicating that sqlite3Fts5ParserTrace() is unused */
 
197658 #ifndef NDEBUG
197659 (void)sqlite3Fts5ParserTrace;
197660 #endif
 
197661
197662 return rc;
197663 }
197664
197665 /*
@@ -207583,11 +211451,11 @@
207583 int nArg, /* Number of args */
207584 sqlite3_value **apUnused /* Function arguments */
207585 ){
207586 assert( nArg==0 );
207587 UNUSED_PARAM2(nArg, apUnused);
207588 sqlite3_result_text(pCtx, "fts5: 2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca", -1, SQLITE_TRANSIENT);
207589 }
207590
207591 static int fts5Init(sqlite3 *db){
207592 static const sqlite3_module fts5Mod = {
207593 /* iVersion */ 2,
@@ -209071,10 +212939,12 @@
209071 char *aFold; /* Buffer to fold text into */
209072 int nFold; /* Size of aFold[] in bytes */
209073 int bRemoveDiacritic; /* True if remove_diacritics=1 is set */
209074 int nException;
209075 int *aiException;
 
 
209076 };
209077
209078 static int fts5UnicodeAddExceptions(
209079 Unicode61Tokenizer *p, /* Tokenizer object */
209080 const char *z, /* Characters to treat as exceptions */
@@ -209095,11 +212965,11 @@
209095 int bToken;
209096 READ_UTF8(zCsr, zTerm, iCode);
209097 if( iCode<128 ){
209098 p->aTokenChar[iCode] = (unsigned char)bTokenChars;
209099 }else{
209100 bToken = sqlite3Fts5UnicodeIsalnum(iCode);
209101 assert( (bToken==0 || bToken==1) );
209102 assert( (bTokenChars==0 || bTokenChars==1) );
209103 if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){
209104 int i;
209105 for(i=0; i<nNew; i++){
@@ -209155,10 +213025,25 @@
209155 sqlite3_free(p->aFold);
209156 sqlite3_free(p);
209157 }
209158 return;
209159 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209160
209161 /*
209162 ** Create a "unicode61" tokenizer.
209163 */
209164 static int fts5UnicodeCreate(
@@ -209174,19 +213059,32 @@
209174 if( nArg%2 ){
209175 rc = SQLITE_ERROR;
209176 }else{
209177 p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer));
209178 if( p ){
 
209179 int i;
209180 memset(p, 0, sizeof(Unicode61Tokenizer));
209181 memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar));
209182 p->bRemoveDiacritic = 1;
209183 p->nFold = 64;
209184 p->aFold = sqlite3_malloc(p->nFold * sizeof(char));
209185 if( p->aFold==0 ){
209186 rc = SQLITE_NOMEM;
209187 }
 
 
 
 
 
 
 
 
 
 
 
 
209188 for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
209189 const char *zArg = azArg[i+1];
209190 if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){
209191 if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1] ){
209192 rc = SQLITE_ERROR;
@@ -209196,14 +213094,18 @@
209196 if( 0==sqlite3_stricmp(azArg[i], "tokenchars") ){
209197 rc = fts5UnicodeAddExceptions(p, zArg, 1);
209198 }else
209199 if( 0==sqlite3_stricmp(azArg[i], "separators") ){
209200 rc = fts5UnicodeAddExceptions(p, zArg, 0);
 
 
 
209201 }else{
209202 rc = SQLITE_ERROR;
209203 }
209204 }
 
209205 }else{
209206 rc = SQLITE_NOMEM;
209207 }
209208 if( rc!=SQLITE_OK ){
209209 fts5UnicodeDelete((Fts5Tokenizer*)p);
@@ -209218,12 +213120,14 @@
209218 ** Return true if, for the purposes of tokenizing with the tokenizer
209219 ** passed as the first argument, codepoint iCode is considered a token
209220 ** character (not a separator).
209221 */
209222 static int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){
209223 assert( (sqlite3Fts5UnicodeIsalnum(iCode) & 0xFFFFFFFE)==0 );
209224 return sqlite3Fts5UnicodeIsalnum(iCode) ^ fts5UnicodeIsException(p, iCode);
 
 
209225 }
209226
209227 static int fts5UnicodeTokenize(
209228 Fts5Tokenizer *pTokenizer,
209229 void *pCtx,
@@ -210095,139 +213999,10 @@
210095 */
210096
210097
210098 /* #include <assert.h> */
210099
210100 /*
210101 ** Return true if the argument corresponds to a unicode codepoint
210102 ** classified as either a letter or a number. Otherwise false.
210103 **
210104 ** The results are undefined if the value passed to this function
210105 ** is less than zero.
210106 */
210107 static int sqlite3Fts5UnicodeIsalnum(int c){
210108 /* Each unsigned integer in the following array corresponds to a contiguous
210109 ** range of unicode codepoints that are not either letters or numbers (i.e.
210110 ** codepoints for which this function should return 0).
210111 **
210112 ** The most significant 22 bits in each 32-bit value contain the first
210113 ** codepoint in the range. The least significant 10 bits are used to store
210114 ** the size of the range (always at least 1). In other words, the value
210115 ** ((C<<22) + N) represents a range of N codepoints starting with codepoint
210116 ** C. It is not possible to represent a range larger than 1023 codepoints
210117 ** using this format.
210118 */
210119 static const unsigned int aEntry[] = {
210120 0x00000030, 0x0000E807, 0x00016C06, 0x0001EC2F, 0x0002AC07,
210121 0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01,
210122 0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401,
210123 0x000BBC81, 0x000DD401, 0x000DF801, 0x000E1002, 0x000E1C01,
210124 0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163C01,
210125 0x00164437, 0x0017CC02, 0x00180005, 0x00181816, 0x00187802,
210126 0x00192C15, 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F,
210127 0x001B9C07, 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401,
210128 0x001CC01B, 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804,
210129 0x00206C09, 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403,
210130 0x00217801, 0x0023901B, 0x00240004, 0x0024E803, 0x0024F812,
210131 0x00254407, 0x00258804, 0x0025C001, 0x00260403, 0x0026F001,
210132 0x0026F807, 0x00271C02, 0x00272C03, 0x00275C01, 0x00278802,
210133 0x0027C802, 0x0027E802, 0x00280403, 0x0028F001, 0x0028F805,
210134 0x00291C02, 0x00292C03, 0x00294401, 0x0029C002, 0x0029D401,
210135 0x002A0403, 0x002AF001, 0x002AF808, 0x002B1C03, 0x002B2C03,
210136 0x002B8802, 0x002BC002, 0x002C0403, 0x002CF001, 0x002CF807,
210137 0x002D1C02, 0x002D2C03, 0x002D5802, 0x002D8802, 0x002DC001,
210138 0x002E0801, 0x002EF805, 0x002F1803, 0x002F2804, 0x002F5C01,
210139 0x002FCC08, 0x00300403, 0x0030F807, 0x00311803, 0x00312804,
210140 0x00315402, 0x00318802, 0x0031FC01, 0x00320802, 0x0032F001,
210141 0x0032F807, 0x00331803, 0x00332804, 0x00335402, 0x00338802,
210142 0x00340802, 0x0034F807, 0x00351803, 0x00352804, 0x00355C01,
210143 0x00358802, 0x0035E401, 0x00360802, 0x00372801, 0x00373C06,
210144 0x00375801, 0x00376008, 0x0037C803, 0x0038C401, 0x0038D007,
210145 0x0038FC01, 0x00391C09, 0x00396802, 0x003AC401, 0x003AD006,
210146 0x003AEC02, 0x003B2006, 0x003C041F, 0x003CD00C, 0x003DC417,
210147 0x003E340B, 0x003E6424, 0x003EF80F, 0x003F380D, 0x0040AC14,
210148 0x00412806, 0x00415804, 0x00417803, 0x00418803, 0x00419C07,
210149 0x0041C404, 0x0042080C, 0x00423C01, 0x00426806, 0x0043EC01,
210150 0x004D740C, 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001,
210151 0x005A6C02, 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802,
210152 0x005DC802, 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F,
210153 0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002,
210154 0x0066C011, 0x00672002, 0x00677822, 0x00685C05, 0x00687802,
210155 0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, 0x006AA006,
210156 0x006C0005, 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D,
210157 0x006F980E, 0x006FF004, 0x00709014, 0x0070EC05, 0x0071F802,
210158 0x00730008, 0x00734019, 0x0073B401, 0x0073C803, 0x00770027,
210159 0x0077F004, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403,
210160 0x007FB403, 0x007FF402, 0x00800065, 0x0081A806, 0x0081E805,
210161 0x00822805, 0x0082801A, 0x00834021, 0x00840002, 0x00840C04,
210162 0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401,
210163 0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005,
210164 0x00852804, 0x00853C01, 0x00864264, 0x00900027, 0x0091000B,
210165 0x0092704E, 0x00940200, 0x009C0475, 0x009E53B9, 0x00AD400A,
210166 0x00B39406, 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001,
210167 0x00B5FC01, 0x00B7804F, 0x00B8C00C, 0x00BA001A, 0x00BA6C59,
210168 0x00BC00D6, 0x00BFC00C, 0x00C00005, 0x00C02019, 0x00C0A807,
210169 0x00C0D802, 0x00C0F403, 0x00C26404, 0x00C28001, 0x00C3EC01,
210170 0x00C64002, 0x00C6580A, 0x00C70024, 0x00C8001F, 0x00C8A81E,
210171 0x00C94001, 0x00C98020, 0x00CA2827, 0x00CB003F, 0x00CC0100,
210172 0x01370040, 0x02924037, 0x0293F802, 0x02983403, 0x0299BC10,
210173 0x029A7C01, 0x029BC008, 0x029C0017, 0x029C8002, 0x029E2402,
210174 0x02A00801, 0x02A01801, 0x02A02C01, 0x02A08C09, 0x02A0D804,
210175 0x02A1D004, 0x02A20002, 0x02A2D011, 0x02A33802, 0x02A38012,
210176 0x02A3E003, 0x02A4980A, 0x02A51C0D, 0x02A57C01, 0x02A60004,
210177 0x02A6CC1B, 0x02A77802, 0x02A8A40E, 0x02A90C01, 0x02A93002,
210178 0x02A97004, 0x02A9DC03, 0x02A9EC01, 0x02AAC001, 0x02AAC803,
210179 0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07,
210180 0x02ABD402, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02,
210181 0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802,
210182 0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023, 0x03F95013,
210183 0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06,
210184 0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003,
210185 0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E, 0x040E7C01,
210186 0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01, 0x04280403,
210187 0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009,
210188 0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016, 0x04420003,
210189 0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, 0x04460003,
210190 0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004, 0x05BD442E,
210191 0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5, 0x07480046,
210192 0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401,
210193 0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401,
210194 0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064, 0x07C2800F,
210195 0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F, 0x07C4C03C,
210196 0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, 0x07C94002,
210197 0x07CC0021, 0x07CCC006, 0x07CCDC46, 0x07CE0014, 0x07CE8025,
210198 0x07CF1805, 0x07CF8011, 0x07D0003F, 0x07D10001, 0x07D108B6,
210199 0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018, 0x07D7EC46,
210200 0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401, 0x38008060,
210201 0x380400F0,
210202 };
210203 static const unsigned int aAscii[4] = {
210204 0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001,
210205 };
210206
210207 if( (unsigned int)c<128 ){
210208 return ( (aAscii[c >> 5] & (1 << (c & 0x001F)))==0 );
210209 }else if( (unsigned int)c<(1<<22) ){
210210 unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;
210211 int iRes = 0;
210212 int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;
210213 int iLo = 0;
210214 while( iHi>=iLo ){
210215 int iTest = (iHi + iLo) / 2;
210216 if( key >= aEntry[iTest] ){
210217 iRes = iTest;
210218 iLo = iTest+1;
210219 }else{
210220 iHi = iTest-1;
210221 }
210222 }
210223 assert( aEntry[0]<key );
210224 assert( key>=aEntry[iRes] );
210225 return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));
210226 }
210227 return 1;
210228 }
210229
210230
210231 /*
210232 ** If the argument is a codepoint corresponding to a lowercase letter
210233 ** in the ASCII range with a diacritic added, return the codepoint
@@ -210435,10 +214210,543 @@
210435 ret = c + 40;
210436 }
210437
210438 return ret;
210439 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210440
210441 /*
210442 ** 2015 May 30
210443 **
210444 ** The author disclaims copyright to this source code. In place of
@@ -211853,12 +216161,12 @@
211853 }
211854 #endif /* SQLITE_CORE */
211855 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
211856
211857 /************** End of stmt.c ************************************************/
211858 #if __LINE__!=211858
211859 #undef SQLITE_SOURCE_ID
211860 #define SQLITE_SOURCE_ID "2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199aalt2"
211861 #endif
211862 /* Return the source-id for this library */
211863 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
211864 /************************** End of sqlite3.c ******************************/
211865
--- 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.25.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.
@@ -1148,13 +1148,13 @@
1148 **
1149 ** See also: [sqlite3_libversion()],
1150 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1151 ** [sqlite_version()] and [sqlite_source_id()].
1152 */
1153 #define SQLITE_VERSION "3.25.0"
1154 #define SQLITE_VERSION_NUMBER 3025000
1155 #define SQLITE_SOURCE_ID "2018-07-13 20:28:54 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb36212426b1"
1156
1157 /*
1158 ** CAPI3REF: Run-Time Library Version Numbers
1159 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1160 **
@@ -1536,10 +1536,11 @@
1536 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1537 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1538 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
1539 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
1540 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
1541 #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
1542 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
1543 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
1544 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
1545 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
1546 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -3146,10 +3147,16 @@
3147 ** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
3148 ** [VACUUM] in order to reset a database back to an empty database
3149 ** with no schema and no content. The following process works even for
3150 ** a badly corrupted database file:
3151 ** <ol>
3152 ** <li> If the database connection is newly opened, make sure it has read the
3153 ** database schema by preparing then discarding some query against the
3154 ** database, or calling sqlite3_table_column_metadata(), ignoring any
3155 ** errors. This step is only necessary if the application desires to keep
3156 ** the database in WAL mode after the reset if it was in WAL mode before
3157 ** the reset.
3158 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
3159 ** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
3160 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
3161 ** </ol>
3162 ** Because resetting a database is destructive and irreversible, the
@@ -4379,16 +4386,27 @@
4386 **
4387 ** ^If the most recent sqlite3_* API call associated with
4388 ** [database connection] D failed, then the sqlite3_errcode(D) interface
4389 ** returns the numeric [result code] or [extended result code] for that
4390 ** API call.
 
 
4391 ** ^The sqlite3_extended_errcode()
4392 ** interface is the same except that it always returns the
4393 ** [extended result code] even when extended result codes are
4394 ** disabled.
4395 **
4396 ** The values returned by sqlite3_errcode() and/or
4397 ** sqlite3_extended_errcode() might change with each API call.
4398 ** Except, there are some interfaces that are guaranteed to never
4399 ** change the value of the error code. The error-code preserving
4400 ** interfaces are:
4401 **
4402 ** <ul>
4403 ** <li> sqlite3_errcode()
4404 ** <li> sqlite3_extended_errcode()
4405 ** <li> sqlite3_errmsg()
4406 ** <li> sqlite3_errmsg16()
4407 ** </ul>
4408 **
4409 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
4410 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
4411 ** ^(Memory to hold the error message string is managed internally.
4412 ** The application does not need to worry about freeing the result.
@@ -5539,15 +5557,29 @@
5557 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
5558 ** and BLOBs is freed automatically. Do not pass the pointers returned
5559 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
5560 ** [sqlite3_free()].
5561 **
5562 ** As long as the input parameters are correct, these routines will only
5563 ** fail if an out-of-memory error occurs during a format conversion.
5564 ** Only the following subset of interfaces are subject to out-of-memory
5565 ** errors:
5566 **
5567 ** <ul>
5568 ** <li> sqlite3_column_blob()
5569 ** <li> sqlite3_column_text()
5570 ** <li> sqlite3_column_text16()
5571 ** <li> sqlite3_column_bytes()
5572 ** <li> sqlite3_column_bytes16()
5573 ** </ul>
5574 **
5575 ** If an out-of-memory error occurs, then the return value from these
5576 ** routines is the same as if the column had contained an SQL NULL value.
5577 ** Valid SQL NULL returns can be distinguished from out-of-memory errors
5578 ** by invoking the [sqlite3_errcode()] immediately after the suspect
5579 ** return value is obtained and before any
5580 ** other SQLite interface is called on the same [database connection].
5581 */
5582 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
5583 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
5584 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
5585 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
@@ -5620,15 +5652,17 @@
5652 ** KEYWORDS: {application-defined SQL functions}
5653 ** METHOD: sqlite3
5654 **
5655 ** ^These functions (collectively known as "function creation routines")
5656 ** are used to add SQL functions or aggregates or to redefine the behavior
5657 ** of existing SQL functions or aggregates. The only differences between
5658 ** the three "sqlite3_create_function*" routines are the text encoding
5659 ** expected for the second parameter (the name of the function being
5660 ** created) and the presence or absence of a destructor callback for
5661 ** the application data pointer. Function sqlite3_create_window_function()
5662 ** is similar, but allows the user to supply the extra callback functions
5663 ** needed by [aggregate window functions].
5664 **
5665 ** ^The first parameter is the [database connection] to which the SQL
5666 ** function is to be added. ^If an application uses more than one database
5667 ** connection then application-defined SQL functions must be added
5668 ** to each database connection separately.
@@ -5670,28 +5704,38 @@
5704 ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
5705 **
5706 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
5707 ** function can gain access to this pointer using [sqlite3_user_data()].)^
5708 **
5709 ** ^The sixth, seventh and eighth parameters passed to the three
5710 ** "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are
5711 ** pointers to C-language functions that implement the SQL function or
5712 ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
5713 ** callback only; NULL pointers must be passed as the xStep and xFinal
5714 ** parameters. ^An aggregate SQL function requires an implementation of xStep
5715 ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
5716 ** SQL function or aggregate, pass NULL pointers for all three function
5717 ** callbacks.
5718 **
5719 ** ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue
5720 ** and xInverse) passed to sqlite3_create_window_function are pointers to
5721 ** C-lanugage callbacks that implement the new function. xStep and xFinal
5722 ** must both be non-NULL. xValue and xInverse may either both be NULL, in
5723 ** which case a regular aggregate function is created, or must both be
5724 ** non-NULL, in which case the new function may be used as either an aggregate
5725 ** or aggregate window function. More details regarding the implementation
5726 ** of aggregate window functions are
5727 ** [user-defined window functions|available here].
5728 **
5729 ** ^(If the final parameter to sqlite3_create_function_v2() or
5730 ** sqlite3_create_window_function() is not NULL, then it is destructor for
5731 ** the application data pointer. The destructor is invoked when the function
5732 ** is deleted, either by being overloaded or when the database connection
5733 ** closes.)^ ^The destructor is also invoked if the call to
5734 ** sqlite3_create_function_v2() fails. ^When the destructor callback is
5735 ** invoked, it is passed a single argument which is a copy of the application
5736 ** data pointer which was the fifth parameter to sqlite3_create_function_v2().
5737 **
5738 ** ^It is permitted to register multiple implementations of the same
5739 ** functions with the same name but with either differing numbers of
5740 ** arguments or differing preferred text encodings. ^SQLite will use
5741 ** the implementation that most closely matches the way in which the
@@ -5739,10 +5783,22 @@
5783 void *pApp,
5784 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
5785 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
5786 void (*xFinal)(sqlite3_context*),
5787 void(*xDestroy)(void*)
5788 );
5789 SQLITE_API int sqlite3_create_window_function(
5790 sqlite3 *db,
5791 const char *zFunctionName,
5792 int nArg,
5793 int eTextRep,
5794 void *pApp,
5795 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
5796 void (*xFinal)(sqlite3_context*),
5797 void (*xValue)(sqlite3_context*),
5798 void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
5799 void(*xDestroy)(void*)
5800 );
5801
5802 /*
5803 ** CAPI3REF: Text Encodings
5804 **
@@ -5882,10 +5938,32 @@
5938 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
5939 ** or [sqlite3_value_text16()].
5940 **
5941 ** These routines must be called from the same thread as
5942 ** the SQL function that supplied the [sqlite3_value*] parameters.
5943 **
5944 ** As long as the input parameter is correct, these routines can only
5945 ** fail if an out-of-memory error occurs during a format conversion.
5946 ** Only the following subset of interfaces are subject to out-of-memory
5947 ** errors:
5948 **
5949 ** <ul>
5950 ** <li> sqlite3_value_blob()
5951 ** <li> sqlite3_value_text()
5952 ** <li> sqlite3_value_text16()
5953 ** <li> sqlite3_value_text16le()
5954 ** <li> sqlite3_value_text16be()
5955 ** <li> sqlite3_value_bytes()
5956 ** <li> sqlite3_value_bytes16()
5957 ** </ul>
5958 **
5959 ** If an out-of-memory error occurs, then the return value from these
5960 ** routines is the same as if the column had contained an SQL NULL value.
5961 ** Valid SQL NULL returns can be distinguished from out-of-memory errors
5962 ** by invoking the [sqlite3_errcode()] immediately after the suspect
5963 ** return value is obtained and before any
5964 ** other SQLite interface is called on the same [database connection].
5965 */
5966 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
5967 SQLITE_API double sqlite3_value_double(sqlite3_value*);
5968 SQLITE_API int sqlite3_value_int(sqlite3_value*);
5969 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
@@ -12877,10 +12955,21 @@
12955 #endif
12956 #if defined(NDEBUG) && defined(SQLITE_DEBUG)
12957 # undef NDEBUG
12958 #endif
12959
12960 /* SQLITE_DEBUG_COLUMNCACHE is synomous with SQLITE_DEBUG. The
12961 ** SQLITE_DEBUG_COLUMNCACHE symbol only exists to provide a convenient
12962 ** way to search for all code that deals with verifying correct behavior
12963 ** of the column cache.
12964 */
12965 #ifdef SQLITE_DEBUG
12966 # define SQLITE_DEBUG_COLUMNCACHE 1
12967 #else
12968 # undef SQLIT_DEBUG_COLUMNCACHE
12969 #endif
12970
12971 /*
12972 ** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
12973 */
12974 #if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)
12975 # define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
@@ -13214,98 +13303,108 @@
13303 #define TK_RAISE 71
13304 #define TK_RECURSIVE 72
13305 #define TK_REPLACE 73
13306 #define TK_RESTRICT 74
13307 #define TK_ROW 75
13308 #define TK_ROWS 76
13309 #define TK_TRIGGER 77
13310 #define TK_VACUUM 78
13311 #define TK_VIEW 79
13312 #define TK_VIRTUAL 80
13313 #define TK_WITH 81
13314 #define TK_CURRENT 82
13315 #define TK_FOLLOWING 83
13316 #define TK_PARTITION 84
13317 #define TK_PRECEDING 85
13318 #define TK_RANGE 86
13319 #define TK_UNBOUNDED 87
13320 #define TK_REINDEX 88
13321 #define TK_RENAME 89
13322 #define TK_CTIME_KW 90
13323 #define TK_ANY 91
13324 #define TK_BITAND 92
13325 #define TK_BITOR 93
13326 #define TK_LSHIFT 94
13327 #define TK_RSHIFT 95
13328 #define TK_PLUS 96
13329 #define TK_MINUS 97
13330 #define TK_STAR 98
13331 #define TK_SLASH 99
13332 #define TK_REM 100
13333 #define TK_CONCAT 101
13334 #define TK_COLLATE 102
13335 #define TK_BITNOT 103
13336 #define TK_ON 104
13337 #define TK_INDEXED 105
13338 #define TK_STRING 106
13339 #define TK_JOIN_KW 107
13340 #define TK_CONSTRAINT 108
13341 #define TK_DEFAULT 109
13342 #define TK_NULL 110
13343 #define TK_PRIMARY 111
13344 #define TK_UNIQUE 112
13345 #define TK_CHECK 113
13346 #define TK_REFERENCES 114
13347 #define TK_AUTOINCR 115
13348 #define TK_INSERT 116
13349 #define TK_DELETE 117
13350 #define TK_UPDATE 118
13351 #define TK_SET 119
13352 #define TK_DEFERRABLE 120
13353 #define TK_FOREIGN 121
13354 #define TK_DROP 122
13355 #define TK_UNION 123
13356 #define TK_ALL 124
13357 #define TK_EXCEPT 125
13358 #define TK_INTERSECT 126
13359 #define TK_SELECT 127
13360 #define TK_VALUES 128
13361 #define TK_DISTINCT 129
13362 #define TK_DOT 130
13363 #define TK_FROM 131
13364 #define TK_JOIN 132
13365 #define TK_USING 133
13366 #define TK_ORDER 134
13367 #define TK_GROUP 135
13368 #define TK_HAVING 136
13369 #define TK_LIMIT 137
13370 #define TK_WHERE 138
13371 #define TK_INTO 139
13372 #define TK_NOTHING 140
13373 #define TK_FLOAT 141
13374 #define TK_BLOB 142
13375 #define TK_INTEGER 143
13376 #define TK_VARIABLE 144
13377 #define TK_CASE 145
13378 #define TK_WHEN 146
13379 #define TK_THEN 147
13380 #define TK_ELSE 148
13381 #define TK_INDEX 149
13382 #define TK_ALTER 150
13383 #define TK_ADD 151
13384 #define TK_WINDOW 152
13385 #define TK_OVER 153
13386 #define TK_FILTER 154
13387 #define TK_TRUEFALSE 155
13388 #define TK_ISNOT 156
13389 #define TK_FUNCTION 157
13390 #define TK_COLUMN 158
13391 #define TK_AGG_FUNCTION 159
13392 #define TK_AGG_COLUMN 160
13393 #define TK_UMINUS 161
13394 #define TK_UPLUS 162
13395 #define TK_TRUTH 163
13396 #define TK_REGISTER 164
13397 #define TK_VECTOR 165
13398 #define TK_SELECT_COLUMN 166
13399 #define TK_IF_NULL_ROW 167
13400 #define TK_ASTERISK 168
13401 #define TK_SPAN 169
13402 #define TK_END_OF_FILE 170
13403 #define TK_UNCLOSED_STRING 171
13404 #define TK_SPACE 172
13405 #define TK_ILLEGAL 173
13406
13407 /* The token codes above must all fit in 8 bits */
13408 #define TKFLG_MASK 0xff
13409
13410 /* Flags that can be added to a token code when it is not
@@ -13891,12 +13990,39 @@
13990 typedef struct Upsert Upsert;
13991 typedef struct VTable VTable;
13992 typedef struct VtabCtx VtabCtx;
13993 typedef struct Walker Walker;
13994 typedef struct WhereInfo WhereInfo;
13995 typedef struct Window Window;
13996 typedef struct With With;
13997
13998
13999 /*
14000 ** The bitmask datatype defined below is used for various optimizations.
14001 **
14002 ** Changing this from a 64-bit to a 32-bit type limits the number of
14003 ** tables in a join to 32 instead of 64. But it also reduces the size
14004 ** of the library by 738 bytes on ix86.
14005 */
14006 #ifdef SQLITE_BITMASK_TYPE
14007 typedef SQLITE_BITMASK_TYPE Bitmask;
14008 #else
14009 typedef u64 Bitmask;
14010 #endif
14011
14012 /*
14013 ** The number of bits in a Bitmask. "BMS" means "BitMask Size".
14014 */
14015 #define BMS ((int)(sizeof(Bitmask)*8))
14016
14017 /*
14018 ** A bit in a Bitmask
14019 */
14020 #define MASKBIT(n) (((Bitmask)1)<<(n))
14021 #define MASKBIT32(n) (((unsigned int)1)<<(n))
14022 #define ALLBITS ((Bitmask)-1)
14023
14024 /* A VList object records a mapping between parameters/variables/wildcards
14025 ** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer
14026 ** variable number associated with that parameter. See the format description
14027 ** on the sqlite3VListAdd() routine for more information. A VList is really
14028 ** just an array of integers.
@@ -13988,11 +14114,11 @@
14114 SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int);
14115 SQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree*);
14116 SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p);
14117 SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
14118 SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);
14119 SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int,int*);
14120 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
14121 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*, int);
14122 SQLITE_PRIVATE int sqlite3BtreeCommit(Btree*);
14123 SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int,int);
14124 SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);
@@ -14211,10 +14337,13 @@
14337 };
14338
14339 SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
14340 int flags, int seekResult);
14341 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
14342 #ifndef SQLITE_OMIT_WINDOWFUNC
14343 SQLITE_PRIVATE void sqlite3BtreeSkipNext(BtCursor*);
14344 #endif
14345 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
14346 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
14347 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
14348 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
14349 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
@@ -14378,11 +14507,12 @@
14507 #ifdef VDBE_PROFILE
14508 u32 cnt; /* Number of times this instruction was executed */
14509 u64 cycles; /* Total time spent executing this instruction */
14510 #endif
14511 #ifdef SQLITE_VDBE_COVERAGE
14512 u32 iSrcLine; /* Source-code line that generated this opcode
14513 ** with flags in the upper 8 bits */
14514 #endif
14515 };
14516 typedef struct VdbeOp VdbeOp;
14517
14518
@@ -14479,122 +14609,122 @@
14609 /* See the tool/mkopcodeh.tcl script for details */
14610 #define OP_Savepoint 0
14611 #define OP_AutoCommit 1
14612 #define OP_Transaction 2
14613 #define OP_SorterNext 3 /* jump */
14614 #define OP_Prev 4 /* jump */
14615 #define OP_Next 5 /* jump */
14616 #define OP_Checkpoint 6
14617 #define OP_JournalMode 7
14618 #define OP_Vacuum 8
14619 #define OP_VFilter 9 /* jump, synopsis: iplan=r[P3] zplan='P4' */
14620 #define OP_VUpdate 10 /* synopsis: data=r[P3@P2] */
14621 #define OP_Goto 11 /* jump */
14622 #define OP_Gosub 12 /* jump */
14623 #define OP_InitCoroutine 13 /* jump */
14624 #define OP_Yield 14 /* jump */
14625 #define OP_MustBeInt 15 /* jump */
14626 #define OP_Jump 16 /* jump */
14627 #define OP_Once 17 /* jump */
14628 #define OP_If 18 /* jump */
14629 #define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */
14630 #define OP_IfNot 20 /* jump */
14631 #define OP_IfNullRow 21 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
14632 #define OP_SeekLT 22 /* jump, synopsis: key=r[P3@P4] */
14633 #define OP_SeekLE 23 /* jump, synopsis: key=r[P3@P4] */
14634 #define OP_SeekGE 24 /* jump, synopsis: key=r[P3@P4] */
14635 #define OP_SeekGT 25 /* jump, synopsis: key=r[P3@P4] */
14636 #define OP_IfNoHope 26 /* jump, synopsis: key=r[P3@P4] */
14637 #define OP_NoConflict 27 /* jump, synopsis: key=r[P3@P4] */
14638 #define OP_NotFound 28 /* jump, synopsis: key=r[P3@P4] */
14639 #define OP_Found 29 /* jump, synopsis: key=r[P3@P4] */
14640 #define OP_SeekRowid 30 /* jump, synopsis: intkey=r[P3] */
14641 #define OP_NotExists 31 /* jump, synopsis: intkey=r[P3] */
14642 #define OP_Last 32 /* jump */
14643 #define OP_IfSmaller 33 /* jump */
14644 #define OP_SorterSort 34 /* jump */
14645 #define OP_Sort 35 /* jump */
14646 #define OP_Rewind 36 /* jump */
14647 #define OP_IdxLE 37 /* jump, synopsis: key=r[P3@P4] */
14648 #define OP_IdxGT 38 /* jump, synopsis: key=r[P3@P4] */
14649 #define OP_IdxLT 39 /* jump, synopsis: key=r[P3@P4] */
14650 #define OP_IdxGE 40 /* jump, synopsis: key=r[P3@P4] */
14651 #define OP_RowSetRead 41 /* jump, synopsis: r[P3]=rowset(P1) */
14652 #define OP_RowSetTest 42 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
14653 #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
14654 #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
14655 #define OP_Program 45 /* jump */
14656 #define OP_FkIfZero 46 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
14657 #define OP_IfPos 47 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
14658 #define OP_IfNotZero 48 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
14659 #define OP_DecrJumpZero 49 /* jump, synopsis: if (--r[P1])==0 goto P2 */
14660 #define OP_IsNull 50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
14661 #define OP_NotNull 51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
14662 #define OP_Ne 52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
14663 #define OP_Eq 53 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
14664 #define OP_Gt 54 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
14665 #define OP_Le 55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
14666 #define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
14667 #define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
14668 #define OP_ElseNotEq 58 /* jump, same as TK_ESCAPE */
14669 #define OP_IncrVacuum 59 /* jump */
14670 #define OP_VNext 60 /* jump */
14671 #define OP_Init 61 /* jump, synopsis: Start at P2 */
14672 #define OP_Return 62
14673 #define OP_EndCoroutine 63
14674 #define OP_HaltIfNull 64 /* synopsis: if r[P3]=null halt */
14675 #define OP_Halt 65
14676 #define OP_Integer 66 /* synopsis: r[P2]=P1 */
14677 #define OP_Int64 67 /* synopsis: r[P2]=P4 */
14678 #define OP_String 68 /* synopsis: r[P2]='P4' (len=P1) */
14679 #define OP_Null 69 /* synopsis: r[P2..P3]=NULL */
14680 #define OP_SoftNull 70 /* synopsis: r[P1]=NULL */
14681 #define OP_Blob 71 /* synopsis: r[P2]=P4 (len=P1) */
14682 #define OP_Variable 72 /* synopsis: r[P2]=parameter(P1,P4) */
14683 #define OP_Move 73 /* synopsis: r[P2@P3]=r[P1@P3] */
14684 #define OP_Copy 74 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
14685 #define OP_SCopy 75 /* synopsis: r[P2]=r[P1] */
14686 #define OP_IntCopy 76 /* synopsis: r[P2]=r[P1] */
14687 #define OP_ResultRow 77 /* synopsis: output=r[P1@P2] */
14688 #define OP_CollSeq 78
14689 #define OP_AddImm 79 /* synopsis: r[P1]=r[P1]+P2 */
14690 #define OP_RealAffinity 80
14691 #define OP_Cast 81 /* synopsis: affinity(r[P1]) */
14692 #define OP_Permutation 82
14693 #define OP_Compare 83 /* synopsis: r[P1@P3] <-> r[P2@P3] */
14694 #define OP_IsTrue 84 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
14695 #define OP_Offset 85 /* synopsis: r[P3] = sqlite_offset(P1) */
14696 #define OP_Column 86 /* synopsis: r[P3]=PX */
14697 #define OP_Affinity 87 /* synopsis: affinity(r[P1@P2]) */
14698 #define OP_MakeRecord 88 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
14699 #define OP_Count 89 /* synopsis: r[P2]=count() */
14700 #define OP_ReadCookie 90
14701 #define OP_SetCookie 91
14702 #define OP_BitAnd 92 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
14703 #define OP_BitOr 93 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
14704 #define OP_ShiftLeft 94 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
14705 #define OP_ShiftRight 95 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
14706 #define OP_Add 96 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
14707 #define OP_Subtract 97 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
14708 #define OP_Multiply 98 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
14709 #define OP_Divide 99 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
14710 #define OP_Remainder 100 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
14711 #define OP_Concat 101 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
14712 #define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
14713 #define OP_BitNot 103 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
14714 #define OP_OpenRead 104 /* synopsis: root=P2 iDb=P3 */
14715 #define OP_OpenWrite 105 /* synopsis: root=P2 iDb=P3 */
14716 #define OP_String8 106 /* same as TK_STRING, synopsis: r[P2]='P4' */
14717 #define OP_OpenDup 107
14718 #define OP_OpenAutoindex 108 /* synopsis: nColumn=P2 */
14719 #define OP_OpenEphemeral 109 /* synopsis: nColumn=P2 */
14720 #define OP_SorterOpen 110
14721 #define OP_SequenceTest 111 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
14722 #define OP_OpenPseudo 112 /* synopsis: P3 columns in r[P2] */
14723 #define OP_Close 113
14724 #define OP_ColumnsUsed 114
14725 #define OP_SeekHit 115 /* synopsis: seekHit=P2 */
14726 #define OP_Sequence 116 /* synopsis: r[P2]=cursor[P1].ctr++ */
14727 #define OP_NewRowid 117 /* synopsis: r[P2]=rowid */
14728 #define OP_Insert 118 /* synopsis: intkey=r[P3] data=r[P2] */
14729 #define OP_InsertInt 119 /* synopsis: intkey=P3 data=r[P2] */
14730 #define OP_Delete 120
@@ -14609,48 +14739,52 @@
14739 #define OP_IdxInsert 129 /* synopsis: key=r[P2] */
14740 #define OP_IdxDelete 130 /* synopsis: key=r[P2@P3] */
14741 #define OP_DeferredSeek 131 /* synopsis: Move P3 to P1.rowid if needed */
14742 #define OP_IdxRowid 132 /* synopsis: r[P2]=rowid */
14743 #define OP_Destroy 133
14744 #define OP_Clear 134
14745 #define OP_ResetSorter 135
14746 #define OP_CreateBtree 136 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
14747 #define OP_SqlExec 137
14748 #define OP_ParseSchema 138
14749 #define OP_LoadAnalysis 139
14750 #define OP_DropTable 140
14751 #define OP_Real 141 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
14752 #define OP_DropIndex 142
14753 #define OP_DropTrigger 143
14754 #define OP_IntegrityCk 144
14755 #define OP_RowSetAdd 145 /* synopsis: rowset(P1)=r[P2] */
14756 #define OP_Param 146
14757 #define OP_FkCounter 147 /* synopsis: fkctr[P1]+=P2 */
14758 #define OP_MemMax 148 /* synopsis: r[P1]=max(r[P1],r[P2]) */
14759 #define OP_OffsetLimit 149 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
14760 #define OP_AggInverse 150 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
14761 #define OP_AggStep 151 /* synopsis: accum=r[P3] step(r[P2@P5]) */
14762 #define OP_AggStep1 152 /* synopsis: accum=r[P3] step(r[P2@P5]) */
14763 #define OP_AggValue 153 /* synopsis: r[P3]=value N=P2 */
14764 #define OP_AggFinal 154 /* synopsis: accum=r[P1] N=P2 */
14765 #define OP_Expire 155
14766 #define OP_TableLock 156 /* synopsis: iDb=P1 root=P2 write=P3 */
14767 #define OP_VBegin 157
14768 #define OP_VCreate 158
14769 #define OP_VDestroy 159
14770 #define OP_VOpen 160
14771 #define OP_VColumn 161 /* synopsis: r[P3]=vcolumn(P2) */
14772 #define OP_VRename 162
14773 #define OP_Pagecount 163
14774 #define OP_MaxPgcnt 164
14775 #define OP_PureFunc0 165
14776 #define OP_Function0 166 /* synopsis: r[P3]=func(r[P2@P5]) */
14777 #define OP_PureFunc 167
14778 #define OP_Function 168 /* synopsis: r[P3]=func(r[P2@P5]) */
14779 #define OP_Trace 169
14780 #define OP_CursorHint 170
14781 #define OP_SetTabCol 171
14782 #define OP_VerifyTabCol 172
14783 #define OP_Noop 173
14784 #define OP_Explain 174
14785 #define OP_Abortable 175
14786
14787 /* Properties such as "out2" or "jump" that are specified in
14788 ** comments following the "case" for each opcode in the vdbe.c
14789 ** are encoded into bitvectors as follows:
14790 */
@@ -14659,40 +14793,41 @@
14793 #define OPFLG_IN2 0x04 /* in2: P2 is an input */
14794 #define OPFLG_IN3 0x08 /* in3: P3 is an input */
14795 #define OPFLG_OUT2 0x10 /* out2: P2 is an output */
14796 #define OPFLG_OUT3 0x20 /* out3: P3 is an output */
14797 #define OPFLG_INITIALIZER {\
14798 /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\
14799 /* 8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\
14800 /* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x01, 0x09, 0x09,\
14801 /* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
14802 /* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
14803 /* 40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\
14804 /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
14805 /* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02,\
14806 /* 64 */ 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10,\
14807 /* 72 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x02,\
14808 /* 80 */ 0x02, 0x02, 0x00, 0x00, 0x12, 0x20, 0x00, 0x00,\
14809 /* 88 */ 0x00, 0x10, 0x10, 0x00, 0x26, 0x26, 0x26, 0x26,\
14810 /* 96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\
14811 /* 104 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
14812 /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
14813 /* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
14814 /* 128 */ 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
14815 /* 136 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
14816 /* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00,\
14817 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
14818 /* 160 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
14819 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
14820 }
14821
14822 /* The sqlite3P2Values() routine is able to run faster if it knows
14823 ** the value of the largest JUMP opcode. The smaller the maximum
14824 ** JUMP opcode the better, so the mkopcodeh.tcl script that
14825 ** generated this include file strives to group all JUMP opcodes
14826 ** together near the beginning of the list.
14827 */
14828 #define SQLITE_MX_JUMP_OPCODE 61 /* Maximum JUMP opcode */
14829
14830 /************** End of opcodes.h *********************************************/
14831 /************** Continuing where we left off in vdbe.h ***********************/
14832
14833 /*
@@ -14786,10 +14921,11 @@
14921 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
14922 #ifndef SQLITE_OMIT_TRACE
14923 SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*);
14924 #endif
14925 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
14926 SQLITE_PRIVATE int sqlite3BlobCompare(const Mem*, const Mem*);
14927
14928 SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);
14929 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
14930 SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int);
14931 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*);
@@ -14841,35 +14977,68 @@
14977 **
14978 ** VdbeCoverageAlwaysTaken(v) // Previous branch is always taken
14979 **
14980 ** VdbeCoverageNeverTaken(v) // Previous branch is never taken
14981 **
14982 ** VdbeCoverageNeverNull(v) // Previous three-way branch is only
14983 ** // taken on the first two ways. The
14984 ** // NULL option is not possible
14985 **
14986 ** VdbeCoverageEqNe(v) // Previous OP_Jump is only interested
14987 ** // in distingishing equal and not-equal.
14988 **
14989 ** Every VDBE branch operation must be tagged with one of the macros above.
14990 ** If not, then when "make test" is run with -DSQLITE_VDBE_COVERAGE and
14991 ** -DSQLITE_DEBUG then an ALWAYS() will fail in the vdbeTakeBranch()
14992 ** routine in vdbe.c, alerting the developer to the missed tag.
14993 **
14994 ** During testing, the test application will invoke
14995 ** sqlite3_test_control(SQLITE_TESTCTRL_VDBE_COVERAGE,...) to set a callback
14996 ** routine that is invoked as each bytecode branch is taken. The callback
14997 ** contains the sqlite3.c source line number ov the VdbeCoverage macro and
14998 ** flags to indicate whether or not the branch was taken. The test application
14999 ** is responsible for keeping track of this and reporting byte-code branches
15000 ** that are never taken.
15001 **
15002 ** See the VdbeBranchTaken() macro and vdbeTakeBranch() function in the
15003 ** vdbe.c source file for additional information.
15004 */
15005 #ifdef SQLITE_VDBE_COVERAGE
15006 SQLITE_PRIVATE void sqlite3VdbeSetLineNumber(Vdbe*,int);
15007 # define VdbeCoverage(v) sqlite3VdbeSetLineNumber(v,__LINE__)
15008 # define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__)
15009 # define VdbeCoverageAlwaysTaken(v) \
15010 sqlite3VdbeSetLineNumber(v,__LINE__|0x5000000);
15011 # define VdbeCoverageNeverTaken(v) \
15012 sqlite3VdbeSetLineNumber(v,__LINE__|0x6000000);
15013 # define VdbeCoverageNeverNull(v) \
15014 sqlite3VdbeSetLineNumber(v,__LINE__|0x4000000);
15015 # define VdbeCoverageNeverNullIf(v,x) \
15016 if(x)sqlite3VdbeSetLineNumber(v,__LINE__|0x4000000);
15017 # define VdbeCoverageEqNe(v) \
15018 sqlite3VdbeSetLineNumber(v,__LINE__|0x8000000);
15019 # define VDBE_OFFSET_LINENO(x) (__LINE__+x)
15020 #else
15021 # define VdbeCoverage(v)
15022 # define VdbeCoverageIf(v,x)
15023 # define VdbeCoverageAlwaysTaken(v)
15024 # define VdbeCoverageNeverTaken(v)
15025 # define VdbeCoverageNeverNull(v)
15026 # define VdbeCoverageNeverNullIf(v,x)
15027 # define VdbeCoverageEqNe(v)
15028 # define VDBE_OFFSET_LINENO(x) 0
15029 #endif
15030
15031 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
15032 SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
15033 #else
15034 # define sqlite3VdbeScanStatus(a,b,c,d,e)
15035 #endif
15036
15037 #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
15038 SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, VdbeOp*);
15039 #endif
15040
15041 #endif /* SQLITE_VDBE_H */
15042
15043 /************** End of vdbe.h ************************************************/
15044 /************** Continuing where we left off in sqliteInt.h ******************/
@@ -16082,10 +16251,11 @@
16251 #define SQLITE_CursorHints 0x0400 /* Add OP_CursorHint opcodes */
16252 #define SQLITE_Stat34 0x0800 /* Use STAT3 or STAT4 data */
16253 /* TH3 expects the Stat34 ^^^^^^ value to be 0x0800. Don't change it */
16254 #define SQLITE_PushDown 0x1000 /* The push-down optimization */
16255 #define SQLITE_SimplifyJoin 0x2000 /* Convert LEFT JOIN to JOIN */
16256 #define SQLITE_SkipScan 0x4000 /* Skip-scans */
16257 #define SQLITE_AllOpts 0xffff /* All optimizations */
16258
16259 /*
16260 ** Macros for testing whether or not optimizations are enabled or disabled.
16261 */
@@ -16120,15 +16290,17 @@
16290 ** The u.pHash field is used by the global built-ins. The u.pDestructor
16291 ** field is used by per-connection app-def functions.
16292 */
16293 struct FuncDef {
16294 i8 nArg; /* Number of arguments. -1 means unlimited */
16295 u32 funcFlags; /* Some combination of SQLITE_FUNC_* */
16296 void *pUserData; /* User data parameter */
16297 FuncDef *pNext; /* Next function with same name */
16298 void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
16299 void (*xFinalize)(sqlite3_context*); /* Agg finalizer */
16300 void (*xValue)(sqlite3_context*); /* Current agg value */
16301 void (*xInverse)(sqlite3_context*,int,sqlite3_value**); /* inverse agg-step */
16302 const char *zName; /* SQL name of the function. */
16303 union {
16304 FuncDef *pHash; /* Next with a different name but the same hash */
16305 FuncDestructor *pDestructor; /* Reference counted destructor function */
16306 } u;
@@ -16181,10 +16353,12 @@
16353 #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */
16354 #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
16355 ** single query - might change over time */
16356 #define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
16357 #define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */
16358 #define SQLITE_FUNC_WINDOW 0x10000 /* Built-in window-only function */
16359 #define SQLITE_FUNC_WINDOW_SIZE 0x20000 /* Requires partition size as arg. */
16360
16361 /*
16362 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
16363 ** used to create the initializers for the FuncDef structures.
16364 **
@@ -16214,10 +16388,16 @@
16388 ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
16389 ** Used to create an aggregate function definition implemented by
16390 ** the C functions xStep and xFinal. The first four parameters
16391 ** are interpreted in the same way as the first 4 parameters to
16392 ** FUNCTION().
16393 **
16394 ** WFUNCTION(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)
16395 ** Used to create an aggregate function definition implemented by
16396 ** the C functions xStep and xFinal. The first four parameters
16397 ** are interpreted in the same way as the first 4 parameters to
16398 ** FUNCTION().
16399 **
16400 ** LIKEFUNC(zName, nArg, pArg, flags)
16401 ** Used to create a scalar function definition of a function zName
16402 ** that accepts nArg arguments and is implemented by a call to C
16403 ** function likeFunc. Argument pArg is cast to a (void *) and made
@@ -16225,35 +16405,39 @@
16405 ** FuncDef.flags variable is set to the value passed as the flags
16406 ** parameter.
16407 */
16408 #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
16409 {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
16410 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
16411 #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
16412 {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
16413 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
16414 #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \
16415 {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \
16416 0, 0, xFunc, 0, 0, 0, #zName, {0} }
16417 #define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \
16418 {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
16419 (void*)&sqlite3Config, 0, xFunc, 0, 0, 0, #zName, {0} }
16420 #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
16421 {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
16422 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
16423 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
16424 {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
16425 pArg, 0, xFunc, 0, 0, 0, #zName, }
16426 #define LIKEFUNC(zName, nArg, arg, flags) \
16427 {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
16428 (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
16429 #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue) \
16430 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \
16431 SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,0,#zName, {0}}
16432 #define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \
16433 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
16434 SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xFinal,0,#zName, {0}}
16435
16436 #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
16437 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
16438 SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}}
16439
16440 /*
16441 ** All current savepoints are stored in a linked list starting at
16442 ** sqlite3.pSavepoint. The first element in the list is the most recently
16443 ** opened savepoint. Savepoints are added to the list by the vdbe
@@ -16735,10 +16919,11 @@
16919 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
16920 IndexSample *aSample; /* Samples of the left-most key */
16921 tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */
16922 tRowcnt nRowEst0; /* Non-logarithmic number of rows in the index */
16923 #endif
16924 Bitmask colNotIdxed; /* 0 for unindexed columns in pTab */
16925 };
16926
16927 /*
16928 ** Allowed values for Index.idxType
16929 */
@@ -16950,10 +17135,13 @@
17135 ** TK_COLUMN: the value of p5 for OP_Column
17136 ** TK_AGG_FUNCTION: nesting depth */
17137 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
17138 Table *pTab; /* Table for TK_COLUMN expressions. Can be NULL
17139 ** for a column of an index on an expression */
17140 #ifndef SQLITE_OMIT_WINDOWFUNC
17141 Window *pWin; /* Window definition for window functions */
17142 #endif
17143 };
17144
17145 /*
17146 ** The following are the meanings of bits in the Expr.flags field.
17147 */
@@ -17080,35 +17268,10 @@
17268 int idx; /* Index in some Table.aCol[] of a column named zName */
17269 } *a;
17270 int nId; /* Number of identifiers on the list */
17271 };
17272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17273 /*
17274 ** The following structure describes the FROM clause of a SELECT statement.
17275 ** Each table or subquery in the FROM clause is a separate element of
17276 ** the SrcList.a[] array.
17277 **
@@ -17236,10 +17399,11 @@
17399 } uNC;
17400 NameContext *pNext; /* Next outer name context. NULL for outermost */
17401 int nRef; /* Number of names resolved by this context */
17402 int nErr; /* Number of errors encountered while resolving names */
17403 u16 ncFlags; /* Zero or more NC_* flags defined below */
17404 Select *pWinSelect; /* SELECT statement for any window functions */
17405 };
17406
17407 /*
17408 ** Allowed values for the NameContext, ncFlags field.
17409 **
@@ -17258,10 +17422,11 @@
17422 #define NC_UEList 0x0080 /* True if uNC.pEList is used */
17423 #define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */
17424 #define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */
17425 #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
17426 #define NC_Complex 0x2000 /* True if a function or subquery seen */
17427 #define NC_AllowWin 0x4000 /* Window functions are allowed here */
17428
17429 /*
17430 ** An instance of the following object describes a single ON CONFLICT
17431 ** clause in an upsert.
17432 **
@@ -17312,13 +17477,11 @@
17477 ExprList *pEList; /* The fields of the result */
17478 u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
17479 LogEst nSelectRow; /* Estimated number of result rows */
17480 u32 selFlags; /* Various SF_* values */
17481 int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */
17482 u32 selId; /* Unique identifier number for this SELECT */
 
 
17483 int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */
17484 SrcList *pSrc; /* The FROM clause */
17485 Expr *pWhere; /* The WHERE clause */
17486 ExprList *pGroupBy; /* The GROUP BY clause */
17487 Expr *pHaving; /* The HAVING clause */
@@ -17325,10 +17488,14 @@
17488 ExprList *pOrderBy; /* The ORDER BY clause */
17489 Select *pPrior; /* Prior select in a compound select statement */
17490 Select *pNext; /* Next select to the left in a compound */
17491 Expr *pLimit; /* LIMIT expression. NULL means not used. */
17492 With *pWith; /* WITH clause attached to this select. Or NULL. */
17493 #ifndef SQLITE_OMIT_WINDOWFUNC
17494 Window *pWin; /* List of window functions */
17495 Window *pWinDefn; /* List of named window definitions */
17496 #endif
17497 };
17498
17499 /*
17500 ** Allowed values for Select.selFlags. The "SF" prefix stands for
17501 ** "Select Flag".
@@ -17571,13 +17738,11 @@
17738 yDbMask writeMask; /* Start a write transaction on these databases */
17739 yDbMask cookieMask; /* Bitmask of schema verified databases */
17740 int regRowid; /* Register holding rowid of CREATE TABLE entry */
17741 int regRoot; /* Register holding root page number for new objects */
17742 int nMaxArg; /* Max args passed to user function by sub-program */
17743 int nSelect; /* Number of SELECT stmts. Counter for Select.selId */
 
 
17744 #ifndef SQLITE_OMIT_SHARED_CACHE
17745 int nTableLock; /* Number of locks in aTableLock */
17746 TableLock *aTableLock; /* Required table locks for shared-cache mode */
17747 #endif
17748 AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
@@ -17887,11 +18052,11 @@
18052 #endif
18053 #ifdef SQLITE_VDBE_COVERAGE
18054 /* The following callback (if not NULL) is invoked on every VDBE branch
18055 ** operation. Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE.
18056 */
18057 void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */
18058 void *pVdbeBranchArg; /* 1st argument */
18059 #endif
18060 #ifndef SQLITE_UNTESTABLE
18061 int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
18062 #endif
@@ -17938,10 +18103,11 @@
18103 int *aiCol; /* array of column indexes */
18104 struct IdxCover *pIdxCover; /* Check for index coverage */
18105 struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */
18106 ExprList *pGroupBy; /* GROUP BY clause */
18107 Select *pSelect; /* HAVING to WHERE clause ctx */
18108 struct WindowRewrite *pRewrite; /* Window rewrite context */
18109 } u;
18110 };
18111
18112 /* Forward declarations */
18113 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -17988,10 +18154,72 @@
18154 int iLevel; /* Which level of the tree we are on */
18155 u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */
18156 };
18157 #endif /* SQLITE_DEBUG */
18158
18159 /*
18160 ** This object is used in varioius ways, all related to window functions
18161 **
18162 ** (1) A single instance of this structure is attached to the
18163 ** the Expr.pWin field for each window function in an expression tree.
18164 ** This object holds the information contained in the OVER clause,
18165 ** plus additional fields used during code generation.
18166 **
18167 ** (2) All window functions in a single SELECT form a linked-list
18168 ** attached to Select.pWin. The Window.pFunc and Window.pExpr
18169 ** fields point back to the expression that is the window function.
18170 **
18171 ** (3) The terms of the WINDOW clause of a SELECT are instances of this
18172 ** object on a linked list attached to Select.pWinDefn.
18173 **
18174 ** The uses (1) and (2) are really the same Window object that just happens
18175 ** to be accessible in two different ways. Use (3) is are separate objects.
18176 */
18177 struct Window {
18178 char *zName; /* Name of window (may be NULL) */
18179 ExprList *pPartition; /* PARTITION BY clause */
18180 ExprList *pOrderBy; /* ORDER BY clause */
18181 u8 eType; /* TK_RANGE or TK_ROWS */
18182 u8 eStart; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
18183 u8 eEnd; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
18184 Expr *pStart; /* Expression for "<expr> PRECEDING" */
18185 Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
18186 Window *pNextWin; /* Next window function belonging to this SELECT */
18187 Expr *pFilter; /* The FILTER expression */
18188 FuncDef *pFunc; /* The function */
18189 int iEphCsr; /* Partition buffer or Peer buffer */
18190 int regAccum;
18191 int regResult;
18192 int csrApp; /* Function cursor (used by min/max) */
18193 int regApp; /* Function register (also used by min/max) */
18194 int regPart; /* First in a set of registers holding PARTITION BY
18195 ** and ORDER BY values for the window */
18196 Expr *pOwner; /* Expression object this window is attached to */
18197 int nBufferCol; /* Number of columns in buffer table */
18198 int iArgCol; /* Offset of first argument for this function */
18199 };
18200
18201 #ifndef SQLITE_OMIT_WINDOWFUNC
18202 SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3*, Window*);
18203 SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p);
18204 SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*);
18205 SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*);
18206 SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*);
18207 SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*);
18208 SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);
18209 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*);
18210 SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*);
18211 SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*);
18212 SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p);
18213 SQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p);
18214 SQLITE_PRIVATE void sqlite3WindowFunctions(void);
18215 #else
18216 # define sqlite3WindowDelete(a,b)
18217 # define sqlite3WindowFunctions()
18218 # define sqlite3WindowAttach(a,b,c)
18219 #endif
18220
18221 /*
18222 ** Assuming zIn points to the first byte of a UTF-8 character,
18223 ** advance zIn to point to the first byte of the next UTF-8 character.
18224 */
18225 #define SQLITE_SKIP_UTF8(zIn) { \
@@ -18202,10 +18430,14 @@
18430 SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
18431 SQLITE_PRIVATE void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);
18432 SQLITE_PRIVATE void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
18433 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
18434 SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView*, const With*, u8);
18435 #ifndef SQLITE_OMIT_WINDOWFUNC
18436 SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView*, const Window*, u8);
18437 SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8);
18438 #endif
18439 #endif
18440
18441
18442 SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*);
18443 SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);
@@ -18457,15 +18689,10 @@
18689 SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
18690 SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
18691 SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
18692 SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
18693 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
 
 
 
 
 
18694 SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int);
18695 SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
18696 SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);
18697 SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
18698 SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
@@ -18695,16 +18922,21 @@
18922 SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
18923 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);
18924 SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo*);
18925 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo*);
18926 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);
18927 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList(Parse*, ExprList*, int, int);
18928
18929 #ifdef SQLITE_DEBUG
18930 SQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo*);
18931 #endif
18932 SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
18933 void (*)(sqlite3_context*,int,sqlite3_value **),
18934 void (*)(sqlite3_context*,int,sqlite3_value **),
18935 void (*)(sqlite3_context*),
18936 void (*)(sqlite3_context*),
18937 void (*)(sqlite3_context*,int,sqlite3_value **),
18938 FuncDestructor *pDestructor
18939 );
18940 SQLITE_PRIVATE void sqlite3NoopDestructor(void*);
18941 SQLITE_PRIVATE void sqlite3OomFault(sqlite3*);
18942 SQLITE_PRIVATE void sqlite3OomClear(sqlite3*);
@@ -18741,10 +18973,11 @@
18973 #ifndef SQLITE_AMALGAMATION
18974 SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64), Parse*);
18975 SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*));
18976 #endif
18977 SQLITE_PRIVATE void sqlite3Parser(void*, int, Token);
18978 SQLITE_PRIVATE int sqlite3ParserFallback(int);
18979 #ifdef YYTRACKMAXSTACKDEPTH
18980 SQLITE_PRIVATE int sqlite3ParserStackPeak(void*);
18981 #endif
18982
18983 SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3*);
@@ -19441,10 +19674,11 @@
19674 u8 wrFlag; /* The wrFlag argument to sqlite3BtreeCursor() */
19675 #endif
19676 Bool isEphemeral:1; /* True for an ephemeral table */
19677 Bool useRandomRowid:1; /* Generate new record numbers semi-randomly */
19678 Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
19679 Bool seekHit:1; /* See the OP_SeekHit and OP_IfNoHope opcodes */
19680 Btree *pBtx; /* Separate file holding temporary table */
19681 i64 seqCount; /* Sequence counter */
19682 int *aAltMap; /* Mapping from table to index column numbers */
19683
19684 /* Cached OP_Column parse information is only valid if cacheStatus matches
@@ -19564,11 +19798,15 @@
19798 u32 uTemp; /* Transient storage for serial_type in OP_MakeRecord */
19799 sqlite3 *db; /* The associated database connection */
19800 void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
19801 #ifdef SQLITE_DEBUG
19802 Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
19803 u16 mScopyFlags; /* flags value immediately after the shallow copy */
19804 #endif
19805 #ifdef SQLITE_DEBUG_COLUMNCACHE
19806 u32 iTabColHash; /* Hash of table.column that is origin of this value */
19807 u32 iPadding; /* sqlite3_value objects must be 8-byte aligned */
19808 #endif
19809 };
19810
19811 /*
19812 ** Size of struct Mem not including the Mem.zMalloc member or anything that
@@ -19804,13 +20042,10 @@
20042 SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...);
20043 SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);
20044 void sqliteVdbePopStack(Vdbe*,int);
20045 SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, int*);
20046 SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
 
 
 
20047 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
20048 SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
20049 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int, u32*);
20050 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
20051 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
@@ -19851,10 +20086,13 @@
20086 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
20087 SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem*,u8,u8);
20088 SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);
20089 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
20090 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
20091 #ifndef SQLITE_OMIT_WINDOWFUNC
20092 SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*);
20093 #endif
20094 SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
20095 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
20096 SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int n);
20097 SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
20098 SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
@@ -21953,13 +22191,16 @@
22191
22192 /*
22193 ** Unregister a VFS so that it is no longer accessible.
22194 */
22195 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
22196 MUTEX_LOGIC(sqlite3_mutex *mutex;)
22197 #ifndef SQLITE_OMIT_AUTOINIT
22198 int rc = sqlite3_initialize();
22199 if( rc ) return rc;
22200 #endif
22201 MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )
22202 sqlite3_mutex_enter(mutex);
22203 vfsUnlink(pVfs);
22204 sqlite3_mutex_leave(mutex);
22205 return SQLITE_OK;
22206 }
@@ -27984,25 +28225,17 @@
28225 sqlite3TreeViewWith(pView, p->pWith, 1);
28226 cnt = 1;
28227 sqlite3TreeViewPush(pView, 1);
28228 }
28229 do{
28230 sqlite3TreeViewLine(pView,
28231 "SELECT%s%s (%u/%p) selFlags=0x%x nSelectRow=%d",
28232 ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
28233 ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""),
28234 p->selId, p, p->selFlags,
28235 (int)p->nSelectRow
28236 );
 
 
 
 
 
 
 
 
28237 if( cnt++ ) sqlite3TreeViewPop(pView);
28238 if( p->pPrior ){
28239 n = 1000;
28240 }else{
28241 n = 0;
@@ -28010,12 +28243,27 @@
28243 if( p->pWhere ) n++;
28244 if( p->pGroupBy ) n++;
28245 if( p->pHaving ) n++;
28246 if( p->pOrderBy ) n++;
28247 if( p->pLimit ) n++;
28248 #ifndef SQLITE_OMIT_WINDOWFUNC
28249 if( p->pWin ) n++;
28250 if( p->pWinDefn ) n++;
28251 #endif
28252 }
28253 sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, "result-set");
28254 #ifndef SQLITE_OMIT_WINDOWFUNC
28255 if( p->pWin ){
28256 Window *pX;
28257 pView = sqlite3TreeViewPush(pView, (n--)>0);
28258 sqlite3TreeViewLine(pView, "window-functions");
28259 for(pX=p->pWin; pX; pX=pX->pNextWin){
28260 sqlite3TreeViewWinFunc(pView, pX, pX->pNextWin!=0);
28261 }
28262 sqlite3TreeViewPop(pView);
28263 }
28264 #endif
28265 if( p->pSrc && p->pSrc->nSrc ){
28266 int i;
28267 pView = sqlite3TreeViewPush(pView, (n--)>0);
28268 sqlite3TreeViewLine(pView, "FROM");
28269 for(i=0; i<p->pSrc->nSrc; i++){
@@ -28061,10 +28309,20 @@
28309 if( p->pHaving ){
28310 sqlite3TreeViewItem(pView, "HAVING", (n--)>0);
28311 sqlite3TreeViewExpr(pView, p->pHaving, 0);
28312 sqlite3TreeViewPop(pView);
28313 }
28314 #ifndef SQLITE_OMIT_WINDOWFUNC
28315 if( p->pWinDefn ){
28316 Window *pX;
28317 sqlite3TreeViewItem(pView, "WINDOW", (n--)>0);
28318 for(pX=p->pWinDefn; pX; pX=pX->pNextWin){
28319 sqlite3TreeViewWindow(pView, pX, pX->pNextWin!=0);
28320 }
28321 sqlite3TreeViewPop(pView);
28322 }
28323 #endif
28324 if( p->pOrderBy ){
28325 sqlite3TreeViewExprList(pView, p->pOrderBy, (n--)>0, "ORDERBY");
28326 }
28327 if( p->pLimit ){
28328 sqlite3TreeViewItem(pView, "LIMIT", (n--)>0);
@@ -28088,10 +28346,87 @@
28346 p = p->pPrior;
28347 }while( p!=0 );
28348 sqlite3TreeViewPop(pView);
28349 }
28350
28351 #ifndef SQLITE_OMIT_WINDOWFUNC
28352 /*
28353 ** Generate a description of starting or stopping bounds
28354 */
28355 SQLITE_PRIVATE void sqlite3TreeViewBound(
28356 TreeView *pView, /* View context */
28357 u8 eBound, /* UNBOUNDED, CURRENT, PRECEDING, FOLLOWING */
28358 Expr *pExpr, /* Value for PRECEDING or FOLLOWING */
28359 u8 moreToFollow /* True if more to follow */
28360 ){
28361 switch( eBound ){
28362 case TK_UNBOUNDED: {
28363 sqlite3TreeViewItem(pView, "UNBOUNDED", moreToFollow);
28364 sqlite3TreeViewPop(pView);
28365 break;
28366 }
28367 case TK_CURRENT: {
28368 sqlite3TreeViewItem(pView, "CURRENT", moreToFollow);
28369 sqlite3TreeViewPop(pView);
28370 break;
28371 }
28372 case TK_PRECEDING: {
28373 sqlite3TreeViewItem(pView, "PRECEDING", moreToFollow);
28374 sqlite3TreeViewExpr(pView, pExpr, 0);
28375 sqlite3TreeViewPop(pView);
28376 break;
28377 }
28378 case TK_FOLLOWING: {
28379 sqlite3TreeViewItem(pView, "FOLLOWING", moreToFollow);
28380 sqlite3TreeViewExpr(pView, pExpr, 0);
28381 sqlite3TreeViewPop(pView);
28382 break;
28383 }
28384 }
28385 }
28386 #endif /* SQLITE_OMIT_WINDOWFUNC */
28387
28388 #ifndef SQLITE_OMIT_WINDOWFUNC
28389 /*
28390 ** Generate a human-readable explanation for a Window object
28391 */
28392 SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u8 more){
28393 pView = sqlite3TreeViewPush(pView, more);
28394 if( pWin->zName ){
28395 sqlite3TreeViewLine(pView, "OVER %s", pWin->zName);
28396 }else{
28397 sqlite3TreeViewLine(pView, "OVER");
28398 }
28399 if( pWin->pPartition ){
28400 sqlite3TreeViewExprList(pView, pWin->pPartition, 1, "PARTITION-BY");
28401 }
28402 if( pWin->pOrderBy ){
28403 sqlite3TreeViewExprList(pView, pWin->pOrderBy, 1, "ORDER-BY");
28404 }
28405 if( pWin->eType ){
28406 sqlite3TreeViewItem(pView, pWin->eType==TK_RANGE ? "RANGE" : "ROWS", 0);
28407 sqlite3TreeViewBound(pView, pWin->eStart, pWin->pStart, 1);
28408 sqlite3TreeViewBound(pView, pWin->eEnd, pWin->pEnd, 0);
28409 sqlite3TreeViewPop(pView);
28410 }
28411 sqlite3TreeViewPop(pView);
28412 }
28413 #endif /* SQLITE_OMIT_WINDOWFUNC */
28414
28415 #ifndef SQLITE_OMIT_WINDOWFUNC
28416 /*
28417 ** Generate a human-readable explanation for a Window Function object
28418 */
28419 SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView *pView, const Window *pWin, u8 more){
28420 pView = sqlite3TreeViewPush(pView, more);
28421 sqlite3TreeViewLine(pView, "WINFUNC %s(%d)",
28422 pWin->pFunc->zName, pWin->pFunc->nArg);
28423 sqlite3TreeViewWindow(pView, pWin, 0);
28424 sqlite3TreeViewPop(pView);
28425 }
28426 #endif /* SQLITE_OMIT_WINDOWFUNC */
28427
28428 /*
28429 ** Generate a human-readable explanation of an expression tree.
28430 */
28431 SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){
28432 const char *zBinOp = 0; /* Binary operator */
@@ -28238,24 +28573,36 @@
28573 }
28574
28575 case TK_AGG_FUNCTION:
28576 case TK_FUNCTION: {
28577 ExprList *pFarg; /* List of function arguments */
28578 Window *pWin;
28579 if( ExprHasProperty(pExpr, EP_TokenOnly) ){
28580 pFarg = 0;
28581 pWin = 0;
28582 }else{
28583 pFarg = pExpr->x.pList;
28584 #ifndef SQLITE_OMIT_WINDOWFUNC
28585 pWin = pExpr->pWin;
28586 #else
28587 pWin = 0;
28588 #endif
28589 }
28590 if( pExpr->op==TK_AGG_FUNCTION ){
28591 sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q",
28592 pExpr->op2, pExpr->u.zToken);
28593 }else{
28594 sqlite3TreeViewLine(pView, "FUNCTION %Q", pExpr->u.zToken);
28595 }
28596 if( pFarg ){
28597 sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);
28598 }
28599 #ifndef SQLITe_OMIT_WINDOWFUNC
28600 if( pWin ){
28601 sqlite3TreeViewWindow(pView, pWin, 0);
28602 }
28603 #endif
28604 break;
28605 }
28606 #ifndef SQLITE_OMIT_SUBQUERY
28607 case TK_EXISTS: {
28608 sqlite3TreeViewLine(pView, "EXISTS-expr flags=0x%x", pExpr->flags);
@@ -31283,122 +31630,122 @@
31630 static const char *const azName[] = {
31631 /* 0 */ "Savepoint" OpHelp(""),
31632 /* 1 */ "AutoCommit" OpHelp(""),
31633 /* 2 */ "Transaction" OpHelp(""),
31634 /* 3 */ "SorterNext" OpHelp(""),
31635 /* 4 */ "Prev" OpHelp(""),
31636 /* 5 */ "Next" OpHelp(""),
31637 /* 6 */ "Checkpoint" OpHelp(""),
31638 /* 7 */ "JournalMode" OpHelp(""),
31639 /* 8 */ "Vacuum" OpHelp(""),
31640 /* 9 */ "VFilter" OpHelp("iplan=r[P3] zplan='P4'"),
31641 /* 10 */ "VUpdate" OpHelp("data=r[P3@P2]"),
31642 /* 11 */ "Goto" OpHelp(""),
31643 /* 12 */ "Gosub" OpHelp(""),
31644 /* 13 */ "InitCoroutine" OpHelp(""),
31645 /* 14 */ "Yield" OpHelp(""),
31646 /* 15 */ "MustBeInt" OpHelp(""),
31647 /* 16 */ "Jump" OpHelp(""),
31648 /* 17 */ "Once" OpHelp(""),
31649 /* 18 */ "If" OpHelp(""),
31650 /* 19 */ "Not" OpHelp("r[P2]= !r[P1]"),
31651 /* 20 */ "IfNot" OpHelp(""),
31652 /* 21 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"),
31653 /* 22 */ "SeekLT" OpHelp("key=r[P3@P4]"),
31654 /* 23 */ "SeekLE" OpHelp("key=r[P3@P4]"),
31655 /* 24 */ "SeekGE" OpHelp("key=r[P3@P4]"),
31656 /* 25 */ "SeekGT" OpHelp("key=r[P3@P4]"),
31657 /* 26 */ "IfNoHope" OpHelp("key=r[P3@P4]"),
31658 /* 27 */ "NoConflict" OpHelp("key=r[P3@P4]"),
31659 /* 28 */ "NotFound" OpHelp("key=r[P3@P4]"),
31660 /* 29 */ "Found" OpHelp("key=r[P3@P4]"),
31661 /* 30 */ "SeekRowid" OpHelp("intkey=r[P3]"),
31662 /* 31 */ "NotExists" OpHelp("intkey=r[P3]"),
31663 /* 32 */ "Last" OpHelp(""),
31664 /* 33 */ "IfSmaller" OpHelp(""),
31665 /* 34 */ "SorterSort" OpHelp(""),
31666 /* 35 */ "Sort" OpHelp(""),
31667 /* 36 */ "Rewind" OpHelp(""),
31668 /* 37 */ "IdxLE" OpHelp("key=r[P3@P4]"),
31669 /* 38 */ "IdxGT" OpHelp("key=r[P3@P4]"),
31670 /* 39 */ "IdxLT" OpHelp("key=r[P3@P4]"),
31671 /* 40 */ "IdxGE" OpHelp("key=r[P3@P4]"),
31672 /* 41 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
31673 /* 42 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
31674 /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
31675 /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
31676 /* 45 */ "Program" OpHelp(""),
31677 /* 46 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
31678 /* 47 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
31679 /* 48 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
31680 /* 49 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
31681 /* 50 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
31682 /* 51 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
31683 /* 52 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
31684 /* 53 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
31685 /* 54 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
31686 /* 55 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
31687 /* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
31688 /* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
31689 /* 58 */ "ElseNotEq" OpHelp(""),
31690 /* 59 */ "IncrVacuum" OpHelp(""),
31691 /* 60 */ "VNext" OpHelp(""),
31692 /* 61 */ "Init" OpHelp("Start at P2"),
31693 /* 62 */ "Return" OpHelp(""),
31694 /* 63 */ "EndCoroutine" OpHelp(""),
31695 /* 64 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
31696 /* 65 */ "Halt" OpHelp(""),
31697 /* 66 */ "Integer" OpHelp("r[P2]=P1"),
31698 /* 67 */ "Int64" OpHelp("r[P2]=P4"),
31699 /* 68 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
31700 /* 69 */ "Null" OpHelp("r[P2..P3]=NULL"),
31701 /* 70 */ "SoftNull" OpHelp("r[P1]=NULL"),
31702 /* 71 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
31703 /* 72 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
31704 /* 73 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
31705 /* 74 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
31706 /* 75 */ "SCopy" OpHelp("r[P2]=r[P1]"),
31707 /* 76 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
31708 /* 77 */ "ResultRow" OpHelp("output=r[P1@P2]"),
31709 /* 78 */ "CollSeq" OpHelp(""),
31710 /* 79 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
31711 /* 80 */ "RealAffinity" OpHelp(""),
31712 /* 81 */ "Cast" OpHelp("affinity(r[P1])"),
31713 /* 82 */ "Permutation" OpHelp(""),
31714 /* 83 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
31715 /* 84 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
31716 /* 85 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
31717 /* 86 */ "Column" OpHelp("r[P3]=PX"),
31718 /* 87 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
31719 /* 88 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
31720 /* 89 */ "Count" OpHelp("r[P2]=count()"),
31721 /* 90 */ "ReadCookie" OpHelp(""),
31722 /* 91 */ "SetCookie" OpHelp(""),
31723 /* 92 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
31724 /* 93 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
31725 /* 94 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
31726 /* 95 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
31727 /* 96 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
31728 /* 97 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
31729 /* 98 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
31730 /* 99 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
31731 /* 100 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
31732 /* 101 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
31733 /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
31734 /* 103 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
31735 /* 104 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
31736 /* 105 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
31737 /* 106 */ "String8" OpHelp("r[P2]='P4'"),
31738 /* 107 */ "OpenDup" OpHelp(""),
31739 /* 108 */ "OpenAutoindex" OpHelp("nColumn=P2"),
31740 /* 109 */ "OpenEphemeral" OpHelp("nColumn=P2"),
31741 /* 110 */ "SorterOpen" OpHelp(""),
31742 /* 111 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
31743 /* 112 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
31744 /* 113 */ "Close" OpHelp(""),
31745 /* 114 */ "ColumnsUsed" OpHelp(""),
31746 /* 115 */ "SeekHit" OpHelp("seekHit=P2"),
31747 /* 116 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
31748 /* 117 */ "NewRowid" OpHelp("r[P2]=rowid"),
31749 /* 118 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
31750 /* 119 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
31751 /* 120 */ "Delete" OpHelp(""),
@@ -31413,48 +31760,52 @@
31760 /* 129 */ "IdxInsert" OpHelp("key=r[P2]"),
31761 /* 130 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
31762 /* 131 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
31763 /* 132 */ "IdxRowid" OpHelp("r[P2]=rowid"),
31764 /* 133 */ "Destroy" OpHelp(""),
31765 /* 134 */ "Clear" OpHelp(""),
31766 /* 135 */ "ResetSorter" OpHelp(""),
31767 /* 136 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
31768 /* 137 */ "SqlExec" OpHelp(""),
31769 /* 138 */ "ParseSchema" OpHelp(""),
31770 /* 139 */ "LoadAnalysis" OpHelp(""),
31771 /* 140 */ "DropTable" OpHelp(""),
31772 /* 141 */ "Real" OpHelp("r[P2]=P4"),
31773 /* 142 */ "DropIndex" OpHelp(""),
31774 /* 143 */ "DropTrigger" OpHelp(""),
31775 /* 144 */ "IntegrityCk" OpHelp(""),
31776 /* 145 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
31777 /* 146 */ "Param" OpHelp(""),
31778 /* 147 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
31779 /* 148 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
31780 /* 149 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
31781 /* 150 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
31782 /* 151 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
31783 /* 152 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
31784 /* 153 */ "AggValue" OpHelp("r[P3]=value N=P2"),
31785 /* 154 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
31786 /* 155 */ "Expire" OpHelp(""),
31787 /* 156 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
31788 /* 157 */ "VBegin" OpHelp(""),
31789 /* 158 */ "VCreate" OpHelp(""),
31790 /* 159 */ "VDestroy" OpHelp(""),
31791 /* 160 */ "VOpen" OpHelp(""),
31792 /* 161 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
31793 /* 162 */ "VRename" OpHelp(""),
31794 /* 163 */ "Pagecount" OpHelp(""),
31795 /* 164 */ "MaxPgcnt" OpHelp(""),
31796 /* 165 */ "PureFunc0" OpHelp(""),
31797 /* 166 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
31798 /* 167 */ "PureFunc" OpHelp(""),
31799 /* 168 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
31800 /* 169 */ "Trace" OpHelp(""),
31801 /* 170 */ "CursorHint" OpHelp(""),
31802 /* 171 */ "SetTabCol" OpHelp(""),
31803 /* 172 */ "VerifyTabCol" OpHelp(""),
31804 /* 173 */ "Noop" OpHelp(""),
31805 /* 174 */ "Explain" OpHelp(""),
31806 /* 175 */ "Abortable" OpHelp(""),
31807 };
31808 return azName[i];
31809 }
31810 #endif
31811
@@ -58091,53 +58442,56 @@
58442 return (iPage*HASHTABLE_HASH_1) & (HASHTABLE_NSLOT-1);
58443 }
58444 static int walNextHash(int iPriorHash){
58445 return (iPriorHash+1)&(HASHTABLE_NSLOT-1);
58446 }
58447
58448 /*
58449 ** An instance of the WalHashLoc object is used to describe the location
58450 ** of a page hash table in the wal-index. This becomes the return value
58451 ** from walHashGet().
58452 */
58453 typedef struct WalHashLoc WalHashLoc;
58454 struct WalHashLoc {
58455 volatile ht_slot *aHash; /* Start of the wal-index hash table */
58456 volatile u32 *aPgno; /* aPgno[1] is the page of first frame indexed */
58457 u32 iZero; /* One less than the frame number of first indexed*/
58458 };
58459
58460 /*
58461 ** Return pointers to the hash table and page number array stored on
58462 ** page iHash of the wal-index. The wal-index is broken into 32KB pages
58463 ** numbered starting from 0.
58464 **
58465 ** Set output variable pLoc->aHash to point to the start of the hash table
58466 ** in the wal-index file. Set pLoc->iZero to one less than the frame
58467 ** number of the first frame indexed by this hash table. If a
58468 ** slot in the hash table is set to N, it refers to frame number
58469 ** (pLoc->iZero+N) in the log.
58470 **
58471 ** Finally, set pLoc->aPgno so that pLoc->aPgno[1] is the page number of the
58472 ** first frame indexed by the hash table, frame (pLoc->iZero+1).
58473 */
58474 static int walHashGet(
58475 Wal *pWal, /* WAL handle */
58476 int iHash, /* Find the iHash'th table */
58477 WalHashLoc *pLoc /* OUT: Hash table location */
 
 
58478 ){
58479 int rc; /* Return code */
 
58480
58481 rc = walIndexPage(pWal, iHash, &pLoc->aPgno);
58482 assert( rc==SQLITE_OK || iHash>0 );
58483
58484 if( rc==SQLITE_OK ){
58485 pLoc->aHash = (volatile ht_slot *)&pLoc->aPgno[HASHTABLE_NPAGE];
 
 
 
58486 if( iHash==0 ){
58487 pLoc->aPgno = &pLoc->aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];
58488 pLoc->iZero = 0;
58489 }else{
58490 pLoc->iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;
58491 }
58492 pLoc->aPgno = &pLoc->aPgno[-1];
 
 
 
58493 }
58494 return rc;
58495 }
58496
58497 /*
@@ -58179,13 +58533,11 @@
58533 ** updated. Any later hash tables will be automatically cleared when
58534 ** pWal->hdr.mxFrame advances to the point where those hash tables are
58535 ** actually needed.
58536 */
58537 static void walCleanupHash(Wal *pWal){
58538 WalHashLoc sLoc; /* Hash table location */
 
 
58539 int iLimit = 0; /* Zero values greater than this */
58540 int nByte; /* Number of bytes to zero in aPgno[] */
58541 int i; /* Used to iterate through aHash[] */
58542
58543 assert( pWal->writeLock );
@@ -58199,41 +58551,41 @@
58551 ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
58552 ** that the page said hash-table and array reside on is already mapped.
58553 */
58554 assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
58555 assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
58556 walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
58557
58558 /* Zero all hash-table entries that correspond to frame numbers greater
58559 ** than pWal->hdr.mxFrame.
58560 */
58561 iLimit = pWal->hdr.mxFrame - sLoc.iZero;
58562 assert( iLimit>0 );
58563 for(i=0; i<HASHTABLE_NSLOT; i++){
58564 if( sLoc.aHash[i]>iLimit ){
58565 sLoc.aHash[i] = 0;
58566 }
58567 }
58568
58569 /* Zero the entries in the aPgno array that correspond to frames with
58570 ** frame numbers greater than pWal->hdr.mxFrame.
58571 */
58572 nByte = (int)((char *)sLoc.aHash - (char *)&sLoc.aPgno[iLimit+1]);
58573 memset((void *)&sLoc.aPgno[iLimit+1], 0, nByte);
58574
58575 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
58576 /* Verify that the every entry in the mapping region is still reachable
58577 ** via the hash table even after the cleanup.
58578 */
58579 if( iLimit ){
58580 int j; /* Loop counter */
58581 int iKey; /* Hash key */
58582 for(j=1; j<=iLimit; j++){
58583 for(iKey=walHash(sLoc.aPgno[j]);sLoc.aHash[iKey];iKey=walNextHash(iKey)){
58584 if( sLoc.aHash[iKey]==j ) break;
58585 }
58586 assert( sLoc.aHash[iKey]==j );
58587 }
58588 }
58589 #endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
58590 }
58591
@@ -58242,62 +58594,61 @@
58594 ** Set an entry in the wal-index that will map database page number
58595 ** pPage into WAL frame iFrame.
58596 */
58597 static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
58598 int rc; /* Return code */
58599 WalHashLoc sLoc; /* Wal-index hash table location */
 
 
58600
58601 rc = walHashGet(pWal, walFramePage(iFrame), &sLoc);
58602
58603 /* Assuming the wal-index file was successfully mapped, populate the
58604 ** page number array and hash table entry.
58605 */
58606 if( rc==SQLITE_OK ){
58607 int iKey; /* Hash table key */
58608 int idx; /* Value to write to hash-table slot */
58609 int nCollide; /* Number of hash collisions */
58610
58611 idx = iFrame - sLoc.iZero;
58612 assert( idx <= HASHTABLE_NSLOT/2 + 1 );
58613
58614 /* If this is the first entry to be added to this hash-table, zero the
58615 ** entire hash table and aPgno[] array before proceeding.
58616 */
58617 if( idx==1 ){
58618 int nByte = (int)((u8 *)&sLoc.aHash[HASHTABLE_NSLOT]
58619 - (u8 *)&sLoc.aPgno[1]);
58620 memset((void*)&sLoc.aPgno[1], 0, nByte);
58621 }
58622
58623 /* If the entry in aPgno[] is already set, then the previous writer
58624 ** must have exited unexpectedly in the middle of a transaction (after
58625 ** writing one or more dirty pages to the WAL to free up memory).
58626 ** Remove the remnants of that writers uncommitted transaction from
58627 ** the hash-table before writing any new entries.
58628 */
58629 if( sLoc.aPgno[idx] ){
58630 walCleanupHash(pWal);
58631 assert( !sLoc.aPgno[idx] );
58632 }
58633
58634 /* Write the aPgno[] array entry and the hash-table slot. */
58635 nCollide = idx;
58636 for(iKey=walHash(iPage); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
58637 if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;
58638 }
58639 sLoc.aPgno[idx] = iPage;
58640 sLoc.aHash[iKey] = (ht_slot)idx;
58641
58642 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
58643 /* Verify that the number of entries in the hash table exactly equals
58644 ** the number of entries in the mapping region.
58645 */
58646 {
58647 int i; /* Loop counter */
58648 int nEntry = 0; /* Number of entries in the hash table */
58649 for(i=0; i<HASHTABLE_NSLOT; i++){ if( sLoc.aHash[i] ) nEntry++; }
58650 assert( nEntry==idx );
58651 }
58652
58653 /* Verify that the every entry in the mapping region is reachable
58654 ** via the hash table. This turns out to be a really, really expensive
@@ -58305,14 +58656,16 @@
58656 ** iteration.
58657 */
58658 if( (idx&0x3ff)==0 ){
58659 int i; /* Loop counter */
58660 for(i=1; i<=idx; i++){
58661 for(iKey=walHash(sLoc.aPgno[i]);
58662 sLoc.aHash[iKey];
58663 iKey=walNextHash(iKey)){
58664 if( sLoc.aHash[iKey]==i ) break;
58665 }
58666 assert( sLoc.aHash[iKey]==i );
58667 }
58668 }
58669 #endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
58670 }
58671
@@ -58846,37 +59199,35 @@
59199 if( !aTmp ){
59200 rc = SQLITE_NOMEM_BKPT;
59201 }
59202
59203 for(i=walFramePage(nBackfill+1); rc==SQLITE_OK && i<nSegment; i++){
59204 WalHashLoc sLoc;
 
 
59205
59206 rc = walHashGet(pWal, i, &sLoc);
59207 if( rc==SQLITE_OK ){
59208 int j; /* Counter variable */
59209 int nEntry; /* Number of entries in this segment */
59210 ht_slot *aIndex; /* Sorted index for this segment */
59211
59212 sLoc.aPgno++;
59213 if( (i+1)==nSegment ){
59214 nEntry = (int)(iLast - sLoc.iZero);
59215 }else{
59216 nEntry = (int)((u32*)sLoc.aHash - (u32*)sLoc.aPgno);
59217 }
59218 aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[sLoc.iZero];
59219 sLoc.iZero++;
59220
59221 for(j=0; j<nEntry; j++){
59222 aIndex[j] = (ht_slot)j;
59223 }
59224 walMergesort((u32 *)sLoc.aPgno, aTmp, aIndex, &nEntry);
59225 p->aSegment[i].iZero = sLoc.iZero;
59226 p->aSegment[i].nEntry = nEntry;
59227 p->aSegment[i].aIndex = aIndex;
59228 p->aSegment[i].aPgno = (u32 *)sLoc.aPgno;
59229 }
59230 }
59231 sqlite3_free(aTmp);
59232
59233 if( rc!=SQLITE_OK ){
@@ -59885,20 +60236,18 @@
60236 if( pBuf1==0 || pBuf2==0 ){
60237 rc = SQLITE_NOMEM;
60238 }else{
60239 u32 i = pInfo->nBackfillAttempted;
60240 for(i=pInfo->nBackfillAttempted; i>pInfo->nBackfill; i--){
60241 WalHashLoc sLoc; /* Hash table location */
 
 
60242 u32 pgno; /* Page number in db file */
60243 i64 iDbOff; /* Offset of db file entry */
60244 i64 iWalOff; /* Offset of wal file entry */
60245
60246 rc = walHashGet(pWal, walFramePage(i), &sLoc);
60247 if( rc!=SQLITE_OK ) break;
60248 pgno = sLoc.aPgno[i-sLoc.iZero];
60249 iDbOff = (i64)(pgno-1) * szPage;
60250
60251 if( iDbOff+szPage<=szDb ){
60252 iWalOff = walFrameOffset(i, szPage) + WAL_FRAME_HDRSIZE;
60253 rc = sqlite3OsRead(pWal->pWalFd, pBuf1, szPage, iWalOff);
@@ -60095,25 +60444,24 @@
60444 ** This condition filters out entries that were added to the hash
60445 ** table after the current read-transaction had started.
60446 */
60447 iMinHash = walFramePage(pWal->minFrame);
60448 for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){
60449 WalHashLoc sLoc; /* Hash table location */
 
 
60450 int iKey; /* Hash slot index */
60451 int nCollide; /* Number of hash collisions remaining */
60452 int rc; /* Error code */
60453
60454 rc = walHashGet(pWal, iHash, &sLoc);
60455 if( rc!=SQLITE_OK ){
60456 return rc;
60457 }
60458 nCollide = HASHTABLE_NSLOT;
60459 for(iKey=walHash(pgno); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
60460 u32 iFrame = sLoc.aHash[iKey] + sLoc.iZero;
60461 if( iFrame<=iLast && iFrame>=pWal->minFrame
60462 && sLoc.aPgno[sLoc.aHash[iKey]]==pgno ){
60463 assert( iFrame>iRead || CORRUPT_DB );
60464 iRead = iFrame;
60465 }
60466 if( (nCollide--)==0 ){
60467 return SQLITE_CORRUPT_BKPT;
@@ -65329,11 +65677,11 @@
65677 ** One or the other of the two processes must give way or there can be
65678 ** no progress. By returning SQLITE_BUSY and not invoking the busy callback
65679 ** when A already has a read lock, we encourage A to give up and let B
65680 ** proceed.
65681 */
65682 SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){
65683 BtShared *pBt = p->pBt;
65684 int rc = SQLITE_OK;
65685
65686 sqlite3BtreeEnter(p);
65687 btreeIntegrity(p);
@@ -65404,10 +65752,15 @@
65752 rc = SQLITE_READONLY;
65753 }else{
65754 rc = sqlite3PagerBegin(pBt->pPager,wrflag>1,sqlite3TempInMemory(p->db));
65755 if( rc==SQLITE_OK ){
65756 rc = newDatabase(pBt);
65757 }else if( rc==SQLITE_BUSY_SNAPSHOT && pBt->inTransaction==TRANS_NONE ){
65758 /* if there was no transaction opened when this function was
65759 ** called and SQLITE_BUSY_SNAPSHOT is returned, change the error
65760 ** code to SQLITE_BUSY. */
65761 rc = SQLITE_BUSY;
65762 }
65763 }
65764 }
65765
65766 if( rc!=SQLITE_OK ){
@@ -65455,18 +65808,22 @@
65808 }
65809 }
65810 }
65811 }
65812
 
65813 trans_begun:
65814 if( rc==SQLITE_OK ){
65815 if( pSchemaVersion ){
65816 *pSchemaVersion = get4byte(&pBt->pPage1->aData[40]);
65817 }
65818 if( wrflag ){
65819 /* This call makes sure that the pager has the correct number of
65820 ** open savepoints. If the second parameter is greater than 0 and
65821 ** the sub-journal is not already open, then it will be opened here.
65822 */
65823 rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);
65824 }
65825 }
65826
65827 btreeIntegrity(p);
65828 sqlite3BtreeLeave(p);
65829 return rc;
@@ -67209,10 +67566,27 @@
67566 rc = SQLITE_OK;
67567 }
67568 return rc;
67569 }
67570
67571 /*
67572 ** This function is a no-op if cursor pCur does not point to a valid row.
67573 ** Otherwise, if pCur is valid, configure it so that the next call to
67574 ** sqlite3BtreeNext() is a no-op.
67575 */
67576 #ifndef SQLITE_OMIT_WINDOWFUNC
67577 SQLITE_PRIVATE void sqlite3BtreeSkipNext(BtCursor *pCur){
67578 /* We believe that the cursor must always be in the valid state when
67579 ** this routine is called, but the proof is difficult, so we add an
67580 ** ALWaYS() test just in case we are wrong. */
67581 if( ALWAYS(pCur->eState==CURSOR_VALID) ){
67582 pCur->eState = CURSOR_SKIPNEXT;
67583 pCur->skipNext = 1;
67584 }
67585 }
67586 #endif /* SQLITE_OMIT_WINDOWFUNC */
67587
67588 /* Move the cursor to the last entry in the table. Return SQLITE_OK
67589 ** on success. Set *pRes to 0 if the cursor actually points to something
67590 ** or set *pRes to 1 if the table is empty.
67591 */
67592 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
@@ -67613,11 +67987,20 @@
67987 }
67988 }
67989
67990 pPage = pCur->pPage;
67991 idx = ++pCur->ix;
67992 if( !pPage->isInit ){
67993 /* The only known way for this to happen is for there to be a
67994 ** recursive SQL function that does a DELETE operation as part of a
67995 ** SELECT which deletes content out from under an active cursor
67996 ** in a corrupt database file where the table being DELETE-ed from
67997 ** has pages in common with the table being queried. See TH3
67998 ** module cov1/btree78.test testcase 220 (2018-06-08) for an
67999 ** example. */
68000 return SQLITE_CORRUPT_BKPT;
68001 }
68002
68003 /* If the database file is corrupt, it is possible for the value of idx
68004 ** to be invalid here. This can only occur if a second cursor modifies
68005 ** the page while cursor pCur is holding a reference to it. Which can
68006 ** only happen if the database is corrupt in such a way as to link the
@@ -72113,15 +72496,15 @@
72496 ** WAL connection, even if the version fields are currently set to 2.
72497 */
72498 pBt->btsFlags &= ~BTS_NO_WAL;
72499 if( iVersion==1 ) pBt->btsFlags |= BTS_NO_WAL;
72500
72501 rc = sqlite3BtreeBeginTrans(pBtree, 0, 0);
72502 if( rc==SQLITE_OK ){
72503 u8 *aData = pBt->pPage1->aData;
72504 if( aData[18]!=(u8)iVersion || aData[19]!=(u8)iVersion ){
72505 rc = sqlite3BtreeBeginTrans(pBtree, 2, 0);
72506 if( rc==SQLITE_OK ){
72507 rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
72508 if( rc==SQLITE_OK ){
72509 aData[18] = (u8)iVersion;
72510 aData[19] = (u8)iVersion;
@@ -72557,11 +72940,11 @@
72940 /* If there is no open read-transaction on the source database, open
72941 ** one now. If a transaction is opened here, then it will be closed
72942 ** before this function exits.
72943 */
72944 if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){
72945 rc = sqlite3BtreeBeginTrans(p->pSrc, 0, 0);
72946 bCloseTrans = 1;
72947 }
72948
72949 /* If the destination database has not yet been locked (i.e. if this
72950 ** is the first call to backup_step() for the current backup operation),
@@ -72573,14 +72956,14 @@
72956 rc = SQLITE_NOMEM;
72957 }
72958
72959 /* Lock the destination database, if it is not locked already. */
72960 if( SQLITE_OK==rc && p->bDestLocked==0
72961 && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2,
72962 (int*)&p->iDestSchema))
72963 ){
72964 p->bDestLocked = 1;
 
72965 }
72966
72967 /* Do not allow backup if the destination database is in WAL mode
72968 ** and the page sizes are different between source and destination */
72969 pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);
@@ -73393,10 +73776,39 @@
73776 if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
73777 memcpy(pMem, &t, sizeof(t));
73778 return ctx.isError;
73779 }
73780
73781 /*
73782 ** Memory cell pAccum contains the context of an aggregate function.
73783 ** This routine calls the xValue method for that function and stores
73784 ** the results in memory cell pMem.
73785 **
73786 ** SQLITE_ERROR is returned if xValue() reports an error. SQLITE_OK
73787 ** otherwise.
73788 */
73789 #ifndef SQLITE_OMIT_WINDOWFUNC
73790 SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem *pAccum, Mem *pOut, FuncDef *pFunc){
73791 sqlite3_context ctx;
73792 Mem t;
73793 assert( pFunc!=0 );
73794 assert( pFunc->xValue!=0 );
73795 assert( (pAccum->flags & MEM_Null)!=0 || pFunc==pAccum->u.pDef );
73796 assert( pAccum->db==0 || sqlite3_mutex_held(pAccum->db->mutex) );
73797 memset(&ctx, 0, sizeof(ctx));
73798 memset(&t, 0, sizeof(t));
73799 t.flags = MEM_Null;
73800 t.db = pAccum->db;
73801 sqlite3VdbeMemSetNull(pOut);
73802 ctx.pOut = pOut;
73803 ctx.pMem = pAccum;
73804 ctx.pFunc = pFunc;
73805 pFunc->xValue(&ctx);
73806 return ctx.isError;
73807 }
73808 #endif /* SQLITE_OMIT_WINDOWFUNC */
73809
73810 /*
73811 ** If the memory cell contains a value that must be freed by
73812 ** invoking the external callback in Mem.xDel, then this routine
73813 ** will free that value. It also sets Mem.flags to MEM_Null.
73814 **
@@ -73864,15 +74276,32 @@
74276 SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
74277 int i;
74278 Mem *pX;
74279 for(i=0, pX=pVdbe->aMem; i<pVdbe->nMem; i++, pX++){
74280 if( pX->pScopyFrom==pMem ){
74281 /* If pX is marked as a shallow copy of pMem, then verify that
74282 ** no significant changes have been made to pX since the OP_SCopy.
74283 ** A significant change would indicated a missed call to this
74284 ** function for pX. Minor changes, such as adding or removing a
74285 ** dual type, are allowed, as long as the underlying value is the
74286 ** same. */
74287 u16 mFlags = pMem->flags & pX->flags & pX->mScopyFlags;
74288 assert( (mFlags&MEM_Int)==0 || pMem->u.i==pX->u.i );
74289 assert( (mFlags&MEM_Real)==0 || pMem->u.r==pX->u.r );
74290 assert( (mFlags&MEM_Str)==0 || (pMem->n==pX->n && pMem->z==pX->z) );
74291 assert( (mFlags&MEM_Blob)==0 || sqlite3BlobCompare(pMem,pX)==0 );
74292
74293 /* pMem is the register that is changing. But also mark pX as
74294 ** undefined so that we can quickly detect the shallow-copy error */
74295 pX->flags = MEM_Undefined;
74296 pX->pScopyFrom = 0;
74297 }
74298 }
74299 pMem->pScopyFrom = 0;
74300 #ifdef SQLITE_DEBUG_COLUMN_CACHE
74301 pMem->iTabColHash = 0;
74302 #endif
74303 }
74304 #endif /* SQLITE_DEBUG */
74305
74306
74307 /*
@@ -73889,10 +74318,13 @@
74318 SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
74319 assert( (pFrom->flags & MEM_RowSet)==0 );
74320 assert( pTo->db==pFrom->db );
74321 if( VdbeMemDynamic(pTo) ){ vdbeClrCopy(pTo,pFrom,srcType); return; }
74322 memcpy(pTo, pFrom, MEMCELLSIZE);
74323 #ifdef SQLITE_DEBUG_COLUMNCACHE
74324 pTo->iTabColHash = pFrom->iTabColHash;
74325 #endif
74326 if( (pFrom->flags&MEM_Static)==0 ){
74327 pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
74328 assert( srcType==MEM_Ephem || srcType==MEM_Static );
74329 pTo->flags |= srcType;
74330 }
@@ -73906,10 +74338,13 @@
74338 int rc = SQLITE_OK;
74339
74340 assert( (pFrom->flags & MEM_RowSet)==0 );
74341 if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);
74342 memcpy(pTo, pFrom, MEMCELLSIZE);
74343 #ifdef SQLITE_DEBUG_COLUMNCACHE
74344 pTo->iTabColHash = pFrom->iTabColHash;
74345 #endif
74346 pTo->flags &= ~MEM_Dyn;
74347 if( pTo->flags&(MEM_Str|MEM_Blob) ){
74348 if( 0==(pFrom->flags&MEM_Static) ){
74349 pTo->flags |= MEM_Ephem;
74350 rc = sqlite3VdbeMemMakeWriteable(pTo);
@@ -75510,22 +75945,20 @@
75945 p->readOnly = 0;
75946 p->bIsReader = 1;
75947 break;
75948 }
75949 case OP_Next:
 
75950 case OP_SorterNext: {
75951 pOp->p4.xAdvance = sqlite3BtreeNext;
75952 pOp->p4type = P4_ADVANCE;
75953 /* The code generator never codes any of these opcodes as a jump
75954 ** to a label. They are always coded as a jump backwards to a
75955 ** known address */
75956 assert( pOp->p2>=0 );
75957 break;
75958 }
75959 case OP_Prev: {
 
75960 pOp->p4.xAdvance = sqlite3BtreePrevious;
75961 pOp->p4type = P4_ADVANCE;
75962 /* The code generator never codes any of these opcodes as a jump
75963 ** to a label. They are always coded as a jump backwards to a
75964 ** known address */
@@ -76436,11 +76869,11 @@
76869
76870 #if defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
76871 /*
76872 ** Print a single opcode. This routine is used for debugging only.
76873 */
76874 SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE *pOut, int pc, VdbeOp *pOp){
76875 char *zP4;
76876 char zPtr[50];
76877 char zCom[100];
76878 static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-13s %.2X %s\n";
76879 if( pOut==0 ) pOut = stdout;
@@ -76469,10 +76902,13 @@
76902 p->db = db;
76903 p->flags = flags;
76904 p->szMalloc = 0;
76905 #ifdef SQLITE_DEBUG
76906 p->pScopyFrom = 0;
76907 #endif
76908 #ifdef SQLITE_DEBUG_COLUMNCACHE
76909 p->iTabColHash = 0;
76910 #endif
76911 p++;
76912 }
76913 }
76914
@@ -78735,11 +79171,11 @@
79171 /*
79172 ** Compare two blobs. Return negative, zero, or positive if the first
79173 ** is less than, equal to, or greater than the second, respectively.
79174 ** If one blob is a prefix of the other, then the shorter is the lessor.
79175 */
79176 SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){
79177 int c;
79178 int n1 = pB1->n;
79179 int n2 = pB2->n;
79180
79181 /* It is possible to have a Blob value that has some non-zero content
@@ -78950,11 +79386,11 @@
79386 int i; /* Index of next field to compare */
79387 u32 szHdr1; /* Size of record header in bytes */
79388 u32 idx1; /* Offset of first type in header */
79389 int rc = 0; /* Return value */
79390 Mem *pRhs = pPKey2->aMem; /* Next field of pPKey2 to compare */
79391 KeyInfo *pKeyInfo;
79392 const unsigned char *aKey1 = (const unsigned char *)pKey1;
79393 Mem mem1;
79394
79395 /* If bSkip is true, then the caller has already determined that the first
79396 ** two elements in the keys are equal. Fix the various stack variables so
@@ -79045,11 +79481,11 @@
79481 testcase( (d1+mem1.n)==(unsigned)nKey1 );
79482 testcase( (d1+mem1.n+1)==(unsigned)nKey1 );
79483 if( (d1+mem1.n) > (unsigned)nKey1 ){
79484 pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
79485 return 0; /* Corruption */
79486 }else if( (pKeyInfo = pPKey2->pKeyInfo)->aColl[i] ){
79487 mem1.enc = pKeyInfo->enc;
79488 mem1.db = pKeyInfo->db;
79489 mem1.flags = MEM_Str;
79490 mem1.z = (char*)&aKey1[d1];
79491 rc = vdbeCompareMemString(
@@ -79096,23 +79532,24 @@
79532 serial_type = aKey1[idx1];
79533 rc = (serial_type!=0);
79534 }
79535
79536 if( rc!=0 ){
79537 if( pPKey2->pKeyInfo->aSortOrder[i] ){
79538 rc = -rc;
79539 }
79540 assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );
79541 assert( mem1.szMalloc==0 ); /* See comment below */
79542 return rc;
79543 }
79544
79545 i++;
79546 if( i==pPKey2->nField ) break;
79547 pRhs++;
79548 d1 += sqlite3VdbeSerialTypeLen(serial_type);
79549 idx1 += sqlite3VarintLen(serial_type);
79550 }while( idx1<(unsigned)szHdr1 && d1<=(unsigned)nKey1 );
79551
79552 /* No memory allocation is ever used on mem1. Prove this using
79553 ** the following assert(). If the assert() fails, it indicates a
79554 ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1). */
79555 assert( mem1.szMalloc==0 );
@@ -79120,11 +79557,11 @@
79557 /* rc==0 here means that one or both of the keys ran out of fields and
79558 ** all the fields up to that point were equal. Return the default_rc
79559 ** value. */
79560 assert( CORRUPT_DB
79561 || vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, pPKey2->default_rc)
79562 || pPKey2->pKeyInfo->db->mallocFailed
79563 );
79564 pPKey2->eqSeen = 1;
79565 return pPKey2->default_rc;
79566 }
79567 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
@@ -79446,11 +79883,11 @@
79883 sqlite3VdbeMemInit(&m, db, 0);
79884 rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);
79885 if( rc ){
79886 return rc;
79887 }
79888 *res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, pUnpacked, 0);
79889 sqlite3VdbeMemRelease(&m);
79890 return SQLITE_OK;
79891 }
79892
79893 /*
@@ -80642,11 +81079,14 @@
81079 /* .uTemp = */ (u32)0,
81080 /* .db = */ (sqlite3*)0,
81081 /* .xDel = */ (void(*)(void*))0,
81082 #ifdef SQLITE_DEBUG
81083 /* .pScopyFrom = */ (Mem*)0,
81084 /* .mScopyFlags= */ 0,
81085 #endif
81086 #ifdef SQLITE_DEBUG_COLUMNCACHE
81087 /* .iTabColHash= */ 0,
81088 #endif
81089 };
81090 return &nullMem;
81091 }
81092
@@ -81866,10 +82306,22 @@
82306 # define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)
82307 #else
82308 # define memAboutToChange(P,M)
82309 #endif
82310
82311 /*
82312 ** Given a cursor number and a column for a table or index, compute a
82313 ** hash value for use in the Mem.iTabColHash value. The iTabColHash
82314 ** column is only used for verification - it is omitted from production
82315 ** builds. Collisions are harmless in the sense that the correct answer
82316 ** still results. The only harm of collisions is that they can potential
82317 ** reduce column-cache error detection during SQLITE_DEBUG builds.
82318 **
82319 ** No valid hash should be 0.
82320 */
82321 #define TableColumnHash(T,C) (((u32)(T)<<16)^(u32)(C+2))
82322
82323 /*
82324 ** The following global variable is incremented every time a cursor
82325 ** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test
82326 ** procedures use this information to make sure that indices are
82327 ** working correctly. This variable has no function other than to
@@ -81952,36 +82404,60 @@
82404 /*
82405 ** Invoke the VDBE coverage callback, if that callback is defined. This
82406 ** feature is used for test suite validation only and does not appear an
82407 ** production builds.
82408 **
82409 ** M is an integer between 2 and 4. 2 indicates a ordinary two-way
82410 ** branch (I=0 means fall through and I=1 means taken). 3 indicates
82411 ** a 3-way branch where the third way is when one of the operands is
82412 ** NULL. 4 indicates the OP_Jump instruction which has three destinations
82413 ** depending on whether the first operand is less than, equal to, or greater
82414 ** than the second.
82415 **
82416 ** iSrcLine is the source code line (from the __LINE__ macro) that
82417 ** generated the VDBE instruction combined with flag bits. The source
82418 ** code line number is in the lower 24 bits of iSrcLine and the upper
82419 ** 8 bytes are flags. The lower three bits of the flags indicate
82420 ** values for I that should never occur. For example, if the branch is
82421 ** always taken, the flags should be 0x05 since the fall-through and
82422 ** alternate branch are never taken. If a branch is never taken then
82423 ** flags should be 0x06 since only the fall-through approach is allowed.
82424 **
82425 ** Bit 0x04 of the flags indicates an OP_Jump opcode that is only
82426 ** interested in equal or not-equal. In other words, I==0 and I==2
82427 ** should be treated the same.
82428 **
82429 ** Since only a line number is retained, not the filename, this macro
82430 ** only works for amalgamation builds. But that is ok, since these macros
82431 ** should be no-ops except for special builds used to measure test coverage.
82432 */
82433 #if !defined(SQLITE_VDBE_COVERAGE)
82434 # define VdbeBranchTaken(I,M)
82435 #else
82436 # define VdbeBranchTaken(I,M) vdbeTakeBranch(pOp->iSrcLine,I,M)
82437 static void vdbeTakeBranch(u32 iSrcLine, u8 I, u8 M){
82438 u8 mNever;
82439 assert( I<=2 ); /* 0: fall through, 1: taken, 2: alternate taken */
82440 assert( M<=4 ); /* 2: two-way branch, 3: three-way branch, 4: OP_Jump */
82441 assert( I<M ); /* I can only be 2 if M is 3 or 4 */
82442 /* Transform I from a integer [0,1,2] into a bitmask of [1,2,4] */
82443 I = 1<<I;
82444 /* The upper 8 bits of iSrcLine are flags. The lower three bits of
82445 ** the flags indicate directions that the branch can never go. If
82446 ** a branch really does go in one of those directions, assert right
82447 ** away. */
82448 mNever = iSrcLine >> 24;
82449 assert( (I & mNever)==0 );
82450 if( sqlite3GlobalConfig.xVdbeBranch==0 ) return; /*NO_TEST*/
82451 I |= mNever;
82452 if( M==2 ) I |= 0x04;
82453 if( M==4 ){
82454 I |= 0x08;
82455 if( (mNever&0x08)!=0 && (I&0x05)!=0) I |= 0x05; /*NO_TEST*/
82456 }
82457 sqlite3GlobalConfig.xVdbeBranch(sqlite3GlobalConfig.pVdbeBranchArg,
82458 iSrcLine&0xffffff, I, M);
82459 }
82460 #endif
82461
82462 /*
82463 ** Convert the given register into a string if it isn't one
@@ -83062,10 +83538,13 @@
83538 pOut = out2Prerelease(p, pOp);
83539 cnt = pOp->p3-pOp->p2;
83540 assert( pOp->p3<=(p->nMem+1 - p->nCursor) );
83541 pOut->flags = nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null;
83542 pOut->n = 0;
83543 #ifdef SQLITE_DEBUG
83544 pOut->uTemp = 0;
83545 #endif
83546 while( cnt>0 ){
83547 pOut++;
83548 memAboutToChange(p, pOut);
83549 sqlite3VdbeMemSetNull(pOut);
83550 pOut->flags = nullFlag;
@@ -83183,14 +83662,16 @@
83662 n = pOp->p3;
83663 pIn1 = &aMem[pOp->p1];
83664 pOut = &aMem[pOp->p2];
83665 assert( pOut!=pIn1 );
83666 while( 1 ){
83667 memAboutToChange(p, pOut);
83668 sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
83669 Deephemeralize(pOut);
83670 #ifdef SQLITE_DEBUG
83671 pOut->pScopyFrom = 0;
83672 pOut->iTabColHash = 0;
83673 #endif
83674 REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);
83675 if( (n--)==0 ) break;
83676 pOut++;
83677 pIn1++;
@@ -83215,11 +83696,12 @@
83696 pIn1 = &aMem[pOp->p1];
83697 pOut = &aMem[pOp->p2];
83698 assert( pOut!=pIn1 );
83699 sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
83700 #ifdef SQLITE_DEBUG
83701 pOut->pScopyFrom = pIn1;
83702 pOut->mScopyFlags = pIn1->flags;
83703 #endif
83704 break;
83705 }
83706
83707 /* Opcode: IntCopy P1 P2 * * *
@@ -84063,15 +84545,15 @@
84545 ** in the most recent OP_Compare instruction the P1 vector was less than
84546 ** equal to, or greater than the P2 vector, respectively.
84547 */
84548 case OP_Jump: { /* jump */
84549 if( iCompare<0 ){
84550 VdbeBranchTaken(0,4); pOp = &aOp[pOp->p1 - 1];
84551 }else if( iCompare==0 ){
84552 VdbeBranchTaken(1,4); pOp = &aOp[pOp->p2 - 1];
84553 }else{
84554 VdbeBranchTaken(2,4); pOp = &aOp[pOp->p3 - 1];
84555 }
84556 break;
84557 }
84558
84559 /* Opcode: And P1 P2 P3 * *
@@ -84164,11 +84646,11 @@
84646 }
84647 break;
84648 }
84649
84650 /* Opcode: BitNot P1 P2 * * *
84651 ** Synopsis: r[P2]= ~r[P1]
84652 **
84653 ** Interpret the content of register P1 as an integer. Store the
84654 ** ones-complement of the P1 value into register P2. If P1 holds
84655 ** a NULL then store a NULL in P2.
84656 */
@@ -85121,12 +85603,11 @@
85603 ** halts. The sqlite3_step() wrapper function might then reprepare the
85604 ** statement and rerun it from the beginning.
85605 */
85606 case OP_Transaction: {
85607 Btree *pBt;
85608 int iMeta = 0;
 
85609
85610 assert( p->bIsReader );
85611 assert( p->readOnly==0 || pOp->p2==0 );
85612 assert( pOp->p1>=0 && pOp->p1<db->nDb );
85613 assert( DbMaskTest(p->btreeMask, pOp->p1) );
@@ -85135,11 +85616,11 @@
85616 goto abort_due_to_error;
85617 }
85618 pBt = db->aDb[pOp->p1].pBt;
85619
85620 if( pBt ){
85621 rc = sqlite3BtreeBeginTrans(pBt, pOp->p2, &iMeta);
85622 testcase( rc==SQLITE_BUSY_SNAPSHOT );
85623 testcase( rc==SQLITE_BUSY_RECOVERY );
85624 if( rc!=SQLITE_OK ){
85625 if( (rc&0xff)==SQLITE_BUSY ){
85626 p->pc = (int)(pOp - aOp);
@@ -85168,23 +85649,21 @@
85649 ** counter. If the statement transaction needs to be rolled back,
85650 ** the value of this counter needs to be restored too. */
85651 p->nStmtDefCons = db->nDeferredCons;
85652 p->nStmtDefImmCons = db->nDeferredImmCons;
85653 }
85654 }
85655 assert( pOp->p5==0 || pOp->p4type==P4_INT32 );
85656 if( pOp->p5
85657 && (iMeta!=pOp->p3
85658 || db->aDb[pOp->p1].pSchema->iGeneration!=pOp->p4.i)
85659 ){
85660 /*
85661 ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema
85662 ** version is checked to ensure that the schema has not changed since the
85663 ** SQL statement was prepared.
85664 */
 
 
 
 
 
 
 
85665 sqlite3DbFree(db, p->zErrMsg);
85666 p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed");
85667 /* If the schema-cookie from the database file matches the cookie
85668 ** stored with the in-memory representation of the schema, do
85669 ** not reload the schema from the database file.
@@ -85289,63 +85768,82 @@
85768 ** temporary tables, and P3>1 means used the corresponding attached
85769 ** database. Give the new cursor an identifier of P1. The P1
85770 ** values need not be contiguous but all P1 values should be small integers.
85771 ** It is an error for P1 to be negative.
85772 **
85773 ** Allowed P5 bits:
85774 ** <ul>
85775 ** <li> <b>0x02 OPFLAG_SEEKEQ</b>: This cursor will only be used for
85776 ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT
85777 ** of OP_SeekLE/OP_IdxGT)
85778 ** </ul>
 
 
 
 
 
85779 **
85780 ** The P4 value may be either an integer (P4_INT32) or a pointer to
85781 ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
85782 ** object, then table being opened must be an [index b-tree] where the
85783 ** KeyInfo object defines the content and collating
85784 ** sequence of that index b-tree. Otherwise, if P4 is an integer
85785 ** value, then the table being opened must be a [table b-tree] with a
85786 ** number of columns no less than the value of P4.
85787 **
85788 ** See also: OpenWrite, ReopenIdx
85789 */
85790 /* Opcode: ReopenIdx P1 P2 P3 P4 P5
85791 ** Synopsis: root=P2 iDb=P3
85792 **
85793 ** The ReopenIdx opcode works like OP_OpenRead except that it first
85794 ** checks to see if the cursor on P1 is already open on the same
85795 ** b-tree and if it is this opcode becomes a no-op. In other words,
85796 ** if the cursor is already open, do not reopen it.
85797 **
85798 ** The ReopenIdx opcode may only be used with P5==0 or P5==OPFLAG_SEEKEQ
85799 ** and with P4 being a P4_KEYINFO object. Furthermore, the P3 value must
85800 ** be the same as every other ReopenIdx or OpenRead for the same cursor
85801 ** number.
85802 **
85803 ** Allowed P5 bits:
85804 ** <ul>
85805 ** <li> <b>0x02 OPFLAG_SEEKEQ</b>: This cursor will only be used for
85806 ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT
85807 ** of OP_SeekLE/OP_IdxGT)
85808 ** </ul>
85809 **
85810 ** See also: OP_OpenRead, OP_OpenWrite
85811 */
85812 /* Opcode: OpenWrite P1 P2 P3 P4 P5
85813 ** Synopsis: root=P2 iDb=P3
85814 **
85815 ** Open a read/write cursor named P1 on the table or index whose root
85816 ** page is P2 (or whose root page is held in register P2 if the
85817 ** OPFLAG_P2ISREG bit is set in P5 - see below).
85818 **
85819 ** The P4 value may be either an integer (P4_INT32) or a pointer to
85820 ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
85821 ** object, then table being opened must be an [index b-tree] where the
85822 ** KeyInfo object defines the content and collating
85823 ** sequence of that index b-tree. Otherwise, if P4 is an integer
85824 ** value, then the table being opened must be a [table b-tree] with a
85825 ** number of columns no less than the value of P4.
85826 **
85827 ** Allowed P5 bits:
85828 ** <ul>
85829 ** <li> <b>0x02 OPFLAG_SEEKEQ</b>: This cursor will only be used for
85830 ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT
85831 ** of OP_SeekLE/OP_IdxGT)
85832 ** <li> <b>0x08 OPFLAG_FORDELETE</b>: This cursor is used only to seek
85833 ** and subsequently delete entries in an index btree. This is a
85834 ** hint to the storage engine that the storage engine is allowed to
85835 ** ignore. The hint is not used by the official SQLite b*tree storage
85836 ** engine, but is used by COMDB2.
85837 ** <li> <b>0x10 OPFLAG_P2ISREG</b>: Use the content of register P2
85838 ** as the root page, not the value of P2 itself.
85839 ** </ul>
85840 **
85841 ** This instruction works like OpenRead except that it opens the cursor
85842 ** in read/write mode.
85843 **
85844 ** See also: OP_OpenRead, OP_ReopenIdx
85845 */
85846 case OP_ReopenIdx: {
85847 int nField;
85848 KeyInfo *pKeyInfo;
85849 int p2;
@@ -85397,10 +85895,11 @@
85895 wrFlag = 0;
85896 }
85897 if( pOp->p5 & OPFLAG_P2ISREG ){
85898 assert( p2>0 );
85899 assert( p2<=(p->nMem+1 - p->nCursor) );
85900 assert( pOp->opcode==OP_OpenWrite );
85901 pIn2 = &aMem[p2];
85902 assert( memIsValid(pIn2) );
85903 assert( (pIn2->flags & MEM_Int)!=0 );
85904 sqlite3VdbeMemIntegerify(pIn2);
85905 p2 = (int)pIn2->u.i;
@@ -85525,11 +86024,11 @@
86024 pCx->nullRow = 1;
86025 pCx->isEphemeral = 1;
86026 rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
86027 BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags);
86028 if( rc==SQLITE_OK ){
86029 rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
86030 }
86031 if( rc==SQLITE_OK ){
86032 /* If a transient index is required, create it by calling
86033 ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
86034 ** opening it. If a transient table is required, just use the
@@ -85932,10 +86431,29 @@
86431 assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
86432 pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */
86433 }
86434 break;
86435 }
86436
86437 /* Opcode: SeekHit P1 P2 * * *
86438 ** Synopsis: seekHit=P2
86439 **
86440 ** Set the seekHit flag on cursor P1 to the value in P2.
86441 ** The seekHit flag is used by the IfNoHope opcode.
86442 **
86443 ** P1 must be a valid b-tree cursor. P2 must be a boolean value,
86444 ** either 0 or 1.
86445 */
86446 case OP_SeekHit: {
86447 VdbeCursor *pC;
86448 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
86449 pC = p->apCsr[pOp->p1];
86450 assert( pC!=0 );
86451 assert( pOp->p2==0 || pOp->p2==1 );
86452 pC->seekHit = pOp->p2 & 1;
86453 break;
86454 }
86455
86456 /* Opcode: Found P1 P2 P3 P4 *
86457 ** Synopsis: key=r[P3@P4]
86458 **
86459 ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If
@@ -85967,11 +86485,38 @@
86485 **
86486 ** This operation leaves the cursor in a state where it cannot be
86487 ** advanced in either direction. In other words, the Next and Prev
86488 ** opcodes do not work after this operation.
86489 **
86490 ** See also: Found, NotExists, NoConflict, IfNoHope
86491 */
86492 /* Opcode: IfNoHope P1 P2 P3 P4 *
86493 ** Synopsis: key=r[P3@P4]
86494 **
86495 ** Register P3 is the first of P4 registers that form an unpacked
86496 ** record.
86497 **
86498 ** Cursor P1 is on an index btree. If the seekHit flag is set on P1, then
86499 ** this opcode is a no-op. But if the seekHit flag of P1 is clear, then
86500 ** check to see if there is any entry in P1 that matches the
86501 ** prefix identified by P3 and P4. If no entry matches the prefix,
86502 ** jump to P2. Otherwise fall through.
86503 **
86504 ** This opcode behaves like OP_NotFound if the seekHit
86505 ** flag is clear and it behaves like OP_Noop if the seekHit flag is set.
86506 **
86507 ** This opcode is used in IN clause processing for a multi-column key.
86508 ** If an IN clause is attached to an element of the key other than the
86509 ** left-most element, and if there are no matches on the most recent
86510 ** seek over the whole key, then it might be that one of the key element
86511 ** to the left is prohibiting a match, and hence there is "no hope" of
86512 ** any match regardless of how many IN clause elements are checked.
86513 ** In such a case, we abandon the IN clause search early, using this
86514 ** opcode. The opcode name comes from the fact that the
86515 ** jump is taken if there is "no hope" of achieving a match.
86516 **
86517 ** See also: NotFound, SeekHit
86518 */
86519 /* Opcode: NoConflict P1 P2 P3 P4 *
86520 ** Synopsis: key=r[P3@P4]
86521 **
86522 ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If
@@ -85992,10 +86537,18 @@
86537 ** advanced in either direction. In other words, the Next and Prev
86538 ** opcodes do not work after this operation.
86539 **
86540 ** See also: NotFound, Found, NotExists
86541 */
86542 case OP_IfNoHope: { /* jump, in3 */
86543 VdbeCursor *pC;
86544 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
86545 pC = p->apCsr[pOp->p1];
86546 assert( pC!=0 );
86547 if( pC->seekHit ) break;
86548 /* Fall through into OP_NotFound */
86549 }
86550 case OP_NoConflict: /* jump, in3 */
86551 case OP_NotFound: /* jump, in3 */
86552 case OP_Found: { /* jump, in3 */
86553 int alreadyExists;
86554 int takeJump;
@@ -86140,11 +86693,11 @@
86693 assert( pIn3->flags & MEM_Int );
86694 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
86695 pC = p->apCsr[pOp->p1];
86696 assert( pC!=0 );
86697 #ifdef SQLITE_DEBUG
86698 pC->seekOp = OP_SeekRowid;
86699 #endif
86700 assert( pC->isTable );
86701 assert( pC->eCurType==CURTYPE_BTREE );
86702 pCrsr = pC->uc.pCursor;
86703 assert( pCrsr!=0 );
@@ -86794,10 +87347,13 @@
87347 pC->cacheStatus = CACHE_STALE;
87348 if( pC->eCurType==CURTYPE_BTREE ){
87349 assert( pC->uc.pCursor!=0 );
87350 sqlite3BtreeClearCursor(pC->uc.pCursor);
87351 }
87352 #ifdef SQLITE_DEBUG
87353 if( pC->seekOp==0 ) pC->seekOp = OP_NullRow;
87354 #endif
87355 break;
87356 }
87357
87358 /* Opcode: SeekEnd P1 * * * *
87359 **
@@ -86912,17 +87468,21 @@
87468 sqlite3_search_count--;
87469 #endif
87470 p->aCounter[SQLITE_STMTSTATUS_SORT]++;
87471 /* Fall through into OP_Rewind */
87472 }
87473 /* Opcode: Rewind P1 P2 * * P5
87474 **
87475 ** The next use of the Rowid or Column or Next instruction for P1
87476 ** will refer to the first entry in the database table or index.
87477 ** If the table or index is empty, jump immediately to P2.
87478 ** If the table or index is not empty, fall through to the following
87479 ** instruction.
87480 **
87481 ** If P5 is non-zero and the table is not empty, then the "skip-next"
87482 ** flag is set on the cursor so that the next OP_Next instruction
87483 ** executed on it is a no-op.
87484 **
87485 ** This opcode leaves the cursor configured to move in forward order,
87486 ** from the beginning toward the end. In other words, the cursor is
87487 ** configured to use Next, not Prev.
87488 */
@@ -86944,10 +87504,13 @@
87504 }else{
87505 assert( pC->eCurType==CURTYPE_BTREE );
87506 pCrsr = pC->uc.pCursor;
87507 assert( pCrsr );
87508 rc = sqlite3BtreeFirst(pCrsr, &res);
87509 #ifndef SQLITE_OMIT_WINDOWFUNC
87510 if( pOp->p5 ) sqlite3BtreeSkipNext(pCrsr);
87511 #endif
87512 pC->deferredMoveto = 0;
87513 pC->cacheStatus = CACHE_STALE;
87514 }
87515 if( rc ) goto abort_due_to_error;
87516 pC->nullRow = (u8)res;
@@ -86980,16 +87543,11 @@
87543 ** sqlite3BtreeNext().
87544 **
87545 ** If P5 is positive and the jump is taken, then event counter
87546 ** number P5-1 in the prepared statement is incremented.
87547 **
87548 ** See also: Prev
 
 
 
 
 
87549 */
87550 /* Opcode: Prev P1 P2 P3 P4 P5
87551 **
87552 ** Back up cursor P1 so that it points to the previous key/data pair in its
87553 ** table or index. If there is no previous key/value pairs then fall through
@@ -87013,15 +87571,10 @@
87571 ** sqlite3BtreePrevious().
87572 **
87573 ** If P5 is positive and the jump is taken, then event counter
87574 ** number P5-1 in the prepared statement is incremented.
87575 */
 
 
 
 
 
87576 /* Opcode: SorterNext P1 P2 * * P5
87577 **
87578 ** This opcode works just like OP_Next except that P1 must be a
87579 ** sorter object for which the OP_SorterSort opcode has been
87580 ** invoked. This opcode advances the cursor to the next sorted
@@ -87032,14 +87585,10 @@
87585
87586 pC = p->apCsr[pOp->p1];
87587 assert( isSorter(pC) );
87588 rc = sqlite3VdbeSorterNext(db, pC);
87589 goto next_tail;
 
 
 
 
87590 case OP_Prev: /* jump */
87591 case OP_Next: /* jump */
87592 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
87593 assert( pOp->p5<ArraySize(p->aCounter) );
87594 pC = p->apCsr[pOp->p1];
@@ -87046,21 +87595,21 @@
87595 assert( pC!=0 );
87596 assert( pC->deferredMoveto==0 );
87597 assert( pC->eCurType==CURTYPE_BTREE );
87598 assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );
87599 assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );
 
 
87600
87601 /* The Next opcode is only used after SeekGT, SeekGE, Rewind, and Found.
87602 ** The Prev opcode is only used after SeekLT, SeekLE, and Last. */
87603 assert( pOp->opcode!=OP_Next
87604 || pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
87605 || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
87606 || pC->seekOp==OP_NullRow);
87607 assert( pOp->opcode!=OP_Prev
87608 || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
87609 || pC->seekOp==OP_Last
87610 || pC->seekOp==OP_NullRow);
87611
87612 rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
87613 next_tail:
87614 pC->cacheStatus = CACHE_STALE;
87615 VdbeBranchTaken(rc==SQLITE_OK,2);
@@ -88125,28 +88674,39 @@
88674 if( pIn1->u.i==0 ) goto jump_to_p2;
88675 break;
88676 }
88677
88678
88679 /* Opcode: AggStep * P2 P3 P4 P5
88680 ** Synopsis: accum=r[P3] step(r[P2@P5])
88681 **
88682 ** Execute the xStep function for an aggregate.
88683 ** The function has P5 arguments. P4 is a pointer to the
88684 ** FuncDef structure that specifies the function. Register P3 is the
88685 ** accumulator.
88686 **
88687 ** The P5 arguments are taken from register P2 and its
88688 ** successors.
88689 */
88690 /* Opcode: AggInverse * P2 P3 P4 P5
88691 ** Synopsis: accum=r[P3] inverse(r[P2@P5])
88692 **
88693 ** Execute the xInverse function for an aggregate.
88694 ** The function has P5 arguments. P4 is a pointer to the
88695 ** FuncDef structure that specifies the function. Register P3 is the
88696 ** accumulator.
88697 **
88698 ** The P5 arguments are taken from register P2 and its
88699 ** successors.
88700 */
88701 /* Opcode: AggStep1 P1 P2 P3 P4 P5
88702 ** Synopsis: accum=r[P3] step(r[P2@P5])
88703 **
88704 ** Execute the xStep (if P1==0) or xInverse (if P1!=0) function for an
88705 ** aggregate. The function has P5 arguments. P4 is a pointer to the
88706 ** FuncDef structure that specifies the function. Register P3 is the
88707 ** accumulator.
88708 **
88709 ** The P5 arguments are taken from register P2 and its
88710 ** successors.
88711 **
88712 ** This opcode is initially coded as OP_AggStep0. On first evaluation,
@@ -88153,11 +88713,12 @@
88713 ** the FuncDef stored in P4 is converted into an sqlite3_context and
88714 ** the opcode is changed. In this way, the initialization of the
88715 ** sqlite3_context only happens once, instead of on each call to the
88716 ** step function.
88717 */
88718 case OP_AggInverse:
88719 case OP_AggStep: {
88720 int n;
88721 sqlite3_context *pCtx;
88722
88723 assert( pOp->p4type==P4_FUNCDEF );
88724 n = pOp->p5;
@@ -88176,21 +88737,36 @@
88737 pCtx->skipFlag = 0;
88738 pCtx->isError = 0;
88739 pCtx->argc = n;
88740 pOp->p4type = P4_FUNCCTX;
88741 pOp->p4.pCtx = pCtx;
88742
88743 /* OP_AggInverse must have P1==1 and OP_AggStep must have P1==0 */
88744 assert( pOp->p1==(pOp->opcode==OP_AggInverse) );
88745
88746 pOp->opcode = OP_AggStep1;
88747 /* Fall through into OP_AggStep */
88748 }
88749 case OP_AggStep1: {
88750 int i;
88751 sqlite3_context *pCtx;
88752 Mem *pMem;
88753
88754 assert( pOp->p4type==P4_FUNCCTX );
88755 pCtx = pOp->p4.pCtx;
88756 pMem = &aMem[pOp->p3];
88757
88758 #ifdef SQLITE_DEBUG
88759 if( pOp->p1 ){
88760 /* This is an OP_AggInverse call. Verify that xStep has always
88761 ** been called at least once prior to any xInverse call. */
88762 assert( pMem->uTemp==0x1122e0e3 );
88763 }else{
88764 /* This is an OP_AggStep call. Mark it as such. */
88765 pMem->uTemp = 0x1122e0e3;
88766 }
88767 #endif
88768
88769 /* If this function is inside of a trigger, the register array in aMem[]
88770 ** might change from one evaluation to the next. The next block of code
88771 ** checks to see if the register array has changed, and if so it
88772 ** reinitializes the relavant parts of the sqlite3_context object */
@@ -88208,11 +88784,17 @@
88784
88785 pMem->n++;
88786 assert( pCtx->pOut->flags==MEM_Null );
88787 assert( pCtx->isError==0 );
88788 assert( pCtx->skipFlag==0 );
88789 #ifndef SQLITE_OMIT_WINDOWFUNC
88790 if( pOp->p1 ){
88791 (pCtx->pFunc->xInverse)(pCtx,pCtx->argc,pCtx->argv);
88792 }else
88793 #endif
88794 (pCtx->pFunc->xSFunc)(pCtx,pCtx->argc,pCtx->argv); /* IMP: R-24505-23230 */
88795
88796 if( pCtx->isError ){
88797 if( pCtx->isError>0 ){
88798 sqlite3VdbeError(p, "%s", sqlite3_value_text(pCtx->pOut));
88799 rc = pCtx->isError;
88800 }
@@ -88233,26 +88815,50 @@
88815 }
88816
88817 /* Opcode: AggFinal P1 P2 * P4 *
88818 ** Synopsis: accum=r[P1] N=P2
88819 **
88820 ** P1 is the memory location that is the accumulator for an aggregate
88821 ** or window function. Execute the finalizer function
88822 ** for an aggregate and store the result in P1.
88823 **
88824 ** P2 is the number of arguments that the step function takes and
88825 ** P4 is a pointer to the FuncDef for this function. The P2
88826 ** argument is not used by this opcode. It is only there to disambiguate
88827 ** functions that can take varying numbers of arguments. The
88828 ** P4 argument is only needed for the case where
88829 ** the step function was not previously called.
88830 */
88831 /* Opcode: AggValue * P2 P3 P4 *
88832 ** Synopsis: r[P3]=value N=P2
88833 **
88834 ** Invoke the xValue() function and store the result in register P3.
88835 **
88836 ** P2 is the number of arguments that the step function takes and
88837 ** P4 is a pointer to the FuncDef for this function. The P2
88838 ** argument is not used by this opcode. It is only there to disambiguate
88839 ** functions that can take varying numbers of arguments. The
88840 ** P4 argument is only needed for the case where
88841 ** the step function was not previously called.
88842 */
88843 case OP_AggValue:
88844 case OP_AggFinal: {
88845 Mem *pMem;
88846 assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
88847 assert( pOp->p3==0 || pOp->opcode==OP_AggValue );
88848 pMem = &aMem[pOp->p1];
88849 assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
88850 #ifndef SQLITE_OMIT_WINDOWFUNC
88851 if( pOp->p3 ){
88852 rc = sqlite3VdbeMemAggValue(pMem, &aMem[pOp->p3], pOp->p4.pFunc);
88853 pMem = &aMem[pOp->p3];
88854 }else
88855 #endif
88856 {
88857 rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
88858 }
88859
88860 if( rc ){
88861 sqlite3VdbeError(p, "%s", sqlite3_value_text(pMem));
88862 goto abort_due_to_error;
88863 }
88864 sqlite3VdbeChangeEncoding(pMem, encoding);
@@ -88843,10 +89449,11 @@
89449
89450 assert( pOp->p2==1 || pOp->p5==OE_Fail || pOp->p5==OE_Rollback
89451 || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
89452 );
89453 assert( p->readOnly==0 );
89454 if( db->mallocFailed ) goto no_mem;
89455 sqlite3VdbeIncrWriteCounter(p, 0);
89456 pVtab = pOp->p4.pVtab->pVtab;
89457 if( pVtab==0 || NEVER(pVtab->pModule==0) ){
89458 rc = SQLITE_LOCKED;
89459 goto abort_due_to_error;
@@ -89176,10 +89783,38 @@
89783 case OP_Abortable: {
89784 sqlite3VdbeAssertAbortable(p);
89785 break;
89786 }
89787 #endif
89788
89789 #ifdef SQLITE_DEBUG_COLUMNCACHE
89790 /* Opcode: SetTabCol P1 P2 P3 * *
89791 **
89792 ** Set a flag in register REG[P3] indicating that it holds the value
89793 ** of column P2 from the table on cursor P1. This flag is checked
89794 ** by a subsequent VerifyTabCol opcode.
89795 **
89796 ** This opcode only appears SQLITE_DEBUG builds. It is used to verify
89797 ** that the expression table column cache is working correctly.
89798 */
89799 case OP_SetTabCol: {
89800 aMem[pOp->p3].iTabColHash = TableColumnHash(pOp->p1,pOp->p2);
89801 break;
89802 }
89803 /* Opcode: VerifyTabCol P1 P2 P3 * *
89804 **
89805 ** Verify that register REG[P3] contains the value of column P2 from
89806 ** cursor P1. Assert() if this is not the case.
89807 **
89808 ** This opcode only appears SQLITE_DEBUG builds. It is used to verify
89809 ** that the expression table column cache is working correctly.
89810 */
89811 case OP_VerifyTabCol: {
89812 assert( aMem[pOp->p3].iTabColHash == TableColumnHash(pOp->p1,pOp->p2) );
89813 break;
89814 }
89815 #endif
89816
89817 /* Opcode: Noop * * * * *
89818 **
89819 ** Do nothing. This instruction is often useful as a jump
89820 ** destination.
@@ -93052,10 +93687,18 @@
93687 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
93688 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
93689 }else if( pExpr->x.pList ){
93690 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
93691 }
93692 #ifndef SQLITE_OMIT_WINDOWFUNC
93693 if( !ExprHasProperty(pExpr, EP_Reduced) && pExpr->pWin ){
93694 Window *pWin = pExpr->pWin;
93695 if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
93696 if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
93697 if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
93698 }
93699 #endif
93700 }
93701 break;
93702 }
93703 return WRC_Continue;
93704 }
@@ -93916,15 +94559,44 @@
94559 ** in an index. */
94560 notValid(pParse, pNC, "non-deterministic functions",
94561 NC_IdxExpr|NC_PartIdx);
94562 }
94563 }
94564
94565 #ifndef SQLITE_OMIT_WINDOWFUNC
94566 assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
94567 || (pDef->xValue==0 && pDef->xInverse==0)
94568 || (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
94569 );
94570 if( pDef && pDef->xValue==0 && pExpr->pWin ){
94571 sqlite3ErrorMsg(pParse,
94572 "%.*s() may not be used as a window function", nId, zId
94573 );
94574 pNC->nErr++;
94575 }else if(
94576 (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
94577 || (is_agg && (pDef->funcFlags & SQLITE_FUNC_WINDOW) && !pExpr->pWin)
94578 || (is_agg && pExpr->pWin && (pNC->ncFlags & NC_AllowWin)==0)
94579 ){
94580 const char *zType;
94581 if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->pWin ){
94582 zType = "window";
94583 }else{
94584 zType = "aggregate";
94585 }
94586 sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()", zType, nId,zId);
94587 pNC->nErr++;
94588 is_agg = 0;
94589 }
94590 #else
94591 if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
94592 sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
94593 pNC->nErr++;
94594 is_agg = 0;
94595 }
94596 #endif
94597 else if( no_such_func && pParse->db->init.busy==0
94598 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
94599 && pParse->explain==0
94600 #endif
94601 ){
94602 sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
@@ -93932,28 +94604,52 @@
94604 }else if( wrong_num_args ){
94605 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
94606 nId, zId);
94607 pNC->nErr++;
94608 }
94609 if( is_agg ){
94610 #ifndef SQLITE_OMIT_WINDOWFUNC
94611 pNC->ncFlags &= ~(pExpr->pWin ? NC_AllowWin : NC_AllowAgg);
94612 #else
94613 pNC->ncFlags &= ~NC_AllowAgg;
94614 #endif
94615 }
94616 sqlite3WalkExprList(pWalker, pList);
94617 if( is_agg ){
94618 #ifndef SQLITE_OMIT_WINDOWFUNC
94619 if( pExpr->pWin ){
94620 Select *pSel = pNC->pWinSelect;
94621 sqlite3WalkExprList(pWalker, pExpr->pWin->pPartition);
94622 sqlite3WalkExprList(pWalker, pExpr->pWin->pOrderBy);
94623 sqlite3WalkExpr(pWalker, pExpr->pWin->pFilter);
94624 sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->pWin, pDef);
94625 if( 0==pSel->pWin
94626 || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->pWin)
94627 ){
94628 pExpr->pWin->pNextWin = pSel->pWin;
94629 pSel->pWin = pExpr->pWin;
94630 }
94631 pNC->ncFlags |= NC_AllowWin;
94632 }else
94633 #endif /* SQLITE_OMIT_WINDOWFUNC */
94634 {
94635 NameContext *pNC2 = pNC;
94636 pExpr->op = TK_AGG_FUNCTION;
94637 pExpr->op2 = 0;
94638 while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){
94639 pExpr->op2++;
94640 pNC2 = pNC2->pNext;
94641 }
94642 assert( pDef!=0 );
94643 if( pNC2 ){
94644 assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
94645 testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
94646 pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
94647
94648 }
94649 pNC->ncFlags |= NC_AllowAgg;
94650 }
94651 }
94652 /* FIX ME: Compute pExpr->affinity based on the expected return
94653 ** type of the function
94654 */
94655 return WRC_Prune;
@@ -94350,10 +95046,23 @@
95046 if( sqlite3ResolveExprNames(pNC, pE) ){
95047 return 1;
95048 }
95049 for(j=0; j<pSelect->pEList->nExpr; j++){
95050 if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
95051 #ifndef SQLITE_OMIT_WINDOWFUNC
95052 if( pE->pWin ){
95053 /* Since this window function is being changed into a reference
95054 ** to the same window function the result set, remove the instance
95055 ** of this window function from the Select.pWin list. */
95056 Window **pp;
95057 for(pp=&pSelect->pWin; *pp; pp=&(*pp)->pNextWin){
95058 if( *pp==pE->pWin ){
95059 *pp = (*pp)->pNextWin;
95060 }
95061 }
95062 }
95063 #endif
95064 pItem->u.x.iOrderByCol = j+1;
95065 }
95066 }
95067 }
95068 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -94406,10 +95115,11 @@
95115 /* Resolve the expressions in the LIMIT and OFFSET clauses. These
95116 ** are not allowed to refer to any names, so pass an empty NameContext.
95117 */
95118 memset(&sNC, 0, sizeof(sNC));
95119 sNC.pParse = pParse;
95120 sNC.pWinSelect = p;
95121 if( sqlite3ResolveExprNames(&sNC, p->pLimit) ){
95122 return WRC_Abort;
95123 }
95124
95125 /* If the SF_Converted flags is set, then this Select object was
@@ -94454,16 +95164,17 @@
95164 }
95165
95166 /* Set up the local name-context to pass to sqlite3ResolveExprNames() to
95167 ** resolve the result-set expression list.
95168 */
95169 sNC.ncFlags = NC_AllowAgg|NC_AllowWin;
95170 sNC.pSrcList = p->pSrc;
95171 sNC.pNext = pOuterNC;
95172
95173 /* Resolve names in the result set. */
95174 if( sqlite3ResolveExprListNames(&sNC, p->pEList) ) return WRC_Abort;
95175 sNC.ncFlags &= ~NC_AllowWin;
95176
95177 /* If there are no aggregate functions in the result-set, and no GROUP BY
95178 ** expression, do not allow aggregates in any of the other expressions.
95179 */
95180 assert( (p->selFlags & SF_Aggregate)==0 );
@@ -94508,11 +95219,11 @@
95219
95220 /* The ORDER BY and GROUP BY clauses may not refer to terms in
95221 ** outer queries
95222 */
95223 sNC.pNext = 0;
95224 sNC.ncFlags |= NC_AllowAgg|NC_AllowWin;
95225
95226 /* If this is a converted compound query, move the ORDER BY clause from
95227 ** the sub-query back to the parent query. At this point each term
95228 ** within the ORDER BY clause has been transformed to an integer value.
95229 ** These integers will be replaced by copies of the corresponding result
@@ -94539,10 +95250,11 @@
95250 return WRC_Abort;
95251 }
95252 if( db->mallocFailed ){
95253 return WRC_Abort;
95254 }
95255 sNC.ncFlags &= ~NC_AllowWin;
95256
95257 /* Resolve the GROUP BY clause. At the same time, make sure
95258 ** the GROUP BY clause does not contain aggregate functions.
95259 */
95260 if( pGroupBy ){
@@ -95809,10 +96521,13 @@
96521 }else if( ExprHasProperty(p, EP_xIsSelect) ){
96522 sqlite3SelectDelete(db, p->x.pSelect);
96523 }else{
96524 sqlite3ExprListDelete(db, p->x.pList);
96525 }
96526 if( !ExprHasProperty(p, EP_Reduced) ){
96527 sqlite3WindowDelete(db, p->pWin);
96528 }
96529 }
96530 if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
96531 if( !ExprHasProperty(p, EP_Static) ){
96532 sqlite3DbFreeNN(db, p);
96533 }
@@ -95857,11 +96572,11 @@
96572 ** return value with EP_Reduced|EP_TokenOnly.
96573 **
96574 ** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size
96575 ** (unreduced) Expr objects as they or originally constructed by the parser.
96576 ** During expression analysis, extra information is computed and moved into
96577 ** later parts of the Expr object and that extra information might get chopped
96578 ** off if the expression is reduced. Note also that it does not work to
96579 ** make an EXPRDUP_REDUCE copy of a reduced expression. It is only legal
96580 ** to reduce a pristine expression tree from the parser. The implementation
96581 ** of dupedExprStructSize() contain multiple assert() statements that attempt
96582 ** to enforce this constraint.
@@ -95869,11 +96584,15 @@
96584 static int dupedExprStructSize(Expr *p, int flags){
96585 int nSize;
96586 assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */
96587 assert( EXPR_FULLSIZE<=0xfff );
96588 assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );
96589 if( 0==flags || p->op==TK_SELECT_COLUMN
96590 #ifndef SQLITE_OMIT_WINDOWFUNC
96591 || p->pWin
96592 #endif
96593 ){
96594 nSize = EXPR_FULLSIZE;
96595 }else{
96596 assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
96597 assert( !ExprHasProperty(p, EP_FromJoin) );
96598 assert( !ExprHasProperty(p, EP_MemToken) );
@@ -96009,10 +96728,17 @@
96728 }
96729 if( pzBuffer ){
96730 *pzBuffer = zAlloc;
96731 }
96732 }else{
96733 #ifndef SQLITE_OMIT_WINDOWFUNC
96734 if( ExprHasProperty(p, EP_Reduced|EP_TokenOnly) ){
96735 pNew->pWin = 0;
96736 }else{
96737 pNew->pWin = sqlite3WindowDup(db, pNew, p->pWin);
96738 }
96739 #endif /* SQLITE_OMIT_WINDOWFUNC */
96740 if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
96741 if( pNew->op==TK_SELECT_COLUMN ){
96742 pNew->pLeft = p->pLeft;
96743 assert( p->iColumn==0 || p->pRight==0 );
96744 assert( p->pRight==0 || p->pRight==p->pLeft );
@@ -96215,11 +96941,15 @@
96941 pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
96942 pNew->addrOpenEphm[0] = -1;
96943 pNew->addrOpenEphm[1] = -1;
96944 pNew->nSelectRow = p->nSelectRow;
96945 pNew->pWith = withDup(db, p->pWith);
96946 #ifndef SQLITE_OMIT_WINDOWFUNC
96947 pNew->pWin = 0;
96948 pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
96949 #endif
96950 pNew->selId = p->selId;
96951 *pp = pNew;
96952 pp = &pNew->pPrior;
96953 pNext = pNew;
96954 }
96955
@@ -97945,10 +98675,17 @@
98675 #ifndef NDEBUG
98676 for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){
98677 assert( p->iTable!=iTab || p->iColumn!=iCol );
98678 }
98679 #endif
98680
98681 #ifdef SQLITE_DEBUG_COLUMNCACHE
98682 /* Add a SetTabCol opcode for run-time verification that the column
98683 ** cache is working correctly.
98684 */
98685 sqlite3VdbeAddOp3(pParse->pVdbe, OP_SetTabCol, iTab, iCol, iReg);
98686 #endif
98687
98688 /* If the cache is already full, delete the least recently used entry */
98689 if( pParse->nColCache>=SQLITE_N_COLCACHE ){
98690 minLru = 0x7fffffff;
98691 idxLru = -1;
@@ -98119,10 +98856,13 @@
98856
98857 for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){
98858 if( p->iTable==iTable && p->iColumn==iColumn ){
98859 p->lru = pParse->iCacheCnt++;
98860 sqlite3ExprCachePinRegister(pParse, p->iReg);
98861 #ifdef SQLITE_DEBUG_COLUMNCACHE
98862 sqlite3VdbeAddOp3(v, OP_VerifyTabCol, iTable, iColumn, p->iReg);
98863 #endif
98864 return p->iReg;
98865 }
98866 }
98867 assert( v!=0 );
98868 sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
@@ -98523,10 +99263,16 @@
99263 u32 constMask = 0; /* Mask of function arguments that are constant */
99264 int i; /* Loop counter */
99265 sqlite3 *db = pParse->db; /* The database connection */
99266 u8 enc = ENC(db); /* The text encoding used by this database */
99267 CollSeq *pColl = 0; /* A collating sequence */
99268
99269 #ifndef SQLITE_OMIT_WINDOWFUNC
99270 if( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) && pExpr->pWin ){
99271 return pExpr->pWin->regResult;
99272 }
99273 #endif
99274
99275 if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
99276 /* SQL functions can be expensive. So try to move constant functions
99277 ** out of the inner loop, even if that means an extra OP_Copy. */
99278 return sqlite3ExprCodeAtInit(pParse, pExpr, -1);
@@ -99663,10 +100409,25 @@
100409 if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
100410 if( pA->iColumn!=pB->iColumn ) return 2;
100411 if( pA->iTable!=pB->iTable
100412 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
100413 }
100414 #ifndef SQLITE_OMIT_WINDOWFUNC
100415 /* Justification for the assert():
100416 ** window functions have p->op==TK_FUNCTION but aggregate functions
100417 ** have p->op==TK_AGG_FUNCTION. So any comparison between an aggregate
100418 ** function and a window function should have failed before reaching
100419 ** this point. And, it is not possible to have a window function and
100420 ** a scalar function with the same name and number of arguments. So
100421 ** if we reach this point, either A and B both window functions or
100422 ** neither are a window functions. */
100423 assert( (pA->pWin==0)==(pB->pWin==0) );
100424
100425 if( pA->pWin!=0 ){
100426 if( sqlite3WindowCompare(pParse,pA->pWin,pB->pWin)!=0 ) return 2;
100427 }
100428 #endif
100429 }
100430 return 0;
100431 }
100432
100433 /*
@@ -100342,11 +101103,11 @@
101103 */
101104 do {
101105 zCsr += len;
101106 len = sqlite3GetToken(zCsr, &token);
101107 } while( token==TK_SPACE );
101108 assert( len>0 || !*zCsr );
101109 } while( token!=TK_LP && token!=TK_USING );
101110
101111 zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", (int)(((u8*)tname.z) - zSql),
101112 zSql, zTableName, tname.z+tname.n);
101113 sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);
@@ -100410,11 +101171,11 @@
101171 }
101172 sqlite3DbFree(db, zParent);
101173 }
101174 }
101175
101176 zResult = sqlite3MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput);
101177 sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);
101178 sqlite3DbFree(db, zOutput);
101179 }
101180 #endif
101181
@@ -100466,11 +101227,11 @@
101227 */
101228 do {
101229 zCsr += len;
101230 len = sqlite3GetToken(zCsr, &token);
101231 }while( token==TK_SPACE );
101232 assert( len>0 || !*zCsr );
101233
101234 /* Variable 'dist' stores the number of tokens read since the most
101235 ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN
101236 ** token is read and 'dist' equals 2, the condition stated above
101237 ** to be met.
@@ -101564,10 +102325,11 @@
102325 SQLITE_UTF8, /* funcFlags */
102326 0, /* pUserData */
102327 0, /* pNext */
102328 statInit, /* xSFunc */
102329 0, /* xFinalize */
102330 0, 0, /* xValue, xInverse */
102331 "stat_init", /* zName */
102332 {0}
102333 };
102334
102335 #ifdef SQLITE_ENABLE_STAT4
@@ -101880,10 +102642,11 @@
102642 SQLITE_UTF8, /* funcFlags */
102643 0, /* pUserData */
102644 0, /* pNext */
102645 statPush, /* xSFunc */
102646 0, /* xFinalize */
102647 0, 0, /* xValue, xInverse */
102648 "stat_push", /* zName */
102649 {0}
102650 };
102651
102652 #define STAT_GET_STAT1 0 /* "stat" column of stat1 table */
@@ -102031,10 +102794,11 @@
102794 SQLITE_UTF8, /* funcFlags */
102795 0, /* pUserData */
102796 0, /* pNext */
102797 statGet, /* xSFunc */
102798 0, /* xFinalize */
102799 0, 0, /* xValue, xInverse */
102800 "stat_get", /* zName */
102801 {0}
102802 };
102803
102804 static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
@@ -102350,14 +103114,11 @@
103114 VdbeCoverage(v);
103115 callStatGet(v, regStat4, STAT_GET_NEQ, regEq);
103116 callStatGet(v, regStat4, STAT_GET_NLT, regLt);
103117 callStatGet(v, regStat4, STAT_GET_NDLT, regDLt);
103118 sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);
103119 VdbeCoverage(v);
 
 
 
103120 #ifdef SQLITE_ENABLE_STAT3
103121 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, 0, regSample);
103122 #else
103123 for(i=0; i<nCol; i++){
103124 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
@@ -103432,10 +104193,11 @@
104193 SQLITE_UTF8, /* funcFlags */
104194 0, /* pUserData */
104195 0, /* pNext */
104196 detachFunc, /* xSFunc */
104197 0, /* xFinalize */
104198 0, 0, /* xValue, xInverse */
104199 "sqlite_detach", /* zName */
104200 {0}
104201 };
104202 codeAttach(pParse, SQLITE_DETACH, &detach_func, pDbname, 0, 0, pDbname);
104203 }
@@ -103451,10 +104213,11 @@
104213 SQLITE_UTF8, /* funcFlags */
104214 0, /* pUserData */
104215 0, /* pNext */
104216 attachFunc, /* xSFunc */
104217 0, /* xFinalize */
104218 0, 0, /* xValue, xInverse */
104219 "sqlite_attach", /* zName */
104220 {0}
104221 };
104222 codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);
104223 }
@@ -105613,10 +106376,35 @@
106376 */
106377 static int hasColumn(const i16 *aiCol, int nCol, int x){
106378 while( nCol-- > 0 ) if( x==*(aiCol++) ) return 1;
106379 return 0;
106380 }
106381
106382 /* Recompute the colNotIdxed field of the Index.
106383 **
106384 ** colNotIdxed is a bitmask that has a 0 bit representing each indexed
106385 ** columns that are within the first 63 columns of the table. The
106386 ** high-order bit of colNotIdxed is always 1. All unindexed columns
106387 ** of the table have a 1.
106388 **
106389 ** The colNotIdxed mask is AND-ed with the SrcList.a[].colUsed mask
106390 ** to determine if the index is covering index.
106391 */
106392 static void recomputeColumnsNotIndexed(Index *pIdx){
106393 Bitmask m = 0;
106394 int j;
106395 for(j=pIdx->nColumn-1; j>=0; j--){
106396 int x = pIdx->aiColumn[j];
106397 if( x>=0 ){
106398 testcase( x==BMS-1 );
106399 testcase( x==BMS-2 );
106400 if( x<BMS-1 ) m |= MASKBIT(x);
106401 }
106402 }
106403 pIdx->colNotIdxed = ~m;
106404 assert( (pIdx->colNotIdxed>>63)==1 );
106405 }
106406
106407 /*
106408 ** This routine runs at the end of parsing a CREATE TABLE statement that
106409 ** has a WITHOUT ROWID clause. The job of this routine is to convert both
106410 ** internal schema data structures and the generated VDBE code so that they
@@ -105682,11 +106470,11 @@
106470 if( pList==0 ) return;
106471 pList->a[0].sortOrder = pParse->iPkSortOrder;
106472 assert( pParse->pNewTable==pTab );
106473 sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
106474 SQLITE_IDXTYPE_PRIMARYKEY);
106475 if( db->mallocFailed || pParse->nErr ) return;
106476 pPk = sqlite3PrimaryKeyIndex(pTab);
106477 pTab->iPKey = -1;
106478 }else{
106479 pPk = sqlite3PrimaryKeyIndex(pTab);
106480
@@ -105762,10 +106550,11 @@
106550 assert( pPk->nColumn==j );
106551 assert( pTab->nCol==j );
106552 }else{
106553 pPk->nColumn = pTab->nCol;
106554 }
106555 recomputeColumnsNotIndexed(pPk);
106556 }
106557
106558 /*
106559 ** This routine is called to report the final ")" that terminates
106560 ** a CREATE TABLE statement.
@@ -106212,10 +107001,15 @@
107001 db->lookaside.bDisable--;
107002 } else {
107003 nErr++;
107004 }
107005 pTable->pSchema->schemaFlags |= DB_UnresetViews;
107006 if( db->mallocFailed ){
107007 sqlite3DeleteColumnNames(db, pTable);
107008 pTable->aCol = 0;
107009 pTable->nCol = 0;
107010 }
107011 #endif /* SQLITE_OMIT_VIEW */
107012 return nErr;
107013 }
107014 #endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */
107015
@@ -107195,10 +107989,11 @@
107989
107990 /* If this index contains every column of its table, then mark
107991 ** it as a covering index */
107992 assert( HasRowid(pTab)
107993 || pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 );
107994 recomputeColumnsNotIndexed(pIndex);
107995 if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){
107996 pIndex->isCovering = 1;
107997 for(j=0; j<pTab->nCol; j++){
107998 if( j==pTab->iPKey ) continue;
107999 if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue;
@@ -111366,18 +112161,44 @@
112161 p->cnt++;
112162 if( type==SQLITE_INTEGER ){
112163 i64 v = sqlite3_value_int64(argv[0]);
112164 p->rSum += v;
112165 if( (p->approx|p->overflow)==0 && sqlite3AddInt64(&p->iSum, v) ){
112166 p->approx = p->overflow = 1;
112167 }
112168 }else{
112169 p->rSum += sqlite3_value_double(argv[0]);
112170 p->approx = 1;
112171 }
112172 }
112173 }
112174 #ifndef SQLITE_OMIT_WINDOWFUNC
112175 static void sumInverse(sqlite3_context *context, int argc, sqlite3_value**argv){
112176 SumCtx *p;
112177 int type;
112178 assert( argc==1 );
112179 UNUSED_PARAMETER(argc);
112180 p = sqlite3_aggregate_context(context, sizeof(*p));
112181 type = sqlite3_value_numeric_type(argv[0]);
112182 /* p is always non-NULL because sumStep() will have been called first
112183 ** to initialize it */
112184 if( ALWAYS(p) && type!=SQLITE_NULL ){
112185 assert( p->cnt>0 );
112186 p->cnt--;
112187 assert( type==SQLITE_INTEGER || p->approx );
112188 if( type==SQLITE_INTEGER && p->approx==0 ){
112189 i64 v = sqlite3_value_int64(argv[0]);
112190 p->rSum -= v;
112191 p->iSum -= v;
112192 }else{
112193 p->rSum -= sqlite3_value_double(argv[0]);
112194 }
112195 }
112196 }
112197 #else
112198 # define sumInverse 0
112199 #endif /* SQLITE_OMIT_WINDOWFUNC */
112200 static void sumFinalize(sqlite3_context *context){
112201 SumCtx *p;
112202 p = sqlite3_aggregate_context(context, 0);
112203 if( p && p->cnt>0 ){
112204 if( p->overflow ){
@@ -111408,10 +112229,13 @@
112229 ** count() aggregate function.
112230 */
112231 typedef struct CountCtx CountCtx;
112232 struct CountCtx {
112233 i64 n;
112234 #ifdef SQLITE_DEBUG
112235 int bInverse; /* True if xInverse() ever called */
112236 #endif
112237 };
112238
112239 /*
112240 ** Routines to implement the count() aggregate function.
112241 */
@@ -111425,19 +112249,34 @@
112249 #ifndef SQLITE_OMIT_DEPRECATED
112250 /* The sqlite3_aggregate_count() function is deprecated. But just to make
112251 ** sure it still operates correctly, verify that its count agrees with our
112252 ** internal count when using count(*) and when the total count can be
112253 ** expressed as a 32-bit integer. */
112254 assert( argc==1 || p==0 || p->n>0x7fffffff || p->bInverse
112255 || p->n==sqlite3_aggregate_count(context) );
112256 #endif
112257 }
112258 static void countFinalize(sqlite3_context *context){
112259 CountCtx *p;
112260 p = sqlite3_aggregate_context(context, 0);
112261 sqlite3_result_int64(context, p ? p->n : 0);
112262 }
112263 #ifndef SQLITE_OMIT_WINDOWFUNC
112264 static void countInverse(sqlite3_context *ctx, int argc, sqlite3_value **argv){
112265 CountCtx *p;
112266 p = sqlite3_aggregate_context(ctx, sizeof(*p));
112267 /* p is always non-NULL since countStep() will have been called first */
112268 if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && ALWAYS(p) ){
112269 p->n--;
112270 #ifdef SQLITE_DEBUG
112271 p->bInverse = 1;
112272 #endif
112273 }
112274 }
112275 #else
112276 # define countInverse 0
112277 #endif /* SQLITE_OMIT_WINDOWFUNC */
112278
112279 /*
112280 ** Routines to implement min() and max() aggregate functions.
112281 */
112282 static void minmaxStep(
@@ -111450,11 +112289,11 @@
112289 UNUSED_PARAMETER(NotUsed);
112290
112291 pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));
112292 if( !pBest ) return;
112293
112294 if( sqlite3_value_type(pArg)==SQLITE_NULL ){
112295 if( pBest->flags ) sqlite3SkipAccumulatorLoad(context);
112296 }else if( pBest->flags ){
112297 int max;
112298 int cmp;
112299 CollSeq *pColl = sqlite3GetFuncCollSeq(context);
@@ -111476,20 +112315,30 @@
112315 }else{
112316 pBest->db = sqlite3_context_db_handle(context);
112317 sqlite3VdbeMemCopy(pBest, pArg);
112318 }
112319 }
112320 static void minMaxValueFinalize(sqlite3_context *context, int bValue){
112321 sqlite3_value *pRes;
112322 pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);
112323 if( pRes ){
112324 if( pRes->flags ){
112325 sqlite3_result_value(context, pRes);
112326 }
112327 if( bValue==0 ) sqlite3VdbeMemRelease(pRes);
112328 }
112329 }
112330 #ifndef SQLITE_OMIT_WINDOWFUNC
112331 static void minMaxValue(sqlite3_context *context){
112332 minMaxValueFinalize(context, 1);
112333 }
112334 #else
112335 # define minMaxValue 0
112336 #endif /* SQLITE_OMIT_WINDOWFUNC */
112337 static void minMaxFinalize(sqlite3_context *context){
112338 minMaxValueFinalize(context, 0);
112339 }
112340
112341 /*
112342 ** group_concat(EXPR, ?SEPARATOR?)
112343 */
112344 static void groupConcatStep(
@@ -111522,10 +112371,42 @@
112371 zVal = (char*)sqlite3_value_text(argv[0]);
112372 nVal = sqlite3_value_bytes(argv[0]);
112373 if( zVal ) sqlite3_str_append(pAccum, zVal, nVal);
112374 }
112375 }
112376 #ifndef SQLITE_OMIT_WINDOWFUNC
112377 static void groupConcatInverse(
112378 sqlite3_context *context,
112379 int argc,
112380 sqlite3_value **argv
112381 ){
112382 int n;
112383 StrAccum *pAccum;
112384 assert( argc==1 || argc==2 );
112385 if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
112386 pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
112387 /* pAccum is always non-NULL since groupConcatStep() will have always
112388 ** run frist to initialize it */
112389 if( ALWAYS(pAccum) ){
112390 n = sqlite3_value_bytes(argv[0]);
112391 if( argc==2 ){
112392 n += sqlite3_value_bytes(argv[1]);
112393 }else{
112394 n++;
112395 }
112396 if( n>=(int)pAccum->nChar ){
112397 pAccum->nChar = 0;
112398 }else{
112399 pAccum->nChar -= n;
112400 memmove(pAccum->zText, &pAccum->zText[n], pAccum->nChar);
112401 }
112402 if( pAccum->nChar==0 ) pAccum->mxAlloc = 0;
112403 }
112404 }
112405 #else
112406 # define groupConcatInverse 0
112407 #endif /* SQLITE_OMIT_WINDOWFUNC */
112408 static void groupConcatFinalize(sqlite3_context *context){
112409 StrAccum *pAccum;
112410 pAccum = sqlite3_aggregate_context(context, 0);
112411 if( pAccum ){
112412 if( pAccum->accError==SQLITE_TOOBIG ){
@@ -111536,10 +112417,28 @@
112417 sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1,
112418 sqlite3_free);
112419 }
112420 }
112421 }
112422 #ifndef SQLITE_OMIT_WINDOWFUNC
112423 static void groupConcatValue(sqlite3_context *context){
112424 sqlite3_str *pAccum;
112425 pAccum = (sqlite3_str*)sqlite3_aggregate_context(context, 0);
112426 if( pAccum ){
112427 if( pAccum->accError==SQLITE_TOOBIG ){
112428 sqlite3_result_error_toobig(context);
112429 }else if( pAccum->accError==SQLITE_NOMEM ){
112430 sqlite3_result_error_nomem(context);
112431 }else{
112432 const char *zText = sqlite3_str_value(pAccum);
112433 sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT);
112434 }
112435 }
112436 }
112437 #else
112438 # define groupConcatValue 0
112439 #endif /* SQLITE_OMIT_WINDOWFUNC */
112440
112441 /*
112442 ** This routine does per-connection function registration. Most
112443 ** of the built-in functions above are part of the global function set.
112444 ** This routine only deals with those that are not global.
@@ -111573,14 +112472,14 @@
112472 if( caseSensitive ){
112473 pInfo = (struct compareInfo*)&likeInfoAlt;
112474 }else{
112475 pInfo = (struct compareInfo*)&likeInfoNorm;
112476 }
112477 sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0, 0, 0);
112478 sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0, 0, 0);
112479 sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8,
112480 (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0, 0, 0);
112481 setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);
112482 setLikeOptFlag(db, "like",
112483 caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);
112484 }
112485
@@ -111685,15 +112584,15 @@
112584 FUNCTION(rtrim, 2, 2, 0, trimFunc ),
112585 FUNCTION(trim, 1, 3, 0, trimFunc ),
112586 FUNCTION(trim, 2, 3, 0, trimFunc ),
112587 FUNCTION(min, -1, 0, 1, minmaxFunc ),
112588 FUNCTION(min, 0, 0, 1, 0 ),
112589 WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
112590 SQLITE_FUNC_MINMAX ),
112591 FUNCTION(max, -1, 1, 1, minmaxFunc ),
112592 FUNCTION(max, 0, 1, 1, 0 ),
112593 WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
112594 SQLITE_FUNC_MINMAX ),
112595 FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
112596 FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
112597 FUNCTION(instr, 2, 0, 0, instrFunc ),
112598 FUNCTION(printf, -1, 0, 0, printfFunc ),
@@ -111720,18 +112619,21 @@
112619 VFUNCTION(total_changes, 0, 0, 0, total_changes ),
112620 FUNCTION(replace, 3, 0, 0, replaceFunc ),
112621 FUNCTION(zeroblob, 1, 0, 0, zeroblobFunc ),
112622 FUNCTION(substr, 2, 0, 0, substrFunc ),
112623 FUNCTION(substr, 3, 0, 0, substrFunc ),
112624 WAGGREGATE(sum, 1,0,0, sumStep, sumFinalize, sumFinalize, sumInverse, 0),
112625 WAGGREGATE(total, 1,0,0, sumStep,totalFinalize,totalFinalize,sumInverse, 0),
112626 WAGGREGATE(avg, 1,0,0, sumStep, avgFinalize, avgFinalize, sumInverse, 0),
112627 WAGGREGATE(count, 0,0,0, countStep,
112628 countFinalize, countFinalize, countInverse, SQLITE_FUNC_COUNT ),
112629 WAGGREGATE(count, 1,0,0, countStep,
112630 countFinalize, countFinalize, countInverse, 0 ),
112631 WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep,
112632 groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
112633 WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep,
112634 groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
112635
112636 LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
112637 #ifdef SQLITE_CASE_SENSITIVE_LIKE
112638 LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
112639 LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
@@ -111747,10 +112649,11 @@
112649 FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQLITE_FUNC_COALESCE),
112650 };
112651 #ifndef SQLITE_OMIT_ALTERTABLE
112652 sqlite3AlterFunctions();
112653 #endif
112654 sqlite3WindowFunctions();
112655 #if defined(SQLITE_ENABLE_STAT3) || defined(SQLITE_ENABLE_STAT4)
112656 sqlite3AnalyzeFunctions();
112657 #endif
112658 sqlite3RegisterDateTimeFunctions();
112659 sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));
@@ -114738,10 +115641,11 @@
115641 ** the following conflict logic if it does not. */
115642 VdbeNoopComment((v, "uniqueness check for ROWID"));
115643 sqlite3VdbeVerifyAbortable(v, onError);
115644 sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);
115645 VdbeCoverage(v);
115646 sqlite3ExprCachePush(pParse);
115647
115648 switch( onError ){
115649 default: {
115650 onError = OE_Abort;
115651 /* Fall thru into the next case */
@@ -114814,10 +115718,11 @@
115718 testcase( onError==OE_Ignore );
115719 sqlite3VdbeGoto(v, ignoreDest);
115720 break;
115721 }
115722 }
115723 sqlite3ExprCachePop(pParse);
115724 sqlite3VdbeResolveLabel(v, addrRowidOk);
115725 if( sAddr.ipkTop ){
115726 sAddr.ipkBtm = sqlite3VdbeAddOp0(v, OP_Goto);
115727 sqlite3VdbeJumpHere(v, sAddr.ipkTop-1);
115728 }
@@ -114835,23 +115740,23 @@
115740 int regR; /* Range of registers holding conflicting PK */
115741 int iThisCur; /* Cursor for this UNIQUE index */
115742 int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */
115743
115744 if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */
115745 if( bAffinityDone==0 ){
115746 sqlite3TableAffinity(v, pTab, regNewData+1);
115747 bAffinityDone = 1;
115748 }
115749 if( pUpIdx==pIdx ){
115750 addrUniqueOk = sAddr.upsertBtm;
115751 upsertBypass = sqlite3VdbeGoto(v, 0);
115752 VdbeComment((v, "Skip upsert subroutine"));
115753 sqlite3VdbeResolveLabel(v, sAddr.upsertTop2);
115754 }else{
115755 addrUniqueOk = sqlite3VdbeMakeLabel(v);
115756 }
115757 VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName));
 
 
 
 
115758 iThisCur = iIdxCur+ix;
115759
115760
115761 /* Skip partial indices for which the WHERE clause is not true */
115762 if( pIdx->pPartIdxWhere ){
@@ -119458,10 +120363,15 @@
120363 }
120364 assert( pParse->nMem>=8+j );
120365 assert( sqlite3NoTempsInRange(pParse,1,7+j) );
120366 sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
120367 loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
120368 if( !isQuick ){
120369 /* Sanity check on record header decoding */
120370 sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3);
120371 sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
120372 }
120373 /* Verify that all NOT NULL columns really are NOT NULL */
120374 for(j=0; j<pTab->nCol; j++){
120375 char *zErr;
120376 int jmp2;
120377 if( j==pTab->iPKey ) continue;
@@ -119500,13 +120410,10 @@
120410 sqlite3ExprCachePop(pParse);
120411 }
120412 sqlite3ExprListDelete(db, pCheck);
120413 }
120414 if( !isQuick ){ /* Omit the remaining tests for quick_check */
 
 
 
120415 /* Validate index entries for the current row */
120416 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
120417 int jmp2, jmp3, jmp4, jmp5;
120418 int ckUniq = sqlite3VdbeMakeLabel(v);
120419 if( pPk==pIdx ) continue;
@@ -120573,11 +121480,11 @@
121480 /* If there is not already a read-only (or read-write) transaction opened
121481 ** on the b-tree database, open one now. If a transaction is opened, it
121482 ** will be closed before this function returns. */
121483 sqlite3BtreeEnter(pDb->pBt);
121484 if( !sqlite3BtreeIsInReadTrans(pDb->pBt) ){
121485 rc = sqlite3BtreeBeginTrans(pDb->pBt, 0, 0);
121486 if( rc!=SQLITE_OK ){
121487 sqlite3SetString(pzErrMsg, db, sqlite3ErrStr(rc));
121488 goto initone_error_out;
121489 }
121490 openedTransaction = 1;
@@ -120818,11 +121725,11 @@
121725
121726 /* If there is not already a read-only (or read-write) transaction opened
121727 ** on the b-tree database, open one now. If a transaction is opened, it
121728 ** will be closed immediately after reading the meta-value. */
121729 if( !sqlite3BtreeIsInReadTrans(pBt) ){
121730 rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
121731 if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){
121732 sqlite3OomFault(db);
121733 }
121734 if( rc!=SQLITE_OK ) return;
121735 openedTransaction = 1;
@@ -121315,11 +122222,11 @@
122222 */
122223 #if SELECTTRACE_ENABLED
122224 /***/ int sqlite3SelectTrace = 0;
122225 # define SELECTTRACE(K,P,S,X) \
122226 if(sqlite3SelectTrace&(K)) \
122227 sqlite3DebugPrintf("%u/%d/%p: ",(S)->selId,(P)->addrExplain,(S)),\
122228 sqlite3DebugPrintf X
122229 #else
122230 # define SELECTTRACE(K,P,S,X)
122231 #endif
122232
@@ -121390,10 +122297,15 @@
122297 sqlite3ExprDelete(db, p->pWhere);
122298 sqlite3ExprListDelete(db, p->pGroupBy);
122299 sqlite3ExprDelete(db, p->pHaving);
122300 sqlite3ExprListDelete(db, p->pOrderBy);
122301 sqlite3ExprDelete(db, p->pLimit);
122302 #ifndef SQLITE_OMIT_WINDOWFUNC
122303 if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){
122304 sqlite3WindowListDelete(db, p->pWinDefn);
122305 }
122306 #endif
122307 if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);
122308 if( bFree ) sqlite3DbFreeNN(db, p);
122309 p = pPrior;
122310 bFree = 1;
122311 }
@@ -121440,13 +122352,11 @@
122352 pNew->pEList = pEList;
122353 pNew->op = TK_SELECT;
122354 pNew->selFlags = selFlags;
122355 pNew->iLimit = 0;
122356 pNew->iOffset = 0;
122357 pNew->selId = ++pParse->nSelect;
 
 
122358 pNew->addrOpenEphm[0] = -1;
122359 pNew->addrOpenEphm[1] = -1;
122360 pNew->nSelectRow = 0;
122361 if( pSrc==0 ) pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*pSrc));
122362 pNew->pSrc = pSrc;
@@ -121456,10 +122366,14 @@
122366 pNew->pOrderBy = pOrderBy;
122367 pNew->pPrior = 0;
122368 pNew->pNext = 0;
122369 pNew->pLimit = pLimit;
122370 pNew->pWith = 0;
122371 #ifndef SQLITE_OMIT_WINDOWFUNC
122372 pNew->pWin = 0;
122373 pNew->pWinDefn = 0;
122374 #endif
122375 if( pParse->db->mallocFailed ) {
122376 clearSelect(pParse->db, pNew, pNew!=&standin);
122377 pNew = 0;
122378 }else{
122379 assert( pNew->pSrc!=0 || pParse->nErr>0 );
@@ -121466,21 +122380,10 @@
122380 }
122381 assert( pNew!=&standin );
122382 return pNew;
122383 }
122384
 
 
 
 
 
 
 
 
 
 
 
122385
122386 /*
122387 ** Delete the given Select structure and all of its substructures.
122388 */
122389 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){
@@ -121823,18 +122726,10 @@
122726 }
122727 }
122728 return 0;
122729 }
122730
 
 
 
 
 
 
 
 
122731 /*
122732 ** An instance of this object holds information (beyond pParse and pSelect)
122733 ** needed to load the next result row that is to be added to the sorter.
122734 */
122735 typedef struct RowLoadInfo RowLoadInfo;
@@ -121972,11 +122867,11 @@
122867 pOp->p2 = nKey + nData;
122868 pKI = pOp->p4.pKeyInfo;
122869 memset(pKI->aSortOrder, 0, pKI->nKeyField); /* Makes OP_Jump testable */
122870 sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
122871 testcase( pKI->nAllField > pKI->nKeyField+2 );
122872 pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat,
122873 pKI->nAllField-pKI->nKeyField-1);
122874 addrJmp = sqlite3VdbeCurrentAddr(v);
122875 sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
122876 pSort->labelBkOut = sqlite3VdbeMakeLabel(v);
122877 pSort->regReturn = ++pParse->nMem;
@@ -122642,11 +123537,11 @@
123537 **
123538 ** Space to hold the KeyInfo structure is obtained from malloc. The calling
123539 ** function is responsible for seeing that this structure is eventually
123540 ** freed.
123541 */
123542 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList(
123543 Parse *pParse, /* Parsing context */
123544 ExprList *pList, /* Form the KeyInfo object from this ExprList */
123545 int iStart, /* Begin with this column of pList */
123546 int nExtra /* Add this many extra columns to the end */
123547 ){
@@ -124970,10 +125865,14 @@
125865 ** The subquery may not be an aggregate that uses the built-in min() or
125866 ** or max() functions. (Without this restriction, a query like:
125867 ** "SELECT x FROM (SELECT max(y), x FROM t1)" would not necessarily
125868 ** return the value X for which Y was maximal.)
125869 **
125870 ** (25) If either the subquery or the parent query contains a window
125871 ** function in the select list or ORDER BY clause, flattening
125872 ** is not attempted.
125873 **
125874 **
125875 ** In this routine, the "p" parameter is a pointer to the outer query.
125876 ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query
125877 ** uses aggregates.
125878 **
@@ -125012,10 +125911,14 @@
125911 assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );
125912 pSubitem = &pSrc->a[iFrom];
125913 iParent = pSubitem->iCursor;
125914 pSub = pSubitem->pSelect;
125915 assert( pSub!=0 );
125916
125917 #ifndef SQLITE_OMIT_WINDOWFUNC
125918 if( p->pWin || pSub->pWin ) return 0; /* Restriction (25) */
125919 #endif
125920
125921 pSubSrc = pSub->pSrc;
125922 assert( pSubSrc );
125923 /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,
125924 ** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET
@@ -125123,12 +126026,12 @@
126026 ** restriction (17d3)
126027 */
126028 assert( (p->selFlags & SF_Recursive)==0 || pSub->pPrior==0 );
126029
126030 /***** If we reach this point, flattening is permitted. *****/
126031 SELECTTRACE(1,pParse,p,("flatten %u.%p from term %d\n",
126032 pSub->selId, pSub, iFrom));
126033
126034 /* Authorize the subquery */
126035 pParse->zAuthContext = pSubitem->zName;
126036 TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);
126037 testcase( i==SQLITE_DENY );
@@ -125175,11 +126078,10 @@
126078 p->pOrderBy = 0;
126079 p->pSrc = 0;
126080 p->pPrior = 0;
126081 p->pLimit = 0;
126082 pNew = sqlite3SelectDup(db, p, 0);
 
126083 p->pLimit = pLimit;
126084 p->pOrderBy = pOrderBy;
126085 p->pSrc = pSrc;
126086 p->op = TK_ALL;
126087 if( pNew==0 ){
@@ -125188,11 +126090,11 @@
126090 pNew->pPrior = pPrior;
126091 if( pPrior ) pPrior->pNext = pNew;
126092 pNew->pNext = p;
126093 p->pPrior = pNew;
126094 SELECTTRACE(2,pParse,p,("compound-subquery flattener"
126095 " creates %u as peer\n",pNew->selId));
126096 }
126097 if( db->mallocFailed ) return 1;
126098 }
126099
126100 /* Begin flattening the iFrom-th entry of the FROM clause
@@ -125403,11 +126305,11 @@
126305 ** to suppress it. **)
126306 **
126307 ** (2) The inner query is the recursive part of a common table expression.
126308 **
126309 ** (3) The inner query has a LIMIT clause (since the changes to the WHERE
126310 ** clause would change the meaning of the LIMIT).
126311 **
126312 ** (4) The inner query is the right operand of a LEFT JOIN and the
126313 ** expression to be pushed down does not come from the ON clause
126314 ** on that LEFT JOIN.
126315 **
@@ -125421,10 +126323,14 @@
126323 ** LEFT JOIN (SELECT 8 AS c3 UNION ALL SELECT 9) AS cc ON (b2=2);
126324 **
126325 ** The correct answer is three rows: (1,1,NULL),(2,2,8),(2,2,9).
126326 ** But if the (b2=2) term were to be pushed down into the bb subquery,
126327 ** then the (1,1,NULL) row would be suppressed.
126328 **
126329 ** (6) The inner query features one or more window-functions (since
126330 ** changes to the WHERE clause of the inner query could change the
126331 ** window over which window functions are calculated).
126332 **
126333 ** Return 0 if no changes are made and non-zero if one or more WHERE clause
126334 ** terms are duplicated into the subquery.
126335 */
126336 static int pushDownWhereTerms(
@@ -125436,10 +126342,14 @@
126342 ){
126343 Expr *pNew;
126344 int nChng = 0;
126345 if( pWhere==0 ) return 0;
126346 if( pSubq->selFlags & SF_Recursive ) return 0; /* restriction (2) */
126347
126348 #ifndef SQLITE_OMIT_WINDOWFUNC
126349 if( pSubq->pWin ) return 0; /* restriction (6) */
126350 #endif
126351
126352 #ifdef SQLITE_DEBUG
126353 /* Only the first term of a compound can have a WITH clause. But make
126354 ** sure no other terms are marked SF_Recursive in case something changes
126355 ** in the future.
@@ -125881,10 +126791,39 @@
126791 }
126792 }
126793 #else
126794 #define selectPopWith 0
126795 #endif
126796
126797 /*
126798 ** The SrcList_item structure passed as the second argument represents a
126799 ** sub-query in the FROM clause of a SELECT statement. This function
126800 ** allocates and populates the SrcList_item.pTab object. If successful,
126801 ** SQLITE_OK is returned. Otherwise, if an OOM error is encountered,
126802 ** SQLITE_NOMEM.
126803 */
126804 SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse *pParse, struct SrcList_item *pFrom){
126805 Select *pSel = pFrom->pSelect;
126806 Table *pTab;
126807
126808 assert( pSel );
126809 pFrom->pTab = pTab = sqlite3DbMallocZero(pParse->db, sizeof(Table));
126810 if( pTab==0 ) return SQLITE_NOMEM;
126811 pTab->nTabRef = 1;
126812 if( pFrom->zAlias ){
126813 pTab->zName = sqlite3DbStrDup(pParse->db, pFrom->zAlias);
126814 }else{
126815 pTab->zName = sqlite3MPrintf(pParse->db, "subquery_%u", pSel->selId);
126816 }
126817 while( pSel->pPrior ){ pSel = pSel->pPrior; }
126818 sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);
126819 pTab->iPKey = -1;
126820 pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
126821 pTab->tabFlags |= TF_Ephemeral;
126822
126823 return SQLITE_OK;
126824 }
126825
126826 /*
126827 ** This routine is a Walker callback for "expanding" a SELECT statement.
126828 ** "Expanding" means to do the following:
126829 **
@@ -125954,23 +126893,11 @@
126893 Select *pSel = pFrom->pSelect;
126894 /* A sub-query in the FROM clause of a SELECT */
126895 assert( pSel!=0 );
126896 assert( pFrom->pTab==0 );
126897 if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;
126898 if( sqlite3ExpandSubquery(pParse, pFrom) ) return WRC_Abort;
 
 
 
 
 
 
 
 
 
 
 
 
126899 #endif
126900 }else{
126901 /* An ordinary table or view name in the FROM clause */
126902 assert( pFrom->pTab==0 );
126903 pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom);
@@ -125989,11 +126916,10 @@
126916 if( IsVirtual(pTab) || pTab->pSelect ){
126917 i16 nCol;
126918 if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;
126919 assert( pFrom->pSelect==0 );
126920 pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);
 
126921 nCol = pTab->nCol;
126922 pTab->nCol = -1;
126923 sqlite3WalkSelect(pWalker, pFrom->pSelect);
126924 pTab->nCol = nCol;
126925 }
@@ -126267,11 +127193,11 @@
127193 int i;
127194 SrcList *pTabList;
127195 struct SrcList_item *pFrom;
127196
127197 assert( p->selFlags & SF_Resolved );
127198 if( p->selFlags & SF_HasTypeInfo ) return;
127199 p->selFlags |= SF_HasTypeInfo;
127200 pParse = pWalker->pParse;
127201 pTabList = p->pSrc;
127202 for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
127203 Table *pTab = pFrom->pTab;
@@ -126370,11 +127296,11 @@
127296 if( pE->x.pList==0 || pE->x.pList->nExpr!=1 ){
127297 sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one "
127298 "argument");
127299 pFunc->iDistinct = -1;
127300 }else{
127301 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pE->x.pList,0,0);
127302 sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc->iDistinct, 0, 0,
127303 (char*)pKeyInfo, P4_KEYINFO);
127304 }
127305 }
127306 }
@@ -126393,16 +127319,22 @@
127319 assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
127320 sqlite3VdbeAddOp2(v, OP_AggFinal, pF->iMem, pList ? pList->nExpr : 0);
127321 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
127322 }
127323 }
127324
127325
127326 /*
127327 ** Update the accumulator memory cells for an aggregate based on
127328 ** the current cursor position.
127329 **
127330 ** If regAcc is non-zero and there are no min() or max() aggregates
127331 ** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator
127332 ** registers i register regAcc contains 0. The caller will take care
127333 ** of setting and clearing regAcc.
127334 */
127335 static void updateAccumulator(Parse *pParse, int regAcc, AggInfo *pAggInfo){
127336 Vdbe *v = pParse->pVdbe;
127337 int i;
127338 int regHit = 0;
127339 int addrHitTest = 0;
127340 struct AggInfo_func *pF;
@@ -126441,11 +127373,11 @@
127373 pColl = pParse->db->pDfltColl;
127374 }
127375 if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem;
127376 sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ);
127377 }
127378 sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, pF->iMem);
127379 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
127380 sqlite3VdbeChangeP5(v, (u8)nArg);
127381 sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);
127382 sqlite3ReleaseTempRange(pParse, regAgg, nArg);
127383 if( addrNext ){
@@ -126462,10 +127394,13 @@
127394 ** text or blob value. See ticket [883034dcb5].
127395 **
127396 ** Another solution would be to change the OP_SCopy used to copy cached
127397 ** values to an OP_Copy.
127398 */
127399 if( regHit==0 && pAggInfo->nAccumulator ){
127400 regHit = regAcc;
127401 }
127402 if( regHit ){
127403 addrHitTest = sqlite3VdbeAddOp1(v, OP_If, regHit); VdbeCoverage(v);
127404 }
127405 sqlite3ExprCacheClear(pParse);
127406 for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){
@@ -126735,18 +127670,14 @@
127670 sqlite3ExprListDelete(db, p->pOrderBy);
127671 p->pOrderBy = 0;
127672 p->selFlags &= ~SF_Distinct;
127673 }
127674 sqlite3SelectPrep(pParse, p, 0);
 
 
 
127675 if( pParse->nErr || db->mallocFailed ){
127676 goto select_end;
127677 }
127678 assert( p->pEList!=0 );
 
127679 #if SELECTTRACE_ENABLED
127680 if( sqlite3SelectTrace & 0x104 ){
127681 SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
127682 sqlite3TreeViewSelect(0, p, 0);
127683 }
@@ -126754,10 +127685,26 @@
127685
127686 if( pDest->eDest==SRT_Output ){
127687 generateColumnNames(pParse, p);
127688 }
127689
127690 #ifndef SQLITE_OMIT_WINDOWFUNC
127691 if( sqlite3WindowRewrite(pParse, p) ){
127692 goto select_end;
127693 }
127694 #if SELECTTRACE_ENABLED
127695 if( sqlite3SelectTrace & 0x108 ){
127696 SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n"));
127697 sqlite3TreeViewSelect(0, p, 0);
127698 }
127699 #endif
127700 #endif /* SQLITE_OMIT_WINDOWFUNC */
127701 pTabList = p->pSrc;
127702 isAgg = (p->selFlags & SF_Aggregate)!=0;
127703 memset(&sSort, 0, sizeof(sSort));
127704 sSort.pOrderBy = p->pOrderBy;
127705
127706 /* Try to various optimizations (flattening subqueries, and strength
127707 ** reduction of join operators) in the FROM clause up into the main query
127708 */
127709 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
127710 for(i=0; !p->pPrior && i<pTabList->nSrc; i++){
@@ -126960,11 +127907,11 @@
127907 pItem->regReturn = ++pParse->nMem;
127908 sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->regReturn, 0, addrTop);
127909 VdbeComment((v, "%s", pItem->pTab->zName));
127910 pItem->addrFillSub = addrTop;
127911 sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn);
127912 ExplainQueryPlan((pParse, 1, "CO-ROUTINE %u", pSub->selId));
127913 sqlite3Select(pParse, pSub, &dest);
127914 pItem->pTab->nRowLogEst = pSub->nSelectRow;
127915 pItem->fg.viaCoroutine = 1;
127916 pItem->regResult = dest.iSdst;
127917 sqlite3VdbeEndCoroutine(v, pItem->regReturn);
@@ -126999,11 +127946,11 @@
127946 sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
127947 assert( pPrior->pSelect!=0 );
127948 pSub->nSelectRow = pPrior->pSelect->nSelectRow;
127949 }else{
127950 sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
127951 ExplainQueryPlan((pParse, 1, "MATERIALIZE %u", pSub->selId));
127952 sqlite3Select(pParse, pSub, &dest);
127953 }
127954 pItem->pTab->nRowLogEst = pSub->nSelectRow;
127955 if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);
127956 retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);
@@ -127083,11 +128030,12 @@
128030 ** not needed. The sSort.addrSortIndex variable is used to facilitate
128031 ** that change.
128032 */
128033 if( sSort.pOrderBy ){
128034 KeyInfo *pKeyInfo;
128035 pKeyInfo = sqlite3KeyInfoFromExprList(
128036 pParse, sSort.pOrderBy, 0, pEList->nExpr);
128037 sSort.iECursor = pParse->nTab++;
128038 sSort.addrSortIndex =
128039 sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
128040 sSort.iECursor, sSort.pOrderBy->nExpr+1+pEList->nExpr, 0,
128041 (char*)pKeyInfo, P4_KEYINFO
@@ -127117,24 +128065,31 @@
128065 /* Open an ephemeral index to use for the distinct set.
128066 */
128067 if( p->selFlags & SF_Distinct ){
128068 sDistinct.tabTnct = pParse->nTab++;
128069 sDistinct.addrTnct = sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
128070 sDistinct.tabTnct, 0, 0,
128071 (char*)sqlite3KeyInfoFromExprList(pParse, p->pEList,0,0),
128072 P4_KEYINFO);
128073 sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
128074 sDistinct.eTnctType = WHERE_DISTINCT_UNORDERED;
128075 }else{
128076 sDistinct.eTnctType = WHERE_DISTINCT_NOOP;
128077 }
128078
128079 if( !isAgg && pGroupBy==0 ){
128080 /* No aggregate functions and no GROUP BY clause */
128081 u16 wctrlFlags = (sDistinct.isTnct ? WHERE_WANT_DISTINCT : 0)
128082 | (p->selFlags & SF_FixedLimit);
128083 #ifndef SQLITE_OMIT_WINDOWFUNC
128084 Window *pWin = p->pWin; /* Master window object (or NULL) */
128085 if( pWin ){
128086 sqlite3WindowCodeInit(pParse, pWin);
128087 }
128088 #endif
128089 assert( WHERE_USE_LIMIT==SF_FixedLimit );
128090
128091
128092 /* Begin the database scan. */
128093 SELECTTRACE(1,pParse,p,("WhereBegin\n"));
128094 pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, sSort.pOrderBy,
128095 p->pEList, wctrlFlags, p->nSelectRow);
@@ -127159,19 +128114,40 @@
128114 */
128115 if( sSort.addrSortIndex>=0 && sSort.pOrderBy==0 ){
128116 sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex);
128117 }
128118
 
128119 assert( p->pEList==pEList );
128120 #ifndef SQLITE_OMIT_WINDOWFUNC
128121 if( pWin ){
128122 int addrGosub = sqlite3VdbeMakeLabel(v);
128123 int iCont = sqlite3VdbeMakeLabel(v);
128124 int iBreak = sqlite3VdbeMakeLabel(v);
128125 int regGosub = ++pParse->nMem;
128126
128127 sqlite3WindowCodeStep(pParse, p, pWInfo, regGosub, addrGosub);
128128
128129 sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak);
128130 sqlite3VdbeResolveLabel(v, addrGosub);
128131 VdbeNoopComment((v, "inner-loop subroutine"));
128132 selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest, iCont, iBreak);
128133 sqlite3VdbeResolveLabel(v, iCont);
128134 sqlite3VdbeAddOp1(v, OP_Return, regGosub);
128135 VdbeComment((v, "end inner-loop subroutine"));
128136 sqlite3VdbeResolveLabel(v, iBreak);
128137 }else
128138 #endif /* SQLITE_OMIT_WINDOWFUNC */
128139 {
128140 /* Use the standard inner loop. */
128141 selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest,
128142 sqlite3WhereContinueLabel(pWInfo),
128143 sqlite3WhereBreakLabel(pWInfo));
128144
128145 /* End the database scan loop.
128146 */
128147 sqlite3WhereEnd(pWInfo);
128148 }
128149 }else{
128150 /* This case when there exist aggregate functions or a GROUP BY clause
128151 ** or both */
128152 NameContext sNC; /* Name context for processing aggregate information */
128153 int iAMem; /* First Mem address for storing current GROUP BY */
@@ -127296,11 +128272,11 @@
128272 ** implement it. Allocate that sorting index now. If it turns out
128273 ** that we do not need it after all, the OP_SorterOpen instruction
128274 ** will be converted into a Noop.
128275 */
128276 sAggInfo.sortingIdx = pParse->nTab++;
128277 pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pGroupBy,0,sAggInfo.nColumn);
128278 addrSortingIdx = sqlite3VdbeAddOp4(v, OP_SorterOpen,
128279 sAggInfo.sortingIdx, sAggInfo.nSortingColumn,
128280 0, (char*)pKeyInfo, P4_KEYINFO);
128281
128282 /* Initialize memory locations used by GROUP BY aggregate processing
@@ -127315,12 +128291,10 @@
128291 pParse->nMem += pGroupBy->nExpr;
128292 iBMem = pParse->nMem + 1;
128293 pParse->nMem += pGroupBy->nExpr;
128294 sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag);
128295 VdbeComment((v, "clear abort flag"));
 
 
128296 sqlite3VdbeAddOp3(v, OP_Null, 0, iAMem, iAMem+pGroupBy->nExpr-1);
128297
128298 /* Begin a loop that will extract all source rows in GROUP BY order.
128299 ** This might involve two separate loops with an OP_Sort in between, or
128300 ** it might be a single loop that uses an index to extract information
@@ -127449,11 +128423,11 @@
128423
128424 /* Update the aggregate accumulators based on the content of
128425 ** the current row
128426 */
128427 sqlite3VdbeJumpHere(v, addr1);
128428 updateAccumulator(pParse, iUseFlag, &sAggInfo);
128429 sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);
128430 VdbeComment((v, "indicate data in accumulator"));
128431
128432 /* End of the loop
128433 */
@@ -127501,10 +128475,12 @@
128475
128476 /* Generate a subroutine that will reset the group-by accumulator
128477 */
128478 sqlite3VdbeResolveLabel(v, addrReset);
128479 resetAccumulator(pParse, &sAggInfo);
128480 sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);
128481 VdbeComment((v, "indicate accumulator empty"));
128482 sqlite3VdbeAddOp1(v, OP_Return, regReset);
128483
128484 } /* endif pGroupBy. Begin aggregate queries without GROUP BY: */
128485 else {
128486 #ifndef SQLITE_OMIT_BTREECOUNT
@@ -127566,10 +128542,27 @@
128542 sqlite3VdbeAddOp1(v, OP_Close, iCsr);
128543 explainSimpleCount(pParse, pTab, pBest);
128544 }else
128545 #endif /* SQLITE_OMIT_BTREECOUNT */
128546 {
128547 int regAcc = 0; /* "populate accumulators" flag */
128548
128549 /* If there are accumulator registers but no min() or max() functions,
128550 ** allocate register regAcc. Register regAcc will contain 0 the first
128551 ** time the inner loop runs, and 1 thereafter. The code generated
128552 ** by updateAccumulator() only updates the accumulator registers if
128553 ** regAcc contains 0. */
128554 if( sAggInfo.nAccumulator ){
128555 for(i=0; i<sAggInfo.nFunc; i++){
128556 if( sAggInfo.aFunc[i].pFunc->funcFlags&SQLITE_FUNC_NEEDCOLL ) break;
128557 }
128558 if( i==sAggInfo.nFunc ){
128559 regAcc = ++pParse->nMem;
128560 sqlite3VdbeAddOp2(v, OP_Integer, 0, regAcc);
128561 }
128562 }
128563
128564 /* This case runs if the aggregate has no GROUP BY clause. The
128565 ** processing is much simpler since there is only a single row
128566 ** of output.
128567 */
128568 assert( p->pGroupBy==0 );
@@ -127587,11 +128580,12 @@
128580 pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMaxOrderBy,
128581 0, minMaxFlag, 0);
128582 if( pWInfo==0 ){
128583 goto select_end;
128584 }
128585 updateAccumulator(pParse, regAcc, &sAggInfo);
128586 if( regAcc ) sqlite3VdbeAddOp2(v, OP_Integer, 1, regAcc);
128587 if( sqlite3WhereIsOrdered(pWInfo)>0 ){
128588 sqlite3VdbeGoto(v, sqlite3WhereBreakLabel(pWInfo));
128589 VdbeComment((v, "%s() by index",
128590 (minMaxFlag==WHERE_ORDERBY_MIN?"min":"max")));
128591 }
@@ -129520,11 +130514,11 @@
130514 /* Top of the update loop */
130515 if( eOnePass!=ONEPASS_OFF ){
130516 if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){
130517 assert( pPk );
130518 sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey,nKey);
130519 VdbeCoverage(v);
130520 }
130521 if( eOnePass!=ONEPASS_SINGLE ){
130522 labelContinue = sqlite3VdbeMakeLabel(v);
130523 }
130524 sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
@@ -130423,11 +131417,11 @@
131417 ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,
131418 ** to ensure that we do not try to change the page-size on a WAL database.
131419 */
131420 rc = execSql(db, pzErrMsg, "BEGIN");
131421 if( rc!=SQLITE_OK ) goto end_of_vacuum;
131422 rc = sqlite3BtreeBeginTrans(pMain, 2, 0);
131423 if( rc!=SQLITE_OK ) goto end_of_vacuum;
131424
131425 /* Do not attempt to change the page size for a WAL database */
131426 if( sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain))
131427 ==PAGER_JOURNALMODE_WAL ){
@@ -131932,10 +132926,12 @@
132926 struct {
132927 int nIn; /* Number of entries in aInLoop[] */
132928 struct InLoop {
132929 int iCur; /* The VDBE cursor used by this IN operator */
132930 int addrInTop; /* Top of the IN loop */
132931 int iBase; /* Base register of multi-key index record */
132932 int nPrefix; /* Number of prior entires in the key */
132933 u8 eEndLoopOp; /* IN Loop terminator. OP_Next or OP_Prev */
132934 } *aInLoop; /* Information about each nested IN operator */
132935 } in; /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */
132936 Index *pCovidx; /* Possible covering index for WHERE_MULTI_OR */
132937 } u;
@@ -132170,10 +133166,11 @@
133166 */
133167 struct WhereClause {
133168 WhereInfo *pWInfo; /* WHERE clause processing context */
133169 WhereClause *pOuter; /* Outer conjunction */
133170 u8 op; /* Split operator. TK_AND or TK_OR */
133171 u8 hasOr; /* True if any a[].eOperator is WO_OR */
133172 int nTerm; /* Number of terms */
133173 int nSlot; /* Number of entries in a[] */
133174 WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
133175 #if defined(SQLITE_SMALL_STACK)
133176 WhereTerm aStatic[1]; /* Initial static space for a[] */
@@ -132343,10 +133340,11 @@
133340 /* whereexpr.c: */
133341 SQLITE_PRIVATE void sqlite3WhereClauseInit(WhereClause*,WhereInfo*);
133342 SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause*);
133343 SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause*,Expr*,u8);
133344 SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*);
133345 SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet*, Expr*);
133346 SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*);
133347 SQLITE_PRIVATE void sqlite3WhereExprAnalyze(SrcList*, WhereClause*);
133348 SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*);
133349
133350
@@ -132405,10 +133403,11 @@
133403 #define WHERE_MULTI_OR 0x00002000 /* OR using multiple indices */
133404 #define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
133405 #define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
133406 #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
133407 #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
133408 #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
133409
133410 /************** End of whereInt.h ********************************************/
133411 /************** Continuing where we left off in wherecode.c ******************/
133412
133413 #ifndef SQLITE_OMIT_EXPLAIN
@@ -132539,11 +133538,11 @@
133538 || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
133539
133540 sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
133541 sqlite3_str_appendall(&str, isSearch ? "SEARCH" : "SCAN");
133542 if( pItem->pSelect ){
133543 sqlite3_str_appendf(&str, " SUBQUERY %u", pItem->pSelect->selId);
133544 }else{
133545 sqlite3_str_appendf(&str, " TABLE %s", pItem->zName);
133546 }
133547
133548 if( pItem->zAlias ){
@@ -132980,11 +133979,18 @@
133979 pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut);
133980 }
133981 sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v);
133982 if( i==iEq ){
133983 pIn->iCur = iTab;
133984 pIn->eEndLoopOp = bRev ? OP_Prev : OP_Next;
133985 if( iEq>0 && (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){
133986 pIn->iBase = iReg - i;
133987 pIn->nPrefix = i;
133988 pLoop->wsFlags |= WHERE_IN_EARLYOUT;
133989 }else{
133990 pIn->nPrefix = 0;
133991 }
133992 }else{
133993 pIn->eEndLoopOp = OP_Noop;
133994 }
133995 pIn++;
133996 }
@@ -133624,11 +134630,11 @@
134630 if( pTabItem->fg.viaCoroutine ){
134631 int regYield = pTabItem->regReturn;
134632 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
134633 pLevel->p2 = sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk);
134634 VdbeCoverage(v);
134635 VdbeComment((v, "next row of %s", pTabItem->pTab->zName));
134636 pLevel->op = OP_Goto;
134637 }else
134638
134639 #ifndef SQLITE_OMIT_VIRTUALTABLE
134640 if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){
@@ -134047,10 +135053,13 @@
135053 if( pLoop->nSkip>0 && nConstraint==pLoop->nSkip ){
135054 /* The skip-scan logic inside the call to codeAllEqualityConstraints()
135055 ** above has already left the cursor sitting on the correct row,
135056 ** so no further seeking is needed */
135057 }else{
135058 if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
135059 sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur);
135060 }
135061 op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
135062 assert( op!=0 );
135063 sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
135064 VdbeCoverage(v);
135065 VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind );
@@ -134109,10 +135118,14 @@
135118 testcase( op==OP_IdxGT ); VdbeCoverageIf(v, op==OP_IdxGT );
135119 testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE );
135120 testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
135121 testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
135122 }
135123
135124 if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
135125 sqlite3VdbeAddOp2(v, OP_SeekHit, iIdxCur, 1);
135126 }
135127
135128 /* Seek the table cursor, if required */
135129 if( omitTable ){
135130 /* pIdx is a covering index. No need to access the main table. */
135131 }else if( HasRowid(pIdx->pTable) ){
@@ -134882,15 +135895,17 @@
135895 if( c==wc[3] && z[cnt]!=0 ) cnt++;
135896 }
135897
135898 /* The optimization is possible only if (1) the pattern does not begin
135899 ** with a wildcard and if (2) the non-wildcard prefix does not end with
135900 ** an (illegal 0xff) character, or (3) the pattern does not consist of
135901 ** a single escape character. The second condition is necessary so
135902 ** that we can increment the prefix key to find an upper bound for the
135903 ** range search. The third is because the caller assumes that the pattern
135904 ** consists of at least one character after all escapes have been
135905 ** removed. */
135906 if( cnt!=0 && 255!=(u8)z[cnt-1] && (cnt>1 || z[0]!=wc[3]) ){
135907 Expr *pPrefix;
135908
135909 /* A "complete" match if the pattern ends with "*" or "%" */
135910 *pisComplete = c==wc[0] && z[cnt+1]==0;
135911
@@ -135298,11 +136313,16 @@
136313 /*
136314 ** Record the set of tables that satisfy case 3. The set might be
136315 ** empty.
136316 */
136317 pOrInfo->indexable = indexable;
136318 if( indexable ){
136319 pTerm->eOperator = WO_OR;
136320 pWC->hasOr = 1;
136321 }else{
136322 pTerm->eOperator = WO_OR;
136323 }
136324
136325 /* For a two-way OR, attempt to implementation case 2.
136326 */
136327 if( indexable && pOrWc->nTerm==2 ){
136328 int iOne = 0;
@@ -135637,11 +136657,11 @@
136657 pTerm->prereqRight = 0;
136658 }else{
136659 pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
136660 }
136661 pMaskSet->bVarSelect = 0;
136662 prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);
136663 if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;
136664 if( ExprHasProperty(pExpr, EP_FromJoin) ){
136665 Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
136666 prereqAll |= x;
136667 extraRight = x-1; /* ON clause terms may not be used with an index
@@ -136030,10 +137050,11 @@
137050 SQLITE_PRIVATE void sqlite3WhereClauseInit(
137051 WhereClause *pWC, /* The WhereClause to be initialized */
137052 WhereInfo *pWInfo /* The WHERE processing context */
137053 ){
137054 pWC->pWInfo = pWInfo;
137055 pWC->hasOr = 0;
137056 pWC->pOuter = 0;
137057 pWC->nTerm = 0;
137058 pWC->nSlot = ArraySize(pWC->aStatic);
137059 pWC->a = pWC->aStatic;
137060 }
@@ -136066,29 +137087,33 @@
137087 /*
137088 ** These routines walk (recursively) an expression tree and generate
137089 ** a bitmask indicating which tables are used in that expression
137090 ** tree.
137091 */
137092 SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
137093 Bitmask mask;
 
137094 if( p->op==TK_COLUMN ){
137095 return sqlite3WhereGetMask(pMaskSet, p->iTable);
137096 }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
137097 assert( p->op!=TK_IF_NULL_ROW );
137098 return 0;
137099 }
137100 mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
137101 if( p->pLeft ) mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);
 
137102 if( p->pRight ){
137103 mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pRight);
137104 assert( p->x.pList==0 );
137105 }else if( ExprHasProperty(p, EP_xIsSelect) ){
137106 if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1;
137107 mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
137108 }else if( p->x.pList ){
137109 mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
137110 }
137111 return mask;
137112 }
137113 SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
137114 return p ? sqlite3WhereExprUsageNN(pMaskSet,p) : 0;
137115 }
137116 SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet *pMaskSet, ExprList *pList){
137117 int i;
137118 Bitmask mask = 0;
137119 if( pList ){
@@ -136970,11 +137995,11 @@
137995 int regYield = pTabItem->regReturn;
137996 addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);
137997 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
137998 addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield);
137999 VdbeCoverage(v);
138000 VdbeComment((v, "next row of %s", pTabItem->pTab->zName));
138001 }else{
138002 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);
138003 }
138004 if( pPartial ){
138005 iContinue = sqlite3VdbeMakeLabel(v);
@@ -138611,11 +139636,10 @@
139636 || (pNew->wsFlags & WHERE_SKIPSCAN)!=0
139637 );
139638
139639 if( eOp & WO_IN ){
139640 Expr *pExpr = pTerm->pExpr;
 
139641 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
139642 /* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */
139643 int i;
139644 nIn = 46; assert( 46==sqlite3LogEst(25) );
139645
@@ -138631,10 +139655,46 @@
139655 /* "x IN (value, value, ...)" */
139656 nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
139657 assert( nIn>0 ); /* RHS always has 2 or more terms... The parser
139658 ** changes "x IN (?)" into "x=?". */
139659 }
139660 if( pProbe->hasStat1 ){
139661 LogEst M, logK, safetyMargin;
139662 /* Let:
139663 ** N = the total number of rows in the table
139664 ** K = the number of entries on the RHS of the IN operator
139665 ** M = the number of rows in the table that match terms to the
139666 ** to the left in the same index. If the IN operator is on
139667 ** the left-most index column, M==N.
139668 **
139669 ** Given the definitions above, it is better to omit the IN operator
139670 ** from the index lookup and instead do a scan of the M elements,
139671 ** testing each scanned row against the IN operator separately, if:
139672 **
139673 ** M*log(K) < K*log(N)
139674 **
139675 ** Our estimates for M, K, and N might be inaccurate, so we build in
139676 ** a safety margin of 2 (LogEst: 10) that favors using the IN operator
139677 ** with the index, as using an index has better worst-case behavior.
139678 ** If we do not have real sqlite_stat1 data, always prefer to use
139679 ** the index.
139680 */
139681 M = pProbe->aiRowLogEst[saved_nEq];
139682 logK = estLog(nIn);
139683 safetyMargin = 10; /* TUNING: extra weight for indexed IN */
139684 if( M + logK + safetyMargin < nIn + rLogSize ){
139685 WHERETRACE(0x40,
139686 ("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n",
139687 saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
139688 continue;
139689 }else{
139690 WHERETRACE(0x40,
139691 ("IN operator preferred on column %d of \"%s\" (%d>=%d)\n",
139692 saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
139693 }
139694 }
139695 pNew->wsFlags |= WHERE_COLUMN_IN;
139696 }else if( eOp & (WO_EQ|WO_IS) ){
139697 int iCol = pProbe->aiColumn[saved_nEq];
139698 pNew->wsFlags |= WHERE_COLUMN_EQ;
139699 assert( saved_nEq==pNew->u.btree.nEq );
139700 if( iCol==XN_ROWID
@@ -138797,10 +139857,11 @@
139857 ** more expensive. */
139858 assert( 42==sqlite3LogEst(18) );
139859 if( saved_nEq==saved_nSkip
139860 && saved_nEq+1<pProbe->nKeyCol
139861 && pProbe->noSkipScan==0
139862 && OptimizationEnabled(db, SQLITE_SkipScan)
139863 && pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */
139864 && (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
139865 ){
139866 LogEst nIter;
139867 pNew->u.btree.nEq++;
@@ -138860,28 +139921,10 @@
139921 }
139922 }
139923 return 0;
139924 }
139925
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139926 /* Check to see if a partial index with pPartIndexWhere can be used
139927 ** in the current query. Return true if it can be and false if not.
139928 */
139929 static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
139930 int i;
@@ -139093,11 +140136,11 @@
140136 Bitmask m;
140137 if( pProbe->isCovering ){
140138 pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
140139 m = 0;
140140 }else{
140141 m = pSrc->colUsed & pProbe->colNotIdxed;
140142 pNew->wsFlags = (m==0) ? (WHERE_IDX_ONLY|WHERE_INDEXED) : WHERE_INDEXED;
140143 }
140144
140145 /* Full scan via index */
140146 if( b
@@ -139660,11 +140703,11 @@
140703 }else
140704 #endif /* SQLITE_OMIT_VIRTUALTABLE */
140705 {
140706 rc = whereLoopAddBtree(pBuilder, mPrereq);
140707 }
140708 if( rc==SQLITE_OK && pBuilder->pWC->hasOr ){
140709 rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
140710 }
140711 mPrior |= pNew->maskSelf;
140712 if( rc || db->mallocFailed ) break;
140713 }
@@ -140496,11 +141539,11 @@
141539 testcase( pTerm->eOperator & WO_IS );
141540 pLoop->aLTerm[j] = pTerm;
141541 }
141542 if( j!=pIdx->nKeyCol ) continue;
141543 pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED;
141544 if( pIdx->isCovering || (pItem->colUsed & pIdx->colNotIdxed)==0 ){
141545 pLoop->wsFlags |= WHERE_IDX_ONLY;
141546 }
141547 pLoop->nLTerm = j;
141548 pLoop->u.btree.nEq = j;
141549 pLoop->u.btree.pIndex = pIdx;
@@ -141176,10 +142219,30 @@
142219 whereInfoFree(db, pWInfo);
142220 }
142221 return 0;
142222 }
142223
142224 /*
142225 ** Part of sqlite3WhereEnd() will rewrite opcodes to reference the
142226 ** index rather than the main table. In SQLITE_DEBUG mode, we want
142227 ** to trace those changes if PRAGMA vdbe_addoptrace=on. This routine
142228 ** does that.
142229 */
142230 #ifndef SQLITE_DEBUG
142231 # define OpcodeRewriteTrace(D,K,P) /* no-op */
142232 #else
142233 # define OpcodeRewriteTrace(D,K,P) sqlite3WhereOpcodeRewriteTrace(D,K,P)
142234 static void sqlite3WhereOpcodeRewriteTrace(
142235 sqlite3 *db,
142236 int pc,
142237 VdbeOp *pOp
142238 ){
142239 if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;
142240 sqlite3VdbePrintOp(0, pc, pOp);
142241 }
142242 #endif
142243
142244 /*
142245 ** Generate the end of the WHERE loop. See comments on
142246 ** sqlite3WhereBegin() for additional information.
142247 */
142248 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
@@ -141243,14 +142306,21 @@
142306 int j;
142307 sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
142308 for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
142309 sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
142310 if( pIn->eEndLoopOp!=OP_Noop ){
142311 if( pIn->nPrefix ){
142312 assert( pLoop->wsFlags & WHERE_IN_EARLYOUT );
142313 sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,
142314 sqlite3VdbeCurrentAddr(v)+2,
142315 pIn->iBase, pIn->nPrefix);
142316 VdbeCoverage(v);
142317 }
142318 sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
142319 VdbeCoverage(v);
142320 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Prev);
142321 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Next);
142322 }
142323 sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
142324 }
142325 }
142326 sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
@@ -141337,10 +142407,15 @@
142407 && (pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable))
142408 && !db->mallocFailed
142409 ){
142410 last = sqlite3VdbeCurrentAddr(v);
142411 k = pLevel->addrBody;
142412 #ifdef SQLITE_DEBUG
142413 if( db->flags & SQLITE_VdbeAddopTrace ){
142414 printf("TRANSLATE opcodes in range %d..%d\n", k, last-1);
142415 }
142416 #endif
142417 pOp = sqlite3VdbeGetOp(v, k);
142418 for(; k<last; k++, pOp++){
142419 if( pOp->p1!=pLevel->iTabCur ) continue;
142420 if( pOp->opcode==OP_Column
142421 #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
@@ -141356,20 +142431,26 @@
142431 }
142432 x = sqlite3ColumnOfIndex(pIdx, x);
142433 if( x>=0 ){
142434 pOp->p2 = x;
142435 pOp->p1 = pLevel->iIdxCur;
142436 OpcodeRewriteTrace(db, k, pOp);
142437 }
142438 assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0
142439 || pWInfo->eOnePass );
142440 }else if( pOp->opcode==OP_Rowid ){
142441 pOp->p1 = pLevel->iIdxCur;
142442 pOp->opcode = OP_IdxRowid;
142443 OpcodeRewriteTrace(db, k, pOp);
142444 }else if( pOp->opcode==OP_IfNullRow ){
142445 pOp->p1 = pLevel->iIdxCur;
142446 OpcodeRewriteTrace(db, k, pOp);
142447 }
142448 }
142449 #ifdef SQLITE_DEBUG
142450 if( db->flags & SQLITE_VdbeAddopTrace ) printf("TRANSLATE complete\n");
142451 #endif
142452 }
142453 }
142454
142455 /* Final cleanup
142456 */
@@ -141377,10 +142458,2262 @@
142458 whereInfoFree(db, pWInfo);
142459 return;
142460 }
142461
142462 /************** End of where.c ***********************************************/
142463 /************** Begin file window.c ******************************************/
142464 /*
142465 ** 2018 May 08
142466 **
142467 ** The author disclaims copyright to this source code. In place of
142468 ** a legal notice, here is a blessing:
142469 **
142470 ** May you do good and not evil.
142471 ** May you find forgiveness for yourself and forgive others.
142472 ** May you share freely, never taking more than you give.
142473 **
142474 *************************************************************************
142475 */
142476 /* #include "sqliteInt.h" */
142477
142478 #ifndef SQLITE_OMIT_WINDOWFUNC
142479
142480 /*
142481 ** SELECT REWRITING
142482 **
142483 ** Any SELECT statement that contains one or more window functions in
142484 ** either the select list or ORDER BY clause (the only two places window
142485 ** functions may be used) is transformed by function sqlite3WindowRewrite()
142486 ** in order to support window function processing. For example, with the
142487 ** schema:
142488 **
142489 ** CREATE TABLE t1(a, b, c, d, e, f, g);
142490 **
142491 ** the statement:
142492 **
142493 ** SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM t1 ORDER BY e;
142494 **
142495 ** is transformed to:
142496 **
142497 ** SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM (
142498 ** SELECT a, e, c, d, b FROM t1 ORDER BY c, d
142499 ** ) ORDER BY e;
142500 **
142501 ** The flattening optimization is disabled when processing this transformed
142502 ** SELECT statement. This allows the implementation of the window function
142503 ** (in this case max()) to process rows sorted in order of (c, d), which
142504 ** makes things easier for obvious reasons. More generally:
142505 **
142506 ** * FROM, WHERE, GROUP BY and HAVING clauses are all moved to
142507 ** the sub-query.
142508 **
142509 ** * ORDER BY, LIMIT and OFFSET remain part of the parent query.
142510 **
142511 ** * Terminals from each of the expression trees that make up the
142512 ** select-list and ORDER BY expressions in the parent query are
142513 ** selected by the sub-query. For the purposes of the transformation,
142514 ** terminals are column references and aggregate functions.
142515 **
142516 ** If there is more than one window function in the SELECT that uses
142517 ** the same window declaration (the OVER bit), then a single scan may
142518 ** be used to process more than one window function. For example:
142519 **
142520 ** SELECT max(b) OVER (PARTITION BY c ORDER BY d),
142521 ** min(e) OVER (PARTITION BY c ORDER BY d)
142522 ** FROM t1;
142523 **
142524 ** is transformed in the same way as the example above. However:
142525 **
142526 ** SELECT max(b) OVER (PARTITION BY c ORDER BY d),
142527 ** min(e) OVER (PARTITION BY a ORDER BY b)
142528 ** FROM t1;
142529 **
142530 ** Must be transformed to:
142531 **
142532 ** SELECT max(b) OVER (PARTITION BY c ORDER BY d) FROM (
142533 ** SELECT e, min(e) OVER (PARTITION BY a ORDER BY b), c, d, b FROM
142534 ** SELECT a, e, c, d, b FROM t1 ORDER BY a, b
142535 ** ) ORDER BY c, d
142536 ** ) ORDER BY e;
142537 **
142538 ** so that both min() and max() may process rows in the order defined by
142539 ** their respective window declarations.
142540 **
142541 ** INTERFACE WITH SELECT.C
142542 **
142543 ** When processing the rewritten SELECT statement, code in select.c calls
142544 ** sqlite3WhereBegin() to begin iterating through the results of the
142545 ** sub-query, which is always implemented as a co-routine. It then calls
142546 ** sqlite3WindowCodeStep() to process rows and finish the scan by calling
142547 ** sqlite3WhereEnd().
142548 **
142549 ** sqlite3WindowCodeStep() generates VM code so that, for each row returned
142550 ** by the sub-query a sub-routine (OP_Gosub) coded by select.c is invoked.
142551 ** When the sub-routine is invoked:
142552 **
142553 ** * The results of all window-functions for the row are stored
142554 ** in the associated Window.regResult registers.
142555 **
142556 ** * The required terminal values are stored in the current row of
142557 ** temp table Window.iEphCsr.
142558 **
142559 ** In some cases, depending on the window frame and the specific window
142560 ** functions invoked, sqlite3WindowCodeStep() caches each entire partition
142561 ** in a temp table before returning any rows. In other cases it does not.
142562 ** This detail is encapsulated within this file, the code generated by
142563 ** select.c is the same in either case.
142564 **
142565 ** BUILT-IN WINDOW FUNCTIONS
142566 **
142567 ** This implementation features the following built-in window functions:
142568 **
142569 ** row_number()
142570 ** rank()
142571 ** dense_rank()
142572 ** percent_rank()
142573 ** cume_dist()
142574 ** ntile(N)
142575 ** lead(expr [, offset [, default]])
142576 ** lag(expr [, offset [, default]])
142577 ** first_value(expr)
142578 ** last_value(expr)
142579 ** nth_value(expr, N)
142580 **
142581 ** These are the same built-in window functions supported by Postgres.
142582 ** Although the behaviour of aggregate window functions (functions that
142583 ** can be used as either aggregates or window funtions) allows them to
142584 ** be implemented using an API, built-in window functions are much more
142585 ** esoteric. Additionally, some window functions (e.g. nth_value())
142586 ** may only be implemented by caching the entire partition in memory.
142587 ** As such, some built-in window functions use the same API as aggregate
142588 ** window functions and some are implemented directly using VDBE
142589 ** instructions. Additionally, for those functions that use the API, the
142590 ** window frame is sometimes modified before the SELECT statement is
142591 ** rewritten. For example, regardless of the specified window frame, the
142592 ** row_number() function always uses:
142593 **
142594 ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142595 **
142596 ** See sqlite3WindowUpdate() for details.
142597 **
142598 ** As well as some of the built-in window functions, aggregate window
142599 ** functions min() and max() are implemented using VDBE instructions if
142600 ** the start of the window frame is declared as anything other than
142601 ** UNBOUNDED PRECEDING.
142602 */
142603
142604 /*
142605 ** Implementation of built-in window function row_number(). Assumes that the
142606 ** window frame has been coerced to:
142607 **
142608 ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142609 */
142610 static void row_numberStepFunc(
142611 sqlite3_context *pCtx,
142612 int nArg,
142613 sqlite3_value **apArg
142614 ){
142615 i64 *p = (i64*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142616 if( p ) (*p)++;
142617 UNUSED_PARAMETER(nArg);
142618 UNUSED_PARAMETER(apArg);
142619 }
142620 static void row_numberValueFunc(sqlite3_context *pCtx){
142621 i64 *p = (i64*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142622 sqlite3_result_int64(pCtx, (p ? *p : 0));
142623 }
142624
142625 /*
142626 ** Context object type used by rank(), dense_rank(), percent_rank() and
142627 ** cume_dist().
142628 */
142629 struct CallCount {
142630 i64 nValue;
142631 i64 nStep;
142632 i64 nTotal;
142633 };
142634
142635 /*
142636 ** Implementation of built-in window function dense_rank(). Assumes that
142637 ** the window frame has been set to:
142638 **
142639 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142640 */
142641 static void dense_rankStepFunc(
142642 sqlite3_context *pCtx,
142643 int nArg,
142644 sqlite3_value **apArg
142645 ){
142646 struct CallCount *p;
142647 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142648 if( p ) p->nStep = 1;
142649 UNUSED_PARAMETER(nArg);
142650 UNUSED_PARAMETER(apArg);
142651 }
142652 static void dense_rankValueFunc(sqlite3_context *pCtx){
142653 struct CallCount *p;
142654 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142655 if( p ){
142656 if( p->nStep ){
142657 p->nValue++;
142658 p->nStep = 0;
142659 }
142660 sqlite3_result_int64(pCtx, p->nValue);
142661 }
142662 }
142663
142664 /*
142665 ** Implementation of built-in window function rank(). Assumes that
142666 ** the window frame has been set to:
142667 **
142668 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142669 */
142670 static void rankStepFunc(
142671 sqlite3_context *pCtx,
142672 int nArg,
142673 sqlite3_value **apArg
142674 ){
142675 struct CallCount *p;
142676 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142677 if( p ){
142678 p->nStep++;
142679 if( p->nValue==0 ){
142680 p->nValue = p->nStep;
142681 }
142682 }
142683 UNUSED_PARAMETER(nArg);
142684 UNUSED_PARAMETER(apArg);
142685 }
142686 static void rankValueFunc(sqlite3_context *pCtx){
142687 struct CallCount *p;
142688 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142689 if( p ){
142690 sqlite3_result_int64(pCtx, p->nValue);
142691 p->nValue = 0;
142692 }
142693 }
142694
142695 /*
142696 ** Implementation of built-in window function percent_rank(). Assumes that
142697 ** the window frame has been set to:
142698 **
142699 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142700 */
142701 static void percent_rankStepFunc(
142702 sqlite3_context *pCtx,
142703 int nArg,
142704 sqlite3_value **apArg
142705 ){
142706 struct CallCount *p;
142707 UNUSED_PARAMETER(nArg); assert( nArg==1 );
142708
142709 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142710 if( p ){
142711 if( p->nTotal==0 ){
142712 p->nTotal = sqlite3_value_int64(apArg[0]);
142713 }
142714 p->nStep++;
142715 if( p->nValue==0 ){
142716 p->nValue = p->nStep;
142717 }
142718 }
142719 }
142720 static void percent_rankValueFunc(sqlite3_context *pCtx){
142721 struct CallCount *p;
142722 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142723 if( p ){
142724 if( p->nTotal>1 ){
142725 double r = (double)(p->nValue-1) / (double)(p->nTotal-1);
142726 sqlite3_result_double(pCtx, r);
142727 }else{
142728 sqlite3_result_double(pCtx, 0.0);
142729 }
142730 p->nValue = 0;
142731 }
142732 }
142733
142734 /*
142735 ** Implementation of built-in window function cume_dist(). Assumes that
142736 ** the window frame has been set to:
142737 **
142738 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
142739 */
142740 static void cume_distStepFunc(
142741 sqlite3_context *pCtx,
142742 int nArg,
142743 sqlite3_value **apArg
142744 ){
142745 struct CallCount *p;
142746 assert( nArg==1 ); UNUSED_PARAMETER(nArg);
142747
142748 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142749 if( p ){
142750 if( p->nTotal==0 ){
142751 p->nTotal = sqlite3_value_int64(apArg[0]);
142752 }
142753 p->nStep++;
142754 }
142755 }
142756 static void cume_distValueFunc(sqlite3_context *pCtx){
142757 struct CallCount *p;
142758 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142759 if( p && p->nTotal ){
142760 double r = (double)(p->nStep) / (double)(p->nTotal);
142761 sqlite3_result_double(pCtx, r);
142762 }
142763 }
142764
142765 /*
142766 ** Context object for ntile() window function.
142767 */
142768 struct NtileCtx {
142769 i64 nTotal; /* Total rows in partition */
142770 i64 nParam; /* Parameter passed to ntile(N) */
142771 i64 iRow; /* Current row */
142772 };
142773
142774 /*
142775 ** Implementation of ntile(). This assumes that the window frame has
142776 ** been coerced to:
142777 **
142778 ** ROWS UNBOUNDED PRECEDING AND CURRENT ROW
142779 */
142780 static void ntileStepFunc(
142781 sqlite3_context *pCtx,
142782 int nArg,
142783 sqlite3_value **apArg
142784 ){
142785 struct NtileCtx *p;
142786 assert( nArg==2 ); UNUSED_PARAMETER(nArg);
142787 p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142788 if( p ){
142789 if( p->nTotal==0 ){
142790 p->nParam = sqlite3_value_int64(apArg[0]);
142791 p->nTotal = sqlite3_value_int64(apArg[1]);
142792 if( p->nParam<=0 ){
142793 sqlite3_result_error(
142794 pCtx, "argument of ntile must be a positive integer", -1
142795 );
142796 }
142797 }
142798 p->iRow++;
142799 }
142800 }
142801 static void ntileValueFunc(sqlite3_context *pCtx){
142802 struct NtileCtx *p;
142803 p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142804 if( p && p->nParam>0 ){
142805 int nSize = (p->nTotal / p->nParam);
142806 if( nSize==0 ){
142807 sqlite3_result_int64(pCtx, p->iRow);
142808 }else{
142809 i64 nLarge = p->nTotal - p->nParam*nSize;
142810 i64 iSmall = nLarge*(nSize+1);
142811 i64 iRow = p->iRow-1;
142812
142813 assert( (nLarge*(nSize+1) + (p->nParam-nLarge)*nSize)==p->nTotal );
142814
142815 if( iRow<iSmall ){
142816 sqlite3_result_int64(pCtx, 1 + iRow/(nSize+1));
142817 }else{
142818 sqlite3_result_int64(pCtx, 1 + nLarge + (iRow-iSmall)/nSize);
142819 }
142820 }
142821 }
142822 }
142823
142824 /*
142825 ** Context object for last_value() window function.
142826 */
142827 struct LastValueCtx {
142828 sqlite3_value *pVal;
142829 int nVal;
142830 };
142831
142832 /*
142833 ** Implementation of last_value().
142834 */
142835 static void last_valueStepFunc(
142836 sqlite3_context *pCtx,
142837 int nArg,
142838 sqlite3_value **apArg
142839 ){
142840 struct LastValueCtx *p;
142841 UNUSED_PARAMETER(nArg);
142842 p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142843 if( p ){
142844 sqlite3_value_free(p->pVal);
142845 p->pVal = sqlite3_value_dup(apArg[0]);
142846 if( p->pVal==0 ){
142847 sqlite3_result_error_nomem(pCtx);
142848 }else{
142849 p->nVal++;
142850 }
142851 }
142852 }
142853 static void last_valueInvFunc(
142854 sqlite3_context *pCtx,
142855 int nArg,
142856 sqlite3_value **apArg
142857 ){
142858 struct LastValueCtx *p;
142859 UNUSED_PARAMETER(nArg);
142860 UNUSED_PARAMETER(apArg);
142861 p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142862 if( ALWAYS(p) ){
142863 p->nVal--;
142864 if( p->nVal==0 ){
142865 sqlite3_value_free(p->pVal);
142866 p->pVal = 0;
142867 }
142868 }
142869 }
142870 static void last_valueValueFunc(sqlite3_context *pCtx){
142871 struct LastValueCtx *p;
142872 p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142873 if( p && p->pVal ){
142874 sqlite3_result_value(pCtx, p->pVal);
142875 }
142876 }
142877 static void last_valueFinalizeFunc(sqlite3_context *pCtx){
142878 struct LastValueCtx *p;
142879 p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
142880 if( p && p->pVal ){
142881 sqlite3_result_value(pCtx, p->pVal);
142882 sqlite3_value_free(p->pVal);
142883 p->pVal = 0;
142884 }
142885 }
142886
142887 /*
142888 ** Static names for the built-in window function names. These static
142889 ** names are used, rather than string literals, so that FuncDef objects
142890 ** can be associated with a particular window function by direct
142891 ** comparison of the zName pointer. Example:
142892 **
142893 ** if( pFuncDef->zName==row_valueName ){ ... }
142894 */
142895 static const char row_numberName[] = "row_number";
142896 static const char dense_rankName[] = "dense_rank";
142897 static const char rankName[] = "rank";
142898 static const char percent_rankName[] = "percent_rank";
142899 static const char cume_distName[] = "cume_dist";
142900 static const char ntileName[] = "ntile";
142901 static const char last_valueName[] = "last_value";
142902 static const char nth_valueName[] = "nth_value";
142903 static const char first_valueName[] = "first_value";
142904 static const char leadName[] = "lead";
142905 static const char lagName[] = "lag";
142906
142907 /*
142908 ** No-op implementations of xStep() and xFinalize(). Used as place-holders
142909 ** for built-in window functions that never call those interfaces.
142910 **
142911 ** The noopValueFunc() is called but is expected to do nothing. The
142912 ** noopStepFunc() is never called, and so it is marked with NO_TEST to
142913 ** let the test coverage routine know not to expect this function to be
142914 ** invoked.
142915 */
142916 static void noopStepFunc( /*NO_TEST*/
142917 sqlite3_context *p, /*NO_TEST*/
142918 int n, /*NO_TEST*/
142919 sqlite3_value **a /*NO_TEST*/
142920 ){ /*NO_TEST*/
142921 UNUSED_PARAMETER(p); /*NO_TEST*/
142922 UNUSED_PARAMETER(n); /*NO_TEST*/
142923 UNUSED_PARAMETER(a); /*NO_TEST*/
142924 assert(0); /*NO_TEST*/
142925 } /*NO_TEST*/
142926 static void noopValueFunc(sqlite3_context *p){ UNUSED_PARAMETER(p); /*no-op*/ }
142927
142928 /* Window functions that use all window interfaces: xStep, xFinal,
142929 ** xValue, and xInverse */
142930 #define WINDOWFUNCALL(name,nArg,extra) { \
142931 nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \
142932 name ## StepFunc, name ## FinalizeFunc, name ## ValueFunc, \
142933 name ## InvFunc, name ## Name, {0} \
142934 }
142935
142936 /* Window functions that are implemented using bytecode and thus have
142937 ** no-op routines for their methods */
142938 #define WINDOWFUNCNOOP(name,nArg,extra) { \
142939 nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \
142940 noopStepFunc, noopValueFunc, noopValueFunc, \
142941 noopStepFunc, name ## Name, {0} \
142942 }
142943
142944 /* Window functions that use all window interfaces: xStep, the
142945 ** same routine for xFinalize and xValue and which never call
142946 ** xInverse. */
142947 #define WINDOWFUNCX(name,nArg,extra) { \
142948 nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \
142949 name ## StepFunc, name ## ValueFunc, name ## ValueFunc, \
142950 noopStepFunc, name ## Name, {0} \
142951 }
142952
142953
142954 /*
142955 ** Register those built-in window functions that are not also aggregates.
142956 */
142957 SQLITE_PRIVATE void sqlite3WindowFunctions(void){
142958 static FuncDef aWindowFuncs[] = {
142959 WINDOWFUNCX(row_number, 0, 0),
142960 WINDOWFUNCX(dense_rank, 0, 0),
142961 WINDOWFUNCX(rank, 0, 0),
142962 WINDOWFUNCX(percent_rank, 0, SQLITE_FUNC_WINDOW_SIZE),
142963 WINDOWFUNCX(cume_dist, 0, SQLITE_FUNC_WINDOW_SIZE),
142964 WINDOWFUNCX(ntile, 1, SQLITE_FUNC_WINDOW_SIZE),
142965 WINDOWFUNCALL(last_value, 1, 0),
142966 WINDOWFUNCNOOP(nth_value, 2, 0),
142967 WINDOWFUNCNOOP(first_value, 1, 0),
142968 WINDOWFUNCNOOP(lead, 1, 0),
142969 WINDOWFUNCNOOP(lead, 2, 0),
142970 WINDOWFUNCNOOP(lead, 3, 0),
142971 WINDOWFUNCNOOP(lag, 1, 0),
142972 WINDOWFUNCNOOP(lag, 2, 0),
142973 WINDOWFUNCNOOP(lag, 3, 0),
142974 };
142975 sqlite3InsertBuiltinFuncs(aWindowFuncs, ArraySize(aWindowFuncs));
142976 }
142977
142978 /*
142979 ** This function is called immediately after resolving the function name
142980 ** for a window function within a SELECT statement. Argument pList is a
142981 ** linked list of WINDOW definitions for the current SELECT statement.
142982 ** Argument pFunc is the function definition just resolved and pWin
142983 ** is the Window object representing the associated OVER clause. This
142984 ** function updates the contents of pWin as follows:
142985 **
142986 ** * If the OVER clause refered to a named window (as in "max(x) OVER win"),
142987 ** search list pList for a matching WINDOW definition, and update pWin
142988 ** accordingly. If no such WINDOW clause can be found, leave an error
142989 ** in pParse.
142990 **
142991 ** * If the function is a built-in window function that requires the
142992 ** window to be coerced (see "BUILT-IN WINDOW FUNCTIONS" at the top
142993 ** of this file), pWin is updated here.
142994 */
142995 SQLITE_PRIVATE void sqlite3WindowUpdate(
142996 Parse *pParse,
142997 Window *pList, /* List of named windows for this SELECT */
142998 Window *pWin, /* Window frame to update */
142999 FuncDef *pFunc /* Window function definition */
143000 ){
143001 if( pWin->zName && pWin->eType==0 ){
143002 Window *p;
143003 for(p=pList; p; p=p->pNextWin){
143004 if( sqlite3StrICmp(p->zName, pWin->zName)==0 ) break;
143005 }
143006 if( p==0 ){
143007 sqlite3ErrorMsg(pParse, "no such window: %s", pWin->zName);
143008 return;
143009 }
143010 pWin->pPartition = sqlite3ExprListDup(pParse->db, p->pPartition, 0);
143011 pWin->pOrderBy = sqlite3ExprListDup(pParse->db, p->pOrderBy, 0);
143012 pWin->pStart = sqlite3ExprDup(pParse->db, p->pStart, 0);
143013 pWin->pEnd = sqlite3ExprDup(pParse->db, p->pEnd, 0);
143014 pWin->eStart = p->eStart;
143015 pWin->eEnd = p->eEnd;
143016 pWin->eType = p->eType;
143017 }
143018 if( pFunc->funcFlags & SQLITE_FUNC_WINDOW ){
143019 sqlite3 *db = pParse->db;
143020 if( pWin->pFilter ){
143021 sqlite3ErrorMsg(pParse,
143022 "FILTER clause may only be used with aggregate window functions"
143023 );
143024 }else
143025 if( pFunc->zName==row_numberName || pFunc->zName==ntileName ){
143026 sqlite3ExprDelete(db, pWin->pStart);
143027 sqlite3ExprDelete(db, pWin->pEnd);
143028 pWin->pStart = pWin->pEnd = 0;
143029 pWin->eType = TK_ROWS;
143030 pWin->eStart = TK_UNBOUNDED;
143031 pWin->eEnd = TK_CURRENT;
143032 }else
143033
143034 if( pFunc->zName==dense_rankName || pFunc->zName==rankName
143035 || pFunc->zName==percent_rankName || pFunc->zName==cume_distName
143036 ){
143037 sqlite3ExprDelete(db, pWin->pStart);
143038 sqlite3ExprDelete(db, pWin->pEnd);
143039 pWin->pStart = pWin->pEnd = 0;
143040 pWin->eType = TK_RANGE;
143041 pWin->eStart = TK_UNBOUNDED;
143042 pWin->eEnd = TK_CURRENT;
143043 }
143044 }
143045 pWin->pFunc = pFunc;
143046 }
143047
143048 /*
143049 ** Context object passed through sqlite3WalkExprList() to
143050 ** selectWindowRewriteExprCb() by selectWindowRewriteEList().
143051 */
143052 typedef struct WindowRewrite WindowRewrite;
143053 struct WindowRewrite {
143054 Window *pWin;
143055 SrcList *pSrc;
143056 ExprList *pSub;
143057 Select *pSubSelect; /* Current sub-select, if any */
143058 };
143059
143060 /*
143061 ** Callback function used by selectWindowRewriteEList(). If necessary,
143062 ** this function appends to the output expression-list and updates
143063 ** expression (*ppExpr) in place.
143064 */
143065 static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){
143066 struct WindowRewrite *p = pWalker->u.pRewrite;
143067 Parse *pParse = pWalker->pParse;
143068
143069 /* If this function is being called from within a scalar sub-select
143070 ** that used by the SELECT statement being processed, only process
143071 ** TK_COLUMN expressions that refer to it (the outer SELECT). Do
143072 ** not process aggregates or window functions at all, as they belong
143073 ** to the scalar sub-select. */
143074 if( p->pSubSelect ){
143075 if( pExpr->op!=TK_COLUMN ){
143076 return WRC_Continue;
143077 }else{
143078 int nSrc = p->pSrc->nSrc;
143079 int i;
143080 for(i=0; i<nSrc; i++){
143081 if( pExpr->iTable==p->pSrc->a[i].iCursor ) break;
143082 }
143083 if( i==nSrc ) return WRC_Continue;
143084 }
143085 }
143086
143087 switch( pExpr->op ){
143088
143089 case TK_FUNCTION:
143090 if( pExpr->pWin==0 ){
143091 break;
143092 }else{
143093 Window *pWin;
143094 for(pWin=p->pWin; pWin; pWin=pWin->pNextWin){
143095 if( pExpr->pWin==pWin ){
143096 assert( pWin->pOwner==pExpr );
143097 return WRC_Prune;
143098 }
143099 }
143100 }
143101 /* Fall through. */
143102
143103 case TK_AGG_FUNCTION:
143104 case TK_COLUMN: {
143105 Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0);
143106 p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup);
143107 if( p->pSub ){
143108 assert( ExprHasProperty(pExpr, EP_Static)==0 );
143109 ExprSetProperty(pExpr, EP_Static);
143110 sqlite3ExprDelete(pParse->db, pExpr);
143111 ExprClearProperty(pExpr, EP_Static);
143112 memset(pExpr, 0, sizeof(Expr));
143113
143114 pExpr->op = TK_COLUMN;
143115 pExpr->iColumn = p->pSub->nExpr-1;
143116 pExpr->iTable = p->pWin->iEphCsr;
143117 }
143118
143119 break;
143120 }
143121
143122 default: /* no-op */
143123 break;
143124 }
143125
143126 return WRC_Continue;
143127 }
143128 static int selectWindowRewriteSelectCb(Walker *pWalker, Select *pSelect){
143129 struct WindowRewrite *p = pWalker->u.pRewrite;
143130 Select *pSave = p->pSubSelect;
143131 if( pSave==pSelect ){
143132 return WRC_Continue;
143133 }else{
143134 p->pSubSelect = pSelect;
143135 sqlite3WalkSelect(pWalker, pSelect);
143136 p->pSubSelect = pSave;
143137 }
143138 return WRC_Prune;
143139 }
143140
143141
143142 /*
143143 ** Iterate through each expression in expression-list pEList. For each:
143144 **
143145 ** * TK_COLUMN,
143146 ** * aggregate function, or
143147 ** * window function with a Window object that is not a member of the
143148 ** Window list passed as the second argument (pWin).
143149 **
143150 ** Append the node to output expression-list (*ppSub). And replace it
143151 ** with a TK_COLUMN that reads the (N-1)th element of table
143152 ** pWin->iEphCsr, where N is the number of elements in (*ppSub) after
143153 ** appending the new one.
143154 */
143155 static void selectWindowRewriteEList(
143156 Parse *pParse,
143157 Window *pWin,
143158 SrcList *pSrc,
143159 ExprList *pEList, /* Rewrite expressions in this list */
143160 ExprList **ppSub /* IN/OUT: Sub-select expression-list */
143161 ){
143162 Walker sWalker;
143163 WindowRewrite sRewrite;
143164
143165 memset(&sWalker, 0, sizeof(Walker));
143166 memset(&sRewrite, 0, sizeof(WindowRewrite));
143167
143168 sRewrite.pSub = *ppSub;
143169 sRewrite.pWin = pWin;
143170 sRewrite.pSrc = pSrc;
143171
143172 sWalker.pParse = pParse;
143173 sWalker.xExprCallback = selectWindowRewriteExprCb;
143174 sWalker.xSelectCallback = selectWindowRewriteSelectCb;
143175 sWalker.u.pRewrite = &sRewrite;
143176
143177 (void)sqlite3WalkExprList(&sWalker, pEList);
143178
143179 *ppSub = sRewrite.pSub;
143180 }
143181
143182 /*
143183 ** Append a copy of each expression in expression-list pAppend to
143184 ** expression list pList. Return a pointer to the result list.
143185 */
143186 static ExprList *exprListAppendList(
143187 Parse *pParse, /* Parsing context */
143188 ExprList *pList, /* List to which to append. Might be NULL */
143189 ExprList *pAppend /* List of values to append. Might be NULL */
143190 ){
143191 if( pAppend ){
143192 int i;
143193 int nInit = pList ? pList->nExpr : 0;
143194 for(i=0; i<pAppend->nExpr; i++){
143195 Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);
143196 pList = sqlite3ExprListAppend(pParse, pList, pDup);
143197 if( pList ) pList->a[nInit+i].sortOrder = pAppend->a[i].sortOrder;
143198 }
143199 }
143200 return pList;
143201 }
143202
143203 /*
143204 ** If the SELECT statement passed as the second argument does not invoke
143205 ** any SQL window functions, this function is a no-op. Otherwise, it
143206 ** rewrites the SELECT statement so that window function xStep functions
143207 ** are invoked in the correct order as described under "SELECT REWRITING"
143208 ** at the top of this file.
143209 */
143210 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
143211 int rc = SQLITE_OK;
143212 if( p->pWin ){
143213 Vdbe *v = sqlite3GetVdbe(pParse);
143214 sqlite3 *db = pParse->db;
143215 Select *pSub = 0; /* The subquery */
143216 SrcList *pSrc = p->pSrc;
143217 Expr *pWhere = p->pWhere;
143218 ExprList *pGroupBy = p->pGroupBy;
143219 Expr *pHaving = p->pHaving;
143220 ExprList *pSort = 0;
143221
143222 ExprList *pSublist = 0; /* Expression list for sub-query */
143223 Window *pMWin = p->pWin; /* Master window object */
143224 Window *pWin; /* Window object iterator */
143225
143226 p->pSrc = 0;
143227 p->pWhere = 0;
143228 p->pGroupBy = 0;
143229 p->pHaving = 0;
143230
143231 /* Create the ORDER BY clause for the sub-select. This is the concatenation
143232 ** of the window PARTITION and ORDER BY clauses. Then, if this makes it
143233 ** redundant, remove the ORDER BY from the parent SELECT. */
143234 pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);
143235 pSort = exprListAppendList(pParse, pSort, pMWin->pOrderBy);
143236 if( pSort && p->pOrderBy ){
143237 if( sqlite3ExprListCompare(pSort, p->pOrderBy, -1)==0 ){
143238 sqlite3ExprListDelete(db, p->pOrderBy);
143239 p->pOrderBy = 0;
143240 }
143241 }
143242
143243 /* Assign a cursor number for the ephemeral table used to buffer rows.
143244 ** The OpenEphemeral instruction is coded later, after it is known how
143245 ** many columns the table will have. */
143246 pMWin->iEphCsr = pParse->nTab++;
143247
143248 selectWindowRewriteEList(pParse, pMWin, pSrc, p->pEList, &pSublist);
143249 selectWindowRewriteEList(pParse, pMWin, pSrc, p->pOrderBy, &pSublist);
143250 pMWin->nBufferCol = (pSublist ? pSublist->nExpr : 0);
143251
143252 /* Append the PARTITION BY and ORDER BY expressions to the to the
143253 ** sub-select expression list. They are required to figure out where
143254 ** boundaries for partitions and sets of peer rows lie. */
143255 pSublist = exprListAppendList(pParse, pSublist, pMWin->pPartition);
143256 pSublist = exprListAppendList(pParse, pSublist, pMWin->pOrderBy);
143257
143258 /* Append the arguments passed to each window function to the
143259 ** sub-select expression list. Also allocate two registers for each
143260 ** window function - one for the accumulator, another for interim
143261 ** results. */
143262 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143263 pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);
143264 pSublist = exprListAppendList(pParse, pSublist, pWin->pOwner->x.pList);
143265 if( pWin->pFilter ){
143266 Expr *pFilter = sqlite3ExprDup(db, pWin->pFilter, 0);
143267 pSublist = sqlite3ExprListAppend(pParse, pSublist, pFilter);
143268 }
143269 pWin->regAccum = ++pParse->nMem;
143270 pWin->regResult = ++pParse->nMem;
143271 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
143272 }
143273
143274 /* If there is no ORDER BY or PARTITION BY clause, and the window
143275 ** function accepts zero arguments, and there are no other columns
143276 ** selected (e.g. "SELECT row_number() OVER () FROM t1"), it is possible
143277 ** that pSublist is still NULL here. Add a constant expression here to
143278 ** keep everything legal in this case.
143279 */
143280 if( pSublist==0 ){
143281 pSublist = sqlite3ExprListAppend(pParse, 0,
143282 sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0)
143283 );
143284 }
143285
143286 pSub = sqlite3SelectNew(
143287 pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0
143288 );
143289 p->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
143290 assert( p->pSrc || db->mallocFailed );
143291 if( p->pSrc ){
143292 p->pSrc->a[0].pSelect = pSub;
143293 sqlite3SrcListAssignCursors(pParse, p->pSrc);
143294 if( sqlite3ExpandSubquery(pParse, &p->pSrc->a[0]) ){
143295 rc = SQLITE_NOMEM;
143296 }else{
143297 pSub->selFlags |= SF_Expanded;
143298 p->selFlags &= ~SF_Aggregate;
143299 sqlite3SelectPrep(pParse, pSub, 0);
143300 }
143301
143302 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, pSublist->nExpr);
143303 }else{
143304 sqlite3SelectDelete(db, pSub);
143305 }
143306 if( db->mallocFailed ) rc = SQLITE_NOMEM;
143307 }
143308
143309 return rc;
143310 }
143311
143312 /*
143313 ** Free the Window object passed as the second argument.
143314 */
143315 SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3 *db, Window *p){
143316 if( p ){
143317 sqlite3ExprDelete(db, p->pFilter);
143318 sqlite3ExprListDelete(db, p->pPartition);
143319 sqlite3ExprListDelete(db, p->pOrderBy);
143320 sqlite3ExprDelete(db, p->pEnd);
143321 sqlite3ExprDelete(db, p->pStart);
143322 sqlite3DbFree(db, p->zName);
143323 sqlite3DbFree(db, p);
143324 }
143325 }
143326
143327 /*
143328 ** Free the linked list of Window objects starting at the second argument.
143329 */
143330 SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p){
143331 while( p ){
143332 Window *pNext = p->pNextWin;
143333 sqlite3WindowDelete(db, p);
143334 p = pNext;
143335 }
143336 }
143337
143338 /*
143339 ** The argument expression is an PRECEDING or FOLLOWING offset. The
143340 ** value should be a non-negative integer. If the value is not a
143341 ** constant, change it to NULL. The fact that it is then a non-negative
143342 ** integer will be caught later. But it is important not to leave
143343 ** variable values in the expression tree.
143344 */
143345 static Expr *sqlite3WindowOffsetExpr(Parse *pParse, Expr *pExpr){
143346 if( 0==sqlite3ExprIsConstant(pExpr) ){
143347 sqlite3ExprDelete(pParse->db, pExpr);
143348 pExpr = sqlite3ExprAlloc(pParse->db, TK_NULL, 0, 0);
143349 }
143350 return pExpr;
143351 }
143352
143353 /*
143354 ** Allocate and return a new Window object describing a Window Definition.
143355 */
143356 SQLITE_PRIVATE Window *sqlite3WindowAlloc(
143357 Parse *pParse, /* Parsing context */
143358 int eType, /* Frame type. TK_RANGE or TK_ROWS */
143359 int eStart, /* Start type: CURRENT, PRECEDING, FOLLOWING, UNBOUNDED */
143360 Expr *pStart, /* Start window size if TK_PRECEDING or FOLLOWING */
143361 int eEnd, /* End type: CURRENT, FOLLOWING, TK_UNBOUNDED, PRECEDING */
143362 Expr *pEnd /* End window size if TK_FOLLOWING or PRECEDING */
143363 ){
143364 Window *pWin = 0;
143365
143366 /* Parser assures the following: */
143367 assert( eType==TK_RANGE || eType==TK_ROWS );
143368 assert( eStart==TK_CURRENT || eStart==TK_PRECEDING
143369 || eStart==TK_UNBOUNDED || eStart==TK_FOLLOWING );
143370 assert( eEnd==TK_CURRENT || eEnd==TK_FOLLOWING
143371 || eEnd==TK_UNBOUNDED || eEnd==TK_PRECEDING );
143372 assert( (eStart==TK_PRECEDING || eStart==TK_FOLLOWING)==(pStart!=0) );
143373 assert( (eEnd==TK_FOLLOWING || eEnd==TK_PRECEDING)==(pEnd!=0) );
143374
143375
143376 /* If a frame is declared "RANGE" (not "ROWS"), then it may not use
143377 ** either "<expr> PRECEDING" or "<expr> FOLLOWING".
143378 */
143379 if( eType==TK_RANGE && (pStart!=0 || pEnd!=0) ){
143380 sqlite3ErrorMsg(pParse, "RANGE must use only UNBOUNDED or CURRENT ROW");
143381 goto windowAllocErr;
143382 }
143383
143384 /* Additionally, the
143385 ** starting boundary type may not occur earlier in the following list than
143386 ** the ending boundary type:
143387 **
143388 ** UNBOUNDED PRECEDING
143389 ** <expr> PRECEDING
143390 ** CURRENT ROW
143391 ** <expr> FOLLOWING
143392 ** UNBOUNDED FOLLOWING
143393 **
143394 ** The parser ensures that "UNBOUNDED PRECEDING" cannot be used as an ending
143395 ** boundary, and than "UNBOUNDED FOLLOWING" cannot be used as a starting
143396 ** frame boundary.
143397 */
143398 if( (eStart==TK_CURRENT && eEnd==TK_PRECEDING)
143399 || (eStart==TK_FOLLOWING && (eEnd==TK_PRECEDING || eEnd==TK_CURRENT))
143400 ){
143401 sqlite3ErrorMsg(pParse, "unsupported frame delimiter for ROWS");
143402 goto windowAllocErr;
143403 }
143404
143405 pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
143406 if( pWin==0 ) goto windowAllocErr;
143407 pWin->eType = eType;
143408 pWin->eStart = eStart;
143409 pWin->eEnd = eEnd;
143410 pWin->pEnd = sqlite3WindowOffsetExpr(pParse, pEnd);
143411 pWin->pStart = sqlite3WindowOffsetExpr(pParse, pStart);
143412 return pWin;
143413
143414 windowAllocErr:
143415 sqlite3ExprDelete(pParse->db, pEnd);
143416 sqlite3ExprDelete(pParse->db, pStart);
143417 return 0;
143418 }
143419
143420 /*
143421 ** Attach window object pWin to expression p.
143422 */
143423 SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
143424 if( p ){
143425 if( pWin ){
143426 p->pWin = pWin;
143427 pWin->pOwner = p;
143428 if( p->flags & EP_Distinct ){
143429 sqlite3ErrorMsg(pParse,
143430 "DISTINCT is not supported for window functions");
143431 }
143432 }
143433 }else{
143434 sqlite3WindowDelete(pParse->db, pWin);
143435 }
143436 }
143437
143438 /*
143439 ** Return 0 if the two window objects are identical, or non-zero otherwise.
143440 ** Identical window objects can be processed in a single scan.
143441 */
143442 SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2){
143443 if( p1->eType!=p2->eType ) return 1;
143444 if( p1->eStart!=p2->eStart ) return 1;
143445 if( p1->eEnd!=p2->eEnd ) return 1;
143446 if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
143447 if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1;
143448 if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1;
143449 if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1;
143450 return 0;
143451 }
143452
143453
143454 /*
143455 ** This is called by code in select.c before it calls sqlite3WhereBegin()
143456 ** to begin iterating through the sub-query results. It is used to allocate
143457 ** and initialize registers and cursors used by sqlite3WindowCodeStep().
143458 */
143459 SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse *pParse, Window *pMWin){
143460 Window *pWin;
143461 Vdbe *v = sqlite3GetVdbe(pParse);
143462 int nPart = (pMWin->pPartition ? pMWin->pPartition->nExpr : 0);
143463 nPart += (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
143464 if( nPart ){
143465 pMWin->regPart = pParse->nMem+1;
143466 pParse->nMem += nPart;
143467 sqlite3VdbeAddOp3(v, OP_Null, 0, pMWin->regPart, pMWin->regPart+nPart-1);
143468 }
143469
143470 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143471 FuncDef *p = pWin->pFunc;
143472 if( (p->funcFlags & SQLITE_FUNC_MINMAX) && pWin->eStart!=TK_UNBOUNDED ){
143473 /* The inline versions of min() and max() require a single ephemeral
143474 ** table and 3 registers. The registers are used as follows:
143475 **
143476 ** regApp+0: slot to copy min()/max() argument to for MakeRecord
143477 ** regApp+1: integer value used to ensure keys are unique
143478 ** regApp+2: output of MakeRecord
143479 */
143480 ExprList *pList = pWin->pOwner->x.pList;
143481 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0);
143482 pWin->csrApp = pParse->nTab++;
143483 pWin->regApp = pParse->nMem+1;
143484 pParse->nMem += 3;
143485 if( pKeyInfo && pWin->pFunc->zName[1]=='i' ){
143486 assert( pKeyInfo->aSortOrder[0]==0 );
143487 pKeyInfo->aSortOrder[0] = 1;
143488 }
143489 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2);
143490 sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);
143491 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
143492 }
143493 else if( p->zName==nth_valueName || p->zName==first_valueName ){
143494 /* Allocate two registers at pWin->regApp. These will be used to
143495 ** store the start and end index of the current frame. */
143496 assert( pMWin->iEphCsr );
143497 pWin->regApp = pParse->nMem+1;
143498 pWin->csrApp = pParse->nTab++;
143499 pParse->nMem += 2;
143500 sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
143501 }
143502 else if( p->zName==leadName || p->zName==lagName ){
143503 assert( pMWin->iEphCsr );
143504 pWin->csrApp = pParse->nTab++;
143505 sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
143506 }
143507 }
143508 }
143509
143510 /*
143511 ** A "PRECEDING <expr>" (eCond==0) or "FOLLOWING <expr>" (eCond==1) or the
143512 ** value of the second argument to nth_value() (eCond==2) has just been
143513 ** evaluated and the result left in register reg. This function generates VM
143514 ** code to check that the value is a non-negative integer and throws an
143515 ** exception if it is not.
143516 */
143517 static void windowCheckIntValue(Parse *pParse, int reg, int eCond){
143518 static const char *azErr[] = {
143519 "frame starting offset must be a non-negative integer",
143520 "frame ending offset must be a non-negative integer",
143521 "second argument to nth_value must be a positive integer"
143522 };
143523 static int aOp[] = { OP_Ge, OP_Ge, OP_Gt };
143524 Vdbe *v = sqlite3GetVdbe(pParse);
143525 int regZero = sqlite3GetTempReg(pParse);
143526 assert( eCond==0 || eCond==1 || eCond==2 );
143527 sqlite3VdbeAddOp2(v, OP_Integer, 0, regZero);
143528 sqlite3VdbeAddOp2(v, OP_MustBeInt, reg, sqlite3VdbeCurrentAddr(v)+2);
143529 VdbeCoverageIf(v, eCond==0);
143530 VdbeCoverageIf(v, eCond==1);
143531 VdbeCoverageIf(v, eCond==2);
143532 sqlite3VdbeAddOp3(v, aOp[eCond], regZero, sqlite3VdbeCurrentAddr(v)+2, reg);
143533 VdbeCoverageNeverNullIf(v, eCond==0);
143534 VdbeCoverageNeverNullIf(v, eCond==1);
143535 VdbeCoverageNeverNullIf(v, eCond==2);
143536 sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_ERROR, OE_Abort);
143537 sqlite3VdbeAppendP4(v, (void*)azErr[eCond], P4_STATIC);
143538 sqlite3ReleaseTempReg(pParse, regZero);
143539 }
143540
143541 /*
143542 ** Return the number of arguments passed to the window-function associated
143543 ** with the object passed as the only argument to this function.
143544 */
143545 static int windowArgCount(Window *pWin){
143546 ExprList *pList = pWin->pOwner->x.pList;
143547 return (pList ? pList->nExpr : 0);
143548 }
143549
143550 /*
143551 ** Generate VM code to invoke either xStep() (if bInverse is 0) or
143552 ** xInverse (if bInverse is non-zero) for each window function in the
143553 ** linked list starting at pMWin. Or, for built-in window functions
143554 ** that do not use the standard function API, generate the required
143555 ** inline VM code.
143556 **
143557 ** If argument csr is greater than or equal to 0, then argument reg is
143558 ** the first register in an array of registers guaranteed to be large
143559 ** enough to hold the array of arguments for each function. In this case
143560 ** the arguments are extracted from the current row of csr into the
143561 ** array of registers before invoking OP_AggStep or OP_AggInverse
143562 **
143563 ** Or, if csr is less than zero, then the array of registers at reg is
143564 ** already populated with all columns from the current row of the sub-query.
143565 **
143566 ** If argument regPartSize is non-zero, then it is a register containing the
143567 ** number of rows in the current partition.
143568 */
143569 static void windowAggStep(
143570 Parse *pParse,
143571 Window *pMWin, /* Linked list of window functions */
143572 int csr, /* Read arguments from this cursor */
143573 int bInverse, /* True to invoke xInverse instead of xStep */
143574 int reg, /* Array of registers */
143575 int regPartSize /* Register containing size of partition */
143576 ){
143577 Vdbe *v = sqlite3GetVdbe(pParse);
143578 Window *pWin;
143579 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143580 int flags = pWin->pFunc->funcFlags;
143581 int regArg;
143582 int nArg = windowArgCount(pWin);
143583
143584 if( csr>=0 ){
143585 int i;
143586 for(i=0; i<nArg; i++){
143587 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
143588 }
143589 regArg = reg;
143590 if( flags & SQLITE_FUNC_WINDOW_SIZE ){
143591 if( nArg==0 ){
143592 regArg = regPartSize;
143593 }else{
143594 sqlite3VdbeAddOp2(v, OP_SCopy, regPartSize, reg+nArg);
143595 }
143596 nArg++;
143597 }
143598 }else{
143599 assert( !(flags & SQLITE_FUNC_WINDOW_SIZE) );
143600 regArg = reg + pWin->iArgCol;
143601 }
143602
143603 if( (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
143604 && pWin->eStart!=TK_UNBOUNDED
143605 ){
143606 int addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regArg);
143607 VdbeCoverage(v);
143608 if( bInverse==0 ){
143609 sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1, 1);
143610 sqlite3VdbeAddOp2(v, OP_SCopy, regArg, pWin->regApp);
143611 sqlite3VdbeAddOp3(v, OP_MakeRecord, pWin->regApp, 2, pWin->regApp+2);
143612 sqlite3VdbeAddOp2(v, OP_IdxInsert, pWin->csrApp, pWin->regApp+2);
143613 }else{
143614 sqlite3VdbeAddOp4Int(v, OP_SeekGE, pWin->csrApp, 0, regArg, 1);
143615 VdbeCoverageNeverTaken(v);
143616 sqlite3VdbeAddOp1(v, OP_Delete, pWin->csrApp);
143617 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
143618 }
143619 sqlite3VdbeJumpHere(v, addrIsNull);
143620 }else if( pWin->regApp ){
143621 assert( pWin->pFunc->zName==nth_valueName
143622 || pWin->pFunc->zName==first_valueName
143623 );
143624 assert( bInverse==0 || bInverse==1 );
143625 sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1);
143626 }else if( pWin->pFunc->zName==leadName
143627 || pWin->pFunc->zName==lagName
143628 ){
143629 /* no-op */
143630 }else{
143631 int addrIf = 0;
143632 if( pWin->pFilter ){
143633 int regTmp;
143634 assert( nArg==0 || nArg==pWin->pOwner->x.pList->nExpr );
143635 assert( nArg || pWin->pOwner->x.pList==0 );
143636 if( csr>0 ){
143637 regTmp = sqlite3GetTempReg(pParse);
143638 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp);
143639 }else{
143640 regTmp = regArg + nArg;
143641 }
143642 addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1);
143643 VdbeCoverage(v);
143644 if( csr>0 ){
143645 sqlite3ReleaseTempReg(pParse, regTmp);
143646 }
143647 }
143648 if( pWin->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
143649 CollSeq *pColl;
143650 assert( nArg>0 );
143651 pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr);
143652 sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
143653 }
143654 sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep,
143655 bInverse, regArg, pWin->regAccum);
143656 sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
143657 sqlite3VdbeChangeP5(v, (u8)nArg);
143658 if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
143659 }
143660 }
143661 }
143662
143663 /*
143664 ** Generate VM code to invoke either xValue() (bFinal==0) or xFinalize()
143665 ** (bFinal==1) for each window function in the linked list starting at
143666 ** pMWin. Or, for built-in window-functions that do not use the standard
143667 ** API, generate the equivalent VM code.
143668 */
143669 static void windowAggFinal(Parse *pParse, Window *pMWin, int bFinal){
143670 Vdbe *v = sqlite3GetVdbe(pParse);
143671 Window *pWin;
143672
143673 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143674 if( (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
143675 && pWin->eStart!=TK_UNBOUNDED
143676 ){
143677 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
143678 sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);
143679 VdbeCoverage(v);
143680 sqlite3VdbeAddOp3(v, OP_Column, pWin->csrApp, 0, pWin->regResult);
143681 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
143682 if( bFinal ){
143683 sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);
143684 }
143685 }else if( pWin->regApp ){
143686 }else{
143687 if( bFinal ){
143688 sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, windowArgCount(pWin));
143689 sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
143690 sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
143691 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
143692 }else{
143693 sqlite3VdbeAddOp3(v, OP_AggValue, pWin->regAccum, windowArgCount(pWin),
143694 pWin->regResult);
143695 sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
143696 }
143697 }
143698 }
143699 }
143700
143701 /*
143702 ** This function generates VM code to invoke the sub-routine at address
143703 ** lblFlushPart once for each partition with the entire partition cached in
143704 ** the Window.iEphCsr temp table.
143705 */
143706 static void windowPartitionCache(
143707 Parse *pParse,
143708 Select *p, /* The rewritten SELECT statement */
143709 WhereInfo *pWInfo, /* WhereInfo to call WhereEnd() on */
143710 int regFlushPart, /* Register to use with Gosub lblFlushPart */
143711 int lblFlushPart, /* Subroutine to Gosub to */
143712 int *pRegSize /* OUT: Register containing partition size */
143713 ){
143714 Window *pMWin = p->pWin;
143715 Vdbe *v = sqlite3GetVdbe(pParse);
143716 int iSubCsr = p->pSrc->a[0].iCursor;
143717 int nSub = p->pSrc->a[0].pTab->nCol;
143718 int k;
143719
143720 int reg = pParse->nMem+1;
143721 int regRecord = reg+nSub;
143722 int regRowid = regRecord+1;
143723
143724 *pRegSize = regRowid;
143725 pParse->nMem += nSub + 2;
143726
143727 /* Load the column values for the row returned by the sub-select
143728 ** into an array of registers starting at reg. */
143729 for(k=0; k<nSub; k++){
143730 sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
143731 }
143732 sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, nSub, regRecord);
143733
143734 /* Check if this is the start of a new partition. If so, call the
143735 ** flush_partition sub-routine. */
143736 if( pMWin->pPartition ){
143737 int addr;
143738 ExprList *pPart = pMWin->pPartition;
143739 int nPart = pPart->nExpr;
143740 int regNewPart = reg + pMWin->nBufferCol;
143741 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
143742
143743 addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);
143744 sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
143745 sqlite3VdbeAddOp3(v, OP_Jump, addr+2, addr+4, addr+2);
143746 VdbeCoverageEqNe(v);
143747 sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);
143748 sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
143749 VdbeComment((v, "call flush_partition"));
143750 }
143751
143752 /* Buffer the current row in the ephemeral table. */
143753 sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
143754 sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);
143755
143756 /* End of the input loop */
143757 sqlite3WhereEnd(pWInfo);
143758
143759 /* Invoke "flush_partition" to deal with the final (or only) partition */
143760 sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
143761 VdbeComment((v, "call flush_partition"));
143762 }
143763
143764 /*
143765 ** Invoke the sub-routine at regGosub (generated by code in select.c) to
143766 ** return the current row of Window.iEphCsr. If all window functions are
143767 ** aggregate window functions that use the standard API, a single
143768 ** OP_Gosub instruction is all that this routine generates. Extra VM code
143769 ** for per-row processing is only generated for the following built-in window
143770 ** functions:
143771 **
143772 ** nth_value()
143773 ** first_value()
143774 ** lag()
143775 ** lead()
143776 */
143777 static void windowReturnOneRow(
143778 Parse *pParse,
143779 Window *pMWin,
143780 int regGosub,
143781 int addrGosub
143782 ){
143783 Vdbe *v = sqlite3GetVdbe(pParse);
143784 Window *pWin;
143785 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143786 FuncDef *pFunc = pWin->pFunc;
143787 if( pFunc->zName==nth_valueName
143788 || pFunc->zName==first_valueName
143789 ){
143790 int csr = pWin->csrApp;
143791 int lbl = sqlite3VdbeMakeLabel(v);
143792 int tmpReg = sqlite3GetTempReg(pParse);
143793 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
143794
143795 if( pFunc->zName==nth_valueName ){
143796 sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+1,tmpReg);
143797 windowCheckIntValue(pParse, tmpReg, 2);
143798 }else{
143799 sqlite3VdbeAddOp2(v, OP_Integer, 1, tmpReg);
143800 }
143801 sqlite3VdbeAddOp3(v, OP_Add, tmpReg, pWin->regApp, tmpReg);
143802 sqlite3VdbeAddOp3(v, OP_Gt, pWin->regApp+1, lbl, tmpReg);
143803 VdbeCoverageNeverNull(v);
143804 sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, 0, tmpReg);
143805 VdbeCoverageNeverTaken(v);
143806 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
143807 sqlite3VdbeResolveLabel(v, lbl);
143808 sqlite3ReleaseTempReg(pParse, tmpReg);
143809 }
143810 else if( pFunc->zName==leadName || pFunc->zName==lagName ){
143811 int nArg = pWin->pOwner->x.pList->nExpr;
143812 int iEph = pMWin->iEphCsr;
143813 int csr = pWin->csrApp;
143814 int lbl = sqlite3VdbeMakeLabel(v);
143815 int tmpReg = sqlite3GetTempReg(pParse);
143816
143817 if( nArg<3 ){
143818 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
143819 }else{
143820 sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+2, pWin->regResult);
143821 }
143822 sqlite3VdbeAddOp2(v, OP_Rowid, iEph, tmpReg);
143823 if( nArg<2 ){
143824 int val = (pFunc->zName==leadName ? 1 : -1);
143825 sqlite3VdbeAddOp2(v, OP_AddImm, tmpReg, val);
143826 }else{
143827 int op = (pFunc->zName==leadName ? OP_Add : OP_Subtract);
143828 int tmpReg2 = sqlite3GetTempReg(pParse);
143829 sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+1, tmpReg2);
143830 sqlite3VdbeAddOp3(v, op, tmpReg2, tmpReg, tmpReg);
143831 sqlite3ReleaseTempReg(pParse, tmpReg2);
143832 }
143833
143834 sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, lbl, tmpReg);
143835 VdbeCoverage(v);
143836 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
143837 sqlite3VdbeResolveLabel(v, lbl);
143838 sqlite3ReleaseTempReg(pParse, tmpReg);
143839 }
143840 }
143841 sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
143842 }
143843
143844 /*
143845 ** Invoke the code generated by windowReturnOneRow() and, optionally, the
143846 ** xInverse() function for each window function, for one or more rows
143847 ** from the Window.iEphCsr temp table. This routine generates VM code
143848 ** similar to:
143849 **
143850 ** while( regCtr>0 ){
143851 ** regCtr--;
143852 ** windowReturnOneRow()
143853 ** if( bInverse ){
143854 ** AggInverse
143855 ** }
143856 ** Next (Window.iEphCsr)
143857 ** }
143858 */
143859 static void windowReturnRows(
143860 Parse *pParse,
143861 Window *pMWin, /* List of window functions */
143862 int regCtr, /* Register containing number of rows */
143863 int regGosub, /* Register for Gosub addrGosub */
143864 int addrGosub, /* Address of sub-routine for ReturnOneRow */
143865 int regInvArg, /* Array of registers for xInverse args */
143866 int regInvSize /* Register containing size of partition */
143867 ){
143868 int addr;
143869 Vdbe *v = sqlite3GetVdbe(pParse);
143870 windowAggFinal(pParse, pMWin, 0);
143871 addr = sqlite3VdbeAddOp3(v, OP_IfPos, regCtr, sqlite3VdbeCurrentAddr(v)+2 ,1);
143872 VdbeCoverage(v);
143873 sqlite3VdbeAddOp2(v, OP_Goto, 0, 0);
143874 windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);
143875 if( regInvArg ){
143876 windowAggStep(pParse, pMWin, pMWin->iEphCsr, 1, regInvArg, regInvSize);
143877 }
143878 sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, addr);
143879 VdbeCoverage(v);
143880 sqlite3VdbeJumpHere(v, addr+1); /* The OP_Goto */
143881 }
143882
143883 /*
143884 ** Generate code to set the accumulator register for each window function
143885 ** in the linked list passed as the second argument to NULL. And perform
143886 ** any equivalent initialization required by any built-in window functions
143887 ** in the list.
143888 */
143889 static int windowInitAccum(Parse *pParse, Window *pMWin){
143890 Vdbe *v = sqlite3GetVdbe(pParse);
143891 int regArg;
143892 int nArg = 0;
143893 Window *pWin;
143894 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
143895 FuncDef *pFunc = pWin->pFunc;
143896 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
143897 nArg = MAX(nArg, windowArgCount(pWin));
143898 if( pFunc->zName==nth_valueName
143899 || pFunc->zName==first_valueName
143900 ){
143901 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp);
143902 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
143903 }
143904
143905 if( (pFunc->funcFlags & SQLITE_FUNC_MINMAX) && pWin->csrApp ){
143906 assert( pWin->eStart!=TK_UNBOUNDED );
143907 sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);
143908 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
143909 }
143910 }
143911 regArg = pParse->nMem+1;
143912 pParse->nMem += nArg;
143913 return regArg;
143914 }
143915
143916
143917 /*
143918 ** This function does the work of sqlite3WindowCodeStep() for all "ROWS"
143919 ** window frame types except for "BETWEEN UNBOUNDED PRECEDING AND CURRENT
143920 ** ROW". Pseudo-code for each follows.
143921 **
143922 ** ROWS BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING
143923 **
143924 ** ...
143925 ** if( new partition ){
143926 ** Gosub flush_partition
143927 ** }
143928 ** Insert (record in eph-table)
143929 ** sqlite3WhereEnd()
143930 ** Gosub flush_partition
143931 **
143932 ** flush_partition:
143933 ** Once {
143934 ** OpenDup (iEphCsr -> csrStart)
143935 ** OpenDup (iEphCsr -> csrEnd)
143936 ** }
143937 ** regStart = <expr1> // PRECEDING expression
143938 ** regEnd = <expr2> // FOLLOWING expression
143939 ** if( regStart<0 || regEnd<0 ){ error! }
143940 ** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
143941 ** Next(csrEnd) // if EOF skip Aggstep
143942 ** Aggstep (csrEnd)
143943 ** if( (regEnd--)<=0 ){
143944 ** AggFinal (xValue)
143945 ** Gosub addrGosub
143946 ** Next(csr) // if EOF goto flush_partition_done
143947 ** if( (regStart--)<=0 ){
143948 ** AggInverse (csrStart)
143949 ** Next(csrStart)
143950 ** }
143951 ** }
143952 ** flush_partition_done:
143953 ** ResetSorter (csr)
143954 ** Return
143955 **
143956 ** ROWS BETWEEN <expr> PRECEDING AND CURRENT ROW
143957 ** ROWS BETWEEN CURRENT ROW AND <expr> FOLLOWING
143958 ** ROWS BETWEEN UNBOUNDED PRECEDING AND <expr> FOLLOWING
143959 **
143960 ** These are similar to the above. For "CURRENT ROW", intialize the
143961 ** register to 0. For "UNBOUNDED PRECEDING" to infinity.
143962 **
143963 ** ROWS BETWEEN <expr> PRECEDING AND UNBOUNDED FOLLOWING
143964 ** ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
143965 **
143966 ** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
143967 ** while( 1 ){
143968 ** Next(csrEnd) // Exit while(1) at EOF
143969 ** Aggstep (csrEnd)
143970 ** }
143971 ** while( 1 ){
143972 ** AggFinal (xValue)
143973 ** Gosub addrGosub
143974 ** Next(csr) // if EOF goto flush_partition_done
143975 ** if( (regStart--)<=0 ){
143976 ** AggInverse (csrStart)
143977 ** Next(csrStart)
143978 ** }
143979 ** }
143980 **
143981 ** For the "CURRENT ROW AND UNBOUNDED FOLLOWING" case, the final if()
143982 ** condition is always true (as if regStart were initialized to 0).
143983 **
143984 ** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
143985 **
143986 ** This is the only RANGE case handled by this routine. It modifies the
143987 ** second while( 1 ) loop in "ROWS BETWEEN CURRENT ... UNBOUNDED..." to
143988 ** be:
143989 **
143990 ** while( 1 ){
143991 ** AggFinal (xValue)
143992 ** while( 1 ){
143993 ** regPeer++
143994 ** Gosub addrGosub
143995 ** Next(csr) // if EOF goto flush_partition_done
143996 ** if( new peer ) break;
143997 ** }
143998 ** while( (regPeer--)>0 ){
143999 ** AggInverse (csrStart)
144000 ** Next(csrStart)
144001 ** }
144002 ** }
144003 **
144004 ** ROWS BETWEEN <expr> FOLLOWING AND <expr> FOLLOWING
144005 **
144006 ** regEnd = regEnd - regStart
144007 ** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
144008 ** Aggstep (csrEnd)
144009 ** Next(csrEnd) // if EOF fall-through
144010 ** if( (regEnd--)<=0 ){
144011 ** if( (regStart--)<=0 ){
144012 ** AggFinal (xValue)
144013 ** Gosub addrGosub
144014 ** Next(csr) // if EOF goto flush_partition_done
144015 ** }
144016 ** AggInverse (csrStart)
144017 ** Next (csrStart)
144018 ** }
144019 **
144020 ** ROWS BETWEEN <expr> PRECEDING AND <expr> PRECEDING
144021 **
144022 ** Replace the bit after "Rewind" in the above with:
144023 **
144024 ** if( (regEnd--)<=0 ){
144025 ** AggStep (csrEnd)
144026 ** Next (csrEnd)
144027 ** }
144028 ** AggFinal (xValue)
144029 ** Gosub addrGosub
144030 ** Next(csr) // if EOF goto flush_partition_done
144031 ** if( (regStart--)<=0 ){
144032 ** AggInverse (csr2)
144033 ** Next (csr2)
144034 ** }
144035 **
144036 */
144037 static void windowCodeRowExprStep(
144038 Parse *pParse,
144039 Select *p,
144040 WhereInfo *pWInfo,
144041 int regGosub,
144042 int addrGosub
144043 ){
144044 Window *pMWin = p->pWin;
144045 Vdbe *v = sqlite3GetVdbe(pParse);
144046 int regFlushPart; /* Register for "Gosub flush_partition" */
144047 int lblFlushPart; /* Label for "Gosub flush_partition" */
144048 int lblFlushDone; /* Label for "Gosub flush_partition_done" */
144049
144050 int regArg;
144051 int addr;
144052 int csrStart = pParse->nTab++;
144053 int csrEnd = pParse->nTab++;
144054 int regStart; /* Value of <expr> PRECEDING */
144055 int regEnd; /* Value of <expr> FOLLOWING */
144056 int addrGoto;
144057 int addrTop;
144058 int addrIfPos1 = 0;
144059 int addrIfPos2 = 0;
144060 int regSize = 0;
144061
144062 assert( pMWin->eStart==TK_PRECEDING
144063 || pMWin->eStart==TK_CURRENT
144064 || pMWin->eStart==TK_FOLLOWING
144065 || pMWin->eStart==TK_UNBOUNDED
144066 );
144067 assert( pMWin->eEnd==TK_FOLLOWING
144068 || pMWin->eEnd==TK_CURRENT
144069 || pMWin->eEnd==TK_UNBOUNDED
144070 || pMWin->eEnd==TK_PRECEDING
144071 );
144072
144073 /* Allocate register and label for the "flush_partition" sub-routine. */
144074 regFlushPart = ++pParse->nMem;
144075 lblFlushPart = sqlite3VdbeMakeLabel(v);
144076 lblFlushDone = sqlite3VdbeMakeLabel(v);
144077
144078 regStart = ++pParse->nMem;
144079 regEnd = ++pParse->nMem;
144080
144081 windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);
144082
144083 addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
144084
144085 /* Start of "flush_partition" */
144086 sqlite3VdbeResolveLabel(v, lblFlushPart);
144087 sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+3);
144088 VdbeCoverage(v);
144089 VdbeComment((v, "Flush_partition subroutine"));
144090 sqlite3VdbeAddOp2(v, OP_OpenDup, csrStart, pMWin->iEphCsr);
144091 sqlite3VdbeAddOp2(v, OP_OpenDup, csrEnd, pMWin->iEphCsr);
144092
144093 /* If either regStart or regEnd are not non-negative integers, throw
144094 ** an exception. */
144095 if( pMWin->pStart ){
144096 sqlite3ExprCode(pParse, pMWin->pStart, regStart);
144097 windowCheckIntValue(pParse, regStart, 0);
144098 }
144099 if( pMWin->pEnd ){
144100 sqlite3ExprCode(pParse, pMWin->pEnd, regEnd);
144101 windowCheckIntValue(pParse, regEnd, 1);
144102 }
144103
144104 /* If this is "ROWS <expr1> FOLLOWING AND ROWS <expr2> FOLLOWING", do:
144105 **
144106 ** if( regEnd<regStart ){
144107 ** // The frame always consists of 0 rows
144108 ** regStart = regSize;
144109 ** }
144110 ** regEnd = regEnd - regStart;
144111 */
144112 if( pMWin->pEnd && pMWin->eStart==TK_FOLLOWING ){
144113 assert( pMWin->pStart!=0 );
144114 assert( pMWin->eEnd==TK_FOLLOWING );
144115 sqlite3VdbeAddOp3(v, OP_Ge, regStart, sqlite3VdbeCurrentAddr(v)+2, regEnd);
144116 VdbeCoverageNeverNull(v);
144117 sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);
144118 sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regEnd);
144119 }
144120
144121 if( pMWin->pStart && pMWin->eEnd==TK_PRECEDING ){
144122 assert( pMWin->pEnd!=0 );
144123 assert( pMWin->eStart==TK_PRECEDING );
144124 sqlite3VdbeAddOp3(v, OP_Le, regStart, sqlite3VdbeCurrentAddr(v)+3, regEnd);
144125 VdbeCoverageNeverNull(v);
144126 sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);
144127 sqlite3VdbeAddOp2(v, OP_Copy, regSize, regEnd);
144128 }
144129
144130 /* Initialize the accumulator register for each window function to NULL */
144131 regArg = windowInitAccum(pParse, pMWin);
144132
144133 sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblFlushDone);
144134 VdbeCoverage(v);
144135 sqlite3VdbeAddOp2(v, OP_Rewind, csrStart, lblFlushDone);
144136 VdbeCoverageNeverTaken(v);
144137 sqlite3VdbeChangeP5(v, 1);
144138 sqlite3VdbeAddOp2(v, OP_Rewind, csrEnd, lblFlushDone);
144139 VdbeCoverageNeverTaken(v);
144140 sqlite3VdbeChangeP5(v, 1);
144141
144142 /* Invoke AggStep function for each window function using the row that
144143 ** csrEnd currently points to. Or, if csrEnd is already at EOF,
144144 ** do nothing. */
144145 addrTop = sqlite3VdbeCurrentAddr(v);
144146 if( pMWin->eEnd==TK_PRECEDING ){
144147 addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
144148 VdbeCoverage(v);
144149 }
144150 sqlite3VdbeAddOp2(v, OP_Next, csrEnd, sqlite3VdbeCurrentAddr(v)+2);
144151 VdbeCoverage(v);
144152 addr = sqlite3VdbeAddOp0(v, OP_Goto);
144153 windowAggStep(pParse, pMWin, csrEnd, 0, regArg, regSize);
144154 if( pMWin->eEnd==TK_UNBOUNDED ){
144155 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
144156 sqlite3VdbeJumpHere(v, addr);
144157 addrTop = sqlite3VdbeCurrentAddr(v);
144158 }else{
144159 sqlite3VdbeJumpHere(v, addr);
144160 if( pMWin->eEnd==TK_PRECEDING ){
144161 sqlite3VdbeJumpHere(v, addrIfPos1);
144162 }
144163 }
144164
144165 if( pMWin->eEnd==TK_FOLLOWING ){
144166 addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
144167 VdbeCoverage(v);
144168 }
144169 if( pMWin->eStart==TK_FOLLOWING ){
144170 addrIfPos2 = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
144171 VdbeCoverage(v);
144172 }
144173 windowAggFinal(pParse, pMWin, 0);
144174 windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);
144175 sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)+2);
144176 VdbeCoverage(v);
144177 sqlite3VdbeAddOp2(v, OP_Goto, 0, lblFlushDone);
144178 if( pMWin->eStart==TK_FOLLOWING ){
144179 sqlite3VdbeJumpHere(v, addrIfPos2);
144180 }
144181
144182 if( pMWin->eStart==TK_CURRENT
144183 || pMWin->eStart==TK_PRECEDING
144184 || pMWin->eStart==TK_FOLLOWING
144185 ){
144186 int lblSkipInverse = sqlite3VdbeMakeLabel(v);;
144187 if( pMWin->eStart==TK_PRECEDING ){
144188 sqlite3VdbeAddOp3(v, OP_IfPos, regStart, lblSkipInverse, 1);
144189 VdbeCoverage(v);
144190 }
144191 if( pMWin->eStart==TK_FOLLOWING ){
144192 sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+2);
144193 VdbeCoverage(v);
144194 sqlite3VdbeAddOp2(v, OP_Goto, 0, lblSkipInverse);
144195 }else{
144196 sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+1);
144197 VdbeCoverageAlwaysTaken(v);
144198 }
144199 windowAggStep(pParse, pMWin, csrStart, 1, regArg, regSize);
144200 sqlite3VdbeResolveLabel(v, lblSkipInverse);
144201 }
144202 if( pMWin->eEnd==TK_FOLLOWING ){
144203 sqlite3VdbeJumpHere(v, addrIfPos1);
144204 }
144205 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
144206
144207 /* flush_partition_done: */
144208 sqlite3VdbeResolveLabel(v, lblFlushDone);
144209 sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
144210 sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
144211 VdbeComment((v, "end flush_partition subroutine"));
144212
144213 /* Jump to here to skip over flush_partition */
144214 sqlite3VdbeJumpHere(v, addrGoto);
144215 }
144216
144217 /*
144218 ** This function does the work of sqlite3WindowCodeStep() for cases that
144219 ** would normally be handled by windowCodeDefaultStep() when there are
144220 ** one or more built-in window-functions that require the entire partition
144221 ** to be cached in a temp table before any rows can be returned. Additionally.
144222 ** "RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" is always handled by
144223 ** this function.
144224 **
144225 ** Pseudo-code corresponding to the VM code generated by this function
144226 ** for each type of window follows.
144227 **
144228 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144229 **
144230 ** flush_partition:
144231 ** Once {
144232 ** OpenDup (iEphCsr -> csrLead)
144233 ** }
144234 ** Integer ctr 0
144235 ** foreach row (csrLead){
144236 ** if( new peer ){
144237 ** AggFinal (xValue)
144238 ** for(i=0; i<ctr; i++){
144239 ** Gosub addrGosub
144240 ** Next iEphCsr
144241 ** }
144242 ** Integer ctr 0
144243 ** }
144244 ** AggStep (csrLead)
144245 ** Incr ctr
144246 ** }
144247 **
144248 ** AggFinal (xFinalize)
144249 ** for(i=0; i<ctr; i++){
144250 ** Gosub addrGosub
144251 ** Next iEphCsr
144252 ** }
144253 **
144254 ** ResetSorter (csr)
144255 ** Return
144256 **
144257 ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144258 **
144259 ** As above, except that the "if( new peer )" branch is always taken.
144260 **
144261 ** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
144262 **
144263 ** As above, except that each of the for() loops becomes:
144264 **
144265 ** for(i=0; i<ctr; i++){
144266 ** Gosub addrGosub
144267 ** AggInverse (iEphCsr)
144268 ** Next iEphCsr
144269 ** }
144270 **
144271 ** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
144272 **
144273 ** flush_partition:
144274 ** Once {
144275 ** OpenDup (iEphCsr -> csrLead)
144276 ** }
144277 ** foreach row (csrLead) {
144278 ** AggStep (csrLead)
144279 ** }
144280 ** foreach row (iEphCsr) {
144281 ** Gosub addrGosub
144282 ** }
144283 **
144284 ** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
144285 **
144286 ** flush_partition:
144287 ** Once {
144288 ** OpenDup (iEphCsr -> csrLead)
144289 ** }
144290 ** foreach row (csrLead){
144291 ** AggStep (csrLead)
144292 ** }
144293 ** Rewind (csrLead)
144294 ** Integer ctr 0
144295 ** foreach row (csrLead){
144296 ** if( new peer ){
144297 ** AggFinal (xValue)
144298 ** for(i=0; i<ctr; i++){
144299 ** Gosub addrGosub
144300 ** AggInverse (iEphCsr)
144301 ** Next iEphCsr
144302 ** }
144303 ** Integer ctr 0
144304 ** }
144305 ** Incr ctr
144306 ** }
144307 **
144308 ** AggFinal (xFinalize)
144309 ** for(i=0; i<ctr; i++){
144310 ** Gosub addrGosub
144311 ** Next iEphCsr
144312 ** }
144313 **
144314 ** ResetSorter (csr)
144315 ** Return
144316 */
144317 static void windowCodeCacheStep(
144318 Parse *pParse,
144319 Select *p,
144320 WhereInfo *pWInfo,
144321 int regGosub,
144322 int addrGosub
144323 ){
144324 Window *pMWin = p->pWin;
144325 Vdbe *v = sqlite3GetVdbe(pParse);
144326 int k;
144327 int addr;
144328 ExprList *pPart = pMWin->pPartition;
144329 ExprList *pOrderBy = pMWin->pOrderBy;
144330 int nPeer = pOrderBy ? pOrderBy->nExpr : 0;
144331 int regNewPeer;
144332
144333 int addrGoto; /* Address of Goto used to jump flush_par.. */
144334 int addrNext; /* Jump here for next iteration of loop */
144335 int regFlushPart;
144336 int lblFlushPart;
144337 int csrLead;
144338 int regCtr;
144339 int regArg; /* Register array to martial function args */
144340 int regSize;
144341 int lblEmpty;
144342 int bReverse = pMWin->pOrderBy && pMWin->eStart==TK_CURRENT
144343 && pMWin->eEnd==TK_UNBOUNDED;
144344
144345 assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
144346 || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED)
144347 || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT)
144348 || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED)
144349 );
144350
144351 lblEmpty = sqlite3VdbeMakeLabel(v);
144352 regNewPeer = pParse->nMem+1;
144353 pParse->nMem += nPeer;
144354
144355 /* Allocate register and label for the "flush_partition" sub-routine. */
144356 regFlushPart = ++pParse->nMem;
144357 lblFlushPart = sqlite3VdbeMakeLabel(v);
144358
144359 csrLead = pParse->nTab++;
144360 regCtr = ++pParse->nMem;
144361
144362 windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);
144363 addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
144364
144365 /* Start of "flush_partition" */
144366 sqlite3VdbeResolveLabel(v, lblFlushPart);
144367 sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+2);
144368 VdbeCoverage(v);
144369 sqlite3VdbeAddOp2(v, OP_OpenDup, csrLead, pMWin->iEphCsr);
144370
144371 /* Initialize the accumulator register for each window function to NULL */
144372 regArg = windowInitAccum(pParse, pMWin);
144373
144374 sqlite3VdbeAddOp2(v, OP_Integer, 0, regCtr);
144375 sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);
144376 VdbeCoverage(v);
144377 sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblEmpty);
144378 VdbeCoverageNeverTaken(v);
144379
144380 if( bReverse ){
144381 int addr2 = sqlite3VdbeCurrentAddr(v);
144382 windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);
144383 sqlite3VdbeAddOp2(v, OP_Next, csrLead, addr2);
144384 VdbeCoverage(v);
144385 sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);
144386 VdbeCoverageNeverTaken(v);
144387 }
144388 addrNext = sqlite3VdbeCurrentAddr(v);
144389
144390 if( pOrderBy && (pMWin->eEnd==TK_CURRENT || pMWin->eStart==TK_CURRENT) ){
144391 int bCurrent = (pMWin->eStart==TK_CURRENT);
144392 int addrJump = 0; /* Address of OP_Jump below */
144393 if( pMWin->eType==TK_RANGE ){
144394 int iOff = pMWin->nBufferCol + (pPart ? pPart->nExpr : 0);
144395 int regPeer = pMWin->regPart + (pPart ? pPart->nExpr : 0);
144396 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
144397 for(k=0; k<nPeer; k++){
144398 sqlite3VdbeAddOp3(v, OP_Column, csrLead, iOff+k, regNewPeer+k);
144399 }
144400 addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
144401 sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
144402 addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
144403 VdbeCoverage(v);
144404 sqlite3VdbeAddOp3(v, OP_Copy, regNewPeer, regPeer, nPeer-1);
144405 }
144406
144407 windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub,
144408 (bCurrent ? regArg : 0), (bCurrent ? regSize : 0)
144409 );
144410 if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
144411 }
144412
144413 if( bReverse==0 ){
144414 windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);
144415 }
144416 sqlite3VdbeAddOp2(v, OP_AddImm, regCtr, 1);
144417 sqlite3VdbeAddOp2(v, OP_Next, csrLead, addrNext);
144418 VdbeCoverage(v);
144419
144420 windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub, 0, 0);
144421
144422 sqlite3VdbeResolveLabel(v, lblEmpty);
144423 sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
144424 sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
144425
144426 /* Jump to here to skip over flush_partition */
144427 sqlite3VdbeJumpHere(v, addrGoto);
144428 }
144429
144430
144431 /*
144432 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144433 **
144434 ** ...
144435 ** if( new partition ){
144436 ** AggFinal (xFinalize)
144437 ** Gosub addrGosub
144438 ** ResetSorter eph-table
144439 ** }
144440 ** else if( new peer ){
144441 ** AggFinal (xValue)
144442 ** Gosub addrGosub
144443 ** ResetSorter eph-table
144444 ** }
144445 ** AggStep
144446 ** Insert (record into eph-table)
144447 ** sqlite3WhereEnd()
144448 ** AggFinal (xFinalize)
144449 ** Gosub addrGosub
144450 **
144451 ** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
144452 **
144453 ** As above, except take no action for a "new peer". Invoke
144454 ** the sub-routine once only for each partition.
144455 **
144456 ** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
144457 **
144458 ** As above, except that the "new peer" condition is handled in the
144459 ** same way as "new partition" (so there is no "else if" block).
144460 **
144461 ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144462 **
144463 ** As above, except assume every row is a "new peer".
144464 */
144465 static void windowCodeDefaultStep(
144466 Parse *pParse,
144467 Select *p,
144468 WhereInfo *pWInfo,
144469 int regGosub,
144470 int addrGosub
144471 ){
144472 Window *pMWin = p->pWin;
144473 Vdbe *v = sqlite3GetVdbe(pParse);
144474 int k;
144475 int iSubCsr = p->pSrc->a[0].iCursor;
144476 int nSub = p->pSrc->a[0].pTab->nCol;
144477 int reg = pParse->nMem+1;
144478 int regRecord = reg+nSub;
144479 int regRowid = regRecord+1;
144480 int addr;
144481 ExprList *pPart = pMWin->pPartition;
144482 ExprList *pOrderBy = pMWin->pOrderBy;
144483
144484 assert( pMWin->eType==TK_RANGE
144485 || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
144486 );
144487
144488 assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
144489 || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED)
144490 || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT)
144491 || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED && !pOrderBy)
144492 );
144493
144494 if( pMWin->eEnd==TK_UNBOUNDED ){
144495 pOrderBy = 0;
144496 }
144497
144498 pParse->nMem += nSub + 2;
144499
144500 /* Load the individual column values of the row returned by
144501 ** the sub-select into an array of registers. */
144502 for(k=0; k<nSub; k++){
144503 sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
144504 }
144505
144506 /* Check if this is the start of a new partition or peer group. */
144507 if( pPart || pOrderBy ){
144508 int nPart = (pPart ? pPart->nExpr : 0);
144509 int addrGoto = 0;
144510 int addrJump = 0;
144511 int nPeer = (pOrderBy ? pOrderBy->nExpr : 0);
144512
144513 if( pPart ){
144514 int regNewPart = reg + pMWin->nBufferCol;
144515 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
144516 addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);
144517 sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
144518 addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
144519 VdbeCoverageEqNe(v);
144520 windowAggFinal(pParse, pMWin, 1);
144521 if( pOrderBy ){
144522 addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
144523 }
144524 }
144525
144526 if( pOrderBy ){
144527 int regNewPeer = reg + pMWin->nBufferCol + nPart;
144528 int regPeer = pMWin->regPart + nPart;
144529
144530 if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
144531 if( pMWin->eType==TK_RANGE ){
144532 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
144533 addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
144534 sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
144535 addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
144536 VdbeCoverage(v);
144537 }else{
144538 addrJump = 0;
144539 }
144540 windowAggFinal(pParse, pMWin, pMWin->eStart==TK_CURRENT);
144541 if( addrGoto ) sqlite3VdbeJumpHere(v, addrGoto);
144542 }
144543
144544 sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);
144545 VdbeCoverage(v);
144546 sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
144547 sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);
144548 VdbeCoverage(v);
144549
144550 sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
144551 sqlite3VdbeAddOp3(
144552 v, OP_Copy, reg+pMWin->nBufferCol, pMWin->regPart, nPart+nPeer-1
144553 );
144554
144555 if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
144556 }
144557
144558 /* Invoke step function for window functions */
144559 windowAggStep(pParse, pMWin, -1, 0, reg, 0);
144560
144561 /* Buffer the current row in the ephemeral table. */
144562 if( pMWin->nBufferCol>0 ){
144563 sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, pMWin->nBufferCol, regRecord);
144564 }else{
144565 sqlite3VdbeAddOp2(v, OP_Blob, 0, regRecord);
144566 sqlite3VdbeAppendP4(v, (void*)"", 0);
144567 }
144568 sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
144569 sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);
144570
144571 /* End the database scan loop. */
144572 sqlite3WhereEnd(pWInfo);
144573
144574 windowAggFinal(pParse, pMWin, 1);
144575 sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);
144576 VdbeCoverage(v);
144577 sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
144578 sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);
144579 VdbeCoverage(v);
144580 }
144581
144582 /*
144583 ** Allocate and return a duplicate of the Window object indicated by the
144584 ** third argument. Set the Window.pOwner field of the new object to
144585 ** pOwner.
144586 */
144587 SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){
144588 Window *pNew = 0;
144589 if( p ){
144590 pNew = sqlite3DbMallocZero(db, sizeof(Window));
144591 if( pNew ){
144592 pNew->zName = sqlite3DbStrDup(db, p->zName);
144593 pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
144594 pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
144595 pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
144596 pNew->eType = p->eType;
144597 pNew->eEnd = p->eEnd;
144598 pNew->eStart = p->eStart;
144599 pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);
144600 pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);
144601 pNew->pOwner = pOwner;
144602 }
144603 }
144604 return pNew;
144605 }
144606
144607 /*
144608 ** Return a copy of the linked list of Window objects passed as the
144609 ** second argument.
144610 */
144611 SQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p){
144612 Window *pWin;
144613 Window *pRet = 0;
144614 Window **pp = &pRet;
144615
144616 for(pWin=p; pWin; pWin=pWin->pNextWin){
144617 *pp = sqlite3WindowDup(db, 0, pWin);
144618 if( *pp==0 ) break;
144619 pp = &((*pp)->pNextWin);
144620 }
144621
144622 return pRet;
144623 }
144624
144625 /*
144626 ** sqlite3WhereBegin() has already been called for the SELECT statement
144627 ** passed as the second argument when this function is invoked. It generates
144628 ** code to populate the Window.regResult register for each window function and
144629 ** invoke the sub-routine at instruction addrGosub once for each row.
144630 ** This function calls sqlite3WhereEnd() before returning.
144631 */
144632 SQLITE_PRIVATE void sqlite3WindowCodeStep(
144633 Parse *pParse, /* Parse context */
144634 Select *p, /* Rewritten SELECT statement */
144635 WhereInfo *pWInfo, /* Context returned by sqlite3WhereBegin() */
144636 int regGosub, /* Register for OP_Gosub */
144637 int addrGosub /* OP_Gosub here to return each row */
144638 ){
144639 Window *pMWin = p->pWin;
144640
144641 /* There are three different functions that may be used to do the work
144642 ** of this one, depending on the window frame and the specific built-in
144643 ** window functions used (if any).
144644 **
144645 ** windowCodeRowExprStep() handles all "ROWS" window frames, except for:
144646 **
144647 ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144648 **
144649 ** The exception is because windowCodeRowExprStep() implements all window
144650 ** frame types by caching the entire partition in a temp table, and
144651 ** "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" is easy enough to
144652 ** implement without such a cache.
144653 **
144654 ** windowCodeCacheStep() is used for:
144655 **
144656 ** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
144657 **
144658 ** It is also used for anything not handled by windowCodeRowExprStep()
144659 ** that invokes a built-in window function that requires the entire
144660 ** partition to be cached in a temp table before any rows are returned
144661 ** (e.g. nth_value() or percent_rank()).
144662 **
144663 ** Finally, assuming there is no built-in window function that requires
144664 ** the partition to be cached, windowCodeDefaultStep() is used for:
144665 **
144666 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144667 ** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
144668 ** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
144669 ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
144670 **
144671 ** windowCodeDefaultStep() is the only one of the three functions that
144672 ** does not cache each partition in a temp table before beginning to
144673 ** return rows.
144674 */
144675 if( pMWin->eType==TK_ROWS
144676 && (pMWin->eStart!=TK_UNBOUNDED||pMWin->eEnd!=TK_CURRENT||!pMWin->pOrderBy)
144677 ){
144678 VdbeModuleComment((pParse->pVdbe, "Begin RowExprStep()"));
144679 windowCodeRowExprStep(pParse, p, pWInfo, regGosub, addrGosub);
144680 }else{
144681 Window *pWin;
144682 int bCache = 0; /* True to use CacheStep() */
144683
144684 if( pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED ){
144685 bCache = 1;
144686 }else{
144687 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
144688 FuncDef *pFunc = pWin->pFunc;
144689 if( (pFunc->funcFlags & SQLITE_FUNC_WINDOW_SIZE)
144690 || (pFunc->zName==nth_valueName)
144691 || (pFunc->zName==first_valueName)
144692 || (pFunc->zName==leadName)
144693 || (pFunc->zName==lagName)
144694 ){
144695 bCache = 1;
144696 break;
144697 }
144698 }
144699 }
144700
144701 /* Otherwise, call windowCodeDefaultStep(). */
144702 if( bCache ){
144703 VdbeModuleComment((pParse->pVdbe, "Begin CacheStep()"));
144704 windowCodeCacheStep(pParse, p, pWInfo, regGosub, addrGosub);
144705 }else{
144706 VdbeModuleComment((pParse->pVdbe, "Begin DefaultStep()"));
144707 windowCodeDefaultStep(pParse, p, pWInfo, regGosub, addrGosub);
144708 }
144709 }
144710 }
144711
144712 #endif /* SQLITE_OMIT_WINDOWFUNC */
144713
144714 /************** End of window.c **********************************************/
144715 /************** Begin file parse.c *******************************************/
144716 /*
144717 ** 2000-05-29
144718 **
144719 ** The author disclaims copyright to this source code. In place of
@@ -141453,10 +144786,12 @@
144786 ** UPDATE ON (a,b,c)
144787 **
144788 ** Then the "b" IdList records the list "a,b,c".
144789 */
144790 struct TrigEvent { int a; IdList * b; };
144791
144792 struct FrameBound { int eType; Expr *pExpr; };
144793
144794 /*
144795 ** Disable lookaside memory allocation for objects that might be
144796 ** shared across database connections.
144797 */
@@ -141607,30 +144942,32 @@
144942 */
144943 #ifndef INTERFACE
144944 # define INTERFACE 1
144945 #endif
144946 /************* Begin control #defines *****************************************/
144947 #define YYCODETYPE unsigned short int
144948 #define YYNOCODE 277
144949 #define YYACTIONTYPE unsigned short int
144950 #define YYWILDCARD 91
144951 #define sqlite3ParserTOKENTYPE Token
144952 typedef union {
144953 int yyinit;
144954 sqlite3ParserTOKENTYPE yy0;
144955 Expr* yy18;
144956 struct TrigEvent yy34;
144957 IdList* yy48;
144958 int yy70;
144959 struct {int value; int mask;} yy111;
144960 struct FrameBound yy119;
144961 SrcList* yy135;
144962 TriggerStep* yy207;
144963 Window* yy327;
144964 Upsert* yy340;
144965 const char* yy392;
144966 ExprList* yy420;
144967 With* yy449;
144968 Select* yy489;
144969 } YYMINORTYPE;
144970 #ifndef YYSTACKDEPTH
144971 #define YYSTACKDEPTH 100
144972 #endif
144973 #define sqlite3ParserARG_SDECL
@@ -141642,22 +144979,23 @@
144979 #define sqlite3ParserCTX_PDECL ,Parse *pParse
144980 #define sqlite3ParserCTX_PARAM ,pParse
144981 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
144982 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
144983 #define YYFALLBACK 1
144984 #define YYNSTATE 516
144985 #define YYNRULE 365
144986 #define YYNTOKEN 155
144987 #define YY_MAX_SHIFT 515
144988 #define YY_MIN_SHIFTREDUCE 750
144989 #define YY_MAX_SHIFTREDUCE 1114
144990 #define YY_ERROR_ACTION 1115
144991 #define YY_ACCEPT_ACTION 1116
144992 #define YY_NO_ACTION 1117
144993 #define YY_MIN_REDUCE 1118
144994 #define YY_MAX_REDUCE 1482
144995 /************* End control #defines *******************************************/
144996 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
144997
144998 /* Define the yytestcase() macro to be a no-op if is not already defined
144999 ** otherwise.
145000 **
145001 ** Applications can choose to define yytestcase() in the %include section
@@ -141718,507 +145056,570 @@
145056 ** yy_reduce_ofst[] For each state, the offset into yy_action for
145057 ** shifting non-terminals after a reduce.
145058 ** yy_default[] Default action for each state.
145059 **
145060 *********** Begin parsing tables **********************************************/
145061 #define YY_ACTTAB_COUNT (2009)
145062 static const YYACTIONTYPE yy_action[] = {
145063 /* 0 */ 510, 423, 364, 105, 102, 196, 14, 244, 1116, 1,
145064 /* 10 */ 1, 515, 2, 1120, 510, 361, 1247, 362, 271, 366,
145065 /* 20 */ 127, 37, 37, 1378, 105, 102, 196, 1197, 178, 472,
145066 /* 30 */ 1246, 880, 1184, 1163, 423, 37, 37, 1189, 1189, 881,
145067 /* 40 */ 353, 1184, 425, 112, 113, 103, 1092, 1092, 944, 947,
145068 /* 50 */ 937, 937, 110, 110, 111, 111, 111, 111, 278, 249,
145069 /* 60 */ 249, 249, 249, 105, 102, 196, 510, 105, 102, 196,
145070 /* 70 */ 1071, 254, 507, 177, 507, 1187, 1187, 491, 415, 225,
145071 /* 80 */ 193, 105, 102, 196, 510, 205, 906, 65, 65, 318,
145072 /* 90 */ 249, 249, 109, 109, 109, 109, 108, 108, 107, 107,
145073 /* 100 */ 107, 106, 396, 507, 258, 15, 15, 394, 393, 249,
145074 /* 110 */ 249, 1413, 366, 1408, 400, 1096, 1071, 1072, 1073, 377,
145075 /* 120 */ 1098, 178, 507, 493, 492, 1411, 1407, 396, 1097, 292,
145076 /* 130 */ 411, 280, 366, 365, 134, 152, 112, 113, 103, 1092,
145077 /* 140 */ 1092, 944, 947, 937, 937, 110, 110, 111, 111, 111,
145078 /* 150 */ 111, 1450, 1099, 262, 1099, 262, 112, 113, 103, 1092,
145079 /* 160 */ 1092, 944, 947, 937, 937, 110, 110, 111, 111, 111,
145080 /* 170 */ 111, 107, 107, 107, 106, 396, 1049, 486, 1047, 509,
145081 /* 180 */ 73, 270, 500, 416, 293, 109, 109, 109, 109, 108,
145082 /* 190 */ 108, 107, 107, 107, 106, 396, 366, 111, 111, 111,
145083 /* 200 */ 111, 104, 330, 89, 486, 109, 109, 109, 109, 108,
145084 /* 210 */ 108, 107, 107, 107, 106, 396, 111, 111, 111, 111,
145085 /* 220 */ 112, 113, 103, 1092, 1092, 944, 947, 937, 937, 110,
145086 /* 230 */ 110, 111, 111, 111, 111, 109, 109, 109, 109, 108,
145087 /* 240 */ 108, 107, 107, 107, 106, 396, 114, 108, 108, 107,
145088 /* 250 */ 107, 107, 106, 396, 109, 109, 109, 109, 108, 108,
145089 /* 260 */ 107, 107, 107, 106, 396, 394, 393, 106, 396, 109,
145090 /* 270 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 396,
145091 /* 280 */ 217, 487, 1400, 453, 450, 449, 510, 1278, 423, 366,
145092 /* 290 */ 503, 503, 503, 448, 74, 1071, 109, 109, 109, 109,
145093 /* 300 */ 108, 108, 107, 107, 107, 106, 396, 37, 37, 1401,
145094 /* 310 */ 1099, 440, 1099, 112, 113, 103, 1092, 1092, 944, 947,
145095 /* 320 */ 937, 937, 110, 110, 111, 111, 111, 111, 1426, 515,
145096 /* 330 */ 2, 1120, 934, 934, 945, 948, 271, 1071, 127, 477,
145097 /* 340 */ 924, 1071, 1072, 1073, 217, 1197, 906, 453, 450, 449,
145098 /* 350 */ 388, 167, 510, 1377, 152, 379, 917, 448, 259, 510,
145099 /* 360 */ 916, 285, 109, 109, 109, 109, 108, 108, 107, 107,
145100 /* 370 */ 107, 106, 396, 15, 15, 429, 846, 249, 249, 224,
145101 /* 380 */ 15, 15, 366, 1071, 1072, 1073, 307, 382, 1071, 292,
145102 /* 390 */ 507, 916, 916, 918, 384, 27, 938, 1411, 484, 408,
145103 /* 400 */ 270, 500, 508, 205, 836, 836, 112, 113, 103, 1092,
145104 /* 410 */ 1092, 944, 947, 937, 937, 110, 110, 111, 111, 111,
145105 /* 420 */ 111, 1430, 282, 1120, 284, 1071, 28, 510, 271, 318,
145106 /* 430 */ 127, 1422, 400, 385, 1071, 1072, 1073, 1197, 159, 235,
145107 /* 440 */ 252, 317, 456, 312, 455, 222, 784, 375, 65, 65,
145108 /* 450 */ 332, 310, 194, 243, 243, 109, 109, 109, 109, 108,
145109 /* 460 */ 108, 107, 107, 107, 106, 396, 507, 257, 510, 249,
145110 /* 470 */ 249, 1071, 1072, 1073, 136, 366, 335, 924, 440, 788,
145111 /* 480 */ 270, 500, 507, 1446, 493, 473, 319, 1071, 429, 65,
145112 /* 490 */ 65, 1158, 784, 917, 283, 205, 510, 916, 440, 112,
145113 /* 500 */ 113, 103, 1092, 1092, 944, 947, 937, 937, 110, 110,
145114 /* 510 */ 111, 111, 111, 111, 279, 1027, 1476, 15, 15, 1476,
145115 /* 520 */ 403, 510, 383, 1071, 400, 493, 1404, 1386, 916, 916,
145116 /* 530 */ 918, 261, 463, 1071, 1072, 1073, 173, 1421, 510, 1071,
145117 /* 540 */ 1343, 510, 45, 45, 168, 990, 990, 437, 109, 109,
145118 /* 550 */ 109, 109, 108, 108, 107, 107, 107, 106, 396, 63,
145119 /* 560 */ 63, 510, 15, 15, 249, 249, 375, 510, 366, 1071,
145120 /* 570 */ 1072, 1073, 781, 5, 401, 355, 488, 507, 464, 3,
145121 /* 580 */ 291, 1071, 65, 65, 1025, 1071, 1072, 1073, 65, 65,
145122 /* 590 */ 350, 1112, 112, 113, 103, 1092, 1092, 944, 947, 937,
145123 /* 600 */ 937, 110, 110, 111, 111, 111, 111, 249, 249, 510,
145124 /* 610 */ 1071, 1042, 867, 395, 395, 395, 1071, 336, 493, 490,
145125 /* 620 */ 507, 1041, 1006, 318, 493, 505, 178, 1071, 1072, 1073,
145126 /* 630 */ 65, 65, 1071, 255, 344, 421, 273, 1007, 358, 290,
145127 /* 640 */ 88, 109, 109, 109, 109, 108, 108, 107, 107, 107,
145128 /* 650 */ 106, 396, 1008, 510, 375, 1071, 1071, 1072, 1073, 1113,
145129 /* 660 */ 510, 366, 1071, 1072, 1073, 1056, 493, 462, 133, 1478,
145130 /* 670 */ 351, 249, 249, 822, 65, 65, 152, 440, 1071, 1072,
145131 /* 680 */ 1073, 65, 65, 823, 507, 112, 113, 103, 1092, 1092,
145132 /* 690 */ 944, 947, 937, 937, 110, 110, 111, 111, 111, 111,
145133 /* 700 */ 274, 1071, 1072, 1073, 407, 866, 471, 1219, 1027, 1477,
145134 /* 710 */ 478, 767, 1477, 406, 1195, 1347, 1138, 392, 465, 1196,
145135 /* 720 */ 987, 256, 270, 500, 987, 445, 1075, 18, 18, 793,
145136 /* 730 */ 406, 405, 1347, 1349, 109, 109, 109, 109, 108, 108,
145137 /* 740 */ 107, 107, 107, 106, 396, 510, 249, 249, 249, 249,
145138 /* 750 */ 249, 249, 221, 510, 366, 251, 435, 246, 925, 507,
145139 /* 760 */ 865, 507, 468, 507, 318, 429, 49, 49, 494, 9,
145140 /* 770 */ 414, 228, 802, 1075, 50, 50, 277, 1025, 112, 113,
145141 /* 780 */ 103, 1092, 1092, 944, 947, 937, 937, 110, 110, 111,
145142 /* 790 */ 111, 111, 111, 1006, 249, 249, 510, 406, 1345, 1347,
145143 /* 800 */ 249, 249, 967, 454, 1141, 372, 1090, 507, 1007, 135,
145144 /* 810 */ 371, 803, 440, 507, 220, 219, 218, 17, 17, 1423,
145145 /* 820 */ 460, 510, 440, 1008, 510, 1232, 310, 109, 109, 109,
145146 /* 830 */ 109, 108, 108, 107, 107, 107, 106, 396, 510, 1336,
145147 /* 840 */ 510, 195, 39, 39, 497, 51, 51, 366, 510, 485,
145148 /* 850 */ 1278, 911, 6, 1090, 1192, 985, 386, 260, 221, 52,
145149 /* 860 */ 52, 53, 53, 1439, 298, 510, 865, 366, 510, 54,
145150 /* 870 */ 54, 112, 113, 103, 1092, 1092, 944, 947, 937, 937,
145151 /* 880 */ 110, 110, 111, 111, 111, 111, 55, 55, 865, 40,
145152 /* 890 */ 40, 112, 113, 103, 1092, 1092, 944, 947, 937, 937,
145153 /* 900 */ 110, 110, 111, 111, 111, 111, 250, 250, 755, 756,
145154 /* 910 */ 757, 510, 95, 510, 93, 510, 371, 510, 380, 507,
145155 /* 920 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
145156 /* 930 */ 396, 510, 41, 41, 43, 43, 44, 44, 56, 56,
145157 /* 940 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
145158 /* 950 */ 396, 510, 57, 57, 510, 1231, 510, 370, 510, 410,
145159 /* 960 */ 510, 416, 293, 510, 1291, 510, 1290, 510, 190, 195,
145160 /* 970 */ 510, 319, 58, 58, 1391, 16, 16, 59, 59, 118,
145161 /* 980 */ 118, 60, 60, 458, 46, 46, 61, 61, 62, 62,
145162 /* 990 */ 510, 47, 47, 1201, 865, 91, 510, 474, 510, 461,
145163 /* 1000 */ 510, 461, 510, 228, 510, 507, 510, 390, 510, 841,
145164 /* 1010 */ 510, 64, 64, 1449, 840, 366, 811, 140, 140, 141,
145165 /* 1020 */ 141, 69, 69, 48, 48, 119, 119, 66, 66, 120,
145166 /* 1030 */ 120, 121, 121, 510, 434, 366, 510, 431, 1090, 112,
145167 /* 1040 */ 113, 103, 1092, 1092, 944, 947, 937, 937, 110, 110,
145168 /* 1050 */ 111, 111, 111, 111, 117, 117, 510, 139, 139, 112,
145169 /* 1060 */ 113, 103, 1092, 1092, 944, 947, 937, 937, 110, 110,
145170 /* 1070 */ 111, 111, 111, 111, 305, 427, 116, 138, 138, 510,
145171 /* 1080 */ 86, 510, 131, 475, 510, 1090, 350, 1026, 109, 109,
145172 /* 1090 */ 109, 109, 108, 108, 107, 107, 107, 106, 396, 510,
145173 /* 1100 */ 125, 125, 124, 124, 510, 122, 122, 510, 109, 109,
145174 /* 1110 */ 109, 109, 108, 108, 107, 107, 107, 106, 396, 777,
145175 /* 1120 */ 123, 123, 502, 372, 510, 68, 68, 510, 70, 70,
145176 /* 1130 */ 1089, 510, 286, 14, 1278, 300, 1278, 303, 270, 500,
145177 /* 1140 */ 373, 153, 841, 94, 202, 67, 67, 840, 38, 38,
145178 /* 1150 */ 189, 188, 42, 42, 1278, 1113, 248, 193, 269, 880,
145179 /* 1160 */ 132, 428, 33, 366, 418, 1366, 777, 881, 182, 363,
145180 /* 1170 */ 1022, 289, 908, 352, 88, 227, 422, 424, 294, 227,
145181 /* 1180 */ 227, 88, 446, 366, 19, 223, 903, 112, 113, 103,
145182 /* 1190 */ 1092, 1092, 944, 947, 937, 937, 110, 110, 111, 111,
145183 /* 1200 */ 111, 111, 381, 308, 436, 430, 88, 112, 101, 103,
145184 /* 1210 */ 1092, 1092, 944, 947, 937, 937, 110, 110, 111, 111,
145185 /* 1220 */ 111, 111, 391, 417, 791, 801, 800, 808, 809, 970,
145186 /* 1230 */ 874, 974, 223, 227, 920, 185, 109, 109, 109, 109,
145187 /* 1240 */ 108, 108, 107, 107, 107, 106, 396, 984, 838, 984,
145188 /* 1250 */ 204, 96, 983, 1365, 983, 432, 109, 109, 109, 109,
145189 /* 1260 */ 108, 108, 107, 107, 107, 106, 396, 316, 295, 775,
145190 /* 1270 */ 1228, 791, 130, 299, 1167, 302, 366, 315, 974, 1166,
145191 /* 1280 */ 304, 920, 306, 496, 1180, 1164, 1165, 311, 320, 321,
145192 /* 1290 */ 1240, 267, 1277, 1215, 1226, 495, 366, 1283, 1147, 1140,
145193 /* 1300 */ 1129, 113, 103, 1092, 1092, 944, 947, 937, 937, 110,
145194 /* 1310 */ 110, 111, 111, 111, 111, 1128, 441, 241, 183, 1130,
145195 /* 1320 */ 1212, 1433, 103, 1092, 1092, 944, 947, 937, 937, 110,
145196 /* 1330 */ 110, 111, 111, 111, 111, 349, 323, 325, 327, 288,
145197 /* 1340 */ 426, 191, 187, 99, 501, 409, 4, 499, 314, 109,
145198 /* 1350 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 396,
145199 /* 1360 */ 504, 13, 1163, 1262, 451, 1340, 281, 329, 1339, 109,
145200 /* 1370 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 396,
145201 /* 1380 */ 1270, 357, 1436, 397, 230, 342, 1107, 186, 1385, 1383,
145202 /* 1390 */ 1104, 374, 420, 99, 501, 498, 4, 165, 30, 72,
145203 /* 1400 */ 75, 155, 1267, 149, 157, 152, 86, 1259, 412, 160,
145204 /* 1410 */ 504, 413, 161, 162, 924, 163, 444, 207, 356, 31,
145205 /* 1420 */ 97, 97, 8, 354, 1273, 419, 1334, 98, 169, 397,
145206 /* 1430 */ 512, 511, 433, 397, 916, 211, 80, 242, 1354, 439,
145207 /* 1440 */ 297, 213, 174, 301, 442, 498, 1131, 214, 215, 359,
145208 /* 1450 */ 457, 270, 500, 387, 360, 1183, 482, 1182, 1174, 793,
145209 /* 1460 */ 1181, 481, 476, 1154, 924, 916, 916, 918, 919, 25,
145210 /* 1470 */ 97, 97, 1155, 313, 1173, 1153, 265, 98, 1448, 397,
145211 /* 1480 */ 512, 511, 467, 389, 916, 266, 470, 1223, 99, 501,
145212 /* 1490 */ 85, 4, 1224, 229, 480, 489, 332, 331, 322, 181,
145213 /* 1500 */ 1402, 11, 1320, 334, 92, 504, 115, 129, 337, 99,
145214 /* 1510 */ 501, 324, 4, 1222, 1221, 916, 916, 918, 919, 25,
145215 /* 1520 */ 1425, 1060, 399, 326, 328, 253, 504, 1205, 397, 338,
145216 /* 1530 */ 348, 348, 347, 238, 345, 87, 339, 764, 479, 340,
145217 /* 1540 */ 498, 268, 236, 341, 1137, 29, 1066, 237, 513, 397,
145218 /* 1550 */ 198, 482, 276, 240, 514, 239, 483, 1126, 1121, 924,
145219 /* 1560 */ 275, 498, 154, 142, 1370, 97, 97, 368, 369, 143,
145220 /* 1570 */ 1371, 751, 98, 144, 397, 512, 511, 398, 184, 916,
145221 /* 1580 */ 924, 272, 1369, 1368, 128, 197, 97, 97, 845, 1151,
145222 /* 1590 */ 200, 1150, 263, 98, 71, 397, 512, 511, 201, 1148,
145223 /* 1600 */ 916, 146, 402, 126, 982, 980, 900, 156, 199, 203,
145224 /* 1610 */ 916, 916, 918, 919, 25, 145, 158, 825, 996, 206,
145225 /* 1620 */ 287, 99, 501, 164, 4, 147, 376, 904, 378, 76,
145226 /* 1630 */ 166, 916, 916, 918, 919, 25, 77, 78, 504, 79,
145227 /* 1640 */ 148, 999, 367, 208, 209, 995, 137, 270, 500, 20,
145228 /* 1650 */ 210, 296, 227, 1101, 438, 212, 988, 170, 171, 32,
145229 /* 1660 */ 766, 397, 443, 315, 216, 447, 452, 172, 81, 21,
145230 /* 1670 */ 404, 309, 22, 498, 82, 264, 150, 804, 179, 83,
145231 /* 1680 */ 459, 151, 180, 950, 482, 1030, 34, 84, 1031, 481,
145232 /* 1690 */ 466, 35, 924, 192, 469, 245, 247, 873, 97, 97,
145233 /* 1700 */ 175, 226, 96, 868, 1044, 98, 1048, 397, 512, 511,
145234 /* 1710 */ 1060, 399, 916, 23, 253, 10, 1046, 1035, 7, 348,
145235 /* 1720 */ 348, 347, 238, 345, 333, 176, 764, 88, 965, 24,
145236 /* 1730 */ 951, 99, 501, 949, 4, 954, 953, 1005, 1004, 198,
145237 /* 1740 */ 232, 276, 231, 916, 916, 918, 919, 25, 504, 275,
145238 /* 1750 */ 26, 36, 506, 921, 776, 100, 835, 839, 12, 233,
145239 /* 1760 */ 234, 90, 501, 343, 4, 346, 1441, 1440, 1061, 1117,
145240 /* 1770 */ 1117, 397, 1117, 1117, 1117, 1117, 1117, 1117, 504, 200,
145241 /* 1780 */ 1117, 1117, 1117, 498, 1117, 1117, 1117, 201, 1117, 1117,
145242 /* 1790 */ 146, 1117, 1117, 1117, 1117, 1117, 1117, 199, 1117, 1117,
145243 /* 1800 */ 1117, 397, 924, 1117, 1117, 1117, 1117, 1117, 97, 97,
145244 /* 1810 */ 1117, 1117, 1117, 498, 1117, 98, 1117, 397, 512, 511,
145245 /* 1820 */ 1117, 1117, 916, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145246 /* 1830 */ 1117, 367, 924, 1117, 1117, 1117, 270, 500, 97, 97,
145247 /* 1840 */ 1117, 1117, 1117, 1117, 1117, 98, 1117, 397, 512, 511,
145248 /* 1850 */ 1117, 1117, 916, 916, 916, 918, 919, 25, 1117, 404,
145249 /* 1860 */ 1117, 1117, 1117, 253, 1117, 1117, 1117, 1117, 348, 348,
145250 /* 1870 */ 347, 238, 345, 1117, 1117, 764, 1117, 1117, 1117, 1117,
145251 /* 1880 */ 1117, 1117, 1117, 916, 916, 918, 919, 25, 198, 1117,
145252 /* 1890 */ 276, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 275, 1117,
145253 /* 1900 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145254 /* 1910 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145255 /* 1920 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 200, 1117,
145256 /* 1930 */ 1117, 1117, 1117, 1117, 1117, 1117, 201, 1117, 1117, 146,
145257 /* 1940 */ 1117, 1117, 1117, 1117, 1117, 1117, 199, 1117, 1117, 1117,
145258 /* 1950 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145259 /* 1960 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145260 /* 1970 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145261 /* 1980 */ 367, 1117, 1117, 1117, 1117, 270, 500, 1117, 1117, 1117,
145262 /* 1990 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
145263 /* 2000 */ 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 404,
145264 };
145265 static const YYCODETYPE yy_lookahead[] = {
145266 /* 0 */ 163, 163, 184, 238, 239, 240, 182, 182, 155, 156,
145267 /* 10 */ 157, 158, 159, 160, 163, 184, 187, 184, 165, 19,
145268 /* 20 */ 167, 184, 185, 258, 238, 239, 240, 174, 163, 174,
145269 /* 30 */ 187, 31, 191, 192, 163, 184, 185, 202, 203, 39,
145270 /* 40 */ 175, 200, 163, 43, 44, 45, 46, 47, 48, 49,
145271 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 174, 206,
145272 /* 60 */ 207, 206, 207, 238, 239, 240, 163, 238, 239, 240,
145273 /* 70 */ 59, 233, 219, 249, 219, 202, 203, 174, 254, 224,
145274 /* 80 */ 225, 238, 239, 240, 163, 232, 73, 184, 185, 163,
145275 /* 90 */ 206, 207, 92, 93, 94, 95, 96, 97, 98, 99,
145276 /* 100 */ 100, 101, 102, 219, 233, 184, 185, 96, 97, 206,
145277 /* 110 */ 207, 274, 19, 276, 261, 104, 105, 106, 107, 198,
145278 /* 120 */ 109, 163, 219, 220, 221, 274, 275, 102, 117, 116,
145279 /* 130 */ 117, 118, 19, 175, 208, 81, 43, 44, 45, 46,
145280 /* 140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
145281 /* 150 */ 57, 197, 141, 195, 143, 197, 43, 44, 45, 46,
145282 /* 160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
145283 /* 170 */ 57, 98, 99, 100, 101, 102, 83, 163, 85, 163,
145284 /* 180 */ 67, 127, 128, 117, 118, 92, 93, 94, 95, 96,
145285 /* 190 */ 97, 98, 99, 100, 101, 102, 19, 54, 55, 56,
145286 /* 200 */ 57, 58, 163, 26, 163, 92, 93, 94, 95, 96,
145287 /* 210 */ 97, 98, 99, 100, 101, 102, 54, 55, 56, 57,
145288 /* 220 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
145289 /* 230 */ 53, 54, 55, 56, 57, 92, 93, 94, 95, 96,
145290 /* 240 */ 97, 98, 99, 100, 101, 102, 69, 96, 97, 98,
145291 /* 250 */ 99, 100, 101, 102, 92, 93, 94, 95, 96, 97,
145292 /* 260 */ 98, 99, 100, 101, 102, 96, 97, 101, 102, 92,
145293 /* 270 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
145294 /* 280 */ 108, 267, 268, 111, 112, 113, 163, 163, 163, 19,
145295 /* 290 */ 179, 180, 181, 121, 24, 59, 92, 93, 94, 95,
145296 /* 300 */ 96, 97, 98, 99, 100, 101, 102, 184, 185, 268,
145297 /* 310 */ 141, 163, 143, 43, 44, 45, 46, 47, 48, 49,
145298 /* 320 */ 50, 51, 52, 53, 54, 55, 56, 57, 157, 158,
145299 /* 330 */ 159, 160, 46, 47, 48, 49, 165, 59, 167, 163,
145300 /* 340 */ 90, 105, 106, 107, 108, 174, 73, 111, 112, 113,
145301 /* 350 */ 19, 22, 163, 205, 81, 231, 106, 121, 233, 163,
145302 /* 360 */ 110, 16, 92, 93, 94, 95, 96, 97, 98, 99,
145303 /* 370 */ 100, 101, 102, 184, 185, 163, 98, 206, 207, 26,
145304 /* 380 */ 184, 185, 19, 105, 106, 107, 23, 198, 59, 116,
145305 /* 390 */ 219, 141, 142, 143, 198, 22, 110, 274, 275, 234,
145306 /* 400 */ 127, 128, 123, 232, 125, 126, 43, 44, 45, 46,
145307 /* 410 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
145308 /* 420 */ 57, 158, 77, 160, 79, 59, 53, 163, 165, 163,
145309 /* 430 */ 167, 163, 261, 102, 105, 106, 107, 174, 72, 108,
145310 /* 440 */ 109, 110, 111, 112, 113, 114, 59, 163, 184, 185,
145311 /* 450 */ 22, 120, 163, 206, 207, 92, 93, 94, 95, 96,
145312 /* 460 */ 97, 98, 99, 100, 101, 102, 219, 255, 163, 206,
145313 /* 470 */ 207, 105, 106, 107, 208, 19, 163, 90, 163, 23,
145314 /* 480 */ 127, 128, 219, 183, 220, 221, 163, 59, 163, 184,
145315 /* 490 */ 185, 191, 105, 106, 149, 232, 163, 110, 163, 43,
145316 /* 500 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
145317 /* 510 */ 54, 55, 56, 57, 230, 22, 23, 184, 185, 26,
145318 /* 520 */ 205, 163, 199, 59, 261, 220, 221, 163, 141, 142,
145319 /* 530 */ 143, 198, 174, 105, 106, 107, 72, 269, 163, 59,
145320 /* 540 */ 205, 163, 184, 185, 22, 116, 117, 118, 92, 93,
145321 /* 550 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 184,
145322 /* 560 */ 185, 163, 184, 185, 206, 207, 163, 163, 19, 105,
145323 /* 570 */ 106, 107, 23, 22, 259, 174, 198, 219, 220, 22,
145324 /* 580 */ 255, 59, 184, 185, 91, 105, 106, 107, 184, 185,
145325 /* 590 */ 22, 23, 43, 44, 45, 46, 47, 48, 49, 50,
145326 /* 600 */ 51, 52, 53, 54, 55, 56, 57, 206, 207, 163,
145327 /* 610 */ 59, 76, 132, 179, 180, 181, 59, 242, 220, 221,
145328 /* 620 */ 219, 86, 12, 163, 220, 221, 163, 105, 106, 107,
145329 /* 630 */ 184, 185, 59, 230, 171, 234, 163, 27, 175, 174,
145330 /* 640 */ 26, 92, 93, 94, 95, 96, 97, 98, 99, 100,
145331 /* 650 */ 101, 102, 42, 163, 163, 59, 105, 106, 107, 91,
145332 /* 660 */ 163, 19, 105, 106, 107, 23, 220, 221, 208, 264,
145333 /* 670 */ 265, 206, 207, 63, 184, 185, 81, 163, 105, 106,
145334 /* 680 */ 107, 184, 185, 73, 219, 43, 44, 45, 46, 47,
145335 /* 690 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
145336 /* 700 */ 163, 105, 106, 107, 109, 132, 163, 226, 22, 23,
145337 /* 710 */ 220, 21, 26, 163, 174, 163, 174, 220, 174, 205,
145338 /* 720 */ 29, 230, 127, 128, 33, 19, 59, 184, 185, 115,
145339 /* 730 */ 180, 181, 180, 181, 92, 93, 94, 95, 96, 97,
145340 /* 740 */ 98, 99, 100, 101, 102, 163, 206, 207, 206, 207,
145341 /* 750 */ 206, 207, 46, 163, 19, 22, 65, 23, 23, 219,
145342 /* 760 */ 26, 219, 174, 219, 163, 163, 184, 185, 174, 22,
145343 /* 770 */ 80, 24, 35, 106, 184, 185, 163, 91, 43, 44,
145344 /* 780 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
145345 /* 790 */ 55, 56, 57, 12, 206, 207, 163, 247, 163, 247,
145346 /* 800 */ 206, 207, 112, 66, 177, 178, 59, 219, 27, 208,
145347 /* 810 */ 104, 74, 163, 219, 116, 117, 118, 184, 185, 153,
145348 /* 820 */ 154, 163, 163, 42, 163, 163, 120, 92, 93, 94,
145349 /* 830 */ 95, 96, 97, 98, 99, 100, 101, 102, 163, 149,
145350 /* 840 */ 163, 107, 184, 185, 63, 184, 185, 19, 163, 270,
145351 /* 850 */ 163, 23, 273, 106, 205, 11, 119, 255, 46, 184,
145352 /* 860 */ 185, 184, 185, 130, 205, 163, 132, 19, 163, 184,
145353 /* 870 */ 185, 43, 44, 45, 46, 47, 48, 49, 50, 51,
145354 /* 880 */ 52, 53, 54, 55, 56, 57, 184, 185, 26, 184,
145355 /* 890 */ 185, 43, 44, 45, 46, 47, 48, 49, 50, 51,
145356 /* 900 */ 52, 53, 54, 55, 56, 57, 206, 207, 7, 8,
145357 /* 910 */ 9, 163, 146, 163, 148, 163, 104, 163, 231, 219,
145358 /* 920 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
145359 /* 930 */ 102, 163, 184, 185, 184, 185, 184, 185, 184, 185,
145360 /* 940 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
145361 /* 950 */ 102, 163, 184, 185, 163, 163, 163, 168, 163, 163,
145362 /* 960 */ 163, 117, 118, 163, 237, 163, 237, 163, 26, 107,
145363 /* 970 */ 163, 163, 184, 185, 163, 184, 185, 184, 185, 184,
145364 /* 980 */ 185, 184, 185, 98, 184, 185, 184, 185, 184, 185,
145365 /* 990 */ 163, 184, 185, 207, 132, 147, 163, 19, 163, 272,
145366 /* 1000 */ 163, 272, 163, 24, 163, 219, 163, 199, 163, 124,
145367 /* 1010 */ 163, 184, 185, 23, 129, 19, 26, 184, 185, 184,
145368 /* 1020 */ 185, 184, 185, 184, 185, 184, 185, 184, 185, 184,
145369 /* 1030 */ 185, 184, 185, 163, 245, 19, 163, 248, 59, 43,
145370 /* 1040 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
145371 /* 1050 */ 54, 55, 56, 57, 184, 185, 163, 184, 185, 43,
145372 /* 1060 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
145373 /* 1070 */ 54, 55, 56, 57, 16, 19, 22, 184, 185, 163,
145374 /* 1080 */ 138, 163, 22, 105, 163, 106, 22, 23, 92, 93,
145375 /* 1090 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 163,
145376 /* 1100 */ 184, 185, 184, 185, 163, 184, 185, 163, 92, 93,
145377 /* 1110 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 59,
145378 /* 1120 */ 184, 185, 177, 178, 163, 184, 185, 163, 184, 185,
145379 /* 1130 */ 26, 163, 163, 182, 163, 77, 163, 79, 127, 128,
145380 /* 1140 */ 262, 263, 124, 147, 24, 184, 185, 129, 184, 185,
145381 /* 1150 */ 96, 97, 184, 185, 163, 91, 224, 225, 211, 31,
145382 /* 1160 */ 22, 105, 24, 19, 118, 163, 106, 39, 24, 222,
145383 /* 1170 */ 23, 23, 23, 26, 26, 26, 23, 23, 23, 26,
145384 /* 1180 */ 26, 26, 23, 19, 22, 26, 140, 43, 44, 45,
145385 /* 1190 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
145386 /* 1200 */ 56, 57, 231, 23, 231, 254, 26, 43, 44, 45,
145387 /* 1210 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
145388 /* 1220 */ 56, 57, 231, 61, 59, 109, 110, 7, 8, 23,
145389 /* 1230 */ 23, 59, 26, 26, 59, 131, 92, 93, 94, 95,
145390 /* 1240 */ 96, 97, 98, 99, 100, 101, 102, 141, 23, 143,
145391 /* 1250 */ 130, 26, 141, 163, 143, 163, 92, 93, 94, 95,
145392 /* 1260 */ 96, 97, 98, 99, 100, 101, 102, 110, 163, 23,
145393 /* 1270 */ 163, 106, 26, 163, 193, 163, 19, 120, 106, 193,
145394 /* 1280 */ 163, 106, 163, 203, 163, 163, 193, 163, 163, 163,
145395 /* 1290 */ 163, 223, 163, 163, 163, 163, 19, 163, 163, 163,
145396 /* 1300 */ 163, 44, 45, 46, 47, 48, 49, 50, 51, 52,
145397 /* 1310 */ 53, 54, 55, 56, 57, 163, 251, 250, 209, 163,
145398 /* 1320 */ 223, 163, 45, 46, 47, 48, 49, 50, 51, 52,
145399 /* 1330 */ 53, 54, 55, 56, 57, 161, 223, 223, 223, 256,
145400 /* 1340 */ 256, 196, 182, 19, 20, 227, 22, 244, 187, 92,
145401 /* 1350 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
145402 /* 1360 */ 36, 210, 192, 213, 188, 187, 227, 227, 187, 92,
145403 /* 1370 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
145404 /* 1380 */ 213, 213, 166, 59, 130, 212, 60, 210, 170, 170,
145405 /* 1390 */ 38, 170, 104, 19, 20, 71, 22, 22, 235, 257,
145406 /* 1400 */ 257, 260, 236, 43, 201, 81, 138, 213, 18, 204,
145407 /* 1410 */ 36, 170, 204, 204, 90, 204, 18, 169, 236, 235,
145408 /* 1420 */ 96, 97, 48, 213, 201, 213, 213, 103, 201, 105,
145409 /* 1430 */ 106, 107, 170, 59, 110, 169, 146, 170, 253, 62,
145410 /* 1440 */ 252, 169, 22, 170, 189, 71, 170, 169, 169, 189,
145411 /* 1450 */ 104, 127, 128, 64, 189, 186, 82, 186, 194, 115,
145412 /* 1460 */ 186, 87, 133, 188, 90, 141, 142, 143, 144, 145,
145413 /* 1470 */ 96, 97, 186, 186, 194, 186, 246, 103, 186, 105,
145414 /* 1480 */ 106, 107, 189, 102, 110, 246, 189, 229, 19, 20,
145415 /* 1490 */ 104, 22, 229, 170, 84, 134, 22, 271, 228, 217,
145416 /* 1500 */ 269, 22, 241, 170, 146, 36, 137, 152, 217, 19,
145417 /* 1510 */ 20, 228, 22, 229, 229, 141, 142, 143, 144, 145,
145418 /* 1520 */ 0, 1, 2, 228, 228, 5, 36, 218, 59, 216,
145419 /* 1530 */ 10, 11, 12, 13, 14, 136, 215, 17, 135, 214,
145420 /* 1540 */ 71, 243, 25, 213, 173, 26, 13, 164, 172, 59,
145421 /* 1550 */ 30, 82, 32, 6, 162, 164, 87, 162, 162, 90,
145422 /* 1560 */ 40, 71, 263, 176, 182, 96, 97, 266, 266, 176,
145423 /* 1570 */ 182, 4, 103, 176, 105, 106, 107, 3, 22, 110,
145424 /* 1580 */ 90, 151, 182, 182, 190, 15, 96, 97, 98, 182,
145425 /* 1590 */ 70, 182, 190, 103, 182, 105, 106, 107, 78, 182,
145426 /* 1600 */ 110, 81, 89, 16, 23, 23, 128, 139, 88, 24,
145427 /* 1610 */ 141, 142, 143, 144, 145, 119, 131, 20, 1, 133,
145428 /* 1620 */ 16, 19, 20, 131, 22, 119, 61, 140, 37, 53,
145429 /* 1630 */ 139, 141, 142, 143, 144, 145, 53, 53, 36, 53,
145430 /* 1640 */ 119, 105, 122, 34, 130, 1, 5, 127, 128, 22,
145431 /* 1650 */ 104, 149, 26, 75, 41, 130, 68, 68, 104, 24,
145432 /* 1660 */ 20, 59, 19, 120, 114, 67, 67, 22, 22, 22,
145433 /* 1670 */ 150, 23, 22, 71, 22, 67, 37, 28, 23, 138,
145434 /* 1680 */ 22, 153, 23, 23, 82, 23, 22, 26, 23, 87,
145435 /* 1690 */ 24, 22, 90, 130, 24, 23, 23, 105, 96, 97,
145436 /* 1700 */ 22, 34, 26, 132, 85, 103, 75, 105, 106, 107,
145437 /* 1710 */ 1, 2, 110, 34, 5, 34, 83, 23, 44, 10,
145438 /* 1720 */ 11, 12, 13, 14, 24, 26, 17, 26, 23, 34,
145439 /* 1730 */ 23, 19, 20, 23, 22, 11, 23, 23, 23, 30,
145440 /* 1740 */ 22, 32, 26, 141, 142, 143, 144, 145, 36, 40,
145441 /* 1750 */ 22, 22, 26, 23, 23, 22, 124, 23, 22, 130,
145442 /* 1760 */ 130, 19, 20, 23, 22, 15, 130, 130, 1, 277,
145443 /* 1770 */ 277, 59, 277, 277, 277, 277, 277, 277, 36, 70,
145444 /* 1780 */ 277, 277, 277, 71, 277, 277, 277, 78, 277, 277,
145445 /* 1790 */ 81, 277, 277, 277, 277, 277, 277, 88, 277, 277,
145446 /* 1800 */ 277, 59, 90, 277, 277, 277, 277, 277, 96, 97,
145447 /* 1810 */ 277, 277, 277, 71, 277, 103, 277, 105, 106, 107,
145448 /* 1820 */ 277, 277, 110, 277, 277, 277, 277, 277, 277, 277,
145449 /* 1830 */ 277, 122, 90, 277, 277, 277, 127, 128, 96, 97,
145450 /* 1840 */ 277, 277, 277, 277, 277, 103, 277, 105, 106, 107,
145451 /* 1850 */ 277, 277, 110, 141, 142, 143, 144, 145, 277, 150,
145452 /* 1860 */ 277, 277, 277, 5, 277, 277, 277, 277, 10, 11,
145453 /* 1870 */ 12, 13, 14, 277, 277, 17, 277, 277, 277, 277,
145454 /* 1880 */ 277, 277, 277, 141, 142, 143, 144, 145, 30, 277,
145455 /* 1890 */ 32, 277, 277, 277, 277, 277, 277, 277, 40, 277,
145456 /* 1900 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145457 /* 1910 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145458 /* 1920 */ 277, 277, 277, 277, 277, 277, 277, 277, 70, 277,
145459 /* 1930 */ 277, 277, 277, 277, 277, 277, 78, 277, 277, 81,
145460 /* 1940 */ 277, 277, 277, 277, 277, 277, 88, 277, 277, 277,
145461 /* 1950 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145462 /* 1960 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145463 /* 1970 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145464 /* 1980 */ 122, 277, 277, 277, 277, 127, 128, 277, 277, 277,
145465 /* 1990 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145466 /* 2000 */ 277, 277, 277, 277, 277, 277, 277, 277, 150, 277,
145467 /* 2010 */ 277, 277, 277, 277, 277, 277, 277, 277, 277,
145468 };
145469 #define YY_SHIFT_COUNT (515)
145470 #define YY_SHIFT_MIN (0)
145471 #define YY_SHIFT_MAX (1858)
145472 static const unsigned short int yy_shift_ofst[] = {
145473 /* 0 */ 1709, 1520, 1858, 1324, 1324, 54, 1374, 1469, 1602, 1712,
145474 /* 10 */ 1712, 1712, 1712, 1712, 273, 0, 0, 113, 1016, 1712,
145475 /* 20 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 11, 11, 236,
145476 /* 30 */ 595, 54, 54, 54, 54, 54, 54, 93, 177, 270,
145477 /* 40 */ 363, 456, 549, 642, 735, 828, 848, 996, 1144, 1016,
145478 /* 50 */ 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
145479 /* 60 */ 1016, 1016, 1016, 1016, 1016, 1016, 1164, 1016, 1257, 1277,
145480 /* 70 */ 1277, 1490, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
145481 /* 80 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
145482 /* 90 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
145483 /* 100 */ 1712, 1712, 1712, 1742, 1712, 1712, 1712, 1712, 1712, 1712,
145484 /* 110 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 143, 162, 162,
145485 /* 120 */ 162, 162, 162, 204, 151, 73, 596, 690, 706, 596,
145486 /* 130 */ 169, 169, 596, 353, 353, 353, 353, 66, 166, 25,
145487 /* 140 */ 2009, 2009, 331, 331, 331, 329, 366, 329, 329, 610,
145488 /* 150 */ 610, 428, 464, 493, 686, 596, 596, 596, 596, 596,
145489 /* 160 */ 596, 596, 596, 596, 596, 596, 596, 596, 596, 596,
145490 /* 170 */ 596, 596, 596, 596, 596, 596, 596, 844, 667, 666,
145491 /* 180 */ 666, 535, 667, 1011, 2009, 2009, 2009, 387, 250, 250,
145492 /* 190 */ 522, 172, 278, 551, 480, 573, 557, 596, 596, 596,
145493 /* 200 */ 596, 596, 596, 596, 596, 13, 596, 596, 596, 596,
145494 /* 210 */ 596, 596, 596, 596, 596, 596, 596, 596, 737, 737,
145495 /* 220 */ 737, 596, 596, 596, 596, 734, 596, 596, 596, 747,
145496 /* 230 */ 596, 596, 781, 596, 596, 596, 596, 596, 596, 596,
145497 /* 240 */ 596, 429, 691, 279, 979, 979, 979, 979, 862, 279,
145498 /* 250 */ 279, 885, 1054, 901, 942, 978, 978, 1056, 942, 942,
145499 /* 260 */ 1056, 614, 990, 812, 1128, 1128, 1128, 978, 766, 1104,
145500 /* 270 */ 1018, 1138, 1326, 1254, 1254, 1352, 1352, 1254, 1288, 1375,
145501 /* 280 */ 1360, 1268, 1390, 1390, 1390, 1390, 1254, 1398, 1268, 1268,
145502 /* 290 */ 1288, 1375, 1360, 1360, 1268, 1254, 1398, 1290, 1377, 1254,
145503 /* 300 */ 1398, 1420, 1254, 1398, 1254, 1398, 1420, 1346, 1346, 1346,
145504 /* 310 */ 1389, 1420, 1346, 1344, 1346, 1389, 1346, 1346, 1420, 1381,
145505 /* 320 */ 1381, 1420, 1329, 1386, 1329, 1386, 1329, 1386, 1329, 1386,
145506 /* 330 */ 1254, 1361, 1410, 1474, 1479, 1254, 1358, 1369, 1361, 1355,
145507 /* 340 */ 1399, 1403, 1268, 1517, 1519, 1533, 1533, 1547, 1547, 1547,
145508 /* 350 */ 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
145509 /* 360 */ 2009, 2009, 2009, 2009, 2009, 2009, 286, 345, 568, 1064,
145510 /* 370 */ 1058, 698, 1060, 1147, 373, 1120, 1046, 1148, 1162, 1149,
145511 /* 380 */ 1153, 1154, 1155, 1159, 1180, 1165, 1116, 1220, 1157, 1172,
145512 /* 390 */ 1206, 1207, 1225, 1106, 1111, 1246, 1175, 733, 1567, 1574,
145513 /* 400 */ 1556, 1430, 1570, 1513, 1587, 1581, 1582, 1478, 1468, 1496,
145514 /* 410 */ 1585, 1485, 1597, 1486, 1604, 1617, 1492, 1487, 1506, 1565,
145515 /* 420 */ 1591, 1491, 1576, 1583, 1584, 1586, 1521, 1536, 1609, 1514,
145516 /* 430 */ 1644, 1641, 1627, 1546, 1502, 1588, 1626, 1589, 1578, 1613,
145517 /* 440 */ 1525, 1554, 1635, 1640, 1643, 1543, 1550, 1645, 1598, 1646,
145518 /* 450 */ 1647, 1648, 1650, 1599, 1649, 1652, 1608, 1639, 1655, 1541,
145519 /* 460 */ 1658, 1528, 1659, 1660, 1661, 1662, 1664, 1666, 1665, 1669,
145520 /* 470 */ 1670, 1563, 1672, 1673, 1592, 1667, 1678, 1571, 1676, 1679,
145521 /* 480 */ 1681, 1619, 1631, 1633, 1674, 1694, 1700, 1699, 1701, 1695,
145522 /* 490 */ 1705, 1707, 1710, 1676, 1713, 1714, 1716, 1715, 1718, 1724,
145523 /* 500 */ 1728, 1729, 1730, 1731, 1733, 1734, 1736, 1726, 1632, 1629,
145524 /* 510 */ 1630, 1636, 1637, 1740, 1750, 1767,
145525 };
145526 #define YY_REDUCE_COUNT (365)
145527 #define YY_REDUCE_MIN (-235)
145528 #define YY_REDUCE_MAX (1417)
145529 static const short yy_reduce_ofst[] = {
145530 /* 0 */ -147, 171, 263, -97, 358, -145, -149, -163, 123, 264,
145531 /* 10 */ 305, 398, 404, 446, 401, -171, -157, -235, -175, -79,
145532 /* 20 */ 189, 196, 333, 490, 378, 375, 497, 550, 552, -42,
145533 /* 30 */ -116, 465, 540, 542, 544, 588, 594, -214, -214, -214,
145534 /* 40 */ -214, -214, -214, -214, -214, -214, -214, -214, -214, -214,
145535 /* 50 */ -214, -214, -214, -214, -214, -214, -214, -214, -214, -214,
145536 /* 60 */ -214, -214, -214, -214, -214, -214, -214, -214, -214, -214,
145537 /* 70 */ -214, 543, 582, 590, 633, 658, 661, 675, 677, 685,
145538 /* 80 */ 702, 705, 748, 750, 752, 754, 768, 788, 791, 793,
145539 /* 90 */ 795, 797, 800, 802, 804, 807, 827, 833, 835, 837,
145540 /* 100 */ 839, 841, 843, 845, 847, 870, 873, 893, 916, 918,
145541 /* 110 */ 921, 936, 941, 944, 961, 964, 968, -214, -214, -214,
145542 /* 120 */ -214, -214, -214, -214, -214, -214, 315, 789, -159, 14,
145543 /* 130 */ 111, 434, 463, 247, 700, 247, 700, -176, -214, -214,
145544 /* 140 */ -214, -214, 300, 300, 300, -162, -74, -129, 125, -165,
145545 /* 150 */ -127, 268, 266, 405, 405, -135, 284, 403, 491, 460,
145546 /* 160 */ 148, 335, 514, 649, 212, 124, 325, 687, 971, 602,
145547 /* 170 */ 973, 659, 323, 601, 808, 991, 41, 951, 627, 727,
145548 /* 180 */ 729, 579, 945, 786, 878, 932, 947, -182, -169, -167,
145549 /* 190 */ -121, -46, 16, 39, 176, 289, 313, 364, 473, 537,
145550 /* 200 */ 613, 635, 662, 792, 796, 165, 811, 969, 1002, 1090,
145551 /* 210 */ 1092, 1105, 1107, 1110, 1112, 1117, 1119, 1121, 1081, 1086,
145552 /* 220 */ 1093, 1122, 1124, 1125, 1126, 481, 1127, 1129, 1130, 1068,
145553 /* 230 */ 1131, 1132, 1080, 1134, 16, 1135, 1136, 1137, 1152, 1156,
145554 /* 240 */ 1158, 1065, 1067, 1109, 1097, 1113, 1114, 1115, 481, 1109,
145555 /* 250 */ 1109, 1151, 1160, 1174, 1150, 1118, 1139, 1083, 1167, 1168,
145556 /* 260 */ 1084, 1176, 1145, 1170, 1161, 1178, 1181, 1140, 1103, 1173,
145557 /* 270 */ 1177, 1216, 1141, 1218, 1219, 1142, 1143, 1221, 1166, 1163,
145558 /* 280 */ 1203, 1194, 1205, 1208, 1209, 1211, 1241, 1248, 1210, 1212,
145559 /* 290 */ 1182, 1184, 1223, 1227, 1213, 1262, 1266, 1185, 1188, 1267,
145560 /* 300 */ 1272, 1255, 1273, 1278, 1276, 1279, 1260, 1269, 1271, 1274,
145561 /* 310 */ 1264, 1265, 1286, 1275, 1287, 1280, 1289, 1292, 1293, 1230,
145562 /* 320 */ 1239, 1297, 1258, 1270, 1263, 1283, 1284, 1295, 1285, 1296,
145563 /* 330 */ 1323, 1282, 1226, 1231, 1261, 1333, 1298, 1309, 1291, 1313,
145564 /* 340 */ 1321, 1325, 1330, 1371, 1376, 1383, 1391, 1392, 1395, 1396,
145565 /* 350 */ 1301, 1302, 1299, 1387, 1382, 1388, 1400, 1401, 1393, 1394,
145566 /* 360 */ 1402, 1407, 1409, 1412, 1417, 1397,
145567 };
145568 static const YYACTIONTYPE yy_default[] = {
145569 /* 0 */ 1482, 1482, 1482, 1329, 1115, 1220, 1115, 1115, 1115, 1329,
145570 /* 10 */ 1329, 1329, 1329, 1329, 1115, 1250, 1250, 1380, 1146, 1115,
145571 /* 20 */ 1115, 1115, 1115, 1115, 1115, 1328, 1115, 1115, 1115, 1115,
145572 /* 30 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1256, 1115,
145573 /* 40 */ 1115, 1115, 1115, 1115, 1330, 1331, 1115, 1115, 1115, 1379,
145574 /* 50 */ 1381, 1266, 1265, 1264, 1263, 1362, 1237, 1261, 1254, 1258,
145575 /* 60 */ 1324, 1325, 1323, 1327, 1330, 1331, 1115, 1257, 1295, 1309,
145576 /* 70 */ 1294, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145577 /* 80 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145578 /* 90 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145579 /* 100 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145580 /* 110 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1303, 1308, 1314,
145581 /* 120 */ 1307, 1304, 1297, 1296, 1298, 1299, 1115, 1136, 1185, 1115,
145582 /* 130 */ 1115, 1115, 1115, 1397, 1396, 1115, 1115, 1146, 1300, 1301,
145583 /* 140 */ 1311, 1310, 1387, 1438, 1437, 1115, 1115, 1115, 1115, 1115,
145584 /* 150 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145585 /* 160 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145586 /* 170 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1146, 1142, 1420,
145587 /* 180 */ 1420, 1406, 1142, 1115, 1392, 1220, 1211, 1115, 1115, 1115,
145588 /* 190 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1384, 1382,
145589 /* 200 */ 1115, 1344, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145590 /* 210 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145591 /* 220 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1216,
145592 /* 230 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145593 /* 240 */ 1432, 1115, 1357, 1199, 1216, 1216, 1216, 1216, 1218, 1200,
145594 /* 250 */ 1198, 1210, 1146, 1122, 1260, 1239, 1239, 1471, 1260, 1260,
145595 /* 260 */ 1471, 1160, 1452, 1157, 1250, 1250, 1250, 1239, 1326, 1217,
145596 /* 270 */ 1210, 1115, 1474, 1225, 1225, 1473, 1473, 1225, 1269, 1275,
145597 /* 280 */ 1188, 1260, 1194, 1194, 1194, 1194, 1225, 1133, 1260, 1260,
145598 /* 290 */ 1269, 1275, 1188, 1188, 1260, 1225, 1133, 1361, 1468, 1225,
145599 /* 300 */ 1133, 1337, 1225, 1133, 1225, 1133, 1337, 1186, 1186, 1186,
145600 /* 310 */ 1175, 1337, 1186, 1160, 1186, 1175, 1186, 1186, 1337, 1341,
145601 /* 320 */ 1341, 1337, 1243, 1238, 1243, 1238, 1243, 1238, 1243, 1238,
145602 /* 330 */ 1225, 1244, 1405, 1115, 1332, 1225, 1115, 1255, 1244, 1418,
145603 /* 340 */ 1253, 1251, 1260, 1139, 1178, 1435, 1435, 1431, 1431, 1431,
145604 /* 350 */ 1479, 1479, 1392, 1447, 1146, 1146, 1146, 1146, 1447, 1162,
145605 /* 360 */ 1162, 1146, 1146, 1146, 1146, 1447, 1115, 1115, 1115, 1115,
145606 /* 370 */ 1115, 1115, 1442, 1115, 1346, 1229, 1115, 1115, 1115, 1115,
145607 /* 380 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145608 /* 390 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1280, 1115, 1118,
145609 /* 400 */ 1389, 1115, 1115, 1388, 1115, 1115, 1115, 1115, 1115, 1115,
145610 /* 410 */ 1230, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145611 /* 420 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1470,
145612 /* 430 */ 1115, 1115, 1115, 1115, 1115, 1115, 1360, 1359, 1115, 1115,
145613 /* 440 */ 1227, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145614 /* 450 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145615 /* 460 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
145616 /* 470 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1252, 1115,
145617 /* 480 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1419, 1245, 1115,
145618 /* 490 */ 1115, 1115, 1115, 1461, 1115, 1115, 1115, 1115, 1115, 1115,
145619 /* 500 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1456, 1202, 1282,
145620 /* 510 */ 1115, 1281, 1285, 1115, 1127, 1115,
145621 };
145622 /********** End of lemon-generated parsing tables *****************************/
145623
145624 /* The next table maps tokens (terminal symbols) into fallback tokens.
145625 ** If a construct like the following:
@@ -142310,15 +145711,22 @@
145711 59, /* RAISE => ID */
145712 59, /* RECURSIVE => ID */
145713 59, /* REPLACE => ID */
145714 59, /* RESTRICT => ID */
145715 59, /* ROW => ID */
145716 59, /* ROWS => ID */
145717 59, /* TRIGGER => ID */
145718 59, /* VACUUM => ID */
145719 59, /* VIEW => ID */
145720 59, /* VIRTUAL => ID */
145721 59, /* WITH => ID */
145722 59, /* CURRENT => ID */
145723 59, /* FOLLOWING => ID */
145724 59, /* PARTITION => ID */
145725 59, /* PRECEDING => ID */
145726 59, /* RANGE => ID */
145727 59, /* UNBOUNDED => ID */
145728 59, /* REINDEX => ID */
145729 59, /* RENAME => ID */
145730 59, /* CTIME_KW => ID */
145731 };
145732 #endif /* YYFALLBACK */
@@ -142481,189 +145889,211 @@
145889 /* 71 */ "RAISE",
145890 /* 72 */ "RECURSIVE",
145891 /* 73 */ "REPLACE",
145892 /* 74 */ "RESTRICT",
145893 /* 75 */ "ROW",
145894 /* 76 */ "ROWS",
145895 /* 77 */ "TRIGGER",
145896 /* 78 */ "VACUUM",
145897 /* 79 */ "VIEW",
145898 /* 80 */ "VIRTUAL",
145899 /* 81 */ "WITH",
145900 /* 82 */ "CURRENT",
145901 /* 83 */ "FOLLOWING",
145902 /* 84 */ "PARTITION",
145903 /* 85 */ "PRECEDING",
145904 /* 86 */ "RANGE",
145905 /* 87 */ "UNBOUNDED",
145906 /* 88 */ "REINDEX",
145907 /* 89 */ "RENAME",
145908 /* 90 */ "CTIME_KW",
145909 /* 91 */ "ANY",
145910 /* 92 */ "BITAND",
145911 /* 93 */ "BITOR",
145912 /* 94 */ "LSHIFT",
145913 /* 95 */ "RSHIFT",
145914 /* 96 */ "PLUS",
145915 /* 97 */ "MINUS",
145916 /* 98 */ "STAR",
145917 /* 99 */ "SLASH",
145918 /* 100 */ "REM",
145919 /* 101 */ "CONCAT",
145920 /* 102 */ "COLLATE",
145921 /* 103 */ "BITNOT",
145922 /* 104 */ "ON",
145923 /* 105 */ "INDEXED",
145924 /* 106 */ "STRING",
145925 /* 107 */ "JOIN_KW",
145926 /* 108 */ "CONSTRAINT",
145927 /* 109 */ "DEFAULT",
145928 /* 110 */ "NULL",
145929 /* 111 */ "PRIMARY",
145930 /* 112 */ "UNIQUE",
145931 /* 113 */ "CHECK",
145932 /* 114 */ "REFERENCES",
145933 /* 115 */ "AUTOINCR",
145934 /* 116 */ "INSERT",
145935 /* 117 */ "DELETE",
145936 /* 118 */ "UPDATE",
145937 /* 119 */ "SET",
145938 /* 120 */ "DEFERRABLE",
145939 /* 121 */ "FOREIGN",
145940 /* 122 */ "DROP",
145941 /* 123 */ "UNION",
145942 /* 124 */ "ALL",
145943 /* 125 */ "EXCEPT",
145944 /* 126 */ "INTERSECT",
145945 /* 127 */ "SELECT",
145946 /* 128 */ "VALUES",
145947 /* 129 */ "DISTINCT",
145948 /* 130 */ "DOT",
145949 /* 131 */ "FROM",
145950 /* 132 */ "JOIN",
145951 /* 133 */ "USING",
145952 /* 134 */ "ORDER",
145953 /* 135 */ "GROUP",
145954 /* 136 */ "HAVING",
145955 /* 137 */ "LIMIT",
145956 /* 138 */ "WHERE",
145957 /* 139 */ "INTO",
145958 /* 140 */ "NOTHING",
145959 /* 141 */ "FLOAT",
145960 /* 142 */ "BLOB",
145961 /* 143 */ "INTEGER",
145962 /* 144 */ "VARIABLE",
145963 /* 145 */ "CASE",
145964 /* 146 */ "WHEN",
145965 /* 147 */ "THEN",
145966 /* 148 */ "ELSE",
145967 /* 149 */ "INDEX",
145968 /* 150 */ "ALTER",
145969 /* 151 */ "ADD",
145970 /* 152 */ "WINDOW",
145971 /* 153 */ "OVER",
145972 /* 154 */ "FILTER",
145973 /* 155 */ "input",
145974 /* 156 */ "cmdlist",
145975 /* 157 */ "ecmd",
145976 /* 158 */ "cmdx",
145977 /* 159 */ "explain",
145978 /* 160 */ "cmd",
145979 /* 161 */ "transtype",
145980 /* 162 */ "trans_opt",
145981 /* 163 */ "nm",
145982 /* 164 */ "savepoint_opt",
145983 /* 165 */ "create_table",
145984 /* 166 */ "create_table_args",
145985 /* 167 */ "createkw",
145986 /* 168 */ "temp",
145987 /* 169 */ "ifnotexists",
145988 /* 170 */ "dbnm",
145989 /* 171 */ "columnlist",
145990 /* 172 */ "conslist_opt",
145991 /* 173 */ "table_options",
145992 /* 174 */ "select",
145993 /* 175 */ "columnname",
145994 /* 176 */ "carglist",
145995 /* 177 */ "typetoken",
145996 /* 178 */ "typename",
145997 /* 179 */ "signed",
145998 /* 180 */ "plus_num",
145999 /* 181 */ "minus_num",
146000 /* 182 */ "scanpt",
146001 /* 183 */ "ccons",
146002 /* 184 */ "term",
146003 /* 185 */ "expr",
146004 /* 186 */ "onconf",
146005 /* 187 */ "sortorder",
146006 /* 188 */ "autoinc",
146007 /* 189 */ "eidlist_opt",
146008 /* 190 */ "refargs",
146009 /* 191 */ "defer_subclause",
146010 /* 192 */ "refarg",
146011 /* 193 */ "refact",
146012 /* 194 */ "init_deferred_pred_opt",
146013 /* 195 */ "conslist",
146014 /* 196 */ "tconscomma",
146015 /* 197 */ "tcons",
146016 /* 198 */ "sortlist",
146017 /* 199 */ "eidlist",
146018 /* 200 */ "defer_subclause_opt",
146019 /* 201 */ "orconf",
146020 /* 202 */ "resolvetype",
146021 /* 203 */ "raisetype",
146022 /* 204 */ "ifexists",
146023 /* 205 */ "fullname",
146024 /* 206 */ "selectnowith",
146025 /* 207 */ "oneselect",
146026 /* 208 */ "wqlist",
146027 /* 209 */ "multiselect_op",
146028 /* 210 */ "distinct",
146029 /* 211 */ "selcollist",
146030 /* 212 */ "from",
146031 /* 213 */ "where_opt",
146032 /* 214 */ "groupby_opt",
146033 /* 215 */ "having_opt",
146034 /* 216 */ "windowdefn_opt",
146035 /* 217 */ "orderby_opt",
146036 /* 218 */ "limit_opt",
146037 /* 219 */ "values",
146038 /* 220 */ "nexprlist",
146039 /* 221 */ "exprlist",
146040 /* 222 */ "sclp",
146041 /* 223 */ "as",
146042 /* 224 */ "seltablist",
146043 /* 225 */ "stl_prefix",
146044 /* 226 */ "joinop",
146045 /* 227 */ "indexed_opt",
146046 /* 228 */ "on_opt",
146047 /* 229 */ "using_opt",
146048 /* 230 */ "xfullname",
146049 /* 231 */ "idlist",
146050 /* 232 */ "with",
146051 /* 233 */ "setlist",
146052 /* 234 */ "insert_cmd",
146053 /* 235 */ "idlist_opt",
146054 /* 236 */ "upsert",
146055 /* 237 */ "over_opt",
146056 /* 238 */ "likeop",
146057 /* 239 */ "between_op",
146058 /* 240 */ "in_op",
146059 /* 241 */ "paren_exprlist",
146060 /* 242 */ "case_operand",
146061 /* 243 */ "case_exprlist",
146062 /* 244 */ "case_else",
146063 /* 245 */ "uniqueflag",
146064 /* 246 */ "collate",
146065 /* 247 */ "nmnum",
146066 /* 248 */ "trigger_decl",
146067 /* 249 */ "trigger_cmd_list",
146068 /* 250 */ "trigger_time",
146069 /* 251 */ "trigger_event",
146070 /* 252 */ "foreach_clause",
146071 /* 253 */ "when_clause",
146072 /* 254 */ "trigger_cmd",
146073 /* 255 */ "trnm",
146074 /* 256 */ "tridxby",
146075 /* 257 */ "database_kw_opt",
146076 /* 258 */ "key_opt",
146077 /* 259 */ "add_column_fullname",
146078 /* 260 */ "kwcolumn_opt",
146079 /* 261 */ "create_vtab",
146080 /* 262 */ "vtabarglist",
146081 /* 263 */ "vtabarg",
146082 /* 264 */ "vtabargtoken",
146083 /* 265 */ "lp",
146084 /* 266 */ "anylist",
146085 /* 267 */ "windowdefn_list",
146086 /* 268 */ "windowdefn",
146087 /* 269 */ "window",
146088 /* 270 */ "frame_opt",
146089 /* 271 */ "part_opt",
146090 /* 272 */ "filter_opt",
146091 /* 273 */ "range_or_rows",
146092 /* 274 */ "frame_bound",
146093 /* 275 */ "frame_bound_s",
146094 /* 276 */ "frame_bound_e",
146095 };
146096 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
146097
146098 #ifndef NDEBUG
146099 /* For tracing reduce actions, the names of all rules are required.
@@ -142754,11 +146184,11 @@
146184 /* 82 */ "select ::= selectnowith",
146185 /* 83 */ "selectnowith ::= selectnowith multiselect_op oneselect",
146186 /* 84 */ "multiselect_op ::= UNION",
146187 /* 85 */ "multiselect_op ::= UNION ALL",
146188 /* 86 */ "multiselect_op ::= EXCEPT|INTERSECT",
146189 /* 87 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt windowdefn_opt orderby_opt limit_opt",
146190 /* 88 */ "values ::= VALUES LP nexprlist RP",
146191 /* 89 */ "values ::= values COMMA LP exprlist RP",
146192 /* 90 */ "distinct ::= DISTINCT",
146193 /* 91 */ "distinct ::= ALL",
146194 /* 92 */ "distinct ::=",
@@ -142839,12 +146269,12 @@
146269 /* 167 */ "term ::= STRING",
146270 /* 168 */ "term ::= INTEGER",
146271 /* 169 */ "expr ::= VARIABLE",
146272 /* 170 */ "expr ::= expr COLLATE ID|STRING",
146273 /* 171 */ "expr ::= CAST LP expr AS typetoken RP",
146274 /* 172 */ "expr ::= ID|INDEXED LP distinct exprlist RP over_opt",
146275 /* 173 */ "expr ::= ID|INDEXED LP STAR RP over_opt",
146276 /* 174 */ "term ::= CTIME_KW",
146277 /* 175 */ "expr ::= LP nexprlist COMMA expr RP",
146278 /* 176 */ "expr ::= expr AND expr",
146279 /* 177 */ "expr ::= expr OR expr",
146280 /* 178 */ "expr ::= expr LT|GT|GE|LE expr",
@@ -142860,158 +146290,182 @@
146290 /* 188 */ "expr ::= expr NOT NULL",
146291 /* 189 */ "expr ::= expr IS expr",
146292 /* 190 */ "expr ::= expr IS NOT expr",
146293 /* 191 */ "expr ::= NOT expr",
146294 /* 192 */ "expr ::= BITNOT expr",
146295 /* 193 */ "expr ::= PLUS|MINUS expr",
146296 /* 194 */ "between_op ::= BETWEEN",
146297 /* 195 */ "between_op ::= NOT BETWEEN",
146298 /* 196 */ "expr ::= expr between_op expr AND expr",
146299 /* 197 */ "in_op ::= IN",
146300 /* 198 */ "in_op ::= NOT IN",
146301 /* 199 */ "expr ::= expr in_op LP exprlist RP",
146302 /* 200 */ "expr ::= LP select RP",
146303 /* 201 */ "expr ::= expr in_op LP select RP",
146304 /* 202 */ "expr ::= expr in_op nm dbnm paren_exprlist",
146305 /* 203 */ "expr ::= EXISTS LP select RP",
146306 /* 204 */ "expr ::= CASE case_operand case_exprlist case_else END",
146307 /* 205 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
146308 /* 206 */ "case_exprlist ::= WHEN expr THEN expr",
146309 /* 207 */ "case_else ::= ELSE expr",
146310 /* 208 */ "case_else ::=",
146311 /* 209 */ "case_operand ::= expr",
146312 /* 210 */ "case_operand ::=",
146313 /* 211 */ "exprlist ::=",
146314 /* 212 */ "nexprlist ::= nexprlist COMMA expr",
146315 /* 213 */ "nexprlist ::= expr",
146316 /* 214 */ "paren_exprlist ::=",
146317 /* 215 */ "paren_exprlist ::= LP exprlist RP",
146318 /* 216 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
146319 /* 217 */ "uniqueflag ::= UNIQUE",
146320 /* 218 */ "uniqueflag ::=",
146321 /* 219 */ "eidlist_opt ::=",
146322 /* 220 */ "eidlist_opt ::= LP eidlist RP",
146323 /* 221 */ "eidlist ::= eidlist COMMA nm collate sortorder",
146324 /* 222 */ "eidlist ::= nm collate sortorder",
146325 /* 223 */ "collate ::=",
146326 /* 224 */ "collate ::= COLLATE ID|STRING",
146327 /* 225 */ "cmd ::= DROP INDEX ifexists fullname",
146328 /* 226 */ "cmd ::= VACUUM",
146329 /* 227 */ "cmd ::= VACUUM nm",
146330 /* 228 */ "cmd ::= PRAGMA nm dbnm",
146331 /* 229 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
146332 /* 230 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
146333 /* 231 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
146334 /* 232 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
146335 /* 233 */ "plus_num ::= PLUS INTEGER|FLOAT",
146336 /* 234 */ "minus_num ::= MINUS INTEGER|FLOAT",
146337 /* 235 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
146338 /* 236 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
146339 /* 237 */ "trigger_time ::= BEFORE|AFTER",
146340 /* 238 */ "trigger_time ::= INSTEAD OF",
146341 /* 239 */ "trigger_time ::=",
146342 /* 240 */ "trigger_event ::= DELETE|INSERT",
146343 /* 241 */ "trigger_event ::= UPDATE",
146344 /* 242 */ "trigger_event ::= UPDATE OF idlist",
146345 /* 243 */ "when_clause ::=",
146346 /* 244 */ "when_clause ::= WHEN expr",
146347 /* 245 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
146348 /* 246 */ "trigger_cmd_list ::= trigger_cmd SEMI",
146349 /* 247 */ "trnm ::= nm DOT nm",
146350 /* 248 */ "tridxby ::= INDEXED BY nm",
146351 /* 249 */ "tridxby ::= NOT INDEXED",
146352 /* 250 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
146353 /* 251 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
146354 /* 252 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
146355 /* 253 */ "trigger_cmd ::= scanpt select scanpt",
146356 /* 254 */ "expr ::= RAISE LP IGNORE RP",
146357 /* 255 */ "expr ::= RAISE LP raisetype COMMA nm RP",
146358 /* 256 */ "raisetype ::= ROLLBACK",
146359 /* 257 */ "raisetype ::= ABORT",
146360 /* 258 */ "raisetype ::= FAIL",
146361 /* 259 */ "cmd ::= DROP TRIGGER ifexists fullname",
146362 /* 260 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
146363 /* 261 */ "cmd ::= DETACH database_kw_opt expr",
146364 /* 262 */ "key_opt ::=",
146365 /* 263 */ "key_opt ::= KEY expr",
146366 /* 264 */ "cmd ::= REINDEX",
146367 /* 265 */ "cmd ::= REINDEX nm dbnm",
146368 /* 266 */ "cmd ::= ANALYZE",
146369 /* 267 */ "cmd ::= ANALYZE nm dbnm",
146370 /* 268 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
146371 /* 269 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
146372 /* 270 */ "add_column_fullname ::= fullname",
146373 /* 271 */ "cmd ::= create_vtab",
146374 /* 272 */ "cmd ::= create_vtab LP vtabarglist RP",
146375 /* 273 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
146376 /* 274 */ "vtabarg ::=",
146377 /* 275 */ "vtabargtoken ::= ANY",
146378 /* 276 */ "vtabargtoken ::= lp anylist RP",
146379 /* 277 */ "lp ::= LP",
146380 /* 278 */ "with ::= WITH wqlist",
146381 /* 279 */ "with ::= WITH RECURSIVE wqlist",
146382 /* 280 */ "wqlist ::= nm eidlist_opt AS LP select RP",
146383 /* 281 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
146384 /* 282 */ "windowdefn_list ::= windowdefn",
146385 /* 283 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
146386 /* 284 */ "windowdefn ::= nm AS window",
146387 /* 285 */ "window ::= LP part_opt orderby_opt frame_opt RP",
146388 /* 286 */ "part_opt ::= PARTITION BY exprlist",
146389 /* 287 */ "part_opt ::=",
146390 /* 288 */ "frame_opt ::=",
146391 /* 289 */ "frame_opt ::= range_or_rows frame_bound_s",
146392 /* 290 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e",
146393 /* 291 */ "range_or_rows ::= RANGE",
146394 /* 292 */ "range_or_rows ::= ROWS",
146395 /* 293 */ "frame_bound_s ::= frame_bound",
146396 /* 294 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
146397 /* 295 */ "frame_bound_e ::= frame_bound",
146398 /* 296 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
146399 /* 297 */ "frame_bound ::= expr PRECEDING",
146400 /* 298 */ "frame_bound ::= CURRENT ROW",
146401 /* 299 */ "frame_bound ::= expr FOLLOWING",
146402 /* 300 */ "windowdefn_opt ::=",
146403 /* 301 */ "windowdefn_opt ::= WINDOW windowdefn_list",
146404 /* 302 */ "over_opt ::=",
146405 /* 303 */ "over_opt ::= filter_opt OVER window",
146406 /* 304 */ "over_opt ::= filter_opt OVER nm",
146407 /* 305 */ "filter_opt ::=",
146408 /* 306 */ "filter_opt ::= FILTER LP WHERE expr RP",
146409 /* 307 */ "input ::= cmdlist",
146410 /* 308 */ "cmdlist ::= cmdlist ecmd",
146411 /* 309 */ "cmdlist ::= ecmd",
146412 /* 310 */ "ecmd ::= SEMI",
146413 /* 311 */ "ecmd ::= cmdx SEMI",
146414 /* 312 */ "ecmd ::= explain cmdx",
146415 /* 313 */ "trans_opt ::=",
146416 /* 314 */ "trans_opt ::= TRANSACTION",
146417 /* 315 */ "trans_opt ::= TRANSACTION nm",
146418 /* 316 */ "savepoint_opt ::= SAVEPOINT",
146419 /* 317 */ "savepoint_opt ::=",
146420 /* 318 */ "cmd ::= create_table create_table_args",
146421 /* 319 */ "columnlist ::= columnlist COMMA columnname carglist",
146422 /* 320 */ "columnlist ::= columnname carglist",
146423 /* 321 */ "nm ::= ID|INDEXED",
146424 /* 322 */ "nm ::= STRING",
146425 /* 323 */ "nm ::= JOIN_KW",
146426 /* 324 */ "typetoken ::= typename",
146427 /* 325 */ "typename ::= ID|STRING",
146428 /* 326 */ "signed ::= plus_num",
146429 /* 327 */ "signed ::= minus_num",
146430 /* 328 */ "carglist ::= carglist ccons",
146431 /* 329 */ "carglist ::=",
146432 /* 330 */ "ccons ::= NULL onconf",
146433 /* 331 */ "conslist_opt ::= COMMA conslist",
146434 /* 332 */ "conslist ::= conslist tconscomma tcons",
146435 /* 333 */ "conslist ::= tcons",
146436 /* 334 */ "tconscomma ::=",
146437 /* 335 */ "defer_subclause_opt ::= defer_subclause",
146438 /* 336 */ "resolvetype ::= raisetype",
146439 /* 337 */ "selectnowith ::= oneselect",
146440 /* 338 */ "oneselect ::= values",
146441 /* 339 */ "sclp ::= selcollist COMMA",
146442 /* 340 */ "as ::= ID|STRING",
146443 /* 341 */ "expr ::= term",
146444 /* 342 */ "likeop ::= LIKE_KW|MATCH",
146445 /* 343 */ "exprlist ::= nexprlist",
146446 /* 344 */ "nmnum ::= plus_num",
146447 /* 345 */ "nmnum ::= nm",
146448 /* 346 */ "nmnum ::= ON",
146449 /* 347 */ "nmnum ::= DELETE",
146450 /* 348 */ "nmnum ::= DEFAULT",
146451 /* 349 */ "plus_num ::= INTEGER|FLOAT",
146452 /* 350 */ "foreach_clause ::=",
146453 /* 351 */ "foreach_clause ::= FOR EACH ROW",
146454 /* 352 */ "trnm ::= nm",
146455 /* 353 */ "tridxby ::=",
146456 /* 354 */ "database_kw_opt ::= DATABASE",
146457 /* 355 */ "database_kw_opt ::=",
146458 /* 356 */ "kwcolumn_opt ::=",
146459 /* 357 */ "kwcolumn_opt ::= COLUMNKW",
146460 /* 358 */ "vtabarglist ::= vtabarg",
146461 /* 359 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
146462 /* 360 */ "vtabarg ::= vtabarg vtabargtoken",
146463 /* 361 */ "anylist ::=",
146464 /* 362 */ "anylist ::= anylist LP anylist RP",
146465 /* 363 */ "anylist ::= anylist ANY",
146466 /* 364 */ "with ::=",
146467 };
146468 #endif /* NDEBUG */
146469
146470
146471 #if YYSTACKDEPTH<=0
@@ -143133,77 +146587,100 @@
146587 ** Note: during a reduce, the only symbols destroyed are those
146588 ** which appear on the RHS of the rule, but which are *not* used
146589 ** inside the C code.
146590 */
146591 /********* Begin destructor definitions ***************************************/
146592 case 174: /* select */
146593 case 206: /* selectnowith */
146594 case 207: /* oneselect */
146595 case 219: /* values */
146596 {
146597 sqlite3SelectDelete(pParse->db, (yypminor->yy489));
146598 }
146599 break;
146600 case 184: /* term */
146601 case 185: /* expr */
146602 case 213: /* where_opt */
146603 case 215: /* having_opt */
146604 case 228: /* on_opt */
146605 case 242: /* case_operand */
146606 case 244: /* case_else */
146607 case 253: /* when_clause */
146608 case 258: /* key_opt */
146609 case 272: /* filter_opt */
146610 {
146611 sqlite3ExprDelete(pParse->db, (yypminor->yy18));
146612 }
146613 break;
146614 case 189: /* eidlist_opt */
146615 case 198: /* sortlist */
146616 case 199: /* eidlist */
146617 case 211: /* selcollist */
146618 case 214: /* groupby_opt */
146619 case 217: /* orderby_opt */
146620 case 220: /* nexprlist */
146621 case 221: /* exprlist */
146622 case 222: /* sclp */
146623 case 233: /* setlist */
146624 case 241: /* paren_exprlist */
146625 case 243: /* case_exprlist */
146626 case 271: /* part_opt */
146627 {
146628 sqlite3ExprListDelete(pParse->db, (yypminor->yy420));
146629 }
146630 break;
146631 case 205: /* fullname */
146632 case 212: /* from */
146633 case 224: /* seltablist */
146634 case 225: /* stl_prefix */
146635 case 230: /* xfullname */
146636 {
146637 sqlite3SrcListDelete(pParse->db, (yypminor->yy135));
146638 }
146639 break;
146640 case 208: /* wqlist */
146641 {
146642 sqlite3WithDelete(pParse->db, (yypminor->yy449));
146643 }
146644 break;
146645 case 216: /* windowdefn_opt */
146646 case 267: /* windowdefn_list */
146647 {
146648 sqlite3WindowListDelete(pParse->db, (yypminor->yy327));
146649 }
146650 break;
146651 case 229: /* using_opt */
146652 case 231: /* idlist */
146653 case 235: /* idlist_opt */
146654 {
146655 sqlite3IdListDelete(pParse->db, (yypminor->yy48));
146656 }
146657 break;
146658 case 237: /* over_opt */
146659 case 268: /* windowdefn */
146660 case 269: /* window */
146661 case 270: /* frame_opt */
146662 {
146663 sqlite3WindowDelete(pParse->db, (yypminor->yy327));
146664 }
146665 break;
146666 case 249: /* trigger_cmd_list */
146667 case 254: /* trigger_cmd */
146668 {
146669 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy207));
146670 }
146671 break;
146672 case 251: /* trigger_event */
146673 {
146674 sqlite3IdListDelete(pParse->db, (yypminor->yy34).b);
146675 }
146676 break;
146677 case 274: /* frame_bound */
146678 case 275: /* frame_bound_s */
146679 case 276: /* frame_bound_e */
146680 {
146681 sqlite3ExprDelete(pParse->db, (yypminor->yy119).pExpr);
146682 }
146683 break;
146684 /********* End destructor definitions *****************************************/
146685 default: break; /* If no destructor action specified: do nothing */
146686 }
@@ -143325,15 +146802,15 @@
146802 yycoverage[stateno][iLookAhead] = 1;
146803 #endif
146804 do{
146805 i = yy_shift_ofst[stateno];
146806 assert( i>=0 );
146807 /* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */
146808 assert( iLookAhead!=YYNOCODE );
146809 assert( iLookAhead < YYNTOKEN );
146810 i += iLookAhead;
146811 if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){
146812 #ifdef YYFALLBACK
146813 YYCODETYPE iFallback; /* Fallback token */
146814 if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
146815 && (iFallback = yyFallback[iLookAhead])!=0 ){
146816 #ifndef NDEBUG
@@ -143355,10 +146832,11 @@
146832 j>=0 &&
146833 #endif
146834 #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
146835 j<YY_ACTTAB_COUNT &&
146836 #endif
146837 j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) &&
146838 yy_lookahead[j]==YYWILDCARD && iLookAhead>0
146839 ){
146840 #ifndef NDEBUG
146841 if( yyTraceFILE ){
146842 fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
@@ -143497,351 +146975,375 @@
146975 */
146976 static const struct {
146977 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
146978 signed char nrhs; /* Negative of the number of RHS symbols in the rule */
146979 } yyRuleInfo[] = {
146980 { 159, -1 }, /* (0) explain ::= EXPLAIN */
146981 { 159, -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */
146982 { 158, -1 }, /* (2) cmdx ::= cmd */
146983 { 160, -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */
146984 { 161, 0 }, /* (4) transtype ::= */
146985 { 161, -1 }, /* (5) transtype ::= DEFERRED */
146986 { 161, -1 }, /* (6) transtype ::= IMMEDIATE */
146987 { 161, -1 }, /* (7) transtype ::= EXCLUSIVE */
146988 { 160, -2 }, /* (8) cmd ::= COMMIT|END trans_opt */
146989 { 160, -2 }, /* (9) cmd ::= ROLLBACK trans_opt */
146990 { 160, -2 }, /* (10) cmd ::= SAVEPOINT nm */
146991 { 160, -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */
146992 { 160, -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
146993 { 165, -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
146994 { 167, -1 }, /* (14) createkw ::= CREATE */
146995 { 169, 0 }, /* (15) ifnotexists ::= */
146996 { 169, -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */
146997 { 168, -1 }, /* (17) temp ::= TEMP */
146998 { 168, 0 }, /* (18) temp ::= */
146999 { 166, -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
147000 { 166, -2 }, /* (20) create_table_args ::= AS select */
147001 { 173, 0 }, /* (21) table_options ::= */
147002 { 173, -2 }, /* (22) table_options ::= WITHOUT nm */
147003 { 175, -2 }, /* (23) columnname ::= nm typetoken */
147004 { 177, 0 }, /* (24) typetoken ::= */
147005 { 177, -4 }, /* (25) typetoken ::= typename LP signed RP */
147006 { 177, -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */
147007 { 178, -2 }, /* (27) typename ::= typename ID|STRING */
147008 { 182, 0 }, /* (28) scanpt ::= */
147009 { 183, -2 }, /* (29) ccons ::= CONSTRAINT nm */
147010 { 183, -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */
147011 { 183, -4 }, /* (31) ccons ::= DEFAULT LP expr RP */
147012 { 183, -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */
147013 { 183, -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */
147014 { 183, -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
147015 { 183, -3 }, /* (35) ccons ::= NOT NULL onconf */
147016 { 183, -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
147017 { 183, -2 }, /* (37) ccons ::= UNIQUE onconf */
147018 { 183, -4 }, /* (38) ccons ::= CHECK LP expr RP */
147019 { 183, -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
147020 { 183, -1 }, /* (40) ccons ::= defer_subclause */
147021 { 183, -2 }, /* (41) ccons ::= COLLATE ID|STRING */
147022 { 188, 0 }, /* (42) autoinc ::= */
147023 { 188, -1 }, /* (43) autoinc ::= AUTOINCR */
147024 { 190, 0 }, /* (44) refargs ::= */
147025 { 190, -2 }, /* (45) refargs ::= refargs refarg */
147026 { 192, -2 }, /* (46) refarg ::= MATCH nm */
147027 { 192, -3 }, /* (47) refarg ::= ON INSERT refact */
147028 { 192, -3 }, /* (48) refarg ::= ON DELETE refact */
147029 { 192, -3 }, /* (49) refarg ::= ON UPDATE refact */
147030 { 193, -2 }, /* (50) refact ::= SET NULL */
147031 { 193, -2 }, /* (51) refact ::= SET DEFAULT */
147032 { 193, -1 }, /* (52) refact ::= CASCADE */
147033 { 193, -1 }, /* (53) refact ::= RESTRICT */
147034 { 193, -2 }, /* (54) refact ::= NO ACTION */
147035 { 191, -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
147036 { 191, -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
147037 { 194, 0 }, /* (57) init_deferred_pred_opt ::= */
147038 { 194, -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
147039 { 194, -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
147040 { 172, 0 }, /* (60) conslist_opt ::= */
147041 { 196, -1 }, /* (61) tconscomma ::= COMMA */
147042 { 197, -2 }, /* (62) tcons ::= CONSTRAINT nm */
147043 { 197, -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
147044 { 197, -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
147045 { 197, -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */
147046 { 197, -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
147047 { 200, 0 }, /* (67) defer_subclause_opt ::= */
147048 { 186, 0 }, /* (68) onconf ::= */
147049 { 186, -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */
147050 { 201, 0 }, /* (70) orconf ::= */
147051 { 201, -2 }, /* (71) orconf ::= OR resolvetype */
147052 { 202, -1 }, /* (72) resolvetype ::= IGNORE */
147053 { 202, -1 }, /* (73) resolvetype ::= REPLACE */
147054 { 160, -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
147055 { 204, -2 }, /* (75) ifexists ::= IF EXISTS */
147056 { 204, 0 }, /* (76) ifexists ::= */
147057 { 160, -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
147058 { 160, -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
147059 { 160, -1 }, /* (79) cmd ::= select */
147060 { 174, -3 }, /* (80) select ::= WITH wqlist selectnowith */
147061 { 174, -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
147062 { 174, -1 }, /* (82) select ::= selectnowith */
147063 { 206, -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
147064 { 209, -1 }, /* (84) multiselect_op ::= UNION */
147065 { 209, -2 }, /* (85) multiselect_op ::= UNION ALL */
147066 { 209, -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
147067 { 207, -10 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt windowdefn_opt orderby_opt limit_opt */
147068 { 219, -4 }, /* (88) values ::= VALUES LP nexprlist RP */
147069 { 219, -5 }, /* (89) values ::= values COMMA LP exprlist RP */
147070 { 210, -1 }, /* (90) distinct ::= DISTINCT */
147071 { 210, -1 }, /* (91) distinct ::= ALL */
147072 { 210, 0 }, /* (92) distinct ::= */
147073 { 222, 0 }, /* (93) sclp ::= */
147074 { 211, -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
147075 { 211, -3 }, /* (95) selcollist ::= sclp scanpt STAR */
147076 { 211, -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
147077 { 223, -2 }, /* (97) as ::= AS nm */
147078 { 223, 0 }, /* (98) as ::= */
147079 { 212, 0 }, /* (99) from ::= */
147080 { 212, -2 }, /* (100) from ::= FROM seltablist */
147081 { 225, -2 }, /* (101) stl_prefix ::= seltablist joinop */
147082 { 225, 0 }, /* (102) stl_prefix ::= */
147083 { 224, -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
147084 { 224, -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
147085 { 224, -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
147086 { 224, -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
147087 { 170, 0 }, /* (107) dbnm ::= */
147088 { 170, -2 }, /* (108) dbnm ::= DOT nm */
147089 { 205, -1 }, /* (109) fullname ::= nm */
147090 { 205, -3 }, /* (110) fullname ::= nm DOT nm */
147091 { 230, -1 }, /* (111) xfullname ::= nm */
147092 { 230, -3 }, /* (112) xfullname ::= nm DOT nm */
147093 { 230, -5 }, /* (113) xfullname ::= nm DOT nm AS nm */
147094 { 230, -3 }, /* (114) xfullname ::= nm AS nm */
147095 { 226, -1 }, /* (115) joinop ::= COMMA|JOIN */
147096 { 226, -2 }, /* (116) joinop ::= JOIN_KW JOIN */
147097 { 226, -3 }, /* (117) joinop ::= JOIN_KW nm JOIN */
147098 { 226, -4 }, /* (118) joinop ::= JOIN_KW nm nm JOIN */
147099 { 228, -2 }, /* (119) on_opt ::= ON expr */
147100 { 228, 0 }, /* (120) on_opt ::= */
147101 { 227, 0 }, /* (121) indexed_opt ::= */
147102 { 227, -3 }, /* (122) indexed_opt ::= INDEXED BY nm */
147103 { 227, -2 }, /* (123) indexed_opt ::= NOT INDEXED */
147104 { 229, -4 }, /* (124) using_opt ::= USING LP idlist RP */
147105 { 229, 0 }, /* (125) using_opt ::= */
147106 { 217, 0 }, /* (126) orderby_opt ::= */
147107 { 217, -3 }, /* (127) orderby_opt ::= ORDER BY sortlist */
147108 { 198, -4 }, /* (128) sortlist ::= sortlist COMMA expr sortorder */
147109 { 198, -2 }, /* (129) sortlist ::= expr sortorder */
147110 { 187, -1 }, /* (130) sortorder ::= ASC */
147111 { 187, -1 }, /* (131) sortorder ::= DESC */
147112 { 187, 0 }, /* (132) sortorder ::= */
147113 { 214, 0 }, /* (133) groupby_opt ::= */
147114 { 214, -3 }, /* (134) groupby_opt ::= GROUP BY nexprlist */
147115 { 215, 0 }, /* (135) having_opt ::= */
147116 { 215, -2 }, /* (136) having_opt ::= HAVING expr */
147117 { 218, 0 }, /* (137) limit_opt ::= */
147118 { 218, -2 }, /* (138) limit_opt ::= LIMIT expr */
147119 { 218, -4 }, /* (139) limit_opt ::= LIMIT expr OFFSET expr */
147120 { 218, -4 }, /* (140) limit_opt ::= LIMIT expr COMMA expr */
147121 { 160, -6 }, /* (141) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
147122 { 213, 0 }, /* (142) where_opt ::= */
147123 { 213, -2 }, /* (143) where_opt ::= WHERE expr */
147124 { 160, -8 }, /* (144) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
147125 { 233, -5 }, /* (145) setlist ::= setlist COMMA nm EQ expr */
147126 { 233, -7 }, /* (146) setlist ::= setlist COMMA LP idlist RP EQ expr */
147127 { 233, -3 }, /* (147) setlist ::= nm EQ expr */
147128 { 233, -5 }, /* (148) setlist ::= LP idlist RP EQ expr */
147129 { 160, -7 }, /* (149) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
147130 { 160, -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
147131 { 236, 0 }, /* (151) upsert ::= */
147132 { 236, -11 }, /* (152) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
147133 { 236, -8 }, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
147134 { 236, -4 }, /* (154) upsert ::= ON CONFLICT DO NOTHING */
147135 { 234, -2 }, /* (155) insert_cmd ::= INSERT orconf */
147136 { 234, -1 }, /* (156) insert_cmd ::= REPLACE */
147137 { 235, 0 }, /* (157) idlist_opt ::= */
147138 { 235, -3 }, /* (158) idlist_opt ::= LP idlist RP */
147139 { 231, -3 }, /* (159) idlist ::= idlist COMMA nm */
147140 { 231, -1 }, /* (160) idlist ::= nm */
147141 { 185, -3 }, /* (161) expr ::= LP expr RP */
147142 { 185, -1 }, /* (162) expr ::= ID|INDEXED */
147143 { 185, -1 }, /* (163) expr ::= JOIN_KW */
147144 { 185, -3 }, /* (164) expr ::= nm DOT nm */
147145 { 185, -5 }, /* (165) expr ::= nm DOT nm DOT nm */
147146 { 184, -1 }, /* (166) term ::= NULL|FLOAT|BLOB */
147147 { 184, -1 }, /* (167) term ::= STRING */
147148 { 184, -1 }, /* (168) term ::= INTEGER */
147149 { 185, -1 }, /* (169) expr ::= VARIABLE */
147150 { 185, -3 }, /* (170) expr ::= expr COLLATE ID|STRING */
147151 { 185, -6 }, /* (171) expr ::= CAST LP expr AS typetoken RP */
147152 { 185, -6 }, /* (172) expr ::= ID|INDEXED LP distinct exprlist RP over_opt */
147153 { 185, -5 }, /* (173) expr ::= ID|INDEXED LP STAR RP over_opt */
147154 { 184, -1 }, /* (174) term ::= CTIME_KW */
147155 { 185, -5 }, /* (175) expr ::= LP nexprlist COMMA expr RP */
147156 { 185, -3 }, /* (176) expr ::= expr AND expr */
147157 { 185, -3 }, /* (177) expr ::= expr OR expr */
147158 { 185, -3 }, /* (178) expr ::= expr LT|GT|GE|LE expr */
147159 { 185, -3 }, /* (179) expr ::= expr EQ|NE expr */
147160 { 185, -3 }, /* (180) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
147161 { 185, -3 }, /* (181) expr ::= expr PLUS|MINUS expr */
147162 { 185, -3 }, /* (182) expr ::= expr STAR|SLASH|REM expr */
147163 { 185, -3 }, /* (183) expr ::= expr CONCAT expr */
147164 { 238, -2 }, /* (184) likeop ::= NOT LIKE_KW|MATCH */
147165 { 185, -3 }, /* (185) expr ::= expr likeop expr */
147166 { 185, -5 }, /* (186) expr ::= expr likeop expr ESCAPE expr */
147167 { 185, -2 }, /* (187) expr ::= expr ISNULL|NOTNULL */
147168 { 185, -3 }, /* (188) expr ::= expr NOT NULL */
147169 { 185, -3 }, /* (189) expr ::= expr IS expr */
147170 { 185, -4 }, /* (190) expr ::= expr IS NOT expr */
147171 { 185, -2 }, /* (191) expr ::= NOT expr */
147172 { 185, -2 }, /* (192) expr ::= BITNOT expr */
147173 { 185, -2 }, /* (193) expr ::= PLUS|MINUS expr */
147174 { 239, -1 }, /* (194) between_op ::= BETWEEN */
147175 { 239, -2 }, /* (195) between_op ::= NOT BETWEEN */
147176 { 185, -5 }, /* (196) expr ::= expr between_op expr AND expr */
147177 { 240, -1 }, /* (197) in_op ::= IN */
147178 { 240, -2 }, /* (198) in_op ::= NOT IN */
147179 { 185, -5 }, /* (199) expr ::= expr in_op LP exprlist RP */
147180 { 185, -3 }, /* (200) expr ::= LP select RP */
147181 { 185, -5 }, /* (201) expr ::= expr in_op LP select RP */
147182 { 185, -5 }, /* (202) expr ::= expr in_op nm dbnm paren_exprlist */
147183 { 185, -4 }, /* (203) expr ::= EXISTS LP select RP */
147184 { 185, -5 }, /* (204) expr ::= CASE case_operand case_exprlist case_else END */
147185 { 243, -5 }, /* (205) case_exprlist ::= case_exprlist WHEN expr THEN expr */
147186 { 243, -4 }, /* (206) case_exprlist ::= WHEN expr THEN expr */
147187 { 244, -2 }, /* (207) case_else ::= ELSE expr */
147188 { 244, 0 }, /* (208) case_else ::= */
147189 { 242, -1 }, /* (209) case_operand ::= expr */
147190 { 242, 0 }, /* (210) case_operand ::= */
147191 { 221, 0 }, /* (211) exprlist ::= */
147192 { 220, -3 }, /* (212) nexprlist ::= nexprlist COMMA expr */
147193 { 220, -1 }, /* (213) nexprlist ::= expr */
147194 { 241, 0 }, /* (214) paren_exprlist ::= */
147195 { 241, -3 }, /* (215) paren_exprlist ::= LP exprlist RP */
147196 { 160, -12 }, /* (216) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
147197 { 245, -1 }, /* (217) uniqueflag ::= UNIQUE */
147198 { 245, 0 }, /* (218) uniqueflag ::= */
147199 { 189, 0 }, /* (219) eidlist_opt ::= */
147200 { 189, -3 }, /* (220) eidlist_opt ::= LP eidlist RP */
147201 { 199, -5 }, /* (221) eidlist ::= eidlist COMMA nm collate sortorder */
147202 { 199, -3 }, /* (222) eidlist ::= nm collate sortorder */
147203 { 246, 0 }, /* (223) collate ::= */
147204 { 246, -2 }, /* (224) collate ::= COLLATE ID|STRING */
147205 { 160, -4 }, /* (225) cmd ::= DROP INDEX ifexists fullname */
147206 { 160, -1 }, /* (226) cmd ::= VACUUM */
147207 { 160, -2 }, /* (227) cmd ::= VACUUM nm */
147208 { 160, -3 }, /* (228) cmd ::= PRAGMA nm dbnm */
147209 { 160, -5 }, /* (229) cmd ::= PRAGMA nm dbnm EQ nmnum */
147210 { 160, -6 }, /* (230) cmd ::= PRAGMA nm dbnm LP nmnum RP */
147211 { 160, -5 }, /* (231) cmd ::= PRAGMA nm dbnm EQ minus_num */
147212 { 160, -6 }, /* (232) cmd ::= PRAGMA nm dbnm LP minus_num RP */
147213 { 180, -2 }, /* (233) plus_num ::= PLUS INTEGER|FLOAT */
147214 { 181, -2 }, /* (234) minus_num ::= MINUS INTEGER|FLOAT */
147215 { 160, -5 }, /* (235) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
147216 { 248, -11 }, /* (236) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
147217 { 250, -1 }, /* (237) trigger_time ::= BEFORE|AFTER */
147218 { 250, -2 }, /* (238) trigger_time ::= INSTEAD OF */
147219 { 250, 0 }, /* (239) trigger_time ::= */
147220 { 251, -1 }, /* (240) trigger_event ::= DELETE|INSERT */
147221 { 251, -1 }, /* (241) trigger_event ::= UPDATE */
147222 { 251, -3 }, /* (242) trigger_event ::= UPDATE OF idlist */
147223 { 253, 0 }, /* (243) when_clause ::= */
147224 { 253, -2 }, /* (244) when_clause ::= WHEN expr */
147225 { 249, -3 }, /* (245) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
147226 { 249, -2 }, /* (246) trigger_cmd_list ::= trigger_cmd SEMI */
147227 { 255, -3 }, /* (247) trnm ::= nm DOT nm */
147228 { 256, -3 }, /* (248) tridxby ::= INDEXED BY nm */
147229 { 256, -2 }, /* (249) tridxby ::= NOT INDEXED */
147230 { 254, -8 }, /* (250) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
147231 { 254, -8 }, /* (251) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
147232 { 254, -6 }, /* (252) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
147233 { 254, -3 }, /* (253) trigger_cmd ::= scanpt select scanpt */
147234 { 185, -4 }, /* (254) expr ::= RAISE LP IGNORE RP */
147235 { 185, -6 }, /* (255) expr ::= RAISE LP raisetype COMMA nm RP */
147236 { 203, -1 }, /* (256) raisetype ::= ROLLBACK */
147237 { 203, -1 }, /* (257) raisetype ::= ABORT */
147238 { 203, -1 }, /* (258) raisetype ::= FAIL */
147239 { 160, -4 }, /* (259) cmd ::= DROP TRIGGER ifexists fullname */
147240 { 160, -6 }, /* (260) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
147241 { 160, -3 }, /* (261) cmd ::= DETACH database_kw_opt expr */
147242 { 258, 0 }, /* (262) key_opt ::= */
147243 { 258, -2 }, /* (263) key_opt ::= KEY expr */
147244 { 160, -1 }, /* (264) cmd ::= REINDEX */
147245 { 160, -3 }, /* (265) cmd ::= REINDEX nm dbnm */
147246 { 160, -1 }, /* (266) cmd ::= ANALYZE */
147247 { 160, -3 }, /* (267) cmd ::= ANALYZE nm dbnm */
147248 { 160, -6 }, /* (268) cmd ::= ALTER TABLE fullname RENAME TO nm */
147249 { 160, -7 }, /* (269) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
147250 { 259, -1 }, /* (270) add_column_fullname ::= fullname */
147251 { 160, -1 }, /* (271) cmd ::= create_vtab */
147252 { 160, -4 }, /* (272) cmd ::= create_vtab LP vtabarglist RP */
147253 { 261, -8 }, /* (273) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
147254 { 263, 0 }, /* (274) vtabarg ::= */
147255 { 264, -1 }, /* (275) vtabargtoken ::= ANY */
147256 { 264, -3 }, /* (276) vtabargtoken ::= lp anylist RP */
147257 { 265, -1 }, /* (277) lp ::= LP */
147258 { 232, -2 }, /* (278) with ::= WITH wqlist */
147259 { 232, -3 }, /* (279) with ::= WITH RECURSIVE wqlist */
147260 { 208, -6 }, /* (280) wqlist ::= nm eidlist_opt AS LP select RP */
147261 { 208, -8 }, /* (281) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
147262 { 267, -1 }, /* (282) windowdefn_list ::= windowdefn */
147263 { 267, -3 }, /* (283) windowdefn_list ::= windowdefn_list COMMA windowdefn */
147264 { 268, -3 }, /* (284) windowdefn ::= nm AS window */
147265 { 269, -5 }, /* (285) window ::= LP part_opt orderby_opt frame_opt RP */
147266 { 271, -3 }, /* (286) part_opt ::= PARTITION BY exprlist */
147267 { 271, 0 }, /* (287) part_opt ::= */
147268 { 270, 0 }, /* (288) frame_opt ::= */
147269 { 270, -2 }, /* (289) frame_opt ::= range_or_rows frame_bound_s */
147270 { 270, -5 }, /* (290) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
147271 { 273, -1 }, /* (291) range_or_rows ::= RANGE */
147272 { 273, -1 }, /* (292) range_or_rows ::= ROWS */
147273 { 275, -1 }, /* (293) frame_bound_s ::= frame_bound */
147274 { 275, -2 }, /* (294) frame_bound_s ::= UNBOUNDED PRECEDING */
147275 { 276, -1 }, /* (295) frame_bound_e ::= frame_bound */
147276 { 276, -2 }, /* (296) frame_bound_e ::= UNBOUNDED FOLLOWING */
147277 { 274, -2 }, /* (297) frame_bound ::= expr PRECEDING */
147278 { 274, -2 }, /* (298) frame_bound ::= CURRENT ROW */
147279 { 274, -2 }, /* (299) frame_bound ::= expr FOLLOWING */
147280 { 216, 0 }, /* (300) windowdefn_opt ::= */
147281 { 216, -2 }, /* (301) windowdefn_opt ::= WINDOW windowdefn_list */
147282 { 237, 0 }, /* (302) over_opt ::= */
147283 { 237, -3 }, /* (303) over_opt ::= filter_opt OVER window */
147284 { 237, -3 }, /* (304) over_opt ::= filter_opt OVER nm */
147285 { 272, 0 }, /* (305) filter_opt ::= */
147286 { 272, -5 }, /* (306) filter_opt ::= FILTER LP WHERE expr RP */
147287 { 155, -1 }, /* (307) input ::= cmdlist */
147288 { 156, -2 }, /* (308) cmdlist ::= cmdlist ecmd */
147289 { 156, -1 }, /* (309) cmdlist ::= ecmd */
147290 { 157, -1 }, /* (310) ecmd ::= SEMI */
147291 { 157, -2 }, /* (311) ecmd ::= cmdx SEMI */
147292 { 157, -2 }, /* (312) ecmd ::= explain cmdx */
147293 { 162, 0 }, /* (313) trans_opt ::= */
147294 { 162, -1 }, /* (314) trans_opt ::= TRANSACTION */
147295 { 162, -2 }, /* (315) trans_opt ::= TRANSACTION nm */
147296 { 164, -1 }, /* (316) savepoint_opt ::= SAVEPOINT */
147297 { 164, 0 }, /* (317) savepoint_opt ::= */
147298 { 160, -2 }, /* (318) cmd ::= create_table create_table_args */
147299 { 171, -4 }, /* (319) columnlist ::= columnlist COMMA columnname carglist */
147300 { 171, -2 }, /* (320) columnlist ::= columnname carglist */
147301 { 163, -1 }, /* (321) nm ::= ID|INDEXED */
147302 { 163, -1 }, /* (322) nm ::= STRING */
147303 { 163, -1 }, /* (323) nm ::= JOIN_KW */
147304 { 177, -1 }, /* (324) typetoken ::= typename */
147305 { 178, -1 }, /* (325) typename ::= ID|STRING */
147306 { 179, -1 }, /* (326) signed ::= plus_num */
147307 { 179, -1 }, /* (327) signed ::= minus_num */
147308 { 176, -2 }, /* (328) carglist ::= carglist ccons */
147309 { 176, 0 }, /* (329) carglist ::= */
147310 { 183, -2 }, /* (330) ccons ::= NULL onconf */
147311 { 172, -2 }, /* (331) conslist_opt ::= COMMA conslist */
147312 { 195, -3 }, /* (332) conslist ::= conslist tconscomma tcons */
147313 { 195, -1 }, /* (333) conslist ::= tcons */
147314 { 196, 0 }, /* (334) tconscomma ::= */
147315 { 200, -1 }, /* (335) defer_subclause_opt ::= defer_subclause */
147316 { 202, -1 }, /* (336) resolvetype ::= raisetype */
147317 { 206, -1 }, /* (337) selectnowith ::= oneselect */
147318 { 207, -1 }, /* (338) oneselect ::= values */
147319 { 222, -2 }, /* (339) sclp ::= selcollist COMMA */
147320 { 223, -1 }, /* (340) as ::= ID|STRING */
147321 { 185, -1 }, /* (341) expr ::= term */
147322 { 238, -1 }, /* (342) likeop ::= LIKE_KW|MATCH */
147323 { 221, -1 }, /* (343) exprlist ::= nexprlist */
147324 { 247, -1 }, /* (344) nmnum ::= plus_num */
147325 { 247, -1 }, /* (345) nmnum ::= nm */
147326 { 247, -1 }, /* (346) nmnum ::= ON */
147327 { 247, -1 }, /* (347) nmnum ::= DELETE */
147328 { 247, -1 }, /* (348) nmnum ::= DEFAULT */
147329 { 180, -1 }, /* (349) plus_num ::= INTEGER|FLOAT */
147330 { 252, 0 }, /* (350) foreach_clause ::= */
147331 { 252, -3 }, /* (351) foreach_clause ::= FOR EACH ROW */
147332 { 255, -1 }, /* (352) trnm ::= nm */
147333 { 256, 0 }, /* (353) tridxby ::= */
147334 { 257, -1 }, /* (354) database_kw_opt ::= DATABASE */
147335 { 257, 0 }, /* (355) database_kw_opt ::= */
147336 { 260, 0 }, /* (356) kwcolumn_opt ::= */
147337 { 260, -1 }, /* (357) kwcolumn_opt ::= COLUMNKW */
147338 { 262, -1 }, /* (358) vtabarglist ::= vtabarg */
147339 { 262, -3 }, /* (359) vtabarglist ::= vtabarglist COMMA vtabarg */
147340 { 263, -2 }, /* (360) vtabarg ::= vtabarg vtabargtoken */
147341 { 266, 0 }, /* (361) anylist ::= */
147342 { 266, -4 }, /* (362) anylist ::= anylist LP anylist RP */
147343 { 266, -2 }, /* (363) anylist ::= anylist ANY */
147344 { 232, 0 }, /* (364) with ::= */
147345 };
147346
147347 static void yy_accept(yyParser*); /* Forward Declaration */
147348
147349 /*
@@ -143934,19 +147436,19 @@
147436 break;
147437 case 2: /* cmdx ::= cmd */
147438 { sqlite3FinishCoding(pParse); }
147439 break;
147440 case 3: /* cmd ::= BEGIN transtype trans_opt */
147441 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy70);}
147442 break;
147443 case 4: /* transtype ::= */
147444 {yymsp[1].minor.yy70 = TK_DEFERRED;}
147445 break;
147446 case 5: /* transtype ::= DEFERRED */
147447 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
147448 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
147449 {yymsp[0].minor.yy70 = yymsp[0].major; /*A-overwrites-X*/}
147450 break;
147451 case 8: /* cmd ::= COMMIT|END trans_opt */
147452 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
147453 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
147454 break;
@@ -143965,11 +147467,11 @@
147467 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
147468 }
147469 break;
147470 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
147471 {
147472 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy70,0,0,yymsp[-2].minor.yy70);
147473 }
147474 break;
147475 case 14: /* createkw ::= CREATE */
147476 {disableLookaside(pParse);}
147477 break;
@@ -143979,37 +147481,37 @@
147481 case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
147482 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
147483 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
147484 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
147485 case 92: /* distinct ::= */ yytestcase(yyruleno==92);
147486 case 223: /* collate ::= */ yytestcase(yyruleno==223);
147487 {yymsp[1].minor.yy70 = 0;}
147488 break;
147489 case 16: /* ifnotexists ::= IF NOT EXISTS */
147490 {yymsp[-2].minor.yy70 = 1;}
147491 break;
147492 case 17: /* temp ::= TEMP */
147493 case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
147494 {yymsp[0].minor.yy70 = 1;}
147495 break;
147496 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
147497 {
147498 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy70,0);
147499 }
147500 break;
147501 case 20: /* create_table_args ::= AS select */
147502 {
147503 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy489);
147504 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy489);
147505 }
147506 break;
147507 case 22: /* table_options ::= WITHOUT nm */
147508 {
147509 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
147510 yymsp[-1].minor.yy70 = TF_WithoutRowid | TF_NoVisibleRowid;
147511 }else{
147512 yymsp[-1].minor.yy70 = 0;
147513 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
147514 }
147515 }
147516 break;
147517 case 23: /* columnname ::= nm typetoken */
@@ -144034,30 +147536,30 @@
147536 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
147537 break;
147538 case 28: /* scanpt ::= */
147539 {
147540 assert( yyLookahead!=YYNOCODE );
147541 yymsp[1].minor.yy392 = yyLookaheadToken.z;
147542 }
147543 break;
147544 case 29: /* ccons ::= CONSTRAINT nm */
147545 case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
147546 {pParse->constraintName = yymsp[0].minor.yy0;}
147547 break;
147548 case 30: /* ccons ::= DEFAULT scanpt term scanpt */
147549 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy18,yymsp[-2].minor.yy392,yymsp[0].minor.yy392);}
147550 break;
147551 case 31: /* ccons ::= DEFAULT LP expr RP */
147552 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy18,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
147553 break;
147554 case 32: /* ccons ::= DEFAULT PLUS term scanpt */
147555 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy18,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy392);}
147556 break;
147557 case 33: /* ccons ::= DEFAULT MINUS term scanpt */
147558 {
147559 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy18, 0);
147560 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy392);
147561 }
147562 break;
147563 case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */
147564 {
147565 Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
@@ -144067,612 +147569,595 @@
147569 }
147570 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
147571 }
147572 break;
147573 case 35: /* ccons ::= NOT NULL onconf */
147574 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy70);}
147575 break;
147576 case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
147577 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy70,yymsp[0].minor.yy70,yymsp[-2].minor.yy70);}
147578 break;
147579 case 37: /* ccons ::= UNIQUE onconf */
147580 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy70,0,0,0,0,
147581 SQLITE_IDXTYPE_UNIQUE);}
147582 break;
147583 case 38: /* ccons ::= CHECK LP expr RP */
147584 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy18);}
147585 break;
147586 case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
147587 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy420,yymsp[0].minor.yy70);}
147588 break;
147589 case 40: /* ccons ::= defer_subclause */
147590 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy70);}
147591 break;
147592 case 41: /* ccons ::= COLLATE ID|STRING */
147593 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
147594 break;
147595 case 44: /* refargs ::= */
147596 { yymsp[1].minor.yy70 = OE_None*0x0101; /* EV: R-19803-45884 */}
147597 break;
147598 case 45: /* refargs ::= refargs refarg */
147599 { yymsp[-1].minor.yy70 = (yymsp[-1].minor.yy70 & ~yymsp[0].minor.yy111.mask) | yymsp[0].minor.yy111.value; }
147600 break;
147601 case 46: /* refarg ::= MATCH nm */
147602 { yymsp[-1].minor.yy111.value = 0; yymsp[-1].minor.yy111.mask = 0x000000; }
147603 break;
147604 case 47: /* refarg ::= ON INSERT refact */
147605 { yymsp[-2].minor.yy111.value = 0; yymsp[-2].minor.yy111.mask = 0x000000; }
147606 break;
147607 case 48: /* refarg ::= ON DELETE refact */
147608 { yymsp[-2].minor.yy111.value = yymsp[0].minor.yy70; yymsp[-2].minor.yy111.mask = 0x0000ff; }
147609 break;
147610 case 49: /* refarg ::= ON UPDATE refact */
147611 { yymsp[-2].minor.yy111.value = yymsp[0].minor.yy70<<8; yymsp[-2].minor.yy111.mask = 0x00ff00; }
147612 break;
147613 case 50: /* refact ::= SET NULL */
147614 { yymsp[-1].minor.yy70 = OE_SetNull; /* EV: R-33326-45252 */}
147615 break;
147616 case 51: /* refact ::= SET DEFAULT */
147617 { yymsp[-1].minor.yy70 = OE_SetDflt; /* EV: R-33326-45252 */}
147618 break;
147619 case 52: /* refact ::= CASCADE */
147620 { yymsp[0].minor.yy70 = OE_Cascade; /* EV: R-33326-45252 */}
147621 break;
147622 case 53: /* refact ::= RESTRICT */
147623 { yymsp[0].minor.yy70 = OE_Restrict; /* EV: R-33326-45252 */}
147624 break;
147625 case 54: /* refact ::= NO ACTION */
147626 { yymsp[-1].minor.yy70 = OE_None; /* EV: R-33326-45252 */}
147627 break;
147628 case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
147629 {yymsp[-2].minor.yy70 = 0;}
147630 break;
147631 case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
147632 case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
147633 case 155: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==155);
147634 {yymsp[-1].minor.yy70 = yymsp[0].minor.yy70;}
147635 break;
147636 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
147637 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
147638 case 195: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==195);
147639 case 198: /* in_op ::= NOT IN */ yytestcase(yyruleno==198);
147640 case 224: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==224);
147641 {yymsp[-1].minor.yy70 = 1;}
147642 break;
147643 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
147644 {yymsp[-1].minor.yy70 = 0;}
147645 break;
147646 case 61: /* tconscomma ::= COMMA */
147647 {pParse->constraintName.n = 0;}
147648 break;
147649 case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
147650 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy420,yymsp[0].minor.yy70,yymsp[-2].minor.yy70,0);}
147651 break;
147652 case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
147653 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy420,yymsp[0].minor.yy70,0,0,0,0,
147654 SQLITE_IDXTYPE_UNIQUE);}
147655 break;
147656 case 65: /* tcons ::= CHECK LP expr RP onconf */
147657 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy18);}
147658 break;
147659 case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
147660 {
147661 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy420, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy420, yymsp[-1].minor.yy70);
147662 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy70);
147663 }
147664 break;
147665 case 68: /* onconf ::= */
147666 case 70: /* orconf ::= */ yytestcase(yyruleno==70);
147667 {yymsp[1].minor.yy70 = OE_Default;}
147668 break;
147669 case 69: /* onconf ::= ON CONFLICT resolvetype */
147670 {yymsp[-2].minor.yy70 = yymsp[0].minor.yy70;}
147671 break;
147672 case 72: /* resolvetype ::= IGNORE */
147673 {yymsp[0].minor.yy70 = OE_Ignore;}
147674 break;
147675 case 73: /* resolvetype ::= REPLACE */
147676 case 156: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==156);
147677 {yymsp[0].minor.yy70 = OE_Replace;}
147678 break;
147679 case 74: /* cmd ::= DROP TABLE ifexists fullname */
147680 {
147681 sqlite3DropTable(pParse, yymsp[0].minor.yy135, 0, yymsp[-1].minor.yy70);
147682 }
147683 break;
147684 case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
147685 {
147686 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy420, yymsp[0].minor.yy489, yymsp[-7].minor.yy70, yymsp[-5].minor.yy70);
147687 }
147688 break;
147689 case 78: /* cmd ::= DROP VIEW ifexists fullname */
147690 {
147691 sqlite3DropTable(pParse, yymsp[0].minor.yy135, 1, yymsp[-1].minor.yy70);
147692 }
147693 break;
147694 case 79: /* cmd ::= select */
147695 {
147696 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
147697 sqlite3Select(pParse, yymsp[0].minor.yy489, &dest);
147698 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy489);
147699 }
147700 break;
147701 case 80: /* select ::= WITH wqlist selectnowith */
147702 {
147703 Select *p = yymsp[0].minor.yy489;
147704 if( p ){
147705 p->pWith = yymsp[-1].minor.yy449;
147706 parserDoubleLinkSelect(pParse, p);
147707 }else{
147708 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy449);
147709 }
147710 yymsp[-2].minor.yy489 = p;
147711 }
147712 break;
147713 case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */
147714 {
147715 Select *p = yymsp[0].minor.yy489;
147716 if( p ){
147717 p->pWith = yymsp[-1].minor.yy449;
147718 parserDoubleLinkSelect(pParse, p);
147719 }else{
147720 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy449);
147721 }
147722 yymsp[-3].minor.yy489 = p;
147723 }
147724 break;
147725 case 82: /* select ::= selectnowith */
147726 {
147727 Select *p = yymsp[0].minor.yy489;
147728 if( p ){
147729 parserDoubleLinkSelect(pParse, p);
147730 }
147731 yymsp[0].minor.yy489 = p; /*A-overwrites-X*/
147732 }
147733 break;
147734 case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */
147735 {
147736 Select *pRhs = yymsp[0].minor.yy489;
147737 Select *pLhs = yymsp[-2].minor.yy489;
147738 if( pRhs && pRhs->pPrior ){
147739 SrcList *pFrom;
147740 Token x;
147741 x.n = 0;
147742 parserDoubleLinkSelect(pParse, pRhs);
147743 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
147744 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
147745 }
147746 if( pRhs ){
147747 pRhs->op = (u8)yymsp[-1].minor.yy70;
147748 pRhs->pPrior = pLhs;
147749 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
147750 pRhs->selFlags &= ~SF_MultiValue;
147751 if( yymsp[-1].minor.yy70!=TK_ALL ) pParse->hasCompound = 1;
147752 }else{
147753 sqlite3SelectDelete(pParse->db, pLhs);
147754 }
147755 yymsp[-2].minor.yy489 = pRhs;
147756 }
147757 break;
147758 case 84: /* multiselect_op ::= UNION */
147759 case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
147760 {yymsp[0].minor.yy70 = yymsp[0].major; /*A-overwrites-OP*/}
147761 break;
147762 case 85: /* multiselect_op ::= UNION ALL */
147763 {yymsp[-1].minor.yy70 = TK_ALL;}
147764 break;
147765 case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt windowdefn_opt orderby_opt limit_opt */
147766 {
147767 yymsp[-9].minor.yy489 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy420,yymsp[-6].minor.yy135,yymsp[-5].minor.yy18,yymsp[-4].minor.yy420,yymsp[-3].minor.yy18,yymsp[-1].minor.yy420,yymsp[-8].minor.yy70,yymsp[0].minor.yy18);
147768 #ifndef SQLITE_OMIT_WINDOWFUNC
147769 if( yymsp[-9].minor.yy489 ){
147770 yymsp[-9].minor.yy489->pWinDefn = yymsp[-2].minor.yy327;
147771 }else{
147772 sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy327);
147773 }
147774 #endif /* SQLITE_OMIT_WINDOWFUNC */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147775 }
147776 break;
147777 case 88: /* values ::= VALUES LP nexprlist RP */
147778 {
147779 yymsp[-3].minor.yy489 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy420,0,0,0,0,0,SF_Values,0);
147780 }
147781 break;
147782 case 89: /* values ::= values COMMA LP exprlist RP */
147783 {
147784 Select *pRight, *pLeft = yymsp[-4].minor.yy489;
147785 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy420,0,0,0,0,0,SF_Values|SF_MultiValue,0);
147786 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
147787 if( pRight ){
147788 pRight->op = TK_ALL;
147789 pRight->pPrior = pLeft;
147790 yymsp[-4].minor.yy489 = pRight;
147791 }else{
147792 yymsp[-4].minor.yy489 = pLeft;
147793 }
147794 }
147795 break;
147796 case 90: /* distinct ::= DISTINCT */
147797 {yymsp[0].minor.yy70 = SF_Distinct;}
147798 break;
147799 case 91: /* distinct ::= ALL */
147800 {yymsp[0].minor.yy70 = SF_All;}
147801 break;
147802 case 93: /* sclp ::= */
147803 case 126: /* orderby_opt ::= */ yytestcase(yyruleno==126);
147804 case 133: /* groupby_opt ::= */ yytestcase(yyruleno==133);
147805 case 211: /* exprlist ::= */ yytestcase(yyruleno==211);
147806 case 214: /* paren_exprlist ::= */ yytestcase(yyruleno==214);
147807 case 219: /* eidlist_opt ::= */ yytestcase(yyruleno==219);
147808 {yymsp[1].minor.yy420 = 0;}
147809 break;
147810 case 94: /* selcollist ::= sclp scanpt expr scanpt as */
147811 {
147812 yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy420, yymsp[-2].minor.yy18);
147813 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy420, &yymsp[0].minor.yy0, 1);
147814 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy420,yymsp[-3].minor.yy392,yymsp[-1].minor.yy392);
147815 }
147816 break;
147817 case 95: /* selcollist ::= sclp scanpt STAR */
147818 {
147819 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
147820 yymsp[-2].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy420, p);
147821 }
147822 break;
147823 case 96: /* selcollist ::= sclp scanpt nm DOT STAR */
147824 {
147825 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
147826 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
147827 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
147828 yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, pDot);
147829 }
147830 break;
147831 case 97: /* as ::= AS nm */
147832 case 108: /* dbnm ::= DOT nm */ yytestcase(yyruleno==108);
147833 case 233: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==233);
147834 case 234: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==234);
147835 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
147836 break;
147837 case 99: /* from ::= */
147838 {yymsp[1].minor.yy135 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy135));}
147839 break;
147840 case 100: /* from ::= FROM seltablist */
147841 {
147842 yymsp[-1].minor.yy135 = yymsp[0].minor.yy135;
147843 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy135);
147844 }
147845 break;
147846 case 101: /* stl_prefix ::= seltablist joinop */
147847 {
147848 if( ALWAYS(yymsp[-1].minor.yy135 && yymsp[-1].minor.yy135->nSrc>0) ) yymsp[-1].minor.yy135->a[yymsp[-1].minor.yy135->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy70;
147849 }
147850 break;
147851 case 102: /* stl_prefix ::= */
147852 {yymsp[1].minor.yy135 = 0;}
147853 break;
147854 case 103: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
147855 {
147856 yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
147857 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy135, &yymsp[-2].minor.yy0);
147858 }
147859 break;
147860 case 104: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
147861 {
147862 yymsp[-8].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy135,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
147863 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy135, yymsp[-4].minor.yy420);
147864 }
147865 break;
147866 case 105: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
147867 {
147868 yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy489,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
147869 }
147870 break;
147871 case 106: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
147872 {
147873 if( yymsp[-6].minor.yy135==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy18==0 && yymsp[0].minor.yy48==0 ){
147874 yymsp[-6].minor.yy135 = yymsp[-4].minor.yy135;
147875 }else if( yymsp[-4].minor.yy135->nSrc==1 ){
147876 yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
147877 if( yymsp[-6].minor.yy135 ){
147878 struct SrcList_item *pNew = &yymsp[-6].minor.yy135->a[yymsp[-6].minor.yy135->nSrc-1];
147879 struct SrcList_item *pOld = yymsp[-4].minor.yy135->a;
147880 pNew->zName = pOld->zName;
147881 pNew->zDatabase = pOld->zDatabase;
147882 pNew->pSelect = pOld->pSelect;
147883 pOld->zName = pOld->zDatabase = 0;
147884 pOld->pSelect = 0;
147885 }
147886 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy135);
147887 }else{
147888 Select *pSubquery;
147889 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy135);
147890 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy135,0,0,0,0,SF_NestedFrom,0);
147891 yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
147892 }
147893 }
147894 break;
147895 case 107: /* dbnm ::= */
147896 case 121: /* indexed_opt ::= */ yytestcase(yyruleno==121);
147897 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
147898 break;
147899 case 109: /* fullname ::= nm */
147900 case 111: /* xfullname ::= nm */ yytestcase(yyruleno==111);
147901 {yymsp[0].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
147902 break;
147903 case 110: /* fullname ::= nm DOT nm */
147904 case 112: /* xfullname ::= nm DOT nm */ yytestcase(yyruleno==112);
147905 {yymsp[-2].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
147906 break;
147907 case 113: /* xfullname ::= nm DOT nm AS nm */
147908 {
147909 yymsp[-4].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
147910 if( yymsp[-4].minor.yy135 ) yymsp[-4].minor.yy135->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
147911 }
147912 break;
147913 case 114: /* xfullname ::= nm AS nm */
147914 {
147915 yymsp[-2].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
147916 if( yymsp[-2].minor.yy135 ) yymsp[-2].minor.yy135->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
147917 }
147918 break;
147919 case 115: /* joinop ::= COMMA|JOIN */
147920 { yymsp[0].minor.yy70 = JT_INNER; }
147921 break;
147922 case 116: /* joinop ::= JOIN_KW JOIN */
147923 {yymsp[-1].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
147924 break;
147925 case 117: /* joinop ::= JOIN_KW nm JOIN */
147926 {yymsp[-2].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
147927 break;
147928 case 118: /* joinop ::= JOIN_KW nm nm JOIN */
147929 {yymsp[-3].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
147930 break;
147931 case 119: /* on_opt ::= ON expr */
147932 case 136: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==136);
147933 case 143: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==143);
147934 case 207: /* case_else ::= ELSE expr */ yytestcase(yyruleno==207);
147935 {yymsp[-1].minor.yy18 = yymsp[0].minor.yy18;}
147936 break;
147937 case 120: /* on_opt ::= */
147938 case 135: /* having_opt ::= */ yytestcase(yyruleno==135);
147939 case 137: /* limit_opt ::= */ yytestcase(yyruleno==137);
147940 case 142: /* where_opt ::= */ yytestcase(yyruleno==142);
147941 case 208: /* case_else ::= */ yytestcase(yyruleno==208);
147942 case 210: /* case_operand ::= */ yytestcase(yyruleno==210);
147943 {yymsp[1].minor.yy18 = 0;}
147944 break;
147945 case 122: /* indexed_opt ::= INDEXED BY nm */
147946 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
147947 break;
147948 case 123: /* indexed_opt ::= NOT INDEXED */
147949 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
147950 break;
147951 case 124: /* using_opt ::= USING LP idlist RP */
147952 {yymsp[-3].minor.yy48 = yymsp[-1].minor.yy48;}
147953 break;
147954 case 125: /* using_opt ::= */
147955 case 157: /* idlist_opt ::= */ yytestcase(yyruleno==157);
147956 {yymsp[1].minor.yy48 = 0;}
147957 break;
147958 case 127: /* orderby_opt ::= ORDER BY sortlist */
147959 case 134: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==134);
147960 {yymsp[-2].minor.yy420 = yymsp[0].minor.yy420;}
147961 break;
147962 case 128: /* sortlist ::= sortlist COMMA expr sortorder */
147963 {
147964 yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy420,yymsp[-1].minor.yy18);
147965 sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy420,yymsp[0].minor.yy70);
147966 }
147967 break;
147968 case 129: /* sortlist ::= expr sortorder */
147969 {
147970 yymsp[-1].minor.yy420 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy18); /*A-overwrites-Y*/
147971 sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy420,yymsp[0].minor.yy70);
147972 }
147973 break;
147974 case 130: /* sortorder ::= ASC */
147975 {yymsp[0].minor.yy70 = SQLITE_SO_ASC;}
147976 break;
147977 case 131: /* sortorder ::= DESC */
147978 {yymsp[0].minor.yy70 = SQLITE_SO_DESC;}
147979 break;
147980 case 132: /* sortorder ::= */
147981 {yymsp[1].minor.yy70 = SQLITE_SO_UNDEFINED;}
147982 break;
147983 case 138: /* limit_opt ::= LIMIT expr */
147984 {yymsp[-1].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy18,0);}
147985 break;
147986 case 139: /* limit_opt ::= LIMIT expr OFFSET expr */
147987 {yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);}
147988 break;
147989 case 140: /* limit_opt ::= LIMIT expr COMMA expr */
147990 {yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy18,yymsp[-2].minor.yy18);}
147991 break;
147992 case 141: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
147993 {
147994 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy135, &yymsp[-1].minor.yy0);
147995 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy135,yymsp[0].minor.yy18,0,0);
147996 }
147997 break;
147998 case 144: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
147999 {
148000 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy135, &yymsp[-3].minor.yy0);
148001 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy420,"set list");
148002 sqlite3Update(pParse,yymsp[-4].minor.yy135,yymsp[-1].minor.yy420,yymsp[0].minor.yy18,yymsp[-5].minor.yy70,0,0,0);
148003 }
148004 break;
148005 case 145: /* setlist ::= setlist COMMA nm EQ expr */
148006 {
148007 yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy420, yymsp[0].minor.yy18);
148008 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy420, &yymsp[-2].minor.yy0, 1);
148009 }
148010 break;
148011 case 146: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
148012 {
148013 yymsp[-6].minor.yy420 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy420, yymsp[-3].minor.yy48, yymsp[0].minor.yy18);
148014 }
148015 break;
148016 case 147: /* setlist ::= nm EQ expr */
148017 {
148018 yylhsminor.yy420 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy18);
148019 sqlite3ExprListSetName(pParse, yylhsminor.yy420, &yymsp[-2].minor.yy0, 1);
148020 }
148021 yymsp[-2].minor.yy420 = yylhsminor.yy420;
148022 break;
148023 case 148: /* setlist ::= LP idlist RP EQ expr */
148024 {
148025 yymsp[-4].minor.yy420 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy48, yymsp[0].minor.yy18);
148026 }
148027 break;
148028 case 149: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
148029 {
148030 sqlite3Insert(pParse, yymsp[-3].minor.yy135, yymsp[-1].minor.yy489, yymsp[-2].minor.yy48, yymsp[-5].minor.yy70, yymsp[0].minor.yy340);
148031 }
148032 break;
148033 case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
148034 {
148035 sqlite3Insert(pParse, yymsp[-3].minor.yy135, 0, yymsp[-2].minor.yy48, yymsp[-5].minor.yy70, 0);
148036 }
148037 break;
148038 case 151: /* upsert ::= */
148039 { yymsp[1].minor.yy340 = 0; }
148040 break;
148041 case 152: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
148042 { yymsp[-10].minor.yy340 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy420,yymsp[-5].minor.yy18,yymsp[-1].minor.yy420,yymsp[0].minor.yy18);}
148043 break;
148044 case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
148045 { yymsp[-7].minor.yy340 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy420,yymsp[-2].minor.yy18,0,0); }
148046 break;
148047 case 154: /* upsert ::= ON CONFLICT DO NOTHING */
148048 { yymsp[-3].minor.yy340 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
148049 break;
148050 case 158: /* idlist_opt ::= LP idlist RP */
148051 {yymsp[-2].minor.yy48 = yymsp[-1].minor.yy48;}
148052 break;
148053 case 159: /* idlist ::= idlist COMMA nm */
148054 {yymsp[-2].minor.yy48 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy48,&yymsp[0].minor.yy0);}
148055 break;
148056 case 160: /* idlist ::= nm */
148057 {yymsp[0].minor.yy48 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
148058 break;
148059 case 161: /* expr ::= LP expr RP */
148060 {yymsp[-2].minor.yy18 = yymsp[-1].minor.yy18;}
148061 break;
148062 case 162: /* expr ::= ID|INDEXED */
148063 case 163: /* expr ::= JOIN_KW */ yytestcase(yyruleno==163);
148064 {yymsp[0].minor.yy18=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
148065 break;
148066 case 164: /* expr ::= nm DOT nm */
148067 {
148068 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
148069 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
148070 yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
148071 }
148072 yymsp[-2].minor.yy18 = yylhsminor.yy18;
148073 break;
148074 case 165: /* expr ::= nm DOT nm DOT nm */
148075 {
148076 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
148077 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
148078 Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
148079 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
148080 yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
148081 }
148082 yymsp[-4].minor.yy18 = yylhsminor.yy18;
148083 break;
148084 case 166: /* term ::= NULL|FLOAT|BLOB */
148085 case 167: /* term ::= STRING */ yytestcase(yyruleno==167);
148086 {yymsp[0].minor.yy18=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
148087 break;
148088 case 168: /* term ::= INTEGER */
148089 {
148090 yylhsminor.yy18 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
148091 }
148092 yymsp[0].minor.yy18 = yylhsminor.yy18;
148093 break;
148094 case 169: /* expr ::= VARIABLE */
148095 {
148096 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
148097 u32 n = yymsp[0].minor.yy0.n;
148098 yymsp[0].minor.yy18 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
148099 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy18, n);
148100 }else{
148101 /* When doing a nested parse, one can include terms in an expression
148102 ** that look like this: #1 #2 ... These terms refer to registers
148103 ** in the virtual machine. #N is the N-th register. */
148104 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
148105 assert( t.n>=2 );
148106 if( pParse->nested==0 ){
148107 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
148108 yymsp[0].minor.yy18 = 0;
148109 }else{
148110 yymsp[0].minor.yy18 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
148111 if( yymsp[0].minor.yy18 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy18->iTable);
148112 }
148113 }
148114 }
148115 break;
148116 case 170: /* expr ::= expr COLLATE ID|STRING */
148117 {
148118 yymsp[-2].minor.yy18 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy18, &yymsp[0].minor.yy0, 1);
148119 }
148120 break;
148121 case 171: /* expr ::= CAST LP expr AS typetoken RP */
148122 {
148123 yymsp[-5].minor.yy18 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
148124 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy18, yymsp[-3].minor.yy18, 0);
148125 }
148126 break;
148127 case 172: /* expr ::= ID|INDEXED LP distinct exprlist RP over_opt */
148128 {
148129 if( yymsp[-2].minor.yy420 && yymsp[-2].minor.yy420->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
148130 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-5].minor.yy0);
148131 }
148132 yylhsminor.yy18 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy420, &yymsp[-5].minor.yy0);
148133 if( yymsp[-3].minor.yy70==SF_Distinct && yylhsminor.yy18 ){
148134 yylhsminor.yy18->flags |= EP_Distinct;
148135 }
148136 sqlite3WindowAttach(pParse, yylhsminor.yy18, yymsp[0].minor.yy327);
148137 }
148138 yymsp[-5].minor.yy18 = yylhsminor.yy18;
148139 break;
148140 case 173: /* expr ::= ID|INDEXED LP STAR RP over_opt */
148141 {
148142 yylhsminor.yy18 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0);
148143 sqlite3WindowAttach(pParse, yylhsminor.yy18, yymsp[0].minor.yy327);
148144 }
148145 yymsp[-4].minor.yy18 = yylhsminor.yy18;
148146 break;
148147 case 174: /* term ::= CTIME_KW */
148148 {
148149 yylhsminor.yy18 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
148150 }
148151 yymsp[0].minor.yy18 = yylhsminor.yy18;
148152 break;
148153 case 175: /* expr ::= LP nexprlist COMMA expr RP */
148154 {
148155 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy420, yymsp[-1].minor.yy18);
148156 yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
148157 if( yymsp[-4].minor.yy18 ){
148158 yymsp[-4].minor.yy18->x.pList = pList;
148159 }else{
148160 sqlite3ExprListDelete(pParse->db, pList);
148161 }
148162 }
148163 break;
@@ -144682,99 +148167,99 @@
148167 case 179: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==179);
148168 case 180: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==180);
148169 case 181: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==181);
148170 case 182: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==182);
148171 case 183: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==183);
148172 {yymsp[-2].minor.yy18=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);}
148173 break;
148174 case 184: /* likeop ::= NOT LIKE_KW|MATCH */
148175 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
148176 break;
148177 case 185: /* expr ::= expr likeop expr */
148178 {
148179 ExprList *pList;
148180 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
148181 yymsp[-1].minor.yy0.n &= 0x7fffffff;
148182 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy18);
148183 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy18);
148184 yymsp[-2].minor.yy18 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
148185 if( bNot ) yymsp[-2].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy18, 0);
148186 if( yymsp[-2].minor.yy18 ) yymsp[-2].minor.yy18->flags |= EP_InfixFunc;
148187 }
148188 break;
148189 case 186: /* expr ::= expr likeop expr ESCAPE expr */
148190 {
148191 ExprList *pList;
148192 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
148193 yymsp[-3].minor.yy0.n &= 0x7fffffff;
148194 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
148195 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy18);
148196 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy18);
148197 yymsp[-4].minor.yy18 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
148198 if( bNot ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
148199 if( yymsp[-4].minor.yy18 ) yymsp[-4].minor.yy18->flags |= EP_InfixFunc;
148200 }
148201 break;
148202 case 187: /* expr ::= expr ISNULL|NOTNULL */
148203 {yymsp[-1].minor.yy18 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy18,0);}
148204 break;
148205 case 188: /* expr ::= expr NOT NULL */
148206 {yymsp[-2].minor.yy18 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy18,0);}
148207 break;
148208 case 189: /* expr ::= expr IS expr */
148209 {
148210 yymsp[-2].minor.yy18 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);
148211 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy18, yymsp[-2].minor.yy18, TK_ISNULL);
148212 }
148213 break;
148214 case 190: /* expr ::= expr IS NOT expr */
148215 {
148216 yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy18,yymsp[0].minor.yy18);
148217 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy18, yymsp[-3].minor.yy18, TK_NOTNULL);
148218 }
148219 break;
148220 case 191: /* expr ::= NOT expr */
148221 case 192: /* expr ::= BITNOT expr */ yytestcase(yyruleno==192);
148222 {yymsp[-1].minor.yy18 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy18, 0);/*A-overwrites-B*/}
148223 break;
148224 case 193: /* expr ::= PLUS|MINUS expr */
148225 {
148226 yymsp[-1].minor.yy18 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy18, 0);
148227 /*A-overwrites-B*/
148228 }
148229 break;
148230 case 194: /* between_op ::= BETWEEN */
148231 case 197: /* in_op ::= IN */ yytestcase(yyruleno==197);
148232 {yymsp[0].minor.yy70 = 0;}
148233 break;
148234 case 196: /* expr ::= expr between_op expr AND expr */
148235 {
148236 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
148237 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy18);
148238 yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy18, 0);
148239 if( yymsp[-4].minor.yy18 ){
148240 yymsp[-4].minor.yy18->x.pList = pList;
148241 }else{
148242 sqlite3ExprListDelete(pParse->db, pList);
148243 }
148244 if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
148245 }
148246 break;
148247 case 199: /* expr ::= expr in_op LP exprlist RP */
148248 {
148249 if( yymsp[-1].minor.yy420==0 ){
148250 /* Expressions of the form
148251 **
148252 ** expr1 IN ()
148253 ** expr1 NOT IN ()
148254 **
148255 ** simplify to constants 0 (false) and 1 (true), respectively,
148256 ** regardless of the value of expr1.
148257 */
148258 sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy18);
148259 yymsp[-4].minor.yy18 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy70],1);
148260 }else if( yymsp[-1].minor.yy420->nExpr==1 ){
148261 /* Expressions of the form:
148262 **
148263 ** expr1 IN (?1)
148264 ** expr1 NOT IN (?2)
148265 **
@@ -144787,396 +148272,506 @@
148272 ** But, the RHS of the == or <> is marked with the EP_Generic flag
148273 ** so that it may not contribute to the computation of comparison
148274 ** affinity or the collating sequence to use for comparison. Otherwise,
148275 ** the semantics would be subtly different from IN or NOT IN.
148276 */
148277 Expr *pRHS = yymsp[-1].minor.yy420->a[0].pExpr;
148278 yymsp[-1].minor.yy420->a[0].pExpr = 0;
148279 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy420);
148280 /* pRHS cannot be NULL because a malloc error would have been detected
148281 ** before now and control would have never reached this point */
148282 if( ALWAYS(pRHS) ){
148283 pRHS->flags &= ~EP_Collate;
148284 pRHS->flags |= EP_Generic;
148285 }
148286 yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, yymsp[-3].minor.yy70 ? TK_NE : TK_EQ, yymsp[-4].minor.yy18, pRHS);
148287 }else{
148288 yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy18, 0);
148289 if( yymsp[-4].minor.yy18 ){
148290 yymsp[-4].minor.yy18->x.pList = yymsp[-1].minor.yy420;
148291 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy18);
148292 }else{
148293 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy420);
148294 }
148295 if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
148296 }
148297 }
148298 break;
148299 case 200: /* expr ::= LP select RP */
148300 {
148301 yymsp[-2].minor.yy18 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
148302 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy18, yymsp[-1].minor.yy489);
148303 }
148304 break;
148305 case 201: /* expr ::= expr in_op LP select RP */
148306 {
148307 yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy18, 0);
148308 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy18, yymsp[-1].minor.yy489);
148309 if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
148310 }
148311 break;
148312 case 202: /* expr ::= expr in_op nm dbnm paren_exprlist */
148313 {
148314 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
148315 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
148316 if( yymsp[0].minor.yy420 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy420);
148317 yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy18, 0);
148318 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy18, pSelect);
148319 if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
148320 }
148321 break;
148322 case 203: /* expr ::= EXISTS LP select RP */
148323 {
148324 Expr *p;
148325 p = yymsp[-3].minor.yy18 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
148326 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy489);
148327 }
148328 break;
148329 case 204: /* expr ::= CASE case_operand case_exprlist case_else END */
148330 {
148331 yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy18, 0);
148332 if( yymsp[-4].minor.yy18 ){
148333 yymsp[-4].minor.yy18->x.pList = yymsp[-1].minor.yy18 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy420,yymsp[-1].minor.yy18) : yymsp[-2].minor.yy420;
148334 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy18);
148335 }else{
148336 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy420);
148337 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy18);
148338 }
148339 }
148340 break;
148341 case 205: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
148342 {
148343 yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, yymsp[-2].minor.yy18);
148344 yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, yymsp[0].minor.yy18);
148345 }
148346 break;
148347 case 206: /* case_exprlist ::= WHEN expr THEN expr */
148348 {
148349 yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
148350 yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy420, yymsp[0].minor.yy18);
148351 }
148352 break;
148353 case 209: /* case_operand ::= expr */
148354 {yymsp[0].minor.yy18 = yymsp[0].minor.yy18; /*A-overwrites-X*/}
148355 break;
148356 case 212: /* nexprlist ::= nexprlist COMMA expr */
148357 {yymsp[-2].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy420,yymsp[0].minor.yy18);}
148358 break;
148359 case 213: /* nexprlist ::= expr */
148360 {yymsp[0].minor.yy420 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy18); /*A-overwrites-Y*/}
148361 break;
148362 case 215: /* paren_exprlist ::= LP exprlist RP */
148363 case 220: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==220);
148364 {yymsp[-2].minor.yy420 = yymsp[-1].minor.yy420;}
148365 break;
148366 case 216: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
148367 {
148368 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
148369 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy420, yymsp[-10].minor.yy70,
148370 &yymsp[-11].minor.yy0, yymsp[0].minor.yy18, SQLITE_SO_ASC, yymsp[-8].minor.yy70, SQLITE_IDXTYPE_APPDEF);
148371 }
148372 break;
148373 case 217: /* uniqueflag ::= UNIQUE */
148374 case 257: /* raisetype ::= ABORT */ yytestcase(yyruleno==257);
148375 {yymsp[0].minor.yy70 = OE_Abort;}
148376 break;
148377 case 218: /* uniqueflag ::= */
148378 {yymsp[1].minor.yy70 = OE_None;}
148379 break;
148380 case 221: /* eidlist ::= eidlist COMMA nm collate sortorder */
148381 {
148382 yymsp[-4].minor.yy420 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy420, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy70, yymsp[0].minor.yy70);
148383 }
148384 break;
148385 case 222: /* eidlist ::= nm collate sortorder */
148386 {
148387 yymsp[-2].minor.yy420 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy70, yymsp[0].minor.yy70); /*A-overwrites-Y*/
148388 }
148389 break;
148390 case 225: /* cmd ::= DROP INDEX ifexists fullname */
148391 {sqlite3DropIndex(pParse, yymsp[0].minor.yy135, yymsp[-1].minor.yy70);}
148392 break;
148393 case 226: /* cmd ::= VACUUM */
148394 {sqlite3Vacuum(pParse,0);}
148395 break;
148396 case 227: /* cmd ::= VACUUM nm */
148397 {sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
148398 break;
148399 case 228: /* cmd ::= PRAGMA nm dbnm */
148400 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
148401 break;
148402 case 229: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
148403 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
148404 break;
148405 case 230: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
148406 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
148407 break;
148408 case 231: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
148409 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
148410 break;
148411 case 232: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
148412 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
148413 break;
148414 case 235: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
148415 {
148416 Token all;
148417 all.z = yymsp[-3].minor.yy0.z;
148418 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
148419 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy207, &all);
148420 }
148421 break;
148422 case 236: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
148423 {
148424 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy70, yymsp[-4].minor.yy34.a, yymsp[-4].minor.yy34.b, yymsp[-2].minor.yy135, yymsp[0].minor.yy18, yymsp[-10].minor.yy70, yymsp[-8].minor.yy70);
148425 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
148426 }
148427 break;
148428 case 237: /* trigger_time ::= BEFORE|AFTER */
148429 { yymsp[0].minor.yy70 = yymsp[0].major; /*A-overwrites-X*/ }
148430 break;
148431 case 238: /* trigger_time ::= INSTEAD OF */
148432 { yymsp[-1].minor.yy70 = TK_INSTEAD;}
148433 break;
148434 case 239: /* trigger_time ::= */
148435 { yymsp[1].minor.yy70 = TK_BEFORE; }
148436 break;
148437 case 240: /* trigger_event ::= DELETE|INSERT */
148438 case 241: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==241);
148439 {yymsp[0].minor.yy34.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy34.b = 0;}
148440 break;
148441 case 242: /* trigger_event ::= UPDATE OF idlist */
148442 {yymsp[-2].minor.yy34.a = TK_UPDATE; yymsp[-2].minor.yy34.b = yymsp[0].minor.yy48;}
148443 break;
148444 case 243: /* when_clause ::= */
148445 case 262: /* key_opt ::= */ yytestcase(yyruleno==262);
148446 case 305: /* filter_opt ::= */ yytestcase(yyruleno==305);
148447 { yymsp[1].minor.yy18 = 0; }
148448 break;
148449 case 244: /* when_clause ::= WHEN expr */
148450 case 263: /* key_opt ::= KEY expr */ yytestcase(yyruleno==263);
148451 { yymsp[-1].minor.yy18 = yymsp[0].minor.yy18; }
148452 break;
148453 case 245: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
148454 {
148455 assert( yymsp[-2].minor.yy207!=0 );
148456 yymsp[-2].minor.yy207->pLast->pNext = yymsp[-1].minor.yy207;
148457 yymsp[-2].minor.yy207->pLast = yymsp[-1].minor.yy207;
148458 }
148459 break;
148460 case 246: /* trigger_cmd_list ::= trigger_cmd SEMI */
148461 {
148462 assert( yymsp[-1].minor.yy207!=0 );
148463 yymsp[-1].minor.yy207->pLast = yymsp[-1].minor.yy207;
148464 }
148465 break;
148466 case 247: /* trnm ::= nm DOT nm */
148467 {
148468 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
148469 sqlite3ErrorMsg(pParse,
148470 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
148471 "statements within triggers");
148472 }
148473 break;
148474 case 248: /* tridxby ::= INDEXED BY nm */
148475 {
148476 sqlite3ErrorMsg(pParse,
148477 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
148478 "within triggers");
148479 }
148480 break;
148481 case 249: /* tridxby ::= NOT INDEXED */
148482 {
148483 sqlite3ErrorMsg(pParse,
148484 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
148485 "within triggers");
148486 }
148487 break;
148488 case 250: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
148489 {yylhsminor.yy207 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy420, yymsp[-1].minor.yy18, yymsp[-6].minor.yy70, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy392);}
148490 yymsp[-7].minor.yy207 = yylhsminor.yy207;
148491 break;
148492 case 251: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
148493 {
148494 yylhsminor.yy207 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy48,yymsp[-2].minor.yy489,yymsp[-6].minor.yy70,yymsp[-1].minor.yy340,yymsp[-7].minor.yy392,yymsp[0].minor.yy392);/*yylhsminor.yy207-overwrites-yymsp[-6].minor.yy70*/
148495 }
148496 yymsp[-7].minor.yy207 = yylhsminor.yy207;
148497 break;
148498 case 252: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
148499 {yylhsminor.yy207 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy18, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy392);}
148500 yymsp[-5].minor.yy207 = yylhsminor.yy207;
148501 break;
148502 case 253: /* trigger_cmd ::= scanpt select scanpt */
148503 {yylhsminor.yy207 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy489, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); /*yylhsminor.yy207-overwrites-yymsp[-1].minor.yy489*/}
148504 yymsp[-2].minor.yy207 = yylhsminor.yy207;
148505 break;
148506 case 254: /* expr ::= RAISE LP IGNORE RP */
148507 {
148508 yymsp[-3].minor.yy18 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
148509 if( yymsp[-3].minor.yy18 ){
148510 yymsp[-3].minor.yy18->affinity = OE_Ignore;
148511 }
148512 }
148513 break;
148514 case 255: /* expr ::= RAISE LP raisetype COMMA nm RP */
148515 {
148516 yymsp[-5].minor.yy18 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
148517 if( yymsp[-5].minor.yy18 ) {
148518 yymsp[-5].minor.yy18->affinity = (char)yymsp[-3].minor.yy70;
148519 }
148520 }
148521 break;
148522 case 256: /* raisetype ::= ROLLBACK */
148523 {yymsp[0].minor.yy70 = OE_Rollback;}
148524 break;
148525 case 258: /* raisetype ::= FAIL */
148526 {yymsp[0].minor.yy70 = OE_Fail;}
148527 break;
148528 case 259: /* cmd ::= DROP TRIGGER ifexists fullname */
148529 {
148530 sqlite3DropTrigger(pParse,yymsp[0].minor.yy135,yymsp[-1].minor.yy70);
148531 }
148532 break;
148533 case 260: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
148534 {
148535 sqlite3Attach(pParse, yymsp[-3].minor.yy18, yymsp[-1].minor.yy18, yymsp[0].minor.yy18);
148536 }
148537 break;
148538 case 261: /* cmd ::= DETACH database_kw_opt expr */
148539 {
148540 sqlite3Detach(pParse, yymsp[0].minor.yy18);
148541 }
148542 break;
148543 case 264: /* cmd ::= REINDEX */
148544 {sqlite3Reindex(pParse, 0, 0);}
148545 break;
148546 case 265: /* cmd ::= REINDEX nm dbnm */
148547 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
148548 break;
148549 case 266: /* cmd ::= ANALYZE */
148550 {sqlite3Analyze(pParse, 0, 0);}
148551 break;
148552 case 267: /* cmd ::= ANALYZE nm dbnm */
148553 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
148554 break;
148555 case 268: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
148556 {
148557 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy135,&yymsp[0].minor.yy0);
148558 }
148559 break;
148560 case 269: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
148561 {
148562 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
148563 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
148564 }
148565 break;
148566 case 270: /* add_column_fullname ::= fullname */
148567 {
148568 disableLookaside(pParse);
148569 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy135);
148570 }
148571 break;
148572 case 271: /* cmd ::= create_vtab */
148573 {sqlite3VtabFinishParse(pParse,0);}
148574 break;
148575 case 272: /* cmd ::= create_vtab LP vtabarglist RP */
148576 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
148577 break;
148578 case 273: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
148579 {
148580 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy70);
148581 }
148582 break;
148583 case 274: /* vtabarg ::= */
148584 {sqlite3VtabArgInit(pParse);}
148585 break;
148586 case 275: /* vtabargtoken ::= ANY */
148587 case 276: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==276);
148588 case 277: /* lp ::= LP */ yytestcase(yyruleno==277);
148589 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
148590 break;
148591 case 278: /* with ::= WITH wqlist */
148592 case 279: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==279);
148593 { sqlite3WithPush(pParse, yymsp[0].minor.yy449, 1); }
148594 break;
148595 case 280: /* wqlist ::= nm eidlist_opt AS LP select RP */
148596 {
148597 yymsp[-5].minor.yy449 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489); /*A-overwrites-X*/
148598 }
148599 break;
148600 case 281: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
148601 {
148602 yymsp[-7].minor.yy449 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy449, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489);
148603 }
148604 break;
148605 case 282: /* windowdefn_list ::= windowdefn */
148606 { yylhsminor.yy327 = yymsp[0].minor.yy327; }
148607 yymsp[0].minor.yy327 = yylhsminor.yy327;
148608 break;
148609 case 283: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
148610 {
148611 assert( yymsp[0].minor.yy327!=0 );
148612 yymsp[0].minor.yy327->pNextWin = yymsp[-2].minor.yy327;
148613 yylhsminor.yy327 = yymsp[0].minor.yy327;
148614 }
148615 yymsp[-2].minor.yy327 = yylhsminor.yy327;
148616 break;
148617 case 284: /* windowdefn ::= nm AS window */
148618 {
148619 if( ALWAYS(yymsp[0].minor.yy327) ){
148620 yymsp[0].minor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[-2].minor.yy0.z, yymsp[-2].minor.yy0.n);
148621 }
148622 yylhsminor.yy327 = yymsp[0].minor.yy327;
148623 }
148624 yymsp[-2].minor.yy327 = yylhsminor.yy327;
148625 break;
148626 case 285: /* window ::= LP part_opt orderby_opt frame_opt RP */
148627 {
148628 yymsp[-4].minor.yy327 = yymsp[-1].minor.yy327;
148629 if( ALWAYS(yymsp[-4].minor.yy327) ){
148630 yymsp[-4].minor.yy327->pPartition = yymsp[-3].minor.yy420;
148631 yymsp[-4].minor.yy327->pOrderBy = yymsp[-2].minor.yy420;
148632 }
148633 }
148634 break;
148635 case 286: /* part_opt ::= PARTITION BY exprlist */
148636 { yymsp[-2].minor.yy420 = yymsp[0].minor.yy420; }
148637 break;
148638 case 287: /* part_opt ::= */
148639 { yymsp[1].minor.yy420 = 0; }
148640 break;
148641 case 288: /* frame_opt ::= */
148642 {
148643 yymsp[1].minor.yy327 = sqlite3WindowAlloc(pParse, TK_RANGE, TK_UNBOUNDED, 0, TK_CURRENT, 0);
148644 }
148645 break;
148646 case 289: /* frame_opt ::= range_or_rows frame_bound_s */
148647 {
148648 yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-1].minor.yy70, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr, TK_CURRENT, 0);
148649 }
148650 yymsp[-1].minor.yy327 = yylhsminor.yy327;
148651 break;
148652 case 290: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
148653 {
148654 yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy119.eType, yymsp[-2].minor.yy119.pExpr, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr);
148655 }
148656 yymsp[-4].minor.yy327 = yylhsminor.yy327;
148657 break;
148658 case 291: /* range_or_rows ::= RANGE */
148659 { yymsp[0].minor.yy70 = TK_RANGE; }
148660 break;
148661 case 292: /* range_or_rows ::= ROWS */
148662 { yymsp[0].minor.yy70 = TK_ROWS; }
148663 break;
148664 case 293: /* frame_bound_s ::= frame_bound */
148665 case 295: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==295);
148666 { yylhsminor.yy119 = yymsp[0].minor.yy119; }
148667 yymsp[0].minor.yy119 = yylhsminor.yy119;
148668 break;
148669 case 294: /* frame_bound_s ::= UNBOUNDED PRECEDING */
148670 case 296: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==296);
148671 {yymsp[-1].minor.yy119.eType = TK_UNBOUNDED; yymsp[-1].minor.yy119.pExpr = 0;}
148672 break;
148673 case 297: /* frame_bound ::= expr PRECEDING */
148674 { yylhsminor.yy119.eType = TK_PRECEDING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
148675 yymsp[-1].minor.yy119 = yylhsminor.yy119;
148676 break;
148677 case 298: /* frame_bound ::= CURRENT ROW */
148678 { yymsp[-1].minor.yy119.eType = TK_CURRENT ; yymsp[-1].minor.yy119.pExpr = 0; }
148679 break;
148680 case 299: /* frame_bound ::= expr FOLLOWING */
148681 { yylhsminor.yy119.eType = TK_FOLLOWING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
148682 yymsp[-1].minor.yy119 = yylhsminor.yy119;
148683 break;
148684 case 300: /* windowdefn_opt ::= */
148685 case 302: /* over_opt ::= */ yytestcase(yyruleno==302);
148686 { yymsp[1].minor.yy327 = 0; }
148687 break;
148688 case 301: /* windowdefn_opt ::= WINDOW windowdefn_list */
148689 { yymsp[-1].minor.yy327 = yymsp[0].minor.yy327; }
148690 break;
148691 case 303: /* over_opt ::= filter_opt OVER window */
148692 {
148693 yylhsminor.yy327 = yymsp[0].minor.yy327;
148694 assert( yylhsminor.yy327!=0 );
148695 yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
148696 }
148697 yymsp[-2].minor.yy327 = yylhsminor.yy327;
148698 break;
148699 case 304: /* over_opt ::= filter_opt OVER nm */
148700 {
148701 yylhsminor.yy327 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
148702 if( yylhsminor.yy327 ){
148703 yylhsminor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
148704 yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
148705 }else{
148706 sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy18);
148707 }
148708 }
148709 yymsp[-2].minor.yy327 = yylhsminor.yy327;
148710 break;
148711 case 306: /* filter_opt ::= FILTER LP WHERE expr RP */
148712 { yymsp[-4].minor.yy18 = yymsp[-1].minor.yy18; }
148713 break;
148714 default:
148715 /* (307) input ::= cmdlist */ yytestcase(yyruleno==307);
148716 /* (308) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==308);
148717 /* (309) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=309);
148718 /* (310) ecmd ::= SEMI */ yytestcase(yyruleno==310);
148719 /* (311) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==311);
148720 /* (312) ecmd ::= explain cmdx */ yytestcase(yyruleno==312);
148721 /* (313) trans_opt ::= */ yytestcase(yyruleno==313);
148722 /* (314) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==314);
148723 /* (315) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==315);
148724 /* (316) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==316);
148725 /* (317) savepoint_opt ::= */ yytestcase(yyruleno==317);
148726 /* (318) cmd ::= create_table create_table_args */ yytestcase(yyruleno==318);
148727 /* (319) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==319);
148728 /* (320) columnlist ::= columnname carglist */ yytestcase(yyruleno==320);
148729 /* (321) nm ::= ID|INDEXED */ yytestcase(yyruleno==321);
148730 /* (322) nm ::= STRING */ yytestcase(yyruleno==322);
148731 /* (323) nm ::= JOIN_KW */ yytestcase(yyruleno==323);
148732 /* (324) typetoken ::= typename */ yytestcase(yyruleno==324);
148733 /* (325) typename ::= ID|STRING */ yytestcase(yyruleno==325);
148734 /* (326) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=326);
148735 /* (327) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=327);
148736 /* (328) carglist ::= carglist ccons */ yytestcase(yyruleno==328);
148737 /* (329) carglist ::= */ yytestcase(yyruleno==329);
148738 /* (330) ccons ::= NULL onconf */ yytestcase(yyruleno==330);
148739 /* (331) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==331);
148740 /* (332) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==332);
148741 /* (333) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=333);
148742 /* (334) tconscomma ::= */ yytestcase(yyruleno==334);
148743 /* (335) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=335);
148744 /* (336) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=336);
148745 /* (337) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=337);
148746 /* (338) oneselect ::= values */ yytestcase(yyruleno==338);
148747 /* (339) sclp ::= selcollist COMMA */ yytestcase(yyruleno==339);
148748 /* (340) as ::= ID|STRING */ yytestcase(yyruleno==340);
148749 /* (341) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=341);
148750 /* (342) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==342);
148751 /* (343) exprlist ::= nexprlist */ yytestcase(yyruleno==343);
148752 /* (344) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=344);
148753 /* (345) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=345);
148754 /* (346) nmnum ::= ON */ yytestcase(yyruleno==346);
148755 /* (347) nmnum ::= DELETE */ yytestcase(yyruleno==347);
148756 /* (348) nmnum ::= DEFAULT */ yytestcase(yyruleno==348);
148757 /* (349) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==349);
148758 /* (350) foreach_clause ::= */ yytestcase(yyruleno==350);
148759 /* (351) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==351);
148760 /* (352) trnm ::= nm */ yytestcase(yyruleno==352);
148761 /* (353) tridxby ::= */ yytestcase(yyruleno==353);
148762 /* (354) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==354);
148763 /* (355) database_kw_opt ::= */ yytestcase(yyruleno==355);
148764 /* (356) kwcolumn_opt ::= */ yytestcase(yyruleno==356);
148765 /* (357) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==357);
148766 /* (358) vtabarglist ::= vtabarg */ yytestcase(yyruleno==358);
148767 /* (359) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==359);
148768 /* (360) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==360);
148769 /* (361) anylist ::= */ yytestcase(yyruleno==361);
148770 /* (362) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==362);
148771 /* (363) anylist ::= anylist ANY */ yytestcase(yyruleno==363);
148772 /* (364) with ::= */ yytestcase(yyruleno==364);
148773 break;
148774 /********** End reduce actions ************************************************/
148775 };
148776 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
148777 yygoto = yyRuleInfo[yyruleno].lhs;
@@ -145458,10 +149053,25 @@
149053 fprintf(yyTraceFILE,"]\n");
149054 }
149055 #endif
149056 return;
149057 }
149058
149059 /*
149060 ** Return the fallback token corresponding to canonical token iToken, or
149061 ** 0 if iToken has no fallback.
149062 */
149063 SQLITE_PRIVATE int sqlite3ParserFallback(int iToken){
149064 #ifdef YYFALLBACK
149065 if( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ){
149066 return yyFallback[iToken];
149067 }
149068 #else
149069 (void)iToken;
149070 #endif
149071 return 0;
149072 }
149073
149074 /************** End of parse.c ***********************************************/
149075 /************** Begin file tokenize.c ****************************************/
149076 /*
149077 ** 2001 September 15
@@ -145517,15 +149127,16 @@
149127 #define CC_COMMA 23 /* ',' */
149128 #define CC_AND 24 /* '&' */
149129 #define CC_TILDA 25 /* '~' */
149130 #define CC_DOT 26 /* '.' */
149131 #define CC_ILLEGAL 27 /* Illegal character */
149132 #define CC_NUL 28 /* 0x00 */
149133
149134 static const unsigned char aiClass[] = {
149135 #ifdef SQLITE_ASCII
149136 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
149137 /* 0x */ 28, 27, 27, 27, 27, 27, 27, 27, 27, 7, 7, 27, 7, 7, 27, 27,
149138 /* 1x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
149139 /* 2x */ 7, 15, 8, 5, 4, 22, 24, 8, 17, 18, 21, 20, 23, 11, 26, 16,
149140 /* 3x */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 19, 12, 14, 13, 6,
149141 /* 4x */ 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
149142 /* 5x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 9, 27, 27, 27, 1,
@@ -145620,23 +149231,24 @@
149231 ** might be implemented more directly using a hand-written hash table.
149232 ** But by using this automatically generated code, the size of the code
149233 ** is substantially reduced. This is important for embedded applications
149234 ** on platforms with limited memory.
149235 */
149236 /* Hash score: 208 */
149237 /* zKWText[] encodes 923 bytes of keyword text in 614 bytes */
149238 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
149239 /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
149240 /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
149241 /* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERANGEBETWEEN */
149242 /* OTHINGLOBYCASCADELETECASECOLLATECREATECURRENT_DATEDETACH */
149243 /* IMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMIT */
149244 /* WHENOTNULLWHERECURSIVEAFTERENAMEANDEFAULTAUTOINCREMENTCAST */
149245 /* COLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMPARTITIONDEFERRED */
149246 /* ISTINCTDROPRECEDINGFAILFILTEREPLACEFOLLOWINGFROMFULLIFISNULL */
149247 /* ORDERESTRICTOVERIGHTROLLBACKROWSUNBOUNDEDUNIONUSINGVACUUMVIEW */
149248 /* INDOWINITIALLYPRIMARY */
149249 static const char zKWText[613] = {
149250 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
149251 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
149252 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
149253 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
149254 'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
@@ -145645,88 +149257,94 @@
149257 'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
149258 'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
149259 'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
149260 'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
149261 'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
149262 'T','E','B','E','G','I','N','N','E','R','A','N','G','E','B','E','T','W',
149263 'E','E','N','O','T','H','I','N','G','L','O','B','Y','C','A','S','C','A',
149264 'D','E','L','E','T','E','C','A','S','E','C','O','L','L','A','T','E','C',
149265 'R','E','A','T','E','C','U','R','R','E','N','T','_','D','A','T','E','D',
149266 'E','T','A','C','H','I','M','M','E','D','I','A','T','E','J','O','I','N',
149267 'S','E','R','T','L','I','K','E','M','A','T','C','H','P','L','A','N','A',
149268 'L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U',
149269 'E','S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','O',
149270 'T','N','U','L','L','W','H','E','R','E','C','U','R','S','I','V','E','A',
149271 'F','T','E','R','E','N','A','M','E','A','N','D','E','F','A','U','L','T',
149272 'A','U','T','O','I','N','C','R','E','M','E','N','T','C','A','S','T','C',
149273 'O','L','U','M','N','C','O','M','M','I','T','C','O','N','F','L','I','C',
149274 'T','C','R','O','S','S','C','U','R','R','E','N','T','_','T','I','M','E',
149275 'S','T','A','M','P','A','R','T','I','T','I','O','N','D','E','F','E','R',
149276 'R','E','D','I','S','T','I','N','C','T','D','R','O','P','R','E','C','E',
149277 'D','I','N','G','F','A','I','L','F','I','L','T','E','R','E','P','L','A',
149278 'C','E','F','O','L','L','O','W','I','N','G','F','R','O','M','F','U','L',
149279 'L','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T','R',
149280 'I','C','T','O','V','E','R','I','G','H','T','R','O','L','L','B','A','C',
149281 'K','R','O','W','S','U','N','B','O','U','N','D','E','D','U','N','I','O',
149282 'N','U','S','I','N','G','V','A','C','U','U','M','V','I','E','W','I','N',
149283 'D','O','W','I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R',
149284 'Y',
149285 };
149286 /* aKWHash[i] is the hash value for the i-th keyword */
149287 static const unsigned char aKWHash[127] = {
149288 74, 109, 124, 72, 106, 45, 0, 0, 81, 0, 76, 61, 0,
149289 42, 12, 77, 15, 0, 123, 84, 54, 118, 125, 19, 0, 0,
149290 130, 0, 128, 121, 0, 22, 96, 0, 9, 0, 0, 115, 69,
149291 0, 67, 6, 0, 48, 93, 136, 0, 126, 104, 0, 0, 44,
149292 0, 107, 24, 0, 17, 0, 131, 53, 23, 0, 5, 62, 132,
149293 99, 0, 0, 135, 110, 60, 134, 57, 113, 55, 0, 94, 0,
149294 103, 26, 0, 102, 0, 0, 0, 98, 95, 100, 105, 117, 14,
149295 39, 116, 0, 80, 0, 133, 114, 92, 59, 0, 129, 79, 119,
149296 86, 46, 83, 0, 0, 97, 40, 122, 120, 0, 127, 0, 0,
149297 29, 0, 89, 87, 88, 0, 20, 85, 111, 56,
149298 };
149299 /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
149300 ** then the i-th keyword has no more hash collisions. Otherwise,
149301 ** the next keyword with the same hash is aKWHash[i]-1. */
149302 static const unsigned char aKWNext[136] = {
149303 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
149304 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
149305 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
149306 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
149307 0, 43, 3, 47, 0, 0, 32, 0, 0, 0, 0, 0, 0,
149308 0, 1, 64, 0, 0, 65, 0, 41, 0, 38, 0, 0, 0,
149309 0, 0, 49, 75, 0, 0, 30, 0, 58, 0, 0, 0, 31,
149310 63, 16, 34, 10, 0, 0, 0, 0, 0, 0, 0, 11, 70,
149311 91, 0, 0, 8, 0, 108, 0, 101, 28, 52, 68, 0, 112,
149312 0, 73, 51, 0, 90, 27, 37, 0, 71, 36, 82, 0, 35,
149313 66, 25, 18, 0, 0, 78,
149314 };
149315 /* aKWLen[i] is the length (in bytes) of the i-th keyword */
149316 static const unsigned char aKWLen[136] = {
149317 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
149318 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
149319 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
149320 4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
149321 6, 6, 5, 6, 5, 5, 5, 7, 7, 4, 2, 7, 3,
149322 6, 4, 7, 6, 12, 6, 9, 4, 6, 4, 5, 4, 7,
149323 6, 5, 6, 7, 5, 4, 7, 3, 2, 4, 5, 9, 5,
149324 6, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5, 17, 12,
149325 7, 9, 8, 8, 2, 4, 9, 4, 6, 7, 9, 4, 4,
149326 2, 6, 5, 8, 4, 5, 8, 4, 3, 9, 5, 5, 6,
149327 4, 6, 2, 9, 3, 7,
149328 };
149329 /* aKWOffset[i] is the index into zKWText[] of the start of
149330 ** the text for the i-th keyword. */
149331 static const unsigned short int aKWOffset[136] = {
149332 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
149333 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
149334 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
149335 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
149336 199, 204, 209, 212, 218, 221, 225, 230, 236, 242, 245, 247, 248,
149337 252, 258, 262, 269, 275, 287, 293, 302, 304, 310, 314, 319, 321,
149338 328, 333, 338, 344, 350, 355, 358, 358, 358, 361, 365, 368, 377,
149339 381, 387, 389, 396, 398, 400, 409, 413, 419, 425, 433, 438, 438,
149340 438, 454, 463, 470, 471, 478, 481, 490, 494, 499, 506, 515, 519,
149341 523, 525, 531, 535, 543, 546, 551, 559, 559, 563, 572, 577, 582,
149342 588, 591, 594, 597, 602, 606,
149343 };
149344 /* aKWCode[i] is the parser symbol code for the i-th keyword */
149345 static const unsigned char aKWCode[136] = {
149346 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
149347 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
149348 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
149349 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
149350 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
@@ -145734,25 +149352,27 @@
149352 TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
149353 TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
149354 TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
149355 TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
149356 TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
149357 TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RANGE, TK_BETWEEN,
149358 TK_NOTHING, TK_LIKE_KW, TK_BY, TK_CASCADE, TK_ASC,
149359 TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW,
149360 TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_LIKE_KW,
149361 TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT,
149362 TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_NOTNULL,
149363 TK_NOT, TK_NO, TK_NULL, TK_WHERE, TK_RECURSIVE,
149364 TK_AFTER, TK_RENAME, TK_AND, TK_DEFAULT, TK_AUTOINCR,
149365 TK_TO, TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT,
149366 TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT,
149367 TK_PARTITION, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP,
149368 TK_PRECEDING, TK_FAIL, TK_FILTER, TK_REPLACE, TK_FOLLOWING,
149369 TK_FROM, TK_JOIN_KW, TK_IF, TK_ISNULL, TK_ORDER,
149370 TK_RESTRICT, TK_OVER, TK_JOIN_KW, TK_ROLLBACK, TK_ROWS,
149371 TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING, TK_VACUUM,
149372 TK_VIEW, TK_WINDOW, TK_DO, TK_INITIALLY, TK_ALL,
149373 TK_PRIMARY,
149374 };
149375 /* Check to see if z[0..n-1] is a keyword. If it is, write the
149376 ** parser symbol code for that keyword into *pType. Always
149377 ** return the integer n (the length of the token). */
149378 static int keywordCode(const char *z, int n, int *pType){
@@ -145827,11 +149447,11 @@
149447 testcase( i==53 ); /* HAVING */
149448 testcase( i==54 ); /* GROUP */
149449 testcase( i==55 ); /* UPDATE */
149450 testcase( i==56 ); /* BEGIN */
149451 testcase( i==57 ); /* INNER */
149452 testcase( i==58 ); /* RANGE */
149453 testcase( i==59 ); /* BETWEEN */
149454 testcase( i==60 ); /* NOTHING */
149455 testcase( i==61 ); /* GLOB */
149456 testcase( i==62 ); /* BY */
149457 testcase( i==63 ); /* CASCADE */
@@ -145858,13 +149478,13 @@
149478 testcase( i==84 ); /* NOTNULL */
149479 testcase( i==85 ); /* NOT */
149480 testcase( i==86 ); /* NO */
149481 testcase( i==87 ); /* NULL */
149482 testcase( i==88 ); /* WHERE */
149483 testcase( i==89 ); /* RECURSIVE */
149484 testcase( i==90 ); /* AFTER */
149485 testcase( i==91 ); /* RENAME */
149486 testcase( i==92 ); /* AND */
149487 testcase( i==93 ); /* DEFAULT */
149488 testcase( i==94 ); /* AUTOINCREMENT */
149489 testcase( i==95 ); /* TO */
149490 testcase( i==96 ); /* IN */
@@ -145873,32 +149493,42 @@
149493 testcase( i==99 ); /* COMMIT */
149494 testcase( i==100 ); /* CONFLICT */
149495 testcase( i==101 ); /* CROSS */
149496 testcase( i==102 ); /* CURRENT_TIMESTAMP */
149497 testcase( i==103 ); /* CURRENT_TIME */
149498 testcase( i==104 ); /* CURRENT */
149499 testcase( i==105 ); /* PARTITION */
149500 testcase( i==106 ); /* DEFERRED */
149501 testcase( i==107 ); /* DISTINCT */
149502 testcase( i==108 ); /* IS */
149503 testcase( i==109 ); /* DROP */
149504 testcase( i==110 ); /* PRECEDING */
149505 testcase( i==111 ); /* FAIL */
149506 testcase( i==112 ); /* FILTER */
149507 testcase( i==113 ); /* REPLACE */
149508 testcase( i==114 ); /* FOLLOWING */
149509 testcase( i==115 ); /* FROM */
149510 testcase( i==116 ); /* FULL */
149511 testcase( i==117 ); /* IF */
149512 testcase( i==118 ); /* ISNULL */
149513 testcase( i==119 ); /* ORDER */
149514 testcase( i==120 ); /* RESTRICT */
149515 testcase( i==121 ); /* OVER */
149516 testcase( i==122 ); /* RIGHT */
149517 testcase( i==123 ); /* ROLLBACK */
149518 testcase( i==124 ); /* ROWS */
149519 testcase( i==125 ); /* ROW */
149520 testcase( i==126 ); /* UNBOUNDED */
149521 testcase( i==127 ); /* UNION */
149522 testcase( i==128 ); /* USING */
149523 testcase( i==129 ); /* VACUUM */
149524 testcase( i==130 ); /* VIEW */
149525 testcase( i==131 ); /* WINDOW */
149526 testcase( i==132 ); /* DO */
149527 testcase( i==133 ); /* INITIALLY */
149528 testcase( i==134 ); /* ALL */
149529 testcase( i==135 ); /* PRIMARY */
149530 *pType = aKWCode[i];
149531 break;
149532 }
149533 }
149534 return n;
@@ -145906,11 +149536,11 @@
149536 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
149537 int id = TK_ID;
149538 keywordCode((char*)z, n, &id);
149539 return id;
149540 }
149541 #define SQLITE_N_KEYWORD 136
149542 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
149543 if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
149544 *pzName = zKWText + aKWOffset[i];
149545 *pnName = aKWLen[i];
149546 return SQLITE_OK;
@@ -145965,10 +149595,86 @@
149595 /* Make the IdChar function accessible from ctime.c */
149596 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
149597 SQLITE_PRIVATE int sqlite3IsIdChar(u8 c){ return IdChar(c); }
149598 #endif
149599
149600 #ifndef SQLITE_OMIT_WINDOWFUNC
149601 /*
149602 ** Return the id of the next token in string (*pz). Before returning, set
149603 ** (*pz) to point to the byte following the parsed token.
149604 */
149605 static int getToken(const unsigned char **pz){
149606 const unsigned char *z = *pz;
149607 int t; /* Token type to return */
149608 do {
149609 z += sqlite3GetToken(z, &t);
149610 }while( t==TK_SPACE );
149611 if( t==TK_ID
149612 || t==TK_STRING
149613 || t==TK_JOIN_KW
149614 || t==TK_WINDOW
149615 || t==TK_OVER
149616 || sqlite3ParserFallback(t)==TK_ID
149617 ){
149618 t = TK_ID;
149619 }
149620 *pz = z;
149621 return t;
149622 }
149623
149624 /*
149625 ** The following three functions are called immediately after the tokenizer
149626 ** reads the keywords WINDOW, OVER and FILTER, respectively, to determine
149627 ** whether the token should be treated as a keyword or an SQL identifier.
149628 ** This cannot be handled by the usual lemon %fallback method, due to
149629 ** the ambiguity in some constructions. e.g.
149630 **
149631 ** SELECT sum(x) OVER ...
149632 **
149633 ** In the above, "OVER" might be a keyword, or it might be an alias for the
149634 ** sum(x) expression. If a "%fallback ID OVER" directive were added to
149635 ** grammar, then SQLite would always treat "OVER" as an alias, making it
149636 ** impossible to call a window-function without a FILTER clause.
149637 **
149638 ** WINDOW is treated as a keyword if:
149639 **
149640 ** * the following token is an identifier, or a keyword that can fallback
149641 ** to being an identifier, and
149642 ** * the token after than one is TK_AS.
149643 **
149644 ** OVER is a keyword if:
149645 **
149646 ** * the previous token was TK_RP, and
149647 ** * the next token is either TK_LP or an identifier.
149648 **
149649 ** FILTER is a keyword if:
149650 **
149651 ** * the previous token was TK_RP, and
149652 ** * the next token is TK_LP.
149653 */
149654 static int analyzeWindowKeyword(const unsigned char *z){
149655 int t;
149656 t = getToken(&z);
149657 if( t!=TK_ID ) return TK_ID;
149658 t = getToken(&z);
149659 if( t!=TK_AS ) return TK_ID;
149660 return TK_WINDOW;
149661 }
149662 static int analyzeOverKeyword(const unsigned char *z, int lastToken){
149663 if( lastToken==TK_RP ){
149664 int t = getToken(&z);
149665 if( t==TK_LP || t==TK_ID ) return TK_OVER;
149666 }
149667 return TK_ID;
149668 }
149669 static int analyzeFilterKeyword(const unsigned char *z, int lastToken){
149670 if( lastToken==TK_RP && getToken(&z)==TK_LP ){
149671 return TK_FILTER;
149672 }
149673 return TK_ID;
149674 }
149675 #endif /* SQLITE_OMIT_WINDOWFUNC */
149676
149677 /*
149678 ** Return the length (in bytes) of the token that begins at z[0].
149679 ** Store the token type in *tokenType before returning.
149680 */
@@ -146233,10 +149939,14 @@
149939 }
149940 case CC_ID: {
149941 i = 1;
149942 break;
149943 }
149944 case CC_NUL: {
149945 *tokenType = TK_ILLEGAL;
149946 return 0;
149947 }
149948 default: {
149949 *tokenType = TK_ILLEGAL;
149950 return 1;
149951 }
149952 }
@@ -146286,51 +149996,68 @@
149996 assert( pParse->pNewTable==0 );
149997 assert( pParse->pNewTrigger==0 );
149998 assert( pParse->nVar==0 );
149999 assert( pParse->pVList==0 );
150000 while( 1 ){
150001 n = sqlite3GetToken((u8*)zSql, &tokenType);
150002 mxSqlLen -= n;
150003 if( mxSqlLen<0 ){
150004 pParse->rc = SQLITE_TOOBIG;
150005 break;
150006 }
150007 #ifndef SQLITE_OMIT_WINDOWFUNC
150008 if( tokenType>=TK_WINDOW ){
150009 assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER
150010 || tokenType==TK_ILLEGAL || tokenType==TK_WINDOW
150011 );
150012 #else
 
 
 
 
 
 
 
150013 if( tokenType>=TK_SPACE ){
150014 assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );
150015 #endif /* SQLITE_OMIT_WINDOWFUNC */
150016 if( db->u1.isInterrupted ){
150017 pParse->rc = SQLITE_INTERRUPT;
150018 break;
150019 }
150020 if( tokenType==TK_SPACE ){
150021 zSql += n;
150022 continue;
150023 }
150024 if( zSql[0]==0 ){
150025 /* Upon reaching the end of input, call the parser two more times
150026 ** with tokens TK_SEMI and 0, in that order. */
150027 if( lastTokenParsed==TK_SEMI ){
150028 tokenType = 0;
150029 }else if( lastTokenParsed==0 ){
150030 break;
150031 }else{
150032 tokenType = TK_SEMI;
150033 }
150034 n = 0;
150035 #ifndef SQLITE_OMIT_WINDOWFUNC
150036 }else if( tokenType==TK_WINDOW ){
150037 assert( n==6 );
150038 tokenType = analyzeWindowKeyword((const u8*)&zSql[6]);
150039 }else if( tokenType==TK_OVER ){
150040 assert( n==4 );
150041 tokenType = analyzeOverKeyword((const u8*)&zSql[4], lastTokenParsed);
150042 }else if( tokenType==TK_FILTER ){
150043 assert( n==6 );
150044 tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
150045 #endif /* SQLITE_OMIT_WINDOWFUNC */
150046 }else{
150047 sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql);
150048 break;
150049 }
150050 }
150051 pParse->sLastToken.z = zSql;
150052 pParse->sLastToken.n = n;
150053 sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
150054 lastTokenParsed = tokenType;
150055 zSql += n;
150056 if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
 
 
150057 }
150058 assert( nErr==0 );
 
150059 #ifdef YYTRACKMAXSTACKDEPTH
150060 sqlite3_mutex_enter(sqlite3MallocMutex());
150061 sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK,
150062 sqlite3ParserStackPeak(pEngine)
150063 );
@@ -146348,14 +150075,16 @@
150075 pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
150076 }
150077 assert( pzErrMsg!=0 );
150078 if( pParse->zErrMsg ){
150079 *pzErrMsg = pParse->zErrMsg;
150080 sqlite3_log(pParse->rc, "%s in \"%s\"",
150081 *pzErrMsg, pParse->zTail);
150082 pParse->zErrMsg = 0;
150083 nErr++;
150084 }
150085 pParse->zTail = zSql;
150086 if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){
150087 sqlite3VdbeDelete(pParse->pVdbe);
150088 pParse->pVdbe = 0;
150089 }
150090 #ifndef SQLITE_OMIT_SHARED_CACHE
@@ -148467,23 +152196,27 @@
152196 int enc,
152197 void *pUserData,
152198 void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
152199 void (*xStep)(sqlite3_context*,int,sqlite3_value **),
152200 void (*xFinal)(sqlite3_context*),
152201 void (*xValue)(sqlite3_context*),
152202 void (*xInverse)(sqlite3_context*,int,sqlite3_value **),
152203 FuncDestructor *pDestructor
152204 ){
152205 FuncDef *p;
152206 int nName;
152207 int extraFlags;
152208
152209 assert( sqlite3_mutex_held(db->mutex) );
152210 assert( xValue==0 || xSFunc==0 );
152211 if( zFunctionName==0 /* Must have a valid name */
152212 || (xSFunc!=0 && xFinal!=0) /* Not both xSFunc and xFinal */
152213 || ((xFinal==0)!=(xStep==0)) /* Both or neither of xFinal and xStep */
152214 || ((xValue==0)!=(xInverse==0)) /* Both or neither of xValue, xInverse */
152215 || (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG)
152216 || (255<(nName = sqlite3Strlen30( zFunctionName)))
152217 ){
152218 return SQLITE_MISUSE_BKPT;
152219 }
152220
152221 assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
152222 extraFlags = enc & SQLITE_DETERMINISTIC;
@@ -148500,14 +152233,14 @@
152233 if( enc==SQLITE_UTF16 ){
152234 enc = SQLITE_UTF16NATIVE;
152235 }else if( enc==SQLITE_ANY ){
152236 int rc;
152237 rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8|extraFlags,
152238 pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
152239 if( rc==SQLITE_OK ){
152240 rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE|extraFlags,
152241 pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
152242 }
152243 if( rc!=SQLITE_OK ){
152244 return rc;
152245 }
152246 enc = SQLITE_UTF16BE;
@@ -148520,11 +152253,11 @@
152253 ** and there are active VMs, then return SQLITE_BUSY. If a function
152254 ** is being overridden/deleted but there are no active VMs, allow the
152255 ** operation to continue but invalidate all precompiled statements.
152256 */
152257 p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 0);
152258 if( p && (p->funcFlags & SQLITE_FUNC_ENCMASK)==(u32)enc && p->nArg==nArg ){
152259 if( db->nVdbeActive ){
152260 sqlite3ErrorWithMsg(db, SQLITE_BUSY,
152261 "unable to delete/modify user-function due to active statements");
152262 assert( !db->mallocFailed );
152263 return SQLITE_BUSY;
@@ -148549,42 +152282,36 @@
152282 p->u.pDestructor = pDestructor;
152283 p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags;
152284 testcase( p->funcFlags & SQLITE_DETERMINISTIC );
152285 p->xSFunc = xSFunc ? xSFunc : xStep;
152286 p->xFinalize = xFinal;
152287 p->xValue = xValue;
152288 p->xInverse = xInverse;
152289 p->pUserData = pUserData;
152290 p->nArg = (u16)nArg;
152291 return SQLITE_OK;
152292 }
152293
152294 /*
152295 ** Worker function used by utf-8 APIs that create new functions:
152296 **
152297 ** sqlite3_create_function()
152298 ** sqlite3_create_function_v2()
152299 ** sqlite3_create_window_function()
152300 */
152301 static int createFunctionApi(
152302 sqlite3 *db,
152303 const char *zFunc,
152304 int nArg,
152305 int enc,
152306 void *p,
152307 void (*xSFunc)(sqlite3_context*,int,sqlite3_value**),
152308 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152309 void (*xFinal)(sqlite3_context*),
152310 void (*xValue)(sqlite3_context*),
152311 void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
152312 void(*xDestroy)(void*)
152313 ){
152314 int rc = SQLITE_ERROR;
152315 FuncDestructor *pArg = 0;
152316
152317 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -148602,11 +152329,13 @@
152329 }
152330 pArg->nRef = 0;
152331 pArg->xDestroy = xDestroy;
152332 pArg->pUserData = p;
152333 }
152334 rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p,
152335 xSFunc, xStep, xFinal, xValue, xInverse, pArg
152336 );
152337 if( pArg && pArg->nRef==0 ){
152338 assert( rc!=SQLITE_OK );
152339 xDestroy(p);
152340 sqlite3_free(pArg);
152341 }
@@ -148614,10 +152343,56 @@
152343 out:
152344 rc = sqlite3ApiExit(db, rc);
152345 sqlite3_mutex_leave(db->mutex);
152346 return rc;
152347 }
152348
152349 /*
152350 ** Create new user functions.
152351 */
152352 SQLITE_API int sqlite3_create_function(
152353 sqlite3 *db,
152354 const char *zFunc,
152355 int nArg,
152356 int enc,
152357 void *p,
152358 void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
152359 void (*xStep)(sqlite3_context*,int,sqlite3_value **),
152360 void (*xFinal)(sqlite3_context*)
152361 ){
152362 return createFunctionApi(db, zFunc, nArg, enc, p, xSFunc, xStep,
152363 xFinal, 0, 0, 0);
152364 }
152365 SQLITE_API int sqlite3_create_function_v2(
152366 sqlite3 *db,
152367 const char *zFunc,
152368 int nArg,
152369 int enc,
152370 void *p,
152371 void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
152372 void (*xStep)(sqlite3_context*,int,sqlite3_value **),
152373 void (*xFinal)(sqlite3_context*),
152374 void (*xDestroy)(void *)
152375 ){
152376 return createFunctionApi(db, zFunc, nArg, enc, p, xSFunc, xStep,
152377 xFinal, 0, 0, xDestroy);
152378 }
152379 SQLITE_API int sqlite3_create_window_function(
152380 sqlite3 *db,
152381 const char *zFunc,
152382 int nArg,
152383 int enc,
152384 void *p,
152385 void (*xStep)(sqlite3_context*,int,sqlite3_value **),
152386 void (*xFinal)(sqlite3_context*),
152387 void (*xValue)(sqlite3_context*),
152388 void (*xInverse)(sqlite3_context*,int,sqlite3_value **),
152389 void (*xDestroy)(void *)
152390 ){
152391 return createFunctionApi(db, zFunc, nArg, enc, p, 0, xStep,
152392 xFinal, xValue, xInverse, xDestroy);
152393 }
152394
152395 #ifndef SQLITE_OMIT_UTF16
152396 SQLITE_API int sqlite3_create_function16(
152397 sqlite3 *db,
152398 const void *zFunctionName,
@@ -148635,11 +152410,11 @@
152410 if( !sqlite3SafetyCheckOk(db) || zFunctionName==0 ) return SQLITE_MISUSE_BKPT;
152411 #endif
152412 sqlite3_mutex_enter(db->mutex);
152413 assert( !db->mallocFailed );
152414 zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);
152415 rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xSFunc,xStep,xFinal,0,0,0);
152416 sqlite3DbFree(db, zFunc8);
152417 rc = sqlite3ApiExit(db, rc);
152418 sqlite3_mutex_leave(db->mutex);
152419 return rc;
152420 }
@@ -150712,11 +154487,12 @@
154487 ** Set the VDBE coverage callback function to xCallback with context
154488 ** pointer ptr.
154489 */
154490 case SQLITE_TESTCTRL_VDBE_COVERAGE: {
154491 #ifdef SQLITE_VDBE_COVERAGE
154492 typedef void (*branch_callback)(void*,unsigned int,
154493 unsigned char,unsigned char);
154494 sqlite3GlobalConfig.xVdbeBranch = va_arg(ap,branch_callback);
154495 sqlite3GlobalConfig.pVdbeBranchArg = va_arg(ap,void*);
154496 #endif
154497 break;
154498 }
@@ -150899,11 +154675,11 @@
154675 if( db->autoCommit==0 ){
154676 int iDb = sqlite3FindDbName(db, zDb);
154677 if( iDb==0 || iDb>1 ){
154678 Btree *pBt = db->aDb[iDb].pBt;
154679 if( 0==sqlite3BtreeIsInTrans(pBt) ){
154680 rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
154681 if( rc==SQLITE_OK ){
154682 rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
154683 }
154684 }
154685 }
@@ -150937,11 +154713,11 @@
154713 if( iDb==0 || iDb>1 ){
154714 Btree *pBt = db->aDb[iDb].pBt;
154715 if( 0==sqlite3BtreeIsInReadTrans(pBt) ){
154716 rc = sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), pSnapshot);
154717 if( rc==SQLITE_OK ){
154718 rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
154719 sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), 0);
154720 }
154721 }
154722 }
154723 }
@@ -150969,11 +154745,11 @@
154745 sqlite3_mutex_enter(db->mutex);
154746 iDb = sqlite3FindDbName(db, zDb);
154747 if( iDb==0 || iDb>1 ){
154748 Btree *pBt = db->aDb[iDb].pBt;
154749 if( 0==sqlite3BtreeIsInReadTrans(pBt) ){
154750 rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
154751 if( rc==SQLITE_OK ){
154752 rc = sqlite3PagerSnapshotRecover(sqlite3BtreePager(pBt));
154753 sqlite3BtreeCommit(pBt);
154754 }
154755 }
@@ -182309,11 +186085,11 @@
186085 DbpageTable *pTab = (DbpageTable *)pVtab;
186086 sqlite3 *db = pTab->db;
186087 int i;
186088 for(i=0; i<db->nDb; i++){
186089 Btree *pBt = db->aDb[i].pBt;
186090 if( pBt ) sqlite3BtreeBeginTrans(pBt, 1, 0);
186091 }
186092 return SQLITE_OK;
186093 }
186094
186095
@@ -189536,29 +193312,79 @@
193312 pStr->pCtx = ctx;
193313 }
193314 jsonAppendValue(pStr, argv[0]);
193315 }
193316 }
193317 static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){
193318 JsonString *pStr;
193319 pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
193320 if( pStr ){
193321 pStr->pCtx = ctx;
193322 jsonAppendChar(pStr, ']');
193323 if( pStr->bErr ){
193324 if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);
193325 assert( pStr->bStatic );
193326 }else if( isFinal ){
193327 sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,
193328 pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);
193329 pStr->bStatic = 1;
193330 }else{
193331 sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, SQLITE_TRANSIENT);
193332 pStr->nUsed--;
193333 }
193334 }else{
193335 sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC);
193336 }
193337 sqlite3_result_subtype(ctx, JSON_SUBTYPE);
193338 }
193339 static void jsonArrayValue(sqlite3_context *ctx){
193340 jsonArrayCompute(ctx, 0);
193341 }
193342 static void jsonArrayFinal(sqlite3_context *ctx){
193343 jsonArrayCompute(ctx, 1);
193344 }
193345
193346 #ifndef SQLITE_OMIT_WINDOWFUNC
193347 /*
193348 ** This method works for both json_group_array() and json_group_object().
193349 ** It works by removing the first element of the group by searching forward
193350 ** to the first comma (",") that is not within a string and deleting all
193351 ** text through that comma.
193352 */
193353 static void jsonGroupInverse(
193354 sqlite3_context *ctx,
193355 int argc,
193356 sqlite3_value **argv
193357 ){
193358 int i;
193359 int inStr = 0;
193360 char *z;
193361 JsonString *pStr;
193362 UNUSED_PARAM(argc);
193363 UNUSED_PARAM(argv);
193364 pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
193365 #ifdef NEVER
193366 /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will
193367 ** always have been called to initalize it */
193368 if( NEVER(!pStr) ) return;
193369 #endif
193370 z = pStr->zBuf;
193371 for(i=1; z[i]!=',' || inStr; i++){
193372 assert( i<pStr->nUsed );
193373 if( z[i]=='"' ){
193374 inStr = !inStr;
193375 }else if( z[i]=='\\' ){
193376 i++;
193377 }
193378 }
193379 pStr->nUsed -= i;
193380 memmove(&z[1], &z[i+1], pStr->nUsed-1);
193381 }
193382 #else
193383 # define jsonGroupInverse 0
193384 #endif
193385
193386
193387 /*
193388 ** json_group_obj(NAME,VALUE)
193389 **
193390 ** Return a JSON object composed of all names and values in the aggregate.
@@ -189586,28 +193412,38 @@
193412 jsonAppendString(pStr, z, n);
193413 jsonAppendChar(pStr, ':');
193414 jsonAppendValue(pStr, argv[1]);
193415 }
193416 }
193417 static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){
193418 JsonString *pStr;
193419 pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
193420 if( pStr ){
193421 jsonAppendChar(pStr, '}');
193422 if( pStr->bErr ){
193423 if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);
193424 assert( pStr->bStatic );
193425 }else if( isFinal ){
193426 sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,
193427 pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);
193428 pStr->bStatic = 1;
193429 }else{
193430 sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, SQLITE_TRANSIENT);
193431 pStr->nUsed--;
193432 }
193433 }else{
193434 sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC);
193435 }
193436 sqlite3_result_subtype(ctx, JSON_SUBTYPE);
193437 }
193438 static void jsonObjectValue(sqlite3_context *ctx){
193439 jsonObjectCompute(ctx, 0);
193440 }
193441 static void jsonObjectFinal(sqlite3_context *ctx){
193442 jsonObjectCompute(ctx, 1);
193443 }
193444
193445
193446
193447 #ifndef SQLITE_OMIT_VIRTUALTABLE
193448 /****************************************************************************
193449 ** The json_each virtual table
@@ -190111,13 +193947,16 @@
193947 static const struct {
193948 const char *zName;
193949 int nArg;
193950 void (*xStep)(sqlite3_context*,int,sqlite3_value**);
193951 void (*xFinal)(sqlite3_context*);
193952 void (*xValue)(sqlite3_context*);
193953 } aAgg[] = {
193954 { "json_group_array", 1,
193955 jsonArrayStep, jsonArrayFinal, jsonArrayValue },
193956 { "json_group_object", 2,
193957 jsonObjectStep, jsonObjectFinal, jsonObjectValue },
193958 };
193959 #ifndef SQLITE_OMIT_VIRTUALTABLE
193960 static const struct {
193961 const char *zName;
193962 sqlite3_module *pModule;
@@ -190131,13 +193970,14 @@
193970 SQLITE_UTF8 | SQLITE_DETERMINISTIC,
193971 (void*)&aFunc[i].flag,
193972 aFunc[i].xFunc, 0, 0);
193973 }
193974 for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
193975 rc = sqlite3_create_window_function(db, aAgg[i].zName, aAgg[i].nArg,
193976 SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
193977 aAgg[i].xStep, aAgg[i].xFinal,
193978 aAgg[i].xValue, jsonGroupInverse, 0);
193979 }
193980 #ifndef SQLITE_OMIT_VIRTUALTABLE
193981 for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
193982 rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
193983 }
@@ -191539,13 +195379,16 @@
195379
195380
195381 /**************************************************************************
195382 ** Interface to automatically generated code in fts5_unicode2.c.
195383 */
 
195384 static int sqlite3Fts5UnicodeIsdiacritic(int c);
195385 static int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);
195386
195387 static int sqlite3Fts5UnicodeCatParse(const char*, u8*);
195388 static int sqlite3Fts5UnicodeCategory(int iCode);
195389 static void sqlite3Fts5UnicodeAscii(u8*, u8*);
195390 /*
195391 ** End of interface to code in fts5_unicode2.c.
195392 **************************************************************************/
195393
195394 #endif
@@ -191717,10 +195560,11 @@
195560 #define fts5YY_ACCEPT_ACTION 81
195561 #define fts5YY_NO_ACTION 82
195562 #define fts5YY_MIN_REDUCE 83
195563 #define fts5YY_MAX_REDUCE 110
195564 /************* End control #defines *******************************************/
195565 #define fts5YY_NLOOKAHEAD ((int)(sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0])))
195566
195567 /* Define the fts5yytestcase() macro to be a no-op if is not already defined
195568 ** otherwise.
195569 **
195570 ** Applications can choose to define fts5yytestcase() in the %include section
@@ -192276,15 +196120,15 @@
196120 fts5yycoverage[stateno][iLookAhead] = 1;
196121 #endif
196122 do{
196123 i = fts5yy_shift_ofst[stateno];
196124 assert( i>=0 );
196125 /* assert( i+fts5YYNFTS5TOKEN<=(int)fts5YY_NLOOKAHEAD ); */
196126 assert( iLookAhead!=fts5YYNOCODE );
196127 assert( iLookAhead < fts5YYNFTS5TOKEN );
196128 i += iLookAhead;
196129 if( i>=fts5YY_NLOOKAHEAD || fts5yy_lookahead[i]!=iLookAhead ){
196130 #ifdef fts5YYFALLBACK
196131 fts5YYCODETYPE iFallback; /* Fallback token */
196132 if( iLookAhead<sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])
196133 && (iFallback = fts5yyFallback[iLookAhead])!=0 ){
196134 #ifndef NDEBUG
@@ -192306,10 +196150,11 @@
196150 j>=0 &&
196151 #endif
196152 #if fts5YY_SHIFT_MAX+fts5YYWILDCARD>=fts5YY_ACTTAB_COUNT
196153 j<fts5YY_ACTTAB_COUNT &&
196154 #endif
196155 j<(int)(sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0])) &&
196156 fts5yy_lookahead[j]==fts5YYWILDCARD && iLookAhead>0
196157 ){
196158 #ifndef NDEBUG
196159 if( fts5yyTraceFILE ){
196160 fprintf(fts5yyTraceFILE, "%sWILDCARD %s => %s\n",
@@ -192986,10 +196831,25 @@
196831 fprintf(fts5yyTraceFILE,"]\n");
196832 }
196833 #endif
196834 return;
196835 }
196836
196837 /*
196838 ** Return the fallback token corresponding to canonical token iToken, or
196839 ** 0 if iToken has no fallback.
196840 */
196841 static int sqlite3Fts5ParserFallback(int iToken){
196842 #ifdef fts5YYFALLBACK
196843 if( iToken<(int)(sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])) ){
196844 return fts5yyFallback[iToken];
196845 }
196846 #else
196847 (void)iToken;
196848 #endif
196849 return 0;
196850 }
196851
196852 /*
196853 ** 2014 May 31
196854 **
196855 ** The author disclaims copyright to this source code. In place of
@@ -195097,10 +198957,11 @@
198957 static void sqlite3Fts5Parser(void*, int, Fts5Token, Fts5Parse*);
198958 #ifndef NDEBUG
198959 /* #include <stdio.h> */
198960 static void sqlite3Fts5ParserTrace(FILE*, char*);
198961 #endif
198962 static int sqlite3Fts5ParserFallback(int);
198963
198964
198965 struct Fts5Expr {
198966 Fts5Index *pIndex;
198967 Fts5Config *pConfig;
@@ -197601,18 +201462,23 @@
201462 sqlite3_context *pCtx, /* Function call context */
201463 int nArg, /* Number of args */
201464 sqlite3_value **apVal /* Function arguments */
201465 ){
201466 int iCode;
201467 u8 aArr[32];
201468 if( nArg!=1 ){
201469 sqlite3_result_error(pCtx,
201470 "wrong number of arguments to function fts5_isalnum", -1
201471 );
201472 return;
201473 }
201474 memset(aArr, 0, sizeof(aArr));
201475 sqlite3Fts5UnicodeCatParse("L*", aArr);
201476 sqlite3Fts5UnicodeCatParse("N*", aArr);
201477 sqlite3Fts5UnicodeCatParse("Co", aArr);
201478 iCode = sqlite3_value_int(apVal[0]);
201479 sqlite3_result_int(pCtx, aArr[sqlite3Fts5UnicodeCategory(iCode)]);
201480 }
201481
201482 static void fts5ExprFold(
201483 sqlite3_context *pCtx, /* Function call context */
201484 int nArg, /* Number of args */
@@ -197652,14 +201518,16 @@
201518 for(i=0; rc==SQLITE_OK && i<ArraySize(aFunc); i++){
201519 struct Fts5ExprFunc *p = &aFunc[i];
201520 rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0);
201521 }
201522
201523 /* Avoid warnings indicating that sqlite3Fts5ParserTrace() and
201524 ** sqlite3Fts5ParserFallback() are unused */
201525 #ifndef NDEBUG
201526 (void)sqlite3Fts5ParserTrace;
201527 #endif
201528 (void)sqlite3Fts5ParserFallback;
201529
201530 return rc;
201531 }
201532
201533 /*
@@ -207583,11 +211451,11 @@
211451 int nArg, /* Number of args */
211452 sqlite3_value **apUnused /* Function arguments */
211453 ){
211454 assert( nArg==0 );
211455 UNUSED_PARAM2(nArg, apUnused);
211456 sqlite3_result_text(pCtx, "fts5: 2018-07-13 20:28:54 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb36212426b1", -1, SQLITE_TRANSIENT);
211457 }
211458
211459 static int fts5Init(sqlite3 *db){
211460 static const sqlite3_module fts5Mod = {
211461 /* iVersion */ 2,
@@ -209071,10 +212939,12 @@
212939 char *aFold; /* Buffer to fold text into */
212940 int nFold; /* Size of aFold[] in bytes */
212941 int bRemoveDiacritic; /* True if remove_diacritics=1 is set */
212942 int nException;
212943 int *aiException;
212944
212945 unsigned char aCategory[32]; /* True for token char categories */
212946 };
212947
212948 static int fts5UnicodeAddExceptions(
212949 Unicode61Tokenizer *p, /* Tokenizer object */
212950 const char *z, /* Characters to treat as exceptions */
@@ -209095,11 +212965,11 @@
212965 int bToken;
212966 READ_UTF8(zCsr, zTerm, iCode);
212967 if( iCode<128 ){
212968 p->aTokenChar[iCode] = (unsigned char)bTokenChars;
212969 }else{
212970 bToken = p->aCategory[sqlite3Fts5UnicodeCategory(iCode)];
212971 assert( (bToken==0 || bToken==1) );
212972 assert( (bTokenChars==0 || bTokenChars==1) );
212973 if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){
212974 int i;
212975 for(i=0; i<nNew; i++){
@@ -209155,10 +213025,25 @@
213025 sqlite3_free(p->aFold);
213026 sqlite3_free(p);
213027 }
213028 return;
213029 }
213030
213031 static int unicodeSetCategories(Unicode61Tokenizer *p, const char *zCat){
213032 const char *z = zCat;
213033
213034 while( *z ){
213035 while( *z==' ' || *z=='\t' ) z++;
213036 if( *z && sqlite3Fts5UnicodeCatParse(z, p->aCategory) ){
213037 return SQLITE_ERROR;
213038 }
213039 while( *z!=' ' && *z!='\t' && *z!='\0' ) z++;
213040 }
213041
213042 sqlite3Fts5UnicodeAscii(p->aCategory, p->aTokenChar);
213043 return SQLITE_OK;
213044 }
213045
213046 /*
213047 ** Create a "unicode61" tokenizer.
213048 */
213049 static int fts5UnicodeCreate(
@@ -209174,19 +213059,32 @@
213059 if( nArg%2 ){
213060 rc = SQLITE_ERROR;
213061 }else{
213062 p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer));
213063 if( p ){
213064 const char *zCat = "L* N* Co";
213065 int i;
213066 memset(p, 0, sizeof(Unicode61Tokenizer));
213067
213068 p->bRemoveDiacritic = 1;
213069 p->nFold = 64;
213070 p->aFold = sqlite3_malloc(p->nFold * sizeof(char));
213071 if( p->aFold==0 ){
213072 rc = SQLITE_NOMEM;
213073 }
213074
213075 /* Search for a "categories" argument */
213076 for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
213077 if( 0==sqlite3_stricmp(azArg[i], "categories") ){
213078 zCat = azArg[i+1];
213079 }
213080 }
213081
213082 if( rc==SQLITE_OK ){
213083 rc = unicodeSetCategories(p, zCat);
213084 }
213085
213086 for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
213087 const char *zArg = azArg[i+1];
213088 if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){
213089 if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1] ){
213090 rc = SQLITE_ERROR;
@@ -209196,14 +213094,18 @@
213094 if( 0==sqlite3_stricmp(azArg[i], "tokenchars") ){
213095 rc = fts5UnicodeAddExceptions(p, zArg, 1);
213096 }else
213097 if( 0==sqlite3_stricmp(azArg[i], "separators") ){
213098 rc = fts5UnicodeAddExceptions(p, zArg, 0);
213099 }else
213100 if( 0==sqlite3_stricmp(azArg[i], "categories") ){
213101 /* no-op */
213102 }else{
213103 rc = SQLITE_ERROR;
213104 }
213105 }
213106
213107 }else{
213108 rc = SQLITE_NOMEM;
213109 }
213110 if( rc!=SQLITE_OK ){
213111 fts5UnicodeDelete((Fts5Tokenizer*)p);
@@ -209218,12 +213120,14 @@
213120 ** Return true if, for the purposes of tokenizing with the tokenizer
213121 ** passed as the first argument, codepoint iCode is considered a token
213122 ** character (not a separator).
213123 */
213124 static int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){
213125 return (
213126 p->aCategory[sqlite3Fts5UnicodeCategory(iCode)]
213127 ^ fts5UnicodeIsException(p, iCode)
213128 );
213129 }
213130
213131 static int fts5UnicodeTokenize(
213132 Fts5Tokenizer *pTokenizer,
213133 void *pCtx,
@@ -210095,139 +213999,10 @@
213999 */
214000
214001
214002 /* #include <assert.h> */
214003
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214004
214005
214006 /*
214007 ** If the argument is a codepoint corresponding to a lowercase letter
214008 ** in the ASCII range with a diacritic added, return the codepoint
@@ -210435,10 +214210,543 @@
214210 ret = c + 40;
214211 }
214212
214213 return ret;
214214 }
214215
214216
214217 #if 0
214218 static int sqlite3Fts5UnicodeNCat(void) {
214219 return 32;
214220 }
214221 #endif
214222
214223 static int sqlite3Fts5UnicodeCatParse(const char *zCat, u8 *aArray){
214224 aArray[0] = 1;
214225 switch( zCat[0] ){
214226 case 'C':
214227 switch( zCat[1] ){
214228 case 'c': aArray[1] = 1; break;
214229 case 'f': aArray[2] = 1; break;
214230 case 'n': aArray[3] = 1; break;
214231 case 's': aArray[4] = 1; break;
214232 case 'o': aArray[31] = 1; break;
214233 case '*':
214234 aArray[1] = 1;
214235 aArray[2] = 1;
214236 aArray[3] = 1;
214237 aArray[4] = 1;
214238 aArray[31] = 1;
214239 break;
214240 default: return 1; }
214241 break;
214242
214243 case 'L':
214244 switch( zCat[1] ){
214245 case 'l': aArray[5] = 1; break;
214246 case 'm': aArray[6] = 1; break;
214247 case 'o': aArray[7] = 1; break;
214248 case 't': aArray[8] = 1; break;
214249 case 'u': aArray[9] = 1; break;
214250 case 'C': aArray[30] = 1; break;
214251 case '*':
214252 aArray[5] = 1;
214253 aArray[6] = 1;
214254 aArray[7] = 1;
214255 aArray[8] = 1;
214256 aArray[9] = 1;
214257 aArray[30] = 1;
214258 break;
214259 default: return 1; }
214260 break;
214261
214262 case 'M':
214263 switch( zCat[1] ){
214264 case 'c': aArray[10] = 1; break;
214265 case 'e': aArray[11] = 1; break;
214266 case 'n': aArray[12] = 1; break;
214267 case '*':
214268 aArray[10] = 1;
214269 aArray[11] = 1;
214270 aArray[12] = 1;
214271 break;
214272 default: return 1; }
214273 break;
214274
214275 case 'N':
214276 switch( zCat[1] ){
214277 case 'd': aArray[13] = 1; break;
214278 case 'l': aArray[14] = 1; break;
214279 case 'o': aArray[15] = 1; break;
214280 case '*':
214281 aArray[13] = 1;
214282 aArray[14] = 1;
214283 aArray[15] = 1;
214284 break;
214285 default: return 1; }
214286 break;
214287
214288 case 'P':
214289 switch( zCat[1] ){
214290 case 'c': aArray[16] = 1; break;
214291 case 'd': aArray[17] = 1; break;
214292 case 'e': aArray[18] = 1; break;
214293 case 'f': aArray[19] = 1; break;
214294 case 'i': aArray[20] = 1; break;
214295 case 'o': aArray[21] = 1; break;
214296 case 's': aArray[22] = 1; break;
214297 case '*':
214298 aArray[16] = 1;
214299 aArray[17] = 1;
214300 aArray[18] = 1;
214301 aArray[19] = 1;
214302 aArray[20] = 1;
214303 aArray[21] = 1;
214304 aArray[22] = 1;
214305 break;
214306 default: return 1; }
214307 break;
214308
214309 case 'S':
214310 switch( zCat[1] ){
214311 case 'c': aArray[23] = 1; break;
214312 case 'k': aArray[24] = 1; break;
214313 case 'm': aArray[25] = 1; break;
214314 case 'o': aArray[26] = 1; break;
214315 case '*':
214316 aArray[23] = 1;
214317 aArray[24] = 1;
214318 aArray[25] = 1;
214319 aArray[26] = 1;
214320 break;
214321 default: return 1; }
214322 break;
214323
214324 case 'Z':
214325 switch( zCat[1] ){
214326 case 'l': aArray[27] = 1; break;
214327 case 'p': aArray[28] = 1; break;
214328 case 's': aArray[29] = 1; break;
214329 case '*':
214330 aArray[27] = 1;
214331 aArray[28] = 1;
214332 aArray[29] = 1;
214333 break;
214334 default: return 1; }
214335 break;
214336
214337 }
214338 return 0;
214339 }
214340
214341 static u16 aFts5UnicodeBlock[] = {
214342 0, 1471, 1753, 1760, 1760, 1760, 1760, 1760, 1760, 1760,
214343 1760, 1760, 1760, 1760, 1760, 1763, 1765,
214344 };
214345 static u16 aFts5UnicodeMap[] = {
214346 0, 32, 33, 36, 37, 40, 41, 42, 43, 44,
214347 45, 46, 48, 58, 60, 63, 65, 91, 92, 93,
214348 94, 95, 96, 97, 123, 124, 125, 126, 127, 160,
214349 161, 162, 166, 167, 168, 169, 170, 171, 172, 173,
214350 174, 175, 176, 177, 178, 180, 181, 182, 184, 185,
214351 186, 187, 188, 191, 192, 215, 216, 223, 247, 248,
214352 256, 312, 313, 329, 330, 377, 383, 385, 387, 388,
214353 391, 394, 396, 398, 402, 403, 405, 406, 409, 412,
214354 414, 415, 417, 418, 423, 427, 428, 431, 434, 436,
214355 437, 440, 442, 443, 444, 446, 448, 452, 453, 454,
214356 455, 456, 457, 458, 459, 460, 461, 477, 478, 496,
214357 497, 498, 499, 500, 503, 505, 506, 564, 570, 572,
214358 573, 575, 577, 580, 583, 584, 592, 660, 661, 688,
214359 706, 710, 722, 736, 741, 748, 749, 750, 751, 768,
214360 880, 884, 885, 886, 890, 891, 894, 900, 902, 903,
214361 904, 908, 910, 912, 913, 931, 940, 975, 977, 978,
214362 981, 984, 1008, 1012, 1014, 1015, 1018, 1020, 1021, 1072,
214363 1120, 1154, 1155, 1160, 1162, 1217, 1231, 1232, 1329, 1369,
214364 1370, 1377, 1417, 1418, 1423, 1425, 1470, 1471, 1472, 1473,
214365 1475, 1476, 1478, 1479, 1488, 1520, 1523, 1536, 1542, 1545,
214366 1547, 1548, 1550, 1552, 1563, 1566, 1568, 1600, 1601, 1611,
214367 1632, 1642, 1646, 1648, 1649, 1748, 1749, 1750, 1757, 1758,
214368 1759, 1765, 1767, 1769, 1770, 1774, 1776, 1786, 1789, 1791,
214369 1792, 1807, 1808, 1809, 1810, 1840, 1869, 1958, 1969, 1984,
214370 1994, 2027, 2036, 2038, 2039, 2042, 2048, 2070, 2074, 2075,
214371 2084, 2085, 2088, 2089, 2096, 2112, 2137, 2142, 2208, 2210,
214372 2276, 2304, 2307, 2308, 2362, 2363, 2364, 2365, 2366, 2369,
214373 2377, 2381, 2382, 2384, 2385, 2392, 2402, 2404, 2406, 2416,
214374 2417, 2418, 2425, 2433, 2434, 2437, 2447, 2451, 2474, 2482,
214375 2486, 2492, 2493, 2494, 2497, 2503, 2507, 2509, 2510, 2519,
214376 2524, 2527, 2530, 2534, 2544, 2546, 2548, 2554, 2555, 2561,
214377 2563, 2565, 2575, 2579, 2602, 2610, 2613, 2616, 2620, 2622,
214378 2625, 2631, 2635, 2641, 2649, 2654, 2662, 2672, 2674, 2677,
214379 2689, 2691, 2693, 2703, 2707, 2730, 2738, 2741, 2748, 2749,
214380 2750, 2753, 2759, 2761, 2763, 2765, 2768, 2784, 2786, 2790,
214381 2800, 2801, 2817, 2818, 2821, 2831, 2835, 2858, 2866, 2869,
214382 2876, 2877, 2878, 2879, 2880, 2881, 2887, 2891, 2893, 2902,
214383 2903, 2908, 2911, 2914, 2918, 2928, 2929, 2930, 2946, 2947,
214384 2949, 2958, 2962, 2969, 2972, 2974, 2979, 2984, 2990, 3006,
214385 3008, 3009, 3014, 3018, 3021, 3024, 3031, 3046, 3056, 3059,
214386 3065, 3066, 3073, 3077, 3086, 3090, 3114, 3125, 3133, 3134,
214387 3137, 3142, 3146, 3157, 3160, 3168, 3170, 3174, 3192, 3199,
214388 3202, 3205, 3214, 3218, 3242, 3253, 3260, 3261, 3262, 3263,
214389 3264, 3270, 3271, 3274, 3276, 3285, 3294, 3296, 3298, 3302,
214390 3313, 3330, 3333, 3342, 3346, 3389, 3390, 3393, 3398, 3402,
214391 3405, 3406, 3415, 3424, 3426, 3430, 3440, 3449, 3450, 3458,
214392 3461, 3482, 3507, 3517, 3520, 3530, 3535, 3538, 3542, 3544,
214393 3570, 3572, 3585, 3633, 3634, 3636, 3647, 3648, 3654, 3655,
214394 3663, 3664, 3674, 3713, 3716, 3719, 3722, 3725, 3732, 3737,
214395 3745, 3749, 3751, 3754, 3757, 3761, 3762, 3764, 3771, 3773,
214396 3776, 3782, 3784, 3792, 3804, 3840, 3841, 3844, 3859, 3860,
214397 3861, 3864, 3866, 3872, 3882, 3892, 3893, 3894, 3895, 3896,
214398 3897, 3898, 3899, 3900, 3901, 3902, 3904, 3913, 3953, 3967,
214399 3968, 3973, 3974, 3976, 3981, 3993, 4030, 4038, 4039, 4046,
214400 4048, 4053, 4057, 4096, 4139, 4141, 4145, 4146, 4152, 4153,
214401 4155, 4157, 4159, 4160, 4170, 4176, 4182, 4184, 4186, 4190,
214402 4193, 4194, 4197, 4199, 4206, 4209, 4213, 4226, 4227, 4229,
214403 4231, 4237, 4238, 4239, 4240, 4250, 4253, 4254, 4256, 4295,
214404 4301, 4304, 4347, 4348, 4349, 4682, 4688, 4696, 4698, 4704,
214405 4746, 4752, 4786, 4792, 4800, 4802, 4808, 4824, 4882, 4888,
214406 4957, 4960, 4969, 4992, 5008, 5024, 5120, 5121, 5741, 5743,
214407 5760, 5761, 5787, 5788, 5792, 5867, 5870, 5888, 5902, 5906,
214408 5920, 5938, 5941, 5952, 5970, 5984, 5998, 6002, 6016, 6068,
214409 6070, 6071, 6078, 6086, 6087, 6089, 6100, 6103, 6104, 6107,
214410 6108, 6109, 6112, 6128, 6144, 6150, 6151, 6155, 6158, 6160,
214411 6176, 6211, 6212, 6272, 6313, 6314, 6320, 6400, 6432, 6435,
214412 6439, 6441, 6448, 6450, 6451, 6457, 6464, 6468, 6470, 6480,
214413 6512, 6528, 6576, 6593, 6600, 6608, 6618, 6622, 6656, 6679,
214414 6681, 6686, 6688, 6741, 6742, 6743, 6744, 6752, 6753, 6754,
214415 6755, 6757, 6765, 6771, 6783, 6784, 6800, 6816, 6823, 6824,
214416 6912, 6916, 6917, 6964, 6965, 6966, 6971, 6972, 6973, 6978,
214417 6979, 6981, 6992, 7002, 7009, 7019, 7028, 7040, 7042, 7043,
214418 7073, 7074, 7078, 7080, 7082, 7083, 7084, 7086, 7088, 7098,
214419 7142, 7143, 7144, 7146, 7149, 7150, 7151, 7154, 7164, 7168,
214420 7204, 7212, 7220, 7222, 7227, 7232, 7245, 7248, 7258, 7288,
214421 7294, 7360, 7376, 7379, 7380, 7393, 7394, 7401, 7405, 7406,
214422 7410, 7412, 7413, 7424, 7468, 7531, 7544, 7545, 7579, 7616,
214423 7676, 7680, 7830, 7838, 7936, 7944, 7952, 7960, 7968, 7976,
214424 7984, 7992, 8000, 8008, 8016, 8025, 8027, 8029, 8031, 8033,
214425 8040, 8048, 8064, 8072, 8080, 8088, 8096, 8104, 8112, 8118,
214426 8120, 8124, 8125, 8126, 8127, 8130, 8134, 8136, 8140, 8141,
214427 8144, 8150, 8152, 8157, 8160, 8168, 8173, 8178, 8182, 8184,
214428 8188, 8189, 8192, 8203, 8208, 8214, 8216, 8217, 8218, 8219,
214429 8221, 8222, 8223, 8224, 8232, 8233, 8234, 8239, 8240, 8249,
214430 8250, 8251, 8255, 8257, 8260, 8261, 8262, 8263, 8274, 8275,
214431 8276, 8277, 8287, 8288, 8298, 8304, 8305, 8308, 8314, 8317,
214432 8318, 8319, 8320, 8330, 8333, 8334, 8336, 8352, 8400, 8413,
214433 8417, 8418, 8421, 8448, 8450, 8451, 8455, 8456, 8458, 8459,
214434 8462, 8464, 8467, 8468, 8469, 8470, 8472, 8473, 8478, 8484,
214435 8485, 8486, 8487, 8488, 8489, 8490, 8494, 8495, 8496, 8500,
214436 8501, 8505, 8506, 8508, 8510, 8512, 8517, 8519, 8522, 8523,
214437 8524, 8526, 8527, 8528, 8544, 8579, 8581, 8585, 8592, 8597,
214438 8602, 8604, 8608, 8609, 8611, 8612, 8614, 8615, 8622, 8623,
214439 8654, 8656, 8658, 8659, 8660, 8661, 8692, 8960, 8968, 8972,
214440 8992, 8994, 9001, 9002, 9003, 9084, 9085, 9115, 9140, 9180,
214441 9186, 9216, 9280, 9312, 9372, 9450, 9472, 9655, 9656, 9665,
214442 9666, 9720, 9728, 9839, 9840, 9985, 10088, 10089, 10090, 10091,
214443 10092, 10093, 10094, 10095, 10096, 10097, 10098, 10099, 10100, 10101,
214444 10102, 10132, 10176, 10181, 10182, 10183, 10214, 10215, 10216, 10217,
214445 10218, 10219, 10220, 10221, 10222, 10223, 10224, 10240, 10496, 10627,
214446 10628, 10629, 10630, 10631, 10632, 10633, 10634, 10635, 10636, 10637,
214447 10638, 10639, 10640, 10641, 10642, 10643, 10644, 10645, 10646, 10647,
214448 10648, 10649, 10712, 10713, 10714, 10715, 10716, 10748, 10749, 10750,
214449 11008, 11056, 11077, 11079, 11088, 11264, 11312, 11360, 11363, 11365,
214450 11367, 11374, 11377, 11378, 11380, 11381, 11383, 11388, 11390, 11393,
214451 11394, 11492, 11493, 11499, 11503, 11506, 11513, 11517, 11518, 11520,
214452 11559, 11565, 11568, 11631, 11632, 11647, 11648, 11680, 11688, 11696,
214453 11704, 11712, 11720, 11728, 11736, 11744, 11776, 11778, 11779, 11780,
214454 11781, 11782, 11785, 11786, 11787, 11788, 11789, 11790, 11799, 11800,
214455 11802, 11803, 11804, 11805, 11806, 11808, 11809, 11810, 11811, 11812,
214456 11813, 11814, 11815, 11816, 11817, 11818, 11823, 11824, 11834, 11904,
214457 11931, 12032, 12272, 12288, 12289, 12292, 12293, 12294, 12295, 12296,
214458 12297, 12298, 12299, 12300, 12301, 12302, 12303, 12304, 12305, 12306,
214459 12308, 12309, 12310, 12311, 12312, 12313, 12314, 12315, 12316, 12317,
214460 12318, 12320, 12321, 12330, 12334, 12336, 12337, 12342, 12344, 12347,
214461 12348, 12349, 12350, 12353, 12441, 12443, 12445, 12447, 12448, 12449,
214462 12539, 12540, 12543, 12549, 12593, 12688, 12690, 12694, 12704, 12736,
214463 12784, 12800, 12832, 12842, 12872, 12880, 12881, 12896, 12928, 12938,
214464 12977, 12992, 13056, 13312, 19893, 19904, 19968, 40908, 40960, 40981,
214465 40982, 42128, 42192, 42232, 42238, 42240, 42508, 42509, 42512, 42528,
214466 42538, 42560, 42606, 42607, 42608, 42611, 42612, 42622, 42623, 42624,
214467 42655, 42656, 42726, 42736, 42738, 42752, 42775, 42784, 42786, 42800,
214468 42802, 42864, 42865, 42873, 42878, 42888, 42889, 42891, 42896, 42912,
214469 43000, 43002, 43003, 43010, 43011, 43014, 43015, 43019, 43020, 43043,
214470 43045, 43047, 43048, 43056, 43062, 43064, 43065, 43072, 43124, 43136,
214471 43138, 43188, 43204, 43214, 43216, 43232, 43250, 43256, 43259, 43264,
214472 43274, 43302, 43310, 43312, 43335, 43346, 43359, 43360, 43392, 43395,
214473 43396, 43443, 43444, 43446, 43450, 43452, 43453, 43457, 43471, 43472,
214474 43486, 43520, 43561, 43567, 43569, 43571, 43573, 43584, 43587, 43588,
214475 43596, 43597, 43600, 43612, 43616, 43632, 43633, 43639, 43642, 43643,
214476 43648, 43696, 43697, 43698, 43701, 43703, 43705, 43710, 43712, 43713,
214477 43714, 43739, 43741, 43742, 43744, 43755, 43756, 43758, 43760, 43762,
214478 43763, 43765, 43766, 43777, 43785, 43793, 43808, 43816, 43968, 44003,
214479 44005, 44006, 44008, 44009, 44011, 44012, 44013, 44016, 44032, 55203,
214480 55216, 55243, 55296, 56191, 56319, 57343, 57344, 63743, 63744, 64112,
214481 64256, 64275, 64285, 64286, 64287, 64297, 64298, 64312, 64318, 64320,
214482 64323, 64326, 64434, 64467, 64830, 64831, 64848, 64914, 65008, 65020,
214483 65021, 65024, 65040, 65047, 65048, 65049, 65056, 65072, 65073, 65075,
214484 65077, 65078, 65079, 65080, 65081, 65082, 65083, 65084, 65085, 65086,
214485 65087, 65088, 65089, 65090, 65091, 65092, 65093, 65095, 65096, 65097,
214486 65101, 65104, 65108, 65112, 65113, 65114, 65115, 65116, 65117, 65118,
214487 65119, 65122, 65123, 65124, 65128, 65129, 65130, 65136, 65142, 65279,
214488 65281, 65284, 65285, 65288, 65289, 65290, 65291, 65292, 65293, 65294,
214489 65296, 65306, 65308, 65311, 65313, 65339, 65340, 65341, 65342, 65343,
214490 65344, 65345, 65371, 65372, 65373, 65374, 65375, 65376, 65377, 65378,
214491 65379, 65380, 65382, 65392, 65393, 65438, 65440, 65474, 65482, 65490,
214492 65498, 65504, 65506, 65507, 65508, 65509, 65512, 65513, 65517, 65529,
214493 65532, 0, 13, 40, 60, 63, 80, 128, 256, 263,
214494 311, 320, 373, 377, 394, 400, 464, 509, 640, 672,
214495 768, 800, 816, 833, 834, 842, 896, 927, 928, 968,
214496 976, 977, 1024, 1064, 1104, 1184, 2048, 2056, 2058, 2103,
214497 2108, 2111, 2135, 2136, 2304, 2326, 2335, 2336, 2367, 2432,
214498 2494, 2560, 2561, 2565, 2572, 2576, 2581, 2585, 2616, 2623,
214499 2624, 2640, 2656, 2685, 2687, 2816, 2873, 2880, 2904, 2912,
214500 2936, 3072, 3680, 4096, 4097, 4098, 4099, 4152, 4167, 4178,
214501 4198, 4224, 4226, 4227, 4272, 4275, 4279, 4281, 4283, 4285,
214502 4286, 4304, 4336, 4352, 4355, 4391, 4396, 4397, 4406, 4416,
214503 4480, 4482, 4483, 4531, 4534, 4543, 4545, 4549, 4560, 5760,
214504 5803, 5804, 5805, 5806, 5808, 5814, 5815, 5824, 8192, 9216,
214505 9328, 12288, 26624, 28416, 28496, 28497, 28559, 28563, 45056, 53248,
214506 53504, 53545, 53605, 53607, 53610, 53613, 53619, 53627, 53635, 53637,
214507 53644, 53674, 53678, 53760, 53826, 53829, 54016, 54112, 54272, 54298,
214508 54324, 54350, 54358, 54376, 54402, 54428, 54430, 54434, 54437, 54441,
214509 54446, 54454, 54459, 54461, 54469, 54480, 54506, 54532, 54535, 54541,
214510 54550, 54558, 54584, 54587, 54592, 54598, 54602, 54610, 54636, 54662,
214511 54688, 54714, 54740, 54766, 54792, 54818, 54844, 54870, 54896, 54922,
214512 54952, 54977, 54978, 55003, 55004, 55010, 55035, 55036, 55061, 55062,
214513 55068, 55093, 55094, 55119, 55120, 55126, 55151, 55152, 55177, 55178,
214514 55184, 55209, 55210, 55235, 55236, 55242, 55246, 60928, 60933, 60961,
214515 60964, 60967, 60969, 60980, 60985, 60987, 60994, 60999, 61001, 61003,
214516 61005, 61009, 61012, 61015, 61017, 61019, 61021, 61023, 61025, 61028,
214517 61031, 61036, 61044, 61049, 61054, 61056, 61067, 61089, 61093, 61099,
214518 61168, 61440, 61488, 61600, 61617, 61633, 61649, 61696, 61712, 61744,
214519 61808, 61926, 61968, 62016, 62032, 62208, 62256, 62263, 62336, 62368,
214520 62406, 62432, 62464, 62528, 62530, 62713, 62720, 62784, 62800, 62971,
214521 63045, 63104, 63232, 0, 42710, 42752, 46900, 46912, 47133, 63488,
214522 1, 32, 256, 0, 65533,
214523 };
214524 static u16 aFts5UnicodeData[] = {
214525 1025, 61, 117, 55, 117, 54, 50, 53, 57, 53,
214526 49, 85, 333, 85, 121, 85, 841, 54, 53, 50,
214527 56, 48, 56, 837, 54, 57, 50, 57, 1057, 61,
214528 53, 151, 58, 53, 56, 58, 39, 52, 57, 34,
214529 58, 56, 58, 57, 79, 56, 37, 85, 56, 47,
214530 39, 51, 111, 53, 745, 57, 233, 773, 57, 261,
214531 1822, 37, 542, 37, 1534, 222, 69, 73, 37, 126,
214532 126, 73, 69, 137, 37, 73, 37, 105, 101, 73,
214533 37, 73, 37, 190, 158, 37, 126, 126, 73, 37,
214534 126, 94, 37, 39, 94, 69, 135, 41, 40, 37,
214535 41, 40, 37, 41, 40, 37, 542, 37, 606, 37,
214536 41, 40, 37, 126, 73, 37, 1886, 197, 73, 37,
214537 73, 69, 126, 105, 37, 286, 2181, 39, 869, 582,
214538 152, 390, 472, 166, 248, 38, 56, 38, 568, 3596,
214539 158, 38, 56, 94, 38, 101, 53, 88, 41, 53,
214540 105, 41, 73, 37, 553, 297, 1125, 94, 37, 105,
214541 101, 798, 133, 94, 57, 126, 94, 37, 1641, 1541,
214542 1118, 58, 172, 75, 1790, 478, 37, 2846, 1225, 38,
214543 213, 1253, 53, 49, 55, 1452, 49, 44, 53, 76,
214544 53, 76, 53, 44, 871, 103, 85, 162, 121, 85,
214545 55, 85, 90, 364, 53, 85, 1031, 38, 327, 684,
214546 333, 149, 71, 44, 3175, 53, 39, 236, 34, 58,
214547 204, 70, 76, 58, 140, 71, 333, 103, 90, 39,
214548 469, 34, 39, 44, 967, 876, 2855, 364, 39, 333,
214549 1063, 300, 70, 58, 117, 38, 711, 140, 38, 300,
214550 38, 108, 38, 172, 501, 807, 108, 53, 39, 359,
214551 876, 108, 42, 1735, 44, 42, 44, 39, 106, 268,
214552 138, 44, 74, 39, 236, 327, 76, 85, 333, 53,
214553 38, 199, 231, 44, 74, 263, 71, 711, 231, 39,
214554 135, 44, 39, 106, 140, 74, 74, 44, 39, 42,
214555 71, 103, 76, 333, 71, 87, 207, 58, 55, 76,
214556 42, 199, 71, 711, 231, 71, 71, 71, 44, 106,
214557 76, 76, 108, 44, 135, 39, 333, 76, 103, 44,
214558 76, 42, 295, 103, 711, 231, 71, 167, 44, 39,
214559 106, 172, 76, 42, 74, 44, 39, 71, 76, 333,
214560 53, 55, 44, 74, 263, 71, 711, 231, 71, 167,
214561 44, 39, 42, 44, 42, 140, 74, 74, 44, 44,
214562 42, 71, 103, 76, 333, 58, 39, 207, 44, 39,
214563 199, 103, 135, 71, 39, 71, 71, 103, 391, 74,
214564 44, 74, 106, 106, 44, 39, 42, 333, 111, 218,
214565 55, 58, 106, 263, 103, 743, 327, 167, 39, 108,
214566 138, 108, 140, 76, 71, 71, 76, 333, 239, 58,
214567 74, 263, 103, 743, 327, 167, 44, 39, 42, 44,
214568 170, 44, 74, 74, 76, 74, 39, 71, 76, 333,
214569 71, 74, 263, 103, 1319, 39, 106, 140, 106, 106,
214570 44, 39, 42, 71, 76, 333, 207, 58, 199, 74,
214571 583, 775, 295, 39, 231, 44, 106, 108, 44, 266,
214572 74, 53, 1543, 44, 71, 236, 55, 199, 38, 268,
214573 53, 333, 85, 71, 39, 71, 39, 39, 135, 231,
214574 103, 39, 39, 71, 135, 44, 71, 204, 76, 39,
214575 167, 38, 204, 333, 135, 39, 122, 501, 58, 53,
214576 122, 76, 218, 333, 335, 58, 44, 58, 44, 58,
214577 44, 54, 50, 54, 50, 74, 263, 1159, 460, 42,
214578 172, 53, 76, 167, 364, 1164, 282, 44, 218, 90,
214579 181, 154, 85, 1383, 74, 140, 42, 204, 42, 76,
214580 74, 76, 39, 333, 213, 199, 74, 76, 135, 108,
214581 39, 106, 71, 234, 103, 140, 423, 44, 74, 76,
214582 202, 44, 39, 42, 333, 106, 44, 90, 1225, 41,
214583 41, 1383, 53, 38, 10631, 135, 231, 39, 135, 1319,
214584 135, 1063, 135, 231, 39, 135, 487, 1831, 135, 2151,
214585 108, 309, 655, 519, 346, 2727, 49, 19847, 85, 551,
214586 61, 839, 54, 50, 2407, 117, 110, 423, 135, 108,
214587 583, 108, 85, 583, 76, 423, 103, 76, 1671, 76,
214588 42, 236, 266, 44, 74, 364, 117, 38, 117, 55,
214589 39, 44, 333, 335, 213, 49, 149, 108, 61, 333,
214590 1127, 38, 1671, 1319, 44, 39, 2247, 935, 108, 138,
214591 76, 106, 74, 44, 202, 108, 58, 85, 333, 967,
214592 167, 1415, 554, 231, 74, 333, 47, 1114, 743, 76,
214593 106, 85, 1703, 42, 44, 42, 236, 44, 42, 44,
214594 74, 268, 202, 332, 44, 333, 333, 245, 38, 213,
214595 140, 42, 1511, 44, 42, 172, 42, 44, 170, 44,
214596 74, 231, 333, 245, 346, 300, 314, 76, 42, 967,
214597 42, 140, 74, 76, 42, 44, 74, 71, 333, 1415,
214598 44, 42, 76, 106, 44, 42, 108, 74, 149, 1159,
214599 266, 268, 74, 76, 181, 333, 103, 333, 967, 198,
214600 85, 277, 108, 53, 428, 42, 236, 135, 44, 135,
214601 74, 44, 71, 1413, 2022, 421, 38, 1093, 1190, 1260,
214602 140, 4830, 261, 3166, 261, 265, 197, 201, 261, 265,
214603 261, 265, 197, 201, 261, 41, 41, 41, 94, 229,
214604 265, 453, 261, 264, 261, 264, 261, 264, 165, 69,
214605 137, 40, 56, 37, 120, 101, 69, 137, 40, 120,
214606 133, 69, 137, 120, 261, 169, 120, 101, 69, 137,
214607 40, 88, 381, 162, 209, 85, 52, 51, 54, 84,
214608 51, 54, 52, 277, 59, 60, 162, 61, 309, 52,
214609 51, 149, 80, 117, 57, 54, 50, 373, 57, 53,
214610 48, 341, 61, 162, 194, 47, 38, 207, 121, 54,
214611 50, 38, 335, 121, 54, 50, 422, 855, 428, 139,
214612 44, 107, 396, 90, 41, 154, 41, 90, 37, 105,
214613 69, 105, 37, 58, 41, 90, 57, 169, 218, 41,
214614 58, 41, 58, 41, 58, 137, 58, 37, 137, 37,
214615 135, 37, 90, 69, 73, 185, 94, 101, 58, 57,
214616 90, 37, 58, 527, 1134, 94, 142, 47, 185, 186,
214617 89, 154, 57, 90, 57, 90, 57, 250, 57, 1018,
214618 89, 90, 57, 58, 57, 1018, 8601, 282, 153, 666,
214619 89, 250, 54, 50, 2618, 57, 986, 825, 1306, 217,
214620 602, 1274, 378, 1935, 2522, 719, 5882, 57, 314, 57,
214621 1754, 281, 3578, 57, 4634, 3322, 54, 50, 54, 50,
214622 54, 50, 54, 50, 54, 50, 54, 50, 54, 50,
214623 975, 1434, 185, 54, 50, 1017, 54, 50, 54, 50,
214624 54, 50, 54, 50, 54, 50, 537, 8218, 4217, 54,
214625 50, 54, 50, 54, 50, 54, 50, 54, 50, 54,
214626 50, 54, 50, 54, 50, 54, 50, 54, 50, 54,
214627 50, 2041, 54, 50, 54, 50, 1049, 54, 50, 8281,
214628 1562, 697, 90, 217, 346, 1513, 1509, 126, 73, 69,
214629 254, 105, 37, 94, 37, 94, 165, 70, 105, 37,
214630 3166, 37, 218, 158, 108, 94, 149, 47, 85, 1221,
214631 37, 37, 1799, 38, 53, 44, 743, 231, 231, 231,
214632 231, 231, 231, 231, 231, 1036, 85, 52, 51, 52,
214633 51, 117, 52, 51, 53, 52, 51, 309, 49, 85,
214634 49, 53, 52, 51, 85, 52, 51, 54, 50, 54,
214635 50, 54, 50, 54, 50, 181, 38, 341, 81, 858,
214636 2874, 6874, 410, 61, 117, 58, 38, 39, 46, 54,
214637 50, 54, 50, 54, 50, 54, 50, 54, 50, 90,
214638 54, 50, 54, 50, 54, 50, 54, 50, 49, 54,
214639 82, 58, 302, 140, 74, 49, 166, 90, 110, 38,
214640 39, 53, 90, 2759, 76, 88, 70, 39, 49, 2887,
214641 53, 102, 39, 1319, 3015, 90, 143, 346, 871, 1178,
214642 519, 1018, 335, 986, 271, 58, 495, 1050, 335, 1274,
214643 495, 2042, 8218, 39, 39, 2074, 39, 39, 679, 38,
214644 36583, 1786, 1287, 198, 85, 8583, 38, 117, 519, 333,
214645 71, 1502, 39, 44, 107, 53, 332, 53, 38, 798,
214646 44, 2247, 334, 76, 213, 760, 294, 88, 478, 69,
214647 2014, 38, 261, 190, 350, 38, 88, 158, 158, 382,
214648 70, 37, 231, 44, 103, 44, 135, 44, 743, 74,
214649 76, 42, 154, 207, 90, 55, 58, 1671, 149, 74,
214650 1607, 522, 44, 85, 333, 588, 199, 117, 39, 333,
214651 903, 268, 85, 743, 364, 74, 53, 935, 108, 42,
214652 1511, 44, 74, 140, 74, 44, 138, 437, 38, 333,
214653 85, 1319, 204, 74, 76, 74, 76, 103, 44, 263,
214654 44, 42, 333, 149, 519, 38, 199, 122, 39, 42,
214655 1543, 44, 39, 108, 71, 76, 167, 76, 39, 44,
214656 39, 71, 38, 85, 359, 42, 76, 74, 85, 39,
214657 70, 42, 44, 199, 199, 199, 231, 231, 1127, 74,
214658 44, 74, 44, 74, 53, 42, 44, 333, 39, 39,
214659 743, 1575, 36, 68, 68, 36, 63, 63, 11719, 3399,
214660 229, 165, 39, 44, 327, 57, 423, 167, 39, 71,
214661 71, 3463, 536, 11623, 54, 50, 2055, 1735, 391, 55,
214662 58, 524, 245, 54, 50, 53, 236, 53, 81, 80,
214663 54, 50, 54, 50, 54, 50, 54, 50, 54, 50,
214664 54, 50, 54, 50, 54, 50, 85, 54, 50, 149,
214665 112, 117, 149, 49, 54, 50, 54, 50, 54, 50,
214666 117, 57, 49, 121, 53, 55, 85, 167, 4327, 34,
214667 117, 55, 117, 54, 50, 53, 57, 53, 49, 85,
214668 333, 85, 121, 85, 841, 54, 53, 50, 56, 48,
214669 56, 837, 54, 57, 50, 57, 54, 50, 53, 54,
214670 50, 85, 327, 38, 1447, 70, 999, 199, 199, 199,
214671 103, 87, 57, 56, 58, 87, 58, 153, 90, 98,
214672 90, 391, 839, 615, 71, 487, 455, 3943, 117, 1455,
214673 314, 1710, 143, 570, 47, 410, 1466, 44, 935, 1575,
214674 999, 143, 551, 46, 263, 46, 967, 53, 1159, 263,
214675 53, 174, 1289, 1285, 2503, 333, 199, 39, 1415, 71,
214676 39, 743, 53, 271, 711, 207, 53, 839, 53, 1799,
214677 71, 39, 108, 76, 140, 135, 103, 871, 108, 44,
214678 271, 309, 935, 79, 53, 1735, 245, 711, 271, 615,
214679 271, 2343, 1007, 42, 44, 42, 1703, 492, 245, 655,
214680 333, 76, 42, 1447, 106, 140, 74, 76, 85, 34,
214681 149, 807, 333, 108, 1159, 172, 42, 268, 333, 149,
214682 76, 42, 1543, 106, 300, 74, 135, 149, 333, 1383,
214683 44, 42, 44, 74, 204, 42, 44, 333, 28135, 3182,
214684 149, 34279, 18215, 2215, 39, 1482, 140, 422, 71, 7898,
214685 1274, 1946, 74, 108, 122, 202, 258, 268, 90, 236,
214686 986, 140, 1562, 2138, 108, 58, 2810, 591, 841, 837,
214687 841, 229, 581, 841, 837, 41, 73, 41, 73, 137,
214688 265, 133, 37, 229, 357, 841, 837, 73, 137, 265,
214689 233, 837, 73, 137, 169, 41, 233, 837, 841, 837,
214690 841, 837, 841, 837, 841, 837, 841, 837, 841, 901,
214691 809, 57, 805, 57, 197, 809, 57, 805, 57, 197,
214692 809, 57, 805, 57, 197, 809, 57, 805, 57, 197,
214693 809, 57, 805, 57, 197, 94, 1613, 135, 871, 71,
214694 39, 39, 327, 135, 39, 39, 39, 39, 39, 39,
214695 103, 71, 39, 39, 39, 39, 39, 39, 71, 39,
214696 135, 231, 135, 135, 39, 327, 551, 103, 167, 551,
214697 89, 1434, 3226, 506, 474, 506, 506, 367, 1018, 1946,
214698 1402, 954, 1402, 314, 90, 1082, 218, 2266, 666, 1210,
214699 186, 570, 2042, 58, 5850, 154, 2010, 154, 794, 2266,
214700 378, 2266, 3738, 39, 39, 39, 39, 39, 39, 17351,
214701 34, 3074, 7692, 63, 63,
214702 };
214703
214704 static int sqlite3Fts5UnicodeCategory(int iCode) {
214705 int iRes = -1;
214706 int iHi;
214707 int iLo;
214708 int ret;
214709 u16 iKey;
214710
214711 if( iCode>=(1<<20) ){
214712 return 0;
214713 }
214714 iLo = aFts5UnicodeBlock[(iCode>>16)];
214715 iHi = aFts5UnicodeBlock[1+(iCode>>16)];
214716 iKey = (iCode & 0xFFFF);
214717 while( iHi>iLo ){
214718 int iTest = (iHi + iLo) / 2;
214719 assert( iTest>=iLo && iTest<iHi );
214720 if( iKey>=aFts5UnicodeMap[iTest] ){
214721 iRes = iTest;
214722 iLo = iTest+1;
214723 }else{
214724 iHi = iTest;
214725 }
214726 }
214727
214728 if( iRes<0 ) return 0;
214729 if( iKey>=(aFts5UnicodeMap[iRes]+(aFts5UnicodeData[iRes]>>5)) ) return 0;
214730 ret = aFts5UnicodeData[iRes] & 0x1F;
214731 if( ret!=30 ) return ret;
214732 return ((iKey - aFts5UnicodeMap[iRes]) & 0x01) ? 5 : 9;
214733 }
214734
214735 static void sqlite3Fts5UnicodeAscii(u8 *aArray, u8 *aAscii){
214736 int i = 0;
214737 int iTbl = 0;
214738 while( i<128 ){
214739 int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];
214740 int n = (aFts5UnicodeData[iTbl] >> 5) + i;
214741 for(; i<128 && i<n; i++){
214742 aAscii[i] = bToken;
214743 }
214744 iTbl++;
214745 }
214746 }
214747
214748
214749 /*
214750 ** 2015 May 30
214751 **
214752 ** The author disclaims copyright to this source code. In place of
@@ -211853,12 +216161,12 @@
216161 }
216162 #endif /* SQLITE_CORE */
216163 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
216164
216165 /************** End of stmt.c ************************************************/
216166 #if __LINE__!=216166
216167 #undef SQLITE_SOURCE_ID
216168 #define SQLITE_SOURCE_ID "2018-07-13 20:28:54 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb362124alt2"
216169 #endif
216170 /* Return the source-id for this library */
216171 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
216172 /************************** End of sqlite3.c ******************************/
216173
+103 -25
--- 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.24.0"
127
-#define SQLITE_VERSION_NUMBER 3024000
128
-#define SQLITE_SOURCE_ID "2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca"
126
+#define SQLITE_VERSION "3.25.0"
127
+#define SQLITE_VERSION_NUMBER 3025000
128
+#define SQLITE_SOURCE_ID "2018-07-13 20:28:54 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb36212426b1"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -509,10 +509,11 @@
509509
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
510510
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
511511
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
512512
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
513513
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
514
+#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
514515
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
515516
#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
516517
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
517518
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
518519
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -2119,10 +2120,16 @@
21192120
** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
21202121
** [VACUUM] in order to reset a database back to an empty database
21212122
** with no schema and no content. The following process works even for
21222123
** a badly corrupted database file:
21232124
** <ol>
2125
+** <li> If the database connection is newly opened, make sure it has read the
2126
+** database schema by preparing then discarding some query against the
2127
+** database, or calling sqlite3_table_column_metadata(), ignoring any
2128
+** errors. This step is only necessary if the application desires to keep
2129
+** the database in WAL mode after the reset if it was in WAL mode before
2130
+** the reset.
21242131
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
21252132
** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
21262133
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
21272134
** </ol>
21282135
** Because resetting a database is destructive and irreversible, the
@@ -3352,16 +3359,27 @@
33523359
**
33533360
** ^If the most recent sqlite3_* API call associated with
33543361
** [database connection] D failed, then the sqlite3_errcode(D) interface
33553362
** returns the numeric [result code] or [extended result code] for that
33563363
** API call.
3357
-** If the most recent API call was successful,
3358
-** then the return value from sqlite3_errcode() is undefined.
33593364
** ^The sqlite3_extended_errcode()
33603365
** interface is the same except that it always returns the
33613366
** [extended result code] even when extended result codes are
33623367
** disabled.
3368
+**
3369
+** The values returned by sqlite3_errcode() and/or
3370
+** sqlite3_extended_errcode() might change with each API call.
3371
+** Except, there are some interfaces that are guaranteed to never
3372
+** change the value of the error code. The error-code preserving
3373
+** interfaces are:
3374
+**
3375
+** <ul>
3376
+** <li> sqlite3_errcode()
3377
+** <li> sqlite3_extended_errcode()
3378
+** <li> sqlite3_errmsg()
3379
+** <li> sqlite3_errmsg16()
3380
+** </ul>
33633381
**
33643382
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
33653383
** text that describes the error, as either UTF-8 or UTF-16 respectively.
33663384
** ^(Memory to hold the error message string is managed internally.
33673385
** The application does not need to worry about freeing the result.
@@ -4512,15 +4530,29 @@
45124530
** [sqlite3_finalize()] is called. ^The memory space used to hold strings
45134531
** and BLOBs is freed automatically. Do not pass the pointers returned
45144532
** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
45154533
** [sqlite3_free()].
45164534
**
4517
-** ^(If a memory allocation error occurs during the evaluation of any
4518
-** of these routines, a default value is returned. The default value
4519
-** is either the integer 0, the floating point number 0.0, or a NULL
4520
-** pointer. Subsequent calls to [sqlite3_errcode()] will return
4521
-** [SQLITE_NOMEM].)^
4535
+** As long as the input parameters are correct, these routines will only
4536
+** fail if an out-of-memory error occurs during a format conversion.
4537
+** Only the following subset of interfaces are subject to out-of-memory
4538
+** errors:
4539
+**
4540
+** <ul>
4541
+** <li> sqlite3_column_blob()
4542
+** <li> sqlite3_column_text()
4543
+** <li> sqlite3_column_text16()
4544
+** <li> sqlite3_column_bytes()
4545
+** <li> sqlite3_column_bytes16()
4546
+** </ul>
4547
+**
4548
+** If an out-of-memory error occurs, then the return value from these
4549
+** routines is the same as if the column had contained an SQL NULL value.
4550
+** Valid SQL NULL returns can be distinguished from out-of-memory errors
4551
+** by invoking the [sqlite3_errcode()] immediately after the suspect
4552
+** return value is obtained and before any
4553
+** other SQLite interface is called on the same [database connection].
45224554
*/
45234555
SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
45244556
SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
45254557
SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
45264558
SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
@@ -4593,15 +4625,17 @@
45934625
** KEYWORDS: {application-defined SQL functions}
45944626
** METHOD: sqlite3
45954627
**
45964628
** ^These functions (collectively known as "function creation routines")
45974629
** are used to add SQL functions or aggregates or to redefine the behavior
4598
-** of existing SQL functions or aggregates. The only differences between
4599
-** these routines are the text encoding expected for
4600
-** the second parameter (the name of the function being created)
4601
-** and the presence or absence of a destructor callback for
4602
-** the application data pointer.
4630
+** of existing SQL functions or aggregates. The only differences between
4631
+** the three "sqlite3_create_function*" routines are the text encoding
4632
+** expected for the second parameter (the name of the function being
4633
+** created) and the presence or absence of a destructor callback for
4634
+** the application data pointer. Function sqlite3_create_window_function()
4635
+** is similar, but allows the user to supply the extra callback functions
4636
+** needed by [aggregate window functions].
46034637
**
46044638
** ^The first parameter is the [database connection] to which the SQL
46054639
** function is to be added. ^If an application uses more than one database
46064640
** connection then application-defined SQL functions must be added
46074641
** to each database connection separately.
@@ -4643,28 +4677,38 @@
46434677
** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
46444678
**
46454679
** ^(The fifth parameter is an arbitrary pointer. The implementation of the
46464680
** function can gain access to this pointer using [sqlite3_user_data()].)^
46474681
**
4648
-** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are
4682
+** ^The sixth, seventh and eighth parameters passed to the three
4683
+** "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are
46494684
** pointers to C-language functions that implement the SQL function or
46504685
** aggregate. ^A scalar SQL function requires an implementation of the xFunc
46514686
** callback only; NULL pointers must be passed as the xStep and xFinal
46524687
** parameters. ^An aggregate SQL function requires an implementation of xStep
46534688
** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
46544689
** SQL function or aggregate, pass NULL pointers for all three function
46554690
** callbacks.
46564691
**
4657
-** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,
4658
-** then it is destructor for the application data pointer.
4659
-** The destructor is invoked when the function is deleted, either by being
4660
-** overloaded or when the database connection closes.)^
4661
-** ^The destructor is also invoked if the call to
4662
-** sqlite3_create_function_v2() fails.
4663
-** ^When the destructor callback of the tenth parameter is invoked, it
4664
-** is passed a single argument which is a copy of the application data
4665
-** pointer which was the fifth parameter to sqlite3_create_function_v2().
4692
+** ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue
4693
+** and xInverse) passed to sqlite3_create_window_function are pointers to
4694
+** C-lanugage callbacks that implement the new function. xStep and xFinal
4695
+** must both be non-NULL. xValue and xInverse may either both be NULL, in
4696
+** which case a regular aggregate function is created, or must both be
4697
+** non-NULL, in which case the new function may be used as either an aggregate
4698
+** or aggregate window function. More details regarding the implementation
4699
+** of aggregate window functions are
4700
+** [user-defined window functions|available here].
4701
+**
4702
+** ^(If the final parameter to sqlite3_create_function_v2() or
4703
+** sqlite3_create_window_function() is not NULL, then it is destructor for
4704
+** the application data pointer. The destructor is invoked when the function
4705
+** is deleted, either by being overloaded or when the database connection
4706
+** closes.)^ ^The destructor is also invoked if the call to
4707
+** sqlite3_create_function_v2() fails. ^When the destructor callback is
4708
+** invoked, it is passed a single argument which is a copy of the application
4709
+** data pointer which was the fifth parameter to sqlite3_create_function_v2().
46664710
**
46674711
** ^It is permitted to register multiple implementations of the same
46684712
** functions with the same name but with either differing numbers of
46694713
** arguments or differing preferred text encodings. ^SQLite will use
46704714
** the implementation that most closely matches the way in which the
@@ -4712,10 +4756,22 @@
47124756
void *pApp,
47134757
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
47144758
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
47154759
void (*xFinal)(sqlite3_context*),
47164760
void(*xDestroy)(void*)
4761
+);
4762
+SQLITE_API int sqlite3_create_window_function(
4763
+ sqlite3 *db,
4764
+ const char *zFunctionName,
4765
+ int nArg,
4766
+ int eTextRep,
4767
+ void *pApp,
4768
+ void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4769
+ void (*xFinal)(sqlite3_context*),
4770
+ void (*xValue)(sqlite3_context*),
4771
+ void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
4772
+ void(*xDestroy)(void*)
47174773
);
47184774
47194775
/*
47204776
** CAPI3REF: Text Encodings
47214777
**
@@ -4855,10 +4911,32 @@
48554911
** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
48564912
** or [sqlite3_value_text16()].
48574913
**
48584914
** These routines must be called from the same thread as
48594915
** the SQL function that supplied the [sqlite3_value*] parameters.
4916
+**
4917
+** As long as the input parameter is correct, these routines can only
4918
+** fail if an out-of-memory error occurs during a format conversion.
4919
+** Only the following subset of interfaces are subject to out-of-memory
4920
+** errors:
4921
+**
4922
+** <ul>
4923
+** <li> sqlite3_value_blob()
4924
+** <li> sqlite3_value_text()
4925
+** <li> sqlite3_value_text16()
4926
+** <li> sqlite3_value_text16le()
4927
+** <li> sqlite3_value_text16be()
4928
+** <li> sqlite3_value_bytes()
4929
+** <li> sqlite3_value_bytes16()
4930
+** </ul>
4931
+**
4932
+** If an out-of-memory error occurs, then the return value from these
4933
+** routines is the same as if the column had contained an SQL NULL value.
4934
+** Valid SQL NULL returns can be distinguished from out-of-memory errors
4935
+** by invoking the [sqlite3_errcode()] immediately after the suspect
4936
+** return value is obtained and before any
4937
+** other SQLite interface is called on the same [database connection].
48604938
*/
48614939
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
48624940
SQLITE_API double sqlite3_value_double(sqlite3_value*);
48634941
SQLITE_API int sqlite3_value_int(sqlite3_value*);
48644942
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
48654943
--- 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.24.0"
127 #define SQLITE_VERSION_NUMBER 3024000
128 #define SQLITE_SOURCE_ID "2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -509,10 +509,11 @@
509 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
510 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
511 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
512 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
513 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
 
514 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
515 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
516 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
517 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
518 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -2119,10 +2120,16 @@
2119 ** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
2120 ** [VACUUM] in order to reset a database back to an empty database
2121 ** with no schema and no content. The following process works even for
2122 ** a badly corrupted database file:
2123 ** <ol>
 
 
 
 
 
 
2124 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
2125 ** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
2126 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
2127 ** </ol>
2128 ** Because resetting a database is destructive and irreversible, the
@@ -3352,16 +3359,27 @@
3352 **
3353 ** ^If the most recent sqlite3_* API call associated with
3354 ** [database connection] D failed, then the sqlite3_errcode(D) interface
3355 ** returns the numeric [result code] or [extended result code] for that
3356 ** API call.
3357 ** If the most recent API call was successful,
3358 ** then the return value from sqlite3_errcode() is undefined.
3359 ** ^The sqlite3_extended_errcode()
3360 ** interface is the same except that it always returns the
3361 ** [extended result code] even when extended result codes are
3362 ** disabled.
 
 
 
 
 
 
 
 
 
 
 
 
 
3363 **
3364 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
3365 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
3366 ** ^(Memory to hold the error message string is managed internally.
3367 ** The application does not need to worry about freeing the result.
@@ -4512,15 +4530,29 @@
4512 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
4513 ** and BLOBs is freed automatically. Do not pass the pointers returned
4514 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
4515 ** [sqlite3_free()].
4516 **
4517 ** ^(If a memory allocation error occurs during the evaluation of any
4518 ** of these routines, a default value is returned. The default value
4519 ** is either the integer 0, the floating point number 0.0, or a NULL
4520 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
4521 ** [SQLITE_NOMEM].)^
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4522 */
4523 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4524 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4525 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4526 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
@@ -4593,15 +4625,17 @@
4593 ** KEYWORDS: {application-defined SQL functions}
4594 ** METHOD: sqlite3
4595 **
4596 ** ^These functions (collectively known as "function creation routines")
4597 ** are used to add SQL functions or aggregates or to redefine the behavior
4598 ** of existing SQL functions or aggregates. The only differences between
4599 ** these routines are the text encoding expected for
4600 ** the second parameter (the name of the function being created)
4601 ** and the presence or absence of a destructor callback for
4602 ** the application data pointer.
 
 
4603 **
4604 ** ^The first parameter is the [database connection] to which the SQL
4605 ** function is to be added. ^If an application uses more than one database
4606 ** connection then application-defined SQL functions must be added
4607 ** to each database connection separately.
@@ -4643,28 +4677,38 @@
4643 ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
4644 **
4645 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
4646 ** function can gain access to this pointer using [sqlite3_user_data()].)^
4647 **
4648 ** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are
 
4649 ** pointers to C-language functions that implement the SQL function or
4650 ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
4651 ** callback only; NULL pointers must be passed as the xStep and xFinal
4652 ** parameters. ^An aggregate SQL function requires an implementation of xStep
4653 ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
4654 ** SQL function or aggregate, pass NULL pointers for all three function
4655 ** callbacks.
4656 **
4657 ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,
4658 ** then it is destructor for the application data pointer.
4659 ** The destructor is invoked when the function is deleted, either by being
4660 ** overloaded or when the database connection closes.)^
4661 ** ^The destructor is also invoked if the call to
4662 ** sqlite3_create_function_v2() fails.
4663 ** ^When the destructor callback of the tenth parameter is invoked, it
4664 ** is passed a single argument which is a copy of the application data
4665 ** pointer which was the fifth parameter to sqlite3_create_function_v2().
 
 
 
 
 
 
 
 
 
4666 **
4667 ** ^It is permitted to register multiple implementations of the same
4668 ** functions with the same name but with either differing numbers of
4669 ** arguments or differing preferred text encodings. ^SQLite will use
4670 ** the implementation that most closely matches the way in which the
@@ -4712,10 +4756,22 @@
4712 void *pApp,
4713 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4714 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4715 void (*xFinal)(sqlite3_context*),
4716 void(*xDestroy)(void*)
 
 
 
 
 
 
 
 
 
 
 
 
4717 );
4718
4719 /*
4720 ** CAPI3REF: Text Encodings
4721 **
@@ -4855,10 +4911,32 @@
4855 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
4856 ** or [sqlite3_value_text16()].
4857 **
4858 ** These routines must be called from the same thread as
4859 ** the SQL function that supplied the [sqlite3_value*] parameters.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4860 */
4861 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4862 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4863 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4864 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4865
--- 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.25.0"
127 #define SQLITE_VERSION_NUMBER 3025000
128 #define SQLITE_SOURCE_ID "2018-07-13 20:28:54 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb36212426b1"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -509,10 +509,11 @@
509 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
510 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
511 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
512 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
513 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
514 #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
515 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
516 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
517 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
518 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
519 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -2119,10 +2120,16 @@
2120 ** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
2121 ** [VACUUM] in order to reset a database back to an empty database
2122 ** with no schema and no content. The following process works even for
2123 ** a badly corrupted database file:
2124 ** <ol>
2125 ** <li> If the database connection is newly opened, make sure it has read the
2126 ** database schema by preparing then discarding some query against the
2127 ** database, or calling sqlite3_table_column_metadata(), ignoring any
2128 ** errors. This step is only necessary if the application desires to keep
2129 ** the database in WAL mode after the reset if it was in WAL mode before
2130 ** the reset.
2131 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
2132 ** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
2133 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
2134 ** </ol>
2135 ** Because resetting a database is destructive and irreversible, the
@@ -3352,16 +3359,27 @@
3359 **
3360 ** ^If the most recent sqlite3_* API call associated with
3361 ** [database connection] D failed, then the sqlite3_errcode(D) interface
3362 ** returns the numeric [result code] or [extended result code] for that
3363 ** API call.
 
 
3364 ** ^The sqlite3_extended_errcode()
3365 ** interface is the same except that it always returns the
3366 ** [extended result code] even when extended result codes are
3367 ** disabled.
3368 **
3369 ** The values returned by sqlite3_errcode() and/or
3370 ** sqlite3_extended_errcode() might change with each API call.
3371 ** Except, there are some interfaces that are guaranteed to never
3372 ** change the value of the error code. The error-code preserving
3373 ** interfaces are:
3374 **
3375 ** <ul>
3376 ** <li> sqlite3_errcode()
3377 ** <li> sqlite3_extended_errcode()
3378 ** <li> sqlite3_errmsg()
3379 ** <li> sqlite3_errmsg16()
3380 ** </ul>
3381 **
3382 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
3383 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
3384 ** ^(Memory to hold the error message string is managed internally.
3385 ** The application does not need to worry about freeing the result.
@@ -4512,15 +4530,29 @@
4530 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
4531 ** and BLOBs is freed automatically. Do not pass the pointers returned
4532 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
4533 ** [sqlite3_free()].
4534 **
4535 ** As long as the input parameters are correct, these routines will only
4536 ** fail if an out-of-memory error occurs during a format conversion.
4537 ** Only the following subset of interfaces are subject to out-of-memory
4538 ** errors:
4539 **
4540 ** <ul>
4541 ** <li> sqlite3_column_blob()
4542 ** <li> sqlite3_column_text()
4543 ** <li> sqlite3_column_text16()
4544 ** <li> sqlite3_column_bytes()
4545 ** <li> sqlite3_column_bytes16()
4546 ** </ul>
4547 **
4548 ** If an out-of-memory error occurs, then the return value from these
4549 ** routines is the same as if the column had contained an SQL NULL value.
4550 ** Valid SQL NULL returns can be distinguished from out-of-memory errors
4551 ** by invoking the [sqlite3_errcode()] immediately after the suspect
4552 ** return value is obtained and before any
4553 ** other SQLite interface is called on the same [database connection].
4554 */
4555 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4556 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4557 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4558 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
@@ -4593,15 +4625,17 @@
4625 ** KEYWORDS: {application-defined SQL functions}
4626 ** METHOD: sqlite3
4627 **
4628 ** ^These functions (collectively known as "function creation routines")
4629 ** are used to add SQL functions or aggregates or to redefine the behavior
4630 ** of existing SQL functions or aggregates. The only differences between
4631 ** the three "sqlite3_create_function*" routines are the text encoding
4632 ** expected for the second parameter (the name of the function being
4633 ** created) and the presence or absence of a destructor callback for
4634 ** the application data pointer. Function sqlite3_create_window_function()
4635 ** is similar, but allows the user to supply the extra callback functions
4636 ** needed by [aggregate window functions].
4637 **
4638 ** ^The first parameter is the [database connection] to which the SQL
4639 ** function is to be added. ^If an application uses more than one database
4640 ** connection then application-defined SQL functions must be added
4641 ** to each database connection separately.
@@ -4643,28 +4677,38 @@
4677 ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
4678 **
4679 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
4680 ** function can gain access to this pointer using [sqlite3_user_data()].)^
4681 **
4682 ** ^The sixth, seventh and eighth parameters passed to the three
4683 ** "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are
4684 ** pointers to C-language functions that implement the SQL function or
4685 ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
4686 ** callback only; NULL pointers must be passed as the xStep and xFinal
4687 ** parameters. ^An aggregate SQL function requires an implementation of xStep
4688 ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
4689 ** SQL function or aggregate, pass NULL pointers for all three function
4690 ** callbacks.
4691 **
4692 ** ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue
4693 ** and xInverse) passed to sqlite3_create_window_function are pointers to
4694 ** C-lanugage callbacks that implement the new function. xStep and xFinal
4695 ** must both be non-NULL. xValue and xInverse may either both be NULL, in
4696 ** which case a regular aggregate function is created, or must both be
4697 ** non-NULL, in which case the new function may be used as either an aggregate
4698 ** or aggregate window function. More details regarding the implementation
4699 ** of aggregate window functions are
4700 ** [user-defined window functions|available here].
4701 **
4702 ** ^(If the final parameter to sqlite3_create_function_v2() or
4703 ** sqlite3_create_window_function() is not NULL, then it is destructor for
4704 ** the application data pointer. The destructor is invoked when the function
4705 ** is deleted, either by being overloaded or when the database connection
4706 ** closes.)^ ^The destructor is also invoked if the call to
4707 ** sqlite3_create_function_v2() fails. ^When the destructor callback is
4708 ** invoked, it is passed a single argument which is a copy of the application
4709 ** data pointer which was the fifth parameter to sqlite3_create_function_v2().
4710 **
4711 ** ^It is permitted to register multiple implementations of the same
4712 ** functions with the same name but with either differing numbers of
4713 ** arguments or differing preferred text encodings. ^SQLite will use
4714 ** the implementation that most closely matches the way in which the
@@ -4712,10 +4756,22 @@
4756 void *pApp,
4757 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4758 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4759 void (*xFinal)(sqlite3_context*),
4760 void(*xDestroy)(void*)
4761 );
4762 SQLITE_API int sqlite3_create_window_function(
4763 sqlite3 *db,
4764 const char *zFunctionName,
4765 int nArg,
4766 int eTextRep,
4767 void *pApp,
4768 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4769 void (*xFinal)(sqlite3_context*),
4770 void (*xValue)(sqlite3_context*),
4771 void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
4772 void(*xDestroy)(void*)
4773 );
4774
4775 /*
4776 ** CAPI3REF: Text Encodings
4777 **
@@ -4855,10 +4911,32 @@
4911 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
4912 ** or [sqlite3_value_text16()].
4913 **
4914 ** These routines must be called from the same thread as
4915 ** the SQL function that supplied the [sqlite3_value*] parameters.
4916 **
4917 ** As long as the input parameter is correct, these routines can only
4918 ** fail if an out-of-memory error occurs during a format conversion.
4919 ** Only the following subset of interfaces are subject to out-of-memory
4920 ** errors:
4921 **
4922 ** <ul>
4923 ** <li> sqlite3_value_blob()
4924 ** <li> sqlite3_value_text()
4925 ** <li> sqlite3_value_text16()
4926 ** <li> sqlite3_value_text16le()
4927 ** <li> sqlite3_value_text16be()
4928 ** <li> sqlite3_value_bytes()
4929 ** <li> sqlite3_value_bytes16()
4930 ** </ul>
4931 **
4932 ** If an out-of-memory error occurs, then the return value from these
4933 ** routines is the same as if the column had contained an SQL NULL value.
4934 ** Valid SQL NULL returns can be distinguished from out-of-memory errors
4935 ** by invoking the [sqlite3_errcode()] immediately after the suspect
4936 ** return value is obtained and before any
4937 ** other SQLite interface is called on the same [database connection].
4938 */
4939 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4940 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4941 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4942 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4943

Keyboard Shortcuts

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