diff options
| author | 2021-09-07 01:27:59 +0200 | |
|---|---|---|
| committer | 2021-10-18 17:38:09 +0200 | |
| commit | 0c2c4d248325ee94ec072d95a8fd4b43df560f5c (patch) | |
| tree | 62a65f11c3c3616f86207bd3b76d9be31b278960 /c | |
| parent | Db.getPragmaQuery: use comptimePrint instead of bufPrint (diff) | |
| download | zig-sqlite-0c2c4d248325ee94ec072d95a8fd4b43df560f5c.tar.gz zig-sqlite-0c2c4d248325ee94ec072d95a8fd4b43df560f5c.tar.xz zig-sqlite-0c2c4d248325ee94ec072d95a8fd4b43df560f5c.zip | |
update sqlite bundled source code to 3.36.0
Diffstat (limited to 'c')
| -rw-r--r-- | c/sqlite3.c | 7180 | ||||
| -rw-r--r-- | c/sqlite3.h | 133 |
2 files changed, 4339 insertions, 2974 deletions
diff --git a/c/sqlite3.c b/c/sqlite3.c index df53e43..89faea5 100644 --- a/c/sqlite3.c +++ b/c/sqlite3.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /****************************************************************************** | 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.35.5. By combining all the individual C code files into this | 3 | ** version 3.36.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 | 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 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements | 6 | ** possible if the files were compiled separately. Performance improvements |
| @@ -83,8 +83,10 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 83 | #if SQLITE_64BIT_STATS | 83 | #if SQLITE_64BIT_STATS |
| 84 | "64BIT_STATS", | 84 | "64BIT_STATS", |
| 85 | #endif | 85 | #endif |
| 86 | #if SQLITE_ALLOW_COVERING_INDEX_SCAN | 86 | #ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN |
| 87 | "ALLOW_COVERING_INDEX_SCAN", | 87 | # if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1 |
| 88 | "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN), | ||
| 89 | # endif | ||
| 88 | #endif | 90 | #endif |
| 89 | #if SQLITE_ALLOW_URI_AUTHORITY | 91 | #if SQLITE_ALLOW_URI_AUTHORITY |
| 90 | "ALLOW_URI_AUTHORITY", | 92 | "ALLOW_URI_AUTHORITY", |
| @@ -146,8 +148,10 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 146 | #ifdef SQLITE_DEFAULT_LOOKASIDE | 148 | #ifdef SQLITE_DEFAULT_LOOKASIDE |
| 147 | "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE), | 149 | "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE), |
| 148 | #endif | 150 | #endif |
| 149 | #if SQLITE_DEFAULT_MEMSTATUS | 151 | #ifdef SQLITE_DEFAULT_MEMSTATUS |
| 150 | "DEFAULT_MEMSTATUS", | 152 | # if SQLITE_DEFAULT_MEMSTATUS != 1 |
| 153 | "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS), | ||
| 154 | # endif | ||
| 151 | #endif | 155 | #endif |
| 152 | #ifdef SQLITE_DEFAULT_MMAP_SIZE | 156 | #ifdef SQLITE_DEFAULT_MMAP_SIZE |
| 153 | "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE), | 157 | "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE), |
| @@ -221,7 +225,7 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 221 | #if SQLITE_ENABLE_BYTECODE_VTAB | 225 | #if SQLITE_ENABLE_BYTECODE_VTAB |
| 222 | "ENABLE_BYTECODE_VTAB", | 226 | "ENABLE_BYTECODE_VTAB", |
| 223 | #endif | 227 | #endif |
| 224 | #if SQLITE_ENABLE_CEROD | 228 | #ifdef SQLITE_ENABLE_CEROD |
| 225 | "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD), | 229 | "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD), |
| 226 | #endif | 230 | #endif |
| 227 | #if SQLITE_ENABLE_COLUMN_METADATA | 231 | #if SQLITE_ENABLE_COLUMN_METADATA |
| @@ -236,17 +240,17 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 236 | #if SQLITE_ENABLE_CURSOR_HINTS | 240 | #if SQLITE_ENABLE_CURSOR_HINTS |
| 237 | "ENABLE_CURSOR_HINTS", | 241 | "ENABLE_CURSOR_HINTS", |
| 238 | #endif | 242 | #endif |
| 243 | #if SQLITE_ENABLE_DBPAGE_VTAB | ||
| 244 | "ENABLE_DBPAGE_VTAB", | ||
| 245 | #endif | ||
| 239 | #if SQLITE_ENABLE_DBSTAT_VTAB | 246 | #if SQLITE_ENABLE_DBSTAT_VTAB |
| 240 | "ENABLE_DBSTAT_VTAB", | 247 | "ENABLE_DBSTAT_VTAB", |
| 241 | #endif | 248 | #endif |
| 242 | #if SQLITE_ENABLE_EXPENSIVE_ASSERT | 249 | #if SQLITE_ENABLE_EXPENSIVE_ASSERT |
| 243 | "ENABLE_EXPENSIVE_ASSERT", | 250 | "ENABLE_EXPENSIVE_ASSERT", |
| 244 | #endif | 251 | #endif |
| 245 | #if SQLITE_ENABLE_FTS1 | 252 | #if SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 246 | "ENABLE_FTS1", | 253 | "ENABLE_EXPLAIN_COMMENTS", |
| 247 | #endif | ||
| 248 | #if SQLITE_ENABLE_FTS2 | ||
| 249 | "ENABLE_FTS2", | ||
| 250 | #endif | 254 | #endif |
| 251 | #if SQLITE_ENABLE_FTS3 | 255 | #if SQLITE_ENABLE_FTS3 |
| 252 | "ENABLE_FTS3", | 256 | "ENABLE_FTS3", |
| @@ -305,6 +309,9 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 305 | #if SQLITE_ENABLE_NULL_TRIM | 309 | #if SQLITE_ENABLE_NULL_TRIM |
| 306 | "ENABLE_NULL_TRIM", | 310 | "ENABLE_NULL_TRIM", |
| 307 | #endif | 311 | #endif |
| 312 | #if SQLITE_ENABLE_OFFSET_SQL_FUNC | ||
| 313 | "ENABLE_OFFSET_SQL_FUNC", | ||
| 314 | #endif | ||
| 308 | #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK | 315 | #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK |
| 309 | "ENABLE_OVERSIZE_CELL_CHECK", | 316 | "ENABLE_OVERSIZE_CELL_CHECK", |
| 310 | #endif | 317 | #endif |
| @@ -335,7 +342,7 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 335 | #if SQLITE_ENABLE_SQLLOG | 342 | #if SQLITE_ENABLE_SQLLOG |
| 336 | "ENABLE_SQLLOG", | 343 | "ENABLE_SQLLOG", |
| 337 | #endif | 344 | #endif |
| 338 | #if defined(SQLITE_ENABLE_STAT4) | 345 | #if SQLITE_ENABLE_STAT4 |
| 339 | "ENABLE_STAT4", | 346 | "ENABLE_STAT4", |
| 340 | #endif | 347 | #endif |
| 341 | #if SQLITE_ENABLE_STMTVTAB | 348 | #if SQLITE_ENABLE_STMTVTAB |
| @@ -389,8 +396,10 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 389 | #if HAVE_ISNAN || SQLITE_HAVE_ISNAN | 396 | #if HAVE_ISNAN || SQLITE_HAVE_ISNAN |
| 390 | "HAVE_ISNAN", | 397 | "HAVE_ISNAN", |
| 391 | #endif | 398 | #endif |
| 392 | #if SQLITE_HOMEGROWN_RECURSIVE_MUTEX | 399 | #ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX |
| 393 | "HOMEGROWN_RECURSIVE_MUTEX", | 400 | # if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1 |
| 401 | "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX), | ||
| 402 | # endif | ||
| 394 | #endif | 403 | #endif |
| 395 | #if SQLITE_IGNORE_AFP_LOCK_ERRORS | 404 | #if SQLITE_IGNORE_AFP_LOCK_ERRORS |
| 396 | "IGNORE_AFP_LOCK_ERRORS", | 405 | "IGNORE_AFP_LOCK_ERRORS", |
| @@ -488,9 +497,6 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 488 | #if SQLITE_MUTEX_NOOP | 497 | #if SQLITE_MUTEX_NOOP |
| 489 | "MUTEX_NOOP", | 498 | "MUTEX_NOOP", |
| 490 | #endif | 499 | #endif |
| 491 | #if SQLITE_MUTEX_NREF | ||
| 492 | "MUTEX_NREF", | ||
| 493 | #endif | ||
| 494 | #if SQLITE_MUTEX_OMIT | 500 | #if SQLITE_MUTEX_OMIT |
| 495 | "MUTEX_OMIT", | 501 | "MUTEX_OMIT", |
| 496 | #endif | 502 | #endif |
| @@ -560,7 +566,7 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 560 | #if SQLITE_OMIT_CTE | 566 | #if SQLITE_OMIT_CTE |
| 561 | "OMIT_CTE", | 567 | "OMIT_CTE", |
| 562 | #endif | 568 | #endif |
| 563 | #if SQLITE_OMIT_DATETIME_FUNCS | 569 | #if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT) |
| 564 | "OMIT_DATETIME_FUNCS", | 570 | "OMIT_DATETIME_FUNCS", |
| 565 | #endif | 571 | #endif |
| 566 | #if SQLITE_OMIT_DECLTYPE | 572 | #if SQLITE_OMIT_DECLTYPE |
| @@ -569,6 +575,9 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 569 | #if SQLITE_OMIT_DEPRECATED | 575 | #if SQLITE_OMIT_DEPRECATED |
| 570 | "OMIT_DEPRECATED", | 576 | "OMIT_DEPRECATED", |
| 571 | #endif | 577 | #endif |
| 578 | #if SQLITE_OMIT_DESERIALIZE | ||
| 579 | "OMIT_DESERIALIZE", | ||
| 580 | #endif | ||
| 572 | #if SQLITE_OMIT_DISKIO | 581 | #if SQLITE_OMIT_DISKIO |
| 573 | "OMIT_DISKIO", | 582 | "OMIT_DISKIO", |
| 574 | #endif | 583 | #endif |
| @@ -596,6 +605,9 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 596 | #if SQLITE_OMIT_INTEGRITY_CHECK | 605 | #if SQLITE_OMIT_INTEGRITY_CHECK |
| 597 | "OMIT_INTEGRITY_CHECK", | 606 | "OMIT_INTEGRITY_CHECK", |
| 598 | #endif | 607 | #endif |
| 608 | #if SQLITE_OMIT_INTROSPECTION_PRAGMAS | ||
| 609 | "OMIT_INTROSPECTION_PRAGMAS", | ||
| 610 | #endif | ||
| 599 | #if SQLITE_OMIT_LIKE_OPTIMIZATION | 611 | #if SQLITE_OMIT_LIKE_OPTIMIZATION |
| 600 | "OMIT_LIKE_OPTIMIZATION", | 612 | "OMIT_LIKE_OPTIMIZATION", |
| 601 | #endif | 613 | #endif |
| @@ -659,8 +671,10 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 659 | #if SQLITE_OMIT_TEST_CONTROL | 671 | #if SQLITE_OMIT_TEST_CONTROL |
| 660 | "OMIT_TEST_CONTROL", | 672 | "OMIT_TEST_CONTROL", |
| 661 | #endif | 673 | #endif |
| 662 | #if SQLITE_OMIT_TRACE | 674 | #ifdef SQLITE_OMIT_TRACE |
| 663 | "OMIT_TRACE", | 675 | # if SQLITE_OMIT_TRACE != 1 |
| 676 | "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE), | ||
| 677 | # endif | ||
| 664 | #endif | 678 | #endif |
| 665 | #if SQLITE_OMIT_TRIGGER | 679 | #if SQLITE_OMIT_TRIGGER |
| 666 | "OMIT_TRIGGER", | 680 | "OMIT_TRIGGER", |
| @@ -695,8 +709,10 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 695 | #if SQLITE_PERFORMANCE_TRACE | 709 | #if SQLITE_PERFORMANCE_TRACE |
| 696 | "PERFORMANCE_TRACE", | 710 | "PERFORMANCE_TRACE", |
| 697 | #endif | 711 | #endif |
| 698 | #if SQLITE_POWERSAFE_OVERWRITE | 712 | #ifdef SQLITE_POWERSAFE_OVERWRITE |
| 699 | "POWERSAFE_OVERWRITE", | 713 | # if SQLITE_POWERSAFE_OVERWRITE != 1 |
| 714 | "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE), | ||
| 715 | # endif | ||
| 700 | #endif | 716 | #endif |
| 701 | #if SQLITE_PREFER_PROXY_LOCKING | 717 | #if SQLITE_PREFER_PROXY_LOCKING |
| 702 | "PREFER_PROXY_LOCKING", | 718 | "PREFER_PROXY_LOCKING", |
| @@ -731,7 +747,10 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 731 | #if SQLITE_SUBSTR_COMPATIBILITY | 747 | #if SQLITE_SUBSTR_COMPATIBILITY |
| 732 | "SUBSTR_COMPATIBILITY", | 748 | "SUBSTR_COMPATIBILITY", |
| 733 | #endif | 749 | #endif |
| 734 | #if SQLITE_SYSTEM_MALLOC | 750 | #if (!defined(SQLITE_WIN32_MALLOC) \ |
| 751 | && !defined(SQLITE_ZERO_MALLOC) \ | ||
| 752 | && !defined(SQLITE_MEMDEBUG) \ | ||
| 753 | ) || defined(SQLITE_SYSTEM_MALLOC) | ||
| 735 | "SYSTEM_MALLOC", | 754 | "SYSTEM_MALLOC", |
| 736 | #endif | 755 | #endif |
| 737 | #if SQLITE_TCL | 756 | #if SQLITE_TCL |
| @@ -1186,9 +1205,9 @@ extern "C" { | |||
| 1186 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | 1205 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1187 | ** [sqlite_version()] and [sqlite_source_id()]. | 1206 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1188 | */ | 1207 | */ |
| 1189 | #define SQLITE_VERSION "3.35.5" | 1208 | #define SQLITE_VERSION "3.36.0" |
| 1190 | #define SQLITE_VERSION_NUMBER 3035005 | 1209 | #define SQLITE_VERSION_NUMBER 3036000 |
| 1191 | #define SQLITE_SOURCE_ID "2021-04-19 18:32:05 1b256d97b553a9611efca188a3d995a2fff712759044ba480f9a0c9e98fae886" | 1210 | #define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5" |
| 1192 | 1211 | ||
| 1193 | /* | 1212 | /* |
| 1194 | ** CAPI3REF: Run-Time Library Version Numbers | 1213 | ** CAPI3REF: Run-Time Library Version Numbers |
| @@ -2191,6 +2210,23 @@ struct sqlite3_io_methods { | |||
| 2191 | ** file to the database file, but before the *-shm file is updated to | 2210 | ** file to the database file, but before the *-shm file is updated to |
| 2192 | ** record the fact that the pages have been checkpointed. | 2211 | ** record the fact that the pages have been checkpointed. |
| 2193 | ** </ul> | 2212 | ** </ul> |
| 2213 | ** | ||
| 2214 | ** <li>[[SQLITE_FCNTL_EXTERNAL_READER]] | ||
| 2215 | ** The EXPERIMENTAL [SQLITE_FCNTL_EXTERNAL_READER] opcode is used to detect | ||
| 2216 | ** whether or not there is a database client in another process with a wal-mode | ||
| 2217 | ** transaction open on the database or not. It is only available on unix.The | ||
| 2218 | ** (void*) argument passed with this file-control should be a pointer to a | ||
| 2219 | ** value of type (int). The integer value is set to 1 if the database is a wal | ||
| 2220 | ** mode database and there exists at least one client in another process that | ||
| 2221 | ** currently has an SQL transaction open on the database. It is set to 0 if | ||
| 2222 | ** the database is not a wal-mode db, or if there is no such connection in any | ||
| 2223 | ** other process. This opcode cannot be used to detect transactions opened | ||
| 2224 | ** by clients within the current process, only within other processes. | ||
| 2225 | ** </ul> | ||
| 2226 | ** | ||
| 2227 | ** <li>[[SQLITE_FCNTL_CKSM_FILE]] | ||
| 2228 | ** Used by the cksmvfs VFS module only. | ||
| 2229 | ** </ul> | ||
| 2194 | */ | 2230 | */ |
| 2195 | #define SQLITE_FCNTL_LOCKSTATE 1 | 2231 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 2196 | #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 | 2232 | #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 |
| @@ -2230,6 +2266,8 @@ struct sqlite3_io_methods { | |||
| 2230 | #define SQLITE_FCNTL_CKPT_DONE 37 | 2266 | #define SQLITE_FCNTL_CKPT_DONE 37 |
| 2231 | #define SQLITE_FCNTL_RESERVE_BYTES 38 | 2267 | #define SQLITE_FCNTL_RESERVE_BYTES 38 |
| 2232 | #define SQLITE_FCNTL_CKPT_START 39 | 2268 | #define SQLITE_FCNTL_CKPT_START 39 |
| 2269 | #define SQLITE_FCNTL_EXTERNAL_READER 40 | ||
| 2270 | #define SQLITE_FCNTL_CKSM_FILE 41 | ||
| 2233 | 2271 | ||
| 2234 | /* deprecated names */ | 2272 | /* deprecated names */ |
| 2235 | #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE | 2273 | #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE |
| @@ -5242,6 +5280,15 @@ SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt); | |||
| 5242 | ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and | 5280 | ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and |
| 5243 | ** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so | 5281 | ** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so |
| 5244 | ** sqlite3_stmt_readonly() returns false for those commands. | 5282 | ** sqlite3_stmt_readonly() returns false for those commands. |
| 5283 | ** | ||
| 5284 | ** ^This routine returns false if there is any possibility that the | ||
| 5285 | ** statement might change the database file. ^A false return does | ||
| 5286 | ** not guarantee that the statement will change the database file. | ||
| 5287 | ** ^For example, an UPDATE statement might have a WHERE clause that | ||
| 5288 | ** makes it a no-op, but the sqlite3_stmt_readonly() result would still | ||
| 5289 | ** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a | ||
| 5290 | ** read-only no-op if the table already exists, but | ||
| 5291 | ** sqlite3_stmt_readonly() still returns false for such a statement. | ||
| 5245 | */ | 5292 | */ |
| 5246 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); | 5293 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 5247 | 5294 | ||
| @@ -5411,18 +5458,22 @@ typedef struct sqlite3_context sqlite3_context; | |||
| 5411 | ** contain embedded NULs. The result of expressions involving strings | 5458 | ** contain embedded NULs. The result of expressions involving strings |
| 5412 | ** with embedded NULs is undefined. | 5459 | ** with embedded NULs is undefined. |
| 5413 | ** | 5460 | ** |
| 5414 | ** ^The fifth argument to the BLOB and string binding interfaces | 5461 | ** ^The fifth argument to the BLOB and string binding interfaces controls |
| 5415 | ** is a destructor used to dispose of the BLOB or | 5462 | ** or indicates the lifetime of the object referenced by the third parameter. |
| 5416 | ** string after SQLite has finished with it. ^The destructor is called | 5463 | ** These three options exist: |
| 5417 | ** to dispose of the BLOB or string even if the call to the bind API fails, | 5464 | ** ^ (1) A destructor to dispose of the BLOB or string after SQLite has finished |
| 5418 | ** except the destructor is not called if the third parameter is a NULL | 5465 | ** with it may be passed. ^It is called to dispose of the BLOB or string even |
| 5419 | ** pointer or the fourth parameter is negative. | 5466 | ** if the call to the bind API fails, except the destructor is not called if |
| 5420 | ** ^If the fifth argument is | 5467 | ** the third parameter is a NULL pointer or the fourth parameter is negative. |
| 5421 | ** the special value [SQLITE_STATIC], then SQLite assumes that the | 5468 | ** ^ (2) The special constant, [SQLITE_STATIC], may be passsed to indicate that |
| 5422 | ** information is in static, unmanaged space and does not need to be freed. | 5469 | ** the application remains responsible for disposing of the object. ^In this |
| 5423 | ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then | 5470 | ** case, the object and the provided pointer to it must remain valid until |
| 5424 | ** SQLite makes its own private copy of the data immediately, before | 5471 | ** either the prepared statement is finalized or the same SQL parameter is |
| 5425 | ** the sqlite3_bind_*() routine returns. | 5472 | ** bound to something else, whichever occurs sooner. |
| 5473 | ** ^ (3) The constant, [SQLITE_TRANSIENT], may be passed to indicate that the | ||
| 5474 | ** object is to be copied prior to the return from sqlite3_bind_*(). ^The | ||
| 5475 | ** object and pointer to it must remain valid until then. ^SQLite will then | ||
| 5476 | ** manage the lifetime of its private copy. | ||
| 5426 | ** | 5477 | ** |
| 5427 | ** ^The sixth argument to sqlite3_bind_text64() must be one of | 5478 | ** ^The sixth argument to sqlite3_bind_text64() must be one of |
| 5428 | ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE] | 5479 | ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE] |
| @@ -6164,7 +6215,6 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); | |||
| 6164 | ** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, | 6215 | ** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, |
| 6165 | ** index expressions, or the WHERE clause of partial indexes. | 6216 | ** index expressions, or the WHERE clause of partial indexes. |
| 6166 | ** | 6217 | ** |
| 6167 | ** <span style="background-color:#ffff90;"> | ||
| 6168 | ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for | 6218 | ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for |
| 6169 | ** all application-defined SQL functions that do not need to be | 6219 | ** all application-defined SQL functions that do not need to be |
| 6170 | ** used inside of triggers, view, CHECK constraints, or other elements of | 6220 | ** used inside of triggers, view, CHECK constraints, or other elements of |
| @@ -6174,7 +6224,6 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); | |||
| 6174 | ** a database file to include invocations of the function with parameters | 6224 | ** a database file to include invocations of the function with parameters |
| 6175 | ** chosen by the attacker, which the application will then execute when | 6225 | ** chosen by the attacker, which the application will then execute when |
| 6176 | ** the database file is opened and read. | 6226 | ** the database file is opened and read. |
| 6177 | ** </span> | ||
| 6178 | ** | 6227 | ** |
| 6179 | ** ^(The fifth parameter is an arbitrary pointer. The implementation of the | 6228 | ** ^(The fifth parameter is an arbitrary pointer. The implementation of the |
| 6180 | ** function can gain access to this pointer using [sqlite3_user_data()].)^ | 6229 | ** function can gain access to this pointer using [sqlite3_user_data()].)^ |
| @@ -8842,7 +8891,8 @@ SQLITE_API int sqlite3_test_control(int op, ...); | |||
| 8842 | #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 | 8891 | #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 |
| 8843 | #define SQLITE_TESTCTRL_SEEK_COUNT 30 | 8892 | #define SQLITE_TESTCTRL_SEEK_COUNT 30 |
| 8844 | #define SQLITE_TESTCTRL_TRACEFLAGS 31 | 8893 | #define SQLITE_TESTCTRL_TRACEFLAGS 31 |
| 8845 | #define SQLITE_TESTCTRL_LAST 31 /* Largest TESTCTRL */ | 8894 | #define SQLITE_TESTCTRL_TUNE 32 |
| 8895 | #define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */ | ||
| 8846 | 8896 | ||
| 8847 | /* | 8897 | /* |
| 8848 | ** CAPI3REF: SQL Keyword Checking | 8898 | ** CAPI3REF: SQL Keyword Checking |
| @@ -10594,6 +10644,15 @@ SQLITE_API int sqlite3_db_cacheflush(sqlite3*); | |||
| 10594 | ** triggers; or 2 for changes resulting from triggers called by top-level | 10644 | ** triggers; or 2 for changes resulting from triggers called by top-level |
| 10595 | ** triggers; and so forth. | 10645 | ** triggers; and so forth. |
| 10596 | ** | 10646 | ** |
| 10647 | ** When the [sqlite3_blob_write()] API is used to update a blob column, | ||
| 10648 | ** the pre-update hook is invoked with SQLITE_DELETE. This is because the | ||
| 10649 | ** in this case the new values are not available. In this case, when a | ||
| 10650 | ** callback made with op==SQLITE_DELETE is actuall a write using the | ||
| 10651 | ** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns | ||
| 10652 | ** the index of the column being written. In other cases, where the | ||
| 10653 | ** pre-update hook is being invoked for some other reason, including a | ||
| 10654 | ** regular DELETE, sqlite3_preupdate_blobwrite() returns -1. | ||
| 10655 | ** | ||
| 10597 | ** See also: [sqlite3_update_hook()] | 10656 | ** See also: [sqlite3_update_hook()] |
| 10598 | */ | 10657 | */ |
| 10599 | #if defined(SQLITE_ENABLE_PREUPDATE_HOOK) | 10658 | #if defined(SQLITE_ENABLE_PREUPDATE_HOOK) |
| @@ -10614,6 +10673,7 @@ SQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **); | |||
| 10614 | SQLITE_API int sqlite3_preupdate_count(sqlite3 *); | 10673 | SQLITE_API int sqlite3_preupdate_count(sqlite3 *); |
| 10615 | SQLITE_API int sqlite3_preupdate_depth(sqlite3 *); | 10674 | SQLITE_API int sqlite3_preupdate_depth(sqlite3 *); |
| 10616 | SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **); | 10675 | SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **); |
| 10676 | SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *); | ||
| 10617 | #endif | 10677 | #endif |
| 10618 | 10678 | ||
| 10619 | /* | 10679 | /* |
| @@ -10852,8 +10912,8 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c | |||
| 10852 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory | 10912 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory |
| 10853 | ** allocation error occurs. | 10913 | ** allocation error occurs. |
| 10854 | ** | 10914 | ** |
| 10855 | ** This interface is only available if SQLite is compiled with the | 10915 | ** This interface is omitted if SQLite is compiled with the |
| 10856 | ** [SQLITE_ENABLE_DESERIALIZE] option. | 10916 | ** [SQLITE_OMIT_DESERIALIZE] option. |
| 10857 | */ | 10917 | */ |
| 10858 | SQLITE_API unsigned char *sqlite3_serialize( | 10918 | SQLITE_API unsigned char *sqlite3_serialize( |
| 10859 | sqlite3 *db, /* The database connection */ | 10919 | sqlite3 *db, /* The database connection */ |
| @@ -10904,8 +10964,8 @@ SQLITE_API unsigned char *sqlite3_serialize( | |||
| 10904 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then | 10964 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then |
| 10905 | ** [sqlite3_free()] is invoked on argument P prior to returning. | 10965 | ** [sqlite3_free()] is invoked on argument P prior to returning. |
| 10906 | ** | 10966 | ** |
| 10907 | ** This interface is only available if SQLite is compiled with the | 10967 | ** This interface is omitted if SQLite is compiled with the |
| 10908 | ** [SQLITE_ENABLE_DESERIALIZE] option. | 10968 | ** [SQLITE_OMIT_DESERIALIZE] option. |
| 10909 | */ | 10969 | */ |
| 10910 | SQLITE_API int sqlite3_deserialize( | 10970 | SQLITE_API int sqlite3_deserialize( |
| 10911 | sqlite3 *db, /* The database connection */ | 10971 | sqlite3 *db, /* The database connection */ |
| @@ -11154,6 +11214,38 @@ SQLITE_API int sqlite3session_create( | |||
| 11154 | */ | 11214 | */ |
| 11155 | SQLITE_API void sqlite3session_delete(sqlite3_session *pSession); | 11215 | SQLITE_API void sqlite3session_delete(sqlite3_session *pSession); |
| 11156 | 11216 | ||
| 11217 | /* | ||
| 11218 | ** CAPIREF: Conigure a Session Object | ||
| 11219 | ** METHOD: sqlite3_session | ||
| 11220 | ** | ||
| 11221 | ** This method is used to configure a session object after it has been | ||
| 11222 | ** created. At present the only valid value for the second parameter is | ||
| 11223 | ** [SQLITE_SESSION_OBJCONFIG_SIZE]. | ||
| 11224 | ** | ||
| 11225 | ** Arguments for sqlite3session_object_config() | ||
| 11226 | ** | ||
| 11227 | ** The following values may passed as the the 4th parameter to | ||
| 11228 | ** sqlite3session_object_config(). | ||
| 11229 | ** | ||
| 11230 | ** <dt>SQLITE_SESSION_OBJCONFIG_SIZE <dd> | ||
| 11231 | ** This option is used to set, clear or query the flag that enables | ||
| 11232 | ** the [sqlite3session_changeset_size()] API. Because it imposes some | ||
| 11233 | ** computational overhead, this API is disabled by default. Argument | ||
| 11234 | ** pArg must point to a value of type (int). If the value is initially | ||
| 11235 | ** 0, then the sqlite3session_changeset_size() API is disabled. If it | ||
| 11236 | ** is greater than 0, then the same API is enabled. Or, if the initial | ||
| 11237 | ** value is less than zero, no change is made. In all cases the (int) | ||
| 11238 | ** variable is set to 1 if the sqlite3session_changeset_size() API is | ||
| 11239 | ** enabled following the current call, or 0 otherwise. | ||
| 11240 | ** | ||
| 11241 | ** It is an error (SQLITE_MISUSE) to attempt to modify this setting after | ||
| 11242 | ** the first table has been attached to the session object. | ||
| 11243 | */ | ||
| 11244 | SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg); | ||
| 11245 | |||
| 11246 | /* | ||
| 11247 | */ | ||
| 11248 | #define SQLITE_SESSION_OBJCONFIG_SIZE 1 | ||
| 11157 | 11249 | ||
| 11158 | /* | 11250 | /* |
| 11159 | ** CAPI3REF: Enable Or Disable A Session Object | 11251 | ** CAPI3REF: Enable Or Disable A Session Object |
| @@ -11399,6 +11491,22 @@ SQLITE_API int sqlite3session_changeset( | |||
| 11399 | ); | 11491 | ); |
| 11400 | 11492 | ||
| 11401 | /* | 11493 | /* |
| 11494 | ** CAPI3REF: Return An Upper-limit For The Size Of The Changeset | ||
| 11495 | ** METHOD: sqlite3_session | ||
| 11496 | ** | ||
| 11497 | ** By default, this function always returns 0. For it to return | ||
| 11498 | ** a useful result, the sqlite3_session object must have been configured | ||
| 11499 | ** to enable this API using sqlite3session_object_config() with the | ||
| 11500 | ** SQLITE_SESSION_OBJCONFIG_SIZE verb. | ||
| 11501 | ** | ||
| 11502 | ** When enabled, this function returns an upper limit, in bytes, for the size | ||
| 11503 | ** of the changeset that might be produced if sqlite3session_changeset() were | ||
| 11504 | ** called. The final changeset size might be equal to or smaller than the | ||
| 11505 | ** size in bytes returned by this function. | ||
| 11506 | */ | ||
| 11507 | SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession); | ||
| 11508 | |||
| 11509 | /* | ||
| 11402 | ** CAPI3REF: Load The Difference Between Tables Into A Session | 11510 | ** CAPI3REF: Load The Difference Between Tables Into A Session |
| 11403 | ** METHOD: sqlite3_session | 11511 | ** METHOD: sqlite3_session |
| 11404 | ** | 11512 | ** |
| @@ -14222,8 +14330,9 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*); | |||
| 14222 | #define TK_IF_NULL_ROW 178 | 14330 | #define TK_IF_NULL_ROW 178 |
| 14223 | #define TK_ASTERISK 179 | 14331 | #define TK_ASTERISK 179 |
| 14224 | #define TK_SPAN 180 | 14332 | #define TK_SPAN 180 |
| 14225 | #define TK_SPACE 181 | 14333 | #define TK_ERROR 181 |
| 14226 | #define TK_ILLEGAL 182 | 14334 | #define TK_SPACE 182 |
| 14335 | #define TK_ILLEGAL 183 | ||
| 14227 | 14336 | ||
| 14228 | /************** End of parse.h ***********************************************/ | 14337 | /************** End of parse.h ***********************************************/ |
| 14229 | /************** Continuing where we left off in sqliteInt.h ******************/ | 14338 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| @@ -15760,7 +15869,7 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 15760 | #define OP_Le 55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */ | 15869 | #define OP_Le 55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */ |
| 15761 | #define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */ | 15870 | #define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */ |
| 15762 | #define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */ | 15871 | #define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */ |
| 15763 | #define OP_ElseNotEq 58 /* jump, same as TK_ESCAPE */ | 15872 | #define OP_ElseEq 58 /* jump, same as TK_ESCAPE */ |
| 15764 | #define OP_DecrJumpZero 59 /* jump, synopsis: if (--r[P1])==0 goto P2 */ | 15873 | #define OP_DecrJumpZero 59 /* jump, synopsis: if (--r[P1])==0 goto P2 */ |
| 15765 | #define OP_IncrVacuum 60 /* jump */ | 15874 | #define OP_IncrVacuum 60 /* jump */ |
| 15766 | #define OP_VNext 61 /* jump */ | 15875 | #define OP_VNext 61 /* jump */ |
| @@ -15791,19 +15900,19 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 15791 | #define OP_Permutation 86 | 15900 | #define OP_Permutation 86 |
| 15792 | #define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */ | 15901 | #define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 15793 | #define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ | 15902 | #define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ |
| 15794 | #define OP_Offset 89 /* synopsis: r[P3] = sqlite_offset(P1) */ | 15903 | #define OP_ZeroOrNull 89 /* synopsis: r[P2] = 0 OR NULL */ |
| 15795 | #define OP_Column 90 /* synopsis: r[P3]=PX */ | 15904 | #define OP_Offset 90 /* synopsis: r[P3] = sqlite_offset(P1) */ |
| 15796 | #define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */ | 15905 | #define OP_Column 91 /* synopsis: r[P3]=PX */ |
| 15797 | #define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ | 15906 | #define OP_Affinity 92 /* synopsis: affinity(r[P1@P2]) */ |
| 15798 | #define OP_Count 93 /* synopsis: r[P2]=count() */ | 15907 | #define OP_MakeRecord 93 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 15799 | #define OP_ReadCookie 94 | 15908 | #define OP_Count 94 /* synopsis: r[P2]=count() */ |
| 15800 | #define OP_SetCookie 95 | 15909 | #define OP_ReadCookie 95 |
| 15801 | #define OP_ReopenIdx 96 /* synopsis: root=P2 iDb=P3 */ | 15910 | #define OP_SetCookie 96 |
| 15802 | #define OP_OpenRead 97 /* synopsis: root=P2 iDb=P3 */ | 15911 | #define OP_ReopenIdx 97 /* synopsis: root=P2 iDb=P3 */ |
| 15803 | #define OP_OpenWrite 98 /* synopsis: root=P2 iDb=P3 */ | 15912 | #define OP_OpenRead 98 /* synopsis: root=P2 iDb=P3 */ |
| 15804 | #define OP_OpenDup 99 | 15913 | #define OP_OpenWrite 99 /* synopsis: root=P2 iDb=P3 */ |
| 15805 | #define OP_OpenAutoindex 100 /* synopsis: nColumn=P2 */ | 15914 | #define OP_OpenDup 100 |
| 15806 | #define OP_OpenEphemeral 101 /* synopsis: nColumn=P2 */ | 15915 | #define OP_OpenAutoindex 101 /* synopsis: nColumn=P2 */ |
| 15807 | #define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ | 15916 | #define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 15808 | #define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ | 15917 | #define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 15809 | #define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ | 15918 | #define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| @@ -15814,73 +15923,74 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 15814 | #define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ | 15923 | #define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 15815 | #define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ | 15924 | #define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 15816 | #define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ | 15925 | #define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 15817 | #define OP_SorterOpen 112 | 15926 | #define OP_OpenEphemeral 112 /* synopsis: nColumn=P2 */ |
| 15818 | #define OP_BitNot 113 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ | 15927 | #define OP_BitNot 113 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ |
| 15819 | #define OP_SequenceTest 114 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ | 15928 | #define OP_SorterOpen 114 |
| 15820 | #define OP_OpenPseudo 115 /* synopsis: P3 columns in r[P2] */ | 15929 | #define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 15821 | #define OP_String8 116 /* same as TK_STRING, synopsis: r[P2]='P4' */ | 15930 | #define OP_String8 116 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 15822 | #define OP_Close 117 | 15931 | #define OP_OpenPseudo 117 /* synopsis: P3 columns in r[P2] */ |
| 15823 | #define OP_ColumnsUsed 118 | 15932 | #define OP_Close 118 |
| 15824 | #define OP_SeekScan 119 /* synopsis: Scan-ahead up to P1 rows */ | 15933 | #define OP_ColumnsUsed 119 |
| 15825 | #define OP_SeekHit 120 /* synopsis: set P2<=seekHit<=P3 */ | 15934 | #define OP_SeekScan 120 /* synopsis: Scan-ahead up to P1 rows */ |
| 15826 | #define OP_Sequence 121 /* synopsis: r[P2]=cursor[P1].ctr++ */ | 15935 | #define OP_SeekHit 121 /* synopsis: set P2<=seekHit<=P3 */ |
| 15827 | #define OP_NewRowid 122 /* synopsis: r[P2]=rowid */ | 15936 | #define OP_Sequence 122 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 15828 | #define OP_Insert 123 /* synopsis: intkey=r[P3] data=r[P2] */ | 15937 | #define OP_NewRowid 123 /* synopsis: r[P2]=rowid */ |
| 15829 | #define OP_RowCell 124 | 15938 | #define OP_Insert 124 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 15830 | #define OP_Delete 125 | 15939 | #define OP_RowCell 125 |
| 15831 | #define OP_ResetCount 126 | 15940 | #define OP_Delete 126 |
| 15832 | #define OP_SorterCompare 127 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ | 15941 | #define OP_ResetCount 127 |
| 15833 | #define OP_SorterData 128 /* synopsis: r[P2]=data */ | 15942 | #define OP_SorterCompare 128 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 15834 | #define OP_RowData 129 /* synopsis: r[P2]=data */ | 15943 | #define OP_SorterData 129 /* synopsis: r[P2]=data */ |
| 15835 | #define OP_Rowid 130 /* synopsis: r[P2]=rowid */ | 15944 | #define OP_RowData 130 /* synopsis: r[P2]=data */ |
| 15836 | #define OP_NullRow 131 | 15945 | #define OP_Rowid 131 /* synopsis: r[P2]=rowid */ |
| 15837 | #define OP_SeekEnd 132 | 15946 | #define OP_NullRow 132 |
| 15838 | #define OP_IdxInsert 133 /* synopsis: key=r[P2] */ | 15947 | #define OP_SeekEnd 133 |
| 15839 | #define OP_SorterInsert 134 /* synopsis: key=r[P2] */ | 15948 | #define OP_IdxInsert 134 /* synopsis: key=r[P2] */ |
| 15840 | #define OP_IdxDelete 135 /* synopsis: key=r[P2@P3] */ | 15949 | #define OP_SorterInsert 135 /* synopsis: key=r[P2] */ |
| 15841 | #define OP_DeferredSeek 136 /* synopsis: Move P3 to P1.rowid if needed */ | 15950 | #define OP_IdxDelete 136 /* synopsis: key=r[P2@P3] */ |
| 15842 | #define OP_IdxRowid 137 /* synopsis: r[P2]=rowid */ | 15951 | #define OP_DeferredSeek 137 /* synopsis: Move P3 to P1.rowid if needed */ |
| 15843 | #define OP_FinishSeek 138 | 15952 | #define OP_IdxRowid 138 /* synopsis: r[P2]=rowid */ |
| 15844 | #define OP_Destroy 139 | 15953 | #define OP_FinishSeek 139 |
| 15845 | #define OP_Clear 140 | 15954 | #define OP_Destroy 140 |
| 15846 | #define OP_ResetSorter 141 | 15955 | #define OP_Clear 141 |
| 15847 | #define OP_CreateBtree 142 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ | 15956 | #define OP_ResetSorter 142 |
| 15848 | #define OP_SqlExec 143 | 15957 | #define OP_CreateBtree 143 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ |
| 15849 | #define OP_ParseSchema 144 | 15958 | #define OP_SqlExec 144 |
| 15850 | #define OP_LoadAnalysis 145 | 15959 | #define OP_ParseSchema 145 |
| 15851 | #define OP_DropTable 146 | 15960 | #define OP_LoadAnalysis 146 |
| 15852 | #define OP_DropIndex 147 | 15961 | #define OP_DropTable 147 |
| 15853 | #define OP_DropTrigger 148 | 15962 | #define OP_DropIndex 148 |
| 15854 | #define OP_IntegrityCk 149 | 15963 | #define OP_DropTrigger 149 |
| 15855 | #define OP_RowSetAdd 150 /* synopsis: rowset(P1)=r[P2] */ | 15964 | #define OP_IntegrityCk 150 |
| 15856 | #define OP_Param 151 | 15965 | #define OP_RowSetAdd 151 /* synopsis: rowset(P1)=r[P2] */ |
| 15857 | #define OP_Real 152 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ | 15966 | #define OP_Real 152 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 15858 | #define OP_FkCounter 153 /* synopsis: fkctr[P1]+=P2 */ | 15967 | #define OP_Param 153 |
| 15859 | #define OP_MemMax 154 /* synopsis: r[P1]=max(r[P1],r[P2]) */ | 15968 | #define OP_FkCounter 154 /* synopsis: fkctr[P1]+=P2 */ |
| 15860 | #define OP_OffsetLimit 155 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ | 15969 | #define OP_MemMax 155 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 15861 | #define OP_AggInverse 156 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ | 15970 | #define OP_OffsetLimit 156 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 15862 | #define OP_AggStep 157 /* synopsis: accum=r[P3] step(r[P2@P5]) */ | 15971 | #define OP_AggInverse 157 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ |
| 15863 | #define OP_AggStep1 158 /* synopsis: accum=r[P3] step(r[P2@P5]) */ | 15972 | #define OP_AggStep 158 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 15864 | #define OP_AggValue 159 /* synopsis: r[P3]=value N=P2 */ | 15973 | #define OP_AggStep1 159 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 15865 | #define OP_AggFinal 160 /* synopsis: accum=r[P1] N=P2 */ | 15974 | #define OP_AggValue 160 /* synopsis: r[P3]=value N=P2 */ |
| 15866 | #define OP_Expire 161 | 15975 | #define OP_AggFinal 161 /* synopsis: accum=r[P1] N=P2 */ |
| 15867 | #define OP_CursorLock 162 | 15976 | #define OP_Expire 162 |
| 15868 | #define OP_CursorUnlock 163 | 15977 | #define OP_CursorLock 163 |
| 15869 | #define OP_TableLock 164 /* synopsis: iDb=P1 root=P2 write=P3 */ | 15978 | #define OP_CursorUnlock 164 |
| 15870 | #define OP_VBegin 165 | 15979 | #define OP_TableLock 165 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 15871 | #define OP_VCreate 166 | 15980 | #define OP_VBegin 166 |
| 15872 | #define OP_VDestroy 167 | 15981 | #define OP_VCreate 167 |
| 15873 | #define OP_VOpen 168 | 15982 | #define OP_VDestroy 168 |
| 15874 | #define OP_VColumn 169 /* synopsis: r[P3]=vcolumn(P2) */ | 15983 | #define OP_VOpen 169 |
| 15875 | #define OP_VRename 170 | 15984 | #define OP_VColumn 170 /* synopsis: r[P3]=vcolumn(P2) */ |
| 15876 | #define OP_Pagecount 171 | 15985 | #define OP_VRename 171 |
| 15877 | #define OP_MaxPgcnt 172 | 15986 | #define OP_Pagecount 172 |
| 15878 | #define OP_Trace 173 | 15987 | #define OP_MaxPgcnt 173 |
| 15879 | #define OP_CursorHint 174 | 15988 | #define OP_Trace 174 |
| 15880 | #define OP_ReleaseReg 175 /* synopsis: release r[P1@P2] mask P3 */ | 15989 | #define OP_CursorHint 175 |
| 15881 | #define OP_Noop 176 | 15990 | #define OP_ReleaseReg 176 /* synopsis: release r[P1@P2] mask P3 */ |
| 15882 | #define OP_Explain 177 | 15991 | #define OP_Noop 177 |
| 15883 | #define OP_Abortable 178 | 15992 | #define OP_Explain 178 |
| 15993 | #define OP_Abortable 179 | ||
| 15884 | 15994 | ||
| 15885 | /* Properties such as "out2" or "jump" that are specified in | 15995 | /* Properties such as "out2" or "jump" that are specified in |
| 15886 | ** comments following the "case" for each opcode in the vdbe.c | 15996 | ** comments following the "case" for each opcode in the vdbe.c |
| @@ -15904,20 +16014,20 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 15904 | /* 64 */ 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\ | 16014 | /* 64 */ 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\ |
| 15905 | /* 72 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\ | 16015 | /* 72 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\ |
| 15906 | /* 80 */ 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\ | 16016 | /* 80 */ 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\ |
| 15907 | /* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\ | 16017 | /* 88 */ 0x12, 0x1e, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10,\ |
| 15908 | /* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26,\ | 16018 | /* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26,\ |
| 15909 | /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\ | 16019 | /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 15910 | /* 112 */ 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\ | 16020 | /* 112 */ 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\ |
| 15911 | /* 120 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\ | 16021 | /* 120 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 15912 | /* 128 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x04, 0x04, 0x00,\ | 16022 | /* 128 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x04, 0x04,\ |
| 15913 | /* 136 */ 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00,\ | 16023 | /* 136 */ 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10,\ |
| 15914 | /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10,\ | 16024 | /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,\ |
| 15915 | /* 152 */ 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00,\ | 16025 | /* 152 */ 0x10, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00,\ |
| 15916 | /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ | 16026 | /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15917 | /* 168 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\ | 16027 | /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 15918 | /* 176 */ 0x00, 0x00, 0x00,} | 16028 | /* 176 */ 0x00, 0x00, 0x00, 0x00,} |
| 15919 | 16029 | ||
| 15920 | /* The sqlite3P2Values() routine is able to run faster if it knows | 16030 | /* The resolve3P2Values() routine is able to run faster if it knows |
| 15921 | ** the value of the largest JUMP opcode. The smaller the maximum | 16031 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 15922 | ** JUMP opcode the better, so the mkopcodeh.tcl script that | 16032 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 15923 | ** generated this include file strives to group all JUMP opcodes | 16033 | ** generated this include file strives to group all JUMP opcodes |
| @@ -16450,6 +16560,12 @@ SQLITE_PRIVATE int sqlite3PCacheIsDirty(PCache *pCache); | |||
| 16450 | # define SET_FULLSYNC(x,y) | 16560 | # define SET_FULLSYNC(x,y) |
| 16451 | #endif | 16561 | #endif |
| 16452 | 16562 | ||
| 16563 | /* Maximum pathname length. Note: FILENAME_MAX defined by stdio.h | ||
| 16564 | */ | ||
| 16565 | #ifndef SQLITE_MAX_PATHLEN | ||
| 16566 | # define SQLITE_MAX_PATHLEN FILENAME_MAX | ||
| 16567 | #endif | ||
| 16568 | |||
| 16453 | /* | 16569 | /* |
| 16454 | ** The default size of a disk sector | 16570 | ** The default size of a disk sector |
| 16455 | */ | 16571 | */ |
| @@ -17007,10 +17123,7 @@ struct sqlite3 { | |||
| 17007 | unsigned orphanTrigger : 1; /* Last statement is orphaned TEMP trigger */ | 17123 | unsigned orphanTrigger : 1; /* Last statement is orphaned TEMP trigger */ |
| 17008 | unsigned imposterTable : 1; /* Building an imposter table */ | 17124 | unsigned imposterTable : 1; /* Building an imposter table */ |
| 17009 | unsigned reopenMemdb : 1; /* ATTACH is really a reopen using MemDB */ | 17125 | unsigned reopenMemdb : 1; /* ATTACH is really a reopen using MemDB */ |
| 17010 | unsigned bDropColumn : 1; /* Doing schema check after DROP COLUMN */ | ||
| 17011 | char **azInit; /* "type", "name", and "tbl_name" columns */ | 17126 | char **azInit; /* "type", "name", and "tbl_name" columns */ |
| 17012 | /* or if bDropColumn, then azInit[0] is the */ | ||
| 17013 | /* name of the column being dropped */ | ||
| 17014 | } init; | 17127 | } init; |
| 17015 | int nVdbeActive; /* Number of VDBEs currently running */ | 17128 | int nVdbeActive; /* Number of VDBEs currently running */ |
| 17016 | int nVdbeRead; /* Number of active VDBEs that read or write */ | 17129 | int nVdbeRead; /* Number of active VDBEs that read or write */ |
| @@ -17208,7 +17321,7 @@ struct sqlite3 { | |||
| 17208 | #define SQLITE_SkipScan 0x00004000 /* Skip-scans */ | 17321 | #define SQLITE_SkipScan 0x00004000 /* Skip-scans */ |
| 17209 | #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */ | 17322 | #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */ |
| 17210 | #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */ | 17323 | #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */ |
| 17211 | #define SQLITE_ExistsToIN 0x00020000 /* The EXISTS-to-IN optimization */ | 17324 | #define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */ |
| 17212 | #define SQLITE_AllOpts 0xffffffff /* All optimizations */ | 17325 | #define SQLITE_AllOpts 0xffffffff /* All optimizations */ |
| 17213 | 17326 | ||
| 17214 | /* | 17327 | /* |
| @@ -17581,9 +17694,7 @@ struct CollSeq { | |||
| 17581 | ** operator is NULL. It is added to certain comparison operators to | 17694 | ** operator is NULL. It is added to certain comparison operators to |
| 17582 | ** prove that the operands are always NOT NULL. | 17695 | ** prove that the operands are always NOT NULL. |
| 17583 | */ | 17696 | */ |
| 17584 | #define SQLITE_KEEPNULL 0x08 /* Used by vector == or <> */ | ||
| 17585 | #define SQLITE_JUMPIFNULL 0x10 /* jumps if either operand is NULL */ | 17697 | #define SQLITE_JUMPIFNULL 0x10 /* jumps if either operand is NULL */ |
| 17586 | #define SQLITE_STOREP2 0x20 /* Store result in reg[P2] rather than jump */ | ||
| 17587 | #define SQLITE_NULLEQ 0x80 /* NULL=NULL */ | 17698 | #define SQLITE_NULLEQ 0x80 /* NULL=NULL */ |
| 17588 | #define SQLITE_NOTNULL 0x90 /* Assert that operands are never NULL */ | 17699 | #define SQLITE_NOTNULL 0x90 /* Assert that operands are never NULL */ |
| 17589 | 17700 | ||
| @@ -17715,6 +17826,7 @@ struct Table { | |||
| 17715 | #define TF_Shadow 0x1000 /* True for a shadow table */ | 17826 | #define TF_Shadow 0x1000 /* True for a shadow table */ |
| 17716 | #define TF_HasStat4 0x2000 /* STAT4 info available for this table */ | 17827 | #define TF_HasStat4 0x2000 /* STAT4 info available for this table */ |
| 17717 | #define TF_Ephemeral 0x4000 /* An ephemeral table */ | 17828 | #define TF_Ephemeral 0x4000 /* An ephemeral table */ |
| 17829 | #define TF_Eponymous 0x8000 /* An eponymous virtual table */ | ||
| 17718 | 17830 | ||
| 17719 | /* | 17831 | /* |
| 17720 | ** Test to see whether or not a table is a virtual table. This is | 17832 | ** Test to see whether or not a table is a virtual table. This is |
| @@ -18080,6 +18192,7 @@ struct AggInfo { | |||
| 18080 | FuncDef *pFunc; /* The aggregate function implementation */ | 18192 | FuncDef *pFunc; /* The aggregate function implementation */ |
| 18081 | int iMem; /* Memory location that acts as accumulator */ | 18193 | int iMem; /* Memory location that acts as accumulator */ |
| 18082 | int iDistinct; /* Ephemeral table used to enforce DISTINCT */ | 18194 | int iDistinct; /* Ephemeral table used to enforce DISTINCT */ |
| 18195 | int iDistAddr; /* Address of OP_OpenEphemeral */ | ||
| 18083 | } *aFunc; | 18196 | } *aFunc; |
| 18084 | int nFunc; /* Number of entries in aFunc[] */ | 18197 | int nFunc; /* Number of entries in aFunc[] */ |
| 18085 | u32 selId; /* Select to which this AggInfo belongs */ | 18198 | u32 selId; /* Select to which this AggInfo belongs */ |
| @@ -18352,6 +18465,7 @@ struct Expr { | |||
| 18352 | */ | 18465 | */ |
| 18353 | struct ExprList { | 18466 | struct ExprList { |
| 18354 | int nExpr; /* Number of expressions on the list */ | 18467 | int nExpr; /* Number of expressions on the list */ |
| 18468 | int nAlloc; /* Number of a[] slots allocated */ | ||
| 18355 | struct ExprList_item { /* For each expression in the list */ | 18469 | struct ExprList_item { /* For each expression in the list */ |
| 18356 | Expr *pExpr; /* The parse tree for this expression */ | 18470 | Expr *pExpr; /* The parse tree for this expression */ |
| 18357 | char *zEName; /* Token associated with this expression */ | 18471 | char *zEName; /* Token associated with this expression */ |
| @@ -18425,6 +18539,7 @@ struct SrcItem { | |||
| 18425 | unsigned isRecursive :1; /* True for recursive reference in WITH */ | 18539 | unsigned isRecursive :1; /* True for recursive reference in WITH */ |
| 18426 | unsigned fromDDL :1; /* Comes from sqlite_schema */ | 18540 | unsigned fromDDL :1; /* Comes from sqlite_schema */ |
| 18427 | unsigned isCte :1; /* This is a CTE */ | 18541 | unsigned isCte :1; /* This is a CTE */ |
| 18542 | unsigned notCte :1; /* This item may not match a CTE */ | ||
| 18428 | } fg; | 18543 | } fg; |
| 18429 | int iCursor; /* The VDBE cursor number used to access this table */ | 18544 | int iCursor; /* The VDBE cursor number used to access this table */ |
| 18430 | Expr *pOn; /* The ON clause of a join */ | 18545 | Expr *pOn; /* The ON clause of a join */ |
| @@ -18496,7 +18611,7 @@ struct SrcList { | |||
| 18496 | #define WHERE_DISTINCTBY 0x0080 /* pOrderby is really a DISTINCT clause */ | 18611 | #define WHERE_DISTINCTBY 0x0080 /* pOrderby is really a DISTINCT clause */ |
| 18497 | #define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */ | 18612 | #define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */ |
| 18498 | #define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */ | 18613 | #define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */ |
| 18499 | /* 0x0400 not currently used */ | 18614 | #define WHERE_AGG_DISTINCT 0x0400 /* Query is "SELECT agg(DISTINCT ...)" */ |
| 18500 | #define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */ | 18615 | #define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */ |
| 18501 | /* 0x1000 not currently used */ | 18616 | /* 0x1000 not currently used */ |
| 18502 | /* 0x2000 not currently used */ | 18617 | /* 0x2000 not currently used */ |
| @@ -18542,7 +18657,7 @@ struct NameContext { | |||
| 18542 | } uNC; | 18657 | } uNC; |
| 18543 | NameContext *pNext; /* Next outer name context. NULL for outermost */ | 18658 | NameContext *pNext; /* Next outer name context. NULL for outermost */ |
| 18544 | int nRef; /* Number of names resolved by this context */ | 18659 | int nRef; /* Number of names resolved by this context */ |
| 18545 | int nErr; /* Number of errors encountered while resolving names */ | 18660 | int nNcErr; /* Number of errors encountered while resolving names */ |
| 18546 | int ncFlags; /* Zero or more NC_* flags defined below */ | 18661 | int ncFlags; /* Zero or more NC_* flags defined below */ |
| 18547 | Select *pWinSelect; /* SELECT statement for any window functions */ | 18662 | Select *pWinSelect; /* SELECT statement for any window functions */ |
| 18548 | }; | 18663 | }; |
| @@ -18575,6 +18690,7 @@ struct NameContext { | |||
| 18575 | #define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */ | 18690 | #define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */ |
| 18576 | #define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */ | 18691 | #define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */ |
| 18577 | #define NC_FromDDL 0x40000 /* SQL text comes from sqlite_schema */ | 18692 | #define NC_FromDDL 0x40000 /* SQL text comes from sqlite_schema */ |
| 18693 | #define NC_NoSelect 0x80000 /* Do not descend into sub-selects */ | ||
| 18578 | 18694 | ||
| 18579 | /* | 18695 | /* |
| 18580 | ** An instance of the following object describes a single ON CONFLICT | 18696 | ** An instance of the following object describes a single ON CONFLICT |
| @@ -18687,6 +18803,7 @@ struct Select { | |||
| 18687 | #define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */ | 18803 | #define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */ |
| 18688 | #define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */ | 18804 | #define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */ |
| 18689 | #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */ | 18805 | #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */ |
| 18806 | #define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */ | ||
| 18690 | 18807 | ||
| 18691 | /* | 18808 | /* |
| 18692 | ** The results of a SELECT can be distributed in several ways, as defined | 18809 | ** The results of a SELECT can be distributed in several ways, as defined |
| @@ -19215,6 +19332,22 @@ typedef struct { | |||
| 19215 | #define INITFLAG_AlterRename 0x0001 /* Reparse after a RENAME */ | 19332 | #define INITFLAG_AlterRename 0x0001 /* Reparse after a RENAME */ |
| 19216 | #define INITFLAG_AlterDrop 0x0002 /* Reparse after a DROP COLUMN */ | 19333 | #define INITFLAG_AlterDrop 0x0002 /* Reparse after a DROP COLUMN */ |
| 19217 | 19334 | ||
| 19335 | /* Tuning parameters are set using SQLITE_TESTCTRL_TUNE and are controlled | ||
| 19336 | ** on debug-builds of the CLI using ".testctrl tune ID VALUE". Tuning | ||
| 19337 | ** parameters are for temporary use during development, to help find | ||
| 19338 | ** optimial values for parameters in the query planner. The should not | ||
| 19339 | ** be used on trunk check-ins. They are a temporary mechanism available | ||
| 19340 | ** for transient development builds only. | ||
| 19341 | ** | ||
| 19342 | ** Tuning parameters are numbered starting with 1. | ||
| 19343 | */ | ||
| 19344 | #define SQLITE_NTUNE 6 /* Should be zero for all trunk check-ins */ | ||
| 19345 | #ifdef SQLITE_DEBUG | ||
| 19346 | # define Tuning(X) (sqlite3Config.aTune[(X)-1]) | ||
| 19347 | #else | ||
| 19348 | # define Tuning(X) 0 | ||
| 19349 | #endif | ||
| 19350 | |||
| 19218 | /* | 19351 | /* |
| 19219 | ** Structure containing global configuration data for the SQLite library. | 19352 | ** Structure containing global configuration data for the SQLite library. |
| 19220 | ** | 19353 | ** |
| @@ -19269,7 +19402,7 @@ struct Sqlite3Config { | |||
| 19269 | void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */ | 19402 | void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */ |
| 19270 | void *pVdbeBranchArg; /* 1st argument */ | 19403 | void *pVdbeBranchArg; /* 1st argument */ |
| 19271 | #endif | 19404 | #endif |
| 19272 | #ifdef SQLITE_ENABLE_DESERIALIZE | 19405 | #ifndef SQLITE_OMIT_DESERIALIZE |
| 19273 | sqlite3_int64 mxMemdbSize; /* Default max memdb size */ | 19406 | sqlite3_int64 mxMemdbSize; /* Default max memdb size */ |
| 19274 | #endif | 19407 | #endif |
| 19275 | #ifndef SQLITE_UNTESTABLE | 19408 | #ifndef SQLITE_UNTESTABLE |
| @@ -19279,6 +19412,10 @@ struct Sqlite3Config { | |||
| 19279 | int iOnceResetThreshold; /* When to reset OP_Once counters */ | 19412 | int iOnceResetThreshold; /* When to reset OP_Once counters */ |
| 19280 | u32 szSorterRef; /* Min size in bytes to use sorter-refs */ | 19413 | u32 szSorterRef; /* Min size in bytes to use sorter-refs */ |
| 19281 | unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */ | 19414 | unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */ |
| 19415 | /* vvvv--- must be last ---vvv */ | ||
| 19416 | #ifdef SQLITE_DEBUG | ||
| 19417 | sqlite3_int64 aTune[SQLITE_NTUNE]; /* Tuning parameters */ | ||
| 19418 | #endif | ||
| 19282 | }; | 19419 | }; |
| 19283 | 19420 | ||
| 19284 | /* | 19421 | /* |
| @@ -19356,11 +19493,18 @@ SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*); | |||
| 19356 | SQLITE_PRIVATE int sqlite3SelectWalkFail(Walker*, Select*); | 19493 | SQLITE_PRIVATE int sqlite3SelectWalkFail(Walker*, Select*); |
| 19357 | SQLITE_PRIVATE int sqlite3WalkerDepthIncrease(Walker*,Select*); | 19494 | SQLITE_PRIVATE int sqlite3WalkerDepthIncrease(Walker*,Select*); |
| 19358 | SQLITE_PRIVATE void sqlite3WalkerDepthDecrease(Walker*,Select*); | 19495 | SQLITE_PRIVATE void sqlite3WalkerDepthDecrease(Walker*,Select*); |
| 19496 | SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker*,Select*); | ||
| 19359 | 19497 | ||
| 19360 | #ifdef SQLITE_DEBUG | 19498 | #ifdef SQLITE_DEBUG |
| 19361 | SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*); | 19499 | SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*); |
| 19362 | #endif | 19500 | #endif |
| 19363 | 19501 | ||
| 19502 | #ifndef SQLITE_OMIT_CTE | ||
| 19503 | SQLITE_PRIVATE void sqlite3SelectPopWith(Walker*, Select*); | ||
| 19504 | #else | ||
| 19505 | # define sqlite3SelectPopWith 0 | ||
| 19506 | #endif | ||
| 19507 | |||
| 19364 | /* | 19508 | /* |
| 19365 | ** Return code from the parse-tree walking primitives and their | 19509 | ** Return code from the parse-tree walking primitives and their |
| 19366 | ** callbacks. | 19510 | ** callbacks. |
| @@ -19394,6 +19538,7 @@ struct Cte { | |||
| 19394 | */ | 19538 | */ |
| 19395 | struct With { | 19539 | struct With { |
| 19396 | int nCte; /* Number of CTEs in the WITH clause */ | 19540 | int nCte; /* Number of CTEs in the WITH clause */ |
| 19541 | int bView; /* Belongs to the outermost Select of a view */ | ||
| 19397 | With *pOuter; /* Containing WITH clause, or NULL */ | 19542 | With *pOuter; /* Containing WITH clause, or NULL */ |
| 19398 | Cte a[1]; /* For each CTE in the WITH clause.... */ | 19543 | Cte a[1]; /* For each CTE in the WITH clause.... */ |
| 19399 | }; | 19544 | }; |
| @@ -19786,6 +19931,7 @@ SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int); | |||
| 19786 | SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*); | 19931 | SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*); |
| 19787 | SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*); | 19932 | SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*); |
| 19788 | SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*); | 19933 | SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*); |
| 19934 | SQLITE_PRIVATE void sqlite3GenerateColumnNames(Parse *pParse, Select *pSelect); | ||
| 19789 | SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**); | 19935 | SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**); |
| 19790 | SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char); | 19936 | SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char); |
| 19791 | SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char); | 19937 | SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char); |
| @@ -20021,6 +20167,7 @@ SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*); | |||
| 20021 | SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*); | 20167 | SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*); |
| 20022 | SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*); | 20168 | SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*); |
| 20023 | SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int); | 20169 | SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int); |
| 20170 | SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p); | ||
| 20024 | 20171 | ||
| 20025 | #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) | 20172 | #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) |
| 20026 | SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int); | 20173 | SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int); |
| @@ -20164,7 +20311,7 @@ SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); | |||
| 20164 | SQLITE_PRIVATE const char *sqlite3ErrName(int); | 20311 | SQLITE_PRIVATE const char *sqlite3ErrName(int); |
| 20165 | #endif | 20312 | #endif |
| 20166 | 20313 | ||
| 20167 | #ifdef SQLITE_ENABLE_DESERIALIZE | 20314 | #ifndef SQLITE_OMIT_DESERIALIZE |
| 20168 | SQLITE_PRIVATE int sqlite3MemdbInit(void); | 20315 | SQLITE_PRIVATE int sqlite3MemdbInit(void); |
| 20169 | #endif | 20316 | #endif |
| 20170 | 20317 | ||
| @@ -20215,6 +20362,9 @@ SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); | |||
| 20215 | SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[]; | 20362 | SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[]; |
| 20216 | SQLITE_PRIVATE const char sqlite3StrBINARY[]; | 20363 | SQLITE_PRIVATE const char sqlite3StrBINARY[]; |
| 20217 | SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[]; | 20364 | SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[]; |
| 20365 | SQLITE_PRIVATE const unsigned char *sqlite3aLTb; | ||
| 20366 | SQLITE_PRIVATE const unsigned char *sqlite3aEQb; | ||
| 20367 | SQLITE_PRIVATE const unsigned char *sqlite3aGTb; | ||
| 20218 | SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[]; | 20368 | SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[]; |
| 20219 | SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config; | 20369 | SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config; |
| 20220 | SQLITE_PRIVATE FuncDefHash sqlite3BuiltinFunctions; | 20370 | SQLITE_PRIVATE FuncDefHash sqlite3BuiltinFunctions; |
| @@ -20428,7 +20578,7 @@ SQLITE_PRIVATE Cte *sqlite3CteNew(Parse*,Token*,ExprList*,Select*,u8); | |||
| 20428 | SQLITE_PRIVATE void sqlite3CteDelete(sqlite3*,Cte*); | 20578 | SQLITE_PRIVATE void sqlite3CteDelete(sqlite3*,Cte*); |
| 20429 | SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Cte*); | 20579 | SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Cte*); |
| 20430 | SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*); | 20580 | SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*); |
| 20431 | SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8); | 20581 | SQLITE_PRIVATE With *sqlite3WithPush(Parse*, With*, u8); |
| 20432 | #else | 20582 | #else |
| 20433 | # define sqlite3CteNew(P,T,E,S) ((void*)0) | 20583 | # define sqlite3CteNew(P,T,E,S) ((void*)0) |
| 20434 | # define sqlite3CteDelete(D,C) | 20584 | # define sqlite3CteDelete(D,C) |
| @@ -20681,7 +20831,7 @@ SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[] = { | |||
| 20681 | 198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215, | 20831 | 198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215, |
| 20682 | 216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233, | 20832 | 216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233, |
| 20683 | 234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251, | 20833 | 234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251, |
| 20684 | 252,253,254,255 | 20834 | 252,253,254,255, |
| 20685 | #endif | 20835 | #endif |
| 20686 | #ifdef SQLITE_EBCDIC | 20836 | #ifdef SQLITE_EBCDIC |
| 20687 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 0x */ | 20837 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 0x */ |
| @@ -20701,7 +20851,35 @@ SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[] = { | |||
| 20701 | 224,225,162,163,164,165,166,167,168,169,234,235,236,237,238,239, /* Ex */ | 20851 | 224,225,162,163,164,165,166,167,168,169,234,235,236,237,238,239, /* Ex */ |
| 20702 | 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, /* Fx */ | 20852 | 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, /* Fx */ |
| 20703 | #endif | 20853 | #endif |
| 20854 | /* All of the upper-to-lower conversion data is above. The following | ||
| 20855 | ** 18 integers are completely unrelated. They are appended to the | ||
| 20856 | ** sqlite3UpperToLower[] array to avoid UBSAN warnings. Here's what is | ||
| 20857 | ** going on: | ||
| 20858 | ** | ||
| 20859 | ** The SQL comparison operators (<>, =, >, <=, <, and >=) are implemented | ||
| 20860 | ** by invoking sqlite3MemCompare(A,B) which compares values A and B and | ||
| 20861 | ** returns negative, zero, or positive if A is less then, equal to, or | ||
| 20862 | ** greater than B, respectively. Then the true false results is found by | ||
| 20863 | ** consulting sqlite3aLTb[opcode], sqlite3aEQb[opcode], or | ||
| 20864 | ** sqlite3aGTb[opcode] depending on whether the result of compare(A,B) | ||
| 20865 | ** is negative, zero, or positive, where opcode is the specific opcode. | ||
| 20866 | ** The only works because the comparison opcodes are consecutive and in | ||
| 20867 | ** this order: NE EQ GT LE LT GE. Various assert()s throughout the code | ||
| 20868 | ** ensure that is the case. | ||
| 20869 | ** | ||
| 20870 | ** These elements must be appended to another array. Otherwise the | ||
| 20871 | ** index (here shown as [256-OP_Ne]) would be out-of-bounds and thus | ||
| 20872 | ** be undefined behavior. That's goofy, but the C-standards people thought | ||
| 20873 | ** it was a good idea, so here we are. | ||
| 20874 | */ | ||
| 20875 | /* NE EQ GT LE LT GE */ | ||
| 20876 | 1, 0, 0, 1, 1, 0, /* aLTb[]: Use when compare(A,B) less than zero */ | ||
| 20877 | 0, 1, 0, 1, 0, 1, /* aEQb[]: Use when compare(A,B) equals zero */ | ||
| 20878 | 1, 0, 1, 0, 0, 1 /* aGTb[]: Use when compare(A,B) greater than zero*/ | ||
| 20704 | }; | 20879 | }; |
| 20880 | SQLITE_PRIVATE const unsigned char *sqlite3aLTb = &sqlite3UpperToLower[256-OP_Ne]; | ||
| 20881 | SQLITE_PRIVATE const unsigned char *sqlite3aEQb = &sqlite3UpperToLower[256+6-OP_Ne]; | ||
| 20882 | SQLITE_PRIVATE const unsigned char *sqlite3aGTb = &sqlite3UpperToLower[256+12-OP_Ne]; | ||
| 20705 | 20883 | ||
| 20706 | /* | 20884 | /* |
| 20707 | ** The following 256 byte lookup table is used to support SQLites built-in | 20885 | ** The following 256 byte lookup table is used to support SQLites built-in |
| @@ -20895,7 +21073,7 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = { | |||
| 20895 | 0, /* xVdbeBranch */ | 21073 | 0, /* xVdbeBranch */ |
| 20896 | 0, /* pVbeBranchArg */ | 21074 | 0, /* pVbeBranchArg */ |
| 20897 | #endif | 21075 | #endif |
| 20898 | #ifdef SQLITE_ENABLE_DESERIALIZE | 21076 | #ifndef SQLITE_OMIT_DESERIALIZE |
| 20899 | SQLITE_MEMDB_DEFAULT_MAXSIZE, /* mxMemdbSize */ | 21077 | SQLITE_MEMDB_DEFAULT_MAXSIZE, /* mxMemdbSize */ |
| 20900 | #endif | 21078 | #endif |
| 20901 | #ifndef SQLITE_UNTESTABLE | 21079 | #ifndef SQLITE_UNTESTABLE |
| @@ -21458,6 +21636,7 @@ struct PreUpdate { | |||
| 21458 | UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */ | 21636 | UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */ |
| 21459 | UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */ | 21637 | UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */ |
| 21460 | int iNewReg; /* Register for new.* values */ | 21638 | int iNewReg; /* Register for new.* values */ |
| 21639 | int iBlobWrite; /* Value returned by preupdate_blobwrite() */ | ||
| 21461 | i64 iKey1; /* First key value passed to hook */ | 21640 | i64 iKey1; /* First key value passed to hook */ |
| 21462 | i64 iKey2; /* Second key value passed to hook */ | 21641 | i64 iKey2; /* Second key value passed to hook */ |
| 21463 | Mem *aNew; /* Array of new.* values */ | 21642 | Mem *aNew; /* Array of new.* values */ |
| @@ -21501,7 +21680,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*); | |||
| 21501 | SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int); | 21680 | SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int); |
| 21502 | SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*); | 21681 | SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*); |
| 21503 | SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*); | 21682 | SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*); |
| 21504 | SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*)); | 21683 | SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, i64, u8, void(*)(void*)); |
| 21505 | SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64); | 21684 | SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64); |
| 21506 | #ifdef SQLITE_OMIT_FLOATING_POINT | 21685 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 21507 | # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64 | 21686 | # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64 |
| @@ -21546,7 +21725,8 @@ SQLITE_PRIVATE void sqlite3VdbeFrameMemDel(void*); /* Destructor on Mem */ | |||
| 21546 | SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*); /* Actually deletes the Frame */ | 21725 | SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*); /* Actually deletes the Frame */ |
| 21547 | SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *); | 21726 | SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *); |
| 21548 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK | 21727 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 21549 | SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int); | 21728 | SQLITE_PRIVATE void sqlite3VdbePreUpdateHook( |
| 21729 | Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int,int); | ||
| 21550 | #endif | 21730 | #endif |
| 21551 | SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p); | 21731 | SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p); |
| 21552 | 21732 | ||
| @@ -23474,7 +23654,7 @@ SQLITE_PRIVATE int sqlite3OsOpen( | |||
| 23474 | SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ | 23654 | SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ |
| 23475 | DO_OS_MALLOC_TEST(0); | 23655 | DO_OS_MALLOC_TEST(0); |
| 23476 | assert( dirSync==0 || dirSync==1 ); | 23656 | assert( dirSync==0 || dirSync==1 ); |
| 23477 | return pVfs->xDelete(pVfs, zPath, dirSync); | 23657 | return pVfs->xDelete!=0 ? pVfs->xDelete(pVfs, zPath, dirSync) : SQLITE_OK; |
| 23478 | } | 23658 | } |
| 23479 | SQLITE_PRIVATE int sqlite3OsAccess( | 23659 | SQLITE_PRIVATE int sqlite3OsAccess( |
| 23480 | sqlite3_vfs *pVfs, | 23660 | sqlite3_vfs *pVfs, |
| @@ -23497,6 +23677,8 @@ SQLITE_PRIVATE int sqlite3OsFullPathname( | |||
| 23497 | } | 23677 | } |
| 23498 | #ifndef SQLITE_OMIT_LOAD_EXTENSION | 23678 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 23499 | SQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){ | 23679 | SQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){ |
| 23680 | assert( zPath!=0 ); | ||
| 23681 | assert( strlen(zPath)<=SQLITE_MAX_PATHLEN ); /* tag-20210611-1 */ | ||
| 23500 | return pVfs->xDlOpen(pVfs, zPath); | 23682 | return pVfs->xDlOpen(pVfs, zPath); |
| 23501 | } | 23683 | } |
| 23502 | SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ | 23684 | SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ |
| @@ -27764,7 +27946,6 @@ SQLITE_PRIVATE int sqlite3MallocInit(void){ | |||
| 27764 | if( sqlite3GlobalConfig.m.xMalloc==0 ){ | 27946 | if( sqlite3GlobalConfig.m.xMalloc==0 ){ |
| 27765 | sqlite3MemSetDefault(); | 27947 | sqlite3MemSetDefault(); |
| 27766 | } | 27948 | } |
| 27767 | memset(&mem0, 0, sizeof(mem0)); | ||
| 27768 | mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); | 27949 | mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); |
| 27769 | if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512 | 27950 | if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512 |
| 27770 | || sqlite3GlobalConfig.nPage<=0 ){ | 27951 | || sqlite3GlobalConfig.nPage<=0 ){ |
| @@ -28463,7 +28644,7 @@ SQLITE_PRIVATE int sqlite3ApiExit(sqlite3* db, int rc){ | |||
| 28463 | #define etSQLESCAPE2 10 /* Strings with '\'' doubled and enclosed in '', | 28644 | #define etSQLESCAPE2 10 /* Strings with '\'' doubled and enclosed in '', |
| 28464 | NULL pointers replaced by SQL NULL. %Q */ | 28645 | NULL pointers replaced by SQL NULL. %Q */ |
| 28465 | #define etTOKEN 11 /* a pointer to a Token structure */ | 28646 | #define etTOKEN 11 /* a pointer to a Token structure */ |
| 28466 | #define etSRCLIST 12 /* a pointer to a SrcList */ | 28647 | #define etSRCITEM 12 /* a pointer to a SrcItem */ |
| 28467 | #define etPOINTER 13 /* The %p conversion */ | 28648 | #define etPOINTER 13 /* The %p conversion */ |
| 28468 | #define etSQLESCAPE3 14 /* %w -> Strings with '\"' doubled */ | 28649 | #define etSQLESCAPE3 14 /* %w -> Strings with '\"' doubled */ |
| 28469 | #define etORDINAL 15 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ | 28650 | #define etORDINAL 15 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ |
| @@ -28529,10 +28710,16 @@ static const et_info fmtinfo[] = { | |||
| 28529 | 28710 | ||
| 28530 | /* All the rest are undocumented and are for internal use only */ | 28711 | /* All the rest are undocumented and are for internal use only */ |
| 28531 | { 'T', 0, 0, etTOKEN, 0, 0 }, | 28712 | { 'T', 0, 0, etTOKEN, 0, 0 }, |
| 28532 | { 'S', 0, 0, etSRCLIST, 0, 0 }, | 28713 | { 'S', 0, 0, etSRCITEM, 0, 0 }, |
| 28533 | { 'r', 10, 1, etORDINAL, 0, 0 }, | 28714 | { 'r', 10, 1, etORDINAL, 0, 0 }, |
| 28534 | }; | 28715 | }; |
| 28535 | 28716 | ||
| 28717 | /* Notes: | ||
| 28718 | ** | ||
| 28719 | ** %S Takes a pointer to SrcItem. Shows name or database.name | ||
| 28720 | ** %!S Like %S but prefer the zName over the zAlias | ||
| 28721 | */ | ||
| 28722 | |||
| 28536 | /* Floating point constants used for rounding */ | 28723 | /* Floating point constants used for rounding */ |
| 28537 | static const double arRound[] = { | 28724 | static const double arRound[] = { |
| 28538 | 5.0e-01, 5.0e-02, 5.0e-03, 5.0e-04, 5.0e-05, | 28725 | 5.0e-01, 5.0e-02, 5.0e-03, 5.0e-04, 5.0e-05, |
| @@ -29287,21 +29474,24 @@ SQLITE_API void sqlite3_str_vappendf( | |||
| 29287 | length = width = 0; | 29474 | length = width = 0; |
| 29288 | break; | 29475 | break; |
| 29289 | } | 29476 | } |
| 29290 | case etSRCLIST: { | 29477 | case etSRCITEM: { |
| 29291 | SrcList *pSrc; | ||
| 29292 | int k; | ||
| 29293 | SrcItem *pItem; | 29478 | SrcItem *pItem; |
| 29294 | if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return; | 29479 | if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return; |
| 29295 | pSrc = va_arg(ap, SrcList*); | 29480 | pItem = va_arg(ap, SrcItem*); |
| 29296 | k = va_arg(ap, int); | ||
| 29297 | pItem = &pSrc->a[k]; | ||
| 29298 | assert( bArgList==0 ); | 29481 | assert( bArgList==0 ); |
| 29299 | assert( k>=0 && k<pSrc->nSrc ); | 29482 | if( pItem->zAlias && !flag_altform2 ){ |
| 29300 | if( pItem->zDatabase ){ | 29483 | sqlite3_str_appendall(pAccum, pItem->zAlias); |
| 29301 | sqlite3_str_appendall(pAccum, pItem->zDatabase); | 29484 | }else if( pItem->zName ){ |
| 29302 | sqlite3_str_append(pAccum, ".", 1); | 29485 | if( pItem->zDatabase ){ |
| 29486 | sqlite3_str_appendall(pAccum, pItem->zDatabase); | ||
| 29487 | sqlite3_str_append(pAccum, ".", 1); | ||
| 29488 | } | ||
| 29489 | sqlite3_str_appendall(pAccum, pItem->zName); | ||
| 29490 | }else if( pItem->zAlias ){ | ||
| 29491 | sqlite3_str_appendall(pAccum, pItem->zAlias); | ||
| 29492 | }else if( ALWAYS(pItem->pSelect) ){ | ||
| 29493 | sqlite3_str_appendf(pAccum, "SUBQUERY %u", pItem->pSelect->selId); | ||
| 29303 | } | 29494 | } |
| 29304 | sqlite3_str_appendall(pAccum, pItem->zName); | ||
| 29305 | length = width = 0; | 29495 | length = width = 0; |
| 29306 | break; | 29496 | break; |
| 29307 | } | 29497 | } |
| @@ -29881,19 +30071,12 @@ SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc) | |||
| 29881 | StrAccum x; | 30071 | StrAccum x; |
| 29882 | char zLine[100]; | 30072 | char zLine[100]; |
| 29883 | sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); | 30073 | sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); |
| 29884 | sqlite3_str_appendf(&x, "{%d:*}", pItem->iCursor); | 30074 | x.printfFlags |= SQLITE_PRINTF_INTERNAL; |
| 29885 | if( pItem->zDatabase ){ | 30075 | sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem); |
| 29886 | sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName); | ||
| 29887 | }else if( pItem->zName ){ | ||
| 29888 | sqlite3_str_appendf(&x, " %s", pItem->zName); | ||
| 29889 | } | ||
| 29890 | if( pItem->pTab ){ | 30076 | if( pItem->pTab ){ |
| 29891 | sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx", | 30077 | sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx", |
| 29892 | pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed); | 30078 | pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed); |
| 29893 | } | 30079 | } |
| 29894 | if( pItem->zAlias ){ | ||
| 29895 | sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias); | ||
| 29896 | } | ||
| 29897 | if( pItem->fg.jointype & JT_LEFT ){ | 30080 | if( pItem->fg.jointype & JT_LEFT ){ |
| 29898 | sqlite3_str_appendf(&x, " LEFT-JOIN"); | 30081 | sqlite3_str_appendf(&x, " LEFT-JOIN"); |
| 29899 | } | 30082 | } |
| @@ -30460,6 +30643,14 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30460 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); | 30643 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 30461 | break; | 30644 | break; |
| 30462 | } | 30645 | } |
| 30646 | case TK_ERROR: { | ||
| 30647 | Expr tmp; | ||
| 30648 | sqlite3TreeViewLine(pView, "ERROR"); | ||
| 30649 | tmp = *pExpr; | ||
| 30650 | tmp.op = pExpr->op2; | ||
| 30651 | sqlite3TreeViewExpr(pView, &tmp, 0); | ||
| 30652 | break; | ||
| 30653 | } | ||
| 30463 | default: { | 30654 | default: { |
| 30464 | sqlite3TreeViewLine(pView, "op=%d", pExpr->op); | 30655 | sqlite3TreeViewLine(pView, "op=%d", pExpr->op); |
| 30465 | break; | 30656 | break; |
| @@ -30609,11 +30800,16 @@ SQLITE_API void sqlite3_randomness(int N, void *pBuf){ | |||
| 30609 | ** number generator) not as an encryption device. | 30800 | ** number generator) not as an encryption device. |
| 30610 | */ | 30801 | */ |
| 30611 | if( !wsdPrng.isInit ){ | 30802 | if( !wsdPrng.isInit ){ |
| 30803 | sqlite3_vfs *pVfs = sqlite3_vfs_find(0); | ||
| 30612 | int i; | 30804 | int i; |
| 30613 | char k[256]; | 30805 | char k[256]; |
| 30614 | wsdPrng.j = 0; | 30806 | wsdPrng.j = 0; |
| 30615 | wsdPrng.i = 0; | 30807 | wsdPrng.i = 0; |
| 30616 | sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k); | 30808 | if( NEVER(pVfs==0) ){ |
| 30809 | memset(k, 0, sizeof(k)); | ||
| 30810 | }else{ | ||
| 30811 | sqlite3OsRandomness(pVfs, 256, k); | ||
| 30812 | } | ||
| 30617 | for(i=0; i<256; i++){ | 30813 | for(i=0; i<256; i++){ |
| 30618 | wsdPrng.s[i] = (u8)i; | 30814 | wsdPrng.s[i] = (u8)i; |
| 30619 | } | 30815 | } |
| @@ -33533,7 +33729,7 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ | |||
| 33533 | /* 55 */ "Le" OpHelp("IF r[P3]<=r[P1]"), | 33729 | /* 55 */ "Le" OpHelp("IF r[P3]<=r[P1]"), |
| 33534 | /* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"), | 33730 | /* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"), |
| 33535 | /* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), | 33731 | /* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), |
| 33536 | /* 58 */ "ElseNotEq" OpHelp(""), | 33732 | /* 58 */ "ElseEq" OpHelp(""), |
| 33537 | /* 59 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), | 33733 | /* 59 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 33538 | /* 60 */ "IncrVacuum" OpHelp(""), | 33734 | /* 60 */ "IncrVacuum" OpHelp(""), |
| 33539 | /* 61 */ "VNext" OpHelp(""), | 33735 | /* 61 */ "VNext" OpHelp(""), |
| @@ -33564,19 +33760,19 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ | |||
| 33564 | /* 86 */ "Permutation" OpHelp(""), | 33760 | /* 86 */ "Permutation" OpHelp(""), |
| 33565 | /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), | 33761 | /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 33566 | /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), | 33762 | /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), |
| 33567 | /* 89 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), | 33763 | /* 89 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"), |
| 33568 | /* 90 */ "Column" OpHelp("r[P3]=PX"), | 33764 | /* 90 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), |
| 33569 | /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"), | 33765 | /* 91 */ "Column" OpHelp("r[P3]=PX"), |
| 33570 | /* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), | 33766 | /* 92 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 33571 | /* 93 */ "Count" OpHelp("r[P2]=count()"), | 33767 | /* 93 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 33572 | /* 94 */ "ReadCookie" OpHelp(""), | 33768 | /* 94 */ "Count" OpHelp("r[P2]=count()"), |
| 33573 | /* 95 */ "SetCookie" OpHelp(""), | 33769 | /* 95 */ "ReadCookie" OpHelp(""), |
| 33574 | /* 96 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), | 33770 | /* 96 */ "SetCookie" OpHelp(""), |
| 33575 | /* 97 */ "OpenRead" OpHelp("root=P2 iDb=P3"), | 33771 | /* 97 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 33576 | /* 98 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), | 33772 | /* 98 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 33577 | /* 99 */ "OpenDup" OpHelp(""), | 33773 | /* 99 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 33578 | /* 100 */ "OpenAutoindex" OpHelp("nColumn=P2"), | 33774 | /* 100 */ "OpenDup" OpHelp(""), |
| 33579 | /* 101 */ "OpenEphemeral" OpHelp("nColumn=P2"), | 33775 | /* 101 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 33580 | /* 102 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), | 33776 | /* 102 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 33581 | /* 103 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), | 33777 | /* 103 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 33582 | /* 104 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), | 33778 | /* 104 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| @@ -33587,73 +33783,74 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ | |||
| 33587 | /* 109 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), | 33783 | /* 109 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 33588 | /* 110 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), | 33784 | /* 110 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 33589 | /* 111 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), | 33785 | /* 111 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 33590 | /* 112 */ "SorterOpen" OpHelp(""), | 33786 | /* 112 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 33591 | /* 113 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), | 33787 | /* 113 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), |
| 33592 | /* 114 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), | 33788 | /* 114 */ "SorterOpen" OpHelp(""), |
| 33593 | /* 115 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), | 33789 | /* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 33594 | /* 116 */ "String8" OpHelp("r[P2]='P4'"), | 33790 | /* 116 */ "String8" OpHelp("r[P2]='P4'"), |
| 33595 | /* 117 */ "Close" OpHelp(""), | 33791 | /* 117 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 33596 | /* 118 */ "ColumnsUsed" OpHelp(""), | 33792 | /* 118 */ "Close" OpHelp(""), |
| 33597 | /* 119 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"), | 33793 | /* 119 */ "ColumnsUsed" OpHelp(""), |
| 33598 | /* 120 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"), | 33794 | /* 120 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"), |
| 33599 | /* 121 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), | 33795 | /* 121 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"), |
| 33600 | /* 122 */ "NewRowid" OpHelp("r[P2]=rowid"), | 33796 | /* 122 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 33601 | /* 123 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), | 33797 | /* 123 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 33602 | /* 124 */ "RowCell" OpHelp(""), | 33798 | /* 124 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 33603 | /* 125 */ "Delete" OpHelp(""), | 33799 | /* 125 */ "RowCell" OpHelp(""), |
| 33604 | /* 126 */ "ResetCount" OpHelp(""), | 33800 | /* 126 */ "Delete" OpHelp(""), |
| 33605 | /* 127 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), | 33801 | /* 127 */ "ResetCount" OpHelp(""), |
| 33606 | /* 128 */ "SorterData" OpHelp("r[P2]=data"), | 33802 | /* 128 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 33607 | /* 129 */ "RowData" OpHelp("r[P2]=data"), | 33803 | /* 129 */ "SorterData" OpHelp("r[P2]=data"), |
| 33608 | /* 130 */ "Rowid" OpHelp("r[P2]=rowid"), | 33804 | /* 130 */ "RowData" OpHelp("r[P2]=data"), |
| 33609 | /* 131 */ "NullRow" OpHelp(""), | 33805 | /* 131 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 33610 | /* 132 */ "SeekEnd" OpHelp(""), | 33806 | /* 132 */ "NullRow" OpHelp(""), |
| 33611 | /* 133 */ "IdxInsert" OpHelp("key=r[P2]"), | 33807 | /* 133 */ "SeekEnd" OpHelp(""), |
| 33612 | /* 134 */ "SorterInsert" OpHelp("key=r[P2]"), | 33808 | /* 134 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 33613 | /* 135 */ "IdxDelete" OpHelp("key=r[P2@P3]"), | 33809 | /* 135 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 33614 | /* 136 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), | 33810 | /* 136 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 33615 | /* 137 */ "IdxRowid" OpHelp("r[P2]=rowid"), | 33811 | /* 137 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), |
| 33616 | /* 138 */ "FinishSeek" OpHelp(""), | 33812 | /* 138 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 33617 | /* 139 */ "Destroy" OpHelp(""), | 33813 | /* 139 */ "FinishSeek" OpHelp(""), |
| 33618 | /* 140 */ "Clear" OpHelp(""), | 33814 | /* 140 */ "Destroy" OpHelp(""), |
| 33619 | /* 141 */ "ResetSorter" OpHelp(""), | 33815 | /* 141 */ "Clear" OpHelp(""), |
| 33620 | /* 142 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), | 33816 | /* 142 */ "ResetSorter" OpHelp(""), |
| 33621 | /* 143 */ "SqlExec" OpHelp(""), | 33817 | /* 143 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), |
| 33622 | /* 144 */ "ParseSchema" OpHelp(""), | 33818 | /* 144 */ "SqlExec" OpHelp(""), |
| 33623 | /* 145 */ "LoadAnalysis" OpHelp(""), | 33819 | /* 145 */ "ParseSchema" OpHelp(""), |
| 33624 | /* 146 */ "DropTable" OpHelp(""), | 33820 | /* 146 */ "LoadAnalysis" OpHelp(""), |
| 33625 | /* 147 */ "DropIndex" OpHelp(""), | 33821 | /* 147 */ "DropTable" OpHelp(""), |
| 33626 | /* 148 */ "DropTrigger" OpHelp(""), | 33822 | /* 148 */ "DropIndex" OpHelp(""), |
| 33627 | /* 149 */ "IntegrityCk" OpHelp(""), | 33823 | /* 149 */ "DropTrigger" OpHelp(""), |
| 33628 | /* 150 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), | 33824 | /* 150 */ "IntegrityCk" OpHelp(""), |
| 33629 | /* 151 */ "Param" OpHelp(""), | 33825 | /* 151 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 33630 | /* 152 */ "Real" OpHelp("r[P2]=P4"), | 33826 | /* 152 */ "Real" OpHelp("r[P2]=P4"), |
| 33631 | /* 153 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), | 33827 | /* 153 */ "Param" OpHelp(""), |
| 33632 | /* 154 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), | 33828 | /* 154 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 33633 | /* 155 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), | 33829 | /* 155 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 33634 | /* 156 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), | 33830 | /* 156 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 33635 | /* 157 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), | 33831 | /* 157 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), |
| 33636 | /* 158 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"), | 33832 | /* 158 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 33637 | /* 159 */ "AggValue" OpHelp("r[P3]=value N=P2"), | 33833 | /* 159 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 33638 | /* 160 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), | 33834 | /* 160 */ "AggValue" OpHelp("r[P3]=value N=P2"), |
| 33639 | /* 161 */ "Expire" OpHelp(""), | 33835 | /* 161 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 33640 | /* 162 */ "CursorLock" OpHelp(""), | 33836 | /* 162 */ "Expire" OpHelp(""), |
| 33641 | /* 163 */ "CursorUnlock" OpHelp(""), | 33837 | /* 163 */ "CursorLock" OpHelp(""), |
| 33642 | /* 164 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), | 33838 | /* 164 */ "CursorUnlock" OpHelp(""), |
| 33643 | /* 165 */ "VBegin" OpHelp(""), | 33839 | /* 165 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 33644 | /* 166 */ "VCreate" OpHelp(""), | 33840 | /* 166 */ "VBegin" OpHelp(""), |
| 33645 | /* 167 */ "VDestroy" OpHelp(""), | 33841 | /* 167 */ "VCreate" OpHelp(""), |
| 33646 | /* 168 */ "VOpen" OpHelp(""), | 33842 | /* 168 */ "VDestroy" OpHelp(""), |
| 33647 | /* 169 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), | 33843 | /* 169 */ "VOpen" OpHelp(""), |
| 33648 | /* 170 */ "VRename" OpHelp(""), | 33844 | /* 170 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 33649 | /* 171 */ "Pagecount" OpHelp(""), | 33845 | /* 171 */ "VRename" OpHelp(""), |
| 33650 | /* 172 */ "MaxPgcnt" OpHelp(""), | 33846 | /* 172 */ "Pagecount" OpHelp(""), |
| 33651 | /* 173 */ "Trace" OpHelp(""), | 33847 | /* 173 */ "MaxPgcnt" OpHelp(""), |
| 33652 | /* 174 */ "CursorHint" OpHelp(""), | 33848 | /* 174 */ "Trace" OpHelp(""), |
| 33653 | /* 175 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), | 33849 | /* 175 */ "CursorHint" OpHelp(""), |
| 33654 | /* 176 */ "Noop" OpHelp(""), | 33850 | /* 176 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), |
| 33655 | /* 177 */ "Explain" OpHelp(""), | 33851 | /* 177 */ "Noop" OpHelp(""), |
| 33656 | /* 178 */ "Abortable" OpHelp(""), | 33852 | /* 178 */ "Explain" OpHelp(""), |
| 33853 | /* 179 */ "Abortable" OpHelp(""), | ||
| 33657 | }; | 33854 | }; |
| 33658 | return azName[i]; | 33855 | return azName[i]; |
| 33659 | } | 33856 | } |
| @@ -37812,6 +38009,7 @@ static void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){ | |||
| 37812 | 38009 | ||
| 37813 | /* Forward declaration */ | 38010 | /* Forward declaration */ |
| 37814 | static int unixGetTempname(int nBuf, char *zBuf); | 38011 | static int unixGetTempname(int nBuf, char *zBuf); |
| 38012 | static int unixFcntlExternalReader(unixFile*, int*); | ||
| 37815 | 38013 | ||
| 37816 | /* | 38014 | /* |
| 37817 | ** Information and control of an open file handle. | 38015 | ** Information and control of an open file handle. |
| @@ -37928,6 +38126,10 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ | |||
| 37928 | return proxyFileControl(id,op,pArg); | 38126 | return proxyFileControl(id,op,pArg); |
| 37929 | } | 38127 | } |
| 37930 | #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ | 38128 | #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ |
| 38129 | |||
| 38130 | case SQLITE_FCNTL_EXTERNAL_READER: { | ||
| 38131 | return unixFcntlExternalReader((unixFile*)id, (int*)pArg); | ||
| 38132 | } | ||
| 37931 | } | 38133 | } |
| 37932 | return SQLITE_NOTFOUND; | 38134 | return SQLITE_NOTFOUND; |
| 37933 | } | 38135 | } |
| @@ -38174,6 +38376,40 @@ struct unixShm { | |||
| 38174 | #define UNIX_SHM_DMS (UNIX_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */ | 38376 | #define UNIX_SHM_DMS (UNIX_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */ |
| 38175 | 38377 | ||
| 38176 | /* | 38378 | /* |
| 38379 | ** Use F_GETLK to check whether or not there are any readers with open | ||
| 38380 | ** wal-mode transactions in other processes on database file pFile. If | ||
| 38381 | ** no error occurs, return SQLITE_OK and set (*piOut) to 1 if there are | ||
| 38382 | ** such transactions, or 0 otherwise. If an error occurs, return an | ||
| 38383 | ** SQLite error code. The final value of *piOut is undefined in this | ||
| 38384 | ** case. | ||
| 38385 | */ | ||
| 38386 | static int unixFcntlExternalReader(unixFile *pFile, int *piOut){ | ||
| 38387 | int rc = SQLITE_OK; | ||
| 38388 | *piOut = 0; | ||
| 38389 | if( pFile->pShm){ | ||
| 38390 | unixShmNode *pShmNode = pFile->pShm->pShmNode; | ||
| 38391 | struct flock f; | ||
| 38392 | |||
| 38393 | memset(&f, 0, sizeof(f)); | ||
| 38394 | f.l_type = F_WRLCK; | ||
| 38395 | f.l_whence = SEEK_SET; | ||
| 38396 | f.l_start = UNIX_SHM_BASE + 3; | ||
| 38397 | f.l_len = SQLITE_SHM_NLOCK - 3; | ||
| 38398 | |||
| 38399 | sqlite3_mutex_enter(pShmNode->pShmMutex); | ||
| 38400 | if( osFcntl(pShmNode->hShm, F_GETLK, &f)<0 ){ | ||
| 38401 | rc = SQLITE_IOERR_LOCK; | ||
| 38402 | }else{ | ||
| 38403 | *piOut = (f.l_type!=F_UNLCK); | ||
| 38404 | } | ||
| 38405 | sqlite3_mutex_leave(pShmNode->pShmMutex); | ||
| 38406 | } | ||
| 38407 | |||
| 38408 | return rc; | ||
| 38409 | } | ||
| 38410 | |||
| 38411 | |||
| 38412 | /* | ||
| 38177 | ** Apply posix advisory locks for all bytes from ofst through ofst+n-1. | 38413 | ** Apply posix advisory locks for all bytes from ofst through ofst+n-1. |
| 38178 | ** | 38414 | ** |
| 38179 | ** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking | 38415 | ** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking |
| @@ -41889,6 +42125,25 @@ SQLITE_API int sqlite3_os_init(void){ | |||
| 41889 | sqlite3_vfs_register(&aVfs[i], i==0); | 42125 | sqlite3_vfs_register(&aVfs[i], i==0); |
| 41890 | } | 42126 | } |
| 41891 | unixBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1); | 42127 | unixBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1); |
| 42128 | |||
| 42129 | #ifndef SQLITE_OMIT_WAL | ||
| 42130 | /* Validate lock assumptions */ | ||
| 42131 | assert( SQLITE_SHM_NLOCK==8 ); /* Number of available locks */ | ||
| 42132 | assert( UNIX_SHM_BASE==120 ); /* Start of locking area */ | ||
| 42133 | /* Locks: | ||
| 42134 | ** WRITE UNIX_SHM_BASE 120 | ||
| 42135 | ** CKPT UNIX_SHM_BASE+1 121 | ||
| 42136 | ** RECOVER UNIX_SHM_BASE+2 122 | ||
| 42137 | ** READ-0 UNIX_SHM_BASE+3 123 | ||
| 42138 | ** READ-1 UNIX_SHM_BASE+4 124 | ||
| 42139 | ** READ-2 UNIX_SHM_BASE+5 125 | ||
| 42140 | ** READ-3 UNIX_SHM_BASE+6 126 | ||
| 42141 | ** READ-4 UNIX_SHM_BASE+7 127 | ||
| 42142 | ** DMS UNIX_SHM_BASE+8 128 | ||
| 42143 | */ | ||
| 42144 | assert( UNIX_SHM_DMS==128 ); /* Byte offset of the deadman-switch */ | ||
| 42145 | #endif | ||
| 42146 | |||
| 41892 | return SQLITE_OK; | 42147 | return SQLITE_OK; |
| 41893 | } | 42148 | } |
| 41894 | 42149 | ||
| @@ -48282,32 +48537,89 @@ SQLITE_API int sqlite3_os_end(void){ | |||
| 48282 | ** sqlite3_deserialize(). | 48537 | ** sqlite3_deserialize(). |
| 48283 | */ | 48538 | */ |
| 48284 | /* #include "sqliteInt.h" */ | 48539 | /* #include "sqliteInt.h" */ |
| 48285 | #ifdef SQLITE_ENABLE_DESERIALIZE | 48540 | #ifndef SQLITE_OMIT_DESERIALIZE |
| 48286 | 48541 | ||
| 48287 | /* | 48542 | /* |
| 48288 | ** Forward declaration of objects used by this utility | 48543 | ** Forward declaration of objects used by this utility |
| 48289 | */ | 48544 | */ |
| 48290 | typedef struct sqlite3_vfs MemVfs; | 48545 | typedef struct sqlite3_vfs MemVfs; |
| 48291 | typedef struct MemFile MemFile; | 48546 | typedef struct MemFile MemFile; |
| 48547 | typedef struct MemStore MemStore; | ||
| 48292 | 48548 | ||
| 48293 | /* Access to a lower-level VFS that (might) implement dynamic loading, | 48549 | /* Access to a lower-level VFS that (might) implement dynamic loading, |
| 48294 | ** access to randomness, etc. | 48550 | ** access to randomness, etc. |
| 48295 | */ | 48551 | */ |
| 48296 | #define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData)) | 48552 | #define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData)) |
| 48297 | 48553 | ||
| 48298 | /* An open file */ | 48554 | /* Storage for a memdb file. |
| 48299 | struct MemFile { | 48555 | ** |
| 48300 | sqlite3_file base; /* IO methods */ | 48556 | ** An memdb object can be shared or separate. Shared memdb objects can be |
| 48557 | ** used by more than one database connection. Mutexes are used by shared | ||
| 48558 | ** memdb objects to coordinate access. Separate memdb objects are only | ||
| 48559 | ** connected to a single database connection and do not require additional | ||
| 48560 | ** mutexes. | ||
| 48561 | ** | ||
| 48562 | ** Shared memdb objects have .zFName!=0 and .pMutex!=0. They are created | ||
| 48563 | ** using "file:/name?vfs=memdb". The first character of the name must be | ||
| 48564 | ** "/" or else the object will be a separate memdb object. All shared | ||
| 48565 | ** memdb objects are stored in memdb_g.apMemStore[] in an arbitrary order. | ||
| 48566 | ** | ||
| 48567 | ** Separate memdb objects are created using a name that does not begin | ||
| 48568 | ** with "/" or using sqlite3_deserialize(). | ||
| 48569 | ** | ||
| 48570 | ** Access rules for shared MemStore objects: | ||
| 48571 | ** | ||
| 48572 | ** * .zFName is initialized when the object is created and afterwards | ||
| 48573 | ** is unchanged until the object is destroyed. So it can be accessed | ||
| 48574 | ** at any time as long as we know the object is not being destroyed, | ||
| 48575 | ** which means while either the SQLITE_MUTEX_STATIC_VFS1 or | ||
| 48576 | ** .pMutex is held or the object is not part of memdb_g.apMemStore[]. | ||
| 48577 | ** | ||
| 48578 | ** * Can .pMutex can only be changed while holding the | ||
| 48579 | ** SQLITE_MUTEX_STATIC_VFS1 mutex or while the object is not part | ||
| 48580 | ** of memdb_g.apMemStore[]. | ||
| 48581 | ** | ||
| 48582 | ** * Other fields can only be changed while holding the .pMutex mutex | ||
| 48583 | ** or when the .nRef is less than zero and the object is not part of | ||
| 48584 | ** memdb_g.apMemStore[]. | ||
| 48585 | ** | ||
| 48586 | ** * The .aData pointer has the added requirement that it can can only | ||
| 48587 | ** be changed (for resizing) when nMmap is zero. | ||
| 48588 | ** | ||
| 48589 | */ | ||
| 48590 | struct MemStore { | ||
| 48301 | sqlite3_int64 sz; /* Size of the file */ | 48591 | sqlite3_int64 sz; /* Size of the file */ |
| 48302 | sqlite3_int64 szAlloc; /* Space allocated to aData */ | 48592 | sqlite3_int64 szAlloc; /* Space allocated to aData */ |
| 48303 | sqlite3_int64 szMax; /* Maximum allowed size of the file */ | 48593 | sqlite3_int64 szMax; /* Maximum allowed size of the file */ |
| 48304 | unsigned char *aData; /* content of the file */ | 48594 | unsigned char *aData; /* content of the file */ |
| 48595 | sqlite3_mutex *pMutex; /* Used by shared stores only */ | ||
| 48305 | int nMmap; /* Number of memory mapped pages */ | 48596 | int nMmap; /* Number of memory mapped pages */ |
| 48306 | unsigned mFlags; /* Flags */ | 48597 | unsigned mFlags; /* Flags */ |
| 48598 | int nRdLock; /* Number of readers */ | ||
| 48599 | int nWrLock; /* Number of writers. (Always 0 or 1) */ | ||
| 48600 | int nRef; /* Number of users of this MemStore */ | ||
| 48601 | char *zFName; /* The filename for shared stores */ | ||
| 48602 | }; | ||
| 48603 | |||
| 48604 | /* An open file */ | ||
| 48605 | struct MemFile { | ||
| 48606 | sqlite3_file base; /* IO methods */ | ||
| 48607 | MemStore *pStore; /* The storage */ | ||
| 48307 | int eLock; /* Most recent lock against this file */ | 48608 | int eLock; /* Most recent lock against this file */ |
| 48308 | }; | 48609 | }; |
| 48309 | 48610 | ||
| 48310 | /* | 48611 | /* |
| 48612 | ** File-scope variables for holding the memdb files that are accessible | ||
| 48613 | ** to multiple database connections in separate threads. | ||
| 48614 | ** | ||
| 48615 | ** Must hold SQLITE_MUTEX_STATIC_VFS1 to access any part of this object. | ||
| 48616 | */ | ||
| 48617 | static struct MemFS { | ||
| 48618 | int nMemStore; /* Number of shared MemStore objects */ | ||
| 48619 | MemStore **apMemStore; /* Array of all shared MemStore objects */ | ||
| 48620 | } memdb_g; | ||
| 48621 | |||
| 48622 | /* | ||
| 48311 | ** Methods for MemFile | 48623 | ** Methods for MemFile |
| 48312 | */ | 48624 | */ |
| 48313 | static int memdbClose(sqlite3_file*); | 48625 | static int memdbClose(sqlite3_file*); |
| @@ -48360,7 +48672,10 @@ static sqlite3_vfs memdb_vfs = { | |||
| 48360 | memdbSleep, /* xSleep */ | 48672 | memdbSleep, /* xSleep */ |
| 48361 | 0, /* memdbCurrentTime, */ /* xCurrentTime */ | 48673 | 0, /* memdbCurrentTime, */ /* xCurrentTime */ |
| 48362 | memdbGetLastError, /* xGetLastError */ | 48674 | memdbGetLastError, /* xGetLastError */ |
| 48363 | memdbCurrentTimeInt64 /* xCurrentTimeInt64 */ | 48675 | memdbCurrentTimeInt64, /* xCurrentTimeInt64 */ |
| 48676 | 0, /* xSetSystemCall */ | ||
| 48677 | 0, /* xGetSystemCall */ | ||
| 48678 | 0, /* xNextSystemCall */ | ||
| 48364 | }; | 48679 | }; |
| 48365 | 48680 | ||
| 48366 | static const sqlite3_io_methods memdb_io_methods = { | 48681 | static const sqlite3_io_methods memdb_io_methods = { |
| @@ -48385,19 +48700,67 @@ static const sqlite3_io_methods memdb_io_methods = { | |||
| 48385 | memdbUnfetch /* xUnfetch */ | 48700 | memdbUnfetch /* xUnfetch */ |
| 48386 | }; | 48701 | }; |
| 48387 | 48702 | ||
| 48703 | /* | ||
| 48704 | ** Enter/leave the mutex on a MemStore | ||
| 48705 | */ | ||
| 48706 | #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0 | ||
| 48707 | static void memdbEnter(MemStore *p){ | ||
| 48708 | UNUSED_PARAMETER(p); | ||
| 48709 | } | ||
| 48710 | static void memdbLeave(MemStore *p){ | ||
| 48711 | UNUSED_PARAMETER(p); | ||
| 48712 | } | ||
| 48713 | #else | ||
| 48714 | static void memdbEnter(MemStore *p){ | ||
| 48715 | sqlite3_mutex_enter(p->pMutex); | ||
| 48716 | } | ||
| 48717 | static void memdbLeave(MemStore *p){ | ||
| 48718 | sqlite3_mutex_leave(p->pMutex); | ||
| 48719 | } | ||
| 48720 | #endif | ||
| 48721 | |||
| 48388 | 48722 | ||
| 48389 | 48723 | ||
| 48390 | /* | 48724 | /* |
| 48391 | ** Close an memdb-file. | 48725 | ** Close an memdb-file. |
| 48392 | ** | 48726 | ** Free the underlying MemStore object when its refcount drops to zero |
| 48393 | ** The pData pointer is owned by the application, so there is nothing | 48727 | ** or less. |
| 48394 | ** to free. Unless the SQLITE_DESERIALIZE_FREEONCLOSE flag is set, | ||
| 48395 | ** in which case we own the pData pointer and need to free it. | ||
| 48396 | */ | 48728 | */ |
| 48397 | static int memdbClose(sqlite3_file *pFile){ | 48729 | static int memdbClose(sqlite3_file *pFile){ |
| 48398 | MemFile *p = (MemFile *)pFile; | 48730 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48399 | if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ){ | 48731 | if( p->zFName ){ |
| 48400 | sqlite3_free(p->aData); | 48732 | int i; |
| 48733 | #ifndef SQLITE_MUTEX_OMIT | ||
| 48734 | sqlite3_mutex *pVfsMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1); | ||
| 48735 | #endif | ||
| 48736 | sqlite3_mutex_enter(pVfsMutex); | ||
| 48737 | for(i=0; ALWAYS(i<memdb_g.nMemStore); i++){ | ||
| 48738 | if( memdb_g.apMemStore[i]==p ){ | ||
| 48739 | memdbEnter(p); | ||
| 48740 | if( p->nRef==1 ){ | ||
| 48741 | memdb_g.apMemStore[i] = memdb_g.apMemStore[--memdb_g.nMemStore]; | ||
| 48742 | if( memdb_g.nMemStore==0 ){ | ||
| 48743 | sqlite3_free(memdb_g.apMemStore); | ||
| 48744 | memdb_g.apMemStore = 0; | ||
| 48745 | } | ||
| 48746 | } | ||
| 48747 | break; | ||
| 48748 | } | ||
| 48749 | } | ||
| 48750 | sqlite3_mutex_leave(pVfsMutex); | ||
| 48751 | }else{ | ||
| 48752 | memdbEnter(p); | ||
| 48753 | } | ||
| 48754 | p->nRef--; | ||
| 48755 | if( p->nRef<=0 ){ | ||
| 48756 | if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ){ | ||
| 48757 | sqlite3_free(p->aData); | ||
| 48758 | } | ||
| 48759 | memdbLeave(p); | ||
| 48760 | sqlite3_mutex_free(p->pMutex); | ||
| 48761 | sqlite3_free(p); | ||
| 48762 | }else{ | ||
| 48763 | memdbLeave(p); | ||
| 48401 | } | 48764 | } |
| 48402 | return SQLITE_OK; | 48765 | return SQLITE_OK; |
| 48403 | } | 48766 | } |
| @@ -48411,20 +48774,23 @@ static int memdbRead( | |||
| 48411 | int iAmt, | 48774 | int iAmt, |
| 48412 | sqlite_int64 iOfst | 48775 | sqlite_int64 iOfst |
| 48413 | ){ | 48776 | ){ |
| 48414 | MemFile *p = (MemFile *)pFile; | 48777 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48778 | memdbEnter(p); | ||
| 48415 | if( iOfst+iAmt>p->sz ){ | 48779 | if( iOfst+iAmt>p->sz ){ |
| 48416 | memset(zBuf, 0, iAmt); | 48780 | memset(zBuf, 0, iAmt); |
| 48417 | if( iOfst<p->sz ) memcpy(zBuf, p->aData+iOfst, p->sz - iOfst); | 48781 | if( iOfst<p->sz ) memcpy(zBuf, p->aData+iOfst, p->sz - iOfst); |
| 48782 | memdbLeave(p); | ||
| 48418 | return SQLITE_IOERR_SHORT_READ; | 48783 | return SQLITE_IOERR_SHORT_READ; |
| 48419 | } | 48784 | } |
| 48420 | memcpy(zBuf, p->aData+iOfst, iAmt); | 48785 | memcpy(zBuf, p->aData+iOfst, iAmt); |
| 48786 | memdbLeave(p); | ||
| 48421 | return SQLITE_OK; | 48787 | return SQLITE_OK; |
| 48422 | } | 48788 | } |
| 48423 | 48789 | ||
| 48424 | /* | 48790 | /* |
| 48425 | ** Try to enlarge the memory allocation to hold at least sz bytes | 48791 | ** Try to enlarge the memory allocation to hold at least sz bytes |
| 48426 | */ | 48792 | */ |
| 48427 | static int memdbEnlarge(MemFile *p, sqlite3_int64 newSz){ | 48793 | static int memdbEnlarge(MemStore *p, sqlite3_int64 newSz){ |
| 48428 | unsigned char *pNew; | 48794 | unsigned char *pNew; |
| 48429 | if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || p->nMmap>0 ){ | 48795 | if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || p->nMmap>0 ){ |
| 48430 | return SQLITE_FULL; | 48796 | return SQLITE_FULL; |
| @@ -48435,7 +48801,7 @@ static int memdbEnlarge(MemFile *p, sqlite3_int64 newSz){ | |||
| 48435 | newSz *= 2; | 48801 | newSz *= 2; |
| 48436 | if( newSz>p->szMax ) newSz = p->szMax; | 48802 | if( newSz>p->szMax ) newSz = p->szMax; |
| 48437 | pNew = sqlite3Realloc(p->aData, newSz); | 48803 | pNew = sqlite3Realloc(p->aData, newSz); |
| 48438 | if( pNew==0 ) return SQLITE_NOMEM; | 48804 | if( pNew==0 ) return SQLITE_IOERR_NOMEM; |
| 48439 | p->aData = pNew; | 48805 | p->aData = pNew; |
| 48440 | p->szAlloc = newSz; | 48806 | p->szAlloc = newSz; |
| 48441 | return SQLITE_OK; | 48807 | return SQLITE_OK; |
| @@ -48450,19 +48816,27 @@ static int memdbWrite( | |||
| 48450 | int iAmt, | 48816 | int iAmt, |
| 48451 | sqlite_int64 iOfst | 48817 | sqlite_int64 iOfst |
| 48452 | ){ | 48818 | ){ |
| 48453 | MemFile *p = (MemFile *)pFile; | 48819 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48454 | if( NEVER(p->mFlags & SQLITE_DESERIALIZE_READONLY) ) return SQLITE_READONLY; | 48820 | memdbEnter(p); |
| 48821 | if( NEVER(p->mFlags & SQLITE_DESERIALIZE_READONLY) ){ | ||
| 48822 | /* Can't happen: memdbLock() will return SQLITE_READONLY before | ||
| 48823 | ** reaching this point */ | ||
| 48824 | memdbLeave(p); | ||
| 48825 | return SQLITE_IOERR_WRITE; | ||
| 48826 | } | ||
| 48455 | if( iOfst+iAmt>p->sz ){ | 48827 | if( iOfst+iAmt>p->sz ){ |
| 48456 | int rc; | 48828 | int rc; |
| 48457 | if( iOfst+iAmt>p->szAlloc | 48829 | if( iOfst+iAmt>p->szAlloc |
| 48458 | && (rc = memdbEnlarge(p, iOfst+iAmt))!=SQLITE_OK | 48830 | && (rc = memdbEnlarge(p, iOfst+iAmt))!=SQLITE_OK |
| 48459 | ){ | 48831 | ){ |
| 48832 | memdbLeave(p); | ||
| 48460 | return rc; | 48833 | return rc; |
| 48461 | } | 48834 | } |
| 48462 | if( iOfst>p->sz ) memset(p->aData+p->sz, 0, iOfst-p->sz); | 48835 | if( iOfst>p->sz ) memset(p->aData+p->sz, 0, iOfst-p->sz); |
| 48463 | p->sz = iOfst+iAmt; | 48836 | p->sz = iOfst+iAmt; |
| 48464 | } | 48837 | } |
| 48465 | memcpy(p->aData+iOfst, z, iAmt); | 48838 | memcpy(p->aData+iOfst, z, iAmt); |
| 48839 | memdbLeave(p); | ||
| 48466 | return SQLITE_OK; | 48840 | return SQLITE_OK; |
| 48467 | } | 48841 | } |
| 48468 | 48842 | ||
| @@ -48474,16 +48848,24 @@ static int memdbWrite( | |||
| 48474 | ** the size of a file, never to increase the size. | 48848 | ** the size of a file, never to increase the size. |
| 48475 | */ | 48849 | */ |
| 48476 | static int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){ | 48850 | static int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){ |
| 48477 | MemFile *p = (MemFile *)pFile; | 48851 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48478 | if( NEVER(size>p->sz) ) return SQLITE_FULL; | 48852 | int rc = SQLITE_OK; |
| 48479 | p->sz = size; | 48853 | memdbEnter(p); |
| 48480 | return SQLITE_OK; | 48854 | if( NEVER(size>p->sz) ){ |
| 48855 | rc = SQLITE_FULL; | ||
| 48856 | }else{ | ||
| 48857 | p->sz = size; | ||
| 48858 | } | ||
| 48859 | memdbLeave(p); | ||
| 48860 | return rc; | ||
| 48481 | } | 48861 | } |
| 48482 | 48862 | ||
| 48483 | /* | 48863 | /* |
| 48484 | ** Sync an memdb-file. | 48864 | ** Sync an memdb-file. |
| 48485 | */ | 48865 | */ |
| 48486 | static int memdbSync(sqlite3_file *pFile, int flags){ | 48866 | static int memdbSync(sqlite3_file *pFile, int flags){ |
| 48867 | UNUSED_PARAMETER(pFile); | ||
| 48868 | UNUSED_PARAMETER(flags); | ||
| 48487 | return SQLITE_OK; | 48869 | return SQLITE_OK; |
| 48488 | } | 48870 | } |
| 48489 | 48871 | ||
| @@ -48491,8 +48873,10 @@ static int memdbSync(sqlite3_file *pFile, int flags){ | |||
| 48491 | ** Return the current file-size of an memdb-file. | 48873 | ** Return the current file-size of an memdb-file. |
| 48492 | */ | 48874 | */ |
| 48493 | static int memdbFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ | 48875 | static int memdbFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ |
| 48494 | MemFile *p = (MemFile *)pFile; | 48876 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48877 | memdbEnter(p); | ||
| 48495 | *pSize = p->sz; | 48878 | *pSize = p->sz; |
| 48879 | memdbLeave(p); | ||
| 48496 | return SQLITE_OK; | 48880 | return SQLITE_OK; |
| 48497 | } | 48881 | } |
| 48498 | 48882 | ||
| @@ -48500,19 +48884,48 @@ static int memdbFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ | |||
| 48500 | ** Lock an memdb-file. | 48884 | ** Lock an memdb-file. |
| 48501 | */ | 48885 | */ |
| 48502 | static int memdbLock(sqlite3_file *pFile, int eLock){ | 48886 | static int memdbLock(sqlite3_file *pFile, int eLock){ |
| 48503 | MemFile *p = (MemFile *)pFile; | 48887 | MemFile *pThis = (MemFile*)pFile; |
| 48504 | if( eLock>SQLITE_LOCK_SHARED | 48888 | MemStore *p = pThis->pStore; |
| 48505 | && (p->mFlags & SQLITE_DESERIALIZE_READONLY)!=0 | 48889 | int rc = SQLITE_OK; |
| 48506 | ){ | 48890 | if( eLock==pThis->eLock ) return SQLITE_OK; |
| 48507 | return SQLITE_READONLY; | 48891 | memdbEnter(p); |
| 48892 | if( eLock>SQLITE_LOCK_SHARED ){ | ||
| 48893 | if( p->mFlags & SQLITE_DESERIALIZE_READONLY ){ | ||
| 48894 | rc = SQLITE_READONLY; | ||
| 48895 | }else if( pThis->eLock<=SQLITE_LOCK_SHARED ){ | ||
| 48896 | if( p->nWrLock ){ | ||
| 48897 | rc = SQLITE_BUSY; | ||
| 48898 | }else{ | ||
| 48899 | p->nWrLock = 1; | ||
| 48900 | } | ||
| 48901 | } | ||
| 48902 | }else if( eLock==SQLITE_LOCK_SHARED ){ | ||
| 48903 | if( pThis->eLock > SQLITE_LOCK_SHARED ){ | ||
| 48904 | assert( p->nWrLock==1 ); | ||
| 48905 | p->nWrLock = 0; | ||
| 48906 | }else if( p->nWrLock ){ | ||
| 48907 | rc = SQLITE_BUSY; | ||
| 48908 | }else{ | ||
| 48909 | p->nRdLock++; | ||
| 48910 | } | ||
| 48911 | }else{ | ||
| 48912 | assert( eLock==SQLITE_LOCK_NONE ); | ||
| 48913 | if( pThis->eLock>SQLITE_LOCK_SHARED ){ | ||
| 48914 | assert( p->nWrLock==1 ); | ||
| 48915 | p->nWrLock = 0; | ||
| 48916 | } | ||
| 48917 | assert( p->nRdLock>0 ); | ||
| 48918 | p->nRdLock--; | ||
| 48508 | } | 48919 | } |
| 48509 | p->eLock = eLock; | 48920 | if( rc==SQLITE_OK ) pThis->eLock = eLock; |
| 48510 | return SQLITE_OK; | 48921 | memdbLeave(p); |
| 48922 | return rc; | ||
| 48511 | } | 48923 | } |
| 48512 | 48924 | ||
| 48513 | #if 0 /* Never used because memdbAccess() always returns false */ | 48925 | #if 0 |
| 48514 | /* | 48926 | /* |
| 48515 | ** Check if another file-handle holds a RESERVED lock on an memdb-file. | 48927 | ** This interface is only used for crash recovery, which does not |
| 48928 | ** occur on an in-memory database. | ||
| 48516 | */ | 48929 | */ |
| 48517 | static int memdbCheckReservedLock(sqlite3_file *pFile, int *pResOut){ | 48930 | static int memdbCheckReservedLock(sqlite3_file *pFile, int *pResOut){ |
| 48518 | *pResOut = 0; | 48931 | *pResOut = 0; |
| @@ -48520,12 +48933,14 @@ static int memdbCheckReservedLock(sqlite3_file *pFile, int *pResOut){ | |||
| 48520 | } | 48933 | } |
| 48521 | #endif | 48934 | #endif |
| 48522 | 48935 | ||
| 48936 | |||
| 48523 | /* | 48937 | /* |
| 48524 | ** File control method. For custom operations on an memdb-file. | 48938 | ** File control method. For custom operations on an memdb-file. |
| 48525 | */ | 48939 | */ |
| 48526 | static int memdbFileControl(sqlite3_file *pFile, int op, void *pArg){ | 48940 | static int memdbFileControl(sqlite3_file *pFile, int op, void *pArg){ |
| 48527 | MemFile *p = (MemFile *)pFile; | 48941 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48528 | int rc = SQLITE_NOTFOUND; | 48942 | int rc = SQLITE_NOTFOUND; |
| 48943 | memdbEnter(p); | ||
| 48529 | if( op==SQLITE_FCNTL_VFSNAME ){ | 48944 | if( op==SQLITE_FCNTL_VFSNAME ){ |
| 48530 | *(char**)pArg = sqlite3_mprintf("memdb(%p,%lld)", p->aData, p->sz); | 48945 | *(char**)pArg = sqlite3_mprintf("memdb(%p,%lld)", p->aData, p->sz); |
| 48531 | rc = SQLITE_OK; | 48946 | rc = SQLITE_OK; |
| @@ -48543,6 +48958,7 @@ static int memdbFileControl(sqlite3_file *pFile, int op, void *pArg){ | |||
| 48543 | *(sqlite3_int64*)pArg = iLimit; | 48958 | *(sqlite3_int64*)pArg = iLimit; |
| 48544 | rc = SQLITE_OK; | 48959 | rc = SQLITE_OK; |
| 48545 | } | 48960 | } |
| 48961 | memdbLeave(p); | ||
| 48546 | return rc; | 48962 | return rc; |
| 48547 | } | 48963 | } |
| 48548 | 48964 | ||
| @@ -48559,6 +48975,7 @@ static int memdbSectorSize(sqlite3_file *pFile){ | |||
| 48559 | ** Return the device characteristic flags supported by an memdb-file. | 48975 | ** Return the device characteristic flags supported by an memdb-file. |
| 48560 | */ | 48976 | */ |
| 48561 | static int memdbDeviceCharacteristics(sqlite3_file *pFile){ | 48977 | static int memdbDeviceCharacteristics(sqlite3_file *pFile){ |
| 48978 | UNUSED_PARAMETER(pFile); | ||
| 48562 | return SQLITE_IOCAP_ATOMIC | | 48979 | return SQLITE_IOCAP_ATOMIC | |
| 48563 | SQLITE_IOCAP_POWERSAFE_OVERWRITE | | 48980 | SQLITE_IOCAP_POWERSAFE_OVERWRITE | |
| 48564 | SQLITE_IOCAP_SAFE_APPEND | | 48981 | SQLITE_IOCAP_SAFE_APPEND | |
| @@ -48572,20 +48989,26 @@ static int memdbFetch( | |||
| 48572 | int iAmt, | 48989 | int iAmt, |
| 48573 | void **pp | 48990 | void **pp |
| 48574 | ){ | 48991 | ){ |
| 48575 | MemFile *p = (MemFile *)pFile; | 48992 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48993 | memdbEnter(p); | ||
| 48576 | if( iOfst+iAmt>p->sz ){ | 48994 | if( iOfst+iAmt>p->sz ){ |
| 48577 | *pp = 0; | 48995 | *pp = 0; |
| 48578 | }else{ | 48996 | }else{ |
| 48579 | p->nMmap++; | 48997 | p->nMmap++; |
| 48580 | *pp = (void*)(p->aData + iOfst); | 48998 | *pp = (void*)(p->aData + iOfst); |
| 48581 | } | 48999 | } |
| 49000 | memdbLeave(p); | ||
| 48582 | return SQLITE_OK; | 49001 | return SQLITE_OK; |
| 48583 | } | 49002 | } |
| 48584 | 49003 | ||
| 48585 | /* Release a memory-mapped page */ | 49004 | /* Release a memory-mapped page */ |
| 48586 | static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ | 49005 | static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ |
| 48587 | MemFile *p = (MemFile *)pFile; | 49006 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 49007 | UNUSED_PARAMETER(iOfst); | ||
| 49008 | UNUSED_PARAMETER(pPage); | ||
| 49009 | memdbEnter(p); | ||
| 48588 | p->nMmap--; | 49010 | p->nMmap--; |
| 49011 | memdbLeave(p); | ||
| 48589 | return SQLITE_OK; | 49012 | return SQLITE_OK; |
| 48590 | } | 49013 | } |
| 48591 | 49014 | ||
| @@ -48595,20 +49018,79 @@ static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ | |||
| 48595 | static int memdbOpen( | 49018 | static int memdbOpen( |
| 48596 | sqlite3_vfs *pVfs, | 49019 | sqlite3_vfs *pVfs, |
| 48597 | const char *zName, | 49020 | const char *zName, |
| 48598 | sqlite3_file *pFile, | 49021 | sqlite3_file *pFd, |
| 48599 | int flags, | 49022 | int flags, |
| 48600 | int *pOutFlags | 49023 | int *pOutFlags |
| 48601 | ){ | 49024 | ){ |
| 48602 | MemFile *p = (MemFile*)pFile; | 49025 | MemFile *pFile = (MemFile*)pFd; |
| 49026 | MemStore *p = 0; | ||
| 49027 | int szName; | ||
| 48603 | if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){ | 49028 | if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){ |
| 48604 | return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFile, flags, pOutFlags); | 49029 | return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFd, flags, pOutFlags); |
| 48605 | } | 49030 | } |
| 48606 | memset(p, 0, sizeof(*p)); | 49031 | memset(pFile, 0, sizeof(*p)); |
| 48607 | p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE; | 49032 | szName = sqlite3Strlen30(zName); |
| 49033 | if( szName>1 && zName[0]=='/' ){ | ||
| 49034 | int i; | ||
| 49035 | #ifndef SQLITE_MUTEX_OMIT | ||
| 49036 | sqlite3_mutex *pVfsMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1); | ||
| 49037 | #endif | ||
| 49038 | sqlite3_mutex_enter(pVfsMutex); | ||
| 49039 | for(i=0; i<memdb_g.nMemStore; i++){ | ||
| 49040 | if( strcmp(memdb_g.apMemStore[i]->zFName,zName)==0 ){ | ||
| 49041 | p = memdb_g.apMemStore[i]; | ||
| 49042 | break; | ||
| 49043 | } | ||
| 49044 | } | ||
| 49045 | if( p==0 ){ | ||
| 49046 | MemStore **apNew; | ||
| 49047 | p = sqlite3Malloc( sizeof(*p) + szName + 3 ); | ||
| 49048 | if( p==0 ){ | ||
| 49049 | sqlite3_mutex_leave(pVfsMutex); | ||
| 49050 | return SQLITE_NOMEM; | ||
| 49051 | } | ||
| 49052 | apNew = sqlite3Realloc(memdb_g.apMemStore, | ||
| 49053 | sizeof(apNew[0])*(memdb_g.nMemStore+1) ); | ||
| 49054 | if( apNew==0 ){ | ||
| 49055 | sqlite3_free(p); | ||
| 49056 | sqlite3_mutex_leave(pVfsMutex); | ||
| 49057 | return SQLITE_NOMEM; | ||
| 49058 | } | ||
| 49059 | apNew[memdb_g.nMemStore++] = p; | ||
| 49060 | memdb_g.apMemStore = apNew; | ||
| 49061 | memset(p, 0, sizeof(*p)); | ||
| 49062 | p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE|SQLITE_DESERIALIZE_FREEONCLOSE; | ||
| 49063 | p->szMax = sqlite3GlobalConfig.mxMemdbSize; | ||
| 49064 | p->zFName = (char*)&p[1]; | ||
| 49065 | memcpy(p->zFName, zName, szName+1); | ||
| 49066 | p->pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); | ||
| 49067 | if( p->pMutex==0 ){ | ||
| 49068 | memdb_g.nMemStore--; | ||
| 49069 | sqlite3_free(p); | ||
| 49070 | sqlite3_mutex_leave(pVfsMutex); | ||
| 49071 | return SQLITE_NOMEM; | ||
| 49072 | } | ||
| 49073 | p->nRef = 1; | ||
| 49074 | memdbEnter(p); | ||
| 49075 | }else{ | ||
| 49076 | memdbEnter(p); | ||
| 49077 | p->nRef++; | ||
| 49078 | } | ||
| 49079 | sqlite3_mutex_leave(pVfsMutex); | ||
| 49080 | }else{ | ||
| 49081 | p = sqlite3Malloc( sizeof(*p) ); | ||
| 49082 | if( p==0 ){ | ||
| 49083 | return SQLITE_NOMEM; | ||
| 49084 | } | ||
| 49085 | memset(p, 0, sizeof(*p)); | ||
| 49086 | p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE; | ||
| 49087 | p->szMax = sqlite3GlobalConfig.mxMemdbSize; | ||
| 49088 | } | ||
| 49089 | pFile->pStore = p; | ||
| 48608 | assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */ | 49090 | assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */ |
| 48609 | *pOutFlags = flags | SQLITE_OPEN_MEMORY; | 49091 | *pOutFlags = flags | SQLITE_OPEN_MEMORY; |
| 48610 | pFile->pMethods = &memdb_io_methods; | 49092 | pFd->pMethods = &memdb_io_methods; |
| 48611 | p->szMax = sqlite3GlobalConfig.mxMemdbSize; | 49093 | memdbLeave(p); |
| 48612 | return SQLITE_OK; | 49094 | return SQLITE_OK; |
| 48613 | } | 49095 | } |
| 48614 | 49096 | ||
| @@ -48636,6 +49118,9 @@ static int memdbAccess( | |||
| 48636 | int flags, | 49118 | int flags, |
| 48637 | int *pResOut | 49119 | int *pResOut |
| 48638 | ){ | 49120 | ){ |
| 49121 | UNUSED_PARAMETER(pVfs); | ||
| 49122 | UNUSED_PARAMETER(zPath); | ||
| 49123 | UNUSED_PARAMETER(flags); | ||
| 48639 | *pResOut = 0; | 49124 | *pResOut = 0; |
| 48640 | return SQLITE_OK; | 49125 | return SQLITE_OK; |
| 48641 | } | 49126 | } |
| @@ -48651,6 +49136,7 @@ static int memdbFullPathname( | |||
| 48651 | int nOut, | 49136 | int nOut, |
| 48652 | char *zOut | 49137 | char *zOut |
| 48653 | ){ | 49138 | ){ |
| 49139 | UNUSED_PARAMETER(pVfs); | ||
| 48654 | sqlite3_snprintf(nOut, zOut, "%s", zPath); | 49140 | sqlite3_snprintf(nOut, zOut, "%s", zPath); |
| 48655 | return SQLITE_OK; | 49141 | return SQLITE_OK; |
| 48656 | } | 49142 | } |
| @@ -48723,9 +49209,14 @@ static int memdbCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p){ | |||
| 48723 | */ | 49209 | */ |
| 48724 | static MemFile *memdbFromDbSchema(sqlite3 *db, const char *zSchema){ | 49210 | static MemFile *memdbFromDbSchema(sqlite3 *db, const char *zSchema){ |
| 48725 | MemFile *p = 0; | 49211 | MemFile *p = 0; |
| 49212 | MemStore *pStore; | ||
| 48726 | int rc = sqlite3_file_control(db, zSchema, SQLITE_FCNTL_FILE_POINTER, &p); | 49213 | int rc = sqlite3_file_control(db, zSchema, SQLITE_FCNTL_FILE_POINTER, &p); |
| 48727 | if( rc ) return 0; | 49214 | if( rc ) return 0; |
| 48728 | if( p->base.pMethods!=&memdb_io_methods ) return 0; | 49215 | if( p->base.pMethods!=&memdb_io_methods ) return 0; |
| 49216 | pStore = p->pStore; | ||
| 49217 | memdbEnter(pStore); | ||
| 49218 | if( pStore->zFName!=0 ) p = 0; | ||
| 49219 | memdbLeave(pStore); | ||
| 48729 | return p; | 49220 | return p; |
| 48730 | } | 49221 | } |
| 48731 | 49222 | ||
| @@ -48761,12 +49252,14 @@ SQLITE_API unsigned char *sqlite3_serialize( | |||
| 48761 | if( piSize ) *piSize = -1; | 49252 | if( piSize ) *piSize = -1; |
| 48762 | if( iDb<0 ) return 0; | 49253 | if( iDb<0 ) return 0; |
| 48763 | if( p ){ | 49254 | if( p ){ |
| 48764 | if( piSize ) *piSize = p->sz; | 49255 | MemStore *pStore = p->pStore; |
| 49256 | assert( pStore->pMutex==0 ); | ||
| 49257 | if( piSize ) *piSize = pStore->sz; | ||
| 48765 | if( mFlags & SQLITE_SERIALIZE_NOCOPY ){ | 49258 | if( mFlags & SQLITE_SERIALIZE_NOCOPY ){ |
| 48766 | pOut = p->aData; | 49259 | pOut = pStore->aData; |
| 48767 | }else{ | 49260 | }else{ |
| 48768 | pOut = sqlite3_malloc64( p->sz ); | 49261 | pOut = sqlite3_malloc64( pStore->sz ); |
| 48769 | if( pOut ) memcpy(pOut, p->aData, p->sz); | 49262 | if( pOut ) memcpy(pOut, pStore->aData, pStore->sz); |
| 48770 | } | 49263 | } |
| 48771 | return pOut; | 49264 | return pOut; |
| 48772 | } | 49265 | } |
| @@ -48860,15 +49353,16 @@ SQLITE_API int sqlite3_deserialize( | |||
| 48860 | if( p==0 ){ | 49353 | if( p==0 ){ |
| 48861 | rc = SQLITE_ERROR; | 49354 | rc = SQLITE_ERROR; |
| 48862 | }else{ | 49355 | }else{ |
| 48863 | p->aData = pData; | 49356 | MemStore *pStore = p->pStore; |
| 49357 | pStore->aData = pData; | ||
| 48864 | pData = 0; | 49358 | pData = 0; |
| 48865 | p->sz = szDb; | 49359 | pStore->sz = szDb; |
| 48866 | p->szAlloc = szBuf; | 49360 | pStore->szAlloc = szBuf; |
| 48867 | p->szMax = szBuf; | 49361 | pStore->szMax = szBuf; |
| 48868 | if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){ | 49362 | if( pStore->szMax<sqlite3GlobalConfig.mxMemdbSize ){ |
| 48869 | p->szMax = sqlite3GlobalConfig.mxMemdbSize; | 49363 | pStore->szMax = sqlite3GlobalConfig.mxMemdbSize; |
| 48870 | } | 49364 | } |
| 48871 | p->mFlags = mFlags; | 49365 | pStore->mFlags = mFlags; |
| 48872 | rc = SQLITE_OK; | 49366 | rc = SQLITE_OK; |
| 48873 | } | 49367 | } |
| 48874 | 49368 | ||
| @@ -48887,7 +49381,9 @@ end_deserialize: | |||
| 48887 | */ | 49381 | */ |
| 48888 | SQLITE_PRIVATE int sqlite3MemdbInit(void){ | 49382 | SQLITE_PRIVATE int sqlite3MemdbInit(void){ |
| 48889 | sqlite3_vfs *pLower = sqlite3_vfs_find(0); | 49383 | sqlite3_vfs *pLower = sqlite3_vfs_find(0); |
| 48890 | int sz = pLower->szOsFile; | 49384 | unsigned int sz; |
| 49385 | if( NEVER(pLower==0) ) return SQLITE_ERROR; | ||
| 49386 | sz = pLower->szOsFile; | ||
| 48891 | memdb_vfs.pAppData = pLower; | 49387 | memdb_vfs.pAppData = pLower; |
| 48892 | /* The following conditional can only be true when compiled for | 49388 | /* The following conditional can only be true when compiled for |
| 48893 | ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave | 49389 | ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave |
| @@ -48897,7 +49393,7 @@ SQLITE_PRIVATE int sqlite3MemdbInit(void){ | |||
| 48897 | memdb_vfs.szOsFile = sz; | 49393 | memdb_vfs.szOsFile = sz; |
| 48898 | return sqlite3_vfs_register(&memdb_vfs, 0); | 49394 | return sqlite3_vfs_register(&memdb_vfs, 0); |
| 48899 | } | 49395 | } |
| 48900 | #endif /* SQLITE_ENABLE_DESERIALIZE */ | 49396 | #endif /* SQLITE_OMIT_DESERIALIZE */ |
| 48901 | 49397 | ||
| 48902 | /************** End of memdb.c ***********************************************/ | 49398 | /************** End of memdb.c ***********************************************/ |
| 48903 | /************** Begin file bitvec.c ******************************************/ | 49399 | /************** Begin file bitvec.c ******************************************/ |
| @@ -56083,7 +56579,8 @@ static void assertTruncateConstraint(Pager *pPager){ | |||
| 56083 | ** then continue writing to the database. | 56579 | ** then continue writing to the database. |
| 56084 | */ | 56580 | */ |
| 56085 | SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){ | 56581 | SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){ |
| 56086 | assert( pPager->dbSize>=nPage ); | 56582 | assert( pPager->dbSize>=nPage || CORRUPT_DB ); |
| 56583 | testcase( pPager->dbSize<nPage ); | ||
| 56087 | assert( pPager->eState>=PAGER_WRITER_CACHEMOD ); | 56584 | assert( pPager->eState>=PAGER_WRITER_CACHEMOD ); |
| 56088 | pPager->dbSize = nPage; | 56585 | pPager->dbSize = nPage; |
| 56089 | 56586 | ||
| @@ -56811,7 +57308,7 @@ SQLITE_PRIVATE int sqlite3PagerOpen( | |||
| 56811 | int rc = SQLITE_OK; /* Return code */ | 57308 | int rc = SQLITE_OK; /* Return code */ |
| 56812 | int tempFile = 0; /* True for temp files (incl. in-memory files) */ | 57309 | int tempFile = 0; /* True for temp files (incl. in-memory files) */ |
| 56813 | int memDb = 0; /* True if this is an in-memory file */ | 57310 | int memDb = 0; /* True if this is an in-memory file */ |
| 56814 | #ifdef SQLITE_ENABLE_DESERIALIZE | 57311 | #ifndef SQLITE_OMIT_DESERIALIZE |
| 56815 | int memJM = 0; /* Memory journal mode */ | 57312 | int memJM = 0; /* Memory journal mode */ |
| 56816 | #else | 57313 | #else |
| 56817 | # define memJM 0 | 57314 | # define memJM 0 |
| @@ -57015,7 +57512,7 @@ SQLITE_PRIVATE int sqlite3PagerOpen( | |||
| 57015 | int fout = 0; /* VFS flags returned by xOpen() */ | 57512 | int fout = 0; /* VFS flags returned by xOpen() */ |
| 57016 | rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout); | 57513 | rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout); |
| 57017 | assert( !memDb ); | 57514 | assert( !memDb ); |
| 57018 | #ifdef SQLITE_ENABLE_DESERIALIZE | 57515 | #ifndef SQLITE_OMIT_DESERIALIZE |
| 57019 | memJM = (fout&SQLITE_OPEN_MEMORY)!=0; | 57516 | memJM = (fout&SQLITE_OPEN_MEMORY)!=0; |
| 57020 | #endif | 57517 | #endif |
| 57021 | readOnly = (fout&SQLITE_OPEN_READONLY)!=0; | 57518 | readOnly = (fout&SQLITE_OPEN_READONLY)!=0; |
| @@ -57983,7 +58480,7 @@ SQLITE_PRIVATE int sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory | |||
| 57983 | assert( pPager->eState>=PAGER_READER && pPager->eState<PAGER_ERROR ); | 58480 | assert( pPager->eState>=PAGER_READER && pPager->eState<PAGER_ERROR ); |
| 57984 | pPager->subjInMemory = (u8)subjInMemory; | 58481 | pPager->subjInMemory = (u8)subjInMemory; |
| 57985 | 58482 | ||
| 57986 | if( ALWAYS(pPager->eState==PAGER_READER) ){ | 58483 | if( pPager->eState==PAGER_READER ){ |
| 57987 | assert( pPager->pInJournal==0 ); | 58484 | assert( pPager->pInJournal==0 ); |
| 57988 | 58485 | ||
| 57989 | if( pagerUseWal(pPager) ){ | 58486 | if( pagerUseWal(pPager) ){ |
| @@ -60857,7 +61354,6 @@ static void walCleanupHash(Wal *pWal){ | |||
| 60857 | int iLimit = 0; /* Zero values greater than this */ | 61354 | int iLimit = 0; /* Zero values greater than this */ |
| 60858 | int nByte; /* Number of bytes to zero in aPgno[] */ | 61355 | int nByte; /* Number of bytes to zero in aPgno[] */ |
| 60859 | int i; /* Used to iterate through aHash[] */ | 61356 | int i; /* Used to iterate through aHash[] */ |
| 60860 | int rc; /* Return code form walHashGet() */ | ||
| 60861 | 61357 | ||
| 60862 | assert( pWal->writeLock ); | 61358 | assert( pWal->writeLock ); |
| 60863 | testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 ); | 61359 | testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 ); |
| @@ -60872,8 +61368,8 @@ static void walCleanupHash(Wal *pWal){ | |||
| 60872 | */ | 61368 | */ |
| 60873 | assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) ); | 61369 | assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) ); |
| 60874 | assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] ); | 61370 | assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] ); |
| 60875 | rc = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc); | 61371 | i = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc); |
| 60876 | if( NEVER(rc) ) return; /* Defense-in-depth, in case (1) above is wrong */ | 61372 | if( NEVER(i) ) return; /* Defense-in-depth, in case (1) above is wrong */ |
| 60877 | 61373 | ||
| 60878 | /* Zero all hash-table entries that correspond to frame numbers greater | 61374 | /* Zero all hash-table entries that correspond to frame numbers greater |
| 60879 | ** than pWal->hdr.mxFrame. | 61375 | ** than pWal->hdr.mxFrame. |
| @@ -65503,7 +65999,7 @@ static void invalidateIncrblobCursors( | |||
| 65503 | int isClearTable /* True if all rows are being deleted */ | 65999 | int isClearTable /* True if all rows are being deleted */ |
| 65504 | ){ | 66000 | ){ |
| 65505 | BtCursor *p; | 66001 | BtCursor *p; |
| 65506 | if( pBtree->hasIncrblobCur==0 ) return; | 66002 | assert( pBtree->hasIncrblobCur ); |
| 65507 | assert( sqlite3BtreeHoldsMutex(pBtree) ); | 66003 | assert( sqlite3BtreeHoldsMutex(pBtree) ); |
| 65508 | pBtree->hasIncrblobCur = 0; | 66004 | pBtree->hasIncrblobCur = 0; |
| 65509 | for(p=pBtree->pBt->pCursor; p; p=p->pNext){ | 66005 | for(p=pBtree->pBt->pCursor; p; p=p->pNext){ |
| @@ -66404,6 +66900,7 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){ | |||
| 66404 | unsigned char *src; /* Source of content */ | 66900 | unsigned char *src; /* Source of content */ |
| 66405 | int iCellFirst; /* First allowable cell index */ | 66901 | int iCellFirst; /* First allowable cell index */ |
| 66406 | int iCellLast; /* Last possible cell index */ | 66902 | int iCellLast; /* Last possible cell index */ |
| 66903 | int iCellStart; /* First cell offset in input */ | ||
| 66407 | 66904 | ||
| 66408 | assert( sqlite3PagerIswriteable(pPage->pDbPage) ); | 66905 | assert( sqlite3PagerIswriteable(pPage->pDbPage) ); |
| 66409 | assert( pPage->pBt!=0 ); | 66906 | assert( pPage->pBt!=0 ); |
| @@ -66445,7 +66942,7 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){ | |||
| 66445 | if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage); | 66942 | if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage); |
| 66446 | memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz)); | 66943 | memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz)); |
| 66447 | sz += sz2; | 66944 | sz += sz2; |
| 66448 | }else if( NEVER(iFree+sz>usableSize) ){ | 66945 | }else if( iFree+sz>usableSize ){ |
| 66449 | return SQLITE_CORRUPT_PAGE(pPage); | 66946 | return SQLITE_CORRUPT_PAGE(pPage); |
| 66450 | } | 66947 | } |
| 66451 | 66948 | ||
| @@ -66464,6 +66961,7 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){ | |||
| 66464 | 66961 | ||
| 66465 | cbrk = usableSize; | 66962 | cbrk = usableSize; |
| 66466 | iCellLast = usableSize - 4; | 66963 | iCellLast = usableSize - 4; |
| 66964 | iCellStart = get2byte(&data[hdr+5]); | ||
| 66467 | for(i=0; i<nCell; i++){ | 66965 | for(i=0; i<nCell; i++){ |
| 66468 | u8 *pAddr; /* The i-th cell pointer */ | 66966 | u8 *pAddr; /* The i-th cell pointer */ |
| 66469 | pAddr = &data[cellOffset + i*2]; | 66967 | pAddr = &data[cellOffset + i*2]; |
| @@ -66473,25 +66971,23 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){ | |||
| 66473 | /* These conditions have already been verified in btreeInitPage() | 66971 | /* These conditions have already been verified in btreeInitPage() |
| 66474 | ** if PRAGMA cell_size_check=ON. | 66972 | ** if PRAGMA cell_size_check=ON. |
| 66475 | */ | 66973 | */ |
| 66476 | if( pc<iCellFirst || pc>iCellLast ){ | 66974 | if( pc<iCellStart || pc>iCellLast ){ |
| 66477 | return SQLITE_CORRUPT_PAGE(pPage); | 66975 | return SQLITE_CORRUPT_PAGE(pPage); |
| 66478 | } | 66976 | } |
| 66479 | assert( pc>=iCellFirst && pc<=iCellLast ); | 66977 | assert( pc>=iCellStart && pc<=iCellLast ); |
| 66480 | size = pPage->xCellSize(pPage, &src[pc]); | 66978 | size = pPage->xCellSize(pPage, &src[pc]); |
| 66481 | cbrk -= size; | 66979 | cbrk -= size; |
| 66482 | if( cbrk<iCellFirst || pc+size>usableSize ){ | 66980 | if( cbrk<iCellStart || pc+size>usableSize ){ |
| 66483 | return SQLITE_CORRUPT_PAGE(pPage); | 66981 | return SQLITE_CORRUPT_PAGE(pPage); |
| 66484 | } | 66982 | } |
| 66485 | assert( cbrk+size<=usableSize && cbrk>=iCellFirst ); | 66983 | assert( cbrk+size<=usableSize && cbrk>=iCellStart ); |
| 66486 | testcase( cbrk+size==usableSize ); | 66984 | testcase( cbrk+size==usableSize ); |
| 66487 | testcase( pc+size==usableSize ); | 66985 | testcase( pc+size==usableSize ); |
| 66488 | put2byte(pAddr, cbrk); | 66986 | put2byte(pAddr, cbrk); |
| 66489 | if( temp==0 ){ | 66987 | if( temp==0 ){ |
| 66490 | int x; | ||
| 66491 | if( cbrk==pc ) continue; | 66988 | if( cbrk==pc ) continue; |
| 66492 | temp = sqlite3PagerTempSpace(pPage->pBt->pPager); | 66989 | temp = sqlite3PagerTempSpace(pPage->pBt->pPager); |
| 66493 | x = get2byte(&data[hdr+5]); | 66990 | memcpy(&temp[iCellStart], &data[iCellStart], usableSize - iCellStart); |
| 66494 | memcpy(&temp[x], &data[x], (cbrk+size) - x); | ||
| 66495 | src = temp; | 66991 | src = temp; |
| 66496 | } | 66992 | } |
| 66497 | memcpy(&data[cbrk], &src[pc], size); | 66993 | memcpy(&data[cbrk], &src[pc], size); |
| @@ -70350,7 +70846,9 @@ SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){ | |||
| 70350 | for(ii=0; ii<pCur->iPage; ii++){ | 70846 | for(ii=0; ii<pCur->iPage; ii++){ |
| 70351 | assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell ); | 70847 | assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell ); |
| 70352 | } | 70848 | } |
| 70353 | assert( pCur->ix==pCur->pPage->nCell-1 ); | 70849 | assert( pCur->ix==pCur->pPage->nCell-1 || CORRUPT_DB ); |
| 70850 | testcase( pCur->ix!=pCur->pPage->nCell-1 ); | ||
| 70851 | /* ^-- dbsqlfuzz b92b72e4de80b5140c30ab71372ca719b8feb618 */ | ||
| 70354 | assert( pCur->pPage->leaf ); | 70852 | assert( pCur->pPage->leaf ); |
| 70355 | #endif | 70853 | #endif |
| 70356 | *pRes = 0; | 70854 | *pRes = 0; |
| @@ -71117,7 +71615,7 @@ static int allocateBtreePage( | |||
| 71117 | 71615 | ||
| 71118 | iPage = get4byte(&aData[8+closest*4]); | 71616 | iPage = get4byte(&aData[8+closest*4]); |
| 71119 | testcase( iPage==mxPage ); | 71617 | testcase( iPage==mxPage ); |
| 71120 | if( iPage>mxPage ){ | 71618 | if( iPage>mxPage || iPage<2 ){ |
| 71121 | rc = SQLITE_CORRUPT_PGNO(iTrunk); | 71619 | rc = SQLITE_CORRUPT_PGNO(iTrunk); |
| 71122 | goto end_allocate_page; | 71620 | goto end_allocate_page; |
| 71123 | } | 71621 | } |
| @@ -71373,10 +71871,9 @@ static void freePage(MemPage *pPage, int *pRC){ | |||
| 71373 | } | 71871 | } |
| 71374 | 71872 | ||
| 71375 | /* | 71873 | /* |
| 71376 | ** Free any overflow pages associated with the given Cell. Store | 71874 | ** Free the overflow pages associated with the given Cell. |
| 71377 | ** size information about the cell in pInfo. | ||
| 71378 | */ | 71875 | */ |
| 71379 | static int clearCell( | 71876 | static SQLITE_NOINLINE int clearCellOverflow( |
| 71380 | MemPage *pPage, /* The page that contains the Cell */ | 71877 | MemPage *pPage, /* The page that contains the Cell */ |
| 71381 | unsigned char *pCell, /* First byte of the Cell */ | 71878 | unsigned char *pCell, /* First byte of the Cell */ |
| 71382 | CellInfo *pInfo /* Size information about the cell */ | 71879 | CellInfo *pInfo /* Size information about the cell */ |
| @@ -71388,10 +71885,7 @@ static int clearCell( | |||
| 71388 | u32 ovflPageSize; | 71885 | u32 ovflPageSize; |
| 71389 | 71886 | ||
| 71390 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); | 71887 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); |
| 71391 | pPage->xParseCell(pPage, pCell, pInfo); | 71888 | assert( pInfo->nLocal!=pInfo->nPayload ); |
| 71392 | if( pInfo->nLocal==pInfo->nPayload ){ | ||
| 71393 | return SQLITE_OK; /* No overflow pages. Return without doing anything */ | ||
| 71394 | } | ||
| 71395 | testcase( pCell + pInfo->nSize == pPage->aDataEnd ); | 71889 | testcase( pCell + pInfo->nSize == pPage->aDataEnd ); |
| 71396 | testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd ); | 71890 | testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd ); |
| 71397 | if( pCell + pInfo->nSize > pPage->aDataEnd ){ | 71891 | if( pCell + pInfo->nSize > pPage->aDataEnd ){ |
| @@ -71447,6 +71941,21 @@ static int clearCell( | |||
| 71447 | return SQLITE_OK; | 71941 | return SQLITE_OK; |
| 71448 | } | 71942 | } |
| 71449 | 71943 | ||
| 71944 | /* Call xParseCell to compute the size of a cell. If the cell contains | ||
| 71945 | ** overflow, then invoke cellClearOverflow to clear out that overflow. | ||
| 71946 | ** STore the result code (SQLITE_OK or some error code) in rc. | ||
| 71947 | ** | ||
| 71948 | ** Implemented as macro to force inlining for performance. | ||
| 71949 | */ | ||
| 71950 | #define BTREE_CLEAR_CELL(rc, pPage, pCell, sInfo) \ | ||
| 71951 | pPage->xParseCell(pPage, pCell, &sInfo); \ | ||
| 71952 | if( sInfo.nLocal!=sInfo.nPayload ){ \ | ||
| 71953 | rc = clearCellOverflow(pPage, pCell, &sInfo); \ | ||
| 71954 | }else{ \ | ||
| 71955 | rc = SQLITE_OK; \ | ||
| 71956 | } | ||
| 71957 | |||
| 71958 | |||
| 71450 | /* | 71959 | /* |
| 71451 | ** Create the byte sequence used to represent a cell on page pPage | 71960 | ** Create the byte sequence used to represent a cell on page pPage |
| 71452 | ** and write that byte sequence into pCell[]. Overflow pages are | 71961 | ** and write that byte sequence into pCell[]. Overflow pages are |
| @@ -71969,7 +72478,7 @@ static int rebuildPage( | |||
| 71969 | u8 *pCell = pCArray->apCell[i]; | 72478 | u8 *pCell = pCArray->apCell[i]; |
| 71970 | u16 sz = pCArray->szCell[i]; | 72479 | u16 sz = pCArray->szCell[i]; |
| 71971 | assert( sz>0 ); | 72480 | assert( sz>0 ); |
| 71972 | if( SQLITE_WITHIN(pCell,aData,pEnd) ){ | 72481 | if( SQLITE_WITHIN(pCell,aData+j,pEnd) ){ |
| 71973 | if( ((uptr)(pCell+sz))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT; | 72482 | if( ((uptr)(pCell+sz))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT; |
| 71974 | pCell = &pTmp[pCell - aData]; | 72483 | pCell = &pTmp[pCell - aData]; |
| 71975 | }else if( (uptr)(pCell+sz)>(uptr)pSrcEnd | 72484 | }else if( (uptr)(pCell+sz)>(uptr)pSrcEnd |
| @@ -71982,9 +72491,8 @@ static int rebuildPage( | |||
| 71982 | put2byte(pCellptr, (pData - aData)); | 72491 | put2byte(pCellptr, (pData - aData)); |
| 71983 | pCellptr += 2; | 72492 | pCellptr += 2; |
| 71984 | if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT; | 72493 | if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT; |
| 71985 | memcpy(pData, pCell, sz); | 72494 | memmove(pData, pCell, sz); |
| 71986 | assert( sz==pPg->xCellSize(pPg, pCell) || CORRUPT_DB ); | 72495 | assert( sz==pPg->xCellSize(pPg, pCell) || CORRUPT_DB ); |
| 71987 | testcase( sz!=pPg->xCellSize(pPg,pCell) ) | ||
| 71988 | i++; | 72496 | i++; |
| 71989 | if( i>=iEnd ) break; | 72497 | if( i>=iEnd ) break; |
| 71990 | if( pCArray->ixNx[k]<=i ){ | 72498 | if( pCArray->ixNx[k]<=i ){ |
| @@ -72123,7 +72631,9 @@ static int pageFreeArray( | |||
| 72123 | } | 72631 | } |
| 72124 | pFree = pCell; | 72632 | pFree = pCell; |
| 72125 | szFree = sz; | 72633 | szFree = sz; |
| 72126 | if( pFree+sz>pEnd ) return 0; | 72634 | if( pFree+sz>pEnd ){ |
| 72635 | return 0; | ||
| 72636 | } | ||
| 72127 | }else{ | 72637 | }else{ |
| 72128 | pFree = pCell; | 72638 | pFree = pCell; |
| 72129 | szFree += sz; | 72639 | szFree += sz; |
| @@ -72776,7 +73286,7 @@ static int balance_nonroot( | |||
| 72776 | b.szCell[b.nCell] = b.szCell[b.nCell] - leafCorrection; | 73286 | b.szCell[b.nCell] = b.szCell[b.nCell] - leafCorrection; |
| 72777 | if( !pOld->leaf ){ | 73287 | if( !pOld->leaf ){ |
| 72778 | assert( leafCorrection==0 ); | 73288 | assert( leafCorrection==0 ); |
| 72779 | assert( pOld->hdrOffset==0 ); | 73289 | assert( pOld->hdrOffset==0 || CORRUPT_DB ); |
| 72780 | /* The right pointer of the child page pOld becomes the left | 73290 | /* The right pointer of the child page pOld becomes the left |
| 72781 | ** pointer of the divider cell */ | 73291 | ** pointer of the divider cell */ |
| 72782 | memcpy(b.apCell[b.nCell], &pOld->aData[8], 4); | 73292 | memcpy(b.apCell[b.nCell], &pOld->aData[8], 4); |
| @@ -73099,6 +73609,7 @@ static int balance_nonroot( | |||
| 73099 | u8 *pCell; | 73609 | u8 *pCell; |
| 73100 | u8 *pTemp; | 73610 | u8 *pTemp; |
| 73101 | int sz; | 73611 | int sz; |
| 73612 | u8 *pSrcEnd; | ||
| 73102 | MemPage *pNew = apNew[i]; | 73613 | MemPage *pNew = apNew[i]; |
| 73103 | j = cntNew[i]; | 73614 | j = cntNew[i]; |
| 73104 | 73615 | ||
| @@ -73142,6 +73653,12 @@ static int balance_nonroot( | |||
| 73142 | iOvflSpace += sz; | 73653 | iOvflSpace += sz; |
| 73143 | assert( sz<=pBt->maxLocal+23 ); | 73654 | assert( sz<=pBt->maxLocal+23 ); |
| 73144 | assert( iOvflSpace <= (int)pBt->pageSize ); | 73655 | assert( iOvflSpace <= (int)pBt->pageSize ); |
| 73656 | for(k=0; b.ixNx[k]<=i && ALWAYS(k<NB*2); k++){} | ||
| 73657 | pSrcEnd = b.apEnd[k]; | ||
| 73658 | if( SQLITE_WITHIN(pSrcEnd, pCell, pCell+sz) ){ | ||
| 73659 | rc = SQLITE_CORRUPT_BKPT; | ||
| 73660 | goto balance_cleanup; | ||
| 73661 | } | ||
| 73145 | insertCell(pParent, nxDiv+i, pCell, sz, pTemp, pNew->pgno, &rc); | 73662 | insertCell(pParent, nxDiv+i, pCell, sz, pTemp, pNew->pgno, &rc); |
| 73146 | if( rc!=SQLITE_OK ) goto balance_cleanup; | 73663 | if( rc!=SQLITE_OK ) goto balance_cleanup; |
| 73147 | assert( sqlite3PagerIswriteable(pParent->pDbPage) ); | 73664 | assert( sqlite3PagerIswriteable(pParent->pDbPage) ); |
| @@ -73684,13 +74201,23 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( | |||
| 73684 | if( pCur->curFlags & BTCF_Multiple ){ | 74201 | if( pCur->curFlags & BTCF_Multiple ){ |
| 73685 | rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur); | 74202 | rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur); |
| 73686 | if( rc ) return rc; | 74203 | if( rc ) return rc; |
| 74204 | if( loc && pCur->iPage<0 ){ | ||
| 74205 | /* This can only happen if the schema is corrupt such that there is more | ||
| 74206 | ** than one table or index with the same root page as used by the cursor. | ||
| 74207 | ** Which can only happen if the SQLITE_NoSchemaError flag was set when | ||
| 74208 | ** the schema was loaded. This cannot be asserted though, as a user might | ||
| 74209 | ** set the flag, load the schema, and then unset the flag. */ | ||
| 74210 | return SQLITE_CORRUPT_BKPT; | ||
| 74211 | } | ||
| 73687 | } | 74212 | } |
| 73688 | 74213 | ||
| 73689 | if( pCur->pKeyInfo==0 ){ | 74214 | if( pCur->pKeyInfo==0 ){ |
| 73690 | assert( pX->pKey==0 ); | 74215 | assert( pX->pKey==0 ); |
| 73691 | /* If this is an insert into a table b-tree, invalidate any incrblob | 74216 | /* If this is an insert into a table b-tree, invalidate any incrblob |
| 73692 | ** cursors open on the row being replaced */ | 74217 | ** cursors open on the row being replaced */ |
| 73693 | invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0); | 74218 | if( p->hasIncrblobCur ){ |
| 74219 | invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0); | ||
| 74220 | } | ||
| 73694 | 74221 | ||
| 73695 | /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing | 74222 | /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing |
| 73696 | ** to a row with the same key as the new entry being inserted. | 74223 | ** to a row with the same key as the new entry being inserted. |
| @@ -73771,7 +74298,6 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( | |||
| 73771 | return btreeOverwriteCell(pCur, &x2); | 74298 | return btreeOverwriteCell(pCur, &x2); |
| 73772 | } | 74299 | } |
| 73773 | } | 74300 | } |
| 73774 | |||
| 73775 | } | 74301 | } |
| 73776 | assert( pCur->eState==CURSOR_VALID | 74302 | assert( pCur->eState==CURSOR_VALID |
| 73777 | || (pCur->eState==CURSOR_INVALID && loc) | 74303 | || (pCur->eState==CURSOR_INVALID && loc) |
| @@ -73781,7 +74307,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( | |||
| 73781 | assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) ); | 74307 | assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) ); |
| 73782 | assert( pPage->leaf || !pPage->intKey ); | 74308 | assert( pPage->leaf || !pPage->intKey ); |
| 73783 | if( pPage->nFree<0 ){ | 74309 | if( pPage->nFree<0 ){ |
| 73784 | if( pCur->eState>CURSOR_INVALID ){ | 74310 | if( NEVER(pCur->eState>CURSOR_INVALID) ){ |
| 73785 | rc = SQLITE_CORRUPT_BKPT; | 74311 | rc = SQLITE_CORRUPT_BKPT; |
| 73786 | }else{ | 74312 | }else{ |
| 73787 | rc = btreeComputeFreeSpace(pPage); | 74313 | rc = btreeComputeFreeSpace(pPage); |
| @@ -73825,7 +74351,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( | |||
| 73825 | if( !pPage->leaf ){ | 74351 | if( !pPage->leaf ){ |
| 73826 | memcpy(newCell, oldCell, 4); | 74352 | memcpy(newCell, oldCell, 4); |
| 73827 | } | 74353 | } |
| 73828 | rc = clearCell(pPage, oldCell, &info); | 74354 | BTREE_CLEAR_CELL(rc, pPage, oldCell, info); |
| 73829 | testcase( pCur->curFlags & BTCF_ValidOvfl ); | 74355 | testcase( pCur->curFlags & BTCF_ValidOvfl ); |
| 73830 | invalidateOverflowCache(pCur); | 74356 | invalidateOverflowCache(pCur); |
| 73831 | if( info.nSize==szNew && info.nLocal==info.nPayload | 74357 | if( info.nSize==szNew && info.nLocal==info.nPayload |
| @@ -74062,9 +74588,10 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){ | |||
| 74062 | assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 ); | 74588 | assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 ); |
| 74063 | if( pCur->eState==CURSOR_REQUIRESEEK ){ | 74589 | if( pCur->eState==CURSOR_REQUIRESEEK ){ |
| 74064 | rc = btreeRestoreCursorPosition(pCur); | 74590 | rc = btreeRestoreCursorPosition(pCur); |
| 74065 | if( rc ) return rc; | 74591 | assert( rc!=SQLITE_OK || CORRUPT_DB || pCur->eState==CURSOR_VALID ); |
| 74592 | if( rc || pCur->eState!=CURSOR_VALID ) return rc; | ||
| 74066 | } | 74593 | } |
| 74067 | assert( pCur->eState==CURSOR_VALID ); | 74594 | assert( CORRUPT_DB || pCur->eState==CURSOR_VALID ); |
| 74068 | 74595 | ||
| 74069 | iCellDepth = pCur->iPage; | 74596 | iCellDepth = pCur->iPage; |
| 74070 | iCellIdx = pCur->ix; | 74597 | iCellIdx = pCur->ix; |
| @@ -74117,7 +74644,7 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){ | |||
| 74117 | 74644 | ||
| 74118 | /* If this is a delete operation to remove a row from a table b-tree, | 74645 | /* If this is a delete operation to remove a row from a table b-tree, |
| 74119 | ** invalidate any incrblob cursors open on the row being deleted. */ | 74646 | ** invalidate any incrblob cursors open on the row being deleted. */ |
| 74120 | if( pCur->pKeyInfo==0 ){ | 74647 | if( pCur->pKeyInfo==0 && p->hasIncrblobCur ){ |
| 74121 | invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0); | 74648 | invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0); |
| 74122 | } | 74649 | } |
| 74123 | 74650 | ||
| @@ -74126,7 +74653,7 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){ | |||
| 74126 | ** itself from within the page. */ | 74653 | ** itself from within the page. */ |
| 74127 | rc = sqlite3PagerWrite(pPage->pDbPage); | 74654 | rc = sqlite3PagerWrite(pPage->pDbPage); |
| 74128 | if( rc ) return rc; | 74655 | if( rc ) return rc; |
| 74129 | rc = clearCell(pPage, pCell, &info); | 74656 | BTREE_CLEAR_CELL(rc, pPage, pCell, info); |
| 74130 | dropCell(pPage, iCellIdx, info.nSize, &rc); | 74657 | dropCell(pPage, iCellIdx, info.nSize, &rc); |
| 74131 | if( rc ) return rc; | 74658 | if( rc ) return rc; |
| 74132 | 74659 | ||
| @@ -74413,14 +74940,14 @@ static int clearDatabasePage( | |||
| 74413 | rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange); | 74940 | rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange); |
| 74414 | if( rc ) goto cleardatabasepage_out; | 74941 | if( rc ) goto cleardatabasepage_out; |
| 74415 | } | 74942 | } |
| 74416 | rc = clearCell(pPage, pCell, &info); | 74943 | BTREE_CLEAR_CELL(rc, pPage, pCell, info); |
| 74417 | if( rc ) goto cleardatabasepage_out; | 74944 | if( rc ) goto cleardatabasepage_out; |
| 74418 | } | 74945 | } |
| 74419 | if( !pPage->leaf ){ | 74946 | if( !pPage->leaf ){ |
| 74420 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); | 74947 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); |
| 74421 | if( rc ) goto cleardatabasepage_out; | 74948 | if( rc ) goto cleardatabasepage_out; |
| 74422 | }else if( pnChange ){ | 74949 | } |
| 74423 | assert( pPage->intKey || CORRUPT_DB ); | 74950 | if( pnChange ){ |
| 74424 | testcase( !pPage->intKey ); | 74951 | testcase( !pPage->intKey ); |
| 74425 | *pnChange += pPage->nCell; | 74952 | *pnChange += pPage->nCell; |
| 74426 | } | 74953 | } |
| @@ -74445,9 +74972,8 @@ cleardatabasepage_out: | |||
| 74445 | ** read cursors on the table. Open write cursors are moved to the | 74972 | ** read cursors on the table. Open write cursors are moved to the |
| 74446 | ** root of the table. | 74973 | ** root of the table. |
| 74447 | ** | 74974 | ** |
| 74448 | ** If pnChange is not NULL, then table iTable must be an intkey table. The | 74975 | ** If pnChange is not NULL, then the integer value pointed to by pnChange |
| 74449 | ** integer value pointed to by pnChange is incremented by the number of | 74976 | ** is incremented by the number of entries in the table. |
| 74450 | ** entries in the table. | ||
| 74451 | */ | 74977 | */ |
| 74452 | SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){ | 74978 | SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){ |
| 74453 | int rc; | 74979 | int rc; |
| @@ -74461,7 +74987,9 @@ SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){ | |||
| 74461 | /* Invalidate all incrblob cursors open on table iTable (assuming iTable | 74987 | /* Invalidate all incrblob cursors open on table iTable (assuming iTable |
| 74462 | ** is the root of a table b-tree - if it is not, the following call is | 74988 | ** is the root of a table b-tree - if it is not, the following call is |
| 74463 | ** a no-op). */ | 74989 | ** a no-op). */ |
| 74464 | invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1); | 74990 | if( p->hasIncrblobCur ){ |
| 74991 | invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1); | ||
| 74992 | } | ||
| 74465 | rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange); | 74993 | rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange); |
| 74466 | } | 74994 | } |
| 74467 | sqlite3BtreeLeave(p); | 74995 | sqlite3BtreeLeave(p); |
| @@ -76544,7 +77072,9 @@ SQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem *p){ | |||
| 76544 | 77072 | ||
| 76545 | /* The szMalloc field holds the correct memory allocation size */ | 77073 | /* The szMalloc field holds the correct memory allocation size */ |
| 76546 | assert( p->szMalloc==0 | 77074 | assert( p->szMalloc==0 |
| 76547 | || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) ); | 77075 | || (p->flags==MEM_Undefined |
| 77076 | && p->szMalloc<=sqlite3DbMallocSize(p->db,p->zMalloc)) | ||
| 77077 | || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc)); | ||
| 76548 | 77078 | ||
| 76549 | /* If p holds a string or blob, the Mem.z must point to exactly | 77079 | /* If p holds a string or blob, the Mem.z must point to exactly |
| 76550 | ** one of the following: | 77080 | ** one of the following: |
| @@ -76708,7 +77238,9 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPre | |||
| 76708 | testcase( bPreserve && pMem->z==0 ); | 77238 | testcase( bPreserve && pMem->z==0 ); |
| 76709 | 77239 | ||
| 76710 | assert( pMem->szMalloc==0 | 77240 | assert( pMem->szMalloc==0 |
| 76711 | || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) ); | 77241 | || (pMem->flags==MEM_Undefined |
| 77242 | && pMem->szMalloc<=sqlite3DbMallocSize(pMem->db,pMem->zMalloc)) | ||
| 77243 | || pMem->szMalloc==sqlite3DbMallocSize(pMem->db,pMem->zMalloc)); | ||
| 76712 | if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){ | 77244 | if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){ |
| 76713 | if( pMem->db ){ | 77245 | if( pMem->db ){ |
| 76714 | pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); | 77246 | pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); |
| @@ -77537,11 +78069,11 @@ SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem *pTo, Mem *pFrom){ | |||
| 77537 | SQLITE_PRIVATE int sqlite3VdbeMemSetStr( | 78069 | SQLITE_PRIVATE int sqlite3VdbeMemSetStr( |
| 77538 | Mem *pMem, /* Memory cell to set to string value */ | 78070 | Mem *pMem, /* Memory cell to set to string value */ |
| 77539 | const char *z, /* String pointer */ | 78071 | const char *z, /* String pointer */ |
| 77540 | int n, /* Bytes in string, or negative */ | 78072 | i64 n, /* Bytes in string, or negative */ |
| 77541 | u8 enc, /* Encoding of z. 0 for BLOBs */ | 78073 | u8 enc, /* Encoding of z. 0 for BLOBs */ |
| 77542 | void (*xDel)(void*) /* Destructor function */ | 78074 | void (*xDel)(void*) /* Destructor function */ |
| 77543 | ){ | 78075 | ){ |
| 77544 | int nByte = n; /* New value for pMem->n */ | 78076 | i64 nByte = n; /* New value for pMem->n */ |
| 77545 | int iLimit; /* Maximum allowed string or blob size */ | 78077 | int iLimit; /* Maximum allowed string or blob size */ |
| 77546 | u16 flags = 0; /* New value for pMem->flags */ | 78078 | u16 flags = 0; /* New value for pMem->flags */ |
| 77547 | 78079 | ||
| @@ -77563,7 +78095,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemSetStr( | |||
| 77563 | if( nByte<0 ){ | 78095 | if( nByte<0 ){ |
| 77564 | assert( enc!=0 ); | 78096 | assert( enc!=0 ); |
| 77565 | if( enc==SQLITE_UTF8 ){ | 78097 | if( enc==SQLITE_UTF8 ){ |
| 77566 | nByte = 0x7fffffff & (int)strlen(z); | 78098 | nByte = strlen(z); |
| 77567 | }else{ | 78099 | }else{ |
| 77568 | for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){} | 78100 | for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){} |
| 77569 | } | 78101 | } |
| @@ -77575,7 +78107,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemSetStr( | |||
| 77575 | ** management (one of MEM_Dyn or MEM_Static). | 78107 | ** management (one of MEM_Dyn or MEM_Static). |
| 77576 | */ | 78108 | */ |
| 77577 | if( xDel==SQLITE_TRANSIENT ){ | 78109 | if( xDel==SQLITE_TRANSIENT ){ |
| 77578 | u32 nAlloc = nByte; | 78110 | i64 nAlloc = nByte; |
| 77579 | if( flags&MEM_Term ){ | 78111 | if( flags&MEM_Term ){ |
| 77580 | nAlloc += (enc==SQLITE_UTF8?1:2); | 78112 | nAlloc += (enc==SQLITE_UTF8?1:2); |
| 77581 | } | 78113 | } |
| @@ -77601,7 +78133,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemSetStr( | |||
| 77601 | } | 78133 | } |
| 77602 | } | 78134 | } |
| 77603 | 78135 | ||
| 77604 | pMem->n = nByte; | 78136 | pMem->n = (int)(nByte & 0x7fffffff); |
| 77605 | pMem->flags = flags; | 78137 | pMem->flags = flags; |
| 77606 | if( enc ){ | 78138 | if( enc ){ |
| 77607 | pMem->enc = enc; | 78139 | pMem->enc = enc; |
| @@ -77621,7 +78153,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemSetStr( | |||
| 77621 | #endif | 78153 | #endif |
| 77622 | 78154 | ||
| 77623 | if( nByte>iLimit ){ | 78155 | if( nByte>iLimit ){ |
| 77624 | return SQLITE_TOOBIG; | 78156 | return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG); |
| 77625 | } | 78157 | } |
| 77626 | 78158 | ||
| 77627 | return SQLITE_OK; | 78159 | return SQLITE_OK; |
| @@ -79864,11 +80396,7 @@ SQLITE_PRIVATE char *sqlite3VdbeDisplayComment( | |||
| 79864 | char c; | 80396 | char c; |
| 79865 | zSynopsis = zOpName += nOpName + 1; | 80397 | zSynopsis = zOpName += nOpName + 1; |
| 79866 | if( strncmp(zSynopsis,"IF ",3)==0 ){ | 80398 | if( strncmp(zSynopsis,"IF ",3)==0 ){ |
| 79867 | if( pOp->p5 & SQLITE_STOREP2 ){ | 80399 | sqlite3_snprintf(sizeof(zAlt), zAlt, "if %s goto P2", zSynopsis+3); |
| 79868 | sqlite3_snprintf(sizeof(zAlt), zAlt, "r[P2] = (%s)", zSynopsis+3); | ||
| 79869 | }else{ | ||
| 79870 | sqlite3_snprintf(sizeof(zAlt), zAlt, "if %s goto P2", zSynopsis+3); | ||
| 79871 | } | ||
| 79872 | zSynopsis = zAlt; | 80400 | zSynopsis = zAlt; |
| 79873 | } | 80401 | } |
| 79874 | for(ii=0; (c = zSynopsis[ii])!=0; ii++){ | 80402 | for(ii=0; (c = zSynopsis[ii])!=0; ii++){ |
| @@ -83570,7 +84098,8 @@ SQLITE_PRIVATE void sqlite3VdbePreUpdateHook( | |||
| 83570 | const char *zDb, /* Database name */ | 84098 | const char *zDb, /* Database name */ |
| 83571 | Table *pTab, /* Modified table */ | 84099 | Table *pTab, /* Modified table */ |
| 83572 | i64 iKey1, /* Initial key value */ | 84100 | i64 iKey1, /* Initial key value */ |
| 83573 | int iReg /* Register for new.* record */ | 84101 | int iReg, /* Register for new.* record */ |
| 84102 | int iBlobWrite | ||
| 83574 | ){ | 84103 | ){ |
| 83575 | sqlite3 *db = v->db; | 84104 | sqlite3 *db = v->db; |
| 83576 | i64 iKey2; | 84105 | i64 iKey2; |
| @@ -83606,6 +84135,7 @@ SQLITE_PRIVATE void sqlite3VdbePreUpdateHook( | |||
| 83606 | preupdate.iKey1 = iKey1; | 84135 | preupdate.iKey1 = iKey1; |
| 83607 | preupdate.iKey2 = iKey2; | 84136 | preupdate.iKey2 = iKey2; |
| 83608 | preupdate.pTab = pTab; | 84137 | preupdate.pTab = pTab; |
| 84138 | preupdate.iBlobWrite = iBlobWrite; | ||
| 83609 | 84139 | ||
| 83610 | db->pPreUpdate = &preupdate; | 84140 | db->pPreUpdate = &preupdate; |
| 83611 | db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2); | 84141 | db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2); |
| @@ -84019,7 +84549,7 @@ static int invokeValueDestructor( | |||
| 84019 | }else{ | 84549 | }else{ |
| 84020 | xDel((void*)p); | 84550 | xDel((void*)p); |
| 84021 | } | 84551 | } |
| 84022 | if( pCtx ) sqlite3_result_error_toobig(pCtx); | 84552 | sqlite3_result_error_toobig(pCtx); |
| 84023 | return SQLITE_TOOBIG; | 84553 | return SQLITE_TOOBIG; |
| 84024 | } | 84554 | } |
| 84025 | SQLITE_API void sqlite3_result_blob( | 84555 | SQLITE_API void sqlite3_result_blob( |
| @@ -85001,7 +85531,7 @@ static int bindText( | |||
| 85001 | sqlite3_stmt *pStmt, /* The statement to bind against */ | 85531 | sqlite3_stmt *pStmt, /* The statement to bind against */ |
| 85002 | int i, /* Index of the parameter to bind */ | 85532 | int i, /* Index of the parameter to bind */ |
| 85003 | const void *zData, /* Pointer to the data to be bound */ | 85533 | const void *zData, /* Pointer to the data to be bound */ |
| 85004 | int nData, /* Number of bytes of data to be bound */ | 85534 | i64 nData, /* Number of bytes of data to be bound */ |
| 85005 | void (*xDel)(void*), /* Destructor for the data */ | 85535 | void (*xDel)(void*), /* Destructor for the data */ |
| 85006 | u8 encoding /* Encoding for the data */ | 85536 | u8 encoding /* Encoding for the data */ |
| 85007 | ){ | 85537 | ){ |
| @@ -85053,11 +85583,7 @@ SQLITE_API int sqlite3_bind_blob64( | |||
| 85053 | void (*xDel)(void*) | 85583 | void (*xDel)(void*) |
| 85054 | ){ | 85584 | ){ |
| 85055 | assert( xDel!=SQLITE_DYNAMIC ); | 85585 | assert( xDel!=SQLITE_DYNAMIC ); |
| 85056 | if( nData>0x7fffffff ){ | 85586 | return bindText(pStmt, i, zData, nData, xDel, 0); |
| 85057 | return invokeValueDestructor(zData, xDel, 0); | ||
| 85058 | }else{ | ||
| 85059 | return bindText(pStmt, i, zData, (int)nData, xDel, 0); | ||
| 85060 | } | ||
| 85061 | } | 85587 | } |
| 85062 | SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){ | 85588 | SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){ |
| 85063 | int rc; | 85589 | int rc; |
| @@ -85127,12 +85653,8 @@ SQLITE_API int sqlite3_bind_text64( | |||
| 85127 | unsigned char enc | 85653 | unsigned char enc |
| 85128 | ){ | 85654 | ){ |
| 85129 | assert( xDel!=SQLITE_DYNAMIC ); | 85655 | assert( xDel!=SQLITE_DYNAMIC ); |
| 85130 | if( nData>0x7fffffff ){ | 85656 | if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE; |
| 85131 | return invokeValueDestructor(zData, xDel, 0); | 85657 | return bindText(pStmt, i, zData, nData, xDel, enc); |
| 85132 | }else{ | ||
| 85133 | if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE; | ||
| 85134 | return bindText(pStmt, i, zData, (int)nData, xDel, enc); | ||
| 85135 | } | ||
| 85136 | } | 85658 | } |
| 85137 | #ifndef SQLITE_OMIT_UTF16 | 85659 | #ifndef SQLITE_OMIT_UTF16 |
| 85138 | SQLITE_API int sqlite3_bind_text16( | 85660 | SQLITE_API int sqlite3_bind_text16( |
| @@ -85534,6 +86056,17 @@ SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){ | |||
| 85534 | 86056 | ||
| 85535 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK | 86057 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 85536 | /* | 86058 | /* |
| 86059 | ** This function is designed to be called from within a pre-update callback | ||
| 86060 | ** only. | ||
| 86061 | */ | ||
| 86062 | SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){ | ||
| 86063 | PreUpdate *p = db->pPreUpdate; | ||
| 86064 | return (p ? p->iBlobWrite : -1); | ||
| 86065 | } | ||
| 86066 | #endif | ||
| 86067 | |||
| 86068 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK | ||
| 86069 | /* | ||
| 85537 | ** This function is called from within a pre-update callback to retrieve | 86070 | ** This function is called from within a pre-update callback to retrieve |
| 85538 | ** a field of the row currently being updated or inserted. | 86071 | ** a field of the row currently being updated or inserted. |
| 85539 | */ | 86072 | */ |
| @@ -86153,18 +86686,36 @@ static VdbeCursor *allocateCursor( | |||
| 86153 | sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); | 86686 | sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); |
| 86154 | p->apCsr[iCur] = 0; | 86687 | p->apCsr[iCur] = 0; |
| 86155 | } | 86688 | } |
| 86156 | if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){ | 86689 | |
| 86157 | p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z; | 86690 | /* There used to be a call to sqlite3VdbeMemClearAndResize() to make sure |
| 86158 | memset(pCx, 0, offsetof(VdbeCursor,pAltCursor)); | 86691 | ** the pMem used to hold space for the cursor has enough storage available |
| 86159 | pCx->eCurType = eCurType; | 86692 | ** in pMem->zMalloc. But for the special case of the aMem[] entries used |
| 86160 | pCx->iDb = iDb; | 86693 | ** to hold cursors, it is faster to in-line the logic. */ |
| 86161 | pCx->nField = nField; | 86694 | assert( pMem->flags==MEM_Undefined ); |
| 86162 | pCx->aOffset = &pCx->aType[nField]; | 86695 | assert( (pMem->flags & MEM_Dyn)==0 ); |
| 86163 | if( eCurType==CURTYPE_BTREE ){ | 86696 | assert( pMem->szMalloc==0 || pMem->z==pMem->zMalloc ); |
| 86164 | pCx->uc.pCursor = (BtCursor*) | 86697 | if( pMem->szMalloc<nByte ){ |
| 86165 | &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField]; | 86698 | if( pMem->szMalloc>0 ){ |
| 86166 | sqlite3BtreeCursorZero(pCx->uc.pCursor); | 86699 | sqlite3DbFreeNN(pMem->db, pMem->zMalloc); |
| 86700 | } | ||
| 86701 | pMem->z = pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, nByte); | ||
| 86702 | if( pMem->zMalloc==0 ){ | ||
| 86703 | pMem->szMalloc = 0; | ||
| 86704 | return 0; | ||
| 86167 | } | 86705 | } |
| 86706 | pMem->szMalloc = nByte; | ||
| 86707 | } | ||
| 86708 | |||
| 86709 | p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc; | ||
| 86710 | memset(pCx, 0, offsetof(VdbeCursor,pAltCursor)); | ||
| 86711 | pCx->eCurType = eCurType; | ||
| 86712 | pCx->iDb = iDb; | ||
| 86713 | pCx->nField = nField; | ||
| 86714 | pCx->aOffset = &pCx->aType[nField]; | ||
| 86715 | if( eCurType==CURTYPE_BTREE ){ | ||
| 86716 | pCx->uc.pCursor = (BtCursor*) | ||
| 86717 | &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField]; | ||
| 86718 | sqlite3BtreeCursorZero(pCx->uc.pCursor); | ||
| 86168 | } | 86719 | } |
| 86169 | return pCx; | 86720 | return pCx; |
| 86170 | } | 86721 | } |
| @@ -86311,7 +86862,10 @@ static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){ | |||
| 86311 | sqlite3_int64 ix; | 86862 | sqlite3_int64 ix; |
| 86312 | assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal))==0 ); | 86863 | assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal))==0 ); |
| 86313 | assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ); | 86864 | assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ); |
| 86314 | ExpandBlob(pMem); | 86865 | if( ExpandBlob(pMem) ){ |
| 86866 | pMem->u.i = 0; | ||
| 86867 | return MEM_Int; | ||
| 86868 | } | ||
| 86315 | rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc); | 86869 | rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc); |
| 86316 | if( rc<=0 ){ | 86870 | if( rc<=0 ){ |
| 86317 | if( rc==0 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1 ){ | 86871 | if( rc==0 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1 ){ |
| @@ -86449,6 +87003,11 @@ static void registerTrace(int iReg, Mem *p){ | |||
| 86449 | printf("\n"); | 87003 | printf("\n"); |
| 86450 | sqlite3VdbeCheckMemInvariants(p); | 87004 | sqlite3VdbeCheckMemInvariants(p); |
| 86451 | } | 87005 | } |
| 87006 | /**/ void sqlite3PrintMem(Mem *pMem){ | ||
| 87007 | memTracePrint(pMem); | ||
| 87008 | printf("\n"); | ||
| 87009 | fflush(stdout); | ||
| 87010 | } | ||
| 86452 | #endif | 87011 | #endif |
| 86453 | 87012 | ||
| 86454 | #ifdef SQLITE_DEBUG | 87013 | #ifdef SQLITE_DEBUG |
| @@ -87440,7 +87999,7 @@ case OP_ResultRow: { | |||
| 87440 | Mem *pMem; | 87999 | Mem *pMem; |
| 87441 | int i; | 88000 | int i; |
| 87442 | assert( p->nResColumn==pOp->p2 ); | 88001 | assert( p->nResColumn==pOp->p2 ); |
| 87443 | assert( pOp->p1>0 ); | 88002 | assert( pOp->p1>0 || CORRUPT_DB ); |
| 87444 | assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 ); | 88003 | assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 ); |
| 87445 | 88004 | ||
| 87446 | /* Invalidate all ephemeral cursor row caches */ | 88005 | /* Invalidate all ephemeral cursor row caches */ |
| @@ -87882,8 +88441,7 @@ case OP_Cast: { /* in1 */ | |||
| 87882 | ** Synopsis: IF r[P3]==r[P1] | 88441 | ** Synopsis: IF r[P3]==r[P1] |
| 87883 | ** | 88442 | ** |
| 87884 | ** Compare the values in register P1 and P3. If reg(P3)==reg(P1) then | 88443 | ** Compare the values in register P1 and P3. If reg(P3)==reg(P1) then |
| 87885 | ** jump to address P2. Or if the SQLITE_STOREP2 flag is set in P5, then | 88444 | ** jump to address P2. |
| 87886 | ** store the result of comparison in register P2. | ||
| 87887 | ** | 88445 | ** |
| 87888 | ** The SQLITE_AFF_MASK portion of P5 must be an affinity character - | 88446 | ** The SQLITE_AFF_MASK portion of P5 must be an affinity character - |
| 87889 | ** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made | 88447 | ** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made |
| @@ -87909,9 +88467,8 @@ case OP_Cast: { /* in1 */ | |||
| 87909 | ** If neither operand is NULL the result is the same as it would be if | 88467 | ** If neither operand is NULL the result is the same as it would be if |
| 87910 | ** the SQLITE_NULLEQ flag were omitted from P5. | 88468 | ** the SQLITE_NULLEQ flag were omitted from P5. |
| 87911 | ** | 88469 | ** |
| 87912 | ** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the | 88470 | ** This opcode saves the result of comparison for use by the new |
| 87913 | ** content of r[P2] is only changed if the new value is NULL or 0 (false). | 88471 | ** OP_Jump opcode. |
| 87914 | ** In other words, a prior r[P2] value will not be overwritten by 1 (true). | ||
| 87915 | */ | 88472 | */ |
| 87916 | /* Opcode: Ne P1 P2 P3 P4 P5 | 88473 | /* Opcode: Ne P1 P2 P3 P4 P5 |
| 87917 | ** Synopsis: IF r[P3]!=r[P1] | 88474 | ** Synopsis: IF r[P3]!=r[P1] |
| @@ -87919,17 +88476,12 @@ case OP_Cast: { /* in1 */ | |||
| 87919 | ** This works just like the Eq opcode except that the jump is taken if | 88476 | ** This works just like the Eq opcode except that the jump is taken if |
| 87920 | ** the operands in registers P1 and P3 are not equal. See the Eq opcode for | 88477 | ** the operands in registers P1 and P3 are not equal. See the Eq opcode for |
| 87921 | ** additional information. | 88478 | ** additional information. |
| 87922 | ** | ||
| 87923 | ** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the | ||
| 87924 | ** content of r[P2] is only changed if the new value is NULL or 1 (true). | ||
| 87925 | ** In other words, a prior r[P2] value will not be overwritten by 0 (false). | ||
| 87926 | */ | 88479 | */ |
| 87927 | /* Opcode: Lt P1 P2 P3 P4 P5 | 88480 | /* Opcode: Lt P1 P2 P3 P4 P5 |
| 87928 | ** Synopsis: IF r[P3]<r[P1] | 88481 | ** Synopsis: IF r[P3]<r[P1] |
| 87929 | ** | 88482 | ** |
| 87930 | ** Compare the values in register P1 and P3. If reg(P3)<reg(P1) then | 88483 | ** Compare the values in register P1 and P3. If reg(P3)<reg(P1) then |
| 87931 | ** jump to address P2. Or if the SQLITE_STOREP2 flag is set in P5 store | 88484 | ** jump to address P2. |
| 87932 | ** the result of comparison (0 or 1 or NULL) into register P2. | ||
| 87933 | ** | 88485 | ** |
| 87934 | ** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or | 88486 | ** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or |
| 87935 | ** reg(P3) is NULL then the take the jump. If the SQLITE_JUMPIFNULL | 88487 | ** reg(P3) is NULL then the take the jump. If the SQLITE_JUMPIFNULL |
| @@ -87952,6 +88504,9 @@ case OP_Cast: { /* in1 */ | |||
| 87952 | ** numeric, then a numeric comparison is used. If the two values | 88504 | ** numeric, then a numeric comparison is used. If the two values |
| 87953 | ** are of different types, then numbers are considered less than | 88505 | ** are of different types, then numbers are considered less than |
| 87954 | ** strings and strings are considered less than blobs. | 88506 | ** strings and strings are considered less than blobs. |
| 88507 | ** | ||
| 88508 | ** This opcode saves the result of comparison for use by the new | ||
| 88509 | ** OP_Jump opcode. | ||
| 87955 | */ | 88510 | */ |
| 87956 | /* Opcode: Le P1 P2 P3 P4 P5 | 88511 | /* Opcode: Le P1 P2 P3 P4 P5 |
| 87957 | ** Synopsis: IF r[P3]<=r[P1] | 88512 | ** Synopsis: IF r[P3]<=r[P1] |
| @@ -87989,6 +88544,31 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ | |||
| 87989 | pIn3 = &aMem[pOp->p3]; | 88544 | pIn3 = &aMem[pOp->p3]; |
| 87990 | flags1 = pIn1->flags; | 88545 | flags1 = pIn1->flags; |
| 87991 | flags3 = pIn3->flags; | 88546 | flags3 = pIn3->flags; |
| 88547 | if( (flags1 & flags3 & MEM_Int)!=0 ){ | ||
| 88548 | assert( (pOp->p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_TEXT || CORRUPT_DB ); | ||
| 88549 | /* Common case of comparison of two integers */ | ||
| 88550 | if( pIn3->u.i > pIn1->u.i ){ | ||
| 88551 | iCompare = +1; | ||
| 88552 | if( sqlite3aGTb[pOp->opcode] ){ | ||
| 88553 | VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); | ||
| 88554 | goto jump_to_p2; | ||
| 88555 | } | ||
| 88556 | }else if( pIn3->u.i < pIn1->u.i ){ | ||
| 88557 | iCompare = -1; | ||
| 88558 | if( sqlite3aLTb[pOp->opcode] ){ | ||
| 88559 | VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); | ||
| 88560 | goto jump_to_p2; | ||
| 88561 | } | ||
| 88562 | }else{ | ||
| 88563 | iCompare = 0; | ||
| 88564 | if( sqlite3aEQb[pOp->opcode] ){ | ||
| 88565 | VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); | ||
| 88566 | goto jump_to_p2; | ||
| 88567 | } | ||
| 88568 | } | ||
| 88569 | VdbeBranchTaken(0, (pOp->p5 & SQLITE_NULLEQ)?2:3); | ||
| 88570 | break; | ||
| 88571 | } | ||
| 87992 | if( (flags1 | flags3)&MEM_Null ){ | 88572 | if( (flags1 | flags3)&MEM_Null ){ |
| 87993 | /* One or both operands are NULL */ | 88573 | /* One or both operands are NULL */ |
| 87994 | if( pOp->p5 & SQLITE_NULLEQ ){ | 88574 | if( pOp->p5 & SQLITE_NULLEQ ){ |
| @@ -88011,22 +88591,16 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ | |||
| 88011 | ** then the result is always NULL. | 88591 | ** then the result is always NULL. |
| 88012 | ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. | 88592 | ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. |
| 88013 | */ | 88593 | */ |
| 88014 | if( pOp->p5 & SQLITE_STOREP2 ){ | 88594 | iCompare = 1; /* Operands are not equal */ |
| 88015 | pOut = &aMem[pOp->p2]; | 88595 | VdbeBranchTaken(2,3); |
| 88016 | iCompare = 1; /* Operands are not equal */ | 88596 | if( pOp->p5 & SQLITE_JUMPIFNULL ){ |
| 88017 | memAboutToChange(p, pOut); | 88597 | goto jump_to_p2; |
| 88018 | MemSetTypeFlag(pOut, MEM_Null); | ||
| 88019 | REGISTER_TRACE(pOp->p2, pOut); | ||
| 88020 | }else{ | ||
| 88021 | VdbeBranchTaken(2,3); | ||
| 88022 | if( pOp->p5 & SQLITE_JUMPIFNULL ){ | ||
| 88023 | goto jump_to_p2; | ||
| 88024 | } | ||
| 88025 | } | 88598 | } |
| 88026 | break; | 88599 | break; |
| 88027 | } | 88600 | } |
| 88028 | }else{ | 88601 | }else{ |
| 88029 | /* Neither operand is NULL. Do a comparison. */ | 88602 | /* Neither operand is NULL and we couldn't do the special high-speed |
| 88603 | ** integer comparison case. So do a general-case comparison. */ | ||
| 88030 | affinity = pOp->p5 & SQLITE_AFF_MASK; | 88604 | affinity = pOp->p5 & SQLITE_AFF_MASK; |
| 88031 | if( affinity>=SQLITE_AFF_NUMERIC ){ | 88605 | if( affinity>=SQLITE_AFF_NUMERIC ){ |
| 88032 | if( (flags1 | flags3)&MEM_Str ){ | 88606 | if( (flags1 | flags3)&MEM_Str ){ |
| @@ -88039,14 +88613,6 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ | |||
| 88039 | applyNumericAffinity(pIn3,0); | 88613 | applyNumericAffinity(pIn3,0); |
| 88040 | } | 88614 | } |
| 88041 | } | 88615 | } |
| 88042 | /* Handle the common case of integer comparison here, as an | ||
| 88043 | ** optimization, to avoid a call to sqlite3MemCompare() */ | ||
| 88044 | if( (pIn1->flags & pIn3->flags & MEM_Int)!=0 ){ | ||
| 88045 | if( pIn3->u.i > pIn1->u.i ){ res = +1; goto compare_op; } | ||
| 88046 | if( pIn3->u.i < pIn1->u.i ){ res = -1; goto compare_op; } | ||
| 88047 | res = 0; | ||
| 88048 | goto compare_op; | ||
| 88049 | } | ||
| 88050 | }else if( affinity==SQLITE_AFF_TEXT ){ | 88616 | }else if( affinity==SQLITE_AFF_TEXT ){ |
| 88051 | if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ | 88617 | if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ |
| 88052 | testcase( pIn1->flags & MEM_Int ); | 88618 | testcase( pIn1->flags & MEM_Int ); |
| @@ -88069,7 +88635,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ | |||
| 88069 | assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); | 88635 | assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); |
| 88070 | res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl); | 88636 | res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl); |
| 88071 | } | 88637 | } |
| 88072 | compare_op: | 88638 | |
| 88073 | /* At this point, res is negative, zero, or positive if reg[P1] is | 88639 | /* At this point, res is negative, zero, or positive if reg[P1] is |
| 88074 | ** less than, equal to, or greater than reg[P3], respectively. Compute | 88640 | ** less than, equal to, or greater than reg[P3], respectively. Compute |
| 88075 | ** the answer to this operator in res2, depending on what the comparison | 88641 | ** the answer to this operator in res2, depending on what the comparison |
| @@ -88078,16 +88644,14 @@ compare_op: | |||
| 88078 | ** order: NE, EQ, GT, LE, LT, GE */ | 88644 | ** order: NE, EQ, GT, LE, LT, GE */ |
| 88079 | assert( OP_Eq==OP_Ne+1 ); assert( OP_Gt==OP_Ne+2 ); assert( OP_Le==OP_Ne+3 ); | 88645 | assert( OP_Eq==OP_Ne+1 ); assert( OP_Gt==OP_Ne+2 ); assert( OP_Le==OP_Ne+3 ); |
| 88080 | assert( OP_Lt==OP_Ne+4 ); assert( OP_Ge==OP_Ne+5 ); | 88646 | assert( OP_Lt==OP_Ne+4 ); assert( OP_Ge==OP_Ne+5 ); |
| 88081 | if( res<0 ){ /* ne, eq, gt, le, lt, ge */ | 88647 | if( res<0 ){ |
| 88082 | static const unsigned char aLTb[] = { 1, 0, 0, 1, 1, 0 }; | 88648 | res2 = sqlite3aLTb[pOp->opcode]; |
| 88083 | res2 = aLTb[pOp->opcode - OP_Ne]; | ||
| 88084 | }else if( res==0 ){ | 88649 | }else if( res==0 ){ |
| 88085 | static const unsigned char aEQb[] = { 0, 1, 0, 1, 0, 1 }; | 88650 | res2 = sqlite3aEQb[pOp->opcode]; |
| 88086 | res2 = aEQb[pOp->opcode - OP_Ne]; | ||
| 88087 | }else{ | 88651 | }else{ |
| 88088 | static const unsigned char aGTb[] = { 1, 0, 1, 0, 0, 1 }; | 88652 | res2 = sqlite3aGTb[pOp->opcode]; |
| 88089 | res2 = aGTb[pOp->opcode - OP_Ne]; | ||
| 88090 | } | 88653 | } |
| 88654 | iCompare = res; | ||
| 88091 | 88655 | ||
| 88092 | /* Undo any changes made by applyAffinity() to the input registers. */ | 88656 | /* Undo any changes made by applyAffinity() to the input registers. */ |
| 88093 | assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); | 88657 | assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); |
| @@ -88095,67 +88659,39 @@ compare_op: | |||
| 88095 | assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); | 88659 | assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); |
| 88096 | pIn1->flags = flags1; | 88660 | pIn1->flags = flags1; |
| 88097 | 88661 | ||
| 88098 | if( pOp->p5 & SQLITE_STOREP2 ){ | 88662 | VdbeBranchTaken(res2!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 88099 | pOut = &aMem[pOp->p2]; | 88663 | if( res2 ){ |
| 88100 | iCompare = res; | 88664 | goto jump_to_p2; |
| 88101 | if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){ | ||
| 88102 | /* The KEEPNULL flag prevents OP_Eq from overwriting a NULL with 1 | ||
| 88103 | ** and prevents OP_Ne from overwriting NULL with 0. This flag | ||
| 88104 | ** is only used in contexts where either: | ||
| 88105 | ** (1) op==OP_Eq && (r[P2]==NULL || r[P2]==0) | ||
| 88106 | ** (2) op==OP_Ne && (r[P2]==NULL || r[P2]==1) | ||
| 88107 | ** Therefore it is not necessary to check the content of r[P2] for | ||
| 88108 | ** NULL. */ | ||
| 88109 | assert( pOp->opcode==OP_Ne || pOp->opcode==OP_Eq ); | ||
| 88110 | assert( res2==0 || res2==1 ); | ||
| 88111 | testcase( res2==0 && pOp->opcode==OP_Eq ); | ||
| 88112 | testcase( res2==1 && pOp->opcode==OP_Eq ); | ||
| 88113 | testcase( res2==0 && pOp->opcode==OP_Ne ); | ||
| 88114 | testcase( res2==1 && pOp->opcode==OP_Ne ); | ||
| 88115 | if( (pOp->opcode==OP_Eq)==res2 ) break; | ||
| 88116 | } | ||
| 88117 | memAboutToChange(p, pOut); | ||
| 88118 | MemSetTypeFlag(pOut, MEM_Int); | ||
| 88119 | pOut->u.i = res2; | ||
| 88120 | REGISTER_TRACE(pOp->p2, pOut); | ||
| 88121 | }else{ | ||
| 88122 | VdbeBranchTaken(res2!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3); | ||
| 88123 | if( res2 ){ | ||
| 88124 | goto jump_to_p2; | ||
| 88125 | } | ||
| 88126 | } | 88665 | } |
| 88127 | break; | 88666 | break; |
| 88128 | } | 88667 | } |
| 88129 | 88668 | ||
| 88130 | /* Opcode: ElseNotEq * P2 * * * | 88669 | /* Opcode: ElseEq * P2 * * * |
| 88131 | ** | 88670 | ** |
| 88132 | ** This opcode must follow an OP_Lt or OP_Gt comparison operator. There | 88671 | ** This opcode must follow an OP_Lt or OP_Gt comparison operator. There |
| 88133 | ** can be zero or more OP_ReleaseReg opcodes intervening, but no other | 88672 | ** can be zero or more OP_ReleaseReg opcodes intervening, but no other |
| 88134 | ** opcodes are allowed to occur between this instruction and the previous | 88673 | ** opcodes are allowed to occur between this instruction and the previous |
| 88135 | ** OP_Lt or OP_Gt. Furthermore, the prior OP_Lt or OP_Gt must have the | 88674 | ** OP_Lt or OP_Gt. |
| 88136 | ** SQLITE_STOREP2 bit set in the P5 field. | ||
| 88137 | ** | 88675 | ** |
| 88138 | ** If result of an OP_Eq comparison on the same two operands as the | 88676 | ** If result of an OP_Eq comparison on the same two operands as the |
| 88139 | ** prior OP_Lt or OP_Gt would have been NULL or false (0), then then | 88677 | ** prior OP_Lt or OP_Gt would have been true, then jump to P2. |
| 88140 | ** jump to P2. If the result of an OP_Eq comparison on the two previous | 88678 | ** If the result of an OP_Eq comparison on the two previous |
| 88141 | ** operands would have been true (1), then fall through. | 88679 | ** operands would have been false or NULL, then fall through. |
| 88142 | */ | 88680 | */ |
| 88143 | case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */ | 88681 | case OP_ElseEq: { /* same as TK_ESCAPE, jump */ |
| 88144 | 88682 | ||
| 88145 | #ifdef SQLITE_DEBUG | 88683 | #ifdef SQLITE_DEBUG |
| 88146 | /* Verify the preconditions of this opcode - that it follows an OP_Lt or | 88684 | /* Verify the preconditions of this opcode - that it follows an OP_Lt or |
| 88147 | ** OP_Gt with the SQLITE_STOREP2 flag set, with zero or more intervening | 88685 | ** OP_Gt with zero or more intervening OP_ReleaseReg opcodes */ |
| 88148 | ** OP_ReleaseReg opcodes */ | ||
| 88149 | int iAddr; | 88686 | int iAddr; |
| 88150 | for(iAddr = (int)(pOp - aOp) - 1; ALWAYS(iAddr>=0); iAddr--){ | 88687 | for(iAddr = (int)(pOp - aOp) - 1; ALWAYS(iAddr>=0); iAddr--){ |
| 88151 | if( aOp[iAddr].opcode==OP_ReleaseReg ) continue; | 88688 | if( aOp[iAddr].opcode==OP_ReleaseReg ) continue; |
| 88152 | assert( aOp[iAddr].opcode==OP_Lt || aOp[iAddr].opcode==OP_Gt ); | 88689 | assert( aOp[iAddr].opcode==OP_Lt || aOp[iAddr].opcode==OP_Gt ); |
| 88153 | assert( aOp[iAddr].p5 & SQLITE_STOREP2 ); | ||
| 88154 | break; | 88690 | break; |
| 88155 | } | 88691 | } |
| 88156 | #endif /* SQLITE_DEBUG */ | 88692 | #endif /* SQLITE_DEBUG */ |
| 88157 | VdbeBranchTaken(iCompare!=0, 2); | 88693 | VdbeBranchTaken(iCompare==0, 2); |
| 88158 | if( iCompare!=0 ) goto jump_to_p2; | 88694 | if( iCompare==0 ) goto jump_to_p2; |
| 88159 | break; | 88695 | break; |
| 88160 | } | 88696 | } |
| 88161 | 88697 | ||
| @@ -88466,6 +89002,24 @@ case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */ | |||
| 88466 | break; | 89002 | break; |
| 88467 | } | 89003 | } |
| 88468 | 89004 | ||
| 89005 | /* Opcode: ZeroOrNull P1 P2 P3 * * | ||
| 89006 | ** Synopsis: r[P2] = 0 OR NULL | ||
| 89007 | ** | ||
| 89008 | ** If all both registers P1 and P3 are NOT NULL, then store a zero in | ||
| 89009 | ** register P2. If either registers P1 or P3 are NULL then put | ||
| 89010 | ** a NULL in register P2. | ||
| 89011 | */ | ||
| 89012 | case OP_ZeroOrNull: { /* in1, in2, out2, in3 */ | ||
| 89013 | if( (aMem[pOp->p1].flags & MEM_Null)!=0 | ||
| 89014 | || (aMem[pOp->p3].flags & MEM_Null)!=0 | ||
| 89015 | ){ | ||
| 89016 | sqlite3VdbeMemSetNull(aMem + pOp->p2); | ||
| 89017 | }else{ | ||
| 89018 | sqlite3VdbeMemSetInt64(aMem + pOp->p2, 0); | ||
| 89019 | } | ||
| 89020 | break; | ||
| 89021 | } | ||
| 89022 | |||
| 88469 | /* Opcode: NotNull P1 P2 * * * | 89023 | /* Opcode: NotNull P1 P2 * * * |
| 88470 | ** Synopsis: if r[P1]!=NULL goto P2 | 89024 | ** Synopsis: if r[P1]!=NULL goto P2 |
| 88471 | ** | 89025 | ** |
| @@ -90522,8 +91076,18 @@ case OP_SeekHit: { | |||
| 90522 | assert( pC!=0 ); | 91076 | assert( pC!=0 ); |
| 90523 | assert( pOp->p3>=pOp->p2 ); | 91077 | assert( pOp->p3>=pOp->p2 ); |
| 90524 | if( pC->seekHit<pOp->p2 ){ | 91078 | if( pC->seekHit<pOp->p2 ){ |
| 91079 | #ifdef SQLITE_DEBUG | ||
| 91080 | if( db->flags&SQLITE_VdbeTrace ){ | ||
| 91081 | printf("seekHit changes from %d to %d\n", pC->seekHit, pOp->p2); | ||
| 91082 | } | ||
| 91083 | #endif | ||
| 90525 | pC->seekHit = pOp->p2; | 91084 | pC->seekHit = pOp->p2; |
| 90526 | }else if( pC->seekHit>pOp->p3 ){ | 91085 | }else if( pC->seekHit>pOp->p3 ){ |
| 91086 | #ifdef SQLITE_DEBUG | ||
| 91087 | if( db->flags&SQLITE_VdbeTrace ){ | ||
| 91088 | printf("seekHit changes from %d to %d\n", pC->seekHit, pOp->p3); | ||
| 91089 | } | ||
| 91090 | #endif | ||
| 90527 | pC->seekHit = pOp->p3; | 91091 | pC->seekHit = pOp->p3; |
| 90528 | } | 91092 | } |
| 90529 | break; | 91093 | break; |
| @@ -90638,6 +91202,11 @@ case OP_IfNoHope: { /* jump, in3 */ | |||
| 90638 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); | 91202 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 90639 | pC = p->apCsr[pOp->p1]; | 91203 | pC = p->apCsr[pOp->p1]; |
| 90640 | assert( pC!=0 ); | 91204 | assert( pC!=0 ); |
| 91205 | #ifdef SQLITE_DEBUG | ||
| 91206 | if( db->flags&SQLITE_VdbeTrace ){ | ||
| 91207 | printf("seekHit is %d\n", pC->seekHit); | ||
| 91208 | } | ||
| 91209 | #endif | ||
| 90641 | if( pC->seekHit>=pOp->p4.i ) break; | 91210 | if( pC->seekHit>=pOp->p4.i ) break; |
| 90642 | /* Fall through into OP_NotFound */ | 91211 | /* Fall through into OP_NotFound */ |
| 90643 | /* no break */ deliberate_fall_through | 91212 | /* no break */ deliberate_fall_through |
| @@ -91067,7 +91636,7 @@ case OP_Insert: { | |||
| 91067 | /* Invoke the pre-update hook, if any */ | 91636 | /* Invoke the pre-update hook, if any */ |
| 91068 | if( pTab ){ | 91637 | if( pTab ){ |
| 91069 | if( db->xPreUpdateCallback && !(pOp->p5 & OPFLAG_ISUPDATE) ){ | 91638 | if( db->xPreUpdateCallback && !(pOp->p5 & OPFLAG_ISUPDATE) ){ |
| 91070 | sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey,pOp->p2); | 91639 | sqlite3VdbePreUpdateHook(p,pC,SQLITE_INSERT,zDb,pTab,x.nKey,pOp->p2,-1); |
| 91071 | } | 91640 | } |
| 91072 | if( db->xUpdateCallback==0 || pTab->aCol==0 ){ | 91641 | if( db->xUpdateCallback==0 || pTab->aCol==0 ){ |
| 91073 | /* Prevent post-update hook from running in cases when it should not */ | 91642 | /* Prevent post-update hook from running in cases when it should not */ |
| @@ -91227,7 +91796,7 @@ case OP_Delete: { | |||
| 91227 | sqlite3VdbePreUpdateHook(p, pC, | 91796 | sqlite3VdbePreUpdateHook(p, pC, |
| 91228 | (opflags & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_DELETE, | 91797 | (opflags & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_DELETE, |
| 91229 | zDb, pTab, pC->movetoTarget, | 91798 | zDb, pTab, pC->movetoTarget, |
| 91230 | pOp->p3 | 91799 | pOp->p3, -1 |
| 91231 | ); | 91800 | ); |
| 91232 | } | 91801 | } |
| 91233 | if( opflags & OPFLAG_ISNOOP ) break; | 91802 | if( opflags & OPFLAG_ISNOOP ) break; |
| @@ -92173,11 +92742,10 @@ case OP_Destroy: { /* out2 */ | |||
| 92173 | ** P2==1 then the table to be clear is in the auxiliary database file | 92742 | ** P2==1 then the table to be clear is in the auxiliary database file |
| 92174 | ** that is used to store tables create using CREATE TEMPORARY TABLE. | 92743 | ** that is used to store tables create using CREATE TEMPORARY TABLE. |
| 92175 | ** | 92744 | ** |
| 92176 | ** If the P3 value is non-zero, then the table referred to must be an | 92745 | ** If the P3 value is non-zero, then the row change count is incremented |
| 92177 | ** intkey table (an SQL table, not an index). In this case the row change | 92746 | ** by the number of rows in the table being cleared. If P3 is greater |
| 92178 | ** count is incremented by the number of rows in the table being cleared. | 92747 | ** than zero, then the value stored in register P3 is also incremented |
| 92179 | ** If P3 is greater than zero, then the value stored in register P3 is | 92748 | ** by the number of rows in the table being cleared. |
| 92180 | ** also incremented by the number of rows in the table being cleared. | ||
| 92181 | ** | 92749 | ** |
| 92182 | ** See also: Destroy | 92750 | ** See also: Destroy |
| 92183 | */ | 92751 | */ |
| @@ -92188,9 +92756,7 @@ case OP_Clear: { | |||
| 92188 | nChange = 0; | 92756 | nChange = 0; |
| 92189 | assert( p->readOnly==0 ); | 92757 | assert( p->readOnly==0 ); |
| 92190 | assert( DbMaskTest(p->btreeMask, pOp->p2) ); | 92758 | assert( DbMaskTest(p->btreeMask, pOp->p2) ); |
| 92191 | rc = sqlite3BtreeClearTable( | 92759 | rc = sqlite3BtreeClearTable(db->aDb[pOp->p2].pBt, (u32)pOp->p1, &nChange); |
| 92192 | db->aDb[pOp->p2].pBt, (u32)pOp->p1, (pOp->p3 ? &nChange : 0) | ||
| 92193 | ); | ||
| 92194 | if( pOp->p3 ){ | 92760 | if( pOp->p3 ){ |
| 92195 | p->nChange += nChange; | 92761 | p->nChange += nChange; |
| 92196 | if( pOp->p3>0 ){ | 92762 | if( pOp->p3>0 ){ |
| @@ -92296,7 +92862,9 @@ case OP_ParseSchema: { | |||
| 92296 | 92862 | ||
| 92297 | iDb = pOp->p1; | 92863 | iDb = pOp->p1; |
| 92298 | assert( iDb>=0 && iDb<db->nDb ); | 92864 | assert( iDb>=0 && iDb<db->nDb ); |
| 92299 | assert( DbHasProperty(db, iDb, DB_SchemaLoaded) ); | 92865 | assert( DbHasProperty(db, iDb, DB_SchemaLoaded) |
| 92866 | || db->mallocFailed | ||
| 92867 | || (CORRUPT_DB && (db->flags & SQLITE_NoSchemaError)!=0) ); | ||
| 92300 | 92868 | ||
| 92301 | #ifndef SQLITE_OMIT_ALTERTABLE | 92869 | #ifndef SQLITE_OMIT_ALTERTABLE |
| 92302 | if( pOp->p4.z==0 ){ | 92870 | if( pOp->p4.z==0 ){ |
| @@ -93178,6 +93746,7 @@ case OP_JournalMode: { /* out2 */ | |||
| 93178 | pPager = sqlite3BtreePager(pBt); | 93746 | pPager = sqlite3BtreePager(pBt); |
| 93179 | eOld = sqlite3PagerGetJournalMode(pPager); | 93747 | eOld = sqlite3PagerGetJournalMode(pPager); |
| 93180 | if( eNew==PAGER_JOURNALMODE_QUERY ) eNew = eOld; | 93748 | if( eNew==PAGER_JOURNALMODE_QUERY ) eNew = eOld; |
| 93749 | assert( sqlite3BtreeHoldsMutex(pBt) ); | ||
| 93181 | if( !sqlite3PagerOkToChangeJournalMode(pPager) ) eNew = eOld; | 93750 | if( !sqlite3PagerOkToChangeJournalMode(pPager) ) eNew = eOld; |
| 93182 | 93751 | ||
| 93183 | #ifndef SQLITE_OMIT_WAL | 93752 | #ifndef SQLITE_OMIT_WAL |
| @@ -94656,7 +95225,7 @@ static int blobReadWrite( | |||
| 94656 | sqlite3_int64 iKey; | 95225 | sqlite3_int64 iKey; |
| 94657 | iKey = sqlite3BtreeIntegerKey(p->pCsr); | 95226 | iKey = sqlite3BtreeIntegerKey(p->pCsr); |
| 94658 | sqlite3VdbePreUpdateHook( | 95227 | sqlite3VdbePreUpdateHook( |
| 94659 | v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1 | 95228 | v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1, p->iCol |
| 94660 | ); | 95229 | ); |
| 94661 | } | 95230 | } |
| 94662 | #endif | 95231 | #endif |
| @@ -94727,6 +95296,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){ | |||
| 94727 | rc = SQLITE_ABORT; | 95296 | rc = SQLITE_ABORT; |
| 94728 | }else{ | 95297 | }else{ |
| 94729 | char *zErr; | 95298 | char *zErr; |
| 95299 | ((Vdbe*)p->pStmt)->rc = SQLITE_OK; | ||
| 94730 | rc = blobSeekToRow(p, iRow, &zErr); | 95300 | rc = blobSeekToRow(p, iRow, &zErr); |
| 94731 | if( rc!=SQLITE_OK ){ | 95301 | if( rc!=SQLITE_OK ){ |
| 94732 | sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr); | 95302 | sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr); |
| @@ -95820,8 +96390,9 @@ static void vdbeSorterWorkDebug(SortSubtask *pTask, const char *zEvent){ | |||
| 95820 | fprintf(stderr, "%lld:%d %s\n", t, iTask, zEvent); | 96390 | fprintf(stderr, "%lld:%d %s\n", t, iTask, zEvent); |
| 95821 | } | 96391 | } |
| 95822 | static void vdbeSorterRewindDebug(const char *zEvent){ | 96392 | static void vdbeSorterRewindDebug(const char *zEvent){ |
| 95823 | i64 t; | 96393 | i64 t = 0; |
| 95824 | sqlite3OsCurrentTimeInt64(sqlite3_vfs_find(0), &t); | 96394 | sqlite3_vfs *pVfs = sqlite3_vfs_find(0); |
| 96395 | if( ALWAYS(pVfs) ) sqlite3OsCurrentTimeInt64(pVfs, &t); | ||
| 95825 | fprintf(stderr, "%lld:X %s\n", t, zEvent); | 96396 | fprintf(stderr, "%lld:X %s\n", t, zEvent); |
| 95826 | } | 96397 | } |
| 95827 | static void vdbeSorterPopulateDebug( | 96398 | static void vdbeSorterPopulateDebug( |
| @@ -98197,26 +98768,28 @@ static int memjrnlWrite( | |||
| 98197 | */ | 98768 | */ |
| 98198 | static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){ | 98769 | static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){ |
| 98199 | MemJournal *p = (MemJournal *)pJfd; | 98770 | MemJournal *p = (MemJournal *)pJfd; |
| 98200 | FileChunk *pIter = 0; | 98771 | assert( p->endpoint.pChunk==0 || p->endpoint.pChunk->pNext==0 ); |
| 98201 | 98772 | if( size<p->endpoint.iOffset ){ | |
| 98202 | if( size==0 ){ | 98773 | FileChunk *pIter = 0; |
| 98203 | memjrnlFreeChunks(p->pFirst); | 98774 | if( size==0 ){ |
| 98204 | p->pFirst = 0; | 98775 | memjrnlFreeChunks(p->pFirst); |
| 98205 | }else{ | 98776 | p->pFirst = 0; |
| 98206 | i64 iOff = p->nChunkSize; | 98777 | }else{ |
| 98207 | for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){ | 98778 | i64 iOff = p->nChunkSize; |
| 98208 | iOff += p->nChunkSize; | 98779 | for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){ |
| 98209 | } | 98780 | iOff += p->nChunkSize; |
| 98210 | if( ALWAYS(pIter) ){ | 98781 | } |
| 98211 | memjrnlFreeChunks(pIter->pNext); | 98782 | if( ALWAYS(pIter) ){ |
| 98212 | pIter->pNext = 0; | 98783 | memjrnlFreeChunks(pIter->pNext); |
| 98784 | pIter->pNext = 0; | ||
| 98785 | } | ||
| 98213 | } | 98786 | } |
| 98214 | } | ||
| 98215 | 98787 | ||
| 98216 | p->endpoint.pChunk = pIter; | 98788 | p->endpoint.pChunk = pIter; |
| 98217 | p->endpoint.iOffset = size; | 98789 | p->endpoint.iOffset = size; |
| 98218 | p->readpoint.pChunk = 0; | 98790 | p->readpoint.pChunk = 0; |
| 98219 | p->readpoint.iOffset = 0; | 98791 | p->readpoint.iOffset = 0; |
| 98792 | } | ||
| 98220 | return SQLITE_OK; | 98793 | return SQLITE_OK; |
| 98221 | } | 98794 | } |
| 98222 | 98795 | ||
| @@ -98409,15 +98982,10 @@ static int walkWindowList(Walker *pWalker, Window *pList, int bOneOnly){ | |||
| 98409 | if( rc ) return WRC_Abort; | 98982 | if( rc ) return WRC_Abort; |
| 98410 | rc = sqlite3WalkExpr(pWalker, pWin->pFilter); | 98983 | rc = sqlite3WalkExpr(pWalker, pWin->pFilter); |
| 98411 | if( rc ) return WRC_Abort; | 98984 | if( rc ) return WRC_Abort; |
| 98412 | |||
| 98413 | /* The next two are purely for calls to sqlite3RenameExprUnmap() | ||
| 98414 | ** within sqlite3WindowOffsetExpr(). Because of constraints imposed | ||
| 98415 | ** by sqlite3WindowOffsetExpr(), they can never fail. The results do | ||
| 98416 | ** not matter anyhow. */ | ||
| 98417 | rc = sqlite3WalkExpr(pWalker, pWin->pStart); | 98985 | rc = sqlite3WalkExpr(pWalker, pWin->pStart); |
| 98418 | if( NEVER(rc) ) return WRC_Abort; | 98986 | if( rc ) return WRC_Abort; |
| 98419 | rc = sqlite3WalkExpr(pWalker, pWin->pEnd); | 98987 | rc = sqlite3WalkExpr(pWalker, pWin->pEnd); |
| 98420 | if( NEVER(rc) ) return WRC_Abort; | 98988 | if( rc ) return WRC_Abort; |
| 98421 | if( bOneOnly ) break; | 98989 | if( bOneOnly ) break; |
| 98422 | } | 98990 | } |
| 98423 | return WRC_Continue; | 98991 | return WRC_Continue; |
| @@ -98495,6 +99063,16 @@ SQLITE_PRIVATE int sqlite3WalkExprList(Walker *pWalker, ExprList *p){ | |||
| 98495 | } | 99063 | } |
| 98496 | 99064 | ||
| 98497 | /* | 99065 | /* |
| 99066 | ** This is a no-op callback for Walker->xSelectCallback2. If this | ||
| 99067 | ** callback is set, then the Select->pWinDefn list is traversed. | ||
| 99068 | */ | ||
| 99069 | SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker *pWalker, Select *p){ | ||
| 99070 | UNUSED_PARAMETER(pWalker); | ||
| 99071 | UNUSED_PARAMETER(p); | ||
| 99072 | /* No-op */ | ||
| 99073 | } | ||
| 99074 | |||
| 99075 | /* | ||
| 98498 | ** Walk all expressions associated with SELECT statement p. Do | 99076 | ** Walk all expressions associated with SELECT statement p. Do |
| 98499 | ** not invoke the SELECT callback on p, but do (of course) invoke | 99077 | ** not invoke the SELECT callback on p, but do (of course) invoke |
| 98500 | ** any expr callbacks and SELECT callbacks that come from subqueries. | 99078 | ** any expr callbacks and SELECT callbacks that come from subqueries. |
| @@ -98507,10 +99085,15 @@ SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){ | |||
| 98507 | if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort; | 99085 | if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort; |
| 98508 | if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort; | 99086 | if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort; |
| 98509 | if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort; | 99087 | if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort; |
| 98510 | #if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE) | 99088 | #if !defined(SQLITE_OMIT_WINDOWFUNC) |
| 98511 | { | 99089 | if( p->pWinDefn ){ |
| 98512 | Parse *pParse = pWalker->pParse; | 99090 | Parse *pParse; |
| 98513 | if( pParse && IN_RENAME_OBJECT ){ | 99091 | if( pWalker->xSelectCallback2==sqlite3WalkWinDefnDummyCallback |
| 99092 | || ((pParse = pWalker->pParse)!=0 && IN_RENAME_OBJECT) | ||
| 99093 | #ifndef SQLITE_OMIT_CTE | ||
| 99094 | || pWalker->xSelectCallback2==sqlite3SelectPopWith | ||
| 99095 | #endif | ||
| 99096 | ){ | ||
| 98514 | /* The following may return WRC_Abort if there are unresolvable | 99097 | /* The following may return WRC_Abort if there are unresolvable |
| 98515 | ** symbols (e.g. a table that does not exist) in a window definition. */ | 99098 | ** symbols (e.g. a table that does not exist) in a window definition. */ |
| 98516 | int rc = walkWindowList(pWalker, p->pWinDefn, 0); | 99099 | int rc = walkWindowList(pWalker, p->pWinDefn, 0); |
| @@ -98534,7 +99117,7 @@ SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){ | |||
| 98534 | SrcItem *pItem; | 99117 | SrcItem *pItem; |
| 98535 | 99118 | ||
| 98536 | pSrc = p->pSrc; | 99119 | pSrc = p->pSrc; |
| 98537 | if( pSrc ){ | 99120 | if( ALWAYS(pSrc) ){ |
| 98538 | for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){ | 99121 | for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){ |
| 98539 | if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){ | 99122 | if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){ |
| 98540 | return WRC_Abort; | 99123 | return WRC_Abort; |
| @@ -98708,7 +99291,10 @@ static void resolveAlias( | |||
| 98708 | assert( pOrig!=0 ); | 99291 | assert( pOrig!=0 ); |
| 98709 | db = pParse->db; | 99292 | db = pParse->db; |
| 98710 | pDup = sqlite3ExprDup(db, pOrig, 0); | 99293 | pDup = sqlite3ExprDup(db, pOrig, 0); |
| 98711 | if( pDup!=0 ){ | 99294 | if( db->mallocFailed ){ |
| 99295 | sqlite3ExprDelete(db, pDup); | ||
| 99296 | pDup = 0; | ||
| 99297 | }else{ | ||
| 98712 | incrAggFunctionDepth(pDup, nSubquery); | 99298 | incrAggFunctionDepth(pDup, nSubquery); |
| 98713 | if( pExpr->op==TK_COLLATE ){ | 99299 | if( pExpr->op==TK_COLLATE ){ |
| 98714 | pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken); | 99300 | pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken); |
| @@ -98730,10 +99316,8 @@ static void resolveAlias( | |||
| 98730 | pExpr->flags |= EP_MemToken; | 99316 | pExpr->flags |= EP_MemToken; |
| 98731 | } | 99317 | } |
| 98732 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ | 99318 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 98733 | if( pExpr->y.pWin!=0 ){ | 99319 | if( ALWAYS(pExpr->y.pWin!=0) ){ |
| 98734 | pExpr->y.pWin->pOwner = pExpr; | 99320 | pExpr->y.pWin->pOwner = pExpr; |
| 98735 | }else{ | ||
| 98736 | assert( db->mallocFailed ); | ||
| 98737 | } | 99321 | } |
| 98738 | } | 99322 | } |
| 98739 | sqlite3DbFree(db, pDup); | 99323 | sqlite3DbFree(db, pDup); |
| @@ -99125,8 +99709,8 @@ static int lookupName( | |||
| 99125 | ** is supported for backwards compatibility only. Hence, we issue a warning | 99709 | ** is supported for backwards compatibility only. Hence, we issue a warning |
| 99126 | ** on sqlite3_log() whenever the capability is used. | 99710 | ** on sqlite3_log() whenever the capability is used. |
| 99127 | */ | 99711 | */ |
| 99128 | if( (pNC->ncFlags & NC_UEList)!=0 | 99712 | if( cnt==0 |
| 99129 | && cnt==0 | 99713 | && (pNC->ncFlags & NC_UEList)!=0 |
| 99130 | && zTab==0 | 99714 | && zTab==0 |
| 99131 | ){ | 99715 | ){ |
| 99132 | pEList = pNC->uNC.pEList; | 99716 | pEList = pNC->uNC.pEList; |
| @@ -99190,7 +99774,6 @@ static int lookupName( | |||
| 99190 | assert( pExpr->op==TK_ID ); | 99774 | assert( pExpr->op==TK_ID ); |
| 99191 | if( ExprHasProperty(pExpr,EP_DblQuoted) | 99775 | if( ExprHasProperty(pExpr,EP_DblQuoted) |
| 99192 | && areDoubleQuotedStringsEnabled(db, pTopNC) | 99776 | && areDoubleQuotedStringsEnabled(db, pTopNC) |
| 99193 | && (db->init.bDropColumn==0 || sqlite3StrICmp(zCol, db->init.azInit[0])!=0) | ||
| 99194 | ){ | 99777 | ){ |
| 99195 | /* If a double-quoted identifier does not match any known column name, | 99778 | /* If a double-quoted identifier does not match any known column name, |
| 99196 | ** then treat it as a string. | 99779 | ** then treat it as a string. |
| @@ -99205,11 +99788,6 @@ static int lookupName( | |||
| 99205 | ** Someday, I hope to get rid of this hack. Unfortunately there is | 99788 | ** Someday, I hope to get rid of this hack. Unfortunately there is |
| 99206 | ** a huge amount of legacy SQL that uses it. So for now, we just | 99789 | ** a huge amount of legacy SQL that uses it. So for now, we just |
| 99207 | ** issue a warning. | 99790 | ** issue a warning. |
| 99208 | ** | ||
| 99209 | ** 2021-03-15: ticket 1c24a659e6d7f3a1 | ||
| 99210 | ** Do not do the ID-to-STRING conversion when doing the schema | ||
| 99211 | ** sanity check following a DROP COLUMN if the identifer name matches | ||
| 99212 | ** the name of the column being dropped. | ||
| 99213 | */ | 99791 | */ |
| 99214 | sqlite3_log(SQLITE_WARNING, | 99792 | sqlite3_log(SQLITE_WARNING, |
| 99215 | "double-quoted string literal: \"%w\"", zCol); | 99793 | "double-quoted string literal: \"%w\"", zCol); |
| @@ -99240,7 +99818,7 @@ static int lookupName( | |||
| 99240 | sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol); | 99818 | sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol); |
| 99241 | } | 99819 | } |
| 99242 | pParse->checkSchema = 1; | 99820 | pParse->checkSchema = 1; |
| 99243 | pTopNC->nErr++; | 99821 | pTopNC->nNcErr++; |
| 99244 | } | 99822 | } |
| 99245 | 99823 | ||
| 99246 | /* If a column from a table in pSrcList is referenced, then record | 99824 | /* If a column from a table in pSrcList is referenced, then record |
| @@ -99547,7 +100125,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 99547 | sqlite3ErrorMsg(pParse, | 100125 | sqlite3ErrorMsg(pParse, |
| 99548 | "second argument to likelihood() must be a " | 100126 | "second argument to likelihood() must be a " |
| 99549 | "constant between 0.0 and 1.0"); | 100127 | "constant between 0.0 and 1.0"); |
| 99550 | pNC->nErr++; | 100128 | pNC->nNcErr++; |
| 99551 | } | 100129 | } |
| 99552 | }else{ | 100130 | }else{ |
| 99553 | /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is | 100131 | /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is |
| @@ -99569,7 +100147,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 99569 | if( auth==SQLITE_DENY ){ | 100147 | if( auth==SQLITE_DENY ){ |
| 99570 | sqlite3ErrorMsg(pParse, "not authorized to use function: %s", | 100148 | sqlite3ErrorMsg(pParse, "not authorized to use function: %s", |
| 99571 | pDef->zName); | 100149 | pDef->zName); |
| 99572 | pNC->nErr++; | 100150 | pNC->nNcErr++; |
| 99573 | } | 100151 | } |
| 99574 | pExpr->op = TK_NULL; | 100152 | pExpr->op = TK_NULL; |
| 99575 | return WRC_Prune; | 100153 | return WRC_Prune; |
| @@ -99625,7 +100203,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 99625 | sqlite3ErrorMsg(pParse, | 100203 | sqlite3ErrorMsg(pParse, |
| 99626 | "%.*s() may not be used as a window function", nId, zId | 100204 | "%.*s() may not be used as a window function", nId, zId |
| 99627 | ); | 100205 | ); |
| 99628 | pNC->nErr++; | 100206 | pNC->nNcErr++; |
| 99629 | }else if( | 100207 | }else if( |
| 99630 | (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) | 100208 | (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) |
| 99631 | || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pWin) | 100209 | || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pWin) |
| @@ -99638,13 +100216,13 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 99638 | zType = "aggregate"; | 100216 | zType = "aggregate"; |
| 99639 | } | 100217 | } |
| 99640 | sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId); | 100218 | sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId); |
| 99641 | pNC->nErr++; | 100219 | pNC->nNcErr++; |
| 99642 | is_agg = 0; | 100220 | is_agg = 0; |
| 99643 | } | 100221 | } |
| 99644 | #else | 100222 | #else |
| 99645 | if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){ | 100223 | if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){ |
| 99646 | sqlite3ErrorMsg(pParse,"misuse of aggregate function %.*s()",nId,zId); | 100224 | sqlite3ErrorMsg(pParse,"misuse of aggregate function %.*s()",nId,zId); |
| 99647 | pNC->nErr++; | 100225 | pNC->nNcErr++; |
| 99648 | is_agg = 0; | 100226 | is_agg = 0; |
| 99649 | } | 100227 | } |
| 99650 | #endif | 100228 | #endif |
| @@ -99654,11 +100232,11 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 99654 | #endif | 100232 | #endif |
| 99655 | ){ | 100233 | ){ |
| 99656 | sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId); | 100234 | sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId); |
| 99657 | pNC->nErr++; | 100235 | pNC->nNcErr++; |
| 99658 | }else if( wrong_num_args ){ | 100236 | }else if( wrong_num_args ){ |
| 99659 | sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()", | 100237 | sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()", |
| 99660 | nId, zId); | 100238 | nId, zId); |
| 99661 | pNC->nErr++; | 100239 | pNC->nNcErr++; |
| 99662 | } | 100240 | } |
| 99663 | #ifndef SQLITE_OMIT_WINDOWFUNC | 100241 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 99664 | else if( is_agg==0 && ExprHasProperty(pExpr, EP_WinFunc) ){ | 100242 | else if( is_agg==0 && ExprHasProperty(pExpr, EP_WinFunc) ){ |
| @@ -99666,7 +100244,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 99666 | "FILTER may not be used with non-aggregate %.*s()", | 100244 | "FILTER may not be used with non-aggregate %.*s()", |
| 99667 | nId, zId | 100245 | nId, zId |
| 99668 | ); | 100246 | ); |
| 99669 | pNC->nErr++; | 100247 | pNC->nNcErr++; |
| 99670 | } | 100248 | } |
| 99671 | #endif | 100249 | #endif |
| 99672 | if( is_agg ){ | 100250 | if( is_agg ){ |
| @@ -99890,11 +100468,11 @@ static int resolveOrderByTermToExprList( | |||
| 99890 | nc.pParse = pParse; | 100468 | nc.pParse = pParse; |
| 99891 | nc.pSrcList = pSelect->pSrc; | 100469 | nc.pSrcList = pSelect->pSrc; |
| 99892 | nc.uNC.pEList = pEList; | 100470 | nc.uNC.pEList = pEList; |
| 99893 | nc.ncFlags = NC_AllowAgg|NC_UEList; | 100471 | nc.ncFlags = NC_AllowAgg|NC_UEList|NC_NoSelect; |
| 99894 | nc.nErr = 0; | 100472 | nc.nNcErr = 0; |
| 99895 | db = pParse->db; | 100473 | db = pParse->db; |
| 99896 | savedSuppErr = db->suppressErr; | 100474 | savedSuppErr = db->suppressErr; |
| 99897 | if( IN_RENAME_OBJECT==0 ) db->suppressErr = 1; | 100475 | db->suppressErr = 1; |
| 99898 | rc = sqlite3ResolveExprNames(&nc, pE); | 100476 | rc = sqlite3ResolveExprNames(&nc, pE); |
| 99899 | db->suppressErr = savedSuppErr; | 100477 | db->suppressErr = savedSuppErr; |
| 99900 | if( rc ) return 0; | 100478 | if( rc ) return 0; |
| @@ -99993,29 +100571,24 @@ static int resolveCompoundOrderBy( | |||
| 99993 | ** Once the comparisons are finished, the duplicate expression | 100571 | ** Once the comparisons are finished, the duplicate expression |
| 99994 | ** is deleted. | 100572 | ** is deleted. |
| 99995 | ** | 100573 | ** |
| 99996 | ** Or, if this is running as part of an ALTER TABLE operation, | 100574 | ** If this is running as part of an ALTER TABLE operation and |
| 99997 | ** resolve the symbols in the actual expression, not a duplicate. | 100575 | ** the symbols resolve successfully, also resolve the symbols in the |
| 99998 | ** And, if one of the comparisons is successful, leave the expression | 100576 | ** actual expression. This allows the code in alter.c to modify |
| 99999 | ** as is instead of transforming it to an integer as in the usual | 100577 | ** column references within the ORDER BY expression as required. */ |
| 100000 | ** case. This allows the code in alter.c to modify column | 100578 | pDup = sqlite3ExprDup(db, pE, 0); |
| 100001 | ** refererences within the ORDER BY expression as required. */ | ||
| 100002 | if( IN_RENAME_OBJECT ){ | ||
| 100003 | pDup = pE; | ||
| 100004 | }else{ | ||
| 100005 | pDup = sqlite3ExprDup(db, pE, 0); | ||
| 100006 | } | ||
| 100007 | if( !db->mallocFailed ){ | 100579 | if( !db->mallocFailed ){ |
| 100008 | assert(pDup); | 100580 | assert(pDup); |
| 100009 | iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup); | 100581 | iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup); |
| 100582 | if( IN_RENAME_OBJECT && iCol>0 ){ | ||
| 100583 | resolveOrderByTermToExprList(pParse, pSelect, pE); | ||
| 100584 | } | ||
| 100010 | } | 100585 | } |
| 100011 | if( !IN_RENAME_OBJECT ){ | 100586 | sqlite3ExprDelete(db, pDup); |
| 100012 | sqlite3ExprDelete(db, pDup); | ||
| 100013 | } | ||
| 100014 | } | 100587 | } |
| 100015 | } | 100588 | } |
| 100016 | if( iCol>0 ){ | 100589 | if( iCol>0 ){ |
| 100017 | /* Convert the ORDER BY term into an integer column number iCol, | 100590 | /* Convert the ORDER BY term into an integer column number iCol, |
| 100018 | ** taking care to preserve the COLLATE clause if it exists */ | 100591 | ** taking care to preserve the COLLATE clause if it exists. */ |
| 100019 | if( !IN_RENAME_OBJECT ){ | 100592 | if( !IN_RENAME_OBJECT ){ |
| 100020 | Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0); | 100593 | Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0); |
| 100021 | if( pNew==0 ) return 1; | 100594 | if( pNew==0 ) return 1; |
| @@ -100150,7 +100723,7 @@ static int resolveOrderGroupBy( | |||
| 100150 | Parse *pParse; /* Parsing context */ | 100723 | Parse *pParse; /* Parsing context */ |
| 100151 | int nResult; /* Number of terms in the result set */ | 100724 | int nResult; /* Number of terms in the result set */ |
| 100152 | 100725 | ||
| 100153 | if( pOrderBy==0 ) return 0; | 100726 | assert( pOrderBy!=0 ); |
| 100154 | nResult = pSelect->pEList->nExpr; | 100727 | nResult = pSelect->pEList->nExpr; |
| 100155 | pParse = pNC->pParse; | 100728 | pParse = pNC->pParse; |
| 100156 | for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){ | 100729 | for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){ |
| @@ -100240,8 +100813,10 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 100240 | while( p ){ | 100813 | while( p ){ |
| 100241 | assert( (p->selFlags & SF_Expanded)!=0 ); | 100814 | assert( (p->selFlags & SF_Expanded)!=0 ); |
| 100242 | assert( (p->selFlags & SF_Resolved)==0 ); | 100815 | assert( (p->selFlags & SF_Resolved)==0 ); |
| 100816 | assert( db->suppressErr==0 ); /* SF_Resolved not set if errors suppressed */ | ||
| 100243 | p->selFlags |= SF_Resolved; | 100817 | p->selFlags |= SF_Resolved; |
| 100244 | 100818 | ||
| 100819 | |||
| 100245 | /* Resolve the expressions in the LIMIT and OFFSET clauses. These | 100820 | /* Resolve the expressions in the LIMIT and OFFSET clauses. These |
| 100246 | ** are not allowed to refer to any names, so pass an empty NameContext. | 100821 | ** are not allowed to refer to any names, so pass an empty NameContext. |
| 100247 | */ | 100822 | */ |
| @@ -100315,13 +100890,6 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 100315 | sNC.ncFlags &= ~NC_AllowAgg; | 100890 | sNC.ncFlags &= ~NC_AllowAgg; |
| 100316 | } | 100891 | } |
| 100317 | 100892 | ||
| 100318 | /* If a HAVING clause is present, then there must be a GROUP BY clause. | ||
| 100319 | */ | ||
| 100320 | if( p->pHaving && !pGroupBy ){ | ||
| 100321 | sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING"); | ||
| 100322 | return WRC_Abort; | ||
| 100323 | } | ||
| 100324 | |||
| 100325 | /* Add the output column list to the name-context before parsing the | 100893 | /* Add the output column list to the name-context before parsing the |
| 100326 | ** other expressions in the SELECT statement. This is so that | 100894 | ** other expressions in the SELECT statement. This is so that |
| 100327 | ** expressions in the WHERE clause (etc.) can refer to expressions by | 100895 | ** expressions in the WHERE clause (etc.) can refer to expressions by |
| @@ -100333,7 +100901,13 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 100333 | assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert|NC_UBaseReg))==0 ); | 100901 | assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert|NC_UBaseReg))==0 ); |
| 100334 | sNC.uNC.pEList = p->pEList; | 100902 | sNC.uNC.pEList = p->pEList; |
| 100335 | sNC.ncFlags |= NC_UEList; | 100903 | sNC.ncFlags |= NC_UEList; |
| 100336 | if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; | 100904 | if( p->pHaving ){ |
| 100905 | if( !pGroupBy ){ | ||
| 100906 | sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING"); | ||
| 100907 | return WRC_Abort; | ||
| 100908 | } | ||
| 100909 | if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; | ||
| 100910 | } | ||
| 100337 | if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort; | 100911 | if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort; |
| 100338 | 100912 | ||
| 100339 | /* Resolve names in table-valued-function arguments */ | 100913 | /* Resolve names in table-valued-function arguments */ |
| @@ -100346,6 +100920,19 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 100346 | } | 100920 | } |
| 100347 | } | 100921 | } |
| 100348 | 100922 | ||
| 100923 | #ifndef SQLITE_OMIT_WINDOWFUNC | ||
| 100924 | if( IN_RENAME_OBJECT ){ | ||
| 100925 | Window *pWin; | ||
| 100926 | for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){ | ||
| 100927 | if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy) | ||
| 100928 | || sqlite3ResolveExprListNames(&sNC, pWin->pPartition) | ||
| 100929 | ){ | ||
| 100930 | return WRC_Abort; | ||
| 100931 | } | ||
| 100932 | } | ||
| 100933 | } | ||
| 100934 | #endif | ||
| 100935 | |||
| 100349 | /* The ORDER BY and GROUP BY clauses may not refer to terms in | 100936 | /* The ORDER BY and GROUP BY clauses may not refer to terms in |
| 100350 | ** outer queries | 100937 | ** outer queries |
| 100351 | */ | 100938 | */ |
| @@ -100373,7 +100960,8 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 100373 | ** is not detected until much later, and so we need to go ahead and | 100960 | ** is not detected until much later, and so we need to go ahead and |
| 100374 | ** resolve those symbols on the incorrect ORDER BY for consistency. | 100961 | ** resolve those symbols on the incorrect ORDER BY for consistency. |
| 100375 | */ | 100962 | */ |
| 100376 | if( isCompound<=nCompound /* Defer right-most ORDER BY of a compound */ | 100963 | if( p->pOrderBy!=0 |
| 100964 | && isCompound<=nCompound /* Defer right-most ORDER BY of a compound */ | ||
| 100377 | && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER") | 100965 | && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER") |
| 100378 | ){ | 100966 | ){ |
| 100379 | return WRC_Abort; | 100967 | return WRC_Abort; |
| @@ -100401,19 +100989,6 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 100401 | } | 100989 | } |
| 100402 | } | 100990 | } |
| 100403 | 100991 | ||
| 100404 | #ifndef SQLITE_OMIT_WINDOWFUNC | ||
| 100405 | if( IN_RENAME_OBJECT ){ | ||
| 100406 | Window *pWin; | ||
| 100407 | for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){ | ||
| 100408 | if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy) | ||
| 100409 | || sqlite3ResolveExprListNames(&sNC, pWin->pPartition) | ||
| 100410 | ){ | ||
| 100411 | return WRC_Abort; | ||
| 100412 | } | ||
| 100413 | } | ||
| 100414 | } | ||
| 100415 | #endif | ||
| 100416 | |||
| 100417 | /* If this is part of a compound SELECT, check that it has the right | 100992 | /* If this is part of a compound SELECT, check that it has the right |
| 100418 | ** number of expressions in the select list. */ | 100993 | ** number of expressions in the select list. */ |
| 100419 | if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){ | 100994 | if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){ |
| @@ -100497,7 +101072,7 @@ SQLITE_PRIVATE int sqlite3ResolveExprNames( | |||
| 100497 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin); | 101072 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin); |
| 100498 | w.pParse = pNC->pParse; | 101073 | w.pParse = pNC->pParse; |
| 100499 | w.xExprCallback = resolveExprStep; | 101074 | w.xExprCallback = resolveExprStep; |
| 100500 | w.xSelectCallback = resolveSelectStep; | 101075 | w.xSelectCallback = (pNC->ncFlags & NC_NoSelect) ? 0 : resolveSelectStep; |
| 100501 | w.xSelectCallback2 = 0; | 101076 | w.xSelectCallback2 = 0; |
| 100502 | w.u.pNC = pNC; | 101077 | w.u.pNC = pNC; |
| 100503 | #if SQLITE_MAX_EXPR_DEPTH>0 | 101078 | #if SQLITE_MAX_EXPR_DEPTH>0 |
| @@ -100516,7 +101091,7 @@ SQLITE_PRIVATE int sqlite3ResolveExprNames( | |||
| 100516 | testcase( pNC->ncFlags & NC_HasWin ); | 101091 | testcase( pNC->ncFlags & NC_HasWin ); |
| 100517 | ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) ); | 101092 | ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) ); |
| 100518 | pNC->ncFlags |= savedHasAgg; | 101093 | pNC->ncFlags |= savedHasAgg; |
| 100519 | return pNC->nErr>0 || w.pParse->nErr>0; | 101094 | return pNC->nNcErr>0 || w.pParse->nErr>0; |
| 100520 | } | 101095 | } |
| 100521 | 101096 | ||
| 100522 | /* | 101097 | /* |
| @@ -100561,7 +101136,7 @@ SQLITE_PRIVATE int sqlite3ResolveExprListNames( | |||
| 100561 | savedHasAgg |= pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin); | 101136 | savedHasAgg |= pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin); |
| 100562 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin); | 101137 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin); |
| 100563 | } | 101138 | } |
| 100564 | if( pNC->nErr>0 || w.pParse->nErr>0 ) return WRC_Abort; | 101139 | if( w.pParse->nErr>0 ) return WRC_Abort; |
| 100565 | } | 101140 | } |
| 100566 | pNC->ncFlags |= savedHasAgg; | 101141 | pNC->ncFlags |= savedHasAgg; |
| 100567 | return WRC_Continue; | 101142 | return WRC_Continue; |
| @@ -100704,6 +101279,10 @@ SQLITE_PRIVATE char sqlite3ExprAffinity(const Expr *pExpr){ | |||
| 100704 | assert( pExpr!=0 ); | 101279 | assert( pExpr!=0 ); |
| 100705 | } | 101280 | } |
| 100706 | op = pExpr->op; | 101281 | op = pExpr->op; |
| 101282 | if( op==TK_REGISTER ) op = pExpr->op2; | ||
| 101283 | if( (op==TK_COLUMN || op==TK_AGG_COLUMN) && pExpr->y.pTab ){ | ||
| 101284 | return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); | ||
| 101285 | } | ||
| 100707 | if( op==TK_SELECT ){ | 101286 | if( op==TK_SELECT ){ |
| 100708 | assert( pExpr->flags&EP_xIsSelect ); | 101287 | assert( pExpr->flags&EP_xIsSelect ); |
| 100709 | assert( pExpr->x.pSelect!=0 ); | 101288 | assert( pExpr->x.pSelect!=0 ); |
| @@ -100711,16 +101290,12 @@ SQLITE_PRIVATE char sqlite3ExprAffinity(const Expr *pExpr){ | |||
| 100711 | assert( pExpr->x.pSelect->pEList->a[0].pExpr!=0 ); | 101290 | assert( pExpr->x.pSelect->pEList->a[0].pExpr!=0 ); |
| 100712 | return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr); | 101291 | return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr); |
| 100713 | } | 101292 | } |
| 100714 | if( op==TK_REGISTER ) op = pExpr->op2; | ||
| 100715 | #ifndef SQLITE_OMIT_CAST | 101293 | #ifndef SQLITE_OMIT_CAST |
| 100716 | if( op==TK_CAST ){ | 101294 | if( op==TK_CAST ){ |
| 100717 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | 101295 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 100718 | return sqlite3AffinityType(pExpr->u.zToken, 0); | 101296 | return sqlite3AffinityType(pExpr->u.zToken, 0); |
| 100719 | } | 101297 | } |
| 100720 | #endif | 101298 | #endif |
| 100721 | if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->y.pTab ){ | ||
| 100722 | return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); | ||
| 100723 | } | ||
| 100724 | if( op==TK_SELECT_COLUMN ){ | 101299 | if( op==TK_SELECT_COLUMN ){ |
| 100725 | assert( pExpr->pLeft->flags&EP_xIsSelect ); | 101300 | assert( pExpr->pLeft->flags&EP_xIsSelect ); |
| 100726 | return sqlite3ExprAffinity( | 101301 | return sqlite3ExprAffinity( |
| @@ -100747,18 +101322,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken( | |||
| 100747 | const Token *pCollName, /* Name of collating sequence */ | 101322 | const Token *pCollName, /* Name of collating sequence */ |
| 100748 | int dequote /* True to dequote pCollName */ | 101323 | int dequote /* True to dequote pCollName */ |
| 100749 | ){ | 101324 | ){ |
| 100750 | assert( pExpr!=0 || pParse->db->mallocFailed ); | 101325 | if( pCollName->n>0 ){ |
| 100751 | if( pExpr==0 ) return 0; | ||
| 100752 | if( pExpr->op==TK_VECTOR ){ | ||
| 100753 | ExprList *pList = pExpr->x.pList; | ||
| 100754 | if( ALWAYS(pList!=0) ){ | ||
| 100755 | int i; | ||
| 100756 | for(i=0; i<pList->nExpr; i++){ | ||
| 100757 | pList->a[i].pExpr = sqlite3ExprAddCollateToken(pParse,pList->a[i].pExpr, | ||
| 100758 | pCollName, dequote); | ||
| 100759 | } | ||
| 100760 | } | ||
| 100761 | }else if( pCollName->n>0 ){ | ||
| 100762 | Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote); | 101326 | Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote); |
| 100763 | if( pNew ){ | 101327 | if( pNew ){ |
| 100764 | pNew->pLeft = pExpr; | 101328 | pNew->pLeft = pExpr; |
| @@ -101108,7 +101672,7 @@ SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr){ | |||
| 101108 | ** been positioned. | 101672 | ** been positioned. |
| 101109 | */ | 101673 | */ |
| 101110 | SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){ | 101674 | SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){ |
| 101111 | assert( i<sqlite3ExprVectorSize(pVector) ); | 101675 | assert( i<sqlite3ExprVectorSize(pVector) || pVector->op==TK_ERROR ); |
| 101112 | if( sqlite3ExprIsVector(pVector) ){ | 101676 | if( sqlite3ExprIsVector(pVector) ){ |
| 101113 | assert( pVector->op2==0 || pVector->op==TK_REGISTER ); | 101677 | assert( pVector->op2==0 || pVector->op==TK_REGISTER ); |
| 101114 | if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){ | 101678 | if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){ |
| @@ -101224,7 +101788,7 @@ static int exprVectorRegister( | |||
| 101224 | int *pRegFree /* OUT: Temp register to free */ | 101788 | int *pRegFree /* OUT: Temp register to free */ |
| 101225 | ){ | 101789 | ){ |
| 101226 | u8 op = pVector->op; | 101790 | u8 op = pVector->op; |
| 101227 | assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT ); | 101791 | assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT || op==TK_ERROR ); |
| 101228 | if( op==TK_REGISTER ){ | 101792 | if( op==TK_REGISTER ){ |
| 101229 | *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField); | 101793 | *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField); |
| 101230 | return pVector->iTable+iField; | 101794 | return pVector->iTable+iField; |
| @@ -101233,8 +101797,11 @@ static int exprVectorRegister( | |||
| 101233 | *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr; | 101797 | *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr; |
| 101234 | return regSelect+iField; | 101798 | return regSelect+iField; |
| 101235 | } | 101799 | } |
| 101236 | *ppExpr = pVector->x.pList->a[iField].pExpr; | 101800 | if( op==TK_VECTOR ){ |
| 101237 | return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree); | 101801 | *ppExpr = pVector->x.pList->a[iField].pExpr; |
| 101802 | return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree); | ||
| 101803 | } | ||
| 101804 | return 0; | ||
| 101238 | } | 101805 | } |
| 101239 | 101806 | ||
| 101240 | /* | 101807 | /* |
| @@ -101263,6 +101830,7 @@ static void codeVectorCompare( | |||
| 101263 | int regLeft = 0; | 101830 | int regLeft = 0; |
| 101264 | int regRight = 0; | 101831 | int regRight = 0; |
| 101265 | u8 opx = op; | 101832 | u8 opx = op; |
| 101833 | int addrCmp = 0; | ||
| 101266 | int addrDone = sqlite3VdbeMakeLabel(pParse); | 101834 | int addrDone = sqlite3VdbeMakeLabel(pParse); |
| 101267 | int isCommuted = ExprHasProperty(pExpr,EP_Commuted); | 101835 | int isCommuted = ExprHasProperty(pExpr,EP_Commuted); |
| 101268 | 101836 | ||
| @@ -101282,21 +101850,24 @@ static void codeVectorCompare( | |||
| 101282 | assert( p5==0 || pExpr->op!=op ); | 101850 | assert( p5==0 || pExpr->op!=op ); |
| 101283 | assert( p5==SQLITE_NULLEQ || pExpr->op==op ); | 101851 | assert( p5==SQLITE_NULLEQ || pExpr->op==op ); |
| 101284 | 101852 | ||
| 101285 | p5 |= SQLITE_STOREP2; | 101853 | if( op==TK_LE ) opx = TK_LT; |
| 101286 | if( opx==TK_LE ) opx = TK_LT; | 101854 | if( op==TK_GE ) opx = TK_GT; |
| 101287 | if( opx==TK_GE ) opx = TK_GT; | 101855 | if( op==TK_NE ) opx = TK_EQ; |
| 101288 | 101856 | ||
| 101289 | regLeft = exprCodeSubselect(pParse, pLeft); | 101857 | regLeft = exprCodeSubselect(pParse, pLeft); |
| 101290 | regRight = exprCodeSubselect(pParse, pRight); | 101858 | regRight = exprCodeSubselect(pParse, pRight); |
| 101291 | 101859 | ||
| 101860 | sqlite3VdbeAddOp2(v, OP_Integer, 1, dest); | ||
| 101292 | for(i=0; 1 /*Loop exits by "break"*/; i++){ | 101861 | for(i=0; 1 /*Loop exits by "break"*/; i++){ |
| 101293 | int regFree1 = 0, regFree2 = 0; | 101862 | int regFree1 = 0, regFree2 = 0; |
| 101294 | Expr *pL, *pR; | 101863 | Expr *pL = 0, *pR = 0; |
| 101295 | int r1, r2; | 101864 | int r1, r2; |
| 101296 | assert( i>=0 && i<nLeft ); | 101865 | assert( i>=0 && i<nLeft ); |
| 101866 | if( addrCmp ) sqlite3VdbeJumpHere(v, addrCmp); | ||
| 101297 | r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, ®Free1); | 101867 | r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, ®Free1); |
| 101298 | r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, ®Free2); | 101868 | r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, ®Free2); |
| 101299 | codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5, isCommuted); | 101869 | addrCmp = sqlite3VdbeCurrentAddr(v); |
| 101870 | codeCompare(pParse, pL, pR, opx, r1, r2, addrDone, p5, isCommuted); | ||
| 101300 | testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); | 101871 | testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); |
| 101301 | testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); | 101872 | testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); |
| 101302 | testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt); | 101873 | testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt); |
| @@ -101305,26 +101876,32 @@ static void codeVectorCompare( | |||
| 101305 | testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne); | 101876 | testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne); |
| 101306 | sqlite3ReleaseTempReg(pParse, regFree1); | 101877 | sqlite3ReleaseTempReg(pParse, regFree1); |
| 101307 | sqlite3ReleaseTempReg(pParse, regFree2); | 101878 | sqlite3ReleaseTempReg(pParse, regFree2); |
| 101879 | if( (opx==TK_LT || opx==TK_GT) && i<nLeft-1 ){ | ||
| 101880 | addrCmp = sqlite3VdbeAddOp0(v, OP_ElseEq); | ||
| 101881 | testcase(opx==TK_LT); VdbeCoverageIf(v,opx==TK_LT); | ||
| 101882 | testcase(opx==TK_GT); VdbeCoverageIf(v,opx==TK_GT); | ||
| 101883 | } | ||
| 101884 | if( p5==SQLITE_NULLEQ ){ | ||
| 101885 | sqlite3VdbeAddOp2(v, OP_Integer, 0, dest); | ||
| 101886 | }else{ | ||
| 101887 | sqlite3VdbeAddOp3(v, OP_ZeroOrNull, r1, dest, r2); | ||
| 101888 | } | ||
| 101308 | if( i==nLeft-1 ){ | 101889 | if( i==nLeft-1 ){ |
| 101309 | break; | 101890 | break; |
| 101310 | } | 101891 | } |
| 101311 | if( opx==TK_EQ ){ | 101892 | if( opx==TK_EQ ){ |
| 101312 | sqlite3VdbeAddOp2(v, OP_IfNot, dest, addrDone); VdbeCoverage(v); | 101893 | sqlite3VdbeAddOp2(v, OP_NotNull, dest, addrDone); VdbeCoverage(v); |
| 101313 | p5 |= SQLITE_KEEPNULL; | ||
| 101314 | }else if( opx==TK_NE ){ | ||
| 101315 | sqlite3VdbeAddOp2(v, OP_If, dest, addrDone); VdbeCoverage(v); | ||
| 101316 | p5 |= SQLITE_KEEPNULL; | ||
| 101317 | }else{ | 101894 | }else{ |
| 101318 | assert( op==TK_LT || op==TK_GT || op==TK_LE || op==TK_GE ); | 101895 | assert( op==TK_LT || op==TK_GT || op==TK_LE || op==TK_GE ); |
| 101319 | sqlite3VdbeAddOp2(v, OP_ElseNotEq, 0, addrDone); | 101896 | sqlite3VdbeAddOp2(v, OP_Goto, 0, addrDone); |
| 101320 | VdbeCoverageIf(v, op==TK_LT); | ||
| 101321 | VdbeCoverageIf(v, op==TK_GT); | ||
| 101322 | VdbeCoverageIf(v, op==TK_LE); | ||
| 101323 | VdbeCoverageIf(v, op==TK_GE); | ||
| 101324 | if( i==nLeft-2 ) opx = op; | 101897 | if( i==nLeft-2 ) opx = op; |
| 101325 | } | 101898 | } |
| 101326 | } | 101899 | } |
| 101900 | sqlite3VdbeJumpHere(v, addrCmp); | ||
| 101327 | sqlite3VdbeResolveLabel(v, addrDone); | 101901 | sqlite3VdbeResolveLabel(v, addrDone); |
| 101902 | if( op==TK_NE ){ | ||
| 101903 | sqlite3VdbeAddOp2(v, OP_Not, dest, dest); | ||
| 101904 | } | ||
| 101328 | } | 101905 | } |
| 101329 | 101906 | ||
| 101330 | #if SQLITE_MAX_EXPR_DEPTH>0 | 101907 | #if SQLITE_MAX_EXPR_DEPTH>0 |
| @@ -101966,6 +102543,7 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){ | |||
| 101966 | if( pzBuffer ){ | 102543 | if( pzBuffer ){ |
| 101967 | zAlloc = *pzBuffer; | 102544 | zAlloc = *pzBuffer; |
| 101968 | staticFlag = EP_Static; | 102545 | staticFlag = EP_Static; |
| 102546 | assert( zAlloc!=0 ); | ||
| 101969 | }else{ | 102547 | }else{ |
| 101970 | zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags)); | 102548 | zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags)); |
| 101971 | staticFlag = 0; | 102549 | staticFlag = 0; |
| @@ -102044,7 +102622,8 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){ | |||
| 102044 | if( pNew->op==TK_SELECT_COLUMN ){ | 102622 | if( pNew->op==TK_SELECT_COLUMN ){ |
| 102045 | pNew->pLeft = p->pLeft; | 102623 | pNew->pLeft = p->pLeft; |
| 102046 | assert( p->iColumn==0 || p->pRight==0 ); | 102624 | assert( p->iColumn==0 || p->pRight==0 ); |
| 102047 | assert( p->pRight==0 || p->pRight==p->pLeft ); | 102625 | assert( p->pRight==0 || p->pRight==p->pLeft |
| 102626 | || ExprHasProperty(p->pLeft, EP_Subquery) ); | ||
| 102048 | }else{ | 102627 | }else{ |
| 102049 | pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); | 102628 | pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); |
| 102050 | } | 102629 | } |
| @@ -102061,7 +102640,7 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){ | |||
| 102061 | ** and the db->mallocFailed flag set. | 102640 | ** and the db->mallocFailed flag set. |
| 102062 | */ | 102641 | */ |
| 102063 | #ifndef SQLITE_OMIT_CTE | 102642 | #ifndef SQLITE_OMIT_CTE |
| 102064 | static With *withDup(sqlite3 *db, With *p){ | 102643 | SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p){ |
| 102065 | With *pRet = 0; | 102644 | With *pRet = 0; |
| 102066 | if( p ){ | 102645 | if( p ){ |
| 102067 | sqlite3_int64 nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1); | 102646 | sqlite3_int64 nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1); |
| @@ -102079,7 +102658,7 @@ static With *withDup(sqlite3 *db, With *p){ | |||
| 102079 | return pRet; | 102658 | return pRet; |
| 102080 | } | 102659 | } |
| 102081 | #else | 102660 | #else |
| 102082 | # define withDup(x,y) 0 | 102661 | # define sqlite3WithDup(x,y) 0 |
| 102083 | #endif | 102662 | #endif |
| 102084 | 102663 | ||
| 102085 | #ifndef SQLITE_OMIT_WINDOWFUNC | 102664 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| @@ -102146,6 +102725,7 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags) | |||
| 102146 | pNew = sqlite3DbMallocRawNN(db, sqlite3DbMallocSize(db, p)); | 102725 | pNew = sqlite3DbMallocRawNN(db, sqlite3DbMallocSize(db, p)); |
| 102147 | if( pNew==0 ) return 0; | 102726 | if( pNew==0 ) return 0; |
| 102148 | pNew->nExpr = p->nExpr; | 102727 | pNew->nExpr = p->nExpr; |
| 102728 | pNew->nAlloc = p->nAlloc; | ||
| 102149 | pItem = pNew->a; | 102729 | pItem = pNew->a; |
| 102150 | pOldItem = p->a; | 102730 | pOldItem = p->a; |
| 102151 | for(i=0; i<p->nExpr; i++, pItem++, pOldItem++){ | 102731 | for(i=0; i<p->nExpr; i++, pItem++, pOldItem++){ |
| @@ -102158,7 +102738,8 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags) | |||
| 102158 | ){ | 102738 | ){ |
| 102159 | assert( pNewExpr->iColumn==0 || i>0 ); | 102739 | assert( pNewExpr->iColumn==0 || i>0 ); |
| 102160 | if( pNewExpr->iColumn==0 ){ | 102740 | if( pNewExpr->iColumn==0 ){ |
| 102161 | assert( pOldExpr->pLeft==pOldExpr->pRight ); | 102741 | assert( pOldExpr->pLeft==pOldExpr->pRight |
| 102742 | || ExprHasProperty(pOldExpr->pLeft, EP_Subquery) ); | ||
| 102162 | pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight; | 102743 | pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight; |
| 102163 | }else{ | 102744 | }else{ |
| 102164 | assert( i>0 ); | 102745 | assert( i>0 ); |
| @@ -102281,13 +102862,21 @@ SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){ | |||
| 102281 | pNew->addrOpenEphm[0] = -1; | 102862 | pNew->addrOpenEphm[0] = -1; |
| 102282 | pNew->addrOpenEphm[1] = -1; | 102863 | pNew->addrOpenEphm[1] = -1; |
| 102283 | pNew->nSelectRow = p->nSelectRow; | 102864 | pNew->nSelectRow = p->nSelectRow; |
| 102284 | pNew->pWith = withDup(db, p->pWith); | 102865 | pNew->pWith = sqlite3WithDup(db, p->pWith); |
| 102285 | #ifndef SQLITE_OMIT_WINDOWFUNC | 102866 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 102286 | pNew->pWin = 0; | 102867 | pNew->pWin = 0; |
| 102287 | pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn); | 102868 | pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn); |
| 102288 | if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew); | 102869 | if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew); |
| 102289 | #endif | 102870 | #endif |
| 102290 | pNew->selId = p->selId; | 102871 | pNew->selId = p->selId; |
| 102872 | if( db->mallocFailed ){ | ||
| 102873 | /* Any prior OOM might have left the Select object incomplete. | ||
| 102874 | ** Delete the whole thing rather than allow an incomplete Select | ||
| 102875 | ** to be used by the code generator. */ | ||
| 102876 | pNew->pNext = 0; | ||
| 102877 | sqlite3SelectDelete(db, pNew); | ||
| 102878 | break; | ||
| 102879 | } | ||
| 102291 | *pp = pNew; | 102880 | *pp = pNew; |
| 102292 | pp = &pNew->pPrior; | 102881 | pp = &pNew->pPrior; |
| 102293 | pNext = pNew; | 102882 | pNext = pNew; |
| @@ -102318,41 +102907,64 @@ SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){ | |||
| 102318 | ** NULL is returned. If non-NULL is returned, then it is guaranteed | 102907 | ** NULL is returned. If non-NULL is returned, then it is guaranteed |
| 102319 | ** that the new entry was successfully appended. | 102908 | ** that the new entry was successfully appended. |
| 102320 | */ | 102909 | */ |
| 102910 | static const struct ExprList_item zeroItem = {0}; | ||
| 102911 | SQLITE_PRIVATE SQLITE_NOINLINE ExprList *sqlite3ExprListAppendNew( | ||
| 102912 | sqlite3 *db, /* Database handle. Used for memory allocation */ | ||
| 102913 | Expr *pExpr /* Expression to be appended. Might be NULL */ | ||
| 102914 | ){ | ||
| 102915 | struct ExprList_item *pItem; | ||
| 102916 | ExprList *pList; | ||
| 102917 | |||
| 102918 | pList = sqlite3DbMallocRawNN(db, sizeof(ExprList)+sizeof(pList->a[0])*4 ); | ||
| 102919 | if( pList==0 ){ | ||
| 102920 | sqlite3ExprDelete(db, pExpr); | ||
| 102921 | return 0; | ||
| 102922 | } | ||
| 102923 | pList->nAlloc = 4; | ||
| 102924 | pList->nExpr = 1; | ||
| 102925 | pItem = &pList->a[0]; | ||
| 102926 | *pItem = zeroItem; | ||
| 102927 | pItem->pExpr = pExpr; | ||
| 102928 | return pList; | ||
| 102929 | } | ||
| 102930 | SQLITE_PRIVATE SQLITE_NOINLINE ExprList *sqlite3ExprListAppendGrow( | ||
| 102931 | sqlite3 *db, /* Database handle. Used for memory allocation */ | ||
| 102932 | ExprList *pList, /* List to which to append. Might be NULL */ | ||
| 102933 | Expr *pExpr /* Expression to be appended. Might be NULL */ | ||
| 102934 | ){ | ||
| 102935 | struct ExprList_item *pItem; | ||
| 102936 | ExprList *pNew; | ||
| 102937 | pList->nAlloc *= 2; | ||
| 102938 | pNew = sqlite3DbRealloc(db, pList, | ||
| 102939 | sizeof(*pList)+(pList->nAlloc-1)*sizeof(pList->a[0])); | ||
| 102940 | if( pNew==0 ){ | ||
| 102941 | sqlite3ExprListDelete(db, pList); | ||
| 102942 | sqlite3ExprDelete(db, pExpr); | ||
| 102943 | return 0; | ||
| 102944 | }else{ | ||
| 102945 | pList = pNew; | ||
| 102946 | } | ||
| 102947 | pItem = &pList->a[pList->nExpr++]; | ||
| 102948 | *pItem = zeroItem; | ||
| 102949 | pItem->pExpr = pExpr; | ||
| 102950 | return pList; | ||
| 102951 | } | ||
| 102321 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend( | 102952 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend( |
| 102322 | Parse *pParse, /* Parsing context */ | 102953 | Parse *pParse, /* Parsing context */ |
| 102323 | ExprList *pList, /* List to which to append. Might be NULL */ | 102954 | ExprList *pList, /* List to which to append. Might be NULL */ |
| 102324 | Expr *pExpr /* Expression to be appended. Might be NULL */ | 102955 | Expr *pExpr /* Expression to be appended. Might be NULL */ |
| 102325 | ){ | 102956 | ){ |
| 102326 | struct ExprList_item *pItem; | 102957 | struct ExprList_item *pItem; |
| 102327 | sqlite3 *db = pParse->db; | ||
| 102328 | assert( db!=0 ); | ||
| 102329 | if( pList==0 ){ | 102958 | if( pList==0 ){ |
| 102330 | pList = sqlite3DbMallocRawNN(db, sizeof(ExprList) ); | 102959 | return sqlite3ExprListAppendNew(pParse->db,pExpr); |
| 102331 | if( pList==0 ){ | 102960 | } |
| 102332 | goto no_mem; | 102961 | if( pList->nAlloc<pList->nExpr+1 ){ |
| 102333 | } | 102962 | return sqlite3ExprListAppendGrow(pParse->db,pList,pExpr); |
| 102334 | pList->nExpr = 0; | ||
| 102335 | }else if( (pList->nExpr & (pList->nExpr-1))==0 ){ | ||
| 102336 | ExprList *pNew; | ||
| 102337 | pNew = sqlite3DbRealloc(db, pList, | ||
| 102338 | sizeof(*pList)+(2*(sqlite3_int64)pList->nExpr-1)*sizeof(pList->a[0])); | ||
| 102339 | if( pNew==0 ){ | ||
| 102340 | goto no_mem; | ||
| 102341 | } | ||
| 102342 | pList = pNew; | ||
| 102343 | } | 102963 | } |
| 102344 | pItem = &pList->a[pList->nExpr++]; | 102964 | pItem = &pList->a[pList->nExpr++]; |
| 102345 | assert( offsetof(struct ExprList_item,zEName)==sizeof(pItem->pExpr) ); | 102965 | *pItem = zeroItem; |
| 102346 | assert( offsetof(struct ExprList_item,pExpr)==0 ); | ||
| 102347 | memset(&pItem->zEName,0,sizeof(*pItem)-offsetof(struct ExprList_item,zEName)); | ||
| 102348 | pItem->pExpr = pExpr; | 102966 | pItem->pExpr = pExpr; |
| 102349 | return pList; | 102967 | return pList; |
| 102350 | |||
| 102351 | no_mem: | ||
| 102352 | /* Avoid leaking memory if malloc has failed. */ | ||
| 102353 | sqlite3ExprDelete(db, pExpr); | ||
| 102354 | sqlite3ExprListDelete(db, pList); | ||
| 102355 | return 0; | ||
| 102356 | } | 102968 | } |
| 102357 | 102969 | ||
| 102358 | /* | 102970 | /* |
| @@ -102965,8 +103577,10 @@ SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){ | |||
| 102965 | */ | 103577 | */ |
| 102966 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){ | 103578 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){ |
| 102967 | u8 op; | 103579 | u8 op; |
| 103580 | assert( p!=0 ); | ||
| 102968 | while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ | 103581 | while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ |
| 102969 | p = p->pLeft; | 103582 | p = p->pLeft; |
| 103583 | assert( p!=0 ); | ||
| 102970 | } | 103584 | } |
| 102971 | op = p->op; | 103585 | op = p->op; |
| 102972 | if( op==TK_REGISTER ) op = p->op2; | 103586 | if( op==TK_REGISTER ) op = p->op2; |
| @@ -103598,19 +104212,23 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN( | |||
| 103598 | /* If the LHS and RHS of the IN operator do not match, that | 104212 | /* If the LHS and RHS of the IN operator do not match, that |
| 103599 | ** error will have been caught long before we reach this point. */ | 104213 | ** error will have been caught long before we reach this point. */ |
| 103600 | if( ALWAYS(pEList->nExpr==nVal) ){ | 104214 | if( ALWAYS(pEList->nExpr==nVal) ){ |
| 104215 | Select *pCopy; | ||
| 103601 | SelectDest dest; | 104216 | SelectDest dest; |
| 103602 | int i; | 104217 | int i; |
| 104218 | int rc; | ||
| 103603 | sqlite3SelectDestInit(&dest, SRT_Set, iTab); | 104219 | sqlite3SelectDestInit(&dest, SRT_Set, iTab); |
| 103604 | dest.zAffSdst = exprINAffinity(pParse, pExpr); | 104220 | dest.zAffSdst = exprINAffinity(pParse, pExpr); |
| 103605 | pSelect->iLimit = 0; | 104221 | pSelect->iLimit = 0; |
| 103606 | testcase( pSelect->selFlags & SF_Distinct ); | 104222 | testcase( pSelect->selFlags & SF_Distinct ); |
| 103607 | testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */ | 104223 | testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */ |
| 103608 | if( sqlite3Select(pParse, pSelect, &dest) ){ | 104224 | pCopy = sqlite3SelectDup(pParse->db, pSelect, 0); |
| 103609 | sqlite3DbFree(pParse->db, dest.zAffSdst); | 104225 | rc = pParse->db->mallocFailed ? 1 :sqlite3Select(pParse, pCopy, &dest); |
| 104226 | sqlite3SelectDelete(pParse->db, pCopy); | ||
| 104227 | sqlite3DbFree(pParse->db, dest.zAffSdst); | ||
| 104228 | if( rc ){ | ||
| 103610 | sqlite3KeyInfoUnref(pKeyInfo); | 104229 | sqlite3KeyInfoUnref(pKeyInfo); |
| 103611 | return; | 104230 | return; |
| 103612 | } | 104231 | } |
| 103613 | sqlite3DbFree(pParse->db, dest.zAffSdst); | ||
| 103614 | assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */ | 104232 | assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */ |
| 103615 | assert( pEList!=0 ); | 104233 | assert( pEList!=0 ); |
| 103616 | assert( pEList->nExpr>0 ); | 104234 | assert( pEList->nExpr>0 ); |
| @@ -103709,12 +104327,30 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){ | |||
| 103709 | 104327 | ||
| 103710 | Vdbe *v = pParse->pVdbe; | 104328 | Vdbe *v = pParse->pVdbe; |
| 103711 | assert( v!=0 ); | 104329 | assert( v!=0 ); |
| 104330 | if( pParse->nErr ) return 0; | ||
| 103712 | testcase( pExpr->op==TK_EXISTS ); | 104331 | testcase( pExpr->op==TK_EXISTS ); |
| 103713 | testcase( pExpr->op==TK_SELECT ); | 104332 | testcase( pExpr->op==TK_SELECT ); |
| 103714 | assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT ); | 104333 | assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT ); |
| 103715 | assert( ExprHasProperty(pExpr, EP_xIsSelect) ); | 104334 | assert( ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 103716 | pSel = pExpr->x.pSelect; | 104335 | pSel = pExpr->x.pSelect; |
| 103717 | 104336 | ||
| 104337 | /* If this routine has already been coded, then invoke it as a | ||
| 104338 | ** subroutine. */ | ||
| 104339 | if( ExprHasProperty(pExpr, EP_Subrtn) ){ | ||
| 104340 | ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId)); | ||
| 104341 | sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn, | ||
| 104342 | pExpr->y.sub.iAddr); | ||
| 104343 | return pExpr->iTable; | ||
| 104344 | } | ||
| 104345 | |||
| 104346 | /* Begin coding the subroutine */ | ||
| 104347 | ExprSetProperty(pExpr, EP_Subrtn); | ||
| 104348 | pExpr->y.sub.regReturn = ++pParse->nMem; | ||
| 104349 | pExpr->y.sub.iAddr = | ||
| 104350 | sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1; | ||
| 104351 | VdbeComment((v, "return address")); | ||
| 104352 | |||
| 104353 | |||
| 103718 | /* The evaluation of the EXISTS/SELECT must be repeated every time it | 104354 | /* The evaluation of the EXISTS/SELECT must be repeated every time it |
| 103719 | ** is encountered if any of the following is true: | 104355 | ** is encountered if any of the following is true: |
| 103720 | ** | 104356 | ** |
| @@ -103726,22 +104362,6 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){ | |||
| 103726 | ** save the results, and reuse the same result on subsequent invocations. | 104362 | ** save the results, and reuse the same result on subsequent invocations. |
| 103727 | */ | 104363 | */ |
| 103728 | if( !ExprHasProperty(pExpr, EP_VarSelect) ){ | 104364 | if( !ExprHasProperty(pExpr, EP_VarSelect) ){ |
| 103729 | /* If this routine has already been coded, then invoke it as a | ||
| 103730 | ** subroutine. */ | ||
| 103731 | if( ExprHasProperty(pExpr, EP_Subrtn) ){ | ||
| 103732 | ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId)); | ||
| 103733 | sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn, | ||
| 103734 | pExpr->y.sub.iAddr); | ||
| 103735 | return pExpr->iTable; | ||
| 103736 | } | ||
| 103737 | |||
| 103738 | /* Begin coding the subroutine */ | ||
| 103739 | ExprSetProperty(pExpr, EP_Subrtn); | ||
| 103740 | pExpr->y.sub.regReturn = ++pParse->nMem; | ||
| 103741 | pExpr->y.sub.iAddr = | ||
| 103742 | sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1; | ||
| 103743 | VdbeComment((v, "return address")); | ||
| 103744 | |||
| 103745 | addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); | 104365 | addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); |
| 103746 | } | 104366 | } |
| 103747 | 104367 | ||
| @@ -103790,19 +104410,22 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){ | |||
| 103790 | } | 104410 | } |
| 103791 | pSel->iLimit = 0; | 104411 | pSel->iLimit = 0; |
| 103792 | if( sqlite3Select(pParse, pSel, &dest) ){ | 104412 | if( sqlite3Select(pParse, pSel, &dest) ){ |
| 104413 | if( pParse->nErr ){ | ||
| 104414 | pExpr->op2 = pExpr->op; | ||
| 104415 | pExpr->op = TK_ERROR; | ||
| 104416 | } | ||
| 103793 | return 0; | 104417 | return 0; |
| 103794 | } | 104418 | } |
| 103795 | pExpr->iTable = rReg = dest.iSDParm; | 104419 | pExpr->iTable = rReg = dest.iSDParm; |
| 103796 | ExprSetVVAProperty(pExpr, EP_NoReduce); | 104420 | ExprSetVVAProperty(pExpr, EP_NoReduce); |
| 103797 | if( addrOnce ){ | 104421 | if( addrOnce ){ |
| 103798 | sqlite3VdbeJumpHere(v, addrOnce); | 104422 | sqlite3VdbeJumpHere(v, addrOnce); |
| 103799 | |||
| 103800 | /* Subroutine return */ | ||
| 103801 | sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn); | ||
| 103802 | sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1); | ||
| 103803 | sqlite3ClearTempRegCache(pParse); | ||
| 103804 | } | 104423 | } |
| 103805 | 104424 | ||
| 104425 | /* Subroutine return */ | ||
| 104426 | sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn); | ||
| 104427 | sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1); | ||
| 104428 | sqlite3ClearTempRegCache(pParse); | ||
| 103806 | return rReg; | 104429 | return rReg; |
| 103807 | } | 104430 | } |
| 103808 | #endif /* SQLITE_OMIT_SUBQUERY */ | 104431 | #endif /* SQLITE_OMIT_SUBQUERY */ |
| @@ -103816,7 +104439,7 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){ | |||
| 103816 | */ | 104439 | */ |
| 103817 | SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){ | 104440 | SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){ |
| 103818 | int nVector = sqlite3ExprVectorSize(pIn->pLeft); | 104441 | int nVector = sqlite3ExprVectorSize(pIn->pLeft); |
| 103819 | if( (pIn->flags & EP_xIsSelect) ){ | 104442 | if( (pIn->flags & EP_xIsSelect)!=0 && !pParse->db->mallocFailed ){ |
| 103820 | if( nVector!=pIn->x.pSelect->pEList->nExpr ){ | 104443 | if( nVector!=pIn->x.pSelect->pEList->nExpr ){ |
| 103821 | sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector); | 104444 | sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector); |
| 103822 | return 1; | 104445 | return 1; |
| @@ -104007,6 +104630,7 @@ static void sqlite3ExprCodeIN( | |||
| 104007 | if( pParse->nErr ) goto sqlite3ExprCodeIN_finished; | 104630 | if( pParse->nErr ) goto sqlite3ExprCodeIN_finished; |
| 104008 | for(i=0; i<nVector; i++){ | 104631 | for(i=0; i<nVector; i++){ |
| 104009 | Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i); | 104632 | Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i); |
| 104633 | if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error; | ||
| 104010 | if( sqlite3ExprCanBeNull(p) ){ | 104634 | if( sqlite3ExprCanBeNull(p) ){ |
| 104011 | sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2); | 104635 | sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2); |
| 104012 | VdbeCoverage(v); | 104636 | VdbeCoverage(v); |
| @@ -104632,7 +105256,7 @@ expr_code_doover: | |||
| 104632 | ** Expr node to be passed into this function, it will be handled | 105256 | ** Expr node to be passed into this function, it will be handled |
| 104633 | ** sanely and not crash. But keep the assert() to bring the problem | 105257 | ** sanely and not crash. But keep the assert() to bring the problem |
| 104634 | ** to the attention of the developers. */ | 105258 | ** to the attention of the developers. */ |
| 104635 | assert( op==TK_NULL ); | 105259 | assert( op==TK_NULL || op==TK_ERROR || pParse->db->mallocFailed ); |
| 104636 | sqlite3VdbeAddOp2(v, OP_Null, 0, target); | 105260 | sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| 104637 | return target; | 105261 | return target; |
| 104638 | } | 105262 | } |
| @@ -104698,8 +105322,9 @@ expr_code_doover: | |||
| 104698 | }else{ | 105322 | }else{ |
| 104699 | r1 = sqlite3ExprCodeTemp(pParse, pLeft, ®Free1); | 105323 | r1 = sqlite3ExprCodeTemp(pParse, pLeft, ®Free1); |
| 104700 | r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | 105324 | r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); |
| 104701 | codeCompare(pParse, pLeft, pExpr->pRight, op, | 105325 | sqlite3VdbeAddOp2(v, OP_Integer, 1, inReg); |
| 104702 | r1, r2, inReg, SQLITE_STOREP2 | p5, | 105326 | codeCompare(pParse, pLeft, pExpr->pRight, op, r1, r2, |
| 105327 | sqlite3VdbeCurrentAddr(v)+2, p5, | ||
| 104703 | ExprHasProperty(pExpr,EP_Commuted)); | 105328 | ExprHasProperty(pExpr,EP_Commuted)); |
| 104704 | assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); | 105329 | assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); |
| 104705 | assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); | 105330 | assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); |
| @@ -104707,6 +105332,11 @@ expr_code_doover: | |||
| 104707 | assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge); | 105332 | assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge); |
| 104708 | assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq); | 105333 | assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq); |
| 104709 | assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne); | 105334 | assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne); |
| 105335 | if( p5==SQLITE_NULLEQ ){ | ||
| 105336 | sqlite3VdbeAddOp2(v, OP_Integer, 0, inReg); | ||
| 105337 | }else{ | ||
| 105338 | sqlite3VdbeAddOp3(v, OP_ZeroOrNull, r1, inReg, r2); | ||
| 105339 | } | ||
| 104710 | testcase( regFree1==0 ); | 105340 | testcase( regFree1==0 ); |
| 104711 | testcase( regFree2==0 ); | 105341 | testcase( regFree2==0 ); |
| 104712 | } | 105342 | } |
| @@ -104969,7 +105599,8 @@ expr_code_doover: | |||
| 104969 | if( pExpr->pLeft->iTable==0 ){ | 105599 | if( pExpr->pLeft->iTable==0 ){ |
| 104970 | pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft); | 105600 | pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft); |
| 104971 | } | 105601 | } |
| 104972 | assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT ); | 105602 | assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT |
| 105603 | || pExpr->pLeft->op==TK_ERROR ); | ||
| 104973 | if( pExpr->iTable!=0 | 105604 | if( pExpr->iTable!=0 |
| 104974 | && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft)) | 105605 | && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft)) |
| 104975 | ){ | 105606 | ){ |
| @@ -106601,6 +107232,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ | |||
| 106601 | */ | 107232 | */ |
| 106602 | struct AggInfo_func *pItem = pAggInfo->aFunc; | 107233 | struct AggInfo_func *pItem = pAggInfo->aFunc; |
| 106603 | for(i=0; i<pAggInfo->nFunc; i++, pItem++){ | 107234 | for(i=0; i<pAggInfo->nFunc; i++, pItem++){ |
| 107235 | if( pItem->pFExpr==pExpr ) break; | ||
| 106604 | if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){ | 107236 | if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){ |
| 106605 | break; | 107237 | break; |
| 106606 | } | 107238 | } |
| @@ -106801,6 +107433,7 @@ SQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){ | |||
| 106801 | static int isAlterableTable(Parse *pParse, Table *pTab){ | 107433 | static int isAlterableTable(Parse *pParse, Table *pTab){ |
| 106802 | if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) | 107434 | if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) |
| 106803 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 107435 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 107436 | || (pTab->tabFlags & TF_Eponymous)!=0 | ||
| 106804 | || ( (pTab->tabFlags & TF_Shadow)!=0 | 107437 | || ( (pTab->tabFlags & TF_Shadow)!=0 |
| 106805 | && sqlite3ReadOnlyShadowTables(pParse->db) | 107438 | && sqlite3ReadOnlyShadowTables(pParse->db) |
| 106806 | ) | 107439 | ) |
| @@ -106824,7 +107457,7 @@ static void renameTestSchema( | |||
| 106824 | const char *zDb, /* Name of db to verify schema of */ | 107457 | const char *zDb, /* Name of db to verify schema of */ |
| 106825 | int bTemp, /* True if this is the temp db */ | 107458 | int bTemp, /* True if this is the temp db */ |
| 106826 | const char *zWhen, /* "when" part of error message */ | 107459 | const char *zWhen, /* "when" part of error message */ |
| 106827 | const char *zDropColumn /* Name of column being dropped */ | 107460 | int bNoDQS /* Do not allow DQS in the schema */ |
| 106828 | ){ | 107461 | ){ |
| 106829 | pParse->colNamesSet = 1; | 107462 | pParse->colNamesSet = 1; |
| 106830 | sqlite3NestedParse(pParse, | 107463 | sqlite3NestedParse(pParse, |
| @@ -106832,9 +107465,9 @@ static void renameTestSchema( | |||
| 106832 | "FROM \"%w\"." DFLT_SCHEMA_TABLE " " | 107465 | "FROM \"%w\"." DFLT_SCHEMA_TABLE " " |
| 106833 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" | 107466 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" |
| 106834 | " AND sql NOT LIKE 'create virtual%%'" | 107467 | " AND sql NOT LIKE 'create virtual%%'" |
| 106835 | " AND sqlite_rename_test(%Q, sql, type, name, %d, %Q, %Q)=NULL ", | 107468 | " AND sqlite_rename_test(%Q, sql, type, name, %d, %Q, %d)=NULL ", |
| 106836 | zDb, | 107469 | zDb, |
| 106837 | zDb, bTemp, zWhen, zDropColumn | 107470 | zDb, bTemp, zWhen, bNoDQS |
| 106838 | ); | 107471 | ); |
| 106839 | 107472 | ||
| 106840 | if( bTemp==0 ){ | 107473 | if( bTemp==0 ){ |
| @@ -106843,8 +107476,32 @@ static void renameTestSchema( | |||
| 106843 | "FROM temp." DFLT_SCHEMA_TABLE " " | 107476 | "FROM temp." DFLT_SCHEMA_TABLE " " |
| 106844 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" | 107477 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" |
| 106845 | " AND sql NOT LIKE 'create virtual%%'" | 107478 | " AND sql NOT LIKE 'create virtual%%'" |
| 106846 | " AND sqlite_rename_test(%Q, sql, type, name, 1, %Q, %Q)=NULL ", | 107479 | " AND sqlite_rename_test(%Q, sql, type, name, 1, %Q, %d)=NULL ", |
| 106847 | zDb, zWhen, zDropColumn | 107480 | zDb, zWhen, bNoDQS |
| 107481 | ); | ||
| 107482 | } | ||
| 107483 | } | ||
| 107484 | |||
| 107485 | /* | ||
| 107486 | ** Generate VM code to replace any double-quoted strings (but not double-quoted | ||
| 107487 | ** identifiers) within the "sql" column of the sqlite_schema table in | ||
| 107488 | ** database zDb with their single-quoted equivalents. If argument bTemp is | ||
| 107489 | ** not true, similarly update all SQL statements in the sqlite_schema table | ||
| 107490 | ** of the temp db. | ||
| 107491 | */ | ||
| 107492 | static void renameFixQuotes(Parse *pParse, const char *zDb, int bTemp){ | ||
| 107493 | sqlite3NestedParse(pParse, | ||
| 107494 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE | ||
| 107495 | " SET sql = sqlite_rename_quotefix(%Q, sql)" | ||
| 107496 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" | ||
| 107497 | " AND sql NOT LIKE 'create virtual%%'" , zDb, zDb | ||
| 107498 | ); | ||
| 107499 | if( bTemp==0 ){ | ||
| 107500 | sqlite3NestedParse(pParse, | ||
| 107501 | "UPDATE temp." DFLT_SCHEMA_TABLE | ||
| 107502 | " SET sql = sqlite_rename_quotefix('temp', sql)" | ||
| 107503 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" | ||
| 107504 | " AND sql NOT LIKE 'create virtual%%'" | ||
| 106848 | ); | 107505 | ); |
| 106849 | } | 107506 | } |
| 106850 | } | 107507 | } |
| @@ -107007,7 +107664,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable( | |||
| 107007 | "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, 1), " | 107664 | "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, 1), " |
| 107008 | "tbl_name = " | 107665 | "tbl_name = " |
| 107009 | "CASE WHEN tbl_name=%Q COLLATE nocase AND " | 107666 | "CASE WHEN tbl_name=%Q COLLATE nocase AND " |
| 107010 | " sqlite_rename_test(%Q, sql, type, name, 1, 'after rename',0) " | 107667 | " sqlite_rename_test(%Q, sql, type, name, 1, 'after rename', 0) " |
| 107011 | "THEN %Q ELSE tbl_name END " | 107668 | "THEN %Q ELSE tbl_name END " |
| 107012 | "WHERE type IN ('view', 'trigger')" | 107669 | "WHERE type IN ('view', 'trigger')" |
| 107013 | , zDb, zTabName, zName, zTabName, zDb, zName); | 107670 | , zDb, zTabName, zName, zTabName, zDb, zName); |
| @@ -107366,6 +108023,10 @@ SQLITE_PRIVATE void sqlite3AlterRenameColumn( | |||
| 107366 | goto exit_rename_column; | 108023 | goto exit_rename_column; |
| 107367 | } | 108024 | } |
| 107368 | 108025 | ||
| 108026 | /* Ensure the schema contains no double-quoted strings */ | ||
| 108027 | renameTestSchema(pParse, zDb, iSchema==1, "", 0); | ||
| 108028 | renameFixQuotes(pParse, zDb, iSchema==1); | ||
| 108029 | |||
| 107369 | /* Do the rename operation using a recursive UPDATE statement that | 108030 | /* Do the rename operation using a recursive UPDATE statement that |
| 107370 | ** uses the sqlite_rename_column() SQL function to compute the new | 108031 | ** uses the sqlite_rename_column() SQL function to compute the new |
| 107371 | ** CREATE statement text for the sqlite_schema table. | 108032 | ** CREATE statement text for the sqlite_schema table. |
| @@ -107395,7 +108056,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameColumn( | |||
| 107395 | 108056 | ||
| 107396 | /* Drop and reload the database schema. */ | 108057 | /* Drop and reload the database schema. */ |
| 107397 | renameReloadSchema(pParse, iSchema, INITFLAG_AlterRename); | 108058 | renameReloadSchema(pParse, iSchema, INITFLAG_AlterRename); |
| 107398 | renameTestSchema(pParse, zDb, iSchema==1, "after rename", 0); | 108059 | renameTestSchema(pParse, zDb, iSchema==1, "after rename", 1); |
| 107399 | 108060 | ||
| 107400 | exit_rename_column: | 108061 | exit_rename_column: |
| 107401 | sqlite3SrcListDelete(db, pSrc); | 108062 | sqlite3SrcListDelete(db, pSrc); |
| @@ -107541,15 +108202,30 @@ static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){ | |||
| 107541 | static void renameWalkWith(Walker *pWalker, Select *pSelect){ | 108202 | static void renameWalkWith(Walker *pWalker, Select *pSelect){ |
| 107542 | With *pWith = pSelect->pWith; | 108203 | With *pWith = pSelect->pWith; |
| 107543 | if( pWith ){ | 108204 | if( pWith ){ |
| 108205 | Parse *pParse = pWalker->pParse; | ||
| 107544 | int i; | 108206 | int i; |
| 108207 | With *pCopy = 0; | ||
| 108208 | assert( pWith->nCte>0 ); | ||
| 108209 | if( (pWith->a[0].pSelect->selFlags & SF_Expanded)==0 ){ | ||
| 108210 | /* Push a copy of the With object onto the with-stack. We use a copy | ||
| 108211 | ** here as the original will be expanded and resolved (flags SF_Expanded | ||
| 108212 | ** and SF_Resolved) below. And the parser code that uses the with-stack | ||
| 108213 | ** fails if the Select objects on it have already been expanded and | ||
| 108214 | ** resolved. */ | ||
| 108215 | pCopy = sqlite3WithDup(pParse->db, pWith); | ||
| 108216 | pCopy = sqlite3WithPush(pParse, pCopy, 1); | ||
| 108217 | } | ||
| 107545 | for(i=0; i<pWith->nCte; i++){ | 108218 | for(i=0; i<pWith->nCte; i++){ |
| 107546 | Select *p = pWith->a[i].pSelect; | 108219 | Select *p = pWith->a[i].pSelect; |
| 107547 | NameContext sNC; | 108220 | NameContext sNC; |
| 107548 | memset(&sNC, 0, sizeof(sNC)); | 108221 | memset(&sNC, 0, sizeof(sNC)); |
| 107549 | sNC.pParse = pWalker->pParse; | 108222 | sNC.pParse = pParse; |
| 107550 | sqlite3SelectPrep(sNC.pParse, p, &sNC); | 108223 | if( pCopy ) sqlite3SelectPrep(sNC.pParse, p, &sNC); |
| 107551 | sqlite3WalkSelect(pWalker, p); | 108224 | sqlite3WalkSelect(pWalker, p); |
| 107552 | sqlite3RenameExprlistUnmap(pWalker->pParse, pWith->a[i].pCols); | 108225 | sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols); |
| 108226 | } | ||
| 108227 | if( pCopy && pParse->pWith==pCopy ){ | ||
| 108228 | pParse->pWith = pCopy->pOuter; | ||
| 107553 | } | 108229 | } |
| 107554 | } | 108230 | } |
| 107555 | } | 108231 | } |
| @@ -107576,7 +108252,11 @@ static int renameUnmapSelectCb(Walker *pWalker, Select *p){ | |||
| 107576 | Parse *pParse = pWalker->pParse; | 108252 | Parse *pParse = pWalker->pParse; |
| 107577 | int i; | 108253 | int i; |
| 107578 | if( pParse->nErr ) return WRC_Abort; | 108254 | if( pParse->nErr ) return WRC_Abort; |
| 107579 | if( NEVER(p->selFlags & SF_View) ) return WRC_Prune; | 108255 | if( p->selFlags & (SF_View|SF_CopyCte) ){ |
| 108256 | testcase( p->selFlags & SF_View ); | ||
| 108257 | testcase( p->selFlags & SF_CopyCte ); | ||
| 108258 | return WRC_Prune; | ||
| 108259 | } | ||
| 107580 | if( ALWAYS(p->pEList) ){ | 108260 | if( ALWAYS(p->pEList) ){ |
| 107581 | ExprList *pList = p->pEList; | 108261 | ExprList *pList = p->pEList; |
| 107582 | for(i=0; i<pList->nExpr; i++){ | 108262 | for(i=0; i<pList->nExpr; i++){ |
| @@ -107660,7 +108340,9 @@ static RenameToken *renameTokenFind( | |||
| 107660 | void *pPtr | 108340 | void *pPtr |
| 107661 | ){ | 108341 | ){ |
| 107662 | RenameToken **pp; | 108342 | RenameToken **pp; |
| 107663 | assert( pPtr!=0 ); | 108343 | if( NEVER(pPtr==0) ){ |
| 108344 | return 0; | ||
| 108345 | } | ||
| 107664 | for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){ | 108346 | for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){ |
| 107665 | if( (*pp)->p==pPtr ){ | 108347 | if( (*pp)->p==pPtr ){ |
| 107666 | RenameToken *pToken = *pp; | 108348 | RenameToken *pToken = *pp; |
| @@ -107682,7 +108364,11 @@ static RenameToken *renameTokenFind( | |||
| 107682 | ** descend into sub-select statements. | 108364 | ** descend into sub-select statements. |
| 107683 | */ | 108365 | */ |
| 107684 | static int renameColumnSelectCb(Walker *pWalker, Select *p){ | 108366 | static int renameColumnSelectCb(Walker *pWalker, Select *p){ |
| 107685 | if( p->selFlags & SF_View ) return WRC_Prune; | 108367 | if( p->selFlags & (SF_View|SF_CopyCte) ){ |
| 108368 | testcase( p->selFlags & SF_View ); | ||
| 108369 | testcase( p->selFlags & SF_CopyCte ); | ||
| 108370 | return WRC_Prune; | ||
| 108371 | } | ||
| 107686 | renameWalkWith(pWalker, p); | 108372 | renameWalkWith(pWalker, p); |
| 107687 | return WRC_Continue; | 108373 | return WRC_Continue; |
| 107688 | } | 108374 | } |
| @@ -107819,17 +108505,12 @@ static int renameParseSql( | |||
| 107819 | const char *zDb, /* Name of schema SQL belongs to */ | 108505 | const char *zDb, /* Name of schema SQL belongs to */ |
| 107820 | sqlite3 *db, /* Database handle */ | 108506 | sqlite3 *db, /* Database handle */ |
| 107821 | const char *zSql, /* SQL to parse */ | 108507 | const char *zSql, /* SQL to parse */ |
| 107822 | int bTemp, /* True if SQL is from temp schema */ | 108508 | int bTemp /* True if SQL is from temp schema */ |
| 107823 | const char *zDropColumn /* Name of column being dropped */ | ||
| 107824 | ){ | 108509 | ){ |
| 107825 | int rc; | 108510 | int rc; |
| 107826 | char *zErr = 0; | 108511 | char *zErr = 0; |
| 107827 | 108512 | ||
| 107828 | db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb); | 108513 | db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb); |
| 107829 | if( zDropColumn ){ | ||
| 107830 | db->init.bDropColumn = 1; | ||
| 107831 | db->init.azInit = (char**)&zDropColumn; | ||
| 107832 | } | ||
| 107833 | 108514 | ||
| 107834 | /* Parse the SQL statement passed as the first argument. If no error | 108515 | /* Parse the SQL statement passed as the first argument. If no error |
| 107835 | ** occurs and the parse does not result in a new table, index or | 108516 | ** occurs and the parse does not result in a new table, index or |
| @@ -107862,7 +108543,6 @@ static int renameParseSql( | |||
| 107862 | #endif | 108543 | #endif |
| 107863 | 108544 | ||
| 107864 | db->init.iDb = 0; | 108545 | db->init.iDb = 0; |
| 107865 | db->init.bDropColumn = 0; | ||
| 107866 | return rc; | 108546 | return rc; |
| 107867 | } | 108547 | } |
| 107868 | 108548 | ||
| @@ -107882,51 +108562,76 @@ static int renameEditSql( | |||
| 107882 | const char *zNew, /* New token text */ | 108562 | const char *zNew, /* New token text */ |
| 107883 | int bQuote /* True to always quote token */ | 108563 | int bQuote /* True to always quote token */ |
| 107884 | ){ | 108564 | ){ |
| 107885 | int nNew = sqlite3Strlen30(zNew); | 108565 | i64 nNew = sqlite3Strlen30(zNew); |
| 107886 | int nSql = sqlite3Strlen30(zSql); | 108566 | i64 nSql = sqlite3Strlen30(zSql); |
| 107887 | sqlite3 *db = sqlite3_context_db_handle(pCtx); | 108567 | sqlite3 *db = sqlite3_context_db_handle(pCtx); |
| 107888 | int rc = SQLITE_OK; | 108568 | int rc = SQLITE_OK; |
| 107889 | char *zQuot; | 108569 | char *zQuot = 0; |
| 107890 | char *zOut; | 108570 | char *zOut; |
| 107891 | int nQuot; | 108571 | i64 nQuot = 0; |
| 107892 | 108572 | char *zBuf1 = 0; | |
| 107893 | /* Set zQuot to point to a buffer containing a quoted copy of the | 108573 | char *zBuf2 = 0; |
| 107894 | ** identifier zNew. If the corresponding identifier in the original | 108574 | |
| 107895 | ** ALTER TABLE statement was quoted (bQuote==1), then set zNew to | 108575 | if( zNew ){ |
| 107896 | ** point to zQuot so that all substitutions are made using the | 108576 | /* Set zQuot to point to a buffer containing a quoted copy of the |
| 107897 | ** quoted version of the new column name. */ | 108577 | ** identifier zNew. If the corresponding identifier in the original |
| 107898 | zQuot = sqlite3MPrintf(db, "\"%w\"", zNew); | 108578 | ** ALTER TABLE statement was quoted (bQuote==1), then set zNew to |
| 107899 | if( zQuot==0 ){ | 108579 | ** point to zQuot so that all substitutions are made using the |
| 107900 | return SQLITE_NOMEM; | 108580 | ** quoted version of the new column name. */ |
| 108581 | zQuot = sqlite3MPrintf(db, "\"%w\" ", zNew); | ||
| 108582 | if( zQuot==0 ){ | ||
| 108583 | return SQLITE_NOMEM; | ||
| 108584 | }else{ | ||
| 108585 | nQuot = sqlite3Strlen30(zQuot)-1; | ||
| 108586 | } | ||
| 108587 | |||
| 108588 | assert( nQuot>=nNew ); | ||
| 108589 | zOut = sqlite3DbMallocZero(db, nSql + pRename->nList*nQuot + 1); | ||
| 107901 | }else{ | 108590 | }else{ |
| 107902 | nQuot = sqlite3Strlen30(zQuot); | 108591 | zOut = (char*)sqlite3DbMallocZero(db, (nSql*2+1) * 3); |
| 107903 | } | 108592 | if( zOut ){ |
| 107904 | if( bQuote ){ | 108593 | zBuf1 = &zOut[nSql*2+1]; |
| 107905 | zNew = zQuot; | 108594 | zBuf2 = &zOut[nSql*4+2]; |
| 107906 | nNew = nQuot; | 108595 | } |
| 107907 | } | 108596 | } |
| 107908 | 108597 | ||
| 107909 | /* At this point pRename->pList contains a list of RenameToken objects | 108598 | /* At this point pRename->pList contains a list of RenameToken objects |
| 107910 | ** corresponding to all tokens in the input SQL that must be replaced | 108599 | ** corresponding to all tokens in the input SQL that must be replaced |
| 107911 | ** with the new column name. All that remains is to construct and | 108600 | ** with the new column name, or with single-quoted versions of themselves. |
| 107912 | ** return the edited SQL string. */ | 108601 | ** All that remains is to construct and return the edited SQL string. */ |
| 107913 | assert( nQuot>=nNew ); | ||
| 107914 | zOut = sqlite3DbMallocZero(db, nSql + pRename->nList*nQuot + 1); | ||
| 107915 | if( zOut ){ | 108602 | if( zOut ){ |
| 107916 | int nOut = nSql; | 108603 | int nOut = nSql; |
| 107917 | memcpy(zOut, zSql, nSql); | 108604 | memcpy(zOut, zSql, nSql); |
| 107918 | while( pRename->pList ){ | 108605 | while( pRename->pList ){ |
| 107919 | int iOff; /* Offset of token to replace in zOut */ | 108606 | int iOff; /* Offset of token to replace in zOut */ |
| 107920 | RenameToken *pBest = renameColumnTokenNext(pRename); | ||
| 107921 | |||
| 107922 | u32 nReplace; | 108607 | u32 nReplace; |
| 107923 | const char *zReplace; | 108608 | const char *zReplace; |
| 107924 | if( sqlite3IsIdChar(*pBest->t.z) ){ | 108609 | RenameToken *pBest = renameColumnTokenNext(pRename); |
| 107925 | nReplace = nNew; | 108610 | |
| 107926 | zReplace = zNew; | 108611 | if( zNew ){ |
| 108612 | if( bQuote==0 && sqlite3IsIdChar(*pBest->t.z) ){ | ||
| 108613 | nReplace = nNew; | ||
| 108614 | zReplace = zNew; | ||
| 108615 | }else{ | ||
| 108616 | nReplace = nQuot; | ||
| 108617 | zReplace = zQuot; | ||
| 108618 | if( pBest->t.z[pBest->t.n]=='"' ) nReplace++; | ||
| 108619 | } | ||
| 107927 | }else{ | 108620 | }else{ |
| 107928 | nReplace = nQuot; | 108621 | /* Dequote the double-quoted token. Then requote it again, this time |
| 107929 | zReplace = zQuot; | 108622 | ** using single quotes. If the character immediately following the |
| 108623 | ** original token within the input SQL was a single quote ('), then | ||
| 108624 | ** add another space after the new, single-quoted version of the | ||
| 108625 | ** token. This is so that (SELECT "string"'alias') maps to | ||
| 108626 | ** (SELECT 'string' 'alias'), and not (SELECT 'string''alias'). */ | ||
| 108627 | memcpy(zBuf1, pBest->t.z, pBest->t.n); | ||
| 108628 | zBuf1[pBest->t.n] = 0; | ||
| 108629 | sqlite3Dequote(zBuf1); | ||
| 108630 | sqlite3_snprintf(nSql*2, zBuf2, "%Q%s", zBuf1, | ||
| 108631 | pBest->t.z[pBest->t.n]=='\'' ? " " : "" | ||
| 108632 | ); | ||
| 108633 | zReplace = zBuf2; | ||
| 108634 | nReplace = sqlite3Strlen30(zReplace); | ||
| 107930 | } | 108635 | } |
| 107931 | 108636 | ||
| 107932 | iOff = pBest->t.z - zSql; | 108637 | iOff = pBest->t.z - zSql; |
| @@ -108164,7 +108869,7 @@ static void renameColumnFunc( | |||
| 108164 | #ifndef SQLITE_OMIT_AUTHORIZATION | 108869 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 108165 | db->xAuth = 0; | 108870 | db->xAuth = 0; |
| 108166 | #endif | 108871 | #endif |
| 108167 | rc = renameParseSql(&sParse, zDb, db, zSql, bTemp, 0); | 108872 | rc = renameParseSql(&sParse, zDb, db, zSql, bTemp); |
| 108168 | 108873 | ||
| 108169 | /* Find tokens that need to be replaced. */ | 108874 | /* Find tokens that need to be replaced. */ |
| 108170 | memset(&sWalker, 0, sizeof(Walker)); | 108875 | memset(&sWalker, 0, sizeof(Walker)); |
| @@ -108193,9 +108898,11 @@ static void renameColumnFunc( | |||
| 108193 | assert( sParse.pNewTable->pSelect==0 ); | 108898 | assert( sParse.pNewTable->pSelect==0 ); |
| 108194 | sCtx.pTab = sParse.pNewTable; | 108899 | sCtx.pTab = sParse.pNewTable; |
| 108195 | if( bFKOnly==0 ){ | 108900 | if( bFKOnly==0 ){ |
| 108196 | renameTokenFind( | 108901 | if( iCol<sParse.pNewTable->nCol ){ |
| 108197 | &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName | 108902 | renameTokenFind( |
| 108198 | ); | 108903 | &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName |
| 108904 | ); | ||
| 108905 | } | ||
| 108199 | if( sCtx.iCol<0 ){ | 108906 | if( sCtx.iCol<0 ){ |
| 108200 | renameTokenFind(&sParse, &sCtx, (void*)&sParse.pNewTable->iPKey); | 108907 | renameTokenFind(&sParse, &sCtx, (void*)&sParse.pNewTable->iPKey); |
| 108201 | } | 108908 | } |
| @@ -108297,8 +109004,12 @@ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ | |||
| 108297 | int i; | 109004 | int i; |
| 108298 | RenameCtx *p = pWalker->u.pRename; | 109005 | RenameCtx *p = pWalker->u.pRename; |
| 108299 | SrcList *pSrc = pSelect->pSrc; | 109006 | SrcList *pSrc = pSelect->pSrc; |
| 108300 | if( pSelect->selFlags & SF_View ) return WRC_Prune; | 109007 | if( pSelect->selFlags & (SF_View|SF_CopyCte) ){ |
| 108301 | if( pSrc==0 ){ | 109008 | testcase( pSelect->selFlags & SF_View ); |
| 109009 | testcase( pSelect->selFlags & SF_CopyCte ); | ||
| 109010 | return WRC_Prune; | ||
| 109011 | } | ||
| 109012 | if( NEVER(pSrc==0) ){ | ||
| 108302 | assert( pWalker->pParse->db->mallocFailed ); | 109013 | assert( pWalker->pParse->db->mallocFailed ); |
| 108303 | return WRC_Abort; | 109014 | return WRC_Abort; |
| 108304 | } | 109015 | } |
| @@ -108368,7 +109079,7 @@ static void renameTableFunc( | |||
| 108368 | sWalker.xSelectCallback = renameTableSelectCb; | 109079 | sWalker.xSelectCallback = renameTableSelectCb; |
| 108369 | sWalker.u.pRename = &sCtx; | 109080 | sWalker.u.pRename = &sCtx; |
| 108370 | 109081 | ||
| 108371 | rc = renameParseSql(&sParse, zDb, db, zInput, bTemp, 0); | 109082 | rc = renameParseSql(&sParse, zDb, db, zInput, bTemp); |
| 108372 | 109083 | ||
| 108373 | if( rc==SQLITE_OK ){ | 109084 | if( rc==SQLITE_OK ){ |
| 108374 | int isLegacy = (db->flags & SQLITE_LegacyAlter); | 109085 | int isLegacy = (db->flags & SQLITE_LegacyAlter); |
| @@ -108471,6 +109182,119 @@ static void renameTableFunc( | |||
| 108471 | return; | 109182 | return; |
| 108472 | } | 109183 | } |
| 108473 | 109184 | ||
| 109185 | static int renameQuotefixExprCb(Walker *pWalker, Expr *pExpr){ | ||
| 109186 | if( pExpr->op==TK_STRING && (pExpr->flags & EP_DblQuoted) ){ | ||
| 109187 | renameTokenFind(pWalker->pParse, pWalker->u.pRename, (void*)pExpr); | ||
| 109188 | } | ||
| 109189 | return WRC_Continue; | ||
| 109190 | } | ||
| 109191 | |||
| 109192 | /* | ||
| 109193 | ** The implementation of an SQL scalar function that rewrites DDL statements | ||
| 109194 | ** so that any string literals that use double-quotes are modified so that | ||
| 109195 | ** they use single quotes. | ||
| 109196 | ** | ||
| 109197 | ** Two arguments must be passed: | ||
| 109198 | ** | ||
| 109199 | ** 0: Database name ("main", "temp" etc.). | ||
| 109200 | ** 1: SQL statement to edit. | ||
| 109201 | ** | ||
| 109202 | ** The returned value is the modified SQL statement. For example, given | ||
| 109203 | ** the database schema: | ||
| 109204 | ** | ||
| 109205 | ** CREATE TABLE t1(a, b, c); | ||
| 109206 | ** | ||
| 109207 | ** SELECT sqlite_rename_quotefix('main', | ||
| 109208 | ** 'CREATE VIEW v1 AS SELECT "a", "string" FROM t1' | ||
| 109209 | ** ); | ||
| 109210 | ** | ||
| 109211 | ** returns the string: | ||
| 109212 | ** | ||
| 109213 | ** CREATE VIEW v1 AS SELECT "a", 'string' FROM t1 | ||
| 109214 | */ | ||
| 109215 | static void renameQuotefixFunc( | ||
| 109216 | sqlite3_context *context, | ||
| 109217 | int NotUsed, | ||
| 109218 | sqlite3_value **argv | ||
| 109219 | ){ | ||
| 109220 | sqlite3 *db = sqlite3_context_db_handle(context); | ||
| 109221 | char const *zDb = (const char*)sqlite3_value_text(argv[0]); | ||
| 109222 | char const *zInput = (const char*)sqlite3_value_text(argv[1]); | ||
| 109223 | |||
| 109224 | #ifndef SQLITE_OMIT_AUTHORIZATION | ||
| 109225 | sqlite3_xauth xAuth = db->xAuth; | ||
| 109226 | db->xAuth = 0; | ||
| 109227 | #endif | ||
| 109228 | |||
| 109229 | sqlite3BtreeEnterAll(db); | ||
| 109230 | |||
| 109231 | UNUSED_PARAMETER(NotUsed); | ||
| 109232 | if( zDb && zInput ){ | ||
| 109233 | int rc; | ||
| 109234 | Parse sParse; | ||
| 109235 | rc = renameParseSql(&sParse, zDb, db, zInput, 0); | ||
| 109236 | |||
| 109237 | if( rc==SQLITE_OK ){ | ||
| 109238 | RenameCtx sCtx; | ||
| 109239 | Walker sWalker; | ||
| 109240 | |||
| 109241 | /* Walker to find tokens that need to be replaced. */ | ||
| 109242 | memset(&sCtx, 0, sizeof(RenameCtx)); | ||
| 109243 | memset(&sWalker, 0, sizeof(Walker)); | ||
| 109244 | sWalker.pParse = &sParse; | ||
| 109245 | sWalker.xExprCallback = renameQuotefixExprCb; | ||
| 109246 | sWalker.xSelectCallback = renameColumnSelectCb; | ||
| 109247 | sWalker.u.pRename = &sCtx; | ||
| 109248 | |||
| 109249 | if( sParse.pNewTable ){ | ||
| 109250 | Select *pSelect = sParse.pNewTable->pSelect; | ||
| 109251 | if( pSelect ){ | ||
| 109252 | pSelect->selFlags &= ~SF_View; | ||
| 109253 | sParse.rc = SQLITE_OK; | ||
| 109254 | sqlite3SelectPrep(&sParse, pSelect, 0); | ||
| 109255 | rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc); | ||
| 109256 | if( rc==SQLITE_OK ){ | ||
| 109257 | sqlite3WalkSelect(&sWalker, pSelect); | ||
| 109258 | } | ||
| 109259 | }else{ | ||
| 109260 | int i; | ||
| 109261 | sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck); | ||
| 109262 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS | ||
| 109263 | for(i=0; i<sParse.pNewTable->nCol; i++){ | ||
| 109264 | sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt); | ||
| 109265 | } | ||
| 109266 | #endif /* SQLITE_OMIT_GENERATED_COLUMNS */ | ||
| 109267 | } | ||
| 109268 | }else if( sParse.pNewIndex ){ | ||
| 109269 | sqlite3WalkExprList(&sWalker, sParse.pNewIndex->aColExpr); | ||
| 109270 | sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere); | ||
| 109271 | }else{ | ||
| 109272 | #ifndef SQLITE_OMIT_TRIGGER | ||
| 109273 | rc = renameResolveTrigger(&sParse); | ||
| 109274 | if( rc==SQLITE_OK ){ | ||
| 109275 | renameWalkTrigger(&sWalker, sParse.pNewTrigger); | ||
| 109276 | } | ||
| 109277 | #endif /* SQLITE_OMIT_TRIGGER */ | ||
| 109278 | } | ||
| 109279 | |||
| 109280 | if( rc==SQLITE_OK ){ | ||
| 109281 | rc = renameEditSql(context, &sCtx, zInput, 0, 0); | ||
| 109282 | } | ||
| 109283 | renameTokenFree(db, sCtx.pList); | ||
| 109284 | } | ||
| 109285 | if( rc!=SQLITE_OK ){ | ||
| 109286 | sqlite3_result_error_code(context, rc); | ||
| 109287 | } | ||
| 109288 | renameParseCleanup(&sParse); | ||
| 109289 | } | ||
| 109290 | |||
| 109291 | #ifndef SQLITE_OMIT_AUTHORIZATION | ||
| 109292 | db->xAuth = xAuth; | ||
| 109293 | #endif | ||
| 109294 | |||
| 109295 | sqlite3BtreeLeaveAll(db); | ||
| 109296 | } | ||
| 109297 | |||
| 108474 | /* | 109298 | /* |
| 108475 | ** An SQL user function that checks that there are no parse or symbol | 109299 | ** An SQL user function that checks that there are no parse or symbol |
| 108476 | ** resolution problems in a CREATE TRIGGER|TABLE|VIEW|INDEX statement. | 109300 | ** resolution problems in a CREATE TRIGGER|TABLE|VIEW|INDEX statement. |
| @@ -108484,7 +109308,7 @@ static void renameTableFunc( | |||
| 108484 | ** 3: Object name. | 109308 | ** 3: Object name. |
| 108485 | ** 4: True if object is from temp schema. | 109309 | ** 4: True if object is from temp schema. |
| 108486 | ** 5: "when" part of error message. | 109310 | ** 5: "when" part of error message. |
| 108487 | ** 6: Name of column being dropped, or NULL. | 109311 | ** 6: True to disable the DQS quirk when parsing SQL. |
| 108488 | ** | 109312 | ** |
| 108489 | ** Unless it finds an error, this function normally returns NULL. However, it | 109313 | ** Unless it finds an error, this function normally returns NULL. However, it |
| 108490 | ** returns integer value 1 if: | 109314 | ** returns integer value 1 if: |
| @@ -108503,7 +109327,7 @@ static void renameTableTest( | |||
| 108503 | int bTemp = sqlite3_value_int(argv[4]); | 109327 | int bTemp = sqlite3_value_int(argv[4]); |
| 108504 | int isLegacy = (db->flags & SQLITE_LegacyAlter); | 109328 | int isLegacy = (db->flags & SQLITE_LegacyAlter); |
| 108505 | char const *zWhen = (const char*)sqlite3_value_text(argv[5]); | 109329 | char const *zWhen = (const char*)sqlite3_value_text(argv[5]); |
| 108506 | char const *zDropColumn = (const char*)sqlite3_value_text(argv[6]); | 109330 | int bNoDQS = sqlite3_value_int(argv[6]); |
| 108507 | 109331 | ||
| 108508 | #ifndef SQLITE_OMIT_AUTHORIZATION | 109332 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 108509 | sqlite3_xauth xAuth = db->xAuth; | 109333 | sqlite3_xauth xAuth = db->xAuth; |
| @@ -108511,10 +109335,14 @@ static void renameTableTest( | |||
| 108511 | #endif | 109335 | #endif |
| 108512 | 109336 | ||
| 108513 | UNUSED_PARAMETER(NotUsed); | 109337 | UNUSED_PARAMETER(NotUsed); |
| 109338 | |||
| 108514 | if( zDb && zInput ){ | 109339 | if( zDb && zInput ){ |
| 108515 | int rc; | 109340 | int rc; |
| 108516 | Parse sParse; | 109341 | Parse sParse; |
| 108517 | rc = renameParseSql(&sParse, zDb, db, zInput, bTemp, zDropColumn); | 109342 | int flags = db->flags; |
| 109343 | if( bNoDQS ) db->flags &= ~(SQLITE_DqsDML|SQLITE_DqsDDL); | ||
| 109344 | rc = renameParseSql(&sParse, zDb, db, zInput, bTemp); | ||
| 109345 | db->flags |= (flags & (SQLITE_DqsDML|SQLITE_DqsDDL)); | ||
| 108518 | if( rc==SQLITE_OK ){ | 109346 | if( rc==SQLITE_OK ){ |
| 108519 | if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){ | 109347 | if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){ |
| 108520 | NameContext sNC; | 109348 | NameContext sNC; |
| @@ -108582,7 +109410,7 @@ static void dropColumnFunc( | |||
| 108582 | #endif | 109410 | #endif |
| 108583 | 109411 | ||
| 108584 | UNUSED_PARAMETER(NotUsed); | 109412 | UNUSED_PARAMETER(NotUsed); |
| 108585 | rc = renameParseSql(&sParse, zDb, db, zSql, iSchema==1, 0); | 109413 | rc = renameParseSql(&sParse, zDb, db, zSql, iSchema==1); |
| 108586 | if( rc!=SQLITE_OK ) goto drop_column_done; | 109414 | if( rc!=SQLITE_OK ) goto drop_column_done; |
| 108587 | pTab = sParse.pNewTable; | 109415 | pTab = sParse.pNewTable; |
| 108588 | if( pTab==0 || pTab->nCol==1 || iCol>=pTab->nCol ){ | 109416 | if( pTab==0 || pTab->nCol==1 || iCol>=pTab->nCol ){ |
| @@ -108676,6 +109504,7 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, Token * | |||
| 108676 | assert( iDb>=0 ); | 109504 | assert( iDb>=0 ); |
| 108677 | zDb = db->aDb[iDb].zDbSName; | 109505 | zDb = db->aDb[iDb].zDbSName; |
| 108678 | renameTestSchema(pParse, zDb, iDb==1, "", 0); | 109506 | renameTestSchema(pParse, zDb, iDb==1, "", 0); |
| 109507 | renameFixQuotes(pParse, zDb, iDb==1); | ||
| 108679 | sqlite3NestedParse(pParse, | 109508 | sqlite3NestedParse(pParse, |
| 108680 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET " | 109509 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET " |
| 108681 | "sql = sqlite_drop_column(%d, sql, %d) " | 109510 | "sql = sqlite_drop_column(%d, sql, %d) " |
| @@ -108685,7 +109514,7 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, Token * | |||
| 108685 | 109514 | ||
| 108686 | /* Drop and reload the database schema. */ | 109515 | /* Drop and reload the database schema. */ |
| 108687 | renameReloadSchema(pParse, iDb, INITFLAG_AlterDrop); | 109516 | renameReloadSchema(pParse, iDb, INITFLAG_AlterDrop); |
| 108688 | renameTestSchema(pParse, zDb, iDb==1, "after drop column", zCol); | 109517 | renameTestSchema(pParse, zDb, iDb==1, "after drop column", 1); |
| 108689 | 109518 | ||
| 108690 | /* Edit rows of table on disk */ | 109519 | /* Edit rows of table on disk */ |
| 108691 | if( pParse->nErr==0 && (pTab->aCol[iCol].colFlags & COLFLAG_VIRTUAL)==0 ){ | 109520 | if( pParse->nErr==0 && (pTab->aCol[iCol].colFlags & COLFLAG_VIRTUAL)==0 ){ |
| @@ -108758,6 +109587,7 @@ SQLITE_PRIVATE void sqlite3AlterFunctions(void){ | |||
| 108758 | INTERNAL_FUNCTION(sqlite_rename_table, 7, renameTableFunc), | 109587 | INTERNAL_FUNCTION(sqlite_rename_table, 7, renameTableFunc), |
| 108759 | INTERNAL_FUNCTION(sqlite_rename_test, 7, renameTableTest), | 109588 | INTERNAL_FUNCTION(sqlite_rename_test, 7, renameTableTest), |
| 108760 | INTERNAL_FUNCTION(sqlite_drop_column, 3, dropColumnFunc), | 109589 | INTERNAL_FUNCTION(sqlite_drop_column, 3, dropColumnFunc), |
| 109590 | INTERNAL_FUNCTION(sqlite_rename_quotefix,2, renameQuotefixFunc), | ||
| 108761 | }; | 109591 | }; |
| 108762 | sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs)); | 109592 | sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs)); |
| 108763 | } | 109593 | } |
| @@ -110808,7 +111638,7 @@ static void attachFunc( | |||
| 110808 | if( zFile==0 ) zFile = ""; | 111638 | if( zFile==0 ) zFile = ""; |
| 110809 | if( zName==0 ) zName = ""; | 111639 | if( zName==0 ) zName = ""; |
| 110810 | 111640 | ||
| 110811 | #ifdef SQLITE_ENABLE_DESERIALIZE | 111641 | #ifndef SQLITE_OMIT_DESERIALIZE |
| 110812 | # define REOPEN_AS_MEMDB(db) (db->init.reopenMemdb) | 111642 | # define REOPEN_AS_MEMDB(db) (db->init.reopenMemdb) |
| 110813 | #else | 111643 | #else |
| 110814 | # define REOPEN_AS_MEMDB(db) (0) | 111644 | # define REOPEN_AS_MEMDB(db) (0) |
| @@ -111177,14 +112007,17 @@ static int fixSelectCb(Walker *p, Select *pSelect){ | |||
| 111177 | if( NEVER(pList==0) ) return WRC_Continue; | 112007 | if( NEVER(pList==0) ) return WRC_Continue; |
| 111178 | for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ | 112008 | for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ |
| 111179 | if( pFix->bTemp==0 ){ | 112009 | if( pFix->bTemp==0 ){ |
| 111180 | if( pItem->zDatabase && iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){ | 112010 | if( pItem->zDatabase ){ |
| 111181 | sqlite3ErrorMsg(pFix->pParse, | 112011 | if( iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){ |
| 111182 | "%s %T cannot reference objects in database %s", | 112012 | sqlite3ErrorMsg(pFix->pParse, |
| 111183 | pFix->zType, pFix->pName, pItem->zDatabase); | 112013 | "%s %T cannot reference objects in database %s", |
| 111184 | return WRC_Abort; | 112014 | pFix->zType, pFix->pName, pItem->zDatabase); |
| 112015 | return WRC_Abort; | ||
| 112016 | } | ||
| 112017 | sqlite3DbFree(db, pItem->zDatabase); | ||
| 112018 | pItem->zDatabase = 0; | ||
| 112019 | pItem->fg.notCte = 1; | ||
| 111185 | } | 112020 | } |
| 111186 | sqlite3DbFree(db, pItem->zDatabase); | ||
| 111187 | pItem->zDatabase = 0; | ||
| 111188 | pItem->pSchema = pFix->pSchema; | 112021 | pItem->pSchema = pFix->pSchema; |
| 111189 | pItem->fg.fromDDL = 1; | 112022 | pItem->fg.fromDDL = 1; |
| 111190 | } | 112023 | } |
| @@ -111224,7 +112057,7 @@ SQLITE_PRIVATE void sqlite3FixInit( | |||
| 111224 | pFix->w.pParse = pParse; | 112057 | pFix->w.pParse = pParse; |
| 111225 | pFix->w.xExprCallback = fixExprCb; | 112058 | pFix->w.xExprCallback = fixExprCb; |
| 111226 | pFix->w.xSelectCallback = fixSelectCb; | 112059 | pFix->w.xSelectCallback = fixSelectCb; |
| 111227 | pFix->w.xSelectCallback2 = 0; | 112060 | pFix->w.xSelectCallback2 = sqlite3WalkWinDefnDummyCallback; |
| 111228 | pFix->w.walkerDepth = 0; | 112061 | pFix->w.walkerDepth = 0; |
| 111229 | pFix->w.eCode = 0; | 112062 | pFix->w.eCode = 0; |
| 111230 | pFix->w.u.pFix = pFix; | 112063 | pFix->w.u.pFix = pFix; |
| @@ -111286,14 +112119,16 @@ SQLITE_PRIVATE int sqlite3FixTriggerStep( | |||
| 111286 | return 1; | 112119 | return 1; |
| 111287 | } | 112120 | } |
| 111288 | #ifndef SQLITE_OMIT_UPSERT | 112121 | #ifndef SQLITE_OMIT_UPSERT |
| 111289 | if( pStep->pUpsert ){ | 112122 | { |
| 111290 | Upsert *pUp = pStep->pUpsert; | 112123 | Upsert *pUp; |
| 111291 | if( sqlite3WalkExprList(&pFix->w, pUp->pUpsertTarget) | 112124 | for(pUp=pStep->pUpsert; pUp; pUp=pUp->pNextUpsert){ |
| 111292 | || sqlite3WalkExpr(&pFix->w, pUp->pUpsertTargetWhere) | 112125 | if( sqlite3WalkExprList(&pFix->w, pUp->pUpsertTarget) |
| 111293 | || sqlite3WalkExprList(&pFix->w, pUp->pUpsertSet) | 112126 | || sqlite3WalkExpr(&pFix->w, pUp->pUpsertTargetWhere) |
| 111294 | || sqlite3WalkExpr(&pFix->w, pUp->pUpsertWhere) | 112127 | || sqlite3WalkExprList(&pFix->w, pUp->pUpsertSet) |
| 111295 | ){ | 112128 | || sqlite3WalkExpr(&pFix->w, pUp->pUpsertWhere) |
| 111296 | return 1; | 112129 | ){ |
| 112130 | return 1; | ||
| 112131 | } | ||
| 111297 | } | 112132 | } |
| 111298 | } | 112133 | } |
| 111299 | #endif | 112134 | #endif |
| @@ -111625,7 +112460,7 @@ struct TableLock { | |||
| 111625 | ** code to make the lock occur is generated by a later call to | 112460 | ** code to make the lock occur is generated by a later call to |
| 111626 | ** codeTableLocks() which occurs during sqlite3FinishCoding(). | 112461 | ** codeTableLocks() which occurs during sqlite3FinishCoding(). |
| 111627 | */ | 112462 | */ |
| 111628 | SQLITE_PRIVATE void sqlite3TableLock( | 112463 | static SQLITE_NOINLINE void lockTable( |
| 111629 | Parse *pParse, /* Parsing context */ | 112464 | Parse *pParse, /* Parsing context */ |
| 111630 | int iDb, /* Index of the database containing the table to lock */ | 112465 | int iDb, /* Index of the database containing the table to lock */ |
| 111631 | Pgno iTab, /* Root page number of the table to be locked */ | 112466 | Pgno iTab, /* Root page number of the table to be locked */ |
| @@ -111638,8 +112473,6 @@ SQLITE_PRIVATE void sqlite3TableLock( | |||
| 111638 | TableLock *p; | 112473 | TableLock *p; |
| 111639 | assert( iDb>=0 ); | 112474 | assert( iDb>=0 ); |
| 111640 | 112475 | ||
| 111641 | if( iDb==1 ) return; | ||
| 111642 | if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return; | ||
| 111643 | pToplevel = sqlite3ParseToplevel(pParse); | 112476 | pToplevel = sqlite3ParseToplevel(pParse); |
| 111644 | for(i=0; i<pToplevel->nTableLock; i++){ | 112477 | for(i=0; i<pToplevel->nTableLock; i++){ |
| 111645 | p = &pToplevel->aTableLock[i]; | 112478 | p = &pToplevel->aTableLock[i]; |
| @@ -111663,6 +112496,17 @@ SQLITE_PRIVATE void sqlite3TableLock( | |||
| 111663 | sqlite3OomFault(pToplevel->db); | 112496 | sqlite3OomFault(pToplevel->db); |
| 111664 | } | 112497 | } |
| 111665 | } | 112498 | } |
| 112499 | SQLITE_PRIVATE void sqlite3TableLock( | ||
| 112500 | Parse *pParse, /* Parsing context */ | ||
| 112501 | int iDb, /* Index of the database containing the table to lock */ | ||
| 112502 | Pgno iTab, /* Root page number of the table to be locked */ | ||
| 112503 | u8 isWriteLock, /* True for a write lock */ | ||
| 112504 | const char *zName /* Name of the table to be locked */ | ||
| 112505 | ){ | ||
| 112506 | if( iDb==1 ) return; | ||
| 112507 | if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return; | ||
| 112508 | lockTable(pParse, iDb, iTab, isWriteLock, zName); | ||
| 112509 | } | ||
| 111666 | 112510 | ||
| 111667 | /* | 112511 | /* |
| 111668 | ** Code an OP_TableLock instruction for each table locked by the | 112512 | ** Code an OP_TableLock instruction for each table locked by the |
| @@ -112017,7 +112861,7 @@ SQLITE_PRIVATE Table *sqlite3LocateTable( | |||
| 112017 | /* If zName is the not the name of a table in the schema created using | 112861 | /* If zName is the not the name of a table in the schema created using |
| 112018 | ** CREATE, then check to see if it is the name of an virtual table that | 112862 | ** CREATE, then check to see if it is the name of an virtual table that |
| 112019 | ** can be an eponymous virtual table. */ | 112863 | ** can be an eponymous virtual table. */ |
| 112020 | if( pParse->disableVtab==0 ){ | 112864 | if( pParse->disableVtab==0 && db->init.busy==0 ){ |
| 112021 | Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName); | 112865 | Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName); |
| 112022 | if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){ | 112866 | if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){ |
| 112023 | pMod = sqlite3PragmaVtabRegister(db, zName); | 112867 | pMod = sqlite3PragmaVtabRegister(db, zName); |
| @@ -112040,6 +112884,8 @@ SQLITE_PRIVATE Table *sqlite3LocateTable( | |||
| 112040 | }else{ | 112884 | }else{ |
| 112041 | sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName); | 112885 | sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName); |
| 112042 | } | 112886 | } |
| 112887 | }else{ | ||
| 112888 | assert( HasRowid(p) || p->iPKey<0 ); | ||
| 112043 | } | 112889 | } |
| 112044 | 112890 | ||
| 112045 | return p; | 112891 | return p; |
| @@ -112456,7 +113302,7 @@ SQLITE_PRIVATE int sqlite3TwoPartName( | |||
| 112456 | return -1; | 113302 | return -1; |
| 112457 | } | 113303 | } |
| 112458 | }else{ | 113304 | }else{ |
| 112459 | assert( db->init.iDb==0 || db->init.busy || IN_RENAME_OBJECT | 113305 | assert( db->init.iDb==0 || db->init.busy || IN_SPECIAL_PARSE |
| 112460 | || (db->mDbFlags & DBFLAG_Vacuum)!=0); | 113306 | || (db->mDbFlags & DBFLAG_Vacuum)!=0); |
| 112461 | iDb = db->init.iDb; | 113307 | iDb = db->init.iDb; |
| 112462 | *pUnqual = pName1; | 113308 | *pUnqual = pName1; |
| @@ -112626,6 +113472,23 @@ SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table *pTab, i16 iCol){ | |||
| 112626 | #endif | 113472 | #endif |
| 112627 | 113473 | ||
| 112628 | /* | 113474 | /* |
| 113475 | ** Insert a single OP_JournalMode query opcode in order to force the | ||
| 113476 | ** prepared statement to return false for sqlite3_stmt_readonly(). This | ||
| 113477 | ** is used by CREATE TABLE IF NOT EXISTS and similar if the table already | ||
| 113478 | ** exists, so that the prepared statement for CREATE TABLE IF NOT EXISTS | ||
| 113479 | ** will return false for sqlite3_stmt_readonly() even if that statement | ||
| 113480 | ** is a read-only no-op. | ||
| 113481 | */ | ||
| 113482 | static void sqlite3ForceNotReadOnly(Parse *pParse){ | ||
| 113483 | int iReg = ++pParse->nMem; | ||
| 113484 | Vdbe *v = sqlite3GetVdbe(pParse); | ||
| 113485 | if( v ){ | ||
| 113486 | sqlite3VdbeAddOp3(v, OP_JournalMode, 0, iReg, PAGER_JOURNALMODE_QUERY); | ||
| 113487 | sqlite3VdbeUsesBtree(v, 0); | ||
| 113488 | } | ||
| 113489 | } | ||
| 113490 | |||
| 113491 | /* | ||
| 112629 | ** Begin constructing a new table representation in memory. This is | 113492 | ** Begin constructing a new table representation in memory. This is |
| 112630 | ** the first of several action routines that get called in response | 113493 | ** the first of several action routines that get called in response |
| 112631 | ** to a CREATE TABLE statement. In particular, this routine is called | 113494 | ** to a CREATE TABLE statement. In particular, this routine is called |
| @@ -112724,6 +113587,7 @@ SQLITE_PRIVATE void sqlite3StartTable( | |||
| 112724 | }else{ | 113587 | }else{ |
| 112725 | assert( !db->init.busy || CORRUPT_DB ); | 113588 | assert( !db->init.busy || CORRUPT_DB ); |
| 112726 | sqlite3CodeVerifySchema(pParse, iDb); | 113589 | sqlite3CodeVerifySchema(pParse, iDb); |
| 113590 | sqlite3ForceNotReadOnly(pParse); | ||
| 112727 | } | 113591 | } |
| 112728 | goto begin_table_error; | 113592 | goto begin_table_error; |
| 112729 | } | 113593 | } |
| @@ -112752,17 +113616,6 @@ SQLITE_PRIVATE void sqlite3StartTable( | |||
| 112752 | assert( pParse->pNewTable==0 ); | 113616 | assert( pParse->pNewTable==0 ); |
| 112753 | pParse->pNewTable = pTable; | 113617 | pParse->pNewTable = pTable; |
| 112754 | 113618 | ||
| 112755 | /* If this is the magic sqlite_sequence table used by autoincrement, | ||
| 112756 | ** then record a pointer to this table in the main database structure | ||
| 112757 | ** so that INSERT can find the table easily. | ||
| 112758 | */ | ||
| 112759 | #ifndef SQLITE_OMIT_AUTOINCREMENT | ||
| 112760 | if( !pParse->nested && strcmp(zName, "sqlite_sequence")==0 ){ | ||
| 112761 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); | ||
| 112762 | pTable->pSchema->pSeqTab = pTable; | ||
| 112763 | } | ||
| 112764 | #endif | ||
| 112765 | |||
| 112766 | /* Begin generating the code that will insert the table record into | 113619 | /* Begin generating the code that will insert the table record into |
| 112767 | ** the schema table. Note in particular that we must go ahead | 113620 | ** the schema table. Note in particular that we must go ahead |
| 112768 | ** and allocate the record number for the table entry now. Before any | 113621 | ** and allocate the record number for the table entry now. Before any |
| @@ -112911,6 +113764,7 @@ SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){ | |||
| 112911 | pRet->retTrig.tr_tm = TRIGGER_AFTER; | 113764 | pRet->retTrig.tr_tm = TRIGGER_AFTER; |
| 112912 | pRet->retTrig.bReturning = 1; | 113765 | pRet->retTrig.bReturning = 1; |
| 112913 | pRet->retTrig.pSchema = db->aDb[1].pSchema; | 113766 | pRet->retTrig.pSchema = db->aDb[1].pSchema; |
| 113767 | pRet->retTrig.pTabSchema = db->aDb[1].pSchema; | ||
| 112914 | pRet->retTrig.step_list = &pRet->retTStep; | 113768 | pRet->retTrig.step_list = &pRet->retTStep; |
| 112915 | pRet->retTStep.op = TK_RETURNING; | 113769 | pRet->retTStep.op = TK_RETURNING; |
| 112916 | pRet->retTStep.pTrig = &pRet->retTrig; | 113770 | pRet->retTStep.pTrig = &pRet->retTrig; |
| @@ -113769,7 +114623,10 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ | |||
| 113769 | sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName); | 114623 | sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName); |
| 113770 | pList = sqlite3ExprListAppend(pParse, 0, | 114624 | pList = sqlite3ExprListAppend(pParse, 0, |
| 113771 | sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0)); | 114625 | sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0)); |
| 113772 | if( pList==0 ) return; | 114626 | if( pList==0 ){ |
| 114627 | pTab->tabFlags &= ~TF_WithoutRowid; | ||
| 114628 | return; | ||
| 114629 | } | ||
| 113773 | if( IN_RENAME_OBJECT ){ | 114630 | if( IN_RENAME_OBJECT ){ |
| 113774 | sqlite3RenameTokenRemap(pParse, pList->a[0].pExpr, &pTab->iPKey); | 114631 | sqlite3RenameTokenRemap(pParse, pList->a[0].pExpr, &pTab->iPKey); |
| 113775 | } | 114632 | } |
| @@ -113778,7 +114635,10 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ | |||
| 113778 | pTab->iPKey = -1; | 114635 | pTab->iPKey = -1; |
| 113779 | sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0, | 114636 | sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0, |
| 113780 | SQLITE_IDXTYPE_PRIMARYKEY); | 114637 | SQLITE_IDXTYPE_PRIMARYKEY); |
| 113781 | if( db->mallocFailed || pParse->nErr ) return; | 114638 | if( db->mallocFailed || pParse->nErr ){ |
| 114639 | pTab->tabFlags &= ~TF_WithoutRowid; | ||
| 114640 | return; | ||
| 114641 | } | ||
| 113782 | pPk = sqlite3PrimaryKeyIndex(pTab); | 114642 | pPk = sqlite3PrimaryKeyIndex(pTab); |
| 113783 | assert( pPk->nKeyCol==1 ); | 114643 | assert( pPk->nKeyCol==1 ); |
| 113784 | }else{ | 114644 | }else{ |
| @@ -113982,7 +114842,6 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 113982 | if( pEnd==0 && pSelect==0 ){ | 114842 | if( pEnd==0 && pSelect==0 ){ |
| 113983 | return; | 114843 | return; |
| 113984 | } | 114844 | } |
| 113985 | assert( !db->mallocFailed ); | ||
| 113986 | p = pParse->pNewTable; | 114845 | p = pParse->pNewTable; |
| 113987 | if( p==0 ) return; | 114846 | if( p==0 ) return; |
| 113988 | 114847 | ||
| @@ -114207,7 +115066,7 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 114207 | /* Check to see if we need to create an sqlite_sequence table for | 115066 | /* Check to see if we need to create an sqlite_sequence table for |
| 114208 | ** keeping track of autoincrement keys. | 115067 | ** keeping track of autoincrement keys. |
| 114209 | */ | 115068 | */ |
| 114210 | if( (p->tabFlags & TF_Autoincrement)!=0 ){ | 115069 | if( (p->tabFlags & TF_Autoincrement)!=0 && !IN_SPECIAL_PARSE ){ |
| 114211 | Db *pDb = &db->aDb[iDb]; | 115070 | Db *pDb = &db->aDb[iDb]; |
| 114212 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); | 115071 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 114213 | if( pDb->pSchema->pSeqTab==0 ){ | 115072 | if( pDb->pSchema->pSeqTab==0 ){ |
| @@ -114230,6 +115089,7 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 114230 | Table *pOld; | 115089 | Table *pOld; |
| 114231 | Schema *pSchema = p->pSchema; | 115090 | Schema *pSchema = p->pSchema; |
| 114232 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); | 115091 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 115092 | assert( HasRowid(p) || p->iPKey<0 ); | ||
| 114233 | pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p); | 115093 | pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p); |
| 114234 | if( pOld ){ | 115094 | if( pOld ){ |
| 114235 | assert( p==pOld ); /* Malloc must have failed inside HashInsert() */ | 115095 | assert( p==pOld ); /* Malloc must have failed inside HashInsert() */ |
| @@ -114238,6 +115098,17 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 114238 | } | 115098 | } |
| 114239 | pParse->pNewTable = 0; | 115099 | pParse->pNewTable = 0; |
| 114240 | db->mDbFlags |= DBFLAG_SchemaChange; | 115100 | db->mDbFlags |= DBFLAG_SchemaChange; |
| 115101 | |||
| 115102 | /* If this is the magic sqlite_sequence table used by autoincrement, | ||
| 115103 | ** then record a pointer to this table in the main database structure | ||
| 115104 | ** so that INSERT can find the table easily. */ | ||
| 115105 | assert( !pParse->nested ); | ||
| 115106 | #ifndef SQLITE_OMIT_AUTOINCREMENT | ||
| 115107 | if( strcmp(p->zName, "sqlite_sequence")==0 ){ | ||
| 115108 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); | ||
| 115109 | p->pSchema->pSeqTab = p; | ||
| 115110 | } | ||
| 115111 | #endif | ||
| 114241 | } | 115112 | } |
| 114242 | 115113 | ||
| 114243 | #ifndef SQLITE_OMIT_ALTERTABLE | 115114 | #ifndef SQLITE_OMIT_ALTERTABLE |
| @@ -114281,6 +115152,16 @@ SQLITE_PRIVATE void sqlite3CreateView( | |||
| 114281 | sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr); | 115152 | sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr); |
| 114282 | p = pParse->pNewTable; | 115153 | p = pParse->pNewTable; |
| 114283 | if( p==0 || pParse->nErr ) goto create_view_fail; | 115154 | if( p==0 || pParse->nErr ) goto create_view_fail; |
| 115155 | |||
| 115156 | /* Legacy versions of SQLite allowed the use of the magic "rowid" column | ||
| 115157 | ** on a view, even though views do not have rowids. The following flag | ||
| 115158 | ** setting fixes this problem. But the fix can be disabled by compiling | ||
| 115159 | ** with -DSQLITE_ALLOW_ROWID_IN_VIEW in case there are legacy apps that | ||
| 115160 | ** depend upon the old buggy behavior. */ | ||
| 115161 | #ifndef SQLITE_ALLOW_ROWID_IN_VIEW | ||
| 115162 | p->tabFlags |= TF_NoVisibleRowid; | ||
| 115163 | #endif | ||
| 115164 | |||
| 114284 | sqlite3TwoPartName(pParse, pName1, pName2, &pName); | 115165 | sqlite3TwoPartName(pParse, pName1, pName2, &pName); |
| 114285 | iDb = sqlite3SchemaToIndex(db, p->pSchema); | 115166 | iDb = sqlite3SchemaToIndex(db, p->pSchema); |
| 114286 | sqlite3FixInit(&sFix, pParse, iDb, "view", pName); | 115167 | sqlite3FixInit(&sFix, pParse, iDb, "view", pName); |
| @@ -114757,7 +115638,10 @@ SQLITE_PRIVATE void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, | |||
| 114757 | if( noErr ) db->suppressErr--; | 115638 | if( noErr ) db->suppressErr--; |
| 114758 | 115639 | ||
| 114759 | if( pTab==0 ){ | 115640 | if( pTab==0 ){ |
| 114760 | if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); | 115641 | if( noErr ){ |
| 115642 | sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); | ||
| 115643 | sqlite3ForceNotReadOnly(pParse); | ||
| 115644 | } | ||
| 114761 | goto exit_drop_table; | 115645 | goto exit_drop_table; |
| 114762 | } | 115646 | } |
| 114763 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); | 115647 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| @@ -115327,6 +116211,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex( | |||
| 115327 | }else{ | 116211 | }else{ |
| 115328 | assert( !db->init.busy ); | 116212 | assert( !db->init.busy ); |
| 115329 | sqlite3CodeVerifySchema(pParse, iDb); | 116213 | sqlite3CodeVerifySchema(pParse, iDb); |
| 116214 | sqlite3ForceNotReadOnly(pParse); | ||
| 115330 | } | 116215 | } |
| 115331 | goto exit_create_index; | 116216 | goto exit_create_index; |
| 115332 | } | 116217 | } |
| @@ -115807,7 +116692,7 @@ SQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){ | |||
| 115807 | if( x<99 ){ | 116692 | if( x<99 ){ |
| 115808 | pIdx->pTable->nRowLogEst = x = 99; | 116693 | pIdx->pTable->nRowLogEst = x = 99; |
| 115809 | } | 116694 | } |
| 115810 | if( pIdx->pPartIdxWhere!=0 ) x -= 10; assert( 10==sqlite3LogEst(2) ); | 116695 | if( pIdx->pPartIdxWhere!=0 ){ x -= 10; assert( 10==sqlite3LogEst(2) ); } |
| 115811 | a[0] = x; | 116696 | a[0] = x; |
| 115812 | 116697 | ||
| 115813 | /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is | 116698 | /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is |
| @@ -115842,9 +116727,10 @@ SQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists | |||
| 115842 | pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].zDatabase); | 116727 | pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].zDatabase); |
| 115843 | if( pIndex==0 ){ | 116728 | if( pIndex==0 ){ |
| 115844 | if( !ifExists ){ | 116729 | if( !ifExists ){ |
| 115845 | sqlite3ErrorMsg(pParse, "no such index: %S", pName, 0); | 116730 | sqlite3ErrorMsg(pParse, "no such index: %S", pName->a); |
| 115846 | }else{ | 116731 | }else{ |
| 115847 | sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); | 116732 | sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); |
| 116733 | sqlite3ForceNotReadOnly(pParse); | ||
| 115848 | } | 116734 | } |
| 115849 | pParse->checkSchema = 1; | 116735 | pParse->checkSchema = 1; |
| 115850 | goto exit_drop_index; | 116736 | goto exit_drop_index; |
| @@ -115864,7 +116750,7 @@ SQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists | |||
| 115864 | if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){ | 116750 | if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){ |
| 115865 | goto exit_drop_index; | 116751 | goto exit_drop_index; |
| 115866 | } | 116752 | } |
| 115867 | if( !OMIT_TEMPDB && iDb ) code = SQLITE_DROP_TEMP_INDEX; | 116753 | if( !OMIT_TEMPDB && iDb==1 ) code = SQLITE_DROP_TEMP_INDEX; |
| 115868 | if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){ | 116754 | if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){ |
| 115869 | goto exit_drop_index; | 116755 | goto exit_drop_index; |
| 115870 | } | 116756 | } |
| @@ -116156,8 +117042,8 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListAppend( | |||
| 116156 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){ | 117042 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){ |
| 116157 | int i; | 117043 | int i; |
| 116158 | SrcItem *pItem; | 117044 | SrcItem *pItem; |
| 116159 | assert(pList || pParse->db->mallocFailed ); | 117045 | assert( pList || pParse->db->mallocFailed ); |
| 116160 | if( pList ){ | 117046 | if( ALWAYS(pList) ){ |
| 116161 | for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ | 117047 | for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ |
| 116162 | if( pItem->iCursor>=0 ) continue; | 117048 | if( pItem->iCursor>=0 ) continue; |
| 116163 | pItem->iCursor = pParse->nTab++; | 117049 | pItem->iCursor = pParse->nTab++; |
| @@ -117882,6 +118768,9 @@ SQLITE_PRIVATE void sqlite3DeleteFrom( | |||
| 117882 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ | 118768 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 117883 | assert( pIdx->pSchema==pTab->pSchema ); | 118769 | assert( pIdx->pSchema==pTab->pSchema ); |
| 117884 | sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb); | 118770 | sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb); |
| 118771 | if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){ | ||
| 118772 | sqlite3VdbeChangeP3(v, -1, memCnt ? memCnt : -1); | ||
| 118773 | } | ||
| 117885 | } | 118774 | } |
| 117886 | }else | 118775 | }else |
| 117887 | #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ | 118776 | #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ |
| @@ -118393,13 +119282,15 @@ SQLITE_PRIVATE int sqlite3GenerateIndexKey( | |||
| 118393 | continue; | 119282 | continue; |
| 118394 | } | 119283 | } |
| 118395 | sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j); | 119284 | sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j); |
| 118396 | /* If the column affinity is REAL but the number is an integer, then it | 119285 | if( pIdx->aiColumn[j]>=0 ){ |
| 118397 | ** might be stored in the table as an integer (using a compact | 119286 | /* If the column affinity is REAL but the number is an integer, then it |
| 118398 | ** representation) then converted to REAL by an OP_RealAffinity opcode. | 119287 | ** might be stored in the table as an integer (using a compact |
| 118399 | ** But we are getting ready to store this value back into an index, where | 119288 | ** representation) then converted to REAL by an OP_RealAffinity opcode. |
| 118400 | ** it should be converted by to INTEGER again. So omit the OP_RealAffinity | 119289 | ** But we are getting ready to store this value back into an index, where |
| 118401 | ** opcode if it is present */ | 119290 | ** it should be converted by to INTEGER again. So omit the |
| 118402 | sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity); | 119291 | ** OP_RealAffinity opcode if it is present */ |
| 119292 | sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity); | ||
| 119293 | } | ||
| 118403 | } | 119294 | } |
| 118404 | if( regOut ){ | 119295 | if( regOut ){ |
| 118405 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut); | 119296 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut); |
| @@ -119739,10 +120630,10 @@ static void trimFunc( | |||
| 119739 | ){ | 120630 | ){ |
| 119740 | const unsigned char *zIn; /* Input string */ | 120631 | const unsigned char *zIn; /* Input string */ |
| 119741 | const unsigned char *zCharSet; /* Set of characters to trim */ | 120632 | const unsigned char *zCharSet; /* Set of characters to trim */ |
| 119742 | int nIn; /* Number of bytes in input */ | 120633 | unsigned int nIn; /* Number of bytes in input */ |
| 119743 | int flags; /* 1: trimleft 2: trimright 3: trim */ | 120634 | int flags; /* 1: trimleft 2: trimright 3: trim */ |
| 119744 | int i; /* Loop counter */ | 120635 | int i; /* Loop counter */ |
| 119745 | unsigned char *aLen = 0; /* Length of each character in zCharSet */ | 120636 | unsigned int *aLen = 0; /* Length of each character in zCharSet */ |
| 119746 | unsigned char **azChar = 0; /* Individual characters in zCharSet */ | 120637 | unsigned char **azChar = 0; /* Individual characters in zCharSet */ |
| 119747 | int nChar; /* Number of characters in zCharSet */ | 120638 | int nChar; /* Number of characters in zCharSet */ |
| 119748 | 120639 | ||
| @@ -119751,13 +120642,13 @@ static void trimFunc( | |||
| 119751 | } | 120642 | } |
| 119752 | zIn = sqlite3_value_text(argv[0]); | 120643 | zIn = sqlite3_value_text(argv[0]); |
| 119753 | if( zIn==0 ) return; | 120644 | if( zIn==0 ) return; |
| 119754 | nIn = sqlite3_value_bytes(argv[0]); | 120645 | nIn = (unsigned)sqlite3_value_bytes(argv[0]); |
| 119755 | assert( zIn==sqlite3_value_text(argv[0]) ); | 120646 | assert( zIn==sqlite3_value_text(argv[0]) ); |
| 119756 | if( argc==1 ){ | 120647 | if( argc==1 ){ |
| 119757 | static const unsigned char lenOne[] = { 1 }; | 120648 | static const unsigned lenOne[] = { 1 }; |
| 119758 | static unsigned char * const azOne[] = { (u8*)" " }; | 120649 | static unsigned char * const azOne[] = { (u8*)" " }; |
| 119759 | nChar = 1; | 120650 | nChar = 1; |
| 119760 | aLen = (u8*)lenOne; | 120651 | aLen = (unsigned*)lenOne; |
| 119761 | azChar = (unsigned char **)azOne; | 120652 | azChar = (unsigned char **)azOne; |
| 119762 | zCharSet = 0; | 120653 | zCharSet = 0; |
| 119763 | }else if( (zCharSet = sqlite3_value_text(argv[1]))==0 ){ | 120654 | }else if( (zCharSet = sqlite3_value_text(argv[1]))==0 ){ |
| @@ -119768,15 +120659,16 @@ static void trimFunc( | |||
| 119768 | SQLITE_SKIP_UTF8(z); | 120659 | SQLITE_SKIP_UTF8(z); |
| 119769 | } | 120660 | } |
| 119770 | if( nChar>0 ){ | 120661 | if( nChar>0 ){ |
| 119771 | azChar = contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1)); | 120662 | azChar = contextMalloc(context, |
| 120663 | ((i64)nChar)*(sizeof(char*)+sizeof(unsigned))); | ||
| 119772 | if( azChar==0 ){ | 120664 | if( azChar==0 ){ |
| 119773 | return; | 120665 | return; |
| 119774 | } | 120666 | } |
| 119775 | aLen = (unsigned char*)&azChar[nChar]; | 120667 | aLen = (unsigned*)&azChar[nChar]; |
| 119776 | for(z=zCharSet, nChar=0; *z; nChar++){ | 120668 | for(z=zCharSet, nChar=0; *z; nChar++){ |
| 119777 | azChar[nChar] = (unsigned char *)z; | 120669 | azChar[nChar] = (unsigned char *)z; |
| 119778 | SQLITE_SKIP_UTF8(z); | 120670 | SQLITE_SKIP_UTF8(z); |
| 119779 | aLen[nChar] = (u8)(z - azChar[nChar]); | 120671 | aLen[nChar] = (unsigned)(z - azChar[nChar]); |
| 119780 | } | 120672 | } |
| 119781 | } | 120673 | } |
| 119782 | } | 120674 | } |
| @@ -119784,7 +120676,7 @@ static void trimFunc( | |||
| 119784 | flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context)); | 120676 | flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context)); |
| 119785 | if( flags & 1 ){ | 120677 | if( flags & 1 ){ |
| 119786 | while( nIn>0 ){ | 120678 | while( nIn>0 ){ |
| 119787 | int len = 0; | 120679 | unsigned int len = 0; |
| 119788 | for(i=0; i<nChar; i++){ | 120680 | for(i=0; i<nChar; i++){ |
| 119789 | len = aLen[i]; | 120681 | len = aLen[i]; |
| 119790 | if( len<=nIn && memcmp(zIn, azChar[i], len)==0 ) break; | 120682 | if( len<=nIn && memcmp(zIn, azChar[i], len)==0 ) break; |
| @@ -119796,7 +120688,7 @@ static void trimFunc( | |||
| 119796 | } | 120688 | } |
| 119797 | if( flags & 2 ){ | 120689 | if( flags & 2 ){ |
| 119798 | while( nIn>0 ){ | 120690 | while( nIn>0 ){ |
| 119799 | int len = 0; | 120691 | unsigned int len = 0; |
| 119800 | for(i=0; i<nChar; i++){ | 120692 | for(i=0; i<nChar; i++){ |
| 119801 | len = aLen[i]; | 120693 | len = aLen[i]; |
| 119802 | if( len<=nIn && memcmp(&zIn[nIn-len],azChar[i],len)==0 ) break; | 120694 | if( len<=nIn && memcmp(&zIn[nIn-len],azChar[i],len)==0 ) break; |
| @@ -120494,9 +121386,7 @@ static void math2Func( | |||
| 120494 | } | 121386 | } |
| 120495 | 121387 | ||
| 120496 | /* | 121388 | /* |
| 120497 | ** Implementation of 2-argument SQL math functions: | 121389 | ** Implementation of 0-argument pi() function. |
| 120498 | ** | ||
| 120499 | ** power(X,Y) - Compute X to the Y-th power | ||
| 120500 | */ | 121390 | */ |
| 120501 | static void piFunc( | 121391 | static void piFunc( |
| 120502 | sqlite3_context *context, | 121392 | sqlite3_context *context, |
| @@ -122526,7 +123416,7 @@ static int autoIncBegin( | |||
| 122526 | ** Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 */ | 123416 | ** Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 */ |
| 122527 | if( pSeqTab==0 | 123417 | if( pSeqTab==0 |
| 122528 | || !HasRowid(pSeqTab) | 123418 | || !HasRowid(pSeqTab) |
| 122529 | || IsVirtual(pSeqTab) | 123419 | || NEVER(IsVirtual(pSeqTab)) |
| 122530 | || pSeqTab->nCol!=2 | 123420 | || pSeqTab->nCol!=2 |
| 122531 | ){ | 123421 | ){ |
| 122532 | pParse->nErr++; | 123422 | pParse->nErr++; |
| @@ -122985,7 +123875,7 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 122985 | bIdListInOrder = 0; | 123875 | bIdListInOrder = 0; |
| 122986 | }else{ | 123876 | }else{ |
| 122987 | sqlite3ErrorMsg(pParse, "table %S has no column named %s", | 123877 | sqlite3ErrorMsg(pParse, "table %S has no column named %s", |
| 122988 | pTabList, 0, pColumn->a[i].zName); | 123878 | pTabList->a, pColumn->a[i].zName); |
| 122989 | pParse->checkSchema = 1; | 123879 | pParse->checkSchema = 1; |
| 122990 | goto insert_cleanup; | 123880 | goto insert_cleanup; |
| 122991 | } | 123881 | } |
| @@ -123113,7 +124003,7 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 123113 | if( nColumn!=(pTab->nCol-nHidden) ){ | 124003 | if( nColumn!=(pTab->nCol-nHidden) ){ |
| 123114 | sqlite3ErrorMsg(pParse, | 124004 | sqlite3ErrorMsg(pParse, |
| 123115 | "table %S has %d columns but %d values were supplied", | 124005 | "table %S has %d columns but %d values were supplied", |
| 123116 | pTabList, 0, pTab->nCol-nHidden, nColumn); | 124006 | pTabList->a, pTab->nCol-nHidden, nColumn); |
| 123117 | goto insert_cleanup; | 124007 | goto insert_cleanup; |
| 123118 | } | 124008 | } |
| 123119 | } | 124009 | } |
| @@ -123416,7 +124306,7 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 123416 | }else | 124306 | }else |
| 123417 | #endif | 124307 | #endif |
| 123418 | { | 124308 | { |
| 123419 | int isReplace; /* Set to true if constraints may cause a replace */ | 124309 | int isReplace = 0;/* Set to true if constraints may cause a replace */ |
| 123420 | int bUseSeek; /* True to use OPFLAG_SEEKRESULT */ | 124310 | int bUseSeek; /* True to use OPFLAG_SEEKRESULT */ |
| 123421 | sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur, | 124311 | sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur, |
| 123422 | regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0, pUpsert | 124312 | regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0, pUpsert |
| @@ -123436,6 +124326,13 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 123436 | regIns, aRegIdx, 0, appendFlag, bUseSeek | 124326 | regIns, aRegIdx, 0, appendFlag, bUseSeek |
| 123437 | ); | 124327 | ); |
| 123438 | } | 124328 | } |
| 124329 | #ifdef SQLITE_ALLOW_ROWID_IN_VIEW | ||
| 124330 | }else if( pParse->bReturning ){ | ||
| 124331 | /* If there is a RETURNING clause, populate the rowid register with | ||
| 124332 | ** constant value -1, in case one or more of the returned expressions | ||
| 124333 | ** refer to the "rowid" of the view. */ | ||
| 124334 | sqlite3VdbeAddOp2(v, OP_Integer, -1, regRowid); | ||
| 124335 | #endif | ||
| 123439 | } | 124336 | } |
| 123440 | 124337 | ||
| 123441 | /* Update the count of rows that are inserted | 124338 | /* Update the count of rows that are inserted |
| @@ -126552,7 +127449,7 @@ static int sqlite3LoadExtension( | |||
| 126552 | const char *zEntry; | 127449 | const char *zEntry; |
| 126553 | char *zAltEntry = 0; | 127450 | char *zAltEntry = 0; |
| 126554 | void **aHandle; | 127451 | void **aHandle; |
| 126555 | u64 nMsg = 300 + sqlite3Strlen30(zFile); | 127452 | u64 nMsg = strlen(zFile); |
| 126556 | int ii; | 127453 | int ii; |
| 126557 | int rc; | 127454 | int rc; |
| 126558 | 127455 | ||
| @@ -126586,6 +127483,12 @@ static int sqlite3LoadExtension( | |||
| 126586 | 127483 | ||
| 126587 | zEntry = zProc ? zProc : "sqlite3_extension_init"; | 127484 | zEntry = zProc ? zProc : "sqlite3_extension_init"; |
| 126588 | 127485 | ||
| 127486 | /* tag-20210611-1. Some dlopen() implementations will segfault if given | ||
| 127487 | ** an oversize filename. Most filesystems have a pathname limit of 4K, | ||
| 127488 | ** so limit the extension filename length to about twice that. | ||
| 127489 | ** https://sqlite.org/forum/forumpost/08a0d6d9bf */ | ||
| 127490 | if( nMsg>SQLITE_MAX_PATHLEN ) goto extension_not_found; | ||
| 127491 | |||
| 126589 | handle = sqlite3OsDlOpen(pVfs, zFile); | 127492 | handle = sqlite3OsDlOpen(pVfs, zFile); |
| 126590 | #if SQLITE_OS_UNIX || SQLITE_OS_WIN | 127493 | #if SQLITE_OS_UNIX || SQLITE_OS_WIN |
| 126591 | for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){ | 127494 | for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){ |
| @@ -126595,17 +127498,7 @@ static int sqlite3LoadExtension( | |||
| 126595 | sqlite3_free(zAltFile); | 127498 | sqlite3_free(zAltFile); |
| 126596 | } | 127499 | } |
| 126597 | #endif | 127500 | #endif |
| 126598 | if( handle==0 ){ | 127501 | if( handle==0 ) goto extension_not_found; |
| 126599 | if( pzErrMsg ){ | ||
| 126600 | *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg); | ||
| 126601 | if( zErrmsg ){ | ||
| 126602 | sqlite3_snprintf(nMsg, zErrmsg, | ||
| 126603 | "unable to open shared library [%s]", zFile); | ||
| 126604 | sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); | ||
| 126605 | } | ||
| 126606 | } | ||
| 126607 | return SQLITE_ERROR; | ||
| 126608 | } | ||
| 126609 | xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry); | 127502 | xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry); |
| 126610 | 127503 | ||
| 126611 | /* If no entry point was specified and the default legacy | 127504 | /* If no entry point was specified and the default legacy |
| @@ -126642,10 +127535,11 @@ static int sqlite3LoadExtension( | |||
| 126642 | } | 127535 | } |
| 126643 | if( xInit==0 ){ | 127536 | if( xInit==0 ){ |
| 126644 | if( pzErrMsg ){ | 127537 | if( pzErrMsg ){ |
| 126645 | nMsg += sqlite3Strlen30(zEntry); | 127538 | nMsg += strlen(zEntry) + 300; |
| 126646 | *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg); | 127539 | *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg); |
| 126647 | if( zErrmsg ){ | 127540 | if( zErrmsg ){ |
| 126648 | sqlite3_snprintf(nMsg, zErrmsg, | 127541 | assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */ |
| 127542 | sqlite3_snprintf((int)nMsg, zErrmsg, | ||
| 126649 | "no entry point [%s] in shared library [%s]", zEntry, zFile); | 127543 | "no entry point [%s] in shared library [%s]", zEntry, zFile); |
| 126650 | sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); | 127544 | sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); |
| 126651 | } | 127545 | } |
| @@ -126679,6 +127573,19 @@ static int sqlite3LoadExtension( | |||
| 126679 | 127573 | ||
| 126680 | db->aExtension[db->nExtension++] = handle; | 127574 | db->aExtension[db->nExtension++] = handle; |
| 126681 | return SQLITE_OK; | 127575 | return SQLITE_OK; |
| 127576 | |||
| 127577 | extension_not_found: | ||
| 127578 | if( pzErrMsg ){ | ||
| 127579 | nMsg += 300; | ||
| 127580 | *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg); | ||
| 127581 | if( zErrmsg ){ | ||
| 127582 | assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */ | ||
| 127583 | sqlite3_snprintf((int)nMsg, zErrmsg, | ||
| 127584 | "unable to open shared library [%.*s]", SQLITE_MAX_PATHLEN, zFile); | ||
| 127585 | sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); | ||
| 127586 | } | ||
| 127587 | } | ||
| 127588 | return SQLITE_ERROR; | ||
| 126682 | } | 127589 | } |
| 126683 | SQLITE_API int sqlite3_load_extension( | 127590 | SQLITE_API int sqlite3_load_extension( |
| 126684 | sqlite3 *db, /* Load the extension into this database connection */ | 127591 | sqlite3 *db, /* Load the extension into this database connection */ |
| @@ -130238,6 +131145,7 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char | |||
| 130238 | UNUSED_PARAMETER2(NotUsed, argc); | 131145 | UNUSED_PARAMETER2(NotUsed, argc); |
| 130239 | assert( sqlite3_mutex_held(db->mutex) ); | 131146 | assert( sqlite3_mutex_held(db->mutex) ); |
| 130240 | db->mDbFlags |= DBFLAG_EncodingFixed; | 131147 | db->mDbFlags |= DBFLAG_EncodingFixed; |
| 131148 | if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ | ||
| 130241 | pData->nInitRow++; | 131149 | pData->nInitRow++; |
| 130242 | if( db->mallocFailed ){ | 131150 | if( db->mallocFailed ){ |
| 130243 | corruptSchema(pData, argv, 0); | 131151 | corruptSchema(pData, argv, 0); |
| @@ -130245,7 +131153,6 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char | |||
| 130245 | } | 131153 | } |
| 130246 | 131154 | ||
| 130247 | assert( iDb>=0 && iDb<db->nDb ); | 131155 | assert( iDb>=0 && iDb<db->nDb ); |
| 130248 | if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ | ||
| 130249 | if( argv[3]==0 ){ | 131156 | if( argv[3]==0 ){ |
| 130250 | corruptSchema(pData, argv, 0); | 131157 | corruptSchema(pData, argv, 0); |
| 130251 | }else if( argv[4] | 131158 | }else if( argv[4] |
| @@ -130519,18 +131426,22 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl | |||
| 130519 | } | 131426 | } |
| 130520 | #endif | 131427 | #endif |
| 130521 | } | 131428 | } |
| 131429 | assert( pDb == &(db->aDb[iDb]) ); | ||
| 130522 | if( db->mallocFailed ){ | 131430 | if( db->mallocFailed ){ |
| 130523 | rc = SQLITE_NOMEM_BKPT; | 131431 | rc = SQLITE_NOMEM_BKPT; |
| 130524 | sqlite3ResetAllSchemasOfConnection(db); | 131432 | sqlite3ResetAllSchemasOfConnection(db); |
| 130525 | } | 131433 | pDb = &db->aDb[iDb]; |
| 131434 | }else | ||
| 130526 | if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){ | 131435 | if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){ |
| 130527 | /* Black magic: If the SQLITE_NoSchemaError flag is set, then consider | 131436 | /* Hack: If the SQLITE_NoSchemaError flag is set, then consider |
| 130528 | ** the schema loaded, even if errors occurred. In this situation the | 131437 | ** the schema loaded, even if errors (other than OOM) occurred. In |
| 130529 | ** current sqlite3_prepare() operation will fail, but the following one | 131438 | ** this situation the current sqlite3_prepare() operation will fail, |
| 130530 | ** will attempt to compile the supplied statement against whatever subset | 131439 | ** but the following one will attempt to compile the supplied statement |
| 130531 | ** of the schema was loaded before the error occurred. The primary | 131440 | ** against whatever subset of the schema was loaded before the error |
| 130532 | ** purpose of this is to allow access to the sqlite_schema table | 131441 | ** occurred. |
| 130533 | ** even when its contents have been corrupted. | 131442 | ** |
| 131443 | ** The primary purpose of this is to allow access to the sqlite_schema | ||
| 131444 | ** table even when its contents have been corrupted. | ||
| 130534 | */ | 131445 | */ |
| 130535 | DbSetProperty(db, iDb, DB_SchemaLoaded); | 131446 | DbSetProperty(db, iDb, DB_SchemaLoaded); |
| 130536 | rc = SQLITE_OK; | 131447 | rc = SQLITE_OK; |
| @@ -130640,6 +131551,7 @@ static void schemaIsValid(Parse *pParse){ | |||
| 130640 | rc = sqlite3BtreeBeginTrans(pBt, 0, 0); | 131551 | rc = sqlite3BtreeBeginTrans(pBt, 0, 0); |
| 130641 | if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){ | 131552 | if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){ |
| 130642 | sqlite3OomFault(db); | 131553 | sqlite3OomFault(db); |
| 131554 | pParse->rc = SQLITE_NOMEM; | ||
| 130643 | } | 131555 | } |
| 130644 | if( rc!=SQLITE_OK ) return; | 131556 | if( rc!=SQLITE_OK ) return; |
| 130645 | openedTransaction = 1; | 131557 | openedTransaction = 1; |
| @@ -130875,6 +131787,7 @@ static int sqlite3Prepare( | |||
| 130875 | } | 131787 | } |
| 130876 | if( db->mallocFailed ){ | 131788 | if( db->mallocFailed ){ |
| 130877 | sParse.rc = SQLITE_NOMEM_BKPT; | 131789 | sParse.rc = SQLITE_NOMEM_BKPT; |
| 131790 | sParse.checkSchema = 0; | ||
| 130878 | } | 131791 | } |
| 130879 | if( sParse.rc!=SQLITE_OK && sParse.rc!=SQLITE_DONE ){ | 131792 | if( sParse.rc!=SQLITE_OK && sParse.rc!=SQLITE_DONE ){ |
| 130880 | if( sParse.checkSchema ){ | 131793 | if( sParse.checkSchema ){ |
| @@ -131899,31 +132812,155 @@ static void codeOffset( | |||
| 131899 | } | 132812 | } |
| 131900 | 132813 | ||
| 131901 | /* | 132814 | /* |
| 131902 | ** Add code that will check to make sure the N registers starting at iMem | 132815 | ** Add code that will check to make sure the array of registers starting at |
| 131903 | ** form a distinct entry. iTab is a sorting index that holds previously | 132816 | ** iMem form a distinct entry. This is used by both "SELECT DISTINCT ..." and |
| 131904 | ** seen combinations of the N values. A new entry is made in iTab | 132817 | ** distinct aggregates ("SELECT count(DISTINCT <expr>) ..."). Three strategies |
| 131905 | ** if the current N values are new. | 132818 | ** are available. Which is used depends on the value of parameter eTnctType, |
| 132819 | ** as follows: | ||
| 131906 | ** | 132820 | ** |
| 131907 | ** A jump to addrRepeat is made and the N+1 values are popped from the | 132821 | ** WHERE_DISTINCT_UNORDERED/WHERE_DISTINCT_NOOP: |
| 131908 | ** stack if the top N elements are not distinct. | 132822 | ** Build an ephemeral table that contains all entries seen before and |
| 131909 | */ | 132823 | ** skip entries which have been seen before. |
| 131910 | static void codeDistinct( | 132824 | ** |
| 132825 | ** Parameter iTab is the cursor number of an ephemeral table that must | ||
| 132826 | ** be opened before the VM code generated by this routine is executed. | ||
| 132827 | ** The ephemeral cursor table is queried for a record identical to the | ||
| 132828 | ** record formed by the current array of registers. If one is found, | ||
| 132829 | ** jump to VM address addrRepeat. Otherwise, insert a new record into | ||
| 132830 | ** the ephemeral cursor and proceed. | ||
| 132831 | ** | ||
| 132832 | ** The returned value in this case is a copy of parameter iTab. | ||
| 132833 | ** | ||
| 132834 | ** WHERE_DISTINCT_ORDERED: | ||
| 132835 | ** In this case rows are being delivered sorted order. The ephermal | ||
| 132836 | ** table is not required. Instead, the current set of values | ||
| 132837 | ** is compared against previous row. If they match, the new row | ||
| 132838 | ** is not distinct and control jumps to VM address addrRepeat. Otherwise, | ||
| 132839 | ** the VM program proceeds with processing the new row. | ||
| 132840 | ** | ||
| 132841 | ** The returned value in this case is the register number of the first | ||
| 132842 | ** in an array of registers used to store the previous result row so that | ||
| 132843 | ** it can be compared to the next. The caller must ensure that this | ||
| 132844 | ** register is initialized to NULL. (The fixDistinctOpenEph() routine | ||
| 132845 | ** will take care of this initialization.) | ||
| 132846 | ** | ||
| 132847 | ** WHERE_DISTINCT_UNIQUE: | ||
| 132848 | ** In this case it has already been determined that the rows are distinct. | ||
| 132849 | ** No special action is required. The return value is zero. | ||
| 132850 | ** | ||
| 132851 | ** Parameter pEList is the list of expressions used to generated the | ||
| 132852 | ** contents of each row. It is used by this routine to determine (a) | ||
| 132853 | ** how many elements there are in the array of registers and (b) the | ||
| 132854 | ** collation sequences that should be used for the comparisons if | ||
| 132855 | ** eTnctType is WHERE_DISTINCT_ORDERED. | ||
| 132856 | */ | ||
| 132857 | static int codeDistinct( | ||
| 131911 | Parse *pParse, /* Parsing and code generating context */ | 132858 | Parse *pParse, /* Parsing and code generating context */ |
| 132859 | int eTnctType, /* WHERE_DISTINCT_* value */ | ||
| 131912 | int iTab, /* A sorting index used to test for distinctness */ | 132860 | int iTab, /* A sorting index used to test for distinctness */ |
| 131913 | int addrRepeat, /* Jump to here if not distinct */ | 132861 | int addrRepeat, /* Jump to here if not distinct */ |
| 131914 | int N, /* Number of elements */ | 132862 | ExprList *pEList, /* Expression for each element */ |
| 131915 | int iMem /* First element */ | 132863 | int regElem /* First element */ |
| 131916 | ){ | 132864 | ){ |
| 131917 | Vdbe *v; | 132865 | int iRet = 0; |
| 131918 | int r1; | 132866 | int nResultCol = pEList->nExpr; |
| 132867 | Vdbe *v = pParse->pVdbe; | ||
| 131919 | 132868 | ||
| 131920 | v = pParse->pVdbe; | 132869 | switch( eTnctType ){ |
| 131921 | r1 = sqlite3GetTempReg(pParse); | 132870 | case WHERE_DISTINCT_ORDERED: { |
| 131922 | sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); VdbeCoverage(v); | 132871 | int i; |
| 131923 | sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1); | 132872 | int iJump; /* Jump destination */ |
| 131924 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r1, iMem, N); | 132873 | int regPrev; /* Previous row content */ |
| 131925 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); | 132874 | |
| 131926 | sqlite3ReleaseTempReg(pParse, r1); | 132875 | /* Allocate space for the previous row */ |
| 132876 | iRet = regPrev = pParse->nMem+1; | ||
| 132877 | pParse->nMem += nResultCol; | ||
| 132878 | |||
| 132879 | iJump = sqlite3VdbeCurrentAddr(v) + nResultCol; | ||
| 132880 | for(i=0; i<nResultCol; i++){ | ||
| 132881 | CollSeq *pColl = sqlite3ExprCollSeq(pParse, pEList->a[i].pExpr); | ||
| 132882 | if( i<nResultCol-1 ){ | ||
| 132883 | sqlite3VdbeAddOp3(v, OP_Ne, regElem+i, iJump, regPrev+i); | ||
| 132884 | VdbeCoverage(v); | ||
| 132885 | }else{ | ||
| 132886 | sqlite3VdbeAddOp3(v, OP_Eq, regElem+i, addrRepeat, regPrev+i); | ||
| 132887 | VdbeCoverage(v); | ||
| 132888 | } | ||
| 132889 | sqlite3VdbeChangeP4(v, -1, (const char *)pColl, P4_COLLSEQ); | ||
| 132890 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); | ||
| 132891 | } | ||
| 132892 | assert( sqlite3VdbeCurrentAddr(v)==iJump || pParse->db->mallocFailed ); | ||
| 132893 | sqlite3VdbeAddOp3(v, OP_Copy, regElem, regPrev, nResultCol-1); | ||
| 132894 | break; | ||
| 132895 | } | ||
| 132896 | |||
| 132897 | case WHERE_DISTINCT_UNIQUE: { | ||
| 132898 | /* nothing to do */ | ||
| 132899 | break; | ||
| 132900 | } | ||
| 132901 | |||
| 132902 | default: { | ||
| 132903 | int r1 = sqlite3GetTempReg(pParse); | ||
| 132904 | sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, regElem, nResultCol); | ||
| 132905 | VdbeCoverage(v); | ||
| 132906 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regElem, nResultCol, r1); | ||
| 132907 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r1, regElem, nResultCol); | ||
| 132908 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); | ||
| 132909 | sqlite3ReleaseTempReg(pParse, r1); | ||
| 132910 | iRet = iTab; | ||
| 132911 | break; | ||
| 132912 | } | ||
| 132913 | } | ||
| 132914 | |||
| 132915 | return iRet; | ||
| 132916 | } | ||
| 132917 | |||
| 132918 | /* | ||
| 132919 | ** This routine runs after codeDistinct(). It makes necessary | ||
| 132920 | ** adjustments to the OP_OpenEphemeral opcode that the codeDistinct() | ||
| 132921 | ** routine made use of. This processing must be done separately since | ||
| 132922 | ** sometimes codeDistinct is called before the OP_OpenEphemeral is actually | ||
| 132923 | ** laid down. | ||
| 132924 | ** | ||
| 132925 | ** WHERE_DISTINCT_NOOP: | ||
| 132926 | ** WHERE_DISTINCT_UNORDERED: | ||
| 132927 | ** | ||
| 132928 | ** No adjustments necessary. This function is a no-op. | ||
| 132929 | ** | ||
| 132930 | ** WHERE_DISTINCT_UNIQUE: | ||
| 132931 | ** | ||
| 132932 | ** The ephemeral table is not needed. So change the | ||
| 132933 | ** OP_OpenEphemeral opcode into an OP_Noop. | ||
| 132934 | ** | ||
| 132935 | ** WHERE_DISTINCT_ORDERED: | ||
| 132936 | ** | ||
| 132937 | ** The ephemeral table is not needed. But we do need register | ||
| 132938 | ** iVal to be initialized to NULL. So change the OP_OpenEphemeral | ||
| 132939 | ** into an OP_Null on the iVal register. | ||
| 132940 | */ | ||
| 132941 | static void fixDistinctOpenEph( | ||
| 132942 | Parse *pParse, /* Parsing and code generating context */ | ||
| 132943 | int eTnctType, /* WHERE_DISTINCT_* value */ | ||
| 132944 | int iVal, /* Value returned by codeDistinct() */ | ||
| 132945 | int iOpenEphAddr /* Address of OP_OpenEphemeral instruction for iTab */ | ||
| 132946 | ){ | ||
| 132947 | if( eTnctType==WHERE_DISTINCT_UNIQUE || eTnctType==WHERE_DISTINCT_ORDERED ){ | ||
| 132948 | Vdbe *v = pParse->pVdbe; | ||
| 132949 | sqlite3VdbeChangeToNoop(v, iOpenEphAddr); | ||
| 132950 | if( sqlite3VdbeGetOp(v, iOpenEphAddr+1)->opcode==OP_Explain ){ | ||
| 132951 | sqlite3VdbeChangeToNoop(v, iOpenEphAddr+1); | ||
| 132952 | } | ||
| 132953 | if( eTnctType==WHERE_DISTINCT_ORDERED ){ | ||
| 132954 | /* Change the OP_OpenEphemeral to an OP_Null that sets the MEM_Cleared | ||
| 132955 | ** bit on the first register of the previous value. This will cause the | ||
| 132956 | ** OP_Ne added in codeDistinct() to always fail on the first iteration of | ||
| 132957 | ** the loop even if the first row is all NULLs. */ | ||
| 132958 | VdbeOp *pOp = sqlite3VdbeGetOp(v, iOpenEphAddr); | ||
| 132959 | pOp->opcode = OP_Null; | ||
| 132960 | pOp->p1 = 1; | ||
| 132961 | pOp->p2 = iVal; | ||
| 132962 | } | ||
| 132963 | } | ||
| 131927 | } | 132964 | } |
| 131928 | 132965 | ||
| 131929 | #ifdef SQLITE_ENABLE_SORTER_REFERENCES | 132966 | #ifdef SQLITE_ENABLE_SORTER_REFERENCES |
| @@ -132171,59 +133208,11 @@ static void selectInnerLoop( | |||
| 132171 | ** part of the result. | 133208 | ** part of the result. |
| 132172 | */ | 133209 | */ |
| 132173 | if( hasDistinct ){ | 133210 | if( hasDistinct ){ |
| 132174 | switch( pDistinct->eTnctType ){ | 133211 | int eType = pDistinct->eTnctType; |
| 132175 | case WHERE_DISTINCT_ORDERED: { | 133212 | int iTab = pDistinct->tabTnct; |
| 132176 | VdbeOp *pOp; /* No longer required OpenEphemeral instr. */ | 133213 | assert( nResultCol==p->pEList->nExpr ); |
| 132177 | int iJump; /* Jump destination */ | 133214 | iTab = codeDistinct(pParse, eType, iTab, iContinue, p->pEList, regResult); |
| 132178 | int regPrev; /* Previous row content */ | 133215 | fixDistinctOpenEph(pParse, eType, iTab, pDistinct->addrTnct); |
| 132179 | |||
| 132180 | /* Allocate space for the previous row */ | ||
| 132181 | regPrev = pParse->nMem+1; | ||
| 132182 | pParse->nMem += nResultCol; | ||
| 132183 | |||
| 132184 | /* Change the OP_OpenEphemeral coded earlier to an OP_Null | ||
| 132185 | ** sets the MEM_Cleared bit on the first register of the | ||
| 132186 | ** previous value. This will cause the OP_Ne below to always | ||
| 132187 | ** fail on the first iteration of the loop even if the first | ||
| 132188 | ** row is all NULLs. | ||
| 132189 | */ | ||
| 132190 | sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct); | ||
| 132191 | pOp = sqlite3VdbeGetOp(v, pDistinct->addrTnct); | ||
| 132192 | pOp->opcode = OP_Null; | ||
| 132193 | pOp->p1 = 1; | ||
| 132194 | pOp->p2 = regPrev; | ||
| 132195 | pOp = 0; /* Ensure pOp is not used after sqlite3VdbeAddOp() */ | ||
| 132196 | |||
| 132197 | iJump = sqlite3VdbeCurrentAddr(v) + nResultCol; | ||
| 132198 | for(i=0; i<nResultCol; i++){ | ||
| 132199 | CollSeq *pColl = sqlite3ExprCollSeq(pParse, p->pEList->a[i].pExpr); | ||
| 132200 | if( i<nResultCol-1 ){ | ||
| 132201 | sqlite3VdbeAddOp3(v, OP_Ne, regResult+i, iJump, regPrev+i); | ||
| 132202 | VdbeCoverage(v); | ||
| 132203 | }else{ | ||
| 132204 | sqlite3VdbeAddOp3(v, OP_Eq, regResult+i, iContinue, regPrev+i); | ||
| 132205 | VdbeCoverage(v); | ||
| 132206 | } | ||
| 132207 | sqlite3VdbeChangeP4(v, -1, (const char *)pColl, P4_COLLSEQ); | ||
| 132208 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); | ||
| 132209 | } | ||
| 132210 | assert( sqlite3VdbeCurrentAddr(v)==iJump || pParse->db->mallocFailed ); | ||
| 132211 | sqlite3VdbeAddOp3(v, OP_Copy, regResult, regPrev, nResultCol-1); | ||
| 132212 | break; | ||
| 132213 | } | ||
| 132214 | |||
| 132215 | case WHERE_DISTINCT_UNIQUE: { | ||
| 132216 | sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct); | ||
| 132217 | break; | ||
| 132218 | } | ||
| 132219 | |||
| 132220 | default: { | ||
| 132221 | assert( pDistinct->eTnctType==WHERE_DISTINCT_UNORDERED ); | ||
| 132222 | codeDistinct(pParse, pDistinct->tabTnct, iContinue, nResultCol, | ||
| 132223 | regResult); | ||
| 132224 | break; | ||
| 132225 | } | ||
| 132226 | } | ||
| 132227 | if( pSort==0 ){ | 133216 | if( pSort==0 ){ |
| 132228 | codeOffset(v, p->iOffset, iContinue); | 133217 | codeOffset(v, p->iOffset, iContinue); |
| 132229 | } | 133218 | } |
| @@ -132889,7 +133878,13 @@ static const char *columnTypeImpl( | |||
| 132889 | ** of the SELECT statement. Return the declaration type and origin | 133878 | ** of the SELECT statement. Return the declaration type and origin |
| 132890 | ** data for the result-set column of the sub-select. | 133879 | ** data for the result-set column of the sub-select. |
| 132891 | */ | 133880 | */ |
| 132892 | if( iCol>=0 && iCol<pS->pEList->nExpr ){ | 133881 | if( iCol<pS->pEList->nExpr |
| 133882 | #ifdef SQLITE_ALLOW_ROWID_IN_VIEW | ||
| 133883 | && iCol>=0 | ||
| 133884 | #else | ||
| 133885 | && ALWAYS(iCol>=0) | ||
| 133886 | #endif | ||
| 133887 | ){ | ||
| 132893 | /* If iCol is less than zero, then the expression requests the | 133888 | /* If iCol is less than zero, then the expression requests the |
| 132894 | ** rowid of the sub-select or view. This expression is legal (see | 133889 | ** rowid of the sub-select or view. This expression is legal (see |
| 132895 | ** test case misc2.2.2) - it always evaluates to NULL. | 133890 | ** test case misc2.2.2) - it always evaluates to NULL. |
| @@ -133031,7 +134026,7 @@ static void generateColumnTypes( | |||
| 133031 | ** then the result column name with the table name | 134026 | ** then the result column name with the table name |
| 133032 | ** prefix, ex: TABLE.COLUMN. Otherwise use zSpan. | 134027 | ** prefix, ex: TABLE.COLUMN. Otherwise use zSpan. |
| 133033 | */ | 134028 | */ |
| 133034 | static void generateColumnNames( | 134029 | SQLITE_PRIVATE void sqlite3GenerateColumnNames( |
| 133035 | Parse *pParse, /* Parser context */ | 134030 | Parse *pParse, /* Parser context */ |
| 133036 | Select *pSelect /* Generate column names for this SELECT statement */ | 134031 | Select *pSelect /* Generate column names for this SELECT statement */ |
| 133037 | ){ | 134032 | ){ |
| @@ -133121,7 +134116,7 @@ static void generateColumnNames( | |||
| 133121 | ** and will break if those assumptions changes. Hence, use extreme caution | 134116 | ** and will break if those assumptions changes. Hence, use extreme caution |
| 133122 | ** when modifying this routine to avoid breaking legacy. | 134117 | ** when modifying this routine to avoid breaking legacy. |
| 133123 | ** | 134118 | ** |
| 133124 | ** See Also: generateColumnNames() | 134119 | ** See Also: sqlite3GenerateColumnNames() |
| 133125 | */ | 134120 | */ |
| 133126 | SQLITE_PRIVATE int sqlite3ColumnsFromExprList( | 134121 | SQLITE_PRIVATE int sqlite3ColumnsFromExprList( |
| 133127 | Parse *pParse, /* Parsing context */ | 134122 | Parse *pParse, /* Parsing context */ |
| @@ -133819,11 +134814,12 @@ static int multiSelect( | |||
| 133819 | switch( p->op ){ | 134814 | switch( p->op ){ |
| 133820 | case TK_ALL: { | 134815 | case TK_ALL: { |
| 133821 | int addr = 0; | 134816 | int addr = 0; |
| 133822 | int nLimit; | 134817 | int nLimit = 0; /* Initialize to suppress harmless compiler warning */ |
| 133823 | assert( !pPrior->pLimit ); | 134818 | assert( !pPrior->pLimit ); |
| 133824 | pPrior->iLimit = p->iLimit; | 134819 | pPrior->iLimit = p->iLimit; |
| 133825 | pPrior->iOffset = p->iOffset; | 134820 | pPrior->iOffset = p->iOffset; |
| 133826 | pPrior->pLimit = p->pLimit; | 134821 | pPrior->pLimit = p->pLimit; |
| 134822 | SELECTTRACE(1, pParse, p, ("multiSelect UNION ALL left...\n")); | ||
| 133827 | rc = sqlite3Select(pParse, pPrior, &dest); | 134823 | rc = sqlite3Select(pParse, pPrior, &dest); |
| 133828 | pPrior->pLimit = 0; | 134824 | pPrior->pLimit = 0; |
| 133829 | if( rc ){ | 134825 | if( rc ){ |
| @@ -133841,6 +134837,7 @@ static int multiSelect( | |||
| 133841 | } | 134837 | } |
| 133842 | } | 134838 | } |
| 133843 | ExplainQueryPlan((pParse, 1, "UNION ALL")); | 134839 | ExplainQueryPlan((pParse, 1, "UNION ALL")); |
| 134840 | SELECTTRACE(1, pParse, p, ("multiSelect UNION ALL right...\n")); | ||
| 133844 | rc = sqlite3Select(pParse, p, &dest); | 134841 | rc = sqlite3Select(pParse, p, &dest); |
| 133845 | testcase( rc!=SQLITE_OK ); | 134842 | testcase( rc!=SQLITE_OK ); |
| 133846 | pDelete = p->pPrior; | 134843 | pDelete = p->pPrior; |
| @@ -133893,6 +134890,7 @@ static int multiSelect( | |||
| 133893 | */ | 134890 | */ |
| 133894 | assert( !pPrior->pOrderBy ); | 134891 | assert( !pPrior->pOrderBy ); |
| 133895 | sqlite3SelectDestInit(&uniondest, priorOp, unionTab); | 134892 | sqlite3SelectDestInit(&uniondest, priorOp, unionTab); |
| 134893 | SELECTTRACE(1, pParse, p, ("multiSelect EXCEPT/UNION left...\n")); | ||
| 133896 | rc = sqlite3Select(pParse, pPrior, &uniondest); | 134894 | rc = sqlite3Select(pParse, pPrior, &uniondest); |
| 133897 | if( rc ){ | 134895 | if( rc ){ |
| 133898 | goto multi_select_end; | 134896 | goto multi_select_end; |
| @@ -133912,6 +134910,7 @@ static int multiSelect( | |||
| 133912 | uniondest.eDest = op; | 134910 | uniondest.eDest = op; |
| 133913 | ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE", | 134911 | ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE", |
| 133914 | sqlite3SelectOpName(p->op))); | 134912 | sqlite3SelectOpName(p->op))); |
| 134913 | SELECTTRACE(1, pParse, p, ("multiSelect EXCEPT/UNION right...\n")); | ||
| 133915 | rc = sqlite3Select(pParse, p, &uniondest); | 134914 | rc = sqlite3Select(pParse, p, &uniondest); |
| 133916 | testcase( rc!=SQLITE_OK ); | 134915 | testcase( rc!=SQLITE_OK ); |
| 133917 | assert( p->pOrderBy==0 ); | 134916 | assert( p->pOrderBy==0 ); |
| @@ -133972,6 +134971,7 @@ static int multiSelect( | |||
| 133972 | /* Code the SELECTs to our left into temporary table "tab1". | 134971 | /* Code the SELECTs to our left into temporary table "tab1". |
| 133973 | */ | 134972 | */ |
| 133974 | sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1); | 134973 | sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1); |
| 134974 | SELECTTRACE(1, pParse, p, ("multiSelect INTERSECT left...\n")); | ||
| 133975 | rc = sqlite3Select(pParse, pPrior, &intersectdest); | 134975 | rc = sqlite3Select(pParse, pPrior, &intersectdest); |
| 133976 | if( rc ){ | 134976 | if( rc ){ |
| 133977 | goto multi_select_end; | 134977 | goto multi_select_end; |
| @@ -133988,6 +134988,7 @@ static int multiSelect( | |||
| 133988 | intersectdest.iSDParm = tab2; | 134988 | intersectdest.iSDParm = tab2; |
| 133989 | ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE", | 134989 | ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE", |
| 133990 | sqlite3SelectOpName(p->op))); | 134990 | sqlite3SelectOpName(p->op))); |
| 134991 | SELECTTRACE(1, pParse, p, ("multiSelect INTERSECT right...\n")); | ||
| 133991 | rc = sqlite3Select(pParse, p, &intersectdest); | 134992 | rc = sqlite3Select(pParse, p, &intersectdest); |
| 133992 | testcase( rc!=SQLITE_OK ); | 134993 | testcase( rc!=SQLITE_OK ); |
| 133993 | pDelete = p->pPrior; | 134994 | pDelete = p->pPrior; |
| @@ -134621,6 +135622,9 @@ static int multiSelectOrderBy( | |||
| 134621 | p->pPrior = pPrior; | 135622 | p->pPrior = pPrior; |
| 134622 | pPrior->pNext = p; | 135623 | pPrior->pNext = p; |
| 134623 | 135624 | ||
| 135625 | sqlite3ExprListDelete(db, pPrior->pOrderBy); | ||
| 135626 | pPrior->pOrderBy = 0; | ||
| 135627 | |||
| 134624 | /*** TBD: Insert subroutine calls to close cursors on incomplete | 135628 | /*** TBD: Insert subroutine calls to close cursors on incomplete |
| 134625 | **** subqueries ****/ | 135629 | **** subqueries ****/ |
| 134626 | ExplainQueryPlanPop(pParse); | 135630 | ExplainQueryPlanPop(pParse); |
| @@ -134675,9 +135679,12 @@ static Expr *substExpr( | |||
| 134675 | && pExpr->iTable==pSubst->iTable | 135679 | && pExpr->iTable==pSubst->iTable |
| 134676 | && !ExprHasProperty(pExpr, EP_FixedCol) | 135680 | && !ExprHasProperty(pExpr, EP_FixedCol) |
| 134677 | ){ | 135681 | ){ |
| 135682 | #ifdef SQLITE_ALLOW_ROWID_IN_VIEW | ||
| 134678 | if( pExpr->iColumn<0 ){ | 135683 | if( pExpr->iColumn<0 ){ |
| 134679 | pExpr->op = TK_NULL; | 135684 | pExpr->op = TK_NULL; |
| 134680 | }else{ | 135685 | }else |
| 135686 | #endif | ||
| 135687 | { | ||
| 134681 | Expr *pNew; | 135688 | Expr *pNew; |
| 134682 | Expr *pCopy = pSubst->pEList->a[pExpr->iColumn].pExpr; | 135689 | Expr *pCopy = pSubst->pEList->a[pExpr->iColumn].pExpr; |
| 134683 | Expr ifNullRow; | 135690 | Expr ifNullRow; |
| @@ -134697,10 +135704,14 @@ static Expr *substExpr( | |||
| 134697 | } | 135704 | } |
| 134698 | testcase( ExprHasProperty(pCopy, EP_Subquery) ); | 135705 | testcase( ExprHasProperty(pCopy, EP_Subquery) ); |
| 134699 | pNew = sqlite3ExprDup(db, pCopy, 0); | 135706 | pNew = sqlite3ExprDup(db, pCopy, 0); |
| 134700 | if( pNew && pSubst->isLeftJoin ){ | 135707 | if( db->mallocFailed ){ |
| 135708 | sqlite3ExprDelete(db, pNew); | ||
| 135709 | return pExpr; | ||
| 135710 | } | ||
| 135711 | if( pSubst->isLeftJoin ){ | ||
| 134701 | ExprSetProperty(pNew, EP_CanBeNull); | 135712 | ExprSetProperty(pNew, EP_CanBeNull); |
| 134702 | } | 135713 | } |
| 134703 | if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){ | 135714 | if( ExprHasProperty(pExpr,EP_FromJoin) ){ |
| 134704 | sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable); | 135715 | sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable); |
| 134705 | } | 135716 | } |
| 134706 | sqlite3ExprDelete(db, pExpr); | 135717 | sqlite3ExprDelete(db, pExpr); |
| @@ -134708,15 +135719,13 @@ static Expr *substExpr( | |||
| 134708 | 135719 | ||
| 134709 | /* Ensure that the expression now has an implicit collation sequence, | 135720 | /* Ensure that the expression now has an implicit collation sequence, |
| 134710 | ** just as it did when it was a column of a view or sub-query. */ | 135721 | ** just as it did when it was a column of a view or sub-query. */ |
| 134711 | if( pExpr ){ | 135722 | if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){ |
| 134712 | if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){ | 135723 | CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr); |
| 134713 | CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr); | 135724 | pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr, |
| 134714 | pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr, | 135725 | (pColl ? pColl->zName : "BINARY") |
| 134715 | (pColl ? pColl->zName : "BINARY") | 135726 | ); |
| 134716 | ); | ||
| 134717 | } | ||
| 134718 | ExprClearProperty(pExpr, EP_Collate); | ||
| 134719 | } | 135727 | } |
| 135728 | ExprClearProperty(pExpr, EP_Collate); | ||
| 134720 | } | 135729 | } |
| 134721 | } | 135730 | } |
| 134722 | }else{ | 135731 | }else{ |
| @@ -134835,7 +135844,10 @@ static void srclistRenumberCursors( | |||
| 134835 | for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){ | 135844 | for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){ |
| 134836 | if( i!=iExcept ){ | 135845 | if( i!=iExcept ){ |
| 134837 | Select *p; | 135846 | Select *p; |
| 134838 | pItem->iCursor = aCsrMap[pItem->iCursor] = pParse->nTab++; | 135847 | if( !pItem->fg.isRecursive || aCsrMap[pItem->iCursor]==0 ){ |
| 135848 | aCsrMap[pItem->iCursor] = pParse->nTab++; | ||
| 135849 | } | ||
| 135850 | pItem->iCursor = aCsrMap[pItem->iCursor]; | ||
| 134839 | for(p=pItem->pSelect; p; p=p->pPrior){ | 135851 | for(p=pItem->pSelect; p; p=p->pPrior){ |
| 134840 | srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1); | 135852 | srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1); |
| 134841 | } | 135853 | } |
| @@ -135275,7 +136287,7 @@ static int flattenSubquery( | |||
| 135275 | p->pPrior = pPrior; | 136287 | p->pPrior = pPrior; |
| 135276 | }else{ | 136288 | }else{ |
| 135277 | pNew->selId = ++pParse->nSelect; | 136289 | pNew->selId = ++pParse->nSelect; |
| 135278 | if( aCsrMap && db->mallocFailed==0 ){ | 136290 | if( aCsrMap && ALWAYS(db->mallocFailed==0) ){ |
| 135279 | renumberCursors(pParse, pNew, iFrom, aCsrMap); | 136291 | renumberCursors(pParse, pNew, iFrom, aCsrMap); |
| 135280 | } | 136292 | } |
| 135281 | pNew->pPrior = pPrior; | 136293 | pNew->pPrior = pPrior; |
| @@ -135474,8 +136486,10 @@ static int flattenSubquery( | |||
| 135474 | typedef struct WhereConst WhereConst; | 136486 | typedef struct WhereConst WhereConst; |
| 135475 | struct WhereConst { | 136487 | struct WhereConst { |
| 135476 | Parse *pParse; /* Parsing context */ | 136488 | Parse *pParse; /* Parsing context */ |
| 136489 | u8 *pOomFault; /* Pointer to pParse->db->mallocFailed */ | ||
| 135477 | int nConst; /* Number for COLUMN=CONSTANT terms */ | 136490 | int nConst; /* Number for COLUMN=CONSTANT terms */ |
| 135478 | int nChng; /* Number of times a constant is propagated */ | 136491 | int nChng; /* Number of times a constant is propagated */ |
| 136492 | int bHasAffBlob; /* At least one column in apExpr[] as affinity BLOB */ | ||
| 135479 | Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */ | 136493 | Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */ |
| 135480 | }; | 136494 | }; |
| 135481 | 136495 | ||
| @@ -135514,6 +136528,9 @@ static void constInsert( | |||
| 135514 | return; /* Already present. Return without doing anything. */ | 136528 | return; /* Already present. Return without doing anything. */ |
| 135515 | } | 136529 | } |
| 135516 | } | 136530 | } |
| 136531 | if( sqlite3ExprAffinity(pColumn)==SQLITE_AFF_BLOB ){ | ||
| 136532 | pConst->bHasAffBlob = 1; | ||
| 136533 | } | ||
| 135517 | 136534 | ||
| 135518 | pConst->nConst++; | 136535 | pConst->nConst++; |
| 135519 | pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr, | 136536 | pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr, |
| @@ -135534,7 +136551,7 @@ static void constInsert( | |||
| 135534 | */ | 136551 | */ |
| 135535 | static void findConstInWhere(WhereConst *pConst, Expr *pExpr){ | 136552 | static void findConstInWhere(WhereConst *pConst, Expr *pExpr){ |
| 135536 | Expr *pRight, *pLeft; | 136553 | Expr *pRight, *pLeft; |
| 135537 | if( pExpr==0 ) return; | 136554 | if( NEVER(pExpr==0) ) return; |
| 135538 | if( ExprHasProperty(pExpr, EP_FromJoin) ) return; | 136555 | if( ExprHasProperty(pExpr, EP_FromJoin) ) return; |
| 135539 | if( pExpr->op==TK_AND ){ | 136556 | if( pExpr->op==TK_AND ){ |
| 135540 | findConstInWhere(pConst, pExpr->pRight); | 136557 | findConstInWhere(pConst, pExpr->pRight); |
| @@ -135555,38 +136572,84 @@ static void findConstInWhere(WhereConst *pConst, Expr *pExpr){ | |||
| 135555 | } | 136572 | } |
| 135556 | 136573 | ||
| 135557 | /* | 136574 | /* |
| 135558 | ** This is a Walker expression callback. pExpr is a candidate expression | 136575 | ** This is a helper function for Walker callback propagateConstantExprRewrite(). |
| 135559 | ** to be replaced by a value. If pExpr is equivalent to one of the | 136576 | ** |
| 135560 | ** columns named in pWalker->u.pConst, then overwrite it with its | 136577 | ** Argument pExpr is a candidate expression to be replaced by a value. If |
| 135561 | ** corresponding value. | 136578 | ** pExpr is equivalent to one of the columns named in pWalker->u.pConst, |
| 136579 | ** then overwrite it with the corresponding value. Except, do not do so | ||
| 136580 | ** if argument bIgnoreAffBlob is non-zero and the affinity of pExpr | ||
| 136581 | ** is SQLITE_AFF_BLOB. | ||
| 135562 | */ | 136582 | */ |
| 135563 | static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){ | 136583 | static int propagateConstantExprRewriteOne( |
| 136584 | WhereConst *pConst, | ||
| 136585 | Expr *pExpr, | ||
| 136586 | int bIgnoreAffBlob | ||
| 136587 | ){ | ||
| 135564 | int i; | 136588 | int i; |
| 135565 | WhereConst *pConst; | 136589 | if( pConst->pOomFault[0] ) return WRC_Prune; |
| 135566 | if( pExpr->op!=TK_COLUMN ) return WRC_Continue; | 136590 | if( pExpr->op!=TK_COLUMN ) return WRC_Continue; |
| 135567 | if( ExprHasProperty(pExpr, EP_FixedCol|EP_FromJoin) ){ | 136591 | if( ExprHasProperty(pExpr, EP_FixedCol|EP_FromJoin) ){ |
| 135568 | testcase( ExprHasProperty(pExpr, EP_FixedCol) ); | 136592 | testcase( ExprHasProperty(pExpr, EP_FixedCol) ); |
| 135569 | testcase( ExprHasProperty(pExpr, EP_FromJoin) ); | 136593 | testcase( ExprHasProperty(pExpr, EP_FromJoin) ); |
| 135570 | return WRC_Continue; | 136594 | return WRC_Continue; |
| 135571 | } | 136595 | } |
| 135572 | pConst = pWalker->u.pConst; | ||
| 135573 | for(i=0; i<pConst->nConst; i++){ | 136596 | for(i=0; i<pConst->nConst; i++){ |
| 135574 | Expr *pColumn = pConst->apExpr[i*2]; | 136597 | Expr *pColumn = pConst->apExpr[i*2]; |
| 135575 | if( pColumn==pExpr ) continue; | 136598 | if( pColumn==pExpr ) continue; |
| 135576 | if( pColumn->iTable!=pExpr->iTable ) continue; | 136599 | if( pColumn->iTable!=pExpr->iTable ) continue; |
| 135577 | if( pColumn->iColumn!=pExpr->iColumn ) continue; | 136600 | if( pColumn->iColumn!=pExpr->iColumn ) continue; |
| 136601 | if( bIgnoreAffBlob && sqlite3ExprAffinity(pColumn)==SQLITE_AFF_BLOB ){ | ||
| 136602 | break; | ||
| 136603 | } | ||
| 135578 | /* A match is found. Add the EP_FixedCol property */ | 136604 | /* A match is found. Add the EP_FixedCol property */ |
| 135579 | pConst->nChng++; | 136605 | pConst->nChng++; |
| 135580 | ExprClearProperty(pExpr, EP_Leaf); | 136606 | ExprClearProperty(pExpr, EP_Leaf); |
| 135581 | ExprSetProperty(pExpr, EP_FixedCol); | 136607 | ExprSetProperty(pExpr, EP_FixedCol); |
| 135582 | assert( pExpr->pLeft==0 ); | 136608 | assert( pExpr->pLeft==0 ); |
| 135583 | pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0); | 136609 | pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0); |
| 136610 | if( pConst->pParse->db->mallocFailed ) return WRC_Prune; | ||
| 135584 | break; | 136611 | break; |
| 135585 | } | 136612 | } |
| 135586 | return WRC_Prune; | 136613 | return WRC_Prune; |
| 135587 | } | 136614 | } |
| 135588 | 136615 | ||
| 135589 | /* | 136616 | /* |
| 136617 | ** This is a Walker expression callback. pExpr is a node from the WHERE | ||
| 136618 | ** clause of a SELECT statement. This function examines pExpr to see if | ||
| 136619 | ** any substitutions based on the contents of pWalker->u.pConst should | ||
| 136620 | ** be made to pExpr or its immediate children. | ||
| 136621 | ** | ||
| 136622 | ** A substitution is made if: | ||
| 136623 | ** | ||
| 136624 | ** + pExpr is a column with an affinity other than BLOB that matches | ||
| 136625 | ** one of the columns in pWalker->u.pConst, or | ||
| 136626 | ** | ||
| 136627 | ** + pExpr is a binary comparison operator (=, <=, >=, <, >) that | ||
| 136628 | ** uses an affinity other than TEXT and one of its immediate | ||
| 136629 | ** children is a column that matches one of the columns in | ||
| 136630 | ** pWalker->u.pConst. | ||
| 136631 | */ | ||
| 136632 | static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){ | ||
| 136633 | WhereConst *pConst = pWalker->u.pConst; | ||
| 136634 | assert( TK_GT==TK_EQ+1 ); | ||
| 136635 | assert( TK_LE==TK_EQ+2 ); | ||
| 136636 | assert( TK_LT==TK_EQ+3 ); | ||
| 136637 | assert( TK_GE==TK_EQ+4 ); | ||
| 136638 | if( pConst->bHasAffBlob ){ | ||
| 136639 | if( (pExpr->op>=TK_EQ && pExpr->op<=TK_GE) | ||
| 136640 | || pExpr->op==TK_IS | ||
| 136641 | ){ | ||
| 136642 | propagateConstantExprRewriteOne(pConst, pExpr->pLeft, 0); | ||
| 136643 | if( pConst->pOomFault[0] ) return WRC_Prune; | ||
| 136644 | if( sqlite3ExprAffinity(pExpr->pLeft)!=SQLITE_AFF_TEXT ){ | ||
| 136645 | propagateConstantExprRewriteOne(pConst, pExpr->pRight, 0); | ||
| 136646 | } | ||
| 136647 | } | ||
| 136648 | } | ||
| 136649 | return propagateConstantExprRewriteOne(pConst, pExpr, pConst->bHasAffBlob); | ||
| 136650 | } | ||
| 136651 | |||
| 136652 | /* | ||
| 135590 | ** The WHERE-clause constant propagation optimization. | 136653 | ** The WHERE-clause constant propagation optimization. |
| 135591 | ** | 136654 | ** |
| 135592 | ** If the WHERE clause contains terms of the form COLUMN=CONSTANT or | 136655 | ** If the WHERE clause contains terms of the form COLUMN=CONSTANT or |
| @@ -135621,6 +136684,21 @@ static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){ | |||
| 135621 | ** routines know to generate the constant "123" instead of looking up the | 136684 | ** routines know to generate the constant "123" instead of looking up the |
| 135622 | ** column value. Also, to avoid collation problems, this optimization is | 136685 | ** column value. Also, to avoid collation problems, this optimization is |
| 135623 | ** only attempted if the "a=123" term uses the default BINARY collation. | 136686 | ** only attempted if the "a=123" term uses the default BINARY collation. |
| 136687 | ** | ||
| 136688 | ** 2021-05-25 forum post 6a06202608: Another troublesome case is... | ||
| 136689 | ** | ||
| 136690 | ** CREATE TABLE t1(x); | ||
| 136691 | ** INSERT INTO t1 VALUES(10.0); | ||
| 136692 | ** SELECT 1 FROM t1 WHERE x=10 AND x LIKE 10; | ||
| 136693 | ** | ||
| 136694 | ** The query should return no rows, because the t1.x value is '10.0' not '10' | ||
| 136695 | ** and '10.0' is not LIKE '10'. But if we are not careful, the first WHERE | ||
| 136696 | ** term "x=10" will cause the second WHERE term to become "10 LIKE 10", | ||
| 136697 | ** resulting in a false positive. To avoid this, constant propagation for | ||
| 136698 | ** columns with BLOB affinity is only allowed if the constant is used with | ||
| 136699 | ** operators ==, <=, <, >=, >, or IS in a way that will cause the correct | ||
| 136700 | ** type conversions to occur. See logic associated with the bHasAffBlob flag | ||
| 136701 | ** for details. | ||
| 135624 | */ | 136702 | */ |
| 135625 | static int propagateConstants( | 136703 | static int propagateConstants( |
| 135626 | Parse *pParse, /* The parsing context */ | 136704 | Parse *pParse, /* The parsing context */ |
| @@ -135630,10 +136708,12 @@ static int propagateConstants( | |||
| 135630 | Walker w; | 136708 | Walker w; |
| 135631 | int nChng = 0; | 136709 | int nChng = 0; |
| 135632 | x.pParse = pParse; | 136710 | x.pParse = pParse; |
| 136711 | x.pOomFault = &pParse->db->mallocFailed; | ||
| 135633 | do{ | 136712 | do{ |
| 135634 | x.nConst = 0; | 136713 | x.nConst = 0; |
| 135635 | x.nChng = 0; | 136714 | x.nChng = 0; |
| 135636 | x.apExpr = 0; | 136715 | x.apExpr = 0; |
| 136716 | x.bHasAffBlob = 0; | ||
| 135637 | findConstInWhere(&x, p->pWhere); | 136717 | findConstInWhere(&x, p->pWhere); |
| 135638 | if( x.nConst ){ | 136718 | if( x.nConst ){ |
| 135639 | memset(&w, 0, sizeof(w)); | 136719 | memset(&w, 0, sizeof(w)); |
| @@ -136070,6 +137150,7 @@ static struct Cte *searchWith( | |||
| 136070 | return &p->a[i]; | 137150 | return &p->a[i]; |
| 136071 | } | 137151 | } |
| 136072 | } | 137152 | } |
| 137153 | if( p->bView ) break; | ||
| 136073 | } | 137154 | } |
| 136074 | return 0; | 137155 | return 0; |
| 136075 | } | 137156 | } |
| @@ -136079,23 +137160,33 @@ static struct Cte *searchWith( | |||
| 136079 | ** | 137160 | ** |
| 136080 | ** This routine pushes the WITH clause passed as the second argument | 137161 | ** This routine pushes the WITH clause passed as the second argument |
| 136081 | ** onto the top of the stack. If argument bFree is true, then this | 137162 | ** onto the top of the stack. If argument bFree is true, then this |
| 136082 | ** WITH clause will never be popped from the stack. In this case it | 137163 | ** WITH clause will never be popped from the stack but should instead |
| 136083 | ** should be freed along with the Parse object. In other cases, when | 137164 | ** be freed along with the Parse object. In other cases, when |
| 136084 | ** bFree==0, the With object will be freed along with the SELECT | 137165 | ** bFree==0, the With object will be freed along with the SELECT |
| 136085 | ** statement with which it is associated. | 137166 | ** statement with which it is associated. |
| 137167 | ** | ||
| 137168 | ** This routine returns a copy of pWith. Or, if bFree is true and | ||
| 137169 | ** the pWith object is destroyed immediately due to an OOM condition, | ||
| 137170 | ** then this routine return NULL. | ||
| 137171 | ** | ||
| 137172 | ** If bFree is true, do not continue to use the pWith pointer after | ||
| 137173 | ** calling this routine, Instead, use only the return value. | ||
| 136086 | */ | 137174 | */ |
| 136087 | SQLITE_PRIVATE void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){ | 137175 | SQLITE_PRIVATE With *sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){ |
| 136088 | if( pWith ){ | 137176 | if( pWith ){ |
| 136089 | assert( pParse->pWith!=pWith ); | ||
| 136090 | pWith->pOuter = pParse->pWith; | ||
| 136091 | pParse->pWith = pWith; | ||
| 136092 | if( bFree ){ | 137177 | if( bFree ){ |
| 136093 | sqlite3ParserAddCleanup(pParse, | 137178 | pWith = (With*)sqlite3ParserAddCleanup(pParse, |
| 136094 | (void(*)(sqlite3*,void*))sqlite3WithDelete, | 137179 | (void(*)(sqlite3*,void*))sqlite3WithDelete, |
| 136095 | pWith); | 137180 | pWith); |
| 136096 | testcase( pParse->earlyCleanup ); | 137181 | if( pWith==0 ) return 0; |
| 137182 | } | ||
| 137183 | if( pParse->nErr==0 ){ | ||
| 137184 | assert( pParse->pWith!=pWith ); | ||
| 137185 | pWith->pOuter = pParse->pWith; | ||
| 137186 | pParse->pWith = pWith; | ||
| 136097 | } | 137187 | } |
| 136098 | } | 137188 | } |
| 137189 | return pWith; | ||
| 136099 | } | 137190 | } |
| 136100 | 137191 | ||
| 136101 | /* | 137192 | /* |
| @@ -136125,11 +137216,24 @@ static int resolveFromTermToCte( | |||
| 136125 | /* There are no WITH clauses in the stack. No match is possible */ | 137216 | /* There are no WITH clauses in the stack. No match is possible */ |
| 136126 | return 0; | 137217 | return 0; |
| 136127 | } | 137218 | } |
| 137219 | if( pParse->nErr ){ | ||
| 137220 | /* Prior errors might have left pParse->pWith in a goofy state, so | ||
| 137221 | ** go no further. */ | ||
| 137222 | return 0; | ||
| 137223 | } | ||
| 136128 | if( pFrom->zDatabase!=0 ){ | 137224 | if( pFrom->zDatabase!=0 ){ |
| 136129 | /* The FROM term contains a schema qualifier (ex: main.t1) and so | 137225 | /* The FROM term contains a schema qualifier (ex: main.t1) and so |
| 136130 | ** it cannot possibly be a CTE reference. */ | 137226 | ** it cannot possibly be a CTE reference. */ |
| 136131 | return 0; | 137227 | return 0; |
| 136132 | } | 137228 | } |
| 137229 | if( pFrom->fg.notCte ){ | ||
| 137230 | /* The FROM term is specifically excluded from matching a CTE. | ||
| 137231 | ** (1) It is part of a trigger that used to have zDatabase but had | ||
| 137232 | ** zDatabase removed by sqlite3FixTriggerStep(). | ||
| 137233 | ** (2) This is the first term in the FROM clause of an UPDATE. | ||
| 137234 | */ | ||
| 137235 | return 0; | ||
| 137236 | } | ||
| 136133 | pCte = searchWith(pParse->pWith, pFrom, &pWith); | 137237 | pCte = searchWith(pParse->pWith, pFrom, &pWith); |
| 136134 | if( pCte ){ | 137238 | if( pCte ){ |
| 136135 | sqlite3 *db = pParse->db; | 137239 | sqlite3 *db = pParse->db; |
| @@ -136175,6 +137279,7 @@ static int resolveFromTermToCte( | |||
| 136175 | pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid; | 137279 | pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid; |
| 136176 | pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0); | 137280 | pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0); |
| 136177 | if( db->mallocFailed ) return 2; | 137281 | if( db->mallocFailed ) return 2; |
| 137282 | pFrom->pSelect->selFlags |= SF_CopyCte; | ||
| 136178 | assert( pFrom->pSelect ); | 137283 | assert( pFrom->pSelect ); |
| 136179 | pFrom->fg.isCte = 1; | 137284 | pFrom->fg.isCte = 1; |
| 136180 | pFrom->u2.pCteUse = pCteUse; | 137285 | pFrom->u2.pCteUse = pCteUse; |
| @@ -136278,7 +137383,7 @@ static int resolveFromTermToCte( | |||
| 136278 | ** sqlite3SelectExpand() when walking a SELECT tree to resolve table | 137383 | ** sqlite3SelectExpand() when walking a SELECT tree to resolve table |
| 136279 | ** names and other FROM clause elements. | 137384 | ** names and other FROM clause elements. |
| 136280 | */ | 137385 | */ |
| 136281 | static void selectPopWith(Walker *pWalker, Select *p){ | 137386 | SQLITE_PRIVATE void sqlite3SelectPopWith(Walker *pWalker, Select *p){ |
| 136282 | Parse *pParse = pWalker->pParse; | 137387 | Parse *pParse = pWalker->pParse; |
| 136283 | if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){ | 137388 | if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){ |
| 136284 | With *pWith = findRightmost(p)->pWith; | 137389 | With *pWith = findRightmost(p)->pWith; |
| @@ -136288,8 +137393,6 @@ static void selectPopWith(Walker *pWalker, Select *p){ | |||
| 136288 | } | 137393 | } |
| 136289 | } | 137394 | } |
| 136290 | } | 137395 | } |
| 136291 | #else | ||
| 136292 | #define selectPopWith 0 | ||
| 136293 | #endif | 137396 | #endif |
| 136294 | 137397 | ||
| 136295 | /* | 137398 | /* |
| @@ -136316,7 +137419,13 @@ SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse *pParse, SrcItem *pFrom){ | |||
| 136316 | sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol); | 137419 | sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol); |
| 136317 | pTab->iPKey = -1; | 137420 | pTab->iPKey = -1; |
| 136318 | pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); | 137421 | pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); |
| 136319 | pTab->tabFlags |= TF_Ephemeral; | 137422 | #ifndef SQLITE_ALLOW_ROWID_IN_VIEW |
| 137423 | /* The usual case - do not allow ROWID on a subquery */ | ||
| 137424 | pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid; | ||
| 137425 | #else | ||
| 137426 | pTab->tabFlags |= TF_Ephemeral; /* Legacy compatibility mode */ | ||
| 137427 | #endif | ||
| 137428 | |||
| 136320 | 137429 | ||
| 136321 | return pParse->nErr ? SQLITE_ERROR : SQLITE_OK; | 137430 | return pParse->nErr ? SQLITE_ERROR : SQLITE_OK; |
| 136322 | } | 137431 | } |
| @@ -136370,6 +137479,15 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 136370 | } | 137479 | } |
| 136371 | pTabList = p->pSrc; | 137480 | pTabList = p->pSrc; |
| 136372 | pEList = p->pEList; | 137481 | pEList = p->pEList; |
| 137482 | if( pParse->pWith && (p->selFlags & SF_View) ){ | ||
| 137483 | if( p->pWith==0 ){ | ||
| 137484 | p->pWith = (With*)sqlite3DbMallocZero(db, sizeof(With)); | ||
| 137485 | if( p->pWith==0 ){ | ||
| 137486 | return WRC_Abort; | ||
| 137487 | } | ||
| 137488 | } | ||
| 137489 | p->pWith->bView = 1; | ||
| 137490 | } | ||
| 136373 | sqlite3WithPush(pParse, p->pWith, 0); | 137491 | sqlite3WithPush(pParse, p->pWith, 0); |
| 136374 | 137492 | ||
| 136375 | /* Make sure cursor numbers have been assigned to all entries in | 137493 | /* Make sure cursor numbers have been assigned to all entries in |
| @@ -136430,6 +137548,7 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 136430 | pTab->zName); | 137548 | pTab->zName); |
| 136431 | } | 137549 | } |
| 136432 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 137550 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 137551 | assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 ); | ||
| 136433 | if( IsVirtual(pTab) | 137552 | if( IsVirtual(pTab) |
| 136434 | && pFrom->fg.fromDDL | 137553 | && pFrom->fg.fromDDL |
| 136435 | && ALWAYS(pTab->pVTable!=0) | 137554 | && ALWAYS(pTab->pVTable!=0) |
| @@ -136670,7 +137789,7 @@ static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){ | |||
| 136670 | sqlite3WalkSelect(&w, pSelect); | 137789 | sqlite3WalkSelect(&w, pSelect); |
| 136671 | } | 137790 | } |
| 136672 | w.xSelectCallback = selectExpander; | 137791 | w.xSelectCallback = selectExpander; |
| 136673 | w.xSelectCallback2 = selectPopWith; | 137792 | w.xSelectCallback2 = sqlite3SelectPopWith; |
| 136674 | w.eCode = 0; | 137793 | w.eCode = 0; |
| 136675 | sqlite3WalkSelect(&w, pSelect); | 137794 | sqlite3WalkSelect(&w, pSelect); |
| 136676 | } | 137795 | } |
| @@ -136803,8 +137922,10 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){ | |||
| 136803 | pFunc->iDistinct = -1; | 137922 | pFunc->iDistinct = -1; |
| 136804 | }else{ | 137923 | }else{ |
| 136805 | KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pE->x.pList,0,0); | 137924 | KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pE->x.pList,0,0); |
| 136806 | sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc->iDistinct, 0, 0, | 137925 | pFunc->iDistAddr = sqlite3VdbeAddOp4(v, OP_OpenEphemeral, |
| 136807 | (char*)pKeyInfo, P4_KEYINFO); | 137926 | pFunc->iDistinct, 0, 0, (char*)pKeyInfo, P4_KEYINFO); |
| 137927 | ExplainQueryPlan((pParse, 0, "USE TEMP B-TREE FOR %s(DISTINCT)", | ||
| 137928 | pFunc->pFunc->zName)); | ||
| 136808 | } | 137929 | } |
| 136809 | } | 137930 | } |
| 136810 | } | 137931 | } |
| @@ -136836,7 +137957,12 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ | |||
| 136836 | ** registers if register regAcc contains 0. The caller will take care | 137957 | ** registers if register regAcc contains 0. The caller will take care |
| 136837 | ** of setting and clearing regAcc. | 137958 | ** of setting and clearing regAcc. |
| 136838 | */ | 137959 | */ |
| 136839 | static void updateAccumulator(Parse *pParse, int regAcc, AggInfo *pAggInfo){ | 137960 | static void updateAccumulator( |
| 137961 | Parse *pParse, | ||
| 137962 | int regAcc, | ||
| 137963 | AggInfo *pAggInfo, | ||
| 137964 | int eDistinctType | ||
| 137965 | ){ | ||
| 136840 | Vdbe *v = pParse->pVdbe; | 137966 | Vdbe *v = pParse->pVdbe; |
| 136841 | int i; | 137967 | int i; |
| 136842 | int regHit = 0; | 137968 | int regHit = 0; |
| @@ -136882,13 +138008,12 @@ static void updateAccumulator(Parse *pParse, int regAcc, AggInfo *pAggInfo){ | |||
| 136882 | nArg = 0; | 138008 | nArg = 0; |
| 136883 | regAgg = 0; | 138009 | regAgg = 0; |
| 136884 | } | 138010 | } |
| 136885 | if( pF->iDistinct>=0 ){ | 138011 | if( pF->iDistinct>=0 && pList ){ |
| 136886 | if( addrNext==0 ){ | 138012 | if( addrNext==0 ){ |
| 136887 | addrNext = sqlite3VdbeMakeLabel(pParse); | 138013 | addrNext = sqlite3VdbeMakeLabel(pParse); |
| 136888 | } | 138014 | } |
| 136889 | testcase( nArg==0 ); /* Error condition */ | 138015 | pF->iDistinct = codeDistinct(pParse, eDistinctType, |
| 136890 | testcase( nArg>1 ); /* Also an error */ | 138016 | pF->iDistinct, addrNext, pList, regAgg); |
| 136891 | codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg); | ||
| 136892 | } | 138017 | } |
| 136893 | if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ | 138018 | if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ |
| 136894 | CollSeq *pColl = 0; | 138019 | CollSeq *pColl = 0; |
| @@ -136940,7 +138065,7 @@ static void explainSimpleCount( | |||
| 136940 | ){ | 138065 | ){ |
| 136941 | if( pParse->explain==2 ){ | 138066 | if( pParse->explain==2 ){ |
| 136942 | int bCover = (pIdx!=0 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pIdx))); | 138067 | int bCover = (pIdx!=0 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pIdx))); |
| 136943 | sqlite3VdbeExplain(pParse, 0, "SCAN TABLE %s%s%s", | 138068 | sqlite3VdbeExplain(pParse, 0, "SCAN %s%s%s", |
| 136944 | pTab->zName, | 138069 | pTab->zName, |
| 136945 | bCover ? " USING COVERING INDEX " : "", | 138070 | bCover ? " USING COVERING INDEX " : "", |
| 136946 | bCover ? pIdx->zName : "" | 138071 | bCover ? pIdx->zName : "" |
| @@ -137251,12 +138376,11 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 137251 | } | 138376 | } |
| 137252 | 138377 | ||
| 137253 | if( pDest->eDest==SRT_Output ){ | 138378 | if( pDest->eDest==SRT_Output ){ |
| 137254 | generateColumnNames(pParse, p); | 138379 | sqlite3GenerateColumnNames(pParse, p); |
| 137255 | } | 138380 | } |
| 137256 | 138381 | ||
| 137257 | #ifndef SQLITE_OMIT_WINDOWFUNC | 138382 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 137258 | rc = sqlite3WindowRewrite(pParse, p); | 138383 | if( sqlite3WindowRewrite(pParse, p) ){ |
| 137259 | if( rc ){ | ||
| 137260 | assert( db->mallocFailed || pParse->nErr>0 ); | 138384 | assert( db->mallocFailed || pParse->nErr>0 ); |
| 137261 | goto select_end; | 138385 | goto select_end; |
| 137262 | } | 138386 | } |
| @@ -137382,7 +138506,8 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 137382 | ** as the equivalent optimization will be handled by query planner in | 138506 | ** as the equivalent optimization will be handled by query planner in |
| 137383 | ** sqlite3WhereBegin(). | 138507 | ** sqlite3WhereBegin(). |
| 137384 | */ | 138508 | */ |
| 137385 | if( pTabList->nSrc>1 | 138509 | if( p->pWhere!=0 |
| 138510 | && p->pWhere->op==TK_AND | ||
| 137386 | && OptimizationEnabled(db, SQLITE_PropagateConst) | 138511 | && OptimizationEnabled(db, SQLITE_PropagateConst) |
| 137387 | && propagateConstants(pParse, p) | 138512 | && propagateConstants(pParse, p) |
| 137388 | ){ | 138513 | ){ |
| @@ -137445,19 +138570,8 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 137445 | pSub = pItem->pSelect; | 138570 | pSub = pItem->pSelect; |
| 137446 | if( pSub==0 ) continue; | 138571 | if( pSub==0 ) continue; |
| 137447 | 138572 | ||
| 137448 | /* The code for a subquery should only be generated once, though it is | 138573 | /* The code for a subquery should only be generated once. */ |
| 137449 | ** technically harmless for it to be generated multiple times. The | 138574 | assert( pItem->addrFillSub==0 ); |
| 137450 | ** following assert() will detect if something changes to cause | ||
| 137451 | ** the same subquery to be coded multiple times, as a signal to the | ||
| 137452 | ** developers to try to optimize the situation. | ||
| 137453 | ** | ||
| 137454 | ** Update 2019-07-24: | ||
| 137455 | ** See ticket https://sqlite.org/src/tktview/c52b09c7f38903b1311cec40. | ||
| 137456 | ** The dbsqlfuzz fuzzer found a case where the same subquery gets | ||
| 137457 | ** coded twice. So this assert() now becomes a testcase(). It should | ||
| 137458 | ** be very rare, though. | ||
| 137459 | */ | ||
| 137460 | testcase( pItem->addrFillSub!=0 ); | ||
| 137461 | 138575 | ||
| 137462 | /* Increment Parse.nHeight by the height of the largest expression | 138576 | /* Increment Parse.nHeight by the height of the largest expression |
| 137463 | ** tree referred to by this, the parent select. The child select | 138577 | ** tree referred to by this, the parent select. The child select |
| @@ -137513,10 +138627,10 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 137513 | 138627 | ||
| 137514 | pItem->regReturn = ++pParse->nMem; | 138628 | pItem->regReturn = ++pParse->nMem; |
| 137515 | sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->regReturn, 0, addrTop); | 138629 | sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->regReturn, 0, addrTop); |
| 137516 | VdbeComment((v, "%s", pItem->pTab->zName)); | 138630 | VdbeComment((v, "%!S", pItem)); |
| 137517 | pItem->addrFillSub = addrTop; | 138631 | pItem->addrFillSub = addrTop; |
| 137518 | sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn); | 138632 | sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn); |
| 137519 | ExplainQueryPlan((pParse, 1, "CO-ROUTINE %u", pSub->selId)); | 138633 | ExplainQueryPlan((pParse, 1, "CO-ROUTINE %!S", pItem)); |
| 137520 | sqlite3Select(pParse, pSub, &dest); | 138634 | sqlite3Select(pParse, pSub, &dest); |
| 137521 | pItem->pTab->nRowLogEst = pSub->nSelectRow; | 138635 | pItem->pTab->nRowLogEst = pSub->nSelectRow; |
| 137522 | pItem->fg.viaCoroutine = 1; | 138636 | pItem->fg.viaCoroutine = 1; |
| @@ -137544,14 +138658,13 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 137544 | sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); | 138658 | sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); |
| 137545 | pSub->nSelectRow = pPrior->pSelect->nSelectRow; | 138659 | pSub->nSelectRow = pPrior->pSelect->nSelectRow; |
| 137546 | }else{ | 138660 | }else{ |
| 137547 | /* Materalize the view. If the view is not correlated, generate a | 138661 | /* Materialize the view. If the view is not correlated, generate a |
| 137548 | ** subroutine to do the materialization so that subsequent uses of | 138662 | ** subroutine to do the materialization so that subsequent uses of |
| 137549 | ** the same view can reuse the materialization. */ | 138663 | ** the same view can reuse the materialization. */ |
| 137550 | int topAddr; | 138664 | int topAddr; |
| 137551 | int onceAddr = 0; | 138665 | int onceAddr = 0; |
| 137552 | int retAddr; | 138666 | int retAddr; |
| 137553 | 138667 | ||
| 137554 | testcase( pItem->addrFillSub==0 ); /* Ticket c52b09c7f38903b1311 */ | ||
| 137555 | pItem->regReturn = ++pParse->nMem; | 138668 | pItem->regReturn = ++pParse->nMem; |
| 137556 | topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn); | 138669 | topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn); |
| 137557 | pItem->addrFillSub = topAddr+1; | 138670 | pItem->addrFillSub = topAddr+1; |
| @@ -137560,17 +138673,17 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 137560 | ** a trigger, then we only need to compute the value of the subquery | 138673 | ** a trigger, then we only need to compute the value of the subquery |
| 137561 | ** once. */ | 138674 | ** once. */ |
| 137562 | onceAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); | 138675 | onceAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); |
| 137563 | VdbeComment((v, "materialize \"%s\"", pItem->pTab->zName)); | 138676 | VdbeComment((v, "materialize %!S", pItem)); |
| 137564 | }else{ | 138677 | }else{ |
| 137565 | VdbeNoopComment((v, "materialize \"%s\"", pItem->pTab->zName)); | 138678 | VdbeNoopComment((v, "materialize %!S", pItem)); |
| 137566 | } | 138679 | } |
| 137567 | sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor); | 138680 | sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor); |
| 137568 | ExplainQueryPlan((pParse, 1, "MATERIALIZE %u", pSub->selId)); | 138681 | ExplainQueryPlan((pParse, 1, "MATERIALIZE %!S", pItem)); |
| 137569 | sqlite3Select(pParse, pSub, &dest); | 138682 | sqlite3Select(pParse, pSub, &dest); |
| 137570 | pItem->pTab->nRowLogEst = pSub->nSelectRow; | 138683 | pItem->pTab->nRowLogEst = pSub->nSelectRow; |
| 137571 | if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr); | 138684 | if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr); |
| 137572 | retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn); | 138685 | retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn); |
| 137573 | VdbeComment((v, "end %s", pItem->pTab->zName)); | 138686 | VdbeComment((v, "end %!S", pItem)); |
| 137574 | sqlite3VdbeChangeP1(v, topAddr, retAddr); | 138687 | sqlite3VdbeChangeP1(v, topAddr, retAddr); |
| 137575 | sqlite3ClearTempRegCache(pParse); | 138688 | sqlite3ClearTempRegCache(pParse); |
| 137576 | if( pItem->fg.isCte && pItem->fg.isCorrelated==0 ){ | 138689 | if( pItem->fg.isCte && pItem->fg.isCorrelated==0 ){ |
| @@ -137920,6 +139033,20 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 137920 | int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */ | 139033 | int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */ |
| 137921 | int addrReset; /* Subroutine for resetting the accumulator */ | 139034 | int addrReset; /* Subroutine for resetting the accumulator */ |
| 137922 | int regReset; /* Return address register for reset subroutine */ | 139035 | int regReset; /* Return address register for reset subroutine */ |
| 139036 | ExprList *pDistinct = 0; | ||
| 139037 | u16 distFlag = 0; | ||
| 139038 | int eDist = WHERE_DISTINCT_NOOP; | ||
| 139039 | |||
| 139040 | if( pAggInfo->nFunc==1 | ||
| 139041 | && pAggInfo->aFunc[0].iDistinct>=0 | ||
| 139042 | && pAggInfo->aFunc[0].pFExpr->x.pList | ||
| 139043 | ){ | ||
| 139044 | Expr *pExpr = pAggInfo->aFunc[0].pFExpr->x.pList->a[0].pExpr; | ||
| 139045 | pExpr = sqlite3ExprDup(db, pExpr, 0); | ||
| 139046 | pDistinct = sqlite3ExprListDup(db, pGroupBy, 0); | ||
| 139047 | pDistinct = sqlite3ExprListAppend(pParse, pDistinct, pExpr); | ||
| 139048 | distFlag = pDistinct ? (WHERE_WANT_DISTINCT|WHERE_AGG_DISTINCT) : 0; | ||
| 139049 | } | ||
| 137923 | 139050 | ||
| 137924 | /* If there is a GROUP BY clause we might need a sorting index to | 139051 | /* If there is a GROUP BY clause we might need a sorting index to |
| 137925 | ** implement it. Allocate that sorting index now. If it turns out | 139052 | ** implement it. Allocate that sorting index now. If it turns out |
| @@ -137956,10 +139083,14 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 137956 | */ | 139083 | */ |
| 137957 | sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset); | 139084 | sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset); |
| 137958 | SELECTTRACE(1,pParse,p,("WhereBegin\n")); | 139085 | SELECTTRACE(1,pParse,p,("WhereBegin\n")); |
| 137959 | pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, 0, | 139086 | pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, pDistinct, |
| 137960 | WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0), 0 | 139087 | WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0) | distFlag, 0 |
| 137961 | ); | 139088 | ); |
| 137962 | if( pWInfo==0 ) goto select_end; | 139089 | if( pWInfo==0 ){ |
| 139090 | sqlite3ExprListDelete(db, pDistinct); | ||
| 139091 | goto select_end; | ||
| 139092 | } | ||
| 139093 | eDist = sqlite3WhereIsDistinct(pWInfo); | ||
| 137963 | SELECTTRACE(1,pParse,p,("WhereBegin returns\n")); | 139094 | SELECTTRACE(1,pParse,p,("WhereBegin returns\n")); |
| 137964 | if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr ){ | 139095 | if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr ){ |
| 137965 | /* The optimizer is able to deliver rows in group by order so | 139096 | /* The optimizer is able to deliver rows in group by order so |
| @@ -138077,7 +139208,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138077 | ** the current row | 139208 | ** the current row |
| 138078 | */ | 139209 | */ |
| 138079 | sqlite3VdbeJumpHere(v, addr1); | 139210 | sqlite3VdbeJumpHere(v, addr1); |
| 138080 | updateAccumulator(pParse, iUseFlag, pAggInfo); | 139211 | updateAccumulator(pParse, iUseFlag, pAggInfo, eDist); |
| 138081 | sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag); | 139212 | sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag); |
| 138082 | VdbeComment((v, "indicate data in accumulator")); | 139213 | VdbeComment((v, "indicate data in accumulator")); |
| 138083 | 139214 | ||
| @@ -138091,6 +139222,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138091 | sqlite3WhereEnd(pWInfo); | 139222 | sqlite3WhereEnd(pWInfo); |
| 138092 | sqlite3VdbeChangeToNoop(v, addrSortingIdx); | 139223 | sqlite3VdbeChangeToNoop(v, addrSortingIdx); |
| 138093 | } | 139224 | } |
| 139225 | sqlite3ExprListDelete(db, pDistinct); | ||
| 138094 | 139226 | ||
| 138095 | /* Output the final row of result | 139227 | /* Output the final row of result |
| 138096 | */ | 139228 | */ |
| @@ -138134,6 +139266,10 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138134 | VdbeComment((v, "indicate accumulator empty")); | 139266 | VdbeComment((v, "indicate accumulator empty")); |
| 138135 | sqlite3VdbeAddOp1(v, OP_Return, regReset); | 139267 | sqlite3VdbeAddOp1(v, OP_Return, regReset); |
| 138136 | 139268 | ||
| 139269 | if( eDist!=WHERE_DISTINCT_NOOP ){ | ||
| 139270 | struct AggInfo_func *pF = &pAggInfo->aFunc[0]; | ||
| 139271 | fixDistinctOpenEph(pParse, eDist, pF->iDistinct, pF->iDistAddr); | ||
| 139272 | } | ||
| 138137 | } /* endif pGroupBy. Begin aggregate queries without GROUP BY: */ | 139273 | } /* endif pGroupBy. Begin aggregate queries without GROUP BY: */ |
| 138138 | else { | 139274 | else { |
| 138139 | Table *pTab; | 139275 | Table *pTab; |
| @@ -138197,6 +139333,9 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138197 | explainSimpleCount(pParse, pTab, pBest); | 139333 | explainSimpleCount(pParse, pTab, pBest); |
| 138198 | }else{ | 139334 | }else{ |
| 138199 | int regAcc = 0; /* "populate accumulators" flag */ | 139335 | int regAcc = 0; /* "populate accumulators" flag */ |
| 139336 | ExprList *pDistinct = 0; | ||
| 139337 | u16 distFlag = 0; | ||
| 139338 | int eDist; | ||
| 138200 | 139339 | ||
| 138201 | /* If there are accumulator registers but no min() or max() functions | 139340 | /* If there are accumulator registers but no min() or max() functions |
| 138202 | ** without FILTER clauses, allocate register regAcc. Register regAcc | 139341 | ** without FILTER clauses, allocate register regAcc. Register regAcc |
| @@ -138220,6 +139359,9 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138220 | regAcc = ++pParse->nMem; | 139359 | regAcc = ++pParse->nMem; |
| 138221 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regAcc); | 139360 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regAcc); |
| 138222 | } | 139361 | } |
| 139362 | }else if( pAggInfo->nFunc==1 && pAggInfo->aFunc[0].iDistinct>=0 ){ | ||
| 139363 | pDistinct = pAggInfo->aFunc[0].pFExpr->x.pList; | ||
| 139364 | distFlag = pDistinct ? (WHERE_WANT_DISTINCT|WHERE_AGG_DISTINCT) : 0; | ||
| 138223 | } | 139365 | } |
| 138224 | 139366 | ||
| 138225 | /* This case runs if the aggregate has no GROUP BY clause. The | 139367 | /* This case runs if the aggregate has no GROUP BY clause. The |
| @@ -138239,12 +139381,18 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138239 | 139381 | ||
| 138240 | SELECTTRACE(1,pParse,p,("WhereBegin\n")); | 139382 | SELECTTRACE(1,pParse,p,("WhereBegin\n")); |
| 138241 | pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMaxOrderBy, | 139383 | pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMaxOrderBy, |
| 138242 | 0, minMaxFlag, 0); | 139384 | pDistinct, minMaxFlag|distFlag, 0); |
| 138243 | if( pWInfo==0 ){ | 139385 | if( pWInfo==0 ){ |
| 138244 | goto select_end; | 139386 | goto select_end; |
| 138245 | } | 139387 | } |
| 138246 | SELECTTRACE(1,pParse,p,("WhereBegin returns\n")); | 139388 | SELECTTRACE(1,pParse,p,("WhereBegin returns\n")); |
| 138247 | updateAccumulator(pParse, regAcc, pAggInfo); | 139389 | eDist = sqlite3WhereIsDistinct(pWInfo); |
| 139390 | updateAccumulator(pParse, regAcc, pAggInfo, eDist); | ||
| 139391 | if( eDist!=WHERE_DISTINCT_NOOP ){ | ||
| 139392 | struct AggInfo_func *pF = &pAggInfo->aFunc[0]; | ||
| 139393 | fixDistinctOpenEph(pParse, eDist, pF->iDistinct, pF->iDistAddr); | ||
| 139394 | } | ||
| 139395 | |||
| 138248 | if( regAcc ) sqlite3VdbeAddOp2(v, OP_Integer, 1, regAcc); | 139396 | if( regAcc ) sqlite3VdbeAddOp2(v, OP_Integer, 1, regAcc); |
| 138249 | if( minMaxFlag ){ | 139397 | if( minMaxFlag ){ |
| 138250 | sqlite3WhereMinMaxOptEarlyOut(v, pWInfo); | 139398 | sqlite3WhereMinMaxOptEarlyOut(v, pWInfo); |
| @@ -138289,6 +139437,8 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138289 | ** successful coding of the SELECT. | 139437 | ** successful coding of the SELECT. |
| 138290 | */ | 139438 | */ |
| 138291 | select_end: | 139439 | select_end: |
| 139440 | assert( db->mallocFailed==0 || db->mallocFailed==1 ); | ||
| 139441 | pParse->nErr += db->mallocFailed; | ||
| 138292 | sqlite3ExprListDelete(db, pMinMaxOrderBy); | 139442 | sqlite3ExprListDelete(db, pMinMaxOrderBy); |
| 138293 | #ifdef SQLITE_DEBUG | 139443 | #ifdef SQLITE_DEBUG |
| 138294 | if( pAggInfo && !db->mallocFailed ){ | 139444 | if( pAggInfo && !db->mallocFailed ){ |
| @@ -138579,29 +139729,41 @@ SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){ | |||
| 138579 | } | 139729 | } |
| 138580 | pTmpSchema = pParse->db->aDb[1].pSchema; | 139730 | pTmpSchema = pParse->db->aDb[1].pSchema; |
| 138581 | p = sqliteHashFirst(&pTmpSchema->trigHash); | 139731 | p = sqliteHashFirst(&pTmpSchema->trigHash); |
| 138582 | if( p==0 ){ | ||
| 138583 | return pTab->pTrigger; | ||
| 138584 | } | ||
| 138585 | pList = pTab->pTrigger; | 139732 | pList = pTab->pTrigger; |
| 138586 | if( pTmpSchema!=pTab->pSchema ){ | 139733 | while( p ){ |
| 138587 | while( p ){ | 139734 | Trigger *pTrig = (Trigger *)sqliteHashData(p); |
| 138588 | Trigger *pTrig = (Trigger *)sqliteHashData(p); | 139735 | if( pTrig->pTabSchema==pTab->pSchema |
| 138589 | if( pTrig->pTabSchema==pTab->pSchema | 139736 | && pTrig->table |
| 138590 | && 0==sqlite3StrICmp(pTrig->table, pTab->zName) | 139737 | && 0==sqlite3StrICmp(pTrig->table, pTab->zName) |
| 138591 | ){ | 139738 | && pTrig->pTabSchema!=pTmpSchema |
| 138592 | pTrig->pNext = pList; | 139739 | ){ |
| 138593 | pList = pTrig; | 139740 | pTrig->pNext = pList; |
| 138594 | }else if( pTrig->op==TK_RETURNING ){ | 139741 | pList = pTrig; |
| 138595 | assert( pParse->bReturning ); | 139742 | }else if( pTrig->op==TK_RETURNING |
| 138596 | assert( &(pParse->u1.pReturning->retTrig) == pTrig ); | 139743 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 138597 | pTrig->table = pTab->zName; | 139744 | && pParse->db->pVtabCtx==0 |
| 138598 | pTrig->pTabSchema = pTab->pSchema; | 139745 | #endif |
| 138599 | pTrig->pNext = pList; | 139746 | ){ |
| 138600 | pList = pTrig; | 139747 | assert( pParse->bReturning ); |
| 138601 | } | 139748 | assert( &(pParse->u1.pReturning->retTrig) == pTrig ); |
| 138602 | p = sqliteHashNext(p); | 139749 | pTrig->table = pTab->zName; |
| 139750 | pTrig->pTabSchema = pTab->pSchema; | ||
| 139751 | pTrig->pNext = pList; | ||
| 139752 | pList = pTrig; | ||
| 138603 | } | 139753 | } |
| 139754 | p = sqliteHashNext(p); | ||
| 138604 | } | 139755 | } |
| 139756 | #if 0 | ||
| 139757 | if( pList ){ | ||
| 139758 | Trigger *pX; | ||
| 139759 | printf("Triggers for %s:", pTab->zName); | ||
| 139760 | for(pX=pList; pX; pX=pX->pNext){ | ||
| 139761 | printf(" %s", pX->zName); | ||
| 139762 | } | ||
| 139763 | printf("\n"); | ||
| 139764 | fflush(stdout); | ||
| 139765 | } | ||
| 139766 | #endif | ||
| 138605 | return pList; | 139767 | return pList; |
| 138606 | } | 139768 | } |
| 138607 | 139769 | ||
| @@ -138731,12 +139893,12 @@ SQLITE_PRIVATE void sqlite3BeginTrigger( | |||
| 138731 | */ | 139893 | */ |
| 138732 | if( pTab->pSelect && tr_tm!=TK_INSTEAD ){ | 139894 | if( pTab->pSelect && tr_tm!=TK_INSTEAD ){ |
| 138733 | sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S", | 139895 | sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S", |
| 138734 | (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName, 0); | 139896 | (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName->a); |
| 138735 | goto trigger_orphan_error; | 139897 | goto trigger_orphan_error; |
| 138736 | } | 139898 | } |
| 138737 | if( !pTab->pSelect && tr_tm==TK_INSTEAD ){ | 139899 | if( !pTab->pSelect && tr_tm==TK_INSTEAD ){ |
| 138738 | sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF" | 139900 | sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF" |
| 138739 | " trigger on table: %S", pTableName, 0); | 139901 | " trigger on table: %S", pTableName->a); |
| 138740 | goto trigger_orphan_error; | 139902 | goto trigger_orphan_error; |
| 138741 | } | 139903 | } |
| 138742 | 139904 | ||
| @@ -139133,7 +140295,7 @@ SQLITE_PRIVATE void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr) | |||
| 139133 | } | 140295 | } |
| 139134 | if( !pTrigger ){ | 140296 | if( !pTrigger ){ |
| 139135 | if( !noErr ){ | 140297 | if( !noErr ){ |
| 139136 | sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0); | 140298 | sqlite3ErrorMsg(pParse, "no such trigger: %S", pName->a); |
| 139137 | }else{ | 140299 | }else{ |
| 139138 | sqlite3CodeVerifyNamedSchema(pParse, zDb); | 140300 | sqlite3CodeVerifyNamedSchema(pParse, zDb); |
| 139139 | } | 140301 | } |
| @@ -139405,15 +140567,6 @@ static ExprList *sqlite3ExpandReturning( | |||
| 139405 | } | 140567 | } |
| 139406 | } | 140568 | } |
| 139407 | } | 140569 | } |
| 139408 | if( !db->mallocFailed ){ | ||
| 139409 | Vdbe *v = pParse->pVdbe; | ||
| 139410 | assert( v!=0 ); | ||
| 139411 | sqlite3VdbeSetNumCols(v, pNew->nExpr); | ||
| 139412 | for(i=0; i<pNew->nExpr; i++){ | ||
| 139413 | sqlite3VdbeSetColName(v, i, COLNAME_NAME, pNew->a[i].zEName, | ||
| 139414 | SQLITE_TRANSIENT); | ||
| 139415 | } | ||
| 139416 | } | ||
| 139417 | return pNew; | 140570 | return pNew; |
| 139418 | } | 140571 | } |
| 139419 | 140572 | ||
| @@ -139429,13 +140582,27 @@ static void codeReturningTrigger( | |||
| 139429 | int regIn /* The first in an array of registers */ | 140582 | int regIn /* The first in an array of registers */ |
| 139430 | ){ | 140583 | ){ |
| 139431 | Vdbe *v = pParse->pVdbe; | 140584 | Vdbe *v = pParse->pVdbe; |
| 140585 | sqlite3 *db = pParse->db; | ||
| 139432 | ExprList *pNew; | 140586 | ExprList *pNew; |
| 139433 | Returning *pReturning; | 140587 | Returning *pReturning; |
| 140588 | Select sSelect; | ||
| 140589 | SrcList sFrom; | ||
| 139434 | 140590 | ||
| 139435 | assert( v!=0 ); | 140591 | assert( v!=0 ); |
| 139436 | assert( pParse->bReturning ); | 140592 | assert( pParse->bReturning ); |
| 139437 | pReturning = pParse->u1.pReturning; | 140593 | pReturning = pParse->u1.pReturning; |
| 139438 | assert( pTrigger == &(pReturning->retTrig) ); | 140594 | assert( pTrigger == &(pReturning->retTrig) ); |
| 140595 | memset(&sSelect, 0, sizeof(sSelect)); | ||
| 140596 | memset(&sFrom, 0, sizeof(sFrom)); | ||
| 140597 | sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0); | ||
| 140598 | sSelect.pSrc = &sFrom; | ||
| 140599 | sFrom.nSrc = 1; | ||
| 140600 | sFrom.a[0].pTab = pTab; | ||
| 140601 | sqlite3SelectPrep(pParse, &sSelect, 0); | ||
| 140602 | if( db->mallocFailed==0 && pParse->nErr==0 ){ | ||
| 140603 | sqlite3GenerateColumnNames(pParse, &sSelect); | ||
| 140604 | } | ||
| 140605 | sqlite3ExprListDelete(db, sSelect.pEList); | ||
| 139439 | pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab); | 140606 | pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab); |
| 139440 | if( pNew ){ | 140607 | if( pNew ){ |
| 139441 | NameContext sNC; | 140608 | NameContext sNC; |
| @@ -139456,13 +140623,14 @@ static void codeReturningTrigger( | |||
| 139456 | pParse->nMem += nCol+2; | 140623 | pParse->nMem += nCol+2; |
| 139457 | pReturning->iRetReg = reg; | 140624 | pReturning->iRetReg = reg; |
| 139458 | for(i=0; i<nCol; i++){ | 140625 | for(i=0; i<nCol; i++){ |
| 139459 | sqlite3ExprCodeFactorable(pParse, pNew->a[i].pExpr, reg+i); | 140626 | Expr *pCol = pNew->a[i].pExpr; |
| 140627 | sqlite3ExprCodeFactorable(pParse, pCol, reg+i); | ||
| 139460 | } | 140628 | } |
| 139461 | sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i); | 140629 | sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i); |
| 139462 | sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1); | 140630 | sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1); |
| 139463 | sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1); | 140631 | sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1); |
| 139464 | } | 140632 | } |
| 139465 | sqlite3ExprListDelete(pParse->db, pNew); | 140633 | sqlite3ExprListDelete(db, pNew); |
| 139466 | pParse->eTriggerOp = 0; | 140634 | pParse->eTriggerOp = 0; |
| 139467 | pParse->pTriggerTab = 0; | 140635 | pParse->pTriggerTab = 0; |
| 139468 | } | 140636 | } |
| @@ -139665,8 +140833,8 @@ static TriggerPrg *codeRowTrigger( | |||
| 139665 | ** OP_Halt inserted at the end of the program. */ | 140833 | ** OP_Halt inserted at the end of the program. */ |
| 139666 | if( pTrigger->pWhen ){ | 140834 | if( pTrigger->pWhen ){ |
| 139667 | pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0); | 140835 | pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0); |
| 139668 | if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) | 140836 | if( db->mallocFailed==0 |
| 139669 | && db->mallocFailed==0 | 140837 | && SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) |
| 139670 | ){ | 140838 | ){ |
| 139671 | iEndTrigger = sqlite3VdbeMakeLabel(pSubParse); | 140839 | iEndTrigger = sqlite3VdbeMakeLabel(pSubParse); |
| 139672 | sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL); | 140840 | sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL); |
| @@ -140145,6 +141313,7 @@ static void updateFromSelect( | |||
| 140145 | 141313 | ||
| 140146 | assert( pTabList->nSrc>1 ); | 141314 | assert( pTabList->nSrc>1 ); |
| 140147 | if( pSrc ){ | 141315 | if( pSrc ){ |
| 141316 | pSrc->a[0].fg.notCte = 1; | ||
| 140148 | pSrc->a[0].iCursor = -1; | 141317 | pSrc->a[0].iCursor = -1; |
| 140149 | pSrc->a[0].pTab->nTabRef--; | 141318 | pSrc->a[0].pTab->nTabRef--; |
| 140150 | pSrc->a[0].pTab = 0; | 141319 | pSrc->a[0].pTab = 0; |
| @@ -140174,7 +141343,8 @@ static void updateFromSelect( | |||
| 140174 | } | 141343 | } |
| 140175 | #endif | 141344 | #endif |
| 140176 | } | 141345 | } |
| 140177 | if( ALWAYS(pChanges) ){ | 141346 | assert( pChanges!=0 || pParse->db->mallocFailed ); |
| 141347 | if( pChanges ){ | ||
| 140178 | for(i=0; i<pChanges->nExpr; i++){ | 141348 | for(i=0; i<pChanges->nExpr; i++){ |
| 140179 | pList = sqlite3ExprListAppend(pParse, pList, | 141349 | pList = sqlite3ExprListAppend(pParse, pList, |
| 140180 | sqlite3ExprDup(db, pChanges->a[i].pExpr, 0) | 141350 | sqlite3ExprDup(db, pChanges->a[i].pExpr, 0) |
| @@ -140724,7 +141894,12 @@ SQLITE_PRIVATE void sqlite3Update( | |||
| 140724 | 141894 | ||
| 140725 | /* Top of the update loop */ | 141895 | /* Top of the update loop */ |
| 140726 | if( eOnePass!=ONEPASS_OFF ){ | 141896 | if( eOnePass!=ONEPASS_OFF ){ |
| 140727 | if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){ | 141897 | if( aiCurOnePass[0]!=iDataCur |
| 141898 | && aiCurOnePass[1]!=iDataCur | ||
| 141899 | #ifdef SQLITE_ALLOW_ROWID_IN_VIEW | ||
| 141900 | && !isView | ||
| 141901 | #endif | ||
| 141902 | ){ | ||
| 140728 | assert( pPk ); | 141903 | assert( pPk ); |
| 140729 | sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey,nKey); | 141904 | sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey,nKey); |
| 140730 | VdbeCoverage(v); | 141905 | VdbeCoverage(v); |
| @@ -143195,6 +144370,7 @@ SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){ | |||
| 143195 | pTab->pSchema = db->aDb[0].pSchema; | 144370 | pTab->pSchema = db->aDb[0].pSchema; |
| 143196 | assert( pTab->nModuleArg==0 ); | 144371 | assert( pTab->nModuleArg==0 ); |
| 143197 | pTab->iPKey = -1; | 144372 | pTab->iPKey = -1; |
| 144373 | pTab->tabFlags |= TF_Eponymous; | ||
| 143198 | addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName)); | 144374 | addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName)); |
| 143199 | addModuleArgument(pParse, pTab, 0); | 144375 | addModuleArgument(pParse, pTab, 0); |
| 143200 | addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName)); | 144376 | addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName)); |
| @@ -143611,8 +144787,8 @@ struct WhereScan { | |||
| 143611 | const char *zCollName; /* Required collating sequence, if not NULL */ | 144787 | const char *zCollName; /* Required collating sequence, if not NULL */ |
| 143612 | Expr *pIdxExpr; /* Search for this index expression */ | 144788 | Expr *pIdxExpr; /* Search for this index expression */ |
| 143613 | char idxaff; /* Must match this affinity, if zCollName!=NULL */ | 144789 | char idxaff; /* Must match this affinity, if zCollName!=NULL */ |
| 143614 | unsigned char nEquiv; /* Number of entries in aEquiv[] */ | 144790 | unsigned char nEquiv; /* Number of entries in aiCur[] and aiColumn[] */ |
| 143615 | unsigned char iEquiv; /* Next unused slot in aEquiv[] */ | 144791 | unsigned char iEquiv; /* Next unused slot in aiCur[] and aiColumn[] */ |
| 143616 | u32 opMask; /* Acceptable operators */ | 144792 | u32 opMask; /* Acceptable operators */ |
| 143617 | int k; /* Resume scanning at this->pWC->a[this->k] */ | 144793 | int k; /* Resume scanning at this->pWC->a[this->k] */ |
| 143618 | int aiCur[11]; /* Cursors in the equivalence class */ | 144794 | int aiCur[11]; /* Cursors in the equivalence class */ |
| @@ -143921,6 +145097,7 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, SrcItem*, WhereClause*); | |||
| 143921 | #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */ | 145097 | #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */ |
| 143922 | #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */ | 145098 | #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */ |
| 143923 | #define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */ | 145099 | #define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */ |
| 145100 | #define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */ | ||
| 143924 | 145101 | ||
| 143925 | #endif /* !defined(SQLITE_WHEREINT_H) */ | 145102 | #endif /* !defined(SQLITE_WHEREINT_H) */ |
| 143926 | 145103 | ||
| @@ -144055,16 +145232,8 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan( | |||
| 144055 | || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX)); | 145232 | || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX)); |
| 144056 | 145233 | ||
| 144057 | sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH); | 145234 | sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH); |
| 144058 | sqlite3_str_appendall(&str, isSearch ? "SEARCH" : "SCAN"); | 145235 | str.printfFlags = SQLITE_PRINTF_INTERNAL; |
| 144059 | if( pItem->pSelect ){ | 145236 | sqlite3_str_appendf(&str, "%s %S", isSearch ? "SEARCH" : "SCAN", pItem); |
| 144060 | sqlite3_str_appendf(&str, " SUBQUERY %u", pItem->pSelect->selId); | ||
| 144061 | }else{ | ||
| 144062 | sqlite3_str_appendf(&str, " TABLE %s", pItem->zName); | ||
| 144063 | } | ||
| 144064 | |||
| 144065 | if( pItem->zAlias ){ | ||
| 144066 | sqlite3_str_appendf(&str, " AS %s", pItem->zAlias); | ||
| 144067 | } | ||
| 144068 | if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){ | 145237 | if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){ |
| 144069 | const char *zFmt = 0; | 145238 | const char *zFmt = 0; |
| 144070 | Index *pIdx; | 145239 | Index *pIdx; |
| @@ -144212,6 +145381,12 @@ static void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){ | |||
| 144212 | }else{ | 145381 | }else{ |
| 144213 | pTerm->wtFlags |= TERM_CODED; | 145382 | pTerm->wtFlags |= TERM_CODED; |
| 144214 | } | 145383 | } |
| 145384 | #ifdef WHERETRACE_ENABLED | ||
| 145385 | if( sqlite3WhereTrace & 0x20000 ){ | ||
| 145386 | sqlite3DebugPrintf("DISABLE-"); | ||
| 145387 | sqlite3WhereTermPrint(pTerm, (int)(pTerm - (pTerm->pWC->a))); | ||
| 145388 | } | ||
| 145389 | #endif | ||
| 144215 | if( pTerm->iParent<0 ) break; | 145390 | if( pTerm->iParent<0 ) break; |
| 144216 | pTerm = &pTerm->pWC->a[pTerm->iParent]; | 145391 | pTerm = &pTerm->pWC->a[pTerm->iParent]; |
| 144217 | assert( pTerm!=0 ); | 145392 | assert( pTerm!=0 ); |
| @@ -144529,7 +145704,22 @@ static int codeEqualityTerm( | |||
| 144529 | sqlite3DbFree(pParse->db, aiMap); | 145704 | sqlite3DbFree(pParse->db, aiMap); |
| 144530 | #endif | 145705 | #endif |
| 144531 | } | 145706 | } |
| 144532 | disableTerm(pLevel, pTerm); | 145707 | |
| 145708 | /* As an optimization, try to disable the WHERE clause term that is | ||
| 145709 | ** driving the index as it will always be true. The correct answer is | ||
| 145710 | ** obtained regardless, but we might get the answer with fewer CPU cycles | ||
| 145711 | ** by omitting the term. | ||
| 145712 | ** | ||
| 145713 | ** But do not disable the term unless we are certain that the term is | ||
| 145714 | ** not a transitive constraint. For an example of where that does not | ||
| 145715 | ** work, see https://sqlite.org/forum/forumpost/eb8613976a (2021-05-04) | ||
| 145716 | */ | ||
| 145717 | if( (pLevel->pWLoop->wsFlags & WHERE_TRANSCONS)==0 | ||
| 145718 | || (pTerm->eOperator & WO_EQUIV)==0 | ||
| 145719 | ){ | ||
| 145720 | disableTerm(pLevel, pTerm); | ||
| 145721 | } | ||
| 145722 | |||
| 144533 | return iReg; | 145723 | return iReg; |
| 144534 | } | 145724 | } |
| 144535 | 145725 | ||
| @@ -144615,6 +145805,7 @@ static int codeAllEqualityTerms( | |||
| 144615 | 145805 | ||
| 144616 | if( nSkip ){ | 145806 | if( nSkip ){ |
| 144617 | int iIdxCur = pLevel->iIdxCur; | 145807 | int iIdxCur = pLevel->iIdxCur; |
| 145808 | sqlite3VdbeAddOp3(v, OP_Null, 0, regBase, regBase+nSkip-1); | ||
| 144618 | sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur); | 145809 | sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur); |
| 144619 | VdbeCoverageIf(v, bRev==0); | 145810 | VdbeCoverageIf(v, bRev==0); |
| 144620 | VdbeCoverageIf(v, bRev!=0); | 145811 | VdbeCoverageIf(v, bRev!=0); |
| @@ -144649,7 +145840,7 @@ static int codeAllEqualityTerms( | |||
| 144649 | sqlite3ReleaseTempReg(pParse, regBase); | 145840 | sqlite3ReleaseTempReg(pParse, regBase); |
| 144650 | regBase = r1; | 145841 | regBase = r1; |
| 144651 | }else{ | 145842 | }else{ |
| 144652 | sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j); | 145843 | sqlite3VdbeAddOp2(v, OP_Copy, r1, regBase+j); |
| 144653 | } | 145844 | } |
| 144654 | } | 145845 | } |
| 144655 | if( pTerm->eOperator & WO_IN ){ | 145846 | if( pTerm->eOperator & WO_IN ){ |
| @@ -144666,7 +145857,7 @@ static int codeAllEqualityTerms( | |||
| 144666 | sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk); | 145857 | sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk); |
| 144667 | VdbeCoverage(v); | 145858 | VdbeCoverage(v); |
| 144668 | } | 145859 | } |
| 144669 | if( zAff ){ | 145860 | if( pParse->db->mallocFailed==0 && pParse->nErr==0 ){ |
| 144670 | if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){ | 145861 | if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){ |
| 144671 | zAff[j] = SQLITE_AFF_BLOB; | 145862 | zAff[j] = SQLITE_AFF_BLOB; |
| 144672 | } | 145863 | } |
| @@ -145015,7 +146206,7 @@ static void codeExprOrVector(Parse *pParse, Expr *p, int iReg, int nReg){ | |||
| 145015 | } | 146206 | } |
| 145016 | } | 146207 | } |
| 145017 | }else{ | 146208 | }else{ |
| 145018 | assert( nReg==1 ); | 146209 | assert( nReg==1 || pParse->nErr ); |
| 145019 | sqlite3ExprCode(pParse, p, iReg); | 146210 | sqlite3ExprCode(pParse, p, iReg); |
| 145020 | } | 146211 | } |
| 145021 | } | 146212 | } |
| @@ -145642,9 +146833,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 145642 | ** a forward order scan on a descending index, interchange the | 146833 | ** a forward order scan on a descending index, interchange the |
| 145643 | ** start and end terms (pRangeStart and pRangeEnd). | 146834 | ** start and end terms (pRangeStart and pRangeEnd). |
| 145644 | */ | 146835 | */ |
| 145645 | if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC)) | 146836 | if( (nEq<pIdx->nColumn && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC)) ){ |
| 145646 | || (bRev && pIdx->nKeyCol==nEq) | ||
| 145647 | ){ | ||
| 145648 | SWAP(WhereTerm *, pRangeEnd, pRangeStart); | 146837 | SWAP(WhereTerm *, pRangeEnd, pRangeStart); |
| 145649 | SWAP(u8, bSeekPastNull, bStopAtNull); | 146838 | SWAP(u8, bSeekPastNull, bStopAtNull); |
| 145650 | SWAP(u8, nBtm, nTop); | 146839 | SWAP(u8, nBtm, nTop); |
| @@ -146065,7 +147254,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 146065 | /* The extra 0x10000 bit on the opcode is masked off and does not | 147254 | /* The extra 0x10000 bit on the opcode is masked off and does not |
| 146066 | ** become part of the new Expr.op. However, it does make the | 147255 | ** become part of the new Expr.op. However, it does make the |
| 146067 | ** op==TK_AND comparison inside of sqlite3PExpr() false, and this | 147256 | ** op==TK_AND comparison inside of sqlite3PExpr() false, and this |
| 146068 | ** prevents sqlite3PExpr() from implementing AND short-circuit | 147257 | ** prevents sqlite3PExpr() from applying the AND short-circuit |
| 146069 | ** optimization, which we do not want here. */ | 147258 | ** optimization, which we do not want here. */ |
| 146070 | pAndExpr = sqlite3PExpr(pParse, TK_AND|0x10000, 0, pAndExpr); | 147259 | pAndExpr = sqlite3PExpr(pParse, TK_AND|0x10000, 0, pAndExpr); |
| 146071 | } | 147260 | } |
| @@ -146081,10 +147270,16 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 146081 | if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){ | 147270 | if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){ |
| 146082 | WhereInfo *pSubWInfo; /* Info for single OR-term scan */ | 147271 | WhereInfo *pSubWInfo; /* Info for single OR-term scan */ |
| 146083 | Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */ | 147272 | Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */ |
| 147273 | Expr *pDelete; /* Local copy of OR clause term */ | ||
| 146084 | int jmp1 = 0; /* Address of jump operation */ | 147274 | int jmp1 = 0; /* Address of jump operation */ |
| 146085 | testcase( (pTabItem[0].fg.jointype & JT_LEFT)!=0 | 147275 | testcase( (pTabItem[0].fg.jointype & JT_LEFT)!=0 |
| 146086 | && !ExprHasProperty(pOrExpr, EP_FromJoin) | 147276 | && !ExprHasProperty(pOrExpr, EP_FromJoin) |
| 146087 | ); /* See TH3 vtab25.400 and ticket 614b25314c766238 */ | 147277 | ); /* See TH3 vtab25.400 and ticket 614b25314c766238 */ |
| 147278 | pDelete = pOrExpr = sqlite3ExprDup(db, pOrExpr, 0); | ||
| 147279 | if( db->mallocFailed ){ | ||
| 147280 | sqlite3ExprDelete(db, pDelete); | ||
| 147281 | continue; | ||
| 147282 | } | ||
| 146088 | if( pAndExpr ){ | 147283 | if( pAndExpr ){ |
| 146089 | pAndExpr->pLeft = pOrExpr; | 147284 | pAndExpr->pLeft = pOrExpr; |
| 146090 | pOrExpr = pAndExpr; | 147285 | pOrExpr = pAndExpr; |
| @@ -146199,6 +147394,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 146199 | sqlite3WhereEnd(pSubWInfo); | 147394 | sqlite3WhereEnd(pSubWInfo); |
| 146200 | ExplainQueryPlanPop(pParse); | 147395 | ExplainQueryPlanPop(pParse); |
| 146201 | } | 147396 | } |
| 147397 | sqlite3ExprDelete(db, pDelete); | ||
| 146202 | } | 147398 | } |
| 146203 | } | 147399 | } |
| 146204 | ExplainQueryPlanPop(pParse); | 147400 | ExplainQueryPlanPop(pParse); |
| @@ -146363,6 +147559,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 146363 | sEAlt = *pAlt->pExpr; | 147559 | sEAlt = *pAlt->pExpr; |
| 146364 | sEAlt.pLeft = pE->pLeft; | 147560 | sEAlt.pLeft = pE->pLeft; |
| 146365 | sqlite3ExprIfFalse(pParse, &sEAlt, addrCont, SQLITE_JUMPIFNULL); | 147561 | sqlite3ExprIfFalse(pParse, &sEAlt, addrCont, SQLITE_JUMPIFNULL); |
| 147562 | pAlt->wtFlags |= TERM_CODED; | ||
| 146366 | } | 147563 | } |
| 146367 | 147564 | ||
| 146368 | /* For a LEFT OUTER JOIN, generate code that will record the fact that | 147565 | /* For a LEFT OUTER JOIN, generate code that will record the fact that |
| @@ -147276,7 +148473,7 @@ static void exprAnalyzeOrTerm( | |||
| 147276 | idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC); | 148473 | idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC); |
| 147277 | testcase( idxNew==0 ); | 148474 | testcase( idxNew==0 ); |
| 147278 | exprAnalyze(pSrc, pWC, idxNew); | 148475 | exprAnalyze(pSrc, pWC, idxNew); |
| 147279 | /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where used again */ | 148476 | /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where reused */ |
| 147280 | markTermAsChild(pWC, idxNew, idxTerm); | 148477 | markTermAsChild(pWC, idxNew, idxTerm); |
| 147281 | }else{ | 148478 | }else{ |
| 147282 | sqlite3ExprListDelete(db, pList); | 148479 | sqlite3ExprListDelete(db, pList); |
| @@ -147400,6 +148597,7 @@ static int exprMightBeIndexed( | |||
| 147400 | assert( op<=TK_GE ); | 148597 | assert( op<=TK_GE ); |
| 147401 | if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){ | 148598 | if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){ |
| 147402 | pExpr = pExpr->x.pList->a[0].pExpr; | 148599 | pExpr = pExpr->x.pList->a[0].pExpr; |
| 148600 | |||
| 147403 | } | 148601 | } |
| 147404 | 148602 | ||
| 147405 | if( pExpr->op==TK_COLUMN ){ | 148603 | if( pExpr->op==TK_COLUMN ){ |
| @@ -147412,276 +148610,6 @@ static int exprMightBeIndexed( | |||
| 147412 | return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr); | 148610 | return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr); |
| 147413 | } | 148611 | } |
| 147414 | 148612 | ||
| 147415 | /* | ||
| 147416 | ** Expression callback for exprUsesSrclist(). | ||
| 147417 | */ | ||
| 147418 | static int exprUsesSrclistCb(Walker *p, Expr *pExpr){ | ||
| 147419 | if( pExpr->op==TK_COLUMN ){ | ||
| 147420 | SrcList *pSrc = p->u.pSrcList; | ||
| 147421 | int iCsr = pExpr->iTable; | ||
| 147422 | int ii; | ||
| 147423 | for(ii=0; ii<pSrc->nSrc; ii++){ | ||
| 147424 | if( pSrc->a[ii].iCursor==iCsr ){ | ||
| 147425 | return p->eCode ? WRC_Abort : WRC_Continue; | ||
| 147426 | } | ||
| 147427 | } | ||
| 147428 | return p->eCode ? WRC_Continue : WRC_Abort; | ||
| 147429 | } | ||
| 147430 | return WRC_Continue; | ||
| 147431 | } | ||
| 147432 | |||
| 147433 | /* | ||
| 147434 | ** Select callback for exprUsesSrclist(). | ||
| 147435 | */ | ||
| 147436 | static int exprUsesSrclistSelectCb(Walker *NotUsed1, Select *NotUsed2){ | ||
| 147437 | UNUSED_PARAMETER(NotUsed1); | ||
| 147438 | UNUSED_PARAMETER(NotUsed2); | ||
| 147439 | return WRC_Abort; | ||
| 147440 | } | ||
| 147441 | |||
| 147442 | /* | ||
| 147443 | ** This function always returns true if expression pExpr contains | ||
| 147444 | ** a sub-select. | ||
| 147445 | ** | ||
| 147446 | ** If there is no sub-select in pExpr, then return true if pExpr | ||
| 147447 | ** contains a TK_COLUMN node for a table that is (bUses==1) | ||
| 147448 | ** or is not (bUses==0) in pSrc. | ||
| 147449 | ** | ||
| 147450 | ** Said another way: | ||
| 147451 | ** | ||
| 147452 | ** bUses Return Meaning | ||
| 147453 | ** -------- ------ ------------------------------------------------ | ||
| 147454 | ** | ||
| 147455 | ** bUses==1 true pExpr contains either a sub-select or a | ||
| 147456 | ** TK_COLUMN referencing pSrc. | ||
| 147457 | ** | ||
| 147458 | ** bUses==1 false pExpr contains no sub-selects and all TK_COLUMN | ||
| 147459 | ** nodes reference tables not found in pSrc | ||
| 147460 | ** | ||
| 147461 | ** bUses==0 true pExpr contains either a sub-select or a TK_COLUMN | ||
| 147462 | ** that references a table not in pSrc. | ||
| 147463 | ** | ||
| 147464 | ** bUses==0 false pExpr contains no sub-selects and all TK_COLUMN | ||
| 147465 | ** nodes reference pSrc | ||
| 147466 | */ | ||
| 147467 | static int exprUsesSrclist(SrcList *pSrc, Expr *pExpr, int bUses){ | ||
| 147468 | Walker sWalker; | ||
| 147469 | memset(&sWalker, 0, sizeof(Walker)); | ||
| 147470 | sWalker.eCode = bUses; | ||
| 147471 | sWalker.u.pSrcList = pSrc; | ||
| 147472 | sWalker.xExprCallback = exprUsesSrclistCb; | ||
| 147473 | sWalker.xSelectCallback = exprUsesSrclistSelectCb; | ||
| 147474 | return (sqlite3WalkExpr(&sWalker, pExpr)==WRC_Abort); | ||
| 147475 | } | ||
| 147476 | |||
| 147477 | /* | ||
| 147478 | ** Context object used by exprExistsToInIter() as it iterates through an | ||
| 147479 | ** expression tree. | ||
| 147480 | */ | ||
| 147481 | struct ExistsToInCtx { | ||
| 147482 | SrcList *pSrc; /* The tables in an EXISTS(SELECT ... FROM <here> ...) */ | ||
| 147483 | Expr *pInLhs; /* OUT: Use this as the LHS of the IN operator */ | ||
| 147484 | Expr *pEq; /* OUT: The == term that include pInLhs */ | ||
| 147485 | Expr **ppAnd; /* OUT: The AND operator that includes pEq as a child */ | ||
| 147486 | Expr **ppParent; /* The AND operator currently being examined */ | ||
| 147487 | }; | ||
| 147488 | |||
| 147489 | /* | ||
| 147490 | ** Iterate through all AND connected nodes in the expression tree | ||
| 147491 | ** headed by (*ppExpr), populating the structure passed as the first | ||
| 147492 | ** argument with the values required by exprAnalyzeExistsFindEq(). | ||
| 147493 | ** | ||
| 147494 | ** This function returns non-zero if the expression tree does not meet | ||
| 147495 | ** the two conditions described by the header comment for | ||
| 147496 | ** exprAnalyzeExistsFindEq(), or zero if it does. | ||
| 147497 | */ | ||
| 147498 | static int exprExistsToInIter(struct ExistsToInCtx *p, Expr **ppExpr){ | ||
| 147499 | Expr *pExpr = *ppExpr; | ||
| 147500 | switch( pExpr->op ){ | ||
| 147501 | case TK_AND: | ||
| 147502 | p->ppParent = ppExpr; | ||
| 147503 | if( exprExistsToInIter(p, &pExpr->pLeft) ) return 1; | ||
| 147504 | p->ppParent = ppExpr; | ||
| 147505 | if( exprExistsToInIter(p, &pExpr->pRight) ) return 1; | ||
| 147506 | break; | ||
| 147507 | case TK_EQ: { | ||
| 147508 | int bLeft = exprUsesSrclist(p->pSrc, pExpr->pLeft, 0); | ||
| 147509 | int bRight = exprUsesSrclist(p->pSrc, pExpr->pRight, 0); | ||
| 147510 | if( bLeft || bRight ){ | ||
| 147511 | if( (bLeft && bRight) || p->pInLhs ) return 1; | ||
| 147512 | p->pInLhs = bLeft ? pExpr->pLeft : pExpr->pRight; | ||
| 147513 | if( exprUsesSrclist(p->pSrc, p->pInLhs, 1) ) return 1; | ||
| 147514 | p->pEq = pExpr; | ||
| 147515 | p->ppAnd = p->ppParent; | ||
| 147516 | } | ||
| 147517 | break; | ||
| 147518 | } | ||
| 147519 | default: | ||
| 147520 | if( exprUsesSrclist(p->pSrc, pExpr, 0) ){ | ||
| 147521 | return 1; | ||
| 147522 | } | ||
| 147523 | break; | ||
| 147524 | } | ||
| 147525 | |||
| 147526 | return 0; | ||
| 147527 | } | ||
| 147528 | |||
| 147529 | /* | ||
| 147530 | ** This function is used by exprAnalyzeExists() when creating virtual IN(...) | ||
| 147531 | ** terms equivalent to user-supplied EXIST(...) clauses. It splits the WHERE | ||
| 147532 | ** clause of the Select object passed as the first argument into one or more | ||
| 147533 | ** expressions joined by AND operators, and then tests if the following are | ||
| 147534 | ** true: | ||
| 147535 | ** | ||
| 147536 | ** 1. Exactly one of the AND separated terms refers to the outer | ||
| 147537 | ** query, and it is an == (TK_EQ) expression. | ||
| 147538 | ** | ||
| 147539 | ** 2. Only one side of the == expression refers to the outer query, and | ||
| 147540 | ** it does not refer to any columns from the inner query. | ||
| 147541 | ** | ||
| 147542 | ** If both these conditions are true, then a pointer to the side of the == | ||
| 147543 | ** expression that refers to the outer query is returned. The caller will | ||
| 147544 | ** use this expression as the LHS of the IN(...) virtual term. Or, if one | ||
| 147545 | ** or both of the above conditions are not true, NULL is returned. | ||
| 147546 | ** | ||
| 147547 | ** If non-NULL is returned and ppEq is non-NULL, *ppEq is set to point | ||
| 147548 | ** to the == expression node before returning. If pppAnd is non-NULL and | ||
| 147549 | ** the == node is not the root of the WHERE clause, then *pppAnd is set | ||
| 147550 | ** to point to the pointer to the AND node that is the parent of the == | ||
| 147551 | ** node within the WHERE expression tree. | ||
| 147552 | */ | ||
| 147553 | static Expr *exprAnalyzeExistsFindEq( | ||
| 147554 | Select *pSel, /* The SELECT of the EXISTS */ | ||
| 147555 | Expr **ppEq, /* OUT: == node from WHERE clause */ | ||
| 147556 | Expr ***pppAnd /* OUT: Pointer to parent of ==, if any */ | ||
| 147557 | ){ | ||
| 147558 | struct ExistsToInCtx ctx; | ||
| 147559 | memset(&ctx, 0, sizeof(ctx)); | ||
| 147560 | ctx.pSrc = pSel->pSrc; | ||
| 147561 | if( exprExistsToInIter(&ctx, &pSel->pWhere) ){ | ||
| 147562 | return 0; | ||
| 147563 | } | ||
| 147564 | if( ppEq ) *ppEq = ctx.pEq; | ||
| 147565 | if( pppAnd ) *pppAnd = ctx.ppAnd; | ||
| 147566 | return ctx.pInLhs; | ||
| 147567 | } | ||
| 147568 | |||
| 147569 | /* | ||
| 147570 | ** Term idxTerm of the WHERE clause passed as the second argument is an | ||
| 147571 | ** EXISTS expression with a correlated SELECT statement on the RHS. | ||
| 147572 | ** This function analyzes the SELECT statement, and if possible adds an | ||
| 147573 | ** equivalent "? IN(SELECT...)" virtual term to the WHERE clause. | ||
| 147574 | ** | ||
| 147575 | ** For an EXISTS term such as the following: | ||
| 147576 | ** | ||
| 147577 | ** EXISTS (SELECT ... FROM <srclist> WHERE <e1> = <e2> AND <e3>) | ||
| 147578 | ** | ||
| 147579 | ** The virtual IN() term added is: | ||
| 147580 | ** | ||
| 147581 | ** <e1> IN (SELECT <e2> FROM <srclist> WHERE <e3>) | ||
| 147582 | ** | ||
| 147583 | ** The virtual term is only added if the following conditions are met: | ||
| 147584 | ** | ||
| 147585 | ** 1. The sub-select must not be an aggregate or use window functions, | ||
| 147586 | ** | ||
| 147587 | ** 2. The sub-select must not be a compound SELECT, | ||
| 147588 | ** | ||
| 147589 | ** 3. Expression <e1> must refer to at least one column from the outer | ||
| 147590 | ** query, and must not refer to any column from the inner query | ||
| 147591 | ** (i.e. from <srclist>). | ||
| 147592 | ** | ||
| 147593 | ** 4. <e2> and <e3> must not refer to any values from the outer query. | ||
| 147594 | ** In other words, once <e1> has been removed, the inner query | ||
| 147595 | ** must not be correlated. | ||
| 147596 | ** | ||
| 147597 | */ | ||
| 147598 | static void exprAnalyzeExists( | ||
| 147599 | SrcList *pSrc, /* the FROM clause */ | ||
| 147600 | WhereClause *pWC, /* the WHERE clause */ | ||
| 147601 | int idxTerm /* Index of the term to be analyzed */ | ||
| 147602 | ){ | ||
| 147603 | Parse *pParse = pWC->pWInfo->pParse; | ||
| 147604 | WhereTerm *pTerm = &pWC->a[idxTerm]; | ||
| 147605 | Expr *pExpr = pTerm->pExpr; | ||
| 147606 | Select *pSel = pExpr->x.pSelect; | ||
| 147607 | Expr *pDup = 0; | ||
| 147608 | Expr *pEq = 0; | ||
| 147609 | Expr *pRet = 0; | ||
| 147610 | Expr *pInLhs = 0; | ||
| 147611 | Expr **ppAnd = 0; | ||
| 147612 | int idxNew; | ||
| 147613 | sqlite3 *db = pParse->db; | ||
| 147614 | |||
| 147615 | assert( pExpr->op==TK_EXISTS ); | ||
| 147616 | assert( (pExpr->flags & EP_VarSelect) && (pExpr->flags & EP_xIsSelect) ); | ||
| 147617 | |||
| 147618 | if( pSel->selFlags & SF_Aggregate ) return; | ||
| 147619 | #ifndef SQLITE_OMIT_WINDOWFUNC | ||
| 147620 | if( pSel->pWin ) return; | ||
| 147621 | #endif | ||
| 147622 | if( pSel->pPrior ) return; | ||
| 147623 | if( pSel->pWhere==0 ) return; | ||
| 147624 | if( pSel->pLimit ) return; | ||
| 147625 | if( 0==exprAnalyzeExistsFindEq(pSel, 0, 0) ) return; | ||
| 147626 | |||
| 147627 | pDup = sqlite3ExprDup(db, pExpr, 0); | ||
| 147628 | if( db->mallocFailed ){ | ||
| 147629 | sqlite3ExprDelete(db, pDup); | ||
| 147630 | return; | ||
| 147631 | } | ||
| 147632 | pSel = pDup->x.pSelect; | ||
| 147633 | sqlite3ExprListDelete(db, pSel->pEList); | ||
| 147634 | pSel->pEList = 0; | ||
| 147635 | |||
| 147636 | pInLhs = exprAnalyzeExistsFindEq(pSel, &pEq, &ppAnd); | ||
| 147637 | assert( pInLhs && pEq ); | ||
| 147638 | assert( pEq==pSel->pWhere || ppAnd ); | ||
| 147639 | if( pInLhs==pEq->pLeft ){ | ||
| 147640 | pRet = pEq->pRight; | ||
| 147641 | }else{ | ||
| 147642 | CollSeq *p = sqlite3ExprCompareCollSeq(pParse, pEq); | ||
| 147643 | pInLhs = sqlite3ExprAddCollateString(pParse, pInLhs, p?p->zName:"BINARY"); | ||
| 147644 | pRet = pEq->pLeft; | ||
| 147645 | } | ||
| 147646 | |||
| 147647 | assert( pDup->pLeft==0 ); | ||
| 147648 | pDup->op = TK_IN; | ||
| 147649 | pDup->pLeft = pInLhs; | ||
| 147650 | pDup->flags &= ~EP_VarSelect; | ||
| 147651 | if( pRet->op==TK_VECTOR ){ | ||
| 147652 | pSel->pEList = pRet->x.pList; | ||
| 147653 | pRet->x.pList = 0; | ||
| 147654 | sqlite3ExprDelete(db, pRet); | ||
| 147655 | }else{ | ||
| 147656 | pSel->pEList = sqlite3ExprListAppend(pParse, 0, pRet); | ||
| 147657 | } | ||
| 147658 | pEq->pLeft = 0; | ||
| 147659 | pEq->pRight = 0; | ||
| 147660 | if( ppAnd ){ | ||
| 147661 | Expr *pAnd = *ppAnd; | ||
| 147662 | Expr *pOther = (pAnd->pLeft==pEq) ? pAnd->pRight : pAnd->pLeft; | ||
| 147663 | pAnd->pLeft = pAnd->pRight = 0; | ||
| 147664 | sqlite3ExprDelete(db, pAnd); | ||
| 147665 | *ppAnd = pOther; | ||
| 147666 | }else{ | ||
| 147667 | assert( pSel->pWhere==pEq ); | ||
| 147668 | pSel->pWhere = 0; | ||
| 147669 | } | ||
| 147670 | sqlite3ExprDelete(db, pEq); | ||
| 147671 | |||
| 147672 | #ifdef WHERETRACE_ENABLED /* 0x20 */ | ||
| 147673 | if( sqlite3WhereTrace & 0x20 ){ | ||
| 147674 | sqlite3DebugPrintf("Convert EXISTS:\n"); | ||
| 147675 | sqlite3TreeViewExpr(0, pExpr, 0); | ||
| 147676 | sqlite3DebugPrintf("into IN:\n"); | ||
| 147677 | sqlite3TreeViewExpr(0, pDup, 0); | ||
| 147678 | } | ||
| 147679 | #endif | ||
| 147680 | idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC); | ||
| 147681 | exprAnalyze(pSrc, pWC, idxNew); | ||
| 147682 | markTermAsChild(pWC, idxNew, idxTerm); | ||
| 147683 | pWC->a[idxTerm].wtFlags |= TERM_COPIED; | ||
| 147684 | } | ||
| 147685 | 148613 | ||
| 147686 | /* | 148614 | /* |
| 147687 | ** The input to this routine is an WhereTerm structure with only the | 148615 | ** The input to this routine is an WhereTerm structure with only the |
| @@ -147781,6 +148709,7 @@ static void exprAnalyze( | |||
| 147781 | if( op==TK_IS ) pTerm->wtFlags |= TERM_IS; | 148709 | if( op==TK_IS ) pTerm->wtFlags |= TERM_IS; |
| 147782 | if( pRight | 148710 | if( pRight |
| 147783 | && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op) | 148711 | && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op) |
| 148712 | && !ExprHasProperty(pRight, EP_FixedCol) | ||
| 147784 | ){ | 148713 | ){ |
| 147785 | WhereTerm *pNew; | 148714 | WhereTerm *pNew; |
| 147786 | Expr *pDup; | 148715 | Expr *pDup; |
| @@ -147873,16 +148802,6 @@ static void exprAnalyze( | |||
| 147873 | pTerm = &pWC->a[idxTerm]; | 148802 | pTerm = &pWC->a[idxTerm]; |
| 147874 | } | 148803 | } |
| 147875 | #endif /* SQLITE_OMIT_OR_OPTIMIZATION */ | 148804 | #endif /* SQLITE_OMIT_OR_OPTIMIZATION */ |
| 147876 | |||
| 147877 | else if( pExpr->op==TK_EXISTS ){ | ||
| 147878 | /* Perhaps treat an EXISTS operator as an IN operator */ | ||
| 147879 | if( (pExpr->flags & EP_VarSelect)!=0 | ||
| 147880 | && OptimizationEnabled(db, SQLITE_ExistsToIN) | ||
| 147881 | ){ | ||
| 147882 | exprAnalyzeExists(pSrc, pWC, idxTerm); | ||
| 147883 | } | ||
| 147884 | } | ||
| 147885 | |||
| 147886 | /* The form "x IS NOT NULL" can sometimes be evaluated more efficiently | 148805 | /* The form "x IS NOT NULL" can sometimes be evaluated more efficiently |
| 147887 | ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a | 148806 | ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a |
| 147888 | ** virtual term of that form. | 148807 | ** virtual term of that form. |
| @@ -148569,7 +149488,9 @@ static void createMask(WhereMaskSet *pMaskSet, int iCursor){ | |||
| 148569 | */ | 149488 | */ |
| 148570 | static Expr *whereRightSubexprIsColumn(Expr *p){ | 149489 | static Expr *whereRightSubexprIsColumn(Expr *p){ |
| 148571 | p = sqlite3ExprSkipCollateAndLikely(p->pRight); | 149490 | p = sqlite3ExprSkipCollateAndLikely(p->pRight); |
| 148572 | if( ALWAYS(p!=0) && p->op==TK_COLUMN ) return p; | 149491 | if( ALWAYS(p!=0) && p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){ |
| 149492 | return p; | ||
| 149493 | } | ||
| 148573 | return 0; | 149494 | return 0; |
| 148574 | } | 149495 | } |
| 148575 | 149496 | ||
| @@ -148644,6 +149565,18 @@ static WhereTerm *whereScanNext(WhereScan *pScan){ | |||
| 148644 | } | 149565 | } |
| 148645 | pScan->pWC = pWC; | 149566 | pScan->pWC = pWC; |
| 148646 | pScan->k = k+1; | 149567 | pScan->k = k+1; |
| 149568 | #ifdef WHERETRACE_ENABLED | ||
| 149569 | if( sqlite3WhereTrace & 0x20000 ){ | ||
| 149570 | int ii; | ||
| 149571 | sqlite3DebugPrintf("SCAN-TERM %p: nEquiv=%d", | ||
| 149572 | pTerm, pScan->nEquiv); | ||
| 149573 | for(ii=0; ii<pScan->nEquiv; ii++){ | ||
| 149574 | sqlite3DebugPrintf(" {%d:%d}", | ||
| 149575 | pScan->aiCur[ii], pScan->aiColumn[ii]); | ||
| 149576 | } | ||
| 149577 | sqlite3DebugPrintf("\n"); | ||
| 149578 | } | ||
| 149579 | #endif | ||
| 148647 | return pTerm; | 149580 | return pTerm; |
| 148648 | } | 149581 | } |
| 148649 | } | 149582 | } |
| @@ -148800,7 +149733,7 @@ static int findIndexCol( | |||
| 148800 | for(i=0; i<pList->nExpr; i++){ | 149733 | for(i=0; i<pList->nExpr; i++){ |
| 148801 | Expr *p = sqlite3ExprSkipCollateAndLikely(pList->a[i].pExpr); | 149734 | Expr *p = sqlite3ExprSkipCollateAndLikely(pList->a[i].pExpr); |
| 148802 | if( ALWAYS(p!=0) | 149735 | if( ALWAYS(p!=0) |
| 148803 | && p->op==TK_COLUMN | 149736 | && (p->op==TK_COLUMN || p->op==TK_AGG_COLUMN) |
| 148804 | && p->iColumn==pIdx->aiColumn[iCol] | 149737 | && p->iColumn==pIdx->aiColumn[iCol] |
| 148805 | && p->iTable==iBase | 149738 | && p->iTable==iBase |
| 148806 | ){ | 149739 | ){ |
| @@ -148865,7 +149798,8 @@ static int isDistinctRedundant( | |||
| 148865 | for(i=0; i<pDistinct->nExpr; i++){ | 149798 | for(i=0; i<pDistinct->nExpr; i++){ |
| 148866 | Expr *p = sqlite3ExprSkipCollateAndLikely(pDistinct->a[i].pExpr); | 149799 | Expr *p = sqlite3ExprSkipCollateAndLikely(pDistinct->a[i].pExpr); |
| 148867 | if( NEVER(p==0) ) continue; | 149800 | if( NEVER(p==0) ) continue; |
| 148868 | if( p->op==TK_COLUMN && p->iTable==iBase && p->iColumn<0 ) return 1; | 149801 | if( p->op!=TK_COLUMN && p->op!=TK_AGG_COLUMN ) continue; |
| 149802 | if( p->iTable==iBase && p->iColumn<0 ) return 1; | ||
| 148869 | } | 149803 | } |
| 148870 | 149804 | ||
| 148871 | /* Loop through all indices on the table, checking each to see if it makes | 149805 | /* Loop through all indices on the table, checking each to see if it makes |
| @@ -148883,6 +149817,7 @@ static int isDistinctRedundant( | |||
| 148883 | */ | 149817 | */ |
| 148884 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ | 149818 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 148885 | if( !IsUniqueIndex(pIdx) ) continue; | 149819 | if( !IsUniqueIndex(pIdx) ) continue; |
| 149820 | if( pIdx->pPartIdxWhere ) continue; | ||
| 148886 | for(i=0; i<pIdx->nKeyCol; i++){ | 149821 | for(i=0; i<pIdx->nKeyCol; i++){ |
| 148887 | if( 0==sqlite3WhereFindTerm(pWC, iBase, i, ~(Bitmask)0, WO_EQ, pIdx) ){ | 149822 | if( 0==sqlite3WhereFindTerm(pWC, iBase, i, ~(Bitmask)0, WO_EQ, pIdx) ){ |
| 148888 | if( findIndexCol(pParse, pDistinct, iBase, pIdx, i)<0 ) break; | 149823 | if( findIndexCol(pParse, pDistinct, iBase, pIdx, i)<0 ) break; |
| @@ -148937,14 +149872,14 @@ static void translateColumnToCopy( | |||
| 148937 | pOp->p2 = pOp->p3; | 149872 | pOp->p2 = pOp->p3; |
| 148938 | pOp->p3 = 0; | 149873 | pOp->p3 = 0; |
| 148939 | }else if( pOp->opcode==OP_Rowid ){ | 149874 | }else if( pOp->opcode==OP_Rowid ){ |
| 148940 | if( iAutoidxCur ){ | 149875 | pOp->opcode = OP_Sequence; |
| 148941 | pOp->opcode = OP_Sequence; | 149876 | pOp->p1 = iAutoidxCur; |
| 148942 | pOp->p1 = iAutoidxCur; | 149877 | #ifdef SQLITE_ALLOW_ROWID_IN_VIEW |
| 148943 | }else{ | 149878 | if( iAutoidxCur==0 ){ |
| 148944 | pOp->opcode = OP_Null; | 149879 | pOp->opcode = OP_Null; |
| 148945 | pOp->p1 = 0; | ||
| 148946 | pOp->p3 = 0; | 149880 | pOp->p3 = 0; |
| 148947 | } | 149881 | } |
| 149882 | #endif | ||
| 148948 | } | 149883 | } |
| 148949 | } | 149884 | } |
| 148950 | } | 149885 | } |
| @@ -149109,7 +150044,7 @@ static void constructAutomaticIndex( | |||
| 149109 | } | 150044 | } |
| 149110 | } | 150045 | } |
| 149111 | } | 150046 | } |
| 149112 | assert( nKeyCol>0 ); | 150047 | assert( nKeyCol>0 || pParse->db->mallocFailed ); |
| 149113 | pLoop->u.btree.nEq = pLoop->nLTerm = nKeyCol; | 150048 | pLoop->u.btree.nEq = pLoop->nLTerm = nKeyCol; |
| 149114 | pLoop->wsFlags = WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WHERE_INDEXED | 150049 | pLoop->wsFlags = WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WHERE_INDEXED |
| 149115 | | WHERE_AUTO_INDEX; | 150050 | | WHERE_AUTO_INDEX; |
| @@ -150246,7 +151181,7 @@ static int whereLoopResize(sqlite3 *db, WhereLoop *p, int n){ | |||
| 150246 | static int whereLoopXfer(sqlite3 *db, WhereLoop *pTo, WhereLoop *pFrom){ | 151181 | static int whereLoopXfer(sqlite3 *db, WhereLoop *pTo, WhereLoop *pFrom){ |
| 150247 | whereLoopClearUnion(db, pTo); | 151182 | whereLoopClearUnion(db, pTo); |
| 150248 | if( whereLoopResize(db, pTo, pFrom->nLTerm) ){ | 151183 | if( whereLoopResize(db, pTo, pFrom->nLTerm) ){ |
| 150249 | memset(&pTo->u, 0, sizeof(pTo->u)); | 151184 | memset(pTo, 0, WHERE_LOOP_XFER_SZ); |
| 150250 | return SQLITE_NOMEM_BKPT; | 151185 | return SQLITE_NOMEM_BKPT; |
| 150251 | } | 151186 | } |
| 150252 | memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ); | 151187 | memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ); |
| @@ -150289,6 +151224,17 @@ static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){ | |||
| 150289 | sqlite3DbFreeNN(db, pWInfo); | 151224 | sqlite3DbFreeNN(db, pWInfo); |
| 150290 | } | 151225 | } |
| 150291 | 151226 | ||
| 151227 | /* Undo all Expr node modifications | ||
| 151228 | */ | ||
| 151229 | static void whereUndoExprMods(WhereInfo *pWInfo){ | ||
| 151230 | while( pWInfo->pExprMods ){ | ||
| 151231 | WhereExprMod *p = pWInfo->pExprMods; | ||
| 151232 | pWInfo->pExprMods = p->pNext; | ||
| 151233 | memcpy(p->pExpr, &p->orig, sizeof(p->orig)); | ||
| 151234 | sqlite3DbFree(pWInfo->pParse->db, p); | ||
| 151235 | } | ||
| 151236 | } | ||
| 151237 | |||
| 150292 | /* | 151238 | /* |
| 150293 | ** Return TRUE if all of the following are true: | 151239 | ** Return TRUE if all of the following are true: |
| 150294 | ** | 151240 | ** |
| @@ -150794,6 +151740,8 @@ static int whereLoopAddBtreeIndex( | |||
| 150794 | if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); | 151740 | if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); |
| 150795 | 151741 | ||
| 150796 | assert( pNew->u.btree.nEq<pProbe->nColumn ); | 151742 | assert( pNew->u.btree.nEq<pProbe->nColumn ); |
| 151743 | assert( pNew->u.btree.nEq<pProbe->nKeyCol | ||
| 151744 | || pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY ); | ||
| 150797 | 151745 | ||
| 150798 | saved_nEq = pNew->u.btree.nEq; | 151746 | saved_nEq = pNew->u.btree.nEq; |
| 150799 | saved_nBtm = pNew->u.btree.nBtm; | 151747 | saved_nBtm = pNew->u.btree.nBtm; |
| @@ -150876,7 +151824,7 @@ static int whereLoopAddBtreeIndex( | |||
| 150876 | nIn = sqlite3LogEst(pExpr->x.pList->nExpr); | 151824 | nIn = sqlite3LogEst(pExpr->x.pList->nExpr); |
| 150877 | } | 151825 | } |
| 150878 | if( pProbe->hasStat1 && rLogSize>=10 ){ | 151826 | if( pProbe->hasStat1 && rLogSize>=10 ){ |
| 150879 | LogEst M, logK, safetyMargin; | 151827 | LogEst M, logK, x; |
| 150880 | /* Let: | 151828 | /* Let: |
| 150881 | ** N = the total number of rows in the table | 151829 | ** N = the total number of rows in the table |
| 150882 | ** K = the number of entries on the RHS of the IN operator | 151830 | ** K = the number of entries on the RHS of the IN operator |
| @@ -150899,16 +151847,25 @@ static int whereLoopAddBtreeIndex( | |||
| 150899 | */ | 151847 | */ |
| 150900 | M = pProbe->aiRowLogEst[saved_nEq]; | 151848 | M = pProbe->aiRowLogEst[saved_nEq]; |
| 150901 | logK = estLog(nIn); | 151849 | logK = estLog(nIn); |
| 150902 | safetyMargin = 10; /* TUNING: extra weight for indexed IN */ | 151850 | /* TUNING v----- 10 to bias toward indexed IN */ |
| 150903 | if( M + logK + safetyMargin < nIn + rLogSize ){ | 151851 | x = M + logK + 10 - (nIn + rLogSize); |
| 151852 | if( x>=0 ){ | ||
| 151853 | WHERETRACE(0x40, | ||
| 151854 | ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d) " | ||
| 151855 | "prefers indexed lookup\n", | ||
| 151856 | saved_nEq, M, logK, nIn, rLogSize, x)); | ||
| 151857 | }else if( nInMul<2 && OptimizationEnabled(db, SQLITE_SeekScan) ){ | ||
| 150904 | WHERETRACE(0x40, | 151858 | WHERETRACE(0x40, |
| 150905 | ("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n", | 151859 | ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d" |
| 150906 | saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize)); | 151860 | " nInMul=%d) prefers skip-scan\n", |
| 151861 | saved_nEq, M, logK, nIn, rLogSize, x, nInMul)); | ||
| 150907 | pNew->wsFlags |= WHERE_IN_SEEKSCAN; | 151862 | pNew->wsFlags |= WHERE_IN_SEEKSCAN; |
| 150908 | }else{ | 151863 | }else{ |
| 150909 | WHERETRACE(0x40, | 151864 | WHERETRACE(0x40, |
| 150910 | ("IN operator preferred on column %d of \"%s\" (%d>=%d)\n", | 151865 | ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d" |
| 150911 | saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize)); | 151866 | " nInMul=%d) prefers normal scan\n", |
| 151867 | saved_nEq, M, logK, nIn, rLogSize, x, nInMul)); | ||
| 151868 | continue; | ||
| 150912 | } | 151869 | } |
| 150913 | } | 151870 | } |
| 150914 | pNew->wsFlags |= WHERE_COLUMN_IN; | 151871 | pNew->wsFlags |= WHERE_COLUMN_IN; |
| @@ -150927,6 +151884,7 @@ static int whereLoopAddBtreeIndex( | |||
| 150927 | pNew->wsFlags |= WHERE_UNQ_WANTED; | 151884 | pNew->wsFlags |= WHERE_UNQ_WANTED; |
| 150928 | } | 151885 | } |
| 150929 | } | 151886 | } |
| 151887 | if( scan.iEquiv>1 ) pNew->wsFlags |= WHERE_TRANSCONS; | ||
| 150930 | }else if( eOp & WO_ISNULL ){ | 151888 | }else if( eOp & WO_ISNULL ){ |
| 150931 | pNew->wsFlags |= WHERE_COLUMN_NULL; | 151889 | pNew->wsFlags |= WHERE_COLUMN_NULL; |
| 150932 | }else if( eOp & (WO_GT|WO_GE) ){ | 151890 | }else if( eOp & (WO_GT|WO_GE) ){ |
| @@ -150988,7 +151946,7 @@ static int whereLoopAddBtreeIndex( | |||
| 150988 | tRowcnt nOut = 0; | 151946 | tRowcnt nOut = 0; |
| 150989 | if( nInMul==0 | 151947 | if( nInMul==0 |
| 150990 | && pProbe->nSample | 151948 | && pProbe->nSample |
| 150991 | && pNew->u.btree.nEq<=pProbe->nSampleCol | 151949 | && ALWAYS(pNew->u.btree.nEq<=pProbe->nSampleCol) |
| 150992 | && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect)) | 151950 | && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect)) |
| 150993 | && OptimizationEnabled(db, SQLITE_Stat4) | 151951 | && OptimizationEnabled(db, SQLITE_Stat4) |
| 150994 | ){ | 151952 | ){ |
| @@ -151070,6 +152028,8 @@ static int whereLoopAddBtreeIndex( | |||
| 151070 | 152028 | ||
| 151071 | if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 | 152029 | if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 |
| 151072 | && pNew->u.btree.nEq<pProbe->nColumn | 152030 | && pNew->u.btree.nEq<pProbe->nColumn |
| 152031 | && (pNew->u.btree.nEq<pProbe->nKeyCol || | ||
| 152032 | pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY) | ||
| 151073 | ){ | 152033 | ){ |
| 151074 | whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn); | 152034 | whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn); |
| 151075 | } | 152035 | } |
| @@ -151191,6 +152151,7 @@ static int whereUsablePartialIndex( | |||
| 151191 | if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab) | 152151 | if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab) |
| 151192 | && (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin)) | 152152 | && (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin)) |
| 151193 | && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab) | 152153 | && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab) |
| 152154 | && (pTerm->wtFlags & TERM_VNULL)==0 | ||
| 151194 | ){ | 152155 | ){ |
| 151195 | return 1; | 152156 | return 1; |
| 151196 | } | 152157 | } |
| @@ -151901,7 +152862,9 @@ static int whereLoopAddOr( | |||
| 151901 | if( rc==SQLITE_OK ){ | 152862 | if( rc==SQLITE_OK ){ |
| 151902 | rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable); | 152863 | rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable); |
| 151903 | } | 152864 | } |
| 151904 | assert( rc==SQLITE_OK || rc==SQLITE_DONE || sCur.n==0 ); | 152865 | assert( rc==SQLITE_OK || rc==SQLITE_DONE || sCur.n==0 |
| 152866 | || rc==SQLITE_NOMEM ); | ||
| 152867 | testcase( rc==SQLITE_NOMEM && sCur.n>0 ); | ||
| 151905 | testcase( rc==SQLITE_DONE ); | 152868 | testcase( rc==SQLITE_DONE ); |
| 151906 | if( sCur.n==0 ){ | 152869 | if( sCur.n==0 ){ |
| 151907 | sSum.n = 0; | 152870 | sSum.n = 0; |
| @@ -152130,7 +153093,7 @@ static i8 wherePathSatisfiesOrderBy( | |||
| 152130 | if( MASKBIT(i) & obSat ) continue; | 153093 | if( MASKBIT(i) & obSat ) continue; |
| 152131 | pOBExpr = sqlite3ExprSkipCollateAndLikely(pOrderBy->a[i].pExpr); | 153094 | pOBExpr = sqlite3ExprSkipCollateAndLikely(pOrderBy->a[i].pExpr); |
| 152132 | if( NEVER(pOBExpr==0) ) continue; | 153095 | if( NEVER(pOBExpr==0) ) continue; |
| 152133 | if( pOBExpr->op!=TK_COLUMN ) continue; | 153096 | if( pOBExpr->op!=TK_COLUMN && pOBExpr->op!=TK_AGG_COLUMN ) continue; |
| 152134 | if( pOBExpr->iTable!=iCur ) continue; | 153097 | if( pOBExpr->iTable!=iCur ) continue; |
| 152135 | pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn, | 153098 | pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn, |
| 152136 | ~ready, eqOpMask, 0); | 153099 | ~ready, eqOpMask, 0); |
| @@ -152170,6 +153133,10 @@ static i8 wherePathSatisfiesOrderBy( | |||
| 152170 | assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) ); | 153133 | assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) ); |
| 152171 | assert( pIndex->aiColumn[nColumn-1]==XN_ROWID | 153134 | assert( pIndex->aiColumn[nColumn-1]==XN_ROWID |
| 152172 | || !HasRowid(pIndex->pTable)); | 153135 | || !HasRowid(pIndex->pTable)); |
| 153136 | /* All relevant terms of the index must also be non-NULL in order | ||
| 153137 | ** for isOrderDistinct to be true. So the isOrderDistint value | ||
| 153138 | ** computed here might be a false positive. Corrections will be | ||
| 153139 | ** made at tag-20210426-1 below */ | ||
| 152173 | isOrderDistinct = IsUniqueIndex(pIndex) | 153140 | isOrderDistinct = IsUniqueIndex(pIndex) |
| 152174 | && (pLoop->wsFlags & WHERE_SKIPSCAN)==0; | 153141 | && (pLoop->wsFlags & WHERE_SKIPSCAN)==0; |
| 152175 | } | 153142 | } |
| @@ -152237,14 +153204,18 @@ static i8 wherePathSatisfiesOrderBy( | |||
| 152237 | } | 153204 | } |
| 152238 | 153205 | ||
| 152239 | /* An unconstrained column that might be NULL means that this | 153206 | /* An unconstrained column that might be NULL means that this |
| 152240 | ** WhereLoop is not well-ordered | 153207 | ** WhereLoop is not well-ordered. tag-20210426-1 |
| 152241 | */ | 153208 | */ |
| 152242 | if( isOrderDistinct | 153209 | if( isOrderDistinct ){ |
| 152243 | && iColumn>=0 | 153210 | if( iColumn>=0 |
| 152244 | && j>=pLoop->u.btree.nEq | 153211 | && j>=pLoop->u.btree.nEq |
| 152245 | && pIndex->pTable->aCol[iColumn].notNull==0 | 153212 | && pIndex->pTable->aCol[iColumn].notNull==0 |
| 152246 | ){ | 153213 | ){ |
| 152247 | isOrderDistinct = 0; | 153214 | isOrderDistinct = 0; |
| 153215 | } | ||
| 153216 | if( iColumn==XN_EXPR ){ | ||
| 153217 | isOrderDistinct = 0; | ||
| 153218 | } | ||
| 152248 | } | 153219 | } |
| 152249 | 153220 | ||
| 152250 | /* Find the ORDER BY term that corresponds to the j-th column | 153221 | /* Find the ORDER BY term that corresponds to the j-th column |
| @@ -152259,7 +153230,7 @@ static i8 wherePathSatisfiesOrderBy( | |||
| 152259 | if( NEVER(pOBExpr==0) ) continue; | 153230 | if( NEVER(pOBExpr==0) ) continue; |
| 152260 | if( (wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY))==0 ) bOnce = 0; | 153231 | if( (wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY))==0 ) bOnce = 0; |
| 152261 | if( iColumn>=XN_ROWID ){ | 153232 | if( iColumn>=XN_ROWID ){ |
| 152262 | if( pOBExpr->op!=TK_COLUMN ) continue; | 153233 | if( pOBExpr->op!=TK_COLUMN && pOBExpr->op!=TK_AGG_COLUMN ) continue; |
| 152263 | if( pOBExpr->iTable!=iCur ) continue; | 153234 | if( pOBExpr->iTable!=iCur ) continue; |
| 152264 | if( pOBExpr->iColumn!=iColumn ) continue; | 153235 | if( pOBExpr->iColumn!=iColumn ) continue; |
| 152265 | }else{ | 153236 | }else{ |
| @@ -152428,7 +153399,7 @@ static LogEst whereSortingCost( | |||
| 152428 | }else if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT) ){ | 153399 | }else if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT) ){ |
| 152429 | /* TUNING: In the sort for a DISTINCT operator, assume that the DISTINCT | 153400 | /* TUNING: In the sort for a DISTINCT operator, assume that the DISTINCT |
| 152430 | ** reduces the number of output rows by a factor of 2 */ | 153401 | ** reduces the number of output rows by a factor of 2 */ |
| 152431 | if( nRow>10 ) nRow -= 10; assert( 10==sqlite3LogEst(2) ); | 153402 | if( nRow>10 ){ nRow -= 10; assert( 10==sqlite3LogEst(2) ); } |
| 152432 | } | 153403 | } |
| 152433 | rSortCost += estLog(nRow); | 153404 | rSortCost += estLog(nRow); |
| 152434 | return rSortCost; | 153405 | return rSortCost; |
| @@ -153360,7 +154331,8 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( | |||
| 153360 | */ | 154331 | */ |
| 153361 | notReady = ~(Bitmask)0; | 154332 | notReady = ~(Bitmask)0; |
| 153362 | if( pWInfo->nLevel>=2 | 154333 | if( pWInfo->nLevel>=2 |
| 153363 | && pResultSet!=0 /* guarantees condition (1) above */ | 154334 | && pResultSet!=0 /* these two combine to guarantee */ |
| 154335 | && 0==(wctrlFlags & WHERE_AGG_DISTINCT) /* condition (1) above */ | ||
| 153364 | && OptimizationEnabled(db, SQLITE_OmitNoopJoin) | 154336 | && OptimizationEnabled(db, SQLITE_OmitNoopJoin) |
| 153365 | ){ | 154337 | ){ |
| 153366 | int i; | 154338 | int i; |
| @@ -153619,6 +154591,8 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( | |||
| 153619 | /* Jump here if malloc fails */ | 154591 | /* Jump here if malloc fails */ |
| 153620 | whereBeginError: | 154592 | whereBeginError: |
| 153621 | if( pWInfo ){ | 154593 | if( pWInfo ){ |
| 154594 | testcase( pWInfo->pExprMods!=0 ); | ||
| 154595 | whereUndoExprMods(pWInfo); | ||
| 153622 | pParse->nQueryLoop = pWInfo->savedNQueryLoop; | 154596 | pParse->nQueryLoop = pWInfo->savedNQueryLoop; |
| 153623 | whereInfoFree(db, pWInfo); | 154597 | whereInfoFree(db, pWInfo); |
| 153624 | } | 154598 | } |
| @@ -153715,6 +154689,8 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ | |||
| 153715 | int j; | 154689 | int j; |
| 153716 | sqlite3VdbeResolveLabel(v, pLevel->addrNxt); | 154690 | sqlite3VdbeResolveLabel(v, pLevel->addrNxt); |
| 153717 | for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){ | 154691 | for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){ |
| 154692 | assert( sqlite3VdbeGetOp(v, pIn->addrInTop+1)->opcode==OP_IsNull | ||
| 154693 | || pParse->db->mallocFailed ); | ||
| 153718 | sqlite3VdbeJumpHere(v, pIn->addrInTop+1); | 154694 | sqlite3VdbeJumpHere(v, pIn->addrInTop+1); |
| 153719 | if( pIn->eEndLoopOp!=OP_Noop ){ | 154695 | if( pIn->eEndLoopOp!=OP_Noop ){ |
| 153720 | if( pIn->nPrefix ){ | 154696 | if( pIn->nPrefix ){ |
| @@ -153739,6 +154715,11 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ | |||
| 153739 | sqlite3VdbeCurrentAddr(v)+2, | 154715 | sqlite3VdbeCurrentAddr(v)+2, |
| 153740 | pIn->iBase, pIn->nPrefix); | 154716 | pIn->iBase, pIn->nPrefix); |
| 153741 | VdbeCoverage(v); | 154717 | VdbeCoverage(v); |
| 154718 | /* Retarget the OP_IsNull against the left operand of IN so | ||
| 154719 | ** it jumps past the OP_IfNoHope. This is because the | ||
| 154720 | ** OP_IsNull also bypasses the OP_Affinity opcode that is | ||
| 154721 | ** required by OP_IfNoHope. */ | ||
| 154722 | sqlite3VdbeJumpHere(v, pIn->addrInTop+1); | ||
| 153742 | } | 154723 | } |
| 153743 | } | 154724 | } |
| 153744 | sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop); | 154725 | sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop); |
| @@ -153873,7 +154854,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ | |||
| 153873 | #endif | 154854 | #endif |
| 153874 | pOp = sqlite3VdbeGetOp(v, k); | 154855 | pOp = sqlite3VdbeGetOp(v, k); |
| 153875 | pLastOp = pOp + (last - k); | 154856 | pLastOp = pOp + (last - k); |
| 153876 | assert( pOp<pLastOp || (pParse->nErr>0 && pOp==pLastOp) ); | 154857 | assert( pOp<=pLastOp ); |
| 153877 | do{ | 154858 | do{ |
| 153878 | if( pOp->p1!=pLevel->iTabCur ){ | 154859 | if( pOp->p1!=pLevel->iTabCur ){ |
| 153879 | /* no-op */ | 154860 | /* no-op */ |
| @@ -153918,16 +154899,9 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ | |||
| 153918 | } | 154899 | } |
| 153919 | } | 154900 | } |
| 153920 | 154901 | ||
| 153921 | /* Undo all Expr node modifications */ | ||
| 153922 | while( pWInfo->pExprMods ){ | ||
| 153923 | WhereExprMod *p = pWInfo->pExprMods; | ||
| 153924 | pWInfo->pExprMods = p->pNext; | ||
| 153925 | memcpy(p->pExpr, &p->orig, sizeof(p->orig)); | ||
| 153926 | sqlite3DbFree(db, p); | ||
| 153927 | } | ||
| 153928 | |||
| 153929 | /* Final cleanup | 154902 | /* Final cleanup |
| 153930 | */ | 154903 | */ |
| 154904 | if( pWInfo->pExprMods ) whereUndoExprMods(pWInfo); | ||
| 153931 | pParse->nQueryLoop = pWInfo->savedNQueryLoop; | 154905 | pParse->nQueryLoop = pWInfo->savedNQueryLoop; |
| 153932 | whereInfoFree(db, pWInfo); | 154906 | whereInfoFree(db, pWInfo); |
| 153933 | return; | 154907 | return; |
| @@ -154725,6 +155699,7 @@ static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){ | |||
| 154725 | case TK_AGG_FUNCTION: | 155699 | case TK_AGG_FUNCTION: |
| 154726 | case TK_COLUMN: { | 155700 | case TK_COLUMN: { |
| 154727 | int iCol = -1; | 155701 | int iCol = -1; |
| 155702 | if( pParse->db->mallocFailed ) return WRC_Abort; | ||
| 154728 | if( p->pSub ){ | 155703 | if( p->pSub ){ |
| 154729 | int i; | 155704 | int i; |
| 154730 | for(i=0; i<p->pSub->nExpr; i++){ | 155705 | for(i=0; i<p->pSub->nExpr; i++){ |
| @@ -154834,9 +155809,14 @@ static ExprList *exprListAppendList( | |||
| 154834 | int i; | 155809 | int i; |
| 154835 | int nInit = pList ? pList->nExpr : 0; | 155810 | int nInit = pList ? pList->nExpr : 0; |
| 154836 | for(i=0; i<pAppend->nExpr; i++){ | 155811 | for(i=0; i<pAppend->nExpr; i++){ |
| 154837 | Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0); | 155812 | sqlite3 *db = pParse->db; |
| 155813 | Expr *pDup = sqlite3ExprDup(db, pAppend->a[i].pExpr, 0); | ||
| 154838 | assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) ); | 155814 | assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) ); |
| 154839 | if( bIntToNull && pDup ){ | 155815 | if( db->mallocFailed ){ |
| 155816 | sqlite3ExprDelete(db, pDup); | ||
| 155817 | break; | ||
| 155818 | } | ||
| 155819 | if( bIntToNull ){ | ||
| 154840 | int iDummy; | 155820 | int iDummy; |
| 154841 | Expr *pSub; | 155821 | Expr *pSub; |
| 154842 | for(pSub=pDup; ExprHasProperty(pSub, EP_Skip); pSub=pSub->pLeft){ | 155822 | for(pSub=pDup; ExprHasProperty(pSub, EP_Skip); pSub=pSub->pLeft){ |
| @@ -154872,6 +155852,14 @@ static int sqlite3WindowExtraAggFuncDepth(Walker *pWalker, Expr *pExpr){ | |||
| 154872 | return WRC_Continue; | 155852 | return WRC_Continue; |
| 154873 | } | 155853 | } |
| 154874 | 155854 | ||
| 155855 | static int disallowAggregatesInOrderByCb(Walker *pWalker, Expr *pExpr){ | ||
| 155856 | if( pExpr->op==TK_AGG_FUNCTION && pExpr->pAggInfo==0 ){ | ||
| 155857 | sqlite3ErrorMsg(pWalker->pParse, | ||
| 155858 | "misuse of aggregate: %s()", pExpr->u.zToken); | ||
| 155859 | } | ||
| 155860 | return WRC_Continue; | ||
| 155861 | } | ||
| 155862 | |||
| 154875 | /* | 155863 | /* |
| 154876 | ** If the SELECT statement passed as the second argument does not invoke | 155864 | ** If the SELECT statement passed as the second argument does not invoke |
| 154877 | ** any SQL window functions, this function is a no-op. Otherwise, it | 155865 | ** any SQL window functions, this function is a no-op. Otherwise, it |
| @@ -154881,7 +155869,7 @@ static int sqlite3WindowExtraAggFuncDepth(Walker *pWalker, Expr *pExpr){ | |||
| 154881 | */ | 155869 | */ |
| 154882 | SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ | 155870 | SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ |
| 154883 | int rc = SQLITE_OK; | 155871 | int rc = SQLITE_OK; |
| 154884 | if( p->pWin && p->pPrior==0 && (p->selFlags & SF_WinRewrite)==0 ){ | 155872 | if( p->pWin && p->pPrior==0 && ALWAYS((p->selFlags & SF_WinRewrite)==0) ){ |
| 154885 | Vdbe *v = sqlite3GetVdbe(pParse); | 155873 | Vdbe *v = sqlite3GetVdbe(pParse); |
| 154886 | sqlite3 *db = pParse->db; | 155874 | sqlite3 *db = pParse->db; |
| 154887 | Select *pSub = 0; /* The subquery */ | 155875 | Select *pSub = 0; /* The subquery */ |
| @@ -154905,6 +155893,11 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ | |||
| 154905 | } | 155893 | } |
| 154906 | sqlite3AggInfoPersistWalkerInit(&w, pParse); | 155894 | sqlite3AggInfoPersistWalkerInit(&w, pParse); |
| 154907 | sqlite3WalkSelect(&w, p); | 155895 | sqlite3WalkSelect(&w, p); |
| 155896 | if( (p->selFlags & SF_Aggregate)==0 ){ | ||
| 155897 | w.xExprCallback = disallowAggregatesInOrderByCb; | ||
| 155898 | w.xSelectCallback = 0; | ||
| 155899 | sqlite3WalkExprList(&w, p->pOrderBy); | ||
| 155900 | } | ||
| 154908 | 155901 | ||
| 154909 | p->pSrc = 0; | 155902 | p->pSrc = 0; |
| 154910 | p->pWhere = 0; | 155903 | p->pWhere = 0; |
| @@ -155501,6 +156494,7 @@ struct WindowCodeArg { | |||
| 155501 | int regGosub; /* Register used with OP_Gosub(addrGosub) */ | 156494 | int regGosub; /* Register used with OP_Gosub(addrGosub) */ |
| 155502 | int regArg; /* First in array of accumulator registers */ | 156495 | int regArg; /* First in array of accumulator registers */ |
| 155503 | int eDelete; /* See above */ | 156496 | int eDelete; /* See above */ |
| 156497 | int regRowid; | ||
| 155504 | 156498 | ||
| 155505 | WindowCsrAndReg start; | 156499 | WindowCsrAndReg start; |
| 155506 | WindowCsrAndReg current; | 156500 | WindowCsrAndReg current; |
| @@ -155617,15 +156611,15 @@ static void windowAggStep( | |||
| 155617 | } | 156611 | } |
| 155618 | 156612 | ||
| 155619 | if( pWin->bExprArgs ){ | 156613 | if( pWin->bExprArgs ){ |
| 155620 | int iStart = sqlite3VdbeCurrentAddr(v); | 156614 | int iOp = sqlite3VdbeCurrentAddr(v); |
| 155621 | VdbeOp *pOp, *pEnd; | 156615 | int iEnd; |
| 155622 | 156616 | ||
| 155623 | nArg = pWin->pOwner->x.pList->nExpr; | 156617 | nArg = pWin->pOwner->x.pList->nExpr; |
| 155624 | regArg = sqlite3GetTempRange(pParse, nArg); | 156618 | regArg = sqlite3GetTempRange(pParse, nArg); |
| 155625 | sqlite3ExprCodeExprList(pParse, pWin->pOwner->x.pList, regArg, 0, 0); | 156619 | sqlite3ExprCodeExprList(pParse, pWin->pOwner->x.pList, regArg, 0, 0); |
| 155626 | 156620 | ||
| 155627 | pEnd = sqlite3VdbeGetOp(v, -1); | 156621 | for(iEnd=sqlite3VdbeCurrentAddr(v); iOp<iEnd; iOp++){ |
| 155628 | for(pOp=sqlite3VdbeGetOp(v, iStart); pOp<=pEnd; pOp++){ | 156622 | VdbeOp *pOp = sqlite3VdbeGetOp(v, iOp); |
| 155629 | if( pOp->opcode==OP_Column && pOp->p1==pWin->iEphCsr ){ | 156623 | if( pOp->opcode==OP_Column && pOp->p1==pWin->iEphCsr ){ |
| 155630 | pOp->p1 = csr; | 156624 | pOp->p1 = csr; |
| 155631 | } | 156625 | } |
| @@ -155984,7 +156978,7 @@ static void windowIfNewPeer( | |||
| 155984 | ** if( csr1.peerVal - regVal <= csr2.peerVal ) goto lbl; | 156978 | ** if( csr1.peerVal - regVal <= csr2.peerVal ) goto lbl; |
| 155985 | ** | 156979 | ** |
| 155986 | ** A special type of arithmetic is used such that if csr1.peerVal is not | 156980 | ** A special type of arithmetic is used such that if csr1.peerVal is not |
| 155987 | ** a numeric type (real or integer), then the result of the addition addition | 156981 | ** a numeric type (real or integer), then the result of the addition |
| 155988 | ** or subtraction is a a copy of csr1.peerVal. | 156982 | ** or subtraction is a a copy of csr1.peerVal. |
| 155989 | */ | 156983 | */ |
| 155990 | static void windowCodeRangeTest( | 156984 | static void windowCodeRangeTest( |
| @@ -156003,8 +156997,13 @@ static void windowCodeRangeTest( | |||
| 156003 | int regString = ++pParse->nMem; /* Reg. for constant value '' */ | 156997 | int regString = ++pParse->nMem; /* Reg. for constant value '' */ |
| 156004 | int arith = OP_Add; /* OP_Add or OP_Subtract */ | 156998 | int arith = OP_Add; /* OP_Add or OP_Subtract */ |
| 156005 | int addrGe; /* Jump destination */ | 156999 | int addrGe; /* Jump destination */ |
| 157000 | int addrDone = sqlite3VdbeMakeLabel(pParse); /* Address past OP_Ge */ | ||
| 156006 | CollSeq *pColl; | 157001 | CollSeq *pColl; |
| 156007 | 157002 | ||
| 157003 | /* Read the peer-value from each cursor into a register */ | ||
| 157004 | windowReadPeerValues(p, csr1, reg1); | ||
| 157005 | windowReadPeerValues(p, csr2, reg2); | ||
| 157006 | |||
| 156008 | assert( op==OP_Ge || op==OP_Gt || op==OP_Le ); | 157007 | assert( op==OP_Ge || op==OP_Gt || op==OP_Le ); |
| 156009 | assert( pOrderBy && pOrderBy->nExpr==1 ); | 157008 | assert( pOrderBy && pOrderBy->nExpr==1 ); |
| 156010 | if( pOrderBy->a[0].sortFlags & KEYINFO_ORDER_DESC ){ | 157009 | if( pOrderBy->a[0].sortFlags & KEYINFO_ORDER_DESC ){ |
| @@ -156016,34 +157015,11 @@ static void windowCodeRangeTest( | |||
| 156016 | arith = OP_Subtract; | 157015 | arith = OP_Subtract; |
| 156017 | } | 157016 | } |
| 156018 | 157017 | ||
| 156019 | /* Read the peer-value from each cursor into a register */ | ||
| 156020 | windowReadPeerValues(p, csr1, reg1); | ||
| 156021 | windowReadPeerValues(p, csr2, reg2); | ||
| 156022 | |||
| 156023 | VdbeModuleComment((v, "CodeRangeTest: if( R%d %s R%d %s R%d ) goto lbl", | 157018 | VdbeModuleComment((v, "CodeRangeTest: if( R%d %s R%d %s R%d ) goto lbl", |
| 156024 | reg1, (arith==OP_Add ? "+" : "-"), regVal, | 157019 | reg1, (arith==OP_Add ? "+" : "-"), regVal, |
| 156025 | ((op==OP_Ge) ? ">=" : (op==OP_Le) ? "<=" : (op==OP_Gt) ? ">" : "<"), reg2 | 157020 | ((op==OP_Ge) ? ">=" : (op==OP_Le) ? "<=" : (op==OP_Gt) ? ">" : "<"), reg2 |
| 156026 | )); | 157021 | )); |
| 156027 | 157022 | ||
| 156028 | /* Register reg1 currently contains csr1.peerVal (the peer-value from csr1). | ||
| 156029 | ** This block adds (or subtracts for DESC) the numeric value in regVal | ||
| 156030 | ** from it. Or, if reg1 is not numeric (it is a NULL, a text value or a blob), | ||
| 156031 | ** then leave reg1 as it is. In pseudo-code, this is implemented as: | ||
| 156032 | ** | ||
| 156033 | ** if( reg1>='' ) goto addrGe; | ||
| 156034 | ** reg1 = reg1 +/- regVal | ||
| 156035 | ** addrGe: | ||
| 156036 | ** | ||
| 156037 | ** Since all strings and blobs are greater-than-or-equal-to an empty string, | ||
| 156038 | ** the add/subtract is skipped for these, as required. If reg1 is a NULL, | ||
| 156039 | ** then the arithmetic is performed, but since adding or subtracting from | ||
| 156040 | ** NULL is always NULL anyway, this case is handled as required too. */ | ||
| 156041 | sqlite3VdbeAddOp4(v, OP_String8, 0, regString, 0, "", P4_STATIC); | ||
| 156042 | addrGe = sqlite3VdbeAddOp3(v, OP_Ge, regString, 0, reg1); | ||
| 156043 | VdbeCoverage(v); | ||
| 156044 | sqlite3VdbeAddOp3(v, arith, regVal, reg1, reg1); | ||
| 156045 | sqlite3VdbeJumpHere(v, addrGe); | ||
| 156046 | |||
| 156047 | /* If the BIGNULL flag is set for the ORDER BY, then it is required to | 157023 | /* If the BIGNULL flag is set for the ORDER BY, then it is required to |
| 156048 | ** consider NULL values to be larger than all other values, instead of | 157024 | ** consider NULL values to be larger than all other values, instead of |
| 156049 | ** the usual smaller. The VDBE opcodes OP_Ge and so on do not handle this | 157025 | ** the usual smaller. The VDBE opcodes OP_Ge and so on do not handle this |
| @@ -156080,16 +157056,38 @@ static void windowCodeRangeTest( | |||
| 156080 | break; | 157056 | break; |
| 156081 | default: assert( op==OP_Lt ); /* no-op */ break; | 157057 | default: assert( op==OP_Lt ); /* no-op */ break; |
| 156082 | } | 157058 | } |
| 156083 | sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+3); | 157059 | sqlite3VdbeAddOp2(v, OP_Goto, 0, addrDone); |
| 156084 | 157060 | ||
| 156085 | /* This block runs if reg1 is not NULL, but reg2 is. */ | 157061 | /* This block runs if reg1 is not NULL, but reg2 is. */ |
| 156086 | sqlite3VdbeJumpHere(v, addr); | 157062 | sqlite3VdbeJumpHere(v, addr); |
| 156087 | sqlite3VdbeAddOp2(v, OP_IsNull, reg2, lbl); VdbeCoverage(v); | 157063 | sqlite3VdbeAddOp2(v, OP_IsNull, reg2, lbl); VdbeCoverage(v); |
| 156088 | if( op==OP_Gt || op==OP_Ge ){ | 157064 | if( op==OP_Gt || op==OP_Ge ){ |
| 156089 | sqlite3VdbeChangeP2(v, -1, sqlite3VdbeCurrentAddr(v)+1); | 157065 | sqlite3VdbeChangeP2(v, -1, addrDone); |
| 156090 | } | 157066 | } |
| 156091 | } | 157067 | } |
| 156092 | 157068 | ||
| 157069 | /* Register reg1 currently contains csr1.peerVal (the peer-value from csr1). | ||
| 157070 | ** This block adds (or subtracts for DESC) the numeric value in regVal | ||
| 157071 | ** from it. Or, if reg1 is not numeric (it is a NULL, a text value or a blob), | ||
| 157072 | ** then leave reg1 as it is. In pseudo-code, this is implemented as: | ||
| 157073 | ** | ||
| 157074 | ** if( reg1>='' ) goto addrGe; | ||
| 157075 | ** reg1 = reg1 +/- regVal | ||
| 157076 | ** addrGe: | ||
| 157077 | ** | ||
| 157078 | ** Since all strings and blobs are greater-than-or-equal-to an empty string, | ||
| 157079 | ** the add/subtract is skipped for these, as required. If reg1 is a NULL, | ||
| 157080 | ** then the arithmetic is performed, but since adding or subtracting from | ||
| 157081 | ** NULL is always NULL anyway, this case is handled as required too. */ | ||
| 157082 | sqlite3VdbeAddOp4(v, OP_String8, 0, regString, 0, "", P4_STATIC); | ||
| 157083 | addrGe = sqlite3VdbeAddOp3(v, OP_Ge, regString, 0, reg1); | ||
| 157084 | VdbeCoverage(v); | ||
| 157085 | if( (op==OP_Ge && arith==OP_Add) || (op==OP_Le && arith==OP_Subtract) ){ | ||
| 157086 | sqlite3VdbeAddOp3(v, op, reg2, lbl, reg1); VdbeCoverage(v); | ||
| 157087 | } | ||
| 157088 | sqlite3VdbeAddOp3(v, arith, regVal, reg1, reg1); | ||
| 157089 | sqlite3VdbeJumpHere(v, addrGe); | ||
| 157090 | |||
| 156093 | /* Compare registers reg2 and reg1, taking the jump if required. Note that | 157091 | /* Compare registers reg2 and reg1, taking the jump if required. Note that |
| 156094 | ** control skips over this test if the BIGNULL flag is set and either | 157092 | ** control skips over this test if the BIGNULL flag is set and either |
| 156095 | ** reg1 or reg2 contain a NULL value. */ | 157093 | ** reg1 or reg2 contain a NULL value. */ |
| @@ -156097,6 +157095,7 @@ static void windowCodeRangeTest( | |||
| 156097 | pColl = sqlite3ExprNNCollSeq(pParse, pOrderBy->a[0].pExpr); | 157095 | pColl = sqlite3ExprNNCollSeq(pParse, pOrderBy->a[0].pExpr); |
| 156098 | sqlite3VdbeAppendP4(v, (void*)pColl, P4_COLLSEQ); | 157096 | sqlite3VdbeAppendP4(v, (void*)pColl, P4_COLLSEQ); |
| 156099 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); | 157097 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); |
| 157098 | sqlite3VdbeResolveLabel(v, addrDone); | ||
| 156100 | 157099 | ||
| 156101 | assert( op==OP_Ge || op==OP_Gt || op==OP_Lt || op==OP_Le ); | 157100 | assert( op==OP_Ge || op==OP_Gt || op==OP_Lt || op==OP_Le ); |
| 156102 | testcase(op==OP_Ge); VdbeCoverageIf(v, op==OP_Ge); | 157101 | testcase(op==OP_Ge); VdbeCoverageIf(v, op==OP_Ge); |
| @@ -156172,16 +157171,24 @@ static int windowCodeOp( | |||
| 156172 | /* If this is a (RANGE BETWEEN a FOLLOWING AND b FOLLOWING) or | 157171 | /* If this is a (RANGE BETWEEN a FOLLOWING AND b FOLLOWING) or |
| 156173 | ** (RANGE BETWEEN b PRECEDING AND a PRECEDING) frame, ensure the | 157172 | ** (RANGE BETWEEN b PRECEDING AND a PRECEDING) frame, ensure the |
| 156174 | ** start cursor does not advance past the end cursor within the | 157173 | ** start cursor does not advance past the end cursor within the |
| 156175 | ** temporary table. It otherwise might, if (a>b). */ | 157174 | ** temporary table. It otherwise might, if (a>b). Also ensure that, |
| 157175 | ** if the input cursor is still finding new rows, that the end | ||
| 157176 | ** cursor does not go past it to EOF. */ | ||
| 156176 | if( pMWin->eStart==pMWin->eEnd && regCountdown | 157177 | if( pMWin->eStart==pMWin->eEnd && regCountdown |
| 156177 | && pMWin->eFrmType==TK_RANGE && op==WINDOW_AGGINVERSE | 157178 | && pMWin->eFrmType==TK_RANGE |
| 156178 | ){ | 157179 | ){ |
| 156179 | int regRowid1 = sqlite3GetTempReg(pParse); | 157180 | int regRowid1 = sqlite3GetTempReg(pParse); |
| 156180 | int regRowid2 = sqlite3GetTempReg(pParse); | 157181 | int regRowid2 = sqlite3GetTempReg(pParse); |
| 156181 | sqlite3VdbeAddOp2(v, OP_Rowid, p->start.csr, regRowid1); | 157182 | if( op==WINDOW_AGGINVERSE ){ |
| 156182 | sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid2); | 157183 | sqlite3VdbeAddOp2(v, OP_Rowid, p->start.csr, regRowid1); |
| 156183 | sqlite3VdbeAddOp3(v, OP_Ge, regRowid2, lblDone, regRowid1); | 157184 | sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid2); |
| 156184 | VdbeCoverage(v); | 157185 | sqlite3VdbeAddOp3(v, OP_Ge, regRowid2, lblDone, regRowid1); |
| 157186 | VdbeCoverage(v); | ||
| 157187 | }else if( p->regRowid ){ | ||
| 157188 | sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid1); | ||
| 157189 | sqlite3VdbeAddOp3(v, OP_Ge, p->regRowid, lblDone, regRowid1); | ||
| 157190 | VdbeCoverageNeverNull(v); | ||
| 157191 | } | ||
| 156185 | sqlite3ReleaseTempReg(pParse, regRowid1); | 157192 | sqlite3ReleaseTempReg(pParse, regRowid1); |
| 156186 | sqlite3ReleaseTempReg(pParse, regRowid2); | 157193 | sqlite3ReleaseTempReg(pParse, regRowid2); |
| 156187 | assert( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING ); | 157194 | assert( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING ); |
| @@ -156678,7 +157685,6 @@ SQLITE_PRIVATE void sqlite3WindowCodeStep( | |||
| 156678 | int addrEmpty; /* Address of OP_Rewind in flush: */ | 157685 | int addrEmpty; /* Address of OP_Rewind in flush: */ |
| 156679 | int regNew; /* Array of registers holding new input row */ | 157686 | int regNew; /* Array of registers holding new input row */ |
| 156680 | int regRecord; /* regNew array in record form */ | 157687 | int regRecord; /* regNew array in record form */ |
| 156681 | int regRowid; /* Rowid for regRecord in eph table */ | ||
| 156682 | int regNewPeer = 0; /* Peer values for new row (part of regNew) */ | 157688 | int regNewPeer = 0; /* Peer values for new row (part of regNew) */ |
| 156683 | int regPeer = 0; /* Peer values for current row */ | 157689 | int regPeer = 0; /* Peer values for current row */ |
| 156684 | int regFlushPart = 0; /* Register for "Gosub flush_partition" */ | 157690 | int regFlushPart = 0; /* Register for "Gosub flush_partition" */ |
| @@ -156750,7 +157756,7 @@ SQLITE_PRIVATE void sqlite3WindowCodeStep( | |||
| 156750 | regNew = pParse->nMem+1; | 157756 | regNew = pParse->nMem+1; |
| 156751 | pParse->nMem += nInput; | 157757 | pParse->nMem += nInput; |
| 156752 | regRecord = ++pParse->nMem; | 157758 | regRecord = ++pParse->nMem; |
| 156753 | regRowid = ++pParse->nMem; | 157759 | s.regRowid = ++pParse->nMem; |
| 156754 | 157760 | ||
| 156755 | /* If the window frame contains an "<expr> PRECEDING" or "<expr> FOLLOWING" | 157761 | /* If the window frame contains an "<expr> PRECEDING" or "<expr> FOLLOWING" |
| 156756 | ** clause, allocate registers to store the results of evaluating each | 157762 | ** clause, allocate registers to store the results of evaluating each |
| @@ -156806,9 +157812,9 @@ SQLITE_PRIVATE void sqlite3WindowCodeStep( | |||
| 156806 | } | 157812 | } |
| 156807 | 157813 | ||
| 156808 | /* Insert the new row into the ephemeral table */ | 157814 | /* Insert the new row into the ephemeral table */ |
| 156809 | sqlite3VdbeAddOp2(v, OP_NewRowid, csrWrite, regRowid); | 157815 | sqlite3VdbeAddOp2(v, OP_NewRowid, csrWrite, s.regRowid); |
| 156810 | sqlite3VdbeAddOp3(v, OP_Insert, csrWrite, regRecord, regRowid); | 157816 | sqlite3VdbeAddOp3(v, OP_Insert, csrWrite, regRecord, s.regRowid); |
| 156811 | addrNe = sqlite3VdbeAddOp3(v, OP_Ne, pMWin->regOne, 0, regRowid); | 157817 | addrNe = sqlite3VdbeAddOp3(v, OP_Ne, pMWin->regOne, 0, s.regRowid); |
| 156812 | VdbeCoverageNeverNull(v); | 157818 | VdbeCoverageNeverNull(v); |
| 156813 | 157819 | ||
| 156814 | /* This block is run for the first row of each partition */ | 157820 | /* This block is run for the first row of each partition */ |
| @@ -156926,6 +157932,7 @@ SQLITE_PRIVATE void sqlite3WindowCodeStep( | |||
| 156926 | sqlite3VdbeJumpHere(v, addrGosubFlush); | 157932 | sqlite3VdbeJumpHere(v, addrGosubFlush); |
| 156927 | } | 157933 | } |
| 156928 | 157934 | ||
| 157935 | s.regRowid = 0; | ||
| 156929 | addrEmpty = sqlite3VdbeAddOp1(v, OP_Rewind, csrWrite); | 157936 | addrEmpty = sqlite3VdbeAddOp1(v, OP_Rewind, csrWrite); |
| 156930 | VdbeCoverage(v); | 157937 | VdbeCoverage(v); |
| 156931 | if( pMWin->eEnd==TK_PRECEDING ){ | 157938 | if( pMWin->eEnd==TK_PRECEDING ){ |
| @@ -157399,8 +158406,9 @@ static void updateDeleteLimitError( | |||
| 157399 | #define TK_IF_NULL_ROW 178 | 158406 | #define TK_IF_NULL_ROW 178 |
| 157400 | #define TK_ASTERISK 179 | 158407 | #define TK_ASTERISK 179 |
| 157401 | #define TK_SPAN 180 | 158408 | #define TK_SPAN 180 |
| 157402 | #define TK_SPACE 181 | 158409 | #define TK_ERROR 181 |
| 157403 | #define TK_ILLEGAL 182 | 158410 | #define TK_SPACE 182 |
| 158411 | #define TK_ILLEGAL 183 | ||
| 157404 | #endif | 158412 | #endif |
| 157405 | /**************** End token definitions ***************************************/ | 158413 | /**************** End token definitions ***************************************/ |
| 157406 | 158414 | ||
| @@ -157460,29 +158468,29 @@ static void updateDeleteLimitError( | |||
| 157460 | #endif | 158468 | #endif |
| 157461 | /************* Begin control #defines *****************************************/ | 158469 | /************* Begin control #defines *****************************************/ |
| 157462 | #define YYCODETYPE unsigned short int | 158470 | #define YYCODETYPE unsigned short int |
| 157463 | #define YYNOCODE 316 | 158471 | #define YYNOCODE 317 |
| 157464 | #define YYACTIONTYPE unsigned short int | 158472 | #define YYACTIONTYPE unsigned short int |
| 157465 | #define YYWILDCARD 101 | 158473 | #define YYWILDCARD 101 |
| 157466 | #define sqlite3ParserTOKENTYPE Token | 158474 | #define sqlite3ParserTOKENTYPE Token |
| 157467 | typedef union { | 158475 | typedef union { |
| 157468 | int yyinit; | 158476 | int yyinit; |
| 157469 | sqlite3ParserTOKENTYPE yy0; | 158477 | sqlite3ParserTOKENTYPE yy0; |
| 157470 | Window* yy19; | 158478 | Window* yy49; |
| 157471 | struct TrigEvent yy50; | 158479 | ExprList* yy70; |
| 157472 | int yy60; | 158480 | Select* yy81; |
| 157473 | struct FrameBound yy113; | 158481 | With* yy103; |
| 157474 | Upsert* yy178; | 158482 | struct FrameBound yy117; |
| 157475 | With* yy195; | 158483 | struct {int value; int mask;} yy139; |
| 157476 | IdList* yy288; | 158484 | SrcList* yy153; |
| 157477 | SrcList* yy291; | 158485 | TriggerStep* yy157; |
| 157478 | Select* yy307; | 158486 | Upsert* yy190; |
| 157479 | ExprList* yy338; | 158487 | struct TrigEvent yy262; |
| 157480 | TriggerStep* yy483; | 158488 | Cte* yy329; |
| 157481 | const char* yy528; | 158489 | int yy376; |
| 157482 | u8 yy570; | 158490 | Expr* yy404; |
| 157483 | Expr* yy602; | 158491 | IdList* yy436; |
| 157484 | Cte* yy607; | 158492 | const char* yy504; |
| 157485 | struct {int value; int mask;} yy615; | 158493 | u8 yy552; |
| 157486 | } YYMINORTYPE; | 158494 | } YYMINORTYPE; |
| 157487 | #ifndef YYSTACKDEPTH | 158495 | #ifndef YYSTACKDEPTH |
| 157488 | #define YYSTACKDEPTH 100 | 158496 | #define YYSTACKDEPTH 100 |
| @@ -157501,7 +158509,7 @@ typedef union { | |||
| 157501 | #define YYNSTATE 570 | 158509 | #define YYNSTATE 570 |
| 157502 | #define YYNRULE 398 | 158510 | #define YYNRULE 398 |
| 157503 | #define YYNRULE_WITH_ACTION 337 | 158511 | #define YYNRULE_WITH_ACTION 337 |
| 157504 | #define YYNTOKEN 183 | 158512 | #define YYNTOKEN 184 |
| 157505 | #define YY_MAX_SHIFT 569 | 158513 | #define YY_MAX_SHIFT 569 |
| 157506 | #define YY_MIN_SHIFTREDUCE 825 | 158514 | #define YY_MIN_SHIFTREDUCE 825 |
| 157507 | #define YY_MAX_SHIFTREDUCE 1222 | 158515 | #define YY_MAX_SHIFTREDUCE 1222 |
| @@ -157576,443 +158584,444 @@ typedef union { | |||
| 157576 | ** yy_default[] Default action for each state. | 158584 | ** yy_default[] Default action for each state. |
| 157577 | ** | 158585 | ** |
| 157578 | *********** Begin parsing tables **********************************************/ | 158586 | *********** Begin parsing tables **********************************************/ |
| 157579 | #define YY_ACTTAB_COUNT (2020) | 158587 | #define YY_ACTTAB_COUNT (2023) |
| 157580 | static const YYACTIONTYPE yy_action[] = { | 158588 | static const YYACTIONTYPE yy_action[] = { |
| 157581 | /* 0 */ 563, 1295, 563, 1274, 168, 361, 115, 112, 218, 373, | 158589 | /* 0 */ 563, 1295, 563, 1274, 168, 1257, 115, 112, 218, 373, |
| 157582 | /* 10 */ 563, 1295, 374, 563, 488, 563, 115, 112, 218, 406, | 158590 | /* 10 */ 563, 1295, 374, 563, 488, 563, 115, 112, 218, 406, |
| 157583 | /* 20 */ 1300, 1300, 41, 41, 41, 41, 514, 1504, 520, 1298, | 158591 | /* 20 */ 1300, 1300, 41, 41, 41, 41, 514, 1504, 520, 1298, |
| 157584 | /* 30 */ 1298, 959, 41, 41, 1257, 71, 71, 51, 51, 960, | 158592 | /* 30 */ 1298, 959, 41, 41, 1260, 71, 71, 51, 51, 960, |
| 157585 | /* 40 */ 557, 557, 557, 122, 123, 113, 1200, 1200, 1035, 1038, | 158593 | /* 40 */ 557, 557, 557, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 157586 | /* 50 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 414, 406, | 158594 | /* 50 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 414, 406, |
| 157587 | /* 60 */ 273, 273, 273, 273, 115, 112, 218, 115, 112, 218, | 158595 | /* 60 */ 273, 273, 273, 273, 115, 112, 218, 115, 112, 218, |
| 157588 | /* 70 */ 197, 268, 545, 560, 515, 560, 1260, 563, 385, 248, | 158596 | /* 70 */ 197, 268, 545, 560, 515, 560, 211, 563, 385, 248, |
| 157589 | /* 80 */ 215, 521, 399, 122, 123, 113, 1200, 1200, 1035, 1038, | 158597 | /* 80 */ 215, 521, 399, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 157590 | /* 90 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 540, 13, | 158598 | /* 90 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 540, 13, |
| 157591 | /* 100 */ 13, 1259, 119, 119, 119, 119, 118, 118, 117, 117, | 158599 | /* 100 */ 13, 1259, 119, 119, 119, 119, 118, 118, 117, 117, |
| 157592 | /* 110 */ 117, 116, 441, 1176, 419, 1531, 446, 137, 512, 1539, | 158600 | /* 110 */ 117, 116, 441, 1176, 419, 197, 446, 320, 512, 1539, |
| 157593 | /* 120 */ 1545, 372, 1547, 6, 371, 1176, 1148, 1584, 1148, 406, | 158601 | /* 120 */ 1545, 372, 1547, 6, 371, 1176, 1148, 394, 1148, 406, |
| 157594 | /* 130 */ 1545, 534, 115, 112, 218, 1267, 99, 441, 121, 121, | 158602 | /* 130 */ 1545, 534, 115, 112, 218, 1415, 99, 30, 121, 121, |
| 157595 | /* 140 */ 121, 121, 119, 119, 119, 119, 118, 118, 117, 117, | 158603 | /* 140 */ 121, 121, 119, 119, 119, 119, 118, 118, 117, 117, |
| 157596 | /* 150 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, | 158604 | /* 150 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 157597 | /* 160 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 197, 1176, | 158605 | /* 160 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 31, 1176, |
| 157598 | /* 170 */ 1177, 1178, 241, 304, 554, 501, 498, 497, 473, 124, | 158606 | /* 170 */ 1177, 1178, 241, 357, 1558, 501, 498, 497, 317, 124, |
| 157599 | /* 180 */ 394, 1176, 1177, 1178, 1176, 496, 119, 119, 119, 119, | 158607 | /* 180 */ 319, 1176, 1177, 1178, 1176, 496, 119, 119, 119, 119, |
| 157600 | /* 190 */ 118, 118, 117, 117, 117, 116, 441, 139, 540, 406, | 158608 | /* 190 */ 118, 118, 117, 117, 117, 116, 441, 139, 96, 406, |
| 157601 | /* 200 */ 121, 121, 121, 121, 114, 117, 117, 117, 116, 441, | 158609 | /* 200 */ 121, 121, 121, 121, 114, 117, 117, 117, 116, 441, |
| 157602 | /* 210 */ 541, 1532, 119, 119, 119, 119, 118, 118, 117, 117, | 158610 | /* 210 */ 541, 1532, 119, 119, 119, 119, 118, 118, 117, 117, |
| 157603 | /* 220 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, | 158611 | /* 220 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 157604 | /* 230 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 406, 320, | 158612 | /* 230 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 406, 441, |
| 157605 | /* 240 */ 1176, 1177, 1178, 81, 342, 1590, 396, 80, 119, 119, | 158613 | /* 240 */ 1176, 1177, 1178, 81, 439, 439, 439, 80, 119, 119, |
| 157606 | /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 1176, | 158614 | /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 488, |
| 157607 | /* 260 */ 211, 450, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, | 158615 | /* 260 */ 1176, 318, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 157608 | /* 270 */ 1028, 120, 120, 121, 121, 121, 121, 251, 450, 449, | 158616 | /* 270 */ 1028, 120, 120, 121, 121, 121, 121, 493, 1025, 1025, |
| 157609 | /* 280 */ 273, 273, 119, 119, 119, 119, 118, 118, 117, 117, | 158617 | /* 280 */ 1036, 1039, 119, 119, 119, 119, 118, 118, 117, 117, |
| 157610 | /* 290 */ 117, 116, 441, 560, 1224, 1, 1, 569, 2, 1228, | 158618 | /* 290 */ 117, 116, 441, 1584, 995, 1224, 1, 1, 569, 2, |
| 157611 | /* 300 */ 317, 1176, 319, 1561, 305, 337, 140, 340, 406, 430, | 158619 | /* 300 */ 1228, 1267, 137, 1503, 245, 305, 473, 140, 406, 860, |
| 157612 | /* 310 */ 469, 1533, 1197, 1308, 348, 1176, 1177, 1178, 168, 462, | 158620 | /* 310 */ 561, 1176, 914, 914, 1308, 359, 1176, 1177, 1178, 462, |
| 157613 | /* 320 */ 330, 119, 119, 119, 119, 118, 118, 117, 117, 117, | 158621 | /* 320 */ 330, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 157614 | /* 330 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, | 158622 | /* 330 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 157615 | /* 340 */ 1028, 120, 120, 121, 121, 121, 121, 273, 273, 563, | 158623 | /* 340 */ 1028, 120, 120, 121, 121, 121, 121, 328, 273, 273, |
| 157616 | /* 350 */ 83, 450, 416, 1564, 569, 2, 1228, 1176, 1177, 1178, | 158624 | /* 350 */ 1015, 83, 1029, 425, 1564, 569, 2, 1228, 304, 554, |
| 157617 | /* 360 */ 560, 305, 471, 140, 944, 995, 860, 563, 467, 1197, | 158625 | /* 360 */ 925, 560, 305, 944, 140, 860, 1006, 1176, 1177, 1178, |
| 157618 | /* 370 */ 1308, 13, 13, 137, 229, 118, 118, 117, 117, 117, | 158626 | /* 370 */ 1005, 1308, 411, 213, 511, 229, 119, 119, 119, 119, |
| 157619 | /* 380 */ 116, 441, 96, 318, 946, 504, 424, 361, 562, 71, | 158627 | /* 380 */ 118, 118, 117, 117, 117, 116, 441, 519, 347, 116, |
| 157620 | /* 390 */ 71, 119, 119, 119, 119, 118, 118, 117, 117, 117, | 158628 | /* 390 */ 441, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 157621 | /* 400 */ 116, 441, 427, 205, 273, 273, 445, 1015, 259, 276, | 158629 | /* 400 */ 116, 441, 1005, 1005, 1007, 273, 273, 445, 563, 16, |
| 157622 | /* 410 */ 356, 507, 351, 506, 246, 406, 959, 560, 328, 344, | 158630 | /* 410 */ 16, 1590, 563, 1540, 563, 406, 1176, 6, 560, 344, |
| 157623 | /* 420 */ 347, 315, 860, 1006, 960, 126, 545, 1005, 313, 304, | 158631 | /* 420 */ 182, 118, 118, 117, 117, 117, 116, 441, 416, 142, |
| 157624 | /* 430 */ 554, 229, 538, 1539, 148, 544, 281, 6, 203, 122, | 158632 | /* 430 */ 71, 71, 229, 563, 71, 71, 55, 55, 203, 122, |
| 157625 | /* 440 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, | 158633 | /* 440 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, |
| 157626 | /* 450 */ 121, 121, 121, 121, 563, 217, 563, 12, 406, 1005, | 158634 | /* 450 */ 121, 121, 121, 121, 217, 13, 13, 1176, 406, 568, |
| 157627 | /* 460 */ 1005, 1007, 502, 445, 119, 119, 119, 119, 118, 118, | 158635 | /* 460 */ 1400, 1228, 502, 137, 445, 168, 305, 545, 140, 1180, |
| 157628 | /* 470 */ 117, 117, 117, 116, 441, 452, 71, 71, 70, 70, | 158636 | /* 470 */ 424, 545, 1176, 1177, 1178, 1308, 544, 438, 437, 944, |
| 157629 | /* 480 */ 944, 137, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, | 158637 | /* 480 */ 513, 452, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 157630 | /* 490 */ 1028, 120, 120, 121, 121, 121, 121, 1530, 119, 119, | 158638 | /* 490 */ 1028, 120, 120, 121, 121, 121, 121, 315, 119, 119, |
| 157631 | /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 403, | 158639 | /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 273, |
| 157632 | /* 510 */ 402, 241, 1176, 545, 501, 498, 497, 1468, 1143, 451, | 158640 | /* 510 */ 273, 1143, 416, 1176, 1177, 1178, 543, 563, 1143, 304, |
| 157633 | /* 520 */ 267, 267, 513, 1540, 496, 142, 1176, 6, 406, 530, | 158641 | /* 520 */ 554, 1561, 560, 1207, 1143, 1207, 1180, 1143, 406, 530, |
| 157634 | /* 530 */ 194, 1143, 864, 560, 1143, 461, 182, 304, 554, 32, | 158642 | /* 530 */ 421, 1143, 864, 183, 1143, 143, 229, 562, 32, 71, |
| 157635 | /* 540 */ 379, 119, 119, 119, 119, 118, 118, 117, 117, 117, | 158643 | /* 540 */ 71, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 157636 | /* 550 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, | 158644 | /* 550 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 157637 | /* 560 */ 1028, 120, 120, 121, 121, 121, 121, 406, 1176, 1177, | 158645 | /* 560 */ 1028, 120, 120, 121, 121, 121, 121, 406, 445, 241, |
| 157638 | /* 570 */ 1178, 857, 568, 1176, 1228, 925, 1176, 454, 361, 305, | 158646 | /* 570 */ 1176, 857, 501, 498, 497, 1176, 526, 189, 245, 538, |
| 157639 | /* 580 */ 189, 140, 1176, 1177, 1178, 519, 529, 404, 1308, 183, | 158647 | /* 580 */ 1539, 282, 496, 370, 6, 563, 529, 477, 5, 279, |
| 157640 | /* 590 */ 1015, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, | 158648 | /* 590 */ 1015, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, |
| 157641 | /* 600 */ 120, 120, 121, 121, 121, 121, 1006, 16, 16, 370, | 158649 | /* 600 */ 120, 120, 121, 121, 121, 121, 1006, 13, 13, 1414, |
| 157642 | /* 610 */ 1005, 119, 119, 119, 119, 118, 118, 117, 117, 117, | 158650 | /* 610 */ 1005, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 157643 | /* 620 */ 116, 441, 273, 273, 1537, 150, 1176, 98, 6, 1176, | 158651 | /* 620 */ 116, 441, 426, 273, 273, 1176, 1176, 1177, 1178, 1619, |
| 157644 | /* 630 */ 1177, 1178, 1176, 1177, 1178, 560, 380, 406, 376, 438, | 158652 | /* 630 */ 392, 1176, 1177, 1178, 1176, 342, 560, 406, 525, 361, |
| 157645 | /* 640 */ 437, 1161, 1005, 1005, 1007, 1025, 1025, 1036, 1039, 229, | 158653 | /* 640 */ 430, 1161, 1005, 1005, 1007, 348, 411, 357, 1558, 488, |
| 157646 | /* 650 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, | 158654 | /* 650 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 157647 | /* 660 */ 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, | 158655 | /* 660 */ 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, |
| 157648 | /* 670 */ 120, 120, 121, 121, 121, 121, 406, 1143, 1619, 392, | 158656 | /* 670 */ 120, 120, 121, 121, 121, 121, 406, 830, 831, 832, |
| 157649 | /* 680 */ 1016, 445, 1176, 1177, 1178, 1207, 525, 1207, 1530, 995, | 158657 | /* 680 */ 1016, 1176, 1177, 1178, 396, 285, 148, 1312, 304, 554, |
| 157650 | /* 690 */ 1143, 304, 554, 1143, 5, 563, 543, 3, 361, 216, | 158658 | /* 690 */ 1176, 1177, 1178, 1467, 216, 3, 337, 137, 340, 560, |
| 157651 | /* 700 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, | 158659 | /* 700 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, |
| 157652 | /* 710 */ 120, 121, 121, 121, 121, 143, 563, 13, 13, 1029, | 158660 | /* 710 */ 120, 121, 121, 121, 121, 563, 504, 946, 273, 273, |
| 157653 | /* 720 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, | 158661 | /* 720 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 157654 | /* 730 */ 441, 1176, 426, 563, 1176, 563, 274, 274, 13, 13, | 158662 | /* 730 */ 441, 560, 1176, 427, 563, 451, 98, 13, 13, 259, |
| 157655 | /* 740 */ 1078, 1176, 328, 457, 316, 147, 406, 211, 361, 560, | 158663 | /* 740 */ 276, 356, 507, 351, 506, 246, 406, 361, 469, 1530, |
| 157656 | /* 750 */ 1000, 213, 511, 293, 477, 55, 55, 71, 71, 119, | 158664 | /* 750 */ 1000, 347, 293, 304, 554, 1589, 71, 71, 889, 119, |
| 157657 | /* 760 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441, | 158665 | /* 760 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441, |
| 157658 | /* 770 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, | 158666 | /* 770 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, |
| 157659 | /* 780 */ 120, 121, 121, 121, 121, 406, 455, 1176, 1177, 1178, | 158667 | /* 780 */ 120, 121, 121, 121, 121, 406, 1143, 1078, 1176, 1177, |
| 157660 | /* 790 */ 1176, 1177, 1178, 471, 526, 149, 404, 1176, 1177, 1178, | 158668 | /* 790 */ 1178, 416, 1080, 300, 150, 995, 1080, 361, 361, 1143, |
| 157661 | /* 800 */ 105, 270, 103, 563, 944, 563, 116, 441, 1530, 122, | 158669 | /* 800 */ 361, 378, 1143, 477, 563, 244, 243, 242, 1278, 122, |
| 157662 | /* 810 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, | 158670 | /* 810 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, |
| 157663 | /* 820 */ 121, 121, 121, 121, 945, 13, 13, 13, 13, 119, | 158671 | /* 820 */ 121, 121, 121, 121, 563, 880, 13, 13, 483, 119, |
| 157664 | /* 830 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441, | 158672 | /* 830 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441, |
| 157665 | /* 840 */ 191, 563, 192, 563, 416, 439, 439, 439, 1083, 1083, | 158673 | /* 840 */ 1176, 191, 540, 563, 147, 149, 13, 13, 328, 457, |
| 157666 | /* 850 */ 485, 561, 285, 914, 914, 406, 462, 330, 1530, 830, | 158674 | /* 850 */ 316, 1083, 1083, 485, 1537, 406, 505, 1530, 6, 1514, |
| 157667 | /* 860 */ 831, 832, 206, 71, 71, 71, 71, 286, 119, 119, | 158675 | /* 860 */ 284, 192, 1277, 145, 881, 71, 71, 488, 119, 119, |
| 157668 | /* 870 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 122, | 158676 | /* 870 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 122, |
| 157669 | /* 880 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, | 158677 | /* 880 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, |
| 157670 | /* 890 */ 121, 121, 121, 121, 563, 217, 563, 1122, 1617, 406, | 158678 | /* 890 */ 121, 121, 121, 121, 563, 471, 1176, 1177, 1178, 406, |
| 157671 | /* 900 */ 300, 1617, 301, 416, 1278, 1473, 244, 243, 242, 1249, | 158679 | /* 900 */ 852, 327, 301, 462, 330, 1516, 270, 1530, 1530, 944, |
| 157672 | /* 910 */ 412, 556, 412, 282, 842, 279, 71, 71, 71, 71, | 158680 | /* 910 */ 1531, 1307, 313, 9, 842, 251, 71, 71, 477, 428, |
| 157673 | /* 920 */ 944, 1415, 1473, 1475, 101, 113, 1200, 1200, 1035, 1038, | 158681 | /* 920 */ 146, 488, 38, 945, 101, 113, 1200, 1200, 1035, 1038, |
| 157674 | /* 930 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 119, 119, | 158682 | /* 930 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 119, 119, |
| 157675 | /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 273, | 158683 | /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 563, |
| 157676 | /* 950 */ 273, 1099, 563, 436, 1143, 440, 563, 1122, 1618, 357, | 158684 | /* 950 */ 1197, 1099, 563, 436, 563, 1533, 563, 852, 1122, 1617, |
| 157677 | /* 960 */ 1558, 1618, 560, 546, 488, 197, 1100, 1143, 378, 290, | 158685 | /* 960 */ 454, 290, 1617, 546, 251, 1303, 1100, 267, 267, 281, |
| 157678 | /* 970 */ 1143, 1306, 284, 460, 71, 71, 1120, 405, 13, 13, | 158686 | /* 970 */ 404, 70, 70, 460, 71, 71, 71, 71, 13, 13, |
| 157679 | /* 980 */ 145, 1101, 119, 119, 119, 119, 118, 118, 117, 117, | 158687 | /* 980 */ 560, 1101, 119, 119, 119, 119, 118, 118, 117, 117, |
| 157680 | /* 990 */ 117, 116, 441, 542, 104, 1473, 509, 273, 273, 294, | 158688 | /* 990 */ 117, 116, 441, 542, 104, 273, 273, 273, 273, 1197, |
| 157681 | /* 1000 */ 1514, 294, 900, 273, 273, 273, 273, 563, 1503, 563, | 158689 | /* 1000 */ 217, 1468, 900, 471, 450, 563, 1473, 1197, 560, 447, |
| 157682 | /* 1010 */ 560, 545, 901, 464, 406, 1058, 560, 852, 560, 198, | 158690 | /* 1010 */ 560, 545, 901, 440, 406, 1058, 292, 274, 274, 198, |
| 157683 | /* 1020 */ 547, 1080, 920, 404, 1400, 1080, 146, 919, 38, 56, | 158691 | /* 1020 */ 547, 450, 449, 1473, 1475, 944, 455, 56, 56, 410, |
| 157684 | /* 1030 */ 56, 15, 15, 563, 406, 12, 1120, 471, 122, 123, | 158692 | /* 1030 */ 560, 1122, 1618, 379, 406, 1618, 404, 1120, 122, 123, |
| 157685 | /* 1040 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, | 158693 | /* 1040 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, |
| 157686 | /* 1050 */ 121, 121, 121, 1460, 406, 43, 43, 483, 122, 123, | 158694 | /* 1050 */ 121, 121, 121, 1460, 406, 12, 1197, 1512, 122, 123, |
| 157687 | /* 1060 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, | 158695 | /* 1060 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, |
| 157688 | /* 1070 */ 121, 121, 121, 563, 852, 9, 471, 251, 122, 111, | 158696 | /* 1070 */ 121, 121, 121, 308, 471, 126, 359, 286, 122, 111, |
| 157689 | /* 1080 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, | 158697 | /* 1080 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, |
| 157690 | /* 1090 */ 121, 121, 121, 563, 421, 57, 57, 119, 119, 119, | 158698 | /* 1090 */ 121, 121, 121, 309, 450, 471, 1473, 119, 119, 119, |
| 157691 | /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 441, 1176, 493, | 158699 | /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 441, 1176, 563, |
| 157692 | /* 1110 */ 563, 289, 1197, 478, 1516, 44, 44, 119, 119, 119, | 158700 | /* 1110 */ 1120, 482, 563, 312, 433, 479, 197, 119, 119, 119, |
| 157693 | /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 441, 880, 563, | 158701 | /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 441, 405, 12, |
| 157694 | /* 1130 */ 536, 563, 58, 58, 488, 1414, 245, 119, 119, 119, | 158702 | /* 1130 */ 536, 15, 15, 478, 43, 43, 509, 119, 119, 119, |
| 157695 | /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 441, 563, 535, | 158703 | /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 441, 289, 535, |
| 157696 | /* 1150 */ 291, 59, 59, 60, 60, 438, 437, 406, 1154, 505, | 158704 | /* 1150 */ 294, 563, 294, 391, 1220, 438, 437, 406, 1154, 403, |
| 157697 | /* 1160 */ 304, 554, 477, 1204, 1176, 1177, 1178, 881, 1206, 1197, | 158705 | /* 1160 */ 402, 1400, 920, 1204, 1176, 1177, 1178, 919, 1206, 291, |
| 157698 | /* 1170 */ 61, 61, 1246, 357, 1558, 1538, 1205, 563, 1467, 6, | 158706 | /* 1170 */ 1306, 1249, 412, 57, 57, 488, 1205, 563, 556, 412, |
| 157699 | /* 1180 */ 1176, 488, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, | 158707 | /* 1180 */ 1176, 1344, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, |
| 157700 | /* 1190 */ 120, 120, 121, 121, 121, 121, 1400, 1143, 410, 62, | 158708 | /* 1190 */ 120, 120, 121, 121, 121, 121, 1400, 1143, 563, 44, |
| 157701 | /* 1200 */ 62, 1207, 1099, 1207, 411, 447, 273, 273, 537, 1154, | 158709 | /* 1200 */ 44, 1207, 194, 1207, 273, 273, 1400, 461, 537, 1154, |
| 157702 | /* 1210 */ 1143, 108, 555, 1143, 4, 391, 1220, 1100, 1512, 560, | 158710 | /* 1210 */ 1143, 108, 555, 1143, 4, 391, 1121, 560, 1538, 335, |
| 157703 | /* 1220 */ 347, 516, 428, 548, 308, 1307, 1536, 1077, 558, 1077, | 158711 | /* 1220 */ 58, 58, 6, 1246, 1099, 380, 1400, 376, 558, 1536, |
| 157704 | /* 1230 */ 6, 488, 1101, 1400, 488, 309, 1176, 1177, 1178, 563, | 158712 | /* 1230 */ 563, 422, 1221, 6, 304, 554, 1176, 1177, 1178, 1100, |
| 157705 | /* 1240 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, | 158713 | /* 1240 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 157706 | /* 1250 */ 441, 442, 278, 551, 563, 273, 273, 273, 273, 563, | 158714 | /* 1250 */ 441, 442, 59, 59, 1101, 516, 1535, 273, 273, 563, |
| 157707 | /* 1260 */ 327, 45, 45, 552, 563, 528, 422, 563, 560, 1400, | 158715 | /* 1260 */ 6, 563, 110, 552, 563, 528, 423, 413, 169, 548, |
| 157708 | /* 1270 */ 560, 108, 555, 137, 4, 1303, 46, 46, 335, 563, | 158716 | /* 1270 */ 560, 108, 555, 137, 4, 551, 484, 272, 215, 222, |
| 157709 | /* 1280 */ 482, 47, 47, 477, 479, 307, 49, 49, 558, 50, | 158717 | /* 1280 */ 211, 60, 60, 61, 61, 98, 62, 62, 558, 273, |
| 157710 | /* 1290 */ 50, 563, 1015, 563, 1221, 563, 1400, 563, 106, 106, | 158718 | /* 1290 */ 273, 563, 1015, 467, 1221, 563, 434, 563, 106, 106, |
| 157711 | /* 1300 */ 8, 63, 63, 423, 563, 107, 312, 442, 565, 564, | 158719 | /* 1300 */ 8, 920, 560, 273, 273, 107, 919, 442, 565, 564, |
| 157712 | /* 1310 */ 563, 442, 1005, 64, 64, 65, 65, 14, 14, 66, | 158720 | /* 1310 */ 563, 442, 1005, 45, 45, 464, 560, 46, 46, 47, |
| 157713 | /* 1320 */ 66, 391, 1121, 552, 1312, 1180, 128, 128, 563, 304, | 158721 | /* 1320 */ 47, 84, 202, 552, 1215, 404, 468, 563, 205, 304, |
| 157714 | /* 1330 */ 554, 563, 67, 67, 563, 359, 560, 532, 563, 484, | 158722 | /* 1330 */ 554, 563, 49, 49, 563, 522, 404, 532, 563, 867, |
| 157715 | /* 1340 */ 563, 1196, 531, 222, 1005, 1005, 1007, 1008, 27, 522, | 158723 | /* 1340 */ 563, 105, 531, 103, 1005, 1005, 1007, 1008, 27, 50, |
| 157716 | /* 1350 */ 52, 52, 1015, 68, 68, 563, 69, 69, 106, 106, | 158724 | /* 1350 */ 50, 563, 1015, 63, 63, 475, 64, 64, 106, 106, |
| 157717 | /* 1360 */ 53, 53, 156, 156, 563, 107, 434, 442, 565, 564, | 158725 | /* 1360 */ 65, 65, 14, 14, 17, 107, 563, 442, 565, 564, |
| 157718 | /* 1370 */ 272, 215, 1005, 425, 563, 359, 563, 157, 157, 563, | 158726 | /* 1370 */ 563, 303, 1005, 66, 66, 563, 226, 563, 959, 563, |
| 157719 | /* 1380 */ 1535, 292, 1180, 98, 6, 1344, 76, 76, 1215, 475, | 158727 | /* 1380 */ 543, 404, 1196, 1343, 871, 278, 960, 456, 128, 128, |
| 157720 | /* 1390 */ 413, 169, 226, 563, 245, 563, 54, 54, 72, 72, | 158728 | /* 1390 */ 563, 1065, 67, 67, 563, 206, 867, 52, 52, 68, |
| 157721 | /* 1400 */ 1221, 129, 129, 1343, 1005, 1005, 1007, 1008, 27, 1563, | 158729 | /* 1400 */ 68, 69, 69, 417, 1005, 1005, 1007, 1008, 27, 1563, |
| 157722 | /* 1410 */ 1165, 444, 456, 433, 277, 73, 73, 130, 130, 389, | 158730 | /* 1410 */ 1165, 444, 53, 53, 277, 1519, 156, 156, 307, 389, |
| 157723 | /* 1420 */ 389, 388, 262, 386, 1165, 444, 839, 1519, 277, 108, | 158731 | /* 1420 */ 389, 388, 262, 386, 1165, 444, 839, 321, 277, 108, |
| 157724 | /* 1430 */ 555, 321, 4, 389, 389, 388, 262, 386, 563, 223, | 158732 | /* 1430 */ 555, 523, 4, 389, 389, 388, 262, 386, 563, 223, |
| 157725 | /* 1440 */ 839, 311, 468, 84, 202, 523, 558, 1492, 303, 310, | 158733 | /* 1440 */ 839, 311, 326, 1492, 1117, 98, 558, 393, 1065, 310, |
| 157726 | /* 1450 */ 563, 110, 404, 223, 563, 311, 206, 30, 404, 277, | 158734 | /* 1450 */ 563, 476, 563, 223, 563, 311, 879, 878, 1009, 277, |
| 157727 | /* 1460 */ 131, 131, 411, 310, 389, 389, 388, 262, 386, 442, | 158735 | /* 1460 */ 157, 157, 463, 310, 389, 389, 388, 262, 386, 442, |
| 157728 | /* 1470 */ 920, 839, 127, 127, 563, 919, 155, 155, 1491, 225, | 158736 | /* 1470 */ 518, 839, 76, 76, 54, 54, 72, 72, 355, 225, |
| 157729 | /* 1480 */ 563, 552, 871, 563, 223, 476, 311, 161, 31, 563, | 158737 | /* 1480 */ 563, 552, 275, 563, 223, 325, 311, 161, 354, 465, |
| 157730 | /* 1490 */ 135, 563, 480, 225, 310, 532, 154, 154, 332, 17, | 158738 | /* 1490 */ 135, 563, 228, 225, 310, 532, 563, 206, 886, 887, |
| 157731 | /* 1500 */ 533, 161, 136, 136, 135, 134, 134, 224, 228, 355, | 158739 | /* 1500 */ 533, 161, 129, 129, 135, 73, 73, 224, 962, 963, |
| 157732 | /* 1510 */ 1015, 132, 132, 133, 133, 1589, 106, 106, 889, 354, | 158740 | /* 1510 */ 1015, 563, 287, 130, 130, 1009, 106, 106, 131, 131, |
| 157733 | /* 1520 */ 563, 224, 563, 107, 225, 442, 565, 564, 1117, 275, | 158741 | /* 1520 */ 563, 224, 563, 107, 225, 442, 565, 564, 997, 1276, |
| 157734 | /* 1530 */ 1005, 393, 161, 518, 563, 135, 108, 555, 417, 4, | 158742 | /* 1530 */ 1005, 250, 161, 127, 127, 135, 108, 555, 1077, 4, |
| 157735 | /* 1540 */ 1340, 407, 75, 75, 77, 77, 304, 554, 867, 563, | 158743 | /* 1540 */ 1077, 407, 155, 155, 154, 154, 304, 554, 1126, 563, |
| 157736 | /* 1550 */ 336, 563, 224, 558, 463, 407, 74, 74, 465, 1065, | 158744 | /* 1550 */ 1331, 563, 224, 558, 470, 407, 563, 250, 563, 1491, |
| 157737 | /* 1560 */ 304, 554, 1005, 1005, 1007, 1008, 27, 962, 963, 543, | 158745 | /* 1560 */ 304, 554, 1005, 1005, 1007, 1008, 27, 563, 480, 332, |
| 157738 | /* 1570 */ 448, 42, 42, 48, 48, 326, 442, 325, 98, 997, | 158746 | /* 1570 */ 448, 136, 136, 134, 134, 1340, 442, 336, 132, 132, |
| 157739 | /* 1580 */ 470, 287, 250, 250, 448, 1009, 407, 472, 552, 339, | 158747 | /* 1580 */ 133, 133, 563, 1076, 448, 1076, 407, 563, 552, 75, |
| 157740 | /* 1590 */ 250, 304, 554, 879, 878, 331, 108, 555, 98, 4, | 158748 | /* 1590 */ 75, 304, 554, 339, 341, 343, 108, 555, 563, 4, |
| 157741 | /* 1600 */ 1277, 494, 532, 345, 247, 867, 98, 531, 341, 886, | 158749 | /* 1600 */ 1577, 299, 532, 563, 77, 77, 1291, 531, 472, 74, |
| 157742 | /* 1610 */ 887, 1126, 1076, 558, 1076, 448, 1065, 1015, 1061, 953, | 158750 | /* 1610 */ 74, 250, 1275, 558, 350, 448, 331, 1015, 360, 98, |
| 157743 | /* 1620 */ 343, 247, 250, 106, 106, 1291, 917, 1276, 850, 110, | 158751 | /* 1620 */ 42, 42, 1352, 106, 106, 48, 48, 1399, 494, 1327, |
| 157744 | /* 1630 */ 107, 144, 442, 565, 564, 918, 442, 1005, 110, 1275, | 158752 | /* 1630 */ 107, 247, 442, 565, 564, 345, 442, 1005, 98, 1061, |
| 157745 | /* 1640 */ 350, 360, 1009, 1331, 1352, 299, 1399, 1577, 552, 1327, | 158753 | /* 1640 */ 953, 917, 247, 250, 110, 1552, 550, 850, 552, 918, |
| 157746 | /* 1650 */ 1552, 550, 1338, 549, 1405, 1256, 1248, 1237, 1236, 1238, | 158754 | /* 1650 */ 144, 1338, 110, 549, 1405, 1256, 1248, 1237, 1236, 1238, |
| 157747 | /* 1660 */ 1571, 489, 265, 200, 1324, 363, 365, 367, 11, 1005, | 158755 | /* 1660 */ 1571, 1324, 208, 390, 489, 265, 363, 200, 365, 1005, |
| 157748 | /* 1670 */ 1005, 1007, 1008, 27, 390, 221, 1386, 1015, 280, 1391, | 158756 | /* 1670 */ 1005, 1007, 1008, 27, 11, 280, 221, 1015, 323, 474, |
| 157749 | /* 1680 */ 1381, 208, 323, 106, 106, 924, 1374, 453, 283, 324, | 158757 | /* 1680 */ 1274, 367, 212, 106, 106, 924, 1386, 324, 288, 1381, |
| 157750 | /* 1690 */ 107, 474, 442, 565, 564, 1390, 499, 1005, 212, 288, | 158758 | /* 1690 */ 107, 453, 442, 565, 564, 283, 329, 1005, 1391, 499, |
| 157751 | /* 1700 */ 1274, 397, 353, 108, 555, 195, 4, 1464, 369, 1463, | 158759 | /* 1700 */ 353, 1374, 1464, 108, 555, 1463, 4, 1574, 1390, 397, |
| 157752 | /* 1710 */ 1574, 1215, 1212, 329, 553, 171, 207, 383, 1511, 196, | 158760 | /* 1710 */ 1215, 171, 254, 369, 383, 207, 195, 196, 1511, 553, |
| 157753 | /* 1720 */ 558, 254, 1509, 415, 100, 555, 83, 4, 204, 1005, | 158761 | /* 1720 */ 558, 1509, 415, 1212, 100, 555, 83, 4, 204, 1005, |
| 157754 | /* 1730 */ 1005, 1007, 1008, 27, 219, 79, 82, 1469, 180, 166, | 158762 | /* 1730 */ 1005, 1007, 1008, 27, 180, 166, 173, 219, 79, 82, |
| 157755 | /* 1740 */ 173, 558, 458, 442, 175, 176, 177, 178, 35, 1387, | 158763 | /* 1740 */ 458, 558, 175, 442, 35, 1387, 176, 459, 177, 178, |
| 157756 | /* 1750 */ 492, 459, 231, 1395, 96, 552, 1393, 1392, 395, 184, | 158764 | /* 1750 */ 492, 231, 96, 1469, 395, 552, 1393, 1392, 36, 466, |
| 157757 | /* 1760 */ 481, 466, 36, 235, 442, 89, 398, 266, 487, 1480, | 158765 | /* 1760 */ 1395, 184, 398, 481, 442, 1458, 235, 89, 1480, 487, |
| 157758 | /* 1770 */ 1458, 237, 188, 338, 508, 429, 552, 490, 400, 238, | 158766 | /* 1770 */ 266, 334, 237, 188, 490, 400, 552, 338, 238, 508, |
| 157759 | /* 1780 */ 334, 1239, 239, 1294, 1015, 1293, 1292, 1285, 91, 871, | 158767 | /* 1780 */ 1239, 239, 1294, 1293, 1015, 1292, 1285, 429, 91, 871, |
| 157760 | /* 1790 */ 106, 106, 213, 431, 1588, 432, 524, 107, 517, 442, | 158768 | /* 1790 */ 106, 106, 1588, 213, 401, 1587, 431, 107, 1264, 442, |
| 157761 | /* 1800 */ 565, 564, 401, 1264, 1005, 1015, 1263, 1587, 352, 1262, | 158769 | /* 1800 */ 565, 564, 1263, 352, 1005, 1015, 1262, 1586, 1557, 517, |
| 157762 | /* 1810 */ 1557, 106, 106, 1586, 1284, 297, 298, 358, 107, 1335, | 158770 | /* 1810 */ 432, 106, 106, 1284, 297, 298, 358, 524, 107, 1335, |
| 157763 | /* 1820 */ 442, 565, 564, 95, 362, 1005, 253, 252, 435, 125, | 158771 | /* 1820 */ 442, 565, 564, 95, 1336, 1005, 252, 253, 435, 125, |
| 157764 | /* 1830 */ 543, 10, 1444, 1543, 377, 1542, 1005, 1005, 1007, 1008, | 158772 | /* 1830 */ 543, 1543, 10, 1444, 377, 1542, 1005, 1005, 1007, 1008, |
| 157765 | /* 1840 */ 27, 302, 102, 97, 527, 1336, 260, 1317, 364, 1245, | 158773 | /* 1840 */ 27, 97, 527, 375, 362, 102, 260, 364, 381, 1317, |
| 157766 | /* 1850 */ 1334, 34, 566, 1171, 366, 381, 375, 1005, 1005, 1007, | 158774 | /* 1850 */ 382, 1334, 366, 1245, 1333, 1316, 368, 1005, 1005, 1007, |
| 157767 | /* 1860 */ 1008, 27, 1333, 1359, 368, 1316, 199, 382, 261, 263, | 158775 | /* 1860 */ 1008, 27, 1359, 1358, 34, 199, 1171, 566, 261, 263, |
| 157768 | /* 1870 */ 264, 1358, 158, 1496, 141, 1497, 1495, 567, 1234, 1229, | 158776 | /* 1870 */ 264, 567, 1234, 158, 1229, 141, 295, 159, 1496, 302, |
| 157769 | /* 1880 */ 1494, 295, 159, 209, 210, 78, 826, 443, 201, 306, | 158777 | /* 1880 */ 1497, 1495, 1494, 160, 826, 209, 443, 201, 306, 210, |
| 157770 | /* 1890 */ 220, 1075, 138, 1073, 160, 314, 162, 172, 1196, 174, | 158778 | /* 1890 */ 78, 220, 1075, 138, 1073, 314, 162, 172, 1196, 227, |
| 157771 | /* 1900 */ 903, 227, 230, 322, 1089, 179, 163, 164, 418, 85, | 158779 | /* 1900 */ 174, 903, 322, 230, 1089, 179, 163, 164, 418, 408, |
| 157772 | /* 1910 */ 420, 181, 170, 408, 409, 86, 87, 165, 88, 1092, | 158780 | /* 1910 */ 409, 170, 181, 85, 86, 420, 87, 165, 1092, 88, |
| 157773 | /* 1920 */ 232, 233, 1088, 151, 18, 234, 1081, 250, 333, 185, | 158781 | /* 1920 */ 233, 232, 1088, 151, 18, 234, 1081, 250, 333, 1209, |
| 157774 | /* 1930 */ 1209, 486, 236, 186, 37, 841, 491, 354, 240, 346, | 158782 | /* 1930 */ 185, 486, 236, 186, 37, 841, 491, 354, 240, 346, |
| 157775 | /* 1940 */ 503, 187, 90, 167, 19, 495, 20, 869, 500, 349, | 158783 | /* 1940 */ 495, 187, 90, 869, 19, 20, 500, 503, 349, 92, |
| 157776 | /* 1950 */ 92, 882, 296, 152, 93, 510, 1127, 1159, 153, 1041, | 158784 | /* 1950 */ 167, 152, 296, 882, 93, 510, 94, 1159, 153, 1041, |
| 157777 | /* 1960 */ 214, 1128, 39, 94, 269, 271, 952, 190, 947, 110, | 158785 | /* 1960 */ 1128, 39, 214, 269, 1127, 271, 249, 952, 190, 947, |
| 157778 | /* 1970 */ 1149, 1145, 1153, 249, 1133, 1147, 7, 33, 21, 193, | 158786 | /* 1970 */ 110, 1149, 21, 7, 1153, 22, 1145, 23, 1147, 24, |
| 157779 | /* 1980 */ 22, 23, 24, 25, 1152, 539, 98, 1056, 26, 1042, | 158787 | /* 1980 */ 1133, 25, 1152, 33, 539, 193, 26, 1056, 98, 1042, |
| 157780 | /* 1990 */ 1040, 1044, 1098, 1045, 1097, 256, 255, 28, 40, 387, | 158788 | /* 1990 */ 1040, 1044, 1098, 1045, 1097, 256, 255, 28, 40, 257, |
| 157781 | /* 2000 */ 1010, 851, 109, 29, 1167, 559, 384, 257, 913, 258, | 158789 | /* 2000 */ 1010, 851, 109, 29, 913, 559, 384, 387, 258, 1167, |
| 157782 | /* 2010 */ 1166, 1579, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1578, | 158790 | /* 2010 */ 1166, 1225, 1225, 1225, 1579, 1225, 1225, 1225, 1225, 1225, |
| 158791 | /* 2020 */ 1225, 1225, 1578, | ||
| 157783 | }; | 158792 | }; |
| 157784 | static const YYCODETYPE yy_lookahead[] = { | 158793 | static const YYCODETYPE yy_lookahead[] = { |
| 157785 | /* 0 */ 191, 220, 191, 222, 191, 191, 271, 272, 273, 216, | 158794 | /* 0 */ 192, 221, 192, 223, 192, 214, 272, 273, 274, 217, |
| 157786 | /* 10 */ 191, 230, 216, 191, 191, 191, 271, 272, 273, 19, | 158795 | /* 10 */ 192, 231, 217, 192, 192, 192, 272, 273, 274, 19, |
| 157787 | /* 20 */ 232, 233, 213, 214, 213, 214, 202, 292, 202, 232, | 158796 | /* 20 */ 233, 234, 214, 215, 214, 215, 203, 293, 203, 233, |
| 157788 | /* 30 */ 233, 31, 213, 214, 213, 213, 214, 213, 214, 39, | 158797 | /* 30 */ 234, 31, 214, 215, 214, 214, 215, 214, 215, 39, |
| 157789 | /* 40 */ 207, 208, 209, 43, 44, 45, 46, 47, 48, 49, | 158798 | /* 40 */ 208, 209, 210, 43, 44, 45, 46, 47, 48, 49, |
| 157790 | /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 235, 19, | 158799 | /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 236, 19, |
| 157791 | /* 60 */ 236, 237, 236, 237, 271, 272, 273, 271, 272, 273, | 158800 | /* 60 */ 237, 238, 237, 238, 272, 273, 274, 272, 273, 274, |
| 157792 | /* 70 */ 191, 210, 250, 249, 250, 249, 213, 191, 199, 253, | 158801 | /* 70 */ 192, 211, 251, 250, 251, 250, 26, 192, 200, 254, |
| 157793 | /* 80 */ 254, 259, 203, 43, 44, 45, 46, 47, 48, 49, | 158802 | /* 80 */ 255, 260, 204, 43, 44, 45, 46, 47, 48, 49, |
| 157794 | /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 213, | 158803 | /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 192, 214, |
| 157795 | /* 100 */ 214, 213, 102, 103, 104, 105, 106, 107, 108, 109, | 158804 | /* 100 */ 215, 214, 102, 103, 104, 105, 106, 107, 108, 109, |
| 157796 | /* 110 */ 110, 111, 112, 59, 228, 301, 293, 81, 305, 306, | 158805 | /* 110 */ 110, 111, 112, 59, 229, 192, 294, 16, 306, 307, |
| 157797 | /* 120 */ 311, 312, 311, 310, 313, 59, 86, 212, 88, 19, | 158806 | /* 120 */ 312, 313, 312, 311, 314, 59, 86, 204, 88, 19, |
| 157798 | /* 130 */ 311, 312, 271, 272, 273, 220, 26, 112, 54, 55, | 158807 | /* 130 */ 312, 313, 272, 273, 274, 271, 26, 22, 54, 55, |
| 157799 | /* 140 */ 56, 57, 102, 103, 104, 105, 106, 107, 108, 109, | 158808 | /* 140 */ 56, 57, 102, 103, 104, 105, 106, 107, 108, 109, |
| 157800 | /* 150 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, | 158809 | /* 150 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, |
| 157801 | /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 115, | 158810 | /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 53, 115, |
| 157802 | /* 170 */ 116, 117, 118, 137, 138, 121, 122, 123, 191, 69, | 158811 | /* 170 */ 116, 117, 118, 309, 310, 121, 122, 123, 77, 69, |
| 157803 | /* 180 */ 203, 115, 116, 117, 59, 131, 102, 103, 104, 105, | 158812 | /* 180 */ 79, 115, 116, 117, 59, 131, 102, 103, 104, 105, |
| 157804 | /* 190 */ 106, 107, 108, 109, 110, 111, 112, 72, 191, 19, | 158813 | /* 190 */ 106, 107, 108, 109, 110, 111, 112, 72, 148, 19, |
| 157805 | /* 200 */ 54, 55, 56, 57, 58, 108, 109, 110, 111, 112, | 158814 | /* 200 */ 54, 55, 56, 57, 58, 108, 109, 110, 111, 112, |
| 157806 | /* 210 */ 303, 304, 102, 103, 104, 105, 106, 107, 108, 109, | 158815 | /* 210 */ 304, 305, 102, 103, 104, 105, 106, 107, 108, 109, |
| 157807 | /* 220 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, | 158816 | /* 220 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, |
| 157808 | /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 16, | 158817 | /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 112, |
| 157809 | /* 240 */ 115, 116, 117, 24, 16, 227, 202, 67, 102, 103, | 158818 | /* 240 */ 115, 116, 117, 24, 208, 209, 210, 67, 102, 103, |
| 157810 | /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 59, | 158819 | /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 192, |
| 157811 | /* 260 */ 26, 191, 43, 44, 45, 46, 47, 48, 49, 50, | 158820 | /* 260 */ 59, 160, 43, 44, 45, 46, 47, 48, 49, 50, |
| 157812 | /* 270 */ 51, 52, 53, 54, 55, 56, 57, 24, 208, 209, | 158821 | /* 270 */ 51, 52, 53, 54, 55, 56, 57, 19, 46, 47, |
| 157813 | /* 280 */ 236, 237, 102, 103, 104, 105, 106, 107, 108, 109, | 158822 | /* 280 */ 48, 49, 102, 103, 104, 105, 106, 107, 108, 109, |
| 157814 | /* 290 */ 110, 111, 112, 249, 183, 184, 185, 186, 187, 188, | 158823 | /* 290 */ 110, 111, 112, 213, 73, 184, 185, 186, 187, 188, |
| 157815 | /* 300 */ 77, 59, 79, 191, 193, 77, 195, 79, 19, 19, | 158824 | /* 300 */ 189, 221, 81, 236, 46, 194, 192, 196, 19, 59, |
| 157816 | /* 310 */ 266, 304, 59, 202, 24, 115, 116, 117, 191, 127, | 158825 | /* 310 */ 133, 59, 135, 136, 203, 192, 115, 116, 117, 127, |
| 157817 | /* 320 */ 128, 102, 103, 104, 105, 106, 107, 108, 109, 110, | 158826 | /* 320 */ 128, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 157818 | /* 330 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, | 158827 | /* 330 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, |
| 157819 | /* 340 */ 51, 52, 53, 54, 55, 56, 57, 236, 237, 191, | 158828 | /* 340 */ 51, 52, 53, 54, 55, 56, 57, 126, 237, 238, |
| 157820 | /* 350 */ 150, 281, 191, 185, 186, 187, 188, 115, 116, 117, | 158829 | /* 350 */ 100, 150, 120, 230, 186, 187, 188, 189, 137, 138, |
| 157821 | /* 360 */ 249, 193, 191, 195, 26, 73, 59, 191, 114, 116, | 158830 | /* 360 */ 108, 250, 194, 26, 196, 115, 116, 115, 116, 117, |
| 157822 | /* 370 */ 202, 213, 214, 81, 263, 106, 107, 108, 109, 110, | 158831 | /* 370 */ 120, 203, 114, 164, 165, 264, 102, 103, 104, 105, |
| 157823 | /* 380 */ 111, 112, 148, 160, 142, 95, 228, 191, 191, 213, | 158832 | /* 380 */ 106, 107, 108, 109, 110, 111, 112, 192, 130, 111, |
| 157824 | /* 390 */ 214, 102, 103, 104, 105, 106, 107, 108, 109, 110, | 158833 | /* 390 */ 112, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 157825 | /* 400 */ 111, 112, 112, 149, 236, 237, 295, 100, 118, 119, | 158834 | /* 400 */ 111, 112, 152, 153, 154, 237, 238, 296, 192, 214, |
| 157826 | /* 410 */ 120, 121, 122, 123, 124, 19, 31, 249, 126, 23, | 158835 | /* 410 */ 215, 228, 192, 307, 192, 19, 59, 311, 250, 23, |
| 157827 | /* 420 */ 130, 260, 115, 116, 39, 22, 250, 120, 191, 137, | 158836 | /* 420 */ 22, 106, 107, 108, 109, 110, 111, 112, 192, 72, |
| 157828 | /* 430 */ 138, 263, 305, 306, 238, 259, 265, 310, 149, 43, | 158837 | /* 430 */ 214, 215, 264, 192, 214, 215, 214, 215, 149, 43, |
| 157829 | /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, | 158838 | /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 157830 | /* 450 */ 54, 55, 56, 57, 191, 117, 191, 210, 19, 152, | 158839 | /* 450 */ 54, 55, 56, 57, 117, 214, 215, 59, 19, 187, |
| 157831 | /* 460 */ 153, 154, 23, 295, 102, 103, 104, 105, 106, 107, | 158840 | /* 460 */ 192, 189, 23, 81, 296, 192, 194, 251, 196, 59, |
| 157832 | /* 470 */ 108, 109, 110, 111, 112, 266, 213, 214, 213, 214, | 158841 | /* 470 */ 229, 251, 115, 116, 117, 203, 260, 106, 107, 142, |
| 157833 | /* 480 */ 142, 81, 43, 44, 45, 46, 47, 48, 49, 50, | 158842 | /* 480 */ 260, 267, 43, 44, 45, 46, 47, 48, 49, 50, |
| 157834 | /* 490 */ 51, 52, 53, 54, 55, 56, 57, 301, 102, 103, | 158843 | /* 490 */ 51, 52, 53, 54, 55, 56, 57, 261, 102, 103, |
| 157835 | /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 106, | 158844 | /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 237, |
| 157836 | /* 510 */ 107, 118, 59, 250, 121, 122, 123, 280, 76, 119, | 158845 | /* 510 */ 238, 76, 192, 115, 116, 117, 144, 192, 76, 137, |
| 157837 | /* 520 */ 236, 237, 259, 306, 131, 72, 59, 310, 19, 87, | 158846 | /* 520 */ 138, 192, 250, 152, 89, 154, 116, 92, 19, 87, |
| 157838 | /* 530 */ 283, 89, 23, 249, 92, 288, 22, 137, 138, 22, | 158847 | /* 530 */ 262, 89, 23, 22, 92, 163, 264, 192, 22, 214, |
| 157839 | /* 540 */ 275, 102, 103, 104, 105, 106, 107, 108, 109, 110, | 158848 | /* 540 */ 215, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 157840 | /* 550 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, | 158849 | /* 550 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, |
| 157841 | /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 115, 116, | 158850 | /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 296, 118, |
| 157842 | /* 570 */ 117, 23, 186, 59, 188, 108, 59, 241, 191, 193, | 158851 | /* 570 */ 59, 23, 121, 122, 123, 59, 251, 26, 46, 306, |
| 157843 | /* 580 */ 26, 195, 115, 116, 117, 191, 144, 251, 202, 22, | 158852 | /* 580 */ 307, 261, 131, 192, 311, 192, 144, 192, 22, 203, |
| 157844 | /* 590 */ 100, 43, 44, 45, 46, 47, 48, 49, 50, 51, | 158853 | /* 590 */ 100, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 157845 | /* 600 */ 52, 53, 54, 55, 56, 57, 116, 213, 214, 191, | 158854 | /* 600 */ 52, 53, 54, 55, 56, 57, 116, 214, 215, 271, |
| 157846 | /* 610 */ 120, 102, 103, 104, 105, 106, 107, 108, 109, 110, | 158855 | /* 610 */ 120, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 157847 | /* 620 */ 111, 112, 236, 237, 306, 238, 59, 26, 310, 115, | 158856 | /* 620 */ 111, 112, 229, 237, 238, 59, 115, 116, 117, 299, |
| 157848 | /* 630 */ 116, 117, 115, 116, 117, 249, 246, 19, 248, 106, | 158857 | /* 630 */ 300, 115, 116, 117, 59, 16, 250, 19, 192, 192, |
| 157849 | /* 640 */ 107, 23, 152, 153, 154, 46, 47, 48, 49, 263, | 158858 | /* 640 */ 19, 23, 152, 153, 154, 24, 114, 309, 310, 192, |
| 157850 | /* 650 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, | 158859 | /* 650 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 157851 | /* 660 */ 112, 43, 44, 45, 46, 47, 48, 49, 50, 51, | 158860 | /* 660 */ 112, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 157852 | /* 670 */ 52, 53, 54, 55, 56, 57, 19, 76, 298, 299, | 158861 | /* 670 */ 52, 53, 54, 55, 56, 57, 19, 7, 8, 9, |
| 157853 | /* 680 */ 23, 295, 115, 116, 117, 152, 191, 154, 301, 73, | 158862 | /* 680 */ 23, 115, 116, 117, 203, 290, 239, 238, 137, 138, |
| 157854 | /* 690 */ 89, 137, 138, 92, 22, 191, 144, 22, 191, 191, | 158863 | /* 690 */ 115, 116, 117, 236, 192, 22, 77, 81, 79, 250, |
| 157855 | /* 700 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, | 158864 | /* 700 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 157856 | /* 710 */ 53, 54, 55, 56, 57, 163, 191, 213, 214, 120, | 158865 | /* 710 */ 53, 54, 55, 56, 57, 192, 95, 142, 237, 238, |
| 157857 | /* 720 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, | 158866 | /* 720 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 157858 | /* 730 */ 112, 59, 228, 191, 59, 191, 236, 237, 213, 214, | 158867 | /* 730 */ 112, 250, 59, 112, 192, 119, 26, 214, 215, 118, |
| 157859 | /* 740 */ 11, 59, 126, 127, 128, 238, 19, 26, 191, 249, | 158868 | /* 740 */ 119, 120, 121, 122, 123, 124, 19, 192, 267, 302, |
| 157860 | /* 750 */ 23, 164, 165, 228, 191, 213, 214, 213, 214, 102, | 158869 | /* 750 */ 23, 130, 229, 137, 138, 23, 214, 215, 26, 102, |
| 157861 | /* 760 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, | 158870 | /* 760 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 157862 | /* 770 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, | 158871 | /* 770 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 157863 | /* 780 */ 53, 54, 55, 56, 57, 19, 241, 115, 116, 117, | 158872 | /* 780 */ 53, 54, 55, 56, 57, 19, 76, 11, 115, 116, |
| 157864 | /* 790 */ 115, 116, 117, 191, 250, 238, 251, 115, 116, 117, | 158873 | /* 790 */ 117, 192, 29, 251, 239, 73, 33, 192, 192, 89, |
| 157865 | /* 800 */ 157, 23, 159, 191, 26, 191, 111, 112, 301, 43, | 158874 | /* 800 */ 192, 192, 92, 192, 192, 126, 127, 128, 224, 43, |
| 157866 | /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, | 158875 | /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 157867 | /* 820 */ 54, 55, 56, 57, 142, 213, 214, 213, 214, 102, | 158876 | /* 820 */ 54, 55, 56, 57, 192, 35, 214, 215, 65, 102, |
| 157868 | /* 830 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, | 158877 | /* 830 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 157869 | /* 840 */ 228, 191, 228, 191, 191, 207, 208, 209, 126, 127, | 158878 | /* 840 */ 59, 229, 192, 192, 239, 239, 214, 215, 126, 127, |
| 157870 | /* 850 */ 128, 133, 289, 135, 136, 19, 127, 128, 301, 7, | 158879 | /* 850 */ 128, 126, 127, 128, 307, 19, 66, 302, 311, 192, |
| 157871 | /* 860 */ 8, 9, 141, 213, 214, 213, 214, 265, 102, 103, | 158880 | /* 860 */ 261, 229, 224, 22, 74, 214, 215, 192, 102, 103, |
| 157872 | /* 870 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 43, | 158881 | /* 870 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 43, |
| 157873 | /* 880 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, | 158882 | /* 880 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 157874 | /* 890 */ 54, 55, 56, 57, 191, 117, 191, 22, 23, 19, | 158883 | /* 890 */ 54, 55, 56, 57, 192, 192, 115, 116, 117, 19, |
| 157875 | /* 900 */ 250, 26, 250, 191, 223, 191, 126, 127, 128, 205, | 158884 | /* 900 */ 59, 290, 251, 127, 128, 192, 23, 302, 302, 26, |
| 157876 | /* 910 */ 206, 205, 206, 260, 21, 202, 213, 214, 213, 214, | 158885 | /* 910 */ 302, 236, 192, 22, 21, 24, 214, 215, 192, 129, |
| 157877 | /* 920 */ 142, 270, 208, 209, 158, 45, 46, 47, 48, 49, | 158886 | /* 920 */ 22, 192, 24, 142, 158, 45, 46, 47, 48, 49, |
| 157878 | /* 930 */ 50, 51, 52, 53, 54, 55, 56, 57, 102, 103, | 158887 | /* 930 */ 50, 51, 52, 53, 54, 55, 56, 57, 102, 103, |
| 157879 | /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 236, | 158888 | /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 192, |
| 157880 | /* 950 */ 237, 12, 191, 250, 76, 250, 191, 22, 23, 308, | 158889 | /* 950 */ 59, 12, 192, 251, 192, 305, 192, 116, 22, 23, |
| 157881 | /* 960 */ 309, 26, 249, 202, 191, 191, 27, 89, 191, 202, | 158890 | /* 960 */ 242, 203, 26, 203, 24, 236, 27, 237, 238, 266, |
| 157882 | /* 970 */ 92, 202, 260, 80, 213, 214, 101, 203, 213, 214, | 158891 | /* 970 */ 252, 214, 215, 80, 214, 215, 214, 215, 214, 215, |
| 157883 | /* 980 */ 22, 42, 102, 103, 104, 105, 106, 107, 108, 109, | 158892 | /* 980 */ 250, 42, 102, 103, 104, 105, 106, 107, 108, 109, |
| 157884 | /* 990 */ 110, 111, 112, 228, 158, 281, 108, 236, 237, 225, | 158893 | /* 990 */ 110, 111, 112, 229, 158, 237, 238, 237, 238, 59, |
| 157885 | /* 1000 */ 191, 227, 63, 236, 237, 236, 237, 191, 235, 191, | 158894 | /* 1000 */ 117, 281, 63, 192, 192, 192, 192, 116, 250, 192, |
| 157886 | /* 1010 */ 249, 250, 73, 241, 19, 122, 249, 59, 249, 24, | 158895 | /* 1010 */ 250, 251, 73, 251, 19, 122, 290, 237, 238, 24, |
| 157887 | /* 1020 */ 259, 29, 134, 251, 191, 33, 22, 139, 24, 213, | 158896 | /* 1020 */ 260, 209, 210, 209, 210, 142, 242, 214, 215, 197, |
| 157888 | /* 1030 */ 214, 213, 214, 191, 19, 210, 101, 191, 43, 44, | 158897 | /* 1030 */ 250, 22, 23, 276, 19, 26, 252, 101, 43, 44, |
| 157889 | /* 1040 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, | 158898 | /* 1040 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 157890 | /* 1050 */ 55, 56, 57, 160, 19, 213, 214, 65, 43, 44, | 158899 | /* 1050 */ 55, 56, 57, 160, 19, 211, 116, 192, 43, 44, |
| 157891 | /* 1060 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, | 158900 | /* 1060 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 157892 | /* 1070 */ 55, 56, 57, 191, 116, 22, 191, 24, 43, 44, | 158901 | /* 1070 */ 55, 56, 57, 192, 192, 22, 192, 266, 43, 44, |
| 157893 | /* 1080 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, | 158902 | /* 1080 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 157894 | /* 1090 */ 55, 56, 57, 191, 261, 213, 214, 102, 103, 104, | 158903 | /* 1090 */ 55, 56, 57, 192, 282, 192, 282, 102, 103, 104, |
| 157895 | /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 19, | 158904 | /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 192, |
| 157896 | /* 1110 */ 191, 265, 59, 288, 191, 213, 214, 102, 103, 104, | 158905 | /* 1110 */ 101, 279, 192, 192, 230, 283, 192, 102, 103, 104, |
| 157897 | /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 35, 191, | 158906 | /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 204, 211, |
| 157898 | /* 1130 */ 66, 191, 213, 214, 191, 270, 46, 102, 103, 104, | 158907 | /* 1130 */ 66, 214, 215, 289, 214, 215, 108, 102, 103, 104, |
| 157899 | /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 191, 85, | 158908 | /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 266, 85, |
| 157900 | /* 1150 */ 265, 213, 214, 213, 214, 106, 107, 19, 94, 66, | 158909 | /* 1150 */ 226, 192, 228, 22, 23, 106, 107, 19, 94, 106, |
| 157901 | /* 1160 */ 137, 138, 191, 114, 115, 116, 117, 74, 119, 116, | 158910 | /* 1160 */ 107, 192, 134, 114, 115, 116, 117, 139, 119, 266, |
| 157902 | /* 1170 */ 213, 214, 202, 308, 309, 306, 127, 191, 235, 310, | 158911 | /* 1170 */ 203, 206, 207, 214, 215, 192, 127, 192, 206, 207, |
| 157903 | /* 1180 */ 59, 191, 44, 45, 46, 47, 48, 49, 50, 51, | 158912 | /* 1180 */ 59, 192, 44, 45, 46, 47, 48, 49, 50, 51, |
| 157904 | /* 1190 */ 52, 53, 54, 55, 56, 57, 191, 76, 196, 213, | 158913 | /* 1190 */ 52, 53, 54, 55, 56, 57, 192, 76, 192, 214, |
| 157905 | /* 1200 */ 214, 152, 12, 154, 114, 191, 236, 237, 87, 145, | 158914 | /* 1200 */ 215, 152, 284, 154, 237, 238, 192, 289, 87, 145, |
| 157906 | /* 1210 */ 89, 19, 20, 92, 22, 22, 23, 27, 191, 249, | 158915 | /* 1210 */ 89, 19, 20, 92, 22, 22, 23, 250, 307, 236, |
| 157907 | /* 1220 */ 130, 202, 129, 202, 191, 235, 306, 152, 36, 154, | 158916 | /* 1220 */ 214, 215, 311, 203, 12, 247, 192, 249, 36, 307, |
| 157908 | /* 1230 */ 310, 191, 42, 191, 191, 191, 115, 116, 117, 191, | 158917 | /* 1230 */ 192, 262, 101, 311, 137, 138, 115, 116, 117, 27, |
| 157909 | /* 1240 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, | 158918 | /* 1240 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 157910 | /* 1250 */ 112, 59, 99, 63, 191, 236, 237, 236, 237, 191, | 158919 | /* 1250 */ 112, 59, 214, 215, 42, 203, 307, 237, 238, 192, |
| 157911 | /* 1260 */ 289, 213, 214, 71, 191, 144, 261, 191, 249, 191, | 158920 | /* 1260 */ 311, 192, 26, 71, 192, 144, 262, 297, 298, 203, |
| 157912 | /* 1270 */ 249, 19, 20, 81, 22, 235, 213, 214, 235, 191, | 158921 | /* 1270 */ 250, 19, 20, 81, 22, 63, 262, 254, 255, 15, |
| 157913 | /* 1280 */ 278, 213, 214, 191, 282, 132, 213, 214, 36, 213, | 158922 | /* 1280 */ 26, 214, 215, 214, 215, 26, 214, 215, 36, 237, |
| 157914 | /* 1290 */ 214, 191, 100, 191, 101, 191, 191, 191, 106, 107, | 158923 | /* 1290 */ 238, 192, 100, 114, 101, 192, 262, 192, 106, 107, |
| 157915 | /* 1300 */ 48, 213, 214, 261, 191, 113, 191, 115, 116, 117, | 158924 | /* 1300 */ 48, 134, 250, 237, 238, 113, 139, 115, 116, 117, |
| 157916 | /* 1310 */ 191, 59, 120, 213, 214, 213, 214, 213, 214, 213, | 158925 | /* 1310 */ 192, 59, 120, 214, 215, 242, 250, 214, 215, 214, |
| 157917 | /* 1320 */ 214, 22, 23, 71, 237, 59, 213, 214, 191, 137, | 158926 | /* 1320 */ 215, 148, 149, 71, 60, 252, 242, 192, 149, 137, |
| 157918 | /* 1330 */ 138, 191, 213, 214, 191, 191, 249, 85, 191, 261, | 158927 | /* 1330 */ 138, 192, 214, 215, 192, 19, 252, 85, 192, 59, |
| 157919 | /* 1340 */ 191, 26, 90, 15, 152, 153, 154, 155, 156, 19, | 158928 | /* 1340 */ 192, 157, 90, 159, 152, 153, 154, 155, 156, 214, |
| 157920 | /* 1350 */ 213, 214, 100, 213, 214, 191, 213, 214, 106, 107, | 158929 | /* 1350 */ 215, 192, 100, 214, 215, 19, 214, 215, 106, 107, |
| 157921 | /* 1360 */ 213, 214, 213, 214, 191, 113, 261, 115, 116, 117, | 158930 | /* 1360 */ 214, 215, 214, 215, 22, 113, 192, 115, 116, 117, |
| 157922 | /* 1370 */ 253, 254, 120, 229, 191, 191, 191, 213, 214, 191, | 158931 | /* 1370 */ 192, 242, 120, 214, 215, 192, 24, 192, 31, 192, |
| 157923 | /* 1380 */ 306, 289, 116, 26, 310, 191, 213, 214, 60, 19, | 158932 | /* 1380 */ 144, 252, 26, 192, 125, 99, 39, 192, 214, 215, |
| 157924 | /* 1390 */ 296, 297, 24, 191, 46, 191, 213, 214, 213, 214, | 158933 | /* 1390 */ 192, 59, 214, 215, 192, 141, 116, 214, 215, 214, |
| 157925 | /* 1400 */ 101, 213, 214, 191, 152, 153, 154, 155, 156, 0, | 158934 | /* 1400 */ 215, 214, 215, 61, 152, 153, 154, 155, 156, 0, |
| 157926 | /* 1410 */ 1, 2, 191, 229, 5, 213, 214, 213, 214, 10, | 158935 | /* 1410 */ 1, 2, 214, 215, 5, 192, 214, 215, 132, 10, |
| 157927 | /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 191, 5, 19, | 158936 | /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 192, 5, 19, |
| 157928 | /* 1430 */ 20, 191, 22, 10, 11, 12, 13, 14, 191, 30, | 158937 | /* 1430 */ 20, 115, 22, 10, 11, 12, 13, 14, 192, 30, |
| 157929 | /* 1440 */ 17, 32, 241, 148, 149, 115, 36, 191, 241, 40, | 158938 | /* 1440 */ 17, 32, 23, 192, 23, 26, 36, 26, 116, 40, |
| 157930 | /* 1450 */ 191, 26, 251, 30, 191, 32, 141, 22, 251, 5, | 158939 | /* 1450 */ 192, 115, 192, 30, 192, 32, 119, 120, 59, 5, |
| 157931 | /* 1460 */ 213, 214, 114, 40, 10, 11, 12, 13, 14, 59, | 158940 | /* 1460 */ 214, 215, 128, 40, 10, 11, 12, 13, 14, 59, |
| 157932 | /* 1470 */ 134, 17, 213, 214, 191, 139, 213, 214, 191, 70, | 158941 | /* 1470 */ 19, 17, 214, 215, 214, 215, 214, 215, 120, 70, |
| 157933 | /* 1480 */ 191, 71, 125, 191, 30, 115, 32, 78, 53, 191, | 158942 | /* 1480 */ 192, 71, 22, 192, 30, 151, 32, 78, 130, 128, |
| 157934 | /* 1490 */ 81, 191, 191, 70, 40, 85, 213, 214, 191, 22, | 158943 | /* 1490 */ 81, 192, 140, 70, 40, 85, 192, 141, 7, 8, |
| 157935 | /* 1500 */ 90, 78, 213, 214, 81, 213, 214, 98, 140, 120, | 158944 | /* 1500 */ 90, 78, 214, 215, 81, 214, 215, 98, 83, 84, |
| 157936 | /* 1510 */ 100, 213, 214, 213, 214, 23, 106, 107, 26, 130, | 158945 | /* 1510 */ 100, 192, 151, 214, 215, 116, 106, 107, 214, 215, |
| 157937 | /* 1520 */ 191, 98, 191, 113, 70, 115, 116, 117, 23, 22, | 158946 | /* 1520 */ 192, 98, 192, 113, 70, 115, 116, 117, 23, 224, |
| 157938 | /* 1530 */ 120, 26, 78, 19, 191, 81, 19, 20, 61, 22, | 158947 | /* 1530 */ 120, 26, 78, 214, 215, 81, 19, 20, 152, 22, |
| 157939 | /* 1540 */ 191, 132, 213, 214, 213, 214, 137, 138, 59, 191, | 158948 | /* 1540 */ 154, 132, 214, 215, 214, 215, 137, 138, 97, 192, |
| 157940 | /* 1550 */ 191, 191, 98, 36, 128, 132, 213, 214, 128, 59, | 158949 | /* 1550 */ 256, 192, 98, 36, 23, 132, 192, 26, 192, 192, |
| 157941 | /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 83, 84, 144, | 158950 | /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 192, 192, 192, |
| 157942 | /* 1570 */ 161, 213, 214, 213, 214, 23, 59, 151, 26, 23, | 158951 | /* 1570 */ 161, 214, 215, 214, 215, 192, 59, 192, 214, 215, |
| 157943 | /* 1580 */ 23, 151, 26, 26, 161, 59, 132, 23, 71, 191, | 158952 | /* 1580 */ 214, 215, 192, 152, 161, 154, 132, 192, 71, 214, |
| 157944 | /* 1590 */ 26, 137, 138, 119, 120, 23, 19, 20, 26, 22, | 158953 | /* 1590 */ 215, 137, 138, 192, 192, 192, 19, 20, 192, 22, |
| 157945 | /* 1600 */ 223, 23, 85, 23, 26, 116, 26, 90, 191, 7, | 158954 | /* 1600 */ 140, 253, 85, 192, 214, 215, 192, 90, 23, 214, |
| 157946 | /* 1610 */ 8, 97, 152, 36, 154, 161, 116, 100, 23, 23, | 158955 | /* 1610 */ 215, 26, 192, 36, 192, 161, 23, 100, 192, 26, |
| 157947 | /* 1620 */ 191, 26, 26, 106, 107, 191, 23, 223, 23, 26, | 158956 | /* 1620 */ 214, 215, 192, 106, 107, 214, 215, 192, 23, 192, |
| 157948 | /* 1630 */ 113, 26, 115, 116, 117, 23, 59, 120, 26, 191, | 158957 | /* 1630 */ 113, 26, 115, 116, 117, 23, 59, 120, 26, 23, |
| 157949 | /* 1640 */ 191, 191, 116, 255, 191, 252, 191, 140, 71, 191, | 158958 | /* 1640 */ 23, 23, 26, 26, 26, 316, 234, 23, 71, 23, |
| 157950 | /* 1650 */ 315, 233, 191, 191, 191, 191, 191, 191, 191, 191, | 158959 | /* 1650 */ 26, 192, 26, 192, 192, 192, 192, 192, 192, 192, |
| 157951 | /* 1660 */ 191, 285, 284, 239, 252, 252, 252, 252, 240, 152, | 158960 | /* 1660 */ 192, 253, 212, 190, 286, 285, 253, 240, 253, 152, |
| 157952 | /* 1670 */ 153, 154, 155, 156, 189, 294, 268, 100, 242, 268, | 158961 | /* 1670 */ 153, 154, 155, 156, 241, 243, 295, 100, 291, 291, |
| 157953 | /* 1680 */ 264, 211, 290, 106, 107, 108, 264, 256, 256, 243, | 158962 | /* 1680 */ 223, 253, 227, 106, 107, 108, 269, 244, 244, 265, |
| 157954 | /* 1690 */ 113, 290, 115, 116, 117, 268, 217, 120, 226, 243, | 158963 | /* 1690 */ 113, 257, 115, 116, 117, 257, 243, 120, 269, 218, |
| 157955 | /* 1700 */ 222, 268, 216, 19, 20, 246, 22, 216, 256, 216, | 158964 | /* 1700 */ 217, 265, 217, 19, 20, 217, 22, 195, 269, 269, |
| 157956 | /* 1710 */ 194, 60, 38, 242, 277, 294, 240, 242, 198, 246, | 158965 | /* 1710 */ 60, 295, 140, 257, 243, 241, 247, 247, 199, 278, |
| 157957 | /* 1720 */ 36, 140, 198, 198, 19, 20, 150, 22, 149, 152, | 158966 | /* 1720 */ 36, 199, 199, 38, 19, 20, 150, 22, 149, 152, |
| 157958 | /* 1730 */ 153, 154, 155, 156, 294, 291, 291, 280, 22, 43, | 158967 | /* 1730 */ 153, 154, 155, 156, 22, 43, 232, 295, 292, 292, |
| 157959 | /* 1740 */ 231, 36, 18, 59, 234, 234, 234, 234, 267, 269, | 158968 | /* 1740 */ 18, 36, 235, 59, 268, 270, 235, 199, 235, 235, |
| 157960 | /* 1750 */ 18, 198, 197, 231, 148, 71, 269, 269, 243, 231, | 158969 | /* 1750 */ 18, 198, 148, 281, 244, 71, 270, 270, 268, 244, |
| 157961 | /* 1760 */ 198, 243, 267, 197, 59, 157, 243, 198, 62, 287, | 158970 | /* 1760 */ 232, 232, 244, 199, 59, 244, 198, 157, 288, 62, |
| 157962 | /* 1770 */ 243, 197, 22, 198, 114, 64, 71, 218, 218, 197, | 158971 | /* 1770 */ 199, 287, 198, 22, 219, 219, 71, 199, 198, 114, |
| 157963 | /* 1780 */ 286, 198, 197, 215, 100, 215, 215, 224, 22, 125, | 158972 | /* 1780 */ 199, 198, 216, 216, 100, 216, 225, 64, 22, 125, |
| 157964 | /* 1790 */ 106, 107, 164, 24, 221, 112, 143, 113, 302, 115, | 158973 | /* 1790 */ 106, 107, 222, 164, 219, 222, 24, 113, 216, 115, |
| 157965 | /* 1800 */ 116, 117, 218, 215, 120, 100, 217, 221, 215, 215, | 158974 | /* 1800 */ 116, 117, 218, 216, 120, 100, 216, 216, 310, 303, |
| 157966 | /* 1810 */ 309, 106, 107, 215, 224, 279, 279, 218, 113, 258, | 158975 | /* 1810 */ 112, 106, 107, 225, 280, 280, 219, 143, 113, 259, |
| 157967 | /* 1820 */ 115, 116, 117, 114, 257, 120, 91, 198, 82, 147, | 158976 | /* 1820 */ 115, 116, 117, 114, 259, 120, 199, 91, 82, 147, |
| 157968 | /* 1830 */ 144, 22, 274, 314, 198, 314, 152, 153, 154, 155, | 158977 | /* 1830 */ 144, 315, 22, 275, 199, 315, 152, 153, 154, 155, |
| 157969 | /* 1840 */ 156, 276, 157, 146, 145, 258, 25, 247, 257, 201, | 158978 | /* 1840 */ 156, 146, 145, 247, 258, 157, 25, 258, 245, 248, |
| 157970 | /* 1850 */ 258, 26, 200, 13, 257, 244, 246, 152, 153, 154, | 158979 | /* 1850 */ 244, 259, 258, 202, 259, 248, 258, 152, 153, 154, |
| 157971 | /* 1860 */ 155, 156, 258, 262, 257, 247, 245, 243, 192, 192, | 158980 | /* 1860 */ 155, 156, 263, 263, 26, 246, 13, 201, 193, 193, |
| 157972 | /* 1870 */ 6, 262, 204, 210, 219, 210, 210, 190, 190, 190, | 158981 | /* 1870 */ 6, 191, 191, 205, 191, 220, 220, 205, 211, 277, |
| 157973 | /* 1880 */ 210, 219, 204, 211, 211, 210, 4, 3, 22, 162, | 158982 | /* 1880 */ 211, 211, 211, 205, 4, 212, 3, 22, 162, 212, |
| 157974 | /* 1890 */ 15, 23, 16, 23, 204, 138, 129, 150, 26, 141, | 158983 | /* 1890 */ 211, 15, 23, 16, 23, 138, 129, 150, 26, 24, |
| 157975 | /* 1900 */ 20, 24, 143, 16, 1, 141, 129, 129, 61, 53, | 158984 | /* 1900 */ 141, 20, 16, 143, 1, 141, 129, 129, 61, 301, |
| 157976 | /* 1910 */ 37, 150, 297, 300, 300, 53, 53, 129, 53, 115, | 158985 | /* 1910 */ 301, 298, 150, 53, 53, 37, 53, 129, 115, 53, |
| 157977 | /* 1920 */ 34, 140, 1, 5, 22, 114, 68, 26, 160, 68, | 158986 | /* 1920 */ 140, 34, 1, 5, 22, 114, 68, 26, 160, 75, |
| 157978 | /* 1930 */ 75, 41, 140, 114, 24, 20, 19, 130, 124, 23, | 158987 | /* 1930 */ 68, 41, 140, 114, 24, 20, 19, 130, 124, 23, |
| 157979 | /* 1940 */ 96, 22, 22, 37, 22, 67, 22, 59, 67, 24, | 158988 | /* 1940 */ 67, 22, 22, 59, 22, 22, 67, 96, 24, 22, |
| 157980 | /* 1950 */ 22, 28, 67, 23, 148, 22, 97, 23, 23, 23, | 158989 | /* 1950 */ 37, 23, 67, 28, 148, 22, 26, 23, 23, 23, |
| 157981 | /* 1960 */ 140, 23, 22, 26, 23, 23, 115, 22, 142, 26, | 158990 | /* 1960 */ 23, 22, 140, 23, 97, 23, 34, 115, 22, 142, |
| 157982 | /* 1970 */ 75, 88, 75, 34, 23, 86, 44, 22, 34, 26, | 158991 | /* 1970 */ 26, 75, 34, 44, 75, 34, 88, 34, 86, 34, |
| 157983 | /* 1980 */ 34, 34, 34, 34, 93, 24, 26, 23, 34, 23, | 158992 | /* 1980 */ 23, 34, 93, 22, 24, 26, 34, 23, 26, 23, |
| 157984 | /* 1990 */ 23, 23, 23, 11, 23, 22, 26, 22, 22, 15, | 158993 | /* 1990 */ 23, 23, 23, 11, 23, 22, 26, 22, 22, 140, |
| 157985 | /* 2000 */ 23, 23, 22, 22, 1, 26, 23, 140, 134, 140, | 158994 | /* 2000 */ 23, 23, 22, 22, 134, 26, 23, 15, 140, 1, |
| 157986 | /* 2010 */ 1, 140, 316, 316, 316, 316, 316, 316, 316, 140, | 158995 | /* 2010 */ 1, 317, 317, 317, 140, 317, 317, 317, 317, 317, |
| 157987 | /* 2020 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 158996 | /* 2020 */ 317, 317, 140, 317, 317, 317, 317, 317, 317, 317, |
| 157988 | /* 2030 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 158997 | /* 2030 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 157989 | /* 2040 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 158998 | /* 2040 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 157990 | /* 2050 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 158999 | /* 2050 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 157991 | /* 2060 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159000 | /* 2060 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 157992 | /* 2070 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159001 | /* 2070 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 157993 | /* 2080 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159002 | /* 2080 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 157994 | /* 2090 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159003 | /* 2090 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 157995 | /* 2100 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159004 | /* 2100 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 157996 | /* 2110 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159005 | /* 2110 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 157997 | /* 2120 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159006 | /* 2120 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 157998 | /* 2130 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159007 | /* 2130 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 157999 | /* 2140 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159008 | /* 2140 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158000 | /* 2150 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159009 | /* 2150 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158001 | /* 2160 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159010 | /* 2160 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158002 | /* 2170 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159011 | /* 2170 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158003 | /* 2180 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159012 | /* 2180 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158004 | /* 2190 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | 159013 | /* 2190 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158005 | /* 2200 */ 316, 316, 316, | 159014 | /* 2200 */ 317, 317, 317, 317, 317, 317, 317, |
| 158006 | }; | 159015 | }; |
| 158007 | #define YY_SHIFT_COUNT (569) | 159016 | #define YY_SHIFT_COUNT (569) |
| 158008 | #define YY_SHIFT_MIN (0) | 159017 | #define YY_SHIFT_MIN (0) |
| 158009 | #define YY_SHIFT_MAX (2009) | 159018 | #define YY_SHIFT_MAX (2009) |
| 158010 | static const unsigned short int yy_shift_ofst[] = { | 159019 | static const unsigned short int yy_shift_ofst[] = { |
| 158011 | /* 0 */ 1423, 1409, 1454, 1192, 1192, 36, 1252, 1410, 1517, 1684, | 159020 | /* 0 */ 1423, 1409, 1454, 1192, 1192, 382, 1252, 1410, 1517, 1684, |
| 158012 | /* 10 */ 1684, 1684, 292, 0, 0, 180, 1015, 1684, 1684, 1684, | 159021 | /* 10 */ 1684, 1684, 221, 0, 0, 180, 1015, 1684, 1684, 1684, |
| 158013 | /* 20 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, | 159022 | /* 20 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 158014 | /* 30 */ 1049, 1049, 1121, 1121, 54, 400, 36, 36, 36, 36, | 159023 | /* 30 */ 1049, 1049, 1121, 1121, 54, 616, 382, 382, 382, 382, |
| 158015 | /* 40 */ 36, 40, 110, 219, 289, 396, 439, 509, 548, 618, | 159024 | /* 40 */ 382, 40, 110, 219, 289, 396, 439, 509, 548, 618, |
| 158016 | /* 50 */ 657, 727, 766, 836, 995, 1015, 1015, 1015, 1015, 1015, | 159025 | /* 50 */ 657, 727, 766, 836, 995, 1015, 1015, 1015, 1015, 1015, |
| 158017 | /* 60 */ 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, | 159026 | /* 60 */ 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, |
| 158018 | /* 70 */ 1015, 1015, 1015, 1035, 1015, 1138, 880, 880, 1577, 1684, | 159027 | /* 70 */ 1015, 1015, 1015, 1035, 1015, 1138, 880, 880, 1577, 1684, |
| @@ -158021,96 +159030,96 @@ static const unsigned short int yy_shift_ofst[] = { | |||
| 158021 | /* 100 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, | 159030 | /* 100 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 158022 | /* 110 */ 1684, 1684, 1684, 1705, 1684, 1684, 1684, 1684, 1684, 1684, | 159031 | /* 110 */ 1684, 1684, 1684, 1705, 1684, 1684, 1684, 1684, 1684, 1684, |
| 158023 | /* 120 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 146, 84, 84, | 159032 | /* 120 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 146, 84, 84, |
| 158024 | /* 130 */ 84, 84, 84, 362, 269, 125, 97, 453, 66, 66, | 159033 | /* 130 */ 84, 84, 84, 274, 315, 125, 97, 357, 66, 66, |
| 158025 | /* 140 */ 893, 1090, 66, 66, 533, 533, 66, 554, 554, 554, | 159034 | /* 140 */ 893, 258, 66, 66, 371, 371, 66, 551, 551, 551, |
| 158026 | /* 150 */ 554, 192, 587, 587, 695, 25, 2020, 2020, 290, 290, | 159035 | /* 150 */ 551, 192, 209, 209, 278, 127, 2023, 2023, 621, 621, |
| 158027 | /* 160 */ 290, 200, 514, 514, 514, 514, 939, 939, 442, 875, | 159036 | /* 160 */ 621, 201, 398, 398, 398, 398, 939, 939, 442, 936, |
| 158028 | /* 170 */ 935, 66, 66, 66, 66, 66, 66, 66, 66, 66, | 159037 | /* 170 */ 1009, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 158029 | /* 180 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, | 159038 | /* 180 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 158030 | /* 190 */ 66, 601, 601, 66, 729, 878, 878, 1266, 1266, 552, | 159039 | /* 190 */ 66, 710, 710, 66, 776, 435, 435, 410, 410, 372, |
| 158031 | /* 200 */ 1023, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 307, 490, | 159040 | /* 200 */ 1097, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 250, 490, |
| 158032 | /* 210 */ 490, 567, 393, 517, 467, 672, 242, 682, 675, 66, | 159041 | /* 210 */ 490, 511, 451, 516, 252, 566, 575, 781, 673, 66, |
| 158033 | /* 220 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 616, | 159042 | /* 220 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 722, |
| 158034 | /* 230 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, | 159043 | /* 230 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 158035 | /* 240 */ 66, 66, 1093, 1093, 1093, 66, 66, 66, 778, 66, | 159044 | /* 240 */ 66, 66, 790, 790, 790, 66, 66, 66, 883, 66, |
| 158036 | /* 250 */ 66, 66, 1053, 1064, 66, 66, 1190, 66, 66, 66, | 159045 | /* 250 */ 66, 66, 891, 1064, 66, 66, 1212, 66, 66, 66, |
| 158037 | /* 260 */ 66, 66, 66, 66, 66, 722, 992, 718, 253, 253, | 159046 | /* 260 */ 66, 66, 66, 66, 66, 725, 763, 177, 940, 940, |
| 158038 | /* 270 */ 253, 253, 338, 718, 718, 888, 403, 852, 1328, 254, | 159047 | /* 270 */ 940, 940, 337, 177, 177, 1028, 1053, 670, 1264, 1179, |
| 158039 | /* 280 */ 1295, 721, 1330, 1295, 1330, 1370, 234, 254, 254, 234, | 159048 | /* 280 */ 1173, 1254, 1316, 1173, 1316, 1336, 50, 1179, 1179, 50, |
| 158040 | /* 290 */ 254, 721, 1370, 1357, 1492, 1348, 385, 385, 385, 1330, | 159049 | /* 290 */ 1179, 1254, 1336, 1259, 732, 532, 1347, 1347, 1347, 1316, |
| 158041 | /* 300 */ 1425, 1425, 643, 1315, 1336, 1004, 1651, 1651, 1581, 1581, | 159050 | /* 300 */ 1236, 1236, 1184, 1356, 1167, 898, 1650, 1650, 1572, 1572, |
| 158042 | /* 310 */ 1674, 1674, 1581, 1576, 1579, 1716, 1696, 1724, 1724, 1724, | 159051 | /* 310 */ 1685, 1685, 1572, 1576, 1579, 1712, 1692, 1722, 1722, 1722, |
| 158043 | /* 320 */ 1724, 1581, 1732, 1606, 1579, 1579, 1606, 1716, 1696, 1606, | 159052 | /* 320 */ 1722, 1572, 1732, 1604, 1579, 1579, 1604, 1712, 1692, 1604, |
| 158044 | /* 330 */ 1696, 1606, 1581, 1732, 1608, 1706, 1581, 1732, 1750, 1581, | 159053 | /* 330 */ 1692, 1604, 1572, 1732, 1610, 1707, 1572, 1732, 1751, 1572, |
| 158045 | /* 340 */ 1732, 1581, 1732, 1750, 1660, 1660, 1660, 1711, 1766, 1766, | 159054 | /* 340 */ 1732, 1572, 1732, 1751, 1665, 1665, 1665, 1723, 1766, 1766, |
| 158046 | /* 350 */ 1750, 1660, 1664, 1660, 1711, 1660, 1660, 1628, 1769, 1683, | 159055 | /* 350 */ 1751, 1665, 1664, 1665, 1723, 1665, 1665, 1629, 1772, 1698, |
| 158047 | /* 360 */ 1683, 1750, 1653, 1709, 1653, 1709, 1653, 1709, 1653, 1709, | 159056 | /* 360 */ 1698, 1751, 1674, 1709, 1674, 1709, 1674, 1709, 1674, 1709, |
| 158048 | /* 370 */ 1581, 1735, 1735, 1746, 1746, 1682, 1686, 1809, 1581, 1685, | 159057 | /* 370 */ 1572, 1736, 1736, 1746, 1746, 1682, 1686, 1810, 1572, 1688, |
| 158049 | /* 380 */ 1682, 1697, 1699, 1606, 1821, 1825, 1840, 1840, 1864, 1864, | 159058 | /* 380 */ 1682, 1695, 1697, 1604, 1821, 1838, 1853, 1853, 1864, 1864, |
| 158050 | /* 390 */ 1864, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, | 159059 | /* 390 */ 1864, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, |
| 158051 | /* 400 */ 2020, 2020, 2020, 2020, 2020, 2020, 599, 223, 1193, 1299, | 159060 | /* 400 */ 2023, 2023, 2023, 2023, 2023, 2023, 232, 101, 1131, 1193, |
| 158052 | /* 410 */ 228, 780, 958, 1505, 1153, 1435, 1368, 1426, 1430, 1552, | 159061 | /* 410 */ 619, 679, 841, 1421, 1286, 115, 1352, 1334, 1361, 1419, |
| 158053 | /* 420 */ 1477, 1556, 1557, 1564, 1572, 1578, 1580, 1489, 1474, 1602, | 159062 | /* 420 */ 1342, 1505, 1531, 1585, 1593, 1605, 1612, 1280, 1337, 1491, |
| 158054 | /* 430 */ 1389, 1514, 1500, 1595, 1596, 1484, 1603, 1075, 1460, 1605, | 159063 | /* 430 */ 1358, 1451, 1332, 1616, 1617, 1425, 1618, 1386, 1431, 1624, |
| 158055 | /* 440 */ 1612, 1526, 1507, 1882, 1884, 1866, 1727, 1875, 1876, 1868, | 159064 | /* 440 */ 1626, 1399, 1460, 1880, 1883, 1865, 1726, 1876, 1877, 1869, |
| 158056 | /* 450 */ 1870, 1757, 1747, 1767, 1872, 1872, 1877, 1758, 1880, 1759, | 159065 | /* 450 */ 1871, 1757, 1747, 1767, 1872, 1872, 1875, 1759, 1881, 1760, |
| 158057 | /* 460 */ 1887, 1903, 1764, 1777, 1872, 1778, 1847, 1873, 1872, 1761, | 159066 | /* 460 */ 1886, 1903, 1764, 1777, 1872, 1778, 1847, 1878, 1872, 1762, |
| 158058 | /* 470 */ 1856, 1862, 1863, 1865, 1788, 1804, 1886, 1781, 1921, 1918, | 159067 | /* 470 */ 1860, 1861, 1863, 1866, 1788, 1803, 1887, 1780, 1921, 1918, |
| 158059 | /* 480 */ 1902, 1811, 1768, 1858, 1901, 1861, 1855, 1890, 1792, 1819, | 159068 | /* 480 */ 1902, 1811, 1768, 1858, 1901, 1862, 1854, 1890, 1792, 1819, |
| 158060 | /* 490 */ 1910, 1915, 1917, 1807, 1814, 1919, 1878, 1920, 1922, 1916, | 159069 | /* 490 */ 1910, 1915, 1917, 1807, 1814, 1919, 1873, 1920, 1922, 1916, |
| 158061 | /* 500 */ 1924, 1881, 1888, 1925, 1844, 1923, 1928, 1885, 1906, 1930, | 159070 | /* 500 */ 1923, 1879, 1884, 1924, 1851, 1925, 1927, 1885, 1913, 1928, |
| 158062 | /* 510 */ 1806, 1933, 1934, 1935, 1936, 1937, 1938, 1940, 1859, 1820, | 159071 | /* 510 */ 1806, 1933, 1934, 1935, 1936, 1930, 1937, 1939, 1867, 1822, |
| 158063 | /* 520 */ 1941, 1942, 1851, 1939, 1945, 1826, 1943, 1944, 1946, 1947, | 159072 | /* 520 */ 1940, 1942, 1852, 1932, 1946, 1827, 1944, 1938, 1941, 1943, |
| 158064 | /* 530 */ 1948, 1883, 1895, 1889, 1932, 1897, 1891, 1949, 1951, 1955, | 159073 | /* 530 */ 1945, 1888, 1896, 1892, 1929, 1899, 1889, 1947, 1957, 1961, |
| 158065 | /* 540 */ 1961, 1953, 1960, 1954, 1964, 1943, 1966, 1967, 1968, 1969, | 159074 | /* 540 */ 1960, 1959, 1962, 1952, 1964, 1944, 1966, 1967, 1968, 1969, |
| 158066 | /* 550 */ 1970, 1971, 1973, 1982, 1975, 1976, 1977, 1978, 1980, 1981, | 159075 | /* 550 */ 1970, 1971, 1973, 1982, 1975, 1976, 1977, 1978, 1980, 1981, |
| 158067 | /* 560 */ 1979, 1874, 1867, 1869, 1871, 1879, 1983, 1984, 2003, 2009, | 159076 | /* 560 */ 1979, 1870, 1859, 1868, 1874, 1882, 1983, 1992, 2008, 2009, |
| 158068 | }; | 159077 | }; |
| 158069 | #define YY_REDUCE_COUNT (405) | 159078 | #define YY_REDUCE_COUNT (405) |
| 158070 | #define YY_REDUCE_MIN (-265) | 159079 | #define YY_REDUCE_MIN (-266) |
| 158071 | #define YY_REDUCE_MAX (1690) | 159080 | #define YY_REDUCE_MAX (1683) |
| 158072 | static const short yy_reduce_ofst[] = { | 159081 | static const short yy_reduce_ofst[] = { |
| 158073 | /* 0 */ 111, 168, 386, 761, -176, -174, -191, -189, -181, -178, | 159082 | /* 0 */ 111, 168, 272, 760, -177, -175, -192, -190, -182, -179, |
| 158074 | /* 10 */ 176, 263, 44, -207, -204, -265, -139, -114, 158, 504, | 159083 | /* 10 */ 216, 220, 481, -208, -205, -266, -140, -115, 241, 393, |
| 158075 | /* 20 */ 525, 544, 612, 614, 650, 652, 765, 265, 703, 705, | 159084 | /* 20 */ 523, 325, 612, 632, 542, 651, 764, 757, 702, 762, |
| 158076 | /* 30 */ 70, 714, -187, 127, 774, 713, 767, 769, 970, 1019, | 159085 | /* 30 */ 812, 814, -188, 273, 924, 386, 758, 967, 1020, 1052, |
| 158077 | /* 40 */ 1021, -255, -255, -255, -255, -255, -255, -255, -255, -255, | 159086 | /* 40 */ 1066, -256, -256, -256, -256, -256, -256, -256, -256, -256, |
| 158078 | /* 50 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, | 159087 | /* 50 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256, |
| 158079 | /* 60 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, | 159088 | /* 60 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256, |
| 158080 | /* 70 */ -255, -255, -255, -255, -255, -255, -255, -255, 394, 542, | 159089 | /* 70 */ -256, -256, -256, -256, -256, -256, -256, -256, 195, 222, |
| 158081 | /* 80 */ 816, 818, 842, 882, 902, 919, 938, 940, 957, 986, | 159090 | /* 80 */ 813, 917, 920, 959, 985, 1006, 1038, 1067, 1069, 1072, |
| 158082 | /* 90 */ 1048, 1063, 1068, 1073, 1076, 1088, 1100, 1102, 1104, 1106, | 159091 | /* 90 */ 1099, 1103, 1105, 1118, 1135, 1139, 1142, 1146, 1148, 1159, |
| 158083 | /* 100 */ 1113, 1119, 1137, 1140, 1143, 1147, 1149, 1164, 1173, 1183, | 159092 | /* 100 */ 1174, 1178, 1183, 1185, 1187, 1198, 1202, 1246, 1258, 1260, |
| 158084 | /* 110 */ 1185, 1188, 1202, 1204, 1247, 1259, 1263, 1283, 1289, 1292, | 159093 | /* 110 */ 1262, 1288, 1291, 1299, 1304, 1319, 1328, 1330, 1357, 1359, |
| 158085 | /* 120 */ 1298, 1300, 1329, 1331, 1343, 1358, 1360, -255, -255, -255, | 159094 | /* 120 */ 1364, 1366, 1375, 1390, 1395, 1406, 1411, -256, -256, -256, |
| 158086 | /* 130 */ -255, -255, -255, -255, -255, 196, -255, 387, -177, 507, | 159095 | /* 130 */ -256, -256, -256, -256, -256, 447, -256, 555, -178, 605, |
| 158087 | /* 140 */ 1002, -219, 557, -93, -167, 638, -121, 284, 500, 284, | 159096 | /* 140 */ 832, -220, 606, -94, -168, 36, -122, 730, 780, 730, |
| 158088 | /* 150 */ 500, 247, 651, 865, -255, -255, -255, -255, -85, -85, | 159097 | /* 150 */ 780, 918, -136, 338, -256, -256, -256, -256, 80, 80, |
| 158089 | /* 160 */ -85, 237, 171, 602, 846, 885, -212, -203, 217, 380, | 159098 | /* 160 */ 80, 720, 703, 811, 882, 903, -213, -204, 106, 330, |
| 158090 | /* 170 */ 380, -23, 161, 653, 712, 773, 943, 990, 1040, 563, | 159099 | /* 170 */ 330, -77, 236, 320, 599, 67, 457, 675, 729, 395, |
| 158091 | /* 180 */ 833, 971, 1005, 1042, 1092, 1078, 1043, 1144, 1184, -186, | 159100 | /* 180 */ 268, 611, 969, 1004, 726, 1014, 983, 123, 884, 608, |
| 158092 | /* 190 */ 1105, 318, 869, 7, 825, 920, 1074, 704, 706, 390, | 159101 | /* 190 */ 1034, 547, 911, 650, 844, 922, 949, 965, 972, 978, |
| 158093 | /* 200 */ 1087, 1094, 336, 545, 772, 1201, 1117, 1207, -179, -137, | 159102 | /* 200 */ 449, 970, 718, 784, 1073, 1084, 1023, 1129, -209, -180, |
| 158094 | /* 210 */ -112, -13, 18, 112, 197, 418, 495, 508, 777, 809, | 159103 | /* 210 */ -113, 114, 183, 329, 345, 391, 446, 502, 609, 667, |
| 158095 | /* 220 */ 923, 1014, 1027, 1033, 1044, 1115, 1194, 1212, 1221, 209, | 159104 | /* 220 */ 713, 817, 865, 881, 901, 921, 989, 1191, 1195, 214, |
| 158096 | /* 230 */ 1236, 1240, 1256, 1287, 1301, 1307, 1349, 1359, 1398, 1417, | 159105 | /* 230 */ 1223, 1235, 1251, 1367, 1376, 1377, 1383, 1385, 1401, 1402, |
| 158097 | /* 240 */ 1429, 1434, 681, 1377, 1404, 1448, 1449, 1450, 1388, 1453, | 159106 | /* 240 */ 1403, 1414, 584, 638, 1305, 1420, 1422, 1426, 1294, 1430, |
| 158098 | /* 250 */ 1455, 1458, 1393, 1335, 1461, 1462, 1418, 1463, 197, 1464, | 159107 | /* 250 */ 1435, 1437, 1348, 1329, 1459, 1461, 1412, 1462, 345, 1463, |
| 158099 | /* 260 */ 1465, 1466, 1467, 1468, 1469, 1376, 1378, 1424, 1412, 1413, | 159108 | /* 260 */ 1464, 1465, 1466, 1467, 1468, 1378, 1380, 1427, 1408, 1413, |
| 158100 | /* 270 */ 1414, 1415, 1388, 1424, 1424, 1428, 1470, 1485, 1381, 1408, | 159109 | /* 270 */ 1415, 1428, 1294, 1427, 1427, 1433, 1450, 1473, 1381, 1417, |
| 158101 | /* 280 */ 1416, 1436, 1431, 1422, 1432, 1392, 1446, 1411, 1427, 1456, | 159110 | /* 280 */ 1424, 1432, 1434, 1436, 1438, 1387, 1443, 1429, 1439, 1444, |
| 158102 | /* 290 */ 1433, 1471, 1401, 1479, 1472, 1478, 1486, 1491, 1493, 1452, | 159111 | /* 290 */ 1440, 1453, 1388, 1481, 1455, 1457, 1483, 1485, 1488, 1456, |
| 158103 | /* 300 */ 1459, 1473, 1437, 1475, 1476, 1516, 1421, 1440, 1520, 1524, | 159112 | /* 300 */ 1469, 1470, 1441, 1471, 1474, 1512, 1416, 1442, 1519, 1522, |
| 158104 | /* 310 */ 1444, 1445, 1525, 1457, 1480, 1481, 1509, 1510, 1511, 1512, | 159113 | /* 310 */ 1446, 1447, 1523, 1472, 1475, 1476, 1504, 1507, 1511, 1513, |
| 158105 | /* 320 */ 1513, 1553, 1555, 1515, 1487, 1488, 1518, 1495, 1522, 1523, | 159114 | /* 320 */ 1514, 1548, 1553, 1510, 1486, 1487, 1515, 1490, 1528, 1518, |
| 158106 | /* 330 */ 1528, 1527, 1562, 1566, 1482, 1494, 1569, 1574, 1559, 1575, | 159115 | /* 330 */ 1529, 1521, 1564, 1568, 1480, 1484, 1571, 1574, 1555, 1578, |
| 158107 | /* 340 */ 1582, 1583, 1585, 1560, 1568, 1570, 1571, 1563, 1573, 1586, | 159116 | /* 340 */ 1580, 1581, 1583, 1556, 1566, 1567, 1569, 1561, 1570, 1573, |
| 158108 | /* 350 */ 1584, 1588, 1589, 1593, 1590, 1594, 1598, 1501, 1496, 1536, | 159117 | /* 350 */ 1575, 1582, 1584, 1587, 1588, 1590, 1591, 1498, 1506, 1534, |
| 158109 | /* 360 */ 1537, 1599, 1561, 1567, 1587, 1591, 1592, 1597, 1604, 1607, | 159118 | /* 360 */ 1535, 1597, 1560, 1586, 1565, 1589, 1592, 1594, 1595, 1598, |
| 158110 | /* 370 */ 1629, 1519, 1521, 1601, 1609, 1600, 1610, 1558, 1636, 1565, | 159119 | /* 370 */ 1627, 1516, 1520, 1599, 1600, 1601, 1596, 1558, 1635, 1602, |
| 158111 | /* 380 */ 1618, 1621, 1611, 1624, 1648, 1652, 1676, 1677, 1687, 1688, | 159120 | /* 380 */ 1607, 1619, 1603, 1606, 1651, 1666, 1675, 1676, 1680, 1681, |
| 158112 | /* 390 */ 1689, 1613, 1614, 1615, 1668, 1663, 1665, 1666, 1670, 1678, | 159121 | /* 390 */ 1683, 1608, 1609, 1613, 1668, 1667, 1669, 1670, 1671, 1672, |
| 158113 | /* 400 */ 1655, 1662, 1672, 1673, 1675, 1690, | 159122 | /* 400 */ 1655, 1656, 1673, 1677, 1679, 1678, |
| 158114 | }; | 159123 | }; |
| 158115 | static const YYACTIONTYPE yy_default[] = { | 159124 | static const YYACTIONTYPE yy_default[] = { |
| 158116 | /* 0 */ 1623, 1623, 1623, 1453, 1223, 1332, 1223, 1223, 1223, 1453, | 159125 | /* 0 */ 1623, 1623, 1623, 1453, 1223, 1332, 1223, 1223, 1223, 1453, |
| @@ -158370,6 +159379,7 @@ static const YYCODETYPE yyFallback[] = { | |||
| 158370 | 0, /* IF_NULL_ROW => nothing */ | 159379 | 0, /* IF_NULL_ROW => nothing */ |
| 158371 | 0, /* ASTERISK => nothing */ | 159380 | 0, /* ASTERISK => nothing */ |
| 158372 | 0, /* SPAN => nothing */ | 159381 | 0, /* SPAN => nothing */ |
| 159382 | 0, /* ERROR => nothing */ | ||
| 158373 | 0, /* SPACE => nothing */ | 159383 | 0, /* SPACE => nothing */ |
| 158374 | 0, /* ILLEGAL => nothing */ | 159384 | 0, /* ILLEGAL => nothing */ |
| 158375 | }; | 159385 | }; |
| @@ -158641,141 +159651,142 @@ static const char *const yyTokenName[] = { | |||
| 158641 | /* 178 */ "IF_NULL_ROW", | 159651 | /* 178 */ "IF_NULL_ROW", |
| 158642 | /* 179 */ "ASTERISK", | 159652 | /* 179 */ "ASTERISK", |
| 158643 | /* 180 */ "SPAN", | 159653 | /* 180 */ "SPAN", |
| 158644 | /* 181 */ "SPACE", | 159654 | /* 181 */ "ERROR", |
| 158645 | /* 182 */ "ILLEGAL", | 159655 | /* 182 */ "SPACE", |
| 158646 | /* 183 */ "input", | 159656 | /* 183 */ "ILLEGAL", |
| 158647 | /* 184 */ "cmdlist", | 159657 | /* 184 */ "input", |
| 158648 | /* 185 */ "ecmd", | 159658 | /* 185 */ "cmdlist", |
| 158649 | /* 186 */ "cmdx", | 159659 | /* 186 */ "ecmd", |
| 158650 | /* 187 */ "explain", | 159660 | /* 187 */ "cmdx", |
| 158651 | /* 188 */ "cmd", | 159661 | /* 188 */ "explain", |
| 158652 | /* 189 */ "transtype", | 159662 | /* 189 */ "cmd", |
| 158653 | /* 190 */ "trans_opt", | 159663 | /* 190 */ "transtype", |
| 158654 | /* 191 */ "nm", | 159664 | /* 191 */ "trans_opt", |
| 158655 | /* 192 */ "savepoint_opt", | 159665 | /* 192 */ "nm", |
| 158656 | /* 193 */ "create_table", | 159666 | /* 193 */ "savepoint_opt", |
| 158657 | /* 194 */ "create_table_args", | 159667 | /* 194 */ "create_table", |
| 158658 | /* 195 */ "createkw", | 159668 | /* 195 */ "create_table_args", |
| 158659 | /* 196 */ "temp", | 159669 | /* 196 */ "createkw", |
| 158660 | /* 197 */ "ifnotexists", | 159670 | /* 197 */ "temp", |
| 158661 | /* 198 */ "dbnm", | 159671 | /* 198 */ "ifnotexists", |
| 158662 | /* 199 */ "columnlist", | 159672 | /* 199 */ "dbnm", |
| 158663 | /* 200 */ "conslist_opt", | 159673 | /* 200 */ "columnlist", |
| 158664 | /* 201 */ "table_options", | 159674 | /* 201 */ "conslist_opt", |
| 158665 | /* 202 */ "select", | 159675 | /* 202 */ "table_options", |
| 158666 | /* 203 */ "columnname", | 159676 | /* 203 */ "select", |
| 158667 | /* 204 */ "carglist", | 159677 | /* 204 */ "columnname", |
| 158668 | /* 205 */ "typetoken", | 159678 | /* 205 */ "carglist", |
| 158669 | /* 206 */ "typename", | 159679 | /* 206 */ "typetoken", |
| 158670 | /* 207 */ "signed", | 159680 | /* 207 */ "typename", |
| 158671 | /* 208 */ "plus_num", | 159681 | /* 208 */ "signed", |
| 158672 | /* 209 */ "minus_num", | 159682 | /* 209 */ "plus_num", |
| 158673 | /* 210 */ "scanpt", | 159683 | /* 210 */ "minus_num", |
| 158674 | /* 211 */ "scantok", | 159684 | /* 211 */ "scanpt", |
| 158675 | /* 212 */ "ccons", | 159685 | /* 212 */ "scantok", |
| 158676 | /* 213 */ "term", | 159686 | /* 213 */ "ccons", |
| 158677 | /* 214 */ "expr", | 159687 | /* 214 */ "term", |
| 158678 | /* 215 */ "onconf", | 159688 | /* 215 */ "expr", |
| 158679 | /* 216 */ "sortorder", | 159689 | /* 216 */ "onconf", |
| 158680 | /* 217 */ "autoinc", | 159690 | /* 217 */ "sortorder", |
| 158681 | /* 218 */ "eidlist_opt", | 159691 | /* 218 */ "autoinc", |
| 158682 | /* 219 */ "refargs", | 159692 | /* 219 */ "eidlist_opt", |
| 158683 | /* 220 */ "defer_subclause", | 159693 | /* 220 */ "refargs", |
| 158684 | /* 221 */ "generated", | 159694 | /* 221 */ "defer_subclause", |
| 158685 | /* 222 */ "refarg", | 159695 | /* 222 */ "generated", |
| 158686 | /* 223 */ "refact", | 159696 | /* 223 */ "refarg", |
| 158687 | /* 224 */ "init_deferred_pred_opt", | 159697 | /* 224 */ "refact", |
| 158688 | /* 225 */ "conslist", | 159698 | /* 225 */ "init_deferred_pred_opt", |
| 158689 | /* 226 */ "tconscomma", | 159699 | /* 226 */ "conslist", |
| 158690 | /* 227 */ "tcons", | 159700 | /* 227 */ "tconscomma", |
| 158691 | /* 228 */ "sortlist", | 159701 | /* 228 */ "tcons", |
| 158692 | /* 229 */ "eidlist", | 159702 | /* 229 */ "sortlist", |
| 158693 | /* 230 */ "defer_subclause_opt", | 159703 | /* 230 */ "eidlist", |
| 158694 | /* 231 */ "orconf", | 159704 | /* 231 */ "defer_subclause_opt", |
| 158695 | /* 232 */ "resolvetype", | 159705 | /* 232 */ "orconf", |
| 158696 | /* 233 */ "raisetype", | 159706 | /* 233 */ "resolvetype", |
| 158697 | /* 234 */ "ifexists", | 159707 | /* 234 */ "raisetype", |
| 158698 | /* 235 */ "fullname", | 159708 | /* 235 */ "ifexists", |
| 158699 | /* 236 */ "selectnowith", | 159709 | /* 236 */ "fullname", |
| 158700 | /* 237 */ "oneselect", | 159710 | /* 237 */ "selectnowith", |
| 158701 | /* 238 */ "wqlist", | 159711 | /* 238 */ "oneselect", |
| 158702 | /* 239 */ "multiselect_op", | 159712 | /* 239 */ "wqlist", |
| 158703 | /* 240 */ "distinct", | 159713 | /* 240 */ "multiselect_op", |
| 158704 | /* 241 */ "selcollist", | 159714 | /* 241 */ "distinct", |
| 158705 | /* 242 */ "from", | 159715 | /* 242 */ "selcollist", |
| 158706 | /* 243 */ "where_opt", | 159716 | /* 243 */ "from", |
| 158707 | /* 244 */ "groupby_opt", | 159717 | /* 244 */ "where_opt", |
| 158708 | /* 245 */ "having_opt", | 159718 | /* 245 */ "groupby_opt", |
| 158709 | /* 246 */ "orderby_opt", | 159719 | /* 246 */ "having_opt", |
| 158710 | /* 247 */ "limit_opt", | 159720 | /* 247 */ "orderby_opt", |
| 158711 | /* 248 */ "window_clause", | 159721 | /* 248 */ "limit_opt", |
| 158712 | /* 249 */ "values", | 159722 | /* 249 */ "window_clause", |
| 158713 | /* 250 */ "nexprlist", | 159723 | /* 250 */ "values", |
| 158714 | /* 251 */ "sclp", | 159724 | /* 251 */ "nexprlist", |
| 158715 | /* 252 */ "as", | 159725 | /* 252 */ "sclp", |
| 158716 | /* 253 */ "seltablist", | 159726 | /* 253 */ "as", |
| 158717 | /* 254 */ "stl_prefix", | 159727 | /* 254 */ "seltablist", |
| 158718 | /* 255 */ "joinop", | 159728 | /* 255 */ "stl_prefix", |
| 158719 | /* 256 */ "indexed_opt", | 159729 | /* 256 */ "joinop", |
| 158720 | /* 257 */ "on_opt", | 159730 | /* 257 */ "indexed_opt", |
| 158721 | /* 258 */ "using_opt", | 159731 | /* 258 */ "on_opt", |
| 158722 | /* 259 */ "exprlist", | 159732 | /* 259 */ "using_opt", |
| 158723 | /* 260 */ "xfullname", | 159733 | /* 260 */ "exprlist", |
| 158724 | /* 261 */ "idlist", | 159734 | /* 261 */ "xfullname", |
| 158725 | /* 262 */ "nulls", | 159735 | /* 262 */ "idlist", |
| 158726 | /* 263 */ "with", | 159736 | /* 263 */ "nulls", |
| 158727 | /* 264 */ "where_opt_ret", | 159737 | /* 264 */ "with", |
| 158728 | /* 265 */ "setlist", | 159738 | /* 265 */ "where_opt_ret", |
| 158729 | /* 266 */ "insert_cmd", | 159739 | /* 266 */ "setlist", |
| 158730 | /* 267 */ "idlist_opt", | 159740 | /* 267 */ "insert_cmd", |
| 158731 | /* 268 */ "upsert", | 159741 | /* 268 */ "idlist_opt", |
| 158732 | /* 269 */ "returning", | 159742 | /* 269 */ "upsert", |
| 158733 | /* 270 */ "filter_over", | 159743 | /* 270 */ "returning", |
| 158734 | /* 271 */ "likeop", | 159744 | /* 271 */ "filter_over", |
| 158735 | /* 272 */ "between_op", | 159745 | /* 272 */ "likeop", |
| 158736 | /* 273 */ "in_op", | 159746 | /* 273 */ "between_op", |
| 158737 | /* 274 */ "paren_exprlist", | 159747 | /* 274 */ "in_op", |
| 158738 | /* 275 */ "case_operand", | 159748 | /* 275 */ "paren_exprlist", |
| 158739 | /* 276 */ "case_exprlist", | 159749 | /* 276 */ "case_operand", |
| 158740 | /* 277 */ "case_else", | 159750 | /* 277 */ "case_exprlist", |
| 158741 | /* 278 */ "uniqueflag", | 159751 | /* 278 */ "case_else", |
| 158742 | /* 279 */ "collate", | 159752 | /* 279 */ "uniqueflag", |
| 158743 | /* 280 */ "vinto", | 159753 | /* 280 */ "collate", |
| 158744 | /* 281 */ "nmnum", | 159754 | /* 281 */ "vinto", |
| 158745 | /* 282 */ "trigger_decl", | 159755 | /* 282 */ "nmnum", |
| 158746 | /* 283 */ "trigger_cmd_list", | 159756 | /* 283 */ "trigger_decl", |
| 158747 | /* 284 */ "trigger_time", | 159757 | /* 284 */ "trigger_cmd_list", |
| 158748 | /* 285 */ "trigger_event", | 159758 | /* 285 */ "trigger_time", |
| 158749 | /* 286 */ "foreach_clause", | 159759 | /* 286 */ "trigger_event", |
| 158750 | /* 287 */ "when_clause", | 159760 | /* 287 */ "foreach_clause", |
| 158751 | /* 288 */ "trigger_cmd", | 159761 | /* 288 */ "when_clause", |
| 158752 | /* 289 */ "trnm", | 159762 | /* 289 */ "trigger_cmd", |
| 158753 | /* 290 */ "tridxby", | 159763 | /* 290 */ "trnm", |
| 158754 | /* 291 */ "database_kw_opt", | 159764 | /* 291 */ "tridxby", |
| 158755 | /* 292 */ "key_opt", | 159765 | /* 292 */ "database_kw_opt", |
| 158756 | /* 293 */ "add_column_fullname", | 159766 | /* 293 */ "key_opt", |
| 158757 | /* 294 */ "kwcolumn_opt", | 159767 | /* 294 */ "add_column_fullname", |
| 158758 | /* 295 */ "create_vtab", | 159768 | /* 295 */ "kwcolumn_opt", |
| 158759 | /* 296 */ "vtabarglist", | 159769 | /* 296 */ "create_vtab", |
| 158760 | /* 297 */ "vtabarg", | 159770 | /* 297 */ "vtabarglist", |
| 158761 | /* 298 */ "vtabargtoken", | 159771 | /* 298 */ "vtabarg", |
| 158762 | /* 299 */ "lp", | 159772 | /* 299 */ "vtabargtoken", |
| 158763 | /* 300 */ "anylist", | 159773 | /* 300 */ "lp", |
| 158764 | /* 301 */ "wqitem", | 159774 | /* 301 */ "anylist", |
| 158765 | /* 302 */ "wqas", | 159775 | /* 302 */ "wqitem", |
| 158766 | /* 303 */ "windowdefn_list", | 159776 | /* 303 */ "wqas", |
| 158767 | /* 304 */ "windowdefn", | 159777 | /* 304 */ "windowdefn_list", |
| 158768 | /* 305 */ "window", | 159778 | /* 305 */ "windowdefn", |
| 158769 | /* 306 */ "frame_opt", | 159779 | /* 306 */ "window", |
| 158770 | /* 307 */ "part_opt", | 159780 | /* 307 */ "frame_opt", |
| 158771 | /* 308 */ "filter_clause", | 159781 | /* 308 */ "part_opt", |
| 158772 | /* 309 */ "over_clause", | 159782 | /* 309 */ "filter_clause", |
| 158773 | /* 310 */ "range_or_rows", | 159783 | /* 310 */ "over_clause", |
| 158774 | /* 311 */ "frame_bound", | 159784 | /* 311 */ "range_or_rows", |
| 158775 | /* 312 */ "frame_bound_s", | 159785 | /* 312 */ "frame_bound", |
| 158776 | /* 313 */ "frame_bound_e", | 159786 | /* 313 */ "frame_bound_s", |
| 158777 | /* 314 */ "frame_exclude_opt", | 159787 | /* 314 */ "frame_bound_e", |
| 158778 | /* 315 */ "frame_exclude", | 159788 | /* 315 */ "frame_exclude_opt", |
| 159789 | /* 316 */ "frame_exclude", | ||
| 158779 | }; | 159790 | }; |
| 158780 | #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ | 159791 | #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ |
| 158781 | 159792 | ||
| @@ -159306,99 +160317,99 @@ static void yy_destructor( | |||
| 159306 | ** inside the C code. | 160317 | ** inside the C code. |
| 159307 | */ | 160318 | */ |
| 159308 | /********* Begin destructor definitions ***************************************/ | 160319 | /********* Begin destructor definitions ***************************************/ |
| 159309 | case 202: /* select */ | 160320 | case 203: /* select */ |
| 159310 | case 236: /* selectnowith */ | 160321 | case 237: /* selectnowith */ |
| 159311 | case 237: /* oneselect */ | 160322 | case 238: /* oneselect */ |
| 159312 | case 249: /* values */ | 160323 | case 250: /* values */ |
| 159313 | { | 160324 | { |
| 159314 | sqlite3SelectDelete(pParse->db, (yypminor->yy307)); | 160325 | sqlite3SelectDelete(pParse->db, (yypminor->yy81)); |
| 159315 | } | 160326 | } |
| 159316 | break; | 160327 | break; |
| 159317 | case 213: /* term */ | 160328 | case 214: /* term */ |
| 159318 | case 214: /* expr */ | 160329 | case 215: /* expr */ |
| 159319 | case 243: /* where_opt */ | 160330 | case 244: /* where_opt */ |
| 159320 | case 245: /* having_opt */ | 160331 | case 246: /* having_opt */ |
| 159321 | case 257: /* on_opt */ | 160332 | case 258: /* on_opt */ |
| 159322 | case 264: /* where_opt_ret */ | 160333 | case 265: /* where_opt_ret */ |
| 159323 | case 275: /* case_operand */ | 160334 | case 276: /* case_operand */ |
| 159324 | case 277: /* case_else */ | 160335 | case 278: /* case_else */ |
| 159325 | case 280: /* vinto */ | 160336 | case 281: /* vinto */ |
| 159326 | case 287: /* when_clause */ | 160337 | case 288: /* when_clause */ |
| 159327 | case 292: /* key_opt */ | 160338 | case 293: /* key_opt */ |
| 159328 | case 308: /* filter_clause */ | 160339 | case 309: /* filter_clause */ |
| 159329 | { | 160340 | { |
| 159330 | sqlite3ExprDelete(pParse->db, (yypminor->yy602)); | 160341 | sqlite3ExprDelete(pParse->db, (yypminor->yy404)); |
| 159331 | } | 160342 | } |
| 159332 | break; | 160343 | break; |
| 159333 | case 218: /* eidlist_opt */ | 160344 | case 219: /* eidlist_opt */ |
| 159334 | case 228: /* sortlist */ | 160345 | case 229: /* sortlist */ |
| 159335 | case 229: /* eidlist */ | 160346 | case 230: /* eidlist */ |
| 159336 | case 241: /* selcollist */ | 160347 | case 242: /* selcollist */ |
| 159337 | case 244: /* groupby_opt */ | 160348 | case 245: /* groupby_opt */ |
| 159338 | case 246: /* orderby_opt */ | 160349 | case 247: /* orderby_opt */ |
| 159339 | case 250: /* nexprlist */ | 160350 | case 251: /* nexprlist */ |
| 159340 | case 251: /* sclp */ | 160351 | case 252: /* sclp */ |
| 159341 | case 259: /* exprlist */ | 160352 | case 260: /* exprlist */ |
| 159342 | case 265: /* setlist */ | 160353 | case 266: /* setlist */ |
| 159343 | case 274: /* paren_exprlist */ | 160354 | case 275: /* paren_exprlist */ |
| 159344 | case 276: /* case_exprlist */ | 160355 | case 277: /* case_exprlist */ |
| 159345 | case 307: /* part_opt */ | 160356 | case 308: /* part_opt */ |
| 159346 | { | 160357 | { |
| 159347 | sqlite3ExprListDelete(pParse->db, (yypminor->yy338)); | 160358 | sqlite3ExprListDelete(pParse->db, (yypminor->yy70)); |
| 159348 | } | 160359 | } |
| 159349 | break; | 160360 | break; |
| 159350 | case 235: /* fullname */ | 160361 | case 236: /* fullname */ |
| 159351 | case 242: /* from */ | 160362 | case 243: /* from */ |
| 159352 | case 253: /* seltablist */ | 160363 | case 254: /* seltablist */ |
| 159353 | case 254: /* stl_prefix */ | 160364 | case 255: /* stl_prefix */ |
| 159354 | case 260: /* xfullname */ | 160365 | case 261: /* xfullname */ |
| 159355 | { | 160366 | { |
| 159356 | sqlite3SrcListDelete(pParse->db, (yypminor->yy291)); | 160367 | sqlite3SrcListDelete(pParse->db, (yypminor->yy153)); |
| 159357 | } | 160368 | } |
| 159358 | break; | 160369 | break; |
| 159359 | case 238: /* wqlist */ | 160370 | case 239: /* wqlist */ |
| 159360 | { | 160371 | { |
| 159361 | sqlite3WithDelete(pParse->db, (yypminor->yy195)); | 160372 | sqlite3WithDelete(pParse->db, (yypminor->yy103)); |
| 159362 | } | 160373 | } |
| 159363 | break; | 160374 | break; |
| 159364 | case 248: /* window_clause */ | 160375 | case 249: /* window_clause */ |
| 159365 | case 303: /* windowdefn_list */ | 160376 | case 304: /* windowdefn_list */ |
| 159366 | { | 160377 | { |
| 159367 | sqlite3WindowListDelete(pParse->db, (yypminor->yy19)); | 160378 | sqlite3WindowListDelete(pParse->db, (yypminor->yy49)); |
| 159368 | } | 160379 | } |
| 159369 | break; | 160380 | break; |
| 159370 | case 258: /* using_opt */ | 160381 | case 259: /* using_opt */ |
| 159371 | case 261: /* idlist */ | 160382 | case 262: /* idlist */ |
| 159372 | case 267: /* idlist_opt */ | 160383 | case 268: /* idlist_opt */ |
| 159373 | { | 160384 | { |
| 159374 | sqlite3IdListDelete(pParse->db, (yypminor->yy288)); | 160385 | sqlite3IdListDelete(pParse->db, (yypminor->yy436)); |
| 159375 | } | 160386 | } |
| 159376 | break; | 160387 | break; |
| 159377 | case 270: /* filter_over */ | 160388 | case 271: /* filter_over */ |
| 159378 | case 304: /* windowdefn */ | 160389 | case 305: /* windowdefn */ |
| 159379 | case 305: /* window */ | 160390 | case 306: /* window */ |
| 159380 | case 306: /* frame_opt */ | 160391 | case 307: /* frame_opt */ |
| 159381 | case 309: /* over_clause */ | 160392 | case 310: /* over_clause */ |
| 159382 | { | 160393 | { |
| 159383 | sqlite3WindowDelete(pParse->db, (yypminor->yy19)); | 160394 | sqlite3WindowDelete(pParse->db, (yypminor->yy49)); |
| 159384 | } | 160395 | } |
| 159385 | break; | 160396 | break; |
| 159386 | case 283: /* trigger_cmd_list */ | 160397 | case 284: /* trigger_cmd_list */ |
| 159387 | case 288: /* trigger_cmd */ | 160398 | case 289: /* trigger_cmd */ |
| 159388 | { | 160399 | { |
| 159389 | sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy483)); | 160400 | sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy157)); |
| 159390 | } | 160401 | } |
| 159391 | break; | 160402 | break; |
| 159392 | case 285: /* trigger_event */ | 160403 | case 286: /* trigger_event */ |
| 159393 | { | 160404 | { |
| 159394 | sqlite3IdListDelete(pParse->db, (yypminor->yy50).b); | 160405 | sqlite3IdListDelete(pParse->db, (yypminor->yy262).b); |
| 159395 | } | 160406 | } |
| 159396 | break; | 160407 | break; |
| 159397 | case 311: /* frame_bound */ | 160408 | case 312: /* frame_bound */ |
| 159398 | case 312: /* frame_bound_s */ | 160409 | case 313: /* frame_bound_s */ |
| 159399 | case 313: /* frame_bound_e */ | 160410 | case 314: /* frame_bound_e */ |
| 159400 | { | 160411 | { |
| 159401 | sqlite3ExprDelete(pParse->db, (yypminor->yy113).pExpr); | 160412 | sqlite3ExprDelete(pParse->db, (yypminor->yy117).pExpr); |
| 159402 | } | 160413 | } |
| 159403 | break; | 160414 | break; |
| 159404 | /********* End destructor definitions *****************************************/ | 160415 | /********* End destructor definitions *****************************************/ |
| @@ -159689,404 +160700,404 @@ static void yy_shift( | |||
| 159689 | /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side | 160700 | /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side |
| 159690 | ** of that rule */ | 160701 | ** of that rule */ |
| 159691 | static const YYCODETYPE yyRuleInfoLhs[] = { | 160702 | static const YYCODETYPE yyRuleInfoLhs[] = { |
| 159692 | 187, /* (0) explain ::= EXPLAIN */ | 160703 | 188, /* (0) explain ::= EXPLAIN */ |
| 159693 | 187, /* (1) explain ::= EXPLAIN QUERY PLAN */ | 160704 | 188, /* (1) explain ::= EXPLAIN QUERY PLAN */ |
| 159694 | 186, /* (2) cmdx ::= cmd */ | 160705 | 187, /* (2) cmdx ::= cmd */ |
| 159695 | 188, /* (3) cmd ::= BEGIN transtype trans_opt */ | 160706 | 189, /* (3) cmd ::= BEGIN transtype trans_opt */ |
| 159696 | 189, /* (4) transtype ::= */ | 160707 | 190, /* (4) transtype ::= */ |
| 159697 | 189, /* (5) transtype ::= DEFERRED */ | 160708 | 190, /* (5) transtype ::= DEFERRED */ |
| 159698 | 189, /* (6) transtype ::= IMMEDIATE */ | 160709 | 190, /* (6) transtype ::= IMMEDIATE */ |
| 159699 | 189, /* (7) transtype ::= EXCLUSIVE */ | 160710 | 190, /* (7) transtype ::= EXCLUSIVE */ |
| 159700 | 188, /* (8) cmd ::= COMMIT|END trans_opt */ | 160711 | 189, /* (8) cmd ::= COMMIT|END trans_opt */ |
| 159701 | 188, /* (9) cmd ::= ROLLBACK trans_opt */ | 160712 | 189, /* (9) cmd ::= ROLLBACK trans_opt */ |
| 159702 | 188, /* (10) cmd ::= SAVEPOINT nm */ | 160713 | 189, /* (10) cmd ::= SAVEPOINT nm */ |
| 159703 | 188, /* (11) cmd ::= RELEASE savepoint_opt nm */ | 160714 | 189, /* (11) cmd ::= RELEASE savepoint_opt nm */ |
| 159704 | 188, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ | 160715 | 189, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ |
| 159705 | 193, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */ | 160716 | 194, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 159706 | 195, /* (14) createkw ::= CREATE */ | 160717 | 196, /* (14) createkw ::= CREATE */ |
| 159707 | 197, /* (15) ifnotexists ::= */ | 160718 | 198, /* (15) ifnotexists ::= */ |
| 159708 | 197, /* (16) ifnotexists ::= IF NOT EXISTS */ | 160719 | 198, /* (16) ifnotexists ::= IF NOT EXISTS */ |
| 159709 | 196, /* (17) temp ::= TEMP */ | 160720 | 197, /* (17) temp ::= TEMP */ |
| 159710 | 196, /* (18) temp ::= */ | 160721 | 197, /* (18) temp ::= */ |
| 159711 | 194, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ | 160722 | 195, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ |
| 159712 | 194, /* (20) create_table_args ::= AS select */ | 160723 | 195, /* (20) create_table_args ::= AS select */ |
| 159713 | 201, /* (21) table_options ::= */ | 160724 | 202, /* (21) table_options ::= */ |
| 159714 | 201, /* (22) table_options ::= WITHOUT nm */ | 160725 | 202, /* (22) table_options ::= WITHOUT nm */ |
| 159715 | 203, /* (23) columnname ::= nm typetoken */ | 160726 | 204, /* (23) columnname ::= nm typetoken */ |
| 159716 | 205, /* (24) typetoken ::= */ | 160727 | 206, /* (24) typetoken ::= */ |
| 159717 | 205, /* (25) typetoken ::= typename LP signed RP */ | 160728 | 206, /* (25) typetoken ::= typename LP signed RP */ |
| 159718 | 205, /* (26) typetoken ::= typename LP signed COMMA signed RP */ | 160729 | 206, /* (26) typetoken ::= typename LP signed COMMA signed RP */ |
| 159719 | 206, /* (27) typename ::= typename ID|STRING */ | 160730 | 207, /* (27) typename ::= typename ID|STRING */ |
| 159720 | 210, /* (28) scanpt ::= */ | 160731 | 211, /* (28) scanpt ::= */ |
| 159721 | 211, /* (29) scantok ::= */ | 160732 | 212, /* (29) scantok ::= */ |
| 159722 | 212, /* (30) ccons ::= CONSTRAINT nm */ | 160733 | 213, /* (30) ccons ::= CONSTRAINT nm */ |
| 159723 | 212, /* (31) ccons ::= DEFAULT scantok term */ | 160734 | 213, /* (31) ccons ::= DEFAULT scantok term */ |
| 159724 | 212, /* (32) ccons ::= DEFAULT LP expr RP */ | 160735 | 213, /* (32) ccons ::= DEFAULT LP expr RP */ |
| 159725 | 212, /* (33) ccons ::= DEFAULT PLUS scantok term */ | 160736 | 213, /* (33) ccons ::= DEFAULT PLUS scantok term */ |
| 159726 | 212, /* (34) ccons ::= DEFAULT MINUS scantok term */ | 160737 | 213, /* (34) ccons ::= DEFAULT MINUS scantok term */ |
| 159727 | 212, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */ | 160738 | 213, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */ |
| 159728 | 212, /* (36) ccons ::= NOT NULL onconf */ | 160739 | 213, /* (36) ccons ::= NOT NULL onconf */ |
| 159729 | 212, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */ | 160740 | 213, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 159730 | 212, /* (38) ccons ::= UNIQUE onconf */ | 160741 | 213, /* (38) ccons ::= UNIQUE onconf */ |
| 159731 | 212, /* (39) ccons ::= CHECK LP expr RP */ | 160742 | 213, /* (39) ccons ::= CHECK LP expr RP */ |
| 159732 | 212, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */ | 160743 | 213, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 159733 | 212, /* (41) ccons ::= defer_subclause */ | 160744 | 213, /* (41) ccons ::= defer_subclause */ |
| 159734 | 212, /* (42) ccons ::= COLLATE ID|STRING */ | 160745 | 213, /* (42) ccons ::= COLLATE ID|STRING */ |
| 159735 | 221, /* (43) generated ::= LP expr RP */ | 160746 | 222, /* (43) generated ::= LP expr RP */ |
| 159736 | 221, /* (44) generated ::= LP expr RP ID */ | 160747 | 222, /* (44) generated ::= LP expr RP ID */ |
| 159737 | 217, /* (45) autoinc ::= */ | 160748 | 218, /* (45) autoinc ::= */ |
| 159738 | 217, /* (46) autoinc ::= AUTOINCR */ | 160749 | 218, /* (46) autoinc ::= AUTOINCR */ |
| 159739 | 219, /* (47) refargs ::= */ | 160750 | 220, /* (47) refargs ::= */ |
| 159740 | 219, /* (48) refargs ::= refargs refarg */ | 160751 | 220, /* (48) refargs ::= refargs refarg */ |
| 159741 | 222, /* (49) refarg ::= MATCH nm */ | 160752 | 223, /* (49) refarg ::= MATCH nm */ |
| 159742 | 222, /* (50) refarg ::= ON INSERT refact */ | 160753 | 223, /* (50) refarg ::= ON INSERT refact */ |
| 159743 | 222, /* (51) refarg ::= ON DELETE refact */ | 160754 | 223, /* (51) refarg ::= ON DELETE refact */ |
| 159744 | 222, /* (52) refarg ::= ON UPDATE refact */ | 160755 | 223, /* (52) refarg ::= ON UPDATE refact */ |
| 159745 | 223, /* (53) refact ::= SET NULL */ | 160756 | 224, /* (53) refact ::= SET NULL */ |
| 159746 | 223, /* (54) refact ::= SET DEFAULT */ | 160757 | 224, /* (54) refact ::= SET DEFAULT */ |
| 159747 | 223, /* (55) refact ::= CASCADE */ | 160758 | 224, /* (55) refact ::= CASCADE */ |
| 159748 | 223, /* (56) refact ::= RESTRICT */ | 160759 | 224, /* (56) refact ::= RESTRICT */ |
| 159749 | 223, /* (57) refact ::= NO ACTION */ | 160760 | 224, /* (57) refact ::= NO ACTION */ |
| 159750 | 220, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ | 160761 | 221, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 159751 | 220, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ | 160762 | 221, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 159752 | 224, /* (60) init_deferred_pred_opt ::= */ | 160763 | 225, /* (60) init_deferred_pred_opt ::= */ |
| 159753 | 224, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */ | 160764 | 225, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 159754 | 224, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ | 160765 | 225, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 159755 | 200, /* (63) conslist_opt ::= */ | 160766 | 201, /* (63) conslist_opt ::= */ |
| 159756 | 226, /* (64) tconscomma ::= COMMA */ | 160767 | 227, /* (64) tconscomma ::= COMMA */ |
| 159757 | 227, /* (65) tcons ::= CONSTRAINT nm */ | 160768 | 228, /* (65) tcons ::= CONSTRAINT nm */ |
| 159758 | 227, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ | 160769 | 228, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 159759 | 227, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */ | 160770 | 228, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */ |
| 159760 | 227, /* (68) tcons ::= CHECK LP expr RP onconf */ | 160771 | 228, /* (68) tcons ::= CHECK LP expr RP onconf */ |
| 159761 | 227, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ | 160772 | 228, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 159762 | 230, /* (70) defer_subclause_opt ::= */ | 160773 | 231, /* (70) defer_subclause_opt ::= */ |
| 159763 | 215, /* (71) onconf ::= */ | 160774 | 216, /* (71) onconf ::= */ |
| 159764 | 215, /* (72) onconf ::= ON CONFLICT resolvetype */ | 160775 | 216, /* (72) onconf ::= ON CONFLICT resolvetype */ |
| 159765 | 231, /* (73) orconf ::= */ | 160776 | 232, /* (73) orconf ::= */ |
| 159766 | 231, /* (74) orconf ::= OR resolvetype */ | 160777 | 232, /* (74) orconf ::= OR resolvetype */ |
| 159767 | 232, /* (75) resolvetype ::= IGNORE */ | 160778 | 233, /* (75) resolvetype ::= IGNORE */ |
| 159768 | 232, /* (76) resolvetype ::= REPLACE */ | 160779 | 233, /* (76) resolvetype ::= REPLACE */ |
| 159769 | 188, /* (77) cmd ::= DROP TABLE ifexists fullname */ | 160780 | 189, /* (77) cmd ::= DROP TABLE ifexists fullname */ |
| 159770 | 234, /* (78) ifexists ::= IF EXISTS */ | 160781 | 235, /* (78) ifexists ::= IF EXISTS */ |
| 159771 | 234, /* (79) ifexists ::= */ | 160782 | 235, /* (79) ifexists ::= */ |
| 159772 | 188, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ | 160783 | 189, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 159773 | 188, /* (81) cmd ::= DROP VIEW ifexists fullname */ | 160784 | 189, /* (81) cmd ::= DROP VIEW ifexists fullname */ |
| 159774 | 188, /* (82) cmd ::= select */ | 160785 | 189, /* (82) cmd ::= select */ |
| 159775 | 202, /* (83) select ::= WITH wqlist selectnowith */ | 160786 | 203, /* (83) select ::= WITH wqlist selectnowith */ |
| 159776 | 202, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */ | 160787 | 203, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */ |
| 159777 | 202, /* (85) select ::= selectnowith */ | 160788 | 203, /* (85) select ::= selectnowith */ |
| 159778 | 236, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */ | 160789 | 237, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */ |
| 159779 | 239, /* (87) multiselect_op ::= UNION */ | 160790 | 240, /* (87) multiselect_op ::= UNION */ |
| 159780 | 239, /* (88) multiselect_op ::= UNION ALL */ | 160791 | 240, /* (88) multiselect_op ::= UNION ALL */ |
| 159781 | 239, /* (89) multiselect_op ::= EXCEPT|INTERSECT */ | 160792 | 240, /* (89) multiselect_op ::= EXCEPT|INTERSECT */ |
| 159782 | 237, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ | 160793 | 238, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 159783 | 237, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ | 160794 | 238, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ |
| 159784 | 249, /* (92) values ::= VALUES LP nexprlist RP */ | 160795 | 250, /* (92) values ::= VALUES LP nexprlist RP */ |
| 159785 | 249, /* (93) values ::= values COMMA LP nexprlist RP */ | 160796 | 250, /* (93) values ::= values COMMA LP nexprlist RP */ |
| 159786 | 240, /* (94) distinct ::= DISTINCT */ | 160797 | 241, /* (94) distinct ::= DISTINCT */ |
| 159787 | 240, /* (95) distinct ::= ALL */ | 160798 | 241, /* (95) distinct ::= ALL */ |
| 159788 | 240, /* (96) distinct ::= */ | 160799 | 241, /* (96) distinct ::= */ |
| 159789 | 251, /* (97) sclp ::= */ | 160800 | 252, /* (97) sclp ::= */ |
| 159790 | 241, /* (98) selcollist ::= sclp scanpt expr scanpt as */ | 160801 | 242, /* (98) selcollist ::= sclp scanpt expr scanpt as */ |
| 159791 | 241, /* (99) selcollist ::= sclp scanpt STAR */ | 160802 | 242, /* (99) selcollist ::= sclp scanpt STAR */ |
| 159792 | 241, /* (100) selcollist ::= sclp scanpt nm DOT STAR */ | 160803 | 242, /* (100) selcollist ::= sclp scanpt nm DOT STAR */ |
| 159793 | 252, /* (101) as ::= AS nm */ | 160804 | 253, /* (101) as ::= AS nm */ |
| 159794 | 252, /* (102) as ::= */ | 160805 | 253, /* (102) as ::= */ |
| 159795 | 242, /* (103) from ::= */ | 160806 | 243, /* (103) from ::= */ |
| 159796 | 242, /* (104) from ::= FROM seltablist */ | 160807 | 243, /* (104) from ::= FROM seltablist */ |
| 159797 | 254, /* (105) stl_prefix ::= seltablist joinop */ | 160808 | 255, /* (105) stl_prefix ::= seltablist joinop */ |
| 159798 | 254, /* (106) stl_prefix ::= */ | 160809 | 255, /* (106) stl_prefix ::= */ |
| 159799 | 253, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ | 160810 | 254, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 159800 | 253, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ | 160811 | 254, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 159801 | 253, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ | 160812 | 254, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 159802 | 253, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ | 160813 | 254, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 159803 | 198, /* (111) dbnm ::= */ | 160814 | 199, /* (111) dbnm ::= */ |
| 159804 | 198, /* (112) dbnm ::= DOT nm */ | 160815 | 199, /* (112) dbnm ::= DOT nm */ |
| 159805 | 235, /* (113) fullname ::= nm */ | 160816 | 236, /* (113) fullname ::= nm */ |
| 159806 | 235, /* (114) fullname ::= nm DOT nm */ | 160817 | 236, /* (114) fullname ::= nm DOT nm */ |
| 159807 | 260, /* (115) xfullname ::= nm */ | 160818 | 261, /* (115) xfullname ::= nm */ |
| 159808 | 260, /* (116) xfullname ::= nm DOT nm */ | 160819 | 261, /* (116) xfullname ::= nm DOT nm */ |
| 159809 | 260, /* (117) xfullname ::= nm DOT nm AS nm */ | 160820 | 261, /* (117) xfullname ::= nm DOT nm AS nm */ |
| 159810 | 260, /* (118) xfullname ::= nm AS nm */ | 160821 | 261, /* (118) xfullname ::= nm AS nm */ |
| 159811 | 255, /* (119) joinop ::= COMMA|JOIN */ | 160822 | 256, /* (119) joinop ::= COMMA|JOIN */ |
| 159812 | 255, /* (120) joinop ::= JOIN_KW JOIN */ | 160823 | 256, /* (120) joinop ::= JOIN_KW JOIN */ |
| 159813 | 255, /* (121) joinop ::= JOIN_KW nm JOIN */ | 160824 | 256, /* (121) joinop ::= JOIN_KW nm JOIN */ |
| 159814 | 255, /* (122) joinop ::= JOIN_KW nm nm JOIN */ | 160825 | 256, /* (122) joinop ::= JOIN_KW nm nm JOIN */ |
| 159815 | 257, /* (123) on_opt ::= ON expr */ | 160826 | 258, /* (123) on_opt ::= ON expr */ |
| 159816 | 257, /* (124) on_opt ::= */ | 160827 | 258, /* (124) on_opt ::= */ |
| 159817 | 256, /* (125) indexed_opt ::= */ | 160828 | 257, /* (125) indexed_opt ::= */ |
| 159818 | 256, /* (126) indexed_opt ::= INDEXED BY nm */ | 160829 | 257, /* (126) indexed_opt ::= INDEXED BY nm */ |
| 159819 | 256, /* (127) indexed_opt ::= NOT INDEXED */ | 160830 | 257, /* (127) indexed_opt ::= NOT INDEXED */ |
| 159820 | 258, /* (128) using_opt ::= USING LP idlist RP */ | 160831 | 259, /* (128) using_opt ::= USING LP idlist RP */ |
| 159821 | 258, /* (129) using_opt ::= */ | 160832 | 259, /* (129) using_opt ::= */ |
| 159822 | 246, /* (130) orderby_opt ::= */ | 160833 | 247, /* (130) orderby_opt ::= */ |
| 159823 | 246, /* (131) orderby_opt ::= ORDER BY sortlist */ | 160834 | 247, /* (131) orderby_opt ::= ORDER BY sortlist */ |
| 159824 | 228, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */ | 160835 | 229, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 159825 | 228, /* (133) sortlist ::= expr sortorder nulls */ | 160836 | 229, /* (133) sortlist ::= expr sortorder nulls */ |
| 159826 | 216, /* (134) sortorder ::= ASC */ | 160837 | 217, /* (134) sortorder ::= ASC */ |
| 159827 | 216, /* (135) sortorder ::= DESC */ | 160838 | 217, /* (135) sortorder ::= DESC */ |
| 159828 | 216, /* (136) sortorder ::= */ | 160839 | 217, /* (136) sortorder ::= */ |
| 159829 | 262, /* (137) nulls ::= NULLS FIRST */ | 160840 | 263, /* (137) nulls ::= NULLS FIRST */ |
| 159830 | 262, /* (138) nulls ::= NULLS LAST */ | 160841 | 263, /* (138) nulls ::= NULLS LAST */ |
| 159831 | 262, /* (139) nulls ::= */ | 160842 | 263, /* (139) nulls ::= */ |
| 159832 | 244, /* (140) groupby_opt ::= */ | 160843 | 245, /* (140) groupby_opt ::= */ |
| 159833 | 244, /* (141) groupby_opt ::= GROUP BY nexprlist */ | 160844 | 245, /* (141) groupby_opt ::= GROUP BY nexprlist */ |
| 159834 | 245, /* (142) having_opt ::= */ | 160845 | 246, /* (142) having_opt ::= */ |
| 159835 | 245, /* (143) having_opt ::= HAVING expr */ | 160846 | 246, /* (143) having_opt ::= HAVING expr */ |
| 159836 | 247, /* (144) limit_opt ::= */ | 160847 | 248, /* (144) limit_opt ::= */ |
| 159837 | 247, /* (145) limit_opt ::= LIMIT expr */ | 160848 | 248, /* (145) limit_opt ::= LIMIT expr */ |
| 159838 | 247, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ | 160849 | 248, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ |
| 159839 | 247, /* (147) limit_opt ::= LIMIT expr COMMA expr */ | 160850 | 248, /* (147) limit_opt ::= LIMIT expr COMMA expr */ |
| 159840 | 188, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ | 160851 | 189, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 159841 | 243, /* (149) where_opt ::= */ | 160852 | 244, /* (149) where_opt ::= */ |
| 159842 | 243, /* (150) where_opt ::= WHERE expr */ | 160853 | 244, /* (150) where_opt ::= WHERE expr */ |
| 159843 | 264, /* (151) where_opt_ret ::= */ | 160854 | 265, /* (151) where_opt_ret ::= */ |
| 159844 | 264, /* (152) where_opt_ret ::= WHERE expr */ | 160855 | 265, /* (152) where_opt_ret ::= WHERE expr */ |
| 159845 | 264, /* (153) where_opt_ret ::= RETURNING selcollist */ | 160856 | 265, /* (153) where_opt_ret ::= RETURNING selcollist */ |
| 159846 | 264, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */ | 160857 | 265, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */ |
| 159847 | 188, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ | 160858 | 189, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ |
| 159848 | 265, /* (156) setlist ::= setlist COMMA nm EQ expr */ | 160859 | 266, /* (156) setlist ::= setlist COMMA nm EQ expr */ |
| 159849 | 265, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */ | 160860 | 266, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 159850 | 265, /* (158) setlist ::= nm EQ expr */ | 160861 | 266, /* (158) setlist ::= nm EQ expr */ |
| 159851 | 265, /* (159) setlist ::= LP idlist RP EQ expr */ | 160862 | 266, /* (159) setlist ::= LP idlist RP EQ expr */ |
| 159852 | 188, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ | 160863 | 189, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 159853 | 188, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ | 160864 | 189, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 159854 | 268, /* (162) upsert ::= */ | 160865 | 269, /* (162) upsert ::= */ |
| 159855 | 268, /* (163) upsert ::= RETURNING selcollist */ | 160866 | 269, /* (163) upsert ::= RETURNING selcollist */ |
| 159856 | 268, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ | 160867 | 269, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ |
| 159857 | 268, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ | 160868 | 269, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 159858 | 268, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */ | 160869 | 269, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */ |
| 159859 | 268, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ | 160870 | 269, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 159860 | 269, /* (168) returning ::= RETURNING selcollist */ | 160871 | 270, /* (168) returning ::= RETURNING selcollist */ |
| 159861 | 266, /* (169) insert_cmd ::= INSERT orconf */ | 160872 | 267, /* (169) insert_cmd ::= INSERT orconf */ |
| 159862 | 266, /* (170) insert_cmd ::= REPLACE */ | 160873 | 267, /* (170) insert_cmd ::= REPLACE */ |
| 159863 | 267, /* (171) idlist_opt ::= */ | 160874 | 268, /* (171) idlist_opt ::= */ |
| 159864 | 267, /* (172) idlist_opt ::= LP idlist RP */ | 160875 | 268, /* (172) idlist_opt ::= LP idlist RP */ |
| 159865 | 261, /* (173) idlist ::= idlist COMMA nm */ | 160876 | 262, /* (173) idlist ::= idlist COMMA nm */ |
| 159866 | 261, /* (174) idlist ::= nm */ | 160877 | 262, /* (174) idlist ::= nm */ |
| 159867 | 214, /* (175) expr ::= LP expr RP */ | 160878 | 215, /* (175) expr ::= LP expr RP */ |
| 159868 | 214, /* (176) expr ::= ID|INDEXED */ | 160879 | 215, /* (176) expr ::= ID|INDEXED */ |
| 159869 | 214, /* (177) expr ::= JOIN_KW */ | 160880 | 215, /* (177) expr ::= JOIN_KW */ |
| 159870 | 214, /* (178) expr ::= nm DOT nm */ | 160881 | 215, /* (178) expr ::= nm DOT nm */ |
| 159871 | 214, /* (179) expr ::= nm DOT nm DOT nm */ | 160882 | 215, /* (179) expr ::= nm DOT nm DOT nm */ |
| 159872 | 213, /* (180) term ::= NULL|FLOAT|BLOB */ | 160883 | 214, /* (180) term ::= NULL|FLOAT|BLOB */ |
| 159873 | 213, /* (181) term ::= STRING */ | 160884 | 214, /* (181) term ::= STRING */ |
| 159874 | 213, /* (182) term ::= INTEGER */ | 160885 | 214, /* (182) term ::= INTEGER */ |
| 159875 | 214, /* (183) expr ::= VARIABLE */ | 160886 | 215, /* (183) expr ::= VARIABLE */ |
| 159876 | 214, /* (184) expr ::= expr COLLATE ID|STRING */ | 160887 | 215, /* (184) expr ::= expr COLLATE ID|STRING */ |
| 159877 | 214, /* (185) expr ::= CAST LP expr AS typetoken RP */ | 160888 | 215, /* (185) expr ::= CAST LP expr AS typetoken RP */ |
| 159878 | 214, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */ | 160889 | 215, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 159879 | 214, /* (187) expr ::= ID|INDEXED LP STAR RP */ | 160890 | 215, /* (187) expr ::= ID|INDEXED LP STAR RP */ |
| 159880 | 214, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ | 160891 | 215, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ |
| 159881 | 214, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */ | 160892 | 215, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */ |
| 159882 | 213, /* (190) term ::= CTIME_KW */ | 160893 | 214, /* (190) term ::= CTIME_KW */ |
| 159883 | 214, /* (191) expr ::= LP nexprlist COMMA expr RP */ | 160894 | 215, /* (191) expr ::= LP nexprlist COMMA expr RP */ |
| 159884 | 214, /* (192) expr ::= expr AND expr */ | 160895 | 215, /* (192) expr ::= expr AND expr */ |
| 159885 | 214, /* (193) expr ::= expr OR expr */ | 160896 | 215, /* (193) expr ::= expr OR expr */ |
| 159886 | 214, /* (194) expr ::= expr LT|GT|GE|LE expr */ | 160897 | 215, /* (194) expr ::= expr LT|GT|GE|LE expr */ |
| 159887 | 214, /* (195) expr ::= expr EQ|NE expr */ | 160898 | 215, /* (195) expr ::= expr EQ|NE expr */ |
| 159888 | 214, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ | 160899 | 215, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 159889 | 214, /* (197) expr ::= expr PLUS|MINUS expr */ | 160900 | 215, /* (197) expr ::= expr PLUS|MINUS expr */ |
| 159890 | 214, /* (198) expr ::= expr STAR|SLASH|REM expr */ | 160901 | 215, /* (198) expr ::= expr STAR|SLASH|REM expr */ |
| 159891 | 214, /* (199) expr ::= expr CONCAT expr */ | 160902 | 215, /* (199) expr ::= expr CONCAT expr */ |
| 159892 | 271, /* (200) likeop ::= NOT LIKE_KW|MATCH */ | 160903 | 272, /* (200) likeop ::= NOT LIKE_KW|MATCH */ |
| 159893 | 214, /* (201) expr ::= expr likeop expr */ | 160904 | 215, /* (201) expr ::= expr likeop expr */ |
| 159894 | 214, /* (202) expr ::= expr likeop expr ESCAPE expr */ | 160905 | 215, /* (202) expr ::= expr likeop expr ESCAPE expr */ |
| 159895 | 214, /* (203) expr ::= expr ISNULL|NOTNULL */ | 160906 | 215, /* (203) expr ::= expr ISNULL|NOTNULL */ |
| 159896 | 214, /* (204) expr ::= expr NOT NULL */ | 160907 | 215, /* (204) expr ::= expr NOT NULL */ |
| 159897 | 214, /* (205) expr ::= expr IS expr */ | 160908 | 215, /* (205) expr ::= expr IS expr */ |
| 159898 | 214, /* (206) expr ::= expr IS NOT expr */ | 160909 | 215, /* (206) expr ::= expr IS NOT expr */ |
| 159899 | 214, /* (207) expr ::= NOT expr */ | 160910 | 215, /* (207) expr ::= NOT expr */ |
| 159900 | 214, /* (208) expr ::= BITNOT expr */ | 160911 | 215, /* (208) expr ::= BITNOT expr */ |
| 159901 | 214, /* (209) expr ::= PLUS|MINUS expr */ | 160912 | 215, /* (209) expr ::= PLUS|MINUS expr */ |
| 159902 | 272, /* (210) between_op ::= BETWEEN */ | 160913 | 273, /* (210) between_op ::= BETWEEN */ |
| 159903 | 272, /* (211) between_op ::= NOT BETWEEN */ | 160914 | 273, /* (211) between_op ::= NOT BETWEEN */ |
| 159904 | 214, /* (212) expr ::= expr between_op expr AND expr */ | 160915 | 215, /* (212) expr ::= expr between_op expr AND expr */ |
| 159905 | 273, /* (213) in_op ::= IN */ | 160916 | 274, /* (213) in_op ::= IN */ |
| 159906 | 273, /* (214) in_op ::= NOT IN */ | 160917 | 274, /* (214) in_op ::= NOT IN */ |
| 159907 | 214, /* (215) expr ::= expr in_op LP exprlist RP */ | 160918 | 215, /* (215) expr ::= expr in_op LP exprlist RP */ |
| 159908 | 214, /* (216) expr ::= LP select RP */ | 160919 | 215, /* (216) expr ::= LP select RP */ |
| 159909 | 214, /* (217) expr ::= expr in_op LP select RP */ | 160920 | 215, /* (217) expr ::= expr in_op LP select RP */ |
| 159910 | 214, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */ | 160921 | 215, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 159911 | 214, /* (219) expr ::= EXISTS LP select RP */ | 160922 | 215, /* (219) expr ::= EXISTS LP select RP */ |
| 159912 | 214, /* (220) expr ::= CASE case_operand case_exprlist case_else END */ | 160923 | 215, /* (220) expr ::= CASE case_operand case_exprlist case_else END */ |
| 159913 | 276, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */ | 160924 | 277, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 159914 | 276, /* (222) case_exprlist ::= WHEN expr THEN expr */ | 160925 | 277, /* (222) case_exprlist ::= WHEN expr THEN expr */ |
| 159915 | 277, /* (223) case_else ::= ELSE expr */ | 160926 | 278, /* (223) case_else ::= ELSE expr */ |
| 159916 | 277, /* (224) case_else ::= */ | 160927 | 278, /* (224) case_else ::= */ |
| 159917 | 275, /* (225) case_operand ::= expr */ | 160928 | 276, /* (225) case_operand ::= expr */ |
| 159918 | 275, /* (226) case_operand ::= */ | 160929 | 276, /* (226) case_operand ::= */ |
| 159919 | 259, /* (227) exprlist ::= */ | 160930 | 260, /* (227) exprlist ::= */ |
| 159920 | 250, /* (228) nexprlist ::= nexprlist COMMA expr */ | 160931 | 251, /* (228) nexprlist ::= nexprlist COMMA expr */ |
| 159921 | 250, /* (229) nexprlist ::= expr */ | 160932 | 251, /* (229) nexprlist ::= expr */ |
| 159922 | 274, /* (230) paren_exprlist ::= */ | 160933 | 275, /* (230) paren_exprlist ::= */ |
| 159923 | 274, /* (231) paren_exprlist ::= LP exprlist RP */ | 160934 | 275, /* (231) paren_exprlist ::= LP exprlist RP */ |
| 159924 | 188, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | 160935 | 189, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 159925 | 278, /* (233) uniqueflag ::= UNIQUE */ | 160936 | 279, /* (233) uniqueflag ::= UNIQUE */ |
| 159926 | 278, /* (234) uniqueflag ::= */ | 160937 | 279, /* (234) uniqueflag ::= */ |
| 159927 | 218, /* (235) eidlist_opt ::= */ | 160938 | 219, /* (235) eidlist_opt ::= */ |
| 159928 | 218, /* (236) eidlist_opt ::= LP eidlist RP */ | 160939 | 219, /* (236) eidlist_opt ::= LP eidlist RP */ |
| 159929 | 229, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */ | 160940 | 230, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 159930 | 229, /* (238) eidlist ::= nm collate sortorder */ | 160941 | 230, /* (238) eidlist ::= nm collate sortorder */ |
| 159931 | 279, /* (239) collate ::= */ | 160942 | 280, /* (239) collate ::= */ |
| 159932 | 279, /* (240) collate ::= COLLATE ID|STRING */ | 160943 | 280, /* (240) collate ::= COLLATE ID|STRING */ |
| 159933 | 188, /* (241) cmd ::= DROP INDEX ifexists fullname */ | 160944 | 189, /* (241) cmd ::= DROP INDEX ifexists fullname */ |
| 159934 | 188, /* (242) cmd ::= VACUUM vinto */ | 160945 | 189, /* (242) cmd ::= VACUUM vinto */ |
| 159935 | 188, /* (243) cmd ::= VACUUM nm vinto */ | 160946 | 189, /* (243) cmd ::= VACUUM nm vinto */ |
| 159936 | 280, /* (244) vinto ::= INTO expr */ | 160947 | 281, /* (244) vinto ::= INTO expr */ |
| 159937 | 280, /* (245) vinto ::= */ | 160948 | 281, /* (245) vinto ::= */ |
| 159938 | 188, /* (246) cmd ::= PRAGMA nm dbnm */ | 160949 | 189, /* (246) cmd ::= PRAGMA nm dbnm */ |
| 159939 | 188, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */ | 160950 | 189, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 159940 | 188, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */ | 160951 | 189, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 159941 | 188, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */ | 160952 | 189, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 159942 | 188, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */ | 160953 | 189, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 159943 | 208, /* (251) plus_num ::= PLUS INTEGER|FLOAT */ | 160954 | 209, /* (251) plus_num ::= PLUS INTEGER|FLOAT */ |
| 159944 | 209, /* (252) minus_num ::= MINUS INTEGER|FLOAT */ | 160955 | 210, /* (252) minus_num ::= MINUS INTEGER|FLOAT */ |
| 159945 | 188, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | 160956 | 189, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 159946 | 282, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | 160957 | 283, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 159947 | 284, /* (255) trigger_time ::= BEFORE|AFTER */ | 160958 | 285, /* (255) trigger_time ::= BEFORE|AFTER */ |
| 159948 | 284, /* (256) trigger_time ::= INSTEAD OF */ | 160959 | 285, /* (256) trigger_time ::= INSTEAD OF */ |
| 159949 | 284, /* (257) trigger_time ::= */ | 160960 | 285, /* (257) trigger_time ::= */ |
| 159950 | 285, /* (258) trigger_event ::= DELETE|INSERT */ | 160961 | 286, /* (258) trigger_event ::= DELETE|INSERT */ |
| 159951 | 285, /* (259) trigger_event ::= UPDATE */ | 160962 | 286, /* (259) trigger_event ::= UPDATE */ |
| 159952 | 285, /* (260) trigger_event ::= UPDATE OF idlist */ | 160963 | 286, /* (260) trigger_event ::= UPDATE OF idlist */ |
| 159953 | 287, /* (261) when_clause ::= */ | 160964 | 288, /* (261) when_clause ::= */ |
| 159954 | 287, /* (262) when_clause ::= WHEN expr */ | 160965 | 288, /* (262) when_clause ::= WHEN expr */ |
| 159955 | 283, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | 160966 | 284, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 159956 | 283, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */ | 160967 | 284, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 159957 | 289, /* (265) trnm ::= nm DOT nm */ | 160968 | 290, /* (265) trnm ::= nm DOT nm */ |
| 159958 | 290, /* (266) tridxby ::= INDEXED BY nm */ | 160969 | 291, /* (266) tridxby ::= INDEXED BY nm */ |
| 159959 | 290, /* (267) tridxby ::= NOT INDEXED */ | 160970 | 291, /* (267) tridxby ::= NOT INDEXED */ |
| 159960 | 288, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | 160971 | 289, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 159961 | 288, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | 160972 | 289, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 159962 | 288, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | 160973 | 289, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 159963 | 288, /* (271) trigger_cmd ::= scanpt select scanpt */ | 160974 | 289, /* (271) trigger_cmd ::= scanpt select scanpt */ |
| 159964 | 214, /* (272) expr ::= RAISE LP IGNORE RP */ | 160975 | 215, /* (272) expr ::= RAISE LP IGNORE RP */ |
| 159965 | 214, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */ | 160976 | 215, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 159966 | 233, /* (274) raisetype ::= ROLLBACK */ | 160977 | 234, /* (274) raisetype ::= ROLLBACK */ |
| 159967 | 233, /* (275) raisetype ::= ABORT */ | 160978 | 234, /* (275) raisetype ::= ABORT */ |
| 159968 | 233, /* (276) raisetype ::= FAIL */ | 160979 | 234, /* (276) raisetype ::= FAIL */ |
| 159969 | 188, /* (277) cmd ::= DROP TRIGGER ifexists fullname */ | 160980 | 189, /* (277) cmd ::= DROP TRIGGER ifexists fullname */ |
| 159970 | 188, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | 160981 | 189, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 159971 | 188, /* (279) cmd ::= DETACH database_kw_opt expr */ | 160982 | 189, /* (279) cmd ::= DETACH database_kw_opt expr */ |
| 159972 | 292, /* (280) key_opt ::= */ | 160983 | 293, /* (280) key_opt ::= */ |
| 159973 | 292, /* (281) key_opt ::= KEY expr */ | 160984 | 293, /* (281) key_opt ::= KEY expr */ |
| 159974 | 188, /* (282) cmd ::= REINDEX */ | 160985 | 189, /* (282) cmd ::= REINDEX */ |
| 159975 | 188, /* (283) cmd ::= REINDEX nm dbnm */ | 160986 | 189, /* (283) cmd ::= REINDEX nm dbnm */ |
| 159976 | 188, /* (284) cmd ::= ANALYZE */ | 160987 | 189, /* (284) cmd ::= ANALYZE */ |
| 159977 | 188, /* (285) cmd ::= ANALYZE nm dbnm */ | 160988 | 189, /* (285) cmd ::= ANALYZE nm dbnm */ |
| 159978 | 188, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */ | 160989 | 189, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 159979 | 188, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | 160990 | 189, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 159980 | 188, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | 160991 | 189, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 159981 | 293, /* (289) add_column_fullname ::= fullname */ | 160992 | 294, /* (289) add_column_fullname ::= fullname */ |
| 159982 | 188, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | 160993 | 189, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 159983 | 188, /* (291) cmd ::= create_vtab */ | 160994 | 189, /* (291) cmd ::= create_vtab */ |
| 159984 | 188, /* (292) cmd ::= create_vtab LP vtabarglist RP */ | 160995 | 189, /* (292) cmd ::= create_vtab LP vtabarglist RP */ |
| 159985 | 295, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | 160996 | 296, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 159986 | 297, /* (294) vtabarg ::= */ | 160997 | 298, /* (294) vtabarg ::= */ |
| 159987 | 298, /* (295) vtabargtoken ::= ANY */ | 160998 | 299, /* (295) vtabargtoken ::= ANY */ |
| 159988 | 298, /* (296) vtabargtoken ::= lp anylist RP */ | 160999 | 299, /* (296) vtabargtoken ::= lp anylist RP */ |
| 159989 | 299, /* (297) lp ::= LP */ | 161000 | 300, /* (297) lp ::= LP */ |
| 159990 | 263, /* (298) with ::= WITH wqlist */ | 161001 | 264, /* (298) with ::= WITH wqlist */ |
| 159991 | 263, /* (299) with ::= WITH RECURSIVE wqlist */ | 161002 | 264, /* (299) with ::= WITH RECURSIVE wqlist */ |
| 159992 | 302, /* (300) wqas ::= AS */ | 161003 | 303, /* (300) wqas ::= AS */ |
| 159993 | 302, /* (301) wqas ::= AS MATERIALIZED */ | 161004 | 303, /* (301) wqas ::= AS MATERIALIZED */ |
| 159994 | 302, /* (302) wqas ::= AS NOT MATERIALIZED */ | 161005 | 303, /* (302) wqas ::= AS NOT MATERIALIZED */ |
| 159995 | 301, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */ | 161006 | 302, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 159996 | 238, /* (304) wqlist ::= wqitem */ | 161007 | 239, /* (304) wqlist ::= wqitem */ |
| 159997 | 238, /* (305) wqlist ::= wqlist COMMA wqitem */ | 161008 | 239, /* (305) wqlist ::= wqlist COMMA wqitem */ |
| 159998 | 303, /* (306) windowdefn_list ::= windowdefn */ | 161009 | 304, /* (306) windowdefn_list ::= windowdefn */ |
| 159999 | 303, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | 161010 | 304, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 160000 | 304, /* (308) windowdefn ::= nm AS LP window RP */ | 161011 | 305, /* (308) windowdefn ::= nm AS LP window RP */ |
| 160001 | 305, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | 161012 | 306, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 160002 | 305, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | 161013 | 306, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 160003 | 305, /* (311) window ::= ORDER BY sortlist frame_opt */ | 161014 | 306, /* (311) window ::= ORDER BY sortlist frame_opt */ |
| 160004 | 305, /* (312) window ::= nm ORDER BY sortlist frame_opt */ | 161015 | 306, /* (312) window ::= nm ORDER BY sortlist frame_opt */ |
| 160005 | 305, /* (313) window ::= frame_opt */ | 161016 | 306, /* (313) window ::= frame_opt */ |
| 160006 | 305, /* (314) window ::= nm frame_opt */ | 161017 | 306, /* (314) window ::= nm frame_opt */ |
| 160007 | 306, /* (315) frame_opt ::= */ | 161018 | 307, /* (315) frame_opt ::= */ |
| 160008 | 306, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | 161019 | 307, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 160009 | 306, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | 161020 | 307, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 160010 | 310, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */ | 161021 | 311, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 160011 | 312, /* (319) frame_bound_s ::= frame_bound */ | 161022 | 313, /* (319) frame_bound_s ::= frame_bound */ |
| 160012 | 312, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */ | 161023 | 313, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 160013 | 313, /* (321) frame_bound_e ::= frame_bound */ | 161024 | 314, /* (321) frame_bound_e ::= frame_bound */ |
| 160014 | 313, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */ | 161025 | 314, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 160015 | 311, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */ | 161026 | 312, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 160016 | 311, /* (324) frame_bound ::= CURRENT ROW */ | 161027 | 312, /* (324) frame_bound ::= CURRENT ROW */ |
| 160017 | 314, /* (325) frame_exclude_opt ::= */ | 161028 | 315, /* (325) frame_exclude_opt ::= */ |
| 160018 | 314, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */ | 161029 | 315, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 160019 | 315, /* (327) frame_exclude ::= NO OTHERS */ | 161030 | 316, /* (327) frame_exclude ::= NO OTHERS */ |
| 160020 | 315, /* (328) frame_exclude ::= CURRENT ROW */ | 161031 | 316, /* (328) frame_exclude ::= CURRENT ROW */ |
| 160021 | 315, /* (329) frame_exclude ::= GROUP|TIES */ | 161032 | 316, /* (329) frame_exclude ::= GROUP|TIES */ |
| 160022 | 248, /* (330) window_clause ::= WINDOW windowdefn_list */ | 161033 | 249, /* (330) window_clause ::= WINDOW windowdefn_list */ |
| 160023 | 270, /* (331) filter_over ::= filter_clause over_clause */ | 161034 | 271, /* (331) filter_over ::= filter_clause over_clause */ |
| 160024 | 270, /* (332) filter_over ::= over_clause */ | 161035 | 271, /* (332) filter_over ::= over_clause */ |
| 160025 | 270, /* (333) filter_over ::= filter_clause */ | 161036 | 271, /* (333) filter_over ::= filter_clause */ |
| 160026 | 309, /* (334) over_clause ::= OVER LP window RP */ | 161037 | 310, /* (334) over_clause ::= OVER LP window RP */ |
| 160027 | 309, /* (335) over_clause ::= OVER nm */ | 161038 | 310, /* (335) over_clause ::= OVER nm */ |
| 160028 | 308, /* (336) filter_clause ::= FILTER LP WHERE expr RP */ | 161039 | 309, /* (336) filter_clause ::= FILTER LP WHERE expr RP */ |
| 160029 | 183, /* (337) input ::= cmdlist */ | 161040 | 184, /* (337) input ::= cmdlist */ |
| 160030 | 184, /* (338) cmdlist ::= cmdlist ecmd */ | 161041 | 185, /* (338) cmdlist ::= cmdlist ecmd */ |
| 160031 | 184, /* (339) cmdlist ::= ecmd */ | 161042 | 185, /* (339) cmdlist ::= ecmd */ |
| 160032 | 185, /* (340) ecmd ::= SEMI */ | 161043 | 186, /* (340) ecmd ::= SEMI */ |
| 160033 | 185, /* (341) ecmd ::= cmdx SEMI */ | 161044 | 186, /* (341) ecmd ::= cmdx SEMI */ |
| 160034 | 185, /* (342) ecmd ::= explain cmdx SEMI */ | 161045 | 186, /* (342) ecmd ::= explain cmdx SEMI */ |
| 160035 | 190, /* (343) trans_opt ::= */ | 161046 | 191, /* (343) trans_opt ::= */ |
| 160036 | 190, /* (344) trans_opt ::= TRANSACTION */ | 161047 | 191, /* (344) trans_opt ::= TRANSACTION */ |
| 160037 | 190, /* (345) trans_opt ::= TRANSACTION nm */ | 161048 | 191, /* (345) trans_opt ::= TRANSACTION nm */ |
| 160038 | 192, /* (346) savepoint_opt ::= SAVEPOINT */ | 161049 | 193, /* (346) savepoint_opt ::= SAVEPOINT */ |
| 160039 | 192, /* (347) savepoint_opt ::= */ | 161050 | 193, /* (347) savepoint_opt ::= */ |
| 160040 | 188, /* (348) cmd ::= create_table create_table_args */ | 161051 | 189, /* (348) cmd ::= create_table create_table_args */ |
| 160041 | 199, /* (349) columnlist ::= columnlist COMMA columnname carglist */ | 161052 | 200, /* (349) columnlist ::= columnlist COMMA columnname carglist */ |
| 160042 | 199, /* (350) columnlist ::= columnname carglist */ | 161053 | 200, /* (350) columnlist ::= columnname carglist */ |
| 160043 | 191, /* (351) nm ::= ID|INDEXED */ | 161054 | 192, /* (351) nm ::= ID|INDEXED */ |
| 160044 | 191, /* (352) nm ::= STRING */ | 161055 | 192, /* (352) nm ::= STRING */ |
| 160045 | 191, /* (353) nm ::= JOIN_KW */ | 161056 | 192, /* (353) nm ::= JOIN_KW */ |
| 160046 | 205, /* (354) typetoken ::= typename */ | 161057 | 206, /* (354) typetoken ::= typename */ |
| 160047 | 206, /* (355) typename ::= ID|STRING */ | 161058 | 207, /* (355) typename ::= ID|STRING */ |
| 160048 | 207, /* (356) signed ::= plus_num */ | 161059 | 208, /* (356) signed ::= plus_num */ |
| 160049 | 207, /* (357) signed ::= minus_num */ | 161060 | 208, /* (357) signed ::= minus_num */ |
| 160050 | 204, /* (358) carglist ::= carglist ccons */ | 161061 | 205, /* (358) carglist ::= carglist ccons */ |
| 160051 | 204, /* (359) carglist ::= */ | 161062 | 205, /* (359) carglist ::= */ |
| 160052 | 212, /* (360) ccons ::= NULL onconf */ | 161063 | 213, /* (360) ccons ::= NULL onconf */ |
| 160053 | 212, /* (361) ccons ::= GENERATED ALWAYS AS generated */ | 161064 | 213, /* (361) ccons ::= GENERATED ALWAYS AS generated */ |
| 160054 | 212, /* (362) ccons ::= AS generated */ | 161065 | 213, /* (362) ccons ::= AS generated */ |
| 160055 | 200, /* (363) conslist_opt ::= COMMA conslist */ | 161066 | 201, /* (363) conslist_opt ::= COMMA conslist */ |
| 160056 | 225, /* (364) conslist ::= conslist tconscomma tcons */ | 161067 | 226, /* (364) conslist ::= conslist tconscomma tcons */ |
| 160057 | 225, /* (365) conslist ::= tcons */ | 161068 | 226, /* (365) conslist ::= tcons */ |
| 160058 | 226, /* (366) tconscomma ::= */ | 161069 | 227, /* (366) tconscomma ::= */ |
| 160059 | 230, /* (367) defer_subclause_opt ::= defer_subclause */ | 161070 | 231, /* (367) defer_subclause_opt ::= defer_subclause */ |
| 160060 | 232, /* (368) resolvetype ::= raisetype */ | 161071 | 233, /* (368) resolvetype ::= raisetype */ |
| 160061 | 236, /* (369) selectnowith ::= oneselect */ | 161072 | 237, /* (369) selectnowith ::= oneselect */ |
| 160062 | 237, /* (370) oneselect ::= values */ | 161073 | 238, /* (370) oneselect ::= values */ |
| 160063 | 251, /* (371) sclp ::= selcollist COMMA */ | 161074 | 252, /* (371) sclp ::= selcollist COMMA */ |
| 160064 | 252, /* (372) as ::= ID|STRING */ | 161075 | 253, /* (372) as ::= ID|STRING */ |
| 160065 | 269, /* (373) returning ::= */ | 161076 | 270, /* (373) returning ::= */ |
| 160066 | 214, /* (374) expr ::= term */ | 161077 | 215, /* (374) expr ::= term */ |
| 160067 | 271, /* (375) likeop ::= LIKE_KW|MATCH */ | 161078 | 272, /* (375) likeop ::= LIKE_KW|MATCH */ |
| 160068 | 259, /* (376) exprlist ::= nexprlist */ | 161079 | 260, /* (376) exprlist ::= nexprlist */ |
| 160069 | 281, /* (377) nmnum ::= plus_num */ | 161080 | 282, /* (377) nmnum ::= plus_num */ |
| 160070 | 281, /* (378) nmnum ::= nm */ | 161081 | 282, /* (378) nmnum ::= nm */ |
| 160071 | 281, /* (379) nmnum ::= ON */ | 161082 | 282, /* (379) nmnum ::= ON */ |
| 160072 | 281, /* (380) nmnum ::= DELETE */ | 161083 | 282, /* (380) nmnum ::= DELETE */ |
| 160073 | 281, /* (381) nmnum ::= DEFAULT */ | 161084 | 282, /* (381) nmnum ::= DEFAULT */ |
| 160074 | 208, /* (382) plus_num ::= INTEGER|FLOAT */ | 161085 | 209, /* (382) plus_num ::= INTEGER|FLOAT */ |
| 160075 | 286, /* (383) foreach_clause ::= */ | 161086 | 287, /* (383) foreach_clause ::= */ |
| 160076 | 286, /* (384) foreach_clause ::= FOR EACH ROW */ | 161087 | 287, /* (384) foreach_clause ::= FOR EACH ROW */ |
| 160077 | 289, /* (385) trnm ::= nm */ | 161088 | 290, /* (385) trnm ::= nm */ |
| 160078 | 290, /* (386) tridxby ::= */ | 161089 | 291, /* (386) tridxby ::= */ |
| 160079 | 291, /* (387) database_kw_opt ::= DATABASE */ | 161090 | 292, /* (387) database_kw_opt ::= DATABASE */ |
| 160080 | 291, /* (388) database_kw_opt ::= */ | 161091 | 292, /* (388) database_kw_opt ::= */ |
| 160081 | 294, /* (389) kwcolumn_opt ::= */ | 161092 | 295, /* (389) kwcolumn_opt ::= */ |
| 160082 | 294, /* (390) kwcolumn_opt ::= COLUMNKW */ | 161093 | 295, /* (390) kwcolumn_opt ::= COLUMNKW */ |
| 160083 | 296, /* (391) vtabarglist ::= vtabarg */ | 161094 | 297, /* (391) vtabarglist ::= vtabarg */ |
| 160084 | 296, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */ | 161095 | 297, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 160085 | 297, /* (393) vtabarg ::= vtabarg vtabargtoken */ | 161096 | 298, /* (393) vtabarg ::= vtabarg vtabargtoken */ |
| 160086 | 300, /* (394) anylist ::= */ | 161097 | 301, /* (394) anylist ::= */ |
| 160087 | 300, /* (395) anylist ::= anylist LP anylist RP */ | 161098 | 301, /* (395) anylist ::= anylist LP anylist RP */ |
| 160088 | 300, /* (396) anylist ::= anylist ANY */ | 161099 | 301, /* (396) anylist ::= anylist ANY */ |
| 160089 | 263, /* (397) with ::= */ | 161100 | 264, /* (397) with ::= */ |
| 160090 | }; | 161101 | }; |
| 160091 | 161102 | ||
| 160092 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number | 161103 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number |
| @@ -160541,16 +161552,16 @@ static YYACTIONTYPE yy_reduce( | |||
| 160541 | { sqlite3FinishCoding(pParse); } | 161552 | { sqlite3FinishCoding(pParse); } |
| 160542 | break; | 161553 | break; |
| 160543 | case 3: /* cmd ::= BEGIN transtype trans_opt */ | 161554 | case 3: /* cmd ::= BEGIN transtype trans_opt */ |
| 160544 | {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy60);} | 161555 | {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy376);} |
| 160545 | break; | 161556 | break; |
| 160546 | case 4: /* transtype ::= */ | 161557 | case 4: /* transtype ::= */ |
| 160547 | {yymsp[1].minor.yy60 = TK_DEFERRED;} | 161558 | {yymsp[1].minor.yy376 = TK_DEFERRED;} |
| 160548 | break; | 161559 | break; |
| 160549 | case 5: /* transtype ::= DEFERRED */ | 161560 | case 5: /* transtype ::= DEFERRED */ |
| 160550 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); | 161561 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); |
| 160551 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); | 161562 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); |
| 160552 | case 318: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==318); | 161563 | case 318: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==318); |
| 160553 | {yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-X*/} | 161564 | {yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-X*/} |
| 160554 | break; | 161565 | break; |
| 160555 | case 8: /* cmd ::= COMMIT|END trans_opt */ | 161566 | case 8: /* cmd ::= COMMIT|END trans_opt */ |
| 160556 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); | 161567 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); |
| @@ -160573,7 +161584,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 160573 | break; | 161584 | break; |
| 160574 | case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ | 161585 | case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 160575 | { | 161586 | { |
| 160576 | sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy60,0,0,yymsp[-2].minor.yy60); | 161587 | sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy376,0,0,yymsp[-2].minor.yy376); |
| 160577 | } | 161588 | } |
| 160578 | break; | 161589 | break; |
| 160579 | case 14: /* createkw ::= CREATE */ | 161590 | case 14: /* createkw ::= CREATE */ |
| @@ -160588,32 +161599,31 @@ static YYACTIONTYPE yy_reduce( | |||
| 160588 | case 79: /* ifexists ::= */ yytestcase(yyruleno==79); | 161599 | case 79: /* ifexists ::= */ yytestcase(yyruleno==79); |
| 160589 | case 96: /* distinct ::= */ yytestcase(yyruleno==96); | 161600 | case 96: /* distinct ::= */ yytestcase(yyruleno==96); |
| 160590 | case 239: /* collate ::= */ yytestcase(yyruleno==239); | 161601 | case 239: /* collate ::= */ yytestcase(yyruleno==239); |
| 160591 | {yymsp[1].minor.yy60 = 0;} | 161602 | {yymsp[1].minor.yy376 = 0;} |
| 160592 | break; | 161603 | break; |
| 160593 | case 16: /* ifnotexists ::= IF NOT EXISTS */ | 161604 | case 16: /* ifnotexists ::= IF NOT EXISTS */ |
| 160594 | {yymsp[-2].minor.yy60 = 1;} | 161605 | {yymsp[-2].minor.yy376 = 1;} |
| 160595 | break; | 161606 | break; |
| 160596 | case 17: /* temp ::= TEMP */ | 161607 | case 17: /* temp ::= TEMP */ |
| 160597 | case 46: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==46); | 161608 | {yymsp[0].minor.yy376 = pParse->db->init.busy==0;} |
| 160598 | {yymsp[0].minor.yy60 = 1;} | ||
| 160599 | break; | 161609 | break; |
| 160600 | case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */ | 161610 | case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */ |
| 160601 | { | 161611 | { |
| 160602 | sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy60,0); | 161612 | sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy376,0); |
| 160603 | } | 161613 | } |
| 160604 | break; | 161614 | break; |
| 160605 | case 20: /* create_table_args ::= AS select */ | 161615 | case 20: /* create_table_args ::= AS select */ |
| 160606 | { | 161616 | { |
| 160607 | sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy307); | 161617 | sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy81); |
| 160608 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy307); | 161618 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy81); |
| 160609 | } | 161619 | } |
| 160610 | break; | 161620 | break; |
| 160611 | case 22: /* table_options ::= WITHOUT nm */ | 161621 | case 22: /* table_options ::= WITHOUT nm */ |
| 160612 | { | 161622 | { |
| 160613 | if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ | 161623 | if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ |
| 160614 | yymsp[-1].minor.yy60 = TF_WithoutRowid | TF_NoVisibleRowid; | 161624 | yymsp[-1].minor.yy376 = TF_WithoutRowid | TF_NoVisibleRowid; |
| 160615 | }else{ | 161625 | }else{ |
| 160616 | yymsp[-1].minor.yy60 = 0; | 161626 | yymsp[-1].minor.yy376 = 0; |
| 160617 | sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); | 161627 | sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); |
| 160618 | } | 161628 | } |
| 160619 | } | 161629 | } |
| @@ -160642,7 +161652,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 160642 | case 28: /* scanpt ::= */ | 161652 | case 28: /* scanpt ::= */ |
| 160643 | { | 161653 | { |
| 160644 | assert( yyLookahead!=YYNOCODE ); | 161654 | assert( yyLookahead!=YYNOCODE ); |
| 160645 | yymsp[1].minor.yy528 = yyLookaheadToken.z; | 161655 | yymsp[1].minor.yy504 = yyLookaheadToken.z; |
| 160646 | } | 161656 | } |
| 160647 | break; | 161657 | break; |
| 160648 | case 29: /* scantok ::= */ | 161658 | case 29: /* scantok ::= */ |
| @@ -160656,17 +161666,17 @@ static YYACTIONTYPE yy_reduce( | |||
| 160656 | {pParse->constraintName = yymsp[0].minor.yy0;} | 161666 | {pParse->constraintName = yymsp[0].minor.yy0;} |
| 160657 | break; | 161667 | break; |
| 160658 | case 31: /* ccons ::= DEFAULT scantok term */ | 161668 | case 31: /* ccons ::= DEFAULT scantok term */ |
| 160659 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy602,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} | 161669 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy404,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 160660 | break; | 161670 | break; |
| 160661 | case 32: /* ccons ::= DEFAULT LP expr RP */ | 161671 | case 32: /* ccons ::= DEFAULT LP expr RP */ |
| 160662 | {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy602,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} | 161672 | {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy404,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} |
| 160663 | break; | 161673 | break; |
| 160664 | case 33: /* ccons ::= DEFAULT PLUS scantok term */ | 161674 | case 33: /* ccons ::= DEFAULT PLUS scantok term */ |
| 160665 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy602,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} | 161675 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy404,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 160666 | break; | 161676 | break; |
| 160667 | case 34: /* ccons ::= DEFAULT MINUS scantok term */ | 161677 | case 34: /* ccons ::= DEFAULT MINUS scantok term */ |
| 160668 | { | 161678 | { |
| 160669 | Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy602, 0); | 161679 | Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy404, 0); |
| 160670 | sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]); | 161680 | sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]); |
| 160671 | } | 161681 | } |
| 160672 | break; | 161682 | break; |
| @@ -160681,158 +161691,161 @@ static YYACTIONTYPE yy_reduce( | |||
| 160681 | } | 161691 | } |
| 160682 | break; | 161692 | break; |
| 160683 | case 36: /* ccons ::= NOT NULL onconf */ | 161693 | case 36: /* ccons ::= NOT NULL onconf */ |
| 160684 | {sqlite3AddNotNull(pParse, yymsp[0].minor.yy60);} | 161694 | {sqlite3AddNotNull(pParse, yymsp[0].minor.yy376);} |
| 160685 | break; | 161695 | break; |
| 160686 | case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ | 161696 | case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 160687 | {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy60,yymsp[0].minor.yy60,yymsp[-2].minor.yy60);} | 161697 | {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy376,yymsp[0].minor.yy376,yymsp[-2].minor.yy376);} |
| 160688 | break; | 161698 | break; |
| 160689 | case 38: /* ccons ::= UNIQUE onconf */ | 161699 | case 38: /* ccons ::= UNIQUE onconf */ |
| 160690 | {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy60,0,0,0,0, | 161700 | {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy376,0,0,0,0, |
| 160691 | SQLITE_IDXTYPE_UNIQUE);} | 161701 | SQLITE_IDXTYPE_UNIQUE);} |
| 160692 | break; | 161702 | break; |
| 160693 | case 39: /* ccons ::= CHECK LP expr RP */ | 161703 | case 39: /* ccons ::= CHECK LP expr RP */ |
| 160694 | {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy602,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);} | 161704 | {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy404,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);} |
| 160695 | break; | 161705 | break; |
| 160696 | case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */ | 161706 | case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 160697 | {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy338,yymsp[0].minor.yy60);} | 161707 | {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy70,yymsp[0].minor.yy376);} |
| 160698 | break; | 161708 | break; |
| 160699 | case 41: /* ccons ::= defer_subclause */ | 161709 | case 41: /* ccons ::= defer_subclause */ |
| 160700 | {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy60);} | 161710 | {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy376);} |
| 160701 | break; | 161711 | break; |
| 160702 | case 42: /* ccons ::= COLLATE ID|STRING */ | 161712 | case 42: /* ccons ::= COLLATE ID|STRING */ |
| 160703 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} | 161713 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} |
| 160704 | break; | 161714 | break; |
| 160705 | case 43: /* generated ::= LP expr RP */ | 161715 | case 43: /* generated ::= LP expr RP */ |
| 160706 | {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy602,0);} | 161716 | {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy404,0);} |
| 160707 | break; | 161717 | break; |
| 160708 | case 44: /* generated ::= LP expr RP ID */ | 161718 | case 44: /* generated ::= LP expr RP ID */ |
| 160709 | {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy602,&yymsp[0].minor.yy0);} | 161719 | {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy404,&yymsp[0].minor.yy0);} |
| 161720 | break; | ||
| 161721 | case 46: /* autoinc ::= AUTOINCR */ | ||
| 161722 | {yymsp[0].minor.yy376 = 1;} | ||
| 160710 | break; | 161723 | break; |
| 160711 | case 47: /* refargs ::= */ | 161724 | case 47: /* refargs ::= */ |
| 160712 | { yymsp[1].minor.yy60 = OE_None*0x0101; /* EV: R-19803-45884 */} | 161725 | { yymsp[1].minor.yy376 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 160713 | break; | 161726 | break; |
| 160714 | case 48: /* refargs ::= refargs refarg */ | 161727 | case 48: /* refargs ::= refargs refarg */ |
| 160715 | { yymsp[-1].minor.yy60 = (yymsp[-1].minor.yy60 & ~yymsp[0].minor.yy615.mask) | yymsp[0].minor.yy615.value; } | 161728 | { yymsp[-1].minor.yy376 = (yymsp[-1].minor.yy376 & ~yymsp[0].minor.yy139.mask) | yymsp[0].minor.yy139.value; } |
| 160716 | break; | 161729 | break; |
| 160717 | case 49: /* refarg ::= MATCH nm */ | 161730 | case 49: /* refarg ::= MATCH nm */ |
| 160718 | { yymsp[-1].minor.yy615.value = 0; yymsp[-1].minor.yy615.mask = 0x000000; } | 161731 | { yymsp[-1].minor.yy139.value = 0; yymsp[-1].minor.yy139.mask = 0x000000; } |
| 160719 | break; | 161732 | break; |
| 160720 | case 50: /* refarg ::= ON INSERT refact */ | 161733 | case 50: /* refarg ::= ON INSERT refact */ |
| 160721 | { yymsp[-2].minor.yy615.value = 0; yymsp[-2].minor.yy615.mask = 0x000000; } | 161734 | { yymsp[-2].minor.yy139.value = 0; yymsp[-2].minor.yy139.mask = 0x000000; } |
| 160722 | break; | 161735 | break; |
| 160723 | case 51: /* refarg ::= ON DELETE refact */ | 161736 | case 51: /* refarg ::= ON DELETE refact */ |
| 160724 | { yymsp[-2].minor.yy615.value = yymsp[0].minor.yy60; yymsp[-2].minor.yy615.mask = 0x0000ff; } | 161737 | { yymsp[-2].minor.yy139.value = yymsp[0].minor.yy376; yymsp[-2].minor.yy139.mask = 0x0000ff; } |
| 160725 | break; | 161738 | break; |
| 160726 | case 52: /* refarg ::= ON UPDATE refact */ | 161739 | case 52: /* refarg ::= ON UPDATE refact */ |
| 160727 | { yymsp[-2].minor.yy615.value = yymsp[0].minor.yy60<<8; yymsp[-2].minor.yy615.mask = 0x00ff00; } | 161740 | { yymsp[-2].minor.yy139.value = yymsp[0].minor.yy376<<8; yymsp[-2].minor.yy139.mask = 0x00ff00; } |
| 160728 | break; | 161741 | break; |
| 160729 | case 53: /* refact ::= SET NULL */ | 161742 | case 53: /* refact ::= SET NULL */ |
| 160730 | { yymsp[-1].minor.yy60 = OE_SetNull; /* EV: R-33326-45252 */} | 161743 | { yymsp[-1].minor.yy376 = OE_SetNull; /* EV: R-33326-45252 */} |
| 160731 | break; | 161744 | break; |
| 160732 | case 54: /* refact ::= SET DEFAULT */ | 161745 | case 54: /* refact ::= SET DEFAULT */ |
| 160733 | { yymsp[-1].minor.yy60 = OE_SetDflt; /* EV: R-33326-45252 */} | 161746 | { yymsp[-1].minor.yy376 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 160734 | break; | 161747 | break; |
| 160735 | case 55: /* refact ::= CASCADE */ | 161748 | case 55: /* refact ::= CASCADE */ |
| 160736 | { yymsp[0].minor.yy60 = OE_Cascade; /* EV: R-33326-45252 */} | 161749 | { yymsp[0].minor.yy376 = OE_Cascade; /* EV: R-33326-45252 */} |
| 160737 | break; | 161750 | break; |
| 160738 | case 56: /* refact ::= RESTRICT */ | 161751 | case 56: /* refact ::= RESTRICT */ |
| 160739 | { yymsp[0].minor.yy60 = OE_Restrict; /* EV: R-33326-45252 */} | 161752 | { yymsp[0].minor.yy376 = OE_Restrict; /* EV: R-33326-45252 */} |
| 160740 | break; | 161753 | break; |
| 160741 | case 57: /* refact ::= NO ACTION */ | 161754 | case 57: /* refact ::= NO ACTION */ |
| 160742 | { yymsp[-1].minor.yy60 = OE_None; /* EV: R-33326-45252 */} | 161755 | { yymsp[-1].minor.yy376 = OE_None; /* EV: R-33326-45252 */} |
| 160743 | break; | 161756 | break; |
| 160744 | case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ | 161757 | case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 160745 | {yymsp[-2].minor.yy60 = 0;} | 161758 | {yymsp[-2].minor.yy376 = 0;} |
| 160746 | break; | 161759 | break; |
| 160747 | case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ | 161760 | case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 160748 | case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74); | 161761 | case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74); |
| 160749 | case 169: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==169); | 161762 | case 169: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==169); |
| 160750 | {yymsp[-1].minor.yy60 = yymsp[0].minor.yy60;} | 161763 | {yymsp[-1].minor.yy376 = yymsp[0].minor.yy376;} |
| 160751 | break; | 161764 | break; |
| 160752 | case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ | 161765 | case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 160753 | case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78); | 161766 | case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78); |
| 160754 | case 211: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==211); | 161767 | case 211: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==211); |
| 160755 | case 214: /* in_op ::= NOT IN */ yytestcase(yyruleno==214); | 161768 | case 214: /* in_op ::= NOT IN */ yytestcase(yyruleno==214); |
| 160756 | case 240: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==240); | 161769 | case 240: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==240); |
| 160757 | {yymsp[-1].minor.yy60 = 1;} | 161770 | {yymsp[-1].minor.yy376 = 1;} |
| 160758 | break; | 161771 | break; |
| 160759 | case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ | 161772 | case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 160760 | {yymsp[-1].minor.yy60 = 0;} | 161773 | {yymsp[-1].minor.yy376 = 0;} |
| 160761 | break; | 161774 | break; |
| 160762 | case 64: /* tconscomma ::= COMMA */ | 161775 | case 64: /* tconscomma ::= COMMA */ |
| 160763 | {pParse->constraintName.n = 0;} | 161776 | {pParse->constraintName.n = 0;} |
| 160764 | break; | 161777 | break; |
| 160765 | case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ | 161778 | case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 160766 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy338,yymsp[0].minor.yy60,yymsp[-2].minor.yy60,0);} | 161779 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy70,yymsp[0].minor.yy376,yymsp[-2].minor.yy376,0);} |
| 160767 | break; | 161780 | break; |
| 160768 | case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */ | 161781 | case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */ |
| 160769 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy338,yymsp[0].minor.yy60,0,0,0,0, | 161782 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy70,yymsp[0].minor.yy376,0,0,0,0, |
| 160770 | SQLITE_IDXTYPE_UNIQUE);} | 161783 | SQLITE_IDXTYPE_UNIQUE);} |
| 160771 | break; | 161784 | break; |
| 160772 | case 68: /* tcons ::= CHECK LP expr RP onconf */ | 161785 | case 68: /* tcons ::= CHECK LP expr RP onconf */ |
| 160773 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy602,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);} | 161786 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy404,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);} |
| 160774 | break; | 161787 | break; |
| 160775 | case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ | 161788 | case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 160776 | { | 161789 | { |
| 160777 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy338, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy338, yymsp[-1].minor.yy60); | 161790 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy70, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy70, yymsp[-1].minor.yy376); |
| 160778 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy60); | 161791 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy376); |
| 160779 | } | 161792 | } |
| 160780 | break; | 161793 | break; |
| 160781 | case 71: /* onconf ::= */ | 161794 | case 71: /* onconf ::= */ |
| 160782 | case 73: /* orconf ::= */ yytestcase(yyruleno==73); | 161795 | case 73: /* orconf ::= */ yytestcase(yyruleno==73); |
| 160783 | {yymsp[1].minor.yy60 = OE_Default;} | 161796 | {yymsp[1].minor.yy376 = OE_Default;} |
| 160784 | break; | 161797 | break; |
| 160785 | case 72: /* onconf ::= ON CONFLICT resolvetype */ | 161798 | case 72: /* onconf ::= ON CONFLICT resolvetype */ |
| 160786 | {yymsp[-2].minor.yy60 = yymsp[0].minor.yy60;} | 161799 | {yymsp[-2].minor.yy376 = yymsp[0].minor.yy376;} |
| 160787 | break; | 161800 | break; |
| 160788 | case 75: /* resolvetype ::= IGNORE */ | 161801 | case 75: /* resolvetype ::= IGNORE */ |
| 160789 | {yymsp[0].minor.yy60 = OE_Ignore;} | 161802 | {yymsp[0].minor.yy376 = OE_Ignore;} |
| 160790 | break; | 161803 | break; |
| 160791 | case 76: /* resolvetype ::= REPLACE */ | 161804 | case 76: /* resolvetype ::= REPLACE */ |
| 160792 | case 170: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==170); | 161805 | case 170: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==170); |
| 160793 | {yymsp[0].minor.yy60 = OE_Replace;} | 161806 | {yymsp[0].minor.yy376 = OE_Replace;} |
| 160794 | break; | 161807 | break; |
| 160795 | case 77: /* cmd ::= DROP TABLE ifexists fullname */ | 161808 | case 77: /* cmd ::= DROP TABLE ifexists fullname */ |
| 160796 | { | 161809 | { |
| 160797 | sqlite3DropTable(pParse, yymsp[0].minor.yy291, 0, yymsp[-1].minor.yy60); | 161810 | sqlite3DropTable(pParse, yymsp[0].minor.yy153, 0, yymsp[-1].minor.yy376); |
| 160798 | } | 161811 | } |
| 160799 | break; | 161812 | break; |
| 160800 | case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ | 161813 | case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 160801 | { | 161814 | { |
| 160802 | sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy338, yymsp[0].minor.yy307, yymsp[-7].minor.yy60, yymsp[-5].minor.yy60); | 161815 | sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy70, yymsp[0].minor.yy81, yymsp[-7].minor.yy376, yymsp[-5].minor.yy376); |
| 160803 | } | 161816 | } |
| 160804 | break; | 161817 | break; |
| 160805 | case 81: /* cmd ::= DROP VIEW ifexists fullname */ | 161818 | case 81: /* cmd ::= DROP VIEW ifexists fullname */ |
| 160806 | { | 161819 | { |
| 160807 | sqlite3DropTable(pParse, yymsp[0].minor.yy291, 1, yymsp[-1].minor.yy60); | 161820 | sqlite3DropTable(pParse, yymsp[0].minor.yy153, 1, yymsp[-1].minor.yy376); |
| 160808 | } | 161821 | } |
| 160809 | break; | 161822 | break; |
| 160810 | case 82: /* cmd ::= select */ | 161823 | case 82: /* cmd ::= select */ |
| 160811 | { | 161824 | { |
| 160812 | SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0}; | 161825 | SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0}; |
| 160813 | sqlite3Select(pParse, yymsp[0].minor.yy307, &dest); | 161826 | sqlite3Select(pParse, yymsp[0].minor.yy81, &dest); |
| 160814 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy307); | 161827 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy81); |
| 160815 | } | 161828 | } |
| 160816 | break; | 161829 | break; |
| 160817 | case 83: /* select ::= WITH wqlist selectnowith */ | 161830 | case 83: /* select ::= WITH wqlist selectnowith */ |
| 160818 | {yymsp[-2].minor.yy307 = attachWithToSelect(pParse,yymsp[0].minor.yy307,yymsp[-1].minor.yy195);} | 161831 | {yymsp[-2].minor.yy81 = attachWithToSelect(pParse,yymsp[0].minor.yy81,yymsp[-1].minor.yy103);} |
| 160819 | break; | 161832 | break; |
| 160820 | case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */ | 161833 | case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */ |
| 160821 | {yymsp[-3].minor.yy307 = attachWithToSelect(pParse,yymsp[0].minor.yy307,yymsp[-1].minor.yy195);} | 161834 | {yymsp[-3].minor.yy81 = attachWithToSelect(pParse,yymsp[0].minor.yy81,yymsp[-1].minor.yy103);} |
| 160822 | break; | 161835 | break; |
| 160823 | case 85: /* select ::= selectnowith */ | 161836 | case 85: /* select ::= selectnowith */ |
| 160824 | { | 161837 | { |
| 160825 | Select *p = yymsp[0].minor.yy307; | 161838 | Select *p = yymsp[0].minor.yy81; |
| 160826 | if( p ){ | 161839 | if( p ){ |
| 160827 | parserDoubleLinkSelect(pParse, p); | 161840 | parserDoubleLinkSelect(pParse, p); |
| 160828 | } | 161841 | } |
| 160829 | yymsp[0].minor.yy307 = p; /*A-overwrites-X*/ | 161842 | yymsp[0].minor.yy81 = p; /*A-overwrites-X*/ |
| 160830 | } | 161843 | } |
| 160831 | break; | 161844 | break; |
| 160832 | case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */ | 161845 | case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */ |
| 160833 | { | 161846 | { |
| 160834 | Select *pRhs = yymsp[0].minor.yy307; | 161847 | Select *pRhs = yymsp[0].minor.yy81; |
| 160835 | Select *pLhs = yymsp[-2].minor.yy307; | 161848 | Select *pLhs = yymsp[-2].minor.yy81; |
| 160836 | if( pRhs && pRhs->pPrior ){ | 161849 | if( pRhs && pRhs->pPrior ){ |
| 160837 | SrcList *pFrom; | 161850 | SrcList *pFrom; |
| 160838 | Token x; | 161851 | Token x; |
| @@ -160842,63 +161855,63 @@ static YYACTIONTYPE yy_reduce( | |||
| 160842 | pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0); | 161855 | pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0); |
| 160843 | } | 161856 | } |
| 160844 | if( pRhs ){ | 161857 | if( pRhs ){ |
| 160845 | pRhs->op = (u8)yymsp[-1].minor.yy60; | 161858 | pRhs->op = (u8)yymsp[-1].minor.yy376; |
| 160846 | pRhs->pPrior = pLhs; | 161859 | pRhs->pPrior = pLhs; |
| 160847 | if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue; | 161860 | if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue; |
| 160848 | pRhs->selFlags &= ~SF_MultiValue; | 161861 | pRhs->selFlags &= ~SF_MultiValue; |
| 160849 | if( yymsp[-1].minor.yy60!=TK_ALL ) pParse->hasCompound = 1; | 161862 | if( yymsp[-1].minor.yy376!=TK_ALL ) pParse->hasCompound = 1; |
| 160850 | }else{ | 161863 | }else{ |
| 160851 | sqlite3SelectDelete(pParse->db, pLhs); | 161864 | sqlite3SelectDelete(pParse->db, pLhs); |
| 160852 | } | 161865 | } |
| 160853 | yymsp[-2].minor.yy307 = pRhs; | 161866 | yymsp[-2].minor.yy81 = pRhs; |
| 160854 | } | 161867 | } |
| 160855 | break; | 161868 | break; |
| 160856 | case 87: /* multiselect_op ::= UNION */ | 161869 | case 87: /* multiselect_op ::= UNION */ |
| 160857 | case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89); | 161870 | case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89); |
| 160858 | {yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-OP*/} | 161871 | {yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-OP*/} |
| 160859 | break; | 161872 | break; |
| 160860 | case 88: /* multiselect_op ::= UNION ALL */ | 161873 | case 88: /* multiselect_op ::= UNION ALL */ |
| 160861 | {yymsp[-1].minor.yy60 = TK_ALL;} | 161874 | {yymsp[-1].minor.yy376 = TK_ALL;} |
| 160862 | break; | 161875 | break; |
| 160863 | case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ | 161876 | case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 160864 | { | 161877 | { |
| 160865 | yymsp[-8].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy338,yymsp[-5].minor.yy291,yymsp[-4].minor.yy602,yymsp[-3].minor.yy338,yymsp[-2].minor.yy602,yymsp[-1].minor.yy338,yymsp[-7].minor.yy60,yymsp[0].minor.yy602); | 161878 | yymsp[-8].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy70,yymsp[-5].minor.yy153,yymsp[-4].minor.yy404,yymsp[-3].minor.yy70,yymsp[-2].minor.yy404,yymsp[-1].minor.yy70,yymsp[-7].minor.yy376,yymsp[0].minor.yy404); |
| 160866 | } | 161879 | } |
| 160867 | break; | 161880 | break; |
| 160868 | case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ | 161881 | case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ |
| 160869 | { | 161882 | { |
| 160870 | yymsp[-9].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy338,yymsp[-6].minor.yy291,yymsp[-5].minor.yy602,yymsp[-4].minor.yy338,yymsp[-3].minor.yy602,yymsp[-1].minor.yy338,yymsp[-8].minor.yy60,yymsp[0].minor.yy602); | 161883 | yymsp[-9].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy70,yymsp[-6].minor.yy153,yymsp[-5].minor.yy404,yymsp[-4].minor.yy70,yymsp[-3].minor.yy404,yymsp[-1].minor.yy70,yymsp[-8].minor.yy376,yymsp[0].minor.yy404); |
| 160871 | if( yymsp[-9].minor.yy307 ){ | 161884 | if( yymsp[-9].minor.yy81 ){ |
| 160872 | yymsp[-9].minor.yy307->pWinDefn = yymsp[-2].minor.yy19; | 161885 | yymsp[-9].minor.yy81->pWinDefn = yymsp[-2].minor.yy49; |
| 160873 | }else{ | 161886 | }else{ |
| 160874 | sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy19); | 161887 | sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy49); |
| 160875 | } | 161888 | } |
| 160876 | } | 161889 | } |
| 160877 | break; | 161890 | break; |
| 160878 | case 92: /* values ::= VALUES LP nexprlist RP */ | 161891 | case 92: /* values ::= VALUES LP nexprlist RP */ |
| 160879 | { | 161892 | { |
| 160880 | yymsp[-3].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy338,0,0,0,0,0,SF_Values,0); | 161893 | yymsp[-3].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy70,0,0,0,0,0,SF_Values,0); |
| 160881 | } | 161894 | } |
| 160882 | break; | 161895 | break; |
| 160883 | case 93: /* values ::= values COMMA LP nexprlist RP */ | 161896 | case 93: /* values ::= values COMMA LP nexprlist RP */ |
| 160884 | { | 161897 | { |
| 160885 | Select *pRight, *pLeft = yymsp[-4].minor.yy307; | 161898 | Select *pRight, *pLeft = yymsp[-4].minor.yy81; |
| 160886 | pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy338,0,0,0,0,0,SF_Values|SF_MultiValue,0); | 161899 | pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy70,0,0,0,0,0,SF_Values|SF_MultiValue,0); |
| 160887 | if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; | 161900 | if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; |
| 160888 | if( pRight ){ | 161901 | if( pRight ){ |
| 160889 | pRight->op = TK_ALL; | 161902 | pRight->op = TK_ALL; |
| 160890 | pRight->pPrior = pLeft; | 161903 | pRight->pPrior = pLeft; |
| 160891 | yymsp[-4].minor.yy307 = pRight; | 161904 | yymsp[-4].minor.yy81 = pRight; |
| 160892 | }else{ | 161905 | }else{ |
| 160893 | yymsp[-4].minor.yy307 = pLeft; | 161906 | yymsp[-4].minor.yy81 = pLeft; |
| 160894 | } | 161907 | } |
| 160895 | } | 161908 | } |
| 160896 | break; | 161909 | break; |
| 160897 | case 94: /* distinct ::= DISTINCT */ | 161910 | case 94: /* distinct ::= DISTINCT */ |
| 160898 | {yymsp[0].minor.yy60 = SF_Distinct;} | 161911 | {yymsp[0].minor.yy376 = SF_Distinct;} |
| 160899 | break; | 161912 | break; |
| 160900 | case 95: /* distinct ::= ALL */ | 161913 | case 95: /* distinct ::= ALL */ |
| 160901 | {yymsp[0].minor.yy60 = SF_All;} | 161914 | {yymsp[0].minor.yy376 = SF_All;} |
| 160902 | break; | 161915 | break; |
| 160903 | case 97: /* sclp ::= */ | 161916 | case 97: /* sclp ::= */ |
| 160904 | case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130); | 161917 | case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130); |
| @@ -160906,19 +161919,19 @@ static YYACTIONTYPE yy_reduce( | |||
| 160906 | case 227: /* exprlist ::= */ yytestcase(yyruleno==227); | 161919 | case 227: /* exprlist ::= */ yytestcase(yyruleno==227); |
| 160907 | case 230: /* paren_exprlist ::= */ yytestcase(yyruleno==230); | 161920 | case 230: /* paren_exprlist ::= */ yytestcase(yyruleno==230); |
| 160908 | case 235: /* eidlist_opt ::= */ yytestcase(yyruleno==235); | 161921 | case 235: /* eidlist_opt ::= */ yytestcase(yyruleno==235); |
| 160909 | {yymsp[1].minor.yy338 = 0;} | 161922 | {yymsp[1].minor.yy70 = 0;} |
| 160910 | break; | 161923 | break; |
| 160911 | case 98: /* selcollist ::= sclp scanpt expr scanpt as */ | 161924 | case 98: /* selcollist ::= sclp scanpt expr scanpt as */ |
| 160912 | { | 161925 | { |
| 160913 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy338, yymsp[-2].minor.yy602); | 161926 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy404); |
| 160914 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy338, &yymsp[0].minor.yy0, 1); | 161927 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy70, &yymsp[0].minor.yy0, 1); |
| 160915 | sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy338,yymsp[-3].minor.yy528,yymsp[-1].minor.yy528); | 161928 | sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy70,yymsp[-3].minor.yy504,yymsp[-1].minor.yy504); |
| 160916 | } | 161929 | } |
| 160917 | break; | 161930 | break; |
| 160918 | case 99: /* selcollist ::= sclp scanpt STAR */ | 161931 | case 99: /* selcollist ::= sclp scanpt STAR */ |
| 160919 | { | 161932 | { |
| 160920 | Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); | 161933 | Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); |
| 160921 | yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy338, p); | 161934 | yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy70, p); |
| 160922 | } | 161935 | } |
| 160923 | break; | 161936 | break; |
| 160924 | case 100: /* selcollist ::= sclp scanpt nm DOT STAR */ | 161937 | case 100: /* selcollist ::= sclp scanpt nm DOT STAR */ |
| @@ -160926,7 +161939,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 160926 | Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); | 161939 | Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); |
| 160927 | Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); | 161940 | Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); |
| 160928 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); | 161941 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); |
| 160929 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, pDot); | 161942 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, pDot); |
| 160930 | } | 161943 | } |
| 160931 | break; | 161944 | break; |
| 160932 | case 101: /* as ::= AS nm */ | 161945 | case 101: /* as ::= AS nm */ |
| @@ -160937,45 +161950,45 @@ static YYACTIONTYPE yy_reduce( | |||
| 160937 | break; | 161950 | break; |
| 160938 | case 103: /* from ::= */ | 161951 | case 103: /* from ::= */ |
| 160939 | case 106: /* stl_prefix ::= */ yytestcase(yyruleno==106); | 161952 | case 106: /* stl_prefix ::= */ yytestcase(yyruleno==106); |
| 160940 | {yymsp[1].minor.yy291 = 0;} | 161953 | {yymsp[1].minor.yy153 = 0;} |
| 160941 | break; | 161954 | break; |
| 160942 | case 104: /* from ::= FROM seltablist */ | 161955 | case 104: /* from ::= FROM seltablist */ |
| 160943 | { | 161956 | { |
| 160944 | yymsp[-1].minor.yy291 = yymsp[0].minor.yy291; | 161957 | yymsp[-1].minor.yy153 = yymsp[0].minor.yy153; |
| 160945 | sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy291); | 161958 | sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy153); |
| 160946 | } | 161959 | } |
| 160947 | break; | 161960 | break; |
| 160948 | case 105: /* stl_prefix ::= seltablist joinop */ | 161961 | case 105: /* stl_prefix ::= seltablist joinop */ |
| 160949 | { | 161962 | { |
| 160950 | if( ALWAYS(yymsp[-1].minor.yy291 && yymsp[-1].minor.yy291->nSrc>0) ) yymsp[-1].minor.yy291->a[yymsp[-1].minor.yy291->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy60; | 161963 | if( ALWAYS(yymsp[-1].minor.yy153 && yymsp[-1].minor.yy153->nSrc>0) ) yymsp[-1].minor.yy153->a[yymsp[-1].minor.yy153->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy376; |
| 160951 | } | 161964 | } |
| 160952 | break; | 161965 | break; |
| 160953 | case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ | 161966 | case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 160954 | { | 161967 | { |
| 160955 | yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288); | 161968 | yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436); |
| 160956 | sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy291, &yymsp[-2].minor.yy0); | 161969 | sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy153, &yymsp[-2].minor.yy0); |
| 160957 | } | 161970 | } |
| 160958 | break; | 161971 | break; |
| 160959 | case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ | 161972 | case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 160960 | { | 161973 | { |
| 160961 | yymsp[-8].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy291,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288); | 161974 | yymsp[-8].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy153,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436); |
| 160962 | sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy291, yymsp[-4].minor.yy338); | 161975 | sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy153, yymsp[-4].minor.yy70); |
| 160963 | } | 161976 | } |
| 160964 | break; | 161977 | break; |
| 160965 | case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ | 161978 | case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 160966 | { | 161979 | { |
| 160967 | yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy307,yymsp[-1].minor.yy602,yymsp[0].minor.yy288); | 161980 | yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy81,yymsp[-1].minor.yy404,yymsp[0].minor.yy436); |
| 160968 | } | 161981 | } |
| 160969 | break; | 161982 | break; |
| 160970 | case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ | 161983 | case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 160971 | { | 161984 | { |
| 160972 | if( yymsp[-6].minor.yy291==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy602==0 && yymsp[0].minor.yy288==0 ){ | 161985 | if( yymsp[-6].minor.yy153==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy404==0 && yymsp[0].minor.yy436==0 ){ |
| 160973 | yymsp[-6].minor.yy291 = yymsp[-4].minor.yy291; | 161986 | yymsp[-6].minor.yy153 = yymsp[-4].minor.yy153; |
| 160974 | }else if( yymsp[-4].minor.yy291->nSrc==1 ){ | 161987 | }else if( yymsp[-4].minor.yy153->nSrc==1 ){ |
| 160975 | yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288); | 161988 | yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436); |
| 160976 | if( yymsp[-6].minor.yy291 ){ | 161989 | if( yymsp[-6].minor.yy153 ){ |
| 160977 | SrcItem *pNew = &yymsp[-6].minor.yy291->a[yymsp[-6].minor.yy291->nSrc-1]; | 161990 | SrcItem *pNew = &yymsp[-6].minor.yy153->a[yymsp[-6].minor.yy153->nSrc-1]; |
| 160978 | SrcItem *pOld = yymsp[-4].minor.yy291->a; | 161991 | SrcItem *pOld = yymsp[-4].minor.yy153->a; |
| 160979 | pNew->zName = pOld->zName; | 161992 | pNew->zName = pOld->zName; |
| 160980 | pNew->zDatabase = pOld->zDatabase; | 161993 | pNew->zDatabase = pOld->zDatabase; |
| 160981 | pNew->pSelect = pOld->pSelect; | 161994 | pNew->pSelect = pOld->pSelect; |
| @@ -160988,12 +162001,12 @@ static YYACTIONTYPE yy_reduce( | |||
| 160988 | pOld->zName = pOld->zDatabase = 0; | 162001 | pOld->zName = pOld->zDatabase = 0; |
| 160989 | pOld->pSelect = 0; | 162002 | pOld->pSelect = 0; |
| 160990 | } | 162003 | } |
| 160991 | sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy291); | 162004 | sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy153); |
| 160992 | }else{ | 162005 | }else{ |
| 160993 | Select *pSubquery; | 162006 | Select *pSubquery; |
| 160994 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy291); | 162007 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy153); |
| 160995 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy291,0,0,0,0,SF_NestedFrom,0); | 162008 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy153,0,0,0,0,SF_NestedFrom,0); |
| 160996 | yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy602,yymsp[0].minor.yy288); | 162009 | yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy404,yymsp[0].minor.yy436); |
| 160997 | } | 162010 | } |
| 160998 | } | 162011 | } |
| 160999 | break; | 162012 | break; |
| @@ -161003,47 +162016,47 @@ static YYACTIONTYPE yy_reduce( | |||
| 161003 | break; | 162016 | break; |
| 161004 | case 113: /* fullname ::= nm */ | 162017 | case 113: /* fullname ::= nm */ |
| 161005 | { | 162018 | { |
| 161006 | yylhsminor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); | 162019 | yylhsminor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); |
| 161007 | if( IN_RENAME_OBJECT && yylhsminor.yy291 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy291->a[0].zName, &yymsp[0].minor.yy0); | 162020 | if( IN_RENAME_OBJECT && yylhsminor.yy153 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy153->a[0].zName, &yymsp[0].minor.yy0); |
| 161008 | } | 162021 | } |
| 161009 | yymsp[0].minor.yy291 = yylhsminor.yy291; | 162022 | yymsp[0].minor.yy153 = yylhsminor.yy153; |
| 161010 | break; | 162023 | break; |
| 161011 | case 114: /* fullname ::= nm DOT nm */ | 162024 | case 114: /* fullname ::= nm DOT nm */ |
| 161012 | { | 162025 | { |
| 161013 | yylhsminor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); | 162026 | yylhsminor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 161014 | if( IN_RENAME_OBJECT && yylhsminor.yy291 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy291->a[0].zName, &yymsp[0].minor.yy0); | 162027 | if( IN_RENAME_OBJECT && yylhsminor.yy153 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy153->a[0].zName, &yymsp[0].minor.yy0); |
| 161015 | } | 162028 | } |
| 161016 | yymsp[-2].minor.yy291 = yylhsminor.yy291; | 162029 | yymsp[-2].minor.yy153 = yylhsminor.yy153; |
| 161017 | break; | 162030 | break; |
| 161018 | case 115: /* xfullname ::= nm */ | 162031 | case 115: /* xfullname ::= nm */ |
| 161019 | {yymsp[0].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} | 162032 | {yymsp[0].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} |
| 161020 | break; | 162033 | break; |
| 161021 | case 116: /* xfullname ::= nm DOT nm */ | 162034 | case 116: /* xfullname ::= nm DOT nm */ |
| 161022 | {yymsp[-2].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} | 162035 | {yymsp[-2].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 161023 | break; | 162036 | break; |
| 161024 | case 117: /* xfullname ::= nm DOT nm AS nm */ | 162037 | case 117: /* xfullname ::= nm DOT nm AS nm */ |
| 161025 | { | 162038 | { |
| 161026 | yymsp[-4].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ | 162039 | yymsp[-4].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ |
| 161027 | if( yymsp[-4].minor.yy291 ) yymsp[-4].minor.yy291->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); | 162040 | if( yymsp[-4].minor.yy153 ) yymsp[-4].minor.yy153->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 161028 | } | 162041 | } |
| 161029 | break; | 162042 | break; |
| 161030 | case 118: /* xfullname ::= nm AS nm */ | 162043 | case 118: /* xfullname ::= nm AS nm */ |
| 161031 | { | 162044 | { |
| 161032 | yymsp[-2].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ | 162045 | yymsp[-2].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ |
| 161033 | if( yymsp[-2].minor.yy291 ) yymsp[-2].minor.yy291->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); | 162046 | if( yymsp[-2].minor.yy153 ) yymsp[-2].minor.yy153->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 161034 | } | 162047 | } |
| 161035 | break; | 162048 | break; |
| 161036 | case 119: /* joinop ::= COMMA|JOIN */ | 162049 | case 119: /* joinop ::= COMMA|JOIN */ |
| 161037 | { yymsp[0].minor.yy60 = JT_INNER; } | 162050 | { yymsp[0].minor.yy376 = JT_INNER; } |
| 161038 | break; | 162051 | break; |
| 161039 | case 120: /* joinop ::= JOIN_KW JOIN */ | 162052 | case 120: /* joinop ::= JOIN_KW JOIN */ |
| 161040 | {yymsp[-1].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} | 162053 | {yymsp[-1].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} |
| 161041 | break; | 162054 | break; |
| 161042 | case 121: /* joinop ::= JOIN_KW nm JOIN */ | 162055 | case 121: /* joinop ::= JOIN_KW nm JOIN */ |
| 161043 | {yymsp[-2].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} | 162056 | {yymsp[-2].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} |
| 161044 | break; | 162057 | break; |
| 161045 | case 122: /* joinop ::= JOIN_KW nm nm JOIN */ | 162058 | case 122: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 161046 | {yymsp[-3].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} | 162059 | {yymsp[-3].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} |
| 161047 | break; | 162060 | break; |
| 161048 | case 123: /* on_opt ::= ON expr */ | 162061 | case 123: /* on_opt ::= ON expr */ |
| 161049 | case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143); | 162062 | case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143); |
| @@ -161051,7 +162064,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 161051 | case 152: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==152); | 162064 | case 152: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==152); |
| 161052 | case 223: /* case_else ::= ELSE expr */ yytestcase(yyruleno==223); | 162065 | case 223: /* case_else ::= ELSE expr */ yytestcase(yyruleno==223); |
| 161053 | case 244: /* vinto ::= INTO expr */ yytestcase(yyruleno==244); | 162066 | case 244: /* vinto ::= INTO expr */ yytestcase(yyruleno==244); |
| 161054 | {yymsp[-1].minor.yy602 = yymsp[0].minor.yy602;} | 162067 | {yymsp[-1].minor.yy404 = yymsp[0].minor.yy404;} |
| 161055 | break; | 162068 | break; |
| 161056 | case 124: /* on_opt ::= */ | 162069 | case 124: /* on_opt ::= */ |
| 161057 | case 142: /* having_opt ::= */ yytestcase(yyruleno==142); | 162070 | case 142: /* having_opt ::= */ yytestcase(yyruleno==142); |
| @@ -161061,7 +162074,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 161061 | case 224: /* case_else ::= */ yytestcase(yyruleno==224); | 162074 | case 224: /* case_else ::= */ yytestcase(yyruleno==224); |
| 161062 | case 226: /* case_operand ::= */ yytestcase(yyruleno==226); | 162075 | case 226: /* case_operand ::= */ yytestcase(yyruleno==226); |
| 161063 | case 245: /* vinto ::= */ yytestcase(yyruleno==245); | 162076 | case 245: /* vinto ::= */ yytestcase(yyruleno==245); |
| 161064 | {yymsp[1].minor.yy602 = 0;} | 162077 | {yymsp[1].minor.yy404 = 0;} |
| 161065 | break; | 162078 | break; |
| 161066 | case 126: /* indexed_opt ::= INDEXED BY nm */ | 162079 | case 126: /* indexed_opt ::= INDEXED BY nm */ |
| 161067 | {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} | 162080 | {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} |
| @@ -161070,142 +162083,142 @@ static YYACTIONTYPE yy_reduce( | |||
| 161070 | {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} | 162083 | {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} |
| 161071 | break; | 162084 | break; |
| 161072 | case 128: /* using_opt ::= USING LP idlist RP */ | 162085 | case 128: /* using_opt ::= USING LP idlist RP */ |
| 161073 | {yymsp[-3].minor.yy288 = yymsp[-1].minor.yy288;} | 162086 | {yymsp[-3].minor.yy436 = yymsp[-1].minor.yy436;} |
| 161074 | break; | 162087 | break; |
| 161075 | case 129: /* using_opt ::= */ | 162088 | case 129: /* using_opt ::= */ |
| 161076 | case 171: /* idlist_opt ::= */ yytestcase(yyruleno==171); | 162089 | case 171: /* idlist_opt ::= */ yytestcase(yyruleno==171); |
| 161077 | {yymsp[1].minor.yy288 = 0;} | 162090 | {yymsp[1].minor.yy436 = 0;} |
| 161078 | break; | 162091 | break; |
| 161079 | case 131: /* orderby_opt ::= ORDER BY sortlist */ | 162092 | case 131: /* orderby_opt ::= ORDER BY sortlist */ |
| 161080 | case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141); | 162093 | case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141); |
| 161081 | {yymsp[-2].minor.yy338 = yymsp[0].minor.yy338;} | 162094 | {yymsp[-2].minor.yy70 = yymsp[0].minor.yy70;} |
| 161082 | break; | 162095 | break; |
| 161083 | case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */ | 162096 | case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 161084 | { | 162097 | { |
| 161085 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338,yymsp[-2].minor.yy602); | 162098 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70,yymsp[-2].minor.yy404); |
| 161086 | sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy338,yymsp[-1].minor.yy60,yymsp[0].minor.yy60); | 162099 | sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy70,yymsp[-1].minor.yy376,yymsp[0].minor.yy376); |
| 161087 | } | 162100 | } |
| 161088 | break; | 162101 | break; |
| 161089 | case 133: /* sortlist ::= expr sortorder nulls */ | 162102 | case 133: /* sortlist ::= expr sortorder nulls */ |
| 161090 | { | 162103 | { |
| 161091 | yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy602); /*A-overwrites-Y*/ | 162104 | yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy404); /*A-overwrites-Y*/ |
| 161092 | sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy338,yymsp[-1].minor.yy60,yymsp[0].minor.yy60); | 162105 | sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy70,yymsp[-1].minor.yy376,yymsp[0].minor.yy376); |
| 161093 | } | 162106 | } |
| 161094 | break; | 162107 | break; |
| 161095 | case 134: /* sortorder ::= ASC */ | 162108 | case 134: /* sortorder ::= ASC */ |
| 161096 | {yymsp[0].minor.yy60 = SQLITE_SO_ASC;} | 162109 | {yymsp[0].minor.yy376 = SQLITE_SO_ASC;} |
| 161097 | break; | 162110 | break; |
| 161098 | case 135: /* sortorder ::= DESC */ | 162111 | case 135: /* sortorder ::= DESC */ |
| 161099 | {yymsp[0].minor.yy60 = SQLITE_SO_DESC;} | 162112 | {yymsp[0].minor.yy376 = SQLITE_SO_DESC;} |
| 161100 | break; | 162113 | break; |
| 161101 | case 136: /* sortorder ::= */ | 162114 | case 136: /* sortorder ::= */ |
| 161102 | case 139: /* nulls ::= */ yytestcase(yyruleno==139); | 162115 | case 139: /* nulls ::= */ yytestcase(yyruleno==139); |
| 161103 | {yymsp[1].minor.yy60 = SQLITE_SO_UNDEFINED;} | 162116 | {yymsp[1].minor.yy376 = SQLITE_SO_UNDEFINED;} |
| 161104 | break; | 162117 | break; |
| 161105 | case 137: /* nulls ::= NULLS FIRST */ | 162118 | case 137: /* nulls ::= NULLS FIRST */ |
| 161106 | {yymsp[-1].minor.yy60 = SQLITE_SO_ASC;} | 162119 | {yymsp[-1].minor.yy376 = SQLITE_SO_ASC;} |
| 161107 | break; | 162120 | break; |
| 161108 | case 138: /* nulls ::= NULLS LAST */ | 162121 | case 138: /* nulls ::= NULLS LAST */ |
| 161109 | {yymsp[-1].minor.yy60 = SQLITE_SO_DESC;} | 162122 | {yymsp[-1].minor.yy376 = SQLITE_SO_DESC;} |
| 161110 | break; | 162123 | break; |
| 161111 | case 145: /* limit_opt ::= LIMIT expr */ | 162124 | case 145: /* limit_opt ::= LIMIT expr */ |
| 161112 | {yymsp[-1].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy602,0);} | 162125 | {yymsp[-1].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy404,0);} |
| 161113 | break; | 162126 | break; |
| 161114 | case 146: /* limit_opt ::= LIMIT expr OFFSET expr */ | 162127 | case 146: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 161115 | {yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);} | 162128 | {yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);} |
| 161116 | break; | 162129 | break; |
| 161117 | case 147: /* limit_opt ::= LIMIT expr COMMA expr */ | 162130 | case 147: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 161118 | {yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy602,yymsp[-2].minor.yy602);} | 162131 | {yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy404,yymsp[-2].minor.yy404);} |
| 161119 | break; | 162132 | break; |
| 161120 | case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ | 162133 | case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 161121 | { | 162134 | { |
| 161122 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy291, &yymsp[-1].minor.yy0); | 162135 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy153, &yymsp[-1].minor.yy0); |
| 161123 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy291,yymsp[0].minor.yy602,0,0); | 162136 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy153,yymsp[0].minor.yy404,0,0); |
| 161124 | } | 162137 | } |
| 161125 | break; | 162138 | break; |
| 161126 | case 153: /* where_opt_ret ::= RETURNING selcollist */ | 162139 | case 153: /* where_opt_ret ::= RETURNING selcollist */ |
| 161127 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy338); yymsp[-1].minor.yy602 = 0;} | 162140 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy70); yymsp[-1].minor.yy404 = 0;} |
| 161128 | break; | 162141 | break; |
| 161129 | case 154: /* where_opt_ret ::= WHERE expr RETURNING selcollist */ | 162142 | case 154: /* where_opt_ret ::= WHERE expr RETURNING selcollist */ |
| 161130 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy338); yymsp[-3].minor.yy602 = yymsp[-2].minor.yy602;} | 162143 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy70); yymsp[-3].minor.yy404 = yymsp[-2].minor.yy404;} |
| 161131 | break; | 162144 | break; |
| 161132 | case 155: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ | 162145 | case 155: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ |
| 161133 | { | 162146 | { |
| 161134 | sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy291, &yymsp[-4].minor.yy0); | 162147 | sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy153, &yymsp[-4].minor.yy0); |
| 161135 | sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy338,"set list"); | 162148 | sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy70,"set list"); |
| 161136 | yymsp[-5].minor.yy291 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy291, yymsp[-1].minor.yy291); | 162149 | yymsp[-5].minor.yy153 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy153, yymsp[-1].minor.yy153); |
| 161137 | sqlite3Update(pParse,yymsp[-5].minor.yy291,yymsp[-2].minor.yy338,yymsp[0].minor.yy602,yymsp[-6].minor.yy60,0,0,0); | 162150 | sqlite3Update(pParse,yymsp[-5].minor.yy153,yymsp[-2].minor.yy70,yymsp[0].minor.yy404,yymsp[-6].minor.yy376,0,0,0); |
| 161138 | } | 162151 | } |
| 161139 | break; | 162152 | break; |
| 161140 | case 156: /* setlist ::= setlist COMMA nm EQ expr */ | 162153 | case 156: /* setlist ::= setlist COMMA nm EQ expr */ |
| 161141 | { | 162154 | { |
| 161142 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy338, yymsp[0].minor.yy602); | 162155 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy70, yymsp[0].minor.yy404); |
| 161143 | sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy338, &yymsp[-2].minor.yy0, 1); | 162156 | sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy70, &yymsp[-2].minor.yy0, 1); |
| 161144 | } | 162157 | } |
| 161145 | break; | 162158 | break; |
| 161146 | case 157: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ | 162159 | case 157: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 161147 | { | 162160 | { |
| 161148 | yymsp[-6].minor.yy338 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy338, yymsp[-3].minor.yy288, yymsp[0].minor.yy602); | 162161 | yymsp[-6].minor.yy70 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy70, yymsp[-3].minor.yy436, yymsp[0].minor.yy404); |
| 161149 | } | 162162 | } |
| 161150 | break; | 162163 | break; |
| 161151 | case 158: /* setlist ::= nm EQ expr */ | 162164 | case 158: /* setlist ::= nm EQ expr */ |
| 161152 | { | 162165 | { |
| 161153 | yylhsminor.yy338 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy602); | 162166 | yylhsminor.yy70 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy404); |
| 161154 | sqlite3ExprListSetName(pParse, yylhsminor.yy338, &yymsp[-2].minor.yy0, 1); | 162167 | sqlite3ExprListSetName(pParse, yylhsminor.yy70, &yymsp[-2].minor.yy0, 1); |
| 161155 | } | 162168 | } |
| 161156 | yymsp[-2].minor.yy338 = yylhsminor.yy338; | 162169 | yymsp[-2].minor.yy70 = yylhsminor.yy70; |
| 161157 | break; | 162170 | break; |
| 161158 | case 159: /* setlist ::= LP idlist RP EQ expr */ | 162171 | case 159: /* setlist ::= LP idlist RP EQ expr */ |
| 161159 | { | 162172 | { |
| 161160 | yymsp[-4].minor.yy338 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy288, yymsp[0].minor.yy602); | 162173 | yymsp[-4].minor.yy70 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy436, yymsp[0].minor.yy404); |
| 161161 | } | 162174 | } |
| 161162 | break; | 162175 | break; |
| 161163 | case 160: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ | 162176 | case 160: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 161164 | { | 162177 | { |
| 161165 | sqlite3Insert(pParse, yymsp[-3].minor.yy291, yymsp[-1].minor.yy307, yymsp[-2].minor.yy288, yymsp[-5].minor.yy60, yymsp[0].minor.yy178); | 162178 | sqlite3Insert(pParse, yymsp[-3].minor.yy153, yymsp[-1].minor.yy81, yymsp[-2].minor.yy436, yymsp[-5].minor.yy376, yymsp[0].minor.yy190); |
| 161166 | } | 162179 | } |
| 161167 | break; | 162180 | break; |
| 161168 | case 161: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ | 162181 | case 161: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 161169 | { | 162182 | { |
| 161170 | sqlite3Insert(pParse, yymsp[-4].minor.yy291, 0, yymsp[-3].minor.yy288, yymsp[-6].minor.yy60, 0); | 162183 | sqlite3Insert(pParse, yymsp[-4].minor.yy153, 0, yymsp[-3].minor.yy436, yymsp[-6].minor.yy376, 0); |
| 161171 | } | 162184 | } |
| 161172 | break; | 162185 | break; |
| 161173 | case 162: /* upsert ::= */ | 162186 | case 162: /* upsert ::= */ |
| 161174 | { yymsp[1].minor.yy178 = 0; } | 162187 | { yymsp[1].minor.yy190 = 0; } |
| 161175 | break; | 162188 | break; |
| 161176 | case 163: /* upsert ::= RETURNING selcollist */ | 162189 | case 163: /* upsert ::= RETURNING selcollist */ |
| 161177 | { yymsp[-1].minor.yy178 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy338); } | 162190 | { yymsp[-1].minor.yy190 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy70); } |
| 161178 | break; | 162191 | break; |
| 161179 | case 164: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ | 162192 | case 164: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ |
| 161180 | { yymsp[-11].minor.yy178 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy338,yymsp[-6].minor.yy602,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602,yymsp[0].minor.yy178);} | 162193 | { yymsp[-11].minor.yy190 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy70,yymsp[-6].minor.yy404,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404,yymsp[0].minor.yy190);} |
| 161181 | break; | 162194 | break; |
| 161182 | case 165: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ | 162195 | case 165: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 161183 | { yymsp[-8].minor.yy178 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy338,yymsp[-3].minor.yy602,0,0,yymsp[0].minor.yy178); } | 162196 | { yymsp[-8].minor.yy190 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy70,yymsp[-3].minor.yy404,0,0,yymsp[0].minor.yy190); } |
| 161184 | break; | 162197 | break; |
| 161185 | case 166: /* upsert ::= ON CONFLICT DO NOTHING returning */ | 162198 | case 166: /* upsert ::= ON CONFLICT DO NOTHING returning */ |
| 161186 | { yymsp[-4].minor.yy178 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); } | 162199 | { yymsp[-4].minor.yy190 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); } |
| 161187 | break; | 162200 | break; |
| 161188 | case 167: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ | 162201 | case 167: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 161189 | { yymsp[-7].minor.yy178 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602,0);} | 162202 | { yymsp[-7].minor.yy190 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404,0);} |
| 161190 | break; | 162203 | break; |
| 161191 | case 168: /* returning ::= RETURNING selcollist */ | 162204 | case 168: /* returning ::= RETURNING selcollist */ |
| 161192 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy338);} | 162205 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy70);} |
| 161193 | break; | 162206 | break; |
| 161194 | case 172: /* idlist_opt ::= LP idlist RP */ | 162207 | case 172: /* idlist_opt ::= LP idlist RP */ |
| 161195 | {yymsp[-2].minor.yy288 = yymsp[-1].minor.yy288;} | 162208 | {yymsp[-2].minor.yy436 = yymsp[-1].minor.yy436;} |
| 161196 | break; | 162209 | break; |
| 161197 | case 173: /* idlist ::= idlist COMMA nm */ | 162210 | case 173: /* idlist ::= idlist COMMA nm */ |
| 161198 | {yymsp[-2].minor.yy288 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy288,&yymsp[0].minor.yy0);} | 162211 | {yymsp[-2].minor.yy436 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy436,&yymsp[0].minor.yy0);} |
| 161199 | break; | 162212 | break; |
| 161200 | case 174: /* idlist ::= nm */ | 162213 | case 174: /* idlist ::= nm */ |
| 161201 | {yymsp[0].minor.yy288 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} | 162214 | {yymsp[0].minor.yy436 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} |
| 161202 | break; | 162215 | break; |
| 161203 | case 175: /* expr ::= LP expr RP */ | 162216 | case 175: /* expr ::= LP expr RP */ |
| 161204 | {yymsp[-2].minor.yy602 = yymsp[-1].minor.yy602;} | 162217 | {yymsp[-2].minor.yy404 = yymsp[-1].minor.yy404;} |
| 161205 | break; | 162218 | break; |
| 161206 | case 176: /* expr ::= ID|INDEXED */ | 162219 | case 176: /* expr ::= ID|INDEXED */ |
| 161207 | case 177: /* expr ::= JOIN_KW */ yytestcase(yyruleno==177); | 162220 | case 177: /* expr ::= JOIN_KW */ yytestcase(yyruleno==177); |
| 161208 | {yymsp[0].minor.yy602=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} | 162221 | {yymsp[0].minor.yy404=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 161209 | break; | 162222 | break; |
| 161210 | case 178: /* expr ::= nm DOT nm */ | 162223 | case 178: /* expr ::= nm DOT nm */ |
| 161211 | { | 162224 | { |
| @@ -161215,9 +162228,9 @@ static YYACTIONTYPE yy_reduce( | |||
| 161215 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0); | 162228 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0); |
| 161216 | sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0); | 162229 | sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0); |
| 161217 | } | 162230 | } |
| 161218 | yylhsminor.yy602 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); | 162231 | yylhsminor.yy404 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); |
| 161219 | } | 162232 | } |
| 161220 | yymsp[-2].minor.yy602 = yylhsminor.yy602; | 162233 | yymsp[-2].minor.yy404 = yylhsminor.yy404; |
| 161221 | break; | 162234 | break; |
| 161222 | case 179: /* expr ::= nm DOT nm DOT nm */ | 162235 | case 179: /* expr ::= nm DOT nm DOT nm */ |
| 161223 | { | 162236 | { |
| @@ -161229,26 +162242,26 @@ static YYACTIONTYPE yy_reduce( | |||
| 161229 | sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0); | 162242 | sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0); |
| 161230 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0); | 162243 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0); |
| 161231 | } | 162244 | } |
| 161232 | yylhsminor.yy602 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); | 162245 | yylhsminor.yy404 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); |
| 161233 | } | 162246 | } |
| 161234 | yymsp[-4].minor.yy602 = yylhsminor.yy602; | 162247 | yymsp[-4].minor.yy404 = yylhsminor.yy404; |
| 161235 | break; | 162248 | break; |
| 161236 | case 180: /* term ::= NULL|FLOAT|BLOB */ | 162249 | case 180: /* term ::= NULL|FLOAT|BLOB */ |
| 161237 | case 181: /* term ::= STRING */ yytestcase(yyruleno==181); | 162250 | case 181: /* term ::= STRING */ yytestcase(yyruleno==181); |
| 161238 | {yymsp[0].minor.yy602=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} | 162251 | {yymsp[0].minor.yy404=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 161239 | break; | 162252 | break; |
| 161240 | case 182: /* term ::= INTEGER */ | 162253 | case 182: /* term ::= INTEGER */ |
| 161241 | { | 162254 | { |
| 161242 | yylhsminor.yy602 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); | 162255 | yylhsminor.yy404 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); |
| 161243 | } | 162256 | } |
| 161244 | yymsp[0].minor.yy602 = yylhsminor.yy602; | 162257 | yymsp[0].minor.yy404 = yylhsminor.yy404; |
| 161245 | break; | 162258 | break; |
| 161246 | case 183: /* expr ::= VARIABLE */ | 162259 | case 183: /* expr ::= VARIABLE */ |
| 161247 | { | 162260 | { |
| 161248 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ | 162261 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ |
| 161249 | u32 n = yymsp[0].minor.yy0.n; | 162262 | u32 n = yymsp[0].minor.yy0.n; |
| 161250 | yymsp[0].minor.yy602 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); | 162263 | yymsp[0].minor.yy404 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); |
| 161251 | sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy602, n); | 162264 | sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy404, n); |
| 161252 | }else{ | 162265 | }else{ |
| 161253 | /* When doing a nested parse, one can include terms in an expression | 162266 | /* When doing a nested parse, one can include terms in an expression |
| 161254 | ** that look like this: #1 #2 ... These terms refer to registers | 162267 | ** that look like this: #1 #2 ... These terms refer to registers |
| @@ -161257,65 +162270,65 @@ static YYACTIONTYPE yy_reduce( | |||
| 161257 | assert( t.n>=2 ); | 162270 | assert( t.n>=2 ); |
| 161258 | if( pParse->nested==0 ){ | 162271 | if( pParse->nested==0 ){ |
| 161259 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); | 162272 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); |
| 161260 | yymsp[0].minor.yy602 = 0; | 162273 | yymsp[0].minor.yy404 = 0; |
| 161261 | }else{ | 162274 | }else{ |
| 161262 | yymsp[0].minor.yy602 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); | 162275 | yymsp[0].minor.yy404 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); |
| 161263 | if( yymsp[0].minor.yy602 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy602->iTable); | 162276 | if( yymsp[0].minor.yy404 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy404->iTable); |
| 161264 | } | 162277 | } |
| 161265 | } | 162278 | } |
| 161266 | } | 162279 | } |
| 161267 | break; | 162280 | break; |
| 161268 | case 184: /* expr ::= expr COLLATE ID|STRING */ | 162281 | case 184: /* expr ::= expr COLLATE ID|STRING */ |
| 161269 | { | 162282 | { |
| 161270 | yymsp[-2].minor.yy602 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy602, &yymsp[0].minor.yy0, 1); | 162283 | yymsp[-2].minor.yy404 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy404, &yymsp[0].minor.yy0, 1); |
| 161271 | } | 162284 | } |
| 161272 | break; | 162285 | break; |
| 161273 | case 185: /* expr ::= CAST LP expr AS typetoken RP */ | 162286 | case 185: /* expr ::= CAST LP expr AS typetoken RP */ |
| 161274 | { | 162287 | { |
| 161275 | yymsp[-5].minor.yy602 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); | 162288 | yymsp[-5].minor.yy404 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); |
| 161276 | sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy602, yymsp[-3].minor.yy602, 0); | 162289 | sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy404, yymsp[-3].minor.yy404, 0); |
| 161277 | } | 162290 | } |
| 161278 | break; | 162291 | break; |
| 161279 | case 186: /* expr ::= ID|INDEXED LP distinct exprlist RP */ | 162292 | case 186: /* expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 161280 | { | 162293 | { |
| 161281 | yylhsminor.yy602 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy338, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy60); | 162294 | yylhsminor.yy404 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy70, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy376); |
| 161282 | } | 162295 | } |
| 161283 | yymsp[-4].minor.yy602 = yylhsminor.yy602; | 162296 | yymsp[-4].minor.yy404 = yylhsminor.yy404; |
| 161284 | break; | 162297 | break; |
| 161285 | case 187: /* expr ::= ID|INDEXED LP STAR RP */ | 162298 | case 187: /* expr ::= ID|INDEXED LP STAR RP */ |
| 161286 | { | 162299 | { |
| 161287 | yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); | 162300 | yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); |
| 161288 | } | 162301 | } |
| 161289 | yymsp[-3].minor.yy602 = yylhsminor.yy602; | 162302 | yymsp[-3].minor.yy404 = yylhsminor.yy404; |
| 161290 | break; | 162303 | break; |
| 161291 | case 188: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ | 162304 | case 188: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ |
| 161292 | { | 162305 | { |
| 161293 | yylhsminor.yy602 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy338, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy60); | 162306 | yylhsminor.yy404 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy70, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy376); |
| 161294 | sqlite3WindowAttach(pParse, yylhsminor.yy602, yymsp[0].minor.yy19); | 162307 | sqlite3WindowAttach(pParse, yylhsminor.yy404, yymsp[0].minor.yy49); |
| 161295 | } | 162308 | } |
| 161296 | yymsp[-5].minor.yy602 = yylhsminor.yy602; | 162309 | yymsp[-5].minor.yy404 = yylhsminor.yy404; |
| 161297 | break; | 162310 | break; |
| 161298 | case 189: /* expr ::= ID|INDEXED LP STAR RP filter_over */ | 162311 | case 189: /* expr ::= ID|INDEXED LP STAR RP filter_over */ |
| 161299 | { | 162312 | { |
| 161300 | yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); | 162313 | yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); |
| 161301 | sqlite3WindowAttach(pParse, yylhsminor.yy602, yymsp[0].minor.yy19); | 162314 | sqlite3WindowAttach(pParse, yylhsminor.yy404, yymsp[0].minor.yy49); |
| 161302 | } | 162315 | } |
| 161303 | yymsp[-4].minor.yy602 = yylhsminor.yy602; | 162316 | yymsp[-4].minor.yy404 = yylhsminor.yy404; |
| 161304 | break; | 162317 | break; |
| 161305 | case 190: /* term ::= CTIME_KW */ | 162318 | case 190: /* term ::= CTIME_KW */ |
| 161306 | { | 162319 | { |
| 161307 | yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); | 162320 | yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); |
| 161308 | } | 162321 | } |
| 161309 | yymsp[0].minor.yy602 = yylhsminor.yy602; | 162322 | yymsp[0].minor.yy404 = yylhsminor.yy404; |
| 161310 | break; | 162323 | break; |
| 161311 | case 191: /* expr ::= LP nexprlist COMMA expr RP */ | 162324 | case 191: /* expr ::= LP nexprlist COMMA expr RP */ |
| 161312 | { | 162325 | { |
| 161313 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy338, yymsp[-1].minor.yy602); | 162326 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy70, yymsp[-1].minor.yy404); |
| 161314 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); | 162327 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); |
| 161315 | if( yymsp[-4].minor.yy602 ){ | 162328 | if( yymsp[-4].minor.yy404 ){ |
| 161316 | yymsp[-4].minor.yy602->x.pList = pList; | 162329 | yymsp[-4].minor.yy404->x.pList = pList; |
| 161317 | if( ALWAYS(pList->nExpr) ){ | 162330 | if( ALWAYS(pList->nExpr) ){ |
| 161318 | yymsp[-4].minor.yy602->flags |= pList->a[0].pExpr->flags & EP_Propagate; | 162331 | yymsp[-4].minor.yy404->flags |= pList->a[0].pExpr->flags & EP_Propagate; |
| 161319 | } | 162332 | } |
| 161320 | }else{ | 162333 | }else{ |
| 161321 | sqlite3ExprListDelete(pParse->db, pList); | 162334 | sqlite3ExprListDelete(pParse->db, pList); |
| @@ -161323,7 +162336,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 161323 | } | 162336 | } |
| 161324 | break; | 162337 | break; |
| 161325 | case 192: /* expr ::= expr AND expr */ | 162338 | case 192: /* expr ::= expr AND expr */ |
| 161326 | {yymsp[-2].minor.yy602=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);} | 162339 | {yymsp[-2].minor.yy404=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);} |
| 161327 | break; | 162340 | break; |
| 161328 | case 193: /* expr ::= expr OR expr */ | 162341 | case 193: /* expr ::= expr OR expr */ |
| 161329 | case 194: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==194); | 162342 | case 194: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==194); |
| @@ -161332,7 +162345,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 161332 | case 197: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==197); | 162345 | case 197: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==197); |
| 161333 | case 198: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==198); | 162346 | case 198: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==198); |
| 161334 | case 199: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==199); | 162347 | case 199: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==199); |
| 161335 | {yymsp[-2].minor.yy602=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);} | 162348 | {yymsp[-2].minor.yy404=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);} |
| 161336 | break; | 162349 | break; |
| 161337 | case 200: /* likeop ::= NOT LIKE_KW|MATCH */ | 162350 | case 200: /* likeop ::= NOT LIKE_KW|MATCH */ |
| 161338 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} | 162351 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} |
| @@ -161342,11 +162355,11 @@ static YYACTIONTYPE yy_reduce( | |||
| 161342 | ExprList *pList; | 162355 | ExprList *pList; |
| 161343 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; | 162356 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; |
| 161344 | yymsp[-1].minor.yy0.n &= 0x7fffffff; | 162357 | yymsp[-1].minor.yy0.n &= 0x7fffffff; |
| 161345 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy602); | 162358 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy404); |
| 161346 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy602); | 162359 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy404); |
| 161347 | yymsp[-2].minor.yy602 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); | 162360 | yymsp[-2].minor.yy404 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 161348 | if( bNot ) yymsp[-2].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy602, 0); | 162361 | if( bNot ) yymsp[-2].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy404, 0); |
| 161349 | if( yymsp[-2].minor.yy602 ) yymsp[-2].minor.yy602->flags |= EP_InfixFunc; | 162362 | if( yymsp[-2].minor.yy404 ) yymsp[-2].minor.yy404->flags |= EP_InfixFunc; |
| 161350 | } | 162363 | } |
| 161351 | break; | 162364 | break; |
| 161352 | case 202: /* expr ::= expr likeop expr ESCAPE expr */ | 162365 | case 202: /* expr ::= expr likeop expr ESCAPE expr */ |
| @@ -161354,62 +162367,62 @@ static YYACTIONTYPE yy_reduce( | |||
| 161354 | ExprList *pList; | 162367 | ExprList *pList; |
| 161355 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; | 162368 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; |
| 161356 | yymsp[-3].minor.yy0.n &= 0x7fffffff; | 162369 | yymsp[-3].minor.yy0.n &= 0x7fffffff; |
| 161357 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602); | 162370 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404); |
| 161358 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy602); | 162371 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy404); |
| 161359 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy602); | 162372 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy404); |
| 161360 | yymsp[-4].minor.yy602 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); | 162373 | yymsp[-4].minor.yy404 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); |
| 161361 | if( bNot ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); | 162374 | if( bNot ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 161362 | if( yymsp[-4].minor.yy602 ) yymsp[-4].minor.yy602->flags |= EP_InfixFunc; | 162375 | if( yymsp[-4].minor.yy404 ) yymsp[-4].minor.yy404->flags |= EP_InfixFunc; |
| 161363 | } | 162376 | } |
| 161364 | break; | 162377 | break; |
| 161365 | case 203: /* expr ::= expr ISNULL|NOTNULL */ | 162378 | case 203: /* expr ::= expr ISNULL|NOTNULL */ |
| 161366 | {yymsp[-1].minor.yy602 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy602,0);} | 162379 | {yymsp[-1].minor.yy404 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy404,0);} |
| 161367 | break; | 162380 | break; |
| 161368 | case 204: /* expr ::= expr NOT NULL */ | 162381 | case 204: /* expr ::= expr NOT NULL */ |
| 161369 | {yymsp[-2].minor.yy602 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy602,0);} | 162382 | {yymsp[-2].minor.yy404 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy404,0);} |
| 161370 | break; | 162383 | break; |
| 161371 | case 205: /* expr ::= expr IS expr */ | 162384 | case 205: /* expr ::= expr IS expr */ |
| 161372 | { | 162385 | { |
| 161373 | yymsp[-2].minor.yy602 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy602,yymsp[0].minor.yy602); | 162386 | yymsp[-2].minor.yy404 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy404,yymsp[0].minor.yy404); |
| 161374 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy602, yymsp[-2].minor.yy602, TK_ISNULL); | 162387 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy404, yymsp[-2].minor.yy404, TK_ISNULL); |
| 161375 | } | 162388 | } |
| 161376 | break; | 162389 | break; |
| 161377 | case 206: /* expr ::= expr IS NOT expr */ | 162390 | case 206: /* expr ::= expr IS NOT expr */ |
| 161378 | { | 162391 | { |
| 161379 | yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy602,yymsp[0].minor.yy602); | 162392 | yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy404,yymsp[0].minor.yy404); |
| 161380 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy602, yymsp[-3].minor.yy602, TK_NOTNULL); | 162393 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy404, yymsp[-3].minor.yy404, TK_NOTNULL); |
| 161381 | } | 162394 | } |
| 161382 | break; | 162395 | break; |
| 161383 | case 207: /* expr ::= NOT expr */ | 162396 | case 207: /* expr ::= NOT expr */ |
| 161384 | case 208: /* expr ::= BITNOT expr */ yytestcase(yyruleno==208); | 162397 | case 208: /* expr ::= BITNOT expr */ yytestcase(yyruleno==208); |
| 161385 | {yymsp[-1].minor.yy602 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy602, 0);/*A-overwrites-B*/} | 162398 | {yymsp[-1].minor.yy404 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy404, 0);/*A-overwrites-B*/} |
| 161386 | break; | 162399 | break; |
| 161387 | case 209: /* expr ::= PLUS|MINUS expr */ | 162400 | case 209: /* expr ::= PLUS|MINUS expr */ |
| 161388 | { | 162401 | { |
| 161389 | yymsp[-1].minor.yy602 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy602, 0); | 162402 | yymsp[-1].minor.yy404 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy404, 0); |
| 161390 | /*A-overwrites-B*/ | 162403 | /*A-overwrites-B*/ |
| 161391 | } | 162404 | } |
| 161392 | break; | 162405 | break; |
| 161393 | case 210: /* between_op ::= BETWEEN */ | 162406 | case 210: /* between_op ::= BETWEEN */ |
| 161394 | case 213: /* in_op ::= IN */ yytestcase(yyruleno==213); | 162407 | case 213: /* in_op ::= IN */ yytestcase(yyruleno==213); |
| 161395 | {yymsp[0].minor.yy60 = 0;} | 162408 | {yymsp[0].minor.yy376 = 0;} |
| 161396 | break; | 162409 | break; |
| 161397 | case 212: /* expr ::= expr between_op expr AND expr */ | 162410 | case 212: /* expr ::= expr between_op expr AND expr */ |
| 161398 | { | 162411 | { |
| 161399 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602); | 162412 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404); |
| 161400 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy602); | 162413 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy404); |
| 161401 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy602, 0); | 162414 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy404, 0); |
| 161402 | if( yymsp[-4].minor.yy602 ){ | 162415 | if( yymsp[-4].minor.yy404 ){ |
| 161403 | yymsp[-4].minor.yy602->x.pList = pList; | 162416 | yymsp[-4].minor.yy404->x.pList = pList; |
| 161404 | }else{ | 162417 | }else{ |
| 161405 | sqlite3ExprListDelete(pParse->db, pList); | 162418 | sqlite3ExprListDelete(pParse->db, pList); |
| 161406 | } | 162419 | } |
| 161407 | if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); | 162420 | if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 161408 | } | 162421 | } |
| 161409 | break; | 162422 | break; |
| 161410 | case 215: /* expr ::= expr in_op LP exprlist RP */ | 162423 | case 215: /* expr ::= expr in_op LP exprlist RP */ |
| 161411 | { | 162424 | { |
| 161412 | if( yymsp[-1].minor.yy338==0 ){ | 162425 | if( yymsp[-1].minor.yy70==0 ){ |
| 161413 | /* Expressions of the form | 162426 | /* Expressions of the form |
| 161414 | ** | 162427 | ** |
| 161415 | ** expr1 IN () | 162428 | ** expr1 IN () |
| @@ -161418,99 +162431,99 @@ static YYACTIONTYPE yy_reduce( | |||
| 161418 | ** simplify to constants 0 (false) and 1 (true), respectively, | 162431 | ** simplify to constants 0 (false) and 1 (true), respectively, |
| 161419 | ** regardless of the value of expr1. | 162432 | ** regardless of the value of expr1. |
| 161420 | */ | 162433 | */ |
| 161421 | sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy602); | 162434 | sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy404); |
| 161422 | yymsp[-4].minor.yy602 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy60 ? "1" : "0"); | 162435 | yymsp[-4].minor.yy404 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy376 ? "1" : "0"); |
| 161423 | }else if( yymsp[-1].minor.yy338->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy338->a[0].pExpr) ){ | 162436 | }else if( yymsp[-1].minor.yy70->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy70->a[0].pExpr) ){ |
| 161424 | Expr *pRHS = yymsp[-1].minor.yy338->a[0].pExpr; | 162437 | Expr *pRHS = yymsp[-1].minor.yy70->a[0].pExpr; |
| 161425 | yymsp[-1].minor.yy338->a[0].pExpr = 0; | 162438 | yymsp[-1].minor.yy70->a[0].pExpr = 0; |
| 161426 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy338); | 162439 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70); |
| 161427 | pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0); | 162440 | pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0); |
| 161428 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy602, pRHS); | 162441 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy404, pRHS); |
| 161429 | if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); | 162442 | if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 161430 | }else{ | 162443 | }else{ |
| 161431 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0); | 162444 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0); |
| 161432 | if( yymsp[-4].minor.yy602 ){ | 162445 | if( yymsp[-4].minor.yy404 ){ |
| 161433 | yymsp[-4].minor.yy602->x.pList = yymsp[-1].minor.yy338; | 162446 | yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy70; |
| 161434 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy602); | 162447 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404); |
| 161435 | }else{ | 162448 | }else{ |
| 161436 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy338); | 162449 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70); |
| 161437 | } | 162450 | } |
| 161438 | if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); | 162451 | if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 161439 | } | 162452 | } |
| 161440 | } | 162453 | } |
| 161441 | break; | 162454 | break; |
| 161442 | case 216: /* expr ::= LP select RP */ | 162455 | case 216: /* expr ::= LP select RP */ |
| 161443 | { | 162456 | { |
| 161444 | yymsp[-2].minor.yy602 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); | 162457 | yymsp[-2].minor.yy404 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); |
| 161445 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy602, yymsp[-1].minor.yy307); | 162458 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy404, yymsp[-1].minor.yy81); |
| 161446 | } | 162459 | } |
| 161447 | break; | 162460 | break; |
| 161448 | case 217: /* expr ::= expr in_op LP select RP */ | 162461 | case 217: /* expr ::= expr in_op LP select RP */ |
| 161449 | { | 162462 | { |
| 161450 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0); | 162463 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0); |
| 161451 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy602, yymsp[-1].minor.yy307); | 162464 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, yymsp[-1].minor.yy81); |
| 161452 | if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); | 162465 | if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 161453 | } | 162466 | } |
| 161454 | break; | 162467 | break; |
| 161455 | case 218: /* expr ::= expr in_op nm dbnm paren_exprlist */ | 162468 | case 218: /* expr ::= expr in_op nm dbnm paren_exprlist */ |
| 161456 | { | 162469 | { |
| 161457 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); | 162470 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); |
| 161458 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); | 162471 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); |
| 161459 | if( yymsp[0].minor.yy338 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy338); | 162472 | if( yymsp[0].minor.yy70 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy70); |
| 161460 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0); | 162473 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0); |
| 161461 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy602, pSelect); | 162474 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, pSelect); |
| 161462 | if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); | 162475 | if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 161463 | } | 162476 | } |
| 161464 | break; | 162477 | break; |
| 161465 | case 219: /* expr ::= EXISTS LP select RP */ | 162478 | case 219: /* expr ::= EXISTS LP select RP */ |
| 161466 | { | 162479 | { |
| 161467 | Expr *p; | 162480 | Expr *p; |
| 161468 | p = yymsp[-3].minor.yy602 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); | 162481 | p = yymsp[-3].minor.yy404 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); |
| 161469 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy307); | 162482 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy81); |
| 161470 | } | 162483 | } |
| 161471 | break; | 162484 | break; |
| 161472 | case 220: /* expr ::= CASE case_operand case_exprlist case_else END */ | 162485 | case 220: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 161473 | { | 162486 | { |
| 161474 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy602, 0); | 162487 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy404, 0); |
| 161475 | if( yymsp[-4].minor.yy602 ){ | 162488 | if( yymsp[-4].minor.yy404 ){ |
| 161476 | yymsp[-4].minor.yy602->x.pList = yymsp[-1].minor.yy602 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602) : yymsp[-2].minor.yy338; | 162489 | yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy404 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404) : yymsp[-2].minor.yy70; |
| 161477 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy602); | 162490 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404); |
| 161478 | }else{ | 162491 | }else{ |
| 161479 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy338); | 162492 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy70); |
| 161480 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy602); | 162493 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy404); |
| 161481 | } | 162494 | } |
| 161482 | } | 162495 | } |
| 161483 | break; | 162496 | break; |
| 161484 | case 221: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ | 162497 | case 221: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 161485 | { | 162498 | { |
| 161486 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, yymsp[-2].minor.yy602); | 162499 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, yymsp[-2].minor.yy404); |
| 161487 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, yymsp[0].minor.yy602); | 162500 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, yymsp[0].minor.yy404); |
| 161488 | } | 162501 | } |
| 161489 | break; | 162502 | break; |
| 161490 | case 222: /* case_exprlist ::= WHEN expr THEN expr */ | 162503 | case 222: /* case_exprlist ::= WHEN expr THEN expr */ |
| 161491 | { | 162504 | { |
| 161492 | yymsp[-3].minor.yy338 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602); | 162505 | yymsp[-3].minor.yy70 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404); |
| 161493 | yymsp[-3].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy338, yymsp[0].minor.yy602); | 162506 | yymsp[-3].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy70, yymsp[0].minor.yy404); |
| 161494 | } | 162507 | } |
| 161495 | break; | 162508 | break; |
| 161496 | case 225: /* case_operand ::= expr */ | 162509 | case 225: /* case_operand ::= expr */ |
| 161497 | {yymsp[0].minor.yy602 = yymsp[0].minor.yy602; /*A-overwrites-X*/} | 162510 | {yymsp[0].minor.yy404 = yymsp[0].minor.yy404; /*A-overwrites-X*/} |
| 161498 | break; | 162511 | break; |
| 161499 | case 228: /* nexprlist ::= nexprlist COMMA expr */ | 162512 | case 228: /* nexprlist ::= nexprlist COMMA expr */ |
| 161500 | {yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy338,yymsp[0].minor.yy602);} | 162513 | {yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy70,yymsp[0].minor.yy404);} |
| 161501 | break; | 162514 | break; |
| 161502 | case 229: /* nexprlist ::= expr */ | 162515 | case 229: /* nexprlist ::= expr */ |
| 161503 | {yymsp[0].minor.yy338 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy602); /*A-overwrites-Y*/} | 162516 | {yymsp[0].minor.yy70 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy404); /*A-overwrites-Y*/} |
| 161504 | break; | 162517 | break; |
| 161505 | case 231: /* paren_exprlist ::= LP exprlist RP */ | 162518 | case 231: /* paren_exprlist ::= LP exprlist RP */ |
| 161506 | case 236: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==236); | 162519 | case 236: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==236); |
| 161507 | {yymsp[-2].minor.yy338 = yymsp[-1].minor.yy338;} | 162520 | {yymsp[-2].minor.yy70 = yymsp[-1].minor.yy70;} |
| 161508 | break; | 162521 | break; |
| 161509 | case 232: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | 162522 | case 232: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 161510 | { | 162523 | { |
| 161511 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, | 162524 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 161512 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy338, yymsp[-10].minor.yy60, | 162525 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy70, yymsp[-10].minor.yy376, |
| 161513 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy602, SQLITE_SO_ASC, yymsp[-8].minor.yy60, SQLITE_IDXTYPE_APPDEF); | 162526 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy404, SQLITE_SO_ASC, yymsp[-8].minor.yy376, SQLITE_IDXTYPE_APPDEF); |
| 161514 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ | 162527 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ |
| 161515 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); | 162528 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); |
| 161516 | } | 162529 | } |
| @@ -161518,29 +162531,29 @@ static YYACTIONTYPE yy_reduce( | |||
| 161518 | break; | 162531 | break; |
| 161519 | case 233: /* uniqueflag ::= UNIQUE */ | 162532 | case 233: /* uniqueflag ::= UNIQUE */ |
| 161520 | case 275: /* raisetype ::= ABORT */ yytestcase(yyruleno==275); | 162533 | case 275: /* raisetype ::= ABORT */ yytestcase(yyruleno==275); |
| 161521 | {yymsp[0].minor.yy60 = OE_Abort;} | 162534 | {yymsp[0].minor.yy376 = OE_Abort;} |
| 161522 | break; | 162535 | break; |
| 161523 | case 234: /* uniqueflag ::= */ | 162536 | case 234: /* uniqueflag ::= */ |
| 161524 | {yymsp[1].minor.yy60 = OE_None;} | 162537 | {yymsp[1].minor.yy376 = OE_None;} |
| 161525 | break; | 162538 | break; |
| 161526 | case 237: /* eidlist ::= eidlist COMMA nm collate sortorder */ | 162539 | case 237: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 161527 | { | 162540 | { |
| 161528 | yymsp[-4].minor.yy338 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy338, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy60, yymsp[0].minor.yy60); | 162541 | yymsp[-4].minor.yy70 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy70, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy376, yymsp[0].minor.yy376); |
| 161529 | } | 162542 | } |
| 161530 | break; | 162543 | break; |
| 161531 | case 238: /* eidlist ::= nm collate sortorder */ | 162544 | case 238: /* eidlist ::= nm collate sortorder */ |
| 161532 | { | 162545 | { |
| 161533 | yymsp[-2].minor.yy338 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy60, yymsp[0].minor.yy60); /*A-overwrites-Y*/ | 162546 | yymsp[-2].minor.yy70 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy376, yymsp[0].minor.yy376); /*A-overwrites-Y*/ |
| 161534 | } | 162547 | } |
| 161535 | break; | 162548 | break; |
| 161536 | case 241: /* cmd ::= DROP INDEX ifexists fullname */ | 162549 | case 241: /* cmd ::= DROP INDEX ifexists fullname */ |
| 161537 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy291, yymsp[-1].minor.yy60);} | 162550 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy153, yymsp[-1].minor.yy376);} |
| 161538 | break; | 162551 | break; |
| 161539 | case 242: /* cmd ::= VACUUM vinto */ | 162552 | case 242: /* cmd ::= VACUUM vinto */ |
| 161540 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy602);} | 162553 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy404);} |
| 161541 | break; | 162554 | break; |
| 161542 | case 243: /* cmd ::= VACUUM nm vinto */ | 162555 | case 243: /* cmd ::= VACUUM nm vinto */ |
| 161543 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy602);} | 162556 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy404);} |
| 161544 | break; | 162557 | break; |
| 161545 | case 246: /* cmd ::= PRAGMA nm dbnm */ | 162558 | case 246: /* cmd ::= PRAGMA nm dbnm */ |
| 161546 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} | 162559 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| @@ -161562,50 +162575,50 @@ static YYACTIONTYPE yy_reduce( | |||
| 161562 | Token all; | 162575 | Token all; |
| 161563 | all.z = yymsp[-3].minor.yy0.z; | 162576 | all.z = yymsp[-3].minor.yy0.z; |
| 161564 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; | 162577 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 161565 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy483, &all); | 162578 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy157, &all); |
| 161566 | } | 162579 | } |
| 161567 | break; | 162580 | break; |
| 161568 | case 254: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | 162581 | case 254: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 161569 | { | 162582 | { |
| 161570 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy60, yymsp[-4].minor.yy50.a, yymsp[-4].minor.yy50.b, yymsp[-2].minor.yy291, yymsp[0].minor.yy602, yymsp[-10].minor.yy60, yymsp[-8].minor.yy60); | 162583 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy376, yymsp[-4].minor.yy262.a, yymsp[-4].minor.yy262.b, yymsp[-2].minor.yy153, yymsp[0].minor.yy404, yymsp[-10].minor.yy376, yymsp[-8].minor.yy376); |
| 161571 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ | 162584 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 161572 | } | 162585 | } |
| 161573 | break; | 162586 | break; |
| 161574 | case 255: /* trigger_time ::= BEFORE|AFTER */ | 162587 | case 255: /* trigger_time ::= BEFORE|AFTER */ |
| 161575 | { yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-X*/ } | 162588 | { yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-X*/ } |
| 161576 | break; | 162589 | break; |
| 161577 | case 256: /* trigger_time ::= INSTEAD OF */ | 162590 | case 256: /* trigger_time ::= INSTEAD OF */ |
| 161578 | { yymsp[-1].minor.yy60 = TK_INSTEAD;} | 162591 | { yymsp[-1].minor.yy376 = TK_INSTEAD;} |
| 161579 | break; | 162592 | break; |
| 161580 | case 257: /* trigger_time ::= */ | 162593 | case 257: /* trigger_time ::= */ |
| 161581 | { yymsp[1].minor.yy60 = TK_BEFORE; } | 162594 | { yymsp[1].minor.yy376 = TK_BEFORE; } |
| 161582 | break; | 162595 | break; |
| 161583 | case 258: /* trigger_event ::= DELETE|INSERT */ | 162596 | case 258: /* trigger_event ::= DELETE|INSERT */ |
| 161584 | case 259: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==259); | 162597 | case 259: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==259); |
| 161585 | {yymsp[0].minor.yy50.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy50.b = 0;} | 162598 | {yymsp[0].minor.yy262.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy262.b = 0;} |
| 161586 | break; | 162599 | break; |
| 161587 | case 260: /* trigger_event ::= UPDATE OF idlist */ | 162600 | case 260: /* trigger_event ::= UPDATE OF idlist */ |
| 161588 | {yymsp[-2].minor.yy50.a = TK_UPDATE; yymsp[-2].minor.yy50.b = yymsp[0].minor.yy288;} | 162601 | {yymsp[-2].minor.yy262.a = TK_UPDATE; yymsp[-2].minor.yy262.b = yymsp[0].minor.yy436;} |
| 161589 | break; | 162602 | break; |
| 161590 | case 261: /* when_clause ::= */ | 162603 | case 261: /* when_clause ::= */ |
| 161591 | case 280: /* key_opt ::= */ yytestcase(yyruleno==280); | 162604 | case 280: /* key_opt ::= */ yytestcase(yyruleno==280); |
| 161592 | { yymsp[1].minor.yy602 = 0; } | 162605 | { yymsp[1].minor.yy404 = 0; } |
| 161593 | break; | 162606 | break; |
| 161594 | case 262: /* when_clause ::= WHEN expr */ | 162607 | case 262: /* when_clause ::= WHEN expr */ |
| 161595 | case 281: /* key_opt ::= KEY expr */ yytestcase(yyruleno==281); | 162608 | case 281: /* key_opt ::= KEY expr */ yytestcase(yyruleno==281); |
| 161596 | { yymsp[-1].minor.yy602 = yymsp[0].minor.yy602; } | 162609 | { yymsp[-1].minor.yy404 = yymsp[0].minor.yy404; } |
| 161597 | break; | 162610 | break; |
| 161598 | case 263: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | 162611 | case 263: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 161599 | { | 162612 | { |
| 161600 | assert( yymsp[-2].minor.yy483!=0 ); | 162613 | assert( yymsp[-2].minor.yy157!=0 ); |
| 161601 | yymsp[-2].minor.yy483->pLast->pNext = yymsp[-1].minor.yy483; | 162614 | yymsp[-2].minor.yy157->pLast->pNext = yymsp[-1].minor.yy157; |
| 161602 | yymsp[-2].minor.yy483->pLast = yymsp[-1].minor.yy483; | 162615 | yymsp[-2].minor.yy157->pLast = yymsp[-1].minor.yy157; |
| 161603 | } | 162616 | } |
| 161604 | break; | 162617 | break; |
| 161605 | case 264: /* trigger_cmd_list ::= trigger_cmd SEMI */ | 162618 | case 264: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 161606 | { | 162619 | { |
| 161607 | assert( yymsp[-1].minor.yy483!=0 ); | 162620 | assert( yymsp[-1].minor.yy157!=0 ); |
| 161608 | yymsp[-1].minor.yy483->pLast = yymsp[-1].minor.yy483; | 162621 | yymsp[-1].minor.yy157->pLast = yymsp[-1].minor.yy157; |
| 161609 | } | 162622 | } |
| 161610 | break; | 162623 | break; |
| 161611 | case 265: /* trnm ::= nm DOT nm */ | 162624 | case 265: /* trnm ::= nm DOT nm */ |
| @@ -161631,58 +162644,58 @@ static YYACTIONTYPE yy_reduce( | |||
| 161631 | } | 162644 | } |
| 161632 | break; | 162645 | break; |
| 161633 | case 268: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | 162646 | case 268: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 161634 | {yylhsminor.yy483 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy291, yymsp[-3].minor.yy338, yymsp[-1].minor.yy602, yymsp[-7].minor.yy60, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy528);} | 162647 | {yylhsminor.yy157 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy153, yymsp[-3].minor.yy70, yymsp[-1].minor.yy404, yymsp[-7].minor.yy376, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy504);} |
| 161635 | yymsp[-8].minor.yy483 = yylhsminor.yy483; | 162648 | yymsp[-8].minor.yy157 = yylhsminor.yy157; |
| 161636 | break; | 162649 | break; |
| 161637 | case 269: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | 162650 | case 269: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 161638 | { | 162651 | { |
| 161639 | yylhsminor.yy483 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy288,yymsp[-2].minor.yy307,yymsp[-6].minor.yy60,yymsp[-1].minor.yy178,yymsp[-7].minor.yy528,yymsp[0].minor.yy528);/*yylhsminor.yy483-overwrites-yymsp[-6].minor.yy60*/ | 162652 | yylhsminor.yy157 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy436,yymsp[-2].minor.yy81,yymsp[-6].minor.yy376,yymsp[-1].minor.yy190,yymsp[-7].minor.yy504,yymsp[0].minor.yy504);/*yylhsminor.yy157-overwrites-yymsp[-6].minor.yy376*/ |
| 161640 | } | 162653 | } |
| 161641 | yymsp[-7].minor.yy483 = yylhsminor.yy483; | 162654 | yymsp[-7].minor.yy157 = yylhsminor.yy157; |
| 161642 | break; | 162655 | break; |
| 161643 | case 270: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | 162656 | case 270: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 161644 | {yylhsminor.yy483 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy602, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy528);} | 162657 | {yylhsminor.yy157 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy404, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy504);} |
| 161645 | yymsp[-5].minor.yy483 = yylhsminor.yy483; | 162658 | yymsp[-5].minor.yy157 = yylhsminor.yy157; |
| 161646 | break; | 162659 | break; |
| 161647 | case 271: /* trigger_cmd ::= scanpt select scanpt */ | 162660 | case 271: /* trigger_cmd ::= scanpt select scanpt */ |
| 161648 | {yylhsminor.yy483 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy307, yymsp[-2].minor.yy528, yymsp[0].minor.yy528); /*yylhsminor.yy483-overwrites-yymsp[-1].minor.yy307*/} | 162661 | {yylhsminor.yy157 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy81, yymsp[-2].minor.yy504, yymsp[0].minor.yy504); /*yylhsminor.yy157-overwrites-yymsp[-1].minor.yy81*/} |
| 161649 | yymsp[-2].minor.yy483 = yylhsminor.yy483; | 162662 | yymsp[-2].minor.yy157 = yylhsminor.yy157; |
| 161650 | break; | 162663 | break; |
| 161651 | case 272: /* expr ::= RAISE LP IGNORE RP */ | 162664 | case 272: /* expr ::= RAISE LP IGNORE RP */ |
| 161652 | { | 162665 | { |
| 161653 | yymsp[-3].minor.yy602 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); | 162666 | yymsp[-3].minor.yy404 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 161654 | if( yymsp[-3].minor.yy602 ){ | 162667 | if( yymsp[-3].minor.yy404 ){ |
| 161655 | yymsp[-3].minor.yy602->affExpr = OE_Ignore; | 162668 | yymsp[-3].minor.yy404->affExpr = OE_Ignore; |
| 161656 | } | 162669 | } |
| 161657 | } | 162670 | } |
| 161658 | break; | 162671 | break; |
| 161659 | case 273: /* expr ::= RAISE LP raisetype COMMA nm RP */ | 162672 | case 273: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 161660 | { | 162673 | { |
| 161661 | yymsp[-5].minor.yy602 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); | 162674 | yymsp[-5].minor.yy404 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 161662 | if( yymsp[-5].minor.yy602 ) { | 162675 | if( yymsp[-5].minor.yy404 ) { |
| 161663 | yymsp[-5].minor.yy602->affExpr = (char)yymsp[-3].minor.yy60; | 162676 | yymsp[-5].minor.yy404->affExpr = (char)yymsp[-3].minor.yy376; |
| 161664 | } | 162677 | } |
| 161665 | } | 162678 | } |
| 161666 | break; | 162679 | break; |
| 161667 | case 274: /* raisetype ::= ROLLBACK */ | 162680 | case 274: /* raisetype ::= ROLLBACK */ |
| 161668 | {yymsp[0].minor.yy60 = OE_Rollback;} | 162681 | {yymsp[0].minor.yy376 = OE_Rollback;} |
| 161669 | break; | 162682 | break; |
| 161670 | case 276: /* raisetype ::= FAIL */ | 162683 | case 276: /* raisetype ::= FAIL */ |
| 161671 | {yymsp[0].minor.yy60 = OE_Fail;} | 162684 | {yymsp[0].minor.yy376 = OE_Fail;} |
| 161672 | break; | 162685 | break; |
| 161673 | case 277: /* cmd ::= DROP TRIGGER ifexists fullname */ | 162686 | case 277: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 161674 | { | 162687 | { |
| 161675 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy291,yymsp[-1].minor.yy60); | 162688 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy153,yymsp[-1].minor.yy376); |
| 161676 | } | 162689 | } |
| 161677 | break; | 162690 | break; |
| 161678 | case 278: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | 162691 | case 278: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 161679 | { | 162692 | { |
| 161680 | sqlite3Attach(pParse, yymsp[-3].minor.yy602, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); | 162693 | sqlite3Attach(pParse, yymsp[-3].minor.yy404, yymsp[-1].minor.yy404, yymsp[0].minor.yy404); |
| 161681 | } | 162694 | } |
| 161682 | break; | 162695 | break; |
| 161683 | case 279: /* cmd ::= DETACH database_kw_opt expr */ | 162696 | case 279: /* cmd ::= DETACH database_kw_opt expr */ |
| 161684 | { | 162697 | { |
| 161685 | sqlite3Detach(pParse, yymsp[0].minor.yy602); | 162698 | sqlite3Detach(pParse, yymsp[0].minor.yy404); |
| 161686 | } | 162699 | } |
| 161687 | break; | 162700 | break; |
| 161688 | case 282: /* cmd ::= REINDEX */ | 162701 | case 282: /* cmd ::= REINDEX */ |
| @@ -161699,7 +162712,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 161699 | break; | 162712 | break; |
| 161700 | case 286: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ | 162713 | case 286: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 161701 | { | 162714 | { |
| 161702 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy291,&yymsp[0].minor.yy0); | 162715 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy153,&yymsp[0].minor.yy0); |
| 161703 | } | 162716 | } |
| 161704 | break; | 162717 | break; |
| 161705 | case 287: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | 162718 | case 287: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| @@ -161710,18 +162723,18 @@ static YYACTIONTYPE yy_reduce( | |||
| 161710 | break; | 162723 | break; |
| 161711 | case 288: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | 162724 | case 288: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 161712 | { | 162725 | { |
| 161713 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy291, &yymsp[0].minor.yy0); | 162726 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy153, &yymsp[0].minor.yy0); |
| 161714 | } | 162727 | } |
| 161715 | break; | 162728 | break; |
| 161716 | case 289: /* add_column_fullname ::= fullname */ | 162729 | case 289: /* add_column_fullname ::= fullname */ |
| 161717 | { | 162730 | { |
| 161718 | disableLookaside(pParse); | 162731 | disableLookaside(pParse); |
| 161719 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy291); | 162732 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy153); |
| 161720 | } | 162733 | } |
| 161721 | break; | 162734 | break; |
| 161722 | case 290: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | 162735 | case 290: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 161723 | { | 162736 | { |
| 161724 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy291, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); | 162737 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy153, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 161725 | } | 162738 | } |
| 161726 | break; | 162739 | break; |
| 161727 | case 291: /* cmd ::= create_vtab */ | 162740 | case 291: /* cmd ::= create_vtab */ |
| @@ -161732,7 +162745,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 161732 | break; | 162745 | break; |
| 161733 | case 293: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | 162746 | case 293: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 161734 | { | 162747 | { |
| 161735 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy60); | 162748 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy376); |
| 161736 | } | 162749 | } |
| 161737 | break; | 162750 | break; |
| 161738 | case 294: /* vtabarg ::= */ | 162751 | case 294: /* vtabarg ::= */ |
| @@ -161745,172 +162758,176 @@ static YYACTIONTYPE yy_reduce( | |||
| 161745 | break; | 162758 | break; |
| 161746 | case 298: /* with ::= WITH wqlist */ | 162759 | case 298: /* with ::= WITH wqlist */ |
| 161747 | case 299: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==299); | 162760 | case 299: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==299); |
| 161748 | { sqlite3WithPush(pParse, yymsp[0].minor.yy195, 1); } | 162761 | { sqlite3WithPush(pParse, yymsp[0].minor.yy103, 1); } |
| 161749 | break; | 162762 | break; |
| 161750 | case 300: /* wqas ::= AS */ | 162763 | case 300: /* wqas ::= AS */ |
| 161751 | {yymsp[0].minor.yy570 = M10d_Any;} | 162764 | {yymsp[0].minor.yy552 = M10d_Any;} |
| 161752 | break; | 162765 | break; |
| 161753 | case 301: /* wqas ::= AS MATERIALIZED */ | 162766 | case 301: /* wqas ::= AS MATERIALIZED */ |
| 161754 | {yymsp[-1].minor.yy570 = M10d_Yes;} | 162767 | {yymsp[-1].minor.yy552 = M10d_Yes;} |
| 161755 | break; | 162768 | break; |
| 161756 | case 302: /* wqas ::= AS NOT MATERIALIZED */ | 162769 | case 302: /* wqas ::= AS NOT MATERIALIZED */ |
| 161757 | {yymsp[-2].minor.yy570 = M10d_No;} | 162770 | {yymsp[-2].minor.yy552 = M10d_No;} |
| 161758 | break; | 162771 | break; |
| 161759 | case 303: /* wqitem ::= nm eidlist_opt wqas LP select RP */ | 162772 | case 303: /* wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 161760 | { | 162773 | { |
| 161761 | yymsp[-5].minor.yy607 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy338, yymsp[-1].minor.yy307, yymsp[-3].minor.yy570); /*A-overwrites-X*/ | 162774 | yymsp[-5].minor.yy329 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy70, yymsp[-1].minor.yy81, yymsp[-3].minor.yy552); /*A-overwrites-X*/ |
| 161762 | } | 162775 | } |
| 161763 | break; | 162776 | break; |
| 161764 | case 304: /* wqlist ::= wqitem */ | 162777 | case 304: /* wqlist ::= wqitem */ |
| 161765 | { | 162778 | { |
| 161766 | yymsp[0].minor.yy195 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy607); /*A-overwrites-X*/ | 162779 | yymsp[0].minor.yy103 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy329); /*A-overwrites-X*/ |
| 161767 | } | 162780 | } |
| 161768 | break; | 162781 | break; |
| 161769 | case 305: /* wqlist ::= wqlist COMMA wqitem */ | 162782 | case 305: /* wqlist ::= wqlist COMMA wqitem */ |
| 161770 | { | 162783 | { |
| 161771 | yymsp[-2].minor.yy195 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy195, yymsp[0].minor.yy607); | 162784 | yymsp[-2].minor.yy103 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy103, yymsp[0].minor.yy329); |
| 161772 | } | 162785 | } |
| 161773 | break; | 162786 | break; |
| 161774 | case 306: /* windowdefn_list ::= windowdefn */ | 162787 | case 306: /* windowdefn_list ::= windowdefn */ |
| 161775 | { yylhsminor.yy19 = yymsp[0].minor.yy19; } | 162788 | { yylhsminor.yy49 = yymsp[0].minor.yy49; } |
| 161776 | yymsp[0].minor.yy19 = yylhsminor.yy19; | 162789 | yymsp[0].minor.yy49 = yylhsminor.yy49; |
| 161777 | break; | 162790 | break; |
| 161778 | case 307: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ | 162791 | case 307: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 161779 | { | 162792 | { |
| 161780 | assert( yymsp[0].minor.yy19!=0 ); | 162793 | assert( yymsp[0].minor.yy49!=0 ); |
| 161781 | sqlite3WindowChain(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy19); | 162794 | sqlite3WindowChain(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy49); |
| 161782 | yymsp[0].minor.yy19->pNextWin = yymsp[-2].minor.yy19; | 162795 | yymsp[0].minor.yy49->pNextWin = yymsp[-2].minor.yy49; |
| 161783 | yylhsminor.yy19 = yymsp[0].minor.yy19; | 162796 | yylhsminor.yy49 = yymsp[0].minor.yy49; |
| 161784 | } | 162797 | } |
| 161785 | yymsp[-2].minor.yy19 = yylhsminor.yy19; | 162798 | yymsp[-2].minor.yy49 = yylhsminor.yy49; |
| 161786 | break; | 162799 | break; |
| 161787 | case 308: /* windowdefn ::= nm AS LP window RP */ | 162800 | case 308: /* windowdefn ::= nm AS LP window RP */ |
| 161788 | { | 162801 | { |
| 161789 | if( ALWAYS(yymsp[-1].minor.yy19) ){ | 162802 | if( ALWAYS(yymsp[-1].minor.yy49) ){ |
| 161790 | yymsp[-1].minor.yy19->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); | 162803 | yymsp[-1].minor.yy49->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); |
| 161791 | } | 162804 | } |
| 161792 | yylhsminor.yy19 = yymsp[-1].minor.yy19; | 162805 | yylhsminor.yy49 = yymsp[-1].minor.yy49; |
| 161793 | } | 162806 | } |
| 161794 | yymsp[-4].minor.yy19 = yylhsminor.yy19; | 162807 | yymsp[-4].minor.yy49 = yylhsminor.yy49; |
| 161795 | break; | 162808 | break; |
| 161796 | case 309: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | 162809 | case 309: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 161797 | { | 162810 | { |
| 161798 | yymsp[-4].minor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy338, yymsp[-1].minor.yy338, 0); | 162811 | yymsp[-4].minor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy70, yymsp[-1].minor.yy70, 0); |
| 161799 | } | 162812 | } |
| 161800 | break; | 162813 | break; |
| 161801 | case 310: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | 162814 | case 310: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 161802 | { | 162815 | { |
| 161803 | yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy338, yymsp[-1].minor.yy338, &yymsp[-5].minor.yy0); | 162816 | yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy70, yymsp[-1].minor.yy70, &yymsp[-5].minor.yy0); |
| 161804 | } | 162817 | } |
| 161805 | yymsp[-5].minor.yy19 = yylhsminor.yy19; | 162818 | yymsp[-5].minor.yy49 = yylhsminor.yy49; |
| 161806 | break; | 162819 | break; |
| 161807 | case 311: /* window ::= ORDER BY sortlist frame_opt */ | 162820 | case 311: /* window ::= ORDER BY sortlist frame_opt */ |
| 161808 | { | 162821 | { |
| 161809 | yymsp[-3].minor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, yymsp[-1].minor.yy338, 0); | 162822 | yymsp[-3].minor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, yymsp[-1].minor.yy70, 0); |
| 161810 | } | 162823 | } |
| 161811 | break; | 162824 | break; |
| 161812 | case 312: /* window ::= nm ORDER BY sortlist frame_opt */ | 162825 | case 312: /* window ::= nm ORDER BY sortlist frame_opt */ |
| 161813 | { | 162826 | { |
| 161814 | yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, yymsp[-1].minor.yy338, &yymsp[-4].minor.yy0); | 162827 | yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, yymsp[-1].minor.yy70, &yymsp[-4].minor.yy0); |
| 161815 | } | 162828 | } |
| 161816 | yymsp[-4].minor.yy19 = yylhsminor.yy19; | 162829 | yymsp[-4].minor.yy49 = yylhsminor.yy49; |
| 161817 | break; | 162830 | break; |
| 161818 | case 313: /* window ::= frame_opt */ | 162831 | case 313: /* window ::= frame_opt */ |
| 161819 | case 332: /* filter_over ::= over_clause */ yytestcase(yyruleno==332); | 162832 | case 332: /* filter_over ::= over_clause */ yytestcase(yyruleno==332); |
| 161820 | { | 162833 | { |
| 161821 | yylhsminor.yy19 = yymsp[0].minor.yy19; | 162834 | yylhsminor.yy49 = yymsp[0].minor.yy49; |
| 161822 | } | 162835 | } |
| 161823 | yymsp[0].minor.yy19 = yylhsminor.yy19; | 162836 | yymsp[0].minor.yy49 = yylhsminor.yy49; |
| 161824 | break; | 162837 | break; |
| 161825 | case 314: /* window ::= nm frame_opt */ | 162838 | case 314: /* window ::= nm frame_opt */ |
| 161826 | { | 162839 | { |
| 161827 | yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, 0, &yymsp[-1].minor.yy0); | 162840 | yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, 0, &yymsp[-1].minor.yy0); |
| 161828 | } | 162841 | } |
| 161829 | yymsp[-1].minor.yy19 = yylhsminor.yy19; | 162842 | yymsp[-1].minor.yy49 = yylhsminor.yy49; |
| 161830 | break; | 162843 | break; |
| 161831 | case 315: /* frame_opt ::= */ | 162844 | case 315: /* frame_opt ::= */ |
| 161832 | { | 162845 | { |
| 161833 | yymsp[1].minor.yy19 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); | 162846 | yymsp[1].minor.yy49 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); |
| 161834 | } | 162847 | } |
| 161835 | break; | 162848 | break; |
| 161836 | case 316: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | 162849 | case 316: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 161837 | { | 162850 | { |
| 161838 | yylhsminor.yy19 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy60, yymsp[-1].minor.yy113.eType, yymsp[-1].minor.yy113.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy570); | 162851 | yylhsminor.yy49 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy376, yymsp[-1].minor.yy117.eType, yymsp[-1].minor.yy117.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy552); |
| 161839 | } | 162852 | } |
| 161840 | yymsp[-2].minor.yy19 = yylhsminor.yy19; | 162853 | yymsp[-2].minor.yy49 = yylhsminor.yy49; |
| 161841 | break; | 162854 | break; |
| 161842 | case 317: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | 162855 | case 317: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 161843 | { | 162856 | { |
| 161844 | yylhsminor.yy19 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy60, yymsp[-3].minor.yy113.eType, yymsp[-3].minor.yy113.pExpr, yymsp[-1].minor.yy113.eType, yymsp[-1].minor.yy113.pExpr, yymsp[0].minor.yy570); | 162857 | yylhsminor.yy49 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy376, yymsp[-3].minor.yy117.eType, yymsp[-3].minor.yy117.pExpr, yymsp[-1].minor.yy117.eType, yymsp[-1].minor.yy117.pExpr, yymsp[0].minor.yy552); |
| 161845 | } | 162858 | } |
| 161846 | yymsp[-5].minor.yy19 = yylhsminor.yy19; | 162859 | yymsp[-5].minor.yy49 = yylhsminor.yy49; |
| 161847 | break; | 162860 | break; |
| 161848 | case 319: /* frame_bound_s ::= frame_bound */ | 162861 | case 319: /* frame_bound_s ::= frame_bound */ |
| 161849 | case 321: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==321); | 162862 | case 321: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==321); |
| 161850 | {yylhsminor.yy113 = yymsp[0].minor.yy113;} | 162863 | {yylhsminor.yy117 = yymsp[0].minor.yy117;} |
| 161851 | yymsp[0].minor.yy113 = yylhsminor.yy113; | 162864 | yymsp[0].minor.yy117 = yylhsminor.yy117; |
| 161852 | break; | 162865 | break; |
| 161853 | case 320: /* frame_bound_s ::= UNBOUNDED PRECEDING */ | 162866 | case 320: /* frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 161854 | case 322: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==322); | 162867 | case 322: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==322); |
| 161855 | case 324: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==324); | 162868 | case 324: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==324); |
| 161856 | {yylhsminor.yy113.eType = yymsp[-1].major; yylhsminor.yy113.pExpr = 0;} | 162869 | {yylhsminor.yy117.eType = yymsp[-1].major; yylhsminor.yy117.pExpr = 0;} |
| 161857 | yymsp[-1].minor.yy113 = yylhsminor.yy113; | 162870 | yymsp[-1].minor.yy117 = yylhsminor.yy117; |
| 161858 | break; | 162871 | break; |
| 161859 | case 323: /* frame_bound ::= expr PRECEDING|FOLLOWING */ | 162872 | case 323: /* frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 161860 | {yylhsminor.yy113.eType = yymsp[0].major; yylhsminor.yy113.pExpr = yymsp[-1].minor.yy602;} | 162873 | {yylhsminor.yy117.eType = yymsp[0].major; yylhsminor.yy117.pExpr = yymsp[-1].minor.yy404;} |
| 161861 | yymsp[-1].minor.yy113 = yylhsminor.yy113; | 162874 | yymsp[-1].minor.yy117 = yylhsminor.yy117; |
| 161862 | break; | 162875 | break; |
| 161863 | case 325: /* frame_exclude_opt ::= */ | 162876 | case 325: /* frame_exclude_opt ::= */ |
| 161864 | {yymsp[1].minor.yy570 = 0;} | 162877 | {yymsp[1].minor.yy552 = 0;} |
| 161865 | break; | 162878 | break; |
| 161866 | case 326: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ | 162879 | case 326: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 161867 | {yymsp[-1].minor.yy570 = yymsp[0].minor.yy570;} | 162880 | {yymsp[-1].minor.yy552 = yymsp[0].minor.yy552;} |
| 161868 | break; | 162881 | break; |
| 161869 | case 327: /* frame_exclude ::= NO OTHERS */ | 162882 | case 327: /* frame_exclude ::= NO OTHERS */ |
| 161870 | case 328: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==328); | 162883 | case 328: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==328); |
| 161871 | {yymsp[-1].minor.yy570 = yymsp[-1].major; /*A-overwrites-X*/} | 162884 | {yymsp[-1].minor.yy552 = yymsp[-1].major; /*A-overwrites-X*/} |
| 161872 | break; | 162885 | break; |
| 161873 | case 329: /* frame_exclude ::= GROUP|TIES */ | 162886 | case 329: /* frame_exclude ::= GROUP|TIES */ |
| 161874 | {yymsp[0].minor.yy570 = yymsp[0].major; /*A-overwrites-X*/} | 162887 | {yymsp[0].minor.yy552 = yymsp[0].major; /*A-overwrites-X*/} |
| 161875 | break; | 162888 | break; |
| 161876 | case 330: /* window_clause ::= WINDOW windowdefn_list */ | 162889 | case 330: /* window_clause ::= WINDOW windowdefn_list */ |
| 161877 | { yymsp[-1].minor.yy19 = yymsp[0].minor.yy19; } | 162890 | { yymsp[-1].minor.yy49 = yymsp[0].minor.yy49; } |
| 161878 | break; | 162891 | break; |
| 161879 | case 331: /* filter_over ::= filter_clause over_clause */ | 162892 | case 331: /* filter_over ::= filter_clause over_clause */ |
| 161880 | { | 162893 | { |
| 161881 | yymsp[0].minor.yy19->pFilter = yymsp[-1].minor.yy602; | 162894 | if( yymsp[0].minor.yy49 ){ |
| 161882 | yylhsminor.yy19 = yymsp[0].minor.yy19; | 162895 | yymsp[0].minor.yy49->pFilter = yymsp[-1].minor.yy404; |
| 162896 | }else{ | ||
| 162897 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy404); | ||
| 162898 | } | ||
| 162899 | yylhsminor.yy49 = yymsp[0].minor.yy49; | ||
| 161883 | } | 162900 | } |
| 161884 | yymsp[-1].minor.yy19 = yylhsminor.yy19; | 162901 | yymsp[-1].minor.yy49 = yylhsminor.yy49; |
| 161885 | break; | 162902 | break; |
| 161886 | case 333: /* filter_over ::= filter_clause */ | 162903 | case 333: /* filter_over ::= filter_clause */ |
| 161887 | { | 162904 | { |
| 161888 | yylhsminor.yy19 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); | 162905 | yylhsminor.yy49 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 161889 | if( yylhsminor.yy19 ){ | 162906 | if( yylhsminor.yy49 ){ |
| 161890 | yylhsminor.yy19->eFrmType = TK_FILTER; | 162907 | yylhsminor.yy49->eFrmType = TK_FILTER; |
| 161891 | yylhsminor.yy19->pFilter = yymsp[0].minor.yy602; | 162908 | yylhsminor.yy49->pFilter = yymsp[0].minor.yy404; |
| 161892 | }else{ | 162909 | }else{ |
| 161893 | sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy602); | 162910 | sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy404); |
| 161894 | } | 162911 | } |
| 161895 | } | 162912 | } |
| 161896 | yymsp[0].minor.yy19 = yylhsminor.yy19; | 162913 | yymsp[0].minor.yy49 = yylhsminor.yy49; |
| 161897 | break; | 162914 | break; |
| 161898 | case 334: /* over_clause ::= OVER LP window RP */ | 162915 | case 334: /* over_clause ::= OVER LP window RP */ |
| 161899 | { | 162916 | { |
| 161900 | yymsp[-3].minor.yy19 = yymsp[-1].minor.yy19; | 162917 | yymsp[-3].minor.yy49 = yymsp[-1].minor.yy49; |
| 161901 | assert( yymsp[-3].minor.yy19!=0 ); | 162918 | assert( yymsp[-3].minor.yy49!=0 ); |
| 161902 | } | 162919 | } |
| 161903 | break; | 162920 | break; |
| 161904 | case 335: /* over_clause ::= OVER nm */ | 162921 | case 335: /* over_clause ::= OVER nm */ |
| 161905 | { | 162922 | { |
| 161906 | yymsp[-1].minor.yy19 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); | 162923 | yymsp[-1].minor.yy49 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 161907 | if( yymsp[-1].minor.yy19 ){ | 162924 | if( yymsp[-1].minor.yy49 ){ |
| 161908 | yymsp[-1].minor.yy19->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); | 162925 | yymsp[-1].minor.yy49->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); |
| 161909 | } | 162926 | } |
| 161910 | } | 162927 | } |
| 161911 | break; | 162928 | break; |
| 161912 | case 336: /* filter_clause ::= FILTER LP WHERE expr RP */ | 162929 | case 336: /* filter_clause ::= FILTER LP WHERE expr RP */ |
| 161913 | { yymsp[-4].minor.yy602 = yymsp[-1].minor.yy602; } | 162930 | { yymsp[-4].minor.yy404 = yymsp[-1].minor.yy404; } |
| 161914 | break; | 162931 | break; |
| 161915 | default: | 162932 | default: |
| 161916 | /* (337) input ::= cmdlist */ yytestcase(yyruleno==337); | 162933 | /* (337) input ::= cmdlist */ yytestcase(yyruleno==337); |
| @@ -162377,6 +163394,7 @@ SQLITE_PRIVATE int sqlite3ParserFallback(int iToken){ | |||
| 162377 | #define CC_ID 27 /* unicode characters usable in IDs */ | 163394 | #define CC_ID 27 /* unicode characters usable in IDs */ |
| 162378 | #define CC_ILLEGAL 28 /* Illegal character */ | 163395 | #define CC_ILLEGAL 28 /* Illegal character */ |
| 162379 | #define CC_NUL 29 /* 0x00 */ | 163396 | #define CC_NUL 29 /* 0x00 */ |
| 163397 | #define CC_BOM 30 /* First byte of UTF8 BOM: 0xEF 0xBB 0xBF */ | ||
| 162380 | 163398 | ||
| 162381 | static const unsigned char aiClass[] = { | 163399 | static const unsigned char aiClass[] = { |
| 162382 | #ifdef SQLITE_ASCII | 163400 | #ifdef SQLITE_ASCII |
| @@ -162389,14 +163407,14 @@ static const unsigned char aiClass[] = { | |||
| 162389 | /* 5x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 9, 28, 28, 28, 2, | 163407 | /* 5x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 9, 28, 28, 28, 2, |
| 162390 | /* 6x */ 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 163408 | /* 6x */ 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 162391 | /* 7x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 28, 10, 28, 25, 28, | 163409 | /* 7x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 28, 10, 28, 25, 28, |
| 162392 | /* 8x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 163410 | /* 8x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 162393 | /* 9x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 163411 | /* 9x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 162394 | /* Ax */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 163412 | /* Ax */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 162395 | /* Bx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 163413 | /* Bx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 162396 | /* Cx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 163414 | /* Cx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 162397 | /* Dx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 163415 | /* Dx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 162398 | /* Ex */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 163416 | /* Ex */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 30, |
| 162399 | /* Fx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 | 163417 | /* Fx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27 |
| 162400 | #endif | 163418 | #endif |
| 162401 | #ifdef SQLITE_EBCDIC | 163419 | #ifdef SQLITE_EBCDIC |
| 162402 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ | 163420 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ |
| @@ -163342,6 +164360,14 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){ | |||
| 163342 | i = 1; | 164360 | i = 1; |
| 163343 | break; | 164361 | break; |
| 163344 | } | 164362 | } |
| 164363 | case CC_BOM: { | ||
| 164364 | if( z[1]==0xbb && z[2]==0xbf ){ | ||
| 164365 | *tokenType = TK_SPACE; | ||
| 164366 | return 3; | ||
| 164367 | } | ||
| 164368 | i = 1; | ||
| 164369 | break; | ||
| 164370 | } | ||
| 163345 | case CC_NUL: { | 164371 | case CC_NUL: { |
| 163346 | *tokenType = TK_ILLEGAL; | 164372 | *tokenType = TK_ILLEGAL; |
| 163347 | return 0; | 164373 | return 0; |
| @@ -164358,7 +165384,7 @@ SQLITE_API int sqlite3_initialize(void){ | |||
| 164358 | sqlite3GlobalConfig.isPCacheInit = 1; | 165384 | sqlite3GlobalConfig.isPCacheInit = 1; |
| 164359 | rc = sqlite3OsInit(); | 165385 | rc = sqlite3OsInit(); |
| 164360 | } | 165386 | } |
| 164361 | #ifdef SQLITE_ENABLE_DESERIALIZE | 165387 | #ifndef SQLITE_OMIT_DESERIALIZE |
| 164362 | if( rc==SQLITE_OK ){ | 165388 | if( rc==SQLITE_OK ){ |
| 164363 | rc = sqlite3MemdbInit(); | 165389 | rc = sqlite3MemdbInit(); |
| 164364 | } | 165390 | } |
| @@ -164773,12 +165799,12 @@ SQLITE_API int sqlite3_config(int op, ...){ | |||
| 164773 | } | 165799 | } |
| 164774 | #endif /* SQLITE_ENABLE_SORTER_REFERENCES */ | 165800 | #endif /* SQLITE_ENABLE_SORTER_REFERENCES */ |
| 164775 | 165801 | ||
| 164776 | #ifdef SQLITE_ENABLE_DESERIALIZE | 165802 | #ifndef SQLITE_OMIT_DESERIALIZE |
| 164777 | case SQLITE_CONFIG_MEMDB_MAXSIZE: { | 165803 | case SQLITE_CONFIG_MEMDB_MAXSIZE: { |
| 164778 | sqlite3GlobalConfig.mxMemdbSize = va_arg(ap, sqlite3_int64); | 165804 | sqlite3GlobalConfig.mxMemdbSize = va_arg(ap, sqlite3_int64); |
| 164779 | break; | 165805 | break; |
| 164780 | } | 165806 | } |
| 164781 | #endif /* SQLITE_ENABLE_DESERIALIZE */ | 165807 | #endif /* SQLITE_OMIT_DESERIALIZE */ |
| 164782 | 165808 | ||
| 164783 | default: { | 165809 | default: { |
| 164784 | rc = SQLITE_ERROR; | 165810 | rc = SQLITE_ERROR; |
| @@ -165327,7 +166353,7 @@ SQLITE_API int sqlite3_txn_state(sqlite3 *db, const char *zSchema){ | |||
| 165327 | /* | 166353 | /* |
| 165328 | ** Two variations on the public interface for closing a database | 166354 | ** Two variations on the public interface for closing a database |
| 165329 | ** connection. The sqlite3_close() version returns SQLITE_BUSY and | 166355 | ** connection. The sqlite3_close() version returns SQLITE_BUSY and |
| 165330 | ** leaves the connection option if there are unfinalized prepared | 166356 | ** leaves the connection open if there are unfinalized prepared |
| 165331 | ** statements or unfinished sqlite3_backups. The sqlite3_close_v2() | 166357 | ** statements or unfinished sqlite3_backups. The sqlite3_close_v2() |
| 165332 | ** version forces the connection to become a zombie if there are | 166358 | ** version forces the connection to become a zombie if there are |
| 165333 | ** unclosed resources, and arranges for deallocation when the last | 166359 | ** unclosed resources, and arranges for deallocation when the last |
| @@ -165937,6 +166963,10 @@ SQLITE_PRIVATE int sqlite3CreateFunc( | |||
| 165937 | }else{ | 166963 | }else{ |
| 165938 | sqlite3ExpirePreparedStatements(db, 0); | 166964 | sqlite3ExpirePreparedStatements(db, 0); |
| 165939 | } | 166965 | } |
| 166966 | }else if( xSFunc==0 && xFinal==0 ){ | ||
| 166967 | /* Trying to delete a function that does not exist. This is a no-op. | ||
| 166968 | ** https://sqlite.org/forum/forumpost/726219164b */ | ||
| 166969 | return SQLITE_OK; | ||
| 165940 | } | 166970 | } |
| 165941 | 166971 | ||
| 165942 | p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1); | 166972 | p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1); |
| @@ -168332,6 +169362,36 @@ SQLITE_API int sqlite3_test_control(int op, ...){ | |||
| 168332 | } | 169362 | } |
| 168333 | break; | 169363 | break; |
| 168334 | } | 169364 | } |
| 169365 | |||
| 169366 | #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD) | ||
| 169367 | /* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue) | ||
| 169368 | ** | ||
| 169369 | ** If "id" is an integer between 1 and SQLITE_NTUNE then set the value | ||
| 169370 | ** of the id-th tuning parameter to *piValue. If "id" is between -1 | ||
| 169371 | ** and -SQLITE_NTUNE, then write the current value of the (-id)-th | ||
| 169372 | ** tuning parameter into *piValue. | ||
| 169373 | ** | ||
| 169374 | ** Tuning parameters are for use during transient development builds, | ||
| 169375 | ** to help find the best values for constants in the query planner. | ||
| 169376 | ** Access tuning parameters using the Tuning(ID) macro. Set the | ||
| 169377 | ** parameters in the CLI using ".testctrl tune ID VALUE". | ||
| 169378 | ** | ||
| 169379 | ** Transient use only. Tuning parameters should not be used in | ||
| 169380 | ** checked-in code. | ||
| 169381 | */ | ||
| 169382 | case SQLITE_TESTCTRL_TUNE: { | ||
| 169383 | int id = va_arg(ap, int); | ||
| 169384 | int *piValue = va_arg(ap, int*); | ||
| 169385 | if( id>0 && id<=SQLITE_NTUNE ){ | ||
| 169386 | Tuning(id) = *piValue; | ||
| 169387 | }else if( id<0 && id>=-SQLITE_NTUNE ){ | ||
| 169388 | *piValue = Tuning(-id); | ||
| 169389 | }else{ | ||
| 169390 | rc = SQLITE_NOTFOUND; | ||
| 169391 | } | ||
| 169392 | break; | ||
| 169393 | } | ||
| 169394 | #endif | ||
| 168335 | } | 169395 | } |
| 168336 | va_end(ap); | 169396 | va_end(ap); |
| 168337 | #endif /* SQLITE_UNTESTABLE */ | 169397 | #endif /* SQLITE_UNTESTABLE */ |
| @@ -169774,7 +170834,7 @@ SQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const voi | |||
| 169774 | ** is used for assert() conditions that are true only if it can be | 170834 | ** is used for assert() conditions that are true only if it can be |
| 169775 | ** guranteed that the database is not corrupt. | 170835 | ** guranteed that the database is not corrupt. |
| 169776 | */ | 170836 | */ |
| 169777 | #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) | 170837 | #ifdef SQLITE_DEBUG |
| 169778 | SQLITE_API extern int sqlite3_fts3_may_be_corrupt; | 170838 | SQLITE_API extern int sqlite3_fts3_may_be_corrupt; |
| 169779 | # define assert_fts3_nc(x) assert(sqlite3_fts3_may_be_corrupt || (x)) | 170839 | # define assert_fts3_nc(x) assert(sqlite3_fts3_may_be_corrupt || (x)) |
| 169780 | #else | 170840 | #else |
| @@ -170330,7 +171390,9 @@ SQLITE_PRIVATE int sqlite3Fts3Never(int b) { assert( !b ); return b; } | |||
| 170330 | ** assert() conditions in the fts3 code are activated - conditions that are | 171390 | ** assert() conditions in the fts3 code are activated - conditions that are |
| 170331 | ** only true if it is guaranteed that the fts3 database is not corrupt. | 171391 | ** only true if it is guaranteed that the fts3 database is not corrupt. |
| 170332 | */ | 171392 | */ |
| 171393 | #ifdef SQLITE_DEBUG | ||
| 170333 | SQLITE_API int sqlite3_fts3_may_be_corrupt = 1; | 171394 | SQLITE_API int sqlite3_fts3_may_be_corrupt = 1; |
| 171395 | #endif | ||
| 170334 | 171396 | ||
| 170335 | /* | 171397 | /* |
| 170336 | ** Write a 64-bit variable-length integer to memory starting at p[0]. | 171398 | ** Write a 64-bit variable-length integer to memory starting at p[0]. |
| @@ -171901,7 +172963,7 @@ static int fts3ScanInteriorNode( | |||
| 171901 | char *zBuffer = 0; /* Buffer to load terms into */ | 172963 | char *zBuffer = 0; /* Buffer to load terms into */ |
| 171902 | i64 nAlloc = 0; /* Size of allocated buffer */ | 172964 | i64 nAlloc = 0; /* Size of allocated buffer */ |
| 171903 | int isFirstTerm = 1; /* True when processing first term on page */ | 172965 | int isFirstTerm = 1; /* True when processing first term on page */ |
| 171904 | sqlite3_int64 iChild; /* Block id of child node to descend to */ | 172966 | u64 iChild; /* Block id of child node to descend to */ |
| 171905 | int nBuffer = 0; /* Total term size */ | 172967 | int nBuffer = 0; /* Total term size */ |
| 171906 | 172968 | ||
| 171907 | /* Skip over the 'height' varint that occurs at the start of every | 172969 | /* Skip over the 'height' varint that occurs at the start of every |
| @@ -171917,8 +172979,8 @@ static int fts3ScanInteriorNode( | |||
| 171917 | ** table, then there are always 20 bytes of zeroed padding following the | 172979 | ** table, then there are always 20 bytes of zeroed padding following the |
| 171918 | ** nNode bytes of content (see sqlite3Fts3ReadBlock() for details). | 172980 | ** nNode bytes of content (see sqlite3Fts3ReadBlock() for details). |
| 171919 | */ | 172981 | */ |
| 171920 | zCsr += sqlite3Fts3GetVarint(zCsr, &iChild); | 172982 | zCsr += sqlite3Fts3GetVarintU(zCsr, &iChild); |
| 171921 | zCsr += sqlite3Fts3GetVarint(zCsr, &iChild); | 172983 | zCsr += sqlite3Fts3GetVarintU(zCsr, &iChild); |
| 171922 | if( zCsr>zEnd ){ | 172984 | if( zCsr>zEnd ){ |
| 171923 | return FTS_CORRUPT_VTAB; | 172985 | return FTS_CORRUPT_VTAB; |
| 171924 | } | 172986 | } |
| @@ -171971,20 +173033,20 @@ static int fts3ScanInteriorNode( | |||
| 171971 | */ | 173033 | */ |
| 171972 | cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer)); | 173034 | cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer)); |
| 171973 | if( piFirst && (cmp<0 || (cmp==0 && nBuffer>nTerm)) ){ | 173035 | if( piFirst && (cmp<0 || (cmp==0 && nBuffer>nTerm)) ){ |
| 171974 | *piFirst = iChild; | 173036 | *piFirst = (i64)iChild; |
| 171975 | piFirst = 0; | 173037 | piFirst = 0; |
| 171976 | } | 173038 | } |
| 171977 | 173039 | ||
| 171978 | if( piLast && cmp<0 ){ | 173040 | if( piLast && cmp<0 ){ |
| 171979 | *piLast = iChild; | 173041 | *piLast = (i64)iChild; |
| 171980 | piLast = 0; | 173042 | piLast = 0; |
| 171981 | } | 173043 | } |
| 171982 | 173044 | ||
| 171983 | iChild++; | 173045 | iChild++; |
| 171984 | }; | 173046 | }; |
| 171985 | 173047 | ||
| 171986 | if( piFirst ) *piFirst = iChild; | 173048 | if( piFirst ) *piFirst = (i64)iChild; |
| 171987 | if( piLast ) *piLast = iChild; | 173049 | if( piLast ) *piLast = (i64)iChild; |
| 171988 | 173050 | ||
| 171989 | finish_scan: | 173051 | finish_scan: |
| 171990 | sqlite3_free(zBuffer); | 173052 | sqlite3_free(zBuffer); |
| @@ -173590,14 +174652,20 @@ static int fts3SetHasStat(Fts3Table *p){ | |||
| 173590 | */ | 174652 | */ |
| 173591 | static int fts3BeginMethod(sqlite3_vtab *pVtab){ | 174653 | static int fts3BeginMethod(sqlite3_vtab *pVtab){ |
| 173592 | Fts3Table *p = (Fts3Table*)pVtab; | 174654 | Fts3Table *p = (Fts3Table*)pVtab; |
| 174655 | int rc; | ||
| 173593 | UNUSED_PARAMETER(pVtab); | 174656 | UNUSED_PARAMETER(pVtab); |
| 173594 | assert( p->pSegments==0 ); | 174657 | assert( p->pSegments==0 ); |
| 173595 | assert( p->nPendingData==0 ); | 174658 | assert( p->nPendingData==0 ); |
| 173596 | assert( p->inTransaction!=1 ); | 174659 | assert( p->inTransaction!=1 ); |
| 173597 | TESTONLY( p->inTransaction = 1 ); | ||
| 173598 | TESTONLY( p->mxSavepoint = -1; ); | ||
| 173599 | p->nLeafAdd = 0; | 174660 | p->nLeafAdd = 0; |
| 173600 | return fts3SetHasStat(p); | 174661 | rc = fts3SetHasStat(p); |
| 174662 | #ifdef SQLITE_DEBUG | ||
| 174663 | if( rc==SQLITE_OK ){ | ||
| 174664 | p->inTransaction = 1; | ||
| 174665 | p->mxSavepoint = -1; | ||
| 174666 | } | ||
| 174667 | #endif | ||
| 174668 | return rc; | ||
| 173601 | } | 174669 | } |
| 173602 | 174670 | ||
| 173603 | /* | 174671 | /* |
| @@ -175126,16 +176194,15 @@ static int fts3EvalStart(Fts3Cursor *pCsr){ | |||
| 175126 | #ifndef SQLITE_DISABLE_FTS4_DEFERRED | 176194 | #ifndef SQLITE_DISABLE_FTS4_DEFERRED |
| 175127 | if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){ | 176195 | if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){ |
| 175128 | Fts3TokenAndCost *aTC; | 176196 | Fts3TokenAndCost *aTC; |
| 175129 | Fts3Expr **apOr; | ||
| 175130 | aTC = (Fts3TokenAndCost *)sqlite3_malloc64( | 176197 | aTC = (Fts3TokenAndCost *)sqlite3_malloc64( |
| 175131 | sizeof(Fts3TokenAndCost) * nToken | 176198 | sizeof(Fts3TokenAndCost) * nToken |
| 175132 | + sizeof(Fts3Expr *) * nOr * 2 | 176199 | + sizeof(Fts3Expr *) * nOr * 2 |
| 175133 | ); | 176200 | ); |
| 175134 | apOr = (Fts3Expr **)&aTC[nToken]; | ||
| 175135 | 176201 | ||
| 175136 | if( !aTC ){ | 176202 | if( !aTC ){ |
| 175137 | rc = SQLITE_NOMEM; | 176203 | rc = SQLITE_NOMEM; |
| 175138 | }else{ | 176204 | }else{ |
| 176205 | Fts3Expr **apOr = (Fts3Expr **)&aTC[nToken]; | ||
| 175139 | int ii; | 176206 | int ii; |
| 175140 | Fts3TokenAndCost *pTC = aTC; | 176207 | Fts3TokenAndCost *pTC = aTC; |
| 175141 | Fts3Expr **ppOr = apOr; | 176208 | Fts3Expr **ppOr = apOr; |
| @@ -176511,6 +177578,7 @@ static int fts3auxFilterMethod( | |||
| 176511 | sqlite3Fts3SegReaderFinish(&pCsr->csr); | 177578 | sqlite3Fts3SegReaderFinish(&pCsr->csr); |
| 176512 | sqlite3_free((void *)pCsr->filter.zTerm); | 177579 | sqlite3_free((void *)pCsr->filter.zTerm); |
| 176513 | sqlite3_free(pCsr->aStat); | 177580 | sqlite3_free(pCsr->aStat); |
| 177581 | sqlite3_free(pCsr->zStop); | ||
| 176514 | memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr); | 177582 | memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr); |
| 176515 | 177583 | ||
| 176516 | pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY; | 177584 | pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY; |
| @@ -182032,7 +183100,7 @@ static int fts3SegReaderCmp(Fts3SegReader *pLhs, Fts3SegReader *pRhs){ | |||
| 182032 | if( rc==0 ){ | 183100 | if( rc==0 ){ |
| 182033 | rc = pRhs->iIdx - pLhs->iIdx; | 183101 | rc = pRhs->iIdx - pLhs->iIdx; |
| 182034 | } | 183102 | } |
| 182035 | assert( rc!=0 ); | 183103 | assert_fts3_nc( rc!=0 ); |
| 182036 | return rc; | 183104 | return rc; |
| 182037 | } | 183105 | } |
| 182038 | 183106 | ||
| @@ -182228,8 +183296,8 @@ static int fts3PrefixCompress( | |||
| 182228 | int nNext /* Size of buffer zNext in bytes */ | 183296 | int nNext /* Size of buffer zNext in bytes */ |
| 182229 | ){ | 183297 | ){ |
| 182230 | int n; | 183298 | int n; |
| 182231 | UNUSED_PARAMETER(nNext); | 183299 | for(n=0; n<nPrev && n<nNext && zPrev[n]==zNext[n]; n++); |
| 182232 | for(n=0; n<nPrev && zPrev[n]==zNext[n]; n++); | 183300 | assert_fts3_nc( n<nNext ); |
| 182233 | return n; | 183301 | return n; |
| 182234 | } | 183302 | } |
| 182235 | 183303 | ||
| @@ -183228,7 +184296,7 @@ SQLITE_PRIVATE int sqlite3Fts3SegReaderStep( | |||
| 183228 | 184296 | ||
| 183229 | nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0); | 184297 | nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0); |
| 183230 | 184298 | ||
| 183231 | rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist); | 184299 | rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist+FTS3_NODE_PADDING); |
| 183232 | if( rc ) return rc; | 184300 | if( rc ) return rc; |
| 183233 | 184301 | ||
| 183234 | if( isFirst ){ | 184302 | if( isFirst ){ |
| @@ -186042,6 +187110,10 @@ SQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *p){ | |||
| 186042 | /* #include <string.h> */ | 187110 | /* #include <string.h> */ |
| 186043 | /* #include <assert.h> */ | 187111 | /* #include <assert.h> */ |
| 186044 | 187112 | ||
| 187113 | #ifndef SQLITE_AMALGAMATION | ||
| 187114 | typedef sqlite3_int64 i64; | ||
| 187115 | #endif | ||
| 187116 | |||
| 186045 | /* | 187117 | /* |
| 186046 | ** Characters that may appear in the second argument to matchinfo(). | 187118 | ** Characters that may appear in the second argument to matchinfo(). |
| 186047 | */ | 187119 | */ |
| @@ -186092,9 +187164,9 @@ struct SnippetIter { | |||
| 186092 | struct SnippetPhrase { | 187164 | struct SnippetPhrase { |
| 186093 | int nToken; /* Number of tokens in phrase */ | 187165 | int nToken; /* Number of tokens in phrase */ |
| 186094 | char *pList; /* Pointer to start of phrase position list */ | 187166 | char *pList; /* Pointer to start of phrase position list */ |
| 186095 | int iHead; /* Next value in position list */ | 187167 | i64 iHead; /* Next value in position list */ |
| 186096 | char *pHead; /* Position list data following iHead */ | 187168 | char *pHead; /* Position list data following iHead */ |
| 186097 | int iTail; /* Next value in trailing position list */ | 187169 | i64 iTail; /* Next value in trailing position list */ |
| 186098 | char *pTail; /* Position list data following iTail */ | 187170 | char *pTail; /* Position list data following iTail */ |
| 186099 | }; | 187171 | }; |
| 186100 | 187172 | ||
| @@ -186259,7 +187331,7 @@ SQLITE_PRIVATE void sqlite3Fts3MIBufferFree(MatchinfoBuffer *p){ | |||
| 186259 | ** After it returns, *piPos contains the value of the next element of the | 187331 | ** After it returns, *piPos contains the value of the next element of the |
| 186260 | ** list and *pp is advanced to the following varint. | 187332 | ** list and *pp is advanced to the following varint. |
| 186261 | */ | 187333 | */ |
| 186262 | static void fts3GetDeltaPosition(char **pp, int *piPos){ | 187334 | static void fts3GetDeltaPosition(char **pp, i64 *piPos){ |
| 186263 | int iVal; | 187335 | int iVal; |
| 186264 | *pp += fts3GetVarint32(*pp, &iVal); | 187336 | *pp += fts3GetVarint32(*pp, &iVal); |
| 186265 | *piPos += (iVal-2); | 187337 | *piPos += (iVal-2); |
| @@ -186368,10 +187440,10 @@ static int fts3ExprPhraseCount(Fts3Expr *pExpr){ | |||
| 186368 | ** arguments so that it points to the first element with a value greater | 187440 | ** arguments so that it points to the first element with a value greater |
| 186369 | ** than or equal to parameter iNext. | 187441 | ** than or equal to parameter iNext. |
| 186370 | */ | 187442 | */ |
| 186371 | static void fts3SnippetAdvance(char **ppIter, int *piIter, int iNext){ | 187443 | static void fts3SnippetAdvance(char **ppIter, i64 *piIter, int iNext){ |
| 186372 | char *pIter = *ppIter; | 187444 | char *pIter = *ppIter; |
| 186373 | if( pIter ){ | 187445 | if( pIter ){ |
| 186374 | int iIter = *piIter; | 187446 | i64 iIter = *piIter; |
| 186375 | 187447 | ||
| 186376 | while( iIter<iNext ){ | 187448 | while( iIter<iNext ){ |
| 186377 | if( 0==(*pIter & 0xFE) ){ | 187449 | if( 0==(*pIter & 0xFE) ){ |
| @@ -186454,7 +187526,7 @@ static void fts3SnippetDetails( | |||
| 186454 | SnippetPhrase *pPhrase = &pIter->aPhrase[i]; | 187526 | SnippetPhrase *pPhrase = &pIter->aPhrase[i]; |
| 186455 | if( pPhrase->pTail ){ | 187527 | if( pPhrase->pTail ){ |
| 186456 | char *pCsr = pPhrase->pTail; | 187528 | char *pCsr = pPhrase->pTail; |
| 186457 | int iCsr = pPhrase->iTail; | 187529 | i64 iCsr = pPhrase->iTail; |
| 186458 | 187530 | ||
| 186459 | while( iCsr<(iStart+pIter->nSnippet) && iCsr>=iStart ){ | 187531 | while( iCsr<(iStart+pIter->nSnippet) && iCsr>=iStart ){ |
| 186460 | int j; | 187532 | int j; |
| @@ -186500,7 +187572,7 @@ static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){ | |||
| 186500 | rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr); | 187572 | rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr); |
| 186501 | assert( rc==SQLITE_OK || pCsr==0 ); | 187573 | assert( rc==SQLITE_OK || pCsr==0 ); |
| 186502 | if( pCsr ){ | 187574 | if( pCsr ){ |
| 186503 | int iFirst = 0; | 187575 | i64 iFirst = 0; |
| 186504 | pPhrase->pList = pCsr; | 187576 | pPhrase->pList = pCsr; |
| 186505 | fts3GetDeltaPosition(&pCsr, &iFirst); | 187577 | fts3GetDeltaPosition(&pCsr, &iFirst); |
| 186506 | if( iFirst<0 ){ | 187578 | if( iFirst<0 ){ |
| @@ -187564,8 +188636,8 @@ typedef struct TermOffsetCtx TermOffsetCtx; | |||
| 187564 | 188636 | ||
| 187565 | struct TermOffset { | 188637 | struct TermOffset { |
| 187566 | char *pList; /* Position-list */ | 188638 | char *pList; /* Position-list */ |
| 187567 | int iPos; /* Position just read from pList */ | 188639 | i64 iPos; /* Position just read from pList */ |
| 187568 | int iOff; /* Offset of this term from read positions */ | 188640 | i64 iOff; /* Offset of this term from read positions */ |
| 187569 | }; | 188641 | }; |
| 187570 | 188642 | ||
| 187571 | struct TermOffsetCtx { | 188643 | struct TermOffsetCtx { |
| @@ -187584,7 +188656,7 @@ static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){ | |||
| 187584 | int nTerm; /* Number of tokens in phrase */ | 188656 | int nTerm; /* Number of tokens in phrase */ |
| 187585 | int iTerm; /* For looping through nTerm phrase terms */ | 188657 | int iTerm; /* For looping through nTerm phrase terms */ |
| 187586 | char *pList; /* Pointer to position list for phrase */ | 188658 | char *pList; /* Pointer to position list for phrase */ |
| 187587 | int iPos = 0; /* First position in position-list */ | 188659 | i64 iPos = 0; /* First position in position-list */ |
| 187588 | int rc; | 188660 | int rc; |
| 187589 | 188661 | ||
| 187590 | UNUSED_PARAMETER(iPhrase); | 188662 | UNUSED_PARAMETER(iPhrase); |
| @@ -188861,7 +189933,7 @@ static void jsonAppendSeparator(JsonString *p){ | |||
| 188861 | */ | 189933 | */ |
| 188862 | static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ | 189934 | static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ |
| 188863 | u32 i; | 189935 | u32 i; |
| 188864 | if( (N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0 ) return; | 189936 | if( zIn==0 || ((N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0) ) return; |
| 188865 | p->zBuf[p->nUsed++] = '"'; | 189937 | p->zBuf[p->nUsed++] = '"'; |
| 188866 | for(i=0; i<N; i++){ | 189938 | for(i=0; i<N; i++){ |
| 188867 | unsigned char c = ((unsigned const char*)zIn)[i]; | 189939 | unsigned char c = ((unsigned const char*)zIn)[i]; |
| @@ -190460,8 +191532,8 @@ static void jsonArrayStep( | |||
| 190460 | jsonAppendChar(pStr, '['); | 191532 | jsonAppendChar(pStr, '['); |
| 190461 | }else if( pStr->nUsed>1 ){ | 191533 | }else if( pStr->nUsed>1 ){ |
| 190462 | jsonAppendChar(pStr, ','); | 191534 | jsonAppendChar(pStr, ','); |
| 190463 | pStr->pCtx = ctx; | ||
| 190464 | } | 191535 | } |
| 191536 | pStr->pCtx = ctx; | ||
| 190465 | jsonAppendValue(pStr, argv[0]); | 191537 | jsonAppendValue(pStr, argv[0]); |
| 190466 | } | 191538 | } |
| 190467 | } | 191539 | } |
| @@ -190521,11 +191593,7 @@ static void jsonGroupInverse( | |||
| 190521 | if( NEVER(!pStr) ) return; | 191593 | if( NEVER(!pStr) ) return; |
| 190522 | #endif | 191594 | #endif |
| 190523 | z = pStr->zBuf; | 191595 | z = pStr->zBuf; |
| 190524 | for(i=1; (c = z[i])!=',' || inStr || nNest; i++){ | 191596 | for(i=1; i<pStr->nUsed && ((c = z[i])!=',' || inStr || nNest); i++){ |
| 190525 | if( i>=pStr->nUsed ){ | ||
| 190526 | pStr->nUsed = 1; | ||
| 190527 | return; | ||
| 190528 | } | ||
| 190529 | if( c=='"' ){ | 191597 | if( c=='"' ){ |
| 190530 | inStr = !inStr; | 191598 | inStr = !inStr; |
| 190531 | }else if( c=='\\' ){ | 191599 | }else if( c=='\\' ){ |
| @@ -190535,8 +191603,13 @@ static void jsonGroupInverse( | |||
| 190535 | if( c=='}' || c==']' ) nNest--; | 191603 | if( c=='}' || c==']' ) nNest--; |
| 190536 | } | 191604 | } |
| 190537 | } | 191605 | } |
| 190538 | pStr->nUsed -= i; | 191606 | if( i<pStr->nUsed ){ |
| 190539 | memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1); | 191607 | pStr->nUsed -= i; |
| 191608 | memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1); | ||
| 191609 | z[pStr->nUsed] = 0; | ||
| 191610 | }else{ | ||
| 191611 | pStr->nUsed = 1; | ||
| 191612 | } | ||
| 190540 | } | 191613 | } |
| 190541 | #else | 191614 | #else |
| 190542 | # define jsonGroupInverse 0 | 191615 | # define jsonGroupInverse 0 |
| @@ -190564,8 +191637,8 @@ static void jsonObjectStep( | |||
| 190564 | jsonAppendChar(pStr, '{'); | 191637 | jsonAppendChar(pStr, '{'); |
| 190565 | }else if( pStr->nUsed>1 ){ | 191638 | }else if( pStr->nUsed>1 ){ |
| 190566 | jsonAppendChar(pStr, ','); | 191639 | jsonAppendChar(pStr, ','); |
| 190567 | pStr->pCtx = ctx; | ||
| 190568 | } | 191640 | } |
| 191641 | pStr->pCtx = ctx; | ||
| 190569 | z = (const char*)sqlite3_value_text(argv[0]); | 191642 | z = (const char*)sqlite3_value_text(argv[0]); |
| 190570 | n = (u32)sqlite3_value_bytes(argv[0]); | 191643 | n = (u32)sqlite3_value_bytes(argv[0]); |
| 190571 | jsonAppendString(pStr, z, n); | 191644 | jsonAppendString(pStr, z, n); |
| @@ -195086,11 +196159,16 @@ static void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ | |||
| 195086 | UNUSED_PARAMETER(nArg); | 196159 | UNUSED_PARAMETER(nArg); |
| 195087 | if( sqlite3_value_type(apArg[0])!=SQLITE_BLOB | 196160 | if( sqlite3_value_type(apArg[0])!=SQLITE_BLOB |
| 195088 | || sqlite3_value_bytes(apArg[0])<2 | 196161 | || sqlite3_value_bytes(apArg[0])<2 |
| 196162 | |||
| 195089 | ){ | 196163 | ){ |
| 195090 | sqlite3_result_error(ctx, "Invalid argument to rtreedepth()", -1); | 196164 | sqlite3_result_error(ctx, "Invalid argument to rtreedepth()", -1); |
| 195091 | }else{ | 196165 | }else{ |
| 195092 | u8 *zBlob = (u8 *)sqlite3_value_blob(apArg[0]); | 196166 | u8 *zBlob = (u8 *)sqlite3_value_blob(apArg[0]); |
| 195093 | sqlite3_result_int(ctx, readInt16(zBlob)); | 196167 | if( zBlob ){ |
| 196168 | sqlite3_result_int(ctx, readInt16(zBlob)); | ||
| 196169 | }else{ | ||
| 196170 | sqlite3_result_error_nomem(ctx); | ||
| 196171 | } | ||
| 195094 | } | 196172 | } |
| 195095 | } | 196173 | } |
| 195096 | 196174 | ||
| @@ -195876,6 +196954,10 @@ static GeoPoly *geopolyFuncParam( | |||
| 195876 | ){ | 196954 | ){ |
| 195877 | const unsigned char *a = sqlite3_value_blob(pVal); | 196955 | const unsigned char *a = sqlite3_value_blob(pVal); |
| 195878 | int nVertex; | 196956 | int nVertex; |
| 196957 | if( a==0 ){ | ||
| 196958 | sqlite3_result_error_nomem(pCtx); | ||
| 196959 | return 0; | ||
| 196960 | } | ||
| 195879 | nVertex = (a[1]<<16) + (a[2]<<8) + a[3]; | 196961 | nVertex = (a[1]<<16) + (a[2]<<8) + a[3]; |
| 195880 | if( (a[0]==0 || a[0]==1) | 196962 | if( (a[0]==0 || a[0]==1) |
| 195881 | && (nVertex*2*sizeof(GeoCoord) + 4)==(unsigned int)nByte | 196963 | && (nVertex*2*sizeof(GeoCoord) + 4)==(unsigned int)nByte |
| @@ -196249,7 +197331,7 @@ static GeoPoly *geopolyBBox( | |||
| 196249 | aCoord[2].f = mnY; | 197331 | aCoord[2].f = mnY; |
| 196250 | aCoord[3].f = mxY; | 197332 | aCoord[3].f = mxY; |
| 196251 | } | 197333 | } |
| 196252 | }else{ | 197334 | }else if( aCoord ){ |
| 196253 | memset(aCoord, 0, sizeof(RtreeCoord)*4); | 197335 | memset(aCoord, 0, sizeof(RtreeCoord)*4); |
| 196254 | } | 197336 | } |
| 196255 | return pOut; | 197337 | return pOut; |
| @@ -200609,7 +201691,9 @@ char *rbuVacuumIndexStart( | |||
| 200609 | zSep = ""; | 201691 | zSep = ""; |
| 200610 | for(iCol=0; iCol<pIter->nCol; iCol++){ | 201692 | for(iCol=0; iCol<pIter->nCol; iCol++){ |
| 200611 | const char *zQuoted = (const char*)sqlite3_column_text(pSel, iCol); | 201693 | const char *zQuoted = (const char*)sqlite3_column_text(pSel, iCol); |
| 200612 | if( zQuoted[0]=='N' ){ | 201694 | if( zQuoted==0 ){ |
| 201695 | p->rc = SQLITE_NOMEM; | ||
| 201696 | }else if( zQuoted[0]=='N' ){ | ||
| 200613 | bFailed = 1; | 201697 | bFailed = 1; |
| 200614 | break; | 201698 | break; |
| 200615 | } | 201699 | } |
| @@ -203981,28 +205065,14 @@ static int rbuVfsOpen( | |||
| 203981 | rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName, 0); | 205065 | rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName, 0); |
| 203982 | if( pDb ){ | 205066 | if( pDb ){ |
| 203983 | if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){ | 205067 | if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){ |
| 203984 | /* This call is to open a *-wal file. Intead, open the *-oal. This | 205068 | /* This call is to open a *-wal file. Intead, open the *-oal. */ |
| 203985 | ** code ensures that the string passed to xOpen() is terminated by a | 205069 | size_t nOpen; |
| 203986 | ** pair of '\0' bytes in case the VFS attempts to extract a URI | ||
| 203987 | ** parameter from it. */ | ||
| 203988 | const char *zBase = zName; | ||
| 203989 | size_t nCopy; | ||
| 203990 | char *zCopy; | ||
| 203991 | if( rbuIsVacuum(pDb->pRbu) ){ | 205070 | if( rbuIsVacuum(pDb->pRbu) ){ |
| 203992 | zBase = sqlite3_db_filename(pDb->pRbu->dbRbu, "main"); | 205071 | zOpen = sqlite3_db_filename(pDb->pRbu->dbRbu, "main"); |
| 203993 | zBase = sqlite3_filename_wal(zBase); | 205072 | zOpen = sqlite3_filename_wal(zOpen); |
| 203994 | } | ||
| 203995 | nCopy = strlen(zBase); | ||
| 203996 | zCopy = sqlite3_malloc64(nCopy+2); | ||
| 203997 | if( zCopy ){ | ||
| 203998 | memcpy(zCopy, zBase, nCopy); | ||
| 203999 | zCopy[nCopy-3] = 'o'; | ||
| 204000 | zCopy[nCopy] = '\0'; | ||
| 204001 | zCopy[nCopy+1] = '\0'; | ||
| 204002 | zOpen = (const char*)(pFd->zDel = zCopy); | ||
| 204003 | }else{ | ||
| 204004 | rc = SQLITE_NOMEM; | ||
| 204005 | } | 205073 | } |
| 205074 | nOpen = strlen(zOpen); | ||
| 205075 | ((char*)zOpen)[nOpen-3] = 'o'; | ||
| 204006 | pFd->pRbu = pDb->pRbu; | 205076 | pFd->pRbu = pDb->pRbu; |
| 204007 | } | 205077 | } |
| 204008 | pDb->pWalFd = pFd; | 205078 | pDb->pWalFd = pFd; |
| @@ -205615,6 +206685,7 @@ struct SessionHook { | |||
| 205615 | struct sqlite3_session { | 206685 | struct sqlite3_session { |
| 205616 | sqlite3 *db; /* Database handle session is attached to */ | 206686 | sqlite3 *db; /* Database handle session is attached to */ |
| 205617 | char *zDb; /* Name of database session is attached to */ | 206687 | char *zDb; /* Name of database session is attached to */ |
| 206688 | int bEnableSize; /* True if changeset_size() enabled */ | ||
| 205618 | int bEnable; /* True if currently recording */ | 206689 | int bEnable; /* True if currently recording */ |
| 205619 | int bIndirect; /* True if all changes are indirect */ | 206690 | int bIndirect; /* True if all changes are indirect */ |
| 205620 | int bAutoAttach; /* True to auto-attach tables */ | 206691 | int bAutoAttach; /* True to auto-attach tables */ |
| @@ -205622,6 +206693,7 @@ struct sqlite3_session { | |||
| 205622 | void *pFilterCtx; /* First argument to pass to xTableFilter */ | 206693 | void *pFilterCtx; /* First argument to pass to xTableFilter */ |
| 205623 | int (*xTableFilter)(void *pCtx, const char *zTab); | 206694 | int (*xTableFilter)(void *pCtx, const char *zTab); |
| 205624 | i64 nMalloc; /* Number of bytes of data allocated */ | 206695 | i64 nMalloc; /* Number of bytes of data allocated */ |
| 206696 | i64 nMaxChangesetSize; | ||
| 205625 | sqlite3_value *pZeroBlob; /* Value containing X'' */ | 206697 | sqlite3_value *pZeroBlob; /* Value containing X'' */ |
| 205626 | sqlite3_session *pNext; /* Next session object on same db. */ | 206698 | sqlite3_session *pNext; /* Next session object on same db. */ |
| 205627 | SessionTable *pTable; /* List of attached tables */ | 206699 | SessionTable *pTable; /* List of attached tables */ |
| @@ -205864,8 +206936,9 @@ struct SessionTable { | |||
| 205864 | ** this structure stored in a SessionTable.aChange[] hash table. | 206936 | ** this structure stored in a SessionTable.aChange[] hash table. |
| 205865 | */ | 206937 | */ |
| 205866 | struct SessionChange { | 206938 | struct SessionChange { |
| 205867 | int op; /* One of UPDATE, DELETE, INSERT */ | 206939 | u8 op; /* One of UPDATE, DELETE, INSERT */ |
| 205868 | int bIndirect; /* True if this change is "indirect" */ | 206940 | u8 bIndirect; /* True if this change is "indirect" */ |
| 206941 | int nMaxSize; /* Max size of eventual changeset record */ | ||
| 205869 | int nRecord; /* Number of bytes in buffer aRecord[] */ | 206942 | int nRecord; /* Number of bytes in buffer aRecord[] */ |
| 205870 | u8 *aRecord; /* Buffer containing old.* record */ | 206943 | u8 *aRecord; /* Buffer containing old.* record */ |
| 205871 | SessionChange *pNext; /* For hash-table collisions */ | 206944 | SessionChange *pNext; /* For hash-table collisions */ |
| @@ -206694,6 +207767,12 @@ static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ | |||
| 206694 | if( 0==sqlite3_stricmp("sqlite_stat1", pTab->zName) ){ | 207767 | if( 0==sqlite3_stricmp("sqlite_stat1", pTab->zName) ){ |
| 206695 | pTab->bStat1 = 1; | 207768 | pTab->bStat1 = 1; |
| 206696 | } | 207769 | } |
| 207770 | |||
| 207771 | if( pSession->bEnableSize ){ | ||
| 207772 | pSession->nMaxChangesetSize += ( | ||
| 207773 | 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1 | ||
| 207774 | ); | ||
| 207775 | } | ||
| 206697 | } | 207776 | } |
| 206698 | } | 207777 | } |
| 206699 | return (pSession->rc || pTab->abPK==0); | 207778 | return (pSession->rc || pTab->abPK==0); |
| @@ -206739,6 +207818,103 @@ static int sessionStat1Depth(void *pCtx){ | |||
| 206739 | return p->hook.xDepth(p->hook.pCtx); | 207818 | return p->hook.xDepth(p->hook.pCtx); |
| 206740 | } | 207819 | } |
| 206741 | 207820 | ||
| 207821 | static int sessionUpdateMaxSize( | ||
| 207822 | int op, | ||
| 207823 | sqlite3_session *pSession, /* Session object pTab is attached to */ | ||
| 207824 | SessionTable *pTab, /* Table that change applies to */ | ||
| 207825 | SessionChange *pC /* Update pC->nMaxSize */ | ||
| 207826 | ){ | ||
| 207827 | i64 nNew = 2; | ||
| 207828 | if( pC->op==SQLITE_INSERT ){ | ||
| 207829 | if( op!=SQLITE_DELETE ){ | ||
| 207830 | int ii; | ||
| 207831 | for(ii=0; ii<pTab->nCol; ii++){ | ||
| 207832 | sqlite3_value *p = 0; | ||
| 207833 | pSession->hook.xNew(pSession->hook.pCtx, ii, &p); | ||
| 207834 | sessionSerializeValue(0, p, &nNew); | ||
| 207835 | } | ||
| 207836 | } | ||
| 207837 | }else if( op==SQLITE_DELETE ){ | ||
| 207838 | nNew += pC->nRecord; | ||
| 207839 | if( sqlite3_preupdate_blobwrite(pSession->db)>=0 ){ | ||
| 207840 | nNew += pC->nRecord; | ||
| 207841 | } | ||
| 207842 | }else{ | ||
| 207843 | int ii; | ||
| 207844 | u8 *pCsr = pC->aRecord; | ||
| 207845 | for(ii=0; ii<pTab->nCol; ii++){ | ||
| 207846 | int bChanged = 1; | ||
| 207847 | int nOld = 0; | ||
| 207848 | int eType; | ||
| 207849 | sqlite3_value *p = 0; | ||
| 207850 | pSession->hook.xNew(pSession->hook.pCtx, ii, &p); | ||
| 207851 | if( p==0 ){ | ||
| 207852 | return SQLITE_NOMEM; | ||
| 207853 | } | ||
| 207854 | |||
| 207855 | eType = *pCsr++; | ||
| 207856 | switch( eType ){ | ||
| 207857 | case SQLITE_NULL: | ||
| 207858 | bChanged = sqlite3_value_type(p)!=SQLITE_NULL; | ||
| 207859 | break; | ||
| 207860 | |||
| 207861 | case SQLITE_FLOAT: | ||
| 207862 | case SQLITE_INTEGER: { | ||
| 207863 | if( eType==sqlite3_value_type(p) ){ | ||
| 207864 | sqlite3_int64 iVal = sessionGetI64(pCsr); | ||
| 207865 | if( eType==SQLITE_INTEGER ){ | ||
| 207866 | bChanged = (iVal!=sqlite3_value_int64(p)); | ||
| 207867 | }else{ | ||
| 207868 | double dVal; | ||
| 207869 | memcpy(&dVal, &iVal, 8); | ||
| 207870 | bChanged = (dVal!=sqlite3_value_double(p)); | ||
| 207871 | } | ||
| 207872 | } | ||
| 207873 | nOld = 8; | ||
| 207874 | pCsr += 8; | ||
| 207875 | break; | ||
| 207876 | } | ||
| 207877 | |||
| 207878 | default: { | ||
| 207879 | int nByte; | ||
| 207880 | nOld = sessionVarintGet(pCsr, &nByte); | ||
| 207881 | pCsr += nOld; | ||
| 207882 | nOld += nByte; | ||
| 207883 | assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); | ||
| 207884 | if( eType==sqlite3_value_type(p) | ||
| 207885 | && nByte==sqlite3_value_bytes(p) | ||
| 207886 | && (nByte==0 || 0==memcmp(pCsr, sqlite3_value_blob(p), nByte)) | ||
| 207887 | ){ | ||
| 207888 | bChanged = 0; | ||
| 207889 | } | ||
| 207890 | pCsr += nByte; | ||
| 207891 | break; | ||
| 207892 | } | ||
| 207893 | } | ||
| 207894 | |||
| 207895 | if( bChanged && pTab->abPK[ii] ){ | ||
| 207896 | nNew = pC->nRecord + 2; | ||
| 207897 | break; | ||
| 207898 | } | ||
| 207899 | |||
| 207900 | if( bChanged ){ | ||
| 207901 | nNew += 1 + nOld; | ||
| 207902 | sessionSerializeValue(0, p, &nNew); | ||
| 207903 | }else if( pTab->abPK[ii] ){ | ||
| 207904 | nNew += 2 + nOld; | ||
| 207905 | }else{ | ||
| 207906 | nNew += 2; | ||
| 207907 | } | ||
| 207908 | } | ||
| 207909 | } | ||
| 207910 | |||
| 207911 | if( nNew>pC->nMaxSize ){ | ||
| 207912 | int nIncr = nNew - pC->nMaxSize; | ||
| 207913 | pC->nMaxSize = nNew; | ||
| 207914 | pSession->nMaxChangesetSize += nIncr; | ||
| 207915 | } | ||
| 207916 | return SQLITE_OK; | ||
| 207917 | } | ||
| 206742 | 207918 | ||
| 206743 | /* | 207919 | /* |
| 206744 | ** This function is only called from with a pre-update-hook reporting a | 207920 | ** This function is only called from with a pre-update-hook reporting a |
| @@ -206812,7 +207988,6 @@ static void sessionPreupdateOneChange( | |||
| 206812 | /* Create a new change object containing all the old values (if | 207988 | /* Create a new change object containing all the old values (if |
| 206813 | ** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK | 207989 | ** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK |
| 206814 | ** values (if this is an INSERT). */ | 207990 | ** values (if this is an INSERT). */ |
| 206815 | SessionChange *pChange; /* New change object */ | ||
| 206816 | sqlite3_int64 nByte; /* Number of bytes to allocate */ | 207991 | sqlite3_int64 nByte; /* Number of bytes to allocate */ |
| 206817 | int i; /* Used to iterate through columns */ | 207992 | int i; /* Used to iterate through columns */ |
| 206818 | 207993 | ||
| @@ -206838,13 +208013,13 @@ static void sessionPreupdateOneChange( | |||
| 206838 | } | 208013 | } |
| 206839 | 208014 | ||
| 206840 | /* Allocate the change object */ | 208015 | /* Allocate the change object */ |
| 206841 | pChange = (SessionChange *)sessionMalloc64(pSession, nByte); | 208016 | pC = (SessionChange *)sessionMalloc64(pSession, nByte); |
| 206842 | if( !pChange ){ | 208017 | if( !pC ){ |
| 206843 | rc = SQLITE_NOMEM; | 208018 | rc = SQLITE_NOMEM; |
| 206844 | goto error_out; | 208019 | goto error_out; |
| 206845 | }else{ | 208020 | }else{ |
| 206846 | memset(pChange, 0, sizeof(SessionChange)); | 208021 | memset(pC, 0, sizeof(SessionChange)); |
| 206847 | pChange->aRecord = (u8 *)&pChange[1]; | 208022 | pC->aRecord = (u8 *)&pC[1]; |
| 206848 | } | 208023 | } |
| 206849 | 208024 | ||
| 206850 | /* Populate the change object. None of the preupdate_old(), | 208025 | /* Populate the change object. None of the preupdate_old(), |
| @@ -206859,17 +208034,17 @@ static void sessionPreupdateOneChange( | |||
| 206859 | }else if( pTab->abPK[i] ){ | 208034 | }else if( pTab->abPK[i] ){ |
| 206860 | pSession->hook.xNew(pSession->hook.pCtx, i, &p); | 208035 | pSession->hook.xNew(pSession->hook.pCtx, i, &p); |
| 206861 | } | 208036 | } |
| 206862 | sessionSerializeValue(&pChange->aRecord[nByte], p, &nByte); | 208037 | sessionSerializeValue(&pC->aRecord[nByte], p, &nByte); |
| 206863 | } | 208038 | } |
| 206864 | 208039 | ||
| 206865 | /* Add the change to the hash-table */ | 208040 | /* Add the change to the hash-table */ |
| 206866 | if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){ | 208041 | if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){ |
| 206867 | pChange->bIndirect = 1; | 208042 | pC->bIndirect = 1; |
| 206868 | } | 208043 | } |
| 206869 | pChange->nRecord = nByte; | 208044 | pC->nRecord = nByte; |
| 206870 | pChange->op = op; | 208045 | pC->op = op; |
| 206871 | pChange->pNext = pTab->apChange[iHash]; | 208046 | pC->pNext = pTab->apChange[iHash]; |
| 206872 | pTab->apChange[iHash] = pChange; | 208047 | pTab->apChange[iHash] = pC; |
| 206873 | 208048 | ||
| 206874 | }else if( pC->bIndirect ){ | 208049 | }else if( pC->bIndirect ){ |
| 206875 | /* If the existing change is considered "indirect", but this current | 208050 | /* If the existing change is considered "indirect", but this current |
| @@ -206880,8 +208055,14 @@ static void sessionPreupdateOneChange( | |||
| 206880 | pC->bIndirect = 0; | 208055 | pC->bIndirect = 0; |
| 206881 | } | 208056 | } |
| 206882 | } | 208057 | } |
| 208058 | |||
| 208059 | assert( rc==SQLITE_OK ); | ||
| 208060 | if( pSession->bEnableSize ){ | ||
| 208061 | rc = sessionUpdateMaxSize(op, pSession, pTab, pC); | ||
| 208062 | } | ||
| 206883 | } | 208063 | } |
| 206884 | 208064 | ||
| 208065 | |||
| 206885 | /* If an error has occurred, mark the session object as failed. */ | 208066 | /* If an error has occurred, mark the session object as failed. */ |
| 206886 | error_out: | 208067 | error_out: |
| 206887 | if( pTab->bStat1 ){ | 208068 | if( pTab->bStat1 ){ |
| @@ -207436,13 +208617,29 @@ SQLITE_API int sqlite3session_attach( | |||
| 207436 | ** If successful, return zero. Otherwise, if an OOM condition is encountered, | 208617 | ** If successful, return zero. Otherwise, if an OOM condition is encountered, |
| 207437 | ** set *pRc to SQLITE_NOMEM and return non-zero. | 208618 | ** set *pRc to SQLITE_NOMEM and return non-zero. |
| 207438 | */ | 208619 | */ |
| 207439 | static int sessionBufferGrow(SessionBuffer *p, size_t nByte, int *pRc){ | 208620 | static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){ |
| 207440 | if( *pRc==SQLITE_OK && (size_t)(p->nAlloc-p->nBuf)<nByte ){ | 208621 | #define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1) |
| 208622 | i64 nReq = p->nBuf + nByte; | ||
| 208623 | if( *pRc==SQLITE_OK && nReq>p->nAlloc ){ | ||
| 207441 | u8 *aNew; | 208624 | u8 *aNew; |
| 207442 | i64 nNew = p->nAlloc ? p->nAlloc : 128; | 208625 | i64 nNew = p->nAlloc ? p->nAlloc : 128; |
| 208626 | |||
| 207443 | do { | 208627 | do { |
| 207444 | nNew = nNew*2; | 208628 | nNew = nNew*2; |
| 207445 | }while( (size_t)(nNew-p->nBuf)<nByte ); | 208629 | }while( nNew<nReq ); |
| 208630 | |||
| 208631 | /* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation | ||
| 208632 | ** of sqlite3_realloc64(). Allocations greater than this size in bytes | ||
| 208633 | ** always fail. It is used here to ensure that this routine can always | ||
| 208634 | ** allocate up to this limit - instead of up to the largest power of | ||
| 208635 | ** two smaller than the limit. */ | ||
| 208636 | if( nNew>SESSION_MAX_BUFFER_SZ ){ | ||
| 208637 | nNew = SESSION_MAX_BUFFER_SZ; | ||
| 208638 | if( nNew<nReq ){ | ||
| 208639 | *pRc = SQLITE_NOMEM; | ||
| 208640 | return 1; | ||
| 208641 | } | ||
| 208642 | } | ||
| 207446 | 208643 | ||
| 207447 | aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew); | 208644 | aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew); |
| 207448 | if( 0==aNew ){ | 208645 | if( 0==aNew ){ |
| @@ -208093,7 +209290,11 @@ SQLITE_API int sqlite3session_changeset( | |||
| 208093 | int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */ | 209290 | int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */ |
| 208094 | void **ppChangeset /* OUT: Buffer containing changeset */ | 209291 | void **ppChangeset /* OUT: Buffer containing changeset */ |
| 208095 | ){ | 209292 | ){ |
| 208096 | return sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset, ppChangeset); | 209293 | int rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset); |
| 209294 | assert( rc || pnChangeset==0 | ||
| 209295 | || pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize | ||
| 209296 | ); | ||
| 209297 | return rc; | ||
| 208097 | } | 209298 | } |
| 208098 | 209299 | ||
| 208099 | /* | 209300 | /* |
| @@ -208186,6 +209387,39 @@ SQLITE_API sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession){ | |||
| 208186 | } | 209387 | } |
| 208187 | 209388 | ||
| 208188 | /* | 209389 | /* |
| 209390 | ** Configure the session object passed as the first argument. | ||
| 209391 | */ | ||
| 209392 | SQLITE_API int sqlite3session_object_config(sqlite3_session *pSession, int op, void *pArg){ | ||
| 209393 | int rc = SQLITE_OK; | ||
| 209394 | switch( op ){ | ||
| 209395 | case SQLITE_SESSION_OBJCONFIG_SIZE: { | ||
| 209396 | int iArg = *(int*)pArg; | ||
| 209397 | if( iArg>=0 ){ | ||
| 209398 | if( pSession->pTable ){ | ||
| 209399 | rc = SQLITE_MISUSE; | ||
| 209400 | }else{ | ||
| 209401 | pSession->bEnableSize = (iArg!=0); | ||
| 209402 | } | ||
| 209403 | } | ||
| 209404 | *(int*)pArg = pSession->bEnableSize; | ||
| 209405 | break; | ||
| 209406 | } | ||
| 209407 | |||
| 209408 | default: | ||
| 209409 | rc = SQLITE_MISUSE; | ||
| 209410 | } | ||
| 209411 | |||
| 209412 | return rc; | ||
| 209413 | } | ||
| 209414 | |||
| 209415 | /* | ||
| 209416 | ** Return the maximum size of sqlite3session_changeset() output. | ||
| 209417 | */ | ||
| 209418 | SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession){ | ||
| 209419 | return pSession->nMaxChangesetSize; | ||
| 209420 | } | ||
| 209421 | |||
| 209422 | /* | ||
| 208189 | ** Do the work for either sqlite3changeset_start() or start_strm(). | 209423 | ** Do the work for either sqlite3changeset_start() or start_strm(). |
| 208190 | */ | 209424 | */ |
| 208191 | static int sessionChangesetStart( | 209425 | static int sessionChangesetStart( |
| @@ -215005,6 +216239,7 @@ static int sqlite3Fts5PoslistNext64( | |||
| 215005 | i64 iOff = *piOff; | 216239 | i64 iOff = *piOff; |
| 215006 | int iVal; | 216240 | int iVal; |
| 215007 | fts5FastGetVarint32(a, i, iVal); | 216241 | fts5FastGetVarint32(a, i, iVal); |
| 216242 | assert( iVal>=0 ); | ||
| 215008 | if( iVal<=1 ){ | 216243 | if( iVal<=1 ){ |
| 215009 | if( iVal==0 ){ | 216244 | if( iVal==0 ){ |
| 215010 | *pi = i; | 216245 | *pi = i; |
| @@ -215018,9 +216253,12 @@ static int sqlite3Fts5PoslistNext64( | |||
| 215018 | *piOff = -1; | 216253 | *piOff = -1; |
| 215019 | return 1; | 216254 | return 1; |
| 215020 | } | 216255 | } |
| 216256 | *piOff = iOff + ((iVal-2) & 0x7FFFFFFF); | ||
| 216257 | }else{ | ||
| 216258 | *piOff = (iOff & (i64)0x7FFFFFFF<<32)+((iOff + (iVal-2)) & 0x7FFFFFFF); | ||
| 215021 | } | 216259 | } |
| 215022 | *piOff = iOff + ((iVal-2) & 0x7FFFFFFF); | ||
| 215023 | *pi = i; | 216260 | *pi = i; |
| 216261 | assert( *piOff>=iOff ); | ||
| 215024 | return 0; | 216262 | return 0; |
| 215025 | } | 216263 | } |
| 215026 | } | 216264 | } |
| @@ -215059,14 +216297,16 @@ static void sqlite3Fts5PoslistSafeAppend( | |||
| 215059 | i64 *piPrev, | 216297 | i64 *piPrev, |
| 215060 | i64 iPos | 216298 | i64 iPos |
| 215061 | ){ | 216299 | ){ |
| 215062 | static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32; | 216300 | if( iPos>=*piPrev ){ |
| 215063 | if( (iPos & colmask) != (*piPrev & colmask) ){ | 216301 | static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32; |
| 215064 | pBuf->p[pBuf->n++] = 1; | 216302 | if( (iPos & colmask) != (*piPrev & colmask) ){ |
| 215065 | pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32)); | 216303 | pBuf->p[pBuf->n++] = 1; |
| 215066 | *piPrev = (iPos & colmask); | 216304 | pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32)); |
| 216305 | *piPrev = (iPos & colmask); | ||
| 216306 | } | ||
| 216307 | pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2); | ||
| 216308 | *piPrev = iPos; | ||
| 215067 | } | 216309 | } |
| 215068 | pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2); | ||
| 215069 | *piPrev = iPos; | ||
| 215070 | } | 216310 | } |
| 215071 | 216311 | ||
| 215072 | static int sqlite3Fts5PoslistWriterAppend( | 216312 | static int sqlite3Fts5PoslistWriterAppend( |
| @@ -215768,7 +217008,7 @@ static int sqlite3Fts5ConfigParse( | |||
| 215768 | 217008 | ||
| 215769 | nByte = nArg * (sizeof(char*) + sizeof(u8)); | 217009 | nByte = nArg * (sizeof(char*) + sizeof(u8)); |
| 215770 | pRet->azCol = (char**)sqlite3Fts5MallocZero(&rc, nByte); | 217010 | pRet->azCol = (char**)sqlite3Fts5MallocZero(&rc, nByte); |
| 215771 | pRet->abUnindexed = (u8*)&pRet->azCol[nArg]; | 217011 | pRet->abUnindexed = pRet->azCol ? (u8*)&pRet->azCol[nArg] : 0; |
| 215772 | pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1); | 217012 | pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1); |
| 215773 | pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1); | 217013 | pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1); |
| 215774 | pRet->bColumnsize = 1; | 217014 | pRet->bColumnsize = 1; |
| @@ -218604,6 +219844,7 @@ static Fts5ExprNode *sqlite3Fts5ParseImplicitAnd( | |||
| 218604 | return pRet; | 219844 | return pRet; |
| 218605 | } | 219845 | } |
| 218606 | 219846 | ||
| 219847 | #ifdef SQLITE_TEST | ||
| 218607 | static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){ | 219848 | static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){ |
| 218608 | sqlite3_int64 nByte = 0; | 219849 | sqlite3_int64 nByte = 0; |
| 218609 | Fts5ExprTerm *p; | 219850 | Fts5ExprTerm *p; |
| @@ -218970,12 +220211,14 @@ static void fts5ExprFold( | |||
| 218970 | sqlite3_result_int(pCtx, sqlite3Fts5UnicodeFold(iCode, bRemoveDiacritics)); | 220211 | sqlite3_result_int(pCtx, sqlite3Fts5UnicodeFold(iCode, bRemoveDiacritics)); |
| 218971 | } | 220212 | } |
| 218972 | } | 220213 | } |
| 220214 | #endif /* ifdef SQLITE_TEST */ | ||
| 218973 | 220215 | ||
| 218974 | /* | 220216 | /* |
| 218975 | ** This is called during initialization to register the fts5_expr() scalar | 220217 | ** This is called during initialization to register the fts5_expr() scalar |
| 218976 | ** UDF with the SQLite handle passed as the only argument. | 220218 | ** UDF with the SQLite handle passed as the only argument. |
| 218977 | */ | 220219 | */ |
| 218978 | static int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){ | 220220 | static int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){ |
| 220221 | #ifdef SQLITE_TEST | ||
| 218979 | struct Fts5ExprFunc { | 220222 | struct Fts5ExprFunc { |
| 218980 | const char *z; | 220223 | const char *z; |
| 218981 | void (*x)(sqlite3_context*,int,sqlite3_value**); | 220224 | void (*x)(sqlite3_context*,int,sqlite3_value**); |
| @@ -218993,6 +220236,10 @@ static int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){ | |||
| 218993 | struct Fts5ExprFunc *p = &aFunc[i]; | 220236 | struct Fts5ExprFunc *p = &aFunc[i]; |
| 218994 | rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0); | 220237 | rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0); |
| 218995 | } | 220238 | } |
| 220239 | #else | ||
| 220240 | int rc = SQLITE_OK; | ||
| 220241 | UNUSED_PARAM2(pGlobal,db); | ||
| 220242 | #endif | ||
| 218996 | 220243 | ||
| 218997 | /* Avoid warnings indicating that sqlite3Fts5ParserTrace() and | 220244 | /* Avoid warnings indicating that sqlite3Fts5ParserTrace() and |
| 218998 | ** sqlite3Fts5ParserFallback() are unused */ | 220245 | ** sqlite3Fts5ParserFallback() are unused */ |
| @@ -220239,7 +221486,7 @@ struct Fts5SegIter { | |||
| 220239 | int iLeafPgno; /* Current leaf page number */ | 221486 | int iLeafPgno; /* Current leaf page number */ |
| 220240 | Fts5Data *pLeaf; /* Current leaf data */ | 221487 | Fts5Data *pLeaf; /* Current leaf data */ |
| 220241 | Fts5Data *pNextLeaf; /* Leaf page (iLeafPgno+1) */ | 221488 | Fts5Data *pNextLeaf; /* Leaf page (iLeafPgno+1) */ |
| 220242 | int iLeafOffset; /* Byte offset within current leaf */ | 221489 | i64 iLeafOffset; /* Byte offset within current leaf */ |
| 220243 | 221490 | ||
| 220244 | /* Next method */ | 221491 | /* Next method */ |
| 220245 | void (*xNext)(Fts5Index*, Fts5SegIter*, int*); | 221492 | void (*xNext)(Fts5Index*, Fts5SegIter*, int*); |
| @@ -221419,7 +222666,7 @@ static void fts5SegIterLoadNPos(Fts5Index *p, Fts5SegIter *pIter){ | |||
| 221419 | 222666 | ||
| 221420 | static void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){ | 222667 | static void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){ |
| 221421 | u8 *a = pIter->pLeaf->p; /* Buffer to read data from */ | 222668 | u8 *a = pIter->pLeaf->p; /* Buffer to read data from */ |
| 221422 | int iOff = pIter->iLeafOffset; | 222669 | i64 iOff = pIter->iLeafOffset; |
| 221423 | 222670 | ||
| 221424 | ASSERT_SZLEAF_OK(pIter->pLeaf); | 222671 | ASSERT_SZLEAF_OK(pIter->pLeaf); |
| 221425 | if( iOff>=pIter->pLeaf->szLeaf ){ | 222672 | if( iOff>=pIter->pLeaf->szLeaf ){ |
| @@ -221452,7 +222699,7 @@ static void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){ | |||
| 221452 | */ | 222699 | */ |
| 221453 | static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){ | 222700 | static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){ |
| 221454 | u8 *a = pIter->pLeaf->p; /* Buffer to read data from */ | 222701 | u8 *a = pIter->pLeaf->p; /* Buffer to read data from */ |
| 221455 | int iOff = pIter->iLeafOffset; /* Offset to read at */ | 222702 | i64 iOff = pIter->iLeafOffset; /* Offset to read at */ |
| 221456 | int nNew; /* Bytes of new data */ | 222703 | int nNew; /* Bytes of new data */ |
| 221457 | 222704 | ||
| 221458 | iOff += fts5GetVarint32(&a[iOff], nNew); | 222705 | iOff += fts5GetVarint32(&a[iOff], nNew); |
| @@ -221880,7 +223127,6 @@ static void fts5SegIterNext( | |||
| 221880 | ** this block is particularly performance critical, so equivalent | 223127 | ** this block is particularly performance critical, so equivalent |
| 221881 | ** code is inlined. */ | 223128 | ** code is inlined. */ |
| 221882 | int nSz; | 223129 | int nSz; |
| 221883 | assert( p->rc==SQLITE_OK ); | ||
| 221884 | assert_nc( pIter->iLeafOffset<=pIter->pLeaf->nn ); | 223130 | assert_nc( pIter->iLeafOffset<=pIter->pLeaf->nn ); |
| 221885 | fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz); | 223131 | fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz); |
| 221886 | pIter->bDel = (nSz & 0x0001); | 223132 | pIter->bDel = (nSz & 0x0001); |
| @@ -222992,7 +224238,7 @@ static void fts5IndexExtractColset( | |||
| 222992 | } | 224238 | } |
| 222993 | fts5BufferSafeAppendBlob(&pIter->poslist, aCopy, p-aCopy); | 224239 | fts5BufferSafeAppendBlob(&pIter->poslist, aCopy, p-aCopy); |
| 222994 | } | 224240 | } |
| 222995 | if( p==pEnd ){ | 224241 | if( p>=pEnd ){ |
| 222996 | pIter->base.pData = pIter->poslist.p; | 224242 | pIter->base.pData = pIter->poslist.p; |
| 222997 | pIter->base.nData = pIter->poslist.n; | 224243 | pIter->base.nData = pIter->poslist.n; |
| 222998 | return; | 224244 | return; |
| @@ -224349,14 +225595,14 @@ static void fts5FlushOneHash(Fts5Index *p){ | |||
| 224349 | fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist); | 225595 | fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist); |
| 224350 | }else{ | 225596 | }else{ |
| 224351 | i64 iRowid = 0; | 225597 | i64 iRowid = 0; |
| 224352 | i64 iDelta = 0; | 225598 | u64 iDelta = 0; |
| 224353 | int iOff = 0; | 225599 | int iOff = 0; |
| 224354 | 225600 | ||
| 224355 | /* The entire doclist will not fit on this leaf. The following | 225601 | /* The entire doclist will not fit on this leaf. The following |
| 224356 | ** loop iterates through the poslists that make up the current | 225602 | ** loop iterates through the poslists that make up the current |
| 224357 | ** doclist. */ | 225603 | ** doclist. */ |
| 224358 | while( p->rc==SQLITE_OK && iOff<nDoclist ){ | 225604 | while( p->rc==SQLITE_OK && iOff<nDoclist ){ |
| 224359 | iOff += fts5GetVarint(&pDoclist[iOff], (u64*)&iDelta); | 225605 | iOff += fts5GetVarint(&pDoclist[iOff], &iDelta); |
| 224360 | iRowid += iDelta; | 225606 | iRowid += iDelta; |
| 224361 | 225607 | ||
| 224362 | if( writer.bFirstRowidInPage ){ | 225608 | if( writer.bFirstRowidInPage ){ |
| @@ -224788,7 +226034,7 @@ static void fts5MergePrefixLists( | |||
| 224788 | Fts5Buffer *aBuf /* Other lists to merge in */ | 226034 | Fts5Buffer *aBuf /* Other lists to merge in */ |
| 224789 | ){ | 226035 | ){ |
| 224790 | #define fts5PrefixMergerNextPosition(p) \ | 226036 | #define fts5PrefixMergerNextPosition(p) \ |
| 224791 | sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos); | 226037 | sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos) |
| 224792 | #define FTS5_MERGE_NLIST 16 | 226038 | #define FTS5_MERGE_NLIST 16 |
| 224793 | PrefixMerger aMerger[FTS5_MERGE_NLIST]; | 226039 | PrefixMerger aMerger[FTS5_MERGE_NLIST]; |
| 224794 | PrefixMerger *pHead = 0; | 226040 | PrefixMerger *pHead = 0; |
| @@ -224887,7 +226133,8 @@ static void fts5MergePrefixLists( | |||
| 224887 | nTail = pHead->iter.nPoslist - pHead->iOff; | 226133 | nTail = pHead->iter.nPoslist - pHead->iOff; |
| 224888 | 226134 | ||
| 224889 | /* WRITEPOSLISTSIZE */ | 226135 | /* WRITEPOSLISTSIZE */ |
| 224890 | assert( tmp.n+nTail<=nTmp ); | 226136 | assert_nc( tmp.n+nTail<=nTmp ); |
| 226137 | assert( tmp.n+nTail<=nTmp+nMerge*10 ); | ||
| 224891 | if( tmp.n+nTail>nTmp-FTS5_DATA_ZERO_PADDING ){ | 226138 | if( tmp.n+nTail>nTmp-FTS5_DATA_ZERO_PADDING ){ |
| 224892 | if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT; | 226139 | if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT; |
| 224893 | break; | 226140 | break; |
| @@ -226034,6 +227281,7 @@ static int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum, int bUseCksum | |||
| 226034 | ** function only. | 227281 | ** function only. |
| 226035 | */ | 227282 | */ |
| 226036 | 227283 | ||
| 227284 | #ifdef SQLITE_TEST | ||
| 226037 | /* | 227285 | /* |
| 226038 | ** Decode a segment-data rowid from the %_data table. This function is | 227286 | ** Decode a segment-data rowid from the %_data table. This function is |
| 226039 | ** the opposite of macro FTS5_SEGMENT_ROWID(). | 227287 | ** the opposite of macro FTS5_SEGMENT_ROWID(). |
| @@ -226056,7 +227304,9 @@ static void fts5DecodeRowid( | |||
| 226056 | 227304 | ||
| 226057 | *piSegid = (int)(iRowid & (((i64)1 << FTS5_DATA_ID_B) - 1)); | 227305 | *piSegid = (int)(iRowid & (((i64)1 << FTS5_DATA_ID_B) - 1)); |
| 226058 | } | 227306 | } |
| 227307 | #endif /* SQLITE_TEST */ | ||
| 226059 | 227308 | ||
| 227309 | #ifdef SQLITE_TEST | ||
| 226060 | static void fts5DebugRowid(int *pRc, Fts5Buffer *pBuf, i64 iKey){ | 227310 | static void fts5DebugRowid(int *pRc, Fts5Buffer *pBuf, i64 iKey){ |
| 226061 | int iSegid, iHeight, iPgno, bDlidx; /* Rowid compenents */ | 227311 | int iSegid, iHeight, iPgno, bDlidx; /* Rowid compenents */ |
| 226062 | fts5DecodeRowid(iKey, &iSegid, &bDlidx, &iHeight, &iPgno); | 227312 | fts5DecodeRowid(iKey, &iSegid, &bDlidx, &iHeight, &iPgno); |
| @@ -226074,7 +227324,9 @@ static void fts5DebugRowid(int *pRc, Fts5Buffer *pBuf, i64 iKey){ | |||
| 226074 | ); | 227324 | ); |
| 226075 | } | 227325 | } |
| 226076 | } | 227326 | } |
| 227327 | #endif /* SQLITE_TEST */ | ||
| 226077 | 227328 | ||
| 227329 | #ifdef SQLITE_TEST | ||
| 226078 | static void fts5DebugStructure( | 227330 | static void fts5DebugStructure( |
| 226079 | int *pRc, /* IN/OUT: error code */ | 227331 | int *pRc, /* IN/OUT: error code */ |
| 226080 | Fts5Buffer *pBuf, | 227332 | Fts5Buffer *pBuf, |
| @@ -226096,7 +227348,9 @@ static void fts5DebugStructure( | |||
| 226096 | sqlite3Fts5BufferAppendPrintf(pRc, pBuf, "}"); | 227348 | sqlite3Fts5BufferAppendPrintf(pRc, pBuf, "}"); |
| 226097 | } | 227349 | } |
| 226098 | } | 227350 | } |
| 227351 | #endif /* SQLITE_TEST */ | ||
| 226099 | 227352 | ||
| 227353 | #ifdef SQLITE_TEST | ||
| 226100 | /* | 227354 | /* |
| 226101 | ** This is part of the fts5_decode() debugging aid. | 227355 | ** This is part of the fts5_decode() debugging aid. |
| 226102 | ** | 227356 | ** |
| @@ -226121,7 +227375,9 @@ static void fts5DecodeStructure( | |||
| 226121 | fts5DebugStructure(pRc, pBuf, p); | 227375 | fts5DebugStructure(pRc, pBuf, p); |
| 226122 | fts5StructureRelease(p); | 227376 | fts5StructureRelease(p); |
| 226123 | } | 227377 | } |
| 227378 | #endif /* SQLITE_TEST */ | ||
| 226124 | 227379 | ||
| 227380 | #ifdef SQLITE_TEST | ||
| 226125 | /* | 227381 | /* |
| 226126 | ** This is part of the fts5_decode() debugging aid. | 227382 | ** This is part of the fts5_decode() debugging aid. |
| 226127 | ** | 227383 | ** |
| @@ -226144,7 +227400,9 @@ static void fts5DecodeAverages( | |||
| 226144 | zSpace = " "; | 227400 | zSpace = " "; |
| 226145 | } | 227401 | } |
| 226146 | } | 227402 | } |
| 227403 | #endif /* SQLITE_TEST */ | ||
| 226147 | 227404 | ||
| 227405 | #ifdef SQLITE_TEST | ||
| 226148 | /* | 227406 | /* |
| 226149 | ** Buffer (a/n) is assumed to contain a list of serialized varints. Read | 227407 | ** Buffer (a/n) is assumed to contain a list of serialized varints. Read |
| 226150 | ** each varint and append its string representation to buffer pBuf. Return | 227408 | ** each varint and append its string representation to buffer pBuf. Return |
| @@ -226161,7 +227419,9 @@ static int fts5DecodePoslist(int *pRc, Fts5Buffer *pBuf, const u8 *a, int n){ | |||
| 226161 | } | 227419 | } |
| 226162 | return iOff; | 227420 | return iOff; |
| 226163 | } | 227421 | } |
| 227422 | #endif /* SQLITE_TEST */ | ||
| 226164 | 227423 | ||
| 227424 | #ifdef SQLITE_TEST | ||
| 226165 | /* | 227425 | /* |
| 226166 | ** The start of buffer (a/n) contains the start of a doclist. The doclist | 227426 | ** The start of buffer (a/n) contains the start of a doclist. The doclist |
| 226167 | ** may or may not finish within the buffer. This function appends a text | 227427 | ** may or may not finish within the buffer. This function appends a text |
| @@ -226194,7 +227454,9 @@ static int fts5DecodeDoclist(int *pRc, Fts5Buffer *pBuf, const u8 *a, int n){ | |||
| 226194 | 227454 | ||
| 226195 | return iOff; | 227455 | return iOff; |
| 226196 | } | 227456 | } |
| 227457 | #endif /* SQLITE_TEST */ | ||
| 226197 | 227458 | ||
| 227459 | #ifdef SQLITE_TEST | ||
| 226198 | /* | 227460 | /* |
| 226199 | ** This function is part of the fts5_decode() debugging function. It is | 227461 | ** This function is part of the fts5_decode() debugging function. It is |
| 226200 | ** only ever used with detail=none tables. | 227462 | ** only ever used with detail=none tables. |
| @@ -226235,7 +227497,9 @@ static void fts5DecodeRowidList( | |||
| 226235 | sqlite3Fts5BufferAppendPrintf(pRc, pBuf, " %lld%s", iRowid, zApp); | 227497 | sqlite3Fts5BufferAppendPrintf(pRc, pBuf, " %lld%s", iRowid, zApp); |
| 226236 | } | 227498 | } |
| 226237 | } | 227499 | } |
| 227500 | #endif /* SQLITE_TEST */ | ||
| 226238 | 227501 | ||
| 227502 | #ifdef SQLITE_TEST | ||
| 226239 | /* | 227503 | /* |
| 226240 | ** The implementation of user-defined scalar function fts5_decode(). | 227504 | ** The implementation of user-defined scalar function fts5_decode(). |
| 226241 | */ | 227505 | */ |
| @@ -226444,7 +227708,9 @@ static void fts5DecodeFunction( | |||
| 226444 | } | 227708 | } |
| 226445 | fts5BufferFree(&s); | 227709 | fts5BufferFree(&s); |
| 226446 | } | 227710 | } |
| 227711 | #endif /* SQLITE_TEST */ | ||
| 226447 | 227712 | ||
| 227713 | #ifdef SQLITE_TEST | ||
| 226448 | /* | 227714 | /* |
| 226449 | ** The implementation of user-defined scalar function fts5_rowid(). | 227715 | ** The implementation of user-defined scalar function fts5_rowid(). |
| 226450 | */ | 227716 | */ |
| @@ -226478,6 +227744,7 @@ static void fts5RowidFunction( | |||
| 226478 | } | 227744 | } |
| 226479 | } | 227745 | } |
| 226480 | } | 227746 | } |
| 227747 | #endif /* SQLITE_TEST */ | ||
| 226481 | 227748 | ||
| 226482 | /* | 227749 | /* |
| 226483 | ** This is called as part of registering the FTS5 module with database | 227750 | ** This is called as part of registering the FTS5 module with database |
| @@ -226488,6 +227755,7 @@ static void fts5RowidFunction( | |||
| 226488 | ** SQLite error code is returned instead. | 227755 | ** SQLite error code is returned instead. |
| 226489 | */ | 227756 | */ |
| 226490 | static int sqlite3Fts5IndexInit(sqlite3 *db){ | 227757 | static int sqlite3Fts5IndexInit(sqlite3 *db){ |
| 227758 | #ifdef SQLITE_TEST | ||
| 226491 | int rc = sqlite3_create_function( | 227759 | int rc = sqlite3_create_function( |
| 226492 | db, "fts5_decode", 2, SQLITE_UTF8, 0, fts5DecodeFunction, 0, 0 | 227760 | db, "fts5_decode", 2, SQLITE_UTF8, 0, fts5DecodeFunction, 0, 0 |
| 226493 | ); | 227761 | ); |
| @@ -226505,6 +227773,10 @@ static int sqlite3Fts5IndexInit(sqlite3 *db){ | |||
| 226505 | ); | 227773 | ); |
| 226506 | } | 227774 | } |
| 226507 | return rc; | 227775 | return rc; |
| 227776 | #else | ||
| 227777 | return SQLITE_OK; | ||
| 227778 | UNUSED_PARAM(db); | ||
| 227779 | #endif | ||
| 226508 | } | 227780 | } |
| 226509 | 227781 | ||
| 226510 | 227782 | ||
| @@ -226540,7 +227812,9 @@ static int sqlite3Fts5IndexReset(Fts5Index *p){ | |||
| 226540 | ** assert() conditions in the fts5 code are activated - conditions that are | 227812 | ** assert() conditions in the fts5 code are activated - conditions that are |
| 226541 | ** only true if it is guaranteed that the fts5 database is not corrupt. | 227813 | ** only true if it is guaranteed that the fts5 database is not corrupt. |
| 226542 | */ | 227814 | */ |
| 227815 | #ifdef SQLITE_DEBUG | ||
| 226543 | SQLITE_API int sqlite3_fts5_may_be_corrupt = 1; | 227816 | SQLITE_API int sqlite3_fts5_may_be_corrupt = 1; |
| 227817 | #endif | ||
| 226544 | 227818 | ||
| 226545 | 227819 | ||
| 226546 | typedef struct Fts5Auxdata Fts5Auxdata; | 227820 | typedef struct Fts5Auxdata Fts5Auxdata; |
| @@ -228465,13 +229739,15 @@ static int fts5CacheInstArray(Fts5Cursor *pCsr){ | |||
| 228465 | 229739 | ||
| 228466 | nInst++; | 229740 | nInst++; |
| 228467 | if( nInst>=pCsr->nInstAlloc ){ | 229741 | if( nInst>=pCsr->nInstAlloc ){ |
| 228468 | pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32; | 229742 | int nNewSize = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32; |
| 228469 | aInst = (int*)sqlite3_realloc64( | 229743 | aInst = (int*)sqlite3_realloc64( |
| 228470 | pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3 | 229744 | pCsr->aInst, nNewSize*sizeof(int)*3 |
| 228471 | ); | 229745 | ); |
| 228472 | if( aInst ){ | 229746 | if( aInst ){ |
| 228473 | pCsr->aInst = aInst; | 229747 | pCsr->aInst = aInst; |
| 229748 | pCsr->nInstAlloc = nNewSize; | ||
| 228474 | }else{ | 229749 | }else{ |
| 229750 | nInst--; | ||
| 228475 | rc = SQLITE_NOMEM; | 229751 | rc = SQLITE_NOMEM; |
| 228476 | break; | 229752 | break; |
| 228477 | } | 229753 | } |
| @@ -229306,7 +230582,7 @@ static void fts5SourceIdFunc( | |||
| 229306 | ){ | 230582 | ){ |
| 229307 | assert( nArg==0 ); | 230583 | assert( nArg==0 ); |
| 229308 | UNUSED_PARAM2(nArg, apUnused); | 230584 | UNUSED_PARAM2(nArg, apUnused); |
| 229309 | sqlite3_result_text(pCtx, "fts5: 2021-04-19 18:32:05 1b256d97b553a9611efca188a3d995a2fff712759044ba480f9a0c9e98fae886", -1, SQLITE_TRANSIENT); | 230585 | sqlite3_result_text(pCtx, "fts5: 2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5", -1, SQLITE_TRANSIENT); |
| 229310 | } | 230586 | } |
| 229311 | 230587 | ||
| 229312 | /* | 230588 | /* |
| @@ -234232,9 +235508,9 @@ SQLITE_API int sqlite3_stmt_init( | |||
| 234232 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ | 235508 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 234233 | 235509 | ||
| 234234 | /************** End of stmt.c ************************************************/ | 235510 | /************** End of stmt.c ************************************************/ |
| 234235 | #if __LINE__!=234235 | 235511 | #if __LINE__!=235511 |
| 234236 | #undef SQLITE_SOURCE_ID | 235512 | #undef SQLITE_SOURCE_ID |
| 234237 | #define SQLITE_SOURCE_ID "2021-04-19 18:32:05 1b256d97b553a9611efca188a3d995a2fff712759044ba480f9a0c9e98faalt2" | 235513 | #define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafaalt2" |
| 234238 | #endif | 235514 | #endif |
| 234239 | /* Return the source-id for this library */ | 235515 | /* Return the source-id for this library */ |
| 234240 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } | 235516 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
diff --git a/c/sqlite3.h b/c/sqlite3.h index 19ee767..3274bbe 100644 --- a/c/sqlite3.h +++ b/c/sqlite3.h | |||
| @@ -123,9 +123,9 @@ extern "C" { | |||
| 123 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | 123 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 124 | ** [sqlite_version()] and [sqlite_source_id()]. | 124 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 125 | */ | 125 | */ |
| 126 | #define SQLITE_VERSION "3.35.5" | 126 | #define SQLITE_VERSION "3.36.0" |
| 127 | #define SQLITE_VERSION_NUMBER 3035005 | 127 | #define SQLITE_VERSION_NUMBER 3036000 |
| 128 | #define SQLITE_SOURCE_ID "2021-04-19 18:32:05 1b256d97b553a9611efca188a3d995a2fff712759044ba480f9a0c9e98fae886" | 128 | #define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5" |
| 129 | 129 | ||
| 130 | /* | 130 | /* |
| 131 | ** CAPI3REF: Run-Time Library Version Numbers | 131 | ** CAPI3REF: Run-Time Library Version Numbers |
| @@ -1128,6 +1128,23 @@ struct sqlite3_io_methods { | |||
| 1128 | ** file to the database file, but before the *-shm file is updated to | 1128 | ** file to the database file, but before the *-shm file is updated to |
| 1129 | ** record the fact that the pages have been checkpointed. | 1129 | ** record the fact that the pages have been checkpointed. |
| 1130 | ** </ul> | 1130 | ** </ul> |
| 1131 | ** | ||
| 1132 | ** <li>[[SQLITE_FCNTL_EXTERNAL_READER]] | ||
| 1133 | ** The EXPERIMENTAL [SQLITE_FCNTL_EXTERNAL_READER] opcode is used to detect | ||
| 1134 | ** whether or not there is a database client in another process with a wal-mode | ||
| 1135 | ** transaction open on the database or not. It is only available on unix.The | ||
| 1136 | ** (void*) argument passed with this file-control should be a pointer to a | ||
| 1137 | ** value of type (int). The integer value is set to 1 if the database is a wal | ||
| 1138 | ** mode database and there exists at least one client in another process that | ||
| 1139 | ** currently has an SQL transaction open on the database. It is set to 0 if | ||
| 1140 | ** the database is not a wal-mode db, or if there is no such connection in any | ||
| 1141 | ** other process. This opcode cannot be used to detect transactions opened | ||
| 1142 | ** by clients within the current process, only within other processes. | ||
| 1143 | ** </ul> | ||
| 1144 | ** | ||
| 1145 | ** <li>[[SQLITE_FCNTL_CKSM_FILE]] | ||
| 1146 | ** Used by the cksmvfs VFS module only. | ||
| 1147 | ** </ul> | ||
| 1131 | */ | 1148 | */ |
| 1132 | #define SQLITE_FCNTL_LOCKSTATE 1 | 1149 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1133 | #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 | 1150 | #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 |
| @@ -1167,6 +1184,8 @@ struct sqlite3_io_methods { | |||
| 1167 | #define SQLITE_FCNTL_CKPT_DONE 37 | 1184 | #define SQLITE_FCNTL_CKPT_DONE 37 |
| 1168 | #define SQLITE_FCNTL_RESERVE_BYTES 38 | 1185 | #define SQLITE_FCNTL_RESERVE_BYTES 38 |
| 1169 | #define SQLITE_FCNTL_CKPT_START 39 | 1186 | #define SQLITE_FCNTL_CKPT_START 39 |
| 1187 | #define SQLITE_FCNTL_EXTERNAL_READER 40 | ||
| 1188 | #define SQLITE_FCNTL_CKSM_FILE 41 | ||
| 1170 | 1189 | ||
| 1171 | /* deprecated names */ | 1190 | /* deprecated names */ |
| 1172 | #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE | 1191 | #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE |
| @@ -4179,6 +4198,15 @@ SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt); | |||
| 4179 | ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and | 4198 | ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and |
| 4180 | ** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so | 4199 | ** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so |
| 4181 | ** sqlite3_stmt_readonly() returns false for those commands. | 4200 | ** sqlite3_stmt_readonly() returns false for those commands. |
| 4201 | ** | ||
| 4202 | ** ^This routine returns false if there is any possibility that the | ||
| 4203 | ** statement might change the database file. ^A false return does | ||
| 4204 | ** not guarantee that the statement will change the database file. | ||
| 4205 | ** ^For example, an UPDATE statement might have a WHERE clause that | ||
| 4206 | ** makes it a no-op, but the sqlite3_stmt_readonly() result would still | ||
| 4207 | ** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a | ||
| 4208 | ** read-only no-op if the table already exists, but | ||
| 4209 | ** sqlite3_stmt_readonly() still returns false for such a statement. | ||
| 4182 | */ | 4210 | */ |
| 4183 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); | 4211 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 4184 | 4212 | ||
| @@ -4348,18 +4376,22 @@ typedef struct sqlite3_context sqlite3_context; | |||
| 4348 | ** contain embedded NULs. The result of expressions involving strings | 4376 | ** contain embedded NULs. The result of expressions involving strings |
| 4349 | ** with embedded NULs is undefined. | 4377 | ** with embedded NULs is undefined. |
| 4350 | ** | 4378 | ** |
| 4351 | ** ^The fifth argument to the BLOB and string binding interfaces | 4379 | ** ^The fifth argument to the BLOB and string binding interfaces controls |
| 4352 | ** is a destructor used to dispose of the BLOB or | 4380 | ** or indicates the lifetime of the object referenced by the third parameter. |
| 4353 | ** string after SQLite has finished with it. ^The destructor is called | 4381 | ** These three options exist: |
| 4354 | ** to dispose of the BLOB or string even if the call to the bind API fails, | 4382 | ** ^ (1) A destructor to dispose of the BLOB or string after SQLite has finished |
| 4355 | ** except the destructor is not called if the third parameter is a NULL | 4383 | ** with it may be passed. ^It is called to dispose of the BLOB or string even |
| 4356 | ** pointer or the fourth parameter is negative. | 4384 | ** if the call to the bind API fails, except the destructor is not called if |
| 4357 | ** ^If the fifth argument is | 4385 | ** the third parameter is a NULL pointer or the fourth parameter is negative. |
| 4358 | ** the special value [SQLITE_STATIC], then SQLite assumes that the | 4386 | ** ^ (2) The special constant, [SQLITE_STATIC], may be passsed to indicate that |
| 4359 | ** information is in static, unmanaged space and does not need to be freed. | 4387 | ** the application remains responsible for disposing of the object. ^In this |
| 4360 | ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then | 4388 | ** case, the object and the provided pointer to it must remain valid until |
| 4361 | ** SQLite makes its own private copy of the data immediately, before | 4389 | ** either the prepared statement is finalized or the same SQL parameter is |
| 4362 | ** the sqlite3_bind_*() routine returns. | 4390 | ** bound to something else, whichever occurs sooner. |
| 4391 | ** ^ (3) The constant, [SQLITE_TRANSIENT], may be passed to indicate that the | ||
| 4392 | ** object is to be copied prior to the return from sqlite3_bind_*(). ^The | ||
| 4393 | ** object and pointer to it must remain valid until then. ^SQLite will then | ||
| 4394 | ** manage the lifetime of its private copy. | ||
| 4363 | ** | 4395 | ** |
| 4364 | ** ^The sixth argument to sqlite3_bind_text64() must be one of | 4396 | ** ^The sixth argument to sqlite3_bind_text64() must be one of |
| 4365 | ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE] | 4397 | ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE] |
| @@ -5101,7 +5133,6 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); | |||
| 5101 | ** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, | 5133 | ** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, |
| 5102 | ** index expressions, or the WHERE clause of partial indexes. | 5134 | ** index expressions, or the WHERE clause of partial indexes. |
| 5103 | ** | 5135 | ** |
| 5104 | ** <span style="background-color:#ffff90;"> | ||
| 5105 | ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for | 5136 | ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for |
| 5106 | ** all application-defined SQL functions that do not need to be | 5137 | ** all application-defined SQL functions that do not need to be |
| 5107 | ** used inside of triggers, view, CHECK constraints, or other elements of | 5138 | ** used inside of triggers, view, CHECK constraints, or other elements of |
| @@ -5111,7 +5142,6 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); | |||
| 5111 | ** a database file to include invocations of the function with parameters | 5142 | ** a database file to include invocations of the function with parameters |
| 5112 | ** chosen by the attacker, which the application will then execute when | 5143 | ** chosen by the attacker, which the application will then execute when |
| 5113 | ** the database file is opened and read. | 5144 | ** the database file is opened and read. |
| 5114 | ** </span> | ||
| 5115 | ** | 5145 | ** |
| 5116 | ** ^(The fifth parameter is an arbitrary pointer. The implementation of the | 5146 | ** ^(The fifth parameter is an arbitrary pointer. The implementation of the |
| 5117 | ** function can gain access to this pointer using [sqlite3_user_data()].)^ | 5147 | ** function can gain access to this pointer using [sqlite3_user_data()].)^ |
| @@ -7779,7 +7809,8 @@ SQLITE_API int sqlite3_test_control(int op, ...); | |||
| 7779 | #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 | 7809 | #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 |
| 7780 | #define SQLITE_TESTCTRL_SEEK_COUNT 30 | 7810 | #define SQLITE_TESTCTRL_SEEK_COUNT 30 |
| 7781 | #define SQLITE_TESTCTRL_TRACEFLAGS 31 | 7811 | #define SQLITE_TESTCTRL_TRACEFLAGS 31 |
| 7782 | #define SQLITE_TESTCTRL_LAST 31 /* Largest TESTCTRL */ | 7812 | #define SQLITE_TESTCTRL_TUNE 32 |
| 7813 | #define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */ | ||
| 7783 | 7814 | ||
| 7784 | /* | 7815 | /* |
| 7785 | ** CAPI3REF: SQL Keyword Checking | 7816 | ** CAPI3REF: SQL Keyword Checking |
| @@ -9531,6 +9562,15 @@ SQLITE_API int sqlite3_db_cacheflush(sqlite3*); | |||
| 9531 | ** triggers; or 2 for changes resulting from triggers called by top-level | 9562 | ** triggers; or 2 for changes resulting from triggers called by top-level |
| 9532 | ** triggers; and so forth. | 9563 | ** triggers; and so forth. |
| 9533 | ** | 9564 | ** |
| 9565 | ** When the [sqlite3_blob_write()] API is used to update a blob column, | ||
| 9566 | ** the pre-update hook is invoked with SQLITE_DELETE. This is because the | ||
| 9567 | ** in this case the new values are not available. In this case, when a | ||
| 9568 | ** callback made with op==SQLITE_DELETE is actuall a write using the | ||
| 9569 | ** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns | ||
| 9570 | ** the index of the column being written. In other cases, where the | ||
| 9571 | ** pre-update hook is being invoked for some other reason, including a | ||
| 9572 | ** regular DELETE, sqlite3_preupdate_blobwrite() returns -1. | ||
| 9573 | ** | ||
| 9534 | ** See also: [sqlite3_update_hook()] | 9574 | ** See also: [sqlite3_update_hook()] |
| 9535 | */ | 9575 | */ |
| 9536 | #if defined(SQLITE_ENABLE_PREUPDATE_HOOK) | 9576 | #if defined(SQLITE_ENABLE_PREUPDATE_HOOK) |
| @@ -9551,6 +9591,7 @@ SQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **); | |||
| 9551 | SQLITE_API int sqlite3_preupdate_count(sqlite3 *); | 9591 | SQLITE_API int sqlite3_preupdate_count(sqlite3 *); |
| 9552 | SQLITE_API int sqlite3_preupdate_depth(sqlite3 *); | 9592 | SQLITE_API int sqlite3_preupdate_depth(sqlite3 *); |
| 9553 | SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **); | 9593 | SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **); |
| 9594 | SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *); | ||
| 9554 | #endif | 9595 | #endif |
| 9555 | 9596 | ||
| 9556 | /* | 9597 | /* |
| @@ -9789,8 +9830,8 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c | |||
| 9789 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory | 9830 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory |
| 9790 | ** allocation error occurs. | 9831 | ** allocation error occurs. |
| 9791 | ** | 9832 | ** |
| 9792 | ** This interface is only available if SQLite is compiled with the | 9833 | ** This interface is omitted if SQLite is compiled with the |
| 9793 | ** [SQLITE_ENABLE_DESERIALIZE] option. | 9834 | ** [SQLITE_OMIT_DESERIALIZE] option. |
| 9794 | */ | 9835 | */ |
| 9795 | SQLITE_API unsigned char *sqlite3_serialize( | 9836 | SQLITE_API unsigned char *sqlite3_serialize( |
| 9796 | sqlite3 *db, /* The database connection */ | 9837 | sqlite3 *db, /* The database connection */ |
| @@ -9841,8 +9882,8 @@ SQLITE_API unsigned char *sqlite3_serialize( | |||
| 9841 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then | 9882 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then |
| 9842 | ** [sqlite3_free()] is invoked on argument P prior to returning. | 9883 | ** [sqlite3_free()] is invoked on argument P prior to returning. |
| 9843 | ** | 9884 | ** |
| 9844 | ** This interface is only available if SQLite is compiled with the | 9885 | ** This interface is omitted if SQLite is compiled with the |
| 9845 | ** [SQLITE_ENABLE_DESERIALIZE] option. | 9886 | ** [SQLITE_OMIT_DESERIALIZE] option. |
| 9846 | */ | 9887 | */ |
| 9847 | SQLITE_API int sqlite3_deserialize( | 9888 | SQLITE_API int sqlite3_deserialize( |
| 9848 | sqlite3 *db, /* The database connection */ | 9889 | sqlite3 *db, /* The database connection */ |
| @@ -10091,6 +10132,38 @@ SQLITE_API int sqlite3session_create( | |||
| 10091 | */ | 10132 | */ |
| 10092 | SQLITE_API void sqlite3session_delete(sqlite3_session *pSession); | 10133 | SQLITE_API void sqlite3session_delete(sqlite3_session *pSession); |
| 10093 | 10134 | ||
| 10135 | /* | ||
| 10136 | ** CAPIREF: Conigure a Session Object | ||
| 10137 | ** METHOD: sqlite3_session | ||
| 10138 | ** | ||
| 10139 | ** This method is used to configure a session object after it has been | ||
| 10140 | ** created. At present the only valid value for the second parameter is | ||
| 10141 | ** [SQLITE_SESSION_OBJCONFIG_SIZE]. | ||
| 10142 | ** | ||
| 10143 | ** Arguments for sqlite3session_object_config() | ||
| 10144 | ** | ||
| 10145 | ** The following values may passed as the the 4th parameter to | ||
| 10146 | ** sqlite3session_object_config(). | ||
| 10147 | ** | ||
| 10148 | ** <dt>SQLITE_SESSION_OBJCONFIG_SIZE <dd> | ||
| 10149 | ** This option is used to set, clear or query the flag that enables | ||
| 10150 | ** the [sqlite3session_changeset_size()] API. Because it imposes some | ||
| 10151 | ** computational overhead, this API is disabled by default. Argument | ||
| 10152 | ** pArg must point to a value of type (int). If the value is initially | ||
| 10153 | ** 0, then the sqlite3session_changeset_size() API is disabled. If it | ||
| 10154 | ** is greater than 0, then the same API is enabled. Or, if the initial | ||
| 10155 | ** value is less than zero, no change is made. In all cases the (int) | ||
| 10156 | ** variable is set to 1 if the sqlite3session_changeset_size() API is | ||
| 10157 | ** enabled following the current call, or 0 otherwise. | ||
| 10158 | ** | ||
| 10159 | ** It is an error (SQLITE_MISUSE) to attempt to modify this setting after | ||
| 10160 | ** the first table has been attached to the session object. | ||
| 10161 | */ | ||
| 10162 | SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg); | ||
| 10163 | |||
| 10164 | /* | ||
| 10165 | */ | ||
| 10166 | #define SQLITE_SESSION_OBJCONFIG_SIZE 1 | ||
| 10094 | 10167 | ||
| 10095 | /* | 10168 | /* |
| 10096 | ** CAPI3REF: Enable Or Disable A Session Object | 10169 | ** CAPI3REF: Enable Or Disable A Session Object |
| @@ -10336,6 +10409,22 @@ SQLITE_API int sqlite3session_changeset( | |||
| 10336 | ); | 10409 | ); |
| 10337 | 10410 | ||
| 10338 | /* | 10411 | /* |
| 10412 | ** CAPI3REF: Return An Upper-limit For The Size Of The Changeset | ||
| 10413 | ** METHOD: sqlite3_session | ||
| 10414 | ** | ||
| 10415 | ** By default, this function always returns 0. For it to return | ||
| 10416 | ** a useful result, the sqlite3_session object must have been configured | ||
| 10417 | ** to enable this API using sqlite3session_object_config() with the | ||
| 10418 | ** SQLITE_SESSION_OBJCONFIG_SIZE verb. | ||
| 10419 | ** | ||
| 10420 | ** When enabled, this function returns an upper limit, in bytes, for the size | ||
| 10421 | ** of the changeset that might be produced if sqlite3session_changeset() were | ||
| 10422 | ** called. The final changeset size might be equal to or smaller than the | ||
| 10423 | ** size in bytes returned by this function. | ||
| 10424 | */ | ||
| 10425 | SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession); | ||
| 10426 | |||
| 10427 | /* | ||
| 10339 | ** CAPI3REF: Load The Difference Between Tables Into A Session | 10428 | ** CAPI3REF: Load The Difference Between Tables Into A Session |
| 10340 | ** METHOD: sqlite3_session | 10429 | ** METHOD: sqlite3_session |
| 10341 | ** | 10430 | ** |