| | @@ -81,12 +81,14 @@ |
| 81 | 81 | "4_BYTE_ALIGNED_MALLOC", |
| 82 | 82 | #endif |
| 83 | 83 | #if SQLITE_64BIT_STATS |
| 84 | 84 | "64BIT_STATS", |
| 85 | 85 | #endif |
| 86 | | -#if SQLITE_ALLOW_COVERING_INDEX_SCAN |
| 87 | | - "ALLOW_COVERING_INDEX_SCAN", |
| 86 | +#ifdef SQLITE_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 | 90 | #endif |
| 89 | 91 | #if SQLITE_ALLOW_URI_AUTHORITY |
| 90 | 92 | "ALLOW_URI_AUTHORITY", |
| 91 | 93 | #endif |
| 92 | 94 | #ifdef SQLITE_BITMASK_TYPE |
| | @@ -144,12 +146,14 @@ |
| 144 | 146 | "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE), |
| 145 | 147 | #endif |
| 146 | 148 | #ifdef SQLITE_DEFAULT_LOOKASIDE |
| 147 | 149 | "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE), |
| 148 | 150 | #endif |
| 149 | | -#if SQLITE_DEFAULT_MEMSTATUS |
| 150 | | - "DEFAULT_MEMSTATUS", |
| 151 | +#ifdef SQLITE_DEFAULT_MEMSTATUS |
| 152 | +# if SQLITE_DEFAULT_MEMSTATUS != 1 |
| 153 | + "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS), |
| 154 | +# endif |
| 151 | 155 | #endif |
| 152 | 156 | #ifdef SQLITE_DEFAULT_MMAP_SIZE |
| 153 | 157 | "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE), |
| 154 | 158 | #endif |
| 155 | 159 | #ifdef SQLITE_DEFAULT_PAGE_SIZE |
| | @@ -219,11 +223,11 @@ |
| 219 | 223 | "ENABLE_BATCH_ATOMIC_WRITE", |
| 220 | 224 | #endif |
| 221 | 225 | #if SQLITE_ENABLE_BYTECODE_VTAB |
| 222 | 226 | "ENABLE_BYTECODE_VTAB", |
| 223 | 227 | #endif |
| 224 | | -#if SQLITE_ENABLE_CEROD |
| 228 | +#ifdef SQLITE_ENABLE_CEROD |
| 225 | 229 | "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD), |
| 226 | 230 | #endif |
| 227 | 231 | #if SQLITE_ENABLE_COLUMN_METADATA |
| 228 | 232 | "ENABLE_COLUMN_METADATA", |
| 229 | 233 | #endif |
| | @@ -233,22 +237,22 @@ |
| 233 | 237 | #if SQLITE_ENABLE_COSTMULT |
| 234 | 238 | "ENABLE_COSTMULT", |
| 235 | 239 | #endif |
| 236 | 240 | #if SQLITE_ENABLE_CURSOR_HINTS |
| 237 | 241 | "ENABLE_CURSOR_HINTS", |
| 242 | +#endif |
| 243 | +#if SQLITE_ENABLE_DBPAGE_VTAB |
| 244 | + "ENABLE_DBPAGE_VTAB", |
| 238 | 245 | #endif |
| 239 | 246 | #if SQLITE_ENABLE_DBSTAT_VTAB |
| 240 | 247 | "ENABLE_DBSTAT_VTAB", |
| 241 | 248 | #endif |
| 242 | 249 | #if SQLITE_ENABLE_EXPENSIVE_ASSERT |
| 243 | 250 | "ENABLE_EXPENSIVE_ASSERT", |
| 244 | 251 | #endif |
| 245 | | -#if SQLITE_ENABLE_FTS1 |
| 246 | | - "ENABLE_FTS1", |
| 247 | | -#endif |
| 248 | | -#if SQLITE_ENABLE_FTS2 |
| 249 | | - "ENABLE_FTS2", |
| 252 | +#if SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 253 | + "ENABLE_EXPLAIN_COMMENTS", |
| 250 | 254 | #endif |
| 251 | 255 | #if SQLITE_ENABLE_FTS3 |
| 252 | 256 | "ENABLE_FTS3", |
| 253 | 257 | #endif |
| 254 | 258 | #if SQLITE_ENABLE_FTS3_PARENTHESIS |
| | @@ -302,10 +306,13 @@ |
| 302 | 306 | #if SQLITE_ENABLE_NORMALIZE |
| 303 | 307 | "ENABLE_NORMALIZE", |
| 304 | 308 | #endif |
| 305 | 309 | #if SQLITE_ENABLE_NULL_TRIM |
| 306 | 310 | "ENABLE_NULL_TRIM", |
| 311 | +#endif |
| 312 | +#if SQLITE_ENABLE_OFFSET_SQL_FUNC |
| 313 | + "ENABLE_OFFSET_SQL_FUNC", |
| 307 | 314 | #endif |
| 308 | 315 | #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK |
| 309 | 316 | "ENABLE_OVERSIZE_CELL_CHECK", |
| 310 | 317 | #endif |
| 311 | 318 | #if SQLITE_ENABLE_PREUPDATE_HOOK |
| | @@ -333,11 +340,11 @@ |
| 333 | 340 | "ENABLE_SORTER_REFERENCES", |
| 334 | 341 | #endif |
| 335 | 342 | #if SQLITE_ENABLE_SQLLOG |
| 336 | 343 | "ENABLE_SQLLOG", |
| 337 | 344 | #endif |
| 338 | | -#if defined(SQLITE_ENABLE_STAT4) |
| 345 | +#if SQLITE_ENABLE_STAT4 |
| 339 | 346 | "ENABLE_STAT4", |
| 340 | 347 | #endif |
| 341 | 348 | #if SQLITE_ENABLE_STMTVTAB |
| 342 | 349 | "ENABLE_STMTVTAB", |
| 343 | 350 | #endif |
| | @@ -387,12 +394,14 @@ |
| 387 | 394 | "FTS5_NO_WITHOUT_ROWID", |
| 388 | 395 | #endif |
| 389 | 396 | #if HAVE_ISNAN || SQLITE_HAVE_ISNAN |
| 390 | 397 | "HAVE_ISNAN", |
| 391 | 398 | #endif |
| 392 | | -#if SQLITE_HOMEGROWN_RECURSIVE_MUTEX |
| 393 | | - "HOMEGROWN_RECURSIVE_MUTEX", |
| 399 | +#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX |
| 400 | +# if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1 |
| 401 | + "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX), |
| 402 | +# endif |
| 394 | 403 | #endif |
| 395 | 404 | #if SQLITE_IGNORE_AFP_LOCK_ERRORS |
| 396 | 405 | "IGNORE_AFP_LOCK_ERRORS", |
| 397 | 406 | #endif |
| 398 | 407 | #if SQLITE_IGNORE_FLOCK_LOCK_ERRORS |
| | @@ -486,13 +495,10 @@ |
| 486 | 495 | "MMAP_READWRITE", |
| 487 | 496 | #endif |
| 488 | 497 | #if SQLITE_MUTEX_NOOP |
| 489 | 498 | "MUTEX_NOOP", |
| 490 | 499 | #endif |
| 491 | | -#if SQLITE_MUTEX_NREF |
| 492 | | - "MUTEX_NREF", |
| 493 | | -#endif |
| 494 | 500 | #if SQLITE_MUTEX_OMIT |
| 495 | 501 | "MUTEX_OMIT", |
| 496 | 502 | #endif |
| 497 | 503 | #if SQLITE_MUTEX_PTHREADS |
| 498 | 504 | "MUTEX_PTHREADS", |
| | @@ -558,18 +564,21 @@ |
| 558 | 564 | "OMIT_CONFLICT_CLAUSE", |
| 559 | 565 | #endif |
| 560 | 566 | #if SQLITE_OMIT_CTE |
| 561 | 567 | "OMIT_CTE", |
| 562 | 568 | #endif |
| 563 | | -#if SQLITE_OMIT_DATETIME_FUNCS |
| 569 | +#if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT) |
| 564 | 570 | "OMIT_DATETIME_FUNCS", |
| 565 | 571 | #endif |
| 566 | 572 | #if SQLITE_OMIT_DECLTYPE |
| 567 | 573 | "OMIT_DECLTYPE", |
| 568 | 574 | #endif |
| 569 | 575 | #if SQLITE_OMIT_DEPRECATED |
| 570 | 576 | "OMIT_DEPRECATED", |
| 577 | +#endif |
| 578 | +#if SQLITE_OMIT_DESERIALIZE |
| 579 | + "OMIT_DESERIALIZE", |
| 571 | 580 | #endif |
| 572 | 581 | #if SQLITE_OMIT_DISKIO |
| 573 | 582 | "OMIT_DISKIO", |
| 574 | 583 | #endif |
| 575 | 584 | #if SQLITE_OMIT_EXPLAIN |
| | @@ -593,10 +602,13 @@ |
| 593 | 602 | #if SQLITE_OMIT_INCRBLOB |
| 594 | 603 | "OMIT_INCRBLOB", |
| 595 | 604 | #endif |
| 596 | 605 | #if SQLITE_OMIT_INTEGRITY_CHECK |
| 597 | 606 | "OMIT_INTEGRITY_CHECK", |
| 607 | +#endif |
| 608 | +#if SQLITE_OMIT_INTROSPECTION_PRAGMAS |
| 609 | + "OMIT_INTROSPECTION_PRAGMAS", |
| 598 | 610 | #endif |
| 599 | 611 | #if SQLITE_OMIT_LIKE_OPTIMIZATION |
| 600 | 612 | "OMIT_LIKE_OPTIMIZATION", |
| 601 | 613 | #endif |
| 602 | 614 | #if SQLITE_OMIT_LOAD_EXTENSION |
| | @@ -657,12 +669,14 @@ |
| 657 | 669 | "OMIT_TEMPDB", |
| 658 | 670 | #endif |
| 659 | 671 | #if SQLITE_OMIT_TEST_CONTROL |
| 660 | 672 | "OMIT_TEST_CONTROL", |
| 661 | 673 | #endif |
| 662 | | -#if SQLITE_OMIT_TRACE |
| 663 | | - "OMIT_TRACE", |
| 674 | +#ifdef SQLITE_OMIT_TRACE |
| 675 | +# if SQLITE_OMIT_TRACE != 1 |
| 676 | + "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE), |
| 677 | +# endif |
| 664 | 678 | #endif |
| 665 | 679 | #if SQLITE_OMIT_TRIGGER |
| 666 | 680 | "OMIT_TRIGGER", |
| 667 | 681 | #endif |
| 668 | 682 | #if SQLITE_OMIT_TRUNCATE_OPTIMIZATION |
| | @@ -693,12 +707,14 @@ |
| 693 | 707 | "PCACHE_SEPARATE_HEADER", |
| 694 | 708 | #endif |
| 695 | 709 | #if SQLITE_PERFORMANCE_TRACE |
| 696 | 710 | "PERFORMANCE_TRACE", |
| 697 | 711 | #endif |
| 698 | | -#if SQLITE_POWERSAFE_OVERWRITE |
| 699 | | - "POWERSAFE_OVERWRITE", |
| 712 | +#ifdef SQLITE_POWERSAFE_OVERWRITE |
| 713 | +# if SQLITE_POWERSAFE_OVERWRITE != 1 |
| 714 | + "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE), |
| 715 | +# endif |
| 700 | 716 | #endif |
| 701 | 717 | #if SQLITE_PREFER_PROXY_LOCKING |
| 702 | 718 | "PREFER_PROXY_LOCKING", |
| 703 | 719 | #endif |
| 704 | 720 | #if SQLITE_PROXY_DEBUG |
| | @@ -729,11 +745,14 @@ |
| 729 | 745 | "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL), |
| 730 | 746 | #endif |
| 731 | 747 | #if SQLITE_SUBSTR_COMPATIBILITY |
| 732 | 748 | "SUBSTR_COMPATIBILITY", |
| 733 | 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 | 754 | "SYSTEM_MALLOC", |
| 736 | 755 | #endif |
| 737 | 756 | #if SQLITE_TCL |
| 738 | 757 | "TCL", |
| 739 | 758 | #endif |
| | @@ -1186,11 +1205,11 @@ |
| 1186 | 1205 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1187 | 1206 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1188 | 1207 | */ |
| 1189 | 1208 | #define SQLITE_VERSION "3.36.0" |
| 1190 | 1209 | #define SQLITE_VERSION_NUMBER 3036000 |
| 1191 | | -#define SQLITE_SOURCE_ID "2021-04-07 18:17:53 a2ddb89b206c13876d34c5f9e3db41cda72d6eb3fea31ffa8cc6daa1e1580e16" |
| 1210 | +#define SQLITE_SOURCE_ID "2021-06-14 20:41:20 e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9ef70" |
| 1192 | 1211 | |
| 1193 | 1212 | /* |
| 1194 | 1213 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1195 | 1214 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1196 | 1215 | ** |
| | @@ -2202,10 +2221,14 @@ |
| 2202 | 2221 | ** currently has an SQL transaction open on the database. It is set to 0 if |
| 2203 | 2222 | ** the database is not a wal-mode db, or if there is no such connection in any |
| 2204 | 2223 | ** other process. This opcode cannot be used to detect transactions opened |
| 2205 | 2224 | ** by clients within the current process, only within other processes. |
| 2206 | 2225 | ** </ul> |
| 2226 | +** |
| 2227 | +** <li>[[SQLITE_FCNTL_CKSM_FILE]] |
| 2228 | +** Used by the cksmvfs VFS module only. |
| 2229 | +** </ul> |
| 2207 | 2230 | */ |
| 2208 | 2231 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 2209 | 2232 | #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 |
| 2210 | 2233 | #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 |
| 2211 | 2234 | #define SQLITE_FCNTL_LAST_ERRNO 4 |
| | @@ -2241,12 +2264,12 @@ |
| 2241 | 2264 | #define SQLITE_FCNTL_DATA_VERSION 35 |
| 2242 | 2265 | #define SQLITE_FCNTL_SIZE_LIMIT 36 |
| 2243 | 2266 | #define SQLITE_FCNTL_CKPT_DONE 37 |
| 2244 | 2267 | #define SQLITE_FCNTL_RESERVE_BYTES 38 |
| 2245 | 2268 | #define SQLITE_FCNTL_CKPT_START 39 |
| 2246 | | - |
| 2247 | 2269 | #define SQLITE_FCNTL_EXTERNAL_READER 40 |
| 2270 | +#define SQLITE_FCNTL_CKSM_FILE 41 |
| 2248 | 2271 | |
| 2249 | 2272 | /* deprecated names */ |
| 2250 | 2273 | #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE |
| 2251 | 2274 | #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE |
| 2252 | 2275 | #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
| | @@ -5255,10 +5278,19 @@ |
| 5255 | 5278 | ** changes to the content of the database files on disk. |
| 5256 | 5279 | ** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since |
| 5257 | 5280 | ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and |
| 5258 | 5281 | ** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so |
| 5259 | 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. |
| 5260 | 5292 | */ |
| 5261 | 5293 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 5262 | 5294 | |
| 5263 | 5295 | /* |
| 5264 | 5296 | ** CAPI3REF: Query The EXPLAIN Setting For A Prepared Statement |
| | @@ -5424,22 +5456,26 @@ |
| 5424 | 5456 | ** terminated. If any NUL characters occurs at byte offsets less than |
| 5425 | 5457 | ** the value of the fourth parameter then the resulting string value will |
| 5426 | 5458 | ** contain embedded NULs. The result of expressions involving strings |
| 5427 | 5459 | ** with embedded NULs is undefined. |
| 5428 | 5460 | ** |
| 5429 | | -** ^The fifth argument to the BLOB and string binding interfaces |
| 5430 | | -** is a destructor used to dispose of the BLOB or |
| 5431 | | -** string after SQLite has finished with it. ^The destructor is called |
| 5432 | | -** to dispose of the BLOB or string even if the call to the bind API fails, |
| 5433 | | -** except the destructor is not called if the third parameter is a NULL |
| 5434 | | -** pointer or the fourth parameter is negative. |
| 5435 | | -** ^If the fifth argument is |
| 5436 | | -** the special value [SQLITE_STATIC], then SQLite assumes that the |
| 5437 | | -** information is in static, unmanaged space and does not need to be freed. |
| 5438 | | -** ^If the fifth argument has the value [SQLITE_TRANSIENT], then |
| 5439 | | -** SQLite makes its own private copy of the data immediately, before |
| 5440 | | -** the sqlite3_bind_*() routine returns. |
| 5461 | +** ^The fifth argument to the BLOB and string binding interfaces controls |
| 5462 | +** or indicates the lifetime of the object referenced by the third parameter. |
| 5463 | +** ^These three options exist: |
| 5464 | +** ^(1) A destructor to dispose of the BLOB or string after SQLite has finished |
| 5465 | +** with it may be passed. ^It is called to dispose of the BLOB or string even |
| 5466 | +** if the call to the bind API fails, except the destructor is not called if |
| 5467 | +** the third parameter is a NULL pointer or the fourth parameter is negative. |
| 5468 | +** ^(2) The special constant, [SQLITE_STATIC], may be passsed to indicate that |
| 5469 | +** the application remains responsible for disposing of the object. ^In this |
| 5470 | +** case, the object and the provided pointer to it must remain valid until |
| 5471 | +** either the prepared statement is finalized or the same SQL parameter is |
| 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. |
| 5441 | 5477 | ** |
| 5442 | 5478 | ** ^The sixth argument to sqlite3_bind_text64() must be one of |
| 5443 | 5479 | ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE] |
| 5444 | 5480 | ** to specify the encoding of the text in the third parameter. If |
| 5445 | 5481 | ** the sixth argument to sqlite3_bind_text64() is not one of the |
| | @@ -6177,21 +6213,19 @@ |
| 6177 | 6213 | ** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY] |
| 6178 | 6214 | ** flag, which if present prevents the function from being invoked from |
| 6179 | 6215 | ** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, |
| 6180 | 6216 | ** index expressions, or the WHERE clause of partial indexes. |
| 6181 | 6217 | ** |
| 6182 | | -** <span style="background-color:#ffff90;"> |
| 6183 | 6218 | ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for |
| 6184 | 6219 | ** all application-defined SQL functions that do not need to be |
| 6185 | 6220 | ** used inside of triggers, view, CHECK constraints, or other elements of |
| 6186 | 6221 | ** the database schema. This flags is especially recommended for SQL |
| 6187 | 6222 | ** functions that have side effects or reveal internal application state. |
| 6188 | 6223 | ** Without this flag, an attacker might be able to modify the schema of |
| 6189 | 6224 | ** a database file to include invocations of the function with parameters |
| 6190 | 6225 | ** chosen by the attacker, which the application will then execute when |
| 6191 | 6226 | ** the database file is opened and read. |
| 6192 | | -** </span> |
| 6193 | 6227 | ** |
| 6194 | 6228 | ** ^(The fifth parameter is an arbitrary pointer. The implementation of the |
| 6195 | 6229 | ** function can gain access to this pointer using [sqlite3_user_data()].)^ |
| 6196 | 6230 | ** |
| 6197 | 6231 | ** ^The sixth, seventh and eighth parameters passed to the three |
| | @@ -8855,11 +8889,12 @@ |
| 8855 | 8889 | #define SQLITE_TESTCTRL_RESULT_INTREAL 27 |
| 8856 | 8890 | #define SQLITE_TESTCTRL_PRNG_SEED 28 |
| 8857 | 8891 | #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 |
| 8858 | 8892 | #define SQLITE_TESTCTRL_SEEK_COUNT 30 |
| 8859 | 8893 | #define SQLITE_TESTCTRL_TRACEFLAGS 31 |
| 8860 | | -#define SQLITE_TESTCTRL_LAST 31 /* Largest TESTCTRL */ |
| 8894 | +#define SQLITE_TESTCTRL_TUNE 32 |
| 8895 | +#define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */ |
| 8861 | 8896 | |
| 8862 | 8897 | /* |
| 8863 | 8898 | ** CAPI3REF: SQL Keyword Checking |
| 8864 | 8899 | ** |
| 8865 | 8900 | ** These routines provide access to the set of SQL language keywords |
| | @@ -10607,10 +10642,19 @@ |
| 10607 | 10642 | ** callback was invoked as a result of a direct insert, update, or delete |
| 10608 | 10643 | ** operation; or 1 for inserts, updates, or deletes invoked by top-level |
| 10609 | 10644 | ** triggers; or 2 for changes resulting from triggers called by top-level |
| 10610 | 10645 | ** triggers; and so forth. |
| 10611 | 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 | +** |
| 10612 | 10656 | ** See also: [sqlite3_update_hook()] |
| 10613 | 10657 | */ |
| 10614 | 10658 | #if defined(SQLITE_ENABLE_PREUPDATE_HOOK) |
| 10615 | 10659 | SQLITE_API void *sqlite3_preupdate_hook( |
| 10616 | 10660 | sqlite3 *db, |
| | @@ -10627,10 +10671,11 @@ |
| 10627 | 10671 | ); |
| 10628 | 10672 | SQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **); |
| 10629 | 10673 | SQLITE_API int sqlite3_preupdate_count(sqlite3 *); |
| 10630 | 10674 | SQLITE_API int sqlite3_preupdate_depth(sqlite3 *); |
| 10631 | 10675 | SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **); |
| 10676 | +SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *); |
| 10632 | 10677 | #endif |
| 10633 | 10678 | |
| 10634 | 10679 | /* |
| 10635 | 10680 | ** CAPI3REF: Low-level system error code |
| 10636 | 10681 | ** METHOD: sqlite3 |
| | @@ -10865,12 +10910,12 @@ |
| 10865 | 10910 | ** |
| 10866 | 10911 | ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the |
| 10867 | 10912 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory |
| 10868 | 10913 | ** allocation error occurs. |
| 10869 | 10914 | ** |
| 10870 | | -** This interface is only available if SQLite is compiled with the |
| 10871 | | -** [SQLITE_ENABLE_DESERIALIZE] option. |
| 10915 | +** This interface is omitted if SQLite is compiled with the |
| 10916 | +** [SQLITE_OMIT_DESERIALIZE] option. |
| 10872 | 10917 | */ |
| 10873 | 10918 | SQLITE_API unsigned char *sqlite3_serialize( |
| 10874 | 10919 | sqlite3 *db, /* The database connection */ |
| 10875 | 10920 | const char *zSchema, /* Which DB to serialize. ex: "main", "temp", ... */ |
| 10876 | 10921 | sqlite3_int64 *piSize, /* Write size of the DB here, if not NULL */ |
| | @@ -10917,12 +10962,12 @@ |
| 10917 | 10962 | ** |
| 10918 | 10963 | ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the |
| 10919 | 10964 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then |
| 10920 | 10965 | ** [sqlite3_free()] is invoked on argument P prior to returning. |
| 10921 | 10966 | ** |
| 10922 | | -** This interface is only available if SQLite is compiled with the |
| 10923 | | -** [SQLITE_ENABLE_DESERIALIZE] option. |
| 10967 | +** This interface is omitted if SQLite is compiled with the |
| 10968 | +** [SQLITE_OMIT_DESERIALIZE] option. |
| 10924 | 10969 | */ |
| 10925 | 10970 | SQLITE_API int sqlite3_deserialize( |
| 10926 | 10971 | sqlite3 *db, /* The database connection */ |
| 10927 | 10972 | const char *zSchema, /* Which DB to reopen with the deserialization */ |
| 10928 | 10973 | unsigned char *pData, /* The serialized database content */ |
| | @@ -11167,10 +11212,42 @@ |
| 11167 | 11212 | ** are attached is closed. Refer to the documentation for |
| 11168 | 11213 | ** [sqlite3session_create()] for details. |
| 11169 | 11214 | */ |
| 11170 | 11215 | SQLITE_API void sqlite3session_delete(sqlite3_session *pSession); |
| 11171 | 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 |
| 11172 | 11249 | |
| 11173 | 11250 | /* |
| 11174 | 11251 | ** CAPI3REF: Enable Or Disable A Session Object |
| 11175 | 11252 | ** METHOD: sqlite3_session |
| 11176 | 11253 | ** |
| | @@ -11411,10 +11488,26 @@ |
| 11411 | 11488 | sqlite3_session *pSession, /* Session object */ |
| 11412 | 11489 | int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */ |
| 11413 | 11490 | void **ppChangeset /* OUT: Buffer containing changeset */ |
| 11414 | 11491 | ); |
| 11415 | 11492 | |
| 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 | + |
| 11416 | 11509 | /* |
| 11417 | 11510 | ** CAPI3REF: Load The Difference Between Tables Into A Session |
| 11418 | 11511 | ** METHOD: sqlite3_session |
| 11419 | 11512 | ** |
| 11420 | 11513 | ** If it is not already attached to the session object passed as the first |
| | @@ -14235,12 +14328,13 @@ |
| 14235 | 14328 | #define TK_VECTOR 176 |
| 14236 | 14329 | #define TK_SELECT_COLUMN 177 |
| 14237 | 14330 | #define TK_IF_NULL_ROW 178 |
| 14238 | 14331 | #define TK_ASTERISK 179 |
| 14239 | 14332 | #define TK_SPAN 180 |
| 14240 | | -#define TK_SPACE 181 |
| 14241 | | -#define TK_ILLEGAL 182 |
| 14333 | +#define TK_ERROR 181 |
| 14334 | +#define TK_SPACE 182 |
| 14335 | +#define TK_ILLEGAL 183 |
| 14242 | 14336 | |
| 14243 | 14337 | /************** End of parse.h ***********************************************/ |
| 14244 | 14338 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 14245 | 14339 | #include <stdio.h> |
| 14246 | 14340 | #include <stdlib.h> |
| | @@ -15931,11 +16025,11 @@ |
| 15931 | 16025 | /* 152 */ 0x10, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00,\ |
| 15932 | 16026 | /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15933 | 16027 | /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 15934 | 16028 | /* 176 */ 0x00, 0x00, 0x00, 0x00,} |
| 15935 | 16029 | |
| 15936 | | -/* The sqlite3P2Values() routine is able to run faster if it knows |
| 16030 | +/* The resolve3P2Values() routine is able to run faster if it knows |
| 15937 | 16031 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 15938 | 16032 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 15939 | 16033 | ** generated this include file strives to group all JUMP opcodes |
| 15940 | 16034 | ** together near the beginning of the list. |
| 15941 | 16035 | */ |
| | @@ -16463,10 +16557,16 @@ |
| 16463 | 16557 | ** a no-op |
| 16464 | 16558 | */ |
| 16465 | 16559 | #ifndef SET_FULLSYNC |
| 16466 | 16560 | # define SET_FULLSYNC(x,y) |
| 16467 | 16561 | #endif |
| 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 |
| 16468 | 16568 | |
| 16469 | 16569 | /* |
| 16470 | 16570 | ** The default size of a disk sector |
| 16471 | 16571 | */ |
| 16472 | 16572 | #ifndef SQLITE_DEFAULT_SECTOR_SIZE |
| | @@ -17219,11 +17319,11 @@ |
| 17219 | 17319 | #define SQLITE_PushDown 0x00001000 /* The push-down optimization */ |
| 17220 | 17320 | #define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */ |
| 17221 | 17321 | #define SQLITE_SkipScan 0x00004000 /* Skip-scans */ |
| 17222 | 17322 | #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */ |
| 17223 | 17323 | #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */ |
| 17224 | | -#define SQLITE_ExistsToIN 0x00020000 /* The EXISTS-to-IN optimization */ |
| 17324 | +#define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */ |
| 17225 | 17325 | #define SQLITE_AllOpts 0xffffffff /* All optimizations */ |
| 17226 | 17326 | |
| 17227 | 17327 | /* |
| 17228 | 17328 | ** Macros for testing whether or not optimizations are enabled or disabled. |
| 17229 | 17329 | */ |
| | @@ -17724,10 +17824,11 @@ |
| 17724 | 17824 | #define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */ |
| 17725 | 17825 | #define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */ |
| 17726 | 17826 | #define TF_Shadow 0x1000 /* True for a shadow table */ |
| 17727 | 17827 | #define TF_HasStat4 0x2000 /* STAT4 info available for this table */ |
| 17728 | 17828 | #define TF_Ephemeral 0x4000 /* An ephemeral table */ |
| 17829 | +#define TF_Eponymous 0x8000 /* An eponymous virtual table */ |
| 17729 | 17830 | |
| 17730 | 17831 | /* |
| 17731 | 17832 | ** Test to see whether or not a table is a virtual table. This is |
| 17732 | 17833 | ** done as a macro so that it will be optimized out when virtual |
| 17733 | 17834 | ** table support is omitted from the build. |
| | @@ -18436,10 +18537,11 @@ |
| 18436 | 18537 | unsigned isCorrelated :1; /* True if sub-query is correlated */ |
| 18437 | 18538 | unsigned viaCoroutine :1; /* Implemented as a co-routine */ |
| 18438 | 18539 | unsigned isRecursive :1; /* True for recursive reference in WITH */ |
| 18439 | 18540 | unsigned fromDDL :1; /* Comes from sqlite_schema */ |
| 18440 | 18541 | unsigned isCte :1; /* This is a CTE */ |
| 18542 | + unsigned notCte :1; /* This item may not match a CTE */ |
| 18441 | 18543 | } fg; |
| 18442 | 18544 | int iCursor; /* The VDBE cursor number used to access this table */ |
| 18443 | 18545 | Expr *pOn; /* The ON clause of a join */ |
| 18444 | 18546 | IdList *pUsing; /* The USING clause of a join */ |
| 18445 | 18547 | Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */ |
| | @@ -18553,11 +18655,11 @@ |
| 18553 | 18655 | Upsert *pUpsert; /* ON CONFLICT clause information from an upsert */ |
| 18554 | 18656 | int iBaseReg; /* For TK_REGISTER when parsing RETURNING */ |
| 18555 | 18657 | } uNC; |
| 18556 | 18658 | NameContext *pNext; /* Next outer name context. NULL for outermost */ |
| 18557 | 18659 | int nRef; /* Number of names resolved by this context */ |
| 18558 | | - int nErr; /* Number of errors encountered while resolving names */ |
| 18660 | + int nNcErr; /* Number of errors encountered while resolving names */ |
| 18559 | 18661 | int ncFlags; /* Zero or more NC_* flags defined below */ |
| 18560 | 18662 | Select *pWinSelect; /* SELECT statement for any window functions */ |
| 18561 | 18663 | }; |
| 18562 | 18664 | |
| 18563 | 18665 | /* |
| | @@ -18586,10 +18688,11 @@ |
| 18586 | 18688 | #define NC_AllowWin 0x04000 /* Window functions are allowed here */ |
| 18587 | 18689 | #define NC_HasWin 0x08000 /* One or more window functions seen */ |
| 18588 | 18690 | #define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */ |
| 18589 | 18691 | #define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */ |
| 18590 | 18692 | #define NC_FromDDL 0x40000 /* SQL text comes from sqlite_schema */ |
| 18693 | +#define NC_NoSelect 0x80000 /* Do not descend into sub-selects */ |
| 18591 | 18694 | |
| 18592 | 18695 | /* |
| 18593 | 18696 | ** An instance of the following object describes a single ON CONFLICT |
| 18594 | 18697 | ** clause in an upsert. |
| 18595 | 18698 | ** |
| | @@ -18698,10 +18801,11 @@ |
| 18698 | 18801 | #define SF_View 0x0200000 /* SELECT statement is a view */ |
| 18699 | 18802 | #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */ |
| 18700 | 18803 | #define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */ |
| 18701 | 18804 | #define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */ |
| 18702 | 18805 | #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */ |
| 18806 | +#define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */ |
| 18703 | 18807 | |
| 18704 | 18808 | /* |
| 18705 | 18809 | ** The results of a SELECT can be distributed in several ways, as defined |
| 18706 | 18810 | ** by one of the following macros. The "SRT" prefix means "SELECT Result |
| 18707 | 18811 | ** Type". |
| | @@ -19226,10 +19330,26 @@ |
| 19226 | 19330 | ** Allowed values for mInitFlags |
| 19227 | 19331 | */ |
| 19228 | 19332 | #define INITFLAG_AlterRename 0x0001 /* Reparse after a RENAME */ |
| 19229 | 19333 | #define INITFLAG_AlterDrop 0x0002 /* Reparse after a DROP COLUMN */ |
| 19230 | 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 | + |
| 19231 | 19351 | /* |
| 19232 | 19352 | ** Structure containing global configuration data for the SQLite library. |
| 19233 | 19353 | ** |
| 19234 | 19354 | ** This structure also contains some state information. |
| 19235 | 19355 | */ |
| | @@ -19280,20 +19400,24 @@ |
| 19280 | 19400 | ** operation. Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE. |
| 19281 | 19401 | */ |
| 19282 | 19402 | void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */ |
| 19283 | 19403 | void *pVdbeBranchArg; /* 1st argument */ |
| 19284 | 19404 | #endif |
| 19285 | | -#ifdef SQLITE_ENABLE_DESERIALIZE |
| 19405 | +#ifndef SQLITE_OMIT_DESERIALIZE |
| 19286 | 19406 | sqlite3_int64 mxMemdbSize; /* Default max memdb size */ |
| 19287 | 19407 | #endif |
| 19288 | 19408 | #ifndef SQLITE_UNTESTABLE |
| 19289 | 19409 | int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */ |
| 19290 | 19410 | #endif |
| 19291 | 19411 | int bLocaltimeFault; /* True to fail localtime() calls */ |
| 19292 | 19412 | int iOnceResetThreshold; /* When to reset OP_Once counters */ |
| 19293 | 19413 | u32 szSorterRef; /* Min size in bytes to use sorter-refs */ |
| 19294 | 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 |
| 19295 | 19419 | }; |
| 19296 | 19420 | |
| 19297 | 19421 | /* |
| 19298 | 19422 | ** This macro is used inside of assert() statements to indicate that |
| 19299 | 19423 | ** the assert is only valid on a well-formed database. Instead of: |
| | @@ -19367,14 +19491,21 @@ |
| 19367 | 19491 | SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*); |
| 19368 | 19492 | SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*); |
| 19369 | 19493 | SQLITE_PRIVATE int sqlite3SelectWalkFail(Walker*, Select*); |
| 19370 | 19494 | SQLITE_PRIVATE int sqlite3WalkerDepthIncrease(Walker*,Select*); |
| 19371 | 19495 | SQLITE_PRIVATE void sqlite3WalkerDepthDecrease(Walker*,Select*); |
| 19496 | +SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker*,Select*); |
| 19372 | 19497 | |
| 19373 | 19498 | #ifdef SQLITE_DEBUG |
| 19374 | 19499 | SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*); |
| 19375 | 19500 | #endif |
| 19501 | + |
| 19502 | +#ifndef SQLITE_OMIT_CTE |
| 19503 | +SQLITE_PRIVATE void sqlite3SelectPopWith(Walker*, Select*); |
| 19504 | +#else |
| 19505 | +# define sqlite3SelectPopWith 0 |
| 19506 | +#endif |
| 19376 | 19507 | |
| 19377 | 19508 | /* |
| 19378 | 19509 | ** Return code from the parse-tree walking primitives and their |
| 19379 | 19510 | ** callbacks. |
| 19380 | 19511 | */ |
| | @@ -19405,10 +19536,11 @@ |
| 19405 | 19536 | ** An instance of the With object represents a WITH clause containing |
| 19406 | 19537 | ** one or more CTEs (common table expressions). |
| 19407 | 19538 | */ |
| 19408 | 19539 | struct With { |
| 19409 | 19540 | int nCte; /* Number of CTEs in the WITH clause */ |
| 19541 | + int bView; /* Belongs to the outermost Select of a view */ |
| 19410 | 19542 | With *pOuter; /* Containing WITH clause, or NULL */ |
| 19411 | 19543 | Cte a[1]; /* For each CTE in the WITH clause.... */ |
| 19412 | 19544 | }; |
| 19413 | 19545 | |
| 19414 | 19546 | /* |
| | @@ -19797,10 +19929,11 @@ |
| 19797 | 19929 | SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*); |
| 19798 | 19930 | SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int); |
| 19799 | 19931 | SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*); |
| 19800 | 19932 | SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*); |
| 19801 | 19933 | SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*); |
| 19934 | +SQLITE_PRIVATE void sqlite3GenerateColumnNames(Parse *pParse, Select *pSelect); |
| 19802 | 19935 | SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**); |
| 19803 | 19936 | SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char); |
| 19804 | 19937 | SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char); |
| 19805 | 19938 | SQLITE_PRIVATE void sqlite3OpenSchemaTable(Parse *, int); |
| 19806 | 19939 | SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*); |
| | @@ -20032,10 +20165,11 @@ |
| 20032 | 20165 | SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void); |
| 20033 | 20166 | SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*); |
| 20034 | 20167 | SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*); |
| 20035 | 20168 | SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*); |
| 20036 | 20169 | SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int); |
| 20170 | +SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p); |
| 20037 | 20171 | |
| 20038 | 20172 | #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) |
| 20039 | 20173 | SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int); |
| 20040 | 20174 | #endif |
| 20041 | 20175 | |
| | @@ -20175,11 +20309,11 @@ |
| 20175 | 20309 | |
| 20176 | 20310 | #if defined(SQLITE_NEED_ERR_NAME) |
| 20177 | 20311 | SQLITE_PRIVATE const char *sqlite3ErrName(int); |
| 20178 | 20312 | #endif |
| 20179 | 20313 | |
| 20180 | | -#ifdef SQLITE_ENABLE_DESERIALIZE |
| 20314 | +#ifndef SQLITE_OMIT_DESERIALIZE |
| 20181 | 20315 | SQLITE_PRIVATE int sqlite3MemdbInit(void); |
| 20182 | 20316 | #endif |
| 20183 | 20317 | |
| 20184 | 20318 | SQLITE_PRIVATE const char *sqlite3ErrStr(int); |
| 20185 | 20319 | SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse); |
| | @@ -20442,11 +20576,11 @@ |
| 20442 | 20576 | #ifndef SQLITE_OMIT_CTE |
| 20443 | 20577 | SQLITE_PRIVATE Cte *sqlite3CteNew(Parse*,Token*,ExprList*,Select*,u8); |
| 20444 | 20578 | SQLITE_PRIVATE void sqlite3CteDelete(sqlite3*,Cte*); |
| 20445 | 20579 | SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Cte*); |
| 20446 | 20580 | SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*); |
| 20447 | | -SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8); |
| 20581 | +SQLITE_PRIVATE With *sqlite3WithPush(Parse*, With*, u8); |
| 20448 | 20582 | #else |
| 20449 | 20583 | # define sqlite3CteNew(P,T,E,S) ((void*)0) |
| 20450 | 20584 | # define sqlite3CteDelete(D,C) |
| 20451 | 20585 | # define sqlite3CteWithAdd(P,W,C) ((void*)0) |
| 20452 | 20586 | # define sqlite3WithDelete(x,y) |
| | @@ -20937,11 +21071,11 @@ |
| 20937 | 21071 | #endif |
| 20938 | 21072 | #ifdef SQLITE_VDBE_COVERAGE |
| 20939 | 21073 | 0, /* xVdbeBranch */ |
| 20940 | 21074 | 0, /* pVbeBranchArg */ |
| 20941 | 21075 | #endif |
| 20942 | | -#ifdef SQLITE_ENABLE_DESERIALIZE |
| 21076 | +#ifndef SQLITE_OMIT_DESERIALIZE |
| 20943 | 21077 | SQLITE_MEMDB_DEFAULT_MAXSIZE, /* mxMemdbSize */ |
| 20944 | 21078 | #endif |
| 20945 | 21079 | #ifndef SQLITE_UNTESTABLE |
| 20946 | 21080 | 0, /* xTestCallback */ |
| 20947 | 21081 | #endif |
| | @@ -21500,10 +21634,11 @@ |
| 21500 | 21634 | u8 *aRecord; /* old.* database record */ |
| 21501 | 21635 | KeyInfo keyinfo; |
| 21502 | 21636 | UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */ |
| 21503 | 21637 | UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */ |
| 21504 | 21638 | int iNewReg; /* Register for new.* values */ |
| 21639 | + int iBlobWrite; /* Value returned by preupdate_blobwrite() */ |
| 21505 | 21640 | i64 iKey1; /* First key value passed to hook */ |
| 21506 | 21641 | i64 iKey2; /* Second key value passed to hook */ |
| 21507 | 21642 | Mem *aNew; /* Array of new.* values */ |
| 21508 | 21643 | Table *pTab; /* Schema object being upated */ |
| 21509 | 21644 | Index *pPk; /* PK index if pTab is WITHOUT ROWID */ |
| | @@ -21543,11 +21678,11 @@ |
| 21543 | 21678 | SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*); |
| 21544 | 21679 | SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*); |
| 21545 | 21680 | SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int); |
| 21546 | 21681 | SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*); |
| 21547 | 21682 | SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*); |
| 21548 | | -SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*)); |
| 21683 | +SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, i64, u8, void(*)(void*)); |
| 21549 | 21684 | SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64); |
| 21550 | 21685 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 21551 | 21686 | # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64 |
| 21552 | 21687 | #else |
| 21553 | 21688 | SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); |
| | @@ -21588,11 +21723,12 @@ |
| 21588 | 21723 | #endif |
| 21589 | 21724 | SQLITE_PRIVATE void sqlite3VdbeFrameMemDel(void*); /* Destructor on Mem */ |
| 21590 | 21725 | SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*); /* Actually deletes the Frame */ |
| 21591 | 21726 | SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *); |
| 21592 | 21727 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 21593 | | -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); |
| 21594 | 21730 | #endif |
| 21595 | 21731 | SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p); |
| 21596 | 21732 | |
| 21597 | 21733 | SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *); |
| 21598 | 21734 | SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *); |
| | @@ -23539,10 +23675,12 @@ |
| 23539 | 23675 | zPathOut[0] = 0; |
| 23540 | 23676 | return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut); |
| 23541 | 23677 | } |
| 23542 | 23678 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 23543 | 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 */ |
| 23544 | 23682 | return pVfs->xDlOpen(pVfs, zPath); |
| 23545 | 23683 | } |
| 23546 | 23684 | SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ |
| 23547 | 23685 | pVfs->xDlError(pVfs, nByte, zBufOut); |
| 23548 | 23686 | } |
| | @@ -27806,11 +27944,10 @@ |
| 27806 | 27944 | SQLITE_PRIVATE int sqlite3MallocInit(void){ |
| 27807 | 27945 | int rc; |
| 27808 | 27946 | if( sqlite3GlobalConfig.m.xMalloc==0 ){ |
| 27809 | 27947 | sqlite3MemSetDefault(); |
| 27810 | 27948 | } |
| 27811 | | - memset(&mem0, 0, sizeof(mem0)); |
| 27812 | 27949 | mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); |
| 27813 | 27950 | if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512 |
| 27814 | 27951 | || sqlite3GlobalConfig.nPage<=0 ){ |
| 27815 | 27952 | sqlite3GlobalConfig.pPage = 0; |
| 27816 | 27953 | sqlite3GlobalConfig.szPage = 0; |
| | @@ -29932,10 +30069,11 @@ |
| 29932 | 30069 | for(i=0; i<pSrc->nSrc; i++){ |
| 29933 | 30070 | const SrcItem *pItem = &pSrc->a[i]; |
| 29934 | 30071 | StrAccum x; |
| 29935 | 30072 | char zLine[100]; |
| 29936 | 30073 | sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); |
| 30074 | + x.printfFlags |= SQLITE_PRINTF_INTERNAL; |
| 29937 | 30075 | sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem); |
| 29938 | 30076 | if( pItem->pTab ){ |
| 29939 | 30077 | sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx", |
| 29940 | 30078 | pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed); |
| 29941 | 30079 | } |
| | @@ -30502,10 +30640,18 @@ |
| 30502 | 30640 | } |
| 30503 | 30641 | case TK_IF_NULL_ROW: { |
| 30504 | 30642 | sqlite3TreeViewLine(pView, "IF-NULL-ROW %d", pExpr->iTable); |
| 30505 | 30643 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 30506 | 30644 | break; |
| 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; |
| 30507 | 30653 | } |
| 30508 | 30654 | default: { |
| 30509 | 30655 | sqlite3TreeViewLine(pView, "op=%d", pExpr->op); |
| 30510 | 30656 | break; |
| 30511 | 30657 | } |
| | @@ -41972,10 +42118,26 @@ |
| 41972 | 42118 | /* Register all VFSes defined in the aVfs[] array */ |
| 41973 | 42119 | for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ |
| 41974 | 42120 | sqlite3_vfs_register(&aVfs[i], i==0); |
| 41975 | 42121 | } |
| 41976 | 42122 | unixBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1); |
| 42123 | + |
| 42124 | + /* Validate lock assumptions */ |
| 42125 | + assert( SQLITE_SHM_NLOCK==8 ); /* Number of available locks */ |
| 42126 | + assert( UNIX_SHM_BASE==120 ); /* Start of locking area */ |
| 42127 | + /* Locks: |
| 42128 | + ** WRITE UNIX_SHM_BASE 120 |
| 42129 | + ** CKPT UNIX_SHM_BASE+1 121 |
| 42130 | + ** RECOVER UNIX_SHM_BASE+2 122 |
| 42131 | + ** READ-0 UNIX_SHM_BASE+3 123 |
| 42132 | + ** READ-1 UNIX_SHM_BASE+4 124 |
| 42133 | + ** READ-2 UNIX_SHM_BASE+5 125 |
| 42134 | + ** READ-3 UNIX_SHM_BASE+6 126 |
| 42135 | + ** READ-4 UNIX_SHM_BASE+7 127 |
| 42136 | + ** DMS UNIX_SHM_BASE+8 128 |
| 42137 | + */ |
| 42138 | + assert( UNIX_SHM_DMS==128 ); /* Byte offset of the deadman-switch */ |
| 41977 | 42139 | return SQLITE_OK; |
| 41978 | 42140 | } |
| 41979 | 42141 | |
| 41980 | 42142 | /* |
| 41981 | 42143 | ** Shutdown the operating system interface. |
| | @@ -48365,35 +48527,92 @@ |
| 48365 | 48527 | ** |
| 48366 | 48528 | ** This file also implements interface sqlite3_serialize() and |
| 48367 | 48529 | ** sqlite3_deserialize(). |
| 48368 | 48530 | */ |
| 48369 | 48531 | /* #include "sqliteInt.h" */ |
| 48370 | | -#ifdef SQLITE_ENABLE_DESERIALIZE |
| 48532 | +#ifndef SQLITE_OMIT_DESERIALIZE |
| 48371 | 48533 | |
| 48372 | 48534 | /* |
| 48373 | 48535 | ** Forward declaration of objects used by this utility |
| 48374 | 48536 | */ |
| 48375 | 48537 | typedef struct sqlite3_vfs MemVfs; |
| 48376 | 48538 | typedef struct MemFile MemFile; |
| 48539 | +typedef struct MemStore MemStore; |
| 48377 | 48540 | |
| 48378 | 48541 | /* Access to a lower-level VFS that (might) implement dynamic loading, |
| 48379 | 48542 | ** access to randomness, etc. |
| 48380 | 48543 | */ |
| 48381 | 48544 | #define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData)) |
| 48382 | 48545 | |
| 48383 | | -/* An open file */ |
| 48384 | | -struct MemFile { |
| 48385 | | - sqlite3_file base; /* IO methods */ |
| 48546 | +/* Storage for a memdb file. |
| 48547 | +** |
| 48548 | +** An memdb object can be shared or separate. Shared memdb objects can be |
| 48549 | +** used by more than one database connection. Mutexes are used by shared |
| 48550 | +** memdb objects to coordinate access. Separate memdb objects are only |
| 48551 | +** connected to a single database connection and do not require additional |
| 48552 | +** mutexes. |
| 48553 | +** |
| 48554 | +** Shared memdb objects have .zFName!=0 and .pMutex!=0. They are created |
| 48555 | +** using "file:/name?vfs=memdb". The first character of the name must be |
| 48556 | +** "/" or else the object will be a separate memdb object. All shared |
| 48557 | +** memdb objects are stored in memdb_g.apMemStore[] in an arbitrary order. |
| 48558 | +** |
| 48559 | +** Separate memdb objects are created using a name that does not begin |
| 48560 | +** with "/" or using sqlite3_deserialize(). |
| 48561 | +** |
| 48562 | +** Access rules for shared MemStore objects: |
| 48563 | +** |
| 48564 | +** * .zFName is initialized when the object is created and afterwards |
| 48565 | +** is unchanged until the object is destroyed. So it can be accessed |
| 48566 | +** at any time as long as we know the object is not being destroyed, |
| 48567 | +** which means while either the SQLITE_MUTEX_STATIC_VFS1 or |
| 48568 | +** .pMutex is held or the object is not part of memdb_g.apMemStore[]. |
| 48569 | +** |
| 48570 | +** * Can .pMutex can only be changed while holding the |
| 48571 | +** SQLITE_MUTEX_STATIC_VFS1 mutex or while the object is not part |
| 48572 | +** of memdb_g.apMemStore[]. |
| 48573 | +** |
| 48574 | +** * Other fields can only be changed while holding the .pMutex mutex |
| 48575 | +** or when the .nRef is less than zero and the object is not part of |
| 48576 | +** memdb_g.apMemStore[]. |
| 48577 | +** |
| 48578 | +** * The .aData pointer has the added requirement that it can can only |
| 48579 | +** be changed (for resizing) when nMmap is zero. |
| 48580 | +** |
| 48581 | +*/ |
| 48582 | +struct MemStore { |
| 48386 | 48583 | sqlite3_int64 sz; /* Size of the file */ |
| 48387 | 48584 | sqlite3_int64 szAlloc; /* Space allocated to aData */ |
| 48388 | 48585 | sqlite3_int64 szMax; /* Maximum allowed size of the file */ |
| 48389 | 48586 | unsigned char *aData; /* content of the file */ |
| 48587 | + sqlite3_mutex *pMutex; /* Used by shared stores only */ |
| 48390 | 48588 | int nMmap; /* Number of memory mapped pages */ |
| 48391 | 48589 | unsigned mFlags; /* Flags */ |
| 48590 | + int nRdLock; /* Number of readers */ |
| 48591 | + int nWrLock; /* Number of writers. (Always 0 or 1) */ |
| 48592 | + int nRef; /* Number of users of this MemStore */ |
| 48593 | + char *zFName; /* The filename for shared stores */ |
| 48594 | +}; |
| 48595 | + |
| 48596 | +/* An open file */ |
| 48597 | +struct MemFile { |
| 48598 | + sqlite3_file base; /* IO methods */ |
| 48599 | + MemStore *pStore; /* The storage */ |
| 48392 | 48600 | int eLock; /* Most recent lock against this file */ |
| 48393 | 48601 | }; |
| 48394 | 48602 | |
| 48603 | +/* |
| 48604 | +** File-scope variables for holding the memdb files that are accessible |
| 48605 | +** to multiple database connections in separate threads. |
| 48606 | +** |
| 48607 | +** Must hold SQLITE_MUTEX_STATIC_VFS1 to access any part of this object. |
| 48608 | +*/ |
| 48609 | +static struct MemFS { |
| 48610 | + int nMemStore; /* Number of shared MemStore objects */ |
| 48611 | + MemStore **apMemStore; /* Array of all shared MemStore objects */ |
| 48612 | +} memdb_g; |
| 48613 | + |
| 48395 | 48614 | /* |
| 48396 | 48615 | ** Methods for MemFile |
| 48397 | 48616 | */ |
| 48398 | 48617 | static int memdbClose(sqlite3_file*); |
| 48399 | 48618 | static int memdbRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); |
| | @@ -48443,11 +48662,14 @@ |
| 48443 | 48662 | memdbDlClose, /* xDlClose */ |
| 48444 | 48663 | memdbRandomness, /* xRandomness */ |
| 48445 | 48664 | memdbSleep, /* xSleep */ |
| 48446 | 48665 | 0, /* memdbCurrentTime, */ /* xCurrentTime */ |
| 48447 | 48666 | memdbGetLastError, /* xGetLastError */ |
| 48448 | | - memdbCurrentTimeInt64 /* xCurrentTimeInt64 */ |
| 48667 | + memdbCurrentTimeInt64, /* xCurrentTimeInt64 */ |
| 48668 | + 0, /* xSetSystemCall */ |
| 48669 | + 0, /* xGetSystemCall */ |
| 48670 | + 0, /* xNextSystemCall */ |
| 48449 | 48671 | }; |
| 48450 | 48672 | |
| 48451 | 48673 | static const sqlite3_io_methods memdb_io_methods = { |
| 48452 | 48674 | 3, /* iVersion */ |
| 48453 | 48675 | memdbClose, /* xClose */ |
| | @@ -48468,23 +48690,71 @@ |
| 48468 | 48690 | 0, /* xShmUnmap */ |
| 48469 | 48691 | memdbFetch, /* xFetch */ |
| 48470 | 48692 | memdbUnfetch /* xUnfetch */ |
| 48471 | 48693 | }; |
| 48472 | 48694 | |
| 48695 | +/* |
| 48696 | +** Enter/leave the mutex on a MemStore |
| 48697 | +*/ |
| 48698 | +#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0 |
| 48699 | +static void memdbEnter(MemStore *p){ |
| 48700 | + UNUSED_PARAMETER(p); |
| 48701 | +} |
| 48702 | +static void memdbLeave(MemStore *p){ |
| 48703 | + UNUSED_PARAMETER(p); |
| 48704 | +} |
| 48705 | +#else |
| 48706 | +static void memdbEnter(MemStore *p){ |
| 48707 | + sqlite3_mutex_enter(p->pMutex); |
| 48708 | +} |
| 48709 | +static void memdbLeave(MemStore *p){ |
| 48710 | + sqlite3_mutex_leave(p->pMutex); |
| 48711 | +} |
| 48712 | +#endif |
| 48713 | + |
| 48473 | 48714 | |
| 48474 | 48715 | |
| 48475 | 48716 | /* |
| 48476 | 48717 | ** Close an memdb-file. |
| 48477 | | -** |
| 48478 | | -** The pData pointer is owned by the application, so there is nothing |
| 48479 | | -** to free. Unless the SQLITE_DESERIALIZE_FREEONCLOSE flag is set, |
| 48480 | | -** in which case we own the pData pointer and need to free it. |
| 48718 | +** Free the underlying MemStore object when its refcount drops to zero |
| 48719 | +** or less. |
| 48481 | 48720 | */ |
| 48482 | 48721 | static int memdbClose(sqlite3_file *pFile){ |
| 48483 | | - MemFile *p = (MemFile *)pFile; |
| 48484 | | - if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ){ |
| 48485 | | - sqlite3_free(p->aData); |
| 48722 | + MemStore *p = ((MemFile*)pFile)->pStore; |
| 48723 | + if( p->zFName ){ |
| 48724 | + int i; |
| 48725 | +#ifndef SQLITE_MUTEX_OMIT |
| 48726 | + sqlite3_mutex *pVfsMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1); |
| 48727 | +#endif |
| 48728 | + sqlite3_mutex_enter(pVfsMutex); |
| 48729 | + for(i=0; ALWAYS(i<memdb_g.nMemStore); i++){ |
| 48730 | + if( memdb_g.apMemStore[i]==p ){ |
| 48731 | + memdbEnter(p); |
| 48732 | + if( p->nRef==1 ){ |
| 48733 | + memdb_g.apMemStore[i] = memdb_g.apMemStore[--memdb_g.nMemStore]; |
| 48734 | + if( memdb_g.nMemStore==0 ){ |
| 48735 | + sqlite3_free(memdb_g.apMemStore); |
| 48736 | + memdb_g.apMemStore = 0; |
| 48737 | + } |
| 48738 | + } |
| 48739 | + break; |
| 48740 | + } |
| 48741 | + } |
| 48742 | + sqlite3_mutex_leave(pVfsMutex); |
| 48743 | + }else{ |
| 48744 | + memdbEnter(p); |
| 48745 | + } |
| 48746 | + p->nRef--; |
| 48747 | + if( p->nRef<=0 ){ |
| 48748 | + if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ){ |
| 48749 | + sqlite3_free(p->aData); |
| 48750 | + } |
| 48751 | + memdbLeave(p); |
| 48752 | + sqlite3_mutex_free(p->pMutex); |
| 48753 | + sqlite3_free(p); |
| 48754 | + }else{ |
| 48755 | + memdbLeave(p); |
| 48486 | 48756 | } |
| 48487 | 48757 | return SQLITE_OK; |
| 48488 | 48758 | } |
| 48489 | 48759 | |
| 48490 | 48760 | /* |
| | @@ -48494,24 +48764,27 @@ |
| 48494 | 48764 | sqlite3_file *pFile, |
| 48495 | 48765 | void *zBuf, |
| 48496 | 48766 | int iAmt, |
| 48497 | 48767 | sqlite_int64 iOfst |
| 48498 | 48768 | ){ |
| 48499 | | - MemFile *p = (MemFile *)pFile; |
| 48769 | + MemStore *p = ((MemFile*)pFile)->pStore; |
| 48770 | + memdbEnter(p); |
| 48500 | 48771 | if( iOfst+iAmt>p->sz ){ |
| 48501 | 48772 | memset(zBuf, 0, iAmt); |
| 48502 | 48773 | if( iOfst<p->sz ) memcpy(zBuf, p->aData+iOfst, p->sz - iOfst); |
| 48774 | + memdbLeave(p); |
| 48503 | 48775 | return SQLITE_IOERR_SHORT_READ; |
| 48504 | 48776 | } |
| 48505 | 48777 | memcpy(zBuf, p->aData+iOfst, iAmt); |
| 48778 | + memdbLeave(p); |
| 48506 | 48779 | return SQLITE_OK; |
| 48507 | 48780 | } |
| 48508 | 48781 | |
| 48509 | 48782 | /* |
| 48510 | 48783 | ** Try to enlarge the memory allocation to hold at least sz bytes |
| 48511 | 48784 | */ |
| 48512 | | -static int memdbEnlarge(MemFile *p, sqlite3_int64 newSz){ |
| 48785 | +static int memdbEnlarge(MemStore *p, sqlite3_int64 newSz){ |
| 48513 | 48786 | unsigned char *pNew; |
| 48514 | 48787 | if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || p->nMmap>0 ){ |
| 48515 | 48788 | return SQLITE_FULL; |
| 48516 | 48789 | } |
| 48517 | 48790 | if( newSz>p->szMax ){ |
| | @@ -48518,11 +48791,11 @@ |
| 48518 | 48791 | return SQLITE_FULL; |
| 48519 | 48792 | } |
| 48520 | 48793 | newSz *= 2; |
| 48521 | 48794 | if( newSz>p->szMax ) newSz = p->szMax; |
| 48522 | 48795 | pNew = sqlite3Realloc(p->aData, newSz); |
| 48523 | | - if( pNew==0 ) return SQLITE_NOMEM; |
| 48796 | + if( pNew==0 ) return SQLITE_IOERR_NOMEM; |
| 48524 | 48797 | p->aData = pNew; |
| 48525 | 48798 | p->szAlloc = newSz; |
| 48526 | 48799 | return SQLITE_OK; |
| 48527 | 48800 | } |
| 48528 | 48801 | |
| | @@ -48533,23 +48806,31 @@ |
| 48533 | 48806 | sqlite3_file *pFile, |
| 48534 | 48807 | const void *z, |
| 48535 | 48808 | int iAmt, |
| 48536 | 48809 | sqlite_int64 iOfst |
| 48537 | 48810 | ){ |
| 48538 | | - MemFile *p = (MemFile *)pFile; |
| 48539 | | - if( NEVER(p->mFlags & SQLITE_DESERIALIZE_READONLY) ) return SQLITE_READONLY; |
| 48811 | + MemStore *p = ((MemFile*)pFile)->pStore; |
| 48812 | + memdbEnter(p); |
| 48813 | + if( NEVER(p->mFlags & SQLITE_DESERIALIZE_READONLY) ){ |
| 48814 | + /* Can't happen: memdbLock() will return SQLITE_READONLY before |
| 48815 | + ** reaching this point */ |
| 48816 | + memdbLeave(p); |
| 48817 | + return SQLITE_IOERR_WRITE; |
| 48818 | + } |
| 48540 | 48819 | if( iOfst+iAmt>p->sz ){ |
| 48541 | 48820 | int rc; |
| 48542 | 48821 | if( iOfst+iAmt>p->szAlloc |
| 48543 | 48822 | && (rc = memdbEnlarge(p, iOfst+iAmt))!=SQLITE_OK |
| 48544 | 48823 | ){ |
| 48824 | + memdbLeave(p); |
| 48545 | 48825 | return rc; |
| 48546 | 48826 | } |
| 48547 | 48827 | if( iOfst>p->sz ) memset(p->aData+p->sz, 0, iOfst-p->sz); |
| 48548 | 48828 | p->sz = iOfst+iAmt; |
| 48549 | 48829 | } |
| 48550 | 48830 | memcpy(p->aData+iOfst, z, iAmt); |
| 48831 | + memdbLeave(p); |
| 48551 | 48832 | return SQLITE_OK; |
| 48552 | 48833 | } |
| 48553 | 48834 | |
| 48554 | 48835 | /* |
| 48555 | 48836 | ** Truncate an memdb-file. |
| | @@ -48557,62 +48838,103 @@ |
| 48557 | 48838 | ** In rollback mode (which is always the case for memdb, as it does not |
| 48558 | 48839 | ** support WAL mode) the truncate() method is only used to reduce |
| 48559 | 48840 | ** the size of a file, never to increase the size. |
| 48560 | 48841 | */ |
| 48561 | 48842 | static int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){ |
| 48562 | | - MemFile *p = (MemFile *)pFile; |
| 48563 | | - if( NEVER(size>p->sz) ) return SQLITE_FULL; |
| 48564 | | - p->sz = size; |
| 48565 | | - return SQLITE_OK; |
| 48843 | + MemStore *p = ((MemFile*)pFile)->pStore; |
| 48844 | + int rc = SQLITE_OK; |
| 48845 | + memdbEnter(p); |
| 48846 | + if( NEVER(size>p->sz) ){ |
| 48847 | + rc = SQLITE_FULL; |
| 48848 | + }else{ |
| 48849 | + p->sz = size; |
| 48850 | + } |
| 48851 | + memdbLeave(p); |
| 48852 | + return rc; |
| 48566 | 48853 | } |
| 48567 | 48854 | |
| 48568 | 48855 | /* |
| 48569 | 48856 | ** Sync an memdb-file. |
| 48570 | 48857 | */ |
| 48571 | 48858 | static int memdbSync(sqlite3_file *pFile, int flags){ |
| 48859 | + UNUSED_PARAMETER(pFile); |
| 48860 | + UNUSED_PARAMETER(flags); |
| 48572 | 48861 | return SQLITE_OK; |
| 48573 | 48862 | } |
| 48574 | 48863 | |
| 48575 | 48864 | /* |
| 48576 | 48865 | ** Return the current file-size of an memdb-file. |
| 48577 | 48866 | */ |
| 48578 | 48867 | static int memdbFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ |
| 48579 | | - MemFile *p = (MemFile *)pFile; |
| 48868 | + MemStore *p = ((MemFile*)pFile)->pStore; |
| 48869 | + memdbEnter(p); |
| 48580 | 48870 | *pSize = p->sz; |
| 48871 | + memdbLeave(p); |
| 48581 | 48872 | return SQLITE_OK; |
| 48582 | 48873 | } |
| 48583 | 48874 | |
| 48584 | 48875 | /* |
| 48585 | 48876 | ** Lock an memdb-file. |
| 48586 | 48877 | */ |
| 48587 | 48878 | static int memdbLock(sqlite3_file *pFile, int eLock){ |
| 48588 | | - MemFile *p = (MemFile *)pFile; |
| 48589 | | - if( eLock>SQLITE_LOCK_SHARED |
| 48590 | | - && (p->mFlags & SQLITE_DESERIALIZE_READONLY)!=0 |
| 48591 | | - ){ |
| 48592 | | - return SQLITE_READONLY; |
| 48593 | | - } |
| 48594 | | - p->eLock = eLock; |
| 48595 | | - return SQLITE_OK; |
| 48879 | + MemFile *pThis = (MemFile*)pFile; |
| 48880 | + MemStore *p = pThis->pStore; |
| 48881 | + int rc = SQLITE_OK; |
| 48882 | + if( eLock==pThis->eLock ) return SQLITE_OK; |
| 48883 | + memdbEnter(p); |
| 48884 | + if( eLock>SQLITE_LOCK_SHARED ){ |
| 48885 | + if( p->mFlags & SQLITE_DESERIALIZE_READONLY ){ |
| 48886 | + rc = SQLITE_READONLY; |
| 48887 | + }else if( pThis->eLock<=SQLITE_LOCK_SHARED ){ |
| 48888 | + if( p->nWrLock ){ |
| 48889 | + rc = SQLITE_BUSY; |
| 48890 | + }else{ |
| 48891 | + p->nWrLock = 1; |
| 48892 | + } |
| 48893 | + } |
| 48894 | + }else if( eLock==SQLITE_LOCK_SHARED ){ |
| 48895 | + if( pThis->eLock > SQLITE_LOCK_SHARED ){ |
| 48896 | + assert( p->nWrLock==1 ); |
| 48897 | + p->nWrLock = 0; |
| 48898 | + }else if( p->nWrLock ){ |
| 48899 | + rc = SQLITE_BUSY; |
| 48900 | + }else{ |
| 48901 | + p->nRdLock++; |
| 48902 | + } |
| 48903 | + }else{ |
| 48904 | + assert( eLock==SQLITE_LOCK_NONE ); |
| 48905 | + if( pThis->eLock>SQLITE_LOCK_SHARED ){ |
| 48906 | + assert( p->nWrLock==1 ); |
| 48907 | + p->nWrLock = 0; |
| 48908 | + } |
| 48909 | + assert( p->nRdLock>0 ); |
| 48910 | + p->nRdLock--; |
| 48911 | + } |
| 48912 | + if( rc==SQLITE_OK ) pThis->eLock = eLock; |
| 48913 | + memdbLeave(p); |
| 48914 | + return rc; |
| 48596 | 48915 | } |
| 48597 | 48916 | |
| 48598 | | -#if 0 /* Never used because memdbAccess() always returns false */ |
| 48917 | +#if 0 |
| 48599 | 48918 | /* |
| 48600 | | -** Check if another file-handle holds a RESERVED lock on an memdb-file. |
| 48919 | +** This interface is only used for crash recovery, which does not |
| 48920 | +** occur on an in-memory database. |
| 48601 | 48921 | */ |
| 48602 | 48922 | static int memdbCheckReservedLock(sqlite3_file *pFile, int *pResOut){ |
| 48603 | 48923 | *pResOut = 0; |
| 48604 | 48924 | return SQLITE_OK; |
| 48605 | 48925 | } |
| 48606 | 48926 | #endif |
| 48927 | + |
| 48607 | 48928 | |
| 48608 | 48929 | /* |
| 48609 | 48930 | ** File control method. For custom operations on an memdb-file. |
| 48610 | 48931 | */ |
| 48611 | 48932 | static int memdbFileControl(sqlite3_file *pFile, int op, void *pArg){ |
| 48612 | | - MemFile *p = (MemFile *)pFile; |
| 48933 | + MemStore *p = ((MemFile*)pFile)->pStore; |
| 48613 | 48934 | int rc = SQLITE_NOTFOUND; |
| 48935 | + memdbEnter(p); |
| 48614 | 48936 | if( op==SQLITE_FCNTL_VFSNAME ){ |
| 48615 | 48937 | *(char**)pArg = sqlite3_mprintf("memdb(%p,%lld)", p->aData, p->sz); |
| 48616 | 48938 | rc = SQLITE_OK; |
| 48617 | 48939 | } |
| 48618 | 48940 | if( op==SQLITE_FCNTL_SIZE_LIMIT ){ |
| | @@ -48626,10 +48948,11 @@ |
| 48626 | 48948 | } |
| 48627 | 48949 | p->szMax = iLimit; |
| 48628 | 48950 | *(sqlite3_int64*)pArg = iLimit; |
| 48629 | 48951 | rc = SQLITE_OK; |
| 48630 | 48952 | } |
| 48953 | + memdbLeave(p); |
| 48631 | 48954 | return rc; |
| 48632 | 48955 | } |
| 48633 | 48956 | |
| 48634 | 48957 | #if 0 /* Not used because of SQLITE_IOCAP_POWERSAFE_OVERWRITE */ |
| 48635 | 48958 | /* |
| | @@ -48642,10 +48965,11 @@ |
| 48642 | 48965 | |
| 48643 | 48966 | /* |
| 48644 | 48967 | ** Return the device characteristic flags supported by an memdb-file. |
| 48645 | 48968 | */ |
| 48646 | 48969 | static int memdbDeviceCharacteristics(sqlite3_file *pFile){ |
| 48970 | + UNUSED_PARAMETER(pFile); |
| 48647 | 48971 | return SQLITE_IOCAP_ATOMIC | |
| 48648 | 48972 | SQLITE_IOCAP_POWERSAFE_OVERWRITE | |
| 48649 | 48973 | SQLITE_IOCAP_SAFE_APPEND | |
| 48650 | 48974 | SQLITE_IOCAP_SEQUENTIAL; |
| 48651 | 48975 | } |
| | @@ -48655,47 +48979,112 @@ |
| 48655 | 48979 | sqlite3_file *pFile, |
| 48656 | 48980 | sqlite3_int64 iOfst, |
| 48657 | 48981 | int iAmt, |
| 48658 | 48982 | void **pp |
| 48659 | 48983 | ){ |
| 48660 | | - MemFile *p = (MemFile *)pFile; |
| 48984 | + MemStore *p = ((MemFile*)pFile)->pStore; |
| 48985 | + memdbEnter(p); |
| 48661 | 48986 | if( iOfst+iAmt>p->sz ){ |
| 48662 | 48987 | *pp = 0; |
| 48663 | 48988 | }else{ |
| 48664 | 48989 | p->nMmap++; |
| 48665 | 48990 | *pp = (void*)(p->aData + iOfst); |
| 48666 | 48991 | } |
| 48992 | + memdbLeave(p); |
| 48667 | 48993 | return SQLITE_OK; |
| 48668 | 48994 | } |
| 48669 | 48995 | |
| 48670 | 48996 | /* Release a memory-mapped page */ |
| 48671 | 48997 | static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ |
| 48672 | | - MemFile *p = (MemFile *)pFile; |
| 48998 | + MemStore *p = ((MemFile*)pFile)->pStore; |
| 48999 | + UNUSED_PARAMETER(iOfst); |
| 49000 | + UNUSED_PARAMETER(pPage); |
| 49001 | + memdbEnter(p); |
| 48673 | 49002 | p->nMmap--; |
| 49003 | + memdbLeave(p); |
| 48674 | 49004 | return SQLITE_OK; |
| 48675 | 49005 | } |
| 48676 | 49006 | |
| 48677 | 49007 | /* |
| 48678 | 49008 | ** Open an mem file handle. |
| 48679 | 49009 | */ |
| 48680 | 49010 | static int memdbOpen( |
| 48681 | 49011 | sqlite3_vfs *pVfs, |
| 48682 | 49012 | const char *zName, |
| 48683 | | - sqlite3_file *pFile, |
| 49013 | + sqlite3_file *pFd, |
| 48684 | 49014 | int flags, |
| 48685 | 49015 | int *pOutFlags |
| 48686 | 49016 | ){ |
| 48687 | | - MemFile *p = (MemFile*)pFile; |
| 49017 | + MemFile *pFile = (MemFile*)pFd; |
| 49018 | + MemStore *p = 0; |
| 49019 | + int szName; |
| 48688 | 49020 | if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){ |
| 48689 | | - return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFile, flags, pOutFlags); |
| 49021 | + return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFd, flags, pOutFlags); |
| 48690 | 49022 | } |
| 48691 | | - memset(p, 0, sizeof(*p)); |
| 48692 | | - p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE; |
| 49023 | + memset(pFile, 0, sizeof(*p)); |
| 49024 | + szName = sqlite3Strlen30(zName); |
| 49025 | + if( szName>1 && zName[0]=='/' ){ |
| 49026 | + int i; |
| 49027 | +#ifndef SQLITE_MUTEX_OMIT |
| 49028 | + sqlite3_mutex *pVfsMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1); |
| 49029 | +#endif |
| 49030 | + sqlite3_mutex_enter(pVfsMutex); |
| 49031 | + for(i=0; i<memdb_g.nMemStore; i++){ |
| 49032 | + if( strcmp(memdb_g.apMemStore[i]->zFName,zName)==0 ){ |
| 49033 | + p = memdb_g.apMemStore[i]; |
| 49034 | + break; |
| 49035 | + } |
| 49036 | + } |
| 49037 | + if( p==0 ){ |
| 49038 | + MemStore **apNew; |
| 49039 | + p = sqlite3Malloc( sizeof(*p) + szName + 3 ); |
| 49040 | + if( p==0 ){ |
| 49041 | + sqlite3_mutex_leave(pVfsMutex); |
| 49042 | + return SQLITE_NOMEM; |
| 49043 | + } |
| 49044 | + apNew = sqlite3Realloc(memdb_g.apMemStore, |
| 49045 | + sizeof(apNew[0])*(memdb_g.nMemStore+1) ); |
| 49046 | + if( apNew==0 ){ |
| 49047 | + sqlite3_free(p); |
| 49048 | + sqlite3_mutex_leave(pVfsMutex); |
| 49049 | + return SQLITE_NOMEM; |
| 49050 | + } |
| 49051 | + apNew[memdb_g.nMemStore++] = p; |
| 49052 | + memdb_g.apMemStore = apNew; |
| 49053 | + memset(p, 0, sizeof(*p)); |
| 49054 | + p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE|SQLITE_DESERIALIZE_FREEONCLOSE; |
| 49055 | + p->szMax = sqlite3GlobalConfig.mxMemdbSize; |
| 49056 | + p->zFName = (char*)&p[1]; |
| 49057 | + memcpy(p->zFName, zName, szName+1); |
| 49058 | + p->pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); |
| 49059 | + if( p->pMutex==0 ){ |
| 49060 | + memdb_g.nMemStore--; |
| 49061 | + sqlite3_free(p); |
| 49062 | + sqlite3_mutex_leave(pVfsMutex); |
| 49063 | + return SQLITE_NOMEM; |
| 49064 | + } |
| 49065 | + p->nRef = 1; |
| 49066 | + memdbEnter(p); |
| 49067 | + }else{ |
| 49068 | + memdbEnter(p); |
| 49069 | + p->nRef++; |
| 49070 | + } |
| 49071 | + sqlite3_mutex_leave(pVfsMutex); |
| 49072 | + }else{ |
| 49073 | + p = sqlite3Malloc( sizeof(*p) ); |
| 49074 | + if( p==0 ){ |
| 49075 | + return SQLITE_NOMEM; |
| 49076 | + } |
| 49077 | + memset(p, 0, sizeof(*p)); |
| 49078 | + p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE; |
| 49079 | + p->szMax = sqlite3GlobalConfig.mxMemdbSize; |
| 49080 | + } |
| 49081 | + pFile->pStore = p; |
| 48693 | 49082 | assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */ |
| 48694 | 49083 | *pOutFlags = flags | SQLITE_OPEN_MEMORY; |
| 48695 | | - pFile->pMethods = &memdb_io_methods; |
| 48696 | | - p->szMax = sqlite3GlobalConfig.mxMemdbSize; |
| 49084 | + pFd->pMethods = &memdb_io_methods; |
| 49085 | + memdbLeave(p); |
| 48697 | 49086 | return SQLITE_OK; |
| 48698 | 49087 | } |
| 48699 | 49088 | |
| 48700 | 49089 | #if 0 /* Only used to delete rollback journals, super-journals, and WAL |
| 48701 | 49090 | ** files, none of which exist in memdb. So this routine is never used */ |
| | @@ -48719,10 +49108,13 @@ |
| 48719 | 49108 | sqlite3_vfs *pVfs, |
| 48720 | 49109 | const char *zPath, |
| 48721 | 49110 | int flags, |
| 48722 | 49111 | int *pResOut |
| 48723 | 49112 | ){ |
| 49113 | + UNUSED_PARAMETER(pVfs); |
| 49114 | + UNUSED_PARAMETER(zPath); |
| 49115 | + UNUSED_PARAMETER(flags); |
| 48724 | 49116 | *pResOut = 0; |
| 48725 | 49117 | return SQLITE_OK; |
| 48726 | 49118 | } |
| 48727 | 49119 | |
| 48728 | 49120 | /* |
| | @@ -48734,10 +49126,11 @@ |
| 48734 | 49126 | sqlite3_vfs *pVfs, |
| 48735 | 49127 | const char *zPath, |
| 48736 | 49128 | int nOut, |
| 48737 | 49129 | char *zOut |
| 48738 | 49130 | ){ |
| 49131 | + UNUSED_PARAMETER(pVfs); |
| 48739 | 49132 | sqlite3_snprintf(nOut, zOut, "%s", zPath); |
| 48740 | 49133 | return SQLITE_OK; |
| 48741 | 49134 | } |
| 48742 | 49135 | |
| 48743 | 49136 | /* |
| | @@ -48806,13 +49199,18 @@ |
| 48806 | 49199 | ** Translate a database connection pointer and schema name into a |
| 48807 | 49200 | ** MemFile pointer. |
| 48808 | 49201 | */ |
| 48809 | 49202 | static MemFile *memdbFromDbSchema(sqlite3 *db, const char *zSchema){ |
| 48810 | 49203 | MemFile *p = 0; |
| 49204 | + MemStore *pStore; |
| 48811 | 49205 | int rc = sqlite3_file_control(db, zSchema, SQLITE_FCNTL_FILE_POINTER, &p); |
| 48812 | 49206 | if( rc ) return 0; |
| 48813 | 49207 | if( p->base.pMethods!=&memdb_io_methods ) return 0; |
| 49208 | + pStore = p->pStore; |
| 49209 | + memdbEnter(pStore); |
| 49210 | + if( pStore->zFName!=0 ) p = 0; |
| 49211 | + memdbLeave(pStore); |
| 48814 | 49212 | return p; |
| 48815 | 49213 | } |
| 48816 | 49214 | |
| 48817 | 49215 | /* |
| 48818 | 49216 | ** Return the serialization of a database |
| | @@ -48844,16 +49242,18 @@ |
| 48844 | 49242 | p = memdbFromDbSchema(db, zSchema); |
| 48845 | 49243 | iDb = sqlite3FindDbName(db, zSchema); |
| 48846 | 49244 | if( piSize ) *piSize = -1; |
| 48847 | 49245 | if( iDb<0 ) return 0; |
| 48848 | 49246 | if( p ){ |
| 48849 | | - if( piSize ) *piSize = p->sz; |
| 49247 | + MemStore *pStore = p->pStore; |
| 49248 | + assert( pStore->pMutex==0 ); |
| 49249 | + if( piSize ) *piSize = pStore->sz; |
| 48850 | 49250 | if( mFlags & SQLITE_SERIALIZE_NOCOPY ){ |
| 48851 | | - pOut = p->aData; |
| 49251 | + pOut = pStore->aData; |
| 48852 | 49252 | }else{ |
| 48853 | | - pOut = sqlite3_malloc64( p->sz ); |
| 48854 | | - if( pOut ) memcpy(pOut, p->aData, p->sz); |
| 49253 | + pOut = sqlite3_malloc64( pStore->sz ); |
| 49254 | + if( pOut ) memcpy(pOut, pStore->aData, pStore->sz); |
| 48855 | 49255 | } |
| 48856 | 49256 | return pOut; |
| 48857 | 49257 | } |
| 48858 | 49258 | pBt = db->aDb[iDb].pBt; |
| 48859 | 49259 | if( pBt==0 ) return 0; |
| | @@ -48943,19 +49343,20 @@ |
| 48943 | 49343 | } |
| 48944 | 49344 | p = memdbFromDbSchema(db, zSchema); |
| 48945 | 49345 | if( p==0 ){ |
| 48946 | 49346 | rc = SQLITE_ERROR; |
| 48947 | 49347 | }else{ |
| 48948 | | - p->aData = pData; |
| 49348 | + MemStore *pStore = p->pStore; |
| 49349 | + pStore->aData = pData; |
| 48949 | 49350 | pData = 0; |
| 48950 | | - p->sz = szDb; |
| 48951 | | - p->szAlloc = szBuf; |
| 48952 | | - p->szMax = szBuf; |
| 48953 | | - if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){ |
| 48954 | | - p->szMax = sqlite3GlobalConfig.mxMemdbSize; |
| 49351 | + pStore->sz = szDb; |
| 49352 | + pStore->szAlloc = szBuf; |
| 49353 | + pStore->szMax = szBuf; |
| 49354 | + if( pStore->szMax<sqlite3GlobalConfig.mxMemdbSize ){ |
| 49355 | + pStore->szMax = sqlite3GlobalConfig.mxMemdbSize; |
| 48955 | 49356 | } |
| 48956 | | - p->mFlags = mFlags; |
| 49357 | + pStore->mFlags = mFlags; |
| 48957 | 49358 | rc = SQLITE_OK; |
| 48958 | 49359 | } |
| 48959 | 49360 | |
| 48960 | 49361 | end_deserialize: |
| 48961 | 49362 | sqlite3_finalize(pStmt); |
| | @@ -48970,21 +49371,21 @@ |
| 48970 | 49371 | ** This routine is called when the extension is loaded. |
| 48971 | 49372 | ** Register the new VFS. |
| 48972 | 49373 | */ |
| 48973 | 49374 | SQLITE_PRIVATE int sqlite3MemdbInit(void){ |
| 48974 | 49375 | sqlite3_vfs *pLower = sqlite3_vfs_find(0); |
| 48975 | | - int sz = pLower->szOsFile; |
| 49376 | + unsigned int sz = pLower->szOsFile; |
| 48976 | 49377 | memdb_vfs.pAppData = pLower; |
| 48977 | 49378 | /* The following conditional can only be true when compiled for |
| 48978 | 49379 | ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave |
| 48979 | 49380 | ** it in, to be safe, but it is marked as NO_TEST since there |
| 48980 | 49381 | ** is no way to reach it under most builds. */ |
| 48981 | 49382 | if( sz<sizeof(MemFile) ) sz = sizeof(MemFile); /*NO_TEST*/ |
| 48982 | 49383 | memdb_vfs.szOsFile = sz; |
| 48983 | 49384 | return sqlite3_vfs_register(&memdb_vfs, 0); |
| 48984 | 49385 | } |
| 48985 | | -#endif /* SQLITE_ENABLE_DESERIALIZE */ |
| 49386 | +#endif /* SQLITE_OMIT_DESERIALIZE */ |
| 48986 | 49387 | |
| 48987 | 49388 | /************** End of memdb.c ***********************************************/ |
| 48988 | 49389 | /************** Begin file bitvec.c ******************************************/ |
| 48989 | 49390 | /* |
| 48990 | 49391 | ** 2008 February 16 |
| | @@ -56895,11 +57296,11 @@ |
| 56895 | 57296 | u8 *pPtr; |
| 56896 | 57297 | Pager *pPager = 0; /* Pager object to allocate and return */ |
| 56897 | 57298 | int rc = SQLITE_OK; /* Return code */ |
| 56898 | 57299 | int tempFile = 0; /* True for temp files (incl. in-memory files) */ |
| 56899 | 57300 | int memDb = 0; /* True if this is an in-memory file */ |
| 56900 | | -#ifdef SQLITE_ENABLE_DESERIALIZE |
| 57301 | +#ifndef SQLITE_OMIT_DESERIALIZE |
| 56901 | 57302 | int memJM = 0; /* Memory journal mode */ |
| 56902 | 57303 | #else |
| 56903 | 57304 | # define memJM 0 |
| 56904 | 57305 | #endif |
| 56905 | 57306 | int readOnly = 0; /* True if this is a read-only file */ |
| | @@ -57099,11 +57500,11 @@ |
| 57099 | 57500 | */ |
| 57100 | 57501 | if( zFilename && zFilename[0] ){ |
| 57101 | 57502 | int fout = 0; /* VFS flags returned by xOpen() */ |
| 57102 | 57503 | rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout); |
| 57103 | 57504 | assert( !memDb ); |
| 57104 | | -#ifdef SQLITE_ENABLE_DESERIALIZE |
| 57505 | +#ifndef SQLITE_OMIT_DESERIALIZE |
| 57105 | 57506 | memJM = (fout&SQLITE_OPEN_MEMORY)!=0; |
| 57106 | 57507 | #endif |
| 57107 | 57508 | readOnly = (fout&SQLITE_OPEN_READONLY)!=0; |
| 57108 | 57509 | |
| 57109 | 57510 | /* If the file was successfully opened for read/write access, |
| | @@ -58067,11 +58468,11 @@ |
| 58067 | 58468 | |
| 58068 | 58469 | if( pPager->errCode ) return pPager->errCode; |
| 58069 | 58470 | assert( pPager->eState>=PAGER_READER && pPager->eState<PAGER_ERROR ); |
| 58070 | 58471 | pPager->subjInMemory = (u8)subjInMemory; |
| 58071 | 58472 | |
| 58072 | | - if( ALWAYS(pPager->eState==PAGER_READER) ){ |
| 58473 | + if( pPager->eState==PAGER_READER ){ |
| 58073 | 58474 | assert( pPager->pInJournal==0 ); |
| 58074 | 58475 | |
| 58075 | 58476 | if( pagerUseWal(pPager) ){ |
| 58076 | 58477 | /* If the pager is configured to use locking_mode=exclusive, and an |
| 58077 | 58478 | ** exclusive lock on the database is not already held, obtain it now. |
| | @@ -60941,11 +61342,10 @@ |
| 60941 | 61342 | static void walCleanupHash(Wal *pWal){ |
| 60942 | 61343 | WalHashLoc sLoc; /* Hash table location */ |
| 60943 | 61344 | int iLimit = 0; /* Zero values greater than this */ |
| 60944 | 61345 | int nByte; /* Number of bytes to zero in aPgno[] */ |
| 60945 | 61346 | int i; /* Used to iterate through aHash[] */ |
| 60946 | | - int rc; /* Return code form walHashGet() */ |
| 60947 | 61347 | |
| 60948 | 61348 | assert( pWal->writeLock ); |
| 60949 | 61349 | testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 ); |
| 60950 | 61350 | testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE ); |
| 60951 | 61351 | testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 ); |
| | @@ -60956,12 +61356,12 @@ |
| 60956 | 61356 | ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed |
| 60957 | 61357 | ** that the page said hash-table and array reside on is already mapped.(1) |
| 60958 | 61358 | */ |
| 60959 | 61359 | assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) ); |
| 60960 | 61360 | assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] ); |
| 60961 | | - rc = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc); |
| 60962 | | - if( NEVER(rc) ) return; /* Defense-in-depth, in case (1) above is wrong */ |
| 61361 | + i = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc); |
| 61362 | + if( NEVER(i) ) return; /* Defense-in-depth, in case (1) above is wrong */ |
| 60963 | 61363 | |
| 60964 | 61364 | /* Zero all hash-table entries that correspond to frame numbers greater |
| 60965 | 61365 | ** than pWal->hdr.mxFrame. |
| 60966 | 61366 | */ |
| 60967 | 61367 | iLimit = pWal->hdr.mxFrame - sLoc.iZero; |
| | @@ -65587,11 +65987,11 @@ |
| 65587 | 65987 | Pgno pgnoRoot, /* The table that might be changing */ |
| 65588 | 65988 | i64 iRow, /* The rowid that might be changing */ |
| 65589 | 65989 | int isClearTable /* True if all rows are being deleted */ |
| 65590 | 65990 | ){ |
| 65591 | 65991 | BtCursor *p; |
| 65592 | | - if( pBtree->hasIncrblobCur==0 ) return; |
| 65992 | + assert( pBtree->hasIncrblobCur ); |
| 65593 | 65993 | assert( sqlite3BtreeHoldsMutex(pBtree) ); |
| 65594 | 65994 | pBtree->hasIncrblobCur = 0; |
| 65595 | 65995 | for(p=pBtree->pBt->pCursor; p; p=p->pNext){ |
| 65596 | 65996 | if( (p->curFlags & BTCF_Incrblob)!=0 ){ |
| 65597 | 65997 | pBtree->hasIncrblobCur = 1; |
| | @@ -66488,10 +66888,11 @@ |
| 66488 | 66888 | unsigned char *data; /* The page data */ |
| 66489 | 66889 | unsigned char *temp; /* Temp area for cell content */ |
| 66490 | 66890 | unsigned char *src; /* Source of content */ |
| 66491 | 66891 | int iCellFirst; /* First allowable cell index */ |
| 66492 | 66892 | int iCellLast; /* Last possible cell index */ |
| 66893 | + int iCellStart; /* First cell offset in input */ |
| 66493 | 66894 | |
| 66494 | 66895 | assert( sqlite3PagerIswriteable(pPage->pDbPage) ); |
| 66495 | 66896 | assert( pPage->pBt!=0 ); |
| 66496 | 66897 | assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE ); |
| 66497 | 66898 | assert( pPage->nOverflow==0 ); |
| | @@ -66529,11 +66930,11 @@ |
| 66529 | 66930 | if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage); |
| 66530 | 66931 | sz2 = get2byte(&data[iFree2+2]); |
| 66531 | 66932 | if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage); |
| 66532 | 66933 | memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz)); |
| 66533 | 66934 | sz += sz2; |
| 66534 | | - }else if( NEVER(iFree+sz>usableSize) ){ |
| 66935 | + }else if( iFree+sz>usableSize ){ |
| 66535 | 66936 | return SQLITE_CORRUPT_PAGE(pPage); |
| 66536 | 66937 | } |
| 66537 | 66938 | |
| 66538 | 66939 | cbrk = top+sz; |
| 66539 | 66940 | assert( cbrk+(iFree-top) <= usableSize ); |
| | @@ -66548,38 +66949,37 @@ |
| 66548 | 66949 | } |
| 66549 | 66950 | } |
| 66550 | 66951 | |
| 66551 | 66952 | cbrk = usableSize; |
| 66552 | 66953 | iCellLast = usableSize - 4; |
| 66954 | + iCellStart = get2byte(&data[hdr+5]); |
| 66553 | 66955 | for(i=0; i<nCell; i++){ |
| 66554 | 66956 | u8 *pAddr; /* The i-th cell pointer */ |
| 66555 | 66957 | pAddr = &data[cellOffset + i*2]; |
| 66556 | 66958 | pc = get2byte(pAddr); |
| 66557 | 66959 | testcase( pc==iCellFirst ); |
| 66558 | 66960 | testcase( pc==iCellLast ); |
| 66559 | 66961 | /* These conditions have already been verified in btreeInitPage() |
| 66560 | 66962 | ** if PRAGMA cell_size_check=ON. |
| 66561 | 66963 | */ |
| 66562 | | - if( pc<iCellFirst || pc>iCellLast ){ |
| 66964 | + if( pc<iCellStart || pc>iCellLast ){ |
| 66563 | 66965 | return SQLITE_CORRUPT_PAGE(pPage); |
| 66564 | 66966 | } |
| 66565 | | - assert( pc>=iCellFirst && pc<=iCellLast ); |
| 66967 | + assert( pc>=iCellStart && pc<=iCellLast ); |
| 66566 | 66968 | size = pPage->xCellSize(pPage, &src[pc]); |
| 66567 | 66969 | cbrk -= size; |
| 66568 | | - if( cbrk<iCellFirst || pc+size>usableSize ){ |
| 66970 | + if( cbrk<iCellStart || pc+size>usableSize ){ |
| 66569 | 66971 | return SQLITE_CORRUPT_PAGE(pPage); |
| 66570 | 66972 | } |
| 66571 | | - assert( cbrk+size<=usableSize && cbrk>=iCellFirst ); |
| 66973 | + assert( cbrk+size<=usableSize && cbrk>=iCellStart ); |
| 66572 | 66974 | testcase( cbrk+size==usableSize ); |
| 66573 | 66975 | testcase( pc+size==usableSize ); |
| 66574 | 66976 | put2byte(pAddr, cbrk); |
| 66575 | 66977 | if( temp==0 ){ |
| 66576 | | - int x; |
| 66577 | 66978 | if( cbrk==pc ) continue; |
| 66578 | 66979 | temp = sqlite3PagerTempSpace(pPage->pBt->pPager); |
| 66579 | | - x = get2byte(&data[hdr+5]); |
| 66580 | | - memcpy(&temp[x], &data[x], (cbrk+size) - x); |
| 66980 | + memcpy(&temp[iCellStart], &data[iCellStart], usableSize - iCellStart); |
| 66581 | 66981 | src = temp; |
| 66582 | 66982 | } |
| 66583 | 66983 | memcpy(&data[cbrk], &src[pc], size); |
| 66584 | 66984 | } |
| 66585 | 66985 | data[hdr+7] = 0; |
| | @@ -71459,14 +71859,13 @@ |
| 71459 | 71859 | *pRC = freePage2(pPage->pBt, pPage, pPage->pgno); |
| 71460 | 71860 | } |
| 71461 | 71861 | } |
| 71462 | 71862 | |
| 71463 | 71863 | /* |
| 71464 | | -** Free any overflow pages associated with the given Cell. Store |
| 71465 | | -** size information about the cell in pInfo. |
| 71864 | +** Free the overflow pages associated with the given Cell. |
| 71466 | 71865 | */ |
| 71467 | | -static int clearCell( |
| 71866 | +static SQLITE_NOINLINE int clearCellOverflow( |
| 71468 | 71867 | MemPage *pPage, /* The page that contains the Cell */ |
| 71469 | 71868 | unsigned char *pCell, /* First byte of the Cell */ |
| 71470 | 71869 | CellInfo *pInfo /* Size information about the cell */ |
| 71471 | 71870 | ){ |
| 71472 | 71871 | BtShared *pBt; |
| | @@ -71474,14 +71873,11 @@ |
| 71474 | 71873 | int rc; |
| 71475 | 71874 | int nOvfl; |
| 71476 | 71875 | u32 ovflPageSize; |
| 71477 | 71876 | |
| 71478 | 71877 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); |
| 71479 | | - pPage->xParseCell(pPage, pCell, pInfo); |
| 71480 | | - if( pInfo->nLocal==pInfo->nPayload ){ |
| 71481 | | - return SQLITE_OK; /* No overflow pages. Return without doing anything */ |
| 71482 | | - } |
| 71878 | + assert( pInfo->nLocal!=pInfo->nPayload ); |
| 71483 | 71879 | testcase( pCell + pInfo->nSize == pPage->aDataEnd ); |
| 71484 | 71880 | testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd ); |
| 71485 | 71881 | if( pCell + pInfo->nSize > pPage->aDataEnd ){ |
| 71486 | 71882 | /* Cell extends past end of page */ |
| 71487 | 71883 | return SQLITE_CORRUPT_PAGE(pPage); |
| | @@ -71532,10 +71928,25 @@ |
| 71532 | 71928 | if( rc ) return rc; |
| 71533 | 71929 | ovflPgno = iNext; |
| 71534 | 71930 | } |
| 71535 | 71931 | return SQLITE_OK; |
| 71536 | 71932 | } |
| 71933 | + |
| 71934 | +/* Call xParseCell to compute the size of a cell. If the cell contains |
| 71935 | +** overflow, then invoke cellClearOverflow to clear out that overflow. |
| 71936 | +** STore the result code (SQLITE_OK or some error code) in rc. |
| 71937 | +** |
| 71938 | +** Implemented as macro to force inlining for performance. |
| 71939 | +*/ |
| 71940 | +#define BTREE_CLEAR_CELL(rc, pPage, pCell, sInfo) \ |
| 71941 | + pPage->xParseCell(pPage, pCell, &sInfo); \ |
| 71942 | + if( sInfo.nLocal!=sInfo.nPayload ){ \ |
| 71943 | + rc = clearCellOverflow(pPage, pCell, &sInfo); \ |
| 71944 | + }else{ \ |
| 71945 | + rc = SQLITE_OK; \ |
| 71946 | + } |
| 71947 | + |
| 71537 | 71948 | |
| 71538 | 71949 | /* |
| 71539 | 71950 | ** Create the byte sequence used to represent a cell on page pPage |
| 71540 | 71951 | ** and write that byte sequence into pCell[]. Overflow pages are |
| 71541 | 71952 | ** allocated and filled in as necessary. The calling procedure |
| | @@ -72055,11 +72466,11 @@ |
| 72055 | 72466 | pData = pEnd; |
| 72056 | 72467 | while( 1/*exit by break*/ ){ |
| 72057 | 72468 | u8 *pCell = pCArray->apCell[i]; |
| 72058 | 72469 | u16 sz = pCArray->szCell[i]; |
| 72059 | 72470 | assert( sz>0 ); |
| 72060 | | - if( SQLITE_WITHIN(pCell,aData,pEnd) ){ |
| 72471 | + if( SQLITE_WITHIN(pCell,aData+j,pEnd) ){ |
| 72061 | 72472 | if( ((uptr)(pCell+sz))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT; |
| 72062 | 72473 | pCell = &pTmp[pCell - aData]; |
| 72063 | 72474 | }else if( (uptr)(pCell+sz)>(uptr)pSrcEnd |
| 72064 | 72475 | && (uptr)(pCell)<(uptr)pSrcEnd |
| 72065 | 72476 | ){ |
| | @@ -72068,13 +72479,12 @@ |
| 72068 | 72479 | |
| 72069 | 72480 | pData -= sz; |
| 72070 | 72481 | put2byte(pCellptr, (pData - aData)); |
| 72071 | 72482 | pCellptr += 2; |
| 72072 | 72483 | if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT; |
| 72073 | | - memcpy(pData, pCell, sz); |
| 72484 | + memmove(pData, pCell, sz); |
| 72074 | 72485 | assert( sz==pPg->xCellSize(pPg, pCell) || CORRUPT_DB ); |
| 72075 | | - testcase( sz!=pPg->xCellSize(pPg,pCell) ) |
| 72076 | 72486 | i++; |
| 72077 | 72487 | if( i>=iEnd ) break; |
| 72078 | 72488 | if( pCArray->ixNx[k]<=i ){ |
| 72079 | 72489 | k++; |
| 72080 | 72490 | pSrcEnd = pCArray->apEnd[k]; |
| | @@ -72209,11 +72619,13 @@ |
| 72209 | 72619 | assert( pFree>aData && (pFree - aData)<65536 ); |
| 72210 | 72620 | freeSpace(pPg, (u16)(pFree - aData), szFree); |
| 72211 | 72621 | } |
| 72212 | 72622 | pFree = pCell; |
| 72213 | 72623 | szFree = sz; |
| 72214 | | - if( pFree+sz>pEnd ) return 0; |
| 72624 | + if( pFree+sz>pEnd ){ |
| 72625 | + return 0; |
| 72626 | + } |
| 72215 | 72627 | }else{ |
| 72216 | 72628 | pFree = pCell; |
| 72217 | 72629 | szFree += sz; |
| 72218 | 72630 | } |
| 72219 | 72631 | nRet++; |
| | @@ -72862,11 +73274,11 @@ |
| 72862 | 73274 | b.apCell[b.nCell] = pTemp+leafCorrection; |
| 72863 | 73275 | assert( leafCorrection==0 || leafCorrection==4 ); |
| 72864 | 73276 | b.szCell[b.nCell] = b.szCell[b.nCell] - leafCorrection; |
| 72865 | 73277 | if( !pOld->leaf ){ |
| 72866 | 73278 | assert( leafCorrection==0 ); |
| 72867 | | - assert( pOld->hdrOffset==0 ); |
| 73279 | + assert( pOld->hdrOffset==0 || CORRUPT_DB ); |
| 72868 | 73280 | /* The right pointer of the child page pOld becomes the left |
| 72869 | 73281 | ** pointer of the divider cell */ |
| 72870 | 73282 | memcpy(b.apCell[b.nCell], &pOld->aData[8], 4); |
| 72871 | 73283 | }else{ |
| 72872 | 73284 | assert( leafCorrection==4 ); |
| | @@ -73185,10 +73597,11 @@ |
| 73185 | 73597 | /* Insert new divider cells into pParent. */ |
| 73186 | 73598 | for(i=0; i<nNew-1; i++){ |
| 73187 | 73599 | u8 *pCell; |
| 73188 | 73600 | u8 *pTemp; |
| 73189 | 73601 | int sz; |
| 73602 | + u8 *pSrcEnd; |
| 73190 | 73603 | MemPage *pNew = apNew[i]; |
| 73191 | 73604 | j = cntNew[i]; |
| 73192 | 73605 | |
| 73193 | 73606 | assert( j<nMaxCells ); |
| 73194 | 73607 | assert( b.apCell[j]!=0 ); |
| | @@ -73228,10 +73641,16 @@ |
| 73228 | 73641 | } |
| 73229 | 73642 | } |
| 73230 | 73643 | iOvflSpace += sz; |
| 73231 | 73644 | assert( sz<=pBt->maxLocal+23 ); |
| 73232 | 73645 | assert( iOvflSpace <= (int)pBt->pageSize ); |
| 73646 | + for(k=0; b.ixNx[k]<=i && ALWAYS(k<NB*2); k++){} |
| 73647 | + pSrcEnd = b.apEnd[k]; |
| 73648 | + if( SQLITE_WITHIN(pSrcEnd, pCell, pCell+sz) ){ |
| 73649 | + rc = SQLITE_CORRUPT_BKPT; |
| 73650 | + goto balance_cleanup; |
| 73651 | + } |
| 73233 | 73652 | insertCell(pParent, nxDiv+i, pCell, sz, pTemp, pNew->pgno, &rc); |
| 73234 | 73653 | if( rc!=SQLITE_OK ) goto balance_cleanup; |
| 73235 | 73654 | assert( sqlite3PagerIswriteable(pParent->pDbPage) ); |
| 73236 | 73655 | } |
| 73237 | 73656 | |
| | @@ -73770,17 +74189,27 @@ |
| 73770 | 74189 | ** not to clear the cursor here. |
| 73771 | 74190 | */ |
| 73772 | 74191 | if( pCur->curFlags & BTCF_Multiple ){ |
| 73773 | 74192 | rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur); |
| 73774 | 74193 | if( rc ) return rc; |
| 74194 | + if( loc && pCur->iPage<0 ){ |
| 74195 | + /* This can only happen if the schema is corrupt such that there is more |
| 74196 | + ** than one table or index with the same root page as used by the cursor. |
| 74197 | + ** Which can only happen if the SQLITE_NoSchemaError flag was set when |
| 74198 | + ** the schema was loaded. This cannot be asserted though, as a user might |
| 74199 | + ** set the flag, load the schema, and then unset the flag. */ |
| 74200 | + return SQLITE_CORRUPT_BKPT; |
| 74201 | + } |
| 73775 | 74202 | } |
| 73776 | 74203 | |
| 73777 | 74204 | if( pCur->pKeyInfo==0 ){ |
| 73778 | 74205 | assert( pX->pKey==0 ); |
| 73779 | 74206 | /* If this is an insert into a table b-tree, invalidate any incrblob |
| 73780 | 74207 | ** cursors open on the row being replaced */ |
| 73781 | | - invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0); |
| 74208 | + if( p->hasIncrblobCur ){ |
| 74209 | + invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0); |
| 74210 | + } |
| 73782 | 74211 | |
| 73783 | 74212 | /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing |
| 73784 | 74213 | ** to a row with the same key as the new entry being inserted. |
| 73785 | 74214 | */ |
| 73786 | 74215 | #ifdef SQLITE_DEBUG |
| | @@ -73857,21 +74286,20 @@ |
| 73857 | 74286 | x2.nData = pX->nKey; |
| 73858 | 74287 | x2.nZero = 0; |
| 73859 | 74288 | return btreeOverwriteCell(pCur, &x2); |
| 73860 | 74289 | } |
| 73861 | 74290 | } |
| 73862 | | - |
| 73863 | 74291 | } |
| 73864 | 74292 | assert( pCur->eState==CURSOR_VALID |
| 73865 | 74293 | || (pCur->eState==CURSOR_INVALID && loc) |
| 73866 | 74294 | || CORRUPT_DB ); |
| 73867 | 74295 | |
| 73868 | 74296 | pPage = pCur->pPage; |
| 73869 | 74297 | assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) ); |
| 73870 | 74298 | assert( pPage->leaf || !pPage->intKey ); |
| 73871 | 74299 | if( pPage->nFree<0 ){ |
| 73872 | | - if( pCur->eState>CURSOR_INVALID ){ |
| 74300 | + if( NEVER(pCur->eState>CURSOR_INVALID) ){ |
| 73873 | 74301 | rc = SQLITE_CORRUPT_BKPT; |
| 73874 | 74302 | }else{ |
| 73875 | 74303 | rc = btreeComputeFreeSpace(pPage); |
| 73876 | 74304 | } |
| 73877 | 74305 | if( rc ) return rc; |
| | @@ -73911,11 +74339,11 @@ |
| 73911 | 74339 | } |
| 73912 | 74340 | oldCell = findCell(pPage, idx); |
| 73913 | 74341 | if( !pPage->leaf ){ |
| 73914 | 74342 | memcpy(newCell, oldCell, 4); |
| 73915 | 74343 | } |
| 73916 | | - rc = clearCell(pPage, oldCell, &info); |
| 74344 | + BTREE_CLEAR_CELL(rc, pPage, oldCell, info); |
| 73917 | 74345 | testcase( pCur->curFlags & BTCF_ValidOvfl ); |
| 73918 | 74346 | invalidateOverflowCache(pCur); |
| 73919 | 74347 | if( info.nSize==szNew && info.nLocal==info.nPayload |
| 73920 | 74348 | && (!ISAUTOVACUUM || szNew<pPage->minLocal) |
| 73921 | 74349 | ){ |
| | @@ -74148,11 +74576,12 @@ |
| 74148 | 74576 | assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) ); |
| 74149 | 74577 | assert( !hasReadConflicts(p, pCur->pgnoRoot) ); |
| 74150 | 74578 | assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 ); |
| 74151 | 74579 | if( pCur->eState==CURSOR_REQUIRESEEK ){ |
| 74152 | 74580 | rc = btreeRestoreCursorPosition(pCur); |
| 74153 | | - if( rc ) return rc; |
| 74581 | + assert( rc!=SQLITE_OK || CORRUPT_DB || pCur->eState==CURSOR_VALID ); |
| 74582 | + if( rc || pCur->eState!=CURSOR_VALID ) return rc; |
| 74154 | 74583 | } |
| 74155 | 74584 | assert( CORRUPT_DB || pCur->eState==CURSOR_VALID ); |
| 74156 | 74585 | |
| 74157 | 74586 | iCellDepth = pCur->iPage; |
| 74158 | 74587 | iCellIdx = pCur->ix; |
| | @@ -74203,20 +74632,20 @@ |
| 74203 | 74632 | if( rc ) return rc; |
| 74204 | 74633 | } |
| 74205 | 74634 | |
| 74206 | 74635 | /* If this is a delete operation to remove a row from a table b-tree, |
| 74207 | 74636 | ** invalidate any incrblob cursors open on the row being deleted. */ |
| 74208 | | - if( pCur->pKeyInfo==0 ){ |
| 74637 | + if( pCur->pKeyInfo==0 && p->hasIncrblobCur ){ |
| 74209 | 74638 | invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0); |
| 74210 | 74639 | } |
| 74211 | 74640 | |
| 74212 | 74641 | /* Make the page containing the entry to be deleted writable. Then free any |
| 74213 | 74642 | ** overflow pages associated with the entry and finally remove the cell |
| 74214 | 74643 | ** itself from within the page. */ |
| 74215 | 74644 | rc = sqlite3PagerWrite(pPage->pDbPage); |
| 74216 | 74645 | if( rc ) return rc; |
| 74217 | | - rc = clearCell(pPage, pCell, &info); |
| 74646 | + BTREE_CLEAR_CELL(rc, pPage, pCell, info); |
| 74218 | 74647 | dropCell(pPage, iCellIdx, info.nSize, &rc); |
| 74219 | 74648 | if( rc ) return rc; |
| 74220 | 74649 | |
| 74221 | 74650 | /* If the cell deleted was not located on a leaf page, then the cursor |
| 74222 | 74651 | ** is currently pointing to the largest entry in the sub-tree headed |
| | @@ -74499,18 +74928,18 @@ |
| 74499 | 74928 | pCell = findCell(pPage, i); |
| 74500 | 74929 | if( !pPage->leaf ){ |
| 74501 | 74930 | rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange); |
| 74502 | 74931 | if( rc ) goto cleardatabasepage_out; |
| 74503 | 74932 | } |
| 74504 | | - rc = clearCell(pPage, pCell, &info); |
| 74933 | + BTREE_CLEAR_CELL(rc, pPage, pCell, info); |
| 74505 | 74934 | if( rc ) goto cleardatabasepage_out; |
| 74506 | 74935 | } |
| 74507 | 74936 | if( !pPage->leaf ){ |
| 74508 | 74937 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); |
| 74509 | 74938 | if( rc ) goto cleardatabasepage_out; |
| 74510 | | - }else if( pnChange ){ |
| 74511 | | - assert( pPage->intKey || CORRUPT_DB ); |
| 74939 | + } |
| 74940 | + if( pnChange ){ |
| 74512 | 74941 | testcase( !pPage->intKey ); |
| 74513 | 74942 | *pnChange += pPage->nCell; |
| 74514 | 74943 | } |
| 74515 | 74944 | if( freePageFlag ){ |
| 74516 | 74945 | freePage(pPage, &rc); |
| | @@ -74531,13 +74960,12 @@ |
| 74531 | 74960 | ** |
| 74532 | 74961 | ** This routine will fail with SQLITE_LOCKED if there are any open |
| 74533 | 74962 | ** read cursors on the table. Open write cursors are moved to the |
| 74534 | 74963 | ** root of the table. |
| 74535 | 74964 | ** |
| 74536 | | -** If pnChange is not NULL, then table iTable must be an intkey table. The |
| 74537 | | -** integer value pointed to by pnChange is incremented by the number of |
| 74538 | | -** entries in the table. |
| 74965 | +** If pnChange is not NULL, then the integer value pointed to by pnChange |
| 74966 | +** is incremented by the number of entries in the table. |
| 74539 | 74967 | */ |
| 74540 | 74968 | SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){ |
| 74541 | 74969 | int rc; |
| 74542 | 74970 | BtShared *pBt = p->pBt; |
| 74543 | 74971 | sqlite3BtreeEnter(p); |
| | @@ -74547,11 +74975,13 @@ |
| 74547 | 74975 | |
| 74548 | 74976 | if( SQLITE_OK==rc ){ |
| 74549 | 74977 | /* Invalidate all incrblob cursors open on table iTable (assuming iTable |
| 74550 | 74978 | ** is the root of a table b-tree - if it is not, the following call is |
| 74551 | 74979 | ** a no-op). */ |
| 74552 | | - invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1); |
| 74980 | + if( p->hasIncrblobCur ){ |
| 74981 | + invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1); |
| 74982 | + } |
| 74553 | 74983 | rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange); |
| 74554 | 74984 | } |
| 74555 | 74985 | sqlite3BtreeLeave(p); |
| 74556 | 74986 | return rc; |
| 74557 | 74987 | } |
| | @@ -76630,11 +77060,13 @@ |
| 76630 | 77060 | assert( (p->flags & MEM_Cleared)==0 ); |
| 76631 | 77061 | } |
| 76632 | 77062 | |
| 76633 | 77063 | /* The szMalloc field holds the correct memory allocation size */ |
| 76634 | 77064 | assert( p->szMalloc==0 |
| 76635 | | - || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) ); |
| 77065 | + || (p->flags==MEM_Undefined |
| 77066 | + && p->szMalloc<=sqlite3DbMallocSize(p->db,p->zMalloc)) |
| 77067 | + || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc)); |
| 76636 | 77068 | |
| 76637 | 77069 | /* If p holds a string or blob, the Mem.z must point to exactly |
| 76638 | 77070 | ** one of the following: |
| 76639 | 77071 | ** |
| 76640 | 77072 | ** (1) Memory in Mem.zMalloc and managed by the Mem object |
| | @@ -76794,11 +77226,13 @@ |
| 76794 | 77226 | ** contain a valid string or blob value. */ |
| 76795 | 77227 | assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) ); |
| 76796 | 77228 | testcase( bPreserve && pMem->z==0 ); |
| 76797 | 77229 | |
| 76798 | 77230 | assert( pMem->szMalloc==0 |
| 76799 | | - || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) ); |
| 77231 | + || (pMem->flags==MEM_Undefined |
| 77232 | + && pMem->szMalloc<=sqlite3DbMallocSize(pMem->db,pMem->zMalloc)) |
| 77233 | + || pMem->szMalloc==sqlite3DbMallocSize(pMem->db,pMem->zMalloc)); |
| 76800 | 77234 | if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){ |
| 76801 | 77235 | if( pMem->db ){ |
| 76802 | 77236 | pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); |
| 76803 | 77237 | }else{ |
| 76804 | 77238 | pMem->zMalloc = sqlite3Realloc(pMem->z, n); |
| | @@ -77623,15 +78057,15 @@ |
| 77623 | 78057 | ** either case, SQLITE_TOOBIG is returned. |
| 77624 | 78058 | */ |
| 77625 | 78059 | SQLITE_PRIVATE int sqlite3VdbeMemSetStr( |
| 77626 | 78060 | Mem *pMem, /* Memory cell to set to string value */ |
| 77627 | 78061 | const char *z, /* String pointer */ |
| 77628 | | - int n, /* Bytes in string, or negative */ |
| 78062 | + i64 n, /* Bytes in string, or negative */ |
| 77629 | 78063 | u8 enc, /* Encoding of z. 0 for BLOBs */ |
| 77630 | 78064 | void (*xDel)(void*) /* Destructor function */ |
| 77631 | 78065 | ){ |
| 77632 | | - int nByte = n; /* New value for pMem->n */ |
| 78066 | + i64 nByte = n; /* New value for pMem->n */ |
| 77633 | 78067 | int iLimit; /* Maximum allowed string or blob size */ |
| 77634 | 78068 | u16 flags = 0; /* New value for pMem->flags */ |
| 77635 | 78069 | |
| 77636 | 78070 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 77637 | 78071 | assert( !sqlite3VdbeMemIsRowSet(pMem) ); |
| | @@ -77649,11 +78083,11 @@ |
| 77649 | 78083 | } |
| 77650 | 78084 | flags = (enc==0?MEM_Blob:MEM_Str); |
| 77651 | 78085 | if( nByte<0 ){ |
| 77652 | 78086 | assert( enc!=0 ); |
| 77653 | 78087 | if( enc==SQLITE_UTF8 ){ |
| 77654 | | - nByte = 0x7fffffff & (int)strlen(z); |
| 78088 | + nByte = strlen(z); |
| 77655 | 78089 | }else{ |
| 77656 | 78090 | for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){} |
| 77657 | 78091 | } |
| 77658 | 78092 | flags |= MEM_Term; |
| 77659 | 78093 | } |
| | @@ -77661,11 +78095,11 @@ |
| 77661 | 78095 | /* The following block sets the new values of Mem.z and Mem.xDel. It |
| 77662 | 78096 | ** also sets a flag in local variable "flags" to indicate the memory |
| 77663 | 78097 | ** management (one of MEM_Dyn or MEM_Static). |
| 77664 | 78098 | */ |
| 77665 | 78099 | if( xDel==SQLITE_TRANSIENT ){ |
| 77666 | | - u32 nAlloc = nByte; |
| 78100 | + i64 nAlloc = nByte; |
| 77667 | 78101 | if( flags&MEM_Term ){ |
| 77668 | 78102 | nAlloc += (enc==SQLITE_UTF8?1:2); |
| 77669 | 78103 | } |
| 77670 | 78104 | if( nByte>iLimit ){ |
| 77671 | 78105 | return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG); |
| | @@ -77687,11 +78121,11 @@ |
| 77687 | 78121 | pMem->xDel = xDel; |
| 77688 | 78122 | flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn); |
| 77689 | 78123 | } |
| 77690 | 78124 | } |
| 77691 | 78125 | |
| 77692 | | - pMem->n = nByte; |
| 78126 | + pMem->n = (int)(nByte & 0x7fffffff); |
| 77693 | 78127 | pMem->flags = flags; |
| 77694 | 78128 | if( enc ){ |
| 77695 | 78129 | pMem->enc = enc; |
| 77696 | 78130 | #ifdef SQLITE_ENABLE_SESSION |
| 77697 | 78131 | }else if( pMem->db==0 ){ |
| | @@ -77707,11 +78141,11 @@ |
| 77707 | 78141 | return SQLITE_NOMEM_BKPT; |
| 77708 | 78142 | } |
| 77709 | 78143 | #endif |
| 77710 | 78144 | |
| 77711 | 78145 | if( nByte>iLimit ){ |
| 77712 | | - return SQLITE_TOOBIG; |
| 78146 | + return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG); |
| 77713 | 78147 | } |
| 77714 | 78148 | |
| 77715 | 78149 | return SQLITE_OK; |
| 77716 | 78150 | } |
| 77717 | 78151 | |
| | @@ -83652,11 +84086,12 @@ |
| 83652 | 84086 | VdbeCursor *pCsr, /* Cursor to grab old.* values from */ |
| 83653 | 84087 | int op, /* SQLITE_INSERT, UPDATE or DELETE */ |
| 83654 | 84088 | const char *zDb, /* Database name */ |
| 83655 | 84089 | Table *pTab, /* Modified table */ |
| 83656 | 84090 | i64 iKey1, /* Initial key value */ |
| 83657 | | - int iReg /* Register for new.* record */ |
| 84091 | + int iReg, /* Register for new.* record */ |
| 84092 | + int iBlobWrite |
| 83658 | 84093 | ){ |
| 83659 | 84094 | sqlite3 *db = v->db; |
| 83660 | 84095 | i64 iKey2; |
| 83661 | 84096 | PreUpdate preupdate; |
| 83662 | 84097 | const char *zTbl = pTab->zName; |
| | @@ -83688,10 +84123,11 @@ |
| 83688 | 84123 | preupdate.keyinfo.nKeyField = pTab->nCol; |
| 83689 | 84124 | preupdate.keyinfo.aSortFlags = (u8*)&fakeSortOrder; |
| 83690 | 84125 | preupdate.iKey1 = iKey1; |
| 83691 | 84126 | preupdate.iKey2 = iKey2; |
| 83692 | 84127 | preupdate.pTab = pTab; |
| 84128 | + preupdate.iBlobWrite = iBlobWrite; |
| 83693 | 84129 | |
| 83694 | 84130 | db->pPreUpdate = &preupdate; |
| 83695 | 84131 | db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2); |
| 83696 | 84132 | db->pPreUpdate = 0; |
| 83697 | 84133 | sqlite3DbFree(db, preupdate.aRecord); |
| | @@ -84101,11 +84537,11 @@ |
| 84101 | 84537 | }else if( xDel==SQLITE_TRANSIENT ){ |
| 84102 | 84538 | /* noop */ |
| 84103 | 84539 | }else{ |
| 84104 | 84540 | xDel((void*)p); |
| 84105 | 84541 | } |
| 84106 | | - if( pCtx ) sqlite3_result_error_toobig(pCtx); |
| 84542 | + sqlite3_result_error_toobig(pCtx); |
| 84107 | 84543 | return SQLITE_TOOBIG; |
| 84108 | 84544 | } |
| 84109 | 84545 | SQLITE_API void sqlite3_result_blob( |
| 84110 | 84546 | sqlite3_context *pCtx, |
| 84111 | 84547 | const void *z, |
| | @@ -85083,11 +85519,11 @@ |
| 85083 | 85519 | */ |
| 85084 | 85520 | static int bindText( |
| 85085 | 85521 | sqlite3_stmt *pStmt, /* The statement to bind against */ |
| 85086 | 85522 | int i, /* Index of the parameter to bind */ |
| 85087 | 85523 | const void *zData, /* Pointer to the data to be bound */ |
| 85088 | | - int nData, /* Number of bytes of data to be bound */ |
| 85524 | + i64 nData, /* Number of bytes of data to be bound */ |
| 85089 | 85525 | void (*xDel)(void*), /* Destructor for the data */ |
| 85090 | 85526 | u8 encoding /* Encoding for the data */ |
| 85091 | 85527 | ){ |
| 85092 | 85528 | Vdbe *p = (Vdbe *)pStmt; |
| 85093 | 85529 | Mem *pVar; |
| | @@ -85135,15 +85571,11 @@ |
| 85135 | 85571 | const void *zData, |
| 85136 | 85572 | sqlite3_uint64 nData, |
| 85137 | 85573 | void (*xDel)(void*) |
| 85138 | 85574 | ){ |
| 85139 | 85575 | assert( xDel!=SQLITE_DYNAMIC ); |
| 85140 | | - if( nData>0x7fffffff ){ |
| 85141 | | - return invokeValueDestructor(zData, xDel, 0); |
| 85142 | | - }else{ |
| 85143 | | - return bindText(pStmt, i, zData, (int)nData, xDel, 0); |
| 85144 | | - } |
| 85576 | + return bindText(pStmt, i, zData, nData, xDel, 0); |
| 85145 | 85577 | } |
| 85146 | 85578 | SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){ |
| 85147 | 85579 | int rc; |
| 85148 | 85580 | Vdbe *p = (Vdbe *)pStmt; |
| 85149 | 85581 | rc = vdbeUnbind(p, i); |
| | @@ -85209,16 +85641,12 @@ |
| 85209 | 85641 | sqlite3_uint64 nData, |
| 85210 | 85642 | void (*xDel)(void*), |
| 85211 | 85643 | unsigned char enc |
| 85212 | 85644 | ){ |
| 85213 | 85645 | assert( xDel!=SQLITE_DYNAMIC ); |
| 85214 | | - if( nData>0x7fffffff ){ |
| 85215 | | - return invokeValueDestructor(zData, xDel, 0); |
| 85216 | | - }else{ |
| 85217 | | - if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE; |
| 85218 | | - return bindText(pStmt, i, zData, (int)nData, xDel, enc); |
| 85219 | | - } |
| 85646 | + if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE; |
| 85647 | + return bindText(pStmt, i, zData, nData, xDel, enc); |
| 85220 | 85648 | } |
| 85221 | 85649 | #ifndef SQLITE_OMIT_UTF16 |
| 85222 | 85650 | SQLITE_API int sqlite3_bind_text16( |
| 85223 | 85651 | sqlite3_stmt *pStmt, |
| 85224 | 85652 | int i, |
| | @@ -85613,10 +86041,21 @@ |
| 85613 | 86041 | SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){ |
| 85614 | 86042 | PreUpdate *p = db->pPreUpdate; |
| 85615 | 86043 | return (p ? p->v->nFrame : 0); |
| 85616 | 86044 | } |
| 85617 | 86045 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 86046 | + |
| 86047 | +#ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 86048 | +/* |
| 86049 | +** This function is designed to be called from within a pre-update callback |
| 86050 | +** only. |
| 86051 | +*/ |
| 86052 | +SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){ |
| 86053 | + PreUpdate *p = db->pPreUpdate; |
| 86054 | + return (p ? p->iBlobWrite : -1); |
| 86055 | +} |
| 86056 | +#endif |
| 85618 | 86057 | |
| 85619 | 86058 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 85620 | 86059 | /* |
| 85621 | 86060 | ** This function is called from within a pre-update callback to retrieve |
| 85622 | 86061 | ** a field of the row currently being updated or inserted. |
| | @@ -86235,22 +86674,40 @@ |
| 86235 | 86674 | assert( iCur>=0 && iCur<p->nCursor ); |
| 86236 | 86675 | if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/ |
| 86237 | 86676 | sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); |
| 86238 | 86677 | p->apCsr[iCur] = 0; |
| 86239 | 86678 | } |
| 86240 | | - if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){ |
| 86241 | | - p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z; |
| 86242 | | - memset(pCx, 0, offsetof(VdbeCursor,pAltCursor)); |
| 86243 | | - pCx->eCurType = eCurType; |
| 86244 | | - pCx->iDb = iDb; |
| 86245 | | - pCx->nField = nField; |
| 86246 | | - pCx->aOffset = &pCx->aType[nField]; |
| 86247 | | - if( eCurType==CURTYPE_BTREE ){ |
| 86248 | | - pCx->uc.pCursor = (BtCursor*) |
| 86249 | | - &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField]; |
| 86250 | | - sqlite3BtreeCursorZero(pCx->uc.pCursor); |
| 86251 | | - } |
| 86679 | + |
| 86680 | + /* There used to be a call to sqlite3VdbeMemClearAndResize() to make sure |
| 86681 | + ** the pMem used to hold space for the cursor has enough storage available |
| 86682 | + ** in pMem->zMalloc. But for the special case of the aMem[] entries used |
| 86683 | + ** to hold cursors, it is faster to in-line the logic. */ |
| 86684 | + assert( pMem->flags==MEM_Undefined ); |
| 86685 | + assert( (pMem->flags & MEM_Dyn)==0 ); |
| 86686 | + assert( pMem->szMalloc==0 || pMem->z==pMem->zMalloc ); |
| 86687 | + if( pMem->szMalloc<nByte ){ |
| 86688 | + if( pMem->szMalloc>0 ){ |
| 86689 | + sqlite3DbFreeNN(pMem->db, pMem->zMalloc); |
| 86690 | + } |
| 86691 | + pMem->z = pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, nByte); |
| 86692 | + if( pMem->zMalloc==0 ){ |
| 86693 | + pMem->szMalloc = 0; |
| 86694 | + return 0; |
| 86695 | + } |
| 86696 | + pMem->szMalloc = nByte; |
| 86697 | + } |
| 86698 | + |
| 86699 | + p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc; |
| 86700 | + memset(pCx, 0, offsetof(VdbeCursor,pAltCursor)); |
| 86701 | + pCx->eCurType = eCurType; |
| 86702 | + pCx->iDb = iDb; |
| 86703 | + pCx->nField = nField; |
| 86704 | + pCx->aOffset = &pCx->aType[nField]; |
| 86705 | + if( eCurType==CURTYPE_BTREE ){ |
| 86706 | + pCx->uc.pCursor = (BtCursor*) |
| 86707 | + &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField]; |
| 86708 | + sqlite3BtreeCursorZero(pCx->uc.pCursor); |
| 86252 | 86709 | } |
| 86253 | 86710 | return pCx; |
| 86254 | 86711 | } |
| 86255 | 86712 | |
| 86256 | 86713 | /* |
| | @@ -86393,11 +86850,14 @@ |
| 86393 | 86850 | static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){ |
| 86394 | 86851 | int rc; |
| 86395 | 86852 | sqlite3_int64 ix; |
| 86396 | 86853 | assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal))==0 ); |
| 86397 | 86854 | assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ); |
| 86398 | | - ExpandBlob(pMem); |
| 86855 | + if( ExpandBlob(pMem) ){ |
| 86856 | + pMem->u.i = 0; |
| 86857 | + return MEM_Int; |
| 86858 | + } |
| 86399 | 86859 | rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc); |
| 86400 | 86860 | if( rc<=0 ){ |
| 86401 | 86861 | if( rc==0 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1 ){ |
| 86402 | 86862 | pMem->u.i = ix; |
| 86403 | 86863 | return MEM_Int; |
| | @@ -86530,10 +86990,15 @@ |
| 86530 | 86990 | if( p->pScopyFrom ){ |
| 86531 | 86991 | printf(" <== R[%d]", (int)(p->pScopyFrom - &p[-iReg])); |
| 86532 | 86992 | } |
| 86533 | 86993 | printf("\n"); |
| 86534 | 86994 | sqlite3VdbeCheckMemInvariants(p); |
| 86995 | +} |
| 86996 | +/**/ void sqlite3PrintMem(Mem *pMem){ |
| 86997 | + memTracePrint(pMem); |
| 86998 | + printf("\n"); |
| 86999 | + fflush(stdout); |
| 86535 | 87000 | } |
| 86536 | 87001 | #endif |
| 86537 | 87002 | |
| 86538 | 87003 | #ifdef SQLITE_DEBUG |
| 86539 | 87004 | /* |
| | @@ -88067,10 +88532,35 @@ |
| 88067 | 88532 | |
| 88068 | 88533 | pIn1 = &aMem[pOp->p1]; |
| 88069 | 88534 | pIn3 = &aMem[pOp->p3]; |
| 88070 | 88535 | flags1 = pIn1->flags; |
| 88071 | 88536 | flags3 = pIn3->flags; |
| 88537 | + if( (flags1 & flags3 & MEM_Int)!=0 ){ |
| 88538 | + assert( (pOp->p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_TEXT || CORRUPT_DB ); |
| 88539 | + /* Common case of comparison of two integers */ |
| 88540 | + if( pIn3->u.i > pIn1->u.i ){ |
| 88541 | + iCompare = +1; |
| 88542 | + if( sqlite3aGTb[pOp->opcode] ){ |
| 88543 | + VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 88544 | + goto jump_to_p2; |
| 88545 | + } |
| 88546 | + }else if( pIn3->u.i < pIn1->u.i ){ |
| 88547 | + iCompare = -1; |
| 88548 | + if( sqlite3aLTb[pOp->opcode] ){ |
| 88549 | + VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 88550 | + goto jump_to_p2; |
| 88551 | + } |
| 88552 | + }else{ |
| 88553 | + iCompare = 0; |
| 88554 | + if( sqlite3aEQb[pOp->opcode] ){ |
| 88555 | + VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 88556 | + goto jump_to_p2; |
| 88557 | + } |
| 88558 | + } |
| 88559 | + VdbeBranchTaken(0, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 88560 | + break; |
| 88561 | + } |
| 88072 | 88562 | if( (flags1 | flags3)&MEM_Null ){ |
| 88073 | 88563 | /* One or both operands are NULL */ |
| 88074 | 88564 | if( pOp->p5 & SQLITE_NULLEQ ){ |
| 88075 | 88565 | /* If SQLITE_NULLEQ is set (which will only happen if the operator is |
| 88076 | 88566 | ** OP_Eq or OP_Ne) then take the jump or not depending on whether |
| | @@ -88097,11 +88587,12 @@ |
| 88097 | 88587 | goto jump_to_p2; |
| 88098 | 88588 | } |
| 88099 | 88589 | break; |
| 88100 | 88590 | } |
| 88101 | 88591 | }else{ |
| 88102 | | - /* Neither operand is NULL. Do a comparison. */ |
| 88592 | + /* Neither operand is NULL and we couldn't do the special high-speed |
| 88593 | + ** integer comparison case. So do a general-case comparison. */ |
| 88103 | 88594 | affinity = pOp->p5 & SQLITE_AFF_MASK; |
| 88104 | 88595 | if( affinity>=SQLITE_AFF_NUMERIC ){ |
| 88105 | 88596 | if( (flags1 | flags3)&MEM_Str ){ |
| 88106 | 88597 | if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 88107 | 88598 | applyNumericAffinity(pIn1,0); |
| | @@ -88110,18 +88601,10 @@ |
| 88110 | 88601 | } |
| 88111 | 88602 | if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 88112 | 88603 | applyNumericAffinity(pIn3,0); |
| 88113 | 88604 | } |
| 88114 | 88605 | } |
| 88115 | | - /* Handle the common case of integer comparison here, as an |
| 88116 | | - ** optimization, to avoid a call to sqlite3MemCompare() */ |
| 88117 | | - if( (pIn1->flags & pIn3->flags & MEM_Int)!=0 ){ |
| 88118 | | - if( pIn3->u.i > pIn1->u.i ){ res = +1; goto compare_op; } |
| 88119 | | - if( pIn3->u.i < pIn1->u.i ){ res = -1; goto compare_op; } |
| 88120 | | - res = 0; |
| 88121 | | - goto compare_op; |
| 88122 | | - } |
| 88123 | 88606 | }else if( affinity==SQLITE_AFF_TEXT ){ |
| 88124 | 88607 | if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ |
| 88125 | 88608 | testcase( pIn1->flags & MEM_Int ); |
| 88126 | 88609 | testcase( pIn1->flags & MEM_Real ); |
| 88127 | 88610 | testcase( pIn1->flags & MEM_IntReal ); |
| | @@ -88140,11 +88623,11 @@ |
| 88140 | 88623 | } |
| 88141 | 88624 | } |
| 88142 | 88625 | assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); |
| 88143 | 88626 | res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl); |
| 88144 | 88627 | } |
| 88145 | | -compare_op: |
| 88628 | + |
| 88146 | 88629 | /* At this point, res is negative, zero, or positive if reg[P1] is |
| 88147 | 88630 | ** less than, equal to, or greater than reg[P3], respectively. Compute |
| 88148 | 88631 | ** the answer to this operator in res2, depending on what the comparison |
| 88149 | 88632 | ** operator actually is. The next block of code depends on the fact |
| 88150 | 88633 | ** that the 6 comparison operators are consecutive integers in this |
| | @@ -90581,12 +91064,22 @@ |
| 90581 | 91064 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 90582 | 91065 | pC = p->apCsr[pOp->p1]; |
| 90583 | 91066 | assert( pC!=0 ); |
| 90584 | 91067 | assert( pOp->p3>=pOp->p2 ); |
| 90585 | 91068 | if( pC->seekHit<pOp->p2 ){ |
| 91069 | +#ifdef SQLITE_DEBUG |
| 91070 | + if( db->flags&SQLITE_VdbeTrace ){ |
| 91071 | + printf("seekHit changes from %d to %d\n", pC->seekHit, pOp->p2); |
| 91072 | + } |
| 91073 | +#endif |
| 90586 | 91074 | pC->seekHit = pOp->p2; |
| 90587 | 91075 | }else if( pC->seekHit>pOp->p3 ){ |
| 91076 | +#ifdef SQLITE_DEBUG |
| 91077 | + if( db->flags&SQLITE_VdbeTrace ){ |
| 91078 | + printf("seekHit changes from %d to %d\n", pC->seekHit, pOp->p3); |
| 91079 | + } |
| 91080 | +#endif |
| 90588 | 91081 | pC->seekHit = pOp->p3; |
| 90589 | 91082 | } |
| 90590 | 91083 | break; |
| 90591 | 91084 | } |
| 90592 | 91085 | |
| | @@ -90697,10 +91190,15 @@ |
| 90697 | 91190 | case OP_IfNoHope: { /* jump, in3 */ |
| 90698 | 91191 | VdbeCursor *pC; |
| 90699 | 91192 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 90700 | 91193 | pC = p->apCsr[pOp->p1]; |
| 90701 | 91194 | assert( pC!=0 ); |
| 91195 | +#ifdef SQLITE_DEBUG |
| 91196 | + if( db->flags&SQLITE_VdbeTrace ){ |
| 91197 | + printf("seekHit is %d\n", pC->seekHit); |
| 91198 | + } |
| 91199 | +#endif |
| 90702 | 91200 | if( pC->seekHit>=pOp->p4.i ) break; |
| 90703 | 91201 | /* Fall through into OP_NotFound */ |
| 90704 | 91202 | /* no break */ deliberate_fall_through |
| 90705 | 91203 | } |
| 90706 | 91204 | case OP_NoConflict: /* jump, in3 */ |
| | @@ -91126,11 +91624,11 @@ |
| 91126 | 91624 | |
| 91127 | 91625 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 91128 | 91626 | /* Invoke the pre-update hook, if any */ |
| 91129 | 91627 | if( pTab ){ |
| 91130 | 91628 | if( db->xPreUpdateCallback && !(pOp->p5 & OPFLAG_ISUPDATE) ){ |
| 91131 | | - sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey,pOp->p2); |
| 91629 | + sqlite3VdbePreUpdateHook(p,pC,SQLITE_INSERT,zDb,pTab,x.nKey,pOp->p2,-1); |
| 91132 | 91630 | } |
| 91133 | 91631 | if( db->xUpdateCallback==0 || pTab->aCol==0 ){ |
| 91134 | 91632 | /* Prevent post-update hook from running in cases when it should not */ |
| 91135 | 91633 | pTab = 0; |
| 91136 | 91634 | } |
| | @@ -91286,11 +91784,11 @@ |
| 91286 | 91784 | || (aMem[pOp->p3].flags & MEM_Int) |
| 91287 | 91785 | ); |
| 91288 | 91786 | sqlite3VdbePreUpdateHook(p, pC, |
| 91289 | 91787 | (opflags & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_DELETE, |
| 91290 | 91788 | zDb, pTab, pC->movetoTarget, |
| 91291 | | - pOp->p3 |
| 91789 | + pOp->p3, -1 |
| 91292 | 91790 | ); |
| 91293 | 91791 | } |
| 91294 | 91792 | if( opflags & OPFLAG_ISNOOP ) break; |
| 91295 | 91793 | #endif |
| 91296 | 91794 | |
| | @@ -92232,15 +92730,14 @@ |
| 92232 | 92730 | ** |
| 92233 | 92731 | ** The table being clear is in the main database file if P2==0. If |
| 92234 | 92732 | ** P2==1 then the table to be clear is in the auxiliary database file |
| 92235 | 92733 | ** that is used to store tables create using CREATE TEMPORARY TABLE. |
| 92236 | 92734 | ** |
| 92237 | | -** If the P3 value is non-zero, then the table referred to must be an |
| 92238 | | -** intkey table (an SQL table, not an index). In this case the row change |
| 92239 | | -** count is incremented by the number of rows in the table being cleared. |
| 92240 | | -** If P3 is greater than zero, then the value stored in register P3 is |
| 92241 | | -** also incremented by the number of rows in the table being cleared. |
| 92735 | +** If the P3 value is non-zero, then the row change count is incremented |
| 92736 | +** by the number of rows in the table being cleared. If P3 is greater |
| 92737 | +** than zero, then the value stored in register P3 is also incremented |
| 92738 | +** by the number of rows in the table being cleared. |
| 92242 | 92739 | ** |
| 92243 | 92740 | ** See also: Destroy |
| 92244 | 92741 | */ |
| 92245 | 92742 | case OP_Clear: { |
| 92246 | 92743 | int nChange; |
| | @@ -92247,13 +92744,11 @@ |
| 92247 | 92744 | |
| 92248 | 92745 | sqlite3VdbeIncrWriteCounter(p, 0); |
| 92249 | 92746 | nChange = 0; |
| 92250 | 92747 | assert( p->readOnly==0 ); |
| 92251 | 92748 | assert( DbMaskTest(p->btreeMask, pOp->p2) ); |
| 92252 | | - rc = sqlite3BtreeClearTable( |
| 92253 | | - db->aDb[pOp->p2].pBt, (u32)pOp->p1, (pOp->p3 ? &nChange : 0) |
| 92254 | | - ); |
| 92749 | + rc = sqlite3BtreeClearTable(db->aDb[pOp->p2].pBt, (u32)pOp->p1, &nChange); |
| 92255 | 92750 | if( pOp->p3 ){ |
| 92256 | 92751 | p->nChange += nChange; |
| 92257 | 92752 | if( pOp->p3>0 ){ |
| 92258 | 92753 | assert( memIsValid(&aMem[pOp->p3]) ); |
| 92259 | 92754 | memAboutToChange(p, &aMem[pOp->p3]); |
| | @@ -92355,11 +92850,13 @@ |
| 92355 | 92850 | } |
| 92356 | 92851 | #endif |
| 92357 | 92852 | |
| 92358 | 92853 | iDb = pOp->p1; |
| 92359 | 92854 | assert( iDb>=0 && iDb<db->nDb ); |
| 92360 | | - assert( DbHasProperty(db, iDb, DB_SchemaLoaded) ); |
| 92855 | + assert( DbHasProperty(db, iDb, DB_SchemaLoaded) |
| 92856 | + || db->mallocFailed |
| 92857 | + || (CORRUPT_DB && (db->flags & SQLITE_NoSchemaError)!=0) ); |
| 92361 | 92858 | |
| 92362 | 92859 | #ifndef SQLITE_OMIT_ALTERTABLE |
| 92363 | 92860 | if( pOp->p4.z==0 ){ |
| 92364 | 92861 | sqlite3SchemaClear(db->aDb[iDb].pSchema); |
| 92365 | 92862 | db->mDbFlags &= ~DBFLAG_SchemaKnownOk; |
| | @@ -93237,10 +93734,11 @@ |
| 93237 | 93734 | |
| 93238 | 93735 | pBt = db->aDb[pOp->p1].pBt; |
| 93239 | 93736 | pPager = sqlite3BtreePager(pBt); |
| 93240 | 93737 | eOld = sqlite3PagerGetJournalMode(pPager); |
| 93241 | 93738 | if( eNew==PAGER_JOURNALMODE_QUERY ) eNew = eOld; |
| 93739 | + assert( sqlite3BtreeHoldsMutex(pBt) ); |
| 93242 | 93740 | if( !sqlite3PagerOkToChangeJournalMode(pPager) ) eNew = eOld; |
| 93243 | 93741 | |
| 93244 | 93742 | #ifndef SQLITE_OMIT_WAL |
| 93245 | 93743 | zFilename = sqlite3PagerFilename(pPager, 1); |
| 93246 | 93744 | |
| | @@ -94715,11 +95213,11 @@ |
| 94715 | 95213 | ** anyhow. |
| 94716 | 95214 | */ |
| 94717 | 95215 | sqlite3_int64 iKey; |
| 94718 | 95216 | iKey = sqlite3BtreeIntegerKey(p->pCsr); |
| 94719 | 95217 | sqlite3VdbePreUpdateHook( |
| 94720 | | - v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1 |
| 95218 | + v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1, p->iCol |
| 94721 | 95219 | ); |
| 94722 | 95220 | } |
| 94723 | 95221 | #endif |
| 94724 | 95222 | |
| 94725 | 95223 | rc = xCall(p->pCsr, iOffset+p->iOffset, n, z); |
| | @@ -94786,10 +95284,11 @@ |
| 94786 | 95284 | ** already been invalidated. Return SQLITE_ABORT in this case. |
| 94787 | 95285 | */ |
| 94788 | 95286 | rc = SQLITE_ABORT; |
| 94789 | 95287 | }else{ |
| 94790 | 95288 | char *zErr; |
| 95289 | + ((Vdbe*)p->pStmt)->rc = SQLITE_OK; |
| 94791 | 95290 | rc = blobSeekToRow(p, iRow, &zErr); |
| 94792 | 95291 | if( rc!=SQLITE_OK ){ |
| 94793 | 95292 | sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr); |
| 94794 | 95293 | sqlite3DbFree(db, zErr); |
| 94795 | 95294 | } |
| | @@ -98256,30 +98755,32 @@ |
| 98256 | 98755 | /* |
| 98257 | 98756 | ** Truncate the in-memory file. |
| 98258 | 98757 | */ |
| 98259 | 98758 | static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){ |
| 98260 | 98759 | MemJournal *p = (MemJournal *)pJfd; |
| 98261 | | - FileChunk *pIter = 0; |
| 98262 | | - |
| 98263 | | - if( size==0 ){ |
| 98264 | | - memjrnlFreeChunks(p->pFirst); |
| 98265 | | - p->pFirst = 0; |
| 98266 | | - }else{ |
| 98267 | | - i64 iOff = p->nChunkSize; |
| 98268 | | - for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){ |
| 98269 | | - iOff += p->nChunkSize; |
| 98270 | | - } |
| 98271 | | - if( ALWAYS(pIter) ){ |
| 98272 | | - memjrnlFreeChunks(pIter->pNext); |
| 98273 | | - pIter->pNext = 0; |
| 98274 | | - } |
| 98275 | | - } |
| 98276 | | - |
| 98277 | | - p->endpoint.pChunk = pIter; |
| 98278 | | - p->endpoint.iOffset = size; |
| 98279 | | - p->readpoint.pChunk = 0; |
| 98280 | | - p->readpoint.iOffset = 0; |
| 98760 | + assert( p->endpoint.pChunk==0 || p->endpoint.pChunk->pNext==0 ); |
| 98761 | + if( size<p->endpoint.iOffset ){ |
| 98762 | + FileChunk *pIter = 0; |
| 98763 | + if( size==0 ){ |
| 98764 | + memjrnlFreeChunks(p->pFirst); |
| 98765 | + p->pFirst = 0; |
| 98766 | + }else{ |
| 98767 | + i64 iOff = p->nChunkSize; |
| 98768 | + for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){ |
| 98769 | + iOff += p->nChunkSize; |
| 98770 | + } |
| 98771 | + if( ALWAYS(pIter) ){ |
| 98772 | + memjrnlFreeChunks(pIter->pNext); |
| 98773 | + pIter->pNext = 0; |
| 98774 | + } |
| 98775 | + } |
| 98776 | + |
| 98777 | + p->endpoint.pChunk = pIter; |
| 98778 | + p->endpoint.iOffset = size; |
| 98779 | + p->readpoint.pChunk = 0; |
| 98780 | + p->readpoint.iOffset = 0; |
| 98781 | + } |
| 98281 | 98782 | return SQLITE_OK; |
| 98282 | 98783 | } |
| 98283 | 98784 | |
| 98284 | 98785 | /* |
| 98285 | 98786 | ** Close the file. |
| | @@ -98468,19 +98969,14 @@ |
| 98468 | 98969 | if( rc ) return WRC_Abort; |
| 98469 | 98970 | rc = sqlite3WalkExprList(pWalker, pWin->pPartition); |
| 98470 | 98971 | if( rc ) return WRC_Abort; |
| 98471 | 98972 | rc = sqlite3WalkExpr(pWalker, pWin->pFilter); |
| 98472 | 98973 | if( rc ) return WRC_Abort; |
| 98473 | | - |
| 98474 | | - /* The next two are purely for calls to sqlite3RenameExprUnmap() |
| 98475 | | - ** within sqlite3WindowOffsetExpr(). Because of constraints imposed |
| 98476 | | - ** by sqlite3WindowOffsetExpr(), they can never fail. The results do |
| 98477 | | - ** not matter anyhow. */ |
| 98478 | 98974 | rc = sqlite3WalkExpr(pWalker, pWin->pStart); |
| 98479 | | - if( NEVER(rc) ) return WRC_Abort; |
| 98975 | + if( rc ) return WRC_Abort; |
| 98480 | 98976 | rc = sqlite3WalkExpr(pWalker, pWin->pEnd); |
| 98481 | | - if( NEVER(rc) ) return WRC_Abort; |
| 98977 | + if( rc ) return WRC_Abort; |
| 98482 | 98978 | if( bOneOnly ) break; |
| 98483 | 98979 | } |
| 98484 | 98980 | return WRC_Continue; |
| 98485 | 98981 | } |
| 98486 | 98982 | #endif |
| | @@ -98552,10 +99048,20 @@ |
| 98552 | 99048 | if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort; |
| 98553 | 99049 | } |
| 98554 | 99050 | } |
| 98555 | 99051 | return WRC_Continue; |
| 98556 | 99052 | } |
| 99053 | + |
| 99054 | +/* |
| 99055 | +** This is a no-op callback for Walker->xSelectCallback2. If this |
| 99056 | +** callback is set, then the Select->pWinDefn list is traversed. |
| 99057 | +*/ |
| 99058 | +SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker *pWalker, Select *p){ |
| 99059 | + UNUSED_PARAMETER(pWalker); |
| 99060 | + UNUSED_PARAMETER(p); |
| 99061 | + /* No-op */ |
| 99062 | +} |
| 98557 | 99063 | |
| 98558 | 99064 | /* |
| 98559 | 99065 | ** Walk all expressions associated with SELECT statement p. Do |
| 98560 | 99066 | ** not invoke the SELECT callback on p, but do (of course) invoke |
| 98561 | 99067 | ** any expr callbacks and SELECT callbacks that come from subqueries. |
| | @@ -98566,14 +99072,19 @@ |
| 98566 | 99072 | if( sqlite3WalkExpr(pWalker, p->pWhere) ) return WRC_Abort; |
| 98567 | 99073 | if( sqlite3WalkExprList(pWalker, p->pGroupBy) ) return WRC_Abort; |
| 98568 | 99074 | if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort; |
| 98569 | 99075 | if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort; |
| 98570 | 99076 | if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort; |
| 98571 | | -#if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE) |
| 98572 | | - { |
| 98573 | | - Parse *pParse = pWalker->pParse; |
| 98574 | | - if( pParse && IN_RENAME_OBJECT ){ |
| 99077 | +#if !defined(SQLITE_OMIT_WINDOWFUNC) |
| 99078 | + if( p->pWinDefn ){ |
| 99079 | + Parse *pParse; |
| 99080 | + if( pWalker->xSelectCallback2==sqlite3WalkWinDefnDummyCallback |
| 99081 | + || ((pParse = pWalker->pParse)!=0 && IN_RENAME_OBJECT) |
| 99082 | +#ifndef SQLITE_OMIT_CTE |
| 99083 | + || pWalker->xSelectCallback2==sqlite3SelectPopWith |
| 99084 | +#endif |
| 99085 | + ){ |
| 98575 | 99086 | /* The following may return WRC_Abort if there are unresolvable |
| 98576 | 99087 | ** symbols (e.g. a table that does not exist) in a window definition. */ |
| 98577 | 99088 | int rc = walkWindowList(pWalker, p->pWinDefn, 0); |
| 98578 | 99089 | return rc; |
| 98579 | 99090 | } |
| | @@ -98593,11 +99104,11 @@ |
| 98593 | 99104 | SrcList *pSrc; |
| 98594 | 99105 | int i; |
| 98595 | 99106 | SrcItem *pItem; |
| 98596 | 99107 | |
| 98597 | 99108 | pSrc = p->pSrc; |
| 98598 | | - if( pSrc ){ |
| 99109 | + if( ALWAYS(pSrc) ){ |
| 98599 | 99110 | for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){ |
| 98600 | 99111 | if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){ |
| 98601 | 99112 | return WRC_Abort; |
| 98602 | 99113 | } |
| 98603 | 99114 | if( pItem->fg.isTabFunc |
| | @@ -98767,11 +99278,14 @@ |
| 98767 | 99278 | assert( iCol>=0 && iCol<pEList->nExpr ); |
| 98768 | 99279 | pOrig = pEList->a[iCol].pExpr; |
| 98769 | 99280 | assert( pOrig!=0 ); |
| 98770 | 99281 | db = pParse->db; |
| 98771 | 99282 | pDup = sqlite3ExprDup(db, pOrig, 0); |
| 98772 | | - if( pDup!=0 ){ |
| 99283 | + if( db->mallocFailed ){ |
| 99284 | + sqlite3ExprDelete(db, pDup); |
| 99285 | + pDup = 0; |
| 99286 | + }else{ |
| 98773 | 99287 | incrAggFunctionDepth(pDup, nSubquery); |
| 98774 | 99288 | if( pExpr->op==TK_COLLATE ){ |
| 98775 | 99289 | pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken); |
| 98776 | 99290 | } |
| 98777 | 99291 | |
| | @@ -98789,14 +99303,12 @@ |
| 98789 | 99303 | assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 ); |
| 98790 | 99304 | pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken); |
| 98791 | 99305 | pExpr->flags |= EP_MemToken; |
| 98792 | 99306 | } |
| 98793 | 99307 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 98794 | | - if( pExpr->y.pWin!=0 ){ |
| 99308 | + if( ALWAYS(pExpr->y.pWin!=0) ){ |
| 98795 | 99309 | pExpr->y.pWin->pOwner = pExpr; |
| 98796 | | - }else{ |
| 98797 | | - assert( db->mallocFailed ); |
| 98798 | 99310 | } |
| 98799 | 99311 | } |
| 98800 | 99312 | sqlite3DbFree(db, pDup); |
| 98801 | 99313 | } |
| 98802 | 99314 | } |
| | @@ -99184,12 +99696,12 @@ |
| 99184 | 99696 | ** or HAVING clauses, or as part of a larger expression in the ORDER BY |
| 99185 | 99697 | ** clause is not standard SQL. This is a (goofy) SQLite extension, that |
| 99186 | 99698 | ** is supported for backwards compatibility only. Hence, we issue a warning |
| 99187 | 99699 | ** on sqlite3_log() whenever the capability is used. |
| 99188 | 99700 | */ |
| 99189 | | - if( (pNC->ncFlags & NC_UEList)!=0 |
| 99190 | | - && cnt==0 |
| 99701 | + if( cnt==0 |
| 99702 | + && (pNC->ncFlags & NC_UEList)!=0 |
| 99191 | 99703 | && zTab==0 |
| 99192 | 99704 | ){ |
| 99193 | 99705 | pEList = pNC->uNC.pEList; |
| 99194 | 99706 | assert( pEList!=0 ); |
| 99195 | 99707 | for(j=0; j<pEList->nExpr; j++){ |
| | @@ -99293,11 +99805,11 @@ |
| 99293 | 99805 | sqlite3ErrorMsg(pParse, "%s: %s.%s", zErr, zTab, zCol); |
| 99294 | 99806 | }else{ |
| 99295 | 99807 | sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol); |
| 99296 | 99808 | } |
| 99297 | 99809 | pParse->checkSchema = 1; |
| 99298 | | - pTopNC->nErr++; |
| 99810 | + pTopNC->nNcErr++; |
| 99299 | 99811 | } |
| 99300 | 99812 | |
| 99301 | 99813 | /* If a column from a table in pSrcList is referenced, then record |
| 99302 | 99814 | ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes |
| 99303 | 99815 | ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is |
| | @@ -99600,11 +100112,11 @@ |
| 99600 | 100112 | pExpr->iTable = exprProbability(pList->a[1].pExpr); |
| 99601 | 100113 | if( pExpr->iTable<0 ){ |
| 99602 | 100114 | sqlite3ErrorMsg(pParse, |
| 99603 | 100115 | "second argument to likelihood() must be a " |
| 99604 | 100116 | "constant between 0.0 and 1.0"); |
| 99605 | | - pNC->nErr++; |
| 100117 | + pNC->nNcErr++; |
| 99606 | 100118 | } |
| 99607 | 100119 | }else{ |
| 99608 | 100120 | /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is |
| 99609 | 100121 | ** equivalent to likelihood(X, 0.0625). |
| 99610 | 100122 | ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is |
| | @@ -99622,11 +100134,11 @@ |
| 99622 | 100134 | int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0); |
| 99623 | 100135 | if( auth!=SQLITE_OK ){ |
| 99624 | 100136 | if( auth==SQLITE_DENY ){ |
| 99625 | 100137 | sqlite3ErrorMsg(pParse, "not authorized to use function: %s", |
| 99626 | 100138 | pDef->zName); |
| 99627 | | - pNC->nErr++; |
| 100139 | + pNC->nNcErr++; |
| 99628 | 100140 | } |
| 99629 | 100141 | pExpr->op = TK_NULL; |
| 99630 | 100142 | return WRC_Prune; |
| 99631 | 100143 | } |
| 99632 | 100144 | } |
| | @@ -99678,11 +100190,11 @@ |
| 99678 | 100190 | ); |
| 99679 | 100191 | if( pDef && pDef->xValue==0 && pWin ){ |
| 99680 | 100192 | sqlite3ErrorMsg(pParse, |
| 99681 | 100193 | "%.*s() may not be used as a window function", nId, zId |
| 99682 | 100194 | ); |
| 99683 | | - pNC->nErr++; |
| 100195 | + pNC->nNcErr++; |
| 99684 | 100196 | }else if( |
| 99685 | 100197 | (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) |
| 99686 | 100198 | || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pWin) |
| 99687 | 100199 | || (is_agg && pWin && (pNC->ncFlags & NC_AllowWin)==0) |
| 99688 | 100200 | ){ |
| | @@ -99691,39 +100203,39 @@ |
| 99691 | 100203 | zType = "window"; |
| 99692 | 100204 | }else{ |
| 99693 | 100205 | zType = "aggregate"; |
| 99694 | 100206 | } |
| 99695 | 100207 | sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId); |
| 99696 | | - pNC->nErr++; |
| 100208 | + pNC->nNcErr++; |
| 99697 | 100209 | is_agg = 0; |
| 99698 | 100210 | } |
| 99699 | 100211 | #else |
| 99700 | 100212 | if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){ |
| 99701 | 100213 | sqlite3ErrorMsg(pParse,"misuse of aggregate function %.*s()",nId,zId); |
| 99702 | | - pNC->nErr++; |
| 100214 | + pNC->nNcErr++; |
| 99703 | 100215 | is_agg = 0; |
| 99704 | 100216 | } |
| 99705 | 100217 | #endif |
| 99706 | 100218 | else if( no_such_func && pParse->db->init.busy==0 |
| 99707 | 100219 | #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 99708 | 100220 | && pParse->explain==0 |
| 99709 | 100221 | #endif |
| 99710 | 100222 | ){ |
| 99711 | 100223 | sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId); |
| 99712 | | - pNC->nErr++; |
| 100224 | + pNC->nNcErr++; |
| 99713 | 100225 | }else if( wrong_num_args ){ |
| 99714 | 100226 | sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()", |
| 99715 | 100227 | nId, zId); |
| 99716 | | - pNC->nErr++; |
| 100228 | + pNC->nNcErr++; |
| 99717 | 100229 | } |
| 99718 | 100230 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 99719 | 100231 | else if( is_agg==0 && ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 99720 | 100232 | sqlite3ErrorMsg(pParse, |
| 99721 | 100233 | "FILTER may not be used with non-aggregate %.*s()", |
| 99722 | 100234 | nId, zId |
| 99723 | 100235 | ); |
| 99724 | | - pNC->nErr++; |
| 100236 | + pNC->nNcErr++; |
| 99725 | 100237 | } |
| 99726 | 100238 | #endif |
| 99727 | 100239 | if( is_agg ){ |
| 99728 | 100240 | /* Window functions may not be arguments of aggregate functions. |
| 99729 | 100241 | ** Or arguments of other window functions. But aggregate functions |
| | @@ -99943,15 +100455,15 @@ |
| 99943 | 100455 | */ |
| 99944 | 100456 | memset(&nc, 0, sizeof(nc)); |
| 99945 | 100457 | nc.pParse = pParse; |
| 99946 | 100458 | nc.pSrcList = pSelect->pSrc; |
| 99947 | 100459 | nc.uNC.pEList = pEList; |
| 99948 | | - nc.ncFlags = NC_AllowAgg|NC_UEList; |
| 99949 | | - nc.nErr = 0; |
| 100460 | + nc.ncFlags = NC_AllowAgg|NC_UEList|NC_NoSelect; |
| 100461 | + nc.nNcErr = 0; |
| 99950 | 100462 | db = pParse->db; |
| 99951 | 100463 | savedSuppErr = db->suppressErr; |
| 99952 | | - if( IN_RENAME_OBJECT==0 ) db->suppressErr = 1; |
| 100464 | + db->suppressErr = 1; |
| 99953 | 100465 | rc = sqlite3ResolveExprNames(&nc, pE); |
| 99954 | 100466 | db->suppressErr = savedSuppErr; |
| 99955 | 100467 | if( rc ) return 0; |
| 99956 | 100468 | |
| 99957 | 100469 | /* Try to match the ORDER BY expression against an expression |
| | @@ -100046,33 +100558,28 @@ |
| 100046 | 100558 | ** expression, resolving any symbols in it, and then comparing |
| 100047 | 100559 | ** it against each expression returned by the SELECT statement. |
| 100048 | 100560 | ** Once the comparisons are finished, the duplicate expression |
| 100049 | 100561 | ** is deleted. |
| 100050 | 100562 | ** |
| 100051 | | - ** Or, if this is running as part of an ALTER TABLE operation, |
| 100052 | | - ** resolve the symbols in the actual expression, not a duplicate. |
| 100053 | | - ** And, if one of the comparisons is successful, leave the expression |
| 100054 | | - ** as is instead of transforming it to an integer as in the usual |
| 100055 | | - ** case. This allows the code in alter.c to modify column |
| 100056 | | - ** refererences within the ORDER BY expression as required. */ |
| 100057 | | - if( IN_RENAME_OBJECT ){ |
| 100058 | | - pDup = pE; |
| 100059 | | - }else{ |
| 100060 | | - pDup = sqlite3ExprDup(db, pE, 0); |
| 100061 | | - } |
| 100563 | + ** If this is running as part of an ALTER TABLE operation and |
| 100564 | + ** the symbols resolve successfully, also resolve the symbols in the |
| 100565 | + ** actual expression. This allows the code in alter.c to modify |
| 100566 | + ** column references within the ORDER BY expression as required. */ |
| 100567 | + pDup = sqlite3ExprDup(db, pE, 0); |
| 100062 | 100568 | if( !db->mallocFailed ){ |
| 100063 | 100569 | assert(pDup); |
| 100064 | 100570 | iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup); |
| 100571 | + if( IN_RENAME_OBJECT && iCol>0 ){ |
| 100572 | + resolveOrderByTermToExprList(pParse, pSelect, pE); |
| 100573 | + } |
| 100065 | 100574 | } |
| 100066 | | - if( !IN_RENAME_OBJECT ){ |
| 100067 | | - sqlite3ExprDelete(db, pDup); |
| 100068 | | - } |
| 100575 | + sqlite3ExprDelete(db, pDup); |
| 100069 | 100576 | } |
| 100070 | 100577 | } |
| 100071 | 100578 | if( iCol>0 ){ |
| 100072 | 100579 | /* Convert the ORDER BY term into an integer column number iCol, |
| 100073 | | - ** taking care to preserve the COLLATE clause if it exists */ |
| 100580 | + ** taking care to preserve the COLLATE clause if it exists. */ |
| 100074 | 100581 | if( !IN_RENAME_OBJECT ){ |
| 100075 | 100582 | Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0); |
| 100076 | 100583 | if( pNew==0 ) return 1; |
| 100077 | 100584 | pNew->flags |= EP_IntValue; |
| 100078 | 100585 | pNew->u.iValue = iCol; |
| | @@ -100203,11 +100710,11 @@ |
| 100203 | 100710 | int iCol; /* Column number */ |
| 100204 | 100711 | struct ExprList_item *pItem; /* A term of the ORDER BY clause */ |
| 100205 | 100712 | Parse *pParse; /* Parsing context */ |
| 100206 | 100713 | int nResult; /* Number of terms in the result set */ |
| 100207 | 100714 | |
| 100208 | | - if( pOrderBy==0 ) return 0; |
| 100715 | + assert( pOrderBy!=0 ); |
| 100209 | 100716 | nResult = pSelect->pEList->nExpr; |
| 100210 | 100717 | pParse = pNC->pParse; |
| 100211 | 100718 | for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){ |
| 100212 | 100719 | Expr *pE = pItem->pExpr; |
| 100213 | 100720 | Expr *pE2 = sqlite3ExprSkipCollateAndLikely(pE); |
| | @@ -100293,11 +100800,13 @@ |
| 100293 | 100800 | nCompound = 0; |
| 100294 | 100801 | pLeftmost = p; |
| 100295 | 100802 | while( p ){ |
| 100296 | 100803 | assert( (p->selFlags & SF_Expanded)!=0 ); |
| 100297 | 100804 | assert( (p->selFlags & SF_Resolved)==0 ); |
| 100805 | + assert( db->suppressErr==0 ); /* SF_Resolved not set if errors suppressed */ |
| 100298 | 100806 | p->selFlags |= SF_Resolved; |
| 100807 | + |
| 100299 | 100808 | |
| 100300 | 100809 | /* Resolve the expressions in the LIMIT and OFFSET clauses. These |
| 100301 | 100810 | ** are not allowed to refer to any names, so pass an empty NameContext. |
| 100302 | 100811 | */ |
| 100303 | 100812 | memset(&sNC, 0, sizeof(sNC)); |
| | @@ -100368,17 +100877,10 @@ |
| 100368 | 100877 | p->selFlags |= SF_Aggregate | (sNC.ncFlags&NC_MinMaxAgg); |
| 100369 | 100878 | }else{ |
| 100370 | 100879 | sNC.ncFlags &= ~NC_AllowAgg; |
| 100371 | 100880 | } |
| 100372 | 100881 | |
| 100373 | | - /* If a HAVING clause is present, then there must be a GROUP BY clause. |
| 100374 | | - */ |
| 100375 | | - if( p->pHaving && !pGroupBy ){ |
| 100376 | | - sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING"); |
| 100377 | | - return WRC_Abort; |
| 100378 | | - } |
| 100379 | | - |
| 100380 | 100882 | /* Add the output column list to the name-context before parsing the |
| 100381 | 100883 | ** other expressions in the SELECT statement. This is so that |
| 100382 | 100884 | ** expressions in the WHERE clause (etc.) can refer to expressions by |
| 100383 | 100885 | ** aliases in the result set. |
| 100384 | 100886 | ** |
| | @@ -100386,11 +100888,17 @@ |
| 100386 | 100888 | ** re-evaluated for each reference to it. |
| 100387 | 100889 | */ |
| 100388 | 100890 | assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert|NC_UBaseReg))==0 ); |
| 100389 | 100891 | sNC.uNC.pEList = p->pEList; |
| 100390 | 100892 | sNC.ncFlags |= NC_UEList; |
| 100391 | | - if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; |
| 100893 | + if( p->pHaving ){ |
| 100894 | + if( !pGroupBy ){ |
| 100895 | + sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING"); |
| 100896 | + return WRC_Abort; |
| 100897 | + } |
| 100898 | + if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; |
| 100899 | + } |
| 100392 | 100900 | if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort; |
| 100393 | 100901 | |
| 100394 | 100902 | /* Resolve names in table-valued-function arguments */ |
| 100395 | 100903 | for(i=0; i<p->pSrc->nSrc; i++){ |
| 100396 | 100904 | SrcItem *pItem = &p->pSrc->a[i]; |
| | @@ -100398,10 +100906,23 @@ |
| 100398 | 100906 | && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg) |
| 100399 | 100907 | ){ |
| 100400 | 100908 | return WRC_Abort; |
| 100401 | 100909 | } |
| 100402 | 100910 | } |
| 100911 | + |
| 100912 | +#ifndef SQLITE_OMIT_WINDOWFUNC |
| 100913 | + if( IN_RENAME_OBJECT ){ |
| 100914 | + Window *pWin; |
| 100915 | + for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){ |
| 100916 | + if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy) |
| 100917 | + || sqlite3ResolveExprListNames(&sNC, pWin->pPartition) |
| 100918 | + ){ |
| 100919 | + return WRC_Abort; |
| 100920 | + } |
| 100921 | + } |
| 100922 | + } |
| 100923 | +#endif |
| 100403 | 100924 | |
| 100404 | 100925 | /* The ORDER BY and GROUP BY clauses may not refer to terms in |
| 100405 | 100926 | ** outer queries |
| 100406 | 100927 | */ |
| 100407 | 100928 | sNC.pNext = 0; |
| | @@ -100426,11 +100947,12 @@ |
| 100426 | 100947 | ** If there is an ORDER BY clause on a term of a compound-select other |
| 100427 | 100948 | ** than the right-most term, then that is a syntax error. But the error |
| 100428 | 100949 | ** is not detected until much later, and so we need to go ahead and |
| 100429 | 100950 | ** resolve those symbols on the incorrect ORDER BY for consistency. |
| 100430 | 100951 | */ |
| 100431 | | - if( isCompound<=nCompound /* Defer right-most ORDER BY of a compound */ |
| 100952 | + if( p->pOrderBy!=0 |
| 100953 | + && isCompound<=nCompound /* Defer right-most ORDER BY of a compound */ |
| 100432 | 100954 | && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER") |
| 100433 | 100955 | ){ |
| 100434 | 100956 | return WRC_Abort; |
| 100435 | 100957 | } |
| 100436 | 100958 | if( db->mallocFailed ){ |
| | @@ -100454,23 +100976,10 @@ |
| 100454 | 100976 | return WRC_Abort; |
| 100455 | 100977 | } |
| 100456 | 100978 | } |
| 100457 | 100979 | } |
| 100458 | 100980 | |
| 100459 | | -#ifndef SQLITE_OMIT_WINDOWFUNC |
| 100460 | | - if( IN_RENAME_OBJECT ){ |
| 100461 | | - Window *pWin; |
| 100462 | | - for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){ |
| 100463 | | - if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy) |
| 100464 | | - || sqlite3ResolveExprListNames(&sNC, pWin->pPartition) |
| 100465 | | - ){ |
| 100466 | | - return WRC_Abort; |
| 100467 | | - } |
| 100468 | | - } |
| 100469 | | - } |
| 100470 | | -#endif |
| 100471 | | - |
| 100472 | 100981 | /* If this is part of a compound SELECT, check that it has the right |
| 100473 | 100982 | ** number of expressions in the select list. */ |
| 100474 | 100983 | if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){ |
| 100475 | 100984 | sqlite3SelectWrongNumTermsError(pParse, p->pNext); |
| 100476 | 100985 | return WRC_Abort; |
| | @@ -100550,11 +101059,11 @@ |
| 100550 | 101059 | if( pExpr==0 ) return SQLITE_OK; |
| 100551 | 101060 | savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin); |
| 100552 | 101061 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin); |
| 100553 | 101062 | w.pParse = pNC->pParse; |
| 100554 | 101063 | w.xExprCallback = resolveExprStep; |
| 100555 | | - w.xSelectCallback = resolveSelectStep; |
| 101064 | + w.xSelectCallback = (pNC->ncFlags & NC_NoSelect) ? 0 : resolveSelectStep; |
| 100556 | 101065 | w.xSelectCallback2 = 0; |
| 100557 | 101066 | w.u.pNC = pNC; |
| 100558 | 101067 | #if SQLITE_MAX_EXPR_DEPTH>0 |
| 100559 | 101068 | w.pParse->nHeight += pExpr->nHeight; |
| 100560 | 101069 | if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){ |
| | @@ -100569,11 +101078,11 @@ |
| 100569 | 101078 | assert( EP_Win==NC_HasWin ); |
| 100570 | 101079 | testcase( pNC->ncFlags & NC_HasAgg ); |
| 100571 | 101080 | testcase( pNC->ncFlags & NC_HasWin ); |
| 100572 | 101081 | ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) ); |
| 100573 | 101082 | pNC->ncFlags |= savedHasAgg; |
| 100574 | | - return pNC->nErr>0 || w.pParse->nErr>0; |
| 101083 | + return pNC->nNcErr>0 || w.pParse->nErr>0; |
| 100575 | 101084 | } |
| 100576 | 101085 | |
| 100577 | 101086 | /* |
| 100578 | 101087 | ** Resolve all names for all expression in an expression list. This is |
| 100579 | 101088 | ** just like sqlite3ResolveExprNames() except that it works for an expression |
| | @@ -100614,11 +101123,11 @@ |
| 100614 | 101123 | if( pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin) ){ |
| 100615 | 101124 | ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) ); |
| 100616 | 101125 | savedHasAgg |= pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin); |
| 100617 | 101126 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin); |
| 100618 | 101127 | } |
| 100619 | | - if( pNC->nErr>0 || w.pParse->nErr>0 ) return WRC_Abort; |
| 101128 | + if( w.pParse->nErr>0 ) return WRC_Abort; |
| 100620 | 101129 | } |
| 100621 | 101130 | pNC->ncFlags |= savedHasAgg; |
| 100622 | 101131 | return WRC_Continue; |
| 100623 | 101132 | } |
| 100624 | 101133 | |
| | @@ -100757,27 +101266,27 @@ |
| 100757 | 101266 | || (pExpr->op==TK_REGISTER && pExpr->op2==TK_IF_NULL_ROW) ); |
| 100758 | 101267 | pExpr = pExpr->pLeft; |
| 100759 | 101268 | assert( pExpr!=0 ); |
| 100760 | 101269 | } |
| 100761 | 101270 | op = pExpr->op; |
| 101271 | + if( op==TK_REGISTER ) op = pExpr->op2; |
| 101272 | + if( (op==TK_COLUMN || op==TK_AGG_COLUMN) && pExpr->y.pTab ){ |
| 101273 | + return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); |
| 101274 | + } |
| 100762 | 101275 | if( op==TK_SELECT ){ |
| 100763 | 101276 | assert( pExpr->flags&EP_xIsSelect ); |
| 100764 | 101277 | assert( pExpr->x.pSelect!=0 ); |
| 100765 | 101278 | assert( pExpr->x.pSelect->pEList!=0 ); |
| 100766 | 101279 | assert( pExpr->x.pSelect->pEList->a[0].pExpr!=0 ); |
| 100767 | 101280 | return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr); |
| 100768 | 101281 | } |
| 100769 | | - if( op==TK_REGISTER ) op = pExpr->op2; |
| 100770 | 101282 | #ifndef SQLITE_OMIT_CAST |
| 100771 | 101283 | if( op==TK_CAST ){ |
| 100772 | 101284 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 100773 | 101285 | return sqlite3AffinityType(pExpr->u.zToken, 0); |
| 100774 | 101286 | } |
| 100775 | 101287 | #endif |
| 100776 | | - if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->y.pTab ){ |
| 100777 | | - return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); |
| 100778 | | - } |
| 100779 | 101288 | if( op==TK_SELECT_COLUMN ){ |
| 100780 | 101289 | assert( pExpr->pLeft->flags&EP_xIsSelect ); |
| 100781 | 101290 | return sqlite3ExprAffinity( |
| 100782 | 101291 | pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr |
| 100783 | 101292 | ); |
| | @@ -100800,22 +101309,11 @@ |
| 100800 | 101309 | Parse *pParse, /* Parsing context */ |
| 100801 | 101310 | Expr *pExpr, /* Add the "COLLATE" clause to this expression */ |
| 100802 | 101311 | const Token *pCollName, /* Name of collating sequence */ |
| 100803 | 101312 | int dequote /* True to dequote pCollName */ |
| 100804 | 101313 | ){ |
| 100805 | | - assert( pExpr!=0 || pParse->db->mallocFailed ); |
| 100806 | | - if( pExpr==0 ) return 0; |
| 100807 | | - if( pExpr->op==TK_VECTOR ){ |
| 100808 | | - ExprList *pList = pExpr->x.pList; |
| 100809 | | - if( ALWAYS(pList!=0) ){ |
| 100810 | | - int i; |
| 100811 | | - for(i=0; i<pList->nExpr; i++){ |
| 100812 | | - pList->a[i].pExpr = sqlite3ExprAddCollateToken(pParse,pList->a[i].pExpr, |
| 100813 | | - pCollName, dequote); |
| 100814 | | - } |
| 100815 | | - } |
| 100816 | | - }else if( pCollName->n>0 ){ |
| 101314 | + if( pCollName->n>0 ){ |
| 100817 | 101315 | Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote); |
| 100818 | 101316 | if( pNew ){ |
| 100819 | 101317 | pNew->pLeft = pExpr; |
| 100820 | 101318 | pNew->flags |= EP_Collate|EP_Skip; |
| 100821 | 101319 | pExpr = pNew; |
| | @@ -101161,11 +101659,11 @@ |
| 101161 | 101659 | ** just the expression for the i-th term of the result set, and may |
| 101162 | 101660 | ** not be ready for evaluation because the table cursor has not yet |
| 101163 | 101661 | ** been positioned. |
| 101164 | 101662 | */ |
| 101165 | 101663 | SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){ |
| 101166 | | - assert( i<sqlite3ExprVectorSize(pVector) ); |
| 101664 | + assert( i<sqlite3ExprVectorSize(pVector) || pVector->op==TK_ERROR ); |
| 101167 | 101665 | if( sqlite3ExprIsVector(pVector) ){ |
| 101168 | 101666 | assert( pVector->op2==0 || pVector->op==TK_REGISTER ); |
| 101169 | 101667 | if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){ |
| 101170 | 101668 | return pVector->x.pSelect->pEList->a[i].pExpr; |
| 101171 | 101669 | }else{ |
| | @@ -101277,21 +101775,24 @@ |
| 101277 | 101775 | int regSelect, /* First in array of registers */ |
| 101278 | 101776 | Expr **ppExpr, /* OUT: Expression element */ |
| 101279 | 101777 | int *pRegFree /* OUT: Temp register to free */ |
| 101280 | 101778 | ){ |
| 101281 | 101779 | u8 op = pVector->op; |
| 101282 | | - assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT ); |
| 101780 | + assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT || op==TK_ERROR ); |
| 101283 | 101781 | if( op==TK_REGISTER ){ |
| 101284 | 101782 | *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField); |
| 101285 | 101783 | return pVector->iTable+iField; |
| 101286 | 101784 | } |
| 101287 | 101785 | if( op==TK_SELECT ){ |
| 101288 | 101786 | *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr; |
| 101289 | 101787 | return regSelect+iField; |
| 101290 | 101788 | } |
| 101291 | | - *ppExpr = pVector->x.pList->a[iField].pExpr; |
| 101292 | | - return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree); |
| 101789 | + if( op==TK_VECTOR ){ |
| 101790 | + *ppExpr = pVector->x.pList->a[iField].pExpr; |
| 101791 | + return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree); |
| 101792 | + } |
| 101793 | + return 0; |
| 101293 | 101794 | } |
| 101294 | 101795 | |
| 101295 | 101796 | /* |
| 101296 | 101797 | ** Expression pExpr is a comparison between two vector values. Compute |
| 101297 | 101798 | ** the result of the comparison (1, 0, or NULL) and write that |
| | @@ -101346,11 +101847,11 @@ |
| 101346 | 101847 | regRight = exprCodeSubselect(pParse, pRight); |
| 101347 | 101848 | |
| 101348 | 101849 | sqlite3VdbeAddOp2(v, OP_Integer, 1, dest); |
| 101349 | 101850 | for(i=0; 1 /*Loop exits by "break"*/; i++){ |
| 101350 | 101851 | int regFree1 = 0, regFree2 = 0; |
| 101351 | | - Expr *pL, *pR; |
| 101852 | + Expr *pL = 0, *pR = 0; |
| 101352 | 101853 | int r1, r2; |
| 101353 | 101854 | assert( i>=0 && i<nLeft ); |
| 101354 | 101855 | if( addrCmp ) sqlite3VdbeJumpHere(v, addrCmp); |
| 101355 | 101856 | r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, ®Free1); |
| 101356 | 101857 | r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, ®Free2); |
| | @@ -102029,10 +102530,11 @@ |
| 102029 | 102530 | |
| 102030 | 102531 | /* Figure out where to write the new Expr structure. */ |
| 102031 | 102532 | if( pzBuffer ){ |
| 102032 | 102533 | zAlloc = *pzBuffer; |
| 102033 | 102534 | staticFlag = EP_Static; |
| 102535 | + assert( zAlloc!=0 ); |
| 102034 | 102536 | }else{ |
| 102035 | 102537 | zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags)); |
| 102036 | 102538 | staticFlag = 0; |
| 102037 | 102539 | } |
| 102038 | 102540 | pNew = (Expr *)zAlloc; |
| | @@ -102107,11 +102609,12 @@ |
| 102107 | 102609 | }else{ |
| 102108 | 102610 | if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){ |
| 102109 | 102611 | if( pNew->op==TK_SELECT_COLUMN ){ |
| 102110 | 102612 | pNew->pLeft = p->pLeft; |
| 102111 | 102613 | assert( p->iColumn==0 || p->pRight==0 ); |
| 102112 | | - assert( p->pRight==0 || p->pRight==p->pLeft ); |
| 102614 | + assert( p->pRight==0 || p->pRight==p->pLeft |
| 102615 | + || ExprHasProperty(p->pLeft, EP_Subquery) ); |
| 102113 | 102616 | }else{ |
| 102114 | 102617 | pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); |
| 102115 | 102618 | } |
| 102116 | 102619 | pNew->pRight = sqlite3ExprDup(db, p->pRight, 0); |
| 102117 | 102620 | } |
| | @@ -102124,11 +102627,11 @@ |
| 102124 | 102627 | ** Create and return a deep copy of the object passed as the second |
| 102125 | 102628 | ** argument. If an OOM condition is encountered, NULL is returned |
| 102126 | 102629 | ** and the db->mallocFailed flag set. |
| 102127 | 102630 | */ |
| 102128 | 102631 | #ifndef SQLITE_OMIT_CTE |
| 102129 | | -static With *withDup(sqlite3 *db, With *p){ |
| 102632 | +SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p){ |
| 102130 | 102633 | With *pRet = 0; |
| 102131 | 102634 | if( p ){ |
| 102132 | 102635 | sqlite3_int64 nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1); |
| 102133 | 102636 | pRet = sqlite3DbMallocZero(db, nByte); |
| 102134 | 102637 | if( pRet ){ |
| | @@ -102142,11 +102645,11 @@ |
| 102142 | 102645 | } |
| 102143 | 102646 | } |
| 102144 | 102647 | return pRet; |
| 102145 | 102648 | } |
| 102146 | 102649 | #else |
| 102147 | | -# define withDup(x,y) 0 |
| 102650 | +# define sqlite3WithDup(x,y) 0 |
| 102148 | 102651 | #endif |
| 102149 | 102652 | |
| 102150 | 102653 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 102151 | 102654 | /* |
| 102152 | 102655 | ** The gatherSelectWindows() procedure and its helper routine |
| | @@ -102222,11 +102725,12 @@ |
| 102222 | 102725 | && pOldExpr->op==TK_SELECT_COLUMN |
| 102223 | 102726 | && (pNewExpr = pItem->pExpr)!=0 |
| 102224 | 102727 | ){ |
| 102225 | 102728 | assert( pNewExpr->iColumn==0 || i>0 ); |
| 102226 | 102729 | if( pNewExpr->iColumn==0 ){ |
| 102227 | | - assert( pOldExpr->pLeft==pOldExpr->pRight ); |
| 102730 | + assert( pOldExpr->pLeft==pOldExpr->pRight |
| 102731 | + || ExprHasProperty(pOldExpr->pLeft, EP_Subquery) ); |
| 102228 | 102732 | pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight; |
| 102229 | 102733 | }else{ |
| 102230 | 102734 | assert( i>0 ); |
| 102231 | 102735 | assert( pItem[-1].pExpr!=0 ); |
| 102232 | 102736 | assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 ); |
| | @@ -102345,17 +102849,25 @@ |
| 102345 | 102849 | pNew->iOffset = 0; |
| 102346 | 102850 | pNew->selFlags = p->selFlags & ~SF_UsesEphemeral; |
| 102347 | 102851 | pNew->addrOpenEphm[0] = -1; |
| 102348 | 102852 | pNew->addrOpenEphm[1] = -1; |
| 102349 | 102853 | pNew->nSelectRow = p->nSelectRow; |
| 102350 | | - pNew->pWith = withDup(db, p->pWith); |
| 102854 | + pNew->pWith = sqlite3WithDup(db, p->pWith); |
| 102351 | 102855 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 102352 | 102856 | pNew->pWin = 0; |
| 102353 | 102857 | pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn); |
| 102354 | 102858 | if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew); |
| 102355 | 102859 | #endif |
| 102356 | 102860 | pNew->selId = p->selId; |
| 102861 | + if( db->mallocFailed ){ |
| 102862 | + /* Any prior OOM might have left the Select object incomplete. |
| 102863 | + ** Delete the whole thing rather than allow an incomplete Select |
| 102864 | + ** to be used by the code generator. */ |
| 102865 | + pNew->pNext = 0; |
| 102866 | + sqlite3SelectDelete(db, pNew); |
| 102867 | + break; |
| 102868 | + } |
| 102357 | 102869 | *pp = pNew; |
| 102358 | 102870 | pp = &pNew->pPrior; |
| 102359 | 102871 | pNext = pNew; |
| 102360 | 102872 | } |
| 102361 | 102873 | |
| | @@ -103052,12 +103564,14 @@ |
| 103052 | 103564 | ** will likely result in an incorrect answer. So when in doubt, return |
| 103053 | 103565 | ** TRUE. |
| 103054 | 103566 | */ |
| 103055 | 103567 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){ |
| 103056 | 103568 | u8 op; |
| 103569 | + assert( p!=0 ); |
| 103057 | 103570 | while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ |
| 103058 | 103571 | p = p->pLeft; |
| 103572 | + assert( p!=0 ); |
| 103059 | 103573 | } |
| 103060 | 103574 | op = p->op; |
| 103061 | 103575 | if( op==TK_REGISTER ) op = p->op2; |
| 103062 | 103576 | switch( op ){ |
| 103063 | 103577 | case TK_INTEGER: |
| | @@ -103685,23 +104199,27 @@ |
| 103685 | 104199 | addrOnce?"":"CORRELATED ", pSelect->selId |
| 103686 | 104200 | )); |
| 103687 | 104201 | /* If the LHS and RHS of the IN operator do not match, that |
| 103688 | 104202 | ** error will have been caught long before we reach this point. */ |
| 103689 | 104203 | if( ALWAYS(pEList->nExpr==nVal) ){ |
| 104204 | + Select *pCopy; |
| 103690 | 104205 | SelectDest dest; |
| 103691 | 104206 | int i; |
| 104207 | + int rc; |
| 103692 | 104208 | sqlite3SelectDestInit(&dest, SRT_Set, iTab); |
| 103693 | 104209 | dest.zAffSdst = exprINAffinity(pParse, pExpr); |
| 103694 | 104210 | pSelect->iLimit = 0; |
| 103695 | 104211 | testcase( pSelect->selFlags & SF_Distinct ); |
| 103696 | 104212 | testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */ |
| 103697 | | - if( sqlite3Select(pParse, pSelect, &dest) ){ |
| 103698 | | - sqlite3DbFree(pParse->db, dest.zAffSdst); |
| 104213 | + pCopy = sqlite3SelectDup(pParse->db, pSelect, 0); |
| 104214 | + rc = pParse->db->mallocFailed ? 1 :sqlite3Select(pParse, pCopy, &dest); |
| 104215 | + sqlite3SelectDelete(pParse->db, pCopy); |
| 104216 | + sqlite3DbFree(pParse->db, dest.zAffSdst); |
| 104217 | + if( rc ){ |
| 103699 | 104218 | sqlite3KeyInfoUnref(pKeyInfo); |
| 103700 | 104219 | return; |
| 103701 | 104220 | } |
| 103702 | | - sqlite3DbFree(pParse->db, dest.zAffSdst); |
| 103703 | 104221 | assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */ |
| 103704 | 104222 | assert( pEList!=0 ); |
| 103705 | 104223 | assert( pEList->nExpr>0 ); |
| 103706 | 104224 | assert( sqlite3KeyInfoIsWriteable(pKeyInfo) ); |
| 103707 | 104225 | for(i=0; i<nVal; i++){ |
| | @@ -103796,15 +104314,33 @@ |
| 103796 | 104314 | int nReg; /* Registers to allocate */ |
| 103797 | 104315 | Expr *pLimit; /* New limit expression */ |
| 103798 | 104316 | |
| 103799 | 104317 | Vdbe *v = pParse->pVdbe; |
| 103800 | 104318 | assert( v!=0 ); |
| 104319 | + if( pParse->nErr ) return 0; |
| 103801 | 104320 | testcase( pExpr->op==TK_EXISTS ); |
| 103802 | 104321 | testcase( pExpr->op==TK_SELECT ); |
| 103803 | 104322 | assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT ); |
| 103804 | 104323 | assert( ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 103805 | 104324 | pSel = pExpr->x.pSelect; |
| 104325 | + |
| 104326 | + /* If this routine has already been coded, then invoke it as a |
| 104327 | + ** subroutine. */ |
| 104328 | + if( ExprHasProperty(pExpr, EP_Subrtn) ){ |
| 104329 | + ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId)); |
| 104330 | + sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn, |
| 104331 | + pExpr->y.sub.iAddr); |
| 104332 | + return pExpr->iTable; |
| 104333 | + } |
| 104334 | + |
| 104335 | + /* Begin coding the subroutine */ |
| 104336 | + ExprSetProperty(pExpr, EP_Subrtn); |
| 104337 | + pExpr->y.sub.regReturn = ++pParse->nMem; |
| 104338 | + pExpr->y.sub.iAddr = |
| 104339 | + sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1; |
| 104340 | + VdbeComment((v, "return address")); |
| 104341 | + |
| 103806 | 104342 | |
| 103807 | 104343 | /* The evaluation of the EXISTS/SELECT must be repeated every time it |
| 103808 | 104344 | ** is encountered if any of the following is true: |
| 103809 | 104345 | ** |
| 103810 | 104346 | ** * The right-hand side is a correlated subquery |
| | @@ -103813,26 +104349,10 @@ |
| 103813 | 104349 | ** |
| 103814 | 104350 | ** If all of the above are false, then we can run this code just once |
| 103815 | 104351 | ** save the results, and reuse the same result on subsequent invocations. |
| 103816 | 104352 | */ |
| 103817 | 104353 | if( !ExprHasProperty(pExpr, EP_VarSelect) ){ |
| 103818 | | - /* If this routine has already been coded, then invoke it as a |
| 103819 | | - ** subroutine. */ |
| 103820 | | - if( ExprHasProperty(pExpr, EP_Subrtn) ){ |
| 103821 | | - ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId)); |
| 103822 | | - sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn, |
| 103823 | | - pExpr->y.sub.iAddr); |
| 103824 | | - return pExpr->iTable; |
| 103825 | | - } |
| 103826 | | - |
| 103827 | | - /* Begin coding the subroutine */ |
| 103828 | | - ExprSetProperty(pExpr, EP_Subrtn); |
| 103829 | | - pExpr->y.sub.regReturn = ++pParse->nMem; |
| 103830 | | - pExpr->y.sub.iAddr = |
| 103831 | | - sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1; |
| 103832 | | - VdbeComment((v, "return address")); |
| 103833 | | - |
| 103834 | 104354 | addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); |
| 103835 | 104355 | } |
| 103836 | 104356 | |
| 103837 | 104357 | /* For a SELECT, generate code to put the values for all columns of |
| 103838 | 104358 | ** the first row into an array of registers and return the index of |
| | @@ -103877,23 +104397,26 @@ |
| 103877 | 104397 | pLimit = sqlite3Expr(pParse->db, TK_INTEGER, "1"); |
| 103878 | 104398 | pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0); |
| 103879 | 104399 | } |
| 103880 | 104400 | pSel->iLimit = 0; |
| 103881 | 104401 | if( sqlite3Select(pParse, pSel, &dest) ){ |
| 104402 | + if( pParse->nErr ){ |
| 104403 | + pExpr->op2 = pExpr->op; |
| 104404 | + pExpr->op = TK_ERROR; |
| 104405 | + } |
| 103882 | 104406 | return 0; |
| 103883 | 104407 | } |
| 103884 | 104408 | pExpr->iTable = rReg = dest.iSDParm; |
| 103885 | 104409 | ExprSetVVAProperty(pExpr, EP_NoReduce); |
| 103886 | 104410 | if( addrOnce ){ |
| 103887 | 104411 | sqlite3VdbeJumpHere(v, addrOnce); |
| 103888 | | - |
| 103889 | | - /* Subroutine return */ |
| 103890 | | - sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn); |
| 103891 | | - sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1); |
| 103892 | | - sqlite3ClearTempRegCache(pParse); |
| 103893 | 104412 | } |
| 103894 | 104413 | |
| 104414 | + /* Subroutine return */ |
| 104415 | + sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn); |
| 104416 | + sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1); |
| 104417 | + sqlite3ClearTempRegCache(pParse); |
| 103895 | 104418 | return rReg; |
| 103896 | 104419 | } |
| 103897 | 104420 | #endif /* SQLITE_OMIT_SUBQUERY */ |
| 103898 | 104421 | |
| 103899 | 104422 | #ifndef SQLITE_OMIT_SUBQUERY |
| | @@ -103903,11 +104426,11 @@ |
| 103903 | 104426 | ** columns as the vector on the LHS. Or, if the RHS of the IN() is not |
| 103904 | 104427 | ** a sub-query, that the LHS is a vector of size 1. |
| 103905 | 104428 | */ |
| 103906 | 104429 | SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){ |
| 103907 | 104430 | int nVector = sqlite3ExprVectorSize(pIn->pLeft); |
| 103908 | | - if( (pIn->flags & EP_xIsSelect) ){ |
| 104431 | + if( (pIn->flags & EP_xIsSelect)!=0 && !pParse->db->mallocFailed ){ |
| 103909 | 104432 | if( nVector!=pIn->x.pSelect->pEList->nExpr ){ |
| 103910 | 104433 | sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector); |
| 103911 | 104434 | return 1; |
| 103912 | 104435 | } |
| 103913 | 104436 | }else if( nVector!=1 ){ |
| | @@ -104720,11 +105243,11 @@ |
| 104720 | 105243 | default: { |
| 104721 | 105244 | /* Make NULL the default case so that if a bug causes an illegal |
| 104722 | 105245 | ** Expr node to be passed into this function, it will be handled |
| 104723 | 105246 | ** sanely and not crash. But keep the assert() to bring the problem |
| 104724 | 105247 | ** to the attention of the developers. */ |
| 104725 | | - assert( op==TK_NULL ); |
| 105248 | + assert( op==TK_NULL || op==TK_ERROR || pParse->db->mallocFailed ); |
| 104726 | 105249 | sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| 104727 | 105250 | return target; |
| 104728 | 105251 | } |
| 104729 | 105252 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
| 104730 | 105253 | case TK_BLOB: { |
| | @@ -105063,11 +105586,12 @@ |
| 105063 | 105586 | case TK_SELECT_COLUMN: { |
| 105064 | 105587 | int n; |
| 105065 | 105588 | if( pExpr->pLeft->iTable==0 ){ |
| 105066 | 105589 | pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft); |
| 105067 | 105590 | } |
| 105068 | | - assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT ); |
| 105591 | + assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT |
| 105592 | + || pExpr->pLeft->op==TK_ERROR ); |
| 105069 | 105593 | if( pExpr->iTable!=0 |
| 105070 | 105594 | && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft)) |
| 105071 | 105595 | ){ |
| 105072 | 105596 | sqlite3ErrorMsg(pParse, "%d columns assigned %d values", |
| 105073 | 105597 | pExpr->iTable, n); |
| | @@ -106695,10 +107219,11 @@ |
| 106695 | 107219 | /* Check to see if pExpr is a duplicate of another aggregate |
| 106696 | 107220 | ** function that is already in the pAggInfo structure |
| 106697 | 107221 | */ |
| 106698 | 107222 | struct AggInfo_func *pItem = pAggInfo->aFunc; |
| 106699 | 107223 | for(i=0; i<pAggInfo->nFunc; i++, pItem++){ |
| 107224 | + if( pItem->pFExpr==pExpr ) break; |
| 106700 | 107225 | if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){ |
| 106701 | 107226 | break; |
| 106702 | 107227 | } |
| 106703 | 107228 | } |
| 106704 | 107229 | if( i>=pAggInfo->nFunc ){ |
| | @@ -106895,10 +107420,11 @@ |
| 106895 | 107420 | ** Or, if zName is not a system table, zero is returned. |
| 106896 | 107421 | */ |
| 106897 | 107422 | static int isAlterableTable(Parse *pParse, Table *pTab){ |
| 106898 | 107423 | if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) |
| 106899 | 107424 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 107425 | + || (pTab->tabFlags & TF_Eponymous)!=0 |
| 106900 | 107426 | || ( (pTab->tabFlags & TF_Shadow)!=0 |
| 106901 | 107427 | && sqlite3ReadOnlyShadowTables(pParse->db) |
| 106902 | 107428 | ) |
| 106903 | 107429 | #endif |
| 106904 | 107430 | ){ |
| | @@ -107663,19 +108189,34 @@ |
| 107663 | 108189 | ** to select statement pSelect. |
| 107664 | 108190 | */ |
| 107665 | 108191 | static void renameWalkWith(Walker *pWalker, Select *pSelect){ |
| 107666 | 108192 | With *pWith = pSelect->pWith; |
| 107667 | 108193 | if( pWith ){ |
| 108194 | + Parse *pParse = pWalker->pParse; |
| 107668 | 108195 | int i; |
| 108196 | + With *pCopy = 0; |
| 108197 | + assert( pWith->nCte>0 ); |
| 108198 | + if( (pWith->a[0].pSelect->selFlags & SF_Expanded)==0 ){ |
| 108199 | + /* Push a copy of the With object onto the with-stack. We use a copy |
| 108200 | + ** here as the original will be expanded and resolved (flags SF_Expanded |
| 108201 | + ** and SF_Resolved) below. And the parser code that uses the with-stack |
| 108202 | + ** fails if the Select objects on it have already been expanded and |
| 108203 | + ** resolved. */ |
| 108204 | + pCopy = sqlite3WithDup(pParse->db, pWith); |
| 108205 | + pCopy = sqlite3WithPush(pParse, pCopy, 1); |
| 108206 | + } |
| 107669 | 108207 | for(i=0; i<pWith->nCte; i++){ |
| 107670 | 108208 | Select *p = pWith->a[i].pSelect; |
| 107671 | 108209 | NameContext sNC; |
| 107672 | 108210 | memset(&sNC, 0, sizeof(sNC)); |
| 107673 | | - sNC.pParse = pWalker->pParse; |
| 107674 | | - sqlite3SelectPrep(sNC.pParse, p, &sNC); |
| 108211 | + sNC.pParse = pParse; |
| 108212 | + if( pCopy ) sqlite3SelectPrep(sNC.pParse, p, &sNC); |
| 107675 | 108213 | sqlite3WalkSelect(pWalker, p); |
| 107676 | | - sqlite3RenameExprlistUnmap(pWalker->pParse, pWith->a[i].pCols); |
| 108214 | + sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols); |
| 108215 | + } |
| 108216 | + if( pCopy && pParse->pWith==pCopy ){ |
| 108217 | + pParse->pWith = pCopy->pOuter; |
| 107677 | 108218 | } |
| 107678 | 108219 | } |
| 107679 | 108220 | } |
| 107680 | 108221 | |
| 107681 | 108222 | /* |
| | @@ -107698,11 +108239,15 @@ |
| 107698 | 108239 | */ |
| 107699 | 108240 | static int renameUnmapSelectCb(Walker *pWalker, Select *p){ |
| 107700 | 108241 | Parse *pParse = pWalker->pParse; |
| 107701 | 108242 | int i; |
| 107702 | 108243 | if( pParse->nErr ) return WRC_Abort; |
| 107703 | | - if( NEVER(p->selFlags & SF_View) ) return WRC_Prune; |
| 108244 | + if( p->selFlags & (SF_View|SF_CopyCte) ){ |
| 108245 | + testcase( pSelect->selFlags & SF_View ); |
| 108246 | + testcase( pSelect->selFlags & SF_CopyCte ); |
| 108247 | + return WRC_Prune; |
| 108248 | + } |
| 107704 | 108249 | if( ALWAYS(p->pEList) ){ |
| 107705 | 108250 | ExprList *pList = p->pEList; |
| 107706 | 108251 | for(i=0; i<pList->nExpr; i++){ |
| 107707 | 108252 | if( pList->a[i].zEName && pList->a[i].eEName==ENAME_NAME ){ |
| 107708 | 108253 | sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zEName); |
| | @@ -107782,11 +108327,13 @@ |
| 107782 | 108327 | Parse *pParse, |
| 107783 | 108328 | struct RenameCtx *pCtx, |
| 107784 | 108329 | void *pPtr |
| 107785 | 108330 | ){ |
| 107786 | 108331 | RenameToken **pp; |
| 107787 | | - assert( pPtr!=0 ); |
| 108332 | + if( NEVER(pPtr==0) ){ |
| 108333 | + return 0; |
| 108334 | + } |
| 107788 | 108335 | for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){ |
| 107789 | 108336 | if( (*pp)->p==pPtr ){ |
| 107790 | 108337 | RenameToken *pToken = *pp; |
| 107791 | 108338 | if( pCtx ){ |
| 107792 | 108339 | *pp = pToken->pNext; |
| | @@ -107804,11 +108351,15 @@ |
| 107804 | 108351 | ** This is a Walker select callback. It does nothing. It is only required |
| 107805 | 108352 | ** because without a dummy callback, sqlite3WalkExpr() and similar do not |
| 107806 | 108353 | ** descend into sub-select statements. |
| 107807 | 108354 | */ |
| 107808 | 108355 | static int renameColumnSelectCb(Walker *pWalker, Select *p){ |
| 107809 | | - if( p->selFlags & SF_View ) return WRC_Prune; |
| 108356 | + if( p->selFlags & (SF_View|SF_CopyCte) ){ |
| 108357 | + testcase( pSelect->selFlags & SF_View ); |
| 108358 | + testcase( pSelect->selFlags & SF_CopyCte ); |
| 108359 | + return WRC_Prune; |
| 108360 | + } |
| 107810 | 108361 | renameWalkWith(pWalker, p); |
| 107811 | 108362 | return WRC_Continue; |
| 107812 | 108363 | } |
| 107813 | 108364 | |
| 107814 | 108365 | /* |
| | @@ -108334,13 +108885,15 @@ |
| 108334 | 108885 | int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName); |
| 108335 | 108886 | FKey *pFKey; |
| 108336 | 108887 | assert( sParse.pNewTable->pSelect==0 ); |
| 108337 | 108888 | sCtx.pTab = sParse.pNewTable; |
| 108338 | 108889 | if( bFKOnly==0 ){ |
| 108339 | | - renameTokenFind( |
| 108340 | | - &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName |
| 108341 | | - ); |
| 108890 | + if( iCol<sParse.pNewTable->nCol ){ |
| 108891 | + renameTokenFind( |
| 108892 | + &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName |
| 108893 | + ); |
| 108894 | + } |
| 108342 | 108895 | if( sCtx.iCol<0 ){ |
| 108343 | 108896 | renameTokenFind(&sParse, &sCtx, (void*)&sParse.pNewTable->iPKey); |
| 108344 | 108897 | } |
| 108345 | 108898 | sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck); |
| 108346 | 108899 | for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){ |
| | @@ -108438,12 +108991,16 @@ |
| 108438 | 108991 | */ |
| 108439 | 108992 | static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ |
| 108440 | 108993 | int i; |
| 108441 | 108994 | RenameCtx *p = pWalker->u.pRename; |
| 108442 | 108995 | SrcList *pSrc = pSelect->pSrc; |
| 108443 | | - if( pSelect->selFlags & SF_View ) return WRC_Prune; |
| 108444 | | - if( pSrc==0 ){ |
| 108996 | + if( pSelect->selFlags & (SF_View|SF_CopyCte) ){ |
| 108997 | + testcase( pSelect->selFlags & SF_View ); |
| 108998 | + testcase( pSelect->selFlags & SF_CopyCte ); |
| 108999 | + return WRC_Prune; |
| 109000 | + } |
| 109001 | + if( NEVER(pSrc==0) ){ |
| 108445 | 109002 | assert( pWalker->pParse->db->mallocFailed ); |
| 108446 | 109003 | return WRC_Abort; |
| 108447 | 109004 | } |
| 108448 | 109005 | for(i=0; i<pSrc->nSrc; i++){ |
| 108449 | 109006 | SrcItem *pItem = &pSrc->a[i]; |
| | @@ -108983,20 +109540,25 @@ |
| 108983 | 109540 | if( iPos<pPk->nKeyCol ) continue; |
| 108984 | 109541 | regOut = reg+1+iPos-(iPos>iColPos); |
| 108985 | 109542 | }else{ |
| 108986 | 109543 | regOut = reg+1+nField; |
| 108987 | 109544 | } |
| 108988 | | - sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOut); |
| 109545 | + if( i==pTab->iPKey ){ |
| 109546 | + sqlite3VdbeAddOp2(v, OP_Null, 0, regOut); |
| 109547 | + }else{ |
| 109548 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOut); |
| 109549 | + } |
| 108989 | 109550 | nField++; |
| 108990 | 109551 | } |
| 108991 | 109552 | } |
| 108992 | 109553 | sqlite3VdbeAddOp3(v, OP_MakeRecord, reg+1, nField, regRec); |
| 108993 | 109554 | if( pPk ){ |
| 108994 | 109555 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iCur, regRec, reg+1, pPk->nKeyCol); |
| 108995 | 109556 | }else{ |
| 108996 | 109557 | sqlite3VdbeAddOp3(v, OP_Insert, iCur, regRec, reg); |
| 108997 | 109558 | } |
| 109559 | + sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION); |
| 108998 | 109560 | |
| 108999 | 109561 | sqlite3VdbeAddOp2(v, OP_Next, iCur, addr+1); VdbeCoverage(v); |
| 109000 | 109562 | sqlite3VdbeJumpHere(v, addr); |
| 109001 | 109563 | } |
| 109002 | 109564 | |
| | @@ -111063,11 +111625,11 @@ |
| 111063 | 111625 | zFile = (const char *)sqlite3_value_text(argv[0]); |
| 111064 | 111626 | zName = (const char *)sqlite3_value_text(argv[1]); |
| 111065 | 111627 | if( zFile==0 ) zFile = ""; |
| 111066 | 111628 | if( zName==0 ) zName = ""; |
| 111067 | 111629 | |
| 111068 | | -#ifdef SQLITE_ENABLE_DESERIALIZE |
| 111630 | +#ifndef SQLITE_OMIT_DESERIALIZE |
| 111069 | 111631 | # define REOPEN_AS_MEMDB(db) (db->init.reopenMemdb) |
| 111070 | 111632 | #else |
| 111071 | 111633 | # define REOPEN_AS_MEMDB(db) (0) |
| 111072 | 111634 | #endif |
| 111073 | 111635 | |
| | @@ -111432,18 +111994,21 @@ |
| 111432 | 111994 | SrcList *pList = pSelect->pSrc; |
| 111433 | 111995 | |
| 111434 | 111996 | if( NEVER(pList==0) ) return WRC_Continue; |
| 111435 | 111997 | for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ |
| 111436 | 111998 | if( pFix->bTemp==0 ){ |
| 111437 | | - if( pItem->zDatabase && iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){ |
| 111438 | | - sqlite3ErrorMsg(pFix->pParse, |
| 111439 | | - "%s %T cannot reference objects in database %s", |
| 111440 | | - pFix->zType, pFix->pName, pItem->zDatabase); |
| 111441 | | - return WRC_Abort; |
| 111442 | | - } |
| 111443 | | - sqlite3DbFree(db, pItem->zDatabase); |
| 111444 | | - pItem->zDatabase = 0; |
| 111999 | + if( pItem->zDatabase ){ |
| 112000 | + if( iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){ |
| 112001 | + sqlite3ErrorMsg(pFix->pParse, |
| 112002 | + "%s %T cannot reference objects in database %s", |
| 112003 | + pFix->zType, pFix->pName, pItem->zDatabase); |
| 112004 | + return WRC_Abort; |
| 112005 | + } |
| 112006 | + sqlite3DbFree(db, pItem->zDatabase); |
| 112007 | + pItem->zDatabase = 0; |
| 112008 | + pItem->fg.notCte = 1; |
| 112009 | + } |
| 111445 | 112010 | pItem->pSchema = pFix->pSchema; |
| 111446 | 112011 | pItem->fg.fromDDL = 1; |
| 111447 | 112012 | } |
| 111448 | 112013 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) |
| 111449 | 112014 | if( sqlite3WalkExpr(&pFix->w, pList->a[i].pOn) ) return WRC_Abort; |
| | @@ -111479,11 +112044,11 @@ |
| 111479 | 112044 | pFix->pName = pName; |
| 111480 | 112045 | pFix->bTemp = (iDb==1); |
| 111481 | 112046 | pFix->w.pParse = pParse; |
| 111482 | 112047 | pFix->w.xExprCallback = fixExprCb; |
| 111483 | 112048 | pFix->w.xSelectCallback = fixSelectCb; |
| 111484 | | - pFix->w.xSelectCallback2 = 0; |
| 112049 | + pFix->w.xSelectCallback2 = sqlite3WalkWinDefnDummyCallback; |
| 111485 | 112050 | pFix->w.walkerDepth = 0; |
| 111486 | 112051 | pFix->w.eCode = 0; |
| 111487 | 112052 | pFix->w.u.pFix = pFix; |
| 111488 | 112053 | } |
| 111489 | 112054 | |
| | @@ -111541,18 +112106,20 @@ |
| 111541 | 112106 | || sqlite3FixSrcList(pFix, pStep->pFrom) |
| 111542 | 112107 | ){ |
| 111543 | 112108 | return 1; |
| 111544 | 112109 | } |
| 111545 | 112110 | #ifndef SQLITE_OMIT_UPSERT |
| 111546 | | - if( pStep->pUpsert ){ |
| 111547 | | - Upsert *pUp = pStep->pUpsert; |
| 111548 | | - if( sqlite3WalkExprList(&pFix->w, pUp->pUpsertTarget) |
| 111549 | | - || sqlite3WalkExpr(&pFix->w, pUp->pUpsertTargetWhere) |
| 111550 | | - || sqlite3WalkExprList(&pFix->w, pUp->pUpsertSet) |
| 111551 | | - || sqlite3WalkExpr(&pFix->w, pUp->pUpsertWhere) |
| 111552 | | - ){ |
| 111553 | | - return 1; |
| 112111 | + { |
| 112112 | + Upsert *pUp; |
| 112113 | + for(pUp=pStep->pUpsert; pUp; pUp=pUp->pNextUpsert){ |
| 112114 | + if( sqlite3WalkExprList(&pFix->w, pUp->pUpsertTarget) |
| 112115 | + || sqlite3WalkExpr(&pFix->w, pUp->pUpsertTargetWhere) |
| 112116 | + || sqlite3WalkExprList(&pFix->w, pUp->pUpsertSet) |
| 112117 | + || sqlite3WalkExpr(&pFix->w, pUp->pUpsertWhere) |
| 112118 | + ){ |
| 112119 | + return 1; |
| 112120 | + } |
| 111554 | 112121 | } |
| 111555 | 112122 | } |
| 111556 | 112123 | #endif |
| 111557 | 112124 | pStep = pStep->pNext; |
| 111558 | 112125 | } |
| | @@ -111880,11 +112447,11 @@ |
| 111880 | 112447 | ** |
| 111881 | 112448 | ** This routine just records the fact that the lock is desired. The |
| 111882 | 112449 | ** code to make the lock occur is generated by a later call to |
| 111883 | 112450 | ** codeTableLocks() which occurs during sqlite3FinishCoding(). |
| 111884 | 112451 | */ |
| 111885 | | -SQLITE_PRIVATE void sqlite3TableLock( |
| 112452 | +static SQLITE_NOINLINE void lockTable( |
| 111886 | 112453 | Parse *pParse, /* Parsing context */ |
| 111887 | 112454 | int iDb, /* Index of the database containing the table to lock */ |
| 111888 | 112455 | Pgno iTab, /* Root page number of the table to be locked */ |
| 111889 | 112456 | u8 isWriteLock, /* True for a write lock */ |
| 111890 | 112457 | const char *zName /* Name of the table to be locked */ |
| | @@ -111893,12 +112460,10 @@ |
| 111893 | 112460 | int i; |
| 111894 | 112461 | int nBytes; |
| 111895 | 112462 | TableLock *p; |
| 111896 | 112463 | assert( iDb>=0 ); |
| 111897 | 112464 | |
| 111898 | | - if( iDb==1 ) return; |
| 111899 | | - if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return; |
| 111900 | 112465 | pToplevel = sqlite3ParseToplevel(pParse); |
| 111901 | 112466 | for(i=0; i<pToplevel->nTableLock; i++){ |
| 111902 | 112467 | p = &pToplevel->aTableLock[i]; |
| 111903 | 112468 | if( p->iDb==iDb && p->iTab==iTab ){ |
| 111904 | 112469 | p->isWriteLock = (p->isWriteLock || isWriteLock); |
| | @@ -111918,10 +112483,21 @@ |
| 111918 | 112483 | }else{ |
| 111919 | 112484 | pToplevel->nTableLock = 0; |
| 111920 | 112485 | sqlite3OomFault(pToplevel->db); |
| 111921 | 112486 | } |
| 111922 | 112487 | } |
| 112488 | +SQLITE_PRIVATE void sqlite3TableLock( |
| 112489 | + Parse *pParse, /* Parsing context */ |
| 112490 | + int iDb, /* Index of the database containing the table to lock */ |
| 112491 | + Pgno iTab, /* Root page number of the table to be locked */ |
| 112492 | + u8 isWriteLock, /* True for a write lock */ |
| 112493 | + const char *zName /* Name of the table to be locked */ |
| 112494 | +){ |
| 112495 | + if( iDb==1 ) return; |
| 112496 | + if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return; |
| 112497 | + lockTable(pParse, iDb, iTab, isWriteLock, zName); |
| 112498 | +} |
| 111923 | 112499 | |
| 111924 | 112500 | /* |
| 111925 | 112501 | ** Code an OP_TableLock instruction for each table locked by the |
| 111926 | 112502 | ** statement (configured by calls to sqlite3TableLock()). |
| 111927 | 112503 | */ |
| | @@ -112272,11 +112848,11 @@ |
| 112272 | 112848 | if( p==0 ){ |
| 112273 | 112849 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 112274 | 112850 | /* If zName is the not the name of a table in the schema created using |
| 112275 | 112851 | ** CREATE, then check to see if it is the name of an virtual table that |
| 112276 | 112852 | ** can be an eponymous virtual table. */ |
| 112277 | | - if( pParse->disableVtab==0 ){ |
| 112853 | + if( pParse->disableVtab==0 && db->init.busy==0 ){ |
| 112278 | 112854 | Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName); |
| 112279 | 112855 | if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){ |
| 112280 | 112856 | pMod = sqlite3PragmaVtabRegister(db, zName); |
| 112281 | 112857 | } |
| 112282 | 112858 | if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){ |
| | @@ -112295,10 +112871,12 @@ |
| 112295 | 112871 | if( zDbase ){ |
| 112296 | 112872 | sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName); |
| 112297 | 112873 | }else{ |
| 112298 | 112874 | sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName); |
| 112299 | 112875 | } |
| 112876 | + }else{ |
| 112877 | + assert( HasRowid(p) || p->iPKey<0 ); |
| 112300 | 112878 | } |
| 112301 | 112879 | |
| 112302 | 112880 | return p; |
| 112303 | 112881 | } |
| 112304 | 112882 | |
| | @@ -112711,11 +113289,11 @@ |
| 112711 | 113289 | if( iDb<0 ){ |
| 112712 | 113290 | sqlite3ErrorMsg(pParse, "unknown database %T", pName1); |
| 112713 | 113291 | return -1; |
| 112714 | 113292 | } |
| 112715 | 113293 | }else{ |
| 112716 | | - assert( db->init.iDb==0 || db->init.busy || IN_RENAME_OBJECT |
| 113294 | + assert( db->init.iDb==0 || db->init.busy || IN_SPECIAL_PARSE |
| 112717 | 113295 | || (db->mDbFlags & DBFLAG_Vacuum)!=0); |
| 112718 | 113296 | iDb = db->init.iDb; |
| 112719 | 113297 | *pUnqual = pName1; |
| 112720 | 113298 | } |
| 112721 | 113299 | return iDb; |
| | @@ -112879,10 +113457,27 @@ |
| 112879 | 113457 | /* iCol is a normal or stored column */ |
| 112880 | 113458 | return n; |
| 112881 | 113459 | } |
| 112882 | 113460 | } |
| 112883 | 113461 | #endif |
| 113462 | + |
| 113463 | +/* |
| 113464 | +** Insert a single OP_JournalMode query opcode in order to force the |
| 113465 | +** prepared statement to return false for sqlite3_stmt_readonly(). This |
| 113466 | +** is used by CREATE TABLE IF NOT EXISTS and similar if the table already |
| 113467 | +** exists, so that the prepared statement for CREATE TABLE IF NOT EXISTS |
| 113468 | +** will return false for sqlite3_stmt_readonly() even if that statement |
| 113469 | +** is a read-only no-op. |
| 113470 | +*/ |
| 113471 | +static void sqlite3ForceNotReadOnly(Parse *pParse){ |
| 113472 | + int iReg = ++pParse->nMem; |
| 113473 | + Vdbe *v = sqlite3GetVdbe(pParse); |
| 113474 | + if( v ){ |
| 113475 | + sqlite3VdbeAddOp3(v, OP_JournalMode, 0, iReg, PAGER_JOURNALMODE_QUERY); |
| 113476 | + sqlite3VdbeUsesBtree(v, 0); |
| 113477 | + } |
| 113478 | +} |
| 112884 | 113479 | |
| 112885 | 113480 | /* |
| 112886 | 113481 | ** Begin constructing a new table representation in memory. This is |
| 112887 | 113482 | ** the first of several action routines that get called in response |
| 112888 | 113483 | ** to a CREATE TABLE statement. In particular, this routine is called |
| | @@ -112979,10 +113574,11 @@ |
| 112979 | 113574 | if( !noErr ){ |
| 112980 | 113575 | sqlite3ErrorMsg(pParse, "table %T already exists", pName); |
| 112981 | 113576 | }else{ |
| 112982 | 113577 | assert( !db->init.busy || CORRUPT_DB ); |
| 112983 | 113578 | sqlite3CodeVerifySchema(pParse, iDb); |
| 113579 | + sqlite3ForceNotReadOnly(pParse); |
| 112984 | 113580 | } |
| 112985 | 113581 | goto begin_table_error; |
| 112986 | 113582 | } |
| 112987 | 113583 | if( sqlite3FindIndex(db, zName, zDb)!=0 ){ |
| 112988 | 113584 | sqlite3ErrorMsg(pParse, "there is already an index named %s", zName); |
| | @@ -113155,10 +113751,11 @@ |
| 113155 | 113751 | pRet->retTrig.zName = RETURNING_TRIGGER_NAME; |
| 113156 | 113752 | pRet->retTrig.op = TK_RETURNING; |
| 113157 | 113753 | pRet->retTrig.tr_tm = TRIGGER_AFTER; |
| 113158 | 113754 | pRet->retTrig.bReturning = 1; |
| 113159 | 113755 | pRet->retTrig.pSchema = db->aDb[1].pSchema; |
| 113756 | + pRet->retTrig.pTabSchema = db->aDb[1].pSchema; |
| 113160 | 113757 | pRet->retTrig.step_list = &pRet->retTStep; |
| 113161 | 113758 | pRet->retTStep.op = TK_RETURNING; |
| 113162 | 113759 | pRet->retTStep.pTrig = &pRet->retTrig; |
| 113163 | 113760 | pRet->retTStep.pExprList = pList; |
| 113164 | 113761 | pHash = &(db->aDb[1].pSchema->trigHash); |
| | @@ -114013,20 +114610,26 @@ |
| 114013 | 114610 | ExprList *pList; |
| 114014 | 114611 | Token ipkToken; |
| 114015 | 114612 | sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName); |
| 114016 | 114613 | pList = sqlite3ExprListAppend(pParse, 0, |
| 114017 | 114614 | sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0)); |
| 114018 | | - if( pList==0 ) return; |
| 114615 | + if( pList==0 ){ |
| 114616 | + pTab->tabFlags &= ~TF_WithoutRowid; |
| 114617 | + return; |
| 114618 | + } |
| 114019 | 114619 | if( IN_RENAME_OBJECT ){ |
| 114020 | 114620 | sqlite3RenameTokenRemap(pParse, pList->a[0].pExpr, &pTab->iPKey); |
| 114021 | 114621 | } |
| 114022 | 114622 | pList->a[0].sortFlags = pParse->iPkSortOrder; |
| 114023 | 114623 | assert( pParse->pNewTable==pTab ); |
| 114024 | 114624 | pTab->iPKey = -1; |
| 114025 | 114625 | sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0, |
| 114026 | 114626 | SQLITE_IDXTYPE_PRIMARYKEY); |
| 114027 | | - if( db->mallocFailed || pParse->nErr ) return; |
| 114627 | + if( db->mallocFailed || pParse->nErr ){ |
| 114628 | + pTab->tabFlags &= ~TF_WithoutRowid; |
| 114629 | + return; |
| 114630 | + } |
| 114028 | 114631 | pPk = sqlite3PrimaryKeyIndex(pTab); |
| 114029 | 114632 | assert( pPk->nKeyCol==1 ); |
| 114030 | 114633 | }else{ |
| 114031 | 114634 | pPk = sqlite3PrimaryKeyIndex(pTab); |
| 114032 | 114635 | assert( pPk!=0 ); |
| | @@ -114226,11 +114829,10 @@ |
| 114226 | 114829 | Index *pIdx; /* An implied index of the table */ |
| 114227 | 114830 | |
| 114228 | 114831 | if( pEnd==0 && pSelect==0 ){ |
| 114229 | 114832 | return; |
| 114230 | 114833 | } |
| 114231 | | - assert( !db->mallocFailed ); |
| 114232 | 114834 | p = pParse->pNewTable; |
| 114233 | 114835 | if( p==0 ) return; |
| 114234 | 114836 | |
| 114235 | 114837 | if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){ |
| 114236 | 114838 | p->tabFlags |= TF_Shadow; |
| | @@ -114474,10 +115076,11 @@ |
| 114474 | 115076 | */ |
| 114475 | 115077 | if( db->init.busy ){ |
| 114476 | 115078 | Table *pOld; |
| 114477 | 115079 | Schema *pSchema = p->pSchema; |
| 114478 | 115080 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 115081 | + assert( HasRowid(p) || p->iPKey<0 ); |
| 114479 | 115082 | pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p); |
| 114480 | 115083 | if( pOld ){ |
| 114481 | 115084 | assert( p==pOld ); /* Malloc must have failed inside HashInsert() */ |
| 114482 | 115085 | sqlite3OomFault(db); |
| 114483 | 115086 | return; |
| | @@ -115022,11 +115625,14 @@ |
| 115022 | 115625 | assert( isView==0 || isView==LOCATE_VIEW ); |
| 115023 | 115626 | pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]); |
| 115024 | 115627 | if( noErr ) db->suppressErr--; |
| 115025 | 115628 | |
| 115026 | 115629 | if( pTab==0 ){ |
| 115027 | | - if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); |
| 115630 | + if( noErr ){ |
| 115631 | + sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); |
| 115632 | + sqlite3ForceNotReadOnly(pParse); |
| 115633 | + } |
| 115028 | 115634 | goto exit_drop_table; |
| 115029 | 115635 | } |
| 115030 | 115636 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 115031 | 115637 | assert( iDb>=0 && iDb<db->nDb ); |
| 115032 | 115638 | |
| | @@ -115592,10 +116198,11 @@ |
| 115592 | 116198 | if( !ifNotExist ){ |
| 115593 | 116199 | sqlite3ErrorMsg(pParse, "index %s already exists", zName); |
| 115594 | 116200 | }else{ |
| 115595 | 116201 | assert( !db->init.busy ); |
| 115596 | 116202 | sqlite3CodeVerifySchema(pParse, iDb); |
| 116203 | + sqlite3ForceNotReadOnly(pParse); |
| 115597 | 116204 | } |
| 115598 | 116205 | goto exit_create_index; |
| 115599 | 116206 | } |
| 115600 | 116207 | } |
| 115601 | 116208 | }else{ |
| | @@ -116072,11 +116679,11 @@ |
| 116072 | 116679 | x = pIdx->pTable->nRowLogEst; |
| 116073 | 116680 | assert( 99==sqlite3LogEst(1000) ); |
| 116074 | 116681 | if( x<99 ){ |
| 116075 | 116682 | pIdx->pTable->nRowLogEst = x = 99; |
| 116076 | 116683 | } |
| 116077 | | - if( pIdx->pPartIdxWhere!=0 ) x -= 10; assert( 10==sqlite3LogEst(2) ); |
| 116684 | + if( pIdx->pPartIdxWhere!=0 ){ x -= 10; assert( 10==sqlite3LogEst(2) ); } |
| 116078 | 116685 | a[0] = x; |
| 116079 | 116686 | |
| 116080 | 116687 | /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is |
| 116081 | 116688 | ** 6 and each subsequent value (if any) is 5. */ |
| 116082 | 116689 | memcpy(&a[1], aVal, nCopy*sizeof(LogEst)); |
| | @@ -116110,10 +116717,11 @@ |
| 116110 | 116717 | if( pIndex==0 ){ |
| 116111 | 116718 | if( !ifExists ){ |
| 116112 | 116719 | sqlite3ErrorMsg(pParse, "no such index: %S", pName->a); |
| 116113 | 116720 | }else{ |
| 116114 | 116721 | sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); |
| 116722 | + sqlite3ForceNotReadOnly(pParse); |
| 116115 | 116723 | } |
| 116116 | 116724 | pParse->checkSchema = 1; |
| 116117 | 116725 | goto exit_drop_index; |
| 116118 | 116726 | } |
| 116119 | 116727 | if( pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ){ |
| | @@ -116129,11 +116737,11 @@ |
| 116129 | 116737 | const char *zDb = db->aDb[iDb].zDbSName; |
| 116130 | 116738 | const char *zTab = SCHEMA_TABLE(iDb); |
| 116131 | 116739 | if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){ |
| 116132 | 116740 | goto exit_drop_index; |
| 116133 | 116741 | } |
| 116134 | | - if( !OMIT_TEMPDB && iDb ) code = SQLITE_DROP_TEMP_INDEX; |
| 116742 | + if( !OMIT_TEMPDB && iDb==1 ) code = SQLITE_DROP_TEMP_INDEX; |
| 116135 | 116743 | if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){ |
| 116136 | 116744 | goto exit_drop_index; |
| 116137 | 116745 | } |
| 116138 | 116746 | } |
| 116139 | 116747 | #endif |
| | @@ -116421,12 +117029,12 @@ |
| 116421 | 117029 | ** Assign VdbeCursor index numbers to all tables in a SrcList |
| 116422 | 117030 | */ |
| 116423 | 117031 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){ |
| 116424 | 117032 | int i; |
| 116425 | 117033 | SrcItem *pItem; |
| 116426 | | - assert(pList || pParse->db->mallocFailed ); |
| 116427 | | - if( pList ){ |
| 117034 | + assert( pList || pParse->db->mallocFailed ); |
| 117035 | + if( ALWAYS(pList) ){ |
| 116428 | 117036 | for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ |
| 116429 | 117037 | if( pItem->iCursor>=0 ) continue; |
| 116430 | 117038 | pItem->iCursor = pParse->nTab++; |
| 116431 | 117039 | if( pItem->pSelect ){ |
| 116432 | 117040 | sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc); |
| | @@ -118147,10 +118755,13 @@ |
| 118147 | 118755 | pTab->zName, P4_STATIC); |
| 118148 | 118756 | } |
| 118149 | 118757 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 118150 | 118758 | assert( pIdx->pSchema==pTab->pSchema ); |
| 118151 | 118759 | sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb); |
| 118760 | + if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){ |
| 118761 | + sqlite3VdbeChangeP3(v, -1, memCnt ? memCnt : -1); |
| 118762 | + } |
| 118152 | 118763 | } |
| 118153 | 118764 | }else |
| 118154 | 118765 | #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ |
| 118155 | 118766 | { |
| 118156 | 118767 | u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK; |
| | @@ -118658,17 +119269,19 @@ |
| 118658 | 119269 | ){ |
| 118659 | 119270 | /* This column was already computed by the previous index */ |
| 118660 | 119271 | continue; |
| 118661 | 119272 | } |
| 118662 | 119273 | sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j); |
| 118663 | | - /* If the column affinity is REAL but the number is an integer, then it |
| 118664 | | - ** might be stored in the table as an integer (using a compact |
| 118665 | | - ** representation) then converted to REAL by an OP_RealAffinity opcode. |
| 118666 | | - ** But we are getting ready to store this value back into an index, where |
| 118667 | | - ** it should be converted by to INTEGER again. So omit the OP_RealAffinity |
| 118668 | | - ** opcode if it is present */ |
| 118669 | | - sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity); |
| 119274 | + if( pIdx->aiColumn[j]>=0 ){ |
| 119275 | + /* If the column affinity is REAL but the number is an integer, then it |
| 119276 | + ** might be stored in the table as an integer (using a compact |
| 119277 | + ** representation) then converted to REAL by an OP_RealAffinity opcode. |
| 119278 | + ** But we are getting ready to store this value back into an index, where |
| 119279 | + ** it should be converted by to INTEGER again. So omit the |
| 119280 | + ** OP_RealAffinity opcode if it is present */ |
| 119281 | + sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity); |
| 119282 | + } |
| 118670 | 119283 | } |
| 118671 | 119284 | if( regOut ){ |
| 118672 | 119285 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut); |
| 118673 | 119286 | } |
| 118674 | 119287 | sqlite3ReleaseTempRange(pParse, regBase, nCol); |
| | @@ -120759,13 +121372,11 @@ |
| 120759 | 121372 | ans = x(v0, v1); |
| 120760 | 121373 | sqlite3_result_double(context, ans); |
| 120761 | 121374 | } |
| 120762 | 121375 | |
| 120763 | 121376 | /* |
| 120764 | | -** Implementation of 2-argument SQL math functions: |
| 120765 | | -** |
| 120766 | | -** power(X,Y) - Compute X to the Y-th power |
| 121377 | +** Implementation of 0-argument pi() function. |
| 120767 | 121378 | */ |
| 120768 | 121379 | static void piFunc( |
| 120769 | 121380 | sqlite3_context *context, |
| 120770 | 121381 | int argc, |
| 120771 | 121382 | sqlite3_value **argv |
| | @@ -122791,11 +123402,11 @@ |
| 122791 | 123402 | /* Verify that the sqlite_sequence table exists and is an ordinary |
| 122792 | 123403 | ** rowid table with exactly two columns. |
| 122793 | 123404 | ** Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 */ |
| 122794 | 123405 | if( pSeqTab==0 |
| 122795 | 123406 | || !HasRowid(pSeqTab) |
| 122796 | | - || IsVirtual(pSeqTab) |
| 123407 | + || NEVER(IsVirtual(pSeqTab)) |
| 122797 | 123408 | || pSeqTab->nCol!=2 |
| 122798 | 123409 | ){ |
| 122799 | 123410 | pParse->nErr++; |
| 122800 | 123411 | pParse->rc = SQLITE_CORRUPT_SEQUENCE; |
| 122801 | 123412 | return 0; |
| | @@ -126824,11 +127435,11 @@ |
| 126824 | 127435 | sqlite3_loadext_entry xInit; |
| 126825 | 127436 | char *zErrmsg = 0; |
| 126826 | 127437 | const char *zEntry; |
| 126827 | 127438 | char *zAltEntry = 0; |
| 126828 | 127439 | void **aHandle; |
| 126829 | | - u64 nMsg = 300 + sqlite3Strlen30(zFile); |
| 127440 | + u64 nMsg = strlen(zFile); |
| 126830 | 127441 | int ii; |
| 126831 | 127442 | int rc; |
| 126832 | 127443 | |
| 126833 | 127444 | /* Shared library endings to try if zFile cannot be loaded as written */ |
| 126834 | 127445 | static const char *azEndings[] = { |
| | @@ -126858,30 +127469,26 @@ |
| 126858 | 127469 | return SQLITE_ERROR; |
| 126859 | 127470 | } |
| 126860 | 127471 | |
| 126861 | 127472 | zEntry = zProc ? zProc : "sqlite3_extension_init"; |
| 126862 | 127473 | |
| 127474 | + /* tag-20210611-1. Some dlopen() implementations will segfault if given |
| 127475 | + ** an oversize filename. Most filesystems have a pathname limit of 4K, |
| 127476 | + ** so limit the extension filename length to about twice that. |
| 127477 | + ** https://sqlite.org/forum/forumpost/08a0d6d9bf */ |
| 127478 | + if( nMsg>SQLITE_MAX_PATHLEN ) goto extension_not_found; |
| 127479 | + |
| 126863 | 127480 | handle = sqlite3OsDlOpen(pVfs, zFile); |
| 126864 | 127481 | #if SQLITE_OS_UNIX || SQLITE_OS_WIN |
| 126865 | 127482 | for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){ |
| 126866 | 127483 | char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]); |
| 126867 | 127484 | if( zAltFile==0 ) return SQLITE_NOMEM_BKPT; |
| 126868 | 127485 | handle = sqlite3OsDlOpen(pVfs, zAltFile); |
| 126869 | 127486 | sqlite3_free(zAltFile); |
| 126870 | 127487 | } |
| 126871 | 127488 | #endif |
| 126872 | | - if( handle==0 ){ |
| 126873 | | - if( pzErrMsg ){ |
| 126874 | | - *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg); |
| 126875 | | - if( zErrmsg ){ |
| 126876 | | - sqlite3_snprintf(nMsg, zErrmsg, |
| 126877 | | - "unable to open shared library [%s]", zFile); |
| 126878 | | - sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); |
| 126879 | | - } |
| 126880 | | - } |
| 126881 | | - return SQLITE_ERROR; |
| 126882 | | - } |
| 127489 | + if( handle==0 ) goto extension_not_found; |
| 126883 | 127490 | xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry); |
| 126884 | 127491 | |
| 126885 | 127492 | /* If no entry point was specified and the default legacy |
| 126886 | 127493 | ** entry point name "sqlite3_extension_init" was not found, then |
| 126887 | 127494 | ** construct an entry point name "sqlite3_X_init" where the X is |
| | @@ -126914,14 +127521,15 @@ |
| 126914 | 127521 | zEntry = zAltEntry; |
| 126915 | 127522 | xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry); |
| 126916 | 127523 | } |
| 126917 | 127524 | if( xInit==0 ){ |
| 126918 | 127525 | if( pzErrMsg ){ |
| 126919 | | - nMsg += sqlite3Strlen30(zEntry); |
| 127526 | + nMsg += strlen(zEntry) + 300; |
| 126920 | 127527 | *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg); |
| 126921 | 127528 | if( zErrmsg ){ |
| 126922 | | - sqlite3_snprintf(nMsg, zErrmsg, |
| 127529 | + assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */ |
| 127530 | + sqlite3_snprintf((int)nMsg, zErrmsg, |
| 126923 | 127531 | "no entry point [%s] in shared library [%s]", zEntry, zFile); |
| 126924 | 127532 | sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); |
| 126925 | 127533 | } |
| 126926 | 127534 | } |
| 126927 | 127535 | sqlite3OsDlClose(pVfs, handle); |
| | @@ -126951,10 +127559,23 @@ |
| 126951 | 127559 | sqlite3DbFree(db, db->aExtension); |
| 126952 | 127560 | db->aExtension = aHandle; |
| 126953 | 127561 | |
| 126954 | 127562 | db->aExtension[db->nExtension++] = handle; |
| 126955 | 127563 | return SQLITE_OK; |
| 127564 | + |
| 127565 | +extension_not_found: |
| 127566 | + if( pzErrMsg ){ |
| 127567 | + nMsg += 300; |
| 127568 | + *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg); |
| 127569 | + if( zErrmsg ){ |
| 127570 | + assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */ |
| 127571 | + sqlite3_snprintf((int)nMsg, zErrmsg, |
| 127572 | + "unable to open shared library [%.*s]", SQLITE_MAX_PATHLEN, zFile); |
| 127573 | + sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); |
| 127574 | + } |
| 127575 | + } |
| 127576 | + return SQLITE_ERROR; |
| 126956 | 127577 | } |
| 126957 | 127578 | SQLITE_API int sqlite3_load_extension( |
| 126958 | 127579 | sqlite3 *db, /* Load the extension into this database connection */ |
| 126959 | 127580 | const char *zFile, /* Name of the shared library containing extension */ |
| 126960 | 127581 | const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ |
| | @@ -130510,18 +131131,18 @@ |
| 130510 | 131131 | |
| 130511 | 131132 | assert( argc==5 ); |
| 130512 | 131133 | UNUSED_PARAMETER2(NotUsed, argc); |
| 130513 | 131134 | assert( sqlite3_mutex_held(db->mutex) ); |
| 130514 | 131135 | db->mDbFlags |= DBFLAG_EncodingFixed; |
| 131136 | + if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ |
| 130515 | 131137 | pData->nInitRow++; |
| 130516 | 131138 | if( db->mallocFailed ){ |
| 130517 | 131139 | corruptSchema(pData, argv, 0); |
| 130518 | 131140 | return 1; |
| 130519 | 131141 | } |
| 130520 | 131142 | |
| 130521 | 131143 | assert( iDb>=0 && iDb<db->nDb ); |
| 130522 | | - if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ |
| 130523 | 131144 | if( argv[3]==0 ){ |
| 130524 | 131145 | corruptSchema(pData, argv, 0); |
| 130525 | 131146 | }else if( argv[4] |
| 130526 | 131147 | && 'c'==sqlite3UpperToLower[(unsigned char)argv[4][0]] |
| 130527 | 131148 | && 'r'==sqlite3UpperToLower[(unsigned char)argv[4][1]] ){ |
| | @@ -130791,22 +131412,26 @@ |
| 130791 | 131412 | if( rc==SQLITE_OK ){ |
| 130792 | 131413 | sqlite3AnalysisLoad(db, iDb); |
| 130793 | 131414 | } |
| 130794 | 131415 | #endif |
| 130795 | 131416 | } |
| 131417 | + assert( pDb == &(db->aDb[iDb]) ); |
| 130796 | 131418 | if( db->mallocFailed ){ |
| 130797 | 131419 | rc = SQLITE_NOMEM_BKPT; |
| 130798 | 131420 | sqlite3ResetAllSchemasOfConnection(db); |
| 130799 | | - } |
| 131421 | + pDb = &db->aDb[iDb]; |
| 131422 | + }else |
| 130800 | 131423 | if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){ |
| 130801 | | - /* Black magic: If the SQLITE_NoSchemaError flag is set, then consider |
| 130802 | | - ** the schema loaded, even if errors occurred. In this situation the |
| 130803 | | - ** current sqlite3_prepare() operation will fail, but the following one |
| 130804 | | - ** will attempt to compile the supplied statement against whatever subset |
| 130805 | | - ** of the schema was loaded before the error occurred. The primary |
| 130806 | | - ** purpose of this is to allow access to the sqlite_schema table |
| 130807 | | - ** even when its contents have been corrupted. |
| 131424 | + /* Hack: If the SQLITE_NoSchemaError flag is set, then consider |
| 131425 | + ** the schema loaded, even if errors (other than OOM) occurred. In |
| 131426 | + ** this situation the current sqlite3_prepare() operation will fail, |
| 131427 | + ** but the following one will attempt to compile the supplied statement |
| 131428 | + ** against whatever subset of the schema was loaded before the error |
| 131429 | + ** occurred. |
| 131430 | + ** |
| 131431 | + ** The primary purpose of this is to allow access to the sqlite_schema |
| 131432 | + ** table even when its contents have been corrupted. |
| 130808 | 131433 | */ |
| 130809 | 131434 | DbSetProperty(db, iDb, DB_SchemaLoaded); |
| 130810 | 131435 | rc = SQLITE_OK; |
| 130811 | 131436 | } |
| 130812 | 131437 | |
| | @@ -133387,11 +134012,11 @@ |
| 133387 | 134012 | ** |
| 133388 | 134013 | ** full=ON, short=ANY: If the result refers directly to a table column, |
| 133389 | 134014 | ** then the result column name with the table name |
| 133390 | 134015 | ** prefix, ex: TABLE.COLUMN. Otherwise use zSpan. |
| 133391 | 134016 | */ |
| 133392 | | -static void generateColumnNames( |
| 134017 | +SQLITE_PRIVATE void sqlite3GenerateColumnNames( |
| 133393 | 134018 | Parse *pParse, /* Parser context */ |
| 133394 | 134019 | Select *pSelect /* Generate column names for this SELECT statement */ |
| 133395 | 134020 | ){ |
| 133396 | 134021 | Vdbe *v = pParse->pVdbe; |
| 133397 | 134022 | int i; |
| | @@ -133477,11 +134102,11 @@ |
| 133477 | 134102 | ** That is the only documented guarantee. However, countless applications |
| 133478 | 134103 | ** developed over the years have made baseless assumptions about column names |
| 133479 | 134104 | ** and will break if those assumptions changes. Hence, use extreme caution |
| 133480 | 134105 | ** when modifying this routine to avoid breaking legacy. |
| 133481 | 134106 | ** |
| 133482 | | -** See Also: generateColumnNames() |
| 134107 | +** See Also: sqlite3GenerateColumnNames() |
| 133483 | 134108 | */ |
| 133484 | 134109 | SQLITE_PRIVATE int sqlite3ColumnsFromExprList( |
| 133485 | 134110 | Parse *pParse, /* Parsing context */ |
| 133486 | 134111 | ExprList *pEList, /* Expr list from which to derive column names */ |
| 133487 | 134112 | i16 *pnCol, /* Write the number of columns here */ |
| | @@ -134180,10 +134805,11 @@ |
| 134180 | 134805 | int nLimit = 0; /* Initialize to suppress harmless compiler warning */ |
| 134181 | 134806 | assert( !pPrior->pLimit ); |
| 134182 | 134807 | pPrior->iLimit = p->iLimit; |
| 134183 | 134808 | pPrior->iOffset = p->iOffset; |
| 134184 | 134809 | pPrior->pLimit = p->pLimit; |
| 134810 | + SELECTTRACE(1, pParse, p, ("multiSelect UNION ALL left...\n")); |
| 134185 | 134811 | rc = sqlite3Select(pParse, pPrior, &dest); |
| 134186 | 134812 | pPrior->pLimit = 0; |
| 134187 | 134813 | if( rc ){ |
| 134188 | 134814 | goto multi_select_end; |
| 134189 | 134815 | } |
| | @@ -134197,10 +134823,11 @@ |
| 134197 | 134823 | sqlite3VdbeAddOp3(v, OP_OffsetLimit, |
| 134198 | 134824 | p->iLimit, p->iOffset+1, p->iOffset); |
| 134199 | 134825 | } |
| 134200 | 134826 | } |
| 134201 | 134827 | ExplainQueryPlan((pParse, 1, "UNION ALL")); |
| 134828 | + SELECTTRACE(1, pParse, p, ("multiSelect UNION ALL right...\n")); |
| 134202 | 134829 | rc = sqlite3Select(pParse, p, &dest); |
| 134203 | 134830 | testcase( rc!=SQLITE_OK ); |
| 134204 | 134831 | pDelete = p->pPrior; |
| 134205 | 134832 | p->pPrior = pPrior; |
| 134206 | 134833 | p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow); |
| | @@ -134249,10 +134876,11 @@ |
| 134249 | 134876 | |
| 134250 | 134877 | /* Code the SELECT statements to our left |
| 134251 | 134878 | */ |
| 134252 | 134879 | assert( !pPrior->pOrderBy ); |
| 134253 | 134880 | sqlite3SelectDestInit(&uniondest, priorOp, unionTab); |
| 134881 | + SELECTTRACE(1, pParse, p, ("multiSelect EXCEPT/UNION left...\n")); |
| 134254 | 134882 | rc = sqlite3Select(pParse, pPrior, &uniondest); |
| 134255 | 134883 | if( rc ){ |
| 134256 | 134884 | goto multi_select_end; |
| 134257 | 134885 | } |
| 134258 | 134886 | |
| | @@ -134268,10 +134896,11 @@ |
| 134268 | 134896 | pLimit = p->pLimit; |
| 134269 | 134897 | p->pLimit = 0; |
| 134270 | 134898 | uniondest.eDest = op; |
| 134271 | 134899 | ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE", |
| 134272 | 134900 | sqlite3SelectOpName(p->op))); |
| 134901 | + SELECTTRACE(1, pParse, p, ("multiSelect EXCEPT/UNION right...\n")); |
| 134273 | 134902 | rc = sqlite3Select(pParse, p, &uniondest); |
| 134274 | 134903 | testcase( rc!=SQLITE_OK ); |
| 134275 | 134904 | assert( p->pOrderBy==0 ); |
| 134276 | 134905 | pDelete = p->pPrior; |
| 134277 | 134906 | p->pPrior = pPrior; |
| | @@ -134328,10 +134957,11 @@ |
| 134328 | 134957 | assert( p->pEList ); |
| 134329 | 134958 | |
| 134330 | 134959 | /* Code the SELECTs to our left into temporary table "tab1". |
| 134331 | 134960 | */ |
| 134332 | 134961 | sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1); |
| 134962 | + SELECTTRACE(1, pParse, p, ("multiSelect INTERSECT left...\n")); |
| 134333 | 134963 | rc = sqlite3Select(pParse, pPrior, &intersectdest); |
| 134334 | 134964 | if( rc ){ |
| 134335 | 134965 | goto multi_select_end; |
| 134336 | 134966 | } |
| 134337 | 134967 | |
| | @@ -134344,10 +134974,11 @@ |
| 134344 | 134974 | pLimit = p->pLimit; |
| 134345 | 134975 | p->pLimit = 0; |
| 134346 | 134976 | intersectdest.iSDParm = tab2; |
| 134347 | 134977 | ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE", |
| 134348 | 134978 | sqlite3SelectOpName(p->op))); |
| 134979 | + SELECTTRACE(1, pParse, p, ("multiSelect INTERSECT right...\n")); |
| 134349 | 134980 | rc = sqlite3Select(pParse, p, &intersectdest); |
| 134350 | 134981 | testcase( rc!=SQLITE_OK ); |
| 134351 | 134982 | pDelete = p->pPrior; |
| 134352 | 134983 | p->pPrior = pPrior; |
| 134353 | 134984 | if( p->nSelectRow>pPrior->nSelectRow ){ |
| | @@ -134976,10 +135607,13 @@ |
| 134976 | 135607 | if( p->pPrior ){ |
| 134977 | 135608 | sqlite3SelectDelete(db, p->pPrior); |
| 134978 | 135609 | } |
| 134979 | 135610 | p->pPrior = pPrior; |
| 134980 | 135611 | pPrior->pNext = p; |
| 135612 | + |
| 135613 | + sqlite3ExprListDelete(db, pPrior->pOrderBy); |
| 135614 | + pPrior->pOrderBy = 0; |
| 134981 | 135615 | |
| 134982 | 135616 | /*** TBD: Insert subroutine calls to close cursors on incomplete |
| 134983 | 135617 | **** subqueries ****/ |
| 134984 | 135618 | ExplainQueryPlanPop(pParse); |
| 134985 | 135619 | return pParse->nErr!=0; |
| | @@ -135056,30 +135690,32 @@ |
| 135056 | 135690 | ifNullRow.flags = EP_IfNullRow; |
| 135057 | 135691 | pCopy = &ifNullRow; |
| 135058 | 135692 | } |
| 135059 | 135693 | testcase( ExprHasProperty(pCopy, EP_Subquery) ); |
| 135060 | 135694 | pNew = sqlite3ExprDup(db, pCopy, 0); |
| 135061 | | - if( pNew && pSubst->isLeftJoin ){ |
| 135695 | + if( db->mallocFailed ){ |
| 135696 | + sqlite3ExprDelete(db, pNew); |
| 135697 | + return pExpr; |
| 135698 | + } |
| 135699 | + if( pSubst->isLeftJoin ){ |
| 135062 | 135700 | ExprSetProperty(pNew, EP_CanBeNull); |
| 135063 | 135701 | } |
| 135064 | | - if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){ |
| 135702 | + if( ExprHasProperty(pExpr,EP_FromJoin) ){ |
| 135065 | 135703 | sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable); |
| 135066 | 135704 | } |
| 135067 | 135705 | sqlite3ExprDelete(db, pExpr); |
| 135068 | 135706 | pExpr = pNew; |
| 135069 | 135707 | |
| 135070 | 135708 | /* Ensure that the expression now has an implicit collation sequence, |
| 135071 | 135709 | ** just as it did when it was a column of a view or sub-query. */ |
| 135072 | | - if( pExpr ){ |
| 135073 | | - if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){ |
| 135074 | | - CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr); |
| 135075 | | - pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr, |
| 135076 | | - (pColl ? pColl->zName : "BINARY") |
| 135077 | | - ); |
| 135078 | | - } |
| 135079 | | - ExprClearProperty(pExpr, EP_Collate); |
| 135080 | | - } |
| 135710 | + if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){ |
| 135711 | + CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr); |
| 135712 | + pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr, |
| 135713 | + (pColl ? pColl->zName : "BINARY") |
| 135714 | + ); |
| 135715 | + } |
| 135716 | + ExprClearProperty(pExpr, EP_Collate); |
| 135081 | 135717 | } |
| 135082 | 135718 | } |
| 135083 | 135719 | }else{ |
| 135084 | 135720 | if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){ |
| 135085 | 135721 | pExpr->iTable = pSubst->iNewTable; |
| | @@ -135194,11 +135830,14 @@ |
| 135194 | 135830 | int i; |
| 135195 | 135831 | SrcItem *pItem; |
| 135196 | 135832 | for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){ |
| 135197 | 135833 | if( i!=iExcept ){ |
| 135198 | 135834 | Select *p; |
| 135199 | | - pItem->iCursor = aCsrMap[pItem->iCursor] = pParse->nTab++; |
| 135835 | + if( !pItem->fg.isRecursive || aCsrMap[pItem->iCursor]==0 ){ |
| 135836 | + aCsrMap[pItem->iCursor] = pParse->nTab++; |
| 135837 | + } |
| 135838 | + pItem->iCursor = aCsrMap[pItem->iCursor]; |
| 135200 | 135839 | for(p=pItem->pSelect; p; p=p->pPrior){ |
| 135201 | 135840 | srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1); |
| 135202 | 135841 | } |
| 135203 | 135842 | } |
| 135204 | 135843 | } |
| | @@ -135634,11 +136273,11 @@ |
| 135634 | 136273 | pSubitem->pTab = pItemTab; |
| 135635 | 136274 | if( pNew==0 ){ |
| 135636 | 136275 | p->pPrior = pPrior; |
| 135637 | 136276 | }else{ |
| 135638 | 136277 | pNew->selId = ++pParse->nSelect; |
| 135639 | | - if( aCsrMap && db->mallocFailed==0 ){ |
| 136278 | + if( aCsrMap && ALWAYS(db->mallocFailed==0) ){ |
| 135640 | 136279 | renumberCursors(pParse, pNew, iFrom, aCsrMap); |
| 135641 | 136280 | } |
| 135642 | 136281 | pNew->pPrior = pPrior; |
| 135643 | 136282 | if( pPrior ) pPrior->pNext = pNew; |
| 135644 | 136283 | pNew->pNext = p; |
| | @@ -135833,12 +136472,14 @@ |
| 135833 | 136472 | ** a known value due to WHERE clause constraints of the form COLUMN=VALUE. |
| 135834 | 136473 | */ |
| 135835 | 136474 | typedef struct WhereConst WhereConst; |
| 135836 | 136475 | struct WhereConst { |
| 135837 | 136476 | Parse *pParse; /* Parsing context */ |
| 136477 | + u8 *pOomFault; /* Pointer to pParse->db->mallocFailed */ |
| 135838 | 136478 | int nConst; /* Number for COLUMN=CONSTANT terms */ |
| 135839 | 136479 | int nChng; /* Number of times a constant is propagated */ |
| 136480 | + int bHasAffBlob; /* At least one column in apExpr[] as affinity BLOB */ |
| 135840 | 136481 | Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */ |
| 135841 | 136482 | }; |
| 135842 | 136483 | |
| 135843 | 136484 | /* |
| 135844 | 136485 | ** Add a new entry to the pConst object. Except, do not add duplicate |
| | @@ -135873,10 +136514,13 @@ |
| 135873 | 136514 | && pE2->iColumn==pColumn->iColumn |
| 135874 | 136515 | ){ |
| 135875 | 136516 | return; /* Already present. Return without doing anything. */ |
| 135876 | 136517 | } |
| 135877 | 136518 | } |
| 136519 | + if( sqlite3ExprAffinity(pColumn)==SQLITE_AFF_BLOB ){ |
| 136520 | + pConst->bHasAffBlob = 1; |
| 136521 | + } |
| 135878 | 136522 | |
| 135879 | 136523 | pConst->nConst++; |
| 135880 | 136524 | pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr, |
| 135881 | 136525 | pConst->nConst*2*sizeof(Expr*)); |
| 135882 | 136526 | if( pConst->apExpr==0 ){ |
| | @@ -135893,11 +136537,11 @@ |
| 135893 | 136537 | ** is part of the AND-connected terms of the expression. For each term |
| 135894 | 136538 | ** found, add it to the pConst structure. |
| 135895 | 136539 | */ |
| 135896 | 136540 | static void findConstInWhere(WhereConst *pConst, Expr *pExpr){ |
| 135897 | 136541 | Expr *pRight, *pLeft; |
| 135898 | | - if( pExpr==0 ) return; |
| 136542 | + if( NEVER(pExpr==0) ) return; |
| 135899 | 136543 | if( ExprHasProperty(pExpr, EP_FromJoin) ) return; |
| 135900 | 136544 | if( pExpr->op==TK_AND ){ |
| 135901 | 136545 | findConstInWhere(pConst, pExpr->pRight); |
| 135902 | 136546 | findConstInWhere(pConst, pExpr->pLeft); |
| 135903 | 136547 | return; |
| | @@ -135914,40 +136558,86 @@ |
| 135914 | 136558 | constInsert(pConst,pLeft,pRight,pExpr); |
| 135915 | 136559 | } |
| 135916 | 136560 | } |
| 135917 | 136561 | |
| 135918 | 136562 | /* |
| 135919 | | -** This is a Walker expression callback. pExpr is a candidate expression |
| 135920 | | -** to be replaced by a value. If pExpr is equivalent to one of the |
| 135921 | | -** columns named in pWalker->u.pConst, then overwrite it with its |
| 135922 | | -** corresponding value. |
| 136563 | +** This is a helper function for Walker callback propagateConstantExprRewrite(). |
| 136564 | +** |
| 136565 | +** Argument pExpr is a candidate expression to be replaced by a value. If |
| 136566 | +** pExpr is equivalent to one of the columns named in pWalker->u.pConst, |
| 136567 | +** then overwrite it with the corresponding value. Except, do not do so |
| 136568 | +** if argument bIgnoreAffBlob is non-zero and the affinity of pExpr |
| 136569 | +** is SQLITE_AFF_BLOB. |
| 135923 | 136570 | */ |
| 135924 | | -static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){ |
| 136571 | +static int propagateConstantExprRewriteOne( |
| 136572 | + WhereConst *pConst, |
| 136573 | + Expr *pExpr, |
| 136574 | + int bIgnoreAffBlob |
| 136575 | +){ |
| 135925 | 136576 | int i; |
| 135926 | | - WhereConst *pConst; |
| 136577 | + if( pConst->pOomFault[0] ) return WRC_Prune; |
| 135927 | 136578 | if( pExpr->op!=TK_COLUMN ) return WRC_Continue; |
| 135928 | 136579 | if( ExprHasProperty(pExpr, EP_FixedCol|EP_FromJoin) ){ |
| 135929 | 136580 | testcase( ExprHasProperty(pExpr, EP_FixedCol) ); |
| 135930 | 136581 | testcase( ExprHasProperty(pExpr, EP_FromJoin) ); |
| 135931 | 136582 | return WRC_Continue; |
| 135932 | 136583 | } |
| 135933 | | - pConst = pWalker->u.pConst; |
| 135934 | 136584 | for(i=0; i<pConst->nConst; i++){ |
| 135935 | 136585 | Expr *pColumn = pConst->apExpr[i*2]; |
| 135936 | 136586 | if( pColumn==pExpr ) continue; |
| 135937 | 136587 | if( pColumn->iTable!=pExpr->iTable ) continue; |
| 135938 | 136588 | if( pColumn->iColumn!=pExpr->iColumn ) continue; |
| 136589 | + if( bIgnoreAffBlob && sqlite3ExprAffinity(pColumn)==SQLITE_AFF_BLOB ){ |
| 136590 | + break; |
| 136591 | + } |
| 135939 | 136592 | /* A match is found. Add the EP_FixedCol property */ |
| 135940 | 136593 | pConst->nChng++; |
| 135941 | 136594 | ExprClearProperty(pExpr, EP_Leaf); |
| 135942 | 136595 | ExprSetProperty(pExpr, EP_FixedCol); |
| 135943 | 136596 | assert( pExpr->pLeft==0 ); |
| 135944 | 136597 | pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0); |
| 136598 | + if( pConst->pParse->db->mallocFailed ) return WRC_Prune; |
| 135945 | 136599 | break; |
| 135946 | 136600 | } |
| 135947 | 136601 | return WRC_Prune; |
| 135948 | 136602 | } |
| 136603 | + |
| 136604 | +/* |
| 136605 | +** This is a Walker expression callback. pExpr is a node from the WHERE |
| 136606 | +** clause of a SELECT statement. This function examines pExpr to see if |
| 136607 | +** any substitutions based on the contents of pWalker->u.pConst should |
| 136608 | +** be made to pExpr or its immediate children. |
| 136609 | +** |
| 136610 | +** A substitution is made if: |
| 136611 | +** |
| 136612 | +** + pExpr is a column with an affinity other than BLOB that matches |
| 136613 | +** one of the columns in pWalker->u.pConst, or |
| 136614 | +** |
| 136615 | +** + pExpr is a binary comparison operator (=, <=, >=, <, >) that |
| 136616 | +** uses an affinity other than TEXT and one of its immediate |
| 136617 | +** children is a column that matches one of the columns in |
| 136618 | +** pWalker->u.pConst. |
| 136619 | +*/ |
| 136620 | +static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){ |
| 136621 | + WhereConst *pConst = pWalker->u.pConst; |
| 136622 | + assert( TK_GT==TK_EQ+1 ); |
| 136623 | + assert( TK_LE==TK_EQ+2 ); |
| 136624 | + assert( TK_LT==TK_EQ+3 ); |
| 136625 | + assert( TK_GE==TK_EQ+4 ); |
| 136626 | + if( pConst->bHasAffBlob ){ |
| 136627 | + if( (pExpr->op>=TK_EQ && pExpr->op<=TK_GE) |
| 136628 | + || pExpr->op==TK_IS |
| 136629 | + ){ |
| 136630 | + propagateConstantExprRewriteOne(pConst, pExpr->pLeft, 0); |
| 136631 | + if( pConst->pOomFault[0] ) return WRC_Prune; |
| 136632 | + if( sqlite3ExprAffinity(pExpr->pLeft)!=SQLITE_AFF_TEXT ){ |
| 136633 | + propagateConstantExprRewriteOne(pConst, pExpr->pRight, 0); |
| 136634 | + } |
| 136635 | + } |
| 136636 | + } |
| 136637 | + return propagateConstantExprRewriteOne(pConst, pExpr, pConst->bHasAffBlob); |
| 136638 | +} |
| 135949 | 136639 | |
| 135950 | 136640 | /* |
| 135951 | 136641 | ** The WHERE-clause constant propagation optimization. |
| 135952 | 136642 | ** |
| 135953 | 136643 | ** If the WHERE clause contains terms of the form COLUMN=CONSTANT or |
| | @@ -135980,23 +136670,40 @@ |
| 135980 | 136670 | ** "b=a" to "b=123" but rather the "a" in "b=a" is tagged with EP_FixedCol |
| 135981 | 136671 | ** and the "123" value is hung off of the pLeft pointer. Code generator |
| 135982 | 136672 | ** routines know to generate the constant "123" instead of looking up the |
| 135983 | 136673 | ** column value. Also, to avoid collation problems, this optimization is |
| 135984 | 136674 | ** only attempted if the "a=123" term uses the default BINARY collation. |
| 136675 | +** |
| 136676 | +** 2021-05-25 forum post 6a06202608: Another troublesome case is... |
| 136677 | +** |
| 136678 | +** CREATE TABLE t1(x); |
| 136679 | +** INSERT INTO t1 VALUES(10.0); |
| 136680 | +** SELECT 1 FROM t1 WHERE x=10 AND x LIKE 10; |
| 136681 | +** |
| 136682 | +** The query should return no rows, because the t1.x value is '10.0' not '10' |
| 136683 | +** and '10.0' is not LIKE '10'. But if we are not careful, the first WHERE |
| 136684 | +** term "x=10" will cause the second WHERE term to become "10 LIKE 10", |
| 136685 | +** resulting in a false positive. To avoid this, constant propagation for |
| 136686 | +** columns with BLOB affinity is only allowed if the constant is used with |
| 136687 | +** operators ==, <=, <, >=, >, or IS in a way that will cause the correct |
| 136688 | +** type conversions to occur. See logic associated with the bHasAffBlob flag |
| 136689 | +** for details. |
| 135985 | 136690 | */ |
| 135986 | 136691 | static int propagateConstants( |
| 135987 | 136692 | Parse *pParse, /* The parsing context */ |
| 135988 | 136693 | Select *p /* The query in which to propagate constants */ |
| 135989 | 136694 | ){ |
| 135990 | 136695 | WhereConst x; |
| 135991 | 136696 | Walker w; |
| 135992 | 136697 | int nChng = 0; |
| 135993 | 136698 | x.pParse = pParse; |
| 136699 | + x.pOomFault = &pParse->db->mallocFailed; |
| 135994 | 136700 | do{ |
| 135995 | 136701 | x.nConst = 0; |
| 135996 | 136702 | x.nChng = 0; |
| 135997 | 136703 | x.apExpr = 0; |
| 136704 | + x.bHasAffBlob = 0; |
| 135998 | 136705 | findConstInWhere(&x, p->pWhere); |
| 135999 | 136706 | if( x.nConst ){ |
| 136000 | 136707 | memset(&w, 0, sizeof(w)); |
| 136001 | 136708 | w.pParse = pParse; |
| 136002 | 136709 | w.xExprCallback = propagateConstantExprRewrite; |
| | @@ -136429,36 +137136,47 @@ |
| 136429 | 137136 | if( sqlite3StrICmp(zName, p->a[i].zName)==0 ){ |
| 136430 | 137137 | *ppContext = p; |
| 136431 | 137138 | return &p->a[i]; |
| 136432 | 137139 | } |
| 136433 | 137140 | } |
| 137141 | + if( p->bView ) break; |
| 136434 | 137142 | } |
| 136435 | 137143 | return 0; |
| 136436 | 137144 | } |
| 136437 | 137145 | |
| 136438 | 137146 | /* The code generator maintains a stack of active WITH clauses |
| 136439 | 137147 | ** with the inner-most WITH clause being at the top of the stack. |
| 136440 | 137148 | ** |
| 136441 | 137149 | ** This routine pushes the WITH clause passed as the second argument |
| 136442 | 137150 | ** onto the top of the stack. If argument bFree is true, then this |
| 136443 | | -** WITH clause will never be popped from the stack. In this case it |
| 136444 | | -** should be freed along with the Parse object. In other cases, when |
| 137151 | +** WITH clause will never be popped from the stack but should instead |
| 137152 | +** be freed along with the Parse object. In other cases, when |
| 136445 | 137153 | ** bFree==0, the With object will be freed along with the SELECT |
| 136446 | 137154 | ** statement with which it is associated. |
| 137155 | +** |
| 137156 | +** This routine returns a copy of pWith. Or, if bFree is true and |
| 137157 | +** the pWith object is destroyed immediately due to an OOM condition, |
| 137158 | +** then this routine return NULL. |
| 137159 | +** |
| 137160 | +** If bFree is true, do not continue to use the pWith pointer after |
| 137161 | +** calling this routine, Instead, use only the return value. |
| 136447 | 137162 | */ |
| 136448 | | -SQLITE_PRIVATE void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){ |
| 137163 | +SQLITE_PRIVATE With *sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){ |
| 136449 | 137164 | if( pWith ){ |
| 136450 | | - assert( pParse->pWith!=pWith ); |
| 136451 | | - pWith->pOuter = pParse->pWith; |
| 136452 | | - pParse->pWith = pWith; |
| 136453 | 137165 | if( bFree ){ |
| 136454 | | - sqlite3ParserAddCleanup(pParse, |
| 136455 | | - (void(*)(sqlite3*,void*))sqlite3WithDelete, |
| 136456 | | - pWith); |
| 136457 | | - testcase( pParse->earlyCleanup ); |
| 137166 | + pWith = (With*)sqlite3ParserAddCleanup(pParse, |
| 137167 | + (void(*)(sqlite3*,void*))sqlite3WithDelete, |
| 137168 | + pWith); |
| 137169 | + if( pWith==0 ) return 0; |
| 137170 | + } |
| 137171 | + if( pParse->nErr==0 ){ |
| 137172 | + assert( pParse->pWith!=pWith ); |
| 137173 | + pWith->pOuter = pParse->pWith; |
| 137174 | + pParse->pWith = pWith; |
| 136458 | 137175 | } |
| 136459 | 137176 | } |
| 137177 | + return pWith; |
| 136460 | 137178 | } |
| 136461 | 137179 | |
| 136462 | 137180 | /* |
| 136463 | 137181 | ** This function checks if argument pFrom refers to a CTE declared by |
| 136464 | 137182 | ** a WITH clause on the stack currently maintained by the parser (on the |
| | @@ -136483,15 +137201,28 @@ |
| 136483 | 137201 | |
| 136484 | 137202 | assert( pFrom->pTab==0 ); |
| 136485 | 137203 | if( pParse->pWith==0 ){ |
| 136486 | 137204 | /* There are no WITH clauses in the stack. No match is possible */ |
| 136487 | 137205 | return 0; |
| 137206 | + } |
| 137207 | + if( pParse->nErr ){ |
| 137208 | + /* Prior errors might have left pParse->pWith in a goofy state, so |
| 137209 | + ** go no further. */ |
| 137210 | + return 0; |
| 136488 | 137211 | } |
| 136489 | 137212 | if( pFrom->zDatabase!=0 ){ |
| 136490 | 137213 | /* The FROM term contains a schema qualifier (ex: main.t1) and so |
| 136491 | 137214 | ** it cannot possibly be a CTE reference. */ |
| 136492 | 137215 | return 0; |
| 137216 | + } |
| 137217 | + if( pFrom->fg.notCte ){ |
| 137218 | + /* The FROM term is specifically excluded from matching a CTE. |
| 137219 | + ** (1) It is part of a trigger that used to have zDatabase but had |
| 137220 | + ** zDatabase removed by sqlite3FixTriggerStep(). |
| 137221 | + ** (2) This is the first term in the FROM clause of an UPDATE. |
| 137222 | + */ |
| 137223 | + return 0; |
| 136493 | 137224 | } |
| 136494 | 137225 | pCte = searchWith(pParse->pWith, pFrom, &pWith); |
| 136495 | 137226 | if( pCte ){ |
| 136496 | 137227 | sqlite3 *db = pParse->db; |
| 136497 | 137228 | Table *pTab; |
| | @@ -136534,10 +137265,11 @@ |
| 136534 | 137265 | pTab->iPKey = -1; |
| 136535 | 137266 | pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); |
| 136536 | 137267 | pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid; |
| 136537 | 137268 | pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0); |
| 136538 | 137269 | if( db->mallocFailed ) return 2; |
| 137270 | + pFrom->pSelect->selFlags |= SF_CopyCte; |
| 136539 | 137271 | assert( pFrom->pSelect ); |
| 136540 | 137272 | pFrom->fg.isCte = 1; |
| 136541 | 137273 | pFrom->u2.pCteUse = pCteUse; |
| 136542 | 137274 | pCteUse->nUse++; |
| 136543 | 137275 | if( pCteUse->nUse>=2 && pCteUse->eM10d==M10d_Any ){ |
| | @@ -136637,22 +137369,20 @@ |
| 136637 | 137369 | ** |
| 136638 | 137370 | ** This function is used as the xSelectCallback2() callback by |
| 136639 | 137371 | ** sqlite3SelectExpand() when walking a SELECT tree to resolve table |
| 136640 | 137372 | ** names and other FROM clause elements. |
| 136641 | 137373 | */ |
| 136642 | | -static void selectPopWith(Walker *pWalker, Select *p){ |
| 137374 | +SQLITE_PRIVATE void sqlite3SelectPopWith(Walker *pWalker, Select *p){ |
| 136643 | 137375 | Parse *pParse = pWalker->pParse; |
| 136644 | 137376 | if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){ |
| 136645 | 137377 | With *pWith = findRightmost(p)->pWith; |
| 136646 | 137378 | if( pWith!=0 ){ |
| 136647 | 137379 | assert( pParse->pWith==pWith || pParse->nErr ); |
| 136648 | 137380 | pParse->pWith = pWith->pOuter; |
| 136649 | 137381 | } |
| 136650 | 137382 | } |
| 136651 | 137383 | } |
| 136652 | | -#else |
| 136653 | | -#define selectPopWith 0 |
| 136654 | 137384 | #endif |
| 136655 | 137385 | |
| 136656 | 137386 | /* |
| 136657 | 137387 | ** The SrcList_item structure passed as the second argument represents a |
| 136658 | 137388 | ** sub-query in the FROM clause of a SELECT statement. This function |
| | @@ -136735,10 +137465,19 @@ |
| 136735 | 137465 | /* Renumber selId because it has been copied from a view */ |
| 136736 | 137466 | p->selId = ++pParse->nSelect; |
| 136737 | 137467 | } |
| 136738 | 137468 | pTabList = p->pSrc; |
| 136739 | 137469 | pEList = p->pEList; |
| 137470 | + if( pParse->pWith && (p->selFlags & SF_View) ){ |
| 137471 | + if( p->pWith==0 ){ |
| 137472 | + p->pWith = (With*)sqlite3DbMallocZero(db, sizeof(With)); |
| 137473 | + if( p->pWith==0 ){ |
| 137474 | + return WRC_Abort; |
| 137475 | + } |
| 137476 | + } |
| 137477 | + p->pWith->bView = 1; |
| 137478 | + } |
| 136740 | 137479 | sqlite3WithPush(pParse, p->pWith, 0); |
| 136741 | 137480 | |
| 136742 | 137481 | /* Make sure cursor numbers have been assigned to all entries in |
| 136743 | 137482 | ** the FROM clause of the SELECT statement. |
| 136744 | 137483 | */ |
| | @@ -136795,10 +137534,11 @@ |
| 136795 | 137534 | ){ |
| 136796 | 137535 | sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited", |
| 136797 | 137536 | pTab->zName); |
| 136798 | 137537 | } |
| 136799 | 137538 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 137539 | + assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 ); |
| 136800 | 137540 | if( IsVirtual(pTab) |
| 136801 | 137541 | && pFrom->fg.fromDDL |
| 136802 | 137542 | && ALWAYS(pTab->pVTable!=0) |
| 136803 | 137543 | && pTab->pVTable->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0) |
| 136804 | 137544 | ){ |
| | @@ -137035,11 +137775,11 @@ |
| 137035 | 137775 | w.xSelectCallback = convertCompoundSelectToSubquery; |
| 137036 | 137776 | w.xSelectCallback2 = 0; |
| 137037 | 137777 | sqlite3WalkSelect(&w, pSelect); |
| 137038 | 137778 | } |
| 137039 | 137779 | w.xSelectCallback = selectExpander; |
| 137040 | | - w.xSelectCallback2 = selectPopWith; |
| 137780 | + w.xSelectCallback2 = sqlite3SelectPopWith; |
| 137041 | 137781 | w.eCode = 0; |
| 137042 | 137782 | sqlite3WalkSelect(&w, pSelect); |
| 137043 | 137783 | } |
| 137044 | 137784 | |
| 137045 | 137785 | |
| | @@ -137622,16 +138362,15 @@ |
| 137622 | 138362 | } |
| 137623 | 138363 | } |
| 137624 | 138364 | } |
| 137625 | 138365 | |
| 137626 | 138366 | if( pDest->eDest==SRT_Output ){ |
| 137627 | | - generateColumnNames(pParse, p); |
| 138367 | + sqlite3GenerateColumnNames(pParse, p); |
| 137628 | 138368 | } |
| 137629 | 138369 | |
| 137630 | 138370 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 137631 | | - rc = sqlite3WindowRewrite(pParse, p); |
| 137632 | | - if( rc ){ |
| 138371 | + if( sqlite3WindowRewrite(pParse, p) ){ |
| 137633 | 138372 | assert( db->mallocFailed || pParse->nErr>0 ); |
| 137634 | 138373 | goto select_end; |
| 137635 | 138374 | } |
| 137636 | 138375 | #if SELECTTRACE_ENABLED |
| 137637 | 138376 | if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){ |
| | @@ -137753,11 +138492,12 @@ |
| 137753 | 138492 | /* Do the WHERE-clause constant propagation optimization if this is |
| 137754 | 138493 | ** a join. No need to speed time on this operation for non-join queries |
| 137755 | 138494 | ** as the equivalent optimization will be handled by query planner in |
| 137756 | 138495 | ** sqlite3WhereBegin(). |
| 137757 | 138496 | */ |
| 137758 | | - if( pTabList->nSrc>1 |
| 138497 | + if( p->pWhere!=0 |
| 138498 | + && p->pWhere->op==TK_AND |
| 137759 | 138499 | && OptimizationEnabled(db, SQLITE_PropagateConst) |
| 137760 | 138500 | && propagateConstants(pParse, p) |
| 137761 | 138501 | ){ |
| 137762 | 138502 | #if SELECTTRACE_ENABLED |
| 137763 | 138503 | if( sqlite3SelectTrace & 0x100 ){ |
| | @@ -137816,23 +138556,12 @@ |
| 137816 | 138556 | /* Generate code for all sub-queries in the FROM clause |
| 137817 | 138557 | */ |
| 137818 | 138558 | pSub = pItem->pSelect; |
| 137819 | 138559 | if( pSub==0 ) continue; |
| 137820 | 138560 | |
| 137821 | | - /* The code for a subquery should only be generated once, though it is |
| 137822 | | - ** technically harmless for it to be generated multiple times. The |
| 137823 | | - ** following assert() will detect if something changes to cause |
| 137824 | | - ** the same subquery to be coded multiple times, as a signal to the |
| 137825 | | - ** developers to try to optimize the situation. |
| 137826 | | - ** |
| 137827 | | - ** Update 2019-07-24: |
| 137828 | | - ** See ticket https://sqlite.org/src/tktview/c52b09c7f38903b1311cec40. |
| 137829 | | - ** The dbsqlfuzz fuzzer found a case where the same subquery gets |
| 137830 | | - ** coded twice. So this assert() now becomes a testcase(). It should |
| 137831 | | - ** be very rare, though. |
| 137832 | | - */ |
| 137833 | | - testcase( pItem->addrFillSub!=0 ); |
| 138561 | + /* The code for a subquery should only be generated once. */ |
| 138562 | + assert( pItem->addrFillSub==0 ); |
| 137834 | 138563 | |
| 137835 | 138564 | /* Increment Parse.nHeight by the height of the largest expression |
| 137836 | 138565 | ** tree referred to by this, the parent select. The child select |
| 137837 | 138566 | ** may contain expression trees of at most |
| 137838 | 138567 | ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit |
| | @@ -137915,18 +138644,17 @@ |
| 137915 | 138644 | sqlite3VdbeAddOp2(v, OP_Gosub, pPrior->regReturn, pPrior->addrFillSub); |
| 137916 | 138645 | } |
| 137917 | 138646 | sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); |
| 137918 | 138647 | pSub->nSelectRow = pPrior->pSelect->nSelectRow; |
| 137919 | 138648 | }else{ |
| 137920 | | - /* Materalize the view. If the view is not correlated, generate a |
| 138649 | + /* Materialize the view. If the view is not correlated, generate a |
| 137921 | 138650 | ** subroutine to do the materialization so that subsequent uses of |
| 137922 | 138651 | ** the same view can reuse the materialization. */ |
| 137923 | 138652 | int topAddr; |
| 137924 | 138653 | int onceAddr = 0; |
| 137925 | 138654 | int retAddr; |
| 137926 | 138655 | |
| 137927 | | - testcase( pItem->addrFillSub==0 ); /* Ticket c52b09c7f38903b1311 */ |
| 137928 | 138656 | pItem->regReturn = ++pParse->nMem; |
| 137929 | 138657 | topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn); |
| 137930 | 138658 | pItem->addrFillSub = topAddr+1; |
| 137931 | 138659 | if( pItem->fg.isCorrelated==0 ){ |
| 137932 | 138660 | /* If the subquery is not correlated and if we are not inside of |
| | @@ -138344,12 +139072,14 @@ |
| 138344 | 139072 | sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset); |
| 138345 | 139073 | SELECTTRACE(1,pParse,p,("WhereBegin\n")); |
| 138346 | 139074 | pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, pDistinct, |
| 138347 | 139075 | WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0) | distFlag, 0 |
| 138348 | 139076 | ); |
| 138349 | | - sqlite3ExprListDelete(db, pDistinct); |
| 138350 | | - if( pWInfo==0 ) goto select_end; |
| 139077 | + if( pWInfo==0 ){ |
| 139078 | + sqlite3ExprListDelete(db, pDistinct); |
| 139079 | + goto select_end; |
| 139080 | + } |
| 138351 | 139081 | eDist = sqlite3WhereIsDistinct(pWInfo); |
| 138352 | 139082 | SELECTTRACE(1,pParse,p,("WhereBegin returns\n")); |
| 138353 | 139083 | if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr ){ |
| 138354 | 139084 | /* The optimizer is able to deliver rows in group by order so |
| 138355 | 139085 | ** we do not have to sort. The OP_OpenEphemeral table will be |
| | @@ -138478,10 +139208,11 @@ |
| 138478 | 139208 | }else{ |
| 138479 | 139209 | SELECTTRACE(1,pParse,p,("WhereEnd\n")); |
| 138480 | 139210 | sqlite3WhereEnd(pWInfo); |
| 138481 | 139211 | sqlite3VdbeChangeToNoop(v, addrSortingIdx); |
| 138482 | 139212 | } |
| 139213 | + sqlite3ExprListDelete(db, pDistinct); |
| 138483 | 139214 | |
| 138484 | 139215 | /* Output the final row of result |
| 138485 | 139216 | */ |
| 138486 | 139217 | sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow); |
| 138487 | 139218 | VdbeComment((v, "output final row")); |
| | @@ -138692,10 +139423,12 @@ |
| 138692 | 139423 | |
| 138693 | 139424 | /* Control jumps to here if an error is encountered above, or upon |
| 138694 | 139425 | ** successful coding of the SELECT. |
| 138695 | 139426 | */ |
| 138696 | 139427 | select_end: |
| 139428 | + assert( db->mallocFailed==0 || db->mallocFailed==1 ); |
| 139429 | + pParse->nErr += db->mallocFailed; |
| 138697 | 139430 | sqlite3ExprListDelete(db, pMinMaxOrderBy); |
| 138698 | 139431 | #ifdef SQLITE_DEBUG |
| 138699 | 139432 | if( pAggInfo && !db->mallocFailed ){ |
| 138700 | 139433 | for(i=0; i<pAggInfo->nColumn; i++){ |
| 138701 | 139434 | Expr *pExpr = pAggInfo->aCol[i].pCExpr; |
| | @@ -138982,37 +139715,45 @@ |
| 138982 | 139715 | if( pParse->disableTriggers ){ |
| 138983 | 139716 | return 0; |
| 138984 | 139717 | } |
| 138985 | 139718 | pTmpSchema = pParse->db->aDb[1].pSchema; |
| 138986 | 139719 | p = sqliteHashFirst(&pTmpSchema->trigHash); |
| 138987 | | - if( p==0 ){ |
| 138988 | | - return pTab->pTrigger; |
| 138989 | | - } |
| 138990 | 139720 | pList = pTab->pTrigger; |
| 138991 | | - if( pTmpSchema!=pTab->pSchema ){ |
| 138992 | | - while( p ){ |
| 138993 | | - Trigger *pTrig = (Trigger *)sqliteHashData(p); |
| 138994 | | - if( pTrig->pTabSchema==pTab->pSchema |
| 138995 | | - && 0==sqlite3StrICmp(pTrig->table, pTab->zName) |
| 138996 | | - ){ |
| 138997 | | - pTrig->pNext = pList; |
| 138998 | | - pList = pTrig; |
| 138999 | | - }else if( pTrig->op==TK_RETURNING |
| 139721 | + while( p ){ |
| 139722 | + Trigger *pTrig = (Trigger *)sqliteHashData(p); |
| 139723 | + if( pTrig->pTabSchema==pTab->pSchema |
| 139724 | + && pTrig->table |
| 139725 | + && 0==sqlite3StrICmp(pTrig->table, pTab->zName) |
| 139726 | + && pTrig->pTabSchema!=pTmpSchema |
| 139727 | + ){ |
| 139728 | + pTrig->pNext = pList; |
| 139729 | + pList = pTrig; |
| 139730 | + }else if( pTrig->op==TK_RETURNING |
| 139000 | 139731 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 139001 | | - && pParse->db->pVtabCtx==0 |
| 139732 | + && pParse->db->pVtabCtx==0 |
| 139002 | 139733 | #endif |
| 139003 | | - ){ |
| 139004 | | - assert( pParse->bReturning ); |
| 139005 | | - assert( &(pParse->u1.pReturning->retTrig) == pTrig ); |
| 139006 | | - pTrig->table = pTab->zName; |
| 139007 | | - pTrig->pTabSchema = pTab->pSchema; |
| 139008 | | - pTrig->pNext = pList; |
| 139009 | | - pList = pTrig; |
| 139010 | | - } |
| 139011 | | - p = sqliteHashNext(p); |
| 139012 | | - } |
| 139013 | | - } |
| 139734 | + ){ |
| 139735 | + assert( pParse->bReturning ); |
| 139736 | + assert( &(pParse->u1.pReturning->retTrig) == pTrig ); |
| 139737 | + pTrig->table = pTab->zName; |
| 139738 | + pTrig->pTabSchema = pTab->pSchema; |
| 139739 | + pTrig->pNext = pList; |
| 139740 | + pList = pTrig; |
| 139741 | + } |
| 139742 | + p = sqliteHashNext(p); |
| 139743 | + } |
| 139744 | +#if 0 |
| 139745 | + if( pList ){ |
| 139746 | + Trigger *pX; |
| 139747 | + printf("Triggers for %s:", pTab->zName); |
| 139748 | + for(pX=pList; pX; pX=pX->pNext){ |
| 139749 | + printf(" %s", pX->zName); |
| 139750 | + } |
| 139751 | + printf("\n"); |
| 139752 | + fflush(stdout); |
| 139753 | + } |
| 139754 | +#endif |
| 139014 | 139755 | return pList; |
| 139015 | 139756 | } |
| 139016 | 139757 | |
| 139017 | 139758 | /* |
| 139018 | 139759 | ** This is called by the parser when it sees a CREATE TRIGGER statement |
| | @@ -139812,19 +140553,10 @@ |
| 139812 | 140553 | pItem->zEName = sqlite3DbStrDup(db, pList->a[i].zEName); |
| 139813 | 140554 | pItem->eEName = pList->a[i].eEName; |
| 139814 | 140555 | } |
| 139815 | 140556 | } |
| 139816 | 140557 | } |
| 139817 | | - if( !db->mallocFailed ){ |
| 139818 | | - Vdbe *v = pParse->pVdbe; |
| 139819 | | - assert( v!=0 ); |
| 139820 | | - sqlite3VdbeSetNumCols(v, pNew->nExpr); |
| 139821 | | - for(i=0; i<pNew->nExpr; i++){ |
| 139822 | | - sqlite3VdbeSetColName(v, i, COLNAME_NAME, pNew->a[i].zEName, |
| 139823 | | - SQLITE_TRANSIENT); |
| 139824 | | - } |
| 139825 | | - } |
| 139826 | 140558 | return pNew; |
| 139827 | 140559 | } |
| 139828 | 140560 | |
| 139829 | 140561 | /* |
| 139830 | 140562 | ** Generate code for the RETURNING trigger. Unlike other triggers |
| | @@ -139836,17 +140568,31 @@ |
| 139836 | 140568 | Trigger *pTrigger, /* The trigger step that defines the RETURNING */ |
| 139837 | 140569 | Table *pTab, /* The table to code triggers from */ |
| 139838 | 140570 | int regIn /* The first in an array of registers */ |
| 139839 | 140571 | ){ |
| 139840 | 140572 | Vdbe *v = pParse->pVdbe; |
| 140573 | + sqlite3 *db = pParse->db; |
| 139841 | 140574 | ExprList *pNew; |
| 139842 | 140575 | Returning *pReturning; |
| 140576 | + Select sSelect; |
| 140577 | + SrcList sFrom; |
| 139843 | 140578 | |
| 139844 | 140579 | assert( v!=0 ); |
| 139845 | 140580 | assert( pParse->bReturning ); |
| 139846 | 140581 | pReturning = pParse->u1.pReturning; |
| 139847 | 140582 | assert( pTrigger == &(pReturning->retTrig) ); |
| 140583 | + memset(&sSelect, 0, sizeof(sSelect)); |
| 140584 | + memset(&sFrom, 0, sizeof(sFrom)); |
| 140585 | + sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0); |
| 140586 | + sSelect.pSrc = &sFrom; |
| 140587 | + sFrom.nSrc = 1; |
| 140588 | + sFrom.a[0].pTab = pTab; |
| 140589 | + sqlite3SelectPrep(pParse, &sSelect, 0); |
| 140590 | + if( db->mallocFailed==0 && pParse->nErr==0 ){ |
| 140591 | + sqlite3GenerateColumnNames(pParse, &sSelect); |
| 140592 | + } |
| 140593 | + sqlite3ExprListDelete(db, sSelect.pEList); |
| 139848 | 140594 | pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab); |
| 139849 | 140595 | if( pNew ){ |
| 139850 | 140596 | NameContext sNC; |
| 139851 | 140597 | memset(&sNC, 0, sizeof(sNC)); |
| 139852 | 140598 | if( pReturning->nRetCol==0 ){ |
| | @@ -139863,17 +140609,18 @@ |
| 139863 | 140609 | int nCol = pNew->nExpr; |
| 139864 | 140610 | int reg = pParse->nMem+1; |
| 139865 | 140611 | pParse->nMem += nCol+2; |
| 139866 | 140612 | pReturning->iRetReg = reg; |
| 139867 | 140613 | for(i=0; i<nCol; i++){ |
| 139868 | | - sqlite3ExprCodeFactorable(pParse, pNew->a[i].pExpr, reg+i); |
| 140614 | + Expr *pCol = pNew->a[i].pExpr; |
| 140615 | + sqlite3ExprCodeFactorable(pParse, pCol, reg+i); |
| 139869 | 140616 | } |
| 139870 | 140617 | sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i); |
| 139871 | 140618 | sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1); |
| 139872 | 140619 | sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1); |
| 139873 | 140620 | } |
| 139874 | | - sqlite3ExprListDelete(pParse->db, pNew); |
| 140621 | + sqlite3ExprListDelete(db, pNew); |
| 139875 | 140622 | pParse->eTriggerOp = 0; |
| 139876 | 140623 | pParse->pTriggerTab = 0; |
| 139877 | 140624 | } |
| 139878 | 140625 | } |
| 139879 | 140626 | |
| | @@ -140552,10 +141299,11 @@ |
| 140552 | 141299 | pSrc = sqlite3SrcListDup(db, pTabList, 0); |
| 140553 | 141300 | pWhere2 = sqlite3ExprDup(db, pWhere, 0); |
| 140554 | 141301 | |
| 140555 | 141302 | assert( pTabList->nSrc>1 ); |
| 140556 | 141303 | if( pSrc ){ |
| 141304 | + pSrc->a[0].fg.notCte = 1; |
| 140557 | 141305 | pSrc->a[0].iCursor = -1; |
| 140558 | 141306 | pSrc->a[0].pTab->nTabRef--; |
| 140559 | 141307 | pSrc->a[0].pTab = 0; |
| 140560 | 141308 | } |
| 140561 | 141309 | if( pPk ){ |
| | @@ -140581,11 +141329,12 @@ |
| 140581 | 141329 | if( pLimit ){ |
| 140582 | 141330 | pGrp = sqlite3ExprListAppend(pParse, 0, sqlite3PExpr(pParse,TK_ROW,0,0)); |
| 140583 | 141331 | } |
| 140584 | 141332 | #endif |
| 140585 | 141333 | } |
| 140586 | | - if( ALWAYS(pChanges) ){ |
| 141334 | + assert( pChanges!=0 || pParse->db->mallocFailed ); |
| 141335 | + if( pChanges ){ |
| 140587 | 141336 | for(i=0; i<pChanges->nExpr; i++){ |
| 140588 | 141337 | pList = sqlite3ExprListAppend(pParse, pList, |
| 140589 | 141338 | sqlite3ExprDup(db, pChanges->a[i].pExpr, 0) |
| 140590 | 141339 | ); |
| 140591 | 141340 | } |
| | @@ -143607,10 +144356,11 @@ |
| 143607 | 144356 | pMod->pEpoTab = pTab; |
| 143608 | 144357 | pTab->nTabRef = 1; |
| 143609 | 144358 | pTab->pSchema = db->aDb[0].pSchema; |
| 143610 | 144359 | assert( pTab->nModuleArg==0 ); |
| 143611 | 144360 | pTab->iPKey = -1; |
| 144361 | + pTab->tabFlags |= TF_Eponymous; |
| 143612 | 144362 | addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName)); |
| 143613 | 144363 | addModuleArgument(pParse, pTab, 0); |
| 143614 | 144364 | addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName)); |
| 143615 | 144365 | rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr); |
| 143616 | 144366 | if( rc ){ |
| | @@ -144023,12 +144773,12 @@ |
| 144023 | 144773 | WhereClause *pOrigWC; /* Original, innermost WhereClause */ |
| 144024 | 144774 | WhereClause *pWC; /* WhereClause currently being scanned */ |
| 144025 | 144775 | const char *zCollName; /* Required collating sequence, if not NULL */ |
| 144026 | 144776 | Expr *pIdxExpr; /* Search for this index expression */ |
| 144027 | 144777 | char idxaff; /* Must match this affinity, if zCollName!=NULL */ |
| 144028 | | - unsigned char nEquiv; /* Number of entries in aEquiv[] */ |
| 144029 | | - unsigned char iEquiv; /* Next unused slot in aEquiv[] */ |
| 144778 | + unsigned char nEquiv; /* Number of entries in aiCur[] and aiColumn[] */ |
| 144779 | + unsigned char iEquiv; /* Next unused slot in aiCur[] and aiColumn[] */ |
| 144030 | 144780 | u32 opMask; /* Acceptable operators */ |
| 144031 | 144781 | int k; /* Resume scanning at this->pWC->a[this->k] */ |
| 144032 | 144782 | int aiCur[11]; /* Cursors in the equivalence class */ |
| 144033 | 144783 | i16 aiColumn[11]; /* Corresponding column number in the eq-class */ |
| 144034 | 144784 | }; |
| | @@ -144333,10 +145083,11 @@ |
| 144333 | 145083 | #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/ |
| 144334 | 145084 | #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */ |
| 144335 | 145085 | #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */ |
| 144336 | 145086 | #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */ |
| 144337 | 145087 | #define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */ |
| 145088 | +#define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */ |
| 144338 | 145089 | |
| 144339 | 145090 | #endif /* !defined(SQLITE_WHEREINT_H) */ |
| 144340 | 145091 | |
| 144341 | 145092 | /************** End of whereInt.h ********************************************/ |
| 144342 | 145093 | /************** Continuing where we left off in wherecode.c ******************/ |
| | @@ -144616,10 +145367,16 @@ |
| 144616 | 145367 | if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){ |
| 144617 | 145368 | pTerm->wtFlags |= TERM_LIKECOND; |
| 144618 | 145369 | }else{ |
| 144619 | 145370 | pTerm->wtFlags |= TERM_CODED; |
| 144620 | 145371 | } |
| 145372 | +#ifdef WHERETRACE_ENABLED |
| 145373 | + if( sqlite3WhereTrace & 0x20000 ){ |
| 145374 | + sqlite3DebugPrintf("DISABLE-"); |
| 145375 | + sqlite3WhereTermPrint(pTerm, (int)(pTerm - (pTerm->pWC->a))); |
| 145376 | + } |
| 145377 | +#endif |
| 144621 | 145378 | if( pTerm->iParent<0 ) break; |
| 144622 | 145379 | pTerm = &pTerm->pWC->a[pTerm->iParent]; |
| 144623 | 145380 | assert( pTerm!=0 ); |
| 144624 | 145381 | pTerm->nChild--; |
| 144625 | 145382 | if( pTerm->nChild!=0 ) break; |
| | @@ -144933,11 +145690,26 @@ |
| 144933 | 145690 | pLevel->u.in.nIn = 0; |
| 144934 | 145691 | } |
| 144935 | 145692 | sqlite3DbFree(pParse->db, aiMap); |
| 144936 | 145693 | #endif |
| 144937 | 145694 | } |
| 144938 | | - disableTerm(pLevel, pTerm); |
| 145695 | + |
| 145696 | + /* As an optimization, try to disable the WHERE clause term that is |
| 145697 | + ** driving the index as it will always be true. The correct answer is |
| 145698 | + ** obtained regardless, but we might get the answer with fewer CPU cycles |
| 145699 | + ** by omitting the term. |
| 145700 | + ** |
| 145701 | + ** But do not disable the term unless we are certain that the term is |
| 145702 | + ** not a transitive constraint. For an example of where that does not |
| 145703 | + ** work, see https://sqlite.org/forum/forumpost/eb8613976a (2021-05-04) |
| 145704 | + */ |
| 145705 | + if( (pLevel->pWLoop->wsFlags & WHERE_TRANSCONS)==0 |
| 145706 | + || (pTerm->eOperator & WO_EQUIV)==0 |
| 145707 | + ){ |
| 145708 | + disableTerm(pLevel, pTerm); |
| 145709 | + } |
| 145710 | + |
| 144939 | 145711 | return iReg; |
| 144940 | 145712 | } |
| 144941 | 145713 | |
| 144942 | 145714 | /* |
| 144943 | 145715 | ** Generate code that will evaluate all == and IN constraints for an |
| | @@ -145019,10 +145791,11 @@ |
| 145019 | 145791 | zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx)); |
| 145020 | 145792 | assert( zAff!=0 || pParse->db->mallocFailed ); |
| 145021 | 145793 | |
| 145022 | 145794 | if( nSkip ){ |
| 145023 | 145795 | int iIdxCur = pLevel->iIdxCur; |
| 145796 | + sqlite3VdbeAddOp3(v, OP_Null, 0, regBase, regBase+nSkip-1); |
| 145024 | 145797 | sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur); |
| 145025 | 145798 | VdbeCoverageIf(v, bRev==0); |
| 145026 | 145799 | VdbeCoverageIf(v, bRev!=0); |
| 145027 | 145800 | VdbeComment((v, "begin skip-scan on %s", pIdx->zName)); |
| 145028 | 145801 | j = sqlite3VdbeAddOp0(v, OP_Goto); |
| | @@ -145053,11 +145826,11 @@ |
| 145053 | 145826 | if( r1!=regBase+j ){ |
| 145054 | 145827 | if( nReg==1 ){ |
| 145055 | 145828 | sqlite3ReleaseTempReg(pParse, regBase); |
| 145056 | 145829 | regBase = r1; |
| 145057 | 145830 | }else{ |
| 145058 | | - sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j); |
| 145831 | + sqlite3VdbeAddOp2(v, OP_Copy, r1, regBase+j); |
| 145059 | 145832 | } |
| 145060 | 145833 | } |
| 145061 | 145834 | if( pTerm->eOperator & WO_IN ){ |
| 145062 | 145835 | if( pTerm->pExpr->flags & EP_xIsSelect ){ |
| 145063 | 145836 | /* No affinity ever needs to be (or should be) applied to a value |
| | @@ -145070,11 +145843,11 @@ |
| 145070 | 145843 | Expr *pRight = pTerm->pExpr->pRight; |
| 145071 | 145844 | if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){ |
| 145072 | 145845 | sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk); |
| 145073 | 145846 | VdbeCoverage(v); |
| 145074 | 145847 | } |
| 145075 | | - if( zAff ){ |
| 145848 | + if( pParse->db->mallocFailed==0 && pParse->nErr==0 ){ |
| 145076 | 145849 | if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){ |
| 145077 | 145850 | zAff[j] = SQLITE_AFF_BLOB; |
| 145078 | 145851 | } |
| 145079 | 145852 | if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){ |
| 145080 | 145853 | zAff[j] = SQLITE_AFF_BLOB; |
| | @@ -145419,11 +146192,11 @@ |
| 145419 | 146192 | for(i=0; i<nReg; i++){ |
| 145420 | 146193 | sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i); |
| 145421 | 146194 | } |
| 145422 | 146195 | } |
| 145423 | 146196 | }else{ |
| 145424 | | - assert( nReg==1 ); |
| 146197 | + assert( nReg==1 || pParse->nErr ); |
| 145425 | 146198 | sqlite3ExprCode(pParse, p, iReg); |
| 145426 | 146199 | } |
| 145427 | 146200 | } |
| 145428 | 146201 | |
| 145429 | 146202 | /* An instance of the IdxExprTrans object carries information about a |
| | @@ -146046,13 +146819,11 @@ |
| 146046 | 146819 | |
| 146047 | 146820 | /* If we are doing a reverse order scan on an ascending index, or |
| 146048 | 146821 | ** a forward order scan on a descending index, interchange the |
| 146049 | 146822 | ** start and end terms (pRangeStart and pRangeEnd). |
| 146050 | 146823 | */ |
| 146051 | | - if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC)) |
| 146052 | | - || (bRev && pIdx->nKeyCol==nEq) |
| 146053 | | - ){ |
| 146824 | + if( (nEq<pIdx->nColumn && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC)) ){ |
| 146054 | 146825 | SWAP(WhereTerm *, pRangeEnd, pRangeStart); |
| 146055 | 146826 | SWAP(u8, bSeekPastNull, bStopAtNull); |
| 146056 | 146827 | SWAP(u8, nBtm, nTop); |
| 146057 | 146828 | } |
| 146058 | 146829 | |
| | @@ -146469,11 +147240,11 @@ |
| 146469 | 147240 | } |
| 146470 | 147241 | if( pAndExpr ){ |
| 146471 | 147242 | /* The extra 0x10000 bit on the opcode is masked off and does not |
| 146472 | 147243 | ** become part of the new Expr.op. However, it does make the |
| 146473 | 147244 | ** op==TK_AND comparison inside of sqlite3PExpr() false, and this |
| 146474 | | - ** prevents sqlite3PExpr() from implementing AND short-circuit |
| 147245 | + ** prevents sqlite3PExpr() from applying the AND short-circuit |
| 146475 | 147246 | ** optimization, which we do not want here. */ |
| 146476 | 147247 | pAndExpr = sqlite3PExpr(pParse, TK_AND|0x10000, 0, pAndExpr); |
| 146477 | 147248 | } |
| 146478 | 147249 | } |
| 146479 | 147250 | |
| | @@ -146485,14 +147256,20 @@ |
| 146485 | 147256 | for(ii=0; ii<pOrWc->nTerm; ii++){ |
| 146486 | 147257 | WhereTerm *pOrTerm = &pOrWc->a[ii]; |
| 146487 | 147258 | if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){ |
| 146488 | 147259 | WhereInfo *pSubWInfo; /* Info for single OR-term scan */ |
| 146489 | 147260 | Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */ |
| 147261 | + Expr *pDelete; /* Local copy of OR clause term */ |
| 146490 | 147262 | int jmp1 = 0; /* Address of jump operation */ |
| 146491 | 147263 | testcase( (pTabItem[0].fg.jointype & JT_LEFT)!=0 |
| 146492 | 147264 | && !ExprHasProperty(pOrExpr, EP_FromJoin) |
| 146493 | 147265 | ); /* See TH3 vtab25.400 and ticket 614b25314c766238 */ |
| 147266 | + pDelete = pOrExpr = sqlite3ExprDup(db, pOrExpr, 0); |
| 147267 | + if( db->mallocFailed ){ |
| 147268 | + sqlite3ExprDelete(db, pDelete); |
| 147269 | + continue; |
| 147270 | + } |
| 146494 | 147271 | if( pAndExpr ){ |
| 146495 | 147272 | pAndExpr->pLeft = pOrExpr; |
| 146496 | 147273 | pOrExpr = pAndExpr; |
| 146497 | 147274 | } |
| 146498 | 147275 | /* Loop through table entries that match term pOrTerm. */ |
| | @@ -146603,10 +147380,11 @@ |
| 146603 | 147380 | |
| 146604 | 147381 | /* Finish the loop through table entries that match term pOrTerm. */ |
| 146605 | 147382 | sqlite3WhereEnd(pSubWInfo); |
| 146606 | 147383 | ExplainQueryPlanPop(pParse); |
| 146607 | 147384 | } |
| 147385 | + sqlite3ExprDelete(db, pDelete); |
| 146608 | 147386 | } |
| 146609 | 147387 | } |
| 146610 | 147388 | ExplainQueryPlanPop(pParse); |
| 146611 | 147389 | pLevel->u.pCovidx = pCov; |
| 146612 | 147390 | if( pCov ) pLevel->iIdxCur = iCovCur; |
| | @@ -147320,10 +148098,11 @@ |
| 147320 | 148098 | sqlite3 *db; /* Database connection (for malloc) */ |
| 147321 | 148099 | Expr *pNew; /* New virtual expression */ |
| 147322 | 148100 | int op; /* Operator for the combined expression */ |
| 147323 | 148101 | int idxNew; /* Index in pWC of the next virtual term */ |
| 147324 | 148102 | |
| 148103 | + if( (pOne->wtFlags | pTwo->wtFlags) & TERM_VNULL ) return; |
| 147325 | 148104 | if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return; |
| 147326 | 148105 | if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return; |
| 147327 | 148106 | if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp |
| 147328 | 148107 | && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return; |
| 147329 | 148108 | assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 ); |
| | @@ -147680,11 +148459,11 @@ |
| 147680 | 148459 | assert( !ExprHasProperty(pNew, EP_xIsSelect) ); |
| 147681 | 148460 | pNew->x.pList = pList; |
| 147682 | 148461 | idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC); |
| 147683 | 148462 | testcase( idxNew==0 ); |
| 147684 | 148463 | exprAnalyze(pSrc, pWC, idxNew); |
| 147685 | | - /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where used again */ |
| 148464 | + /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where reused */ |
| 147686 | 148465 | markTermAsChild(pWC, idxNew, idxTerm); |
| 147687 | 148466 | }else{ |
| 147688 | 148467 | sqlite3ExprListDelete(db, pList); |
| 147689 | 148468 | } |
| 147690 | 148469 | } |
| | @@ -147804,10 +148583,11 @@ |
| 147804 | 148583 | assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE ); |
| 147805 | 148584 | assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE ); |
| 147806 | 148585 | assert( op<=TK_GE ); |
| 147807 | 148586 | if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){ |
| 147808 | 148587 | pExpr = pExpr->x.pList->a[0].pExpr; |
| 148588 | + |
| 147809 | 148589 | } |
| 147810 | 148590 | |
| 147811 | 148591 | if( pExpr->op==TK_COLUMN ){ |
| 147812 | 148592 | aiCurCol[0] = pExpr->iTable; |
| 147813 | 148593 | aiCurCol[1] = pExpr->iColumn; |
| | @@ -147816,280 +148596,10 @@ |
| 147816 | 148596 | if( mPrereq==0 ) return 0; /* No table references */ |
| 147817 | 148597 | if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */ |
| 147818 | 148598 | return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr); |
| 147819 | 148599 | } |
| 147820 | 148600 | |
| 147821 | | -/* |
| 147822 | | -** Expression callback for exprUsesSrclist(). |
| 147823 | | -*/ |
| 147824 | | -static int exprUsesSrclistCb(Walker *p, Expr *pExpr){ |
| 147825 | | - if( pExpr->op==TK_COLUMN ){ |
| 147826 | | - SrcList *pSrc = p->u.pSrcList; |
| 147827 | | - int iCsr = pExpr->iTable; |
| 147828 | | - int ii; |
| 147829 | | - for(ii=0; ii<pSrc->nSrc; ii++){ |
| 147830 | | - if( pSrc->a[ii].iCursor==iCsr ){ |
| 147831 | | - return p->eCode ? WRC_Abort : WRC_Continue; |
| 147832 | | - } |
| 147833 | | - } |
| 147834 | | - return p->eCode ? WRC_Continue : WRC_Abort; |
| 147835 | | - } |
| 147836 | | - return WRC_Continue; |
| 147837 | | -} |
| 147838 | | - |
| 147839 | | -/* |
| 147840 | | -** Select callback for exprUsesSrclist(). |
| 147841 | | -*/ |
| 147842 | | -static int exprUsesSrclistSelectCb(Walker *NotUsed1, Select *NotUsed2){ |
| 147843 | | - UNUSED_PARAMETER(NotUsed1); |
| 147844 | | - UNUSED_PARAMETER(NotUsed2); |
| 147845 | | - return WRC_Abort; |
| 147846 | | -} |
| 147847 | | - |
| 147848 | | -/* |
| 147849 | | -** This function always returns true if expression pExpr contains |
| 147850 | | -** a sub-select. |
| 147851 | | -** |
| 147852 | | -** If there is no sub-select in pExpr, then return true if pExpr |
| 147853 | | -** contains a TK_COLUMN node for a table that is (bUses==1) |
| 147854 | | -** or is not (bUses==0) in pSrc. |
| 147855 | | -** |
| 147856 | | -** Said another way: |
| 147857 | | -** |
| 147858 | | -** bUses Return Meaning |
| 147859 | | -** -------- ------ ------------------------------------------------ |
| 147860 | | -** |
| 147861 | | -** bUses==1 true pExpr contains either a sub-select or a |
| 147862 | | -** TK_COLUMN referencing pSrc. |
| 147863 | | -** |
| 147864 | | -** bUses==1 false pExpr contains no sub-selects and all TK_COLUMN |
| 147865 | | -** nodes reference tables not found in pSrc |
| 147866 | | -** |
| 147867 | | -** bUses==0 true pExpr contains either a sub-select or a TK_COLUMN |
| 147868 | | -** that references a table not in pSrc. |
| 147869 | | -** |
| 147870 | | -** bUses==0 false pExpr contains no sub-selects and all TK_COLUMN |
| 147871 | | -** nodes reference pSrc |
| 147872 | | -*/ |
| 147873 | | -static int exprUsesSrclist(SrcList *pSrc, Expr *pExpr, int bUses){ |
| 147874 | | - Walker sWalker; |
| 147875 | | - memset(&sWalker, 0, sizeof(Walker)); |
| 147876 | | - sWalker.eCode = bUses; |
| 147877 | | - sWalker.u.pSrcList = pSrc; |
| 147878 | | - sWalker.xExprCallback = exprUsesSrclistCb; |
| 147879 | | - sWalker.xSelectCallback = exprUsesSrclistSelectCb; |
| 147880 | | - return (sqlite3WalkExpr(&sWalker, pExpr)==WRC_Abort); |
| 147881 | | -} |
| 147882 | | - |
| 147883 | | -/* |
| 147884 | | -** Context object used by exprExistsToInIter() as it iterates through an |
| 147885 | | -** expression tree. |
| 147886 | | -*/ |
| 147887 | | -struct ExistsToInCtx { |
| 147888 | | - SrcList *pSrc; /* The tables in an EXISTS(SELECT ... FROM <here> ...) */ |
| 147889 | | - Expr *pInLhs; /* OUT: Use this as the LHS of the IN operator */ |
| 147890 | | - Expr *pEq; /* OUT: The == term that include pInLhs */ |
| 147891 | | - Expr **ppAnd; /* OUT: The AND operator that includes pEq as a child */ |
| 147892 | | - Expr **ppParent; /* The AND operator currently being examined */ |
| 147893 | | -}; |
| 147894 | | - |
| 147895 | | -/* |
| 147896 | | -** Iterate through all AND connected nodes in the expression tree |
| 147897 | | -** headed by (*ppExpr), populating the structure passed as the first |
| 147898 | | -** argument with the values required by exprAnalyzeExistsFindEq(). |
| 147899 | | -** |
| 147900 | | -** This function returns non-zero if the expression tree does not meet |
| 147901 | | -** the two conditions described by the header comment for |
| 147902 | | -** exprAnalyzeExistsFindEq(), or zero if it does. |
| 147903 | | -*/ |
| 147904 | | -static int exprExistsToInIter(struct ExistsToInCtx *p, Expr **ppExpr){ |
| 147905 | | - Expr *pExpr = *ppExpr; |
| 147906 | | - switch( pExpr->op ){ |
| 147907 | | - case TK_AND: |
| 147908 | | - p->ppParent = ppExpr; |
| 147909 | | - if( exprExistsToInIter(p, &pExpr->pLeft) ) return 1; |
| 147910 | | - p->ppParent = ppExpr; |
| 147911 | | - if( exprExistsToInIter(p, &pExpr->pRight) ) return 1; |
| 147912 | | - break; |
| 147913 | | - case TK_EQ: { |
| 147914 | | - int bLeft = exprUsesSrclist(p->pSrc, pExpr->pLeft, 0); |
| 147915 | | - int bRight = exprUsesSrclist(p->pSrc, pExpr->pRight, 0); |
| 147916 | | - if( bLeft || bRight ){ |
| 147917 | | - if( (bLeft && bRight) || p->pInLhs ) return 1; |
| 147918 | | - p->pInLhs = bLeft ? pExpr->pLeft : pExpr->pRight; |
| 147919 | | - if( exprUsesSrclist(p->pSrc, p->pInLhs, 1) ) return 1; |
| 147920 | | - p->pEq = pExpr; |
| 147921 | | - p->ppAnd = p->ppParent; |
| 147922 | | - } |
| 147923 | | - break; |
| 147924 | | - } |
| 147925 | | - default: |
| 147926 | | - if( exprUsesSrclist(p->pSrc, pExpr, 0) ){ |
| 147927 | | - return 1; |
| 147928 | | - } |
| 147929 | | - break; |
| 147930 | | - } |
| 147931 | | - |
| 147932 | | - return 0; |
| 147933 | | -} |
| 147934 | | - |
| 147935 | | -/* |
| 147936 | | -** This function is used by exprAnalyzeExists() when creating virtual IN(...) |
| 147937 | | -** terms equivalent to user-supplied EXIST(...) clauses. It splits the WHERE |
| 147938 | | -** clause of the Select object passed as the first argument into one or more |
| 147939 | | -** expressions joined by AND operators, and then tests if the following are |
| 147940 | | -** true: |
| 147941 | | -** |
| 147942 | | -** 1. Exactly one of the AND separated terms refers to the outer |
| 147943 | | -** query, and it is an == (TK_EQ) expression. |
| 147944 | | -** |
| 147945 | | -** 2. Only one side of the == expression refers to the outer query, and |
| 147946 | | -** it does not refer to any columns from the inner query. |
| 147947 | | -** |
| 147948 | | -** If both these conditions are true, then a pointer to the side of the == |
| 147949 | | -** expression that refers to the outer query is returned. The caller will |
| 147950 | | -** use this expression as the LHS of the IN(...) virtual term. Or, if one |
| 147951 | | -** or both of the above conditions are not true, NULL is returned. |
| 147952 | | -** |
| 147953 | | -** If non-NULL is returned and ppEq is non-NULL, *ppEq is set to point |
| 147954 | | -** to the == expression node before returning. If pppAnd is non-NULL and |
| 147955 | | -** the == node is not the root of the WHERE clause, then *pppAnd is set |
| 147956 | | -** to point to the pointer to the AND node that is the parent of the == |
| 147957 | | -** node within the WHERE expression tree. |
| 147958 | | -*/ |
| 147959 | | -static Expr *exprAnalyzeExistsFindEq( |
| 147960 | | - Select *pSel, /* The SELECT of the EXISTS */ |
| 147961 | | - Expr **ppEq, /* OUT: == node from WHERE clause */ |
| 147962 | | - Expr ***pppAnd /* OUT: Pointer to parent of ==, if any */ |
| 147963 | | -){ |
| 147964 | | - struct ExistsToInCtx ctx; |
| 147965 | | - memset(&ctx, 0, sizeof(ctx)); |
| 147966 | | - ctx.pSrc = pSel->pSrc; |
| 147967 | | - if( exprExistsToInIter(&ctx, &pSel->pWhere) ){ |
| 147968 | | - return 0; |
| 147969 | | - } |
| 147970 | | - if( ppEq ) *ppEq = ctx.pEq; |
| 147971 | | - if( pppAnd ) *pppAnd = ctx.ppAnd; |
| 147972 | | - return ctx.pInLhs; |
| 147973 | | -} |
| 147974 | | - |
| 147975 | | -/* |
| 147976 | | -** Term idxTerm of the WHERE clause passed as the second argument is an |
| 147977 | | -** EXISTS expression with a correlated SELECT statement on the RHS. |
| 147978 | | -** This function analyzes the SELECT statement, and if possible adds an |
| 147979 | | -** equivalent "? IN(SELECT...)" virtual term to the WHERE clause. |
| 147980 | | -** |
| 147981 | | -** For an EXISTS term such as the following: |
| 147982 | | -** |
| 147983 | | -** EXISTS (SELECT ... FROM <srclist> WHERE <e1> = <e2> AND <e3>) |
| 147984 | | -** |
| 147985 | | -** The virtual IN() term added is: |
| 147986 | | -** |
| 147987 | | -** <e1> IN (SELECT <e2> FROM <srclist> WHERE <e3>) |
| 147988 | | -** |
| 147989 | | -** The virtual term is only added if the following conditions are met: |
| 147990 | | -** |
| 147991 | | -** 1. The sub-select must not be an aggregate or use window functions, |
| 147992 | | -** |
| 147993 | | -** 2. The sub-select must not be a compound SELECT, |
| 147994 | | -** |
| 147995 | | -** 3. Expression <e1> must refer to at least one column from the outer |
| 147996 | | -** query, and must not refer to any column from the inner query |
| 147997 | | -** (i.e. from <srclist>). |
| 147998 | | -** |
| 147999 | | -** 4. <e2> and <e3> must not refer to any values from the outer query. |
| 148000 | | -** In other words, once <e1> has been removed, the inner query |
| 148001 | | -** must not be correlated. |
| 148002 | | -** |
| 148003 | | -*/ |
| 148004 | | -static void exprAnalyzeExists( |
| 148005 | | - SrcList *pSrc, /* the FROM clause */ |
| 148006 | | - WhereClause *pWC, /* the WHERE clause */ |
| 148007 | | - int idxTerm /* Index of the term to be analyzed */ |
| 148008 | | -){ |
| 148009 | | - Parse *pParse = pWC->pWInfo->pParse; |
| 148010 | | - WhereTerm *pTerm = &pWC->a[idxTerm]; |
| 148011 | | - Expr *pExpr = pTerm->pExpr; |
| 148012 | | - Select *pSel = pExpr->x.pSelect; |
| 148013 | | - Expr *pDup = 0; |
| 148014 | | - Expr *pEq = 0; |
| 148015 | | - Expr *pRet = 0; |
| 148016 | | - Expr *pInLhs = 0; |
| 148017 | | - Expr **ppAnd = 0; |
| 148018 | | - int idxNew; |
| 148019 | | - sqlite3 *db = pParse->db; |
| 148020 | | - |
| 148021 | | - assert( pExpr->op==TK_EXISTS ); |
| 148022 | | - assert( (pExpr->flags & EP_VarSelect) && (pExpr->flags & EP_xIsSelect) ); |
| 148023 | | - |
| 148024 | | - if( pSel->selFlags & SF_Aggregate ) return; |
| 148025 | | -#ifndef SQLITE_OMIT_WINDOWFUNC |
| 148026 | | - if( pSel->pWin ) return; |
| 148027 | | -#endif |
| 148028 | | - if( pSel->pPrior ) return; |
| 148029 | | - if( pSel->pWhere==0 ) return; |
| 148030 | | - if( pSel->pLimit ) return; |
| 148031 | | - if( 0==exprAnalyzeExistsFindEq(pSel, 0, 0) ) return; |
| 148032 | | - |
| 148033 | | - pDup = sqlite3ExprDup(db, pExpr, 0); |
| 148034 | | - if( db->mallocFailed ){ |
| 148035 | | - sqlite3ExprDelete(db, pDup); |
| 148036 | | - return; |
| 148037 | | - } |
| 148038 | | - pSel = pDup->x.pSelect; |
| 148039 | | - sqlite3ExprListDelete(db, pSel->pEList); |
| 148040 | | - pSel->pEList = 0; |
| 148041 | | - |
| 148042 | | - pInLhs = exprAnalyzeExistsFindEq(pSel, &pEq, &ppAnd); |
| 148043 | | - assert( pInLhs && pEq ); |
| 148044 | | - assert( pEq==pSel->pWhere || ppAnd ); |
| 148045 | | - if( pInLhs==pEq->pLeft ){ |
| 148046 | | - pRet = pEq->pRight; |
| 148047 | | - }else{ |
| 148048 | | - CollSeq *p = sqlite3ExprCompareCollSeq(pParse, pEq); |
| 148049 | | - pInLhs = sqlite3ExprAddCollateString(pParse, pInLhs, p?p->zName:"BINARY"); |
| 148050 | | - pRet = pEq->pLeft; |
| 148051 | | - } |
| 148052 | | - |
| 148053 | | - assert( pDup->pLeft==0 ); |
| 148054 | | - pDup->op = TK_IN; |
| 148055 | | - pDup->pLeft = pInLhs; |
| 148056 | | - pDup->flags &= ~EP_VarSelect; |
| 148057 | | - if( pRet->op==TK_VECTOR ){ |
| 148058 | | - pSel->pEList = pRet->x.pList; |
| 148059 | | - pRet->x.pList = 0; |
| 148060 | | - sqlite3ExprDelete(db, pRet); |
| 148061 | | - }else{ |
| 148062 | | - pSel->pEList = sqlite3ExprListAppend(pParse, 0, pRet); |
| 148063 | | - } |
| 148064 | | - pEq->pLeft = 0; |
| 148065 | | - pEq->pRight = 0; |
| 148066 | | - if( ppAnd ){ |
| 148067 | | - Expr *pAnd = *ppAnd; |
| 148068 | | - Expr *pOther = (pAnd->pLeft==pEq) ? pAnd->pRight : pAnd->pLeft; |
| 148069 | | - pAnd->pLeft = pAnd->pRight = 0; |
| 148070 | | - sqlite3ExprDelete(db, pAnd); |
| 148071 | | - *ppAnd = pOther; |
| 148072 | | - }else{ |
| 148073 | | - assert( pSel->pWhere==pEq ); |
| 148074 | | - pSel->pWhere = 0; |
| 148075 | | - } |
| 148076 | | - sqlite3ExprDelete(db, pEq); |
| 148077 | | - |
| 148078 | | -#ifdef WHERETRACE_ENABLED /* 0x20 */ |
| 148079 | | - if( sqlite3WhereTrace & 0x20 ){ |
| 148080 | | - sqlite3DebugPrintf("Convert EXISTS:\n"); |
| 148081 | | - sqlite3TreeViewExpr(0, pExpr, 0); |
| 148082 | | - sqlite3DebugPrintf("into IN:\n"); |
| 148083 | | - sqlite3TreeViewExpr(0, pDup, 0); |
| 148084 | | - } |
| 148085 | | -#endif |
| 148086 | | - idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC); |
| 148087 | | - exprAnalyze(pSrc, pWC, idxNew); |
| 148088 | | - markTermAsChild(pWC, idxNew, idxTerm); |
| 148089 | | - pWC->a[idxTerm].wtFlags |= TERM_COPIED; |
| 148090 | | -} |
| 148091 | 148601 | |
| 148092 | 148602 | /* |
| 148093 | 148603 | ** The input to this routine is an WhereTerm structure with only the |
| 148094 | 148604 | ** "pExpr" field filled in. The job of this routine is to analyze the |
| 148095 | 148605 | ** subexpression and populate all the other fields of the WhereTerm |
| | @@ -148185,10 +148695,11 @@ |
| 148185 | 148695 | pTerm->eOperator = operatorMask(op) & opMask; |
| 148186 | 148696 | } |
| 148187 | 148697 | if( op==TK_IS ) pTerm->wtFlags |= TERM_IS; |
| 148188 | 148698 | if( pRight |
| 148189 | 148699 | && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op) |
| 148700 | + && !ExprHasProperty(pRight, EP_FixedCol) |
| 148190 | 148701 | ){ |
| 148191 | 148702 | WhereTerm *pNew; |
| 148192 | 148703 | Expr *pDup; |
| 148193 | 148704 | u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */ |
| 148194 | 148705 | assert( pTerm->u.x.iField==0 ); |
| | @@ -148277,20 +148788,10 @@ |
| 148277 | 148788 | assert( pWC->op==TK_AND ); |
| 148278 | 148789 | exprAnalyzeOrTerm(pSrc, pWC, idxTerm); |
| 148279 | 148790 | pTerm = &pWC->a[idxTerm]; |
| 148280 | 148791 | } |
| 148281 | 148792 | #endif /* SQLITE_OMIT_OR_OPTIMIZATION */ |
| 148282 | | - |
| 148283 | | - else if( pExpr->op==TK_EXISTS ){ |
| 148284 | | - /* Perhaps treat an EXISTS operator as an IN operator */ |
| 148285 | | - if( (pExpr->flags & EP_VarSelect)!=0 |
| 148286 | | - && OptimizationEnabled(db, SQLITE_ExistsToIN) |
| 148287 | | - ){ |
| 148288 | | - exprAnalyzeExists(pSrc, pWC, idxTerm); |
| 148289 | | - } |
| 148290 | | - } |
| 148291 | | - |
| 148292 | 148793 | /* The form "x IS NOT NULL" can sometimes be evaluated more efficiently |
| 148293 | 148794 | ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a |
| 148294 | 148795 | ** virtual term of that form. |
| 148295 | 148796 | ** |
| 148296 | 148797 | ** The virtual term must be tagged with TERM_VNULL. |
| | @@ -148973,11 +149474,13 @@ |
| 148973 | 149474 | ** If the right-hand branch of the expression is a TK_COLUMN, then return |
| 148974 | 149475 | ** a pointer to the right-hand branch. Otherwise, return NULL. |
| 148975 | 149476 | */ |
| 148976 | 149477 | static Expr *whereRightSubexprIsColumn(Expr *p){ |
| 148977 | 149478 | p = sqlite3ExprSkipCollateAndLikely(p->pRight); |
| 148978 | | - if( ALWAYS(p!=0) && p->op==TK_COLUMN ) return p; |
| 149479 | + if( ALWAYS(p!=0) && p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){ |
| 149480 | + return p; |
| 149481 | + } |
| 148979 | 149482 | return 0; |
| 148980 | 149483 | } |
| 148981 | 149484 | |
| 148982 | 149485 | /* |
| 148983 | 149486 | ** Advance to the next WhereTerm that matches according to the criteria |
| | @@ -149048,10 +149551,22 @@ |
| 149048 | 149551 | testcase( pTerm->eOperator & WO_IS ); |
| 149049 | 149552 | continue; |
| 149050 | 149553 | } |
| 149051 | 149554 | pScan->pWC = pWC; |
| 149052 | 149555 | pScan->k = k+1; |
| 149556 | +#ifdef WHERETRACE_ENABLED |
| 149557 | + if( sqlite3WhereTrace & 0x20000 ){ |
| 149558 | + int ii; |
| 149559 | + sqlite3DebugPrintf("SCAN-TERM %p: nEquiv=%d", |
| 149560 | + pTerm, pScan->nEquiv); |
| 149561 | + for(ii=0; ii<pScan->nEquiv; ii++){ |
| 149562 | + sqlite3DebugPrintf(" {%d:%d}", |
| 149563 | + pScan->aiCur[ii], pScan->aiColumn[ii]); |
| 149564 | + } |
| 149565 | + sqlite3DebugPrintf("\n"); |
| 149566 | + } |
| 149567 | +#endif |
| 149053 | 149568 | return pTerm; |
| 149054 | 149569 | } |
| 149055 | 149570 | } |
| 149056 | 149571 | } |
| 149057 | 149572 | pWC = pWC->pOuter; |
| | @@ -150652,11 +151167,11 @@ |
| 150652 | 151167 | ** Transfer content from the second pLoop into the first. |
| 150653 | 151168 | */ |
| 150654 | 151169 | static int whereLoopXfer(sqlite3 *db, WhereLoop *pTo, WhereLoop *pFrom){ |
| 150655 | 151170 | whereLoopClearUnion(db, pTo); |
| 150656 | 151171 | if( whereLoopResize(db, pTo, pFrom->nLTerm) ){ |
| 150657 | | - memset(&pTo->u, 0, sizeof(pTo->u)); |
| 151172 | + memset(pTo, 0, WHERE_LOOP_XFER_SZ); |
| 150658 | 151173 | return SQLITE_NOMEM_BKPT; |
| 150659 | 151174 | } |
| 150660 | 151175 | memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ); |
| 150661 | 151176 | memcpy(pTo->aLTerm, pFrom->aLTerm, pTo->nLTerm*sizeof(pTo->aLTerm[0])); |
| 150662 | 151177 | if( pFrom->wsFlags & WHERE_VIRTUALTABLE ){ |
| | @@ -150694,10 +151209,21 @@ |
| 150694 | 151209 | whereLoopDelete(db, p); |
| 150695 | 151210 | } |
| 150696 | 151211 | assert( pWInfo->pExprMods==0 ); |
| 150697 | 151212 | sqlite3DbFreeNN(db, pWInfo); |
| 150698 | 151213 | } |
| 151214 | + |
| 151215 | +/* Undo all Expr node modifications |
| 151216 | +*/ |
| 151217 | +static void whereUndoExprMods(WhereInfo *pWInfo){ |
| 151218 | + while( pWInfo->pExprMods ){ |
| 151219 | + WhereExprMod *p = pWInfo->pExprMods; |
| 151220 | + pWInfo->pExprMods = p->pNext; |
| 151221 | + memcpy(p->pExpr, &p->orig, sizeof(p->orig)); |
| 151222 | + sqlite3DbFree(pWInfo->pParse->db, p); |
| 151223 | + } |
| 151224 | +} |
| 150699 | 151225 | |
| 150700 | 151226 | /* |
| 150701 | 151227 | ** Return TRUE if all of the following are true: |
| 150702 | 151228 | ** |
| 150703 | 151229 | ** (1) X has the same or lower cost that Y |
| | @@ -151200,10 +151726,12 @@ |
| 151200 | 151726 | opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS; |
| 151201 | 151727 | } |
| 151202 | 151728 | if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); |
| 151203 | 151729 | |
| 151204 | 151730 | assert( pNew->u.btree.nEq<pProbe->nColumn ); |
| 151731 | + assert( pNew->u.btree.nEq<pProbe->nKeyCol |
| 151732 | + || pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY ); |
| 151205 | 151733 | |
| 151206 | 151734 | saved_nEq = pNew->u.btree.nEq; |
| 151207 | 151735 | saved_nBtm = pNew->u.btree.nBtm; |
| 151208 | 151736 | saved_nTop = pNew->u.btree.nTop; |
| 151209 | 151737 | saved_nSkip = pNew->nSkip; |
| | @@ -151282,11 +151810,11 @@ |
| 151282 | 151810 | }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){ |
| 151283 | 151811 | /* "x IN (value, value, ...)" */ |
| 151284 | 151812 | nIn = sqlite3LogEst(pExpr->x.pList->nExpr); |
| 151285 | 151813 | } |
| 151286 | 151814 | if( pProbe->hasStat1 && rLogSize>=10 ){ |
| 151287 | | - LogEst M, logK, safetyMargin; |
| 151815 | + LogEst M, logK, x; |
| 151288 | 151816 | /* Let: |
| 151289 | 151817 | ** N = the total number of rows in the table |
| 151290 | 151818 | ** K = the number of entries on the RHS of the IN operator |
| 151291 | 151819 | ** M = the number of rows in the table that match terms to the |
| 151292 | 151820 | ** to the left in the same index. If the IN operator is on |
| | @@ -151305,20 +151833,29 @@ |
| 151305 | 151833 | ** the index. Do not bother with this optimization on very small |
| 151306 | 151834 | ** tables (less than 2 rows) as it is pointless in that case. |
| 151307 | 151835 | */ |
| 151308 | 151836 | M = pProbe->aiRowLogEst[saved_nEq]; |
| 151309 | 151837 | logK = estLog(nIn); |
| 151310 | | - safetyMargin = 10; /* TUNING: extra weight for indexed IN */ |
| 151311 | | - if( M + logK + safetyMargin < nIn + rLogSize ){ |
| 151838 | + /* TUNING v----- 10 to bias toward indexed IN */ |
| 151839 | + x = M + logK + 10 - (nIn + rLogSize); |
| 151840 | + if( x>=0 ){ |
| 151841 | + WHERETRACE(0x40, |
| 151842 | + ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d) " |
| 151843 | + "prefers indexed lookup\n", |
| 151844 | + saved_nEq, M, logK, nIn, rLogSize, x)); |
| 151845 | + }else if( nInMul<2 && OptimizationEnabled(db, SQLITE_SeekScan) ){ |
| 151312 | 151846 | WHERETRACE(0x40, |
| 151313 | | - ("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n", |
| 151314 | | - saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize)); |
| 151847 | + ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d" |
| 151848 | + " nInMul=%d) prefers skip-scan\n", |
| 151849 | + saved_nEq, M, logK, nIn, rLogSize, x, nInMul)); |
| 151315 | 151850 | pNew->wsFlags |= WHERE_IN_SEEKSCAN; |
| 151316 | 151851 | }else{ |
| 151317 | 151852 | WHERETRACE(0x40, |
| 151318 | | - ("IN operator preferred on column %d of \"%s\" (%d>=%d)\n", |
| 151319 | | - saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize)); |
| 151853 | + ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d" |
| 151854 | + " nInMul=%d) prefers normal scan\n", |
| 151855 | + saved_nEq, M, logK, nIn, rLogSize, x, nInMul)); |
| 151856 | + continue; |
| 151320 | 151857 | } |
| 151321 | 151858 | } |
| 151322 | 151859 | pNew->wsFlags |= WHERE_COLUMN_IN; |
| 151323 | 151860 | }else if( eOp & (WO_EQ|WO_IS) ){ |
| 151324 | 151861 | int iCol = pProbe->aiColumn[saved_nEq]; |
| | @@ -151333,10 +151870,11 @@ |
| 151333 | 151870 | pNew->wsFlags |= WHERE_ONEROW; |
| 151334 | 151871 | }else{ |
| 151335 | 151872 | pNew->wsFlags |= WHERE_UNQ_WANTED; |
| 151336 | 151873 | } |
| 151337 | 151874 | } |
| 151875 | + if( scan.iEquiv>1 ) pNew->wsFlags |= WHERE_TRANSCONS; |
| 151338 | 151876 | }else if( eOp & WO_ISNULL ){ |
| 151339 | 151877 | pNew->wsFlags |= WHERE_COLUMN_NULL; |
| 151340 | 151878 | }else if( eOp & (WO_GT|WO_GE) ){ |
| 151341 | 151879 | testcase( eOp & WO_GT ); |
| 151342 | 151880 | testcase( eOp & WO_GE ); |
| | @@ -151476,10 +152014,12 @@ |
| 151476 | 152014 | pNew->nOut = nOutUnadjusted; |
| 151477 | 152015 | } |
| 151478 | 152016 | |
| 151479 | 152017 | if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 |
| 151480 | 152018 | && pNew->u.btree.nEq<pProbe->nColumn |
| 152019 | + && (pNew->u.btree.nEq<pProbe->nKeyCol || |
| 152020 | + pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY) |
| 151481 | 152021 | ){ |
| 151482 | 152022 | whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn); |
| 151483 | 152023 | } |
| 151484 | 152024 | pNew->nOut = saved_nOut; |
| 151485 | 152025 | #ifdef SQLITE_ENABLE_STAT4 |
| | @@ -151597,10 +152137,11 @@ |
| 151597 | 152137 | Expr *pExpr; |
| 151598 | 152138 | pExpr = pTerm->pExpr; |
| 151599 | 152139 | if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab) |
| 151600 | 152140 | && (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin)) |
| 151601 | 152141 | && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab) |
| 152142 | + && (pTerm->wtFlags & TERM_VNULL)==0 |
| 151602 | 152143 | ){ |
| 151603 | 152144 | return 1; |
| 151604 | 152145 | } |
| 151605 | 152146 | } |
| 151606 | 152147 | return 0; |
| | @@ -152307,11 +152848,13 @@ |
| 152307 | 152848 | rc = whereLoopAddBtree(&sSubBuild, mPrereq); |
| 152308 | 152849 | } |
| 152309 | 152850 | if( rc==SQLITE_OK ){ |
| 152310 | 152851 | rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable); |
| 152311 | 152852 | } |
| 152312 | | - assert( rc==SQLITE_OK || rc==SQLITE_DONE || sCur.n==0 ); |
| 152853 | + assert( rc==SQLITE_OK || rc==SQLITE_DONE || sCur.n==0 |
| 152854 | + || rc==SQLITE_NOMEM ); |
| 152855 | + testcase( rc==SQLITE_NOMEM && sCur.n>0 ); |
| 152313 | 152856 | testcase( rc==SQLITE_DONE ); |
| 152314 | 152857 | if( sCur.n==0 ){ |
| 152315 | 152858 | sSum.n = 0; |
| 152316 | 152859 | break; |
| 152317 | 152860 | }else if( once ){ |
| | @@ -152576,10 +153119,14 @@ |
| 152576 | 153119 | nKeyCol = pIndex->nKeyCol; |
| 152577 | 153120 | nColumn = pIndex->nColumn; |
| 152578 | 153121 | assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) ); |
| 152579 | 153122 | assert( pIndex->aiColumn[nColumn-1]==XN_ROWID |
| 152580 | 153123 | || !HasRowid(pIndex->pTable)); |
| 153124 | + /* All relevant terms of the index must also be non-NULL in order |
| 153125 | + ** for isOrderDistinct to be true. So the isOrderDistint value |
| 153126 | + ** computed here might be a false positive. Corrections will be |
| 153127 | + ** made at tag-20210426-1 below */ |
| 152581 | 153128 | isOrderDistinct = IsUniqueIndex(pIndex) |
| 152582 | 153129 | && (pLoop->wsFlags & WHERE_SKIPSCAN)==0; |
| 152583 | 153130 | } |
| 152584 | 153131 | |
| 152585 | 153132 | /* Loop through all columns of the index and deal with the ones |
| | @@ -152643,18 +153190,22 @@ |
| 152643 | 153190 | iColumn = XN_ROWID; |
| 152644 | 153191 | revIdx = 0; |
| 152645 | 153192 | } |
| 152646 | 153193 | |
| 152647 | 153194 | /* An unconstrained column that might be NULL means that this |
| 152648 | | - ** WhereLoop is not well-ordered |
| 153195 | + ** WhereLoop is not well-ordered. tag-20210426-1 |
| 152649 | 153196 | */ |
| 152650 | | - if( isOrderDistinct |
| 152651 | | - && iColumn>=0 |
| 152652 | | - && j>=pLoop->u.btree.nEq |
| 152653 | | - && pIndex->pTable->aCol[iColumn].notNull==0 |
| 152654 | | - ){ |
| 152655 | | - isOrderDistinct = 0; |
| 153197 | + if( isOrderDistinct ){ |
| 153198 | + if( iColumn>=0 |
| 153199 | + && j>=pLoop->u.btree.nEq |
| 153200 | + && pIndex->pTable->aCol[iColumn].notNull==0 |
| 153201 | + ){ |
| 153202 | + isOrderDistinct = 0; |
| 153203 | + } |
| 153204 | + if( iColumn==XN_EXPR ){ |
| 153205 | + isOrderDistinct = 0; |
| 153206 | + } |
| 152656 | 153207 | } |
| 152657 | 153208 | |
| 152658 | 153209 | /* Find the ORDER BY term that corresponds to the j-th column |
| 152659 | 153210 | ** of the index and mark that ORDER BY term off |
| 152660 | 153211 | */ |
| | @@ -152834,11 +153385,11 @@ |
| 152834 | 153385 | if( (pWInfo->wctrlFlags & WHERE_USE_LIMIT)!=0 && pWInfo->iLimit<nRow ){ |
| 152835 | 153386 | nRow = pWInfo->iLimit; |
| 152836 | 153387 | }else if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT) ){ |
| 152837 | 153388 | /* TUNING: In the sort for a DISTINCT operator, assume that the DISTINCT |
| 152838 | 153389 | ** reduces the number of output rows by a factor of 2 */ |
| 152839 | | - if( nRow>10 ) nRow -= 10; assert( 10==sqlite3LogEst(2) ); |
| 153390 | + if( nRow>10 ){ nRow -= 10; assert( 10==sqlite3LogEst(2) ); } |
| 152840 | 153391 | } |
| 152841 | 153392 | rSortCost += estLog(nRow); |
| 152842 | 153393 | return rSortCost; |
| 152843 | 153394 | } |
| 152844 | 153395 | |
| | @@ -154026,10 +154577,12 @@ |
| 154026 | 154577 | return pWInfo; |
| 154027 | 154578 | |
| 154028 | 154579 | /* Jump here if malloc fails */ |
| 154029 | 154580 | whereBeginError: |
| 154030 | 154581 | if( pWInfo ){ |
| 154582 | + testcase( pWInfo->pExprMods!=0 ); |
| 154583 | + whereUndoExprMods(pWInfo); |
| 154031 | 154584 | pParse->nQueryLoop = pWInfo->savedNQueryLoop; |
| 154032 | 154585 | whereInfoFree(db, pWInfo); |
| 154033 | 154586 | } |
| 154034 | 154587 | return 0; |
| 154035 | 154588 | } |
| | @@ -154122,10 +154675,12 @@ |
| 154122 | 154675 | if( pLoop->wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){ |
| 154123 | 154676 | struct InLoop *pIn; |
| 154124 | 154677 | int j; |
| 154125 | 154678 | sqlite3VdbeResolveLabel(v, pLevel->addrNxt); |
| 154126 | 154679 | for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){ |
| 154680 | + assert( sqlite3VdbeGetOp(v, pIn->addrInTop+1)->opcode==OP_IsNull |
| 154681 | + || pParse->db->mallocFailed ); |
| 154127 | 154682 | sqlite3VdbeJumpHere(v, pIn->addrInTop+1); |
| 154128 | 154683 | if( pIn->eEndLoopOp!=OP_Noop ){ |
| 154129 | 154684 | if( pIn->nPrefix ){ |
| 154130 | 154685 | int bEarlyOut = |
| 154131 | 154686 | (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 |
| | @@ -154146,10 +154701,15 @@ |
| 154146 | 154701 | if( bEarlyOut ){ |
| 154147 | 154702 | sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur, |
| 154148 | 154703 | sqlite3VdbeCurrentAddr(v)+2, |
| 154149 | 154704 | pIn->iBase, pIn->nPrefix); |
| 154150 | 154705 | VdbeCoverage(v); |
| 154706 | + /* Retarget the OP_IsNull against the left operand of IN so |
| 154707 | + ** it jumps past the OP_IfNoHope. This is because the |
| 154708 | + ** OP_IsNull also bypasses the OP_Affinity opcode that is |
| 154709 | + ** required by OP_IfNoHope. */ |
| 154710 | + sqlite3VdbeJumpHere(v, pIn->addrInTop+1); |
| 154151 | 154711 | } |
| 154152 | 154712 | } |
| 154153 | 154713 | sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop); |
| 154154 | 154714 | VdbeCoverage(v); |
| 154155 | 154715 | VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Prev); |
| | @@ -154325,20 +154885,13 @@ |
| 154325 | 154885 | if( db->flags & SQLITE_VdbeAddopTrace ) printf("TRANSLATE complete\n"); |
| 154326 | 154886 | #endif |
| 154327 | 154887 | } |
| 154328 | 154888 | } |
| 154329 | 154889 | |
| 154330 | | - /* Undo all Expr node modifications */ |
| 154331 | | - while( pWInfo->pExprMods ){ |
| 154332 | | - WhereExprMod *p = pWInfo->pExprMods; |
| 154333 | | - pWInfo->pExprMods = p->pNext; |
| 154334 | | - memcpy(p->pExpr, &p->orig, sizeof(p->orig)); |
| 154335 | | - sqlite3DbFree(db, p); |
| 154336 | | - } |
| 154337 | | - |
| 154338 | 154890 | /* Final cleanup |
| 154339 | 154891 | */ |
| 154892 | + if( pWInfo->pExprMods ) whereUndoExprMods(pWInfo); |
| 154340 | 154893 | pParse->nQueryLoop = pWInfo->savedNQueryLoop; |
| 154341 | 154894 | whereInfoFree(db, pWInfo); |
| 154342 | 154895 | return; |
| 154343 | 154896 | } |
| 154344 | 154897 | |
| | @@ -155284,10 +155837,18 @@ |
| 155284 | 155837 | ){ |
| 155285 | 155838 | pExpr->op2++; |
| 155286 | 155839 | } |
| 155287 | 155840 | return WRC_Continue; |
| 155288 | 155841 | } |
| 155842 | + |
| 155843 | +static int disallowAggregatesInOrderByCb(Walker *pWalker, Expr *pExpr){ |
| 155844 | + if( pExpr->op==TK_AGG_FUNCTION && pExpr->pAggInfo==0 ){ |
| 155845 | + sqlite3ErrorMsg(pWalker->pParse, |
| 155846 | + "misuse of aggregate: %s()", pExpr->u.zToken); |
| 155847 | + } |
| 155848 | + return WRC_Continue; |
| 155849 | +} |
| 155289 | 155850 | |
| 155290 | 155851 | /* |
| 155291 | 155852 | ** If the SELECT statement passed as the second argument does not invoke |
| 155292 | 155853 | ** any SQL window functions, this function is a no-op. Otherwise, it |
| 155293 | 155854 | ** rewrites the SELECT statement so that window function xStep functions |
| | @@ -155294,11 +155855,11 @@ |
| 155294 | 155855 | ** are invoked in the correct order as described under "SELECT REWRITING" |
| 155295 | 155856 | ** at the top of this file. |
| 155296 | 155857 | */ |
| 155297 | 155858 | SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ |
| 155298 | 155859 | int rc = SQLITE_OK; |
| 155299 | | - if( p->pWin && p->pPrior==0 && (p->selFlags & SF_WinRewrite)==0 ){ |
| 155860 | + if( p->pWin && p->pPrior==0 && ALWAYS((p->selFlags & SF_WinRewrite)==0) ){ |
| 155300 | 155861 | Vdbe *v = sqlite3GetVdbe(pParse); |
| 155301 | 155862 | sqlite3 *db = pParse->db; |
| 155302 | 155863 | Select *pSub = 0; /* The subquery */ |
| 155303 | 155864 | SrcList *pSrc = p->pSrc; |
| 155304 | 155865 | Expr *pWhere = p->pWhere; |
| | @@ -155318,10 +155879,15 @@ |
| 155318 | 155879 | if( pTab==0 ){ |
| 155319 | 155880 | return sqlite3ErrorToParser(db, SQLITE_NOMEM); |
| 155320 | 155881 | } |
| 155321 | 155882 | sqlite3AggInfoPersistWalkerInit(&w, pParse); |
| 155322 | 155883 | sqlite3WalkSelect(&w, p); |
| 155884 | + if( (p->selFlags & SF_Aggregate)==0 ){ |
| 155885 | + w.xExprCallback = disallowAggregatesInOrderByCb; |
| 155886 | + w.xSelectCallback = 0; |
| 155887 | + sqlite3WalkExprList(&w, p->pOrderBy); |
| 155888 | + } |
| 155323 | 155889 | |
| 155324 | 155890 | p->pSrc = 0; |
| 155325 | 155891 | p->pWhere = 0; |
| 155326 | 155892 | p->pGroupBy = 0; |
| 155327 | 155893 | p->pHaving = 0; |
| | @@ -155914,10 +156480,11 @@ |
| 155914 | 156480 | Vdbe *pVdbe; /* VDBE object */ |
| 155915 | 156481 | int addrGosub; /* OP_Gosub to this address to return one row */ |
| 155916 | 156482 | int regGosub; /* Register used with OP_Gosub(addrGosub) */ |
| 155917 | 156483 | int regArg; /* First in array of accumulator registers */ |
| 155918 | 156484 | int eDelete; /* See above */ |
| 156485 | + int regRowid; |
| 155919 | 156486 | |
| 155920 | 156487 | WindowCsrAndReg start; |
| 155921 | 156488 | WindowCsrAndReg current; |
| 155922 | 156489 | WindowCsrAndReg end; |
| 155923 | 156490 | }; |
| | @@ -156590,20 +157157,28 @@ |
| 156590 | 157157 | addrContinue = sqlite3VdbeCurrentAddr(v); |
| 156591 | 157158 | |
| 156592 | 157159 | /* If this is a (RANGE BETWEEN a FOLLOWING AND b FOLLOWING) or |
| 156593 | 157160 | ** (RANGE BETWEEN b PRECEDING AND a PRECEDING) frame, ensure the |
| 156594 | 157161 | ** start cursor does not advance past the end cursor within the |
| 156595 | | - ** temporary table. It otherwise might, if (a>b). */ |
| 157162 | + ** temporary table. It otherwise might, if (a>b). Also ensure that, |
| 157163 | + ** if the input cursor is still finding new rows, that the end |
| 157164 | + ** cursor does not go past it to EOF. */ |
| 156596 | 157165 | if( pMWin->eStart==pMWin->eEnd && regCountdown |
| 156597 | | - && pMWin->eFrmType==TK_RANGE && op==WINDOW_AGGINVERSE |
| 157166 | + && pMWin->eFrmType==TK_RANGE |
| 156598 | 157167 | ){ |
| 156599 | 157168 | int regRowid1 = sqlite3GetTempReg(pParse); |
| 156600 | 157169 | int regRowid2 = sqlite3GetTempReg(pParse); |
| 156601 | | - sqlite3VdbeAddOp2(v, OP_Rowid, p->start.csr, regRowid1); |
| 156602 | | - sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid2); |
| 156603 | | - sqlite3VdbeAddOp3(v, OP_Ge, regRowid2, lblDone, regRowid1); |
| 156604 | | - VdbeCoverage(v); |
| 157170 | + if( op==WINDOW_AGGINVERSE ){ |
| 157171 | + sqlite3VdbeAddOp2(v, OP_Rowid, p->start.csr, regRowid1); |
| 157172 | + sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid2); |
| 157173 | + sqlite3VdbeAddOp3(v, OP_Ge, regRowid2, lblDone, regRowid1); |
| 157174 | + VdbeCoverage(v); |
| 157175 | + }else if( p->regRowid ){ |
| 157176 | + sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid1); |
| 157177 | + sqlite3VdbeAddOp3(v, OP_Ge, p->regRowid, lblDone, regRowid1); |
| 157178 | + VdbeCoverageNeverNull(v); |
| 157179 | + } |
| 156605 | 157180 | sqlite3ReleaseTempReg(pParse, regRowid1); |
| 156606 | 157181 | sqlite3ReleaseTempReg(pParse, regRowid2); |
| 156607 | 157182 | assert( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING ); |
| 156608 | 157183 | } |
| 156609 | 157184 | |
| | @@ -157096,11 +157671,10 @@ |
| 157096 | 157671 | int addrGosubFlush = 0; /* Address of OP_Gosub to flush: */ |
| 157097 | 157672 | int addrInteger = 0; /* Address of OP_Integer */ |
| 157098 | 157673 | int addrEmpty; /* Address of OP_Rewind in flush: */ |
| 157099 | 157674 | int regNew; /* Array of registers holding new input row */ |
| 157100 | 157675 | int regRecord; /* regNew array in record form */ |
| 157101 | | - int regRowid; /* Rowid for regRecord in eph table */ |
| 157102 | 157676 | int regNewPeer = 0; /* Peer values for new row (part of regNew) */ |
| 157103 | 157677 | int regPeer = 0; /* Peer values for current row */ |
| 157104 | 157678 | int regFlushPart = 0; /* Register for "Gosub flush_partition" */ |
| 157105 | 157679 | WindowCodeArg s; /* Context object for sub-routines */ |
| 157106 | 157680 | int lblWhereEnd; /* Label just before sqlite3WhereEnd() code */ |
| | @@ -157168,11 +157742,11 @@ |
| 157168 | 157742 | ** samve values in record form, and the rowid used to insert said record |
| 157169 | 157743 | ** into the ephemeral table. */ |
| 157170 | 157744 | regNew = pParse->nMem+1; |
| 157171 | 157745 | pParse->nMem += nInput; |
| 157172 | 157746 | regRecord = ++pParse->nMem; |
| 157173 | | - regRowid = ++pParse->nMem; |
| 157747 | + s.regRowid = ++pParse->nMem; |
| 157174 | 157748 | |
| 157175 | 157749 | /* If the window frame contains an "<expr> PRECEDING" or "<expr> FOLLOWING" |
| 157176 | 157750 | ** clause, allocate registers to store the results of evaluating each |
| 157177 | 157751 | ** <expr>. */ |
| 157178 | 157752 | if( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING ){ |
| | @@ -157224,13 +157798,13 @@ |
| 157224 | 157798 | VdbeComment((v, "call flush_partition")); |
| 157225 | 157799 | sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1); |
| 157226 | 157800 | } |
| 157227 | 157801 | |
| 157228 | 157802 | /* Insert the new row into the ephemeral table */ |
| 157229 | | - sqlite3VdbeAddOp2(v, OP_NewRowid, csrWrite, regRowid); |
| 157230 | | - sqlite3VdbeAddOp3(v, OP_Insert, csrWrite, regRecord, regRowid); |
| 157231 | | - addrNe = sqlite3VdbeAddOp3(v, OP_Ne, pMWin->regOne, 0, regRowid); |
| 157803 | + sqlite3VdbeAddOp2(v, OP_NewRowid, csrWrite, s.regRowid); |
| 157804 | + sqlite3VdbeAddOp3(v, OP_Insert, csrWrite, regRecord, s.regRowid); |
| 157805 | + addrNe = sqlite3VdbeAddOp3(v, OP_Ne, pMWin->regOne, 0, s.regRowid); |
| 157232 | 157806 | VdbeCoverageNeverNull(v); |
| 157233 | 157807 | |
| 157234 | 157808 | /* This block is run for the first row of each partition */ |
| 157235 | 157809 | s.regArg = windowInitAccum(pParse, pMWin); |
| 157236 | 157810 | |
| | @@ -157344,10 +157918,11 @@ |
| 157344 | 157918 | if( pMWin->pPartition ){ |
| 157345 | 157919 | addrInteger = sqlite3VdbeAddOp2(v, OP_Integer, 0, regFlushPart); |
| 157346 | 157920 | sqlite3VdbeJumpHere(v, addrGosubFlush); |
| 157347 | 157921 | } |
| 157348 | 157922 | |
| 157923 | + s.regRowid = 0; |
| 157349 | 157924 | addrEmpty = sqlite3VdbeAddOp1(v, OP_Rewind, csrWrite); |
| 157350 | 157925 | VdbeCoverage(v); |
| 157351 | 157926 | if( pMWin->eEnd==TK_PRECEDING ){ |
| 157352 | 157927 | int bRPS = (pMWin->eStart==TK_PRECEDING && pMWin->eFrmType==TK_RANGE); |
| 157353 | 157928 | windowCodeOp(&s, WINDOW_AGGSTEP, regEnd, 0); |
| | @@ -157817,12 +158392,13 @@ |
| 157817 | 158392 | #define TK_VECTOR 176 |
| 157818 | 158393 | #define TK_SELECT_COLUMN 177 |
| 157819 | 158394 | #define TK_IF_NULL_ROW 178 |
| 157820 | 158395 | #define TK_ASTERISK 179 |
| 157821 | 158396 | #define TK_SPAN 180 |
| 157822 | | -#define TK_SPACE 181 |
| 157823 | | -#define TK_ILLEGAL 182 |
| 158397 | +#define TK_ERROR 181 |
| 158398 | +#define TK_SPACE 182 |
| 158399 | +#define TK_ILLEGAL 183 |
| 157824 | 158400 | #endif |
| 157825 | 158401 | /**************** End token definitions ***************************************/ |
| 157826 | 158402 | |
| 157827 | 158403 | /* The next sections is a series of control #defines. |
| 157828 | 158404 | ** various aspects of the generated parser. |
| | @@ -157878,33 +158454,33 @@ |
| 157878 | 158454 | #ifndef INTERFACE |
| 157879 | 158455 | # define INTERFACE 1 |
| 157880 | 158456 | #endif |
| 157881 | 158457 | /************* Begin control #defines *****************************************/ |
| 157882 | 158458 | #define YYCODETYPE unsigned short int |
| 157883 | | -#define YYNOCODE 316 |
| 158459 | +#define YYNOCODE 317 |
| 157884 | 158460 | #define YYACTIONTYPE unsigned short int |
| 157885 | 158461 | #define YYWILDCARD 101 |
| 157886 | 158462 | #define sqlite3ParserTOKENTYPE Token |
| 157887 | 158463 | typedef union { |
| 157888 | 158464 | int yyinit; |
| 157889 | 158465 | sqlite3ParserTOKENTYPE yy0; |
| 157890 | | - Window* yy19; |
| 157891 | | - struct TrigEvent yy50; |
| 157892 | | - int yy60; |
| 157893 | | - struct FrameBound yy113; |
| 157894 | | - Upsert* yy178; |
| 157895 | | - With* yy195; |
| 157896 | | - IdList* yy288; |
| 157897 | | - SrcList* yy291; |
| 157898 | | - Select* yy307; |
| 157899 | | - ExprList* yy338; |
| 157900 | | - TriggerStep* yy483; |
| 157901 | | - const char* yy528; |
| 157902 | | - u8 yy570; |
| 157903 | | - Expr* yy602; |
| 157904 | | - Cte* yy607; |
| 157905 | | - struct {int value; int mask;} yy615; |
| 158466 | + Window* yy49; |
| 158467 | + ExprList* yy70; |
| 158468 | + Select* yy81; |
| 158469 | + With* yy103; |
| 158470 | + struct FrameBound yy117; |
| 158471 | + struct {int value; int mask;} yy139; |
| 158472 | + SrcList* yy153; |
| 158473 | + TriggerStep* yy157; |
| 158474 | + Upsert* yy190; |
| 158475 | + struct TrigEvent yy262; |
| 158476 | + Cte* yy329; |
| 158477 | + int yy376; |
| 158478 | + Expr* yy404; |
| 158479 | + IdList* yy436; |
| 158480 | + const char* yy504; |
| 158481 | + u8 yy552; |
| 157906 | 158482 | } YYMINORTYPE; |
| 157907 | 158483 | #ifndef YYSTACKDEPTH |
| 157908 | 158484 | #define YYSTACKDEPTH 100 |
| 157909 | 158485 | #endif |
| 157910 | 158486 | #define sqlite3ParserARG_SDECL |
| | @@ -157919,11 +158495,11 @@ |
| 157919 | 158495 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; |
| 157920 | 158496 | #define YYFALLBACK 1 |
| 157921 | 158497 | #define YYNSTATE 570 |
| 157922 | 158498 | #define YYNRULE 398 |
| 157923 | 158499 | #define YYNRULE_WITH_ACTION 337 |
| 157924 | | -#define YYNTOKEN 183 |
| 158500 | +#define YYNTOKEN 184 |
| 157925 | 158501 | #define YY_MAX_SHIFT 569 |
| 157926 | 158502 | #define YY_MIN_SHIFTREDUCE 825 |
| 157927 | 158503 | #define YY_MAX_SHIFTREDUCE 1222 |
| 157928 | 158504 | #define YY_ERROR_ACTION 1223 |
| 157929 | 158505 | #define YY_ACCEPT_ACTION 1224 |
| | @@ -157994,545 +158570,546 @@ |
| 157994 | 158570 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 157995 | 158571 | ** shifting non-terminals after a reduce. |
| 157996 | 158572 | ** yy_default[] Default action for each state. |
| 157997 | 158573 | ** |
| 157998 | 158574 | *********** Begin parsing tables **********************************************/ |
| 157999 | | -#define YY_ACTTAB_COUNT (2020) |
| 158575 | +#define YY_ACTTAB_COUNT (2023) |
| 158000 | 158576 | static const YYACTIONTYPE yy_action[] = { |
| 158001 | | - /* 0 */ 563, 1295, 563, 1274, 168, 361, 115, 112, 218, 373, |
| 158577 | + /* 0 */ 563, 1295, 563, 1274, 168, 1257, 115, 112, 218, 373, |
| 158002 | 158578 | /* 10 */ 563, 1295, 374, 563, 488, 563, 115, 112, 218, 406, |
| 158003 | 158579 | /* 20 */ 1300, 1300, 41, 41, 41, 41, 514, 1504, 520, 1298, |
| 158004 | | - /* 30 */ 1298, 959, 41, 41, 1257, 71, 71, 51, 51, 960, |
| 158580 | + /* 30 */ 1298, 959, 41, 41, 1260, 71, 71, 51, 51, 960, |
| 158005 | 158581 | /* 40 */ 557, 557, 557, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 158006 | 158582 | /* 50 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 414, 406, |
| 158007 | 158583 | /* 60 */ 273, 273, 273, 273, 115, 112, 218, 115, 112, 218, |
| 158008 | | - /* 70 */ 197, 268, 545, 560, 515, 560, 1260, 563, 385, 248, |
| 158584 | + /* 70 */ 197, 268, 545, 560, 515, 560, 211, 563, 385, 248, |
| 158009 | 158585 | /* 80 */ 215, 521, 399, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 158010 | 158586 | /* 90 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 540, 13, |
| 158011 | 158587 | /* 100 */ 13, 1259, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158012 | | - /* 110 */ 117, 116, 441, 1176, 419, 1531, 446, 137, 512, 1539, |
| 158013 | | - /* 120 */ 1545, 372, 1547, 6, 371, 1176, 1148, 1584, 1148, 406, |
| 158014 | | - /* 130 */ 1545, 534, 115, 112, 218, 1267, 99, 441, 121, 121, |
| 158588 | + /* 110 */ 117, 116, 441, 1176, 419, 197, 446, 320, 512, 1539, |
| 158589 | + /* 120 */ 1545, 372, 1547, 6, 371, 1176, 1148, 394, 1148, 406, |
| 158590 | + /* 130 */ 1545, 534, 115, 112, 218, 1415, 99, 30, 121, 121, |
| 158015 | 158591 | /* 140 */ 121, 121, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158016 | 158592 | /* 150 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 158017 | | - /* 160 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 197, 1176, |
| 158018 | | - /* 170 */ 1177, 1178, 241, 304, 554, 501, 498, 497, 473, 124, |
| 158019 | | - /* 180 */ 394, 1176, 1177, 1178, 1176, 496, 119, 119, 119, 119, |
| 158020 | | - /* 190 */ 118, 118, 117, 117, 117, 116, 441, 139, 540, 406, |
| 158593 | + /* 160 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 31, 1176, |
| 158594 | + /* 170 */ 1177, 1178, 241, 357, 1558, 501, 498, 497, 317, 124, |
| 158595 | + /* 180 */ 319, 1176, 1177, 1178, 1176, 496, 119, 119, 119, 119, |
| 158596 | + /* 190 */ 118, 118, 117, 117, 117, 116, 441, 139, 96, 406, |
| 158021 | 158597 | /* 200 */ 121, 121, 121, 121, 114, 117, 117, 117, 116, 441, |
| 158022 | 158598 | /* 210 */ 541, 1532, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158023 | 158599 | /* 220 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 158024 | | - /* 230 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 406, 320, |
| 158025 | | - /* 240 */ 1176, 1177, 1178, 81, 342, 1590, 396, 80, 119, 119, |
| 158026 | | - /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 1176, |
| 158027 | | - /* 260 */ 211, 450, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 158028 | | - /* 270 */ 1028, 120, 120, 121, 121, 121, 121, 251, 450, 449, |
| 158029 | | - /* 280 */ 273, 273, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158030 | | - /* 290 */ 117, 116, 441, 560, 1224, 1, 1, 569, 2, 1228, |
| 158031 | | - /* 300 */ 317, 1176, 319, 1561, 305, 337, 140, 340, 406, 430, |
| 158032 | | - /* 310 */ 469, 1533, 1197, 1308, 348, 1176, 1177, 1178, 168, 462, |
| 158600 | + /* 230 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 406, 441, |
| 158601 | + /* 240 */ 1176, 1177, 1178, 81, 439, 439, 439, 80, 119, 119, |
| 158602 | + /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 488, |
| 158603 | + /* 260 */ 1176, 318, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 158604 | + /* 270 */ 1028, 120, 120, 121, 121, 121, 121, 493, 1025, 1025, |
| 158605 | + /* 280 */ 1036, 1039, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158606 | + /* 290 */ 117, 116, 441, 1584, 995, 1224, 1, 1, 569, 2, |
| 158607 | + /* 300 */ 1228, 1267, 137, 1503, 245, 305, 473, 140, 406, 860, |
| 158608 | + /* 310 */ 561, 1176, 914, 914, 1308, 359, 1176, 1177, 1178, 462, |
| 158033 | 158609 | /* 320 */ 330, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 158034 | 158610 | /* 330 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 158035 | | - /* 340 */ 1028, 120, 120, 121, 121, 121, 121, 273, 273, 563, |
| 158036 | | - /* 350 */ 83, 450, 416, 1564, 569, 2, 1228, 1176, 1177, 1178, |
| 158037 | | - /* 360 */ 560, 305, 471, 140, 944, 995, 860, 563, 467, 1197, |
| 158038 | | - /* 370 */ 1308, 13, 13, 137, 229, 118, 118, 117, 117, 117, |
| 158039 | | - /* 380 */ 116, 441, 96, 318, 946, 504, 424, 361, 562, 71, |
| 158040 | | - /* 390 */ 71, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 158041 | | - /* 400 */ 116, 441, 427, 205, 273, 273, 445, 1015, 259, 276, |
| 158042 | | - /* 410 */ 356, 507, 351, 506, 246, 406, 959, 560, 328, 344, |
| 158043 | | - /* 420 */ 347, 315, 860, 1006, 960, 126, 545, 1005, 313, 304, |
| 158044 | | - /* 430 */ 554, 229, 538, 1539, 148, 544, 281, 6, 203, 122, |
| 158611 | + /* 340 */ 1028, 120, 120, 121, 121, 121, 121, 328, 273, 273, |
| 158612 | + /* 350 */ 1015, 83, 1029, 425, 1564, 569, 2, 1228, 304, 554, |
| 158613 | + /* 360 */ 925, 560, 305, 944, 140, 860, 1006, 1176, 1177, 1178, |
| 158614 | + /* 370 */ 1005, 1308, 411, 213, 511, 229, 119, 119, 119, 119, |
| 158615 | + /* 380 */ 118, 118, 117, 117, 117, 116, 441, 519, 347, 116, |
| 158616 | + /* 390 */ 441, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 158617 | + /* 400 */ 116, 441, 1005, 1005, 1007, 273, 273, 445, 563, 16, |
| 158618 | + /* 410 */ 16, 1590, 563, 1540, 563, 406, 1176, 6, 560, 344, |
| 158619 | + /* 420 */ 182, 118, 118, 117, 117, 117, 116, 441, 416, 142, |
| 158620 | + /* 430 */ 71, 71, 229, 563, 71, 71, 55, 55, 203, 122, |
| 158045 | 158621 | /* 440 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, |
| 158046 | | - /* 450 */ 121, 121, 121, 121, 563, 217, 563, 12, 406, 1005, |
| 158047 | | - /* 460 */ 1005, 1007, 502, 445, 119, 119, 119, 119, 118, 118, |
| 158048 | | - /* 470 */ 117, 117, 117, 116, 441, 452, 71, 71, 70, 70, |
| 158049 | | - /* 480 */ 944, 137, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 158050 | | - /* 490 */ 1028, 120, 120, 121, 121, 121, 121, 1530, 119, 119, |
| 158051 | | - /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 403, |
| 158052 | | - /* 510 */ 402, 241, 1176, 545, 501, 498, 497, 1468, 1143, 451, |
| 158053 | | - /* 520 */ 267, 267, 513, 1540, 496, 142, 1176, 6, 406, 530, |
| 158054 | | - /* 530 */ 194, 1143, 864, 560, 1143, 461, 182, 304, 554, 32, |
| 158055 | | - /* 540 */ 379, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 158622 | + /* 450 */ 121, 121, 121, 121, 217, 13, 13, 1176, 406, 568, |
| 158623 | + /* 460 */ 1400, 1228, 502, 137, 445, 168, 305, 545, 140, 1180, |
| 158624 | + /* 470 */ 424, 545, 1176, 1177, 1178, 1308, 544, 438, 437, 944, |
| 158625 | + /* 480 */ 513, 452, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 158626 | + /* 490 */ 1028, 120, 120, 121, 121, 121, 121, 315, 119, 119, |
| 158627 | + /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 273, |
| 158628 | + /* 510 */ 273, 1143, 416, 1176, 1177, 1178, 543, 563, 1143, 304, |
| 158629 | + /* 520 */ 554, 1561, 560, 1207, 1143, 1207, 1180, 1143, 406, 530, |
| 158630 | + /* 530 */ 421, 1143, 864, 183, 1143, 143, 229, 562, 32, 71, |
| 158631 | + /* 540 */ 71, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 158056 | 158632 | /* 550 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 158057 | | - /* 560 */ 1028, 120, 120, 121, 121, 121, 121, 406, 1176, 1177, |
| 158058 | | - /* 570 */ 1178, 857, 568, 1176, 1228, 925, 1176, 454, 361, 305, |
| 158059 | | - /* 580 */ 189, 140, 1176, 1177, 1178, 519, 529, 404, 1308, 183, |
| 158633 | + /* 560 */ 1028, 120, 120, 121, 121, 121, 121, 406, 445, 241, |
| 158634 | + /* 570 */ 1176, 857, 501, 498, 497, 1176, 526, 189, 245, 538, |
| 158635 | + /* 580 */ 1539, 282, 496, 370, 6, 563, 529, 477, 5, 279, |
| 158060 | 158636 | /* 590 */ 1015, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, |
| 158061 | | - /* 600 */ 120, 120, 121, 121, 121, 121, 1006, 16, 16, 370, |
| 158637 | + /* 600 */ 120, 120, 121, 121, 121, 121, 1006, 13, 13, 1414, |
| 158062 | 158638 | /* 610 */ 1005, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 158063 | | - /* 620 */ 116, 441, 273, 273, 1537, 150, 1176, 98, 6, 1176, |
| 158064 | | - /* 630 */ 1177, 1178, 1176, 1177, 1178, 560, 380, 406, 376, 438, |
| 158065 | | - /* 640 */ 437, 1161, 1005, 1005, 1007, 1025, 1025, 1036, 1039, 229, |
| 158639 | + /* 620 */ 116, 441, 426, 273, 273, 1176, 1176, 1177, 1178, 1619, |
| 158640 | + /* 630 */ 392, 1176, 1177, 1178, 1176, 342, 560, 406, 525, 361, |
| 158641 | + /* 640 */ 430, 1161, 1005, 1005, 1007, 348, 411, 357, 1558, 488, |
| 158066 | 158642 | /* 650 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 158067 | 158643 | /* 660 */ 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, |
| 158068 | | - /* 670 */ 120, 120, 121, 121, 121, 121, 406, 1143, 1619, 392, |
| 158069 | | - /* 680 */ 1016, 445, 1176, 1177, 1178, 1207, 525, 1207, 1530, 995, |
| 158070 | | - /* 690 */ 1143, 304, 554, 1143, 5, 563, 543, 3, 361, 216, |
| 158644 | + /* 670 */ 120, 120, 121, 121, 121, 121, 406, 830, 831, 832, |
| 158645 | + /* 680 */ 1016, 1176, 1177, 1178, 396, 285, 148, 1312, 304, 554, |
| 158646 | + /* 690 */ 1176, 1177, 1178, 1467, 216, 3, 337, 137, 340, 560, |
| 158071 | 158647 | /* 700 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, |
| 158072 | | - /* 710 */ 120, 121, 121, 121, 121, 143, 563, 13, 13, 1029, |
| 158648 | + /* 710 */ 120, 121, 121, 121, 121, 563, 504, 946, 273, 273, |
| 158073 | 158649 | /* 720 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 158074 | | - /* 730 */ 441, 1176, 426, 563, 1176, 563, 274, 274, 13, 13, |
| 158075 | | - /* 740 */ 1078, 1176, 328, 457, 316, 147, 406, 211, 361, 560, |
| 158076 | | - /* 750 */ 1000, 213, 511, 293, 477, 55, 55, 71, 71, 119, |
| 158650 | + /* 730 */ 441, 560, 1176, 427, 563, 451, 98, 13, 13, 259, |
| 158651 | + /* 740 */ 276, 356, 507, 351, 506, 246, 406, 361, 469, 1530, |
| 158652 | + /* 750 */ 1000, 347, 293, 304, 554, 1589, 71, 71, 889, 119, |
| 158077 | 158653 | /* 760 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441, |
| 158078 | 158654 | /* 770 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, |
| 158079 | | - /* 780 */ 120, 121, 121, 121, 121, 406, 455, 1176, 1177, 1178, |
| 158080 | | - /* 790 */ 1176, 1177, 1178, 471, 526, 149, 404, 1176, 1177, 1178, |
| 158081 | | - /* 800 */ 105, 270, 103, 563, 944, 563, 116, 441, 1530, 122, |
| 158655 | + /* 780 */ 120, 121, 121, 121, 121, 406, 1143, 1078, 1176, 1177, |
| 158656 | + /* 790 */ 1178, 416, 1080, 300, 150, 995, 1080, 361, 361, 1143, |
| 158657 | + /* 800 */ 361, 378, 1143, 477, 563, 244, 243, 242, 1278, 122, |
| 158082 | 158658 | /* 810 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, |
| 158083 | | - /* 820 */ 121, 121, 121, 121, 945, 13, 13, 13, 13, 119, |
| 158659 | + /* 820 */ 121, 121, 121, 121, 563, 880, 13, 13, 483, 119, |
| 158084 | 158660 | /* 830 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441, |
| 158085 | | - /* 840 */ 191, 563, 192, 563, 416, 439, 439, 439, 1083, 1083, |
| 158086 | | - /* 850 */ 485, 561, 285, 914, 914, 406, 462, 330, 1530, 830, |
| 158087 | | - /* 860 */ 831, 832, 206, 71, 71, 71, 71, 286, 119, 119, |
| 158661 | + /* 840 */ 1176, 191, 540, 563, 147, 149, 13, 13, 328, 457, |
| 158662 | + /* 850 */ 316, 1083, 1083, 485, 1537, 406, 505, 1530, 6, 1514, |
| 158663 | + /* 860 */ 284, 192, 1277, 145, 881, 71, 71, 488, 119, 119, |
| 158088 | 158664 | /* 870 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 122, |
| 158089 | 158665 | /* 880 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, |
| 158090 | | - /* 890 */ 121, 121, 121, 121, 563, 217, 563, 1122, 1617, 406, |
| 158091 | | - /* 900 */ 300, 1617, 301, 416, 1278, 1473, 244, 243, 242, 1249, |
| 158092 | | - /* 910 */ 412, 556, 412, 282, 842, 279, 71, 71, 71, 71, |
| 158093 | | - /* 920 */ 944, 1415, 1473, 1475, 101, 113, 1200, 1200, 1035, 1038, |
| 158666 | + /* 890 */ 121, 121, 121, 121, 563, 471, 1176, 1177, 1178, 406, |
| 158667 | + /* 900 */ 852, 327, 301, 462, 330, 1516, 270, 1530, 1530, 944, |
| 158668 | + /* 910 */ 1531, 1307, 313, 9, 842, 251, 71, 71, 477, 428, |
| 158669 | + /* 920 */ 146, 488, 38, 945, 101, 113, 1200, 1200, 1035, 1038, |
| 158094 | 158670 | /* 930 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 119, 119, |
| 158095 | | - /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 273, |
| 158096 | | - /* 950 */ 273, 1099, 563, 436, 1143, 440, 563, 1122, 1618, 357, |
| 158097 | | - /* 960 */ 1558, 1618, 560, 546, 488, 197, 1100, 1143, 378, 290, |
| 158098 | | - /* 970 */ 1143, 1306, 284, 460, 71, 71, 1120, 405, 13, 13, |
| 158099 | | - /* 980 */ 145, 1101, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158100 | | - /* 990 */ 117, 116, 441, 542, 104, 1473, 509, 273, 273, 294, |
| 158101 | | - /* 1000 */ 1514, 294, 900, 273, 273, 273, 273, 563, 1503, 563, |
| 158102 | | - /* 1010 */ 560, 545, 901, 464, 406, 1058, 560, 852, 560, 198, |
| 158103 | | - /* 1020 */ 547, 1080, 920, 404, 1400, 1080, 146, 919, 38, 56, |
| 158104 | | - /* 1030 */ 56, 15, 15, 563, 406, 12, 1120, 471, 122, 123, |
| 158671 | + /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 563, |
| 158672 | + /* 950 */ 1197, 1099, 563, 436, 563, 1533, 563, 852, 1122, 1617, |
| 158673 | + /* 960 */ 454, 290, 1617, 546, 251, 1303, 1100, 267, 267, 281, |
| 158674 | + /* 970 */ 404, 70, 70, 460, 71, 71, 71, 71, 13, 13, |
| 158675 | + /* 980 */ 560, 1101, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158676 | + /* 990 */ 117, 116, 441, 542, 104, 273, 273, 273, 273, 1197, |
| 158677 | + /* 1000 */ 217, 1468, 900, 471, 450, 563, 1473, 1197, 560, 447, |
| 158678 | + /* 1010 */ 560, 545, 901, 440, 406, 1058, 292, 274, 274, 198, |
| 158679 | + /* 1020 */ 547, 450, 449, 1473, 1475, 944, 455, 56, 56, 410, |
| 158680 | + /* 1030 */ 560, 1122, 1618, 379, 406, 1618, 404, 1120, 122, 123, |
| 158105 | 158681 | /* 1040 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, |
| 158106 | | - /* 1050 */ 121, 121, 121, 1460, 406, 43, 43, 483, 122, 123, |
| 158682 | + /* 1050 */ 121, 121, 121, 1460, 406, 12, 1197, 1512, 122, 123, |
| 158107 | 158683 | /* 1060 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, |
| 158108 | | - /* 1070 */ 121, 121, 121, 563, 852, 9, 471, 251, 122, 111, |
| 158684 | + /* 1070 */ 121, 121, 121, 308, 471, 126, 359, 286, 122, 111, |
| 158109 | 158685 | /* 1080 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, |
| 158110 | | - /* 1090 */ 121, 121, 121, 563, 421, 57, 57, 119, 119, 119, |
| 158111 | | - /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 441, 1176, 493, |
| 158112 | | - /* 1110 */ 563, 289, 1197, 478, 1516, 44, 44, 119, 119, 119, |
| 158113 | | - /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 441, 880, 563, |
| 158114 | | - /* 1130 */ 536, 563, 58, 58, 488, 1414, 245, 119, 119, 119, |
| 158115 | | - /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 441, 563, 535, |
| 158116 | | - /* 1150 */ 291, 59, 59, 60, 60, 438, 437, 406, 1154, 505, |
| 158117 | | - /* 1160 */ 304, 554, 477, 1204, 1176, 1177, 1178, 881, 1206, 1197, |
| 158118 | | - /* 1170 */ 61, 61, 1246, 357, 1558, 1538, 1205, 563, 1467, 6, |
| 158119 | | - /* 1180 */ 1176, 488, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, |
| 158120 | | - /* 1190 */ 120, 120, 121, 121, 121, 121, 1400, 1143, 410, 62, |
| 158121 | | - /* 1200 */ 62, 1207, 1099, 1207, 411, 447, 273, 273, 537, 1154, |
| 158122 | | - /* 1210 */ 1143, 108, 555, 1143, 4, 391, 1220, 1100, 1512, 560, |
| 158123 | | - /* 1220 */ 347, 516, 428, 548, 308, 1307, 1536, 1077, 558, 1077, |
| 158124 | | - /* 1230 */ 6, 488, 1101, 1400, 488, 309, 1176, 1177, 1178, 563, |
| 158686 | + /* 1090 */ 121, 121, 121, 309, 450, 471, 1473, 119, 119, 119, |
| 158687 | + /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 441, 1176, 563, |
| 158688 | + /* 1110 */ 1120, 482, 563, 312, 433, 479, 197, 119, 119, 119, |
| 158689 | + /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 441, 405, 12, |
| 158690 | + /* 1130 */ 536, 15, 15, 478, 43, 43, 509, 119, 119, 119, |
| 158691 | + /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 441, 289, 535, |
| 158692 | + /* 1150 */ 294, 563, 294, 391, 1220, 438, 437, 406, 1154, 403, |
| 158693 | + /* 1160 */ 402, 1400, 920, 1204, 1176, 1177, 1178, 919, 1206, 291, |
| 158694 | + /* 1170 */ 1306, 1249, 412, 57, 57, 488, 1205, 563, 556, 412, |
| 158695 | + /* 1180 */ 1176, 1344, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, |
| 158696 | + /* 1190 */ 120, 120, 121, 121, 121, 121, 1400, 1143, 563, 44, |
| 158697 | + /* 1200 */ 44, 1207, 194, 1207, 273, 273, 1400, 461, 537, 1154, |
| 158698 | + /* 1210 */ 1143, 108, 555, 1143, 4, 391, 1121, 560, 1538, 335, |
| 158699 | + /* 1220 */ 58, 58, 6, 1246, 1099, 380, 1400, 376, 558, 1536, |
| 158700 | + /* 1230 */ 563, 422, 1221, 6, 304, 554, 1176, 1177, 1178, 1100, |
| 158125 | 158701 | /* 1240 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 158126 | | - /* 1250 */ 441, 442, 278, 551, 563, 273, 273, 273, 273, 563, |
| 158127 | | - /* 1260 */ 327, 45, 45, 552, 563, 528, 422, 563, 560, 1400, |
| 158128 | | - /* 1270 */ 560, 108, 555, 137, 4, 1303, 46, 46, 335, 563, |
| 158129 | | - /* 1280 */ 482, 47, 47, 477, 479, 307, 49, 49, 558, 50, |
| 158130 | | - /* 1290 */ 50, 563, 1015, 563, 1221, 563, 1400, 563, 106, 106, |
| 158131 | | - /* 1300 */ 8, 63, 63, 423, 563, 107, 312, 442, 565, 564, |
| 158132 | | - /* 1310 */ 563, 442, 1005, 64, 64, 65, 65, 14, 14, 66, |
| 158133 | | - /* 1320 */ 66, 391, 1121, 552, 1312, 1180, 128, 128, 563, 304, |
| 158134 | | - /* 1330 */ 554, 563, 67, 67, 563, 359, 560, 532, 563, 484, |
| 158135 | | - /* 1340 */ 563, 1196, 531, 222, 1005, 1005, 1007, 1008, 27, 522, |
| 158136 | | - /* 1350 */ 52, 52, 1015, 68, 68, 563, 69, 69, 106, 106, |
| 158137 | | - /* 1360 */ 53, 53, 156, 156, 563, 107, 434, 442, 565, 564, |
| 158138 | | - /* 1370 */ 272, 215, 1005, 425, 563, 359, 563, 157, 157, 563, |
| 158139 | | - /* 1380 */ 1535, 292, 1180, 98, 6, 1344, 76, 76, 1215, 475, |
| 158140 | | - /* 1390 */ 413, 169, 226, 563, 245, 563, 54, 54, 72, 72, |
| 158141 | | - /* 1400 */ 1221, 129, 129, 1343, 1005, 1005, 1007, 1008, 27, 1563, |
| 158142 | | - /* 1410 */ 1165, 444, 456, 433, 277, 73, 73, 130, 130, 389, |
| 158143 | | - /* 1420 */ 389, 388, 262, 386, 1165, 444, 839, 1519, 277, 108, |
| 158144 | | - /* 1430 */ 555, 321, 4, 389, 389, 388, 262, 386, 563, 223, |
| 158145 | | - /* 1440 */ 839, 311, 468, 84, 202, 523, 558, 1492, 303, 310, |
| 158146 | | - /* 1450 */ 563, 110, 404, 223, 563, 311, 206, 30, 404, 277, |
| 158147 | | - /* 1460 */ 131, 131, 411, 310, 389, 389, 388, 262, 386, 442, |
| 158148 | | - /* 1470 */ 920, 839, 127, 127, 563, 919, 155, 155, 1491, 225, |
| 158149 | | - /* 1480 */ 563, 552, 871, 563, 223, 476, 311, 161, 31, 563, |
| 158150 | | - /* 1490 */ 135, 563, 480, 225, 310, 532, 154, 154, 332, 17, |
| 158151 | | - /* 1500 */ 533, 161, 136, 136, 135, 134, 134, 224, 228, 355, |
| 158152 | | - /* 1510 */ 1015, 132, 132, 133, 133, 1589, 106, 106, 889, 354, |
| 158153 | | - /* 1520 */ 563, 224, 563, 107, 225, 442, 565, 564, 1117, 275, |
| 158154 | | - /* 1530 */ 1005, 393, 161, 518, 563, 135, 108, 555, 417, 4, |
| 158155 | | - /* 1540 */ 1340, 407, 75, 75, 77, 77, 304, 554, 867, 563, |
| 158156 | | - /* 1550 */ 336, 563, 224, 558, 463, 407, 74, 74, 465, 1065, |
| 158157 | | - /* 1560 */ 304, 554, 1005, 1005, 1007, 1008, 27, 962, 963, 543, |
| 158158 | | - /* 1570 */ 448, 42, 42, 48, 48, 326, 442, 325, 98, 997, |
| 158159 | | - /* 1580 */ 470, 287, 250, 250, 448, 1009, 407, 472, 552, 339, |
| 158160 | | - /* 1590 */ 250, 304, 554, 879, 878, 331, 108, 555, 98, 4, |
| 158161 | | - /* 1600 */ 1277, 494, 532, 345, 247, 867, 98, 531, 341, 886, |
| 158162 | | - /* 1610 */ 887, 1126, 1076, 558, 1076, 448, 1065, 1015, 1061, 953, |
| 158163 | | - /* 1620 */ 343, 247, 250, 106, 106, 1291, 917, 1276, 850, 110, |
| 158164 | | - /* 1630 */ 107, 144, 442, 565, 564, 918, 442, 1005, 110, 1275, |
| 158165 | | - /* 1640 */ 350, 360, 1009, 1331, 1352, 299, 1399, 1577, 552, 1327, |
| 158166 | | - /* 1650 */ 1552, 550, 1338, 549, 1405, 1256, 1248, 1237, 1236, 1238, |
| 158167 | | - /* 1660 */ 1571, 489, 265, 200, 1324, 363, 365, 367, 11, 1005, |
| 158168 | | - /* 1670 */ 1005, 1007, 1008, 27, 390, 221, 1386, 1015, 280, 1391, |
| 158169 | | - /* 1680 */ 1381, 208, 323, 106, 106, 924, 1374, 453, 283, 324, |
| 158170 | | - /* 1690 */ 107, 474, 442, 565, 564, 1390, 499, 1005, 212, 288, |
| 158171 | | - /* 1700 */ 1274, 397, 353, 108, 555, 195, 4, 1464, 369, 1463, |
| 158172 | | - /* 1710 */ 1574, 1215, 1212, 329, 553, 171, 207, 383, 1511, 196, |
| 158173 | | - /* 1720 */ 558, 254, 1509, 415, 100, 555, 83, 4, 204, 1005, |
| 158174 | | - /* 1730 */ 1005, 1007, 1008, 27, 219, 79, 82, 1469, 180, 166, |
| 158175 | | - /* 1740 */ 173, 558, 458, 442, 175, 176, 177, 178, 35, 1387, |
| 158176 | | - /* 1750 */ 492, 459, 231, 1395, 96, 552, 1393, 1392, 395, 184, |
| 158177 | | - /* 1760 */ 481, 466, 36, 235, 442, 89, 398, 266, 487, 1480, |
| 158178 | | - /* 1770 */ 1458, 237, 188, 338, 508, 429, 552, 490, 400, 238, |
| 158179 | | - /* 1780 */ 334, 1239, 239, 1294, 1015, 1293, 1292, 1285, 91, 871, |
| 158180 | | - /* 1790 */ 106, 106, 213, 431, 1588, 432, 524, 107, 517, 442, |
| 158181 | | - /* 1800 */ 565, 564, 401, 1264, 1005, 1015, 1263, 1587, 352, 1262, |
| 158182 | | - /* 1810 */ 1557, 106, 106, 1586, 1284, 297, 298, 358, 107, 1335, |
| 158183 | | - /* 1820 */ 442, 565, 564, 95, 362, 1005, 253, 252, 435, 125, |
| 158184 | | - /* 1830 */ 543, 10, 1444, 1543, 377, 1542, 1005, 1005, 1007, 1008, |
| 158185 | | - /* 1840 */ 27, 302, 102, 97, 527, 1336, 260, 1317, 364, 1245, |
| 158186 | | - /* 1850 */ 1334, 34, 566, 1171, 366, 381, 375, 1005, 1005, 1007, |
| 158187 | | - /* 1860 */ 1008, 27, 1333, 1359, 368, 1316, 199, 382, 261, 263, |
| 158188 | | - /* 1870 */ 264, 1358, 158, 1496, 141, 1497, 1495, 567, 1234, 1229, |
| 158189 | | - /* 1880 */ 1494, 295, 159, 209, 210, 78, 826, 443, 201, 306, |
| 158190 | | - /* 1890 */ 220, 1075, 138, 1073, 160, 314, 162, 172, 1196, 174, |
| 158191 | | - /* 1900 */ 903, 227, 230, 322, 1089, 179, 163, 164, 418, 85, |
| 158192 | | - /* 1910 */ 420, 181, 170, 408, 409, 86, 87, 165, 88, 1092, |
| 158193 | | - /* 1920 */ 232, 233, 1088, 151, 18, 234, 1081, 250, 333, 185, |
| 158194 | | - /* 1930 */ 1209, 486, 236, 186, 37, 841, 491, 354, 240, 346, |
| 158195 | | - /* 1940 */ 503, 187, 90, 167, 19, 495, 20, 869, 500, 349, |
| 158196 | | - /* 1950 */ 92, 882, 296, 152, 93, 510, 1127, 1159, 153, 1041, |
| 158197 | | - /* 1960 */ 214, 1128, 39, 94, 269, 271, 952, 190, 947, 110, |
| 158198 | | - /* 1970 */ 1149, 1145, 1153, 249, 1133, 1147, 7, 33, 21, 193, |
| 158199 | | - /* 1980 */ 22, 23, 24, 25, 1152, 539, 98, 1056, 26, 1042, |
| 158200 | | - /* 1990 */ 1040, 1044, 1098, 1045, 1097, 256, 255, 28, 40, 387, |
| 158201 | | - /* 2000 */ 1010, 851, 109, 29, 1167, 559, 384, 257, 913, 258, |
| 158202 | | - /* 2010 */ 1166, 1579, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1578, |
| 158702 | + /* 1250 */ 441, 442, 59, 59, 1101, 516, 1535, 273, 273, 563, |
| 158703 | + /* 1260 */ 6, 563, 110, 552, 563, 528, 423, 413, 169, 548, |
| 158704 | + /* 1270 */ 560, 108, 555, 137, 4, 551, 484, 272, 215, 222, |
| 158705 | + /* 1280 */ 211, 60, 60, 61, 61, 98, 62, 62, 558, 273, |
| 158706 | + /* 1290 */ 273, 563, 1015, 467, 1221, 563, 434, 563, 106, 106, |
| 158707 | + /* 1300 */ 8, 920, 560, 273, 273, 107, 919, 442, 565, 564, |
| 158708 | + /* 1310 */ 563, 442, 1005, 45, 45, 464, 560, 46, 46, 47, |
| 158709 | + /* 1320 */ 47, 84, 202, 552, 1215, 404, 468, 563, 205, 304, |
| 158710 | + /* 1330 */ 554, 563, 49, 49, 563, 522, 404, 532, 563, 867, |
| 158711 | + /* 1340 */ 563, 105, 531, 103, 1005, 1005, 1007, 1008, 27, 50, |
| 158712 | + /* 1350 */ 50, 563, 1015, 63, 63, 475, 64, 64, 106, 106, |
| 158713 | + /* 1360 */ 65, 65, 14, 14, 17, 107, 563, 442, 565, 564, |
| 158714 | + /* 1370 */ 563, 303, 1005, 66, 66, 563, 226, 563, 959, 563, |
| 158715 | + /* 1380 */ 543, 404, 1196, 1343, 871, 278, 960, 456, 128, 128, |
| 158716 | + /* 1390 */ 563, 1065, 67, 67, 563, 206, 867, 52, 52, 68, |
| 158717 | + /* 1400 */ 68, 69, 69, 417, 1005, 1005, 1007, 1008, 27, 1563, |
| 158718 | + /* 1410 */ 1165, 444, 53, 53, 277, 1519, 156, 156, 307, 389, |
| 158719 | + /* 1420 */ 389, 388, 262, 386, 1165, 444, 839, 321, 277, 108, |
| 158720 | + /* 1430 */ 555, 523, 4, 389, 389, 388, 262, 386, 563, 223, |
| 158721 | + /* 1440 */ 839, 311, 326, 1492, 1117, 98, 558, 393, 1065, 310, |
| 158722 | + /* 1450 */ 563, 476, 563, 223, 563, 311, 879, 878, 1009, 277, |
| 158723 | + /* 1460 */ 157, 157, 463, 310, 389, 389, 388, 262, 386, 442, |
| 158724 | + /* 1470 */ 518, 839, 76, 76, 54, 54, 72, 72, 355, 225, |
| 158725 | + /* 1480 */ 563, 552, 275, 563, 223, 325, 311, 161, 354, 465, |
| 158726 | + /* 1490 */ 135, 563, 228, 225, 310, 532, 563, 206, 886, 887, |
| 158727 | + /* 1500 */ 533, 161, 129, 129, 135, 73, 73, 224, 962, 963, |
| 158728 | + /* 1510 */ 1015, 563, 287, 130, 130, 1009, 106, 106, 131, 131, |
| 158729 | + /* 1520 */ 563, 224, 563, 107, 225, 442, 565, 564, 997, 1276, |
| 158730 | + /* 1530 */ 1005, 250, 161, 127, 127, 135, 108, 555, 1077, 4, |
| 158731 | + /* 1540 */ 1077, 407, 155, 155, 154, 154, 304, 554, 1126, 563, |
| 158732 | + /* 1550 */ 1331, 563, 224, 558, 470, 407, 563, 250, 563, 1491, |
| 158733 | + /* 1560 */ 304, 554, 1005, 1005, 1007, 1008, 27, 563, 480, 332, |
| 158734 | + /* 1570 */ 448, 136, 136, 134, 134, 1340, 442, 336, 132, 132, |
| 158735 | + /* 1580 */ 133, 133, 563, 1076, 448, 1076, 407, 563, 552, 75, |
| 158736 | + /* 1590 */ 75, 304, 554, 339, 341, 343, 108, 555, 563, 4, |
| 158737 | + /* 1600 */ 1577, 299, 532, 563, 77, 77, 1291, 531, 472, 74, |
| 158738 | + /* 1610 */ 74, 250, 1275, 558, 350, 448, 331, 1015, 360, 98, |
| 158739 | + /* 1620 */ 42, 42, 1352, 106, 106, 48, 48, 1399, 494, 1327, |
| 158740 | + /* 1630 */ 107, 247, 442, 565, 564, 345, 442, 1005, 98, 1061, |
| 158741 | + /* 1640 */ 953, 917, 247, 250, 110, 1552, 550, 850, 552, 918, |
| 158742 | + /* 1650 */ 144, 1338, 110, 549, 1405, 1256, 1248, 1237, 1236, 1238, |
| 158743 | + /* 1660 */ 1571, 1324, 208, 390, 489, 265, 363, 200, 365, 1005, |
| 158744 | + /* 1670 */ 1005, 1007, 1008, 27, 11, 280, 221, 1015, 323, 474, |
| 158745 | + /* 1680 */ 1274, 367, 212, 106, 106, 924, 1386, 324, 288, 1381, |
| 158746 | + /* 1690 */ 107, 453, 442, 565, 564, 283, 329, 1005, 1391, 499, |
| 158747 | + /* 1700 */ 353, 1374, 1464, 108, 555, 1463, 4, 1574, 1390, 397, |
| 158748 | + /* 1710 */ 1215, 171, 254, 369, 383, 207, 195, 196, 1511, 553, |
| 158749 | + /* 1720 */ 558, 1509, 415, 1212, 100, 555, 83, 4, 204, 1005, |
| 158750 | + /* 1730 */ 1005, 1007, 1008, 27, 180, 166, 173, 219, 79, 82, |
| 158751 | + /* 1740 */ 458, 558, 175, 442, 35, 1387, 176, 459, 177, 178, |
| 158752 | + /* 1750 */ 492, 231, 96, 1469, 395, 552, 1393, 1392, 36, 466, |
| 158753 | + /* 1760 */ 1395, 184, 398, 481, 442, 1458, 235, 89, 1480, 487, |
| 158754 | + /* 1770 */ 266, 334, 237, 188, 490, 400, 552, 338, 238, 508, |
| 158755 | + /* 1780 */ 1239, 239, 1294, 1293, 1015, 1292, 1285, 429, 91, 871, |
| 158756 | + /* 1790 */ 106, 106, 1588, 213, 401, 1587, 431, 107, 1264, 442, |
| 158757 | + /* 1800 */ 565, 564, 1263, 352, 1005, 1015, 1262, 1586, 1557, 517, |
| 158758 | + /* 1810 */ 432, 106, 106, 1284, 297, 298, 358, 524, 107, 1335, |
| 158759 | + /* 1820 */ 442, 565, 564, 95, 1336, 1005, 252, 253, 435, 125, |
| 158760 | + /* 1830 */ 543, 1543, 10, 1444, 377, 1542, 1005, 1005, 1007, 1008, |
| 158761 | + /* 1840 */ 27, 97, 527, 375, 362, 102, 260, 364, 381, 1317, |
| 158762 | + /* 1850 */ 382, 1334, 366, 1245, 1333, 1316, 368, 1005, 1005, 1007, |
| 158763 | + /* 1860 */ 1008, 27, 1359, 1358, 34, 199, 1171, 566, 261, 263, |
| 158764 | + /* 1870 */ 264, 567, 1234, 158, 1229, 141, 295, 159, 1496, 302, |
| 158765 | + /* 1880 */ 1497, 1495, 1494, 160, 826, 209, 443, 201, 306, 210, |
| 158766 | + /* 1890 */ 78, 220, 1075, 138, 1073, 314, 162, 172, 1196, 227, |
| 158767 | + /* 1900 */ 174, 903, 322, 230, 1089, 179, 163, 164, 418, 408, |
| 158768 | + /* 1910 */ 409, 170, 181, 85, 86, 420, 87, 165, 1092, 88, |
| 158769 | + /* 1920 */ 233, 232, 1088, 151, 18, 234, 1081, 250, 333, 1209, |
| 158770 | + /* 1930 */ 185, 486, 236, 186, 37, 841, 491, 354, 240, 346, |
| 158771 | + /* 1940 */ 495, 187, 90, 869, 19, 20, 500, 503, 349, 92, |
| 158772 | + /* 1950 */ 167, 152, 296, 882, 93, 510, 94, 1159, 153, 1041, |
| 158773 | + /* 1960 */ 1128, 39, 214, 269, 1127, 271, 249, 952, 190, 947, |
| 158774 | + /* 1970 */ 110, 1149, 21, 7, 1153, 22, 1145, 23, 1147, 24, |
| 158775 | + /* 1980 */ 1133, 25, 1152, 33, 539, 193, 26, 1056, 98, 1042, |
| 158776 | + /* 1990 */ 1040, 1044, 1098, 1045, 1097, 256, 255, 28, 40, 257, |
| 158777 | + /* 2000 */ 1010, 851, 109, 29, 913, 559, 384, 387, 258, 1167, |
| 158778 | + /* 2010 */ 1166, 1225, 1225, 1225, 1579, 1225, 1225, 1225, 1225, 1225, |
| 158779 | + /* 2020 */ 1225, 1225, 1578, |
| 158203 | 158780 | }; |
| 158204 | 158781 | static const YYCODETYPE yy_lookahead[] = { |
| 158205 | | - /* 0 */ 191, 220, 191, 222, 191, 191, 271, 272, 273, 216, |
| 158206 | | - /* 10 */ 191, 230, 216, 191, 191, 191, 271, 272, 273, 19, |
| 158207 | | - /* 20 */ 232, 233, 213, 214, 213, 214, 202, 292, 202, 232, |
| 158208 | | - /* 30 */ 233, 31, 213, 214, 213, 213, 214, 213, 214, 39, |
| 158209 | | - /* 40 */ 207, 208, 209, 43, 44, 45, 46, 47, 48, 49, |
| 158210 | | - /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 235, 19, |
| 158211 | | - /* 60 */ 236, 237, 236, 237, 271, 272, 273, 271, 272, 273, |
| 158212 | | - /* 70 */ 191, 210, 250, 249, 250, 249, 213, 191, 199, 253, |
| 158213 | | - /* 80 */ 254, 259, 203, 43, 44, 45, 46, 47, 48, 49, |
| 158214 | | - /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 213, |
| 158215 | | - /* 100 */ 214, 213, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158216 | | - /* 110 */ 110, 111, 112, 59, 228, 301, 293, 81, 305, 306, |
| 158217 | | - /* 120 */ 311, 312, 311, 310, 313, 59, 86, 212, 88, 19, |
| 158218 | | - /* 130 */ 311, 312, 271, 272, 273, 220, 26, 112, 54, 55, |
| 158782 | + /* 0 */ 192, 221, 192, 223, 192, 214, 272, 273, 274, 217, |
| 158783 | + /* 10 */ 192, 231, 217, 192, 192, 192, 272, 273, 274, 19, |
| 158784 | + /* 20 */ 233, 234, 214, 215, 214, 215, 203, 293, 203, 233, |
| 158785 | + /* 30 */ 234, 31, 214, 215, 214, 214, 215, 214, 215, 39, |
| 158786 | + /* 40 */ 208, 209, 210, 43, 44, 45, 46, 47, 48, 49, |
| 158787 | + /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 236, 19, |
| 158788 | + /* 60 */ 237, 238, 237, 238, 272, 273, 274, 272, 273, 274, |
| 158789 | + /* 70 */ 192, 211, 251, 250, 251, 250, 26, 192, 200, 254, |
| 158790 | + /* 80 */ 255, 260, 204, 43, 44, 45, 46, 47, 48, 49, |
| 158791 | + /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 192, 214, |
| 158792 | + /* 100 */ 215, 214, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158793 | + /* 110 */ 110, 111, 112, 59, 229, 192, 294, 16, 306, 307, |
| 158794 | + /* 120 */ 312, 313, 312, 311, 314, 59, 86, 204, 88, 19, |
| 158795 | + /* 130 */ 312, 313, 272, 273, 274, 271, 26, 22, 54, 55, |
| 158219 | 158796 | /* 140 */ 56, 57, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158220 | 158797 | /* 150 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, |
| 158221 | | - /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 115, |
| 158222 | | - /* 170 */ 116, 117, 118, 137, 138, 121, 122, 123, 191, 69, |
| 158223 | | - /* 180 */ 203, 115, 116, 117, 59, 131, 102, 103, 104, 105, |
| 158224 | | - /* 190 */ 106, 107, 108, 109, 110, 111, 112, 72, 191, 19, |
| 158798 | + /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 53, 115, |
| 158799 | + /* 170 */ 116, 117, 118, 309, 310, 121, 122, 123, 77, 69, |
| 158800 | + /* 180 */ 79, 115, 116, 117, 59, 131, 102, 103, 104, 105, |
| 158801 | + /* 190 */ 106, 107, 108, 109, 110, 111, 112, 72, 148, 19, |
| 158225 | 158802 | /* 200 */ 54, 55, 56, 57, 58, 108, 109, 110, 111, 112, |
| 158226 | | - /* 210 */ 303, 304, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158803 | + /* 210 */ 304, 305, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158227 | 158804 | /* 220 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, |
| 158228 | | - /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 16, |
| 158229 | | - /* 240 */ 115, 116, 117, 24, 16, 227, 202, 67, 102, 103, |
| 158230 | | - /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 59, |
| 158231 | | - /* 260 */ 26, 191, 43, 44, 45, 46, 47, 48, 49, 50, |
| 158232 | | - /* 270 */ 51, 52, 53, 54, 55, 56, 57, 24, 208, 209, |
| 158233 | | - /* 280 */ 236, 237, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158234 | | - /* 290 */ 110, 111, 112, 249, 183, 184, 185, 186, 187, 188, |
| 158235 | | - /* 300 */ 77, 59, 79, 191, 193, 77, 195, 79, 19, 19, |
| 158236 | | - /* 310 */ 266, 304, 59, 202, 24, 115, 116, 117, 191, 127, |
| 158805 | + /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 112, |
| 158806 | + /* 240 */ 115, 116, 117, 24, 208, 209, 210, 67, 102, 103, |
| 158807 | + /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 192, |
| 158808 | + /* 260 */ 59, 160, 43, 44, 45, 46, 47, 48, 49, 50, |
| 158809 | + /* 270 */ 51, 52, 53, 54, 55, 56, 57, 19, 46, 47, |
| 158810 | + /* 280 */ 48, 49, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158811 | + /* 290 */ 110, 111, 112, 213, 73, 184, 185, 186, 187, 188, |
| 158812 | + /* 300 */ 189, 221, 81, 236, 46, 194, 192, 196, 19, 59, |
| 158813 | + /* 310 */ 133, 59, 135, 136, 203, 192, 115, 116, 117, 127, |
| 158237 | 158814 | /* 320 */ 128, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 158238 | 158815 | /* 330 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, |
| 158239 | | - /* 340 */ 51, 52, 53, 54, 55, 56, 57, 236, 237, 191, |
| 158240 | | - /* 350 */ 150, 281, 191, 185, 186, 187, 188, 115, 116, 117, |
| 158241 | | - /* 360 */ 249, 193, 191, 195, 26, 73, 59, 191, 114, 116, |
| 158242 | | - /* 370 */ 202, 213, 214, 81, 263, 106, 107, 108, 109, 110, |
| 158243 | | - /* 380 */ 111, 112, 148, 160, 142, 95, 228, 191, 191, 213, |
| 158244 | | - /* 390 */ 214, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 158245 | | - /* 400 */ 111, 112, 112, 149, 236, 237, 295, 100, 118, 119, |
| 158246 | | - /* 410 */ 120, 121, 122, 123, 124, 19, 31, 249, 126, 23, |
| 158247 | | - /* 420 */ 130, 260, 115, 116, 39, 22, 250, 120, 191, 137, |
| 158248 | | - /* 430 */ 138, 263, 305, 306, 238, 259, 265, 310, 149, 43, |
| 158816 | + /* 340 */ 51, 52, 53, 54, 55, 56, 57, 126, 237, 238, |
| 158817 | + /* 350 */ 100, 150, 120, 230, 186, 187, 188, 189, 137, 138, |
| 158818 | + /* 360 */ 108, 250, 194, 26, 196, 115, 116, 115, 116, 117, |
| 158819 | + /* 370 */ 120, 203, 114, 164, 165, 264, 102, 103, 104, 105, |
| 158820 | + /* 380 */ 106, 107, 108, 109, 110, 111, 112, 192, 130, 111, |
| 158821 | + /* 390 */ 112, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 158822 | + /* 400 */ 111, 112, 152, 153, 154, 237, 238, 296, 192, 214, |
| 158823 | + /* 410 */ 215, 228, 192, 307, 192, 19, 59, 311, 250, 23, |
| 158824 | + /* 420 */ 22, 106, 107, 108, 109, 110, 111, 112, 192, 72, |
| 158825 | + /* 430 */ 214, 215, 264, 192, 214, 215, 214, 215, 149, 43, |
| 158249 | 158826 | /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 158250 | | - /* 450 */ 54, 55, 56, 57, 191, 117, 191, 210, 19, 152, |
| 158251 | | - /* 460 */ 153, 154, 23, 295, 102, 103, 104, 105, 106, 107, |
| 158252 | | - /* 470 */ 108, 109, 110, 111, 112, 266, 213, 214, 213, 214, |
| 158253 | | - /* 480 */ 142, 81, 43, 44, 45, 46, 47, 48, 49, 50, |
| 158254 | | - /* 490 */ 51, 52, 53, 54, 55, 56, 57, 301, 102, 103, |
| 158255 | | - /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 106, |
| 158256 | | - /* 510 */ 107, 118, 59, 250, 121, 122, 123, 280, 76, 119, |
| 158257 | | - /* 520 */ 236, 237, 259, 306, 131, 72, 59, 310, 19, 87, |
| 158258 | | - /* 530 */ 283, 89, 23, 249, 92, 288, 22, 137, 138, 22, |
| 158259 | | - /* 540 */ 275, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 158827 | + /* 450 */ 54, 55, 56, 57, 117, 214, 215, 59, 19, 187, |
| 158828 | + /* 460 */ 192, 189, 23, 81, 296, 192, 194, 251, 196, 59, |
| 158829 | + /* 470 */ 229, 251, 115, 116, 117, 203, 260, 106, 107, 142, |
| 158830 | + /* 480 */ 260, 267, 43, 44, 45, 46, 47, 48, 49, 50, |
| 158831 | + /* 490 */ 51, 52, 53, 54, 55, 56, 57, 261, 102, 103, |
| 158832 | + /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 237, |
| 158833 | + /* 510 */ 238, 76, 192, 115, 116, 117, 144, 192, 76, 137, |
| 158834 | + /* 520 */ 138, 192, 250, 152, 89, 154, 116, 92, 19, 87, |
| 158835 | + /* 530 */ 262, 89, 23, 22, 92, 163, 264, 192, 22, 214, |
| 158836 | + /* 540 */ 215, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 158260 | 158837 | /* 550 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, |
| 158261 | | - /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 115, 116, |
| 158262 | | - /* 570 */ 117, 23, 186, 59, 188, 108, 59, 241, 191, 193, |
| 158263 | | - /* 580 */ 26, 195, 115, 116, 117, 191, 144, 251, 202, 22, |
| 158838 | + /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 296, 118, |
| 158839 | + /* 570 */ 59, 23, 121, 122, 123, 59, 251, 26, 46, 306, |
| 158840 | + /* 580 */ 307, 261, 131, 192, 311, 192, 144, 192, 22, 203, |
| 158264 | 158841 | /* 590 */ 100, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 158265 | | - /* 600 */ 52, 53, 54, 55, 56, 57, 116, 213, 214, 191, |
| 158842 | + /* 600 */ 52, 53, 54, 55, 56, 57, 116, 214, 215, 271, |
| 158266 | 158843 | /* 610 */ 120, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 158267 | | - /* 620 */ 111, 112, 236, 237, 306, 238, 59, 26, 310, 115, |
| 158268 | | - /* 630 */ 116, 117, 115, 116, 117, 249, 246, 19, 248, 106, |
| 158269 | | - /* 640 */ 107, 23, 152, 153, 154, 46, 47, 48, 49, 263, |
| 158844 | + /* 620 */ 111, 112, 229, 237, 238, 59, 115, 116, 117, 299, |
| 158845 | + /* 630 */ 300, 115, 116, 117, 59, 16, 250, 19, 192, 192, |
| 158846 | + /* 640 */ 19, 23, 152, 153, 154, 24, 114, 309, 310, 192, |
| 158270 | 158847 | /* 650 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 158271 | 158848 | /* 660 */ 112, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 158272 | | - /* 670 */ 52, 53, 54, 55, 56, 57, 19, 76, 298, 299, |
| 158273 | | - /* 680 */ 23, 295, 115, 116, 117, 152, 191, 154, 301, 73, |
| 158274 | | - /* 690 */ 89, 137, 138, 92, 22, 191, 144, 22, 191, 191, |
| 158849 | + /* 670 */ 52, 53, 54, 55, 56, 57, 19, 7, 8, 9, |
| 158850 | + /* 680 */ 23, 115, 116, 117, 203, 290, 239, 238, 137, 138, |
| 158851 | + /* 690 */ 115, 116, 117, 236, 192, 22, 77, 81, 79, 250, |
| 158275 | 158852 | /* 700 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 158276 | | - /* 710 */ 53, 54, 55, 56, 57, 163, 191, 213, 214, 120, |
| 158853 | + /* 710 */ 53, 54, 55, 56, 57, 192, 95, 142, 237, 238, |
| 158277 | 158854 | /* 720 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 158278 | | - /* 730 */ 112, 59, 228, 191, 59, 191, 236, 237, 213, 214, |
| 158279 | | - /* 740 */ 11, 59, 126, 127, 128, 238, 19, 26, 191, 249, |
| 158280 | | - /* 750 */ 23, 164, 165, 228, 191, 213, 214, 213, 214, 102, |
| 158855 | + /* 730 */ 112, 250, 59, 112, 192, 119, 26, 214, 215, 118, |
| 158856 | + /* 740 */ 119, 120, 121, 122, 123, 124, 19, 192, 267, 302, |
| 158857 | + /* 750 */ 23, 130, 229, 137, 138, 23, 214, 215, 26, 102, |
| 158281 | 158858 | /* 760 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 158282 | 158859 | /* 770 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 158283 | | - /* 780 */ 53, 54, 55, 56, 57, 19, 241, 115, 116, 117, |
| 158284 | | - /* 790 */ 115, 116, 117, 191, 250, 238, 251, 115, 116, 117, |
| 158285 | | - /* 800 */ 157, 23, 159, 191, 26, 191, 111, 112, 301, 43, |
| 158860 | + /* 780 */ 53, 54, 55, 56, 57, 19, 76, 11, 115, 116, |
| 158861 | + /* 790 */ 117, 192, 29, 251, 239, 73, 33, 192, 192, 89, |
| 158862 | + /* 800 */ 192, 192, 92, 192, 192, 126, 127, 128, 224, 43, |
| 158286 | 158863 | /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 158287 | | - /* 820 */ 54, 55, 56, 57, 142, 213, 214, 213, 214, 102, |
| 158864 | + /* 820 */ 54, 55, 56, 57, 192, 35, 214, 215, 65, 102, |
| 158288 | 158865 | /* 830 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 158289 | | - /* 840 */ 228, 191, 228, 191, 191, 207, 208, 209, 126, 127, |
| 158290 | | - /* 850 */ 128, 133, 289, 135, 136, 19, 127, 128, 301, 7, |
| 158291 | | - /* 860 */ 8, 9, 141, 213, 214, 213, 214, 265, 102, 103, |
| 158866 | + /* 840 */ 59, 229, 192, 192, 239, 239, 214, 215, 126, 127, |
| 158867 | + /* 850 */ 128, 126, 127, 128, 307, 19, 66, 302, 311, 192, |
| 158868 | + /* 860 */ 261, 229, 224, 22, 74, 214, 215, 192, 102, 103, |
| 158292 | 158869 | /* 870 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 43, |
| 158293 | 158870 | /* 880 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 158294 | | - /* 890 */ 54, 55, 56, 57, 191, 117, 191, 22, 23, 19, |
| 158295 | | - /* 900 */ 250, 26, 250, 191, 223, 191, 126, 127, 128, 205, |
| 158296 | | - /* 910 */ 206, 205, 206, 260, 21, 202, 213, 214, 213, 214, |
| 158297 | | - /* 920 */ 142, 270, 208, 209, 158, 45, 46, 47, 48, 49, |
| 158871 | + /* 890 */ 54, 55, 56, 57, 192, 192, 115, 116, 117, 19, |
| 158872 | + /* 900 */ 59, 290, 251, 127, 128, 192, 23, 302, 302, 26, |
| 158873 | + /* 910 */ 302, 236, 192, 22, 21, 24, 214, 215, 192, 129, |
| 158874 | + /* 920 */ 22, 192, 24, 142, 158, 45, 46, 47, 48, 49, |
| 158298 | 158875 | /* 930 */ 50, 51, 52, 53, 54, 55, 56, 57, 102, 103, |
| 158299 | | - /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 236, |
| 158300 | | - /* 950 */ 237, 12, 191, 250, 76, 250, 191, 22, 23, 308, |
| 158301 | | - /* 960 */ 309, 26, 249, 202, 191, 191, 27, 89, 191, 202, |
| 158302 | | - /* 970 */ 92, 202, 260, 80, 213, 214, 101, 203, 213, 214, |
| 158303 | | - /* 980 */ 22, 42, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158304 | | - /* 990 */ 110, 111, 112, 228, 158, 281, 108, 236, 237, 225, |
| 158305 | | - /* 1000 */ 191, 227, 63, 236, 237, 236, 237, 191, 235, 191, |
| 158306 | | - /* 1010 */ 249, 250, 73, 241, 19, 122, 249, 59, 249, 24, |
| 158307 | | - /* 1020 */ 259, 29, 134, 251, 191, 33, 22, 139, 24, 213, |
| 158308 | | - /* 1030 */ 214, 213, 214, 191, 19, 210, 101, 191, 43, 44, |
| 158876 | + /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 192, |
| 158877 | + /* 950 */ 59, 12, 192, 251, 192, 305, 192, 116, 22, 23, |
| 158878 | + /* 960 */ 242, 203, 26, 203, 24, 236, 27, 237, 238, 266, |
| 158879 | + /* 970 */ 252, 214, 215, 80, 214, 215, 214, 215, 214, 215, |
| 158880 | + /* 980 */ 250, 42, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158881 | + /* 990 */ 110, 111, 112, 229, 158, 237, 238, 237, 238, 59, |
| 158882 | + /* 1000 */ 117, 281, 63, 192, 192, 192, 192, 116, 250, 192, |
| 158883 | + /* 1010 */ 250, 251, 73, 251, 19, 122, 290, 237, 238, 24, |
| 158884 | + /* 1020 */ 260, 209, 210, 209, 210, 142, 242, 214, 215, 197, |
| 158885 | + /* 1030 */ 250, 22, 23, 276, 19, 26, 252, 101, 43, 44, |
| 158309 | 158886 | /* 1040 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 158310 | | - /* 1050 */ 55, 56, 57, 160, 19, 213, 214, 65, 43, 44, |
| 158887 | + /* 1050 */ 55, 56, 57, 160, 19, 211, 116, 192, 43, 44, |
| 158311 | 158888 | /* 1060 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 158312 | | - /* 1070 */ 55, 56, 57, 191, 116, 22, 191, 24, 43, 44, |
| 158889 | + /* 1070 */ 55, 56, 57, 192, 192, 22, 192, 266, 43, 44, |
| 158313 | 158890 | /* 1080 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 158314 | | - /* 1090 */ 55, 56, 57, 191, 261, 213, 214, 102, 103, 104, |
| 158315 | | - /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 19, |
| 158316 | | - /* 1110 */ 191, 265, 59, 288, 191, 213, 214, 102, 103, 104, |
| 158317 | | - /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 35, 191, |
| 158318 | | - /* 1130 */ 66, 191, 213, 214, 191, 270, 46, 102, 103, 104, |
| 158319 | | - /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 191, 85, |
| 158320 | | - /* 1150 */ 265, 213, 214, 213, 214, 106, 107, 19, 94, 66, |
| 158321 | | - /* 1160 */ 137, 138, 191, 114, 115, 116, 117, 74, 119, 116, |
| 158322 | | - /* 1170 */ 213, 214, 202, 308, 309, 306, 127, 191, 235, 310, |
| 158323 | | - /* 1180 */ 59, 191, 44, 45, 46, 47, 48, 49, 50, 51, |
| 158324 | | - /* 1190 */ 52, 53, 54, 55, 56, 57, 191, 76, 196, 213, |
| 158325 | | - /* 1200 */ 214, 152, 12, 154, 114, 191, 236, 237, 87, 145, |
| 158326 | | - /* 1210 */ 89, 19, 20, 92, 22, 22, 23, 27, 191, 249, |
| 158327 | | - /* 1220 */ 130, 202, 129, 202, 191, 235, 306, 152, 36, 154, |
| 158328 | | - /* 1230 */ 310, 191, 42, 191, 191, 191, 115, 116, 117, 191, |
| 158891 | + /* 1090 */ 55, 56, 57, 192, 282, 192, 282, 102, 103, 104, |
| 158892 | + /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 192, |
| 158893 | + /* 1110 */ 101, 279, 192, 192, 230, 283, 192, 102, 103, 104, |
| 158894 | + /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 204, 211, |
| 158895 | + /* 1130 */ 66, 214, 215, 289, 214, 215, 108, 102, 103, 104, |
| 158896 | + /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 266, 85, |
| 158897 | + /* 1150 */ 226, 192, 228, 22, 23, 106, 107, 19, 94, 106, |
| 158898 | + /* 1160 */ 107, 192, 134, 114, 115, 116, 117, 139, 119, 266, |
| 158899 | + /* 1170 */ 203, 206, 207, 214, 215, 192, 127, 192, 206, 207, |
| 158900 | + /* 1180 */ 59, 192, 44, 45, 46, 47, 48, 49, 50, 51, |
| 158901 | + /* 1190 */ 52, 53, 54, 55, 56, 57, 192, 76, 192, 214, |
| 158902 | + /* 1200 */ 215, 152, 284, 154, 237, 238, 192, 289, 87, 145, |
| 158903 | + /* 1210 */ 89, 19, 20, 92, 22, 22, 23, 250, 307, 236, |
| 158904 | + /* 1220 */ 214, 215, 311, 203, 12, 247, 192, 249, 36, 307, |
| 158905 | + /* 1230 */ 192, 262, 101, 311, 137, 138, 115, 116, 117, 27, |
| 158329 | 158906 | /* 1240 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 158330 | | - /* 1250 */ 112, 59, 99, 63, 191, 236, 237, 236, 237, 191, |
| 158331 | | - /* 1260 */ 289, 213, 214, 71, 191, 144, 261, 191, 249, 191, |
| 158332 | | - /* 1270 */ 249, 19, 20, 81, 22, 235, 213, 214, 235, 191, |
| 158333 | | - /* 1280 */ 278, 213, 214, 191, 282, 132, 213, 214, 36, 213, |
| 158334 | | - /* 1290 */ 214, 191, 100, 191, 101, 191, 191, 191, 106, 107, |
| 158335 | | - /* 1300 */ 48, 213, 214, 261, 191, 113, 191, 115, 116, 117, |
| 158336 | | - /* 1310 */ 191, 59, 120, 213, 214, 213, 214, 213, 214, 213, |
| 158337 | | - /* 1320 */ 214, 22, 23, 71, 237, 59, 213, 214, 191, 137, |
| 158338 | | - /* 1330 */ 138, 191, 213, 214, 191, 191, 249, 85, 191, 261, |
| 158339 | | - /* 1340 */ 191, 26, 90, 15, 152, 153, 154, 155, 156, 19, |
| 158340 | | - /* 1350 */ 213, 214, 100, 213, 214, 191, 213, 214, 106, 107, |
| 158341 | | - /* 1360 */ 213, 214, 213, 214, 191, 113, 261, 115, 116, 117, |
| 158342 | | - /* 1370 */ 253, 254, 120, 229, 191, 191, 191, 213, 214, 191, |
| 158343 | | - /* 1380 */ 306, 289, 116, 26, 310, 191, 213, 214, 60, 19, |
| 158344 | | - /* 1390 */ 296, 297, 24, 191, 46, 191, 213, 214, 213, 214, |
| 158345 | | - /* 1400 */ 101, 213, 214, 191, 152, 153, 154, 155, 156, 0, |
| 158346 | | - /* 1410 */ 1, 2, 191, 229, 5, 213, 214, 213, 214, 10, |
| 158347 | | - /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 191, 5, 19, |
| 158348 | | - /* 1430 */ 20, 191, 22, 10, 11, 12, 13, 14, 191, 30, |
| 158349 | | - /* 1440 */ 17, 32, 241, 148, 149, 115, 36, 191, 241, 40, |
| 158350 | | - /* 1450 */ 191, 26, 251, 30, 191, 32, 141, 22, 251, 5, |
| 158351 | | - /* 1460 */ 213, 214, 114, 40, 10, 11, 12, 13, 14, 59, |
| 158352 | | - /* 1470 */ 134, 17, 213, 214, 191, 139, 213, 214, 191, 70, |
| 158353 | | - /* 1480 */ 191, 71, 125, 191, 30, 115, 32, 78, 53, 191, |
| 158354 | | - /* 1490 */ 81, 191, 191, 70, 40, 85, 213, 214, 191, 22, |
| 158355 | | - /* 1500 */ 90, 78, 213, 214, 81, 213, 214, 98, 140, 120, |
| 158356 | | - /* 1510 */ 100, 213, 214, 213, 214, 23, 106, 107, 26, 130, |
| 158357 | | - /* 1520 */ 191, 98, 191, 113, 70, 115, 116, 117, 23, 22, |
| 158358 | | - /* 1530 */ 120, 26, 78, 19, 191, 81, 19, 20, 61, 22, |
| 158359 | | - /* 1540 */ 191, 132, 213, 214, 213, 214, 137, 138, 59, 191, |
| 158360 | | - /* 1550 */ 191, 191, 98, 36, 128, 132, 213, 214, 128, 59, |
| 158361 | | - /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 83, 84, 144, |
| 158362 | | - /* 1570 */ 161, 213, 214, 213, 214, 23, 59, 151, 26, 23, |
| 158363 | | - /* 1580 */ 23, 151, 26, 26, 161, 59, 132, 23, 71, 191, |
| 158364 | | - /* 1590 */ 26, 137, 138, 119, 120, 23, 19, 20, 26, 22, |
| 158365 | | - /* 1600 */ 223, 23, 85, 23, 26, 116, 26, 90, 191, 7, |
| 158366 | | - /* 1610 */ 8, 97, 152, 36, 154, 161, 116, 100, 23, 23, |
| 158367 | | - /* 1620 */ 191, 26, 26, 106, 107, 191, 23, 223, 23, 26, |
| 158368 | | - /* 1630 */ 113, 26, 115, 116, 117, 23, 59, 120, 26, 191, |
| 158369 | | - /* 1640 */ 191, 191, 116, 255, 191, 252, 191, 140, 71, 191, |
| 158370 | | - /* 1650 */ 315, 233, 191, 191, 191, 191, 191, 191, 191, 191, |
| 158371 | | - /* 1660 */ 191, 285, 284, 239, 252, 252, 252, 252, 240, 152, |
| 158372 | | - /* 1670 */ 153, 154, 155, 156, 189, 294, 268, 100, 242, 268, |
| 158373 | | - /* 1680 */ 264, 211, 290, 106, 107, 108, 264, 256, 256, 243, |
| 158374 | | - /* 1690 */ 113, 290, 115, 116, 117, 268, 217, 120, 226, 243, |
| 158375 | | - /* 1700 */ 222, 268, 216, 19, 20, 246, 22, 216, 256, 216, |
| 158376 | | - /* 1710 */ 194, 60, 38, 242, 277, 294, 240, 242, 198, 246, |
| 158377 | | - /* 1720 */ 36, 140, 198, 198, 19, 20, 150, 22, 149, 152, |
| 158378 | | - /* 1730 */ 153, 154, 155, 156, 294, 291, 291, 280, 22, 43, |
| 158379 | | - /* 1740 */ 231, 36, 18, 59, 234, 234, 234, 234, 267, 269, |
| 158380 | | - /* 1750 */ 18, 198, 197, 231, 148, 71, 269, 269, 243, 231, |
| 158381 | | - /* 1760 */ 198, 243, 267, 197, 59, 157, 243, 198, 62, 287, |
| 158382 | | - /* 1770 */ 243, 197, 22, 198, 114, 64, 71, 218, 218, 197, |
| 158383 | | - /* 1780 */ 286, 198, 197, 215, 100, 215, 215, 224, 22, 125, |
| 158384 | | - /* 1790 */ 106, 107, 164, 24, 221, 112, 143, 113, 302, 115, |
| 158385 | | - /* 1800 */ 116, 117, 218, 215, 120, 100, 217, 221, 215, 215, |
| 158386 | | - /* 1810 */ 309, 106, 107, 215, 224, 279, 279, 218, 113, 258, |
| 158387 | | - /* 1820 */ 115, 116, 117, 114, 257, 120, 91, 198, 82, 147, |
| 158388 | | - /* 1830 */ 144, 22, 274, 314, 198, 314, 152, 153, 154, 155, |
| 158389 | | - /* 1840 */ 156, 276, 157, 146, 145, 258, 25, 247, 257, 201, |
| 158390 | | - /* 1850 */ 258, 26, 200, 13, 257, 244, 246, 152, 153, 154, |
| 158391 | | - /* 1860 */ 155, 156, 258, 262, 257, 247, 245, 243, 192, 192, |
| 158392 | | - /* 1870 */ 6, 262, 204, 210, 219, 210, 210, 190, 190, 190, |
| 158393 | | - /* 1880 */ 210, 219, 204, 211, 211, 210, 4, 3, 22, 162, |
| 158394 | | - /* 1890 */ 15, 23, 16, 23, 204, 138, 129, 150, 26, 141, |
| 158395 | | - /* 1900 */ 20, 24, 143, 16, 1, 141, 129, 129, 61, 53, |
| 158396 | | - /* 1910 */ 37, 150, 297, 300, 300, 53, 53, 129, 53, 115, |
| 158397 | | - /* 1920 */ 34, 140, 1, 5, 22, 114, 68, 26, 160, 68, |
| 158398 | | - /* 1930 */ 75, 41, 140, 114, 24, 20, 19, 130, 124, 23, |
| 158399 | | - /* 1940 */ 96, 22, 22, 37, 22, 67, 22, 59, 67, 24, |
| 158400 | | - /* 1950 */ 22, 28, 67, 23, 148, 22, 97, 23, 23, 23, |
| 158401 | | - /* 1960 */ 140, 23, 22, 26, 23, 23, 115, 22, 142, 26, |
| 158402 | | - /* 1970 */ 75, 88, 75, 34, 23, 86, 44, 22, 34, 26, |
| 158403 | | - /* 1980 */ 34, 34, 34, 34, 93, 24, 26, 23, 34, 23, |
| 158404 | | - /* 1990 */ 23, 23, 23, 11, 23, 22, 26, 22, 22, 15, |
| 158405 | | - /* 2000 */ 23, 23, 22, 22, 1, 26, 23, 140, 134, 140, |
| 158406 | | - /* 2010 */ 1, 140, 316, 316, 316, 316, 316, 316, 316, 140, |
| 158407 | | - /* 2020 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158408 | | - /* 2030 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158409 | | - /* 2040 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158410 | | - /* 2050 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158411 | | - /* 2060 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158412 | | - /* 2070 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158413 | | - /* 2080 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158414 | | - /* 2090 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158415 | | - /* 2100 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158416 | | - /* 2110 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158417 | | - /* 2120 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158418 | | - /* 2130 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158419 | | - /* 2140 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158420 | | - /* 2150 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158421 | | - /* 2160 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158422 | | - /* 2170 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158423 | | - /* 2180 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158424 | | - /* 2190 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 158425 | | - /* 2200 */ 316, 316, 316, |
| 158907 | + /* 1250 */ 112, 59, 214, 215, 42, 203, 307, 237, 238, 192, |
| 158908 | + /* 1260 */ 311, 192, 26, 71, 192, 144, 262, 297, 298, 203, |
| 158909 | + /* 1270 */ 250, 19, 20, 81, 22, 63, 262, 254, 255, 15, |
| 158910 | + /* 1280 */ 26, 214, 215, 214, 215, 26, 214, 215, 36, 237, |
| 158911 | + /* 1290 */ 238, 192, 100, 114, 101, 192, 262, 192, 106, 107, |
| 158912 | + /* 1300 */ 48, 134, 250, 237, 238, 113, 139, 115, 116, 117, |
| 158913 | + /* 1310 */ 192, 59, 120, 214, 215, 242, 250, 214, 215, 214, |
| 158914 | + /* 1320 */ 215, 148, 149, 71, 60, 252, 242, 192, 149, 137, |
| 158915 | + /* 1330 */ 138, 192, 214, 215, 192, 19, 252, 85, 192, 59, |
| 158916 | + /* 1340 */ 192, 157, 90, 159, 152, 153, 154, 155, 156, 214, |
| 158917 | + /* 1350 */ 215, 192, 100, 214, 215, 19, 214, 215, 106, 107, |
| 158918 | + /* 1360 */ 214, 215, 214, 215, 22, 113, 192, 115, 116, 117, |
| 158919 | + /* 1370 */ 192, 242, 120, 214, 215, 192, 24, 192, 31, 192, |
| 158920 | + /* 1380 */ 144, 252, 26, 192, 125, 99, 39, 192, 214, 215, |
| 158921 | + /* 1390 */ 192, 59, 214, 215, 192, 141, 116, 214, 215, 214, |
| 158922 | + /* 1400 */ 215, 214, 215, 61, 152, 153, 154, 155, 156, 0, |
| 158923 | + /* 1410 */ 1, 2, 214, 215, 5, 192, 214, 215, 132, 10, |
| 158924 | + /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 192, 5, 19, |
| 158925 | + /* 1430 */ 20, 115, 22, 10, 11, 12, 13, 14, 192, 30, |
| 158926 | + /* 1440 */ 17, 32, 23, 192, 23, 26, 36, 26, 116, 40, |
| 158927 | + /* 1450 */ 192, 115, 192, 30, 192, 32, 119, 120, 59, 5, |
| 158928 | + /* 1460 */ 214, 215, 128, 40, 10, 11, 12, 13, 14, 59, |
| 158929 | + /* 1470 */ 19, 17, 214, 215, 214, 215, 214, 215, 120, 70, |
| 158930 | + /* 1480 */ 192, 71, 22, 192, 30, 151, 32, 78, 130, 128, |
| 158931 | + /* 1490 */ 81, 192, 140, 70, 40, 85, 192, 141, 7, 8, |
| 158932 | + /* 1500 */ 90, 78, 214, 215, 81, 214, 215, 98, 83, 84, |
| 158933 | + /* 1510 */ 100, 192, 151, 214, 215, 116, 106, 107, 214, 215, |
| 158934 | + /* 1520 */ 192, 98, 192, 113, 70, 115, 116, 117, 23, 224, |
| 158935 | + /* 1530 */ 120, 26, 78, 214, 215, 81, 19, 20, 152, 22, |
| 158936 | + /* 1540 */ 154, 132, 214, 215, 214, 215, 137, 138, 97, 192, |
| 158937 | + /* 1550 */ 256, 192, 98, 36, 23, 132, 192, 26, 192, 192, |
| 158938 | + /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 192, 192, 192, |
| 158939 | + /* 1570 */ 161, 214, 215, 214, 215, 192, 59, 192, 214, 215, |
| 158940 | + /* 1580 */ 214, 215, 192, 152, 161, 154, 132, 192, 71, 214, |
| 158941 | + /* 1590 */ 215, 137, 138, 192, 192, 192, 19, 20, 192, 22, |
| 158942 | + /* 1600 */ 140, 253, 85, 192, 214, 215, 192, 90, 23, 214, |
| 158943 | + /* 1610 */ 215, 26, 192, 36, 192, 161, 23, 100, 192, 26, |
| 158944 | + /* 1620 */ 214, 215, 192, 106, 107, 214, 215, 192, 23, 192, |
| 158945 | + /* 1630 */ 113, 26, 115, 116, 117, 23, 59, 120, 26, 23, |
| 158946 | + /* 1640 */ 23, 23, 26, 26, 26, 316, 234, 23, 71, 23, |
| 158947 | + /* 1650 */ 26, 192, 26, 192, 192, 192, 192, 192, 192, 192, |
| 158948 | + /* 1660 */ 192, 253, 212, 190, 286, 285, 253, 240, 253, 152, |
| 158949 | + /* 1670 */ 153, 154, 155, 156, 241, 243, 295, 100, 291, 291, |
| 158950 | + /* 1680 */ 223, 253, 227, 106, 107, 108, 269, 244, 244, 265, |
| 158951 | + /* 1690 */ 113, 257, 115, 116, 117, 257, 243, 120, 269, 218, |
| 158952 | + /* 1700 */ 217, 265, 217, 19, 20, 217, 22, 195, 269, 269, |
| 158953 | + /* 1710 */ 60, 295, 140, 257, 243, 241, 247, 247, 199, 278, |
| 158954 | + /* 1720 */ 36, 199, 199, 38, 19, 20, 150, 22, 149, 152, |
| 158955 | + /* 1730 */ 153, 154, 155, 156, 22, 43, 232, 295, 292, 292, |
| 158956 | + /* 1740 */ 18, 36, 235, 59, 268, 270, 235, 199, 235, 235, |
| 158957 | + /* 1750 */ 18, 198, 148, 281, 244, 71, 270, 270, 268, 244, |
| 158958 | + /* 1760 */ 232, 232, 244, 199, 59, 244, 198, 157, 288, 62, |
| 158959 | + /* 1770 */ 199, 287, 198, 22, 219, 219, 71, 199, 198, 114, |
| 158960 | + /* 1780 */ 199, 198, 216, 216, 100, 216, 225, 64, 22, 125, |
| 158961 | + /* 1790 */ 106, 107, 222, 164, 219, 222, 24, 113, 216, 115, |
| 158962 | + /* 1800 */ 116, 117, 218, 216, 120, 100, 216, 216, 310, 303, |
| 158963 | + /* 1810 */ 112, 106, 107, 225, 280, 280, 219, 143, 113, 259, |
| 158964 | + /* 1820 */ 115, 116, 117, 114, 259, 120, 199, 91, 82, 147, |
| 158965 | + /* 1830 */ 144, 315, 22, 275, 199, 315, 152, 153, 154, 155, |
| 158966 | + /* 1840 */ 156, 146, 145, 247, 258, 157, 25, 258, 245, 248, |
| 158967 | + /* 1850 */ 244, 259, 258, 202, 259, 248, 258, 152, 153, 154, |
| 158968 | + /* 1860 */ 155, 156, 263, 263, 26, 246, 13, 201, 193, 193, |
| 158969 | + /* 1870 */ 6, 191, 191, 205, 191, 220, 220, 205, 211, 277, |
| 158970 | + /* 1880 */ 211, 211, 211, 205, 4, 212, 3, 22, 162, 212, |
| 158971 | + /* 1890 */ 211, 15, 23, 16, 23, 138, 129, 150, 26, 24, |
| 158972 | + /* 1900 */ 141, 20, 16, 143, 1, 141, 129, 129, 61, 301, |
| 158973 | + /* 1910 */ 301, 298, 150, 53, 53, 37, 53, 129, 115, 53, |
| 158974 | + /* 1920 */ 140, 34, 1, 5, 22, 114, 68, 26, 160, 75, |
| 158975 | + /* 1930 */ 68, 41, 140, 114, 24, 20, 19, 130, 124, 23, |
| 158976 | + /* 1940 */ 67, 22, 22, 59, 22, 22, 67, 96, 24, 22, |
| 158977 | + /* 1950 */ 37, 23, 67, 28, 148, 22, 26, 23, 23, 23, |
| 158978 | + /* 1960 */ 23, 22, 140, 23, 97, 23, 34, 115, 22, 142, |
| 158979 | + /* 1970 */ 26, 75, 34, 44, 75, 34, 88, 34, 86, 34, |
| 158980 | + /* 1980 */ 23, 34, 93, 22, 24, 26, 34, 23, 26, 23, |
| 158981 | + /* 1990 */ 23, 23, 23, 11, 23, 22, 26, 22, 22, 140, |
| 158982 | + /* 2000 */ 23, 23, 22, 22, 134, 26, 23, 15, 140, 1, |
| 158983 | + /* 2010 */ 1, 317, 317, 317, 140, 317, 317, 317, 317, 317, |
| 158984 | + /* 2020 */ 317, 317, 140, 317, 317, 317, 317, 317, 317, 317, |
| 158985 | + /* 2030 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158986 | + /* 2040 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158987 | + /* 2050 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158988 | + /* 2060 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158989 | + /* 2070 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158990 | + /* 2080 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158991 | + /* 2090 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158992 | + /* 2100 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158993 | + /* 2110 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158994 | + /* 2120 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158995 | + /* 2130 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158996 | + /* 2140 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158997 | + /* 2150 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158998 | + /* 2160 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 158999 | + /* 2170 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 159000 | + /* 2180 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 159001 | + /* 2190 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, |
| 159002 | + /* 2200 */ 317, 317, 317, 317, 317, 317, 317, |
| 158426 | 159003 | }; |
| 158427 | 159004 | #define YY_SHIFT_COUNT (569) |
| 158428 | 159005 | #define YY_SHIFT_MIN (0) |
| 158429 | 159006 | #define YY_SHIFT_MAX (2009) |
| 158430 | 159007 | static const unsigned short int yy_shift_ofst[] = { |
| 158431 | | - /* 0 */ 1423, 1409, 1454, 1192, 1192, 36, 1252, 1410, 1517, 1684, |
| 158432 | | - /* 10 */ 1684, 1684, 292, 0, 0, 180, 1015, 1684, 1684, 1684, |
| 159008 | + /* 0 */ 1423, 1409, 1454, 1192, 1192, 382, 1252, 1410, 1517, 1684, |
| 159009 | + /* 10 */ 1684, 1684, 221, 0, 0, 180, 1015, 1684, 1684, 1684, |
| 158433 | 159010 | /* 20 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 158434 | | - /* 30 */ 1049, 1049, 1121, 1121, 54, 400, 36, 36, 36, 36, |
| 158435 | | - /* 40 */ 36, 40, 110, 219, 289, 396, 439, 509, 548, 618, |
| 159011 | + /* 30 */ 1049, 1049, 1121, 1121, 54, 616, 382, 382, 382, 382, |
| 159012 | + /* 40 */ 382, 40, 110, 219, 289, 396, 439, 509, 548, 618, |
| 158436 | 159013 | /* 50 */ 657, 727, 766, 836, 995, 1015, 1015, 1015, 1015, 1015, |
| 158437 | 159014 | /* 60 */ 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, |
| 158438 | 159015 | /* 70 */ 1015, 1015, 1015, 1035, 1015, 1138, 880, 880, 1577, 1684, |
| 158439 | 159016 | /* 80 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 158440 | 159017 | /* 90 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 158441 | 159018 | /* 100 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 158442 | 159019 | /* 110 */ 1684, 1684, 1684, 1705, 1684, 1684, 1684, 1684, 1684, 1684, |
| 158443 | 159020 | /* 120 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 146, 84, 84, |
| 158444 | | - /* 130 */ 84, 84, 84, 362, 269, 125, 97, 453, 66, 66, |
| 158445 | | - /* 140 */ 893, 1090, 66, 66, 533, 533, 66, 554, 554, 554, |
| 158446 | | - /* 150 */ 554, 192, 587, 587, 695, 25, 2020, 2020, 290, 290, |
| 158447 | | - /* 160 */ 290, 200, 514, 514, 514, 514, 939, 939, 442, 875, |
| 158448 | | - /* 170 */ 935, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 159021 | + /* 130 */ 84, 84, 84, 274, 315, 125, 97, 357, 66, 66, |
| 159022 | + /* 140 */ 893, 258, 66, 66, 371, 371, 66, 551, 551, 551, |
| 159023 | + /* 150 */ 551, 192, 209, 209, 278, 127, 2023, 2023, 621, 621, |
| 159024 | + /* 160 */ 621, 201, 398, 398, 398, 398, 939, 939, 442, 936, |
| 159025 | + /* 170 */ 1009, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 158449 | 159026 | /* 180 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 158450 | | - /* 190 */ 66, 601, 601, 66, 729, 878, 878, 1266, 1266, 552, |
| 158451 | | - /* 200 */ 1023, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 307, 490, |
| 158452 | | - /* 210 */ 490, 567, 393, 517, 467, 672, 242, 682, 675, 66, |
| 158453 | | - /* 220 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 616, |
| 159027 | + /* 190 */ 66, 710, 710, 66, 776, 435, 435, 410, 410, 372, |
| 159028 | + /* 200 */ 1097, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 250, 490, |
| 159029 | + /* 210 */ 490, 511, 451, 516, 252, 566, 575, 781, 673, 66, |
| 159030 | + /* 220 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 722, |
| 158454 | 159031 | /* 230 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 158455 | | - /* 240 */ 66, 66, 1093, 1093, 1093, 66, 66, 66, 778, 66, |
| 158456 | | - /* 250 */ 66, 66, 1053, 1064, 66, 66, 1190, 66, 66, 66, |
| 158457 | | - /* 260 */ 66, 66, 66, 66, 66, 722, 992, 718, 253, 253, |
| 158458 | | - /* 270 */ 253, 253, 338, 718, 718, 888, 403, 852, 1328, 254, |
| 158459 | | - /* 280 */ 1295, 721, 1330, 1295, 1330, 1370, 234, 254, 254, 234, |
| 158460 | | - /* 290 */ 254, 721, 1370, 1357, 1492, 1348, 385, 385, 385, 1330, |
| 158461 | | - /* 300 */ 1425, 1425, 643, 1315, 1336, 1004, 1651, 1651, 1581, 1581, |
| 158462 | | - /* 310 */ 1674, 1674, 1581, 1576, 1579, 1716, 1696, 1724, 1724, 1724, |
| 158463 | | - /* 320 */ 1724, 1581, 1732, 1606, 1579, 1579, 1606, 1716, 1696, 1606, |
| 158464 | | - /* 330 */ 1696, 1606, 1581, 1732, 1608, 1706, 1581, 1732, 1750, 1581, |
| 158465 | | - /* 340 */ 1732, 1581, 1732, 1750, 1660, 1660, 1660, 1711, 1766, 1766, |
| 158466 | | - /* 350 */ 1750, 1660, 1664, 1660, 1711, 1660, 1660, 1628, 1769, 1683, |
| 158467 | | - /* 360 */ 1683, 1750, 1653, 1709, 1653, 1709, 1653, 1709, 1653, 1709, |
| 158468 | | - /* 370 */ 1581, 1735, 1735, 1746, 1746, 1682, 1686, 1809, 1581, 1685, |
| 158469 | | - /* 380 */ 1682, 1697, 1699, 1606, 1821, 1825, 1840, 1840, 1864, 1864, |
| 158470 | | - /* 390 */ 1864, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, |
| 158471 | | - /* 400 */ 2020, 2020, 2020, 2020, 2020, 2020, 599, 223, 1193, 1299, |
| 158472 | | - /* 410 */ 228, 780, 958, 1505, 1153, 1435, 1368, 1426, 1430, 1552, |
| 158473 | | - /* 420 */ 1477, 1556, 1557, 1564, 1572, 1578, 1580, 1489, 1474, 1602, |
| 158474 | | - /* 430 */ 1389, 1514, 1500, 1595, 1596, 1484, 1603, 1075, 1460, 1605, |
| 158475 | | - /* 440 */ 1612, 1526, 1507, 1882, 1884, 1866, 1727, 1875, 1876, 1868, |
| 158476 | | - /* 450 */ 1870, 1757, 1747, 1767, 1872, 1872, 1877, 1758, 1880, 1759, |
| 158477 | | - /* 460 */ 1887, 1903, 1764, 1777, 1872, 1778, 1847, 1873, 1872, 1761, |
| 158478 | | - /* 470 */ 1856, 1862, 1863, 1865, 1788, 1804, 1886, 1781, 1921, 1918, |
| 158479 | | - /* 480 */ 1902, 1811, 1768, 1858, 1901, 1861, 1855, 1890, 1792, 1819, |
| 158480 | | - /* 490 */ 1910, 1915, 1917, 1807, 1814, 1919, 1878, 1920, 1922, 1916, |
| 158481 | | - /* 500 */ 1924, 1881, 1888, 1925, 1844, 1923, 1928, 1885, 1906, 1930, |
| 158482 | | - /* 510 */ 1806, 1933, 1934, 1935, 1936, 1937, 1938, 1940, 1859, 1820, |
| 158483 | | - /* 520 */ 1941, 1942, 1851, 1939, 1945, 1826, 1943, 1944, 1946, 1947, |
| 158484 | | - /* 530 */ 1948, 1883, 1895, 1889, 1932, 1897, 1891, 1949, 1951, 1955, |
| 158485 | | - /* 540 */ 1961, 1953, 1960, 1954, 1964, 1943, 1966, 1967, 1968, 1969, |
| 159032 | + /* 240 */ 66, 66, 790, 790, 790, 66, 66, 66, 883, 66, |
| 159033 | + /* 250 */ 66, 66, 891, 1064, 66, 66, 1212, 66, 66, 66, |
| 159034 | + /* 260 */ 66, 66, 66, 66, 66, 725, 763, 177, 940, 940, |
| 159035 | + /* 270 */ 940, 940, 337, 177, 177, 1028, 1053, 670, 1264, 1179, |
| 159036 | + /* 280 */ 1173, 1254, 1316, 1173, 1316, 1336, 50, 1179, 1179, 50, |
| 159037 | + /* 290 */ 1179, 1254, 1336, 1259, 732, 532, 1347, 1347, 1347, 1316, |
| 159038 | + /* 300 */ 1236, 1236, 1184, 1356, 1167, 898, 1650, 1650, 1572, 1572, |
| 159039 | + /* 310 */ 1685, 1685, 1572, 1576, 1579, 1712, 1692, 1722, 1722, 1722, |
| 159040 | + /* 320 */ 1722, 1572, 1732, 1604, 1579, 1579, 1604, 1712, 1692, 1604, |
| 159041 | + /* 330 */ 1692, 1604, 1572, 1732, 1610, 1707, 1572, 1732, 1751, 1572, |
| 159042 | + /* 340 */ 1732, 1572, 1732, 1751, 1665, 1665, 1665, 1723, 1766, 1766, |
| 159043 | + /* 350 */ 1751, 1665, 1664, 1665, 1723, 1665, 1665, 1629, 1772, 1698, |
| 159044 | + /* 360 */ 1698, 1751, 1674, 1709, 1674, 1709, 1674, 1709, 1674, 1709, |
| 159045 | + /* 370 */ 1572, 1736, 1736, 1746, 1746, 1682, 1686, 1810, 1572, 1688, |
| 159046 | + /* 380 */ 1682, 1695, 1697, 1604, 1821, 1838, 1853, 1853, 1864, 1864, |
| 159047 | + /* 390 */ 1864, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, |
| 159048 | + /* 400 */ 2023, 2023, 2023, 2023, 2023, 2023, 232, 101, 1131, 1193, |
| 159049 | + /* 410 */ 619, 679, 841, 1421, 1286, 115, 1352, 1334, 1361, 1419, |
| 159050 | + /* 420 */ 1342, 1505, 1531, 1585, 1593, 1605, 1612, 1280, 1337, 1491, |
| 159051 | + /* 430 */ 1358, 1451, 1332, 1616, 1617, 1425, 1618, 1386, 1431, 1624, |
| 159052 | + /* 440 */ 1626, 1399, 1460, 1880, 1883, 1865, 1726, 1876, 1877, 1869, |
| 159053 | + /* 450 */ 1871, 1757, 1747, 1767, 1872, 1872, 1875, 1759, 1881, 1760, |
| 159054 | + /* 460 */ 1886, 1903, 1764, 1777, 1872, 1778, 1847, 1878, 1872, 1762, |
| 159055 | + /* 470 */ 1860, 1861, 1863, 1866, 1788, 1803, 1887, 1780, 1921, 1918, |
| 159056 | + /* 480 */ 1902, 1811, 1768, 1858, 1901, 1862, 1854, 1890, 1792, 1819, |
| 159057 | + /* 490 */ 1910, 1915, 1917, 1807, 1814, 1919, 1873, 1920, 1922, 1916, |
| 159058 | + /* 500 */ 1923, 1879, 1884, 1924, 1851, 1925, 1927, 1885, 1913, 1928, |
| 159059 | + /* 510 */ 1806, 1933, 1934, 1935, 1936, 1930, 1937, 1939, 1867, 1822, |
| 159060 | + /* 520 */ 1940, 1942, 1852, 1932, 1946, 1827, 1944, 1938, 1941, 1943, |
| 159061 | + /* 530 */ 1945, 1888, 1896, 1892, 1929, 1899, 1889, 1947, 1957, 1961, |
| 159062 | + /* 540 */ 1960, 1959, 1962, 1952, 1964, 1944, 1966, 1967, 1968, 1969, |
| 158486 | 159063 | /* 550 */ 1970, 1971, 1973, 1982, 1975, 1976, 1977, 1978, 1980, 1981, |
| 158487 | | - /* 560 */ 1979, 1874, 1867, 1869, 1871, 1879, 1983, 1984, 2003, 2009, |
| 159064 | + /* 560 */ 1979, 1870, 1859, 1868, 1874, 1882, 1983, 1992, 2008, 2009, |
| 158488 | 159065 | }; |
| 158489 | 159066 | #define YY_REDUCE_COUNT (405) |
| 158490 | | -#define YY_REDUCE_MIN (-265) |
| 158491 | | -#define YY_REDUCE_MAX (1690) |
| 159067 | +#define YY_REDUCE_MIN (-266) |
| 159068 | +#define YY_REDUCE_MAX (1683) |
| 158492 | 159069 | static const short yy_reduce_ofst[] = { |
| 158493 | | - /* 0 */ 111, 168, 386, 761, -176, -174, -191, -189, -181, -178, |
| 158494 | | - /* 10 */ 176, 263, 44, -207, -204, -265, -139, -114, 158, 504, |
| 158495 | | - /* 20 */ 525, 544, 612, 614, 650, 652, 765, 265, 703, 705, |
| 158496 | | - /* 30 */ 70, 714, -187, 127, 774, 713, 767, 769, 970, 1019, |
| 158497 | | - /* 40 */ 1021, -255, -255, -255, -255, -255, -255, -255, -255, -255, |
| 158498 | | - /* 50 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, |
| 158499 | | - /* 60 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, |
| 158500 | | - /* 70 */ -255, -255, -255, -255, -255, -255, -255, -255, 394, 542, |
| 158501 | | - /* 80 */ 816, 818, 842, 882, 902, 919, 938, 940, 957, 986, |
| 158502 | | - /* 90 */ 1048, 1063, 1068, 1073, 1076, 1088, 1100, 1102, 1104, 1106, |
| 158503 | | - /* 100 */ 1113, 1119, 1137, 1140, 1143, 1147, 1149, 1164, 1173, 1183, |
| 158504 | | - /* 110 */ 1185, 1188, 1202, 1204, 1247, 1259, 1263, 1283, 1289, 1292, |
| 158505 | | - /* 120 */ 1298, 1300, 1329, 1331, 1343, 1358, 1360, -255, -255, -255, |
| 158506 | | - /* 130 */ -255, -255, -255, -255, -255, 196, -255, 387, -177, 507, |
| 158507 | | - /* 140 */ 1002, -219, 557, -93, -167, 638, -121, 284, 500, 284, |
| 158508 | | - /* 150 */ 500, 247, 651, 865, -255, -255, -255, -255, -85, -85, |
| 158509 | | - /* 160 */ -85, 237, 171, 602, 846, 885, -212, -203, 217, 380, |
| 158510 | | - /* 170 */ 380, -23, 161, 653, 712, 773, 943, 990, 1040, 563, |
| 158511 | | - /* 180 */ 833, 971, 1005, 1042, 1092, 1078, 1043, 1144, 1184, -186, |
| 158512 | | - /* 190 */ 1105, 318, 869, 7, 825, 920, 1074, 704, 706, 390, |
| 158513 | | - /* 200 */ 1087, 1094, 336, 545, 772, 1201, 1117, 1207, -179, -137, |
| 158514 | | - /* 210 */ -112, -13, 18, 112, 197, 418, 495, 508, 777, 809, |
| 158515 | | - /* 220 */ 923, 1014, 1027, 1033, 1044, 1115, 1194, 1212, 1221, 209, |
| 158516 | | - /* 230 */ 1236, 1240, 1256, 1287, 1301, 1307, 1349, 1359, 1398, 1417, |
| 158517 | | - /* 240 */ 1429, 1434, 681, 1377, 1404, 1448, 1449, 1450, 1388, 1453, |
| 158518 | | - /* 250 */ 1455, 1458, 1393, 1335, 1461, 1462, 1418, 1463, 197, 1464, |
| 158519 | | - /* 260 */ 1465, 1466, 1467, 1468, 1469, 1376, 1378, 1424, 1412, 1413, |
| 158520 | | - /* 270 */ 1414, 1415, 1388, 1424, 1424, 1428, 1470, 1485, 1381, 1408, |
| 158521 | | - /* 280 */ 1416, 1436, 1431, 1422, 1432, 1392, 1446, 1411, 1427, 1456, |
| 158522 | | - /* 290 */ 1433, 1471, 1401, 1479, 1472, 1478, 1486, 1491, 1493, 1452, |
| 158523 | | - /* 300 */ 1459, 1473, 1437, 1475, 1476, 1516, 1421, 1440, 1520, 1524, |
| 158524 | | - /* 310 */ 1444, 1445, 1525, 1457, 1480, 1481, 1509, 1510, 1511, 1512, |
| 158525 | | - /* 320 */ 1513, 1553, 1555, 1515, 1487, 1488, 1518, 1495, 1522, 1523, |
| 158526 | | - /* 330 */ 1528, 1527, 1562, 1566, 1482, 1494, 1569, 1574, 1559, 1575, |
| 158527 | | - /* 340 */ 1582, 1583, 1585, 1560, 1568, 1570, 1571, 1563, 1573, 1586, |
| 158528 | | - /* 350 */ 1584, 1588, 1589, 1593, 1590, 1594, 1598, 1501, 1496, 1536, |
| 158529 | | - /* 360 */ 1537, 1599, 1561, 1567, 1587, 1591, 1592, 1597, 1604, 1607, |
| 158530 | | - /* 370 */ 1629, 1519, 1521, 1601, 1609, 1600, 1610, 1558, 1636, 1565, |
| 158531 | | - /* 380 */ 1618, 1621, 1611, 1624, 1648, 1652, 1676, 1677, 1687, 1688, |
| 158532 | | - /* 390 */ 1689, 1613, 1614, 1615, 1668, 1663, 1665, 1666, 1670, 1678, |
| 158533 | | - /* 400 */ 1655, 1662, 1672, 1673, 1675, 1690, |
| 159070 | + /* 0 */ 111, 168, 272, 760, -177, -175, -192, -190, -182, -179, |
| 159071 | + /* 10 */ 216, 220, 481, -208, -205, -266, -140, -115, 241, 393, |
| 159072 | + /* 20 */ 523, 325, 612, 632, 542, 651, 764, 757, 702, 762, |
| 159073 | + /* 30 */ 812, 814, -188, 273, 924, 386, 758, 967, 1020, 1052, |
| 159074 | + /* 40 */ 1066, -256, -256, -256, -256, -256, -256, -256, -256, -256, |
| 159075 | + /* 50 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256, |
| 159076 | + /* 60 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256, |
| 159077 | + /* 70 */ -256, -256, -256, -256, -256, -256, -256, -256, 195, 222, |
| 159078 | + /* 80 */ 813, 917, 920, 959, 985, 1006, 1038, 1067, 1069, 1072, |
| 159079 | + /* 90 */ 1099, 1103, 1105, 1118, 1135, 1139, 1142, 1146, 1148, 1159, |
| 159080 | + /* 100 */ 1174, 1178, 1183, 1185, 1187, 1198, 1202, 1246, 1258, 1260, |
| 159081 | + /* 110 */ 1262, 1288, 1291, 1299, 1304, 1319, 1328, 1330, 1357, 1359, |
| 159082 | + /* 120 */ 1364, 1366, 1375, 1390, 1395, 1406, 1411, -256, -256, -256, |
| 159083 | + /* 130 */ -256, -256, -256, -256, -256, 447, -256, 555, -178, 605, |
| 159084 | + /* 140 */ 832, -220, 606, -94, -168, 36, -122, 730, 780, 730, |
| 159085 | + /* 150 */ 780, 918, -136, 338, -256, -256, -256, -256, 80, 80, |
| 159086 | + /* 160 */ 80, 720, 703, 811, 882, 903, -213, -204, 106, 330, |
| 159087 | + /* 170 */ 330, -77, 236, 320, 599, 67, 457, 675, 729, 395, |
| 159088 | + /* 180 */ 268, 611, 969, 1004, 726, 1014, 983, 123, 884, 608, |
| 159089 | + /* 190 */ 1034, 547, 911, 650, 844, 922, 949, 965, 972, 978, |
| 159090 | + /* 200 */ 449, 970, 718, 784, 1073, 1084, 1023, 1129, -209, -180, |
| 159091 | + /* 210 */ -113, 114, 183, 329, 345, 391, 446, 502, 609, 667, |
| 159092 | + /* 220 */ 713, 817, 865, 881, 901, 921, 989, 1191, 1195, 214, |
| 159093 | + /* 230 */ 1223, 1235, 1251, 1367, 1376, 1377, 1383, 1385, 1401, 1402, |
| 159094 | + /* 240 */ 1403, 1414, 584, 638, 1305, 1420, 1422, 1426, 1294, 1430, |
| 159095 | + /* 250 */ 1435, 1437, 1348, 1329, 1459, 1461, 1412, 1462, 345, 1463, |
| 159096 | + /* 260 */ 1464, 1465, 1466, 1467, 1468, 1378, 1380, 1427, 1408, 1413, |
| 159097 | + /* 270 */ 1415, 1428, 1294, 1427, 1427, 1433, 1450, 1473, 1381, 1417, |
| 159098 | + /* 280 */ 1424, 1432, 1434, 1436, 1438, 1387, 1443, 1429, 1439, 1444, |
| 159099 | + /* 290 */ 1440, 1453, 1388, 1481, 1455, 1457, 1483, 1485, 1488, 1456, |
| 159100 | + /* 300 */ 1469, 1470, 1441, 1471, 1474, 1512, 1416, 1442, 1519, 1522, |
| 159101 | + /* 310 */ 1446, 1447, 1523, 1472, 1475, 1476, 1504, 1507, 1511, 1513, |
| 159102 | + /* 320 */ 1514, 1548, 1553, 1510, 1486, 1487, 1515, 1490, 1528, 1518, |
| 159103 | + /* 330 */ 1529, 1521, 1564, 1568, 1480, 1484, 1571, 1574, 1555, 1578, |
| 159104 | + /* 340 */ 1580, 1581, 1583, 1556, 1566, 1567, 1569, 1561, 1570, 1573, |
| 159105 | + /* 350 */ 1575, 1582, 1584, 1587, 1588, 1590, 1591, 1498, 1506, 1534, |
| 159106 | + /* 360 */ 1535, 1597, 1560, 1586, 1565, 1589, 1592, 1594, 1595, 1598, |
| 159107 | + /* 370 */ 1627, 1516, 1520, 1599, 1600, 1601, 1596, 1558, 1635, 1602, |
| 159108 | + /* 380 */ 1607, 1619, 1603, 1606, 1651, 1666, 1675, 1676, 1680, 1681, |
| 159109 | + /* 390 */ 1683, 1608, 1609, 1613, 1668, 1667, 1669, 1670, 1671, 1672, |
| 159110 | + /* 400 */ 1655, 1656, 1673, 1677, 1679, 1678, |
| 158534 | 159111 | }; |
| 158535 | 159112 | static const YYACTIONTYPE yy_default[] = { |
| 158536 | 159113 | /* 0 */ 1623, 1623, 1623, 1453, 1223, 1332, 1223, 1223, 1223, 1453, |
| 158537 | 159114 | /* 10 */ 1453, 1453, 1223, 1362, 1362, 1506, 1254, 1223, 1223, 1223, |
| 158538 | 159115 | /* 20 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1452, 1223, 1223, |
| | @@ -158788,10 +159365,11 @@ |
| 158788 | 159365 | 0, /* VECTOR => nothing */ |
| 158789 | 159366 | 0, /* SELECT_COLUMN => nothing */ |
| 158790 | 159367 | 0, /* IF_NULL_ROW => nothing */ |
| 158791 | 159368 | 0, /* ASTERISK => nothing */ |
| 158792 | 159369 | 0, /* SPAN => nothing */ |
| 159370 | + 0, /* ERROR => nothing */ |
| 158793 | 159371 | 0, /* SPACE => nothing */ |
| 158794 | 159372 | 0, /* ILLEGAL => nothing */ |
| 158795 | 159373 | }; |
| 158796 | 159374 | #endif /* YYFALLBACK */ |
| 158797 | 159375 | |
| | @@ -159059,145 +159637,146 @@ |
| 159059 | 159637 | /* 176 */ "VECTOR", |
| 159060 | 159638 | /* 177 */ "SELECT_COLUMN", |
| 159061 | 159639 | /* 178 */ "IF_NULL_ROW", |
| 159062 | 159640 | /* 179 */ "ASTERISK", |
| 159063 | 159641 | /* 180 */ "SPAN", |
| 159064 | | - /* 181 */ "SPACE", |
| 159065 | | - /* 182 */ "ILLEGAL", |
| 159066 | | - /* 183 */ "input", |
| 159067 | | - /* 184 */ "cmdlist", |
| 159068 | | - /* 185 */ "ecmd", |
| 159069 | | - /* 186 */ "cmdx", |
| 159070 | | - /* 187 */ "explain", |
| 159071 | | - /* 188 */ "cmd", |
| 159072 | | - /* 189 */ "transtype", |
| 159073 | | - /* 190 */ "trans_opt", |
| 159074 | | - /* 191 */ "nm", |
| 159075 | | - /* 192 */ "savepoint_opt", |
| 159076 | | - /* 193 */ "create_table", |
| 159077 | | - /* 194 */ "create_table_args", |
| 159078 | | - /* 195 */ "createkw", |
| 159079 | | - /* 196 */ "temp", |
| 159080 | | - /* 197 */ "ifnotexists", |
| 159081 | | - /* 198 */ "dbnm", |
| 159082 | | - /* 199 */ "columnlist", |
| 159083 | | - /* 200 */ "conslist_opt", |
| 159084 | | - /* 201 */ "table_options", |
| 159085 | | - /* 202 */ "select", |
| 159086 | | - /* 203 */ "columnname", |
| 159087 | | - /* 204 */ "carglist", |
| 159088 | | - /* 205 */ "typetoken", |
| 159089 | | - /* 206 */ "typename", |
| 159090 | | - /* 207 */ "signed", |
| 159091 | | - /* 208 */ "plus_num", |
| 159092 | | - /* 209 */ "minus_num", |
| 159093 | | - /* 210 */ "scanpt", |
| 159094 | | - /* 211 */ "scantok", |
| 159095 | | - /* 212 */ "ccons", |
| 159096 | | - /* 213 */ "term", |
| 159097 | | - /* 214 */ "expr", |
| 159098 | | - /* 215 */ "onconf", |
| 159099 | | - /* 216 */ "sortorder", |
| 159100 | | - /* 217 */ "autoinc", |
| 159101 | | - /* 218 */ "eidlist_opt", |
| 159102 | | - /* 219 */ "refargs", |
| 159103 | | - /* 220 */ "defer_subclause", |
| 159104 | | - /* 221 */ "generated", |
| 159105 | | - /* 222 */ "refarg", |
| 159106 | | - /* 223 */ "refact", |
| 159107 | | - /* 224 */ "init_deferred_pred_opt", |
| 159108 | | - /* 225 */ "conslist", |
| 159109 | | - /* 226 */ "tconscomma", |
| 159110 | | - /* 227 */ "tcons", |
| 159111 | | - /* 228 */ "sortlist", |
| 159112 | | - /* 229 */ "eidlist", |
| 159113 | | - /* 230 */ "defer_subclause_opt", |
| 159114 | | - /* 231 */ "orconf", |
| 159115 | | - /* 232 */ "resolvetype", |
| 159116 | | - /* 233 */ "raisetype", |
| 159117 | | - /* 234 */ "ifexists", |
| 159118 | | - /* 235 */ "fullname", |
| 159119 | | - /* 236 */ "selectnowith", |
| 159120 | | - /* 237 */ "oneselect", |
| 159121 | | - /* 238 */ "wqlist", |
| 159122 | | - /* 239 */ "multiselect_op", |
| 159123 | | - /* 240 */ "distinct", |
| 159124 | | - /* 241 */ "selcollist", |
| 159125 | | - /* 242 */ "from", |
| 159126 | | - /* 243 */ "where_opt", |
| 159127 | | - /* 244 */ "groupby_opt", |
| 159128 | | - /* 245 */ "having_opt", |
| 159129 | | - /* 246 */ "orderby_opt", |
| 159130 | | - /* 247 */ "limit_opt", |
| 159131 | | - /* 248 */ "window_clause", |
| 159132 | | - /* 249 */ "values", |
| 159133 | | - /* 250 */ "nexprlist", |
| 159134 | | - /* 251 */ "sclp", |
| 159135 | | - /* 252 */ "as", |
| 159136 | | - /* 253 */ "seltablist", |
| 159137 | | - /* 254 */ "stl_prefix", |
| 159138 | | - /* 255 */ "joinop", |
| 159139 | | - /* 256 */ "indexed_opt", |
| 159140 | | - /* 257 */ "on_opt", |
| 159141 | | - /* 258 */ "using_opt", |
| 159142 | | - /* 259 */ "exprlist", |
| 159143 | | - /* 260 */ "xfullname", |
| 159144 | | - /* 261 */ "idlist", |
| 159145 | | - /* 262 */ "nulls", |
| 159146 | | - /* 263 */ "with", |
| 159147 | | - /* 264 */ "where_opt_ret", |
| 159148 | | - /* 265 */ "setlist", |
| 159149 | | - /* 266 */ "insert_cmd", |
| 159150 | | - /* 267 */ "idlist_opt", |
| 159151 | | - /* 268 */ "upsert", |
| 159152 | | - /* 269 */ "returning", |
| 159153 | | - /* 270 */ "filter_over", |
| 159154 | | - /* 271 */ "likeop", |
| 159155 | | - /* 272 */ "between_op", |
| 159156 | | - /* 273 */ "in_op", |
| 159157 | | - /* 274 */ "paren_exprlist", |
| 159158 | | - /* 275 */ "case_operand", |
| 159159 | | - /* 276 */ "case_exprlist", |
| 159160 | | - /* 277 */ "case_else", |
| 159161 | | - /* 278 */ "uniqueflag", |
| 159162 | | - /* 279 */ "collate", |
| 159163 | | - /* 280 */ "vinto", |
| 159164 | | - /* 281 */ "nmnum", |
| 159165 | | - /* 282 */ "trigger_decl", |
| 159166 | | - /* 283 */ "trigger_cmd_list", |
| 159167 | | - /* 284 */ "trigger_time", |
| 159168 | | - /* 285 */ "trigger_event", |
| 159169 | | - /* 286 */ "foreach_clause", |
| 159170 | | - /* 287 */ "when_clause", |
| 159171 | | - /* 288 */ "trigger_cmd", |
| 159172 | | - /* 289 */ "trnm", |
| 159173 | | - /* 290 */ "tridxby", |
| 159174 | | - /* 291 */ "database_kw_opt", |
| 159175 | | - /* 292 */ "key_opt", |
| 159176 | | - /* 293 */ "add_column_fullname", |
| 159177 | | - /* 294 */ "kwcolumn_opt", |
| 159178 | | - /* 295 */ "create_vtab", |
| 159179 | | - /* 296 */ "vtabarglist", |
| 159180 | | - /* 297 */ "vtabarg", |
| 159181 | | - /* 298 */ "vtabargtoken", |
| 159182 | | - /* 299 */ "lp", |
| 159183 | | - /* 300 */ "anylist", |
| 159184 | | - /* 301 */ "wqitem", |
| 159185 | | - /* 302 */ "wqas", |
| 159186 | | - /* 303 */ "windowdefn_list", |
| 159187 | | - /* 304 */ "windowdefn", |
| 159188 | | - /* 305 */ "window", |
| 159189 | | - /* 306 */ "frame_opt", |
| 159190 | | - /* 307 */ "part_opt", |
| 159191 | | - /* 308 */ "filter_clause", |
| 159192 | | - /* 309 */ "over_clause", |
| 159193 | | - /* 310 */ "range_or_rows", |
| 159194 | | - /* 311 */ "frame_bound", |
| 159195 | | - /* 312 */ "frame_bound_s", |
| 159196 | | - /* 313 */ "frame_bound_e", |
| 159197 | | - /* 314 */ "frame_exclude_opt", |
| 159198 | | - /* 315 */ "frame_exclude", |
| 159642 | + /* 181 */ "ERROR", |
| 159643 | + /* 182 */ "SPACE", |
| 159644 | + /* 183 */ "ILLEGAL", |
| 159645 | + /* 184 */ "input", |
| 159646 | + /* 185 */ "cmdlist", |
| 159647 | + /* 186 */ "ecmd", |
| 159648 | + /* 187 */ "cmdx", |
| 159649 | + /* 188 */ "explain", |
| 159650 | + /* 189 */ "cmd", |
| 159651 | + /* 190 */ "transtype", |
| 159652 | + /* 191 */ "trans_opt", |
| 159653 | + /* 192 */ "nm", |
| 159654 | + /* 193 */ "savepoint_opt", |
| 159655 | + /* 194 */ "create_table", |
| 159656 | + /* 195 */ "create_table_args", |
| 159657 | + /* 196 */ "createkw", |
| 159658 | + /* 197 */ "temp", |
| 159659 | + /* 198 */ "ifnotexists", |
| 159660 | + /* 199 */ "dbnm", |
| 159661 | + /* 200 */ "columnlist", |
| 159662 | + /* 201 */ "conslist_opt", |
| 159663 | + /* 202 */ "table_options", |
| 159664 | + /* 203 */ "select", |
| 159665 | + /* 204 */ "columnname", |
| 159666 | + /* 205 */ "carglist", |
| 159667 | + /* 206 */ "typetoken", |
| 159668 | + /* 207 */ "typename", |
| 159669 | + /* 208 */ "signed", |
| 159670 | + /* 209 */ "plus_num", |
| 159671 | + /* 210 */ "minus_num", |
| 159672 | + /* 211 */ "scanpt", |
| 159673 | + /* 212 */ "scantok", |
| 159674 | + /* 213 */ "ccons", |
| 159675 | + /* 214 */ "term", |
| 159676 | + /* 215 */ "expr", |
| 159677 | + /* 216 */ "onconf", |
| 159678 | + /* 217 */ "sortorder", |
| 159679 | + /* 218 */ "autoinc", |
| 159680 | + /* 219 */ "eidlist_opt", |
| 159681 | + /* 220 */ "refargs", |
| 159682 | + /* 221 */ "defer_subclause", |
| 159683 | + /* 222 */ "generated", |
| 159684 | + /* 223 */ "refarg", |
| 159685 | + /* 224 */ "refact", |
| 159686 | + /* 225 */ "init_deferred_pred_opt", |
| 159687 | + /* 226 */ "conslist", |
| 159688 | + /* 227 */ "tconscomma", |
| 159689 | + /* 228 */ "tcons", |
| 159690 | + /* 229 */ "sortlist", |
| 159691 | + /* 230 */ "eidlist", |
| 159692 | + /* 231 */ "defer_subclause_opt", |
| 159693 | + /* 232 */ "orconf", |
| 159694 | + /* 233 */ "resolvetype", |
| 159695 | + /* 234 */ "raisetype", |
| 159696 | + /* 235 */ "ifexists", |
| 159697 | + /* 236 */ "fullname", |
| 159698 | + /* 237 */ "selectnowith", |
| 159699 | + /* 238 */ "oneselect", |
| 159700 | + /* 239 */ "wqlist", |
| 159701 | + /* 240 */ "multiselect_op", |
| 159702 | + /* 241 */ "distinct", |
| 159703 | + /* 242 */ "selcollist", |
| 159704 | + /* 243 */ "from", |
| 159705 | + /* 244 */ "where_opt", |
| 159706 | + /* 245 */ "groupby_opt", |
| 159707 | + /* 246 */ "having_opt", |
| 159708 | + /* 247 */ "orderby_opt", |
| 159709 | + /* 248 */ "limit_opt", |
| 159710 | + /* 249 */ "window_clause", |
| 159711 | + /* 250 */ "values", |
| 159712 | + /* 251 */ "nexprlist", |
| 159713 | + /* 252 */ "sclp", |
| 159714 | + /* 253 */ "as", |
| 159715 | + /* 254 */ "seltablist", |
| 159716 | + /* 255 */ "stl_prefix", |
| 159717 | + /* 256 */ "joinop", |
| 159718 | + /* 257 */ "indexed_opt", |
| 159719 | + /* 258 */ "on_opt", |
| 159720 | + /* 259 */ "using_opt", |
| 159721 | + /* 260 */ "exprlist", |
| 159722 | + /* 261 */ "xfullname", |
| 159723 | + /* 262 */ "idlist", |
| 159724 | + /* 263 */ "nulls", |
| 159725 | + /* 264 */ "with", |
| 159726 | + /* 265 */ "where_opt_ret", |
| 159727 | + /* 266 */ "setlist", |
| 159728 | + /* 267 */ "insert_cmd", |
| 159729 | + /* 268 */ "idlist_opt", |
| 159730 | + /* 269 */ "upsert", |
| 159731 | + /* 270 */ "returning", |
| 159732 | + /* 271 */ "filter_over", |
| 159733 | + /* 272 */ "likeop", |
| 159734 | + /* 273 */ "between_op", |
| 159735 | + /* 274 */ "in_op", |
| 159736 | + /* 275 */ "paren_exprlist", |
| 159737 | + /* 276 */ "case_operand", |
| 159738 | + /* 277 */ "case_exprlist", |
| 159739 | + /* 278 */ "case_else", |
| 159740 | + /* 279 */ "uniqueflag", |
| 159741 | + /* 280 */ "collate", |
| 159742 | + /* 281 */ "vinto", |
| 159743 | + /* 282 */ "nmnum", |
| 159744 | + /* 283 */ "trigger_decl", |
| 159745 | + /* 284 */ "trigger_cmd_list", |
| 159746 | + /* 285 */ "trigger_time", |
| 159747 | + /* 286 */ "trigger_event", |
| 159748 | + /* 287 */ "foreach_clause", |
| 159749 | + /* 288 */ "when_clause", |
| 159750 | + /* 289 */ "trigger_cmd", |
| 159751 | + /* 290 */ "trnm", |
| 159752 | + /* 291 */ "tridxby", |
| 159753 | + /* 292 */ "database_kw_opt", |
| 159754 | + /* 293 */ "key_opt", |
| 159755 | + /* 294 */ "add_column_fullname", |
| 159756 | + /* 295 */ "kwcolumn_opt", |
| 159757 | + /* 296 */ "create_vtab", |
| 159758 | + /* 297 */ "vtabarglist", |
| 159759 | + /* 298 */ "vtabarg", |
| 159760 | + /* 299 */ "vtabargtoken", |
| 159761 | + /* 300 */ "lp", |
| 159762 | + /* 301 */ "anylist", |
| 159763 | + /* 302 */ "wqitem", |
| 159764 | + /* 303 */ "wqas", |
| 159765 | + /* 304 */ "windowdefn_list", |
| 159766 | + /* 305 */ "windowdefn", |
| 159767 | + /* 306 */ "window", |
| 159768 | + /* 307 */ "frame_opt", |
| 159769 | + /* 308 */ "part_opt", |
| 159770 | + /* 309 */ "filter_clause", |
| 159771 | + /* 310 */ "over_clause", |
| 159772 | + /* 311 */ "range_or_rows", |
| 159773 | + /* 312 */ "frame_bound", |
| 159774 | + /* 313 */ "frame_bound_s", |
| 159775 | + /* 314 */ "frame_bound_e", |
| 159776 | + /* 315 */ "frame_exclude_opt", |
| 159777 | + /* 316 */ "frame_exclude", |
| 159199 | 159778 | }; |
| 159200 | 159779 | #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ |
| 159201 | 159780 | |
| 159202 | 159781 | #ifndef NDEBUG |
| 159203 | 159782 | /* For tracing reduce actions, the names of all rules are required. |
| | @@ -159724,103 +160303,103 @@ |
| 159724 | 160303 | ** Note: during a reduce, the only symbols destroyed are those |
| 159725 | 160304 | ** which appear on the RHS of the rule, but which are *not* used |
| 159726 | 160305 | ** inside the C code. |
| 159727 | 160306 | */ |
| 159728 | 160307 | /********* Begin destructor definitions ***************************************/ |
| 159729 | | - case 202: /* select */ |
| 159730 | | - case 236: /* selectnowith */ |
| 159731 | | - case 237: /* oneselect */ |
| 159732 | | - case 249: /* values */ |
| 159733 | | -{ |
| 159734 | | -sqlite3SelectDelete(pParse->db, (yypminor->yy307)); |
| 159735 | | -} |
| 159736 | | - break; |
| 159737 | | - case 213: /* term */ |
| 159738 | | - case 214: /* expr */ |
| 159739 | | - case 243: /* where_opt */ |
| 159740 | | - case 245: /* having_opt */ |
| 159741 | | - case 257: /* on_opt */ |
| 159742 | | - case 264: /* where_opt_ret */ |
| 159743 | | - case 275: /* case_operand */ |
| 159744 | | - case 277: /* case_else */ |
| 159745 | | - case 280: /* vinto */ |
| 159746 | | - case 287: /* when_clause */ |
| 159747 | | - case 292: /* key_opt */ |
| 159748 | | - case 308: /* filter_clause */ |
| 159749 | | -{ |
| 159750 | | -sqlite3ExprDelete(pParse->db, (yypminor->yy602)); |
| 159751 | | -} |
| 159752 | | - break; |
| 159753 | | - case 218: /* eidlist_opt */ |
| 159754 | | - case 228: /* sortlist */ |
| 159755 | | - case 229: /* eidlist */ |
| 159756 | | - case 241: /* selcollist */ |
| 159757 | | - case 244: /* groupby_opt */ |
| 159758 | | - case 246: /* orderby_opt */ |
| 159759 | | - case 250: /* nexprlist */ |
| 159760 | | - case 251: /* sclp */ |
| 159761 | | - case 259: /* exprlist */ |
| 159762 | | - case 265: /* setlist */ |
| 159763 | | - case 274: /* paren_exprlist */ |
| 159764 | | - case 276: /* case_exprlist */ |
| 159765 | | - case 307: /* part_opt */ |
| 159766 | | -{ |
| 159767 | | -sqlite3ExprListDelete(pParse->db, (yypminor->yy338)); |
| 159768 | | -} |
| 159769 | | - break; |
| 159770 | | - case 235: /* fullname */ |
| 159771 | | - case 242: /* from */ |
| 159772 | | - case 253: /* seltablist */ |
| 159773 | | - case 254: /* stl_prefix */ |
| 159774 | | - case 260: /* xfullname */ |
| 159775 | | -{ |
| 159776 | | -sqlite3SrcListDelete(pParse->db, (yypminor->yy291)); |
| 159777 | | -} |
| 159778 | | - break; |
| 159779 | | - case 238: /* wqlist */ |
| 159780 | | -{ |
| 159781 | | -sqlite3WithDelete(pParse->db, (yypminor->yy195)); |
| 159782 | | -} |
| 159783 | | - break; |
| 159784 | | - case 248: /* window_clause */ |
| 159785 | | - case 303: /* windowdefn_list */ |
| 159786 | | -{ |
| 159787 | | -sqlite3WindowListDelete(pParse->db, (yypminor->yy19)); |
| 159788 | | -} |
| 159789 | | - break; |
| 159790 | | - case 258: /* using_opt */ |
| 159791 | | - case 261: /* idlist */ |
| 159792 | | - case 267: /* idlist_opt */ |
| 159793 | | -{ |
| 159794 | | -sqlite3IdListDelete(pParse->db, (yypminor->yy288)); |
| 159795 | | -} |
| 159796 | | - break; |
| 159797 | | - case 270: /* filter_over */ |
| 159798 | | - case 304: /* windowdefn */ |
| 159799 | | - case 305: /* window */ |
| 159800 | | - case 306: /* frame_opt */ |
| 159801 | | - case 309: /* over_clause */ |
| 159802 | | -{ |
| 159803 | | -sqlite3WindowDelete(pParse->db, (yypminor->yy19)); |
| 159804 | | -} |
| 159805 | | - break; |
| 159806 | | - case 283: /* trigger_cmd_list */ |
| 159807 | | - case 288: /* trigger_cmd */ |
| 159808 | | -{ |
| 159809 | | -sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy483)); |
| 159810 | | -} |
| 159811 | | - break; |
| 159812 | | - case 285: /* trigger_event */ |
| 159813 | | -{ |
| 159814 | | -sqlite3IdListDelete(pParse->db, (yypminor->yy50).b); |
| 159815 | | -} |
| 159816 | | - break; |
| 159817 | | - case 311: /* frame_bound */ |
| 159818 | | - case 312: /* frame_bound_s */ |
| 159819 | | - case 313: /* frame_bound_e */ |
| 159820 | | -{ |
| 159821 | | -sqlite3ExprDelete(pParse->db, (yypminor->yy113).pExpr); |
| 160308 | + case 203: /* select */ |
| 160309 | + case 237: /* selectnowith */ |
| 160310 | + case 238: /* oneselect */ |
| 160311 | + case 250: /* values */ |
| 160312 | +{ |
| 160313 | +sqlite3SelectDelete(pParse->db, (yypminor->yy81)); |
| 160314 | +} |
| 160315 | + break; |
| 160316 | + case 214: /* term */ |
| 160317 | + case 215: /* expr */ |
| 160318 | + case 244: /* where_opt */ |
| 160319 | + case 246: /* having_opt */ |
| 160320 | + case 258: /* on_opt */ |
| 160321 | + case 265: /* where_opt_ret */ |
| 160322 | + case 276: /* case_operand */ |
| 160323 | + case 278: /* case_else */ |
| 160324 | + case 281: /* vinto */ |
| 160325 | + case 288: /* when_clause */ |
| 160326 | + case 293: /* key_opt */ |
| 160327 | + case 309: /* filter_clause */ |
| 160328 | +{ |
| 160329 | +sqlite3ExprDelete(pParse->db, (yypminor->yy404)); |
| 160330 | +} |
| 160331 | + break; |
| 160332 | + case 219: /* eidlist_opt */ |
| 160333 | + case 229: /* sortlist */ |
| 160334 | + case 230: /* eidlist */ |
| 160335 | + case 242: /* selcollist */ |
| 160336 | + case 245: /* groupby_opt */ |
| 160337 | + case 247: /* orderby_opt */ |
| 160338 | + case 251: /* nexprlist */ |
| 160339 | + case 252: /* sclp */ |
| 160340 | + case 260: /* exprlist */ |
| 160341 | + case 266: /* setlist */ |
| 160342 | + case 275: /* paren_exprlist */ |
| 160343 | + case 277: /* case_exprlist */ |
| 160344 | + case 308: /* part_opt */ |
| 160345 | +{ |
| 160346 | +sqlite3ExprListDelete(pParse->db, (yypminor->yy70)); |
| 160347 | +} |
| 160348 | + break; |
| 160349 | + case 236: /* fullname */ |
| 160350 | + case 243: /* from */ |
| 160351 | + case 254: /* seltablist */ |
| 160352 | + case 255: /* stl_prefix */ |
| 160353 | + case 261: /* xfullname */ |
| 160354 | +{ |
| 160355 | +sqlite3SrcListDelete(pParse->db, (yypminor->yy153)); |
| 160356 | +} |
| 160357 | + break; |
| 160358 | + case 239: /* wqlist */ |
| 160359 | +{ |
| 160360 | +sqlite3WithDelete(pParse->db, (yypminor->yy103)); |
| 160361 | +} |
| 160362 | + break; |
| 160363 | + case 249: /* window_clause */ |
| 160364 | + case 304: /* windowdefn_list */ |
| 160365 | +{ |
| 160366 | +sqlite3WindowListDelete(pParse->db, (yypminor->yy49)); |
| 160367 | +} |
| 160368 | + break; |
| 160369 | + case 259: /* using_opt */ |
| 160370 | + case 262: /* idlist */ |
| 160371 | + case 268: /* idlist_opt */ |
| 160372 | +{ |
| 160373 | +sqlite3IdListDelete(pParse->db, (yypminor->yy436)); |
| 160374 | +} |
| 160375 | + break; |
| 160376 | + case 271: /* filter_over */ |
| 160377 | + case 305: /* windowdefn */ |
| 160378 | + case 306: /* window */ |
| 160379 | + case 307: /* frame_opt */ |
| 160380 | + case 310: /* over_clause */ |
| 160381 | +{ |
| 160382 | +sqlite3WindowDelete(pParse->db, (yypminor->yy49)); |
| 160383 | +} |
| 160384 | + break; |
| 160385 | + case 284: /* trigger_cmd_list */ |
| 160386 | + case 289: /* trigger_cmd */ |
| 160387 | +{ |
| 160388 | +sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy157)); |
| 160389 | +} |
| 160390 | + break; |
| 160391 | + case 286: /* trigger_event */ |
| 160392 | +{ |
| 160393 | +sqlite3IdListDelete(pParse->db, (yypminor->yy262).b); |
| 160394 | +} |
| 160395 | + break; |
| 160396 | + case 312: /* frame_bound */ |
| 160397 | + case 313: /* frame_bound_s */ |
| 160398 | + case 314: /* frame_bound_e */ |
| 160399 | +{ |
| 160400 | +sqlite3ExprDelete(pParse->db, (yypminor->yy117).pExpr); |
| 159822 | 160401 | } |
| 159823 | 160402 | break; |
| 159824 | 160403 | /********* End destructor definitions *****************************************/ |
| 159825 | 160404 | default: break; /* If no destructor action specified: do nothing */ |
| 159826 | 160405 | } |
| | @@ -160107,408 +160686,408 @@ |
| 160107 | 160686 | } |
| 160108 | 160687 | |
| 160109 | 160688 | /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side |
| 160110 | 160689 | ** of that rule */ |
| 160111 | 160690 | static const YYCODETYPE yyRuleInfoLhs[] = { |
| 160112 | | - 187, /* (0) explain ::= EXPLAIN */ |
| 160113 | | - 187, /* (1) explain ::= EXPLAIN QUERY PLAN */ |
| 160114 | | - 186, /* (2) cmdx ::= cmd */ |
| 160115 | | - 188, /* (3) cmd ::= BEGIN transtype trans_opt */ |
| 160116 | | - 189, /* (4) transtype ::= */ |
| 160117 | | - 189, /* (5) transtype ::= DEFERRED */ |
| 160118 | | - 189, /* (6) transtype ::= IMMEDIATE */ |
| 160119 | | - 189, /* (7) transtype ::= EXCLUSIVE */ |
| 160120 | | - 188, /* (8) cmd ::= COMMIT|END trans_opt */ |
| 160121 | | - 188, /* (9) cmd ::= ROLLBACK trans_opt */ |
| 160122 | | - 188, /* (10) cmd ::= SAVEPOINT nm */ |
| 160123 | | - 188, /* (11) cmd ::= RELEASE savepoint_opt nm */ |
| 160124 | | - 188, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ |
| 160125 | | - 193, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 160126 | | - 195, /* (14) createkw ::= CREATE */ |
| 160127 | | - 197, /* (15) ifnotexists ::= */ |
| 160128 | | - 197, /* (16) ifnotexists ::= IF NOT EXISTS */ |
| 160129 | | - 196, /* (17) temp ::= TEMP */ |
| 160130 | | - 196, /* (18) temp ::= */ |
| 160131 | | - 194, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ |
| 160132 | | - 194, /* (20) create_table_args ::= AS select */ |
| 160133 | | - 201, /* (21) table_options ::= */ |
| 160134 | | - 201, /* (22) table_options ::= WITHOUT nm */ |
| 160135 | | - 203, /* (23) columnname ::= nm typetoken */ |
| 160136 | | - 205, /* (24) typetoken ::= */ |
| 160137 | | - 205, /* (25) typetoken ::= typename LP signed RP */ |
| 160138 | | - 205, /* (26) typetoken ::= typename LP signed COMMA signed RP */ |
| 160139 | | - 206, /* (27) typename ::= typename ID|STRING */ |
| 160140 | | - 210, /* (28) scanpt ::= */ |
| 160141 | | - 211, /* (29) scantok ::= */ |
| 160142 | | - 212, /* (30) ccons ::= CONSTRAINT nm */ |
| 160143 | | - 212, /* (31) ccons ::= DEFAULT scantok term */ |
| 160144 | | - 212, /* (32) ccons ::= DEFAULT LP expr RP */ |
| 160145 | | - 212, /* (33) ccons ::= DEFAULT PLUS scantok term */ |
| 160146 | | - 212, /* (34) ccons ::= DEFAULT MINUS scantok term */ |
| 160147 | | - 212, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */ |
| 160148 | | - 212, /* (36) ccons ::= NOT NULL onconf */ |
| 160149 | | - 212, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 160150 | | - 212, /* (38) ccons ::= UNIQUE onconf */ |
| 160151 | | - 212, /* (39) ccons ::= CHECK LP expr RP */ |
| 160152 | | - 212, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 160153 | | - 212, /* (41) ccons ::= defer_subclause */ |
| 160154 | | - 212, /* (42) ccons ::= COLLATE ID|STRING */ |
| 160155 | | - 221, /* (43) generated ::= LP expr RP */ |
| 160156 | | - 221, /* (44) generated ::= LP expr RP ID */ |
| 160157 | | - 217, /* (45) autoinc ::= */ |
| 160158 | | - 217, /* (46) autoinc ::= AUTOINCR */ |
| 160159 | | - 219, /* (47) refargs ::= */ |
| 160160 | | - 219, /* (48) refargs ::= refargs refarg */ |
| 160161 | | - 222, /* (49) refarg ::= MATCH nm */ |
| 160162 | | - 222, /* (50) refarg ::= ON INSERT refact */ |
| 160163 | | - 222, /* (51) refarg ::= ON DELETE refact */ |
| 160164 | | - 222, /* (52) refarg ::= ON UPDATE refact */ |
| 160165 | | - 223, /* (53) refact ::= SET NULL */ |
| 160166 | | - 223, /* (54) refact ::= SET DEFAULT */ |
| 160167 | | - 223, /* (55) refact ::= CASCADE */ |
| 160168 | | - 223, /* (56) refact ::= RESTRICT */ |
| 160169 | | - 223, /* (57) refact ::= NO ACTION */ |
| 160170 | | - 220, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 160171 | | - 220, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 160172 | | - 224, /* (60) init_deferred_pred_opt ::= */ |
| 160173 | | - 224, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 160174 | | - 224, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 160175 | | - 200, /* (63) conslist_opt ::= */ |
| 160176 | | - 226, /* (64) tconscomma ::= COMMA */ |
| 160177 | | - 227, /* (65) tcons ::= CONSTRAINT nm */ |
| 160178 | | - 227, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 160179 | | - 227, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */ |
| 160180 | | - 227, /* (68) tcons ::= CHECK LP expr RP onconf */ |
| 160181 | | - 227, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 160182 | | - 230, /* (70) defer_subclause_opt ::= */ |
| 160183 | | - 215, /* (71) onconf ::= */ |
| 160184 | | - 215, /* (72) onconf ::= ON CONFLICT resolvetype */ |
| 160185 | | - 231, /* (73) orconf ::= */ |
| 160186 | | - 231, /* (74) orconf ::= OR resolvetype */ |
| 160187 | | - 232, /* (75) resolvetype ::= IGNORE */ |
| 160188 | | - 232, /* (76) resolvetype ::= REPLACE */ |
| 160189 | | - 188, /* (77) cmd ::= DROP TABLE ifexists fullname */ |
| 160190 | | - 234, /* (78) ifexists ::= IF EXISTS */ |
| 160191 | | - 234, /* (79) ifexists ::= */ |
| 160192 | | - 188, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 160193 | | - 188, /* (81) cmd ::= DROP VIEW ifexists fullname */ |
| 160194 | | - 188, /* (82) cmd ::= select */ |
| 160195 | | - 202, /* (83) select ::= WITH wqlist selectnowith */ |
| 160196 | | - 202, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */ |
| 160197 | | - 202, /* (85) select ::= selectnowith */ |
| 160198 | | - 236, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */ |
| 160199 | | - 239, /* (87) multiselect_op ::= UNION */ |
| 160200 | | - 239, /* (88) multiselect_op ::= UNION ALL */ |
| 160201 | | - 239, /* (89) multiselect_op ::= EXCEPT|INTERSECT */ |
| 160202 | | - 237, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 160203 | | - 237, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ |
| 160204 | | - 249, /* (92) values ::= VALUES LP nexprlist RP */ |
| 160205 | | - 249, /* (93) values ::= values COMMA LP nexprlist RP */ |
| 160206 | | - 240, /* (94) distinct ::= DISTINCT */ |
| 160207 | | - 240, /* (95) distinct ::= ALL */ |
| 160208 | | - 240, /* (96) distinct ::= */ |
| 160209 | | - 251, /* (97) sclp ::= */ |
| 160210 | | - 241, /* (98) selcollist ::= sclp scanpt expr scanpt as */ |
| 160211 | | - 241, /* (99) selcollist ::= sclp scanpt STAR */ |
| 160212 | | - 241, /* (100) selcollist ::= sclp scanpt nm DOT STAR */ |
| 160213 | | - 252, /* (101) as ::= AS nm */ |
| 160214 | | - 252, /* (102) as ::= */ |
| 160215 | | - 242, /* (103) from ::= */ |
| 160216 | | - 242, /* (104) from ::= FROM seltablist */ |
| 160217 | | - 254, /* (105) stl_prefix ::= seltablist joinop */ |
| 160218 | | - 254, /* (106) stl_prefix ::= */ |
| 160219 | | - 253, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 160220 | | - 253, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 160221 | | - 253, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 160222 | | - 253, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 160223 | | - 198, /* (111) dbnm ::= */ |
| 160224 | | - 198, /* (112) dbnm ::= DOT nm */ |
| 160225 | | - 235, /* (113) fullname ::= nm */ |
| 160226 | | - 235, /* (114) fullname ::= nm DOT nm */ |
| 160227 | | - 260, /* (115) xfullname ::= nm */ |
| 160228 | | - 260, /* (116) xfullname ::= nm DOT nm */ |
| 160229 | | - 260, /* (117) xfullname ::= nm DOT nm AS nm */ |
| 160230 | | - 260, /* (118) xfullname ::= nm AS nm */ |
| 160231 | | - 255, /* (119) joinop ::= COMMA|JOIN */ |
| 160232 | | - 255, /* (120) joinop ::= JOIN_KW JOIN */ |
| 160233 | | - 255, /* (121) joinop ::= JOIN_KW nm JOIN */ |
| 160234 | | - 255, /* (122) joinop ::= JOIN_KW nm nm JOIN */ |
| 160235 | | - 257, /* (123) on_opt ::= ON expr */ |
| 160236 | | - 257, /* (124) on_opt ::= */ |
| 160237 | | - 256, /* (125) indexed_opt ::= */ |
| 160238 | | - 256, /* (126) indexed_opt ::= INDEXED BY nm */ |
| 160239 | | - 256, /* (127) indexed_opt ::= NOT INDEXED */ |
| 160240 | | - 258, /* (128) using_opt ::= USING LP idlist RP */ |
| 160241 | | - 258, /* (129) using_opt ::= */ |
| 160242 | | - 246, /* (130) orderby_opt ::= */ |
| 160243 | | - 246, /* (131) orderby_opt ::= ORDER BY sortlist */ |
| 160244 | | - 228, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 160245 | | - 228, /* (133) sortlist ::= expr sortorder nulls */ |
| 160246 | | - 216, /* (134) sortorder ::= ASC */ |
| 160247 | | - 216, /* (135) sortorder ::= DESC */ |
| 160248 | | - 216, /* (136) sortorder ::= */ |
| 160249 | | - 262, /* (137) nulls ::= NULLS FIRST */ |
| 160250 | | - 262, /* (138) nulls ::= NULLS LAST */ |
| 160251 | | - 262, /* (139) nulls ::= */ |
| 160252 | | - 244, /* (140) groupby_opt ::= */ |
| 160253 | | - 244, /* (141) groupby_opt ::= GROUP BY nexprlist */ |
| 160254 | | - 245, /* (142) having_opt ::= */ |
| 160255 | | - 245, /* (143) having_opt ::= HAVING expr */ |
| 160256 | | - 247, /* (144) limit_opt ::= */ |
| 160257 | | - 247, /* (145) limit_opt ::= LIMIT expr */ |
| 160258 | | - 247, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ |
| 160259 | | - 247, /* (147) limit_opt ::= LIMIT expr COMMA expr */ |
| 160260 | | - 188, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 160261 | | - 243, /* (149) where_opt ::= */ |
| 160262 | | - 243, /* (150) where_opt ::= WHERE expr */ |
| 160263 | | - 264, /* (151) where_opt_ret ::= */ |
| 160264 | | - 264, /* (152) where_opt_ret ::= WHERE expr */ |
| 160265 | | - 264, /* (153) where_opt_ret ::= RETURNING selcollist */ |
| 160266 | | - 264, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */ |
| 160267 | | - 188, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ |
| 160268 | | - 265, /* (156) setlist ::= setlist COMMA nm EQ expr */ |
| 160269 | | - 265, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 160270 | | - 265, /* (158) setlist ::= nm EQ expr */ |
| 160271 | | - 265, /* (159) setlist ::= LP idlist RP EQ expr */ |
| 160272 | | - 188, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 160273 | | - 188, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 160274 | | - 268, /* (162) upsert ::= */ |
| 160275 | | - 268, /* (163) upsert ::= RETURNING selcollist */ |
| 160276 | | - 268, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ |
| 160277 | | - 268, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 160278 | | - 268, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */ |
| 160279 | | - 268, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 160280 | | - 269, /* (168) returning ::= RETURNING selcollist */ |
| 160281 | | - 266, /* (169) insert_cmd ::= INSERT orconf */ |
| 160282 | | - 266, /* (170) insert_cmd ::= REPLACE */ |
| 160283 | | - 267, /* (171) idlist_opt ::= */ |
| 160284 | | - 267, /* (172) idlist_opt ::= LP idlist RP */ |
| 160285 | | - 261, /* (173) idlist ::= idlist COMMA nm */ |
| 160286 | | - 261, /* (174) idlist ::= nm */ |
| 160287 | | - 214, /* (175) expr ::= LP expr RP */ |
| 160288 | | - 214, /* (176) expr ::= ID|INDEXED */ |
| 160289 | | - 214, /* (177) expr ::= JOIN_KW */ |
| 160290 | | - 214, /* (178) expr ::= nm DOT nm */ |
| 160291 | | - 214, /* (179) expr ::= nm DOT nm DOT nm */ |
| 160292 | | - 213, /* (180) term ::= NULL|FLOAT|BLOB */ |
| 160293 | | - 213, /* (181) term ::= STRING */ |
| 160294 | | - 213, /* (182) term ::= INTEGER */ |
| 160295 | | - 214, /* (183) expr ::= VARIABLE */ |
| 160296 | | - 214, /* (184) expr ::= expr COLLATE ID|STRING */ |
| 160297 | | - 214, /* (185) expr ::= CAST LP expr AS typetoken RP */ |
| 160298 | | - 214, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 160299 | | - 214, /* (187) expr ::= ID|INDEXED LP STAR RP */ |
| 160300 | | - 214, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ |
| 160301 | | - 214, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */ |
| 160302 | | - 213, /* (190) term ::= CTIME_KW */ |
| 160303 | | - 214, /* (191) expr ::= LP nexprlist COMMA expr RP */ |
| 160304 | | - 214, /* (192) expr ::= expr AND expr */ |
| 160305 | | - 214, /* (193) expr ::= expr OR expr */ |
| 160306 | | - 214, /* (194) expr ::= expr LT|GT|GE|LE expr */ |
| 160307 | | - 214, /* (195) expr ::= expr EQ|NE expr */ |
| 160308 | | - 214, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 160309 | | - 214, /* (197) expr ::= expr PLUS|MINUS expr */ |
| 160310 | | - 214, /* (198) expr ::= expr STAR|SLASH|REM expr */ |
| 160311 | | - 214, /* (199) expr ::= expr CONCAT expr */ |
| 160312 | | - 271, /* (200) likeop ::= NOT LIKE_KW|MATCH */ |
| 160313 | | - 214, /* (201) expr ::= expr likeop expr */ |
| 160314 | | - 214, /* (202) expr ::= expr likeop expr ESCAPE expr */ |
| 160315 | | - 214, /* (203) expr ::= expr ISNULL|NOTNULL */ |
| 160316 | | - 214, /* (204) expr ::= expr NOT NULL */ |
| 160317 | | - 214, /* (205) expr ::= expr IS expr */ |
| 160318 | | - 214, /* (206) expr ::= expr IS NOT expr */ |
| 160319 | | - 214, /* (207) expr ::= NOT expr */ |
| 160320 | | - 214, /* (208) expr ::= BITNOT expr */ |
| 160321 | | - 214, /* (209) expr ::= PLUS|MINUS expr */ |
| 160322 | | - 272, /* (210) between_op ::= BETWEEN */ |
| 160323 | | - 272, /* (211) between_op ::= NOT BETWEEN */ |
| 160324 | | - 214, /* (212) expr ::= expr between_op expr AND expr */ |
| 160325 | | - 273, /* (213) in_op ::= IN */ |
| 160326 | | - 273, /* (214) in_op ::= NOT IN */ |
| 160327 | | - 214, /* (215) expr ::= expr in_op LP exprlist RP */ |
| 160328 | | - 214, /* (216) expr ::= LP select RP */ |
| 160329 | | - 214, /* (217) expr ::= expr in_op LP select RP */ |
| 160330 | | - 214, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 160331 | | - 214, /* (219) expr ::= EXISTS LP select RP */ |
| 160332 | | - 214, /* (220) expr ::= CASE case_operand case_exprlist case_else END */ |
| 160333 | | - 276, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 160334 | | - 276, /* (222) case_exprlist ::= WHEN expr THEN expr */ |
| 160335 | | - 277, /* (223) case_else ::= ELSE expr */ |
| 160336 | | - 277, /* (224) case_else ::= */ |
| 160337 | | - 275, /* (225) case_operand ::= expr */ |
| 160338 | | - 275, /* (226) case_operand ::= */ |
| 160339 | | - 259, /* (227) exprlist ::= */ |
| 160340 | | - 250, /* (228) nexprlist ::= nexprlist COMMA expr */ |
| 160341 | | - 250, /* (229) nexprlist ::= expr */ |
| 160342 | | - 274, /* (230) paren_exprlist ::= */ |
| 160343 | | - 274, /* (231) paren_exprlist ::= LP exprlist RP */ |
| 160344 | | - 188, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 160345 | | - 278, /* (233) uniqueflag ::= UNIQUE */ |
| 160346 | | - 278, /* (234) uniqueflag ::= */ |
| 160347 | | - 218, /* (235) eidlist_opt ::= */ |
| 160348 | | - 218, /* (236) eidlist_opt ::= LP eidlist RP */ |
| 160349 | | - 229, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 160350 | | - 229, /* (238) eidlist ::= nm collate sortorder */ |
| 160351 | | - 279, /* (239) collate ::= */ |
| 160352 | | - 279, /* (240) collate ::= COLLATE ID|STRING */ |
| 160353 | | - 188, /* (241) cmd ::= DROP INDEX ifexists fullname */ |
| 160354 | | - 188, /* (242) cmd ::= VACUUM vinto */ |
| 160355 | | - 188, /* (243) cmd ::= VACUUM nm vinto */ |
| 160356 | | - 280, /* (244) vinto ::= INTO expr */ |
| 160357 | | - 280, /* (245) vinto ::= */ |
| 160358 | | - 188, /* (246) cmd ::= PRAGMA nm dbnm */ |
| 160359 | | - 188, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 160360 | | - 188, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 160361 | | - 188, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 160362 | | - 188, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 160363 | | - 208, /* (251) plus_num ::= PLUS INTEGER|FLOAT */ |
| 160364 | | - 209, /* (252) minus_num ::= MINUS INTEGER|FLOAT */ |
| 160365 | | - 188, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 160366 | | - 282, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 160367 | | - 284, /* (255) trigger_time ::= BEFORE|AFTER */ |
| 160368 | | - 284, /* (256) trigger_time ::= INSTEAD OF */ |
| 160369 | | - 284, /* (257) trigger_time ::= */ |
| 160370 | | - 285, /* (258) trigger_event ::= DELETE|INSERT */ |
| 160371 | | - 285, /* (259) trigger_event ::= UPDATE */ |
| 160372 | | - 285, /* (260) trigger_event ::= UPDATE OF idlist */ |
| 160373 | | - 287, /* (261) when_clause ::= */ |
| 160374 | | - 287, /* (262) when_clause ::= WHEN expr */ |
| 160375 | | - 283, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 160376 | | - 283, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 160377 | | - 289, /* (265) trnm ::= nm DOT nm */ |
| 160378 | | - 290, /* (266) tridxby ::= INDEXED BY nm */ |
| 160379 | | - 290, /* (267) tridxby ::= NOT INDEXED */ |
| 160380 | | - 288, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 160381 | | - 288, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 160382 | | - 288, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 160383 | | - 288, /* (271) trigger_cmd ::= scanpt select scanpt */ |
| 160384 | | - 214, /* (272) expr ::= RAISE LP IGNORE RP */ |
| 160385 | | - 214, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 160386 | | - 233, /* (274) raisetype ::= ROLLBACK */ |
| 160387 | | - 233, /* (275) raisetype ::= ABORT */ |
| 160388 | | - 233, /* (276) raisetype ::= FAIL */ |
| 160389 | | - 188, /* (277) cmd ::= DROP TRIGGER ifexists fullname */ |
| 160390 | | - 188, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 160391 | | - 188, /* (279) cmd ::= DETACH database_kw_opt expr */ |
| 160392 | | - 292, /* (280) key_opt ::= */ |
| 160393 | | - 292, /* (281) key_opt ::= KEY expr */ |
| 160394 | | - 188, /* (282) cmd ::= REINDEX */ |
| 160395 | | - 188, /* (283) cmd ::= REINDEX nm dbnm */ |
| 160396 | | - 188, /* (284) cmd ::= ANALYZE */ |
| 160397 | | - 188, /* (285) cmd ::= ANALYZE nm dbnm */ |
| 160398 | | - 188, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 160399 | | - 188, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 160400 | | - 188, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 160401 | | - 293, /* (289) add_column_fullname ::= fullname */ |
| 160402 | | - 188, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 160403 | | - 188, /* (291) cmd ::= create_vtab */ |
| 160404 | | - 188, /* (292) cmd ::= create_vtab LP vtabarglist RP */ |
| 160405 | | - 295, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 160406 | | - 297, /* (294) vtabarg ::= */ |
| 160407 | | - 298, /* (295) vtabargtoken ::= ANY */ |
| 160408 | | - 298, /* (296) vtabargtoken ::= lp anylist RP */ |
| 160409 | | - 299, /* (297) lp ::= LP */ |
| 160410 | | - 263, /* (298) with ::= WITH wqlist */ |
| 160411 | | - 263, /* (299) with ::= WITH RECURSIVE wqlist */ |
| 160412 | | - 302, /* (300) wqas ::= AS */ |
| 160413 | | - 302, /* (301) wqas ::= AS MATERIALIZED */ |
| 160414 | | - 302, /* (302) wqas ::= AS NOT MATERIALIZED */ |
| 160415 | | - 301, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 160416 | | - 238, /* (304) wqlist ::= wqitem */ |
| 160417 | | - 238, /* (305) wqlist ::= wqlist COMMA wqitem */ |
| 160418 | | - 303, /* (306) windowdefn_list ::= windowdefn */ |
| 160419 | | - 303, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 160420 | | - 304, /* (308) windowdefn ::= nm AS LP window RP */ |
| 160421 | | - 305, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 160422 | | - 305, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 160423 | | - 305, /* (311) window ::= ORDER BY sortlist frame_opt */ |
| 160424 | | - 305, /* (312) window ::= nm ORDER BY sortlist frame_opt */ |
| 160425 | | - 305, /* (313) window ::= frame_opt */ |
| 160426 | | - 305, /* (314) window ::= nm frame_opt */ |
| 160427 | | - 306, /* (315) frame_opt ::= */ |
| 160428 | | - 306, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 160429 | | - 306, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 160430 | | - 310, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 160431 | | - 312, /* (319) frame_bound_s ::= frame_bound */ |
| 160432 | | - 312, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 160433 | | - 313, /* (321) frame_bound_e ::= frame_bound */ |
| 160434 | | - 313, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 160435 | | - 311, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 160436 | | - 311, /* (324) frame_bound ::= CURRENT ROW */ |
| 160437 | | - 314, /* (325) frame_exclude_opt ::= */ |
| 160438 | | - 314, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 160439 | | - 315, /* (327) frame_exclude ::= NO OTHERS */ |
| 160440 | | - 315, /* (328) frame_exclude ::= CURRENT ROW */ |
| 160441 | | - 315, /* (329) frame_exclude ::= GROUP|TIES */ |
| 160442 | | - 248, /* (330) window_clause ::= WINDOW windowdefn_list */ |
| 160443 | | - 270, /* (331) filter_over ::= filter_clause over_clause */ |
| 160444 | | - 270, /* (332) filter_over ::= over_clause */ |
| 160445 | | - 270, /* (333) filter_over ::= filter_clause */ |
| 160446 | | - 309, /* (334) over_clause ::= OVER LP window RP */ |
| 160447 | | - 309, /* (335) over_clause ::= OVER nm */ |
| 160448 | | - 308, /* (336) filter_clause ::= FILTER LP WHERE expr RP */ |
| 160449 | | - 183, /* (337) input ::= cmdlist */ |
| 160450 | | - 184, /* (338) cmdlist ::= cmdlist ecmd */ |
| 160451 | | - 184, /* (339) cmdlist ::= ecmd */ |
| 160452 | | - 185, /* (340) ecmd ::= SEMI */ |
| 160453 | | - 185, /* (341) ecmd ::= cmdx SEMI */ |
| 160454 | | - 185, /* (342) ecmd ::= explain cmdx SEMI */ |
| 160455 | | - 190, /* (343) trans_opt ::= */ |
| 160456 | | - 190, /* (344) trans_opt ::= TRANSACTION */ |
| 160457 | | - 190, /* (345) trans_opt ::= TRANSACTION nm */ |
| 160458 | | - 192, /* (346) savepoint_opt ::= SAVEPOINT */ |
| 160459 | | - 192, /* (347) savepoint_opt ::= */ |
| 160460 | | - 188, /* (348) cmd ::= create_table create_table_args */ |
| 160461 | | - 199, /* (349) columnlist ::= columnlist COMMA columnname carglist */ |
| 160462 | | - 199, /* (350) columnlist ::= columnname carglist */ |
| 160463 | | - 191, /* (351) nm ::= ID|INDEXED */ |
| 160464 | | - 191, /* (352) nm ::= STRING */ |
| 160465 | | - 191, /* (353) nm ::= JOIN_KW */ |
| 160466 | | - 205, /* (354) typetoken ::= typename */ |
| 160467 | | - 206, /* (355) typename ::= ID|STRING */ |
| 160468 | | - 207, /* (356) signed ::= plus_num */ |
| 160469 | | - 207, /* (357) signed ::= minus_num */ |
| 160470 | | - 204, /* (358) carglist ::= carglist ccons */ |
| 160471 | | - 204, /* (359) carglist ::= */ |
| 160472 | | - 212, /* (360) ccons ::= NULL onconf */ |
| 160473 | | - 212, /* (361) ccons ::= GENERATED ALWAYS AS generated */ |
| 160474 | | - 212, /* (362) ccons ::= AS generated */ |
| 160475 | | - 200, /* (363) conslist_opt ::= COMMA conslist */ |
| 160476 | | - 225, /* (364) conslist ::= conslist tconscomma tcons */ |
| 160477 | | - 225, /* (365) conslist ::= tcons */ |
| 160478 | | - 226, /* (366) tconscomma ::= */ |
| 160479 | | - 230, /* (367) defer_subclause_opt ::= defer_subclause */ |
| 160480 | | - 232, /* (368) resolvetype ::= raisetype */ |
| 160481 | | - 236, /* (369) selectnowith ::= oneselect */ |
| 160482 | | - 237, /* (370) oneselect ::= values */ |
| 160483 | | - 251, /* (371) sclp ::= selcollist COMMA */ |
| 160484 | | - 252, /* (372) as ::= ID|STRING */ |
| 160485 | | - 269, /* (373) returning ::= */ |
| 160486 | | - 214, /* (374) expr ::= term */ |
| 160487 | | - 271, /* (375) likeop ::= LIKE_KW|MATCH */ |
| 160488 | | - 259, /* (376) exprlist ::= nexprlist */ |
| 160489 | | - 281, /* (377) nmnum ::= plus_num */ |
| 160490 | | - 281, /* (378) nmnum ::= nm */ |
| 160491 | | - 281, /* (379) nmnum ::= ON */ |
| 160492 | | - 281, /* (380) nmnum ::= DELETE */ |
| 160493 | | - 281, /* (381) nmnum ::= DEFAULT */ |
| 160494 | | - 208, /* (382) plus_num ::= INTEGER|FLOAT */ |
| 160495 | | - 286, /* (383) foreach_clause ::= */ |
| 160496 | | - 286, /* (384) foreach_clause ::= FOR EACH ROW */ |
| 160497 | | - 289, /* (385) trnm ::= nm */ |
| 160498 | | - 290, /* (386) tridxby ::= */ |
| 160499 | | - 291, /* (387) database_kw_opt ::= DATABASE */ |
| 160500 | | - 291, /* (388) database_kw_opt ::= */ |
| 160501 | | - 294, /* (389) kwcolumn_opt ::= */ |
| 160502 | | - 294, /* (390) kwcolumn_opt ::= COLUMNKW */ |
| 160503 | | - 296, /* (391) vtabarglist ::= vtabarg */ |
| 160504 | | - 296, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 160505 | | - 297, /* (393) vtabarg ::= vtabarg vtabargtoken */ |
| 160506 | | - 300, /* (394) anylist ::= */ |
| 160507 | | - 300, /* (395) anylist ::= anylist LP anylist RP */ |
| 160508 | | - 300, /* (396) anylist ::= anylist ANY */ |
| 160509 | | - 263, /* (397) with ::= */ |
| 160691 | + 188, /* (0) explain ::= EXPLAIN */ |
| 160692 | + 188, /* (1) explain ::= EXPLAIN QUERY PLAN */ |
| 160693 | + 187, /* (2) cmdx ::= cmd */ |
| 160694 | + 189, /* (3) cmd ::= BEGIN transtype trans_opt */ |
| 160695 | + 190, /* (4) transtype ::= */ |
| 160696 | + 190, /* (5) transtype ::= DEFERRED */ |
| 160697 | + 190, /* (6) transtype ::= IMMEDIATE */ |
| 160698 | + 190, /* (7) transtype ::= EXCLUSIVE */ |
| 160699 | + 189, /* (8) cmd ::= COMMIT|END trans_opt */ |
| 160700 | + 189, /* (9) cmd ::= ROLLBACK trans_opt */ |
| 160701 | + 189, /* (10) cmd ::= SAVEPOINT nm */ |
| 160702 | + 189, /* (11) cmd ::= RELEASE savepoint_opt nm */ |
| 160703 | + 189, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ |
| 160704 | + 194, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 160705 | + 196, /* (14) createkw ::= CREATE */ |
| 160706 | + 198, /* (15) ifnotexists ::= */ |
| 160707 | + 198, /* (16) ifnotexists ::= IF NOT EXISTS */ |
| 160708 | + 197, /* (17) temp ::= TEMP */ |
| 160709 | + 197, /* (18) temp ::= */ |
| 160710 | + 195, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ |
| 160711 | + 195, /* (20) create_table_args ::= AS select */ |
| 160712 | + 202, /* (21) table_options ::= */ |
| 160713 | + 202, /* (22) table_options ::= WITHOUT nm */ |
| 160714 | + 204, /* (23) columnname ::= nm typetoken */ |
| 160715 | + 206, /* (24) typetoken ::= */ |
| 160716 | + 206, /* (25) typetoken ::= typename LP signed RP */ |
| 160717 | + 206, /* (26) typetoken ::= typename LP signed COMMA signed RP */ |
| 160718 | + 207, /* (27) typename ::= typename ID|STRING */ |
| 160719 | + 211, /* (28) scanpt ::= */ |
| 160720 | + 212, /* (29) scantok ::= */ |
| 160721 | + 213, /* (30) ccons ::= CONSTRAINT nm */ |
| 160722 | + 213, /* (31) ccons ::= DEFAULT scantok term */ |
| 160723 | + 213, /* (32) ccons ::= DEFAULT LP expr RP */ |
| 160724 | + 213, /* (33) ccons ::= DEFAULT PLUS scantok term */ |
| 160725 | + 213, /* (34) ccons ::= DEFAULT MINUS scantok term */ |
| 160726 | + 213, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */ |
| 160727 | + 213, /* (36) ccons ::= NOT NULL onconf */ |
| 160728 | + 213, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 160729 | + 213, /* (38) ccons ::= UNIQUE onconf */ |
| 160730 | + 213, /* (39) ccons ::= CHECK LP expr RP */ |
| 160731 | + 213, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 160732 | + 213, /* (41) ccons ::= defer_subclause */ |
| 160733 | + 213, /* (42) ccons ::= COLLATE ID|STRING */ |
| 160734 | + 222, /* (43) generated ::= LP expr RP */ |
| 160735 | + 222, /* (44) generated ::= LP expr RP ID */ |
| 160736 | + 218, /* (45) autoinc ::= */ |
| 160737 | + 218, /* (46) autoinc ::= AUTOINCR */ |
| 160738 | + 220, /* (47) refargs ::= */ |
| 160739 | + 220, /* (48) refargs ::= refargs refarg */ |
| 160740 | + 223, /* (49) refarg ::= MATCH nm */ |
| 160741 | + 223, /* (50) refarg ::= ON INSERT refact */ |
| 160742 | + 223, /* (51) refarg ::= ON DELETE refact */ |
| 160743 | + 223, /* (52) refarg ::= ON UPDATE refact */ |
| 160744 | + 224, /* (53) refact ::= SET NULL */ |
| 160745 | + 224, /* (54) refact ::= SET DEFAULT */ |
| 160746 | + 224, /* (55) refact ::= CASCADE */ |
| 160747 | + 224, /* (56) refact ::= RESTRICT */ |
| 160748 | + 224, /* (57) refact ::= NO ACTION */ |
| 160749 | + 221, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 160750 | + 221, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 160751 | + 225, /* (60) init_deferred_pred_opt ::= */ |
| 160752 | + 225, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 160753 | + 225, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 160754 | + 201, /* (63) conslist_opt ::= */ |
| 160755 | + 227, /* (64) tconscomma ::= COMMA */ |
| 160756 | + 228, /* (65) tcons ::= CONSTRAINT nm */ |
| 160757 | + 228, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 160758 | + 228, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */ |
| 160759 | + 228, /* (68) tcons ::= CHECK LP expr RP onconf */ |
| 160760 | + 228, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 160761 | + 231, /* (70) defer_subclause_opt ::= */ |
| 160762 | + 216, /* (71) onconf ::= */ |
| 160763 | + 216, /* (72) onconf ::= ON CONFLICT resolvetype */ |
| 160764 | + 232, /* (73) orconf ::= */ |
| 160765 | + 232, /* (74) orconf ::= OR resolvetype */ |
| 160766 | + 233, /* (75) resolvetype ::= IGNORE */ |
| 160767 | + 233, /* (76) resolvetype ::= REPLACE */ |
| 160768 | + 189, /* (77) cmd ::= DROP TABLE ifexists fullname */ |
| 160769 | + 235, /* (78) ifexists ::= IF EXISTS */ |
| 160770 | + 235, /* (79) ifexists ::= */ |
| 160771 | + 189, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 160772 | + 189, /* (81) cmd ::= DROP VIEW ifexists fullname */ |
| 160773 | + 189, /* (82) cmd ::= select */ |
| 160774 | + 203, /* (83) select ::= WITH wqlist selectnowith */ |
| 160775 | + 203, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */ |
| 160776 | + 203, /* (85) select ::= selectnowith */ |
| 160777 | + 237, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */ |
| 160778 | + 240, /* (87) multiselect_op ::= UNION */ |
| 160779 | + 240, /* (88) multiselect_op ::= UNION ALL */ |
| 160780 | + 240, /* (89) multiselect_op ::= EXCEPT|INTERSECT */ |
| 160781 | + 238, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 160782 | + 238, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ |
| 160783 | + 250, /* (92) values ::= VALUES LP nexprlist RP */ |
| 160784 | + 250, /* (93) values ::= values COMMA LP nexprlist RP */ |
| 160785 | + 241, /* (94) distinct ::= DISTINCT */ |
| 160786 | + 241, /* (95) distinct ::= ALL */ |
| 160787 | + 241, /* (96) distinct ::= */ |
| 160788 | + 252, /* (97) sclp ::= */ |
| 160789 | + 242, /* (98) selcollist ::= sclp scanpt expr scanpt as */ |
| 160790 | + 242, /* (99) selcollist ::= sclp scanpt STAR */ |
| 160791 | + 242, /* (100) selcollist ::= sclp scanpt nm DOT STAR */ |
| 160792 | + 253, /* (101) as ::= AS nm */ |
| 160793 | + 253, /* (102) as ::= */ |
| 160794 | + 243, /* (103) from ::= */ |
| 160795 | + 243, /* (104) from ::= FROM seltablist */ |
| 160796 | + 255, /* (105) stl_prefix ::= seltablist joinop */ |
| 160797 | + 255, /* (106) stl_prefix ::= */ |
| 160798 | + 254, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 160799 | + 254, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 160800 | + 254, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 160801 | + 254, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 160802 | + 199, /* (111) dbnm ::= */ |
| 160803 | + 199, /* (112) dbnm ::= DOT nm */ |
| 160804 | + 236, /* (113) fullname ::= nm */ |
| 160805 | + 236, /* (114) fullname ::= nm DOT nm */ |
| 160806 | + 261, /* (115) xfullname ::= nm */ |
| 160807 | + 261, /* (116) xfullname ::= nm DOT nm */ |
| 160808 | + 261, /* (117) xfullname ::= nm DOT nm AS nm */ |
| 160809 | + 261, /* (118) xfullname ::= nm AS nm */ |
| 160810 | + 256, /* (119) joinop ::= COMMA|JOIN */ |
| 160811 | + 256, /* (120) joinop ::= JOIN_KW JOIN */ |
| 160812 | + 256, /* (121) joinop ::= JOIN_KW nm JOIN */ |
| 160813 | + 256, /* (122) joinop ::= JOIN_KW nm nm JOIN */ |
| 160814 | + 258, /* (123) on_opt ::= ON expr */ |
| 160815 | + 258, /* (124) on_opt ::= */ |
| 160816 | + 257, /* (125) indexed_opt ::= */ |
| 160817 | + 257, /* (126) indexed_opt ::= INDEXED BY nm */ |
| 160818 | + 257, /* (127) indexed_opt ::= NOT INDEXED */ |
| 160819 | + 259, /* (128) using_opt ::= USING LP idlist RP */ |
| 160820 | + 259, /* (129) using_opt ::= */ |
| 160821 | + 247, /* (130) orderby_opt ::= */ |
| 160822 | + 247, /* (131) orderby_opt ::= ORDER BY sortlist */ |
| 160823 | + 229, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 160824 | + 229, /* (133) sortlist ::= expr sortorder nulls */ |
| 160825 | + 217, /* (134) sortorder ::= ASC */ |
| 160826 | + 217, /* (135) sortorder ::= DESC */ |
| 160827 | + 217, /* (136) sortorder ::= */ |
| 160828 | + 263, /* (137) nulls ::= NULLS FIRST */ |
| 160829 | + 263, /* (138) nulls ::= NULLS LAST */ |
| 160830 | + 263, /* (139) nulls ::= */ |
| 160831 | + 245, /* (140) groupby_opt ::= */ |
| 160832 | + 245, /* (141) groupby_opt ::= GROUP BY nexprlist */ |
| 160833 | + 246, /* (142) having_opt ::= */ |
| 160834 | + 246, /* (143) having_opt ::= HAVING expr */ |
| 160835 | + 248, /* (144) limit_opt ::= */ |
| 160836 | + 248, /* (145) limit_opt ::= LIMIT expr */ |
| 160837 | + 248, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ |
| 160838 | + 248, /* (147) limit_opt ::= LIMIT expr COMMA expr */ |
| 160839 | + 189, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 160840 | + 244, /* (149) where_opt ::= */ |
| 160841 | + 244, /* (150) where_opt ::= WHERE expr */ |
| 160842 | + 265, /* (151) where_opt_ret ::= */ |
| 160843 | + 265, /* (152) where_opt_ret ::= WHERE expr */ |
| 160844 | + 265, /* (153) where_opt_ret ::= RETURNING selcollist */ |
| 160845 | + 265, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */ |
| 160846 | + 189, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ |
| 160847 | + 266, /* (156) setlist ::= setlist COMMA nm EQ expr */ |
| 160848 | + 266, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 160849 | + 266, /* (158) setlist ::= nm EQ expr */ |
| 160850 | + 266, /* (159) setlist ::= LP idlist RP EQ expr */ |
| 160851 | + 189, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 160852 | + 189, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 160853 | + 269, /* (162) upsert ::= */ |
| 160854 | + 269, /* (163) upsert ::= RETURNING selcollist */ |
| 160855 | + 269, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ |
| 160856 | + 269, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 160857 | + 269, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */ |
| 160858 | + 269, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 160859 | + 270, /* (168) returning ::= RETURNING selcollist */ |
| 160860 | + 267, /* (169) insert_cmd ::= INSERT orconf */ |
| 160861 | + 267, /* (170) insert_cmd ::= REPLACE */ |
| 160862 | + 268, /* (171) idlist_opt ::= */ |
| 160863 | + 268, /* (172) idlist_opt ::= LP idlist RP */ |
| 160864 | + 262, /* (173) idlist ::= idlist COMMA nm */ |
| 160865 | + 262, /* (174) idlist ::= nm */ |
| 160866 | + 215, /* (175) expr ::= LP expr RP */ |
| 160867 | + 215, /* (176) expr ::= ID|INDEXED */ |
| 160868 | + 215, /* (177) expr ::= JOIN_KW */ |
| 160869 | + 215, /* (178) expr ::= nm DOT nm */ |
| 160870 | + 215, /* (179) expr ::= nm DOT nm DOT nm */ |
| 160871 | + 214, /* (180) term ::= NULL|FLOAT|BLOB */ |
| 160872 | + 214, /* (181) term ::= STRING */ |
| 160873 | + 214, /* (182) term ::= INTEGER */ |
| 160874 | + 215, /* (183) expr ::= VARIABLE */ |
| 160875 | + 215, /* (184) expr ::= expr COLLATE ID|STRING */ |
| 160876 | + 215, /* (185) expr ::= CAST LP expr AS typetoken RP */ |
| 160877 | + 215, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 160878 | + 215, /* (187) expr ::= ID|INDEXED LP STAR RP */ |
| 160879 | + 215, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ |
| 160880 | + 215, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */ |
| 160881 | + 214, /* (190) term ::= CTIME_KW */ |
| 160882 | + 215, /* (191) expr ::= LP nexprlist COMMA expr RP */ |
| 160883 | + 215, /* (192) expr ::= expr AND expr */ |
| 160884 | + 215, /* (193) expr ::= expr OR expr */ |
| 160885 | + 215, /* (194) expr ::= expr LT|GT|GE|LE expr */ |
| 160886 | + 215, /* (195) expr ::= expr EQ|NE expr */ |
| 160887 | + 215, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 160888 | + 215, /* (197) expr ::= expr PLUS|MINUS expr */ |
| 160889 | + 215, /* (198) expr ::= expr STAR|SLASH|REM expr */ |
| 160890 | + 215, /* (199) expr ::= expr CONCAT expr */ |
| 160891 | + 272, /* (200) likeop ::= NOT LIKE_KW|MATCH */ |
| 160892 | + 215, /* (201) expr ::= expr likeop expr */ |
| 160893 | + 215, /* (202) expr ::= expr likeop expr ESCAPE expr */ |
| 160894 | + 215, /* (203) expr ::= expr ISNULL|NOTNULL */ |
| 160895 | + 215, /* (204) expr ::= expr NOT NULL */ |
| 160896 | + 215, /* (205) expr ::= expr IS expr */ |
| 160897 | + 215, /* (206) expr ::= expr IS NOT expr */ |
| 160898 | + 215, /* (207) expr ::= NOT expr */ |
| 160899 | + 215, /* (208) expr ::= BITNOT expr */ |
| 160900 | + 215, /* (209) expr ::= PLUS|MINUS expr */ |
| 160901 | + 273, /* (210) between_op ::= BETWEEN */ |
| 160902 | + 273, /* (211) between_op ::= NOT BETWEEN */ |
| 160903 | + 215, /* (212) expr ::= expr between_op expr AND expr */ |
| 160904 | + 274, /* (213) in_op ::= IN */ |
| 160905 | + 274, /* (214) in_op ::= NOT IN */ |
| 160906 | + 215, /* (215) expr ::= expr in_op LP exprlist RP */ |
| 160907 | + 215, /* (216) expr ::= LP select RP */ |
| 160908 | + 215, /* (217) expr ::= expr in_op LP select RP */ |
| 160909 | + 215, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 160910 | + 215, /* (219) expr ::= EXISTS LP select RP */ |
| 160911 | + 215, /* (220) expr ::= CASE case_operand case_exprlist case_else END */ |
| 160912 | + 277, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 160913 | + 277, /* (222) case_exprlist ::= WHEN expr THEN expr */ |
| 160914 | + 278, /* (223) case_else ::= ELSE expr */ |
| 160915 | + 278, /* (224) case_else ::= */ |
| 160916 | + 276, /* (225) case_operand ::= expr */ |
| 160917 | + 276, /* (226) case_operand ::= */ |
| 160918 | + 260, /* (227) exprlist ::= */ |
| 160919 | + 251, /* (228) nexprlist ::= nexprlist COMMA expr */ |
| 160920 | + 251, /* (229) nexprlist ::= expr */ |
| 160921 | + 275, /* (230) paren_exprlist ::= */ |
| 160922 | + 275, /* (231) paren_exprlist ::= LP exprlist RP */ |
| 160923 | + 189, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 160924 | + 279, /* (233) uniqueflag ::= UNIQUE */ |
| 160925 | + 279, /* (234) uniqueflag ::= */ |
| 160926 | + 219, /* (235) eidlist_opt ::= */ |
| 160927 | + 219, /* (236) eidlist_opt ::= LP eidlist RP */ |
| 160928 | + 230, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 160929 | + 230, /* (238) eidlist ::= nm collate sortorder */ |
| 160930 | + 280, /* (239) collate ::= */ |
| 160931 | + 280, /* (240) collate ::= COLLATE ID|STRING */ |
| 160932 | + 189, /* (241) cmd ::= DROP INDEX ifexists fullname */ |
| 160933 | + 189, /* (242) cmd ::= VACUUM vinto */ |
| 160934 | + 189, /* (243) cmd ::= VACUUM nm vinto */ |
| 160935 | + 281, /* (244) vinto ::= INTO expr */ |
| 160936 | + 281, /* (245) vinto ::= */ |
| 160937 | + 189, /* (246) cmd ::= PRAGMA nm dbnm */ |
| 160938 | + 189, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 160939 | + 189, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 160940 | + 189, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 160941 | + 189, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 160942 | + 209, /* (251) plus_num ::= PLUS INTEGER|FLOAT */ |
| 160943 | + 210, /* (252) minus_num ::= MINUS INTEGER|FLOAT */ |
| 160944 | + 189, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 160945 | + 283, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 160946 | + 285, /* (255) trigger_time ::= BEFORE|AFTER */ |
| 160947 | + 285, /* (256) trigger_time ::= INSTEAD OF */ |
| 160948 | + 285, /* (257) trigger_time ::= */ |
| 160949 | + 286, /* (258) trigger_event ::= DELETE|INSERT */ |
| 160950 | + 286, /* (259) trigger_event ::= UPDATE */ |
| 160951 | + 286, /* (260) trigger_event ::= UPDATE OF idlist */ |
| 160952 | + 288, /* (261) when_clause ::= */ |
| 160953 | + 288, /* (262) when_clause ::= WHEN expr */ |
| 160954 | + 284, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 160955 | + 284, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 160956 | + 290, /* (265) trnm ::= nm DOT nm */ |
| 160957 | + 291, /* (266) tridxby ::= INDEXED BY nm */ |
| 160958 | + 291, /* (267) tridxby ::= NOT INDEXED */ |
| 160959 | + 289, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 160960 | + 289, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 160961 | + 289, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 160962 | + 289, /* (271) trigger_cmd ::= scanpt select scanpt */ |
| 160963 | + 215, /* (272) expr ::= RAISE LP IGNORE RP */ |
| 160964 | + 215, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 160965 | + 234, /* (274) raisetype ::= ROLLBACK */ |
| 160966 | + 234, /* (275) raisetype ::= ABORT */ |
| 160967 | + 234, /* (276) raisetype ::= FAIL */ |
| 160968 | + 189, /* (277) cmd ::= DROP TRIGGER ifexists fullname */ |
| 160969 | + 189, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 160970 | + 189, /* (279) cmd ::= DETACH database_kw_opt expr */ |
| 160971 | + 293, /* (280) key_opt ::= */ |
| 160972 | + 293, /* (281) key_opt ::= KEY expr */ |
| 160973 | + 189, /* (282) cmd ::= REINDEX */ |
| 160974 | + 189, /* (283) cmd ::= REINDEX nm dbnm */ |
| 160975 | + 189, /* (284) cmd ::= ANALYZE */ |
| 160976 | + 189, /* (285) cmd ::= ANALYZE nm dbnm */ |
| 160977 | + 189, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 160978 | + 189, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 160979 | + 189, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 160980 | + 294, /* (289) add_column_fullname ::= fullname */ |
| 160981 | + 189, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 160982 | + 189, /* (291) cmd ::= create_vtab */ |
| 160983 | + 189, /* (292) cmd ::= create_vtab LP vtabarglist RP */ |
| 160984 | + 296, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 160985 | + 298, /* (294) vtabarg ::= */ |
| 160986 | + 299, /* (295) vtabargtoken ::= ANY */ |
| 160987 | + 299, /* (296) vtabargtoken ::= lp anylist RP */ |
| 160988 | + 300, /* (297) lp ::= LP */ |
| 160989 | + 264, /* (298) with ::= WITH wqlist */ |
| 160990 | + 264, /* (299) with ::= WITH RECURSIVE wqlist */ |
| 160991 | + 303, /* (300) wqas ::= AS */ |
| 160992 | + 303, /* (301) wqas ::= AS MATERIALIZED */ |
| 160993 | + 303, /* (302) wqas ::= AS NOT MATERIALIZED */ |
| 160994 | + 302, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 160995 | + 239, /* (304) wqlist ::= wqitem */ |
| 160996 | + 239, /* (305) wqlist ::= wqlist COMMA wqitem */ |
| 160997 | + 304, /* (306) windowdefn_list ::= windowdefn */ |
| 160998 | + 304, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 160999 | + 305, /* (308) windowdefn ::= nm AS LP window RP */ |
| 161000 | + 306, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 161001 | + 306, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 161002 | + 306, /* (311) window ::= ORDER BY sortlist frame_opt */ |
| 161003 | + 306, /* (312) window ::= nm ORDER BY sortlist frame_opt */ |
| 161004 | + 306, /* (313) window ::= frame_opt */ |
| 161005 | + 306, /* (314) window ::= nm frame_opt */ |
| 161006 | + 307, /* (315) frame_opt ::= */ |
| 161007 | + 307, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 161008 | + 307, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 161009 | + 311, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 161010 | + 313, /* (319) frame_bound_s ::= frame_bound */ |
| 161011 | + 313, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 161012 | + 314, /* (321) frame_bound_e ::= frame_bound */ |
| 161013 | + 314, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 161014 | + 312, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 161015 | + 312, /* (324) frame_bound ::= CURRENT ROW */ |
| 161016 | + 315, /* (325) frame_exclude_opt ::= */ |
| 161017 | + 315, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 161018 | + 316, /* (327) frame_exclude ::= NO OTHERS */ |
| 161019 | + 316, /* (328) frame_exclude ::= CURRENT ROW */ |
| 161020 | + 316, /* (329) frame_exclude ::= GROUP|TIES */ |
| 161021 | + 249, /* (330) window_clause ::= WINDOW windowdefn_list */ |
| 161022 | + 271, /* (331) filter_over ::= filter_clause over_clause */ |
| 161023 | + 271, /* (332) filter_over ::= over_clause */ |
| 161024 | + 271, /* (333) filter_over ::= filter_clause */ |
| 161025 | + 310, /* (334) over_clause ::= OVER LP window RP */ |
| 161026 | + 310, /* (335) over_clause ::= OVER nm */ |
| 161027 | + 309, /* (336) filter_clause ::= FILTER LP WHERE expr RP */ |
| 161028 | + 184, /* (337) input ::= cmdlist */ |
| 161029 | + 185, /* (338) cmdlist ::= cmdlist ecmd */ |
| 161030 | + 185, /* (339) cmdlist ::= ecmd */ |
| 161031 | + 186, /* (340) ecmd ::= SEMI */ |
| 161032 | + 186, /* (341) ecmd ::= cmdx SEMI */ |
| 161033 | + 186, /* (342) ecmd ::= explain cmdx SEMI */ |
| 161034 | + 191, /* (343) trans_opt ::= */ |
| 161035 | + 191, /* (344) trans_opt ::= TRANSACTION */ |
| 161036 | + 191, /* (345) trans_opt ::= TRANSACTION nm */ |
| 161037 | + 193, /* (346) savepoint_opt ::= SAVEPOINT */ |
| 161038 | + 193, /* (347) savepoint_opt ::= */ |
| 161039 | + 189, /* (348) cmd ::= create_table create_table_args */ |
| 161040 | + 200, /* (349) columnlist ::= columnlist COMMA columnname carglist */ |
| 161041 | + 200, /* (350) columnlist ::= columnname carglist */ |
| 161042 | + 192, /* (351) nm ::= ID|INDEXED */ |
| 161043 | + 192, /* (352) nm ::= STRING */ |
| 161044 | + 192, /* (353) nm ::= JOIN_KW */ |
| 161045 | + 206, /* (354) typetoken ::= typename */ |
| 161046 | + 207, /* (355) typename ::= ID|STRING */ |
| 161047 | + 208, /* (356) signed ::= plus_num */ |
| 161048 | + 208, /* (357) signed ::= minus_num */ |
| 161049 | + 205, /* (358) carglist ::= carglist ccons */ |
| 161050 | + 205, /* (359) carglist ::= */ |
| 161051 | + 213, /* (360) ccons ::= NULL onconf */ |
| 161052 | + 213, /* (361) ccons ::= GENERATED ALWAYS AS generated */ |
| 161053 | + 213, /* (362) ccons ::= AS generated */ |
| 161054 | + 201, /* (363) conslist_opt ::= COMMA conslist */ |
| 161055 | + 226, /* (364) conslist ::= conslist tconscomma tcons */ |
| 161056 | + 226, /* (365) conslist ::= tcons */ |
| 161057 | + 227, /* (366) tconscomma ::= */ |
| 161058 | + 231, /* (367) defer_subclause_opt ::= defer_subclause */ |
| 161059 | + 233, /* (368) resolvetype ::= raisetype */ |
| 161060 | + 237, /* (369) selectnowith ::= oneselect */ |
| 161061 | + 238, /* (370) oneselect ::= values */ |
| 161062 | + 252, /* (371) sclp ::= selcollist COMMA */ |
| 161063 | + 253, /* (372) as ::= ID|STRING */ |
| 161064 | + 270, /* (373) returning ::= */ |
| 161065 | + 215, /* (374) expr ::= term */ |
| 161066 | + 272, /* (375) likeop ::= LIKE_KW|MATCH */ |
| 161067 | + 260, /* (376) exprlist ::= nexprlist */ |
| 161068 | + 282, /* (377) nmnum ::= plus_num */ |
| 161069 | + 282, /* (378) nmnum ::= nm */ |
| 161070 | + 282, /* (379) nmnum ::= ON */ |
| 161071 | + 282, /* (380) nmnum ::= DELETE */ |
| 161072 | + 282, /* (381) nmnum ::= DEFAULT */ |
| 161073 | + 209, /* (382) plus_num ::= INTEGER|FLOAT */ |
| 161074 | + 287, /* (383) foreach_clause ::= */ |
| 161075 | + 287, /* (384) foreach_clause ::= FOR EACH ROW */ |
| 161076 | + 290, /* (385) trnm ::= nm */ |
| 161077 | + 291, /* (386) tridxby ::= */ |
| 161078 | + 292, /* (387) database_kw_opt ::= DATABASE */ |
| 161079 | + 292, /* (388) database_kw_opt ::= */ |
| 161080 | + 295, /* (389) kwcolumn_opt ::= */ |
| 161081 | + 295, /* (390) kwcolumn_opt ::= COLUMNKW */ |
| 161082 | + 297, /* (391) vtabarglist ::= vtabarg */ |
| 161083 | + 297, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 161084 | + 298, /* (393) vtabarg ::= vtabarg vtabargtoken */ |
| 161085 | + 301, /* (394) anylist ::= */ |
| 161086 | + 301, /* (395) anylist ::= anylist LP anylist RP */ |
| 161087 | + 301, /* (396) anylist ::= anylist ANY */ |
| 161088 | + 264, /* (397) with ::= */ |
| 160510 | 161089 | }; |
| 160511 | 161090 | |
| 160512 | 161091 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number |
| 160513 | 161092 | ** of symbols on the right-hand side of that rule. */ |
| 160514 | 161093 | static const signed char yyRuleInfoNRhs[] = { |
| | @@ -160959,20 +161538,20 @@ |
| 160959 | 161538 | break; |
| 160960 | 161539 | case 2: /* cmdx ::= cmd */ |
| 160961 | 161540 | { sqlite3FinishCoding(pParse); } |
| 160962 | 161541 | break; |
| 160963 | 161542 | case 3: /* cmd ::= BEGIN transtype trans_opt */ |
| 160964 | | -{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy60);} |
| 161543 | +{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy376);} |
| 160965 | 161544 | break; |
| 160966 | 161545 | case 4: /* transtype ::= */ |
| 160967 | | -{yymsp[1].minor.yy60 = TK_DEFERRED;} |
| 161546 | +{yymsp[1].minor.yy376 = TK_DEFERRED;} |
| 160968 | 161547 | break; |
| 160969 | 161548 | case 5: /* transtype ::= DEFERRED */ |
| 160970 | 161549 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); |
| 160971 | 161550 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); |
| 160972 | 161551 | case 318: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==318); |
| 160973 | | -{yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-X*/} |
| 161552 | +{yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-X*/} |
| 160974 | 161553 | break; |
| 160975 | 161554 | case 8: /* cmd ::= COMMIT|END trans_opt */ |
| 160976 | 161555 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); |
| 160977 | 161556 | {sqlite3EndTransaction(pParse,yymsp[-1].major);} |
| 160978 | 161557 | break; |
| | @@ -160991,11 +161570,11 @@ |
| 160991 | 161570 | sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); |
| 160992 | 161571 | } |
| 160993 | 161572 | break; |
| 160994 | 161573 | case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 160995 | 161574 | { |
| 160996 | | - sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy60,0,0,yymsp[-2].minor.yy60); |
| 161575 | + sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy376,0,0,yymsp[-2].minor.yy376); |
| 160997 | 161576 | } |
| 160998 | 161577 | break; |
| 160999 | 161578 | case 14: /* createkw ::= CREATE */ |
| 161000 | 161579 | {disableLookaside(pParse);} |
| 161001 | 161580 | break; |
| | @@ -161006,36 +161585,35 @@ |
| 161006 | 161585 | case 60: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==60); |
| 161007 | 161586 | case 70: /* defer_subclause_opt ::= */ yytestcase(yyruleno==70); |
| 161008 | 161587 | case 79: /* ifexists ::= */ yytestcase(yyruleno==79); |
| 161009 | 161588 | case 96: /* distinct ::= */ yytestcase(yyruleno==96); |
| 161010 | 161589 | case 239: /* collate ::= */ yytestcase(yyruleno==239); |
| 161011 | | -{yymsp[1].minor.yy60 = 0;} |
| 161590 | +{yymsp[1].minor.yy376 = 0;} |
| 161012 | 161591 | break; |
| 161013 | 161592 | case 16: /* ifnotexists ::= IF NOT EXISTS */ |
| 161014 | | -{yymsp[-2].minor.yy60 = 1;} |
| 161593 | +{yymsp[-2].minor.yy376 = 1;} |
| 161015 | 161594 | break; |
| 161016 | 161595 | case 17: /* temp ::= TEMP */ |
| 161017 | | - case 46: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==46); |
| 161018 | | -{yymsp[0].minor.yy60 = 1;} |
| 161596 | +{yymsp[0].minor.yy376 = pParse->db->init.busy==0;} |
| 161019 | 161597 | break; |
| 161020 | 161598 | case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */ |
| 161021 | 161599 | { |
| 161022 | | - sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy60,0); |
| 161600 | + sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy376,0); |
| 161023 | 161601 | } |
| 161024 | 161602 | break; |
| 161025 | 161603 | case 20: /* create_table_args ::= AS select */ |
| 161026 | 161604 | { |
| 161027 | | - sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy307); |
| 161028 | | - sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy307); |
| 161605 | + sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy81); |
| 161606 | + sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy81); |
| 161029 | 161607 | } |
| 161030 | 161608 | break; |
| 161031 | 161609 | case 22: /* table_options ::= WITHOUT nm */ |
| 161032 | 161610 | { |
| 161033 | 161611 | if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ |
| 161034 | | - yymsp[-1].minor.yy60 = TF_WithoutRowid | TF_NoVisibleRowid; |
| 161612 | + yymsp[-1].minor.yy376 = TF_WithoutRowid | TF_NoVisibleRowid; |
| 161035 | 161613 | }else{ |
| 161036 | | - yymsp[-1].minor.yy60 = 0; |
| 161614 | + yymsp[-1].minor.yy376 = 0; |
| 161037 | 161615 | sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); |
| 161038 | 161616 | } |
| 161039 | 161617 | } |
| 161040 | 161618 | break; |
| 161041 | 161619 | case 23: /* columnname ::= nm typetoken */ |
| | @@ -161060,11 +161638,11 @@ |
| 161060 | 161638 | {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} |
| 161061 | 161639 | break; |
| 161062 | 161640 | case 28: /* scanpt ::= */ |
| 161063 | 161641 | { |
| 161064 | 161642 | assert( yyLookahead!=YYNOCODE ); |
| 161065 | | - yymsp[1].minor.yy528 = yyLookaheadToken.z; |
| 161643 | + yymsp[1].minor.yy504 = yyLookaheadToken.z; |
| 161066 | 161644 | } |
| 161067 | 161645 | break; |
| 161068 | 161646 | case 29: /* scantok ::= */ |
| 161069 | 161647 | { |
| 161070 | 161648 | assert( yyLookahead!=YYNOCODE ); |
| | @@ -161074,21 +161652,21 @@ |
| 161074 | 161652 | case 30: /* ccons ::= CONSTRAINT nm */ |
| 161075 | 161653 | case 65: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==65); |
| 161076 | 161654 | {pParse->constraintName = yymsp[0].minor.yy0;} |
| 161077 | 161655 | break; |
| 161078 | 161656 | case 31: /* ccons ::= DEFAULT scantok term */ |
| 161079 | | -{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy602,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 161657 | +{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy404,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 161080 | 161658 | break; |
| 161081 | 161659 | case 32: /* ccons ::= DEFAULT LP expr RP */ |
| 161082 | | -{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy602,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} |
| 161660 | +{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy404,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} |
| 161083 | 161661 | break; |
| 161084 | 161662 | case 33: /* ccons ::= DEFAULT PLUS scantok term */ |
| 161085 | | -{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy602,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 161663 | +{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy404,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 161086 | 161664 | break; |
| 161087 | 161665 | case 34: /* ccons ::= DEFAULT MINUS scantok term */ |
| 161088 | 161666 | { |
| 161089 | | - Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy602, 0); |
| 161667 | + Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy404, 0); |
| 161090 | 161668 | sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]); |
| 161091 | 161669 | } |
| 161092 | 161670 | break; |
| 161093 | 161671 | case 35: /* ccons ::= DEFAULT scantok ID|INDEXED */ |
| 161094 | 161672 | { |
| | @@ -161099,256 +161677,259 @@ |
| 161099 | 161677 | } |
| 161100 | 161678 | sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n); |
| 161101 | 161679 | } |
| 161102 | 161680 | break; |
| 161103 | 161681 | case 36: /* ccons ::= NOT NULL onconf */ |
| 161104 | | -{sqlite3AddNotNull(pParse, yymsp[0].minor.yy60);} |
| 161682 | +{sqlite3AddNotNull(pParse, yymsp[0].minor.yy376);} |
| 161105 | 161683 | break; |
| 161106 | 161684 | case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 161107 | | -{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy60,yymsp[0].minor.yy60,yymsp[-2].minor.yy60);} |
| 161685 | +{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy376,yymsp[0].minor.yy376,yymsp[-2].minor.yy376);} |
| 161108 | 161686 | break; |
| 161109 | 161687 | case 38: /* ccons ::= UNIQUE onconf */ |
| 161110 | | -{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy60,0,0,0,0, |
| 161688 | +{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy376,0,0,0,0, |
| 161111 | 161689 | SQLITE_IDXTYPE_UNIQUE);} |
| 161112 | 161690 | break; |
| 161113 | 161691 | case 39: /* ccons ::= CHECK LP expr RP */ |
| 161114 | | -{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy602,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);} |
| 161692 | +{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy404,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);} |
| 161115 | 161693 | break; |
| 161116 | 161694 | case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 161117 | | -{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy338,yymsp[0].minor.yy60);} |
| 161695 | +{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy70,yymsp[0].minor.yy376);} |
| 161118 | 161696 | break; |
| 161119 | 161697 | case 41: /* ccons ::= defer_subclause */ |
| 161120 | | -{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy60);} |
| 161698 | +{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy376);} |
| 161121 | 161699 | break; |
| 161122 | 161700 | case 42: /* ccons ::= COLLATE ID|STRING */ |
| 161123 | 161701 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} |
| 161124 | 161702 | break; |
| 161125 | 161703 | case 43: /* generated ::= LP expr RP */ |
| 161126 | | -{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy602,0);} |
| 161704 | +{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy404,0);} |
| 161127 | 161705 | break; |
| 161128 | 161706 | case 44: /* generated ::= LP expr RP ID */ |
| 161129 | | -{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy602,&yymsp[0].minor.yy0);} |
| 161707 | +{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy404,&yymsp[0].minor.yy0);} |
| 161708 | + break; |
| 161709 | + case 46: /* autoinc ::= AUTOINCR */ |
| 161710 | +{yymsp[0].minor.yy376 = 1;} |
| 161130 | 161711 | break; |
| 161131 | 161712 | case 47: /* refargs ::= */ |
| 161132 | | -{ yymsp[1].minor.yy60 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 161713 | +{ yymsp[1].minor.yy376 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 161133 | 161714 | break; |
| 161134 | 161715 | case 48: /* refargs ::= refargs refarg */ |
| 161135 | | -{ yymsp[-1].minor.yy60 = (yymsp[-1].minor.yy60 & ~yymsp[0].minor.yy615.mask) | yymsp[0].minor.yy615.value; } |
| 161716 | +{ yymsp[-1].minor.yy376 = (yymsp[-1].minor.yy376 & ~yymsp[0].minor.yy139.mask) | yymsp[0].minor.yy139.value; } |
| 161136 | 161717 | break; |
| 161137 | 161718 | case 49: /* refarg ::= MATCH nm */ |
| 161138 | | -{ yymsp[-1].minor.yy615.value = 0; yymsp[-1].minor.yy615.mask = 0x000000; } |
| 161719 | +{ yymsp[-1].minor.yy139.value = 0; yymsp[-1].minor.yy139.mask = 0x000000; } |
| 161139 | 161720 | break; |
| 161140 | 161721 | case 50: /* refarg ::= ON INSERT refact */ |
| 161141 | | -{ yymsp[-2].minor.yy615.value = 0; yymsp[-2].minor.yy615.mask = 0x000000; } |
| 161722 | +{ yymsp[-2].minor.yy139.value = 0; yymsp[-2].minor.yy139.mask = 0x000000; } |
| 161142 | 161723 | break; |
| 161143 | 161724 | case 51: /* refarg ::= ON DELETE refact */ |
| 161144 | | -{ yymsp[-2].minor.yy615.value = yymsp[0].minor.yy60; yymsp[-2].minor.yy615.mask = 0x0000ff; } |
| 161725 | +{ yymsp[-2].minor.yy139.value = yymsp[0].minor.yy376; yymsp[-2].minor.yy139.mask = 0x0000ff; } |
| 161145 | 161726 | break; |
| 161146 | 161727 | case 52: /* refarg ::= ON UPDATE refact */ |
| 161147 | | -{ yymsp[-2].minor.yy615.value = yymsp[0].minor.yy60<<8; yymsp[-2].minor.yy615.mask = 0x00ff00; } |
| 161728 | +{ yymsp[-2].minor.yy139.value = yymsp[0].minor.yy376<<8; yymsp[-2].minor.yy139.mask = 0x00ff00; } |
| 161148 | 161729 | break; |
| 161149 | 161730 | case 53: /* refact ::= SET NULL */ |
| 161150 | | -{ yymsp[-1].minor.yy60 = OE_SetNull; /* EV: R-33326-45252 */} |
| 161731 | +{ yymsp[-1].minor.yy376 = OE_SetNull; /* EV: R-33326-45252 */} |
| 161151 | 161732 | break; |
| 161152 | 161733 | case 54: /* refact ::= SET DEFAULT */ |
| 161153 | | -{ yymsp[-1].minor.yy60 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 161734 | +{ yymsp[-1].minor.yy376 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 161154 | 161735 | break; |
| 161155 | 161736 | case 55: /* refact ::= CASCADE */ |
| 161156 | | -{ yymsp[0].minor.yy60 = OE_Cascade; /* EV: R-33326-45252 */} |
| 161737 | +{ yymsp[0].minor.yy376 = OE_Cascade; /* EV: R-33326-45252 */} |
| 161157 | 161738 | break; |
| 161158 | 161739 | case 56: /* refact ::= RESTRICT */ |
| 161159 | | -{ yymsp[0].minor.yy60 = OE_Restrict; /* EV: R-33326-45252 */} |
| 161740 | +{ yymsp[0].minor.yy376 = OE_Restrict; /* EV: R-33326-45252 */} |
| 161160 | 161741 | break; |
| 161161 | 161742 | case 57: /* refact ::= NO ACTION */ |
| 161162 | | -{ yymsp[-1].minor.yy60 = OE_None; /* EV: R-33326-45252 */} |
| 161743 | +{ yymsp[-1].minor.yy376 = OE_None; /* EV: R-33326-45252 */} |
| 161163 | 161744 | break; |
| 161164 | 161745 | case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 161165 | | -{yymsp[-2].minor.yy60 = 0;} |
| 161746 | +{yymsp[-2].minor.yy376 = 0;} |
| 161166 | 161747 | break; |
| 161167 | 161748 | case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 161168 | 161749 | case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74); |
| 161169 | 161750 | case 169: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==169); |
| 161170 | | -{yymsp[-1].minor.yy60 = yymsp[0].minor.yy60;} |
| 161751 | +{yymsp[-1].minor.yy376 = yymsp[0].minor.yy376;} |
| 161171 | 161752 | break; |
| 161172 | 161753 | case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 161173 | 161754 | case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78); |
| 161174 | 161755 | case 211: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==211); |
| 161175 | 161756 | case 214: /* in_op ::= NOT IN */ yytestcase(yyruleno==214); |
| 161176 | 161757 | case 240: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==240); |
| 161177 | | -{yymsp[-1].minor.yy60 = 1;} |
| 161758 | +{yymsp[-1].minor.yy376 = 1;} |
| 161178 | 161759 | break; |
| 161179 | 161760 | case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 161180 | | -{yymsp[-1].minor.yy60 = 0;} |
| 161761 | +{yymsp[-1].minor.yy376 = 0;} |
| 161181 | 161762 | break; |
| 161182 | 161763 | case 64: /* tconscomma ::= COMMA */ |
| 161183 | 161764 | {pParse->constraintName.n = 0;} |
| 161184 | 161765 | break; |
| 161185 | 161766 | case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 161186 | | -{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy338,yymsp[0].minor.yy60,yymsp[-2].minor.yy60,0);} |
| 161767 | +{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy70,yymsp[0].minor.yy376,yymsp[-2].minor.yy376,0);} |
| 161187 | 161768 | break; |
| 161188 | 161769 | case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */ |
| 161189 | | -{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy338,yymsp[0].minor.yy60,0,0,0,0, |
| 161770 | +{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy70,yymsp[0].minor.yy376,0,0,0,0, |
| 161190 | 161771 | SQLITE_IDXTYPE_UNIQUE);} |
| 161191 | 161772 | break; |
| 161192 | 161773 | case 68: /* tcons ::= CHECK LP expr RP onconf */ |
| 161193 | | -{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy602,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);} |
| 161774 | +{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy404,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);} |
| 161194 | 161775 | break; |
| 161195 | 161776 | case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 161196 | 161777 | { |
| 161197 | | - sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy338, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy338, yymsp[-1].minor.yy60); |
| 161198 | | - sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy60); |
| 161778 | + sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy70, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy70, yymsp[-1].minor.yy376); |
| 161779 | + sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy376); |
| 161199 | 161780 | } |
| 161200 | 161781 | break; |
| 161201 | 161782 | case 71: /* onconf ::= */ |
| 161202 | 161783 | case 73: /* orconf ::= */ yytestcase(yyruleno==73); |
| 161203 | | -{yymsp[1].minor.yy60 = OE_Default;} |
| 161784 | +{yymsp[1].minor.yy376 = OE_Default;} |
| 161204 | 161785 | break; |
| 161205 | 161786 | case 72: /* onconf ::= ON CONFLICT resolvetype */ |
| 161206 | | -{yymsp[-2].minor.yy60 = yymsp[0].minor.yy60;} |
| 161787 | +{yymsp[-2].minor.yy376 = yymsp[0].minor.yy376;} |
| 161207 | 161788 | break; |
| 161208 | 161789 | case 75: /* resolvetype ::= IGNORE */ |
| 161209 | | -{yymsp[0].minor.yy60 = OE_Ignore;} |
| 161790 | +{yymsp[0].minor.yy376 = OE_Ignore;} |
| 161210 | 161791 | break; |
| 161211 | 161792 | case 76: /* resolvetype ::= REPLACE */ |
| 161212 | 161793 | case 170: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==170); |
| 161213 | | -{yymsp[0].minor.yy60 = OE_Replace;} |
| 161794 | +{yymsp[0].minor.yy376 = OE_Replace;} |
| 161214 | 161795 | break; |
| 161215 | 161796 | case 77: /* cmd ::= DROP TABLE ifexists fullname */ |
| 161216 | 161797 | { |
| 161217 | | - sqlite3DropTable(pParse, yymsp[0].minor.yy291, 0, yymsp[-1].minor.yy60); |
| 161798 | + sqlite3DropTable(pParse, yymsp[0].minor.yy153, 0, yymsp[-1].minor.yy376); |
| 161218 | 161799 | } |
| 161219 | 161800 | break; |
| 161220 | 161801 | case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 161221 | 161802 | { |
| 161222 | | - 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); |
| 161803 | + 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); |
| 161223 | 161804 | } |
| 161224 | 161805 | break; |
| 161225 | 161806 | case 81: /* cmd ::= DROP VIEW ifexists fullname */ |
| 161226 | 161807 | { |
| 161227 | | - sqlite3DropTable(pParse, yymsp[0].minor.yy291, 1, yymsp[-1].minor.yy60); |
| 161808 | + sqlite3DropTable(pParse, yymsp[0].minor.yy153, 1, yymsp[-1].minor.yy376); |
| 161228 | 161809 | } |
| 161229 | 161810 | break; |
| 161230 | 161811 | case 82: /* cmd ::= select */ |
| 161231 | 161812 | { |
| 161232 | 161813 | SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0}; |
| 161233 | | - sqlite3Select(pParse, yymsp[0].minor.yy307, &dest); |
| 161234 | | - sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy307); |
| 161814 | + sqlite3Select(pParse, yymsp[0].minor.yy81, &dest); |
| 161815 | + sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy81); |
| 161235 | 161816 | } |
| 161236 | 161817 | break; |
| 161237 | 161818 | case 83: /* select ::= WITH wqlist selectnowith */ |
| 161238 | | -{yymsp[-2].minor.yy307 = attachWithToSelect(pParse,yymsp[0].minor.yy307,yymsp[-1].minor.yy195);} |
| 161819 | +{yymsp[-2].minor.yy81 = attachWithToSelect(pParse,yymsp[0].minor.yy81,yymsp[-1].minor.yy103);} |
| 161239 | 161820 | break; |
| 161240 | 161821 | case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */ |
| 161241 | | -{yymsp[-3].minor.yy307 = attachWithToSelect(pParse,yymsp[0].minor.yy307,yymsp[-1].minor.yy195);} |
| 161822 | +{yymsp[-3].minor.yy81 = attachWithToSelect(pParse,yymsp[0].minor.yy81,yymsp[-1].minor.yy103);} |
| 161242 | 161823 | break; |
| 161243 | 161824 | case 85: /* select ::= selectnowith */ |
| 161244 | 161825 | { |
| 161245 | | - Select *p = yymsp[0].minor.yy307; |
| 161826 | + Select *p = yymsp[0].minor.yy81; |
| 161246 | 161827 | if( p ){ |
| 161247 | 161828 | parserDoubleLinkSelect(pParse, p); |
| 161248 | 161829 | } |
| 161249 | | - yymsp[0].minor.yy307 = p; /*A-overwrites-X*/ |
| 161830 | + yymsp[0].minor.yy81 = p; /*A-overwrites-X*/ |
| 161250 | 161831 | } |
| 161251 | 161832 | break; |
| 161252 | 161833 | case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */ |
| 161253 | 161834 | { |
| 161254 | | - Select *pRhs = yymsp[0].minor.yy307; |
| 161255 | | - Select *pLhs = yymsp[-2].minor.yy307; |
| 161835 | + Select *pRhs = yymsp[0].minor.yy81; |
| 161836 | + Select *pLhs = yymsp[-2].minor.yy81; |
| 161256 | 161837 | if( pRhs && pRhs->pPrior ){ |
| 161257 | 161838 | SrcList *pFrom; |
| 161258 | 161839 | Token x; |
| 161259 | 161840 | x.n = 0; |
| 161260 | 161841 | parserDoubleLinkSelect(pParse, pRhs); |
| 161261 | 161842 | pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0); |
| 161262 | 161843 | pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0); |
| 161263 | 161844 | } |
| 161264 | 161845 | if( pRhs ){ |
| 161265 | | - pRhs->op = (u8)yymsp[-1].minor.yy60; |
| 161846 | + pRhs->op = (u8)yymsp[-1].minor.yy376; |
| 161266 | 161847 | pRhs->pPrior = pLhs; |
| 161267 | 161848 | if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue; |
| 161268 | 161849 | pRhs->selFlags &= ~SF_MultiValue; |
| 161269 | | - if( yymsp[-1].minor.yy60!=TK_ALL ) pParse->hasCompound = 1; |
| 161850 | + if( yymsp[-1].minor.yy376!=TK_ALL ) pParse->hasCompound = 1; |
| 161270 | 161851 | }else{ |
| 161271 | 161852 | sqlite3SelectDelete(pParse->db, pLhs); |
| 161272 | 161853 | } |
| 161273 | | - yymsp[-2].minor.yy307 = pRhs; |
| 161854 | + yymsp[-2].minor.yy81 = pRhs; |
| 161274 | 161855 | } |
| 161275 | 161856 | break; |
| 161276 | 161857 | case 87: /* multiselect_op ::= UNION */ |
| 161277 | 161858 | case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89); |
| 161278 | | -{yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-OP*/} |
| 161859 | +{yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-OP*/} |
| 161279 | 161860 | break; |
| 161280 | 161861 | case 88: /* multiselect_op ::= UNION ALL */ |
| 161281 | | -{yymsp[-1].minor.yy60 = TK_ALL;} |
| 161862 | +{yymsp[-1].minor.yy376 = TK_ALL;} |
| 161282 | 161863 | break; |
| 161283 | 161864 | case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 161284 | 161865 | { |
| 161285 | | - 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); |
| 161866 | + 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); |
| 161286 | 161867 | } |
| 161287 | 161868 | break; |
| 161288 | 161869 | case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ |
| 161289 | 161870 | { |
| 161290 | | - 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); |
| 161291 | | - if( yymsp[-9].minor.yy307 ){ |
| 161292 | | - yymsp[-9].minor.yy307->pWinDefn = yymsp[-2].minor.yy19; |
| 161871 | + 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); |
| 161872 | + if( yymsp[-9].minor.yy81 ){ |
| 161873 | + yymsp[-9].minor.yy81->pWinDefn = yymsp[-2].minor.yy49; |
| 161293 | 161874 | }else{ |
| 161294 | | - sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy19); |
| 161875 | + sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy49); |
| 161295 | 161876 | } |
| 161296 | 161877 | } |
| 161297 | 161878 | break; |
| 161298 | 161879 | case 92: /* values ::= VALUES LP nexprlist RP */ |
| 161299 | 161880 | { |
| 161300 | | - yymsp[-3].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy338,0,0,0,0,0,SF_Values,0); |
| 161881 | + yymsp[-3].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy70,0,0,0,0,0,SF_Values,0); |
| 161301 | 161882 | } |
| 161302 | 161883 | break; |
| 161303 | 161884 | case 93: /* values ::= values COMMA LP nexprlist RP */ |
| 161304 | 161885 | { |
| 161305 | | - Select *pRight, *pLeft = yymsp[-4].minor.yy307; |
| 161306 | | - pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy338,0,0,0,0,0,SF_Values|SF_MultiValue,0); |
| 161886 | + Select *pRight, *pLeft = yymsp[-4].minor.yy81; |
| 161887 | + pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy70,0,0,0,0,0,SF_Values|SF_MultiValue,0); |
| 161307 | 161888 | if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; |
| 161308 | 161889 | if( pRight ){ |
| 161309 | 161890 | pRight->op = TK_ALL; |
| 161310 | 161891 | pRight->pPrior = pLeft; |
| 161311 | | - yymsp[-4].minor.yy307 = pRight; |
| 161892 | + yymsp[-4].minor.yy81 = pRight; |
| 161312 | 161893 | }else{ |
| 161313 | | - yymsp[-4].minor.yy307 = pLeft; |
| 161894 | + yymsp[-4].minor.yy81 = pLeft; |
| 161314 | 161895 | } |
| 161315 | 161896 | } |
| 161316 | 161897 | break; |
| 161317 | 161898 | case 94: /* distinct ::= DISTINCT */ |
| 161318 | | -{yymsp[0].minor.yy60 = SF_Distinct;} |
| 161899 | +{yymsp[0].minor.yy376 = SF_Distinct;} |
| 161319 | 161900 | break; |
| 161320 | 161901 | case 95: /* distinct ::= ALL */ |
| 161321 | | -{yymsp[0].minor.yy60 = SF_All;} |
| 161902 | +{yymsp[0].minor.yy376 = SF_All;} |
| 161322 | 161903 | break; |
| 161323 | 161904 | case 97: /* sclp ::= */ |
| 161324 | 161905 | case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130); |
| 161325 | 161906 | case 140: /* groupby_opt ::= */ yytestcase(yyruleno==140); |
| 161326 | 161907 | case 227: /* exprlist ::= */ yytestcase(yyruleno==227); |
| 161327 | 161908 | case 230: /* paren_exprlist ::= */ yytestcase(yyruleno==230); |
| 161328 | 161909 | case 235: /* eidlist_opt ::= */ yytestcase(yyruleno==235); |
| 161329 | | -{yymsp[1].minor.yy338 = 0;} |
| 161910 | +{yymsp[1].minor.yy70 = 0;} |
| 161330 | 161911 | break; |
| 161331 | 161912 | case 98: /* selcollist ::= sclp scanpt expr scanpt as */ |
| 161332 | 161913 | { |
| 161333 | | - yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy338, yymsp[-2].minor.yy602); |
| 161334 | | - if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy338, &yymsp[0].minor.yy0, 1); |
| 161335 | | - sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy338,yymsp[-3].minor.yy528,yymsp[-1].minor.yy528); |
| 161914 | + yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy404); |
| 161915 | + if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy70, &yymsp[0].minor.yy0, 1); |
| 161916 | + sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy70,yymsp[-3].minor.yy504,yymsp[-1].minor.yy504); |
| 161336 | 161917 | } |
| 161337 | 161918 | break; |
| 161338 | 161919 | case 99: /* selcollist ::= sclp scanpt STAR */ |
| 161339 | 161920 | { |
| 161340 | 161921 | Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); |
| 161341 | | - yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy338, p); |
| 161922 | + yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy70, p); |
| 161342 | 161923 | } |
| 161343 | 161924 | break; |
| 161344 | 161925 | case 100: /* selcollist ::= sclp scanpt nm DOT STAR */ |
| 161345 | 161926 | { |
| 161346 | 161927 | Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); |
| 161347 | 161928 | Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); |
| 161348 | 161929 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); |
| 161349 | | - yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, pDot); |
| 161930 | + yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, pDot); |
| 161350 | 161931 | } |
| 161351 | 161932 | break; |
| 161352 | 161933 | case 101: /* as ::= AS nm */ |
| 161353 | 161934 | case 112: /* dbnm ::= DOT nm */ yytestcase(yyruleno==112); |
| 161354 | 161935 | case 251: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==251); |
| | @@ -161355,49 +161936,49 @@ |
| 161355 | 161936 | case 252: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==252); |
| 161356 | 161937 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 161357 | 161938 | break; |
| 161358 | 161939 | case 103: /* from ::= */ |
| 161359 | 161940 | case 106: /* stl_prefix ::= */ yytestcase(yyruleno==106); |
| 161360 | | -{yymsp[1].minor.yy291 = 0;} |
| 161941 | +{yymsp[1].minor.yy153 = 0;} |
| 161361 | 161942 | break; |
| 161362 | 161943 | case 104: /* from ::= FROM seltablist */ |
| 161363 | 161944 | { |
| 161364 | | - yymsp[-1].minor.yy291 = yymsp[0].minor.yy291; |
| 161365 | | - sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy291); |
| 161945 | + yymsp[-1].minor.yy153 = yymsp[0].minor.yy153; |
| 161946 | + sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy153); |
| 161366 | 161947 | } |
| 161367 | 161948 | break; |
| 161368 | 161949 | case 105: /* stl_prefix ::= seltablist joinop */ |
| 161369 | 161950 | { |
| 161370 | | - 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; |
| 161951 | + 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; |
| 161371 | 161952 | } |
| 161372 | 161953 | break; |
| 161373 | 161954 | case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 161374 | 161955 | { |
| 161375 | | - 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); |
| 161376 | | - sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy291, &yymsp[-2].minor.yy0); |
| 161956 | + 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); |
| 161957 | + sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy153, &yymsp[-2].minor.yy0); |
| 161377 | 161958 | } |
| 161378 | 161959 | break; |
| 161379 | 161960 | case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 161380 | 161961 | { |
| 161381 | | - 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); |
| 161382 | | - sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy291, yymsp[-4].minor.yy338); |
| 161962 | + 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); |
| 161963 | + sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy153, yymsp[-4].minor.yy70); |
| 161383 | 161964 | } |
| 161384 | 161965 | break; |
| 161385 | 161966 | case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 161386 | 161967 | { |
| 161387 | | - 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); |
| 161968 | + 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); |
| 161388 | 161969 | } |
| 161389 | 161970 | break; |
| 161390 | 161971 | case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 161391 | 161972 | { |
| 161392 | | - if( yymsp[-6].minor.yy291==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy602==0 && yymsp[0].minor.yy288==0 ){ |
| 161393 | | - yymsp[-6].minor.yy291 = yymsp[-4].minor.yy291; |
| 161394 | | - }else if( yymsp[-4].minor.yy291->nSrc==1 ){ |
| 161395 | | - 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); |
| 161396 | | - if( yymsp[-6].minor.yy291 ){ |
| 161397 | | - SrcItem *pNew = &yymsp[-6].minor.yy291->a[yymsp[-6].minor.yy291->nSrc-1]; |
| 161398 | | - SrcItem *pOld = yymsp[-4].minor.yy291->a; |
| 161973 | + if( yymsp[-6].minor.yy153==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy404==0 && yymsp[0].minor.yy436==0 ){ |
| 161974 | + yymsp[-6].minor.yy153 = yymsp[-4].minor.yy153; |
| 161975 | + }else if( yymsp[-4].minor.yy153->nSrc==1 ){ |
| 161976 | + 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); |
| 161977 | + if( yymsp[-6].minor.yy153 ){ |
| 161978 | + SrcItem *pNew = &yymsp[-6].minor.yy153->a[yymsp[-6].minor.yy153->nSrc-1]; |
| 161979 | + SrcItem *pOld = yymsp[-4].minor.yy153->a; |
| 161399 | 161980 | pNew->zName = pOld->zName; |
| 161400 | 161981 | pNew->zDatabase = pOld->zDatabase; |
| 161401 | 161982 | pNew->pSelect = pOld->pSelect; |
| 161402 | 161983 | if( pOld->fg.isTabFunc ){ |
| 161403 | 161984 | pNew->u1.pFuncArg = pOld->u1.pFuncArg; |
| | @@ -161406,240 +161987,240 @@ |
| 161406 | 161987 | pNew->fg.isTabFunc = 1; |
| 161407 | 161988 | } |
| 161408 | 161989 | pOld->zName = pOld->zDatabase = 0; |
| 161409 | 161990 | pOld->pSelect = 0; |
| 161410 | 161991 | } |
| 161411 | | - sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy291); |
| 161992 | + sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy153); |
| 161412 | 161993 | }else{ |
| 161413 | 161994 | Select *pSubquery; |
| 161414 | | - sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy291); |
| 161415 | | - pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy291,0,0,0,0,SF_NestedFrom,0); |
| 161416 | | - 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); |
| 161995 | + sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy153); |
| 161996 | + pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy153,0,0,0,0,SF_NestedFrom,0); |
| 161997 | + 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); |
| 161417 | 161998 | } |
| 161418 | 161999 | } |
| 161419 | 162000 | break; |
| 161420 | 162001 | case 111: /* dbnm ::= */ |
| 161421 | 162002 | case 125: /* indexed_opt ::= */ yytestcase(yyruleno==125); |
| 161422 | 162003 | {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;} |
| 161423 | 162004 | break; |
| 161424 | 162005 | case 113: /* fullname ::= nm */ |
| 161425 | 162006 | { |
| 161426 | | - yylhsminor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); |
| 161427 | | - if( IN_RENAME_OBJECT && yylhsminor.yy291 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy291->a[0].zName, &yymsp[0].minor.yy0); |
| 162007 | + yylhsminor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); |
| 162008 | + if( IN_RENAME_OBJECT && yylhsminor.yy153 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy153->a[0].zName, &yymsp[0].minor.yy0); |
| 161428 | 162009 | } |
| 161429 | | - yymsp[0].minor.yy291 = yylhsminor.yy291; |
| 162010 | + yymsp[0].minor.yy153 = yylhsminor.yy153; |
| 161430 | 162011 | break; |
| 161431 | 162012 | case 114: /* fullname ::= nm DOT nm */ |
| 161432 | 162013 | { |
| 161433 | | - yylhsminor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 161434 | | - if( IN_RENAME_OBJECT && yylhsminor.yy291 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy291->a[0].zName, &yymsp[0].minor.yy0); |
| 162014 | + yylhsminor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 162015 | + if( IN_RENAME_OBJECT && yylhsminor.yy153 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy153->a[0].zName, &yymsp[0].minor.yy0); |
| 161435 | 162016 | } |
| 161436 | | - yymsp[-2].minor.yy291 = yylhsminor.yy291; |
| 162017 | + yymsp[-2].minor.yy153 = yylhsminor.yy153; |
| 161437 | 162018 | break; |
| 161438 | 162019 | case 115: /* xfullname ::= nm */ |
| 161439 | | -{yymsp[0].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} |
| 162020 | +{yymsp[0].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} |
| 161440 | 162021 | break; |
| 161441 | 162022 | case 116: /* xfullname ::= nm DOT nm */ |
| 161442 | | -{yymsp[-2].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 162023 | +{yymsp[-2].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 161443 | 162024 | break; |
| 161444 | 162025 | case 117: /* xfullname ::= nm DOT nm AS nm */ |
| 161445 | 162026 | { |
| 161446 | | - yymsp[-4].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ |
| 161447 | | - if( yymsp[-4].minor.yy291 ) yymsp[-4].minor.yy291->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 162027 | + yymsp[-4].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ |
| 162028 | + if( yymsp[-4].minor.yy153 ) yymsp[-4].minor.yy153->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 161448 | 162029 | } |
| 161449 | 162030 | break; |
| 161450 | 162031 | case 118: /* xfullname ::= nm AS nm */ |
| 161451 | 162032 | { |
| 161452 | | - yymsp[-2].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ |
| 161453 | | - if( yymsp[-2].minor.yy291 ) yymsp[-2].minor.yy291->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 162033 | + yymsp[-2].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ |
| 162034 | + if( yymsp[-2].minor.yy153 ) yymsp[-2].minor.yy153->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 161454 | 162035 | } |
| 161455 | 162036 | break; |
| 161456 | 162037 | case 119: /* joinop ::= COMMA|JOIN */ |
| 161457 | | -{ yymsp[0].minor.yy60 = JT_INNER; } |
| 162038 | +{ yymsp[0].minor.yy376 = JT_INNER; } |
| 161458 | 162039 | break; |
| 161459 | 162040 | case 120: /* joinop ::= JOIN_KW JOIN */ |
| 161460 | | -{yymsp[-1].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} |
| 162041 | +{yymsp[-1].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} |
| 161461 | 162042 | break; |
| 161462 | 162043 | case 121: /* joinop ::= JOIN_KW nm JOIN */ |
| 161463 | | -{yymsp[-2].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} |
| 162044 | +{yymsp[-2].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} |
| 161464 | 162045 | break; |
| 161465 | 162046 | case 122: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 161466 | | -{yymsp[-3].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} |
| 162047 | +{yymsp[-3].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} |
| 161467 | 162048 | break; |
| 161468 | 162049 | case 123: /* on_opt ::= ON expr */ |
| 161469 | 162050 | case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143); |
| 161470 | 162051 | case 150: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==150); |
| 161471 | 162052 | case 152: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==152); |
| 161472 | 162053 | case 223: /* case_else ::= ELSE expr */ yytestcase(yyruleno==223); |
| 161473 | 162054 | case 244: /* vinto ::= INTO expr */ yytestcase(yyruleno==244); |
| 161474 | | -{yymsp[-1].minor.yy602 = yymsp[0].minor.yy602;} |
| 162055 | +{yymsp[-1].minor.yy404 = yymsp[0].minor.yy404;} |
| 161475 | 162056 | break; |
| 161476 | 162057 | case 124: /* on_opt ::= */ |
| 161477 | 162058 | case 142: /* having_opt ::= */ yytestcase(yyruleno==142); |
| 161478 | 162059 | case 144: /* limit_opt ::= */ yytestcase(yyruleno==144); |
| 161479 | 162060 | case 149: /* where_opt ::= */ yytestcase(yyruleno==149); |
| 161480 | 162061 | case 151: /* where_opt_ret ::= */ yytestcase(yyruleno==151); |
| 161481 | 162062 | case 224: /* case_else ::= */ yytestcase(yyruleno==224); |
| 161482 | 162063 | case 226: /* case_operand ::= */ yytestcase(yyruleno==226); |
| 161483 | 162064 | case 245: /* vinto ::= */ yytestcase(yyruleno==245); |
| 161484 | | -{yymsp[1].minor.yy602 = 0;} |
| 162065 | +{yymsp[1].minor.yy404 = 0;} |
| 161485 | 162066 | break; |
| 161486 | 162067 | case 126: /* indexed_opt ::= INDEXED BY nm */ |
| 161487 | 162068 | {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} |
| 161488 | 162069 | break; |
| 161489 | 162070 | case 127: /* indexed_opt ::= NOT INDEXED */ |
| 161490 | 162071 | {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} |
| 161491 | 162072 | break; |
| 161492 | 162073 | case 128: /* using_opt ::= USING LP idlist RP */ |
| 161493 | | -{yymsp[-3].minor.yy288 = yymsp[-1].minor.yy288;} |
| 162074 | +{yymsp[-3].minor.yy436 = yymsp[-1].minor.yy436;} |
| 161494 | 162075 | break; |
| 161495 | 162076 | case 129: /* using_opt ::= */ |
| 161496 | 162077 | case 171: /* idlist_opt ::= */ yytestcase(yyruleno==171); |
| 161497 | | -{yymsp[1].minor.yy288 = 0;} |
| 162078 | +{yymsp[1].minor.yy436 = 0;} |
| 161498 | 162079 | break; |
| 161499 | 162080 | case 131: /* orderby_opt ::= ORDER BY sortlist */ |
| 161500 | 162081 | case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141); |
| 161501 | | -{yymsp[-2].minor.yy338 = yymsp[0].minor.yy338;} |
| 162082 | +{yymsp[-2].minor.yy70 = yymsp[0].minor.yy70;} |
| 161502 | 162083 | break; |
| 161503 | 162084 | case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 161504 | 162085 | { |
| 161505 | | - yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338,yymsp[-2].minor.yy602); |
| 161506 | | - sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy338,yymsp[-1].minor.yy60,yymsp[0].minor.yy60); |
| 162086 | + yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70,yymsp[-2].minor.yy404); |
| 162087 | + sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy70,yymsp[-1].minor.yy376,yymsp[0].minor.yy376); |
| 161507 | 162088 | } |
| 161508 | 162089 | break; |
| 161509 | 162090 | case 133: /* sortlist ::= expr sortorder nulls */ |
| 161510 | 162091 | { |
| 161511 | | - yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy602); /*A-overwrites-Y*/ |
| 161512 | | - sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy338,yymsp[-1].minor.yy60,yymsp[0].minor.yy60); |
| 162092 | + yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy404); /*A-overwrites-Y*/ |
| 162093 | + sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy70,yymsp[-1].minor.yy376,yymsp[0].minor.yy376); |
| 161513 | 162094 | } |
| 161514 | 162095 | break; |
| 161515 | 162096 | case 134: /* sortorder ::= ASC */ |
| 161516 | | -{yymsp[0].minor.yy60 = SQLITE_SO_ASC;} |
| 162097 | +{yymsp[0].minor.yy376 = SQLITE_SO_ASC;} |
| 161517 | 162098 | break; |
| 161518 | 162099 | case 135: /* sortorder ::= DESC */ |
| 161519 | | -{yymsp[0].minor.yy60 = SQLITE_SO_DESC;} |
| 162100 | +{yymsp[0].minor.yy376 = SQLITE_SO_DESC;} |
| 161520 | 162101 | break; |
| 161521 | 162102 | case 136: /* sortorder ::= */ |
| 161522 | 162103 | case 139: /* nulls ::= */ yytestcase(yyruleno==139); |
| 161523 | | -{yymsp[1].minor.yy60 = SQLITE_SO_UNDEFINED;} |
| 162104 | +{yymsp[1].minor.yy376 = SQLITE_SO_UNDEFINED;} |
| 161524 | 162105 | break; |
| 161525 | 162106 | case 137: /* nulls ::= NULLS FIRST */ |
| 161526 | | -{yymsp[-1].minor.yy60 = SQLITE_SO_ASC;} |
| 162107 | +{yymsp[-1].minor.yy376 = SQLITE_SO_ASC;} |
| 161527 | 162108 | break; |
| 161528 | 162109 | case 138: /* nulls ::= NULLS LAST */ |
| 161529 | | -{yymsp[-1].minor.yy60 = SQLITE_SO_DESC;} |
| 162110 | +{yymsp[-1].minor.yy376 = SQLITE_SO_DESC;} |
| 161530 | 162111 | break; |
| 161531 | 162112 | case 145: /* limit_opt ::= LIMIT expr */ |
| 161532 | | -{yymsp[-1].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy602,0);} |
| 162113 | +{yymsp[-1].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy404,0);} |
| 161533 | 162114 | break; |
| 161534 | 162115 | case 146: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 161535 | | -{yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);} |
| 162116 | +{yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);} |
| 161536 | 162117 | break; |
| 161537 | 162118 | case 147: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 161538 | | -{yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy602,yymsp[-2].minor.yy602);} |
| 162119 | +{yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy404,yymsp[-2].minor.yy404);} |
| 161539 | 162120 | break; |
| 161540 | 162121 | case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 161541 | 162122 | { |
| 161542 | | - sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy291, &yymsp[-1].minor.yy0); |
| 161543 | | - sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy291,yymsp[0].minor.yy602,0,0); |
| 162123 | + sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy153, &yymsp[-1].minor.yy0); |
| 162124 | + sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy153,yymsp[0].minor.yy404,0,0); |
| 161544 | 162125 | } |
| 161545 | 162126 | break; |
| 161546 | 162127 | case 153: /* where_opt_ret ::= RETURNING selcollist */ |
| 161547 | | -{sqlite3AddReturning(pParse,yymsp[0].minor.yy338); yymsp[-1].minor.yy602 = 0;} |
| 162128 | +{sqlite3AddReturning(pParse,yymsp[0].minor.yy70); yymsp[-1].minor.yy404 = 0;} |
| 161548 | 162129 | break; |
| 161549 | 162130 | case 154: /* where_opt_ret ::= WHERE expr RETURNING selcollist */ |
| 161550 | | -{sqlite3AddReturning(pParse,yymsp[0].minor.yy338); yymsp[-3].minor.yy602 = yymsp[-2].minor.yy602;} |
| 162131 | +{sqlite3AddReturning(pParse,yymsp[0].minor.yy70); yymsp[-3].minor.yy404 = yymsp[-2].minor.yy404;} |
| 161551 | 162132 | break; |
| 161552 | 162133 | case 155: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ |
| 161553 | 162134 | { |
| 161554 | | - sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy291, &yymsp[-4].minor.yy0); |
| 161555 | | - sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy338,"set list"); |
| 161556 | | - yymsp[-5].minor.yy291 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy291, yymsp[-1].minor.yy291); |
| 161557 | | - sqlite3Update(pParse,yymsp[-5].minor.yy291,yymsp[-2].minor.yy338,yymsp[0].minor.yy602,yymsp[-6].minor.yy60,0,0,0); |
| 162135 | + sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy153, &yymsp[-4].minor.yy0); |
| 162136 | + sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy70,"set list"); |
| 162137 | + yymsp[-5].minor.yy153 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy153, yymsp[-1].minor.yy153); |
| 162138 | + sqlite3Update(pParse,yymsp[-5].minor.yy153,yymsp[-2].minor.yy70,yymsp[0].minor.yy404,yymsp[-6].minor.yy376,0,0,0); |
| 161558 | 162139 | } |
| 161559 | 162140 | break; |
| 161560 | 162141 | case 156: /* setlist ::= setlist COMMA nm EQ expr */ |
| 161561 | 162142 | { |
| 161562 | | - yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy338, yymsp[0].minor.yy602); |
| 161563 | | - sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy338, &yymsp[-2].minor.yy0, 1); |
| 162143 | + yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy70, yymsp[0].minor.yy404); |
| 162144 | + sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy70, &yymsp[-2].minor.yy0, 1); |
| 161564 | 162145 | } |
| 161565 | 162146 | break; |
| 161566 | 162147 | case 157: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 161567 | 162148 | { |
| 161568 | | - yymsp[-6].minor.yy338 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy338, yymsp[-3].minor.yy288, yymsp[0].minor.yy602); |
| 162149 | + yymsp[-6].minor.yy70 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy70, yymsp[-3].minor.yy436, yymsp[0].minor.yy404); |
| 161569 | 162150 | } |
| 161570 | 162151 | break; |
| 161571 | 162152 | case 158: /* setlist ::= nm EQ expr */ |
| 161572 | 162153 | { |
| 161573 | | - yylhsminor.yy338 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy602); |
| 161574 | | - sqlite3ExprListSetName(pParse, yylhsminor.yy338, &yymsp[-2].minor.yy0, 1); |
| 162154 | + yylhsminor.yy70 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy404); |
| 162155 | + sqlite3ExprListSetName(pParse, yylhsminor.yy70, &yymsp[-2].minor.yy0, 1); |
| 161575 | 162156 | } |
| 161576 | | - yymsp[-2].minor.yy338 = yylhsminor.yy338; |
| 162157 | + yymsp[-2].minor.yy70 = yylhsminor.yy70; |
| 161577 | 162158 | break; |
| 161578 | 162159 | case 159: /* setlist ::= LP idlist RP EQ expr */ |
| 161579 | 162160 | { |
| 161580 | | - yymsp[-4].minor.yy338 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy288, yymsp[0].minor.yy602); |
| 162161 | + yymsp[-4].minor.yy70 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy436, yymsp[0].minor.yy404); |
| 161581 | 162162 | } |
| 161582 | 162163 | break; |
| 161583 | 162164 | case 160: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 161584 | 162165 | { |
| 161585 | | - sqlite3Insert(pParse, yymsp[-3].minor.yy291, yymsp[-1].minor.yy307, yymsp[-2].minor.yy288, yymsp[-5].minor.yy60, yymsp[0].minor.yy178); |
| 162166 | + sqlite3Insert(pParse, yymsp[-3].minor.yy153, yymsp[-1].minor.yy81, yymsp[-2].minor.yy436, yymsp[-5].minor.yy376, yymsp[0].minor.yy190); |
| 161586 | 162167 | } |
| 161587 | 162168 | break; |
| 161588 | 162169 | case 161: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 161589 | 162170 | { |
| 161590 | | - sqlite3Insert(pParse, yymsp[-4].minor.yy291, 0, yymsp[-3].minor.yy288, yymsp[-6].minor.yy60, 0); |
| 162171 | + sqlite3Insert(pParse, yymsp[-4].minor.yy153, 0, yymsp[-3].minor.yy436, yymsp[-6].minor.yy376, 0); |
| 161591 | 162172 | } |
| 161592 | 162173 | break; |
| 161593 | 162174 | case 162: /* upsert ::= */ |
| 161594 | | -{ yymsp[1].minor.yy178 = 0; } |
| 162175 | +{ yymsp[1].minor.yy190 = 0; } |
| 161595 | 162176 | break; |
| 161596 | 162177 | case 163: /* upsert ::= RETURNING selcollist */ |
| 161597 | | -{ yymsp[-1].minor.yy178 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy338); } |
| 162178 | +{ yymsp[-1].minor.yy190 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy70); } |
| 161598 | 162179 | break; |
| 161599 | 162180 | case 164: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ |
| 161600 | | -{ 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);} |
| 162181 | +{ 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);} |
| 161601 | 162182 | break; |
| 161602 | 162183 | case 165: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 161603 | | -{ yymsp[-8].minor.yy178 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy338,yymsp[-3].minor.yy602,0,0,yymsp[0].minor.yy178); } |
| 162184 | +{ yymsp[-8].minor.yy190 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy70,yymsp[-3].minor.yy404,0,0,yymsp[0].minor.yy190); } |
| 161604 | 162185 | break; |
| 161605 | 162186 | case 166: /* upsert ::= ON CONFLICT DO NOTHING returning */ |
| 161606 | | -{ yymsp[-4].minor.yy178 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); } |
| 162187 | +{ yymsp[-4].minor.yy190 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); } |
| 161607 | 162188 | break; |
| 161608 | 162189 | case 167: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 161609 | | -{ yymsp[-7].minor.yy178 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602,0);} |
| 162190 | +{ yymsp[-7].minor.yy190 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404,0);} |
| 161610 | 162191 | break; |
| 161611 | 162192 | case 168: /* returning ::= RETURNING selcollist */ |
| 161612 | | -{sqlite3AddReturning(pParse,yymsp[0].minor.yy338);} |
| 162193 | +{sqlite3AddReturning(pParse,yymsp[0].minor.yy70);} |
| 161613 | 162194 | break; |
| 161614 | 162195 | case 172: /* idlist_opt ::= LP idlist RP */ |
| 161615 | | -{yymsp[-2].minor.yy288 = yymsp[-1].minor.yy288;} |
| 162196 | +{yymsp[-2].minor.yy436 = yymsp[-1].minor.yy436;} |
| 161616 | 162197 | break; |
| 161617 | 162198 | case 173: /* idlist ::= idlist COMMA nm */ |
| 161618 | | -{yymsp[-2].minor.yy288 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy288,&yymsp[0].minor.yy0);} |
| 162199 | +{yymsp[-2].minor.yy436 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy436,&yymsp[0].minor.yy0);} |
| 161619 | 162200 | break; |
| 161620 | 162201 | case 174: /* idlist ::= nm */ |
| 161621 | | -{yymsp[0].minor.yy288 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} |
| 162202 | +{yymsp[0].minor.yy436 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} |
| 161622 | 162203 | break; |
| 161623 | 162204 | case 175: /* expr ::= LP expr RP */ |
| 161624 | | -{yymsp[-2].minor.yy602 = yymsp[-1].minor.yy602;} |
| 162205 | +{yymsp[-2].minor.yy404 = yymsp[-1].minor.yy404;} |
| 161625 | 162206 | break; |
| 161626 | 162207 | case 176: /* expr ::= ID|INDEXED */ |
| 161627 | 162208 | case 177: /* expr ::= JOIN_KW */ yytestcase(yyruleno==177); |
| 161628 | | -{yymsp[0].minor.yy602=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 162209 | +{yymsp[0].minor.yy404=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 161629 | 162210 | break; |
| 161630 | 162211 | case 178: /* expr ::= nm DOT nm */ |
| 161631 | 162212 | { |
| 161632 | 162213 | Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); |
| 161633 | 162214 | Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1); |
| 161634 | 162215 | if( IN_RENAME_OBJECT ){ |
| 161635 | 162216 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0); |
| 161636 | 162217 | sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0); |
| 161637 | 162218 | } |
| 161638 | | - yylhsminor.yy602 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); |
| 162219 | + yylhsminor.yy404 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); |
| 161639 | 162220 | } |
| 161640 | | - yymsp[-2].minor.yy602 = yylhsminor.yy602; |
| 162221 | + yymsp[-2].minor.yy404 = yylhsminor.yy404; |
| 161641 | 162222 | break; |
| 161642 | 162223 | case 179: /* expr ::= nm DOT nm DOT nm */ |
| 161643 | 162224 | { |
| 161644 | 162225 | Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1); |
| 161645 | 162226 | Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); |
| | @@ -161647,322 +162228,322 @@ |
| 161647 | 162228 | Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3); |
| 161648 | 162229 | if( IN_RENAME_OBJECT ){ |
| 161649 | 162230 | sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0); |
| 161650 | 162231 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0); |
| 161651 | 162232 | } |
| 161652 | | - yylhsminor.yy602 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); |
| 162233 | + yylhsminor.yy404 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); |
| 161653 | 162234 | } |
| 161654 | | - yymsp[-4].minor.yy602 = yylhsminor.yy602; |
| 162235 | + yymsp[-4].minor.yy404 = yylhsminor.yy404; |
| 161655 | 162236 | break; |
| 161656 | 162237 | case 180: /* term ::= NULL|FLOAT|BLOB */ |
| 161657 | 162238 | case 181: /* term ::= STRING */ yytestcase(yyruleno==181); |
| 161658 | | -{yymsp[0].minor.yy602=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 162239 | +{yymsp[0].minor.yy404=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 161659 | 162240 | break; |
| 161660 | 162241 | case 182: /* term ::= INTEGER */ |
| 161661 | 162242 | { |
| 161662 | | - yylhsminor.yy602 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); |
| 162243 | + yylhsminor.yy404 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); |
| 161663 | 162244 | } |
| 161664 | | - yymsp[0].minor.yy602 = yylhsminor.yy602; |
| 162245 | + yymsp[0].minor.yy404 = yylhsminor.yy404; |
| 161665 | 162246 | break; |
| 161666 | 162247 | case 183: /* expr ::= VARIABLE */ |
| 161667 | 162248 | { |
| 161668 | 162249 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ |
| 161669 | 162250 | u32 n = yymsp[0].minor.yy0.n; |
| 161670 | | - yymsp[0].minor.yy602 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); |
| 161671 | | - sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy602, n); |
| 162251 | + yymsp[0].minor.yy404 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); |
| 162252 | + sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy404, n); |
| 161672 | 162253 | }else{ |
| 161673 | 162254 | /* When doing a nested parse, one can include terms in an expression |
| 161674 | 162255 | ** that look like this: #1 #2 ... These terms refer to registers |
| 161675 | 162256 | ** in the virtual machine. #N is the N-th register. */ |
| 161676 | 162257 | Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/ |
| 161677 | 162258 | assert( t.n>=2 ); |
| 161678 | 162259 | if( pParse->nested==0 ){ |
| 161679 | 162260 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); |
| 161680 | | - yymsp[0].minor.yy602 = 0; |
| 162261 | + yymsp[0].minor.yy404 = 0; |
| 161681 | 162262 | }else{ |
| 161682 | | - yymsp[0].minor.yy602 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); |
| 161683 | | - if( yymsp[0].minor.yy602 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy602->iTable); |
| 162263 | + yymsp[0].minor.yy404 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); |
| 162264 | + if( yymsp[0].minor.yy404 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy404->iTable); |
| 161684 | 162265 | } |
| 161685 | 162266 | } |
| 161686 | 162267 | } |
| 161687 | 162268 | break; |
| 161688 | 162269 | case 184: /* expr ::= expr COLLATE ID|STRING */ |
| 161689 | 162270 | { |
| 161690 | | - yymsp[-2].minor.yy602 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy602, &yymsp[0].minor.yy0, 1); |
| 162271 | + yymsp[-2].minor.yy404 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy404, &yymsp[0].minor.yy0, 1); |
| 161691 | 162272 | } |
| 161692 | 162273 | break; |
| 161693 | 162274 | case 185: /* expr ::= CAST LP expr AS typetoken RP */ |
| 161694 | 162275 | { |
| 161695 | | - yymsp[-5].minor.yy602 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); |
| 161696 | | - sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy602, yymsp[-3].minor.yy602, 0); |
| 162276 | + yymsp[-5].minor.yy404 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); |
| 162277 | + sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy404, yymsp[-3].minor.yy404, 0); |
| 161697 | 162278 | } |
| 161698 | 162279 | break; |
| 161699 | 162280 | case 186: /* expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 161700 | 162281 | { |
| 161701 | | - yylhsminor.yy602 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy338, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy60); |
| 162282 | + yylhsminor.yy404 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy70, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy376); |
| 161702 | 162283 | } |
| 161703 | | - yymsp[-4].minor.yy602 = yylhsminor.yy602; |
| 162284 | + yymsp[-4].minor.yy404 = yylhsminor.yy404; |
| 161704 | 162285 | break; |
| 161705 | 162286 | case 187: /* expr ::= ID|INDEXED LP STAR RP */ |
| 161706 | 162287 | { |
| 161707 | | - yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); |
| 162288 | + yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); |
| 161708 | 162289 | } |
| 161709 | | - yymsp[-3].minor.yy602 = yylhsminor.yy602; |
| 162290 | + yymsp[-3].minor.yy404 = yylhsminor.yy404; |
| 161710 | 162291 | break; |
| 161711 | 162292 | case 188: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ |
| 161712 | 162293 | { |
| 161713 | | - yylhsminor.yy602 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy338, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy60); |
| 161714 | | - sqlite3WindowAttach(pParse, yylhsminor.yy602, yymsp[0].minor.yy19); |
| 162294 | + yylhsminor.yy404 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy70, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy376); |
| 162295 | + sqlite3WindowAttach(pParse, yylhsminor.yy404, yymsp[0].minor.yy49); |
| 161715 | 162296 | } |
| 161716 | | - yymsp[-5].minor.yy602 = yylhsminor.yy602; |
| 162297 | + yymsp[-5].minor.yy404 = yylhsminor.yy404; |
| 161717 | 162298 | break; |
| 161718 | 162299 | case 189: /* expr ::= ID|INDEXED LP STAR RP filter_over */ |
| 161719 | 162300 | { |
| 161720 | | - yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); |
| 161721 | | - sqlite3WindowAttach(pParse, yylhsminor.yy602, yymsp[0].minor.yy19); |
| 162301 | + yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); |
| 162302 | + sqlite3WindowAttach(pParse, yylhsminor.yy404, yymsp[0].minor.yy49); |
| 161722 | 162303 | } |
| 161723 | | - yymsp[-4].minor.yy602 = yylhsminor.yy602; |
| 162304 | + yymsp[-4].minor.yy404 = yylhsminor.yy404; |
| 161724 | 162305 | break; |
| 161725 | 162306 | case 190: /* term ::= CTIME_KW */ |
| 161726 | 162307 | { |
| 161727 | | - yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); |
| 162308 | + yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); |
| 161728 | 162309 | } |
| 161729 | | - yymsp[0].minor.yy602 = yylhsminor.yy602; |
| 162310 | + yymsp[0].minor.yy404 = yylhsminor.yy404; |
| 161730 | 162311 | break; |
| 161731 | 162312 | case 191: /* expr ::= LP nexprlist COMMA expr RP */ |
| 161732 | 162313 | { |
| 161733 | | - ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy338, yymsp[-1].minor.yy602); |
| 161734 | | - yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); |
| 161735 | | - if( yymsp[-4].minor.yy602 ){ |
| 161736 | | - yymsp[-4].minor.yy602->x.pList = pList; |
| 162314 | + ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy70, yymsp[-1].minor.yy404); |
| 162315 | + yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); |
| 162316 | + if( yymsp[-4].minor.yy404 ){ |
| 162317 | + yymsp[-4].minor.yy404->x.pList = pList; |
| 161737 | 162318 | if( ALWAYS(pList->nExpr) ){ |
| 161738 | | - yymsp[-4].minor.yy602->flags |= pList->a[0].pExpr->flags & EP_Propagate; |
| 162319 | + yymsp[-4].minor.yy404->flags |= pList->a[0].pExpr->flags & EP_Propagate; |
| 161739 | 162320 | } |
| 161740 | 162321 | }else{ |
| 161741 | 162322 | sqlite3ExprListDelete(pParse->db, pList); |
| 161742 | 162323 | } |
| 161743 | 162324 | } |
| 161744 | 162325 | break; |
| 161745 | 162326 | case 192: /* expr ::= expr AND expr */ |
| 161746 | | -{yymsp[-2].minor.yy602=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);} |
| 162327 | +{yymsp[-2].minor.yy404=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);} |
| 161747 | 162328 | break; |
| 161748 | 162329 | case 193: /* expr ::= expr OR expr */ |
| 161749 | 162330 | case 194: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==194); |
| 161750 | 162331 | case 195: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==195); |
| 161751 | 162332 | case 196: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==196); |
| 161752 | 162333 | case 197: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==197); |
| 161753 | 162334 | case 198: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==198); |
| 161754 | 162335 | case 199: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==199); |
| 161755 | | -{yymsp[-2].minor.yy602=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);} |
| 162336 | +{yymsp[-2].minor.yy404=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);} |
| 161756 | 162337 | break; |
| 161757 | 162338 | case 200: /* likeop ::= NOT LIKE_KW|MATCH */ |
| 161758 | 162339 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} |
| 161759 | 162340 | break; |
| 161760 | 162341 | case 201: /* expr ::= expr likeop expr */ |
| 161761 | 162342 | { |
| 161762 | 162343 | ExprList *pList; |
| 161763 | 162344 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; |
| 161764 | 162345 | yymsp[-1].minor.yy0.n &= 0x7fffffff; |
| 161765 | | - pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy602); |
| 161766 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy602); |
| 161767 | | - yymsp[-2].minor.yy602 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 161768 | | - if( bNot ) yymsp[-2].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy602, 0); |
| 161769 | | - if( yymsp[-2].minor.yy602 ) yymsp[-2].minor.yy602->flags |= EP_InfixFunc; |
| 162346 | + pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy404); |
| 162347 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy404); |
| 162348 | + yymsp[-2].minor.yy404 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 162349 | + if( bNot ) yymsp[-2].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy404, 0); |
| 162350 | + if( yymsp[-2].minor.yy404 ) yymsp[-2].minor.yy404->flags |= EP_InfixFunc; |
| 161770 | 162351 | } |
| 161771 | 162352 | break; |
| 161772 | 162353 | case 202: /* expr ::= expr likeop expr ESCAPE expr */ |
| 161773 | 162354 | { |
| 161774 | 162355 | ExprList *pList; |
| 161775 | 162356 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; |
| 161776 | 162357 | yymsp[-3].minor.yy0.n &= 0x7fffffff; |
| 161777 | | - pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602); |
| 161778 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy602); |
| 161779 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy602); |
| 161780 | | - yymsp[-4].minor.yy602 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); |
| 161781 | | - if( bNot ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 161782 | | - if( yymsp[-4].minor.yy602 ) yymsp[-4].minor.yy602->flags |= EP_InfixFunc; |
| 162358 | + pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404); |
| 162359 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy404); |
| 162360 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy404); |
| 162361 | + yymsp[-4].minor.yy404 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); |
| 162362 | + if( bNot ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 162363 | + if( yymsp[-4].minor.yy404 ) yymsp[-4].minor.yy404->flags |= EP_InfixFunc; |
| 161783 | 162364 | } |
| 161784 | 162365 | break; |
| 161785 | 162366 | case 203: /* expr ::= expr ISNULL|NOTNULL */ |
| 161786 | | -{yymsp[-1].minor.yy602 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy602,0);} |
| 162367 | +{yymsp[-1].minor.yy404 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy404,0);} |
| 161787 | 162368 | break; |
| 161788 | 162369 | case 204: /* expr ::= expr NOT NULL */ |
| 161789 | | -{yymsp[-2].minor.yy602 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy602,0);} |
| 162370 | +{yymsp[-2].minor.yy404 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy404,0);} |
| 161790 | 162371 | break; |
| 161791 | 162372 | case 205: /* expr ::= expr IS expr */ |
| 161792 | 162373 | { |
| 161793 | | - yymsp[-2].minor.yy602 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy602,yymsp[0].minor.yy602); |
| 161794 | | - binaryToUnaryIfNull(pParse, yymsp[0].minor.yy602, yymsp[-2].minor.yy602, TK_ISNULL); |
| 162374 | + yymsp[-2].minor.yy404 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy404,yymsp[0].minor.yy404); |
| 162375 | + binaryToUnaryIfNull(pParse, yymsp[0].minor.yy404, yymsp[-2].minor.yy404, TK_ISNULL); |
| 161795 | 162376 | } |
| 161796 | 162377 | break; |
| 161797 | 162378 | case 206: /* expr ::= expr IS NOT expr */ |
| 161798 | 162379 | { |
| 161799 | | - yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy602,yymsp[0].minor.yy602); |
| 161800 | | - binaryToUnaryIfNull(pParse, yymsp[0].minor.yy602, yymsp[-3].minor.yy602, TK_NOTNULL); |
| 162380 | + yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy404,yymsp[0].minor.yy404); |
| 162381 | + binaryToUnaryIfNull(pParse, yymsp[0].minor.yy404, yymsp[-3].minor.yy404, TK_NOTNULL); |
| 161801 | 162382 | } |
| 161802 | 162383 | break; |
| 161803 | 162384 | case 207: /* expr ::= NOT expr */ |
| 161804 | 162385 | case 208: /* expr ::= BITNOT expr */ yytestcase(yyruleno==208); |
| 161805 | | -{yymsp[-1].minor.yy602 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy602, 0);/*A-overwrites-B*/} |
| 162386 | +{yymsp[-1].minor.yy404 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy404, 0);/*A-overwrites-B*/} |
| 161806 | 162387 | break; |
| 161807 | 162388 | case 209: /* expr ::= PLUS|MINUS expr */ |
| 161808 | 162389 | { |
| 161809 | | - yymsp[-1].minor.yy602 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy602, 0); |
| 162390 | + yymsp[-1].minor.yy404 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy404, 0); |
| 161810 | 162391 | /*A-overwrites-B*/ |
| 161811 | 162392 | } |
| 161812 | 162393 | break; |
| 161813 | 162394 | case 210: /* between_op ::= BETWEEN */ |
| 161814 | 162395 | case 213: /* in_op ::= IN */ yytestcase(yyruleno==213); |
| 161815 | | -{yymsp[0].minor.yy60 = 0;} |
| 162396 | +{yymsp[0].minor.yy376 = 0;} |
| 161816 | 162397 | break; |
| 161817 | 162398 | case 212: /* expr ::= expr between_op expr AND expr */ |
| 161818 | 162399 | { |
| 161819 | | - ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602); |
| 161820 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy602); |
| 161821 | | - yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy602, 0); |
| 161822 | | - if( yymsp[-4].minor.yy602 ){ |
| 161823 | | - yymsp[-4].minor.yy602->x.pList = pList; |
| 162400 | + ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404); |
| 162401 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy404); |
| 162402 | + yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy404, 0); |
| 162403 | + if( yymsp[-4].minor.yy404 ){ |
| 162404 | + yymsp[-4].minor.yy404->x.pList = pList; |
| 161824 | 162405 | }else{ |
| 161825 | 162406 | sqlite3ExprListDelete(pParse->db, pList); |
| 161826 | 162407 | } |
| 161827 | | - if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 162408 | + if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 161828 | 162409 | } |
| 161829 | 162410 | break; |
| 161830 | 162411 | case 215: /* expr ::= expr in_op LP exprlist RP */ |
| 161831 | 162412 | { |
| 161832 | | - if( yymsp[-1].minor.yy338==0 ){ |
| 162413 | + if( yymsp[-1].minor.yy70==0 ){ |
| 161833 | 162414 | /* Expressions of the form |
| 161834 | 162415 | ** |
| 161835 | 162416 | ** expr1 IN () |
| 161836 | 162417 | ** expr1 NOT IN () |
| 161837 | 162418 | ** |
| 161838 | 162419 | ** simplify to constants 0 (false) and 1 (true), respectively, |
| 161839 | 162420 | ** regardless of the value of expr1. |
| 161840 | 162421 | */ |
| 161841 | | - sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy602); |
| 161842 | | - yymsp[-4].minor.yy602 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy60 ? "1" : "0"); |
| 161843 | | - }else if( yymsp[-1].minor.yy338->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy338->a[0].pExpr) ){ |
| 161844 | | - Expr *pRHS = yymsp[-1].minor.yy338->a[0].pExpr; |
| 161845 | | - yymsp[-1].minor.yy338->a[0].pExpr = 0; |
| 161846 | | - sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy338); |
| 162422 | + sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy404); |
| 162423 | + yymsp[-4].minor.yy404 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy376 ? "1" : "0"); |
| 162424 | + }else if( yymsp[-1].minor.yy70->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy70->a[0].pExpr) ){ |
| 162425 | + Expr *pRHS = yymsp[-1].minor.yy70->a[0].pExpr; |
| 162426 | + yymsp[-1].minor.yy70->a[0].pExpr = 0; |
| 162427 | + sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70); |
| 161847 | 162428 | pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0); |
| 161848 | | - yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy602, pRHS); |
| 161849 | | - if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 161850 | | - }else{ |
| 161851 | | - yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0); |
| 161852 | | - if( yymsp[-4].minor.yy602 ){ |
| 161853 | | - yymsp[-4].minor.yy602->x.pList = yymsp[-1].minor.yy338; |
| 161854 | | - sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy602); |
| 161855 | | - }else{ |
| 161856 | | - sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy338); |
| 161857 | | - } |
| 161858 | | - if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 162429 | + yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy404, pRHS); |
| 162430 | + if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 162431 | + }else{ |
| 162432 | + yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0); |
| 162433 | + if( yymsp[-4].minor.yy404 ){ |
| 162434 | + yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy70; |
| 162435 | + sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404); |
| 162436 | + }else{ |
| 162437 | + sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70); |
| 162438 | + } |
| 162439 | + if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 161859 | 162440 | } |
| 161860 | 162441 | } |
| 161861 | 162442 | break; |
| 161862 | 162443 | case 216: /* expr ::= LP select RP */ |
| 161863 | 162444 | { |
| 161864 | | - yymsp[-2].minor.yy602 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); |
| 161865 | | - sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy602, yymsp[-1].minor.yy307); |
| 162445 | + yymsp[-2].minor.yy404 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); |
| 162446 | + sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy404, yymsp[-1].minor.yy81); |
| 161866 | 162447 | } |
| 161867 | 162448 | break; |
| 161868 | 162449 | case 217: /* expr ::= expr in_op LP select RP */ |
| 161869 | 162450 | { |
| 161870 | | - yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0); |
| 161871 | | - sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy602, yymsp[-1].minor.yy307); |
| 161872 | | - if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 162451 | + yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0); |
| 162452 | + sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, yymsp[-1].minor.yy81); |
| 162453 | + if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 161873 | 162454 | } |
| 161874 | 162455 | break; |
| 161875 | 162456 | case 218: /* expr ::= expr in_op nm dbnm paren_exprlist */ |
| 161876 | 162457 | { |
| 161877 | 162458 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); |
| 161878 | 162459 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); |
| 161879 | | - if( yymsp[0].minor.yy338 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy338); |
| 161880 | | - yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0); |
| 161881 | | - sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy602, pSelect); |
| 161882 | | - if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 162460 | + if( yymsp[0].minor.yy70 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy70); |
| 162461 | + yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0); |
| 162462 | + sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, pSelect); |
| 162463 | + if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); |
| 161883 | 162464 | } |
| 161884 | 162465 | break; |
| 161885 | 162466 | case 219: /* expr ::= EXISTS LP select RP */ |
| 161886 | 162467 | { |
| 161887 | 162468 | Expr *p; |
| 161888 | | - p = yymsp[-3].minor.yy602 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); |
| 161889 | | - sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy307); |
| 162469 | + p = yymsp[-3].minor.yy404 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); |
| 162470 | + sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy81); |
| 161890 | 162471 | } |
| 161891 | 162472 | break; |
| 161892 | 162473 | case 220: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 161893 | 162474 | { |
| 161894 | | - yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy602, 0); |
| 161895 | | - if( yymsp[-4].minor.yy602 ){ |
| 161896 | | - yymsp[-4].minor.yy602->x.pList = yymsp[-1].minor.yy602 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602) : yymsp[-2].minor.yy338; |
| 161897 | | - sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy602); |
| 162475 | + yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy404, 0); |
| 162476 | + if( yymsp[-4].minor.yy404 ){ |
| 162477 | + yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy404 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404) : yymsp[-2].minor.yy70; |
| 162478 | + sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404); |
| 161898 | 162479 | }else{ |
| 161899 | | - sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy338); |
| 161900 | | - sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy602); |
| 162480 | + sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy70); |
| 162481 | + sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy404); |
| 161901 | 162482 | } |
| 161902 | 162483 | } |
| 161903 | 162484 | break; |
| 161904 | 162485 | case 221: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 161905 | 162486 | { |
| 161906 | | - yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, yymsp[-2].minor.yy602); |
| 161907 | | - yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, yymsp[0].minor.yy602); |
| 162487 | + yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, yymsp[-2].minor.yy404); |
| 162488 | + yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, yymsp[0].minor.yy404); |
| 161908 | 162489 | } |
| 161909 | 162490 | break; |
| 161910 | 162491 | case 222: /* case_exprlist ::= WHEN expr THEN expr */ |
| 161911 | 162492 | { |
| 161912 | | - yymsp[-3].minor.yy338 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602); |
| 161913 | | - yymsp[-3].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy338, yymsp[0].minor.yy602); |
| 162493 | + yymsp[-3].minor.yy70 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404); |
| 162494 | + yymsp[-3].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy70, yymsp[0].minor.yy404); |
| 161914 | 162495 | } |
| 161915 | 162496 | break; |
| 161916 | 162497 | case 225: /* case_operand ::= expr */ |
| 161917 | | -{yymsp[0].minor.yy602 = yymsp[0].minor.yy602; /*A-overwrites-X*/} |
| 162498 | +{yymsp[0].minor.yy404 = yymsp[0].minor.yy404; /*A-overwrites-X*/} |
| 161918 | 162499 | break; |
| 161919 | 162500 | case 228: /* nexprlist ::= nexprlist COMMA expr */ |
| 161920 | | -{yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy338,yymsp[0].minor.yy602);} |
| 162501 | +{yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy70,yymsp[0].minor.yy404);} |
| 161921 | 162502 | break; |
| 161922 | 162503 | case 229: /* nexprlist ::= expr */ |
| 161923 | | -{yymsp[0].minor.yy338 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy602); /*A-overwrites-Y*/} |
| 162504 | +{yymsp[0].minor.yy70 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy404); /*A-overwrites-Y*/} |
| 161924 | 162505 | break; |
| 161925 | 162506 | case 231: /* paren_exprlist ::= LP exprlist RP */ |
| 161926 | 162507 | case 236: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==236); |
| 161927 | | -{yymsp[-2].minor.yy338 = yymsp[-1].minor.yy338;} |
| 162508 | +{yymsp[-2].minor.yy70 = yymsp[-1].minor.yy70;} |
| 161928 | 162509 | break; |
| 161929 | 162510 | case 232: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 161930 | 162511 | { |
| 161931 | 162512 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 161932 | | - sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy338, yymsp[-10].minor.yy60, |
| 161933 | | - &yymsp[-11].minor.yy0, yymsp[0].minor.yy602, SQLITE_SO_ASC, yymsp[-8].minor.yy60, SQLITE_IDXTYPE_APPDEF); |
| 162513 | + sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy70, yymsp[-10].minor.yy376, |
| 162514 | + &yymsp[-11].minor.yy0, yymsp[0].minor.yy404, SQLITE_SO_ASC, yymsp[-8].minor.yy376, SQLITE_IDXTYPE_APPDEF); |
| 161934 | 162515 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ |
| 161935 | 162516 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); |
| 161936 | 162517 | } |
| 161937 | 162518 | } |
| 161938 | 162519 | break; |
| 161939 | 162520 | case 233: /* uniqueflag ::= UNIQUE */ |
| 161940 | 162521 | case 275: /* raisetype ::= ABORT */ yytestcase(yyruleno==275); |
| 161941 | | -{yymsp[0].minor.yy60 = OE_Abort;} |
| 162522 | +{yymsp[0].minor.yy376 = OE_Abort;} |
| 161942 | 162523 | break; |
| 161943 | 162524 | case 234: /* uniqueflag ::= */ |
| 161944 | | -{yymsp[1].minor.yy60 = OE_None;} |
| 162525 | +{yymsp[1].minor.yy376 = OE_None;} |
| 161945 | 162526 | break; |
| 161946 | 162527 | case 237: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 161947 | 162528 | { |
| 161948 | | - yymsp[-4].minor.yy338 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy338, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy60, yymsp[0].minor.yy60); |
| 162529 | + yymsp[-4].minor.yy70 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy70, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy376, yymsp[0].minor.yy376); |
| 161949 | 162530 | } |
| 161950 | 162531 | break; |
| 161951 | 162532 | case 238: /* eidlist ::= nm collate sortorder */ |
| 161952 | 162533 | { |
| 161953 | | - yymsp[-2].minor.yy338 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy60, yymsp[0].minor.yy60); /*A-overwrites-Y*/ |
| 162534 | + yymsp[-2].minor.yy70 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy376, yymsp[0].minor.yy376); /*A-overwrites-Y*/ |
| 161954 | 162535 | } |
| 161955 | 162536 | break; |
| 161956 | 162537 | case 241: /* cmd ::= DROP INDEX ifexists fullname */ |
| 161957 | | -{sqlite3DropIndex(pParse, yymsp[0].minor.yy291, yymsp[-1].minor.yy60);} |
| 162538 | +{sqlite3DropIndex(pParse, yymsp[0].minor.yy153, yymsp[-1].minor.yy376);} |
| 161958 | 162539 | break; |
| 161959 | 162540 | case 242: /* cmd ::= VACUUM vinto */ |
| 161960 | | -{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy602);} |
| 162541 | +{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy404);} |
| 161961 | 162542 | break; |
| 161962 | 162543 | case 243: /* cmd ::= VACUUM nm vinto */ |
| 161963 | | -{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy602);} |
| 162544 | +{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy404);} |
| 161964 | 162545 | break; |
| 161965 | 162546 | case 246: /* cmd ::= PRAGMA nm dbnm */ |
| 161966 | 162547 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 161967 | 162548 | break; |
| 161968 | 162549 | case 247: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| | @@ -161980,54 +162561,54 @@ |
| 161980 | 162561 | case 253: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 161981 | 162562 | { |
| 161982 | 162563 | Token all; |
| 161983 | 162564 | all.z = yymsp[-3].minor.yy0.z; |
| 161984 | 162565 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 161985 | | - sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy483, &all); |
| 162566 | + sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy157, &all); |
| 161986 | 162567 | } |
| 161987 | 162568 | break; |
| 161988 | 162569 | case 254: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 161989 | 162570 | { |
| 161990 | | - 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); |
| 162571 | + 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); |
| 161991 | 162572 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 161992 | 162573 | } |
| 161993 | 162574 | break; |
| 161994 | 162575 | case 255: /* trigger_time ::= BEFORE|AFTER */ |
| 161995 | | -{ yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-X*/ } |
| 162576 | +{ yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-X*/ } |
| 161996 | 162577 | break; |
| 161997 | 162578 | case 256: /* trigger_time ::= INSTEAD OF */ |
| 161998 | | -{ yymsp[-1].minor.yy60 = TK_INSTEAD;} |
| 162579 | +{ yymsp[-1].minor.yy376 = TK_INSTEAD;} |
| 161999 | 162580 | break; |
| 162000 | 162581 | case 257: /* trigger_time ::= */ |
| 162001 | | -{ yymsp[1].minor.yy60 = TK_BEFORE; } |
| 162582 | +{ yymsp[1].minor.yy376 = TK_BEFORE; } |
| 162002 | 162583 | break; |
| 162003 | 162584 | case 258: /* trigger_event ::= DELETE|INSERT */ |
| 162004 | 162585 | case 259: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==259); |
| 162005 | | -{yymsp[0].minor.yy50.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy50.b = 0;} |
| 162586 | +{yymsp[0].minor.yy262.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy262.b = 0;} |
| 162006 | 162587 | break; |
| 162007 | 162588 | case 260: /* trigger_event ::= UPDATE OF idlist */ |
| 162008 | | -{yymsp[-2].minor.yy50.a = TK_UPDATE; yymsp[-2].minor.yy50.b = yymsp[0].minor.yy288;} |
| 162589 | +{yymsp[-2].minor.yy262.a = TK_UPDATE; yymsp[-2].minor.yy262.b = yymsp[0].minor.yy436;} |
| 162009 | 162590 | break; |
| 162010 | 162591 | case 261: /* when_clause ::= */ |
| 162011 | 162592 | case 280: /* key_opt ::= */ yytestcase(yyruleno==280); |
| 162012 | | -{ yymsp[1].minor.yy602 = 0; } |
| 162593 | +{ yymsp[1].minor.yy404 = 0; } |
| 162013 | 162594 | break; |
| 162014 | 162595 | case 262: /* when_clause ::= WHEN expr */ |
| 162015 | 162596 | case 281: /* key_opt ::= KEY expr */ yytestcase(yyruleno==281); |
| 162016 | | -{ yymsp[-1].minor.yy602 = yymsp[0].minor.yy602; } |
| 162597 | +{ yymsp[-1].minor.yy404 = yymsp[0].minor.yy404; } |
| 162017 | 162598 | break; |
| 162018 | 162599 | case 263: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 162019 | 162600 | { |
| 162020 | | - assert( yymsp[-2].minor.yy483!=0 ); |
| 162021 | | - yymsp[-2].minor.yy483->pLast->pNext = yymsp[-1].minor.yy483; |
| 162022 | | - yymsp[-2].minor.yy483->pLast = yymsp[-1].minor.yy483; |
| 162601 | + assert( yymsp[-2].minor.yy157!=0 ); |
| 162602 | + yymsp[-2].minor.yy157->pLast->pNext = yymsp[-1].minor.yy157; |
| 162603 | + yymsp[-2].minor.yy157->pLast = yymsp[-1].minor.yy157; |
| 162023 | 162604 | } |
| 162024 | 162605 | break; |
| 162025 | 162606 | case 264: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 162026 | 162607 | { |
| 162027 | | - assert( yymsp[-1].minor.yy483!=0 ); |
| 162028 | | - yymsp[-1].minor.yy483->pLast = yymsp[-1].minor.yy483; |
| 162608 | + assert( yymsp[-1].minor.yy157!=0 ); |
| 162609 | + yymsp[-1].minor.yy157->pLast = yymsp[-1].minor.yy157; |
| 162029 | 162610 | } |
| 162030 | 162611 | break; |
| 162031 | 162612 | case 265: /* trnm ::= nm DOT nm */ |
| 162032 | 162613 | { |
| 162033 | 162614 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; |
| | @@ -162049,62 +162630,62 @@ |
| 162049 | 162630 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 162050 | 162631 | "within triggers"); |
| 162051 | 162632 | } |
| 162052 | 162633 | break; |
| 162053 | 162634 | case 268: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 162054 | | -{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);} |
| 162055 | | - yymsp[-8].minor.yy483 = yylhsminor.yy483; |
| 162635 | +{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);} |
| 162636 | + yymsp[-8].minor.yy157 = yylhsminor.yy157; |
| 162056 | 162637 | break; |
| 162057 | 162638 | case 269: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 162058 | 162639 | { |
| 162059 | | - 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*/ |
| 162640 | + 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*/ |
| 162060 | 162641 | } |
| 162061 | | - yymsp[-7].minor.yy483 = yylhsminor.yy483; |
| 162642 | + yymsp[-7].minor.yy157 = yylhsminor.yy157; |
| 162062 | 162643 | break; |
| 162063 | 162644 | case 270: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 162064 | | -{yylhsminor.yy483 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy602, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy528);} |
| 162065 | | - yymsp[-5].minor.yy483 = yylhsminor.yy483; |
| 162645 | +{yylhsminor.yy157 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy404, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy504);} |
| 162646 | + yymsp[-5].minor.yy157 = yylhsminor.yy157; |
| 162066 | 162647 | break; |
| 162067 | 162648 | case 271: /* trigger_cmd ::= scanpt select scanpt */ |
| 162068 | | -{yylhsminor.yy483 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy307, yymsp[-2].minor.yy528, yymsp[0].minor.yy528); /*yylhsminor.yy483-overwrites-yymsp[-1].minor.yy307*/} |
| 162069 | | - yymsp[-2].minor.yy483 = yylhsminor.yy483; |
| 162649 | +{yylhsminor.yy157 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy81, yymsp[-2].minor.yy504, yymsp[0].minor.yy504); /*yylhsminor.yy157-overwrites-yymsp[-1].minor.yy81*/} |
| 162650 | + yymsp[-2].minor.yy157 = yylhsminor.yy157; |
| 162070 | 162651 | break; |
| 162071 | 162652 | case 272: /* expr ::= RAISE LP IGNORE RP */ |
| 162072 | 162653 | { |
| 162073 | | - yymsp[-3].minor.yy602 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 162074 | | - if( yymsp[-3].minor.yy602 ){ |
| 162075 | | - yymsp[-3].minor.yy602->affExpr = OE_Ignore; |
| 162654 | + yymsp[-3].minor.yy404 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 162655 | + if( yymsp[-3].minor.yy404 ){ |
| 162656 | + yymsp[-3].minor.yy404->affExpr = OE_Ignore; |
| 162076 | 162657 | } |
| 162077 | 162658 | } |
| 162078 | 162659 | break; |
| 162079 | 162660 | case 273: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 162080 | 162661 | { |
| 162081 | | - yymsp[-5].minor.yy602 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 162082 | | - if( yymsp[-5].minor.yy602 ) { |
| 162083 | | - yymsp[-5].minor.yy602->affExpr = (char)yymsp[-3].minor.yy60; |
| 162662 | + yymsp[-5].minor.yy404 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 162663 | + if( yymsp[-5].minor.yy404 ) { |
| 162664 | + yymsp[-5].minor.yy404->affExpr = (char)yymsp[-3].minor.yy376; |
| 162084 | 162665 | } |
| 162085 | 162666 | } |
| 162086 | 162667 | break; |
| 162087 | 162668 | case 274: /* raisetype ::= ROLLBACK */ |
| 162088 | | -{yymsp[0].minor.yy60 = OE_Rollback;} |
| 162669 | +{yymsp[0].minor.yy376 = OE_Rollback;} |
| 162089 | 162670 | break; |
| 162090 | 162671 | case 276: /* raisetype ::= FAIL */ |
| 162091 | | -{yymsp[0].minor.yy60 = OE_Fail;} |
| 162672 | +{yymsp[0].minor.yy376 = OE_Fail;} |
| 162092 | 162673 | break; |
| 162093 | 162674 | case 277: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 162094 | 162675 | { |
| 162095 | | - sqlite3DropTrigger(pParse,yymsp[0].minor.yy291,yymsp[-1].minor.yy60); |
| 162676 | + sqlite3DropTrigger(pParse,yymsp[0].minor.yy153,yymsp[-1].minor.yy376); |
| 162096 | 162677 | } |
| 162097 | 162678 | break; |
| 162098 | 162679 | case 278: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 162099 | 162680 | { |
| 162100 | | - sqlite3Attach(pParse, yymsp[-3].minor.yy602, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); |
| 162681 | + sqlite3Attach(pParse, yymsp[-3].minor.yy404, yymsp[-1].minor.yy404, yymsp[0].minor.yy404); |
| 162101 | 162682 | } |
| 162102 | 162683 | break; |
| 162103 | 162684 | case 279: /* cmd ::= DETACH database_kw_opt expr */ |
| 162104 | 162685 | { |
| 162105 | | - sqlite3Detach(pParse, yymsp[0].minor.yy602); |
| 162686 | + sqlite3Detach(pParse, yymsp[0].minor.yy404); |
| 162106 | 162687 | } |
| 162107 | 162688 | break; |
| 162108 | 162689 | case 282: /* cmd ::= REINDEX */ |
| 162109 | 162690 | {sqlite3Reindex(pParse, 0, 0);} |
| 162110 | 162691 | break; |
| | @@ -162117,11 +162698,11 @@ |
| 162117 | 162698 | case 285: /* cmd ::= ANALYZE nm dbnm */ |
| 162118 | 162699 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 162119 | 162700 | break; |
| 162120 | 162701 | case 286: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 162121 | 162702 | { |
| 162122 | | - sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy291,&yymsp[0].minor.yy0); |
| 162703 | + sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy153,&yymsp[0].minor.yy0); |
| 162123 | 162704 | } |
| 162124 | 162705 | break; |
| 162125 | 162706 | case 287: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 162126 | 162707 | { |
| 162127 | 162708 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; |
| | @@ -162128,22 +162709,22 @@ |
| 162128 | 162709 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); |
| 162129 | 162710 | } |
| 162130 | 162711 | break; |
| 162131 | 162712 | case 288: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 162132 | 162713 | { |
| 162133 | | - sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy291, &yymsp[0].minor.yy0); |
| 162714 | + sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy153, &yymsp[0].minor.yy0); |
| 162134 | 162715 | } |
| 162135 | 162716 | break; |
| 162136 | 162717 | case 289: /* add_column_fullname ::= fullname */ |
| 162137 | 162718 | { |
| 162138 | 162719 | disableLookaside(pParse); |
| 162139 | | - sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy291); |
| 162720 | + sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy153); |
| 162140 | 162721 | } |
| 162141 | 162722 | break; |
| 162142 | 162723 | case 290: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 162143 | 162724 | { |
| 162144 | | - sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy291, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 162725 | + sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy153, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 162145 | 162726 | } |
| 162146 | 162727 | break; |
| 162147 | 162728 | case 291: /* cmd ::= create_vtab */ |
| 162148 | 162729 | {sqlite3VtabFinishParse(pParse,0);} |
| 162149 | 162730 | break; |
| | @@ -162150,11 +162731,11 @@ |
| 162150 | 162731 | case 292: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 162151 | 162732 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 162152 | 162733 | break; |
| 162153 | 162734 | case 293: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 162154 | 162735 | { |
| 162155 | | - sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy60); |
| 162736 | + sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy376); |
| 162156 | 162737 | } |
| 162157 | 162738 | break; |
| 162158 | 162739 | case 294: /* vtabarg ::= */ |
| 162159 | 162740 | {sqlite3VtabArgInit(pParse);} |
| 162160 | 162741 | break; |
| | @@ -162163,176 +162744,180 @@ |
| 162163 | 162744 | case 297: /* lp ::= LP */ yytestcase(yyruleno==297); |
| 162164 | 162745 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 162165 | 162746 | break; |
| 162166 | 162747 | case 298: /* with ::= WITH wqlist */ |
| 162167 | 162748 | case 299: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==299); |
| 162168 | | -{ sqlite3WithPush(pParse, yymsp[0].minor.yy195, 1); } |
| 162749 | +{ sqlite3WithPush(pParse, yymsp[0].minor.yy103, 1); } |
| 162169 | 162750 | break; |
| 162170 | 162751 | case 300: /* wqas ::= AS */ |
| 162171 | | -{yymsp[0].minor.yy570 = M10d_Any;} |
| 162752 | +{yymsp[0].minor.yy552 = M10d_Any;} |
| 162172 | 162753 | break; |
| 162173 | 162754 | case 301: /* wqas ::= AS MATERIALIZED */ |
| 162174 | | -{yymsp[-1].minor.yy570 = M10d_Yes;} |
| 162755 | +{yymsp[-1].minor.yy552 = M10d_Yes;} |
| 162175 | 162756 | break; |
| 162176 | 162757 | case 302: /* wqas ::= AS NOT MATERIALIZED */ |
| 162177 | | -{yymsp[-2].minor.yy570 = M10d_No;} |
| 162758 | +{yymsp[-2].minor.yy552 = M10d_No;} |
| 162178 | 162759 | break; |
| 162179 | 162760 | case 303: /* wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 162180 | 162761 | { |
| 162181 | | - 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*/ |
| 162762 | + 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*/ |
| 162182 | 162763 | } |
| 162183 | 162764 | break; |
| 162184 | 162765 | case 304: /* wqlist ::= wqitem */ |
| 162185 | 162766 | { |
| 162186 | | - yymsp[0].minor.yy195 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy607); /*A-overwrites-X*/ |
| 162767 | + yymsp[0].minor.yy103 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy329); /*A-overwrites-X*/ |
| 162187 | 162768 | } |
| 162188 | 162769 | break; |
| 162189 | 162770 | case 305: /* wqlist ::= wqlist COMMA wqitem */ |
| 162190 | 162771 | { |
| 162191 | | - yymsp[-2].minor.yy195 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy195, yymsp[0].minor.yy607); |
| 162772 | + yymsp[-2].minor.yy103 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy103, yymsp[0].minor.yy329); |
| 162192 | 162773 | } |
| 162193 | 162774 | break; |
| 162194 | 162775 | case 306: /* windowdefn_list ::= windowdefn */ |
| 162195 | | -{ yylhsminor.yy19 = yymsp[0].minor.yy19; } |
| 162196 | | - yymsp[0].minor.yy19 = yylhsminor.yy19; |
| 162776 | +{ yylhsminor.yy49 = yymsp[0].minor.yy49; } |
| 162777 | + yymsp[0].minor.yy49 = yylhsminor.yy49; |
| 162197 | 162778 | break; |
| 162198 | 162779 | case 307: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 162199 | 162780 | { |
| 162200 | | - assert( yymsp[0].minor.yy19!=0 ); |
| 162201 | | - sqlite3WindowChain(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy19); |
| 162202 | | - yymsp[0].minor.yy19->pNextWin = yymsp[-2].minor.yy19; |
| 162203 | | - yylhsminor.yy19 = yymsp[0].minor.yy19; |
| 162781 | + assert( yymsp[0].minor.yy49!=0 ); |
| 162782 | + sqlite3WindowChain(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy49); |
| 162783 | + yymsp[0].minor.yy49->pNextWin = yymsp[-2].minor.yy49; |
| 162784 | + yylhsminor.yy49 = yymsp[0].minor.yy49; |
| 162204 | 162785 | } |
| 162205 | | - yymsp[-2].minor.yy19 = yylhsminor.yy19; |
| 162786 | + yymsp[-2].minor.yy49 = yylhsminor.yy49; |
| 162206 | 162787 | break; |
| 162207 | 162788 | case 308: /* windowdefn ::= nm AS LP window RP */ |
| 162208 | 162789 | { |
| 162209 | | - if( ALWAYS(yymsp[-1].minor.yy19) ){ |
| 162210 | | - yymsp[-1].minor.yy19->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); |
| 162790 | + if( ALWAYS(yymsp[-1].minor.yy49) ){ |
| 162791 | + yymsp[-1].minor.yy49->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); |
| 162211 | 162792 | } |
| 162212 | | - yylhsminor.yy19 = yymsp[-1].minor.yy19; |
| 162793 | + yylhsminor.yy49 = yymsp[-1].minor.yy49; |
| 162213 | 162794 | } |
| 162214 | | - yymsp[-4].minor.yy19 = yylhsminor.yy19; |
| 162795 | + yymsp[-4].minor.yy49 = yylhsminor.yy49; |
| 162215 | 162796 | break; |
| 162216 | 162797 | case 309: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 162217 | 162798 | { |
| 162218 | | - yymsp[-4].minor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy338, yymsp[-1].minor.yy338, 0); |
| 162799 | + yymsp[-4].minor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy70, yymsp[-1].minor.yy70, 0); |
| 162219 | 162800 | } |
| 162220 | 162801 | break; |
| 162221 | 162802 | case 310: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 162222 | 162803 | { |
| 162223 | | - yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy338, yymsp[-1].minor.yy338, &yymsp[-5].minor.yy0); |
| 162804 | + yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy70, yymsp[-1].minor.yy70, &yymsp[-5].minor.yy0); |
| 162224 | 162805 | } |
| 162225 | | - yymsp[-5].minor.yy19 = yylhsminor.yy19; |
| 162806 | + yymsp[-5].minor.yy49 = yylhsminor.yy49; |
| 162226 | 162807 | break; |
| 162227 | 162808 | case 311: /* window ::= ORDER BY sortlist frame_opt */ |
| 162228 | 162809 | { |
| 162229 | | - yymsp[-3].minor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, yymsp[-1].minor.yy338, 0); |
| 162810 | + yymsp[-3].minor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, yymsp[-1].minor.yy70, 0); |
| 162230 | 162811 | } |
| 162231 | 162812 | break; |
| 162232 | 162813 | case 312: /* window ::= nm ORDER BY sortlist frame_opt */ |
| 162233 | 162814 | { |
| 162234 | | - yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, yymsp[-1].minor.yy338, &yymsp[-4].minor.yy0); |
| 162815 | + yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, yymsp[-1].minor.yy70, &yymsp[-4].minor.yy0); |
| 162235 | 162816 | } |
| 162236 | | - yymsp[-4].minor.yy19 = yylhsminor.yy19; |
| 162817 | + yymsp[-4].minor.yy49 = yylhsminor.yy49; |
| 162237 | 162818 | break; |
| 162238 | 162819 | case 313: /* window ::= frame_opt */ |
| 162239 | 162820 | case 332: /* filter_over ::= over_clause */ yytestcase(yyruleno==332); |
| 162240 | 162821 | { |
| 162241 | | - yylhsminor.yy19 = yymsp[0].minor.yy19; |
| 162822 | + yylhsminor.yy49 = yymsp[0].minor.yy49; |
| 162242 | 162823 | } |
| 162243 | | - yymsp[0].minor.yy19 = yylhsminor.yy19; |
| 162824 | + yymsp[0].minor.yy49 = yylhsminor.yy49; |
| 162244 | 162825 | break; |
| 162245 | 162826 | case 314: /* window ::= nm frame_opt */ |
| 162246 | 162827 | { |
| 162247 | | - yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, 0, &yymsp[-1].minor.yy0); |
| 162828 | + yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, 0, &yymsp[-1].minor.yy0); |
| 162248 | 162829 | } |
| 162249 | | - yymsp[-1].minor.yy19 = yylhsminor.yy19; |
| 162830 | + yymsp[-1].minor.yy49 = yylhsminor.yy49; |
| 162250 | 162831 | break; |
| 162251 | 162832 | case 315: /* frame_opt ::= */ |
| 162252 | 162833 | { |
| 162253 | | - yymsp[1].minor.yy19 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); |
| 162834 | + yymsp[1].minor.yy49 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); |
| 162254 | 162835 | } |
| 162255 | 162836 | break; |
| 162256 | 162837 | case 316: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 162257 | 162838 | { |
| 162258 | | - 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); |
| 162839 | + 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); |
| 162259 | 162840 | } |
| 162260 | | - yymsp[-2].minor.yy19 = yylhsminor.yy19; |
| 162841 | + yymsp[-2].minor.yy49 = yylhsminor.yy49; |
| 162261 | 162842 | break; |
| 162262 | 162843 | case 317: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 162263 | 162844 | { |
| 162264 | | - 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); |
| 162845 | + 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); |
| 162265 | 162846 | } |
| 162266 | | - yymsp[-5].minor.yy19 = yylhsminor.yy19; |
| 162847 | + yymsp[-5].minor.yy49 = yylhsminor.yy49; |
| 162267 | 162848 | break; |
| 162268 | 162849 | case 319: /* frame_bound_s ::= frame_bound */ |
| 162269 | 162850 | case 321: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==321); |
| 162270 | | -{yylhsminor.yy113 = yymsp[0].minor.yy113;} |
| 162271 | | - yymsp[0].minor.yy113 = yylhsminor.yy113; |
| 162851 | +{yylhsminor.yy117 = yymsp[0].minor.yy117;} |
| 162852 | + yymsp[0].minor.yy117 = yylhsminor.yy117; |
| 162272 | 162853 | break; |
| 162273 | 162854 | case 320: /* frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 162274 | 162855 | case 322: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==322); |
| 162275 | 162856 | case 324: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==324); |
| 162276 | | -{yylhsminor.yy113.eType = yymsp[-1].major; yylhsminor.yy113.pExpr = 0;} |
| 162277 | | - yymsp[-1].minor.yy113 = yylhsminor.yy113; |
| 162857 | +{yylhsminor.yy117.eType = yymsp[-1].major; yylhsminor.yy117.pExpr = 0;} |
| 162858 | + yymsp[-1].minor.yy117 = yylhsminor.yy117; |
| 162278 | 162859 | break; |
| 162279 | 162860 | case 323: /* frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 162280 | | -{yylhsminor.yy113.eType = yymsp[0].major; yylhsminor.yy113.pExpr = yymsp[-1].minor.yy602;} |
| 162281 | | - yymsp[-1].minor.yy113 = yylhsminor.yy113; |
| 162861 | +{yylhsminor.yy117.eType = yymsp[0].major; yylhsminor.yy117.pExpr = yymsp[-1].minor.yy404;} |
| 162862 | + yymsp[-1].minor.yy117 = yylhsminor.yy117; |
| 162282 | 162863 | break; |
| 162283 | 162864 | case 325: /* frame_exclude_opt ::= */ |
| 162284 | | -{yymsp[1].minor.yy570 = 0;} |
| 162865 | +{yymsp[1].minor.yy552 = 0;} |
| 162285 | 162866 | break; |
| 162286 | 162867 | case 326: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 162287 | | -{yymsp[-1].minor.yy570 = yymsp[0].minor.yy570;} |
| 162868 | +{yymsp[-1].minor.yy552 = yymsp[0].minor.yy552;} |
| 162288 | 162869 | break; |
| 162289 | 162870 | case 327: /* frame_exclude ::= NO OTHERS */ |
| 162290 | 162871 | case 328: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==328); |
| 162291 | | -{yymsp[-1].minor.yy570 = yymsp[-1].major; /*A-overwrites-X*/} |
| 162872 | +{yymsp[-1].minor.yy552 = yymsp[-1].major; /*A-overwrites-X*/} |
| 162292 | 162873 | break; |
| 162293 | 162874 | case 329: /* frame_exclude ::= GROUP|TIES */ |
| 162294 | | -{yymsp[0].minor.yy570 = yymsp[0].major; /*A-overwrites-X*/} |
| 162875 | +{yymsp[0].minor.yy552 = yymsp[0].major; /*A-overwrites-X*/} |
| 162295 | 162876 | break; |
| 162296 | 162877 | case 330: /* window_clause ::= WINDOW windowdefn_list */ |
| 162297 | | -{ yymsp[-1].minor.yy19 = yymsp[0].minor.yy19; } |
| 162878 | +{ yymsp[-1].minor.yy49 = yymsp[0].minor.yy49; } |
| 162298 | 162879 | break; |
| 162299 | 162880 | case 331: /* filter_over ::= filter_clause over_clause */ |
| 162300 | 162881 | { |
| 162301 | | - yymsp[0].minor.yy19->pFilter = yymsp[-1].minor.yy602; |
| 162302 | | - yylhsminor.yy19 = yymsp[0].minor.yy19; |
| 162882 | + if( yymsp[0].minor.yy49 ){ |
| 162883 | + yymsp[0].minor.yy49->pFilter = yymsp[-1].minor.yy404; |
| 162884 | + }else{ |
| 162885 | + sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy404); |
| 162886 | + } |
| 162887 | + yylhsminor.yy49 = yymsp[0].minor.yy49; |
| 162303 | 162888 | } |
| 162304 | | - yymsp[-1].minor.yy19 = yylhsminor.yy19; |
| 162889 | + yymsp[-1].minor.yy49 = yylhsminor.yy49; |
| 162305 | 162890 | break; |
| 162306 | 162891 | case 333: /* filter_over ::= filter_clause */ |
| 162307 | 162892 | { |
| 162308 | | - yylhsminor.yy19 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 162309 | | - if( yylhsminor.yy19 ){ |
| 162310 | | - yylhsminor.yy19->eFrmType = TK_FILTER; |
| 162311 | | - yylhsminor.yy19->pFilter = yymsp[0].minor.yy602; |
| 162893 | + yylhsminor.yy49 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 162894 | + if( yylhsminor.yy49 ){ |
| 162895 | + yylhsminor.yy49->eFrmType = TK_FILTER; |
| 162896 | + yylhsminor.yy49->pFilter = yymsp[0].minor.yy404; |
| 162312 | 162897 | }else{ |
| 162313 | | - sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy602); |
| 162898 | + sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy404); |
| 162314 | 162899 | } |
| 162315 | 162900 | } |
| 162316 | | - yymsp[0].minor.yy19 = yylhsminor.yy19; |
| 162901 | + yymsp[0].minor.yy49 = yylhsminor.yy49; |
| 162317 | 162902 | break; |
| 162318 | 162903 | case 334: /* over_clause ::= OVER LP window RP */ |
| 162319 | 162904 | { |
| 162320 | | - yymsp[-3].minor.yy19 = yymsp[-1].minor.yy19; |
| 162321 | | - assert( yymsp[-3].minor.yy19!=0 ); |
| 162905 | + yymsp[-3].minor.yy49 = yymsp[-1].minor.yy49; |
| 162906 | + assert( yymsp[-3].minor.yy49!=0 ); |
| 162322 | 162907 | } |
| 162323 | 162908 | break; |
| 162324 | 162909 | case 335: /* over_clause ::= OVER nm */ |
| 162325 | 162910 | { |
| 162326 | | - yymsp[-1].minor.yy19 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 162327 | | - if( yymsp[-1].minor.yy19 ){ |
| 162328 | | - yymsp[-1].minor.yy19->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); |
| 162911 | + yymsp[-1].minor.yy49 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 162912 | + if( yymsp[-1].minor.yy49 ){ |
| 162913 | + yymsp[-1].minor.yy49->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); |
| 162329 | 162914 | } |
| 162330 | 162915 | } |
| 162331 | 162916 | break; |
| 162332 | 162917 | case 336: /* filter_clause ::= FILTER LP WHERE expr RP */ |
| 162333 | | -{ yymsp[-4].minor.yy602 = yymsp[-1].minor.yy602; } |
| 162918 | +{ yymsp[-4].minor.yy404 = yymsp[-1].minor.yy404; } |
| 162334 | 162919 | break; |
| 162335 | 162920 | default: |
| 162336 | 162921 | /* (337) input ::= cmdlist */ yytestcase(yyruleno==337); |
| 162337 | 162922 | /* (338) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==338); |
| 162338 | 162923 | /* (339) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=339); |
| | @@ -162795,10 +163380,11 @@ |
| 162795 | 163380 | #define CC_TILDA 25 /* '~' */ |
| 162796 | 163381 | #define CC_DOT 26 /* '.' */ |
| 162797 | 163382 | #define CC_ID 27 /* unicode characters usable in IDs */ |
| 162798 | 163383 | #define CC_ILLEGAL 28 /* Illegal character */ |
| 162799 | 163384 | #define CC_NUL 29 /* 0x00 */ |
| 163385 | +#define CC_BOM 30 /* First byte of UTF8 BOM: 0xEF 0xBB 0xBF */ |
| 162800 | 163386 | |
| 162801 | 163387 | static const unsigned char aiClass[] = { |
| 162802 | 163388 | #ifdef SQLITE_ASCII |
| 162803 | 163389 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ |
| 162804 | 163390 | /* 0x */ 29, 28, 28, 28, 28, 28, 28, 28, 28, 7, 7, 28, 7, 7, 28, 28, |
| | @@ -162807,18 +163393,18 @@ |
| 162807 | 163393 | /* 3x */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 19, 12, 14, 13, 6, |
| 162808 | 163394 | /* 4x */ 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 162809 | 163395 | /* 5x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 9, 28, 28, 28, 2, |
| 162810 | 163396 | /* 6x */ 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 162811 | 163397 | /* 7x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 28, 10, 28, 25, 28, |
| 162812 | | -/* 8x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 162813 | | -/* 9x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 162814 | | -/* Ax */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 162815 | | -/* Bx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 162816 | | -/* Cx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 162817 | | -/* Dx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 162818 | | -/* Ex */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 162819 | | -/* Fx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 |
| 163398 | +/* 8x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 163399 | +/* 9x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 163400 | +/* Ax */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 163401 | +/* Bx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 163402 | +/* Cx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 163403 | +/* Dx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, |
| 163404 | +/* Ex */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 30, |
| 163405 | +/* Fx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27 |
| 162820 | 163406 | #endif |
| 162821 | 163407 | #ifdef SQLITE_EBCDIC |
| 162822 | 163408 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ |
| 162823 | 163409 | /* 0x */ 29, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 7, 7, 28, 28, |
| 162824 | 163410 | /* 1x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, |
| | @@ -163757,10 +164343,18 @@ |
| 163757 | 164343 | ** SQL keywords start with the letter 'x'. Fall through */ |
| 163758 | 164344 | /* no break */ deliberate_fall_through |
| 163759 | 164345 | } |
| 163760 | 164346 | case CC_KYWD: |
| 163761 | 164347 | case CC_ID: { |
| 164348 | + i = 1; |
| 164349 | + break; |
| 164350 | + } |
| 164351 | + case CC_BOM: { |
| 164352 | + if( z[1]==0xbb && z[2]==0xbf ){ |
| 164353 | + *tokenType = TK_SPACE; |
| 164354 | + return 3; |
| 164355 | + } |
| 163762 | 164356 | i = 1; |
| 163763 | 164357 | break; |
| 163764 | 164358 | } |
| 163765 | 164359 | case CC_NUL: { |
| 163766 | 164360 | *tokenType = TK_ILLEGAL; |
| | @@ -164776,11 +165370,11 @@ |
| 164776 | 165370 | } |
| 164777 | 165371 | if( rc==SQLITE_OK ){ |
| 164778 | 165372 | sqlite3GlobalConfig.isPCacheInit = 1; |
| 164779 | 165373 | rc = sqlite3OsInit(); |
| 164780 | 165374 | } |
| 164781 | | -#ifdef SQLITE_ENABLE_DESERIALIZE |
| 165375 | +#ifndef SQLITE_OMIT_DESERIALIZE |
| 164782 | 165376 | if( rc==SQLITE_OK ){ |
| 164783 | 165377 | rc = sqlite3MemdbInit(); |
| 164784 | 165378 | } |
| 164785 | 165379 | #endif |
| 164786 | 165380 | if( rc==SQLITE_OK ){ |
| | @@ -165191,16 +165785,16 @@ |
| 165191 | 165785 | sqlite3GlobalConfig.szSorterRef = (u32)iVal; |
| 165192 | 165786 | break; |
| 165193 | 165787 | } |
| 165194 | 165788 | #endif /* SQLITE_ENABLE_SORTER_REFERENCES */ |
| 165195 | 165789 | |
| 165196 | | -#ifdef SQLITE_ENABLE_DESERIALIZE |
| 165790 | +#ifndef SQLITE_OMIT_DESERIALIZE |
| 165197 | 165791 | case SQLITE_CONFIG_MEMDB_MAXSIZE: { |
| 165198 | 165792 | sqlite3GlobalConfig.mxMemdbSize = va_arg(ap, sqlite3_int64); |
| 165199 | 165793 | break; |
| 165200 | 165794 | } |
| 165201 | | -#endif /* SQLITE_ENABLE_DESERIALIZE */ |
| 165795 | +#endif /* SQLITE_OMIT_DESERIALIZE */ |
| 165202 | 165796 | |
| 165203 | 165797 | default: { |
| 165204 | 165798 | rc = SQLITE_ERROR; |
| 165205 | 165799 | break; |
| 165206 | 165800 | } |
| | @@ -165745,11 +166339,11 @@ |
| 165745 | 166339 | } |
| 165746 | 166340 | |
| 165747 | 166341 | /* |
| 165748 | 166342 | ** Two variations on the public interface for closing a database |
| 165749 | 166343 | ** connection. The sqlite3_close() version returns SQLITE_BUSY and |
| 165750 | | -** leaves the connection option if there are unfinalized prepared |
| 166344 | +** leaves the connection open if there are unfinalized prepared |
| 165751 | 166345 | ** statements or unfinished sqlite3_backups. The sqlite3_close_v2() |
| 165752 | 166346 | ** version forces the connection to become a zombie if there are |
| 165753 | 166347 | ** unclosed resources, and arranges for deallocation when the last |
| 165754 | 166348 | ** prepare statement or sqlite3_backup closes. |
| 165755 | 166349 | */ |
| | @@ -166355,10 +166949,14 @@ |
| 166355 | 166949 | assert( !db->mallocFailed ); |
| 166356 | 166950 | return SQLITE_BUSY; |
| 166357 | 166951 | }else{ |
| 166358 | 166952 | sqlite3ExpirePreparedStatements(db, 0); |
| 166359 | 166953 | } |
| 166954 | + }else if( xSFunc==0 && xFinal==0 ){ |
| 166955 | + /* Trying to delete a function that does not exist. This is a no-op. |
| 166956 | + ** https://sqlite.org/forum/forumpost/726219164b */ |
| 166957 | + return SQLITE_OK; |
| 166360 | 166958 | } |
| 166361 | 166959 | |
| 166362 | 166960 | p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1); |
| 166363 | 166961 | assert(p || db->mallocFailed); |
| 166364 | 166962 | if( !p ){ |
| | @@ -168750,10 +169348,40 @@ |
| 168750 | 169348 | case 2: *ptr = sqlite3WhereTrace; break; |
| 168751 | 169349 | case 3: sqlite3WhereTrace = *ptr; break; |
| 168752 | 169350 | } |
| 168753 | 169351 | break; |
| 168754 | 169352 | } |
| 169353 | + |
| 169354 | +#ifdef SQLITE_DEBUG |
| 169355 | + /* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue) |
| 169356 | + ** |
| 169357 | + ** If "id" is an integer between 1 and SQLITE_NTUNE then set the value |
| 169358 | + ** of the id-th tuning parameter to *piValue. If "id" is between -1 |
| 169359 | + ** and -SQLITE_NTUNE, then write the current value of the (-id)-th |
| 169360 | + ** tuning parameter into *piValue. |
| 169361 | + ** |
| 169362 | + ** Tuning parameters are for use during transient development builds, |
| 169363 | + ** to help find the best values for constants in the query planner. |
| 169364 | + ** Access tuning parameters using the Tuning(ID) macro. Set the |
| 169365 | + ** parameters in the CLI using ".testctrl tune ID VALUE". |
| 169366 | + ** |
| 169367 | + ** Transient use only. Tuning parameters should not be used in |
| 169368 | + ** checked-in code. |
| 169369 | + */ |
| 169370 | + case SQLITE_TESTCTRL_TUNE: { |
| 169371 | + int id = va_arg(ap, int); |
| 169372 | + int *piValue = va_arg(ap, int*); |
| 169373 | + if( id>0 && id<=SQLITE_NTUNE ){ |
| 169374 | + Tuning(id) = *piValue; |
| 169375 | + }else if( id<0 && id>=-SQLITE_NTUNE ){ |
| 169376 | + *piValue = Tuning(-id); |
| 169377 | + }else{ |
| 169378 | + rc = SQLITE_NOTFOUND; |
| 169379 | + } |
| 169380 | + break; |
| 169381 | + } |
| 169382 | +#endif |
| 168755 | 169383 | } |
| 168756 | 169384 | va_end(ap); |
| 168757 | 169385 | #endif /* SQLITE_UNTESTABLE */ |
| 168758 | 169386 | return rc; |
| 168759 | 169387 | } |
| | @@ -172321,11 +172949,11 @@ |
| 172321 | 172949 | const char *zCsr = zNode; /* Cursor to iterate through node */ |
| 172322 | 172950 | const char *zEnd = &zCsr[nNode];/* End of interior node buffer */ |
| 172323 | 172951 | char *zBuffer = 0; /* Buffer to load terms into */ |
| 172324 | 172952 | i64 nAlloc = 0; /* Size of allocated buffer */ |
| 172325 | 172953 | int isFirstTerm = 1; /* True when processing first term on page */ |
| 172326 | | - sqlite3_int64 iChild; /* Block id of child node to descend to */ |
| 172954 | + u64 iChild; /* Block id of child node to descend to */ |
| 172327 | 172955 | int nBuffer = 0; /* Total term size */ |
| 172328 | 172956 | |
| 172329 | 172957 | /* Skip over the 'height' varint that occurs at the start of every |
| 172330 | 172958 | ** interior node. Then load the blockid of the left-child of the b-tree |
| 172331 | 172959 | ** node into variable iChild. |
| | @@ -172337,12 +172965,12 @@ |
| 172337 | 172965 | ** either more than 20 bytes of allocated space following the nNode bytes of |
| 172338 | 172966 | ** contents, or two zero bytes. Or, if the node is read from the %_segments |
| 172339 | 172967 | ** table, then there are always 20 bytes of zeroed padding following the |
| 172340 | 172968 | ** nNode bytes of content (see sqlite3Fts3ReadBlock() for details). |
| 172341 | 172969 | */ |
| 172342 | | - zCsr += sqlite3Fts3GetVarint(zCsr, &iChild); |
| 172343 | | - zCsr += sqlite3Fts3GetVarint(zCsr, &iChild); |
| 172970 | + zCsr += sqlite3Fts3GetVarintU(zCsr, &iChild); |
| 172971 | + zCsr += sqlite3Fts3GetVarintU(zCsr, &iChild); |
| 172344 | 172972 | if( zCsr>zEnd ){ |
| 172345 | 172973 | return FTS_CORRUPT_VTAB; |
| 172346 | 172974 | } |
| 172347 | 172975 | |
| 172348 | 172976 | while( zCsr<zEnd && (piFirst || piLast) ){ |
| | @@ -172391,24 +173019,24 @@ |
| 172391 | 173019 | ** If the interior node term is larger than the specified term, then |
| 172392 | 173020 | ** the tree headed by iChild may contain the specified term. |
| 172393 | 173021 | */ |
| 172394 | 173022 | cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer)); |
| 172395 | 173023 | if( piFirst && (cmp<0 || (cmp==0 && nBuffer>nTerm)) ){ |
| 172396 | | - *piFirst = iChild; |
| 173024 | + *piFirst = (i64)iChild; |
| 172397 | 173025 | piFirst = 0; |
| 172398 | 173026 | } |
| 172399 | 173027 | |
| 172400 | 173028 | if( piLast && cmp<0 ){ |
| 172401 | | - *piLast = iChild; |
| 173029 | + *piLast = (i64)iChild; |
| 172402 | 173030 | piLast = 0; |
| 172403 | 173031 | } |
| 172404 | 173032 | |
| 172405 | 173033 | iChild++; |
| 172406 | 173034 | }; |
| 172407 | 173035 | |
| 172408 | | - if( piFirst ) *piFirst = iChild; |
| 172409 | | - if( piLast ) *piLast = iChild; |
| 173036 | + if( piFirst ) *piFirst = (i64)iChild; |
| 173037 | + if( piLast ) *piLast = (i64)iChild; |
| 172410 | 173038 | |
| 172411 | 173039 | finish_scan: |
| 172412 | 173040 | sqlite3_free(zBuffer); |
| 172413 | 173041 | return rc; |
| 172414 | 173042 | } |
| | @@ -175552,20 +176180,19 @@ |
| 175552 | 176180 | |
| 175553 | 176181 | /* Determine which, if any, tokens in the expression should be deferred. */ |
| 175554 | 176182 | #ifndef SQLITE_DISABLE_FTS4_DEFERRED |
| 175555 | 176183 | if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){ |
| 175556 | 176184 | Fts3TokenAndCost *aTC; |
| 175557 | | - Fts3Expr **apOr; |
| 175558 | 176185 | aTC = (Fts3TokenAndCost *)sqlite3_malloc64( |
| 175559 | 176186 | sizeof(Fts3TokenAndCost) * nToken |
| 175560 | 176187 | + sizeof(Fts3Expr *) * nOr * 2 |
| 175561 | 176188 | ); |
| 175562 | | - apOr = (Fts3Expr **)&aTC[nToken]; |
| 175563 | 176189 | |
| 175564 | 176190 | if( !aTC ){ |
| 175565 | 176191 | rc = SQLITE_NOMEM; |
| 175566 | 176192 | }else{ |
| 176193 | + Fts3Expr **apOr = (Fts3Expr **)&aTC[nToken]; |
| 175567 | 176194 | int ii; |
| 175568 | 176195 | Fts3TokenAndCost *pTC = aTC; |
| 175569 | 176196 | Fts3Expr **ppOr = apOr; |
| 175570 | 176197 | |
| 175571 | 176198 | fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc); |
| | @@ -176937,10 +177564,11 @@ |
| 176937 | 177564 | /* In case this cursor is being reused, close and zero it. */ |
| 176938 | 177565 | testcase(pCsr->filter.zTerm); |
| 176939 | 177566 | sqlite3Fts3SegReaderFinish(&pCsr->csr); |
| 176940 | 177567 | sqlite3_free((void *)pCsr->filter.zTerm); |
| 176941 | 177568 | sqlite3_free(pCsr->aStat); |
| 177569 | + sqlite3_free(pCsr->zStop); |
| 176942 | 177570 | memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr); |
| 176943 | 177571 | |
| 176944 | 177572 | pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY; |
| 176945 | 177573 | if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN; |
| 176946 | 177574 | |
| | @@ -182458,11 +183086,11 @@ |
| 182458 | 183086 | rc = (pLhs->aNode==0) - (pRhs->aNode==0); |
| 182459 | 183087 | } |
| 182460 | 183088 | if( rc==0 ){ |
| 182461 | 183089 | rc = pRhs->iIdx - pLhs->iIdx; |
| 182462 | 183090 | } |
| 182463 | | - assert( rc!=0 ); |
| 183091 | + assert_fts3_nc( rc!=0 ); |
| 182464 | 183092 | return rc; |
| 182465 | 183093 | } |
| 182466 | 183094 | |
| 182467 | 183095 | /* |
| 182468 | 183096 | ** A different comparison function for SegReader structures. In this |
| | @@ -182654,12 +183282,12 @@ |
| 182654 | 183282 | int nPrev, /* Size of buffer zPrev in bytes */ |
| 182655 | 183283 | const char *zNext, /* Buffer containing next term */ |
| 182656 | 183284 | int nNext /* Size of buffer zNext in bytes */ |
| 182657 | 183285 | ){ |
| 182658 | 183286 | int n; |
| 182659 | | - UNUSED_PARAMETER(nNext); |
| 182660 | | - for(n=0; n<nPrev && zPrev[n]==zNext[n]; n++); |
| 183287 | + for(n=0; n<nPrev && n<nNext && zPrev[n]==zNext[n]; n++); |
| 183288 | + assert_fts3_nc( n<nNext ); |
| 182661 | 183289 | return n; |
| 182662 | 183290 | } |
| 182663 | 183291 | |
| 182664 | 183292 | /* |
| 182665 | 183293 | ** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger |
| | @@ -183654,11 +184282,11 @@ |
| 183654 | 184282 | iDelta = (i64)((u64)iDocid - (u64)iPrev); |
| 183655 | 184283 | } |
| 183656 | 184284 | |
| 183657 | 184285 | nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0); |
| 183658 | 184286 | |
| 183659 | | - rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist); |
| 184287 | + rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist+FTS3_NODE_PADDING); |
| 183660 | 184288 | if( rc ) return rc; |
| 183661 | 184289 | |
| 183662 | 184290 | if( isFirst ){ |
| 183663 | 184291 | char *a = &pCsr->aBuffer[nDoclist]; |
| 183664 | 184292 | int nWrite; |
| | @@ -186468,10 +187096,14 @@ |
| 186468 | 187096 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 186469 | 187097 | |
| 186470 | 187098 | /* #include <string.h> */ |
| 186471 | 187099 | /* #include <assert.h> */ |
| 186472 | 187100 | |
| 187101 | +#ifndef SQLITE_AMALGAMATION |
| 187102 | +typedef sqlite3_int64 i64; |
| 187103 | +#endif |
| 187104 | + |
| 186473 | 187105 | /* |
| 186474 | 187106 | ** Characters that may appear in the second argument to matchinfo(). |
| 186475 | 187107 | */ |
| 186476 | 187108 | #define FTS3_MATCHINFO_NPHRASE 'p' /* 1 value */ |
| 186477 | 187109 | #define FTS3_MATCHINFO_NCOL 'c' /* 1 value */ |
| | @@ -186518,13 +187150,13 @@ |
| 186518 | 187150 | }; |
| 186519 | 187151 | |
| 186520 | 187152 | struct SnippetPhrase { |
| 186521 | 187153 | int nToken; /* Number of tokens in phrase */ |
| 186522 | 187154 | char *pList; /* Pointer to start of phrase position list */ |
| 186523 | | - int iHead; /* Next value in position list */ |
| 187155 | + i64 iHead; /* Next value in position list */ |
| 186524 | 187156 | char *pHead; /* Position list data following iHead */ |
| 186525 | | - int iTail; /* Next value in trailing position list */ |
| 187157 | + i64 iTail; /* Next value in trailing position list */ |
| 186526 | 187158 | char *pTail; /* Position list data following iTail */ |
| 186527 | 187159 | }; |
| 186528 | 187160 | |
| 186529 | 187161 | struct SnippetFragment { |
| 186530 | 187162 | int iCol; /* Column snippet is extracted from */ |
| | @@ -186685,11 +187317,11 @@ |
| 186685 | 187317 | ** When this function is called, *pp points to the start of an element of |
| 186686 | 187318 | ** the list. *piPos contains the value of the previous entry in the list. |
| 186687 | 187319 | ** After it returns, *piPos contains the value of the next element of the |
| 186688 | 187320 | ** list and *pp is advanced to the following varint. |
| 186689 | 187321 | */ |
| 186690 | | -static void fts3GetDeltaPosition(char **pp, int *piPos){ |
| 187322 | +static void fts3GetDeltaPosition(char **pp, i64 *piPos){ |
| 186691 | 187323 | int iVal; |
| 186692 | 187324 | *pp += fts3GetVarint32(*pp, &iVal); |
| 186693 | 187325 | *piPos += (iVal-2); |
| 186694 | 187326 | } |
| 186695 | 187327 | |
| | @@ -186794,14 +187426,14 @@ |
| 186794 | 187426 | /* |
| 186795 | 187427 | ** Advance the position list iterator specified by the first two |
| 186796 | 187428 | ** arguments so that it points to the first element with a value greater |
| 186797 | 187429 | ** than or equal to parameter iNext. |
| 186798 | 187430 | */ |
| 186799 | | -static void fts3SnippetAdvance(char **ppIter, int *piIter, int iNext){ |
| 187431 | +static void fts3SnippetAdvance(char **ppIter, i64 *piIter, int iNext){ |
| 186800 | 187432 | char *pIter = *ppIter; |
| 186801 | 187433 | if( pIter ){ |
| 186802 | | - int iIter = *piIter; |
| 187434 | + i64 iIter = *piIter; |
| 186803 | 187435 | |
| 186804 | 187436 | while( iIter<iNext ){ |
| 186805 | 187437 | if( 0==(*pIter & 0xFE) ){ |
| 186806 | 187438 | iIter = -1; |
| 186807 | 187439 | pIter = 0; |
| | @@ -186880,11 +187512,11 @@ |
| 186880 | 187512 | |
| 186881 | 187513 | for(i=0; i<pIter->nPhrase; i++){ |
| 186882 | 187514 | SnippetPhrase *pPhrase = &pIter->aPhrase[i]; |
| 186883 | 187515 | if( pPhrase->pTail ){ |
| 186884 | 187516 | char *pCsr = pPhrase->pTail; |
| 186885 | | - int iCsr = pPhrase->iTail; |
| 187517 | + i64 iCsr = pPhrase->iTail; |
| 186886 | 187518 | |
| 186887 | 187519 | while( iCsr<(iStart+pIter->nSnippet) && iCsr>=iStart ){ |
| 186888 | 187520 | int j; |
| 186889 | 187521 | u64 mPhrase = (u64)1 << (i%64); |
| 186890 | 187522 | u64 mPos = (u64)1 << (iCsr - iStart); |
| | @@ -186926,11 +187558,11 @@ |
| 186926 | 187558 | |
| 186927 | 187559 | pPhrase->nToken = pExpr->pPhrase->nToken; |
| 186928 | 187560 | rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr); |
| 186929 | 187561 | assert( rc==SQLITE_OK || pCsr==0 ); |
| 186930 | 187562 | if( pCsr ){ |
| 186931 | | - int iFirst = 0; |
| 187563 | + i64 iFirst = 0; |
| 186932 | 187564 | pPhrase->pList = pCsr; |
| 186933 | 187565 | fts3GetDeltaPosition(&pCsr, &iFirst); |
| 186934 | 187566 | if( iFirst<0 ){ |
| 186935 | 187567 | rc = FTS_CORRUPT_VTAB; |
| 186936 | 187568 | }else{ |
| | @@ -187990,12 +188622,12 @@ |
| 187990 | 188622 | typedef struct TermOffset TermOffset; |
| 187991 | 188623 | typedef struct TermOffsetCtx TermOffsetCtx; |
| 187992 | 188624 | |
| 187993 | 188625 | struct TermOffset { |
| 187994 | 188626 | char *pList; /* Position-list */ |
| 187995 | | - int iPos; /* Position just read from pList */ |
| 187996 | | - int iOff; /* Offset of this term from read positions */ |
| 188627 | + i64 iPos; /* Position just read from pList */ |
| 188628 | + i64 iOff; /* Offset of this term from read positions */ |
| 187997 | 188629 | }; |
| 187998 | 188630 | |
| 187999 | 188631 | struct TermOffsetCtx { |
| 188000 | 188632 | Fts3Cursor *pCsr; |
| 188001 | 188633 | int iCol; /* Column of table to populate aTerm for */ |
| | @@ -188010,11 +188642,11 @@ |
| 188010 | 188642 | static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){ |
| 188011 | 188643 | TermOffsetCtx *p = (TermOffsetCtx *)ctx; |
| 188012 | 188644 | int nTerm; /* Number of tokens in phrase */ |
| 188013 | 188645 | int iTerm; /* For looping through nTerm phrase terms */ |
| 188014 | 188646 | char *pList; /* Pointer to position list for phrase */ |
| 188015 | | - int iPos = 0; /* First position in position-list */ |
| 188647 | + i64 iPos = 0; /* First position in position-list */ |
| 188016 | 188648 | int rc; |
| 188017 | 188649 | |
| 188018 | 188650 | UNUSED_PARAMETER(iPhrase); |
| 188019 | 188651 | rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList); |
| 188020 | 188652 | nTerm = pExpr->pPhrase->nToken; |
| | @@ -189287,11 +189919,11 @@ |
| 189287 | 189919 | ** any double-quotes or backslash characters contained within the |
| 189288 | 189920 | ** string. |
| 189289 | 189921 | */ |
| 189290 | 189922 | static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ |
| 189291 | 189923 | u32 i; |
| 189292 | | - if( (N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0 ) return; |
| 189924 | + if( zIn==0 || ((N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0) ) return; |
| 189293 | 189925 | p->zBuf[p->nUsed++] = '"'; |
| 189294 | 189926 | for(i=0; i<N; i++){ |
| 189295 | 189927 | unsigned char c = ((unsigned const char*)zIn)[i]; |
| 189296 | 189928 | if( c=='"' || c=='\\' ){ |
| 189297 | 189929 | json_simple_escape: |
| | @@ -190886,12 +191518,12 @@ |
| 190886 | 191518 | if( pStr->zBuf==0 ){ |
| 190887 | 191519 | jsonInit(pStr, ctx); |
| 190888 | 191520 | jsonAppendChar(pStr, '['); |
| 190889 | 191521 | }else if( pStr->nUsed>1 ){ |
| 190890 | 191522 | jsonAppendChar(pStr, ','); |
| 190891 | | - pStr->pCtx = ctx; |
| 190892 | 191523 | } |
| 191524 | + pStr->pCtx = ctx; |
| 190893 | 191525 | jsonAppendValue(pStr, argv[0]); |
| 190894 | 191526 | } |
| 190895 | 191527 | } |
| 190896 | 191528 | static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){ |
| 190897 | 191529 | JsonString *pStr; |
| | @@ -190947,26 +191579,27 @@ |
| 190947 | 191579 | /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will |
| 190948 | 191580 | ** always have been called to initalize it */ |
| 190949 | 191581 | if( NEVER(!pStr) ) return; |
| 190950 | 191582 | #endif |
| 190951 | 191583 | z = pStr->zBuf; |
| 190952 | | - for(i=1; (c = z[i])!=',' || inStr || nNest; i++){ |
| 190953 | | - if( i>=pStr->nUsed ){ |
| 190954 | | - pStr->nUsed = 1; |
| 190955 | | - return; |
| 190956 | | - } |
| 191584 | + for(i=1; i<pStr->nUsed && ((c = z[i])!=',' || inStr || nNest); i++){ |
| 190957 | 191585 | if( c=='"' ){ |
| 190958 | 191586 | inStr = !inStr; |
| 190959 | 191587 | }else if( c=='\\' ){ |
| 190960 | 191588 | i++; |
| 190961 | 191589 | }else if( !inStr ){ |
| 190962 | 191590 | if( c=='{' || c=='[' ) nNest++; |
| 190963 | 191591 | if( c=='}' || c==']' ) nNest--; |
| 190964 | 191592 | } |
| 190965 | 191593 | } |
| 190966 | | - pStr->nUsed -= i; |
| 190967 | | - memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1); |
| 191594 | + if( i<pStr->nUsed ){ |
| 191595 | + pStr->nUsed -= i; |
| 191596 | + memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1); |
| 191597 | + z[pStr->nUsed] = 0; |
| 191598 | + }else{ |
| 191599 | + pStr->nUsed = 1; |
| 191600 | + } |
| 190968 | 191601 | } |
| 190969 | 191602 | #else |
| 190970 | 191603 | # define jsonGroupInverse 0 |
| 190971 | 191604 | #endif |
| 190972 | 191605 | |
| | @@ -190990,12 +191623,12 @@ |
| 190990 | 191623 | if( pStr->zBuf==0 ){ |
| 190991 | 191624 | jsonInit(pStr, ctx); |
| 190992 | 191625 | jsonAppendChar(pStr, '{'); |
| 190993 | 191626 | }else if( pStr->nUsed>1 ){ |
| 190994 | 191627 | jsonAppendChar(pStr, ','); |
| 190995 | | - pStr->pCtx = ctx; |
| 190996 | 191628 | } |
| 191629 | + pStr->pCtx = ctx; |
| 190997 | 191630 | z = (const char*)sqlite3_value_text(argv[0]); |
| 190998 | 191631 | n = (u32)sqlite3_value_bytes(argv[0]); |
| 190999 | 191632 | jsonAppendString(pStr, z, n); |
| 191000 | 191633 | jsonAppendChar(pStr, ':'); |
| 191001 | 191634 | jsonAppendValue(pStr, argv[1]); |
| | @@ -195512,15 +196145,20 @@ |
| 195512 | 196145 | */ |
| 195513 | 196146 | static void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ |
| 195514 | 196147 | UNUSED_PARAMETER(nArg); |
| 195515 | 196148 | if( sqlite3_value_type(apArg[0])!=SQLITE_BLOB |
| 195516 | 196149 | || sqlite3_value_bytes(apArg[0])<2 |
| 196150 | + |
| 195517 | 196151 | ){ |
| 195518 | 196152 | sqlite3_result_error(ctx, "Invalid argument to rtreedepth()", -1); |
| 195519 | 196153 | }else{ |
| 195520 | 196154 | u8 *zBlob = (u8 *)sqlite3_value_blob(apArg[0]); |
| 195521 | | - sqlite3_result_int(ctx, readInt16(zBlob)); |
| 196155 | + if( zBlob ){ |
| 196156 | + sqlite3_result_int(ctx, readInt16(zBlob)); |
| 196157 | + }else{ |
| 196158 | + sqlite3_result_error_nomem(ctx); |
| 196159 | + } |
| 195522 | 196160 | } |
| 195523 | 196161 | } |
| 195524 | 196162 | |
| 195525 | 196163 | /* |
| 195526 | 196164 | ** Context object passed between the various routines that make up the |
| | @@ -201039,11 +201677,13 @@ |
| 201039 | 201677 | ); |
| 201040 | 201678 | if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSel) ){ |
| 201041 | 201679 | zSep = ""; |
| 201042 | 201680 | for(iCol=0; iCol<pIter->nCol; iCol++){ |
| 201043 | 201681 | const char *zQuoted = (const char*)sqlite3_column_text(pSel, iCol); |
| 201044 | | - if( zQuoted[0]=='N' ){ |
| 201682 | + if( zQuoted==0 ){ |
| 201683 | + p->rc = SQLITE_NOMEM; |
| 201684 | + }else if( zQuoted[0]=='N' ){ |
| 201045 | 201685 | bFailed = 1; |
| 201046 | 201686 | break; |
| 201047 | 201687 | } |
| 201048 | 201688 | zVector = rbuMPrintf(p, "%z%s%s", zVector, zSep, zQuoted); |
| 201049 | 201689 | zSep = ", "; |
| | @@ -204411,32 +205051,18 @@ |
| 204411 | 205051 | } |
| 204412 | 205052 | else if( flags & SQLITE_OPEN_WAL ){ |
| 204413 | 205053 | rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName, 0); |
| 204414 | 205054 | if( pDb ){ |
| 204415 | 205055 | if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){ |
| 204416 | | - /* This call is to open a *-wal file. Intead, open the *-oal. This |
| 204417 | | - ** code ensures that the string passed to xOpen() is terminated by a |
| 204418 | | - ** pair of '\0' bytes in case the VFS attempts to extract a URI |
| 204419 | | - ** parameter from it. */ |
| 204420 | | - const char *zBase = zName; |
| 204421 | | - size_t nCopy; |
| 204422 | | - char *zCopy; |
| 205056 | + /* This call is to open a *-wal file. Intead, open the *-oal. */ |
| 205057 | + size_t nOpen; |
| 204423 | 205058 | if( rbuIsVacuum(pDb->pRbu) ){ |
| 204424 | | - zBase = sqlite3_db_filename(pDb->pRbu->dbRbu, "main"); |
| 204425 | | - zBase = sqlite3_filename_wal(zBase); |
| 204426 | | - } |
| 204427 | | - nCopy = strlen(zBase); |
| 204428 | | - zCopy = sqlite3_malloc64(nCopy+2); |
| 204429 | | - if( zCopy ){ |
| 204430 | | - memcpy(zCopy, zBase, nCopy); |
| 204431 | | - zCopy[nCopy-3] = 'o'; |
| 204432 | | - zCopy[nCopy] = '\0'; |
| 204433 | | - zCopy[nCopy+1] = '\0'; |
| 204434 | | - zOpen = (const char*)(pFd->zDel = zCopy); |
| 204435 | | - }else{ |
| 204436 | | - rc = SQLITE_NOMEM; |
| 204437 | | - } |
| 205059 | + zOpen = sqlite3_db_filename(pDb->pRbu->dbRbu, "main"); |
| 205060 | + zOpen = sqlite3_filename_wal(zOpen); |
| 205061 | + } |
| 205062 | + nOpen = strlen(zOpen); |
| 205063 | + ((char*)zOpen)[nOpen-3] = 'o'; |
| 204438 | 205064 | pFd->pRbu = pDb->pRbu; |
| 204439 | 205065 | } |
| 204440 | 205066 | pDb->pWalFd = pFd; |
| 204441 | 205067 | } |
| 204442 | 205068 | } |
| | @@ -206045,17 +206671,19 @@ |
| 206045 | 206671 | ** Session handle structure. |
| 206046 | 206672 | */ |
| 206047 | 206673 | struct sqlite3_session { |
| 206048 | 206674 | sqlite3 *db; /* Database handle session is attached to */ |
| 206049 | 206675 | char *zDb; /* Name of database session is attached to */ |
| 206676 | + int bEnableSize; /* True if changeset_size() enabled */ |
| 206050 | 206677 | int bEnable; /* True if currently recording */ |
| 206051 | 206678 | int bIndirect; /* True if all changes are indirect */ |
| 206052 | 206679 | int bAutoAttach; /* True to auto-attach tables */ |
| 206053 | 206680 | int rc; /* Non-zero if an error has occurred */ |
| 206054 | 206681 | void *pFilterCtx; /* First argument to pass to xTableFilter */ |
| 206055 | 206682 | int (*xTableFilter)(void *pCtx, const char *zTab); |
| 206056 | 206683 | i64 nMalloc; /* Number of bytes of data allocated */ |
| 206684 | + i64 nMaxChangesetSize; |
| 206057 | 206685 | sqlite3_value *pZeroBlob; /* Value containing X'' */ |
| 206058 | 206686 | sqlite3_session *pNext; /* Next session object on same db. */ |
| 206059 | 206687 | SessionTable *pTable; /* List of attached tables */ |
| 206060 | 206688 | SessionHook hook; /* APIs to grab new and old data with */ |
| 206061 | 206689 | }; |
| | @@ -206294,12 +206922,13 @@ |
| 206294 | 206922 | /* |
| 206295 | 206923 | ** For each row modified during a session, there exists a single instance of |
| 206296 | 206924 | ** this structure stored in a SessionTable.aChange[] hash table. |
| 206297 | 206925 | */ |
| 206298 | 206926 | struct SessionChange { |
| 206299 | | - int op; /* One of UPDATE, DELETE, INSERT */ |
| 206300 | | - int bIndirect; /* True if this change is "indirect" */ |
| 206927 | + u8 op; /* One of UPDATE, DELETE, INSERT */ |
| 206928 | + u8 bIndirect; /* True if this change is "indirect" */ |
| 206929 | + int nMaxSize; /* Max size of eventual changeset record */ |
| 206301 | 206930 | int nRecord; /* Number of bytes in buffer aRecord[] */ |
| 206302 | 206931 | u8 *aRecord; /* Buffer containing old.* record */ |
| 206303 | 206932 | SessionChange *pNext; /* For hash-table collisions */ |
| 206304 | 206933 | }; |
| 206305 | 206934 | |
| | @@ -207124,10 +207753,16 @@ |
| 207124 | 207753 | } |
| 207125 | 207754 | } |
| 207126 | 207755 | if( 0==sqlite3_stricmp("sqlite_stat1", pTab->zName) ){ |
| 207127 | 207756 | pTab->bStat1 = 1; |
| 207128 | 207757 | } |
| 207758 | + |
| 207759 | + if( pSession->bEnableSize ){ |
| 207760 | + pSession->nMaxChangesetSize += ( |
| 207761 | + 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1 |
| 207762 | + ); |
| 207763 | + } |
| 207129 | 207764 | } |
| 207130 | 207765 | } |
| 207131 | 207766 | return (pSession->rc || pTab->abPK==0); |
| 207132 | 207767 | } |
| 207133 | 207768 | |
| | @@ -207169,10 +207804,107 @@ |
| 207169 | 207804 | static int sessionStat1Depth(void *pCtx){ |
| 207170 | 207805 | SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx; |
| 207171 | 207806 | return p->hook.xDepth(p->hook.pCtx); |
| 207172 | 207807 | } |
| 207173 | 207808 | |
| 207809 | +static int sessionUpdateMaxSize( |
| 207810 | + int op, |
| 207811 | + sqlite3_session *pSession, /* Session object pTab is attached to */ |
| 207812 | + SessionTable *pTab, /* Table that change applies to */ |
| 207813 | + SessionChange *pC /* Update pC->nMaxSize */ |
| 207814 | +){ |
| 207815 | + i64 nNew = 2; |
| 207816 | + if( pC->op==SQLITE_INSERT ){ |
| 207817 | + if( op!=SQLITE_DELETE ){ |
| 207818 | + int ii; |
| 207819 | + for(ii=0; ii<pTab->nCol; ii++){ |
| 207820 | + sqlite3_value *p = 0; |
| 207821 | + pSession->hook.xNew(pSession->hook.pCtx, ii, &p); |
| 207822 | + sessionSerializeValue(0, p, &nNew); |
| 207823 | + } |
| 207824 | + } |
| 207825 | + }else if( op==SQLITE_DELETE ){ |
| 207826 | + nNew += pC->nRecord; |
| 207827 | + if( sqlite3_preupdate_blobwrite(pSession->db)>=0 ){ |
| 207828 | + nNew += pC->nRecord; |
| 207829 | + } |
| 207830 | + }else{ |
| 207831 | + int ii; |
| 207832 | + u8 *pCsr = pC->aRecord; |
| 207833 | + for(ii=0; ii<pTab->nCol; ii++){ |
| 207834 | + int bChanged = 1; |
| 207835 | + int nOld = 0; |
| 207836 | + int eType; |
| 207837 | + sqlite3_value *p = 0; |
| 207838 | + pSession->hook.xNew(pSession->hook.pCtx, ii, &p); |
| 207839 | + if( p==0 ){ |
| 207840 | + return SQLITE_NOMEM; |
| 207841 | + } |
| 207842 | + |
| 207843 | + eType = *pCsr++; |
| 207844 | + switch( eType ){ |
| 207845 | + case SQLITE_NULL: |
| 207846 | + bChanged = sqlite3_value_type(p)!=SQLITE_NULL; |
| 207847 | + break; |
| 207848 | + |
| 207849 | + case SQLITE_FLOAT: |
| 207850 | + case SQLITE_INTEGER: { |
| 207851 | + if( eType==sqlite3_value_type(p) ){ |
| 207852 | + sqlite3_int64 iVal = sessionGetI64(pCsr); |
| 207853 | + if( eType==SQLITE_INTEGER ){ |
| 207854 | + bChanged = (iVal!=sqlite3_value_int64(p)); |
| 207855 | + }else{ |
| 207856 | + double dVal; |
| 207857 | + memcpy(&dVal, &iVal, 8); |
| 207858 | + bChanged = (dVal!=sqlite3_value_double(p)); |
| 207859 | + } |
| 207860 | + } |
| 207861 | + nOld = 8; |
| 207862 | + pCsr += 8; |
| 207863 | + break; |
| 207864 | + } |
| 207865 | + |
| 207866 | + default: { |
| 207867 | + int nByte; |
| 207868 | + nOld = sessionVarintGet(pCsr, &nByte); |
| 207869 | + pCsr += nOld; |
| 207870 | + nOld += nByte; |
| 207871 | + assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); |
| 207872 | + if( eType==sqlite3_value_type(p) |
| 207873 | + && nByte==sqlite3_value_bytes(p) |
| 207874 | + && (nByte==0 || 0==memcmp(pCsr, sqlite3_value_blob(p), nByte)) |
| 207875 | + ){ |
| 207876 | + bChanged = 0; |
| 207877 | + } |
| 207878 | + pCsr += nByte; |
| 207879 | + break; |
| 207880 | + } |
| 207881 | + } |
| 207882 | + |
| 207883 | + if( bChanged && pTab->abPK[ii] ){ |
| 207884 | + nNew = pC->nRecord + 2; |
| 207885 | + break; |
| 207886 | + } |
| 207887 | + |
| 207888 | + if( bChanged ){ |
| 207889 | + nNew += 1 + nOld; |
| 207890 | + sessionSerializeValue(0, p, &nNew); |
| 207891 | + }else if( pTab->abPK[ii] ){ |
| 207892 | + nNew += 2 + nOld; |
| 207893 | + }else{ |
| 207894 | + nNew += 2; |
| 207895 | + } |
| 207896 | + } |
| 207897 | + } |
| 207898 | + |
| 207899 | + if( nNew>pC->nMaxSize ){ |
| 207900 | + int nIncr = nNew - pC->nMaxSize; |
| 207901 | + pC->nMaxSize = nNew; |
| 207902 | + pSession->nMaxChangesetSize += nIncr; |
| 207903 | + } |
| 207904 | + return SQLITE_OK; |
| 207905 | +} |
| 207174 | 207906 | |
| 207175 | 207907 | /* |
| 207176 | 207908 | ** This function is only called from with a pre-update-hook reporting a |
| 207177 | 207909 | ** change on table pTab (attached to session pSession). The type of change |
| 207178 | 207910 | ** (UPDATE, INSERT, DELETE) is specified by the first argument. |
| | @@ -207242,11 +207974,10 @@ |
| 207242 | 207974 | |
| 207243 | 207975 | if( pC==0 ){ |
| 207244 | 207976 | /* Create a new change object containing all the old values (if |
| 207245 | 207977 | ** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK |
| 207246 | 207978 | ** values (if this is an INSERT). */ |
| 207247 | | - SessionChange *pChange; /* New change object */ |
| 207248 | 207979 | sqlite3_int64 nByte; /* Number of bytes to allocate */ |
| 207249 | 207980 | int i; /* Used to iterate through columns */ |
| 207250 | 207981 | |
| 207251 | 207982 | assert( rc==SQLITE_OK ); |
| 207252 | 207983 | pTab->nEntry++; |
| | @@ -207268,17 +207999,17 @@ |
| 207268 | 207999 | rc = sessionSerializeValue(0, p, &nByte); |
| 207269 | 208000 | if( rc!=SQLITE_OK ) goto error_out; |
| 207270 | 208001 | } |
| 207271 | 208002 | |
| 207272 | 208003 | /* Allocate the change object */ |
| 207273 | | - pChange = (SessionChange *)sessionMalloc64(pSession, nByte); |
| 207274 | | - if( !pChange ){ |
| 208004 | + pC = (SessionChange *)sessionMalloc64(pSession, nByte); |
| 208005 | + if( !pC ){ |
| 207275 | 208006 | rc = SQLITE_NOMEM; |
| 207276 | 208007 | goto error_out; |
| 207277 | 208008 | }else{ |
| 207278 | | - memset(pChange, 0, sizeof(SessionChange)); |
| 207279 | | - pChange->aRecord = (u8 *)&pChange[1]; |
| 208009 | + memset(pC, 0, sizeof(SessionChange)); |
| 208010 | + pC->aRecord = (u8 *)&pC[1]; |
| 207280 | 208011 | } |
| 207281 | 208012 | |
| 207282 | 208013 | /* Populate the change object. None of the preupdate_old(), |
| 207283 | 208014 | ** preupdate_new() or SerializeValue() calls below may fail as all |
| 207284 | 208015 | ** required values and encodings have already been cached in memory. |
| | @@ -207289,21 +208020,21 @@ |
| 207289 | 208020 | if( op!=SQLITE_INSERT ){ |
| 207290 | 208021 | pSession->hook.xOld(pSession->hook.pCtx, i, &p); |
| 207291 | 208022 | }else if( pTab->abPK[i] ){ |
| 207292 | 208023 | pSession->hook.xNew(pSession->hook.pCtx, i, &p); |
| 207293 | 208024 | } |
| 207294 | | - sessionSerializeValue(&pChange->aRecord[nByte], p, &nByte); |
| 208025 | + sessionSerializeValue(&pC->aRecord[nByte], p, &nByte); |
| 207295 | 208026 | } |
| 207296 | 208027 | |
| 207297 | 208028 | /* Add the change to the hash-table */ |
| 207298 | 208029 | if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){ |
| 207299 | | - pChange->bIndirect = 1; |
| 208030 | + pC->bIndirect = 1; |
| 207300 | 208031 | } |
| 207301 | | - pChange->nRecord = nByte; |
| 207302 | | - pChange->op = op; |
| 207303 | | - pChange->pNext = pTab->apChange[iHash]; |
| 207304 | | - pTab->apChange[iHash] = pChange; |
| 208032 | + pC->nRecord = nByte; |
| 208033 | + pC->op = op; |
| 208034 | + pC->pNext = pTab->apChange[iHash]; |
| 208035 | + pTab->apChange[iHash] = pC; |
| 207305 | 208036 | |
| 207306 | 208037 | }else if( pC->bIndirect ){ |
| 207307 | 208038 | /* If the existing change is considered "indirect", but this current |
| 207308 | 208039 | ** change is "direct", mark the change object as direct. */ |
| 207309 | 208040 | if( pSession->hook.xDepth(pSession->hook.pCtx)==0 |
| | @@ -207310,11 +208041,17 @@ |
| 207310 | 208041 | && pSession->bIndirect==0 |
| 207311 | 208042 | ){ |
| 207312 | 208043 | pC->bIndirect = 0; |
| 207313 | 208044 | } |
| 207314 | 208045 | } |
| 208046 | + |
| 208047 | + assert( rc==SQLITE_OK ); |
| 208048 | + if( pSession->bEnableSize ){ |
| 208049 | + rc = sessionUpdateMaxSize(op, pSession, pTab, pC); |
| 208050 | + } |
| 207315 | 208051 | } |
| 208052 | + |
| 207316 | 208053 | |
| 207317 | 208054 | /* If an error has occurred, mark the session object as failed. */ |
| 207318 | 208055 | error_out: |
| 207319 | 208056 | if( pTab->bStat1 ){ |
| 207320 | 208057 | pSession->hook = stat1.hook; |
| | @@ -207866,17 +208603,33 @@ |
| 207866 | 208603 | ** If not, use sqlite3_realloc() to grow the buffer so that there is. |
| 207867 | 208604 | ** |
| 207868 | 208605 | ** If successful, return zero. Otherwise, if an OOM condition is encountered, |
| 207869 | 208606 | ** set *pRc to SQLITE_NOMEM and return non-zero. |
| 207870 | 208607 | */ |
| 207871 | | -static int sessionBufferGrow(SessionBuffer *p, size_t nByte, int *pRc){ |
| 207872 | | - if( *pRc==SQLITE_OK && (size_t)(p->nAlloc-p->nBuf)<nByte ){ |
| 208608 | +static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){ |
| 208609 | +#define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1) |
| 208610 | + i64 nReq = p->nBuf + nByte; |
| 208611 | + if( *pRc==SQLITE_OK && nReq>p->nAlloc ){ |
| 207873 | 208612 | u8 *aNew; |
| 207874 | 208613 | i64 nNew = p->nAlloc ? p->nAlloc : 128; |
| 208614 | + |
| 207875 | 208615 | do { |
| 207876 | 208616 | nNew = nNew*2; |
| 207877 | | - }while( (size_t)(nNew-p->nBuf)<nByte ); |
| 208617 | + }while( nNew<nReq ); |
| 208618 | + |
| 208619 | + /* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation |
| 208620 | + ** of sqlite3_realloc64(). Allocations greater than this size in bytes |
| 208621 | + ** always fail. It is used here to ensure that this routine can always |
| 208622 | + ** allocate up to this limit - instead of up to the largest power of |
| 208623 | + ** two smaller than the limit. */ |
| 208624 | + if( nNew>SESSION_MAX_BUFFER_SZ ){ |
| 208625 | + nNew = SESSION_MAX_BUFFER_SZ; |
| 208626 | + if( nNew<nReq ){ |
| 208627 | + *pRc = SQLITE_NOMEM; |
| 208628 | + return 1; |
| 208629 | + } |
| 208630 | + } |
| 207878 | 208631 | |
| 207879 | 208632 | aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew); |
| 207880 | 208633 | if( 0==aNew ){ |
| 207881 | 208634 | *pRc = SQLITE_NOMEM; |
| 207882 | 208635 | }else{ |
| | @@ -208523,11 +209276,15 @@ |
| 208523 | 209276 | SQLITE_API int sqlite3session_changeset( |
| 208524 | 209277 | sqlite3_session *pSession, /* Session object */ |
| 208525 | 209278 | int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */ |
| 208526 | 209279 | void **ppChangeset /* OUT: Buffer containing changeset */ |
| 208527 | 209280 | ){ |
| 208528 | | - return sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset, ppChangeset); |
| 209281 | + int rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset); |
| 209282 | + assert( rc || pnChangeset==0 |
| 209283 | + || pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize |
| 209284 | + ); |
| 209285 | + return rc; |
| 208529 | 209286 | } |
| 208530 | 209287 | |
| 208531 | 209288 | /* |
| 208532 | 209289 | ** Streaming version of sqlite3session_changeset(). |
| 208533 | 209290 | */ |
| | @@ -208614,10 +209371,43 @@ |
| 208614 | 209371 | ** Return the amount of heap memory in use. |
| 208615 | 209372 | */ |
| 208616 | 209373 | SQLITE_API sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession){ |
| 208617 | 209374 | return pSession->nMalloc; |
| 208618 | 209375 | } |
| 209376 | + |
| 209377 | +/* |
| 209378 | +** Configure the session object passed as the first argument. |
| 209379 | +*/ |
| 209380 | +SQLITE_API int sqlite3session_object_config(sqlite3_session *pSession, int op, void *pArg){ |
| 209381 | + int rc = SQLITE_OK; |
| 209382 | + switch( op ){ |
| 209383 | + case SQLITE_SESSION_OBJCONFIG_SIZE: { |
| 209384 | + int iArg = *(int*)pArg; |
| 209385 | + if( iArg>=0 ){ |
| 209386 | + if( pSession->pTable ){ |
| 209387 | + rc = SQLITE_MISUSE; |
| 209388 | + }else{ |
| 209389 | + pSession->bEnableSize = (iArg!=0); |
| 209390 | + } |
| 209391 | + } |
| 209392 | + *(int*)pArg = pSession->bEnableSize; |
| 209393 | + break; |
| 209394 | + } |
| 209395 | + |
| 209396 | + default: |
| 209397 | + rc = SQLITE_MISUSE; |
| 209398 | + } |
| 209399 | + |
| 209400 | + return rc; |
| 209401 | +} |
| 209402 | + |
| 209403 | +/* |
| 209404 | +** Return the maximum size of sqlite3session_changeset() output. |
| 209405 | +*/ |
| 209406 | +SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession){ |
| 209407 | + return pSession->nMaxChangesetSize; |
| 209408 | +} |
| 208619 | 209409 | |
| 208620 | 209410 | /* |
| 208621 | 209411 | ** Do the work for either sqlite3changeset_start() or start_strm(). |
| 208622 | 209412 | */ |
| 208623 | 209413 | static int sessionChangesetStart( |
| | @@ -215435,10 +216225,11 @@ |
| 215435 | 216225 | return 1; |
| 215436 | 216226 | }else{ |
| 215437 | 216227 | i64 iOff = *piOff; |
| 215438 | 216228 | int iVal; |
| 215439 | 216229 | fts5FastGetVarint32(a, i, iVal); |
| 216230 | + assert( iVal>=0 ); |
| 215440 | 216231 | if( iVal<=1 ){ |
| 215441 | 216232 | if( iVal==0 ){ |
| 215442 | 216233 | *pi = i; |
| 215443 | 216234 | return 0; |
| 215444 | 216235 | } |
| | @@ -215448,13 +216239,16 @@ |
| 215448 | 216239 | if( iVal<2 ){ |
| 215449 | 216240 | /* This is a corrupt record. So stop parsing it here. */ |
| 215450 | 216241 | *piOff = -1; |
| 215451 | 216242 | return 1; |
| 215452 | 216243 | } |
| 216244 | + *piOff = iOff + ((iVal-2) & 0x7FFFFFFF); |
| 216245 | + }else{ |
| 216246 | + *piOff = (iOff & (i64)0x7FFFFFFF<<32)+((iOff + (iVal-2)) & 0x7FFFFFFF); |
| 215453 | 216247 | } |
| 215454 | | - *piOff = iOff + ((iVal-2) & 0x7FFFFFFF); |
| 215455 | 216248 | *pi = i; |
| 216249 | + assert( *piOff>=iOff ); |
| 215456 | 216250 | return 0; |
| 215457 | 216251 | } |
| 215458 | 216252 | } |
| 215459 | 216253 | |
| 215460 | 216254 | |
| | @@ -215489,18 +216283,20 @@ |
| 215489 | 216283 | static void sqlite3Fts5PoslistSafeAppend( |
| 215490 | 216284 | Fts5Buffer *pBuf, |
| 215491 | 216285 | i64 *piPrev, |
| 215492 | 216286 | i64 iPos |
| 215493 | 216287 | ){ |
| 215494 | | - static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32; |
| 215495 | | - if( (iPos & colmask) != (*piPrev & colmask) ){ |
| 215496 | | - pBuf->p[pBuf->n++] = 1; |
| 215497 | | - pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32)); |
| 215498 | | - *piPrev = (iPos & colmask); |
| 215499 | | - } |
| 215500 | | - pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2); |
| 215501 | | - *piPrev = iPos; |
| 216288 | + if( iPos>=*piPrev ){ |
| 216289 | + static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32; |
| 216290 | + if( (iPos & colmask) != (*piPrev & colmask) ){ |
| 216291 | + pBuf->p[pBuf->n++] = 1; |
| 216292 | + pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32)); |
| 216293 | + *piPrev = (iPos & colmask); |
| 216294 | + } |
| 216295 | + pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2); |
| 216296 | + *piPrev = iPos; |
| 216297 | + } |
| 215502 | 216298 | } |
| 215503 | 216299 | |
| 215504 | 216300 | static int sqlite3Fts5PoslistWriterAppend( |
| 215505 | 216301 | Fts5Buffer *pBuf, |
| 215506 | 216302 | Fts5PoslistWriter *pWriter, |
| | @@ -216198,11 +216994,11 @@ |
| 216198 | 216994 | pRet->db = db; |
| 216199 | 216995 | pRet->iCookie = -1; |
| 216200 | 216996 | |
| 216201 | 216997 | nByte = nArg * (sizeof(char*) + sizeof(u8)); |
| 216202 | 216998 | pRet->azCol = (char**)sqlite3Fts5MallocZero(&rc, nByte); |
| 216203 | | - pRet->abUnindexed = (u8*)&pRet->azCol[nArg]; |
| 216999 | + pRet->abUnindexed = pRet->azCol ? (u8*)&pRet->azCol[nArg] : 0; |
| 216204 | 217000 | pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1); |
| 216205 | 217001 | pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1); |
| 216206 | 217002 | pRet->bColumnsize = 1; |
| 216207 | 217003 | pRet->eDetail = FTS5_DETAIL_FULL; |
| 216208 | 217004 | #ifdef SQLITE_DEBUG |
| | @@ -219034,10 +219830,11 @@ |
| 219034 | 219830 | } |
| 219035 | 219831 | |
| 219036 | 219832 | return pRet; |
| 219037 | 219833 | } |
| 219038 | 219834 | |
| 219835 | +#ifdef SQLITE_TEST |
| 219039 | 219836 | static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){ |
| 219040 | 219837 | sqlite3_int64 nByte = 0; |
| 219041 | 219838 | Fts5ExprTerm *p; |
| 219042 | 219839 | char *zQuoted; |
| 219043 | 219840 | |
| | @@ -219400,16 +220197,18 @@ |
| 219400 | 220197 | iCode = sqlite3_value_int(apVal[0]); |
| 219401 | 220198 | if( nArg==2 ) bRemoveDiacritics = sqlite3_value_int(apVal[1]); |
| 219402 | 220199 | sqlite3_result_int(pCtx, sqlite3Fts5UnicodeFold(iCode, bRemoveDiacritics)); |
| 219403 | 220200 | } |
| 219404 | 220201 | } |
| 220202 | +#endif /* ifdef SQLITE_TEST */ |
| 219405 | 220203 | |
| 219406 | 220204 | /* |
| 219407 | 220205 | ** This is called during initialization to register the fts5_expr() scalar |
| 219408 | 220206 | ** UDF with the SQLite handle passed as the only argument. |
| 219409 | 220207 | */ |
| 219410 | 220208 | static int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){ |
| 220209 | +#ifdef SQLITE_TEST |
| 219411 | 220210 | struct Fts5ExprFunc { |
| 219412 | 220211 | const char *z; |
| 219413 | 220212 | void (*x)(sqlite3_context*,int,sqlite3_value**); |
| 219414 | 220213 | } aFunc[] = { |
| 219415 | 220214 | { "fts5_expr", fts5ExprFunctionHr }, |
| | @@ -219423,10 +220222,14 @@ |
| 219423 | 220222 | |
| 219424 | 220223 | for(i=0; rc==SQLITE_OK && i<ArraySize(aFunc); i++){ |
| 219425 | 220224 | struct Fts5ExprFunc *p = &aFunc[i]; |
| 219426 | 220225 | rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0); |
| 219427 | 220226 | } |
| 220227 | +#else |
| 220228 | + int rc = SQLITE_OK; |
| 220229 | + UNUSED_PARAM2(pGlobal,db); |
| 220230 | +#endif |
| 219428 | 220231 | |
| 219429 | 220232 | /* Avoid warnings indicating that sqlite3Fts5ParserTrace() and |
| 219430 | 220233 | ** sqlite3Fts5ParserFallback() are unused */ |
| 219431 | 220234 | #ifndef NDEBUG |
| 219432 | 220235 | (void)sqlite3Fts5ParserTrace; |
| | @@ -220669,11 +221472,11 @@ |
| 220669 | 221472 | Fts5StructureSegment *pSeg; /* Segment to iterate through */ |
| 220670 | 221473 | int flags; /* Mask of configuration flags */ |
| 220671 | 221474 | int iLeafPgno; /* Current leaf page number */ |
| 220672 | 221475 | Fts5Data *pLeaf; /* Current leaf data */ |
| 220673 | 221476 | Fts5Data *pNextLeaf; /* Leaf page (iLeafPgno+1) */ |
| 220674 | | - int iLeafOffset; /* Byte offset within current leaf */ |
| 221477 | + i64 iLeafOffset; /* Byte offset within current leaf */ |
| 220675 | 221478 | |
| 220676 | 221479 | /* Next method */ |
| 220677 | 221480 | void (*xNext)(Fts5Index*, Fts5SegIter*, int*); |
| 220678 | 221481 | |
| 220679 | 221482 | /* The page and offset from which the current term was read. The offset |
| | @@ -221849,11 +222652,11 @@ |
| 221849 | 222652 | } |
| 221850 | 222653 | } |
| 221851 | 222654 | |
| 221852 | 222655 | static void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){ |
| 221853 | 222656 | u8 *a = pIter->pLeaf->p; /* Buffer to read data from */ |
| 221854 | | - int iOff = pIter->iLeafOffset; |
| 222657 | + i64 iOff = pIter->iLeafOffset; |
| 221855 | 222658 | |
| 221856 | 222659 | ASSERT_SZLEAF_OK(pIter->pLeaf); |
| 221857 | 222660 | if( iOff>=pIter->pLeaf->szLeaf ){ |
| 221858 | 222661 | fts5SegIterNextPage(p, pIter); |
| 221859 | 222662 | if( pIter->pLeaf==0 ){ |
| | @@ -221882,11 +222685,11 @@ |
| 221882 | 222685 | ** the first position list. The position list belonging to document |
| 221883 | 222686 | ** (Fts5SegIter.iRowid). |
| 221884 | 222687 | */ |
| 221885 | 222688 | static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){ |
| 221886 | 222689 | u8 *a = pIter->pLeaf->p; /* Buffer to read data from */ |
| 221887 | | - int iOff = pIter->iLeafOffset; /* Offset to read at */ |
| 222690 | + i64 iOff = pIter->iLeafOffset; /* Offset to read at */ |
| 221888 | 222691 | int nNew; /* Bytes of new data */ |
| 221889 | 222692 | |
| 221890 | 222693 | iOff += fts5GetVarint32(&a[iOff], nNew); |
| 221891 | 222694 | if( iOff+nNew>pIter->pLeaf->szLeaf || nKeep>pIter->term.n || nNew==0 ){ |
| 221892 | 222695 | p->rc = FTS5_CORRUPT; |
| | @@ -222310,11 +223113,10 @@ |
| 222310 | 223113 | }else{ |
| 222311 | 223114 | /* The following could be done by calling fts5SegIterLoadNPos(). But |
| 222312 | 223115 | ** this block is particularly performance critical, so equivalent |
| 222313 | 223116 | ** code is inlined. */ |
| 222314 | 223117 | int nSz; |
| 222315 | | - assert( p->rc==SQLITE_OK ); |
| 222316 | 223118 | assert_nc( pIter->iLeafOffset<=pIter->pLeaf->nn ); |
| 222317 | 223119 | fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz); |
| 222318 | 223120 | pIter->bDel = (nSz & 0x0001); |
| 222319 | 223121 | pIter->nPos = nSz>>1; |
| 222320 | 223122 | assert_nc( pIter->nPos>=0 ); |
| | @@ -223422,11 +224224,11 @@ |
| 223422 | 224224 | pIter->base.nData = p-aCopy; |
| 223423 | 224225 | return; |
| 223424 | 224226 | } |
| 223425 | 224227 | fts5BufferSafeAppendBlob(&pIter->poslist, aCopy, p-aCopy); |
| 223426 | 224228 | } |
| 223427 | | - if( p==pEnd ){ |
| 224229 | + if( p>=pEnd ){ |
| 223428 | 224230 | pIter->base.pData = pIter->poslist.p; |
| 223429 | 224231 | pIter->base.nData = pIter->poslist.n; |
| 223430 | 224232 | return; |
| 223431 | 224233 | } |
| 223432 | 224234 | aCopy = p++; |
| | @@ -224779,18 +225581,18 @@ |
| 224779 | 225581 | if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){ |
| 224780 | 225582 | /* The entire doclist will fit on the current leaf. */ |
| 224781 | 225583 | fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist); |
| 224782 | 225584 | }else{ |
| 224783 | 225585 | i64 iRowid = 0; |
| 224784 | | - i64 iDelta = 0; |
| 225586 | + u64 iDelta = 0; |
| 224785 | 225587 | int iOff = 0; |
| 224786 | 225588 | |
| 224787 | 225589 | /* The entire doclist will not fit on this leaf. The following |
| 224788 | 225590 | ** loop iterates through the poslists that make up the current |
| 224789 | 225591 | ** doclist. */ |
| 224790 | 225592 | while( p->rc==SQLITE_OK && iOff<nDoclist ){ |
| 224791 | | - iOff += fts5GetVarint(&pDoclist[iOff], (u64*)&iDelta); |
| 225593 | + iOff += fts5GetVarint(&pDoclist[iOff], &iDelta); |
| 224792 | 225594 | iRowid += iDelta; |
| 224793 | 225595 | |
| 224794 | 225596 | if( writer.bFirstRowidInPage ){ |
| 224795 | 225597 | fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */ |
| 224796 | 225598 | pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid); |
| | @@ -225218,11 +226020,11 @@ |
| 225218 | 226020 | Fts5Buffer *p1, /* First list to merge */ |
| 225219 | 226021 | int nBuf, /* Number of buffers in array aBuf[] */ |
| 225220 | 226022 | Fts5Buffer *aBuf /* Other lists to merge in */ |
| 225221 | 226023 | ){ |
| 225222 | 226024 | #define fts5PrefixMergerNextPosition(p) \ |
| 225223 | | - sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos); |
| 226025 | + sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos) |
| 225224 | 226026 | #define FTS5_MERGE_NLIST 16 |
| 225225 | 226027 | PrefixMerger aMerger[FTS5_MERGE_NLIST]; |
| 225226 | 226028 | PrefixMerger *pHead = 0; |
| 225227 | 226029 | int i; |
| 225228 | 226030 | int nOut = 0; |
| | @@ -225317,11 +226119,12 @@ |
| 225317 | 226119 | sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, pHead->iPos); |
| 225318 | 226120 | } |
| 225319 | 226121 | nTail = pHead->iter.nPoslist - pHead->iOff; |
| 225320 | 226122 | |
| 225321 | 226123 | /* WRITEPOSLISTSIZE */ |
| 225322 | | - assert( tmp.n+nTail<=nTmp ); |
| 226124 | + assert_nc( tmp.n+nTail<=nTmp ); |
| 226125 | + assert( tmp.n+nTail<=nTmp+nMerge*10 ); |
| 225323 | 226126 | if( tmp.n+nTail>nTmp-FTS5_DATA_ZERO_PADDING ){ |
| 225324 | 226127 | if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT; |
| 225325 | 226128 | break; |
| 225326 | 226129 | } |
| 225327 | 226130 | fts5BufferSafeAppendVarint(&out, (tmp.n+nTail) * 2); |
| | @@ -226958,10 +227761,11 @@ |
| 226958 | 227761 | ); |
| 226959 | 227762 | } |
| 226960 | 227763 | return rc; |
| 226961 | 227764 | #else |
| 226962 | 227765 | return SQLITE_OK; |
| 227766 | + UNUSED_PARAM(db); |
| 226963 | 227767 | #endif |
| 226964 | 227768 | } |
| 226965 | 227769 | |
| 226966 | 227770 | |
| 226967 | 227771 | static int sqlite3Fts5IndexReset(Fts5Index *p){ |
| | @@ -228921,17 +229725,19 @@ |
| 228921 | 229725 | } |
| 228922 | 229726 | if( iBest<0 ) break; |
| 228923 | 229727 | |
| 228924 | 229728 | nInst++; |
| 228925 | 229729 | if( nInst>=pCsr->nInstAlloc ){ |
| 228926 | | - pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32; |
| 229730 | + int nNewSize = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32; |
| 228927 | 229731 | aInst = (int*)sqlite3_realloc64( |
| 228928 | | - pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3 |
| 229732 | + pCsr->aInst, nNewSize*sizeof(int)*3 |
| 228929 | 229733 | ); |
| 228930 | 229734 | if( aInst ){ |
| 228931 | 229735 | pCsr->aInst = aInst; |
| 229736 | + pCsr->nInstAlloc = nNewSize; |
| 228932 | 229737 | }else{ |
| 229738 | + nInst--; |
| 228933 | 229739 | rc = SQLITE_NOMEM; |
| 228934 | 229740 | break; |
| 228935 | 229741 | } |
| 228936 | 229742 | } |
| 228937 | 229743 | |
| | @@ -229762,11 +230568,11 @@ |
| 229762 | 230568 | int nArg, /* Number of args */ |
| 229763 | 230569 | sqlite3_value **apUnused /* Function arguments */ |
| 229764 | 230570 | ){ |
| 229765 | 230571 | assert( nArg==0 ); |
| 229766 | 230572 | UNUSED_PARAM2(nArg, apUnused); |
| 229767 | | - sqlite3_result_text(pCtx, "fts5: 2021-04-07 13:20:34 c22e47c77a35ebcd1fdfc0caea9119dd5e24e76d5fdd0f2ffbb58205a7242297", -1, SQLITE_TRANSIENT); |
| 230573 | + sqlite3_result_text(pCtx, "fts5: 2021-06-14 20:41:20 e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9ef70", -1, SQLITE_TRANSIENT); |
| 229768 | 230574 | } |
| 229769 | 230575 | |
| 229770 | 230576 | /* |
| 229771 | 230577 | ** Return true if zName is the extension on one of the shadow tables used |
| 229772 | 230578 | ** by this module. |
| | @@ -234688,12 +235494,12 @@ |
| 234688 | 235494 | } |
| 234689 | 235495 | #endif /* SQLITE_CORE */ |
| 234690 | 235496 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 234691 | 235497 | |
| 234692 | 235498 | /************** End of stmt.c ************************************************/ |
| 234693 | | -#if __LINE__!=234693 |
| 235499 | +#if __LINE__!=235499 |
| 234694 | 235500 | #undef SQLITE_SOURCE_ID |
| 234695 | | -#define SQLITE_SOURCE_ID "2021-04-07 18:17:53 a2ddb89b206c13876d34c5f9e3db41cda72d6eb3fea31ffa8cc6daa1e158alt2" |
| 235501 | +#define SQLITE_SOURCE_ID "2021-06-14 20:41:20 e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9alt2" |
| 234696 | 235502 | #endif |
| 234697 | 235503 | /* Return the source-id for this library */ |
| 234698 | 235504 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 234699 | 235505 | /************************** End of sqlite3.c ******************************/ |
| 234700 | 235506 | |